ku4web-components 6.4.34 → 6.4.38

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 (278) hide show
  1. package/dist/cjs/{index-fabdc7d0.js → index-38fe0039.js} +1 -1
  2. package/dist/cjs/ku4-carousel-controls.cjs.entry.js +3 -3
  3. package/dist/cjs/ku4-carousel-slide.cjs.entry.js +2 -2
  4. package/dist/cjs/ku4-carousel.cjs.entry.js +15 -9
  5. package/dist/cjs/ku4-col.cjs.entry.js +2 -2
  6. package/dist/cjs/ku4-drawer.cjs.entry.js +2 -2
  7. package/dist/cjs/ku4-feature.cjs.entry.js +3 -3
  8. package/dist/cjs/ku4-focus-trap.cjs.entry.js +27 -27
  9. package/dist/cjs/ku4-form.cjs.entry.js +4 -4
  10. package/dist/cjs/ku4-grid.cjs.entry.js +2 -2
  11. package/dist/cjs/ku4-label.cjs.entry.js +3 -3
  12. package/dist/cjs/ku4-mask.cjs.entry.js +3 -3
  13. package/dist/cjs/ku4-modal.cjs.entry.js +4 -4
  14. package/dist/cjs/ku4-panel.cjs.entry.js +2 -2
  15. package/dist/cjs/ku4-preview.cjs.entry.js +15 -44
  16. package/dist/cjs/ku4-tab-list.cjs.entry.js +5 -5
  17. package/dist/cjs/ku4-tab-panel.cjs.entry.js +4 -4
  18. package/dist/cjs/ku4-tab.cjs.entry.js +4 -4
  19. package/dist/cjs/ku4-table.cjs.entry.js +2 -2
  20. package/dist/cjs/ku4-tooltip.cjs.entry.js +3 -3
  21. package/dist/cjs/ku4-validation.cjs.entry.js +4 -4
  22. package/dist/cjs/ku4web-components.cjs.js +8 -99
  23. package/dist/cjs/loader.cjs.js +3 -19
  24. package/dist/cjs/{shadow-css-4bfd7bfa.js → shadow-css-d8ee70b1.js} +1 -1
  25. package/dist/esm/{index-d14f31b2.js → index-52020db7.js} +1 -1
  26. package/dist/esm/ku4-carousel-controls.entry.js +3 -3
  27. package/dist/esm/ku4-carousel-slide.entry.js +2 -2
  28. package/dist/esm/ku4-carousel.entry.js +15 -9
  29. package/dist/esm/ku4-col.entry.js +2 -2
  30. package/dist/esm/ku4-drawer.entry.js +2 -2
  31. package/dist/esm/ku4-feature.entry.js +3 -3
  32. package/dist/esm/ku4-focus-trap.entry.js +4 -4
  33. package/dist/esm/ku4-form.entry.js +4 -4
  34. package/dist/esm/ku4-grid.entry.js +2 -2
  35. package/dist/esm/ku4-label.entry.js +3 -3
  36. package/dist/esm/ku4-mask.entry.js +3 -3
  37. package/dist/esm/ku4-modal.entry.js +4 -4
  38. package/dist/esm/ku4-panel.entry.js +2 -2
  39. package/dist/esm/ku4-preview.entry.js +6 -35
  40. package/dist/esm/ku4-tab-list.entry.js +5 -5
  41. package/dist/esm/ku4-tab-panel.entry.js +4 -4
  42. package/dist/esm/ku4-tab.entry.js +4 -4
  43. package/dist/esm/ku4-table.entry.js +2 -2
  44. package/dist/esm/ku4-tooltip.entry.js +3 -3
  45. package/dist/esm/ku4-validation.entry.js +4 -4
  46. package/dist/esm/ku4web-components.js +8 -99
  47. package/dist/esm/loader.js +3 -19
  48. package/dist/{ku4web-components/shadow-css-bc14d9fd.js → esm/shadow-css-c1fdfa9f.js} +1 -1
  49. package/dist/esm-es5/{index-d14f31b2.js → index-52020db7.js} +1 -1
  50. package/dist/esm-es5/ku4-carousel-controls.entry.js +1 -1
  51. package/dist/esm-es5/ku4-carousel-slide.entry.js +1 -1
  52. package/dist/esm-es5/ku4-carousel.entry.js +1 -1
  53. package/dist/esm-es5/ku4-col.entry.js +1 -1
  54. package/dist/esm-es5/ku4-drawer.entry.js +1 -1
  55. package/dist/esm-es5/ku4-feature.entry.js +1 -1
  56. package/dist/esm-es5/ku4-focus-trap.entry.js +1 -1
  57. package/dist/esm-es5/ku4-form.entry.js +1 -1
  58. package/dist/esm-es5/ku4-grid.entry.js +1 -1
  59. package/dist/esm-es5/ku4-label.entry.js +1 -1
  60. package/dist/esm-es5/ku4-mask.entry.js +1 -1
  61. package/dist/esm-es5/ku4-modal.entry.js +1 -1
  62. package/dist/esm-es5/ku4-panel.entry.js +1 -1
  63. package/dist/esm-es5/ku4-preview.entry.js +1 -1
  64. package/dist/esm-es5/ku4-tab-list.entry.js +1 -1
  65. package/dist/esm-es5/ku4-tab-panel.entry.js +1 -1
  66. package/dist/esm-es5/ku4-tab.entry.js +1 -1
  67. package/dist/esm-es5/ku4-table.entry.js +1 -1
  68. package/dist/esm-es5/ku4-tooltip.entry.js +1 -1
  69. package/dist/esm-es5/ku4-validation.entry.js +1 -1
  70. package/dist/esm-es5/ku4web-components.js +1 -1
  71. package/dist/esm-es5/loader.js +1 -1
  72. package/dist/esm-es5/{shadow-css-bc14d9fd.js → shadow-css-c1fdfa9f.js} +0 -0
  73. package/dist/index.js +1 -1
  74. package/dist/ku4web-components/index.esm.js +0 -1
  75. package/dist/ku4web-components/ku4web-components.css +1 -283
  76. package/dist/ku4web-components/ku4web-components.esm.js +1 -125
  77. package/dist/ku4web-components/ku4web-components.js +1 -1
  78. package/dist/ku4web-components/{p-967f8f4b.system.entry.js → p-19147286.system.entry.js} +1 -1
  79. package/dist/ku4web-components/p-1fb8966a.entry.js +1 -0
  80. package/dist/ku4web-components/{p-c72b3ced.system.entry.js → p-2bbea5f3.system.entry.js} +1 -1
  81. package/dist/ku4web-components/p-4986dc9a.entry.js +1 -0
  82. package/dist/ku4web-components/{p-176273d5.system.js → p-4de687d8.system.js} +1 -1
  83. package/dist/ku4web-components/p-5848719e.system.js +1 -0
  84. package/dist/ku4web-components/p-5ad4d525.entry.js +1 -0
  85. package/dist/ku4web-components/{p-e0558b2b.system.entry.js → p-60512677.system.entry.js} +1 -1
  86. package/dist/ku4web-components/{p-cb0f32a7.js → p-670d415c.js} +1 -1
  87. package/dist/ku4web-components/{p-c3c31235.system.entry.js → p-67b90b07.system.entry.js} +1 -1
  88. package/dist/ku4web-components/{p-435478fa.system.entry.js → p-6a6ebdd6.system.entry.js} +1 -1
  89. package/dist/ku4web-components/p-6f56d780.entry.js +1 -0
  90. package/dist/ku4web-components/p-7587e933.entry.js +1 -0
  91. package/dist/ku4web-components/{p-3ad57422.system.entry.js → p-769237d3.system.entry.js} +1 -1
  92. package/dist/ku4web-components/p-7a5e62fd.entry.js +1 -0
  93. package/dist/ku4web-components/{p-46d73124.system.entry.js → p-8645d86f.system.entry.js} +1 -1
  94. package/dist/ku4web-components/{p-cb6b67f2.entry.js → p-867d74d6.entry.js} +1 -1
  95. package/dist/ku4web-components/p-911a6cc5.entry.js +1 -0
  96. package/dist/ku4web-components/{p-7bbd50d6.system.entry.js → p-93417cb8.system.entry.js} +1 -1
  97. package/dist/ku4web-components/p-98548901.system.entry.js +1 -0
  98. package/dist/ku4web-components/{p-44f9a1a9.system.entry.js → p-9b9fb5a2.system.entry.js} +1 -1
  99. package/dist/ku4web-components/p-9e2c3988.entry.js +1 -0
  100. package/dist/ku4web-components/{p-64f6379d.system.entry.js → p-ac86618a.system.entry.js} +1 -1
  101. package/dist/ku4web-components/p-af5d8c77.system.entry.js +1 -0
  102. package/dist/ku4web-components/p-b2db2c0b.entry.js +1 -0
  103. package/dist/ku4web-components/p-b9cf48d6.entry.js +1 -0
  104. package/dist/ku4web-components/p-bfd8c04e.entry.js +1 -0
  105. package/dist/ku4web-components/p-c11d7118.entry.js +1 -0
  106. package/dist/ku4web-components/p-c194ee9c.entry.js +1 -0
  107. package/dist/ku4web-components/{p-c2285d3c.system.entry.js → p-c48ff8d2.system.entry.js} +1 -1
  108. package/dist/ku4web-components/p-cdaa80f7.entry.js +1 -0
  109. package/dist/ku4web-components/{ku4-col.entry.js → p-d0579e6f.entry.js} +1 -75
  110. package/dist/ku4web-components/p-d248862c.entry.js +1 -0
  111. package/dist/ku4web-components/{p-9f159c4b.system.entry.js → p-d312c8ae.system.entry.js} +1 -1
  112. package/dist/ku4web-components/{p-110de527.system.entry.js → p-d3dad5b5.system.entry.js} +1 -1
  113. package/dist/ku4web-components/{p-d3379ca9.system.entry.js → p-dda45242.system.entry.js} +1 -1
  114. package/dist/ku4web-components/p-e63f2453.entry.js +1 -0
  115. package/dist/ku4web-components/{p-4e89d6bc.system.entry.js → p-e89bc35d.system.entry.js} +1 -1
  116. package/dist/ku4web-components/{p-308941a0.system.entry.js → p-e9c1a470.system.entry.js} +1 -1
  117. package/dist/ku4web-components/p-ebc49910.entry.js +1 -0
  118. package/dist/ku4web-components/{p-a025c941.system.js → p-f4d979bb.system.js} +0 -0
  119. package/dist/ku4web-components/{p-3fb7c6ff.js → p-f566887e.js} +0 -0
  120. package/dist/ku4web-components/{p-7a3a3b7f.system.entry.js → p-faef0a79.system.entry.js} +1 -1
  121. package/dist/ku4web-components/p-fbba3322.entry.js +1 -0
  122. package/dist/ku4web-components/{p-d8836783.system.entry.js → p-ff4c04f5.system.entry.js} +1 -1
  123. package/dist/types/components/ku4-carousel/ku4-carousel.d.ts +4 -0
  124. package/dist/types/components/ku4-validation/ku4-validation.d.ts +5 -0
  125. package/dist/types/components.d.ts +16 -0
  126. package/loader/index.d.ts +0 -1
  127. package/package.json +1 -1
  128. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  129. package/dist/cjs/css-shim-a6998297.js +0 -6
  130. package/dist/cjs/dom-66f79778.js +0 -75
  131. package/dist/cjs/index-51b7a610.js +0 -14
  132. package/dist/cjs/index-c52d450b.js +0 -10
  133. package/dist/cjs/index-ff13b651.js +0 -3046
  134. package/dist/cjs/uid-3dd31175.js +0 -11
  135. package/dist/collection/capabilities/a11y/aria.js +0 -26
  136. package/dist/collection/capabilities/angular/index.js +0 -24
  137. package/dist/collection/capabilities/decorators/deprecated.js +0 -20
  138. package/dist/collection/capabilities/decorators/index.js +0 -3
  139. package/dist/collection/capabilities/decorators/memoize.js +0 -7
  140. package/dist/collection/capabilities/dom/isFocusable.js +0 -7
  141. package/dist/collection/capabilities/dom/queryFocusable.js +0 -2
  142. package/dist/collection/capabilities/identity/uid.js +0 -6
  143. package/dist/collection/capabilities/mask/index.js +0 -5
  144. package/dist/collection/capabilities/mask/patterns/date.js +0 -40
  145. package/dist/collection/capabilities/mask/patterns/index.js +0 -7
  146. package/dist/collection/capabilities/react/index.js +0 -25
  147. package/dist/collection/capabilities/testing/html.js +0 -14
  148. package/dist/collection/capabilities/testing/styles.js +0 -14
  149. package/dist/collection/capabilities/vue/index.js +0 -28
  150. package/dist/collection/capabilities/vue3/index.js +0 -26
  151. package/dist/collection/collection-manifest.json +0 -31
  152. package/dist/collection/components/ku4-carousel/ku4-carousel.css +0 -215
  153. package/dist/collection/components/ku4-carousel/ku4-carousel.js +0 -335
  154. package/dist/collection/components/ku4-carousel-controls/ku4-carousel-controls.css +0 -32
  155. package/dist/collection/components/ku4-carousel-controls/ku4-carousel-controls.js +0 -93
  156. package/dist/collection/components/ku4-carousel-slide/ku4-carousel-slide.css +0 -3
  157. package/dist/collection/components/ku4-carousel-slide/ku4-carousel-slide.js +0 -140
  158. package/dist/collection/components/ku4-col/ku4-col.css +0 -601
  159. package/dist/collection/components/ku4-col/ku4-col.js +0 -288
  160. package/dist/collection/components/ku4-drawer/ku4-drawer.css +0 -56
  161. package/dist/collection/components/ku4-drawer/ku4-drawer.js +0 -163
  162. package/dist/collection/components/ku4-feature/ku4-feature.js +0 -70
  163. package/dist/collection/components/ku4-focus-trap/ku4-focus-trap.css +0 -3
  164. package/dist/collection/components/ku4-focus-trap/ku4-focus-trap.js +0 -441
  165. package/dist/collection/components/ku4-form/ku4-form.js +0 -194
  166. package/dist/collection/components/ku4-grid/ku4-grid.css +0 -751
  167. package/dist/collection/components/ku4-grid/ku4-grid.js +0 -408
  168. package/dist/collection/components/ku4-label/ku4-label.css +0 -36
  169. package/dist/collection/components/ku4-label/ku4-label.js +0 -115
  170. package/dist/collection/components/ku4-mask/ku4-mask.css +0 -3
  171. package/dist/collection/components/ku4-mask/ku4-mask.js +0 -427
  172. package/dist/collection/components/ku4-modal/ku4-modal.css +0 -85
  173. package/dist/collection/components/ku4-modal/ku4-modal.js +0 -186
  174. package/dist/collection/components/ku4-panel/ku4-panel.css +0 -14
  175. package/dist/collection/components/ku4-panel/ku4-panel.js +0 -119
  176. package/dist/collection/components/ku4-preview/ku4-preview.css +0 -23
  177. package/dist/collection/components/ku4-preview/ku4-preview.js +0 -249
  178. package/dist/collection/components/ku4-tab/ku4-tab.css +0 -82
  179. package/dist/collection/components/ku4-tab/ku4-tab.js +0 -191
  180. package/dist/collection/components/ku4-tab-list/ku4-tab-list.css +0 -6
  181. package/dist/collection/components/ku4-tab-list/ku4-tab-list.js +0 -118
  182. package/dist/collection/components/ku4-tab-panel/ku4-tab-panel.css +0 -26
  183. package/dist/collection/components/ku4-tab-panel/ku4-tab-panel.js +0 -166
  184. package/dist/collection/components/ku4-table/ku4-table.css +0 -116
  185. package/dist/collection/components/ku4-table/ku4-table.js +0 -120
  186. package/dist/collection/components/ku4-tooltip/ku4-tooltip.css +0 -56
  187. package/dist/collection/components/ku4-tooltip/ku4-tooltip.js +0 -274
  188. package/dist/collection/components/ku4-validation/ku4-validation.css +0 -7
  189. package/dist/collection/components/ku4-validation/ku4-validation.js +0 -309
  190. package/dist/collection/components/ku4-validation/validate.js +0 -14
  191. package/dist/collection/index.js +0 -1
  192. package/dist/collection/security.js +0 -27
  193. package/dist/esm/app-globals-0f993ce5.js +0 -3
  194. package/dist/esm/css-shim-a64b8820.js +0 -4
  195. package/dist/esm/dom-d08ba8aa.js +0 -73
  196. package/dist/esm/index-4693d116.js +0 -3
  197. package/dist/esm/index-88e7b9d4.js +0 -3010
  198. package/dist/esm/index-89916128.js +0 -3
  199. package/dist/esm/shadow-css-bc14d9fd.js +0 -389
  200. package/dist/esm/uid-5355229f.js +0 -9
  201. package/dist/ku4web-components/app-globals-0f993ce5.js +0 -3
  202. package/dist/ku4web-components/app-globals-497eb362.system.js +0 -1
  203. package/dist/ku4web-components/css-shim-00dc76e5.system.js +0 -1
  204. package/dist/ku4web-components/css-shim-a64b8820.js +0 -4
  205. package/dist/ku4web-components/dom-59f9ee66.system.js +0 -21
  206. package/dist/ku4web-components/dom-d08ba8aa.js +0 -73
  207. package/dist/ku4web-components/index-3127d7f7.system.js +0 -1
  208. package/dist/ku4web-components/index-4693d116.js +0 -3
  209. package/dist/ku4web-components/index-7624f416.system.js +0 -1
  210. package/dist/ku4web-components/index-88e7b9d4.js +0 -3010
  211. package/dist/ku4web-components/index-89916128.js +0 -3
  212. package/dist/ku4web-components/index-aea7f048.system.js +0 -1
  213. package/dist/ku4web-components/index.system.js +0 -1
  214. package/dist/ku4web-components/ku4-carousel-controls.entry.js +0 -70
  215. package/dist/ku4web-components/ku4-carousel-controls.system.entry.js +0 -1
  216. package/dist/ku4web-components/ku4-carousel-slide.entry.js +0 -47
  217. package/dist/ku4web-components/ku4-carousel-slide.system.entry.js +0 -1
  218. package/dist/ku4web-components/ku4-carousel.entry.js +0 -159
  219. package/dist/ku4web-components/ku4-carousel.system.entry.js +0 -1
  220. package/dist/ku4web-components/ku4-col.system.entry.js +0 -1
  221. package/dist/ku4web-components/ku4-drawer.entry.js +0 -35
  222. package/dist/ku4web-components/ku4-drawer.system.entry.js +0 -1
  223. package/dist/ku4web-components/ku4-feature.entry.js +0 -29
  224. package/dist/ku4web-components/ku4-feature.system.entry.js +0 -1
  225. package/dist/ku4web-components/ku4-focus-trap.entry.js +0 -323
  226. package/dist/ku4web-components/ku4-focus-trap.system.entry.js +0 -1
  227. package/dist/ku4web-components/ku4-form.entry.js +0 -97
  228. package/dist/ku4web-components/ku4-form.system.entry.js +0 -1
  229. package/dist/ku4web-components/ku4-grid.entry.js +0 -108
  230. package/dist/ku4web-components/ku4-grid.system.entry.js +0 -1
  231. package/dist/ku4web-components/ku4-label.entry.js +0 -70
  232. package/dist/ku4web-components/ku4-label.system.entry.js +0 -1
  233. package/dist/ku4web-components/ku4-mask.entry.js +0 -311
  234. package/dist/ku4web-components/ku4-mask.system.entry.js +0 -1
  235. package/dist/ku4web-components/ku4-modal.entry.js +0 -71
  236. package/dist/ku4web-components/ku4-modal.system.entry.js +0 -1
  237. package/dist/ku4web-components/ku4-panel.entry.js +0 -49
  238. package/dist/ku4web-components/ku4-panel.system.entry.js +0 -1
  239. package/dist/ku4web-components/ku4-preview.entry.js +0 -128
  240. package/dist/ku4web-components/ku4-preview.system.entry.js +0 -1
  241. package/dist/ku4web-components/ku4-tab-list.entry.js +0 -76
  242. package/dist/ku4web-components/ku4-tab-list.system.entry.js +0 -1
  243. package/dist/ku4web-components/ku4-tab-panel.entry.js +0 -72
  244. package/dist/ku4web-components/ku4-tab-panel.system.entry.js +0 -1
  245. package/dist/ku4web-components/ku4-tab.entry.js +0 -63
  246. package/dist/ku4web-components/ku4-tab.system.entry.js +0 -1
  247. package/dist/ku4web-components/ku4-table.entry.js +0 -79
  248. package/dist/ku4web-components/ku4-table.system.entry.js +0 -1
  249. package/dist/ku4web-components/ku4-tooltip.entry.js +0 -120
  250. package/dist/ku4web-components/ku4-tooltip.system.entry.js +0 -1
  251. package/dist/ku4web-components/ku4-validation.entry.js +0 -158
  252. package/dist/ku4web-components/ku4-validation.system.entry.js +0 -1
  253. package/dist/ku4web-components/ku4web-components.system.js +0 -1
  254. package/dist/ku4web-components/p-026e04d8.entry.js +0 -1
  255. package/dist/ku4web-components/p-0a7ce92f.entry.js +0 -1
  256. package/dist/ku4web-components/p-10a643bb.system.js +0 -1
  257. package/dist/ku4web-components/p-288c6e27.entry.js +0 -1
  258. package/dist/ku4web-components/p-417f04e9.entry.js +0 -1
  259. package/dist/ku4web-components/p-4c117404.entry.js +0 -1
  260. package/dist/ku4web-components/p-5299172c.entry.js +0 -1
  261. package/dist/ku4web-components/p-6b080fd7.entry.js +0 -1
  262. package/dist/ku4web-components/p-731d15d8.entry.js +0 -1
  263. package/dist/ku4web-components/p-7760e8b4.entry.js +0 -1
  264. package/dist/ku4web-components/p-7764c6f2.entry.js +0 -1
  265. package/dist/ku4web-components/p-7ffb5116.entry.js +0 -1
  266. package/dist/ku4web-components/p-8063491d.entry.js +0 -1
  267. package/dist/ku4web-components/p-8b7e72eb.entry.js +0 -1
  268. package/dist/ku4web-components/p-92ddb4be.entry.js +0 -1
  269. package/dist/ku4web-components/p-c7dc83c3.entry.js +0 -1
  270. package/dist/ku4web-components/p-cb142835.system.entry.js +0 -1
  271. package/dist/ku4web-components/p-cb746d07.entry.js +0 -1
  272. package/dist/ku4web-components/p-da065955.entry.js +0 -1
  273. package/dist/ku4web-components/p-e7698568.system.entry.js +0 -1
  274. package/dist/ku4web-components/p-e8367ca4.entry.js +0 -1
  275. package/dist/ku4web-components/p-fb68de75.entry.js +0 -1
  276. package/dist/ku4web-components/shadow-css-c015bba2.system.js +0 -13
  277. package/dist/ku4web-components/uid-5355229f.js +0 -9
  278. package/dist/ku4web-components/uid-93975202.system.js +0 -1
@@ -1,3046 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopNamespace(e) {
4
- if (e && e.__esModule) return e;
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () {
13
- return e[k];
14
- }
15
- });
16
- }
17
- });
18
- }
19
- n['default'] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- const NAMESPACE = 'ku4web-components';
24
- const BUILD = /* ku4web-components */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: true, constructableCSS: true, cssAnnotations: true, cssVarShim: false, devTools: false, disconnectedCallback: true, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: true, hydratedClass: false, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: true, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: true, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: false, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: true };
25
- const Env = /* ku4web-components */ {};
26
-
27
- let scopeId;
28
- let contentRef;
29
- let hostTagName;
30
- let customError;
31
- let i = 0;
32
- let useNativeShadowDom = false;
33
- let checkSlotFallbackVisibility = false;
34
- let checkSlotRelocate = false;
35
- let isSvgMode = false;
36
- let renderingRef = null;
37
- let queueCongestion = 0;
38
- let queuePending = false;
39
- const win = typeof window !== 'undefined' ? window : {};
40
- const CSS = BUILD.cssVarShim ? win.CSS : null;
41
- const doc = win.document || { head: {} };
42
- const H = (win.HTMLElement || class {
43
- });
44
- const plt = {
45
- $flags$: 0,
46
- $resourcesUrl$: '',
47
- jmp: (h) => h(),
48
- raf: (h) => requestAnimationFrame(h),
49
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
50
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
51
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
52
- };
53
- const setPlatformHelpers = (helpers) => {
54
- Object.assign(plt, helpers);
55
- };
56
- const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
57
- ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
58
- : true;
59
- const supportsListenerOptions = /*@__PURE__*/ (() => {
60
- let supportsListenerOptions = false;
61
- try {
62
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
63
- get() {
64
- supportsListenerOptions = true;
65
- },
66
- }));
67
- }
68
- catch (e) { }
69
- return supportsListenerOptions;
70
- })();
71
- const promiseResolve = (v) => Promise.resolve(v);
72
- const supportsConstructibleStylesheets = BUILD.constructableCSS
73
- ? /*@__PURE__*/ (() => {
74
- try {
75
- new CSSStyleSheet();
76
- return typeof new CSSStyleSheet().replace === 'function';
77
- }
78
- catch (e) { }
79
- return false;
80
- })()
81
- : false;
82
- const Context = {};
83
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
84
- if (BUILD.hostListener && listeners) {
85
- // this is called immediately within the element's constructor
86
- // initialize our event listeners on the host element
87
- // we do this now so that we can listen to events that may
88
- // have fired even before the instance is ready
89
- if (BUILD.hostListenerTargetParent) {
90
- // this component may have event listeners that should be attached to the parent
91
- if (attachParentListeners) {
92
- // this is being ran from within the connectedCallback
93
- // which is important so that we know the host element actually has a parent element
94
- // filter out the listeners to only have the ones that ARE being attached to the parent
95
- listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
96
- }
97
- else {
98
- // this is being ran from within the component constructor
99
- // everything BUT the parent element listeners should be attached at this time
100
- // filter out the listeners that are NOT being attached to the parent
101
- listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
102
- }
103
- }
104
- listeners.map(([flags, name, method]) => {
105
- const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
106
- const handler = hostListenerProxy(hostRef, method);
107
- const opts = hostListenerOpts(flags);
108
- plt.ael(target, name, handler, opts);
109
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
110
- });
111
- }
112
- };
113
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
114
- try {
115
- if (BUILD.lazyLoad) {
116
- if (hostRef.$flags$ & 256 /* isListenReady */) {
117
- // instance is ready, let's call it's member method for this event
118
- hostRef.$lazyInstance$[methodName](ev);
119
- }
120
- else {
121
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
122
- }
123
- }
124
- else {
125
- hostRef.$hostElement$[methodName](ev);
126
- }
127
- }
128
- catch (e) {
129
- consoleError(e);
130
- }
131
- };
132
- const getHostListenerTarget = (elm, flags) => {
133
- if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
134
- return doc;
135
- if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
136
- return win;
137
- if (BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */)
138
- return doc.body;
139
- if (BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */)
140
- return elm.parentElement;
141
- return elm;
142
- };
143
- // prettier-ignore
144
- const hostListenerOpts = (flags) => supportsListenerOptions
145
- ? ({
146
- passive: (flags & 1 /* Passive */) !== 0,
147
- capture: (flags & 2 /* Capture */) !== 0,
148
- })
149
- : (flags & 2 /* Capture */) !== 0;
150
- const CONTENT_REF_ID = 'r';
151
- const ORG_LOCATION_ID = 'o';
152
- const SLOT_NODE_ID = 's';
153
- const TEXT_NODE_ID = 't';
154
- const HYDRATE_ID = 's-id';
155
- const HYDRATED_STYLE_ID = 'sty-id';
156
- const HYDRATE_CHILD_ID = 'c-id';
157
- const HYDRATED_CSS = '{visibility:hidden}[hydrated]{visibility:inherit}';
158
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
159
- const createTime = (fnName, tagName = '') => {
160
- if (BUILD.profile && performance.mark) {
161
- const key = `st:${fnName}:${tagName}:${i++}`;
162
- // Start
163
- performance.mark(key);
164
- // End
165
- return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
166
- }
167
- else {
168
- return () => {
169
- return;
170
- };
171
- }
172
- };
173
- const uniqueTime = (key, measureText) => {
174
- if (BUILD.profile && performance.mark) {
175
- if (performance.getEntriesByName(key).length === 0) {
176
- performance.mark(key);
177
- }
178
- return () => {
179
- if (performance.getEntriesByName(measureText).length === 0) {
180
- performance.measure(measureText, key);
181
- }
182
- };
183
- }
184
- else {
185
- return () => {
186
- return;
187
- };
188
- }
189
- };
190
- const inspect = (ref) => {
191
- const hostRef = getHostRef(ref);
192
- if (!hostRef) {
193
- return undefined;
194
- }
195
- const flags = hostRef.$flags$;
196
- const hostElement = hostRef.$hostElement$;
197
- return {
198
- renderCount: hostRef.$renderCount$,
199
- flags: {
200
- hasRendered: !!(flags & 2 /* hasRendered */),
201
- hasConnected: !!(flags & 1 /* hasConnected */),
202
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
203
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
204
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
205
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
206
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
207
- isWatchReady: !!(flags & 128 /* isWatchReady */),
208
- isListenReady: !!(flags & 256 /* isListenReady */),
209
- needsRerender: !!(flags & 512 /* needsRerender */),
210
- },
211
- instanceValues: hostRef.$instanceValues$,
212
- ancestorComponent: hostRef.$ancestorComponent$,
213
- hostElement,
214
- lazyInstance: hostRef.$lazyInstance$,
215
- vnode: hostRef.$vnode$,
216
- modeName: hostRef.$modeName$,
217
- onReadyPromise: hostRef.$onReadyPromise$,
218
- onReadyResolve: hostRef.$onReadyResolve$,
219
- onInstancePromise: hostRef.$onInstancePromise$,
220
- onInstanceResolve: hostRef.$onInstanceResolve$,
221
- onRenderResolve: hostRef.$onRenderResolve$,
222
- queuedListeners: hostRef.$queuedListeners$,
223
- rmListeners: hostRef.$rmListeners$,
224
- ['s-id']: hostElement['s-id'],
225
- ['s-cr']: hostElement['s-cr'],
226
- ['s-lr']: hostElement['s-lr'],
227
- ['s-p']: hostElement['s-p'],
228
- ['s-rc']: hostElement['s-rc'],
229
- ['s-sc']: hostElement['s-sc'],
230
- };
231
- };
232
- const installDevTools = () => {
233
- if (BUILD.devTools) {
234
- const stencil = (win.stencil = win.stencil || {});
235
- const originalInspect = stencil.inspect;
236
- stencil.inspect = (ref) => {
237
- let result = inspect(ref);
238
- if (!result && typeof originalInspect === 'function') {
239
- result = originalInspect(ref);
240
- }
241
- return result;
242
- };
243
- }
244
- };
245
- const rootAppliedStyles = new WeakMap();
246
- const registerStyle = (scopeId, cssText, allowCS) => {
247
- let style = styles.get(scopeId);
248
- if (supportsConstructibleStylesheets && allowCS) {
249
- style = (style || new CSSStyleSheet());
250
- style.replace(cssText);
251
- }
252
- else {
253
- style = cssText;
254
- }
255
- styles.set(scopeId, style);
256
- };
257
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
258
- let scopeId = getScopeId(cmpMeta, mode);
259
- let style = styles.get(scopeId);
260
- if (!BUILD.attachStyles) {
261
- return scopeId;
262
- }
263
- // if an element is NOT connected then getRootNode() will return the wrong root node
264
- // so the fallback is to always use the document for the root node in those cases
265
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
266
- if (style) {
267
- if (typeof style === 'string') {
268
- styleContainerNode = styleContainerNode.head || styleContainerNode;
269
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
270
- let styleElm;
271
- if (!appliedStyles) {
272
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
273
- }
274
- if (!appliedStyles.has(scopeId)) {
275
- if (BUILD.hydrateClientSide &&
276
- styleContainerNode.host &&
277
- (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
278
- // This is only happening on native shadow-dom, do not needs CSS var shim
279
- styleElm.innerHTML = style;
280
- }
281
- else {
282
- if (BUILD.cssVarShim && plt.$cssShim$) {
283
- styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
284
- const newScopeId = styleElm['s-sc'];
285
- if (newScopeId) {
286
- scopeId = newScopeId;
287
- // we don't want to add this styleID to the appliedStyles Set
288
- // since the cssVarShim might need to apply several different
289
- // stylesheets for the same component
290
- appliedStyles = null;
291
- }
292
- }
293
- else {
294
- styleElm = doc.createElement('style');
295
- styleElm.innerHTML = style;
296
- }
297
- if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
298
- styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
299
- }
300
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
301
- }
302
- if (appliedStyles) {
303
- appliedStyles.add(scopeId);
304
- }
305
- }
306
- }
307
- else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
308
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
309
- }
310
- }
311
- return scopeId;
312
- };
313
- const attachStyles = (hostRef) => {
314
- const cmpMeta = hostRef.$cmpMeta$;
315
- const elm = hostRef.$hostElement$;
316
- const flags = cmpMeta.$flags$;
317
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
318
- const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
319
- if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
320
- // only required when we're NOT using native shadow dom (slot)
321
- // or this browser doesn't support native shadow dom
322
- // and this host element was NOT created with SSR
323
- // let's pick out the inner content for slot projection
324
- // create a node to represent where the original
325
- // content was first placed, which is useful later on
326
- // DOM WRITE!!
327
- elm['s-sc'] = scopeId;
328
- elm.classList.add(scopeId + '-h');
329
- if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
330
- elm.classList.add(scopeId + '-s');
331
- }
332
- }
333
- endAttachStyles();
334
- };
335
- const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
336
- const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
337
- // Private
338
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
339
- // Public
340
- const setMode = (handler) => modeResolutionChain.push(handler);
341
- const getMode = (ref) => getHostRef(ref).$modeName$;
342
- /**
343
- * Default style mode id
344
- */
345
- /**
346
- * Reusable empty obj/array
347
- * Don't add values to these!!
348
- */
349
- const EMPTY_OBJ = {};
350
- /**
351
- * Namespaces
352
- */
353
- const SVG_NS = 'http://www.w3.org/2000/svg';
354
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
355
- const isDef = (v) => v != null;
356
- const isComplexType = (o) => {
357
- // https://jsperf.com/typeof-fn-object/5
358
- o = typeof o;
359
- return o === 'object' || o === 'function';
360
- };
361
- /**
362
- * Production h() function based on Preact by
363
- * Jason Miller (@developit)
364
- * Licensed under the MIT License
365
- * https://github.com/developit/preact/blob/master/LICENSE
366
- *
367
- * Modified for Stencil's compiler and vdom
368
- */
369
- // const stack: any[] = [];
370
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
371
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
372
- const h = (nodeName, vnodeData, ...children) => {
373
- let child = null;
374
- let key = null;
375
- let slotName = null;
376
- let simple = false;
377
- let lastSimple = false;
378
- let vNodeChildren = [];
379
- const walk = (c) => {
380
- for (let i = 0; i < c.length; i++) {
381
- child = c[i];
382
- if (Array.isArray(child)) {
383
- walk(child);
384
- }
385
- else if (child != null && typeof child !== 'boolean') {
386
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
387
- child = String(child);
388
- }
389
- else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
390
- consoleDevError(`vNode passed as children has unexpected type.
391
- Make sure it's using the correct h() function.
392
- Empty objects can also be the cause, look for JSX comments that became objects.`);
393
- }
394
- if (simple && lastSimple) {
395
- // If the previous child was simple (string), we merge both
396
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
397
- }
398
- else {
399
- // Append a new vNode, if it's text, we create a text vNode
400
- vNodeChildren.push(simple ? newVNode(null, child) : child);
401
- }
402
- lastSimple = simple;
403
- }
404
- }
405
- };
406
- walk(children);
407
- if (vnodeData) {
408
- if (BUILD.isDev && nodeName === 'input') {
409
- validateInputProperties(vnodeData);
410
- }
411
- // normalize class / classname attributes
412
- if (BUILD.vdomKey && vnodeData.key) {
413
- key = vnodeData.key;
414
- }
415
- if (BUILD.slotRelocation && vnodeData.name) {
416
- slotName = vnodeData.name;
417
- }
418
- if (BUILD.vdomClass) {
419
- const classData = vnodeData.className || vnodeData.class;
420
- if (classData) {
421
- vnodeData.class =
422
- typeof classData !== 'object'
423
- ? classData
424
- : Object.keys(classData)
425
- .filter((k) => classData[k])
426
- .join(' ');
427
- }
428
- }
429
- }
430
- if (BUILD.isDev && vNodeChildren.some(isHost)) {
431
- consoleDevError(`The <Host> must be the single root component. Make sure:
432
- - You are NOT using hostData() and <Host> in the same component.
433
- - <Host> is used once, and it's the single root component of the render() function.`);
434
- }
435
- if (BUILD.vdomFunctional && typeof nodeName === 'function') {
436
- // nodeName is a functional component
437
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
438
- }
439
- const vnode = newVNode(nodeName, null);
440
- vnode.$attrs$ = vnodeData;
441
- if (vNodeChildren.length > 0) {
442
- vnode.$children$ = vNodeChildren;
443
- }
444
- if (BUILD.vdomKey) {
445
- vnode.$key$ = key;
446
- }
447
- if (BUILD.slotRelocation) {
448
- vnode.$name$ = slotName;
449
- }
450
- return vnode;
451
- };
452
- const newVNode = (tag, text) => {
453
- const vnode = {
454
- $flags$: 0,
455
- $tag$: tag,
456
- $text$: text,
457
- $elm$: null,
458
- $children$: null,
459
- };
460
- if (BUILD.vdomAttribute) {
461
- vnode.$attrs$ = null;
462
- }
463
- if (BUILD.vdomKey) {
464
- vnode.$key$ = null;
465
- }
466
- if (BUILD.slotRelocation) {
467
- vnode.$name$ = null;
468
- }
469
- return vnode;
470
- };
471
- const Host = {};
472
- const isHost = (node) => node && node.$tag$ === Host;
473
- const vdomFnUtils = {
474
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
475
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
476
- };
477
- const convertToPublic = (node) => ({
478
- vattrs: node.$attrs$,
479
- vchildren: node.$children$,
480
- vkey: node.$key$,
481
- vname: node.$name$,
482
- vtag: node.$tag$,
483
- vtext: node.$text$,
484
- });
485
- const convertToPrivate = (node) => {
486
- if (typeof node.vtag === 'function') {
487
- const vnodeData = Object.assign({}, node.vattrs);
488
- if (node.vkey) {
489
- vnodeData.key = node.vkey;
490
- }
491
- if (node.vname) {
492
- vnodeData.name = node.vname;
493
- }
494
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
495
- }
496
- const vnode = newVNode(node.vtag, node.vtext);
497
- vnode.$attrs$ = node.vattrs;
498
- vnode.$children$ = node.vchildren;
499
- vnode.$key$ = node.vkey;
500
- vnode.$name$ = node.vname;
501
- return vnode;
502
- };
503
- const validateInputProperties = (vnodeData) => {
504
- const props = Object.keys(vnodeData);
505
- const typeIndex = props.indexOf('type');
506
- const minIndex = props.indexOf('min');
507
- const maxIndex = props.indexOf('max');
508
- const stepIndex = props.indexOf('min');
509
- const value = props.indexOf('value');
510
- if (value === -1) {
511
- return;
512
- }
513
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
514
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
515
- }
516
- };
517
- /**
518
- * Production setAccessor() function based on Preact by
519
- * Jason Miller (@developit)
520
- * Licensed under the MIT License
521
- * https://github.com/developit/preact/blob/master/LICENSE
522
- *
523
- * Modified for Stencil's compiler and vdom
524
- */
525
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
526
- if (oldValue !== newValue) {
527
- let isProp = isMemberInElement(elm, memberName);
528
- let ln = memberName.toLowerCase();
529
- if (BUILD.vdomClass && memberName === 'class') {
530
- const classList = elm.classList;
531
- const oldClasses = parseClassList(oldValue);
532
- const newClasses = parseClassList(newValue);
533
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
534
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
535
- }
536
- else if (BUILD.vdomStyle && memberName === 'style') {
537
- // update style attribute, css properties and values
538
- if (BUILD.updatable) {
539
- for (const prop in oldValue) {
540
- if (!newValue || newValue[prop] == null) {
541
- if (!BUILD.hydrateServerSide && prop.includes('-')) {
542
- elm.style.removeProperty(prop);
543
- }
544
- else {
545
- elm.style[prop] = '';
546
- }
547
- }
548
- }
549
- }
550
- for (const prop in newValue) {
551
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
552
- if (!BUILD.hydrateServerSide && prop.includes('-')) {
553
- elm.style.setProperty(prop, newValue[prop]);
554
- }
555
- else {
556
- elm.style[prop] = newValue[prop];
557
- }
558
- }
559
- }
560
- }
561
- else if (BUILD.vdomKey && memberName === 'key')
562
- ;
563
- else if (BUILD.vdomRef && memberName === 'ref') {
564
- // minifier will clean this up
565
- if (newValue) {
566
- newValue(elm);
567
- }
568
- }
569
- else if (BUILD.vdomListener &&
570
- (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
571
- memberName[0] === 'o' &&
572
- memberName[1] === 'n') {
573
- // Event Handlers
574
- // so if the member name starts with "on" and the 3rd characters is
575
- // a capital letter, and it's not already a member on the element,
576
- // then we're assuming it's an event listener
577
- if (memberName[2] === '-') {
578
- // on- prefixed events
579
- // allows to be explicit about the dom event to listen without any magic
580
- // under the hood:
581
- // <my-cmp on-click> // listens for "click"
582
- // <my-cmp on-Click> // listens for "Click"
583
- // <my-cmp on-ionChange> // listens for "ionChange"
584
- // <my-cmp on-EVENTS> // listens for "EVENTS"
585
- memberName = memberName.slice(3);
586
- }
587
- else if (isMemberInElement(win, ln)) {
588
- // standard event
589
- // the JSX attribute could have been "onMouseOver" and the
590
- // member name "onmouseover" is on the window's prototype
591
- // so let's add the listener "mouseover", which is all lowercased
592
- memberName = ln.slice(2);
593
- }
594
- else {
595
- // custom event
596
- // the JSX attribute could have been "onMyCustomEvent"
597
- // so let's trim off the "on" prefix and lowercase the first character
598
- // and add the listener "myCustomEvent"
599
- // except for the first character, we keep the event name case
600
- memberName = ln[2] + memberName.slice(3);
601
- }
602
- if (oldValue) {
603
- plt.rel(elm, memberName, oldValue, false);
604
- }
605
- if (newValue) {
606
- plt.ael(elm, memberName, newValue, false);
607
- }
608
- }
609
- else if (BUILD.vdomPropOrAttr) {
610
- // Set property if it exists and it's not a SVG
611
- const isComplex = isComplexType(newValue);
612
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
613
- try {
614
- if (!elm.tagName.includes('-')) {
615
- let n = newValue == null ? '' : newValue;
616
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
617
- if (memberName === 'list') {
618
- isProp = false;
619
- // tslint:disable-next-line: triple-equals
620
- }
621
- else if (oldValue == null || elm[memberName] != n) {
622
- elm[memberName] = n;
623
- }
624
- }
625
- else {
626
- elm[memberName] = newValue;
627
- }
628
- }
629
- catch (e) { }
630
- }
631
- /**
632
- * Need to manually update attribute if:
633
- * - memberName is not an attribute
634
- * - if we are rendering the host element in order to reflect attribute
635
- * - if it's a SVG, since properties might not work in <svg>
636
- * - if the newValue is null/undefined or 'false'.
637
- */
638
- let xlink = false;
639
- if (BUILD.vdomXlink) {
640
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
641
- memberName = ln;
642
- xlink = true;
643
- }
644
- }
645
- if (newValue == null || newValue === false) {
646
- if (newValue !== false || elm.getAttribute(memberName) === '') {
647
- if (BUILD.vdomXlink && xlink) {
648
- elm.removeAttributeNS(XLINK_NS, memberName);
649
- }
650
- else {
651
- elm.removeAttribute(memberName);
652
- }
653
- }
654
- }
655
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
656
- newValue = newValue === true ? '' : newValue;
657
- if (BUILD.vdomXlink && xlink) {
658
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
659
- }
660
- else {
661
- elm.setAttribute(memberName, newValue);
662
- }
663
- }
664
- }
665
- }
666
- };
667
- const parseClassListRegex = /\s/;
668
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
669
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
670
- // if the element passed in is a shadow root, which is a document fragment
671
- // then we want to be adding attrs/props to the shadow root's "host" element
672
- // if it's not a shadow root, then we add attrs/props to the same element
673
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
674
- ? newVnode.$elm$.host
675
- : newVnode.$elm$;
676
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
677
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
678
- if (BUILD.updatable) {
679
- // remove attributes no longer present on the vnode by setting them to undefined
680
- for (memberName in oldVnodeAttrs) {
681
- if (!(memberName in newVnodeAttrs)) {
682
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
683
- }
684
- }
685
- }
686
- // add new & update changed attributes
687
- for (memberName in newVnodeAttrs) {
688
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
689
- }
690
- };
691
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
692
- // tslint:disable-next-line: prefer-const
693
- let newVNode = newParentVNode.$children$[childIndex];
694
- let i = 0;
695
- let elm;
696
- let childNode;
697
- let oldVNode;
698
- if (BUILD.slotRelocation && !useNativeShadowDom) {
699
- // remember for later we need to check to relocate nodes
700
- checkSlotRelocate = true;
701
- if (newVNode.$tag$ === 'slot') {
702
- if (scopeId) {
703
- // scoped css needs to add its scoped id to the parent element
704
- parentElm.classList.add(scopeId + '-s');
705
- }
706
- newVNode.$flags$ |= newVNode.$children$
707
- ? // slot element has fallback content
708
- 2 /* isSlotFallback */
709
- : // slot element does not have fallback content
710
- 1 /* isSlotReference */;
711
- }
712
- }
713
- if (BUILD.isDev && newVNode.$elm$) {
714
- consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
715
- }
716
- if (BUILD.vdomText && newVNode.$text$ !== null) {
717
- // create text node
718
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
719
- }
720
- else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
721
- // create a slot reference node
722
- elm = newVNode.$elm$ =
723
- BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
724
- }
725
- else {
726
- if (BUILD.svg && !isSvgMode) {
727
- isSvgMode = newVNode.$tag$ === 'svg';
728
- }
729
- // create element
730
- elm = newVNode.$elm$ = (BUILD.svg
731
- ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
732
- ? 'slot-fb'
733
- : newVNode.$tag$)
734
- : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
735
- ? 'slot-fb'
736
- : newVNode.$tag$));
737
- if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
738
- isSvgMode = false;
739
- }
740
- // add css classes, attrs, props, listeners, etc.
741
- if (BUILD.vdomAttribute) {
742
- updateElement(null, newVNode, isSvgMode);
743
- }
744
- if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
745
- // if there is a scopeId and this is the initial render
746
- // then let's add the scopeId as a css class
747
- elm.classList.add((elm['s-si'] = scopeId));
748
- }
749
- if (newVNode.$children$) {
750
- for (i = 0; i < newVNode.$children$.length; ++i) {
751
- // create the node
752
- childNode = createElm(oldParentVNode, newVNode, i, elm);
753
- // return node could have been null
754
- if (childNode) {
755
- // append our new node
756
- elm.appendChild(childNode);
757
- }
758
- }
759
- }
760
- if (BUILD.svg) {
761
- if (newVNode.$tag$ === 'svg') {
762
- // Only reset the SVG context when we're exiting <svg> element
763
- isSvgMode = false;
764
- }
765
- else if (elm.tagName === 'foreignObject') {
766
- // Reenter SVG context when we're exiting <foreignObject> element
767
- isSvgMode = true;
768
- }
769
- }
770
- }
771
- if (BUILD.slotRelocation) {
772
- elm['s-hn'] = hostTagName;
773
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
774
- // remember the content reference comment
775
- elm['s-sr'] = true;
776
- // remember the content reference comment
777
- elm['s-cr'] = contentRef;
778
- // remember the slot name, or empty string for default slot
779
- elm['s-sn'] = newVNode.$name$ || '';
780
- // check if we've got an old vnode for this slot
781
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
782
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
783
- // we've got an old slot vnode and the wrapper is being replaced
784
- // so let's move the old slot content back to it's original location
785
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
786
- }
787
- }
788
- }
789
- return elm;
790
- };
791
- const putBackInOriginalLocation = (parentElm, recursive) => {
792
- plt.$flags$ |= 1 /* isTmpDisconnected */;
793
- const oldSlotChildNodes = parentElm.childNodes;
794
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
795
- const childNode = oldSlotChildNodes[i];
796
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
797
- // // this child node in the old element is from another component
798
- // // remove this node from the old slot's parent
799
- // childNode.remove();
800
- // and relocate it back to it's original location
801
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
802
- // remove the old original location comment entirely
803
- // later on the patch function will know what to do
804
- // and move this to the correct spot in need be
805
- childNode['s-ol'].remove();
806
- childNode['s-ol'] = undefined;
807
- checkSlotRelocate = true;
808
- }
809
- if (recursive) {
810
- putBackInOriginalLocation(childNode, recursive);
811
- }
812
- }
813
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
814
- };
815
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
816
- let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
817
- let childNode;
818
- if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
819
- containerElm = containerElm.shadowRoot;
820
- }
821
- for (; startIdx <= endIdx; ++startIdx) {
822
- if (vnodes[startIdx]) {
823
- childNode = createElm(null, parentVNode, startIdx, parentElm);
824
- if (childNode) {
825
- vnodes[startIdx].$elm$ = childNode;
826
- containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
827
- }
828
- }
829
- }
830
- };
831
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
832
- for (; startIdx <= endIdx; ++startIdx) {
833
- if ((vnode = vnodes[startIdx])) {
834
- elm = vnode.$elm$;
835
- callNodeRefs(vnode);
836
- if (BUILD.slotRelocation) {
837
- // we're removing this element
838
- // so it's possible we need to show slot fallback content now
839
- checkSlotFallbackVisibility = true;
840
- if (elm['s-ol']) {
841
- // remove the original location comment
842
- elm['s-ol'].remove();
843
- }
844
- else {
845
- // it's possible that child nodes of the node
846
- // that's being removed are slot nodes
847
- putBackInOriginalLocation(elm, true);
848
- }
849
- }
850
- // remove the vnode's element from the dom
851
- elm.remove();
852
- }
853
- }
854
- };
855
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
856
- let oldStartIdx = 0;
857
- let newStartIdx = 0;
858
- let idxInOld = 0;
859
- let i = 0;
860
- let oldEndIdx = oldCh.length - 1;
861
- let oldStartVnode = oldCh[0];
862
- let oldEndVnode = oldCh[oldEndIdx];
863
- let newEndIdx = newCh.length - 1;
864
- let newStartVnode = newCh[0];
865
- let newEndVnode = newCh[newEndIdx];
866
- let node;
867
- let elmToMove;
868
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
869
- if (oldStartVnode == null) {
870
- // Vnode might have been moved left
871
- oldStartVnode = oldCh[++oldStartIdx];
872
- }
873
- else if (oldEndVnode == null) {
874
- oldEndVnode = oldCh[--oldEndIdx];
875
- }
876
- else if (newStartVnode == null) {
877
- newStartVnode = newCh[++newStartIdx];
878
- }
879
- else if (newEndVnode == null) {
880
- newEndVnode = newCh[--newEndIdx];
881
- }
882
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
883
- patch(oldStartVnode, newStartVnode);
884
- oldStartVnode = oldCh[++oldStartIdx];
885
- newStartVnode = newCh[++newStartIdx];
886
- }
887
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
888
- patch(oldEndVnode, newEndVnode);
889
- oldEndVnode = oldCh[--oldEndIdx];
890
- newEndVnode = newCh[--newEndIdx];
891
- }
892
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
893
- // Vnode moved right
894
- if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
895
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
896
- }
897
- patch(oldStartVnode, newEndVnode);
898
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
899
- oldStartVnode = oldCh[++oldStartIdx];
900
- newEndVnode = newCh[--newEndIdx];
901
- }
902
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
903
- // Vnode moved left
904
- if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
905
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
906
- }
907
- patch(oldEndVnode, newStartVnode);
908
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
909
- oldEndVnode = oldCh[--oldEndIdx];
910
- newStartVnode = newCh[++newStartIdx];
911
- }
912
- else {
913
- // createKeyToOldIdx
914
- idxInOld = -1;
915
- if (BUILD.vdomKey) {
916
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
917
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
918
- idxInOld = i;
919
- break;
920
- }
921
- }
922
- }
923
- if (BUILD.vdomKey && idxInOld >= 0) {
924
- elmToMove = oldCh[idxInOld];
925
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
926
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
927
- }
928
- else {
929
- patch(elmToMove, newStartVnode);
930
- oldCh[idxInOld] = undefined;
931
- node = elmToMove.$elm$;
932
- }
933
- newStartVnode = newCh[++newStartIdx];
934
- }
935
- else {
936
- // new element
937
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
938
- newStartVnode = newCh[++newStartIdx];
939
- }
940
- if (node) {
941
- if (BUILD.slotRelocation) {
942
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
943
- }
944
- else {
945
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
946
- }
947
- }
948
- }
949
- }
950
- if (oldStartIdx > oldEndIdx) {
951
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
952
- }
953
- else if (BUILD.updatable && newStartIdx > newEndIdx) {
954
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
955
- }
956
- };
957
- const isSameVnode = (vnode1, vnode2) => {
958
- // compare if two vnode to see if they're "technically" the same
959
- // need to have the same element tag, and same key to be the same
960
- if (vnode1.$tag$ === vnode2.$tag$) {
961
- if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
962
- return vnode1.$name$ === vnode2.$name$;
963
- }
964
- if (BUILD.vdomKey) {
965
- return vnode1.$key$ === vnode2.$key$;
966
- }
967
- return true;
968
- }
969
- return false;
970
- };
971
- const referenceNode = (node) => {
972
- // this node was relocated to a new location in the dom
973
- // because of some other component's slot
974
- // but we still have an html comment in place of where
975
- // it's original location was according to it's original vdom
976
- return (node && node['s-ol']) || node;
977
- };
978
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
979
- const patch = (oldVNode, newVNode) => {
980
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
981
- const oldChildren = oldVNode.$children$;
982
- const newChildren = newVNode.$children$;
983
- const tag = newVNode.$tag$;
984
- const text = newVNode.$text$;
985
- let defaultHolder;
986
- if (!BUILD.vdomText || text === null) {
987
- if (BUILD.svg) {
988
- // test if we're rendering an svg element, or still rendering nodes inside of one
989
- // only add this to the when the compiler sees we're using an svg somewhere
990
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
991
- }
992
- // element node
993
- if (BUILD.vdomAttribute || BUILD.reflect) {
994
- if (BUILD.slot && tag === 'slot')
995
- ;
996
- else {
997
- // either this is the first render of an element OR it's an update
998
- // AND we already know it's possible it could have changed
999
- // this updates the element's css classes, attrs, props, listeners, etc.
1000
- updateElement(oldVNode, newVNode, isSvgMode);
1001
- }
1002
- }
1003
- if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1004
- // looks like there's child vnodes for both the old and new vnodes
1005
- updateChildren(elm, oldChildren, newVNode, newChildren);
1006
- }
1007
- else if (newChildren !== null) {
1008
- // no old child vnodes, but there are new child vnodes to add
1009
- if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1010
- // the old vnode was text, so be sure to clear it out
1011
- elm.textContent = '';
1012
- }
1013
- // add the new vnode children
1014
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1015
- }
1016
- else if (BUILD.updatable && oldChildren !== null) {
1017
- // no new child vnodes, but there are old child vnodes to remove
1018
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1019
- }
1020
- if (BUILD.svg && isSvgMode && tag === 'svg') {
1021
- isSvgMode = false;
1022
- }
1023
- }
1024
- else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1025
- // this element has slotted content
1026
- defaultHolder.parentNode.textContent = text;
1027
- }
1028
- else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1029
- // update the text content for the text only vnode
1030
- // and also only if the text is different than before
1031
- elm.data = text;
1032
- }
1033
- };
1034
- const updateFallbackSlotVisibility = (elm) => {
1035
- // tslint:disable-next-line: prefer-const
1036
- let childNodes = elm.childNodes;
1037
- let childNode;
1038
- let i;
1039
- let ilen;
1040
- let j;
1041
- let slotNameAttr;
1042
- let nodeType;
1043
- for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1044
- childNode = childNodes[i];
1045
- if (childNode.nodeType === 1 /* ElementNode */) {
1046
- if (childNode['s-sr']) {
1047
- // this is a slot fallback node
1048
- // get the slot name for this slot reference node
1049
- slotNameAttr = childNode['s-sn'];
1050
- // by default always show a fallback slot node
1051
- // then hide it if there are other slots in the light dom
1052
- childNode.hidden = false;
1053
- for (j = 0; j < ilen; j++) {
1054
- nodeType = childNodes[j].nodeType;
1055
- if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1056
- // this sibling node is from a different component OR is a named fallback slot node
1057
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1058
- childNode.hidden = true;
1059
- break;
1060
- }
1061
- }
1062
- else {
1063
- // this is a default fallback slot node
1064
- // any element or text node (with content)
1065
- // should hide the default fallback slot node
1066
- if (nodeType === 1 /* ElementNode */ ||
1067
- (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1068
- childNode.hidden = true;
1069
- break;
1070
- }
1071
- }
1072
- }
1073
- }
1074
- // keep drilling down
1075
- updateFallbackSlotVisibility(childNode);
1076
- }
1077
- }
1078
- };
1079
- const relocateNodes = [];
1080
- const relocateSlotContent = (elm) => {
1081
- // tslint:disable-next-line: prefer-const
1082
- let childNode;
1083
- let node;
1084
- let hostContentNodes;
1085
- let slotNameAttr;
1086
- let relocateNodeData;
1087
- let j;
1088
- let i = 0;
1089
- let childNodes = elm.childNodes;
1090
- let ilen = childNodes.length;
1091
- for (; i < ilen; i++) {
1092
- childNode = childNodes[i];
1093
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1094
- // first got the content reference comment node
1095
- // then we got it's parent, which is where all the host content is in now
1096
- hostContentNodes = node.parentNode.childNodes;
1097
- slotNameAttr = childNode['s-sn'];
1098
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1099
- node = hostContentNodes[j];
1100
- if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1101
- // let's do some relocating to its new home
1102
- // but never relocate a content reference node
1103
- // that is suppose to always represent the original content location
1104
- if (isNodeLocatedInSlot(node, slotNameAttr)) {
1105
- // it's possible we've already decided to relocate this node
1106
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1107
- // made some changes to slots
1108
- // let's make sure we also double check
1109
- // fallbacks are correctly hidden or shown
1110
- checkSlotFallbackVisibility = true;
1111
- node['s-sn'] = node['s-sn'] || slotNameAttr;
1112
- if (relocateNodeData) {
1113
- // previously we never found a slot home for this node
1114
- // but turns out we did, so let's remember it now
1115
- relocateNodeData.$slotRefNode$ = childNode;
1116
- }
1117
- else {
1118
- // add to our list of nodes to relocate
1119
- relocateNodes.push({
1120
- $slotRefNode$: childNode,
1121
- $nodeToRelocate$: node,
1122
- });
1123
- }
1124
- if (node['s-sr']) {
1125
- relocateNodes.map((relocateNode) => {
1126
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1127
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1128
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1129
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1130
- }
1131
- }
1132
- });
1133
- }
1134
- }
1135
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1136
- // so far this element does not have a slot home, not setting slotRefNode on purpose
1137
- // if we never find a home for this element then we'll need to hide it
1138
- relocateNodes.push({
1139
- $nodeToRelocate$: node,
1140
- });
1141
- }
1142
- }
1143
- }
1144
- }
1145
- if (childNode.nodeType === 1 /* ElementNode */) {
1146
- relocateSlotContent(childNode);
1147
- }
1148
- }
1149
- };
1150
- const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1151
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1152
- if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1153
- return true;
1154
- }
1155
- if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1156
- return true;
1157
- }
1158
- return false;
1159
- }
1160
- if (nodeToRelocate['s-sn'] === slotNameAttr) {
1161
- return true;
1162
- }
1163
- return slotNameAttr === '';
1164
- };
1165
- const callNodeRefs = (vNode) => {
1166
- if (BUILD.vdomRef) {
1167
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1168
- vNode.$children$ && vNode.$children$.map(callNodeRefs);
1169
- }
1170
- };
1171
- const renderVdom = (hostRef, renderFnResults) => {
1172
- const hostElm = hostRef.$hostElement$;
1173
- const cmpMeta = hostRef.$cmpMeta$;
1174
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1175
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1176
- hostTagName = hostElm.tagName;
1177
- // <Host> runtime check
1178
- if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1179
- throw new Error(`The <Host> must be the single root component.
1180
- Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1181
-
1182
- The render() function should look like this instead:
1183
-
1184
- render() {
1185
- // Do not return an array
1186
- return (
1187
- <Host>{content}</Host>
1188
- );
1189
- }
1190
- `);
1191
- }
1192
- if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1193
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1194
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1195
- }
1196
- rootVnode.$tag$ = null;
1197
- rootVnode.$flags$ |= 4 /* isHost */;
1198
- hostRef.$vnode$ = rootVnode;
1199
- rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1200
- if (BUILD.scoped || BUILD.shadowDom) {
1201
- scopeId = hostElm['s-sc'];
1202
- }
1203
- if (BUILD.slotRelocation) {
1204
- contentRef = hostElm['s-cr'];
1205
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1206
- // always reset
1207
- checkSlotFallbackVisibility = false;
1208
- }
1209
- // synchronous patch
1210
- patch(oldVNode, rootVnode);
1211
- if (BUILD.slotRelocation) {
1212
- // while we're moving nodes around existing nodes, temporarily disable
1213
- // the disconnectCallback from working
1214
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1215
- if (checkSlotRelocate) {
1216
- relocateSlotContent(rootVnode.$elm$);
1217
- let relocateData;
1218
- let nodeToRelocate;
1219
- let orgLocationNode;
1220
- let parentNodeRef;
1221
- let insertBeforeNode;
1222
- let refNode;
1223
- let i = 0;
1224
- for (; i < relocateNodes.length; i++) {
1225
- relocateData = relocateNodes[i];
1226
- nodeToRelocate = relocateData.$nodeToRelocate$;
1227
- if (!nodeToRelocate['s-ol']) {
1228
- // add a reference node marking this node's original location
1229
- // keep a reference to this node for later lookups
1230
- orgLocationNode =
1231
- BUILD.isDebug || BUILD.hydrateServerSide
1232
- ? originalLocationDebugNode(nodeToRelocate)
1233
- : doc.createTextNode('');
1234
- orgLocationNode['s-nr'] = nodeToRelocate;
1235
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1236
- }
1237
- }
1238
- for (i = 0; i < relocateNodes.length; i++) {
1239
- relocateData = relocateNodes[i];
1240
- nodeToRelocate = relocateData.$nodeToRelocate$;
1241
- if (relocateData.$slotRefNode$) {
1242
- // by default we're just going to insert it directly
1243
- // after the slot reference node
1244
- parentNodeRef = relocateData.$slotRefNode$.parentNode;
1245
- insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1246
- orgLocationNode = nodeToRelocate['s-ol'];
1247
- while ((orgLocationNode = orgLocationNode.previousSibling)) {
1248
- refNode = orgLocationNode['s-nr'];
1249
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1250
- refNode = refNode.nextSibling;
1251
- if (!refNode || !refNode['s-nr']) {
1252
- insertBeforeNode = refNode;
1253
- break;
1254
- }
1255
- }
1256
- }
1257
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1258
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1259
- // we've checked that it's worth while to relocate
1260
- // since that the node to relocate
1261
- // has a different next sibling or parent relocated
1262
- if (nodeToRelocate !== insertBeforeNode) {
1263
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1264
- // probably a component in the index.html that doesn't have it's hostname set
1265
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1266
- }
1267
- // add it back to the dom but in its new home
1268
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1269
- }
1270
- }
1271
- }
1272
- else {
1273
- // this node doesn't have a slot home to go to, so let's hide it
1274
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1275
- nodeToRelocate.hidden = true;
1276
- }
1277
- }
1278
- }
1279
- }
1280
- if (checkSlotFallbackVisibility) {
1281
- updateFallbackSlotVisibility(rootVnode.$elm$);
1282
- }
1283
- // done moving nodes around
1284
- // allow the disconnect callback to work again
1285
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1286
- // always reset
1287
- relocateNodes.length = 0;
1288
- }
1289
- };
1290
- // slot comment debug nodes only created with the `--debug` flag
1291
- // otherwise these nodes are text nodes w/out content
1292
- const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1293
- const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1294
- (nodeToRelocate.localName
1295
- ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1296
- : `[${nodeToRelocate.textContent}]`));
1297
- const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
1298
- const createEvent = (ref, name, flags) => {
1299
- const elm = getElement(ref);
1300
- return {
1301
- emit: (detail) => {
1302
- if (BUILD.isDev && !elm.isConnected) {
1303
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1304
- }
1305
- return emitEvent(elm, name, {
1306
- bubbles: !!(flags & 4 /* Bubbles */),
1307
- composed: !!(flags & 2 /* Composed */),
1308
- cancelable: !!(flags & 1 /* Cancellable */),
1309
- detail,
1310
- });
1311
- },
1312
- };
1313
- };
1314
- /**
1315
- * Helper function to create & dispatch a custom Event on a provided target
1316
- * @param elm the target of the Event
1317
- * @param name the name to give the custom Event
1318
- * @param opts options for configuring a custom Event
1319
- * @returns the custom Event
1320
- */
1321
- const emitEvent = (elm, name, opts) => {
1322
- const ev = plt.ce(name, opts);
1323
- elm.dispatchEvent(ev);
1324
- return ev;
1325
- };
1326
- const attachToAncestor = (hostRef, ancestorComponent) => {
1327
- if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1328
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1329
- }
1330
- };
1331
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1332
- if (BUILD.taskQueue && BUILD.updatable) {
1333
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1334
- }
1335
- if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1336
- hostRef.$flags$ |= 512 /* needsRerender */;
1337
- return;
1338
- }
1339
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1340
- // there is no ancestor component or the ancestor component
1341
- // has already fired off its lifecycle update then
1342
- // fire off the initial update
1343
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1344
- return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1345
- };
1346
- const dispatchHooks = (hostRef, isInitialLoad) => {
1347
- const elm = hostRef.$hostElement$;
1348
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1349
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1350
- let promise;
1351
- if (isInitialLoad) {
1352
- if (BUILD.lazyLoad && BUILD.hostListener) {
1353
- hostRef.$flags$ |= 256 /* isListenReady */;
1354
- if (hostRef.$queuedListeners$) {
1355
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1356
- hostRef.$queuedListeners$ = null;
1357
- }
1358
- }
1359
- emitLifecycleEvent(elm, 'componentWillLoad');
1360
- if (BUILD.cmpWillLoad) {
1361
- promise = safeCall(instance, 'componentWillLoad');
1362
- }
1363
- }
1364
- else {
1365
- emitLifecycleEvent(elm, 'componentWillUpdate');
1366
- if (BUILD.cmpWillUpdate) {
1367
- promise = safeCall(instance, 'componentWillUpdate');
1368
- }
1369
- }
1370
- emitLifecycleEvent(elm, 'componentWillRender');
1371
- if (BUILD.cmpWillRender) {
1372
- promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1373
- }
1374
- endSchedule();
1375
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1376
- };
1377
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1378
- // updateComponent
1379
- const elm = hostRef.$hostElement$;
1380
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1381
- const rc = elm['s-rc'];
1382
- if (BUILD.style && isInitialLoad) {
1383
- // DOM WRITE!
1384
- attachStyles(hostRef);
1385
- }
1386
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1387
- if (BUILD.isDev) {
1388
- hostRef.$flags$ |= 1024 /* devOnRender */;
1389
- }
1390
- if (BUILD.hydrateServerSide) {
1391
- await callRender(hostRef, instance, elm);
1392
- }
1393
- else {
1394
- callRender(hostRef, instance, elm);
1395
- }
1396
- if (BUILD.cssVarShim && plt.$cssShim$) {
1397
- plt.$cssShim$.updateHost(elm);
1398
- }
1399
- if (BUILD.isDev) {
1400
- hostRef.$renderCount$++;
1401
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1402
- }
1403
- if (BUILD.hydrateServerSide) {
1404
- try {
1405
- // manually connected child components during server-side hydrate
1406
- serverSideConnected(elm);
1407
- if (isInitialLoad) {
1408
- // using only during server-side hydrate
1409
- if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1410
- elm['s-en'] = '';
1411
- }
1412
- else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1413
- elm['s-en'] = 'c';
1414
- }
1415
- }
1416
- }
1417
- catch (e) {
1418
- consoleError(e, elm);
1419
- }
1420
- }
1421
- if (BUILD.asyncLoading && rc) {
1422
- // ok, so turns out there are some child host elements
1423
- // waiting on this parent element to load
1424
- // let's fire off all update callbacks waiting
1425
- rc.map((cb) => cb());
1426
- elm['s-rc'] = undefined;
1427
- }
1428
- endRender();
1429
- endUpdate();
1430
- if (BUILD.asyncLoading) {
1431
- const childrenPromises = elm['s-p'];
1432
- const postUpdate = () => postUpdateComponent(hostRef);
1433
- if (childrenPromises.length === 0) {
1434
- postUpdate();
1435
- }
1436
- else {
1437
- Promise.all(childrenPromises).then(postUpdate);
1438
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1439
- childrenPromises.length = 0;
1440
- }
1441
- }
1442
- else {
1443
- postUpdateComponent(hostRef);
1444
- }
1445
- };
1446
- const callRender = (hostRef, instance, elm) => {
1447
- // in order for bundlers to correctly treeshake the BUILD object
1448
- // we need to ensure BUILD is not deoptimized within a try/catch
1449
- // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1450
- const allRenderFn = BUILD.allRenderFn ? true : false;
1451
- const lazyLoad = BUILD.lazyLoad ? true : false;
1452
- const taskQueue = BUILD.taskQueue ? true : false;
1453
- const updatable = BUILD.updatable ? true : false;
1454
- try {
1455
- renderingRef = instance;
1456
- instance = allRenderFn ? instance.render() : instance.render && instance.render();
1457
- if (updatable && taskQueue) {
1458
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1459
- }
1460
- if (updatable || lazyLoad) {
1461
- hostRef.$flags$ |= 2 /* hasRendered */;
1462
- }
1463
- if (BUILD.hasRenderFn || BUILD.reflect) {
1464
- if (BUILD.vdomRender || BUILD.reflect) {
1465
- // looks like we've got child nodes to render into this host element
1466
- // or we need to update the css class/attrs on the host element
1467
- // DOM WRITE!
1468
- if (BUILD.hydrateServerSide) {
1469
- return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1470
- }
1471
- else {
1472
- renderVdom(hostRef, instance);
1473
- }
1474
- }
1475
- else {
1476
- elm.textContent = instance;
1477
- }
1478
- }
1479
- }
1480
- catch (e) {
1481
- consoleError(e, hostRef.$hostElement$);
1482
- }
1483
- renderingRef = null;
1484
- return null;
1485
- };
1486
- const getRenderingRef = () => renderingRef;
1487
- const postUpdateComponent = (hostRef) => {
1488
- const tagName = hostRef.$cmpMeta$.$tagName$;
1489
- const elm = hostRef.$hostElement$;
1490
- const endPostUpdate = createTime('postUpdate', tagName);
1491
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1492
- const ancestorComponent = hostRef.$ancestorComponent$;
1493
- if (BUILD.cmpDidRender) {
1494
- if (BUILD.isDev) {
1495
- hostRef.$flags$ |= 1024 /* devOnRender */;
1496
- }
1497
- safeCall(instance, 'componentDidRender');
1498
- if (BUILD.isDev) {
1499
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1500
- }
1501
- }
1502
- emitLifecycleEvent(elm, 'componentDidRender');
1503
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1504
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1505
- if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1506
- // DOM WRITE!
1507
- addHydratedFlag(elm);
1508
- }
1509
- if (BUILD.cmpDidLoad) {
1510
- if (BUILD.isDev) {
1511
- hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1512
- }
1513
- safeCall(instance, 'componentDidLoad');
1514
- if (BUILD.isDev) {
1515
- hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1516
- }
1517
- }
1518
- emitLifecycleEvent(elm, 'componentDidLoad');
1519
- endPostUpdate();
1520
- if (BUILD.asyncLoading) {
1521
- hostRef.$onReadyResolve$(elm);
1522
- if (!ancestorComponent) {
1523
- appDidLoad(tagName);
1524
- }
1525
- }
1526
- }
1527
- else {
1528
- if (BUILD.cmpDidUpdate) {
1529
- // we've already loaded this component
1530
- // fire off the user's componentDidUpdate method (if one was provided)
1531
- // componentDidUpdate runs AFTER render() has been called
1532
- // and all child components have finished updating
1533
- if (BUILD.isDev) {
1534
- hostRef.$flags$ |= 1024 /* devOnRender */;
1535
- }
1536
- safeCall(instance, 'componentDidUpdate');
1537
- if (BUILD.isDev) {
1538
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1539
- }
1540
- }
1541
- emitLifecycleEvent(elm, 'componentDidUpdate');
1542
- endPostUpdate();
1543
- }
1544
- if (BUILD.hotModuleReplacement) {
1545
- elm['s-hmr-load'] && elm['s-hmr-load']();
1546
- }
1547
- if (BUILD.method && BUILD.lazyLoad) {
1548
- hostRef.$onInstanceResolve$(elm);
1549
- }
1550
- // load events fire from bottom to top
1551
- // the deepest elements load first then bubbles up
1552
- if (BUILD.asyncLoading) {
1553
- if (hostRef.$onRenderResolve$) {
1554
- hostRef.$onRenderResolve$();
1555
- hostRef.$onRenderResolve$ = undefined;
1556
- }
1557
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1558
- nextTick(() => scheduleUpdate(hostRef, false));
1559
- }
1560
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1561
- }
1562
- // ( •_•)
1563
- // ( •_•)>⌐■-■
1564
- // (⌐■_■)
1565
- };
1566
- const forceUpdate = (ref) => {
1567
- if (BUILD.updatable) {
1568
- const hostRef = getHostRef(ref);
1569
- const isConnected = hostRef.$hostElement$.isConnected;
1570
- if (isConnected &&
1571
- (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1572
- scheduleUpdate(hostRef, false);
1573
- }
1574
- // Returns "true" when the forced update was successfully scheduled
1575
- return isConnected;
1576
- }
1577
- return false;
1578
- };
1579
- const appDidLoad = (who) => {
1580
- // on appload
1581
- // we have finish the first big initial render
1582
- if (BUILD.cssAnnotations) {
1583
- addHydratedFlag(doc.documentElement);
1584
- }
1585
- if (BUILD.asyncQueue) {
1586
- plt.$flags$ |= 2 /* appLoaded */;
1587
- }
1588
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1589
- if (BUILD.profile && performance.measure) {
1590
- performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1591
- }
1592
- };
1593
- const safeCall = (instance, method, arg) => {
1594
- if (instance && instance[method]) {
1595
- try {
1596
- return instance[method](arg);
1597
- }
1598
- catch (e) {
1599
- consoleError(e);
1600
- }
1601
- }
1602
- return undefined;
1603
- };
1604
- const then = (promise, thenFn) => {
1605
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1606
- };
1607
- const emitLifecycleEvent = (elm, lifecycleName) => {
1608
- if (BUILD.lifecycleDOMEvents) {
1609
- emitEvent(elm, 'stencil_' + lifecycleName, {
1610
- bubbles: true,
1611
- composed: true,
1612
- detail: {
1613
- namespace: NAMESPACE,
1614
- },
1615
- });
1616
- }
1617
- };
1618
- const addHydratedFlag = (elm) => BUILD.hydratedClass
1619
- ? elm.classList.add('hydrated')
1620
- : BUILD.hydratedAttribute
1621
- ? elm.setAttribute('hydrated', '')
1622
- : undefined;
1623
- const serverSideConnected = (elm) => {
1624
- const children = elm.children;
1625
- if (children != null) {
1626
- for (let i = 0, ii = children.length; i < ii; i++) {
1627
- const childElm = children[i];
1628
- if (typeof childElm.connectedCallback === 'function') {
1629
- childElm.connectedCallback();
1630
- }
1631
- serverSideConnected(childElm);
1632
- }
1633
- }
1634
- };
1635
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1636
- const endHydrate = createTime('hydrateClient', tagName);
1637
- const shadowRoot = hostElm.shadowRoot;
1638
- const childRenderNodes = [];
1639
- const slotNodes = [];
1640
- const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1641
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1642
- if (!plt.$orgLocNodes$) {
1643
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1644
- }
1645
- hostElm[HYDRATE_ID] = hostId;
1646
- hostElm.removeAttribute(HYDRATE_ID);
1647
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1648
- childRenderNodes.map((c) => {
1649
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1650
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1651
- const node = c.$elm$;
1652
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1653
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1654
- }
1655
- if (!shadowRoot) {
1656
- node['s-hn'] = tagName;
1657
- if (orgLocationNode) {
1658
- node['s-ol'] = orgLocationNode;
1659
- node['s-ol']['s-nr'] = node;
1660
- }
1661
- }
1662
- plt.$orgLocNodes$.delete(orgLocationId);
1663
- });
1664
- if (BUILD.shadowDom && shadowRoot) {
1665
- shadowRootNodes.map((shadowRootNode) => {
1666
- if (shadowRootNode) {
1667
- shadowRoot.appendChild(shadowRootNode);
1668
- }
1669
- });
1670
- }
1671
- endHydrate();
1672
- };
1673
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1674
- let childNodeType;
1675
- let childIdSplt;
1676
- let childVNode;
1677
- let i;
1678
- if (node.nodeType === 1 /* ElementNode */) {
1679
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1680
- if (childNodeType) {
1681
- // got the node data from the element's attribute
1682
- // `${hostId}.${nodeId}.${depth}.${index}`
1683
- childIdSplt = childNodeType.split('.');
1684
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1685
- childVNode = {
1686
- $flags$: 0,
1687
- $hostId$: childIdSplt[0],
1688
- $nodeId$: childIdSplt[1],
1689
- $depth$: childIdSplt[2],
1690
- $index$: childIdSplt[3],
1691
- $tag$: node.tagName.toLowerCase(),
1692
- $elm$: node,
1693
- $attrs$: null,
1694
- $children$: null,
1695
- $key$: null,
1696
- $name$: null,
1697
- $text$: null,
1698
- };
1699
- childRenderNodes.push(childVNode);
1700
- node.removeAttribute(HYDRATE_CHILD_ID);
1701
- // this is a new child vnode
1702
- // so ensure its parent vnode has the vchildren array
1703
- if (!parentVNode.$children$) {
1704
- parentVNode.$children$ = [];
1705
- }
1706
- // add our child vnode to a specific index of the vnode's children
1707
- parentVNode.$children$[childVNode.$index$] = childVNode;
1708
- // this is now the new parent vnode for all the next child checks
1709
- parentVNode = childVNode;
1710
- if (shadowRootNodes && childVNode.$depth$ === '0') {
1711
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1712
- }
1713
- }
1714
- }
1715
- // recursively drill down, end to start so we can remove nodes
1716
- for (i = node.childNodes.length - 1; i >= 0; i--) {
1717
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1718
- }
1719
- if (node.shadowRoot) {
1720
- // keep drilling down through the shadow root nodes
1721
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1722
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1723
- }
1724
- }
1725
- }
1726
- else if (node.nodeType === 8 /* CommentNode */) {
1727
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1728
- childIdSplt = node.nodeValue.split('.');
1729
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1730
- // comment node for either the host id or a 0 host id
1731
- childNodeType = childIdSplt[0];
1732
- childVNode = {
1733
- $flags$: 0,
1734
- $hostId$: childIdSplt[1],
1735
- $nodeId$: childIdSplt[2],
1736
- $depth$: childIdSplt[3],
1737
- $index$: childIdSplt[4],
1738
- $elm$: node,
1739
- $attrs$: null,
1740
- $children$: null,
1741
- $key$: null,
1742
- $name$: null,
1743
- $tag$: null,
1744
- $text$: null,
1745
- };
1746
- if (childNodeType === TEXT_NODE_ID) {
1747
- childVNode.$elm$ = node.nextSibling;
1748
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1749
- childVNode.$text$ = childVNode.$elm$.textContent;
1750
- childRenderNodes.push(childVNode);
1751
- // remove the text comment since it's no longer needed
1752
- node.remove();
1753
- if (!parentVNode.$children$) {
1754
- parentVNode.$children$ = [];
1755
- }
1756
- parentVNode.$children$[childVNode.$index$] = childVNode;
1757
- if (shadowRootNodes && childVNode.$depth$ === '0') {
1758
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1759
- }
1760
- }
1761
- }
1762
- else if (childVNode.$hostId$ === hostId) {
1763
- // this comment node is specifcally for this host id
1764
- if (childNodeType === SLOT_NODE_ID) {
1765
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1766
- childVNode.$tag$ = 'slot';
1767
- if (childIdSplt[5]) {
1768
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1769
- }
1770
- else {
1771
- node['s-sn'] = '';
1772
- }
1773
- node['s-sr'] = true;
1774
- if (BUILD.shadowDom && shadowRootNodes) {
1775
- // browser support shadowRoot and this is a shadow dom component
1776
- // create an actual slot element
1777
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1778
- if (childVNode.$name$) {
1779
- // add the slot name attribute
1780
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
1781
- }
1782
- // insert the new slot element before the slot comment
1783
- node.parentNode.insertBefore(childVNode.$elm$, node);
1784
- // remove the slot comment since it's not needed for shadow
1785
- node.remove();
1786
- if (childVNode.$depth$ === '0') {
1787
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1788
- }
1789
- }
1790
- slotNodes.push(childVNode);
1791
- if (!parentVNode.$children$) {
1792
- parentVNode.$children$ = [];
1793
- }
1794
- parentVNode.$children$[childVNode.$index$] = childVNode;
1795
- }
1796
- else if (childNodeType === CONTENT_REF_ID) {
1797
- // `${CONTENT_REF_ID}.${hostId}`;
1798
- if (BUILD.shadowDom && shadowRootNodes) {
1799
- // remove the content ref comment since it's not needed for shadow
1800
- node.remove();
1801
- }
1802
- else if (BUILD.slotRelocation) {
1803
- hostElm['s-cr'] = node;
1804
- node['s-cn'] = true;
1805
- }
1806
- }
1807
- }
1808
- }
1809
- }
1810
- else if (parentVNode && parentVNode.$tag$ === 'style') {
1811
- const vnode = newVNode(null, node.textContent);
1812
- vnode.$elm$ = node;
1813
- vnode.$index$ = '0';
1814
- parentVNode.$children$ = [vnode];
1815
- }
1816
- };
1817
- const initializeDocumentHydrate = (node, orgLocNodes) => {
1818
- if (node.nodeType === 1 /* ElementNode */) {
1819
- let i = 0;
1820
- for (; i < node.childNodes.length; i++) {
1821
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1822
- }
1823
- if (node.shadowRoot) {
1824
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1825
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1826
- }
1827
- }
1828
- }
1829
- else if (node.nodeType === 8 /* CommentNode */) {
1830
- const childIdSplt = node.nodeValue.split('.');
1831
- if (childIdSplt[0] === ORG_LOCATION_ID) {
1832
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1833
- node.nodeValue = '';
1834
- // useful to know if the original location is
1835
- // the root light-dom of a shadow dom component
1836
- node['s-en'] = childIdSplt[3];
1837
- }
1838
- }
1839
- };
1840
- const parsePropertyValue = (propValue, propType) => {
1841
- // ensure this value is of the correct prop type
1842
- if (propValue != null && !isComplexType(propValue)) {
1843
- if (BUILD.propBoolean && propType & 4 /* Boolean */) {
1844
- // per the HTML spec, any string value means it is a boolean true value
1845
- // but we'll cheat here and say that the string "false" is the boolean false
1846
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1847
- }
1848
- if (BUILD.propNumber && propType & 2 /* Number */) {
1849
- // force it to be a number
1850
- return parseFloat(propValue);
1851
- }
1852
- if (BUILD.propString && propType & 1 /* String */) {
1853
- // could have been passed as a number or boolean
1854
- // but we still want it as a string
1855
- return String(propValue);
1856
- }
1857
- // redundant return here for better minification
1858
- return propValue;
1859
- }
1860
- // not sure exactly what type we want
1861
- // so no need to change to a different type
1862
- return propValue;
1863
- };
1864
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1865
- const setValue = (ref, propName, newVal, cmpMeta) => {
1866
- // check our new property value against our internal value
1867
- const hostRef = getHostRef(ref);
1868
- const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1869
- const oldVal = hostRef.$instanceValues$.get(propName);
1870
- const flags = hostRef.$flags$;
1871
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1872
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1873
- if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1874
- // gadzooks! the property's value has changed!!
1875
- // set our new value!
1876
- hostRef.$instanceValues$.set(propName, newVal);
1877
- if (BUILD.isDev) {
1878
- if (hostRef.$flags$ & 1024 /* devOnRender */) {
1879
- consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1880
- }
1881
- else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
1882
- consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
1883
- }
1884
- }
1885
- if (!BUILD.lazyLoad || instance) {
1886
- // get an array of method names of watch functions to call
1887
- if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1888
- const watchMethods = cmpMeta.$watchers$[propName];
1889
- if (watchMethods) {
1890
- // this instance is watching for when this property changed
1891
- watchMethods.map((watchMethodName) => {
1892
- try {
1893
- // fire off each of the watch methods that are watching this property
1894
- instance[watchMethodName](newVal, oldVal, propName);
1895
- }
1896
- catch (e) {
1897
- consoleError(e, elm);
1898
- }
1899
- });
1900
- }
1901
- }
1902
- if (BUILD.updatable &&
1903
- (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1904
- if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1905
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1906
- return;
1907
- }
1908
- }
1909
- // looks like this value actually changed, so we've got work to do!
1910
- // but only if we've already rendered, otherwise just chill out
1911
- // queue that we need to do an update, but don't worry about queuing
1912
- // up millions cuz this function ensures it only runs once
1913
- scheduleUpdate(hostRef, false);
1914
- }
1915
- }
1916
- }
1917
- };
1918
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1919
- if (BUILD.member && cmpMeta.$members$) {
1920
- if (BUILD.watchCallback && Cstr.watchers) {
1921
- cmpMeta.$watchers$ = Cstr.watchers;
1922
- }
1923
- // It's better to have a const than two Object.entries()
1924
- const members = Object.entries(cmpMeta.$members$);
1925
- const prototype = Cstr.prototype;
1926
- members.map(([memberName, [memberFlags]]) => {
1927
- if ((BUILD.prop || BUILD.state) &&
1928
- (memberFlags & 31 /* Prop */ ||
1929
- ((!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1930
- // proxyComponent - prop
1931
- Object.defineProperty(prototype, memberName, {
1932
- get() {
1933
- // proxyComponent, get value
1934
- return getValue(this, memberName);
1935
- },
1936
- set(newValue) {
1937
- // only during dev time
1938
- if (BUILD.isDev) {
1939
- const ref = getHostRef(this);
1940
- if (
1941
- // we are proxying the instance (not element)
1942
- (flags & 1 /* isElementConstructor */) === 0 &&
1943
- // the element is not constructing
1944
- (ref.$flags$ & 8 /* isConstructingInstance */) === 0 &&
1945
- // the member is a prop
1946
- (memberFlags & 31 /* Prop */) !== 0 &&
1947
- // the member is not mutable
1948
- (memberFlags & 1024 /* Mutable */) === 0) {
1949
- consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
1950
- }
1951
- }
1952
- // proxyComponent, set value
1953
- setValue(this, memberName, newValue, cmpMeta);
1954
- },
1955
- configurable: true,
1956
- enumerable: true,
1957
- });
1958
- }
1959
- else if (BUILD.lazyLoad &&
1960
- BUILD.method &&
1961
- flags & 1 /* isElementConstructor */ &&
1962
- memberFlags & 64 /* Method */) {
1963
- // proxyComponent - method
1964
- Object.defineProperty(prototype, memberName, {
1965
- value(...args) {
1966
- const ref = getHostRef(this);
1967
- return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1968
- },
1969
- });
1970
- }
1971
- });
1972
- if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
1973
- const attrNameToPropName = new Map();
1974
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1975
- plt.jmp(() => {
1976
- const propName = attrNameToPropName.get(attrName);
1977
- // In a webcomponent lifecyle the attributeChangedCallback runs prior to connectedCallback
1978
- // in the case where an attribute was set inline.
1979
- // ```html
1980
- // <my-component some-attribute="some-value"></my-component>
1981
- // ```
1982
- //
1983
- // There is an edge case where a developer sets the attribute inline on a custom element and then programatically
1984
- // changes it before it has been upgraded as shown below:
1985
- //
1986
- // ```html
1987
- // <!-- this component has _not_ been upgraded yet -->
1988
- // <my-component id="test" some-attribute="some-value"></my-component>
1989
- // <script>
1990
- // // grab non-upgraded component
1991
- // el = document.querySelector("#test");
1992
- // el.someAttribute = "another-value";
1993
- // // upgrade component
1994
- // cutsomElements.define('my-component', MyComponent);
1995
- // </script>
1996
- // ```
1997
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1998
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1999
- // to the value that was set inline i.e. "some-value" from above example. When
2000
- // the connectedCallback attempts to unshadow it will use "some-value" as the intial value rather than "another-value"
2001
- //
2002
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
2003
- // by connectedCallback as this attributeChangedCallback will not fire.
2004
- //
2005
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2006
- //
2007
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2008
- // properties here given that this goes against best practices outlined here
2009
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2010
- if (this.hasOwnProperty(propName)) {
2011
- newValue = this[propName];
2012
- delete this[propName];
2013
- }
2014
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2015
- });
2016
- };
2017
- // create an array of attributes to observe
2018
- // and also create a map of html attribute name to js property name
2019
- Cstr.observedAttributes = members
2020
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
2021
- .map(([propName, m]) => {
2022
- const attrName = m[1] || propName;
2023
- attrNameToPropName.set(attrName, propName);
2024
- if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
2025
- cmpMeta.$attrsToReflect$.push([propName, attrName]);
2026
- }
2027
- return attrName;
2028
- });
2029
- }
2030
- }
2031
- return Cstr;
2032
- };
2033
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2034
- // initializeComponent
2035
- if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2036
- (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2037
- if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2038
- // we haven't initialized this element yet
2039
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2040
- // lazy loaded components
2041
- // request the component's implementation to be
2042
- // wired up with the host element
2043
- Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2044
- if (Cstr.then) {
2045
- // Await creates a micro-task avoid if possible
2046
- const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
2047
- Cstr = await Cstr;
2048
- endLoad();
2049
- }
2050
- if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2051
- throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2052
- }
2053
- if (BUILD.member && !Cstr.isProxied) {
2054
- // we've never proxied this Constructor before
2055
- // let's add the getters/setters to its prototype before
2056
- // the first time we create an instance of the implementation
2057
- if (BUILD.watchCallback) {
2058
- cmpMeta.$watchers$ = Cstr.watchers;
2059
- }
2060
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2061
- Cstr.isProxied = true;
2062
- }
2063
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2064
- // ok, time to construct the instance
2065
- // but let's keep track of when we start and stop
2066
- // so that the getters/setters don't incorrectly step on data
2067
- if (BUILD.member) {
2068
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
2069
- }
2070
- // construct the lazy-loaded component implementation
2071
- // passing the hostRef is very important during
2072
- // construction in order to directly wire together the
2073
- // host element and the lazy-loaded instance
2074
- try {
2075
- new Cstr(hostRef);
2076
- }
2077
- catch (e) {
2078
- consoleError(e);
2079
- }
2080
- if (BUILD.member) {
2081
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2082
- }
2083
- if (BUILD.watchCallback) {
2084
- hostRef.$flags$ |= 128 /* isWatchReady */;
2085
- }
2086
- endNewInstance();
2087
- fireConnectedCallback(hostRef.$lazyInstance$);
2088
- }
2089
- else {
2090
- // sync constructor component
2091
- Cstr = elm.constructor;
2092
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2093
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2094
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2095
- // Stencil has completed instantiating the component.
2096
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* isWatchReady */));
2097
- }
2098
- if (BUILD.style && Cstr.style) {
2099
- // this component has styles but we haven't registered them yet
2100
- let style = Cstr.style;
2101
- if (BUILD.mode && typeof style !== 'string') {
2102
- style = style[(hostRef.$modeName$ = computeMode(elm))];
2103
- if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2104
- elm.setAttribute('s-mode', hostRef.$modeName$);
2105
- }
2106
- }
2107
- const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2108
- if (!styles.has(scopeId)) {
2109
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2110
- if (!BUILD.hydrateServerSide &&
2111
- BUILD.shadowDom &&
2112
- BUILD.shadowDomShim &&
2113
- cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2114
- style = await Promise.resolve().then(function () { return require('./shadow-css-4bfd7bfa.js'); }).then((m) => m.scopeCss(style, scopeId, false));
2115
- }
2116
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2117
- endRegisterStyles();
2118
- }
2119
- }
2120
- }
2121
- // we've successfully created a lazy instance
2122
- const ancestorComponent = hostRef.$ancestorComponent$;
2123
- const schedule = () => scheduleUpdate(hostRef, true);
2124
- if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2125
- // this is the intial load and this component it has an ancestor component
2126
- // but the ancestor component has NOT fired its will update lifecycle yet
2127
- // so let's just cool our jets and wait for the ancestor to continue first
2128
- // this will get fired off when the ancestor component
2129
- // finally gets around to rendering its lazy self
2130
- // fire off the initial update
2131
- ancestorComponent['s-rc'].push(schedule);
2132
- }
2133
- else {
2134
- schedule();
2135
- }
2136
- };
2137
- const fireConnectedCallback = (instance) => {
2138
- if (BUILD.lazyLoad && BUILD.connectedCallback) {
2139
- safeCall(instance, 'connectedCallback');
2140
- }
2141
- };
2142
- const connectedCallback = (elm) => {
2143
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2144
- const hostRef = getHostRef(elm);
2145
- const cmpMeta = hostRef.$cmpMeta$;
2146
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2147
- if (BUILD.hostListenerTargetParent) {
2148
- // only run if we have listeners being attached to a parent
2149
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2150
- }
2151
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2152
- // first time this component has connected
2153
- hostRef.$flags$ |= 1 /* hasConnected */;
2154
- let hostId;
2155
- if (BUILD.hydrateClientSide) {
2156
- hostId = elm.getAttribute(HYDRATE_ID);
2157
- if (hostId) {
2158
- if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2159
- const scopeId = BUILD.mode
2160
- ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2161
- : addStyle(elm.shadowRoot, cmpMeta);
2162
- elm.classList.remove(scopeId + '-h', scopeId + '-s');
2163
- }
2164
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2165
- }
2166
- }
2167
- if (BUILD.slotRelocation && !hostId) {
2168
- // initUpdate
2169
- // if the slot polyfill is required we'll need to put some nodes
2170
- // in here to act as original content anchors as we move nodes around
2171
- // host element has been connected to the DOM
2172
- if (BUILD.hydrateServerSide ||
2173
- ((BUILD.slot || BUILD.shadowDom) &&
2174
- cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
2175
- setContentReference(elm);
2176
- }
2177
- }
2178
- if (BUILD.asyncLoading) {
2179
- // find the first ancestor component (if there is one) and register
2180
- // this component as one of the actively loading child components for its ancestor
2181
- let ancestorComponent = elm;
2182
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2183
- // climb up the ancestors looking for the first
2184
- // component that hasn't finished its lifecycle update yet
2185
- if ((BUILD.hydrateClientSide &&
2186
- ancestorComponent.nodeType === 1 /* ElementNode */ &&
2187
- ancestorComponent.hasAttribute('s-id') &&
2188
- ancestorComponent['s-p']) ||
2189
- ancestorComponent['s-p']) {
2190
- // we found this components first ancestor component
2191
- // keep a reference to this component's ancestor component
2192
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2193
- break;
2194
- }
2195
- }
2196
- }
2197
- // Lazy properties
2198
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2199
- if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2200
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2201
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2202
- const value = elm[memberName];
2203
- delete elm[memberName];
2204
- elm[memberName] = value;
2205
- }
2206
- });
2207
- }
2208
- if (BUILD.initializeNextTick) {
2209
- // connectedCallback, taskQueue, initialLoad
2210
- // angular sets attribute AFTER connectCallback
2211
- // https://github.com/angular/angular/issues/18909
2212
- // https://github.com/angular/angular/issues/19940
2213
- nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2214
- }
2215
- else {
2216
- initializeComponent(elm, hostRef, cmpMeta);
2217
- }
2218
- }
2219
- else {
2220
- // not the first time this has connected
2221
- // reattach any event listeners to the host
2222
- // since they would have been removed when disconnected
2223
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2224
- // fire off connectedCallback() on component instance
2225
- fireConnectedCallback(hostRef.$lazyInstance$);
2226
- }
2227
- endConnected();
2228
- }
2229
- };
2230
- const setContentReference = (elm) => {
2231
- // only required when we're NOT using native shadow dom (slot)
2232
- // or this browser doesn't support native shadow dom
2233
- // and this host element was NOT created with SSR
2234
- // let's pick out the inner content for slot projection
2235
- // create a node to represent where the original
2236
- // content was first placed, which is useful later on
2237
- const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2238
- contentRefElm['s-cn'] = true;
2239
- elm.insertBefore(contentRefElm, elm.firstChild);
2240
- };
2241
- const disconnectedCallback = (elm) => {
2242
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2243
- const hostRef = getHostRef(elm);
2244
- const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2245
- if (BUILD.hostListener) {
2246
- if (hostRef.$rmListeners$) {
2247
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2248
- hostRef.$rmListeners$ = undefined;
2249
- }
2250
- }
2251
- // clear CSS var-shim tracking
2252
- if (BUILD.cssVarShim && plt.$cssShim$) {
2253
- plt.$cssShim$.removeHost(elm);
2254
- }
2255
- if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2256
- safeCall(instance, 'disconnectedCallback');
2257
- }
2258
- if (BUILD.cmpDidUnload) {
2259
- safeCall(instance, 'componentDidUnload');
2260
- }
2261
- }
2262
- };
2263
- const defineCustomElement = (Cstr, compactMeta) => {
2264
- customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2265
- };
2266
- const proxyCustomElement = (Cstr, compactMeta) => {
2267
- const cmpMeta = {
2268
- $flags$: compactMeta[0],
2269
- $tagName$: compactMeta[1],
2270
- };
2271
- if (BUILD.member) {
2272
- cmpMeta.$members$ = compactMeta[2];
2273
- }
2274
- if (BUILD.hostListener) {
2275
- cmpMeta.$listeners$ = compactMeta[3];
2276
- }
2277
- if (BUILD.watchCallback) {
2278
- cmpMeta.$watchers$ = Cstr.$watchers$;
2279
- }
2280
- if (BUILD.reflect) {
2281
- cmpMeta.$attrsToReflect$ = [];
2282
- }
2283
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2284
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2285
- }
2286
- const originalConnectedCallback = Cstr.prototype.connectedCallback;
2287
- const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2288
- Object.assign(Cstr.prototype, {
2289
- __registerHost() {
2290
- registerHost(this, cmpMeta);
2291
- },
2292
- connectedCallback() {
2293
- connectedCallback(this);
2294
- if (BUILD.connectedCallback && originalConnectedCallback) {
2295
- originalConnectedCallback.call(this);
2296
- }
2297
- },
2298
- disconnectedCallback() {
2299
- disconnectedCallback(this);
2300
- if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2301
- originalDisconnectedCallback.call(this);
2302
- }
2303
- },
2304
- });
2305
- Cstr.is = cmpMeta.$tagName$;
2306
- return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2307
- };
2308
- const forceModeUpdate = (elm) => {
2309
- if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2310
- const mode = computeMode(elm);
2311
- const hostRef = getHostRef(elm);
2312
- if (hostRef.$modeName$ !== mode) {
2313
- const cmpMeta = hostRef.$cmpMeta$;
2314
- const oldScopeId = elm['s-sc'];
2315
- const scopeId = getScopeId(cmpMeta, mode);
2316
- const style = elm.constructor.style[mode];
2317
- const flags = cmpMeta.$flags$;
2318
- if (style) {
2319
- if (!styles.has(scopeId)) {
2320
- registerStyle(scopeId, style, !!(flags & 1 /* shadowDomEncapsulation */));
2321
- }
2322
- hostRef.$modeName$ = mode;
2323
- elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2324
- attachStyles(hostRef);
2325
- forceUpdate(elm);
2326
- }
2327
- }
2328
- }
2329
- };
2330
- const attachShadow = (el) => {
2331
- if (supportsShadow) {
2332
- el.attachShadow({ mode: 'open' });
2333
- }
2334
- else {
2335
- el.shadowRoot = el;
2336
- }
2337
- };
2338
- const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2339
- // ¯\_(ツ)_/¯
2340
- const hostRef = getHostRef(elm);
2341
- // reset state flags to only have been connected
2342
- hostRef.$flags$ = 1 /* hasConnected */;
2343
- // TODO
2344
- // detatch any event listeners that may have been added
2345
- // because we're not passing an exact event name it'll
2346
- // remove all of this element's event, which is good
2347
- // create a callback for when this component finishes hmr
2348
- elm['s-hmr-load'] = () => {
2349
- // finished hmr for this element
2350
- delete elm['s-hmr-load'];
2351
- };
2352
- // re-initialize the component
2353
- initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2354
- };
2355
- const patchCloneNode = (HostElementPrototype) => {
2356
- const orgCloneNode = HostElementPrototype.cloneNode;
2357
- HostElementPrototype.cloneNode = function (deep) {
2358
- const srcNode = this;
2359
- const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2360
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2361
- if (BUILD.slot && !isShadowDom && deep) {
2362
- let i = 0;
2363
- let slotted, nonStencilNode;
2364
- let stencilPrivates = [
2365
- 's-id',
2366
- 's-cr',
2367
- 's-lr',
2368
- 's-rc',
2369
- 's-sc',
2370
- 's-p',
2371
- 's-cn',
2372
- 's-sr',
2373
- 's-sn',
2374
- 's-hn',
2375
- 's-ol',
2376
- 's-nr',
2377
- 's-si',
2378
- ];
2379
- for (; i < srcNode.childNodes.length; i++) {
2380
- slotted = srcNode.childNodes[i]['s-nr'];
2381
- nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2382
- if (slotted) {
2383
- if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2384
- clonedNode.__appendChild(slotted.cloneNode(true));
2385
- }
2386
- else {
2387
- clonedNode.appendChild(slotted.cloneNode(true));
2388
- }
2389
- }
2390
- if (nonStencilNode) {
2391
- clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2392
- }
2393
- }
2394
- }
2395
- return clonedNode;
2396
- };
2397
- };
2398
- const patchSlotAppendChild = (HostElementPrototype) => {
2399
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2400
- HostElementPrototype.appendChild = function (newChild) {
2401
- const slotName = (newChild['s-sn'] = getSlotName(newChild));
2402
- const slotNode = getHostSlotNode(this.childNodes, slotName);
2403
- if (slotNode) {
2404
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2405
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2406
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2407
- }
2408
- return this.__appendChild(newChild);
2409
- };
2410
- };
2411
- /**
2412
- * Patches the text content of an unnamed slotted node inside a scoped component
2413
- * @param hostElementPrototype the `Element` to be patched
2414
- * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2415
- */
2416
- const patchTextContent = (hostElementPrototype, cmpMeta) => {
2417
- if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2418
- const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2419
- Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2420
- Object.defineProperty(hostElementPrototype, 'textContent', {
2421
- get() {
2422
- var _a;
2423
- // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2424
- // the empty string
2425
- const slotNode = getHostSlotNode(this.childNodes, '');
2426
- // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2427
- // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2428
- if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2429
- return slotNode.nextSibling.textContent;
2430
- }
2431
- else if (slotNode) {
2432
- return slotNode.textContent;
2433
- }
2434
- else {
2435
- // fallback to the original implementation
2436
- return this.__textContent;
2437
- }
2438
- },
2439
- set(value) {
2440
- var _a;
2441
- // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2442
- // the empty string
2443
- const slotNode = getHostSlotNode(this.childNodes, '');
2444
- // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2445
- // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2446
- // sibling.
2447
- if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2448
- slotNode.nextSibling.textContent = value;
2449
- }
2450
- else if (slotNode) {
2451
- slotNode.textContent = value;
2452
- }
2453
- else {
2454
- // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2455
- // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2456
- // it there
2457
- this.__textContent = value;
2458
- const contentRefElm = this['s-cr'];
2459
- if (contentRefElm) {
2460
- this.insertBefore(contentRefElm, this.firstChild);
2461
- }
2462
- }
2463
- },
2464
- });
2465
- }
2466
- };
2467
- const patchChildSlotNodes = (elm, cmpMeta) => {
2468
- class FakeNodeList extends Array {
2469
- item(n) {
2470
- return this[n];
2471
- }
2472
- }
2473
- if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2474
- const childNodesFn = elm.__lookupGetter__('childNodes');
2475
- Object.defineProperty(elm, 'children', {
2476
- get() {
2477
- return this.childNodes.map((n) => n.nodeType === 1);
2478
- },
2479
- });
2480
- Object.defineProperty(elm, 'childElementCount', {
2481
- get() {
2482
- return elm.children.length;
2483
- },
2484
- });
2485
- Object.defineProperty(elm, 'childNodes', {
2486
- get() {
2487
- const childNodes = childNodesFn.call(this);
2488
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 &&
2489
- getHostRef(this).$flags$ & 2 /* hasRendered */) {
2490
- const result = new FakeNodeList();
2491
- for (let i = 0; i < childNodes.length; i++) {
2492
- const slot = childNodes[i]['s-nr'];
2493
- if (slot) {
2494
- result.push(slot);
2495
- }
2496
- }
2497
- return result;
2498
- }
2499
- return FakeNodeList.from(childNodes);
2500
- },
2501
- });
2502
- }
2503
- };
2504
- const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2505
- /**
2506
- * Recursively searches a series of child nodes for a slot with the provided name.
2507
- * @param childNodes the nodes to search for a slot with a specific name.
2508
- * @param slotName the name of the slot to match on.
2509
- * @returns a reference to the slot node that matches the provided name, `null` otherwise
2510
- */
2511
- const getHostSlotNode = (childNodes, slotName) => {
2512
- let i = 0;
2513
- let childNode;
2514
- for (; i < childNodes.length; i++) {
2515
- childNode = childNodes[i];
2516
- if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2517
- return childNode;
2518
- }
2519
- childNode = getHostSlotNode(childNode.childNodes, slotName);
2520
- if (childNode) {
2521
- return childNode;
2522
- }
2523
- }
2524
- return null;
2525
- };
2526
- const getHostSlotChildNodes = (n, slotName) => {
2527
- const childNodes = [n];
2528
- while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2529
- childNodes.push(n);
2530
- }
2531
- return childNodes;
2532
- };
2533
- const bootstrapLazy = (lazyBundles, options = {}) => {
2534
- if (BUILD.profile && performance.mark) {
2535
- performance.mark('st:app:start');
2536
- }
2537
- installDevTools();
2538
- const endBootstrap = createTime('bootstrapLazy');
2539
- const cmpTags = [];
2540
- const exclude = options.exclude || [];
2541
- const customElements = win.customElements;
2542
- const head = doc.head;
2543
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2544
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2545
- const deferredConnectedCallbacks = [];
2546
- const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2547
- let appLoadFallback;
2548
- let isBootstrapping = true;
2549
- let i = 0;
2550
- Object.assign(plt, options);
2551
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2552
- if (BUILD.asyncQueue) {
2553
- if (options.syncQueue) {
2554
- plt.$flags$ |= 4 /* queueSync */;
2555
- }
2556
- }
2557
- if (BUILD.hydrateClientSide) {
2558
- // If the app is already hydrated there is not point to disable the
2559
- // async queue. This will improve the first input delay
2560
- plt.$flags$ |= 2 /* appLoaded */;
2561
- }
2562
- if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2563
- for (; i < styles.length; i++) {
2564
- registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2565
- }
2566
- }
2567
- lazyBundles.map((lazyBundle) => lazyBundle[1].map((compactMeta) => {
2568
- const cmpMeta = {
2569
- $flags$: compactMeta[0],
2570
- $tagName$: compactMeta[1],
2571
- $members$: compactMeta[2],
2572
- $listeners$: compactMeta[3],
2573
- };
2574
- if (BUILD.member) {
2575
- cmpMeta.$members$ = compactMeta[2];
2576
- }
2577
- if (BUILD.hostListener) {
2578
- cmpMeta.$listeners$ = compactMeta[3];
2579
- }
2580
- if (BUILD.reflect) {
2581
- cmpMeta.$attrsToReflect$ = [];
2582
- }
2583
- if (BUILD.watchCallback) {
2584
- cmpMeta.$watchers$ = {};
2585
- }
2586
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2587
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2588
- }
2589
- const tagName = BUILD.transformTagName && options.transformTagName
2590
- ? options.transformTagName(cmpMeta.$tagName$)
2591
- : cmpMeta.$tagName$;
2592
- const HostElement = class extends HTMLElement {
2593
- // StencilLazyHost
2594
- constructor(self) {
2595
- // @ts-ignore
2596
- super(self);
2597
- self = this;
2598
- registerHost(self, cmpMeta);
2599
- if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2600
- // this component is using shadow dom
2601
- // and this browser supports shadow dom
2602
- // add the read-only property "shadowRoot" to the host element
2603
- // adding the shadow root build conditionals to minimize runtime
2604
- if (supportsShadow) {
2605
- if (BUILD.shadowDelegatesFocus) {
2606
- self.attachShadow({
2607
- mode: 'open',
2608
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2609
- });
2610
- }
2611
- else {
2612
- self.attachShadow({ mode: 'open' });
2613
- }
2614
- }
2615
- else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2616
- self.shadowRoot = self;
2617
- }
2618
- }
2619
- if (BUILD.slotChildNodesFix) {
2620
- patchChildSlotNodes(self, cmpMeta);
2621
- }
2622
- }
2623
- connectedCallback() {
2624
- if (appLoadFallback) {
2625
- clearTimeout(appLoadFallback);
2626
- appLoadFallback = null;
2627
- }
2628
- if (isBootstrapping) {
2629
- // connectedCallback will be processed once all components have been registered
2630
- deferredConnectedCallbacks.push(this);
2631
- }
2632
- else {
2633
- plt.jmp(() => connectedCallback(this));
2634
- }
2635
- }
2636
- disconnectedCallback() {
2637
- plt.jmp(() => disconnectedCallback(this));
2638
- }
2639
- componentOnReady() {
2640
- return getHostRef(this).$onReadyPromise$;
2641
- }
2642
- };
2643
- if (BUILD.cloneNodeFix) {
2644
- patchCloneNode(HostElement.prototype);
2645
- }
2646
- if (BUILD.appendChildSlotFix) {
2647
- patchSlotAppendChild(HostElement.prototype);
2648
- }
2649
- if (BUILD.hotModuleReplacement) {
2650
- HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2651
- hmrStart(this, cmpMeta, hmrVersionId);
2652
- };
2653
- }
2654
- if (BUILD.scopedSlotTextContentFix) {
2655
- patchTextContent(HostElement.prototype, cmpMeta);
2656
- }
2657
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2658
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2659
- cmpTags.push(tagName);
2660
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
2661
- }
2662
- }));
2663
- if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2664
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2665
- visibilityStyle.setAttribute('data-styles', '');
2666
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2667
- }
2668
- // Process deferred connectedCallbacks now all components have been registered
2669
- isBootstrapping = false;
2670
- if (deferredConnectedCallbacks.length) {
2671
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2672
- }
2673
- else {
2674
- if (BUILD.profile) {
2675
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2676
- }
2677
- else {
2678
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2679
- }
2680
- }
2681
- // Fallback appLoad event
2682
- endBootstrap();
2683
- };
2684
- const getAssetPath = (path) => {
2685
- const assetUrl = new URL(path, plt.$resourcesUrl$);
2686
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
2687
- };
2688
- const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
2689
- const getConnect = (_ref, tagName) => {
2690
- const componentOnReady = () => {
2691
- let elm = doc.querySelector(tagName);
2692
- if (!elm) {
2693
- elm = doc.createElement(tagName);
2694
- doc.body.appendChild(elm);
2695
- }
2696
- return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2697
- };
2698
- const create = (...args) => {
2699
- return componentOnReady().then((el) => el.create(...args));
2700
- };
2701
- return {
2702
- create,
2703
- componentOnReady,
2704
- };
2705
- };
2706
- const getContext = (_elm, context) => {
2707
- if (context in Context) {
2708
- return Context[context];
2709
- }
2710
- else if (context === 'window') {
2711
- return win;
2712
- }
2713
- else if (context === 'document') {
2714
- return doc;
2715
- }
2716
- else if (context === 'isServer' || context === 'isPrerender') {
2717
- return BUILD.hydrateServerSide ? true : false;
2718
- }
2719
- else if (context === 'isClient') {
2720
- return BUILD.hydrateServerSide ? false : true;
2721
- }
2722
- else if (context === 'resourcesUrl' || context === 'publicPath') {
2723
- return getAssetPath('.');
2724
- }
2725
- else if (context === 'queue') {
2726
- return {
2727
- write: writeTask,
2728
- read: readTask,
2729
- tick: {
2730
- then(cb) {
2731
- return nextTick(cb);
2732
- },
2733
- },
2734
- };
2735
- }
2736
- return undefined;
2737
- };
2738
- const insertVdomAnnotations = (doc, staticComponents) => {
2739
- if (doc != null) {
2740
- const docData = {
2741
- hostIds: 0,
2742
- rootLevelIds: 0,
2743
- staticComponents: new Set(staticComponents),
2744
- };
2745
- const orgLocationNodes = [];
2746
- parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
2747
- orgLocationNodes.forEach((orgLocationNode) => {
2748
- if (orgLocationNode != null) {
2749
- const nodeRef = orgLocationNode['s-nr'];
2750
- let hostId = nodeRef['s-host-id'];
2751
- let nodeId = nodeRef['s-node-id'];
2752
- let childId = `${hostId}.${nodeId}`;
2753
- if (hostId == null) {
2754
- hostId = 0;
2755
- docData.rootLevelIds++;
2756
- nodeId = docData.rootLevelIds;
2757
- childId = `${hostId}.${nodeId}`;
2758
- if (nodeRef.nodeType === 1 /* ElementNode */) {
2759
- nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2760
- }
2761
- else if (nodeRef.nodeType === 3 /* TextNode */) {
2762
- if (hostId === 0) {
2763
- const textContent = nodeRef.nodeValue.trim();
2764
- if (textContent === '') {
2765
- // useless whitespace node at the document root
2766
- orgLocationNode.remove();
2767
- return;
2768
- }
2769
- }
2770
- const commentBeforeTextNode = doc.createComment(childId);
2771
- commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2772
- nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
2773
- }
2774
- }
2775
- let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2776
- const orgLocationParentNode = orgLocationNode.parentElement;
2777
- if (orgLocationParentNode) {
2778
- if (orgLocationParentNode['s-en'] === '') {
2779
- // ending with a "." means that the parent element
2780
- // of this node's original location is a SHADOW dom element
2781
- // and this node is apart of the root level light dom
2782
- orgLocationNodeId += `.`;
2783
- }
2784
- else if (orgLocationParentNode['s-en'] === 'c') {
2785
- // ending with a ".c" means that the parent element
2786
- // of this node's original location is a SCOPED element
2787
- // and this node is apart of the root level light dom
2788
- orgLocationNodeId += `.c`;
2789
- }
2790
- }
2791
- orgLocationNode.nodeValue = orgLocationNodeId;
2792
- }
2793
- });
2794
- }
2795
- };
2796
- const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2797
- if (node == null) {
2798
- return;
2799
- }
2800
- if (node['s-nr'] != null) {
2801
- orgLocationNodes.push(node);
2802
- }
2803
- if (node.nodeType === 1 /* ElementNode */) {
2804
- node.childNodes.forEach((childNode) => {
2805
- const hostRef = getHostRef(childNode);
2806
- if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2807
- const cmpData = {
2808
- nodeIds: 0,
2809
- };
2810
- insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
2811
- }
2812
- parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
2813
- });
2814
- }
2815
- };
2816
- const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2817
- if (vnode != null) {
2818
- const hostId = ++docData.hostIds;
2819
- hostElm.setAttribute(HYDRATE_ID, hostId);
2820
- if (hostElm['s-cr'] != null) {
2821
- hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2822
- }
2823
- if (vnode.$children$ != null) {
2824
- const depth = 0;
2825
- vnode.$children$.forEach((vnodeChild, index) => {
2826
- insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
2827
- });
2828
- }
2829
- if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
2830
- const parent = hostElm.parentElement;
2831
- if (parent && parent.childNodes) {
2832
- const parentChildNodes = Array.from(parent.childNodes);
2833
- const comment = parentChildNodes.find((node) => node.nodeType === 8 /* CommentNode */ && node['s-sr']);
2834
- if (comment) {
2835
- const index = parentChildNodes.indexOf(hostElm) - 1;
2836
- vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
2837
- }
2838
- }
2839
- }
2840
- }
2841
- };
2842
- const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
2843
- const childElm = vnodeChild.$elm$;
2844
- if (childElm == null) {
2845
- return;
2846
- }
2847
- const nodeId = cmpData.nodeIds++;
2848
- const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2849
- childElm['s-host-id'] = hostId;
2850
- childElm['s-node-id'] = nodeId;
2851
- if (childElm.nodeType === 1 /* ElementNode */) {
2852
- childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2853
- }
2854
- else if (childElm.nodeType === 3 /* TextNode */) {
2855
- const parentNode = childElm.parentNode;
2856
- const nodeName = parentNode.nodeName;
2857
- if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
2858
- const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2859
- const commentBeforeTextNode = doc.createComment(textNodeId);
2860
- parentNode.insertBefore(commentBeforeTextNode, childElm);
2861
- }
2862
- }
2863
- else if (childElm.nodeType === 8 /* CommentNode */) {
2864
- if (childElm['s-sr']) {
2865
- const slotName = childElm['s-sn'] || '';
2866
- const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
2867
- childElm.nodeValue = slotNodeId;
2868
- }
2869
- }
2870
- if (vnodeChild.$children$ != null) {
2871
- const childDepth = depth + 1;
2872
- vnodeChild.$children$.forEach((vnode, index) => {
2873
- insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
2874
- });
2875
- }
2876
- };
2877
- const setPlatformOptions = (opts) => Object.assign(plt, opts);
2878
- const Fragment = (_, children) => children;
2879
- const hostRefs = new WeakMap();
2880
- const getHostRef = (ref) => hostRefs.get(ref);
2881
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2882
- const registerHost = (elm, cmpMeta) => {
2883
- const hostRef = {
2884
- $flags$: 0,
2885
- $hostElement$: elm,
2886
- $cmpMeta$: cmpMeta,
2887
- $instanceValues$: new Map(),
2888
- };
2889
- if (BUILD.isDev) {
2890
- hostRef.$renderCount$ = 0;
2891
- }
2892
- if (BUILD.method && BUILD.lazyLoad) {
2893
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2894
- }
2895
- if (BUILD.asyncLoading) {
2896
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2897
- elm['s-p'] = [];
2898
- elm['s-rc'] = [];
2899
- }
2900
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2901
- return hostRefs.set(elm, hostRef);
2902
- };
2903
- const isMemberInElement = (elm, memberName) => memberName in elm;
2904
- const consoleError = (e, el) => (customError || console.error)(e, el);
2905
- const STENCIL_DEV_MODE = BUILD.isTesting
2906
- ? ['STENCIL:'] // E2E testing
2907
- : [
2908
- '%cstencil',
2909
- 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
2910
- ];
2911
- const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
2912
- const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
2913
- const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
2914
- const setErrorHandler = (handler) => (customError = handler);
2915
- const cmpModules = /*@__PURE__*/ new Map();
2916
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2917
- // loadModuleImport
2918
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2919
- const bundleId = cmpMeta.$lazyBundleId$;
2920
- if (BUILD.isDev && typeof bundleId !== 'string') {
2921
- consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
2922
- return undefined;
2923
- }
2924
- const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
2925
- if (module) {
2926
- return module[exportName];
2927
- }
2928
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2929
- /* webpackInclude: /\.entry\.js$/ */
2930
- /* webpackExclude: /\.system\.entry\.js$/ */
2931
- /* webpackMode: "lazy" */
2932
- `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then((importedModule) => {
2933
- if (!BUILD.hotModuleReplacement) {
2934
- cmpModules.set(bundleId, importedModule);
2935
- }
2936
- return importedModule[exportName];
2937
- }, consoleError);
2938
- };
2939
- const styles = new Map();
2940
- const modeResolutionChain = [];
2941
- const queueDomReads = [];
2942
- const queueDomWrites = [];
2943
- const queueDomWritesLow = [];
2944
- const queueTask = (queue, write) => (cb) => {
2945
- queue.push(cb);
2946
- if (!queuePending) {
2947
- queuePending = true;
2948
- if (write && plt.$flags$ & 4 /* queueSync */) {
2949
- nextTick(flush);
2950
- }
2951
- else {
2952
- plt.raf(flush);
2953
- }
2954
- }
2955
- };
2956
- const consume = (queue) => {
2957
- for (let i = 0; i < queue.length; i++) {
2958
- try {
2959
- queue[i](performance.now());
2960
- }
2961
- catch (e) {
2962
- consoleError(e);
2963
- }
2964
- }
2965
- queue.length = 0;
2966
- };
2967
- const consumeTimeout = (queue, timeout) => {
2968
- let i = 0;
2969
- let ts = 0;
2970
- while (i < queue.length && (ts = performance.now()) < timeout) {
2971
- try {
2972
- queue[i++](ts);
2973
- }
2974
- catch (e) {
2975
- consoleError(e);
2976
- }
2977
- }
2978
- if (i === queue.length) {
2979
- queue.length = 0;
2980
- }
2981
- else if (i !== 0) {
2982
- queue.splice(0, i);
2983
- }
2984
- };
2985
- const flush = () => {
2986
- if (BUILD.asyncQueue) {
2987
- queueCongestion++;
2988
- }
2989
- // always force a bunch of medium callbacks to run, but still have
2990
- // a throttle on how many can run in a certain time
2991
- // DOM READS!!!
2992
- consume(queueDomReads);
2993
- // DOM WRITES!!!
2994
- if (BUILD.asyncQueue) {
2995
- const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
2996
- ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
2997
- : Infinity;
2998
- consumeTimeout(queueDomWrites, timeout);
2999
- consumeTimeout(queueDomWritesLow, timeout);
3000
- if (queueDomWrites.length > 0) {
3001
- queueDomWritesLow.push(...queueDomWrites);
3002
- queueDomWrites.length = 0;
3003
- }
3004
- if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3005
- // still more to do yet, but we've run out of time
3006
- // let's let this thing cool off and try again in the next tick
3007
- plt.raf(flush);
3008
- }
3009
- else {
3010
- queueCongestion = 0;
3011
- }
3012
- }
3013
- else {
3014
- consume(queueDomWrites);
3015
- if ((queuePending = queueDomReads.length > 0)) {
3016
- // still more to do yet, but we've run out of time
3017
- // let's let this thing cool off and try again in the next tick
3018
- plt.raf(flush);
3019
- }
3020
- }
3021
- };
3022
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3023
- const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3024
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3025
- const Build = {
3026
- isDev: BUILD.isDev ? true : false,
3027
- isBrowser: true,
3028
- isServer: false,
3029
- isTesting: BUILD.isTesting ? true : false,
3030
- };
3031
-
3032
- exports.BUILD = BUILD;
3033
- exports.CSS = CSS;
3034
- exports.H = H;
3035
- exports.Host = Host;
3036
- exports.NAMESPACE = NAMESPACE;
3037
- exports.bootstrapLazy = bootstrapLazy;
3038
- exports.consoleDevInfo = consoleDevInfo;
3039
- exports.createEvent = createEvent;
3040
- exports.doc = doc;
3041
- exports.getElement = getElement;
3042
- exports.h = h;
3043
- exports.plt = plt;
3044
- exports.promiseResolve = promiseResolve;
3045
- exports.registerInstance = registerInstance;
3046
- exports.win = win;