@sankhyalabs/sankhyablocks 10.1.0-dev.2 → 10.1.0-dev.20

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 (318) hide show
  1. package/dist/cjs/{ConfigStorage-5a73e979.js → ConfigStorage-a4e1e518.js} +2 -2
  2. package/dist/cjs/{DataFetcher-eeb3b0b7.js → DataFetcher-0b6aa084.js} +34 -24
  3. package/dist/cjs/{FormConfigHelper-ebb77625.js → FormConfigHelper-28fe4668.js} +44 -0
  4. package/dist/cjs/{ISave-861e9d6d.js → ISave-2c455a77.js} +4 -4
  5. package/dist/cjs/{PersonalizedFilterUtils-7259cf65.js → PersonalizedFilterUtils-eccb267a.js} +13 -0
  6. package/dist/cjs/{SnkFormConfigManager-8d4fded8.js → SnkFormConfigManager-b8c81493.js} +7 -7
  7. package/dist/cjs/{SnkMultiSelectionListDataSource-3b93f6a6.js → SnkMultiSelectionListDataSource-03b58f5a.js} +5 -5
  8. package/dist/cjs/{auth-fetcher-8d8acd69.js → auth-fetcher-7e7796c9.js} +1 -1
  9. package/dist/cjs/config-header.cjs.entry.js +1 -1
  10. package/dist/cjs/configs-button.cjs.entry.js +1 -1
  11. package/dist/cjs/css-shim-a27d231b.js +6 -0
  12. package/dist/cjs/{dataunit-fetcher-1cea0695.js → dataunit-fetcher-8dffbcdf.js} +1 -1
  13. package/dist/cjs/dom-ff96a4bc.js +75 -0
  14. package/dist/cjs/field-config_2.cjs.entry.js +3 -3
  15. package/dist/cjs/fields-layout.cjs.entry.js +7 -4
  16. package/dist/cjs/fields-selector.cjs.entry.js +2 -2
  17. package/dist/cjs/{form-config-fetcher-f347f884.js → form-config-fetcher-5516d68a.js} +1 -1
  18. package/dist/cjs/guides-configurator.cjs.entry.js +6 -4
  19. package/dist/cjs/{index-1cf293c1.js → index-1894343a.js} +1515 -171
  20. package/dist/cjs/{index-13d05f03.js → index-f0fe7e6e.js} +90 -21
  21. package/dist/cjs/loader.cjs.js +16 -2
  22. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +5 -5
  23. package/dist/cjs/sankhyablocks.cjs.js +132 -4
  24. package/dist/cjs/shadow-css-7e3e0ab1.js +389 -0
  25. package/dist/cjs/snk-actions-button_9.cjs.entry.js +6 -6
  26. package/dist/cjs/snk-actions-form.cjs.entry.js +1 -1
  27. package/dist/cjs/snk-application.cjs.entry.js +99 -70
  28. package/dist/cjs/snk-attach.cjs.entry.js +8 -8
  29. package/dist/cjs/snk-client-confirm.cjs.entry.js +1 -1
  30. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  31. package/dist/cjs/snk-crud.cjs.entry.js +100 -9
  32. package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-custom-slot-guide.cjs.entry.js +40 -0
  34. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -6
  35. package/dist/cjs/{snk-data-unit-de248308.js → snk-data-unit-036ce58c.js} +12 -3
  36. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -4
  37. package/dist/cjs/snk-default-filter.cjs.entry.js +1 -1
  38. package/dist/cjs/snk-detail-view.cjs.entry.js +10 -10
  39. package/dist/cjs/snk-entity-list.cjs.entry.js +1 -1
  40. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  41. package/dist/cjs/snk-expression-group_2.cjs.entry.js +2 -2
  42. package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +2 -2
  43. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +58 -25
  44. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  45. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  46. package/dist/cjs/snk-filter-detail.cjs.entry.js +2 -2
  47. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +2 -2
  48. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +4 -4
  49. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  50. package/dist/cjs/snk-filter-number.cjs.entry.js +2 -2
  51. package/dist/cjs/snk-filter-period.cjs.entry.js +11 -6
  52. package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
  53. package/dist/cjs/snk-filter-text.cjs.entry.js +2 -2
  54. package/dist/cjs/snk-form-summary.cjs.entry.js +1 -1
  55. package/dist/cjs/snk-form-view.cjs.entry.js +1 -1
  56. package/dist/cjs/snk-form_2.cjs.entry.js +33 -10
  57. package/dist/cjs/snk-grid.cjs.entry.js +28 -19
  58. package/dist/cjs/{snk-guides-viewer-4ec3e7e1.js → snk-guides-viewer-164c063e.js} +86 -40
  59. package/dist/cjs/snk-guides-viewer.cjs.entry.js +10 -10
  60. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
  61. package/dist/cjs/snk-personalized-filter.cjs.entry.js +6 -6
  62. package/dist/cjs/snk-pesquisa.cjs.entry.js +17 -6
  63. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  64. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  65. package/dist/cjs/snk-simple-crud.cjs.entry.js +12 -20
  66. package/dist/cjs/snk-taskbar.cjs.entry.js +67 -51
  67. package/dist/cjs/{taskbar-elements-fb5d1e08.js → taskbar-elements-8a80420e.js} +2 -2
  68. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  69. package/dist/collection/collection-manifest.json +2 -1
  70. package/dist/collection/components/snk-application/search-strategy/exec-prepared-search-advaced-mode.js +27 -0
  71. package/dist/collection/components/snk-application/search-strategy/exec-prepared-search-plus.js +5 -25
  72. package/dist/collection/components/snk-application/snk-application.js +104 -44
  73. package/dist/collection/components/snk-attach/snk-attach.js +1 -1
  74. package/dist/collection/components/snk-crud/snk-crud.js +151 -2
  75. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +133 -34
  76. package/dist/collection/components/snk-custom-slot-guide/snk-custom-slot-guide.css +3 -0
  77. package/dist/collection/components/snk-custom-slot-guide/snk-custom-slot-guide.js +95 -0
  78. package/dist/collection/components/snk-data-unit/snk-data-unit.js +9 -0
  79. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +2 -2
  80. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +11 -6
  81. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +1 -1
  82. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.css +4 -0
  83. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +7 -1
  84. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.css +1 -0
  85. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +15 -4
  86. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +30 -13
  87. package/dist/collection/components/snk-form-config/FormConfigHelper.js +42 -0
  88. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -6
  89. package/dist/collection/components/snk-form-config/field-item/field-config/field-config.css +1 -0
  90. package/dist/collection/components/snk-form-config/fields-layout/fields-layout.css +16 -0
  91. package/dist/collection/components/snk-form-config/fields-layout/fields-layout.js +6 -3
  92. package/dist/collection/components/snk-form-config/guides-configurator/guides-configurator.css +3 -3
  93. package/dist/collection/components/snk-form-config/guides-configurator/guides-configurator.js +5 -3
  94. package/dist/collection/components/snk-form-config/snk-form-config.js +53 -6
  95. package/dist/collection/components/snk-grid/snk-grid.css +12 -0
  96. package/dist/collection/components/snk-grid/snk-grid.js +39 -12
  97. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/utils/PersonalizedFilterUtils.js +13 -0
  98. package/dist/collection/components/snk-pesquisa/snk-pesquisa.css +5 -1
  99. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +43 -0
  100. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +3 -11
  101. package/dist/collection/components/snk-taskbar/snk-taskbar.js +87 -48
  102. package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +3 -3
  103. package/dist/collection/lib/message/SnkMessageBuilder.js +11 -2
  104. package/dist/collection/lib/message/resources/en-us/snk-form.msg.js +7 -0
  105. package/dist/collection/lib/message/resources/es-es/snk-form.msg.js +7 -0
  106. package/dist/collection/lib/message/resources/pt-br/snk-form.msg.js +8 -1
  107. package/dist/collection/lib/message/resources/pt-br/snk-pesquisa.msg.js +1 -1
  108. package/dist/components/DataFetcher.js +34 -4
  109. package/dist/components/ISave.js +3 -3
  110. package/dist/components/PersonalizedFilterUtils.js +13 -0
  111. package/dist/components/SnkFormConfigManager.js +6 -6
  112. package/dist/components/field-config2.js +44 -2
  113. package/dist/components/fields-layout2.js +6 -3
  114. package/dist/components/guides-configurator2.js +5 -3
  115. package/dist/components/index.d.ts +1 -0
  116. package/dist/components/index.js +1 -0
  117. package/dist/components/index2.js +90 -21
  118. package/dist/components/snk-application2.js +93 -63
  119. package/dist/components/snk-attach2.js +1 -1
  120. package/dist/components/snk-crud.js +96 -1
  121. package/dist/components/snk-custom-slot-guide.d.ts +11 -0
  122. package/dist/components/snk-custom-slot-guide.js +55 -0
  123. package/dist/components/snk-data-unit2.js +9 -0
  124. package/dist/components/snk-detail-view2.js +81 -34
  125. package/dist/components/snk-filter-bar2.js +30 -13
  126. package/dist/components/snk-filter-item2.js +8 -2
  127. package/dist/components/snk-filter-modal2.js +16 -6
  128. package/dist/components/snk-filter-number.js +2 -2
  129. package/dist/components/snk-filter-period.js +10 -5
  130. package/dist/components/snk-filter-text.js +1 -1
  131. package/dist/components/snk-form-config2.js +29 -5
  132. package/dist/components/snk-grid2.js +22 -11
  133. package/dist/components/snk-pesquisa2.js +14 -2
  134. package/dist/components/snk-simple-crud2.js +3 -11
  135. package/dist/components/snk-taskbar2.js +66 -49
  136. package/dist/esm/{ConfigStorage-568dc227.js → ConfigStorage-39ac8fef.js} +2 -2
  137. package/dist/esm/{DataFetcher-743feb3b.js → DataFetcher-0b9da57d.js} +34 -4
  138. package/dist/esm/{FormConfigHelper-4e42f0b6.js → FormConfigHelper-d09669f3.js} +43 -1
  139. package/dist/esm/{ISave-345481c1.js → ISave-f1c9269b.js} +4 -4
  140. package/dist/esm/{PersonalizedFilterUtils-2db38ff2.js → PersonalizedFilterUtils-d2439a9a.js} +13 -0
  141. package/dist/esm/{SnkFormConfigManager-d61df0c8.js → SnkFormConfigManager-a87566c8.js} +7 -7
  142. package/dist/esm/{SnkMultiSelectionListDataSource-ca8d7a09.js → SnkMultiSelectionListDataSource-01b3744b.js} +5 -5
  143. package/dist/esm/{auth-fetcher-c353127d.js → auth-fetcher-acdc1cb4.js} +1 -1
  144. package/dist/esm/config-header.entry.js +1 -1
  145. package/dist/esm/configs-button.entry.js +1 -1
  146. package/dist/esm/css-shim-9f2d321e.js +4 -0
  147. package/dist/esm/{dataunit-fetcher-7f2c61ca.js → dataunit-fetcher-4c312b43.js} +1 -1
  148. package/dist/esm/dom-64053c71.js +73 -0
  149. package/dist/esm/field-config_2.entry.js +3 -3
  150. package/dist/esm/fields-layout.entry.js +7 -4
  151. package/dist/esm/fields-selector.entry.js +2 -2
  152. package/dist/esm/{form-config-fetcher-898d2dd1.js → form-config-fetcher-7cda6254.js} +1 -1
  153. package/dist/esm/guides-configurator.entry.js +6 -4
  154. package/dist/esm/{index-479e1293.js → index-04f73a26.js} +1507 -171
  155. package/dist/esm/{index-446f9341.js → index-ea250be6.js} +90 -21
  156. package/dist/esm/loader.js +17 -3
  157. package/dist/esm/pesquisa-grid_2.entry.js +5 -5
  158. package/dist/esm/sankhyablocks.js +133 -5
  159. package/dist/esm/shadow-css-98135883.js +387 -0
  160. package/dist/esm/snk-actions-button_9.entry.js +6 -6
  161. package/dist/esm/snk-actions-form.entry.js +1 -1
  162. package/dist/esm/snk-application.entry.js +99 -70
  163. package/dist/esm/snk-attach.entry.js +8 -8
  164. package/dist/esm/snk-client-confirm.entry.js +1 -1
  165. package/dist/esm/snk-configurator.entry.js +1 -1
  166. package/dist/esm/snk-crud.entry.js +100 -9
  167. package/dist/esm/snk-custom-slot-elements.entry.js +1 -1
  168. package/dist/esm/snk-custom-slot-guide.entry.js +36 -0
  169. package/dist/esm/snk-data-exporter.entry.js +6 -6
  170. package/dist/esm/{snk-data-unit-60b338c5.js → snk-data-unit-130021b3.js} +12 -3
  171. package/dist/esm/snk-data-unit.entry.js +4 -4
  172. package/dist/esm/snk-default-filter.entry.js +1 -1
  173. package/dist/esm/snk-detail-view.entry.js +10 -10
  174. package/dist/esm/snk-entity-list.entry.js +1 -1
  175. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  176. package/dist/esm/snk-expression-group_2.entry.js +2 -2
  177. package/dist/esm/snk-filter-advanced-mode_2.entry.js +2 -2
  178. package/dist/esm/snk-filter-bar_4.entry.js +58 -25
  179. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  180. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  181. package/dist/esm/snk-filter-detail.entry.js +2 -2
  182. package/dist/esm/snk-filter-field-search_2.entry.js +2 -2
  183. package/dist/esm/snk-filter-modal-item.entry.js +4 -4
  184. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  185. package/dist/esm/snk-filter-number.entry.js +2 -2
  186. package/dist/esm/snk-filter-period.entry.js +11 -6
  187. package/dist/esm/snk-filter-search.entry.js +1 -1
  188. package/dist/esm/snk-filter-text.entry.js +2 -2
  189. package/dist/esm/snk-form-summary.entry.js +1 -1
  190. package/dist/esm/snk-form-view.entry.js +1 -1
  191. package/dist/esm/snk-form_2.entry.js +33 -10
  192. package/dist/esm/snk-grid.entry.js +28 -19
  193. package/dist/esm/{snk-guides-viewer-339e10b3.js → snk-guides-viewer-3fd18298.js} +86 -40
  194. package/dist/esm/snk-guides-viewer.entry.js +10 -10
  195. package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
  196. package/dist/esm/snk-personalized-filter.entry.js +6 -6
  197. package/dist/esm/snk-pesquisa.entry.js +17 -6
  198. package/dist/esm/snk-print-selector.entry.js +1 -1
  199. package/dist/esm/snk-simple-bar.entry.js +1 -1
  200. package/dist/esm/snk-simple-crud.entry.js +12 -20
  201. package/dist/esm/snk-taskbar.entry.js +68 -52
  202. package/dist/esm/{taskbar-elements-faaf5d8f.js → taskbar-elements-d1e63fb2.js} +2 -2
  203. package/dist/esm/teste-pesquisa.entry.js +1 -1
  204. package/dist/sankhyablocks/{p-7f7fe6c4.entry.js → p-0a160fb5.entry.js} +1 -1
  205. package/dist/sankhyablocks/{p-144da1d1.entry.js → p-12f595a6.entry.js} +1 -1
  206. package/dist/sankhyablocks/{p-162bddae.entry.js → p-175c9576.entry.js} +1 -1
  207. package/dist/sankhyablocks/p-18d66638.entry.js +1 -0
  208. package/dist/sankhyablocks/{p-1788d191.js → p-1f310bc6.js} +1 -1
  209. package/dist/sankhyablocks/{p-c4fcf1fb.entry.js → p-27e0cd68.entry.js} +1 -1
  210. package/dist/sankhyablocks/p-2ac55a5d.js +1 -0
  211. package/dist/sankhyablocks/{p-9a63f3f7.entry.js → p-2b882835.entry.js} +1 -1
  212. package/dist/sankhyablocks/{p-1f8cb438.entry.js → p-2c6be187.entry.js} +1 -1
  213. package/dist/sankhyablocks/p-2c9d0870.js +2 -0
  214. package/dist/sankhyablocks/{p-cb4343c4.entry.js → p-2cc2526e.entry.js} +1 -1
  215. package/dist/sankhyablocks/{p-75af335e.entry.js → p-2ebda226.entry.js} +1 -1
  216. package/dist/sankhyablocks/{p-093f58fa.entry.js → p-2f94cf87.entry.js} +1 -1
  217. package/dist/sankhyablocks/p-3a35917e.entry.js +1 -0
  218. package/dist/sankhyablocks/p-3a443150.entry.js +1 -0
  219. package/dist/sankhyablocks/{p-c90f337a.entry.js → p-3b6d8d33.entry.js} +1 -1
  220. package/dist/sankhyablocks/p-3db72758.entry.js +1 -0
  221. package/dist/sankhyablocks/{p-e8c49c12.js → p-48a5c311.js} +2 -2
  222. package/dist/sankhyablocks/p-52691b42.js +1 -0
  223. package/dist/sankhyablocks/{p-27482793.entry.js → p-5aae5c74.entry.js} +1 -1
  224. package/dist/sankhyablocks/p-6564180d.entry.js +1 -0
  225. package/dist/sankhyablocks/{p-6d241415.js → p-6768f176.js} +1 -1
  226. package/dist/sankhyablocks/p-68c1a093.js +1 -0
  227. package/dist/sankhyablocks/p-6d322b0a.js +1 -0
  228. package/dist/sankhyablocks/{p-7b3ca294.entry.js → p-7150eacf.entry.js} +1 -1
  229. package/dist/sankhyablocks/{p-825098c1.entry.js → p-752c57f4.entry.js} +1 -1
  230. package/dist/sankhyablocks/{p-49ddc27a.entry.js → p-752f4e29.entry.js} +1 -1
  231. package/dist/sankhyablocks/{p-e258de96.entry.js → p-76729994.entry.js} +1 -1
  232. package/dist/sankhyablocks/{p-7fc46290.js → p-7ee6b1bf.js} +1 -1
  233. package/dist/sankhyablocks/{p-27005fac.entry.js → p-877d9614.entry.js} +1 -1
  234. package/dist/sankhyablocks/p-8b4d6719.js +1 -0
  235. package/dist/sankhyablocks/{p-3d41f5a8.entry.js → p-8d946600.entry.js} +1 -1
  236. package/dist/sankhyablocks/{p-96d45943.entry.js → p-90ae6c2e.entry.js} +1 -1
  237. package/dist/sankhyablocks/p-94267a30.entry.js +1 -0
  238. package/dist/sankhyablocks/{p-59b8f277.js → p-998a9d6f.js} +1 -1
  239. package/dist/sankhyablocks/{p-21107f0d.entry.js → p-9c1ff75e.entry.js} +1 -1
  240. package/dist/sankhyablocks/{p-2fdac5e6.entry.js → p-9e109f5e.entry.js} +1 -1
  241. package/dist/sankhyablocks/{p-88ed2793.js → p-9e4555ab.js} +1 -1
  242. package/dist/sankhyablocks/p-a46ac091.js +1 -0
  243. package/dist/sankhyablocks/p-a73b6b00.js +1 -0
  244. package/dist/sankhyablocks/{p-164c822d.entry.js → p-acd2ba28.entry.js} +1 -1
  245. package/dist/sankhyablocks/{p-180716b2.entry.js → p-ae326d06.entry.js} +1 -1
  246. package/dist/sankhyablocks/p-b471bfab.entry.js +1 -0
  247. package/dist/sankhyablocks/p-b533edab.entry.js +1 -0
  248. package/dist/sankhyablocks/p-b555ce38.entry.js +1 -0
  249. package/dist/sankhyablocks/p-c2d33fc8.entry.js +1 -0
  250. package/dist/sankhyablocks/p-c3ec6642.js +19 -0
  251. package/dist/sankhyablocks/{p-91a9abb6.entry.js → p-c8043a53.entry.js} +1 -1
  252. package/dist/sankhyablocks/{p-c3dbf441.entry.js → p-cc64239c.entry.js} +1 -1
  253. package/dist/sankhyablocks/{p-b987e15d.js → p-cc9935af.js} +1 -1
  254. package/dist/sankhyablocks/{p-471b34f4.entry.js → p-cd00a3d1.entry.js} +1 -1
  255. package/dist/sankhyablocks/{p-b7e891cc.entry.js → p-cd40c8cf.entry.js} +1 -1
  256. package/dist/sankhyablocks/{p-bd203e8d.entry.js → p-cd412add.entry.js} +1 -1
  257. package/dist/sankhyablocks/{p-4c763b10.entry.js → p-d657f71f.entry.js} +1 -1
  258. package/dist/sankhyablocks/{p-e6b1c769.entry.js → p-d6dad5e4.entry.js} +1 -1
  259. package/dist/sankhyablocks/p-d714b6ca.js +1 -0
  260. package/dist/sankhyablocks/p-da455c82.js +12 -0
  261. package/dist/sankhyablocks/p-dea58642.entry.js +11 -0
  262. package/dist/sankhyablocks/p-e30acdca.entry.js +1 -0
  263. package/dist/sankhyablocks/p-ec9027a7.entry.js +1 -0
  264. package/dist/sankhyablocks/p-ef9343c3.entry.js +1 -0
  265. package/dist/sankhyablocks/{p-667cab42.entry.js → p-f152ef98.entry.js} +1 -1
  266. package/dist/sankhyablocks/{p-7e250432.entry.js → p-f7170e10.entry.js} +1 -1
  267. package/dist/sankhyablocks/p-f8c5395a.entry.js +1 -0
  268. package/dist/sankhyablocks/p-f8da8569.entry.js +1 -0
  269. package/dist/sankhyablocks/{p-7345782c.entry.js → p-f921270b.entry.js} +1 -1
  270. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  271. package/dist/types/components/snk-application/search-strategy/exec-prepared-search-advaced-mode.d.ts +5 -0
  272. package/dist/types/components/snk-application/snk-application.d.ts +9 -0
  273. package/dist/types/components/snk-crud/snk-crud.d.ts +22 -0
  274. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +23 -0
  275. package/dist/types/components/snk-custom-slot-guide/snk-custom-slot-guide.d.ts +16 -0
  276. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +1 -0
  277. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +1 -0
  278. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -1
  279. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +2 -1
  280. package/dist/types/components/snk-form-config/FormConfigHelper.d.ts +6 -1
  281. package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +1 -1
  282. package/dist/types/components/snk-form-config/fields-layout/fields-layout.d.ts +2 -2
  283. package/dist/types/components/snk-form-config/guides-configurator/guides-configurator.d.ts +1 -1
  284. package/dist/types/components/snk-form-config/snk-form-config.d.ts +9 -2
  285. package/dist/types/components/snk-grid/snk-grid.d.ts +6 -0
  286. package/dist/types/components/snk-personalized-filter/interfaces/IParameter.d.ts +1 -0
  287. package/dist/types/components/snk-pesquisa/snk-pesquisa.d.ts +8 -0
  288. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -1
  289. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +12 -4
  290. package/dist/types/components.d.ts +105 -0
  291. package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
  292. package/package.json +1 -1
  293. package/react/components.d.ts +1 -0
  294. package/react/components.js +1 -0
  295. package/react/components.js.map +1 -1
  296. package/dist/sankhyablocks/p-0cf9aa38.js +0 -1
  297. package/dist/sankhyablocks/p-11346b8d.entry.js +0 -1
  298. package/dist/sankhyablocks/p-1649f51e.entry.js +0 -1
  299. package/dist/sankhyablocks/p-1d585081.js +0 -1
  300. package/dist/sankhyablocks/p-3ed04f0d.entry.js +0 -1
  301. package/dist/sankhyablocks/p-4759912d.entry.js +0 -1
  302. package/dist/sankhyablocks/p-55798617.js +0 -1
  303. package/dist/sankhyablocks/p-56948f00.entry.js +0 -11
  304. package/dist/sankhyablocks/p-60dd1d27.entry.js +0 -1
  305. package/dist/sankhyablocks/p-626b7a17.js +0 -1
  306. package/dist/sankhyablocks/p-8f73da95.js +0 -1
  307. package/dist/sankhyablocks/p-95c71f5e.entry.js +0 -1
  308. package/dist/sankhyablocks/p-988afe78.js +0 -1
  309. package/dist/sankhyablocks/p-9f2cdaab.entry.js +0 -1
  310. package/dist/sankhyablocks/p-9fe91526.js +0 -1
  311. package/dist/sankhyablocks/p-a5108625.entry.js +0 -1
  312. package/dist/sankhyablocks/p-aae4258d.entry.js +0 -1
  313. package/dist/sankhyablocks/p-af9d79e0.entry.js +0 -1
  314. package/dist/sankhyablocks/p-bb0de89c.entry.js +0 -1
  315. package/dist/sankhyablocks/p-d8d8169b.js +0 -2
  316. package/dist/sankhyablocks/p-e64958ba.entry.js +0 -1
  317. package/dist/sankhyablocks/p-f25c50f7.entry.js +0 -1
  318. package/dist/sankhyablocks/p-f8f29e1a.entry.js +0 -1
@@ -21,6 +21,8 @@ function _interopNamespace(e) {
21
21
  }
22
22
 
23
23
  const NAMESPACE = 'sankhyablocks';
24
+ const BUILD = /* sankhyablocks */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: true, cmpShouldUpdate: true, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: true, 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: true, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: false, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
25
+ const Env = /* sankhyablocks */ {};
24
26
 
25
27
  /**
26
28
  * Virtual DOM patching algorithm based on Snabbdom by
@@ -33,26 +35,120 @@ const NAMESPACE = 'sankhyablocks';
33
35
  let scopeId;
34
36
  let contentRef;
35
37
  let hostTagName;
38
+ let customError;
39
+ let i = 0;
36
40
  let useNativeShadowDom = false;
37
41
  let checkSlotFallbackVisibility = false;
38
42
  let checkSlotRelocate = false;
39
43
  let isSvgMode = false;
40
44
  let renderingRef = null;
45
+ let queueCongestion = 0;
41
46
  let queuePending = false;
47
+ const Build = {
48
+ isDev: BUILD.isDev ? true : false,
49
+ isBrowser: true,
50
+ isServer: false,
51
+ isTesting: BUILD.isTesting ? true : false,
52
+ };
53
+ const Context = {};
54
+ const getAssetPath = (path) => {
55
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
56
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
57
+ };
58
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
42
59
  const createTime = (fnName, tagName = '') => {
43
- {
60
+ if (BUILD.profile && performance.mark) {
61
+ const key = `st:${fnName}:${tagName}:${i++}`;
62
+ // Start
63
+ performance.mark(key);
64
+ // End
65
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
66
+ }
67
+ else {
44
68
  return () => {
45
69
  return;
46
70
  };
47
71
  }
48
72
  };
49
73
  const uniqueTime = (key, measureText) => {
50
- {
74
+ if (BUILD.profile && performance.mark) {
75
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
76
+ performance.mark(key);
77
+ }
78
+ return () => {
79
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
80
+ performance.measure(measureText, key);
81
+ }
82
+ };
83
+ }
84
+ else {
51
85
  return () => {
52
86
  return;
53
87
  };
54
88
  }
55
89
  };
90
+ const inspect = (ref) => {
91
+ const hostRef = getHostRef(ref);
92
+ if (!hostRef) {
93
+ return undefined;
94
+ }
95
+ const flags = hostRef.$flags$;
96
+ const hostElement = hostRef.$hostElement$;
97
+ return {
98
+ renderCount: hostRef.$renderCount$,
99
+ flags: {
100
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
101
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
102
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
103
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
104
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
105
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
106
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
107
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
108
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
109
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
110
+ },
111
+ instanceValues: hostRef.$instanceValues$,
112
+ ancestorComponent: hostRef.$ancestorComponent$,
113
+ hostElement,
114
+ lazyInstance: hostRef.$lazyInstance$,
115
+ vnode: hostRef.$vnode$,
116
+ modeName: hostRef.$modeName$,
117
+ onReadyPromise: hostRef.$onReadyPromise$,
118
+ onReadyResolve: hostRef.$onReadyResolve$,
119
+ onInstancePromise: hostRef.$onInstancePromise$,
120
+ onInstanceResolve: hostRef.$onInstanceResolve$,
121
+ onRenderResolve: hostRef.$onRenderResolve$,
122
+ queuedListeners: hostRef.$queuedListeners$,
123
+ rmListeners: hostRef.$rmListeners$,
124
+ ['s-id']: hostElement['s-id'],
125
+ ['s-cr']: hostElement['s-cr'],
126
+ ['s-lr']: hostElement['s-lr'],
127
+ ['s-p']: hostElement['s-p'],
128
+ ['s-rc']: hostElement['s-rc'],
129
+ ['s-sc']: hostElement['s-sc'],
130
+ };
131
+ };
132
+ const installDevTools = () => {
133
+ if (BUILD.devTools) {
134
+ const stencil = (win.stencil = win.stencil || {});
135
+ const originalInspect = stencil.inspect;
136
+ stencil.inspect = (ref) => {
137
+ let result = inspect(ref);
138
+ if (!result && typeof originalInspect === 'function') {
139
+ result = originalInspect(ref);
140
+ }
141
+ return result;
142
+ };
143
+ }
144
+ };
145
+ const CONTENT_REF_ID = 'r';
146
+ const ORG_LOCATION_ID = 'o';
147
+ const SLOT_NODE_ID = 's';
148
+ const TEXT_NODE_ID = 't';
149
+ const HYDRATE_ID = 's-id';
150
+ const HYDRATED_STYLE_ID = 'sty-id';
151
+ const HYDRATE_CHILD_ID = 'c-id';
56
152
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
57
153
  const XLINK_NS = 'http://www.w3.org/1999/xlink';
58
154
  /**
@@ -63,6 +159,11 @@ const XLINK_NS = 'http://www.w3.org/1999/xlink';
63
159
  * Don't add values to these!!
64
160
  */
65
161
  const EMPTY_OBJ = {};
162
+ /**
163
+ * Namespaces
164
+ */
165
+ const SVG_NS = 'http://www.w3.org/2000/svg';
166
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
66
167
  const isDef = (v) => v != null;
67
168
  const isComplexType = (o) => {
68
169
  // https://jsperf.com/typeof-fn-object/5
@@ -108,6 +209,11 @@ const h = (nodeName, vnodeData, ...children) => {
108
209
  if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
109
210
  child = String(child);
110
211
  }
212
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
213
+ consoleDevError(`vNode passed as children has unexpected type.
214
+ Make sure it's using the correct h() function.
215
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
216
+ }
111
217
  if (simple && lastSimple) {
112
218
  // If the previous child was simple (string), we merge both
113
219
  vNodeChildren[vNodeChildren.length - 1].$text$ += child;
@@ -122,14 +228,17 @@ const h = (nodeName, vnodeData, ...children) => {
122
228
  };
123
229
  walk(children);
124
230
  if (vnodeData) {
231
+ if (BUILD.isDev && nodeName === 'input') {
232
+ validateInputProperties(vnodeData);
233
+ }
125
234
  // normalize class / classname attributes
126
- if (vnodeData.key) {
235
+ if (BUILD.vdomKey && vnodeData.key) {
127
236
  key = vnodeData.key;
128
237
  }
129
- if (vnodeData.name) {
238
+ if (BUILD.slotRelocation && vnodeData.name) {
130
239
  slotName = vnodeData.name;
131
240
  }
132
- {
241
+ if (BUILD.vdomClass) {
133
242
  const classData = vnodeData.className || vnodeData.class;
134
243
  if (classData) {
135
244
  vnodeData.class =
@@ -141,7 +250,12 @@ const h = (nodeName, vnodeData, ...children) => {
141
250
  }
142
251
  }
143
252
  }
144
- if (typeof nodeName === 'function') {
253
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
254
+ consoleDevError(`The <Host> must be the single root component. Make sure:
255
+ - You are NOT using hostData() and <Host> in the same component.
256
+ - <Host> is used once, and it's the single root component of the render() function.`);
257
+ }
258
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
145
259
  // nodeName is a functional component
146
260
  return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
147
261
  }
@@ -150,10 +264,10 @@ const h = (nodeName, vnodeData, ...children) => {
150
264
  if (vNodeChildren.length > 0) {
151
265
  vnode.$children$ = vNodeChildren;
152
266
  }
153
- {
267
+ if (BUILD.vdomKey) {
154
268
  vnode.$key$ = key;
155
269
  }
156
- {
270
+ if (BUILD.slotRelocation) {
157
271
  vnode.$name$ = slotName;
158
272
  }
159
273
  return vnode;
@@ -174,13 +288,13 @@ const newVNode = (tag, text) => {
174
288
  $elm$: null,
175
289
  $children$: null,
176
290
  };
177
- {
291
+ if (BUILD.vdomAttribute) {
178
292
  vnode.$attrs$ = null;
179
293
  }
180
- {
294
+ if (BUILD.vdomKey) {
181
295
  vnode.$key$ = null;
182
296
  }
183
- {
297
+ if (BUILD.slotRelocation) {
184
298
  vnode.$name$ = null;
185
299
  }
186
300
  return vnode;
@@ -246,6 +360,235 @@ const convertToPrivate = (node) => {
246
360
  vnode.$name$ = node.vname;
247
361
  return vnode;
248
362
  };
363
+ /**
364
+ * Validates the ordering of attributes on an input element
365
+ *
366
+ * @param inputElm the element to validate
367
+ */
368
+ const validateInputProperties = (inputElm) => {
369
+ const props = Object.keys(inputElm);
370
+ const value = props.indexOf('value');
371
+ if (value === -1) {
372
+ return;
373
+ }
374
+ const typeIndex = props.indexOf('type');
375
+ const minIndex = props.indexOf('min');
376
+ const maxIndex = props.indexOf('max');
377
+ const stepIndex = props.indexOf('step');
378
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
379
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
380
+ }
381
+ };
382
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
383
+ const endHydrate = createTime('hydrateClient', tagName);
384
+ const shadowRoot = hostElm.shadowRoot;
385
+ const childRenderNodes = [];
386
+ const slotNodes = [];
387
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
388
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
389
+ if (!plt.$orgLocNodes$) {
390
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
391
+ }
392
+ hostElm[HYDRATE_ID] = hostId;
393
+ hostElm.removeAttribute(HYDRATE_ID);
394
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
395
+ childRenderNodes.map((c) => {
396
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
397
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
398
+ const node = c.$elm$;
399
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
400
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
401
+ }
402
+ if (!shadowRoot) {
403
+ node['s-hn'] = tagName;
404
+ if (orgLocationNode) {
405
+ node['s-ol'] = orgLocationNode;
406
+ node['s-ol']['s-nr'] = node;
407
+ }
408
+ }
409
+ plt.$orgLocNodes$.delete(orgLocationId);
410
+ });
411
+ if (BUILD.shadowDom && shadowRoot) {
412
+ shadowRootNodes.map((shadowRootNode) => {
413
+ if (shadowRootNode) {
414
+ shadowRoot.appendChild(shadowRootNode);
415
+ }
416
+ });
417
+ }
418
+ endHydrate();
419
+ };
420
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
421
+ let childNodeType;
422
+ let childIdSplt;
423
+ let childVNode;
424
+ let i;
425
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
426
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
427
+ if (childNodeType) {
428
+ // got the node data from the element's attribute
429
+ // `${hostId}.${nodeId}.${depth}.${index}`
430
+ childIdSplt = childNodeType.split('.');
431
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
432
+ childVNode = {
433
+ $flags$: 0,
434
+ $hostId$: childIdSplt[0],
435
+ $nodeId$: childIdSplt[1],
436
+ $depth$: childIdSplt[2],
437
+ $index$: childIdSplt[3],
438
+ $tag$: node.tagName.toLowerCase(),
439
+ $elm$: node,
440
+ $attrs$: null,
441
+ $children$: null,
442
+ $key$: null,
443
+ $name$: null,
444
+ $text$: null,
445
+ };
446
+ childRenderNodes.push(childVNode);
447
+ node.removeAttribute(HYDRATE_CHILD_ID);
448
+ // this is a new child vnode
449
+ // so ensure its parent vnode has the vchildren array
450
+ if (!parentVNode.$children$) {
451
+ parentVNode.$children$ = [];
452
+ }
453
+ // add our child vnode to a specific index of the vnode's children
454
+ parentVNode.$children$[childVNode.$index$] = childVNode;
455
+ // this is now the new parent vnode for all the next child checks
456
+ parentVNode = childVNode;
457
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
458
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
459
+ }
460
+ }
461
+ }
462
+ // recursively drill down, end to start so we can remove nodes
463
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
464
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
465
+ }
466
+ if (node.shadowRoot) {
467
+ // keep drilling down through the shadow root nodes
468
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
469
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
470
+ }
471
+ }
472
+ }
473
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
474
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
475
+ childIdSplt = node.nodeValue.split('.');
476
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
477
+ // comment node for either the host id or a 0 host id
478
+ childNodeType = childIdSplt[0];
479
+ childVNode = {
480
+ $flags$: 0,
481
+ $hostId$: childIdSplt[1],
482
+ $nodeId$: childIdSplt[2],
483
+ $depth$: childIdSplt[3],
484
+ $index$: childIdSplt[4],
485
+ $elm$: node,
486
+ $attrs$: null,
487
+ $children$: null,
488
+ $key$: null,
489
+ $name$: null,
490
+ $tag$: null,
491
+ $text$: null,
492
+ };
493
+ if (childNodeType === TEXT_NODE_ID) {
494
+ childVNode.$elm$ = node.nextSibling;
495
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
496
+ childVNode.$text$ = childVNode.$elm$.textContent;
497
+ childRenderNodes.push(childVNode);
498
+ // remove the text comment since it's no longer needed
499
+ node.remove();
500
+ if (!parentVNode.$children$) {
501
+ parentVNode.$children$ = [];
502
+ }
503
+ parentVNode.$children$[childVNode.$index$] = childVNode;
504
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
505
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
506
+ }
507
+ }
508
+ }
509
+ else if (childVNode.$hostId$ === hostId) {
510
+ // this comment node is specifcally for this host id
511
+ if (childNodeType === SLOT_NODE_ID) {
512
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
513
+ childVNode.$tag$ = 'slot';
514
+ if (childIdSplt[5]) {
515
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
516
+ }
517
+ else {
518
+ node['s-sn'] = '';
519
+ }
520
+ node['s-sr'] = true;
521
+ if (BUILD.shadowDom && shadowRootNodes) {
522
+ // browser support shadowRoot and this is a shadow dom component
523
+ // create an actual slot element
524
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
525
+ if (childVNode.$name$) {
526
+ // add the slot name attribute
527
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
528
+ }
529
+ // insert the new slot element before the slot comment
530
+ node.parentNode.insertBefore(childVNode.$elm$, node);
531
+ // remove the slot comment since it's not needed for shadow
532
+ node.remove();
533
+ if (childVNode.$depth$ === '0') {
534
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
535
+ }
536
+ }
537
+ slotNodes.push(childVNode);
538
+ if (!parentVNode.$children$) {
539
+ parentVNode.$children$ = [];
540
+ }
541
+ parentVNode.$children$[childVNode.$index$] = childVNode;
542
+ }
543
+ else if (childNodeType === CONTENT_REF_ID) {
544
+ // `${CONTENT_REF_ID}.${hostId}`;
545
+ if (BUILD.shadowDom && shadowRootNodes) {
546
+ // remove the content ref comment since it's not needed for shadow
547
+ node.remove();
548
+ }
549
+ else if (BUILD.slotRelocation) {
550
+ hostElm['s-cr'] = node;
551
+ node['s-cn'] = true;
552
+ }
553
+ }
554
+ }
555
+ }
556
+ }
557
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
558
+ const vnode = newVNode(null, node.textContent);
559
+ vnode.$elm$ = node;
560
+ vnode.$index$ = '0';
561
+ parentVNode.$children$ = [vnode];
562
+ }
563
+ };
564
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
565
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
566
+ let i = 0;
567
+ for (; i < node.childNodes.length; i++) {
568
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
569
+ }
570
+ if (node.shadowRoot) {
571
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
572
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
573
+ }
574
+ }
575
+ }
576
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
577
+ const childIdSplt = node.nodeValue.split('.');
578
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
579
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
580
+ node.nodeValue = '';
581
+ // useful to know if the original location is
582
+ // the root light-dom of a shadow dom component
583
+ node['s-en'] = childIdSplt[3];
584
+ }
585
+ }
586
+ };
587
+ // Private
588
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
589
+ // Public
590
+ const setMode = (handler) => modeResolutionChain.push(handler);
591
+ const getMode = (ref) => getHostRef(ref).$modeName$;
249
592
  /**
250
593
  * Parse a new property value for a given property type.
251
594
  *
@@ -272,16 +615,16 @@ const convertToPrivate = (node) => {
272
615
  const parsePropertyValue = (propValue, propType) => {
273
616
  // ensure this value is of the correct prop type
274
617
  if (propValue != null && !isComplexType(propValue)) {
275
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
618
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
276
619
  // per the HTML spec, any string value means it is a boolean true value
277
620
  // but we'll cheat here and say that the string "false" is the boolean false
278
621
  return propValue === 'false' ? false : propValue === '' || !!propValue;
279
622
  }
280
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
623
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
281
624
  // force it to be a number
282
625
  return parseFloat(propValue);
283
626
  }
284
- if (propType & 1 /* MEMBER_FLAGS.String */) {
627
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
285
628
  // could have been passed as a number or boolean
286
629
  // but we still want it as a string
287
630
  return String(propValue);
@@ -293,11 +636,14 @@ const parsePropertyValue = (propValue, propType) => {
293
636
  // so no need to change to a different type
294
637
  return propValue;
295
638
  };
296
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
639
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
297
640
  const createEvent = (ref, name, flags) => {
298
641
  const elm = getElement(ref);
299
642
  return {
300
643
  emit: (detail) => {
644
+ if (BUILD.isDev && !elm.isConnected) {
645
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
646
+ }
301
647
  return emitEvent(elm, name, {
302
648
  bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
303
649
  composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
@@ -338,8 +684,11 @@ const registerStyle = (scopeId, cssText, allowCS) => {
338
684
  };
339
685
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
340
686
  var _a;
341
- let scopeId = getScopeId(cmpMeta);
687
+ let scopeId = getScopeId(cmpMeta, mode);
342
688
  const style = styles.get(scopeId);
689
+ if (!BUILD.attachStyles) {
690
+ return scopeId;
691
+ }
343
692
  // if an element is NOT connected then getRootNode() will return the wrong root node
344
693
  // so the fallback is to always use the document for the root node in those cases
345
694
  styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
@@ -352,8 +701,25 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
352
701
  rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
353
702
  }
354
703
  if (!appliedStyles.has(scopeId)) {
355
- {
356
- {
704
+ if (BUILD.hydrateClientSide &&
705
+ styleContainerNode.host &&
706
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
707
+ // This is only happening on native shadow-dom, do not needs CSS var shim
708
+ styleElm.innerHTML = style;
709
+ }
710
+ else {
711
+ if (BUILD.cssVarShim && plt.$cssShim$) {
712
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
713
+ const newScopeId = styleElm['s-sc'];
714
+ if (newScopeId) {
715
+ scopeId = newScopeId;
716
+ // we don't want to add this styleID to the appliedStyles Set
717
+ // since the cssVarShim might need to apply several different
718
+ // stylesheets for the same component
719
+ appliedStyles = null;
720
+ }
721
+ }
722
+ else {
357
723
  styleElm = doc.createElement('style');
358
724
  styleElm.innerHTML = style;
359
725
  }
@@ -362,6 +728,9 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
362
728
  if (nonce != null) {
363
729
  styleElm.setAttribute('nonce', nonce);
364
730
  }
731
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
732
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
733
+ }
365
734
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
366
735
  }
367
736
  if (appliedStyles) {
@@ -369,7 +738,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
369
738
  }
370
739
  }
371
740
  }
372
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
741
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
373
742
  styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
374
743
  }
375
744
  }
@@ -380,8 +749,8 @@ const attachStyles = (hostRef) => {
380
749
  const elm = hostRef.$hostElement$;
381
750
  const flags = cmpMeta.$flags$;
382
751
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
383
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
384
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
752
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
753
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
385
754
  // only required when we're NOT using native shadow dom (slot)
386
755
  // or this browser doesn't support native shadow dom
387
756
  // and this host element was NOT created with SSR
@@ -391,13 +760,14 @@ const attachStyles = (hostRef) => {
391
760
  // DOM WRITE!!
392
761
  elm['s-sc'] = scopeId;
393
762
  elm.classList.add(scopeId + '-h');
394
- if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
763
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
395
764
  elm.classList.add(scopeId + '-s');
396
765
  }
397
766
  }
398
767
  endAttachStyles();
399
768
  };
400
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
769
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
770
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
401
771
  /**
402
772
  * Production setAccessor() function based on Preact by
403
773
  * Jason Miller (@developit)
@@ -410,19 +780,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
410
780
  if (oldValue !== newValue) {
411
781
  let isProp = isMemberInElement(elm, memberName);
412
782
  let ln = memberName.toLowerCase();
413
- if (memberName === 'class') {
783
+ if (BUILD.vdomClass && memberName === 'class') {
414
784
  const classList = elm.classList;
415
785
  const oldClasses = parseClassList(oldValue);
416
786
  const newClasses = parseClassList(newValue);
417
787
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
418
788
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
419
789
  }
420
- else if (memberName === 'style') {
790
+ else if (BUILD.vdomStyle && memberName === 'style') {
421
791
  // update style attribute, css properties and values
422
- {
792
+ if (BUILD.updatable) {
423
793
  for (const prop in oldValue) {
424
794
  if (!newValue || newValue[prop] == null) {
425
- if (prop.includes('-')) {
795
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
426
796
  elm.style.removeProperty(prop);
427
797
  }
428
798
  else {
@@ -433,7 +803,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
433
803
  }
434
804
  for (const prop in newValue) {
435
805
  if (!oldValue || newValue[prop] !== oldValue[prop]) {
436
- if (prop.includes('-')) {
806
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
437
807
  elm.style.setProperty(prop, newValue[prop]);
438
808
  }
439
809
  else {
@@ -442,15 +812,16 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
442
812
  }
443
813
  }
444
814
  }
445
- else if (memberName === 'key')
815
+ else if (BUILD.vdomKey && memberName === 'key')
446
816
  ;
447
- else if (memberName === 'ref') {
817
+ else if (BUILD.vdomRef && memberName === 'ref') {
448
818
  // minifier will clean this up
449
819
  if (newValue) {
450
820
  newValue(elm);
451
821
  }
452
822
  }
453
- else if ((!isProp ) &&
823
+ else if (BUILD.vdomListener &&
824
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
454
825
  memberName[0] === 'o' &&
455
826
  memberName[1] === 'n') {
456
827
  // Event Handlers
@@ -489,7 +860,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
489
860
  plt.ael(elm, memberName, newValue, false);
490
861
  }
491
862
  }
492
- else {
863
+ else if (BUILD.vdomPropOrAttr) {
493
864
  // Set property if it exists and it's not a SVG
494
865
  const isComplex = isComplexType(newValue);
495
866
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
@@ -518,7 +889,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
518
889
  * - if the newValue is null/undefined or 'false'.
519
890
  */
520
891
  let xlink = false;
521
- {
892
+ if (BUILD.vdomXlink) {
522
893
  if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
523
894
  memberName = ln;
524
895
  xlink = true;
@@ -526,7 +897,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
526
897
  }
527
898
  if (newValue == null || newValue === false) {
528
899
  if (newValue !== false || elm.getAttribute(memberName) === '') {
529
- if (xlink) {
900
+ if (BUILD.vdomXlink && xlink) {
530
901
  elm.removeAttributeNS(XLINK_NS, memberName);
531
902
  }
532
903
  else {
@@ -536,7 +907,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
536
907
  }
537
908
  else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
538
909
  newValue = newValue === true ? '' : newValue;
539
- if (xlink) {
910
+ if (BUILD.vdomXlink && xlink) {
540
911
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
541
912
  }
542
913
  else {
@@ -557,7 +928,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
557
928
  : newVnode.$elm$;
558
929
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
559
930
  const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
560
- {
931
+ if (BUILD.updatable) {
561
932
  // remove attributes no longer present on the vnode by setting them to undefined
562
933
  for (memberName in oldVnodeAttrs) {
563
934
  if (!(memberName in newVnodeAttrs)) {
@@ -587,7 +958,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
587
958
  let elm;
588
959
  let childNode;
589
960
  let oldVNode;
590
- if (!useNativeShadowDom) {
961
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
591
962
  // remember for later we need to check to relocate nodes
592
963
  checkSlotRelocate = true;
593
964
  if (newVNode.$tag$ === 'slot') {
@@ -602,25 +973,38 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
602
973
  1 /* VNODE_FLAGS.isSlotReference */;
603
974
  }
604
975
  }
605
- if (newVNode.$text$ !== null) {
976
+ if (BUILD.isDev && newVNode.$elm$) {
977
+ 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`);
978
+ }
979
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
606
980
  // create text node
607
981
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
608
982
  }
609
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
983
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
610
984
  // create a slot reference node
611
985
  elm = newVNode.$elm$ =
612
- doc.createTextNode('');
986
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
613
987
  }
614
988
  else {
989
+ if (BUILD.svg && !isSvgMode) {
990
+ isSvgMode = newVNode.$tag$ === 'svg';
991
+ }
615
992
  // create element
616
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
993
+ elm = newVNode.$elm$ = (BUILD.svg
994
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
995
+ ? 'slot-fb'
996
+ : newVNode.$tag$)
997
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
617
998
  ? 'slot-fb'
618
999
  : newVNode.$tag$));
1000
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
1001
+ isSvgMode = false;
1002
+ }
619
1003
  // add css classes, attrs, props, listeners, etc.
620
- {
1004
+ if (BUILD.vdomAttribute) {
621
1005
  updateElement(null, newVNode, isSvgMode);
622
1006
  }
623
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
1007
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
624
1008
  // if there is a scopeId and this is the initial render
625
1009
  // then let's add the scopeId as a css class
626
1010
  elm.classList.add((elm['s-si'] = scopeId));
@@ -636,8 +1020,18 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
636
1020
  }
637
1021
  }
638
1022
  }
1023
+ if (BUILD.svg) {
1024
+ if (newVNode.$tag$ === 'svg') {
1025
+ // Only reset the SVG context when we're exiting <svg> element
1026
+ isSvgMode = false;
1027
+ }
1028
+ else if (elm.tagName === 'foreignObject') {
1029
+ // Reenter SVG context when we're exiting <foreignObject> element
1030
+ isSvgMode = true;
1031
+ }
1032
+ }
639
1033
  }
640
- {
1034
+ if (BUILD.slotRelocation) {
641
1035
  elm['s-hn'] = hostTagName;
642
1036
  if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
643
1037
  // remember the content reference comment
@@ -697,9 +1091,9 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
697
1091
  * creating DOM nodes (inclusive)
698
1092
  */
699
1093
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
700
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1094
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
701
1095
  let childNode;
702
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1096
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
703
1097
  containerElm = containerElm.shadowRoot;
704
1098
  }
705
1099
  for (; startIdx <= endIdx; ++startIdx) {
@@ -707,7 +1101,7 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
707
1101
  childNode = createElm(null, parentVNode, startIdx, parentElm);
708
1102
  if (childNode) {
709
1103
  vnodes[startIdx].$elm$ = childNode;
710
- containerElm.insertBefore(childNode, referenceNode(before) );
1104
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
711
1105
  }
712
1106
  }
713
1107
  }
@@ -730,7 +1124,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
730
1124
  if ((vnode = vnodes[startIdx])) {
731
1125
  elm = vnode.$elm$;
732
1126
  callNodeRefs(vnode);
733
- {
1127
+ if (BUILD.slotRelocation) {
734
1128
  // we're removing this element
735
1129
  // so it's possible we need to show slot fallback content now
736
1130
  checkSlotFallbackVisibility = true;
@@ -876,7 +1270,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
876
1270
  //
877
1271
  // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
878
1272
  // and move the DOM element for `oldStartVnode`.
879
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1273
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
880
1274
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
881
1275
  }
882
1276
  patch(oldStartVnode, newEndVnode);
@@ -917,7 +1311,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
917
1311
  // (which will handle updating any changed attributes, reconciling their
918
1312
  // children etc) but we also need to move the DOM node to which
919
1313
  // `oldEndVnode` corresponds.
920
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1314
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
921
1315
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
922
1316
  }
923
1317
  patch(oldEndVnode, newStartVnode);
@@ -940,7 +1334,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
940
1334
  // children which have the same key as the first node in the new
941
1335
  // children.
942
1336
  idxInOld = -1;
943
- {
1337
+ if (BUILD.vdomKey) {
944
1338
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
945
1339
  if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
946
1340
  idxInOld = i;
@@ -948,7 +1342,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
948
1342
  }
949
1343
  }
950
1344
  }
951
- if (idxInOld >= 0) {
1345
+ if (BUILD.vdomKey && idxInOld >= 0) {
952
1346
  // We found a node in the old children which matches up with the first
953
1347
  // node in the new children! So let's deal with that
954
1348
  elmToMove = oldCh[idxInOld];
@@ -975,9 +1369,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
975
1369
  }
976
1370
  if (node) {
977
1371
  // if we created a new node then handle inserting it to the DOM
978
- {
1372
+ if (BUILD.slotRelocation) {
979
1373
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
980
1374
  }
1375
+ else {
1376
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1377
+ }
981
1378
  }
982
1379
  }
983
1380
  }
@@ -985,7 +1382,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
985
1382
  // we have some more new nodes to add which don't match up with old nodes
986
1383
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
987
1384
  }
988
- else if (newStartIdx > newEndIdx) {
1385
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
989
1386
  // there are nodes in the `oldCh` array which no longer correspond to nodes
990
1387
  // in the new array, so lets remove them (which entails cleaning up the
991
1388
  // relevant DOM nodes)
@@ -1014,13 +1411,14 @@ const isSameVnode = (leftVNode, rightVNode) => {
1014
1411
  // compare if two vnode to see if they're "technically" the same
1015
1412
  // need to have the same element tag, and same key to be the same
1016
1413
  if (leftVNode.$tag$ === rightVNode.$tag$) {
1017
- if (leftVNode.$tag$ === 'slot') {
1414
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1018
1415
  return leftVNode.$name$ === rightVNode.$name$;
1019
1416
  }
1020
1417
  // this will be set if components in the build have `key` attrs set on them
1021
- {
1418
+ if (BUILD.vdomKey) {
1022
1419
  return leftVNode.$key$ === rightVNode.$key$;
1023
1420
  }
1421
+ return true;
1024
1422
  }
1025
1423
  return false;
1026
1424
  };
@@ -1047,9 +1445,14 @@ const patch = (oldVNode, newVNode) => {
1047
1445
  const tag = newVNode.$tag$;
1048
1446
  const text = newVNode.$text$;
1049
1447
  let defaultHolder;
1050
- if (text === null) {
1051
- {
1052
- if (tag === 'slot')
1448
+ if (!BUILD.vdomText || text === null) {
1449
+ if (BUILD.svg) {
1450
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1451
+ // only add this to the when the compiler sees we're using an svg somewhere
1452
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1453
+ }
1454
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1455
+ if (BUILD.slot && tag === 'slot')
1053
1456
  ;
1054
1457
  else {
1055
1458
  // either this is the first render of an element OR it's an update
@@ -1058,30 +1461,33 @@ const patch = (oldVNode, newVNode) => {
1058
1461
  updateElement(oldVNode, newVNode, isSvgMode);
1059
1462
  }
1060
1463
  }
1061
- if (oldChildren !== null && newChildren !== null) {
1464
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1062
1465
  // looks like there's child vnodes for both the old and new vnodes
1063
1466
  // so we need to call `updateChildren` to reconcile them
1064
1467
  updateChildren(elm, oldChildren, newVNode, newChildren);
1065
1468
  }
1066
1469
  else if (newChildren !== null) {
1067
1470
  // no old child vnodes, but there are new child vnodes to add
1068
- if (oldVNode.$text$ !== null) {
1471
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1069
1472
  // the old vnode was text, so be sure to clear it out
1070
1473
  elm.textContent = '';
1071
1474
  }
1072
1475
  // add the new vnode children
1073
1476
  addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1074
1477
  }
1075
- else if (oldChildren !== null) {
1478
+ else if (BUILD.updatable && oldChildren !== null) {
1076
1479
  // no new child vnodes, but there are old child vnodes to remove
1077
1480
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
1078
1481
  }
1482
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1483
+ isSvgMode = false;
1484
+ }
1079
1485
  }
1080
- else if ((defaultHolder = elm['s-cr'])) {
1486
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1081
1487
  // this element has slotted content
1082
1488
  defaultHolder.parentNode.textContent = text;
1083
1489
  }
1084
- else if (oldVNode.$text$ !== text) {
1490
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1085
1491
  // update the text content for the text only vnode
1086
1492
  // and also only if the text is different than before
1087
1493
  elm.data = text;
@@ -1219,7 +1625,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1219
1625
  return slotNameAttr === '';
1220
1626
  };
1221
1627
  const callNodeRefs = (vNode) => {
1222
- {
1628
+ if (BUILD.vdomRef) {
1223
1629
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1224
1630
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
1225
1631
  }
@@ -1242,26 +1648,41 @@ const renderVdom = (hostRef, renderFnResults) => {
1242
1648
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1243
1649
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1244
1650
  hostTagName = hostElm.tagName;
1245
- if (cmpMeta.$attrsToReflect$) {
1651
+ // <Host> runtime check
1652
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1653
+ throw new Error(`The <Host> must be the single root component.
1654
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1655
+
1656
+ The render() function should look like this instead:
1657
+
1658
+ render() {
1659
+ // Do not return an array
1660
+ return (
1661
+ <Host>{content}</Host>
1662
+ );
1663
+ }
1664
+ `);
1665
+ }
1666
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1246
1667
  rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1247
1668
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1248
1669
  }
1249
1670
  rootVnode.$tag$ = null;
1250
1671
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1251
1672
  hostRef.$vnode$ = rootVnode;
1252
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1253
- {
1673
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1674
+ if (BUILD.scoped || BUILD.shadowDom) {
1254
1675
  scopeId = hostElm['s-sc'];
1255
1676
  }
1256
- {
1677
+ if (BUILD.slotRelocation) {
1257
1678
  contentRef = hostElm['s-cr'];
1258
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1679
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1259
1680
  // always reset
1260
1681
  checkSlotFallbackVisibility = false;
1261
1682
  }
1262
1683
  // synchronous patch
1263
1684
  patch(oldVNode, rootVnode);
1264
- {
1685
+ if (BUILD.slotRelocation) {
1265
1686
  // while we're moving nodes around existing nodes, temporarily disable
1266
1687
  // the disconnectCallback from working
1267
1688
  plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
@@ -1281,7 +1702,9 @@ const renderVdom = (hostRef, renderFnResults) => {
1281
1702
  // add a reference node marking this node's original location
1282
1703
  // keep a reference to this node for later lookups
1283
1704
  orgLocationNode =
1284
- doc.createTextNode('');
1705
+ BUILD.isDebug || BUILD.hydrateServerSide
1706
+ ? originalLocationDebugNode(nodeToRelocate)
1707
+ : doc.createTextNode('');
1285
1708
  orgLocationNode['s-nr'] = nodeToRelocate;
1286
1709
  nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1287
1710
  }
@@ -1338,16 +1761,23 @@ const renderVdom = (hostRef, renderFnResults) => {
1338
1761
  relocateNodes.length = 0;
1339
1762
  }
1340
1763
  };
1764
+ // slot comment debug nodes only created with the `--debug` flag
1765
+ // otherwise these nodes are text nodes w/out content
1766
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1767
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1768
+ (nodeToRelocate.localName
1769
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1770
+ : `[${nodeToRelocate.textContent}]`));
1341
1771
  const attachToAncestor = (hostRef, ancestorComponent) => {
1342
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1772
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1343
1773
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1344
1774
  }
1345
1775
  };
1346
1776
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1347
- {
1777
+ if (BUILD.taskQueue && BUILD.updatable) {
1348
1778
  hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1349
1779
  }
1350
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1780
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1351
1781
  hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1352
1782
  return;
1353
1783
  }
@@ -1356,30 +1786,34 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
1356
1786
  // has already fired off its lifecycle update then
1357
1787
  // fire off the initial update
1358
1788
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1359
- return writeTask(dispatch) ;
1789
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1360
1790
  };
1361
1791
  const dispatchHooks = (hostRef, isInitialLoad) => {
1792
+ const elm = hostRef.$hostElement$;
1362
1793
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1363
- const instance = hostRef.$lazyInstance$ ;
1794
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1364
1795
  let promise;
1365
1796
  if (isInitialLoad) {
1366
- {
1797
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1367
1798
  hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1368
1799
  if (hostRef.$queuedListeners$) {
1369
1800
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1370
1801
  hostRef.$queuedListeners$ = null;
1371
1802
  }
1372
1803
  }
1373
- {
1804
+ emitLifecycleEvent(elm, 'componentWillLoad');
1805
+ if (BUILD.cmpWillLoad) {
1374
1806
  promise = safeCall(instance, 'componentWillLoad');
1375
1807
  }
1376
1808
  }
1377
1809
  else {
1378
- {
1810
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1811
+ if (BUILD.cmpWillUpdate) {
1379
1812
  promise = safeCall(instance, 'componentWillUpdate');
1380
1813
  }
1381
1814
  }
1382
- {
1815
+ emitLifecycleEvent(elm, 'componentWillRender');
1816
+ if (BUILD.cmpWillRender) {
1383
1817
  promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1384
1818
  }
1385
1819
  endSchedule();
@@ -1390,15 +1824,46 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1390
1824
  const elm = hostRef.$hostElement$;
1391
1825
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1392
1826
  const rc = elm['s-rc'];
1393
- if (isInitialLoad) {
1827
+ if (BUILD.style && isInitialLoad) {
1394
1828
  // DOM WRITE!
1395
1829
  attachStyles(hostRef);
1396
1830
  }
1397
1831
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1398
- {
1399
- callRender(hostRef, instance);
1832
+ if (BUILD.isDev) {
1833
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1834
+ }
1835
+ if (BUILD.hydrateServerSide) {
1836
+ await callRender(hostRef, instance, elm);
1837
+ }
1838
+ else {
1839
+ callRender(hostRef, instance, elm);
1840
+ }
1841
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1842
+ plt.$cssShim$.updateHost(elm);
1843
+ }
1844
+ if (BUILD.isDev) {
1845
+ hostRef.$renderCount$++;
1846
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1847
+ }
1848
+ if (BUILD.hydrateServerSide) {
1849
+ try {
1850
+ // manually connected child components during server-side hydrate
1851
+ serverSideConnected(elm);
1852
+ if (isInitialLoad) {
1853
+ // using only during server-side hydrate
1854
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1855
+ elm['s-en'] = '';
1856
+ }
1857
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1858
+ elm['s-en'] = 'c';
1859
+ }
1860
+ }
1861
+ }
1862
+ catch (e) {
1863
+ consoleError(e, elm);
1864
+ }
1400
1865
  }
1401
- if (rc) {
1866
+ if (BUILD.asyncLoading && rc) {
1402
1867
  // ok, so turns out there are some child host elements
1403
1868
  // waiting on this parent element to load
1404
1869
  // let's fire off all update callbacks waiting
@@ -1407,7 +1872,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1407
1872
  }
1408
1873
  endRender();
1409
1874
  endUpdate();
1410
- {
1875
+ if (BUILD.asyncLoading) {
1411
1876
  const childrenPromises = elm['s-p'];
1412
1877
  const postUpdate = () => postUpdateComponent(hostRef);
1413
1878
  if (childrenPromises.length === 0) {
@@ -1419,26 +1884,42 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1419
1884
  childrenPromises.length = 0;
1420
1885
  }
1421
1886
  }
1887
+ else {
1888
+ postUpdateComponent(hostRef);
1889
+ }
1422
1890
  };
1423
1891
  const callRender = (hostRef, instance, elm) => {
1892
+ // in order for bundlers to correctly treeshake the BUILD object
1893
+ // we need to ensure BUILD is not deoptimized within a try/catch
1894
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1895
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1896
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1897
+ const taskQueue = BUILD.taskQueue ? true : false;
1898
+ const updatable = BUILD.updatable ? true : false;
1424
1899
  try {
1425
1900
  renderingRef = instance;
1426
- instance = instance.render() ;
1427
- {
1901
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1902
+ if (updatable && taskQueue) {
1428
1903
  hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1429
1904
  }
1430
- {
1905
+ if (updatable || lazyLoad) {
1431
1906
  hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1432
1907
  }
1433
- {
1434
- {
1908
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1909
+ if (BUILD.vdomRender || BUILD.reflect) {
1435
1910
  // looks like we've got child nodes to render into this host element
1436
1911
  // or we need to update the css class/attrs on the host element
1437
1912
  // DOM WRITE!
1438
- {
1913
+ if (BUILD.hydrateServerSide) {
1914
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1915
+ }
1916
+ else {
1439
1917
  renderVdom(hostRef, instance);
1440
1918
  }
1441
1919
  }
1920
+ else {
1921
+ elm.textContent = instance;
1922
+ }
1442
1923
  }
1443
1924
  }
1444
1925
  catch (e) {
@@ -1452,40 +1933,68 @@ const postUpdateComponent = (hostRef) => {
1452
1933
  const tagName = hostRef.$cmpMeta$.$tagName$;
1453
1934
  const elm = hostRef.$hostElement$;
1454
1935
  const endPostUpdate = createTime('postUpdate', tagName);
1455
- const instance = hostRef.$lazyInstance$ ;
1936
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1456
1937
  const ancestorComponent = hostRef.$ancestorComponent$;
1457
- {
1938
+ if (BUILD.cmpDidRender) {
1939
+ if (BUILD.isDev) {
1940
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1941
+ }
1458
1942
  safeCall(instance, 'componentDidRender');
1943
+ if (BUILD.isDev) {
1944
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1945
+ }
1459
1946
  }
1947
+ emitLifecycleEvent(elm, 'componentDidRender');
1460
1948
  if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1461
1949
  hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1462
- {
1950
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1463
1951
  // DOM WRITE!
1464
1952
  addHydratedFlag(elm);
1465
1953
  }
1466
- {
1954
+ if (BUILD.cmpDidLoad) {
1955
+ if (BUILD.isDev) {
1956
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1957
+ }
1467
1958
  safeCall(instance, 'componentDidLoad');
1959
+ if (BUILD.isDev) {
1960
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1961
+ }
1468
1962
  }
1963
+ emitLifecycleEvent(elm, 'componentDidLoad');
1469
1964
  endPostUpdate();
1470
- {
1965
+ if (BUILD.asyncLoading) {
1471
1966
  hostRef.$onReadyResolve$(elm);
1472
1967
  if (!ancestorComponent) {
1473
- appDidLoad();
1968
+ appDidLoad(tagName);
1474
1969
  }
1475
1970
  }
1476
1971
  }
1477
1972
  else {
1478
- {
1973
+ if (BUILD.cmpDidUpdate) {
1974
+ // we've already loaded this component
1975
+ // fire off the user's componentDidUpdate method (if one was provided)
1976
+ // componentDidUpdate runs AFTER render() has been called
1977
+ // and all child components have finished updating
1978
+ if (BUILD.isDev) {
1979
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1980
+ }
1479
1981
  safeCall(instance, 'componentDidUpdate');
1982
+ if (BUILD.isDev) {
1983
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1984
+ }
1480
1985
  }
1986
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1481
1987
  endPostUpdate();
1482
1988
  }
1483
- {
1989
+ if (BUILD.hotModuleReplacement) {
1990
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1991
+ }
1992
+ if (BUILD.method && BUILD.lazyLoad) {
1484
1993
  hostRef.$onInstanceResolve$(elm);
1485
1994
  }
1486
1995
  // load events fire from bottom to top
1487
1996
  // the deepest elements load first then bubbles up
1488
- {
1997
+ if (BUILD.asyncLoading) {
1489
1998
  if (hostRef.$onRenderResolve$) {
1490
1999
  hostRef.$onRenderResolve$();
1491
2000
  hostRef.$onRenderResolve$ = undefined;
@@ -1500,7 +2009,7 @@ const postUpdateComponent = (hostRef) => {
1500
2009
  // (⌐■_■)
1501
2010
  };
1502
2011
  const forceUpdate = (ref) => {
1503
- {
2012
+ if (BUILD.updatable) {
1504
2013
  const hostRef = getHostRef(ref);
1505
2014
  const isConnected = hostRef.$hostElement$.isConnected;
1506
2015
  if (isConnected &&
@@ -1510,14 +2019,21 @@ const forceUpdate = (ref) => {
1510
2019
  // Returns "true" when the forced update was successfully scheduled
1511
2020
  return isConnected;
1512
2021
  }
2022
+ return false;
1513
2023
  };
1514
2024
  const appDidLoad = (who) => {
1515
2025
  // on appload
1516
2026
  // we have finish the first big initial render
1517
- {
2027
+ if (BUILD.cssAnnotations) {
1518
2028
  addHydratedFlag(doc.documentElement);
1519
2029
  }
2030
+ if (BUILD.asyncQueue) {
2031
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2032
+ }
1520
2033
  nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2034
+ if (BUILD.profile && performance.measure) {
2035
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
2036
+ }
1521
2037
  };
1522
2038
  const safeCall = (instance, method, arg) => {
1523
2039
  if (instance && instance[method]) {
@@ -1533,27 +2049,61 @@ const safeCall = (instance, method, arg) => {
1533
2049
  const then = (promise, thenFn) => {
1534
2050
  return promise && promise.then ? promise.then(thenFn) : thenFn();
1535
2051
  };
1536
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1537
- ;
2052
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2053
+ if (BUILD.lifecycleDOMEvents) {
2054
+ emitEvent(elm, 'stencil_' + lifecycleName, {
2055
+ bubbles: true,
2056
+ composed: true,
2057
+ detail: {
2058
+ namespace: NAMESPACE,
2059
+ },
2060
+ });
2061
+ }
2062
+ };
2063
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2064
+ ? elm.classList.add('hydrated')
2065
+ : BUILD.hydratedAttribute
2066
+ ? elm.setAttribute('hydrated', '')
2067
+ : undefined;
2068
+ const serverSideConnected = (elm) => {
2069
+ const children = elm.children;
2070
+ if (children != null) {
2071
+ for (let i = 0, ii = children.length; i < ii; i++) {
2072
+ const childElm = children[i];
2073
+ if (typeof childElm.connectedCallback === 'function') {
2074
+ childElm.connectedCallback();
2075
+ }
2076
+ serverSideConnected(childElm);
2077
+ }
2078
+ }
2079
+ };
1538
2080
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1539
2081
  const setValue = (ref, propName, newVal, cmpMeta) => {
1540
2082
  // check our new property value against our internal value
1541
2083
  const hostRef = getHostRef(ref);
1542
- const elm = hostRef.$hostElement$ ;
2084
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1543
2085
  const oldVal = hostRef.$instanceValues$.get(propName);
1544
2086
  const flags = hostRef.$flags$;
1545
- const instance = hostRef.$lazyInstance$ ;
2087
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1546
2088
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1547
2089
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1548
2090
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1549
2091
  const didValueChange = newVal !== oldVal && !areBothNaN;
1550
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2092
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1551
2093
  // gadzooks! the property's value has changed!!
1552
2094
  // set our new value!
1553
2095
  hostRef.$instanceValues$.set(propName, newVal);
1554
- if (instance) {
2096
+ if (BUILD.isDev) {
2097
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2098
+ 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);
2099
+ }
2100
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2101
+ 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);
2102
+ }
2103
+ }
2104
+ if (!BUILD.lazyLoad || instance) {
1555
2105
  // get an array of method names of watch functions to call
1556
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2106
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1557
2107
  const watchMethods = cmpMeta.$watchers$[propName];
1558
2108
  if (watchMethods) {
1559
2109
  // this instance is watching for when this property changed
@@ -1568,8 +2118,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1568
2118
  });
1569
2119
  }
1570
2120
  }
1571
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1572
- if (instance.componentShouldUpdate) {
2121
+ if (BUILD.updatable &&
2122
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2123
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1573
2124
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1574
2125
  return;
1575
2126
  }
@@ -1594,16 +2145,17 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1594
2145
  * @returns a reference to the same constructor passed in (but now mutated)
1595
2146
  */
1596
2147
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1597
- if (cmpMeta.$members$) {
1598
- if (Cstr.watchers) {
2148
+ if (BUILD.member && cmpMeta.$members$) {
2149
+ if (BUILD.watchCallback && Cstr.watchers) {
1599
2150
  cmpMeta.$watchers$ = Cstr.watchers;
1600
2151
  }
1601
2152
  // It's better to have a const than two Object.entries()
1602
2153
  const members = Object.entries(cmpMeta.$members$);
1603
2154
  const prototype = Cstr.prototype;
1604
2155
  members.map(([memberName, [memberFlags]]) => {
1605
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1606
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2156
+ if ((BUILD.prop || BUILD.state) &&
2157
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2158
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1607
2159
  // proxyComponent - prop
1608
2160
  Object.defineProperty(prototype, memberName, {
1609
2161
  get() {
@@ -1611,6 +2163,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1611
2163
  return getValue(this, memberName);
1612
2164
  },
1613
2165
  set(newValue) {
2166
+ // only during dev time
2167
+ if (BUILD.isDev) {
2168
+ const ref = getHostRef(this);
2169
+ if (
2170
+ // we are proxying the instance (not element)
2171
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2172
+ // the element is not constructing
2173
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2174
+ // the member is a prop
2175
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2176
+ // the member is not mutable
2177
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2178
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2179
+ }
2180
+ }
1614
2181
  // proxyComponent, set value
1615
2182
  setValue(this, memberName, newValue, cmpMeta);
1616
2183
  },
@@ -1618,7 +2185,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1618
2185
  enumerable: true,
1619
2186
  });
1620
2187
  }
1621
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2188
+ else if (BUILD.lazyLoad &&
2189
+ BUILD.method &&
2190
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1622
2191
  memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1623
2192
  // proxyComponent - method
1624
2193
  Object.defineProperty(prototype, memberName, {
@@ -1629,7 +2198,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1629
2198
  });
1630
2199
  }
1631
2200
  });
1632
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2201
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1633
2202
  const attrNameToPropName = new Map();
1634
2203
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1635
2204
  plt.jmp(() => {
@@ -1689,7 +2258,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1689
2258
  .map(([propName, m]) => {
1690
2259
  const attrName = m[1] || propName;
1691
2260
  attrNameToPropName.set(attrName, propName);
1692
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2261
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1693
2262
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1694
2263
  }
1695
2264
  return attrName;
@@ -1700,25 +2269,29 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1700
2269
  };
1701
2270
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1702
2271
  // initializeComponent
1703
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1704
- {
2272
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2273
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2274
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
1705
2275
  // we haven't initialized this element yet
1706
2276
  hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1707
2277
  // lazy loaded components
1708
2278
  // request the component's implementation to be
1709
2279
  // wired up with the host element
1710
- Cstr = loadModule(cmpMeta);
2280
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
1711
2281
  if (Cstr.then) {
1712
2282
  // Await creates a micro-task avoid if possible
1713
- const endLoad = uniqueTime();
2283
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
1714
2284
  Cstr = await Cstr;
1715
2285
  endLoad();
1716
2286
  }
1717
- if (!Cstr.isProxied) {
2287
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2288
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2289
+ }
2290
+ if (BUILD.member && !Cstr.isProxied) {
1718
2291
  // we've never proxied this Constructor before
1719
2292
  // let's add the getters/setters to its prototype before
1720
2293
  // the first time we create an instance of the implementation
1721
- {
2294
+ if (BUILD.watchCallback) {
1722
2295
  cmpMeta.$watchers$ = Cstr.watchers;
1723
2296
  }
1724
2297
  proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
@@ -1728,7 +2301,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1728
2301
  // ok, time to construct the instance
1729
2302
  // but let's keep track of when we start and stop
1730
2303
  // so that the getters/setters don't incorrectly step on data
1731
- {
2304
+ if (BUILD.member) {
1732
2305
  hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1733
2306
  }
1734
2307
  // construct the lazy-loaded component implementation
@@ -1741,21 +2314,42 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1741
2314
  catch (e) {
1742
2315
  consoleError(e);
1743
2316
  }
1744
- {
2317
+ if (BUILD.member) {
1745
2318
  hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1746
2319
  }
1747
- {
2320
+ if (BUILD.watchCallback) {
1748
2321
  hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1749
2322
  }
1750
2323
  endNewInstance();
1751
2324
  fireConnectedCallback(hostRef.$lazyInstance$);
1752
2325
  }
1753
- if (Cstr.style) {
2326
+ else {
2327
+ // sync constructor component
2328
+ Cstr = elm.constructor;
2329
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2330
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2331
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2332
+ // Stencil has completed instantiating the component.
2333
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2334
+ }
2335
+ if (BUILD.style && Cstr.style) {
1754
2336
  // this component has styles but we haven't registered them yet
1755
2337
  let style = Cstr.style;
1756
- const scopeId = getScopeId(cmpMeta);
2338
+ if (BUILD.mode && typeof style !== 'string') {
2339
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2340
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2341
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2342
+ }
2343
+ }
2344
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
1757
2345
  if (!styles.has(scopeId)) {
1758
2346
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2347
+ if (!BUILD.hydrateServerSide &&
2348
+ BUILD.shadowDom &&
2349
+ BUILD.shadowDomShim &&
2350
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2351
+ style = await Promise.resolve().then(function () { return require('./shadow-css-7e3e0ab1.js'); }).then((m) => m.scopeCss(style, scopeId, false));
2352
+ }
1759
2353
  registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1760
2354
  endRegisterStyles();
1761
2355
  }
@@ -1764,7 +2358,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1764
2358
  // we've successfully created a lazy instance
1765
2359
  const ancestorComponent = hostRef.$ancestorComponent$;
1766
2360
  const schedule = () => scheduleUpdate(hostRef, true);
1767
- if (ancestorComponent && ancestorComponent['s-rc']) {
2361
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
1768
2362
  // this is the initial load and this component it has an ancestor component
1769
2363
  // but the ancestor component has NOT fired its will update lifecycle yet
1770
2364
  // so let's just cool our jets and wait for the ancestor to continue first
@@ -1778,7 +2372,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1778
2372
  }
1779
2373
  };
1780
2374
  const fireConnectedCallback = (instance) => {
1781
- {
2375
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
1782
2376
  safeCall(instance, 'connectedCallback');
1783
2377
  }
1784
2378
  };
@@ -1787,26 +2381,49 @@ const connectedCallback = (elm) => {
1787
2381
  const hostRef = getHostRef(elm);
1788
2382
  const cmpMeta = hostRef.$cmpMeta$;
1789
2383
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2384
+ if (BUILD.hostListenerTargetParent) {
2385
+ // only run if we have listeners being attached to a parent
2386
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2387
+ }
1790
2388
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1791
2389
  // first time this component has connected
1792
2390
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1793
- {
2391
+ let hostId;
2392
+ if (BUILD.hydrateClientSide) {
2393
+ hostId = elm.getAttribute(HYDRATE_ID);
2394
+ if (hostId) {
2395
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2396
+ const scopeId = BUILD.mode
2397
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2398
+ : addStyle(elm.shadowRoot, cmpMeta);
2399
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2400
+ }
2401
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2402
+ }
2403
+ }
2404
+ if (BUILD.slotRelocation && !hostId) {
1794
2405
  // initUpdate
1795
2406
  // if the slot polyfill is required we'll need to put some nodes
1796
2407
  // in here to act as original content anchors as we move nodes around
1797
2408
  // host element has been connected to the DOM
1798
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2409
+ if (BUILD.hydrateServerSide ||
2410
+ ((BUILD.slot || BUILD.shadowDom) &&
2411
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1799
2412
  setContentReference(elm);
1800
2413
  }
1801
2414
  }
1802
- {
2415
+ if (BUILD.asyncLoading) {
1803
2416
  // find the first ancestor component (if there is one) and register
1804
2417
  // this component as one of the actively loading child components for its ancestor
1805
2418
  let ancestorComponent = elm;
1806
2419
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1807
2420
  // climb up the ancestors looking for the first
1808
2421
  // component that hasn't finished its lifecycle update yet
1809
- if (ancestorComponent['s-p']) {
2422
+ if ((BUILD.hydrateClientSide &&
2423
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2424
+ ancestorComponent.hasAttribute('s-id') &&
2425
+ ancestorComponent['s-p']) ||
2426
+ ancestorComponent['s-p']) {
1810
2427
  // we found this components first ancestor component
1811
2428
  // keep a reference to this component's ancestor component
1812
2429
  attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
@@ -1816,7 +2433,7 @@ const connectedCallback = (elm) => {
1816
2433
  }
1817
2434
  // Lazy properties
1818
2435
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1819
- if (cmpMeta.$members$) {
2436
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
1820
2437
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1821
2438
  if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1822
2439
  const value = elm[memberName];
@@ -1825,7 +2442,14 @@ const connectedCallback = (elm) => {
1825
2442
  }
1826
2443
  });
1827
2444
  }
1828
- {
2445
+ if (BUILD.initializeNextTick) {
2446
+ // connectedCallback, taskQueue, initialLoad
2447
+ // angular sets attribute AFTER connectCallback
2448
+ // https://github.com/angular/angular/issues/18909
2449
+ // https://github.com/angular/angular/issues/19940
2450
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2451
+ }
2452
+ else {
1829
2453
  initializeComponent(elm, hostRef, cmpMeta);
1830
2454
  }
1831
2455
  }
@@ -1833,7 +2457,7 @@ const connectedCallback = (elm) => {
1833
2457
  // not the first time this has connected
1834
2458
  // reattach any event listeners to the host
1835
2459
  // since they would have been removed when disconnected
1836
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2460
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
1837
2461
  // fire off connectedCallback() on component instance
1838
2462
  fireConnectedCallback(hostRef.$lazyInstance$);
1839
2463
  }
@@ -1847,28 +2471,317 @@ const setContentReference = (elm) => {
1847
2471
  // let's pick out the inner content for slot projection
1848
2472
  // create a node to represent where the original
1849
2473
  // content was first placed, which is useful later on
1850
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2474
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
1851
2475
  contentRefElm['s-cn'] = true;
1852
2476
  elm.insertBefore(contentRefElm, elm.firstChild);
1853
2477
  };
1854
2478
  const disconnectedCallback = (elm) => {
1855
2479
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1856
2480
  const hostRef = getHostRef(elm);
1857
- const instance = hostRef.$lazyInstance$ ;
1858
- {
2481
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2482
+ if (BUILD.hostListener) {
1859
2483
  if (hostRef.$rmListeners$) {
1860
2484
  hostRef.$rmListeners$.map((rmListener) => rmListener());
1861
2485
  hostRef.$rmListeners$ = undefined;
1862
2486
  }
1863
2487
  }
1864
- {
2488
+ // clear CSS var-shim tracking
2489
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2490
+ plt.$cssShim$.removeHost(elm);
2491
+ }
2492
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
1865
2493
  safeCall(instance, 'disconnectedCallback');
1866
2494
  }
2495
+ if (BUILD.cmpDidUnload) {
2496
+ safeCall(instance, 'componentDidUnload');
2497
+ }
2498
+ }
2499
+ };
2500
+ const defineCustomElement = (Cstr, compactMeta) => {
2501
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2502
+ };
2503
+ const proxyCustomElement = (Cstr, compactMeta) => {
2504
+ const cmpMeta = {
2505
+ $flags$: compactMeta[0],
2506
+ $tagName$: compactMeta[1],
2507
+ };
2508
+ if (BUILD.member) {
2509
+ cmpMeta.$members$ = compactMeta[2];
2510
+ }
2511
+ if (BUILD.hostListener) {
2512
+ cmpMeta.$listeners$ = compactMeta[3];
2513
+ }
2514
+ if (BUILD.watchCallback) {
2515
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2516
+ }
2517
+ if (BUILD.reflect) {
2518
+ cmpMeta.$attrsToReflect$ = [];
2519
+ }
2520
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2521
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2522
+ }
2523
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2524
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2525
+ Object.assign(Cstr.prototype, {
2526
+ __registerHost() {
2527
+ registerHost(this, cmpMeta);
2528
+ },
2529
+ connectedCallback() {
2530
+ connectedCallback(this);
2531
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2532
+ originalConnectedCallback.call(this);
2533
+ }
2534
+ },
2535
+ disconnectedCallback() {
2536
+ disconnectedCallback(this);
2537
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2538
+ originalDisconnectedCallback.call(this);
2539
+ }
2540
+ },
2541
+ __attachShadow() {
2542
+ if (supportsShadow) {
2543
+ if (BUILD.shadowDelegatesFocus) {
2544
+ this.attachShadow({
2545
+ mode: 'open',
2546
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2547
+ });
2548
+ }
2549
+ else {
2550
+ this.attachShadow({ mode: 'open' });
2551
+ }
2552
+ }
2553
+ else {
2554
+ this.shadowRoot = this;
2555
+ }
2556
+ },
2557
+ });
2558
+ Cstr.is = cmpMeta.$tagName$;
2559
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2560
+ };
2561
+ const forceModeUpdate = (elm) => {
2562
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2563
+ const mode = computeMode(elm);
2564
+ const hostRef = getHostRef(elm);
2565
+ if (hostRef.$modeName$ !== mode) {
2566
+ const cmpMeta = hostRef.$cmpMeta$;
2567
+ const oldScopeId = elm['s-sc'];
2568
+ const scopeId = getScopeId(cmpMeta, mode);
2569
+ const style = elm.constructor.style[mode];
2570
+ const flags = cmpMeta.$flags$;
2571
+ if (style) {
2572
+ if (!styles.has(scopeId)) {
2573
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2574
+ }
2575
+ hostRef.$modeName$ = mode;
2576
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2577
+ attachStyles(hostRef);
2578
+ forceUpdate(elm);
2579
+ }
2580
+ }
1867
2581
  }
1868
2582
  };
2583
+ const patchCloneNode = (HostElementPrototype) => {
2584
+ const orgCloneNode = HostElementPrototype.cloneNode;
2585
+ HostElementPrototype.cloneNode = function (deep) {
2586
+ const srcNode = this;
2587
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2588
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2589
+ if (BUILD.slot && !isShadowDom && deep) {
2590
+ let i = 0;
2591
+ let slotted, nonStencilNode;
2592
+ const stencilPrivates = [
2593
+ 's-id',
2594
+ 's-cr',
2595
+ 's-lr',
2596
+ 's-rc',
2597
+ 's-sc',
2598
+ 's-p',
2599
+ 's-cn',
2600
+ 's-sr',
2601
+ 's-sn',
2602
+ 's-hn',
2603
+ 's-ol',
2604
+ 's-nr',
2605
+ 's-si',
2606
+ ];
2607
+ for (; i < srcNode.childNodes.length; i++) {
2608
+ slotted = srcNode.childNodes[i]['s-nr'];
2609
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2610
+ if (slotted) {
2611
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2612
+ clonedNode.__appendChild(slotted.cloneNode(true));
2613
+ }
2614
+ else {
2615
+ clonedNode.appendChild(slotted.cloneNode(true));
2616
+ }
2617
+ }
2618
+ if (nonStencilNode) {
2619
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2620
+ }
2621
+ }
2622
+ }
2623
+ return clonedNode;
2624
+ };
2625
+ };
2626
+ const patchSlotAppendChild = (HostElementPrototype) => {
2627
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2628
+ HostElementPrototype.appendChild = function (newChild) {
2629
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2630
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2631
+ if (slotNode) {
2632
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2633
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2634
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2635
+ }
2636
+ return this.__appendChild(newChild);
2637
+ };
2638
+ };
2639
+ /**
2640
+ * Patches the text content of an unnamed slotted node inside a scoped component
2641
+ * @param hostElementPrototype the `Element` to be patched
2642
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2643
+ */
2644
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2645
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2646
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2647
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2648
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2649
+ get() {
2650
+ var _a;
2651
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2652
+ // the empty string
2653
+ const slotNode = getHostSlotNode(this.childNodes, '');
2654
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2655
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2656
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2657
+ return slotNode.nextSibling.textContent;
2658
+ }
2659
+ else if (slotNode) {
2660
+ return slotNode.textContent;
2661
+ }
2662
+ else {
2663
+ // fallback to the original implementation
2664
+ return this.__textContent;
2665
+ }
2666
+ },
2667
+ set(value) {
2668
+ var _a;
2669
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2670
+ // the empty string
2671
+ const slotNode = getHostSlotNode(this.childNodes, '');
2672
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2673
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2674
+ // sibling.
2675
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2676
+ slotNode.nextSibling.textContent = value;
2677
+ }
2678
+ else if (slotNode) {
2679
+ slotNode.textContent = value;
2680
+ }
2681
+ else {
2682
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2683
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2684
+ // it there
2685
+ this.__textContent = value;
2686
+ const contentRefElm = this['s-cr'];
2687
+ if (contentRefElm) {
2688
+ this.insertBefore(contentRefElm, this.firstChild);
2689
+ }
2690
+ }
2691
+ },
2692
+ });
2693
+ }
2694
+ };
2695
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2696
+ class FakeNodeList extends Array {
2697
+ item(n) {
2698
+ return this[n];
2699
+ }
2700
+ }
2701
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2702
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2703
+ Object.defineProperty(elm, 'children', {
2704
+ get() {
2705
+ return this.childNodes.map((n) => n.nodeType === 1);
2706
+ },
2707
+ });
2708
+ Object.defineProperty(elm, 'childElementCount', {
2709
+ get() {
2710
+ return elm.children.length;
2711
+ },
2712
+ });
2713
+ Object.defineProperty(elm, 'childNodes', {
2714
+ get() {
2715
+ const childNodes = childNodesFn.call(this);
2716
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2717
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2718
+ const result = new FakeNodeList();
2719
+ for (let i = 0; i < childNodes.length; i++) {
2720
+ const slot = childNodes[i]['s-nr'];
2721
+ if (slot) {
2722
+ result.push(slot);
2723
+ }
2724
+ }
2725
+ return result;
2726
+ }
2727
+ return FakeNodeList.from(childNodes);
2728
+ },
2729
+ });
2730
+ }
2731
+ };
2732
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2733
+ /**
2734
+ * Recursively searches a series of child nodes for a slot with the provided name.
2735
+ * @param childNodes the nodes to search for a slot with a specific name.
2736
+ * @param slotName the name of the slot to match on.
2737
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2738
+ */
2739
+ const getHostSlotNode = (childNodes, slotName) => {
2740
+ let i = 0;
2741
+ let childNode;
2742
+ for (; i < childNodes.length; i++) {
2743
+ childNode = childNodes[i];
2744
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2745
+ return childNode;
2746
+ }
2747
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2748
+ if (childNode) {
2749
+ return childNode;
2750
+ }
2751
+ }
2752
+ return null;
2753
+ };
2754
+ const getHostSlotChildNodes = (n, slotName) => {
2755
+ const childNodes = [n];
2756
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2757
+ childNodes.push(n);
2758
+ }
2759
+ return childNodes;
2760
+ };
2761
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2762
+ // ¯\_(ツ)_/¯
2763
+ const hostRef = getHostRef(elm);
2764
+ // reset state flags to only have been connected
2765
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2766
+ // TODO
2767
+ // detatch any event listeners that may have been added
2768
+ // because we're not passing an exact event name it'll
2769
+ // remove all of this element's event, which is good
2770
+ // create a callback for when this component finishes hmr
2771
+ elm['s-hmr-load'] = () => {
2772
+ // finished hmr for this element
2773
+ delete elm['s-hmr-load'];
2774
+ };
2775
+ // re-initialize the component
2776
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2777
+ };
1869
2778
  const bootstrapLazy = (lazyBundles, options = {}) => {
1870
2779
  var _a;
1871
- const endBootstrap = createTime();
2780
+ if (BUILD.profile && performance.mark) {
2781
+ performance.mark('st:app:start');
2782
+ }
2783
+ installDevTools();
2784
+ const endBootstrap = createTime('bootstrapLazy');
1872
2785
  const cmpTags = [];
1873
2786
  const exclude = options.exclude || [];
1874
2787
  const customElements = win.customElements;
@@ -1876,10 +2789,27 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1876
2789
  const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1877
2790
  const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1878
2791
  const deferredConnectedCallbacks = [];
2792
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1879
2793
  let appLoadFallback;
1880
2794
  let isBootstrapping = true;
2795
+ let i = 0;
1881
2796
  Object.assign(plt, options);
1882
2797
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2798
+ if (BUILD.asyncQueue) {
2799
+ if (options.syncQueue) {
2800
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2801
+ }
2802
+ }
2803
+ if (BUILD.hydrateClientSide) {
2804
+ // If the app is already hydrated there is not point to disable the
2805
+ // async queue. This will improve the first input delay
2806
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2807
+ }
2808
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2809
+ for (; i < styles.length; i++) {
2810
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2811
+ }
2812
+ }
1883
2813
  lazyBundles.map((lazyBundle) => {
1884
2814
  lazyBundle[1].map((compactMeta) => {
1885
2815
  const cmpMeta = {
@@ -1888,19 +2818,24 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1888
2818
  $members$: compactMeta[2],
1889
2819
  $listeners$: compactMeta[3],
1890
2820
  };
1891
- {
2821
+ if (BUILD.member) {
1892
2822
  cmpMeta.$members$ = compactMeta[2];
1893
2823
  }
1894
- {
2824
+ if (BUILD.hostListener) {
1895
2825
  cmpMeta.$listeners$ = compactMeta[3];
1896
2826
  }
1897
- {
2827
+ if (BUILD.reflect) {
1898
2828
  cmpMeta.$attrsToReflect$ = [];
1899
2829
  }
1900
- {
2830
+ if (BUILD.watchCallback) {
1901
2831
  cmpMeta.$watchers$ = {};
1902
2832
  }
1903
- const tagName = cmpMeta.$tagName$;
2833
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2834
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2835
+ }
2836
+ const tagName = BUILD.transformTagName && options.transformTagName
2837
+ ? options.transformTagName(cmpMeta.$tagName$)
2838
+ : cmpMeta.$tagName$;
1904
2839
  const HostElement = class extends HTMLElement {
1905
2840
  // StencilLazyHost
1906
2841
  constructor(self) {
@@ -1908,16 +2843,28 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1908
2843
  super(self);
1909
2844
  self = this;
1910
2845
  registerHost(self, cmpMeta);
1911
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2846
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1912
2847
  // this component is using shadow dom
1913
2848
  // and this browser supports shadow dom
1914
2849
  // add the read-only property "shadowRoot" to the host element
1915
2850
  // adding the shadow root build conditionals to minimize runtime
1916
- {
1917
- {
2851
+ if (supportsShadow) {
2852
+ if (BUILD.shadowDelegatesFocus) {
2853
+ self.attachShadow({
2854
+ mode: 'open',
2855
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2856
+ });
2857
+ }
2858
+ else {
1918
2859
  self.attachShadow({ mode: 'open' });
1919
2860
  }
1920
2861
  }
2862
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2863
+ self.shadowRoot = self;
2864
+ }
2865
+ }
2866
+ if (BUILD.slotChildNodesFix) {
2867
+ patchChildSlotNodes(self, cmpMeta);
1921
2868
  }
1922
2869
  }
1923
2870
  connectedCallback() {
@@ -1940,6 +2887,20 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1940
2887
  return getHostRef(this).$onReadyPromise$;
1941
2888
  }
1942
2889
  };
2890
+ if (BUILD.cloneNodeFix) {
2891
+ patchCloneNode(HostElement.prototype);
2892
+ }
2893
+ if (BUILD.appendChildSlotFix) {
2894
+ patchSlotAppendChild(HostElement.prototype);
2895
+ }
2896
+ if (BUILD.hotModuleReplacement) {
2897
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2898
+ hmrStart(this, cmpMeta, hmrVersionId);
2899
+ };
2900
+ }
2901
+ if (BUILD.scopedSlotTextContentFix) {
2902
+ patchTextContent(HostElement.prototype, cmpMeta);
2903
+ }
1943
2904
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1944
2905
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1945
2906
  cmpTags.push(tagName);
@@ -1947,7 +2908,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1947
2908
  }
1948
2909
  });
1949
2910
  });
1950
- {
2911
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
1951
2912
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1952
2913
  visibilityStyle.setAttribute('data-styles', '');
1953
2914
  // Apply CSP nonce to the style tag if it exists
@@ -1963,18 +2924,89 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1963
2924
  deferredConnectedCallbacks.map((host) => host.connectedCallback());
1964
2925
  }
1965
2926
  else {
1966
- {
2927
+ if (BUILD.profile) {
2928
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2929
+ }
2930
+ else {
1967
2931
  plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1968
2932
  }
1969
2933
  }
1970
2934
  // Fallback appLoad event
1971
2935
  endBootstrap();
1972
2936
  };
2937
+ const getConnect = (_ref, tagName) => {
2938
+ const componentOnReady = () => {
2939
+ let elm = doc.querySelector(tagName);
2940
+ if (!elm) {
2941
+ elm = doc.createElement(tagName);
2942
+ doc.body.appendChild(elm);
2943
+ }
2944
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2945
+ };
2946
+ const create = (...args) => {
2947
+ return componentOnReady().then((el) => el.create(...args));
2948
+ };
2949
+ return {
2950
+ create,
2951
+ componentOnReady,
2952
+ };
2953
+ };
2954
+ const getContext = (_elm, context) => {
2955
+ if (context in Context) {
2956
+ return Context[context];
2957
+ }
2958
+ else if (context === 'window') {
2959
+ return win;
2960
+ }
2961
+ else if (context === 'document') {
2962
+ return doc;
2963
+ }
2964
+ else if (context === 'isServer' || context === 'isPrerender') {
2965
+ return BUILD.hydrateServerSide ? true : false;
2966
+ }
2967
+ else if (context === 'isClient') {
2968
+ return BUILD.hydrateServerSide ? false : true;
2969
+ }
2970
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2971
+ return getAssetPath('.');
2972
+ }
2973
+ else if (context === 'queue') {
2974
+ return {
2975
+ write: writeTask,
2976
+ read: readTask,
2977
+ tick: {
2978
+ then(cb) {
2979
+ return nextTick(cb);
2980
+ },
2981
+ },
2982
+ };
2983
+ }
2984
+ return undefined;
2985
+ };
1973
2986
  const Fragment = (_, children) => children;
1974
2987
  const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1975
- if (listeners) {
2988
+ if (BUILD.hostListener && listeners) {
2989
+ // this is called immediately within the element's constructor
2990
+ // initialize our event listeners on the host element
2991
+ // we do this now so that we can listen to events that may
2992
+ // have fired even before the instance is ready
2993
+ if (BUILD.hostListenerTargetParent) {
2994
+ // this component may have event listeners that should be attached to the parent
2995
+ if (attachParentListeners) {
2996
+ // this is being ran from within the connectedCallback
2997
+ // which is important so that we know the host element actually has a parent element
2998
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2999
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
3000
+ }
3001
+ else {
3002
+ // this is being ran from within the component constructor
3003
+ // everything BUT the parent element listeners should be attached at this time
3004
+ // filter out the listeners that are NOT being attached to the parent
3005
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
3006
+ }
3007
+ }
1976
3008
  listeners.map(([flags, name, method]) => {
1977
- const target = getHostListenerTarget(elm, flags) ;
3009
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
1978
3010
  const handler = hostListenerProxy(hostRef, method);
1979
3011
  const opts = hostListenerOpts(flags);
1980
3012
  plt.ael(target, name, handler, opts);
@@ -1984,7 +3016,7 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
1984
3016
  };
1985
3017
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
1986
3018
  try {
1987
- {
3019
+ if (BUILD.lazyLoad) {
1988
3020
  if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1989
3021
  // instance is ready, let's call it's member method for this event
1990
3022
  hostRef.$lazyInstance$[methodName](ev);
@@ -1993,20 +3025,32 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1993
3025
  (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1994
3026
  }
1995
3027
  }
3028
+ else {
3029
+ hostRef.$hostElement$[methodName](ev);
3030
+ }
1996
3031
  }
1997
3032
  catch (e) {
1998
3033
  consoleError(e);
1999
3034
  }
2000
3035
  };
2001
3036
  const getHostListenerTarget = (elm, flags) => {
2002
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3037
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3038
+ return doc;
3039
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2003
3040
  return win;
2004
- if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
3041
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
2005
3042
  return doc.body;
3043
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3044
+ return elm.parentElement;
2006
3045
  return elm;
2007
3046
  };
2008
3047
  // prettier-ignore
2009
- const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3048
+ const hostListenerOpts = (flags) => supportsListenerOptions
3049
+ ? ({
3050
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3051
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3052
+ })
3053
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2010
3054
  /**
2011
3055
  * Assigns the given value to the nonce property on the runtime platform object.
2012
3056
  * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
@@ -2014,6 +3058,146 @@ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !==
2014
3058
  * @returns void
2015
3059
  */
2016
3060
  const setNonce = (nonce) => (plt.$nonce$ = nonce);
3061
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
3062
+ const insertVdomAnnotations = (doc, staticComponents) => {
3063
+ if (doc != null) {
3064
+ const docData = {
3065
+ hostIds: 0,
3066
+ rootLevelIds: 0,
3067
+ staticComponents: new Set(staticComponents),
3068
+ };
3069
+ const orgLocationNodes = [];
3070
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3071
+ orgLocationNodes.forEach((orgLocationNode) => {
3072
+ if (orgLocationNode != null) {
3073
+ const nodeRef = orgLocationNode['s-nr'];
3074
+ let hostId = nodeRef['s-host-id'];
3075
+ let nodeId = nodeRef['s-node-id'];
3076
+ let childId = `${hostId}.${nodeId}`;
3077
+ if (hostId == null) {
3078
+ hostId = 0;
3079
+ docData.rootLevelIds++;
3080
+ nodeId = docData.rootLevelIds;
3081
+ childId = `${hostId}.${nodeId}`;
3082
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3083
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3084
+ }
3085
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
3086
+ if (hostId === 0) {
3087
+ const textContent = nodeRef.nodeValue.trim();
3088
+ if (textContent === '') {
3089
+ // useless whitespace node at the document root
3090
+ orgLocationNode.remove();
3091
+ return;
3092
+ }
3093
+ }
3094
+ const commentBeforeTextNode = doc.createComment(childId);
3095
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3096
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3097
+ }
3098
+ }
3099
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3100
+ const orgLocationParentNode = orgLocationNode.parentElement;
3101
+ if (orgLocationParentNode) {
3102
+ if (orgLocationParentNode['s-en'] === '') {
3103
+ // ending with a "." means that the parent element
3104
+ // of this node's original location is a SHADOW dom element
3105
+ // and this node is apart of the root level light dom
3106
+ orgLocationNodeId += `.`;
3107
+ }
3108
+ else if (orgLocationParentNode['s-en'] === 'c') {
3109
+ // ending with a ".c" means that the parent element
3110
+ // of this node's original location is a SCOPED element
3111
+ // and this node is apart of the root level light dom
3112
+ orgLocationNodeId += `.c`;
3113
+ }
3114
+ }
3115
+ orgLocationNode.nodeValue = orgLocationNodeId;
3116
+ }
3117
+ });
3118
+ }
3119
+ };
3120
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3121
+ if (node == null) {
3122
+ return;
3123
+ }
3124
+ if (node['s-nr'] != null) {
3125
+ orgLocationNodes.push(node);
3126
+ }
3127
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3128
+ node.childNodes.forEach((childNode) => {
3129
+ const hostRef = getHostRef(childNode);
3130
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3131
+ const cmpData = {
3132
+ nodeIds: 0,
3133
+ };
3134
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3135
+ }
3136
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3137
+ });
3138
+ }
3139
+ };
3140
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3141
+ if (vnode != null) {
3142
+ const hostId = ++docData.hostIds;
3143
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3144
+ if (hostElm['s-cr'] != null) {
3145
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3146
+ }
3147
+ if (vnode.$children$ != null) {
3148
+ const depth = 0;
3149
+ vnode.$children$.forEach((vnodeChild, index) => {
3150
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3151
+ });
3152
+ }
3153
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3154
+ const parent = hostElm.parentElement;
3155
+ if (parent && parent.childNodes) {
3156
+ const parentChildNodes = Array.from(parent.childNodes);
3157
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3158
+ if (comment) {
3159
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3160
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3161
+ }
3162
+ }
3163
+ }
3164
+ }
3165
+ };
3166
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3167
+ const childElm = vnodeChild.$elm$;
3168
+ if (childElm == null) {
3169
+ return;
3170
+ }
3171
+ const nodeId = cmpData.nodeIds++;
3172
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3173
+ childElm['s-host-id'] = hostId;
3174
+ childElm['s-node-id'] = nodeId;
3175
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3176
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3177
+ }
3178
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3179
+ const parentNode = childElm.parentNode;
3180
+ const nodeName = parentNode.nodeName;
3181
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3182
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3183
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3184
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3185
+ }
3186
+ }
3187
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3188
+ if (childElm['s-sr']) {
3189
+ const slotName = childElm['s-sn'] || '';
3190
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3191
+ childElm.nodeValue = slotNodeId;
3192
+ }
3193
+ }
3194
+ if (vnodeChild.$children$ != null) {
3195
+ const childDepth = depth + 1;
3196
+ vnodeChild.$children$.forEach((vnode, index) => {
3197
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3198
+ });
3199
+ }
3200
+ };
2017
3201
  const hostRefs = /*@__PURE__*/ new WeakMap();
2018
3202
  const getHostRef = (ref) => hostRefs.get(ref);
2019
3203
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -2024,25 +3208,42 @@ const registerHost = (elm, cmpMeta) => {
2024
3208
  $cmpMeta$: cmpMeta,
2025
3209
  $instanceValues$: new Map(),
2026
3210
  };
2027
- {
3211
+ if (BUILD.isDev) {
3212
+ hostRef.$renderCount$ = 0;
3213
+ }
3214
+ if (BUILD.method && BUILD.lazyLoad) {
2028
3215
  hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2029
3216
  }
2030
- {
3217
+ if (BUILD.asyncLoading) {
2031
3218
  hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2032
3219
  elm['s-p'] = [];
2033
3220
  elm['s-rc'] = [];
2034
3221
  }
2035
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
3222
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2036
3223
  return hostRefs.set(elm, hostRef);
2037
3224
  };
2038
3225
  const isMemberInElement = (elm, memberName) => memberName in elm;
2039
- const consoleError = (e, el) => (0, console.error)(e, el);
3226
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3227
+ const STENCIL_DEV_MODE = BUILD.isTesting
3228
+ ? ['STENCIL:'] // E2E testing
3229
+ : [
3230
+ '%cstencil',
3231
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3232
+ ];
3233
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3234
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3235
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3236
+ const setErrorHandler = (handler) => (customError = handler);
2040
3237
  const cmpModules = /*@__PURE__*/ new Map();
2041
3238
  const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2042
3239
  // loadModuleImport
2043
3240
  const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2044
3241
  const bundleId = cmpMeta.$lazyBundleId$;
2045
- const module = cmpModules.get(bundleId) ;
3242
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3243
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3244
+ return undefined;
3245
+ }
3246
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
2046
3247
  if (module) {
2047
3248
  return module[exportName];
2048
3249
  }
@@ -2126,6 +3327,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2126
3327
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2127
3328
  /* webpackMode: "lazy" */
2128
3329
  './snk-custom-slot-elements.cjs.entry.js')); }).then(processMod, consoleError);
3330
+ case 'snk-custom-slot-guide.cjs':
3331
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
3332
+ /* webpackMode: "lazy" */
3333
+ './snk-custom-slot-guide.cjs.entry.js')); }).then(processMod, consoleError);
2129
3334
  case 'snk-entity-list.cjs':
2130
3335
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2131
3336
  /* webpackMode: "lazy" */
@@ -2249,16 +3454,20 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2249
3454
  /* webpackInclude: /\.entry\.js$/ */
2250
3455
  /* webpackExclude: /\.system\.entry\.js$/ */
2251
3456
  /* webpackMode: "lazy" */
2252
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
2253
- {
3457
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then((importedModule) => {
3458
+ if (!BUILD.hotModuleReplacement) {
2254
3459
  cmpModules.set(bundleId, importedModule);
2255
3460
  }
2256
3461
  return importedModule[exportName];
2257
3462
  }, consoleError);
2258
3463
  };
2259
3464
  const styles = /*@__PURE__*/ new Map();
3465
+ const modeResolutionChain = [];
2260
3466
  const win = typeof window !== 'undefined' ? window : {};
3467
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
2261
3468
  const doc = win.document || { head: {} };
3469
+ const H = (win.HTMLElement || class {
3470
+ });
2262
3471
  const plt = {
2263
3472
  $flags$: 0,
2264
3473
  $resourcesUrl$: '',
@@ -2268,8 +3477,27 @@ const plt = {
2268
3477
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2269
3478
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
2270
3479
  };
3480
+ const setPlatformHelpers = (helpers) => {
3481
+ Object.assign(plt, helpers);
3482
+ };
3483
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3484
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3485
+ : true;
3486
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3487
+ let supportsListenerOptions = false;
3488
+ try {
3489
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3490
+ get() {
3491
+ supportsListenerOptions = true;
3492
+ },
3493
+ }));
3494
+ }
3495
+ catch (e) { }
3496
+ return supportsListenerOptions;
3497
+ })();
2271
3498
  const promiseResolve = (v) => Promise.resolve(v);
2272
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
3499
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3500
+ ? /*@__PURE__*/ (() => {
2273
3501
  try {
2274
3502
  new CSSStyleSheet();
2275
3503
  return typeof new CSSStyleSheet().replaceSync === 'function';
@@ -2277,9 +3505,10 @@ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2277
3505
  catch (e) { }
2278
3506
  return false;
2279
3507
  })()
2280
- ;
3508
+ : false;
2281
3509
  const queueDomReads = [];
2282
3510
  const queueDomWrites = [];
3511
+ const queueDomWritesLow = [];
2283
3512
  const queueTask = (queue, write) => (cb) => {
2284
3513
  queue.push(cb);
2285
3514
  if (!queuePending) {
@@ -2303,13 +3532,53 @@ const consume = (queue) => {
2303
3532
  }
2304
3533
  queue.length = 0;
2305
3534
  };
3535
+ const consumeTimeout = (queue, timeout) => {
3536
+ let i = 0;
3537
+ let ts = 0;
3538
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3539
+ try {
3540
+ queue[i++](ts);
3541
+ }
3542
+ catch (e) {
3543
+ consoleError(e);
3544
+ }
3545
+ }
3546
+ if (i === queue.length) {
3547
+ queue.length = 0;
3548
+ }
3549
+ else if (i !== 0) {
3550
+ queue.splice(0, i);
3551
+ }
3552
+ };
2306
3553
  const flush = () => {
3554
+ if (BUILD.asyncQueue) {
3555
+ queueCongestion++;
3556
+ }
2307
3557
  // always force a bunch of medium callbacks to run, but still have
2308
3558
  // a throttle on how many can run in a certain time
2309
3559
  // DOM READS!!!
2310
3560
  consume(queueDomReads);
2311
3561
  // DOM WRITES!!!
2312
- {
3562
+ if (BUILD.asyncQueue) {
3563
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3564
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3565
+ : Infinity;
3566
+ consumeTimeout(queueDomWrites, timeout);
3567
+ consumeTimeout(queueDomWritesLow, timeout);
3568
+ if (queueDomWrites.length > 0) {
3569
+ queueDomWritesLow.push(...queueDomWrites);
3570
+ queueDomWrites.length = 0;
3571
+ }
3572
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3573
+ // still more to do yet, but we've run out of time
3574
+ // let's let this thing cool off and try again in the next tick
3575
+ plt.raf(flush);
3576
+ }
3577
+ else {
3578
+ queueCongestion = 0;
3579
+ }
3580
+ }
3581
+ else {
2313
3582
  consume(queueDomWrites);
2314
3583
  if ((queuePending = queueDomReads.length > 0)) {
2315
3584
  // still more to do yet, but we've run out of time
@@ -2319,16 +3588,91 @@ const flush = () => {
2319
3588
  }
2320
3589
  };
2321
3590
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3591
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
2322
3592
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2323
3593
 
3594
+ const StencilCore = /*#__PURE__*/Object.freeze({
3595
+ __proto__: null,
3596
+ Build: Build,
3597
+ CSS: CSS,
3598
+ Context: Context,
3599
+ Fragment: Fragment,
3600
+ H: H,
3601
+ HTMLElement: H,
3602
+ Host: Host,
3603
+ STENCIL_DEV_MODE: STENCIL_DEV_MODE,
3604
+ addHostEventListeners: addHostEventListeners,
3605
+ bootstrapLazy: bootstrapLazy,
3606
+ cmpModules: cmpModules,
3607
+ connectedCallback: connectedCallback,
3608
+ consoleDevError: consoleDevError,
3609
+ consoleDevInfo: consoleDevInfo,
3610
+ consoleDevWarn: consoleDevWarn,
3611
+ consoleError: consoleError,
3612
+ createEvent: createEvent,
3613
+ defineCustomElement: defineCustomElement,
3614
+ disconnectedCallback: disconnectedCallback,
3615
+ doc: doc,
3616
+ forceModeUpdate: forceModeUpdate,
3617
+ forceUpdate: forceUpdate,
3618
+ getAssetPath: getAssetPath,
3619
+ getConnect: getConnect,
3620
+ getContext: getContext,
3621
+ getElement: getElement,
3622
+ getHostRef: getHostRef,
3623
+ getMode: getMode,
3624
+ getRenderingRef: getRenderingRef,
3625
+ getValue: getValue,
3626
+ h: h,
3627
+ insertVdomAnnotations: insertVdomAnnotations,
3628
+ isMemberInElement: isMemberInElement,
3629
+ loadModule: loadModule,
3630
+ modeResolutionChain: modeResolutionChain,
3631
+ nextTick: nextTick,
3632
+ parsePropertyValue: parsePropertyValue,
3633
+ plt: plt,
3634
+ postUpdateComponent: postUpdateComponent,
3635
+ promiseResolve: promiseResolve,
3636
+ proxyComponent: proxyComponent,
3637
+ proxyCustomElement: proxyCustomElement,
3638
+ readTask: readTask,
3639
+ registerHost: registerHost,
3640
+ registerInstance: registerInstance,
3641
+ renderVdom: renderVdom,
3642
+ setAssetPath: setAssetPath,
3643
+ setErrorHandler: setErrorHandler,
3644
+ setMode: setMode,
3645
+ setNonce: setNonce,
3646
+ setPlatformHelpers: setPlatformHelpers,
3647
+ setPlatformOptions: setPlatformOptions,
3648
+ setValue: setValue,
3649
+ styles: styles,
3650
+ supportsConstructableStylesheets: supportsConstructableStylesheets,
3651
+ supportsListenerOptions: supportsListenerOptions,
3652
+ supportsShadow: supportsShadow,
3653
+ win: win,
3654
+ writeTask: writeTask,
3655
+ BUILD: BUILD,
3656
+ Env: Env,
3657
+ NAMESPACE: NAMESPACE
3658
+ });
3659
+
3660
+ exports.BUILD = BUILD;
3661
+ exports.CSS = CSS;
2324
3662
  exports.Fragment = Fragment;
3663
+ exports.H = H;
2325
3664
  exports.Host = Host;
3665
+ exports.NAMESPACE = NAMESPACE;
3666
+ exports.StencilCore = StencilCore;
2326
3667
  exports.bootstrapLazy = bootstrapLazy;
3668
+ exports.consoleDevInfo = consoleDevInfo;
2327
3669
  exports.createEvent = createEvent;
3670
+ exports.doc = doc;
2328
3671
  exports.forceUpdate = forceUpdate;
2329
3672
  exports.getElement = getElement;
2330
- exports.getRenderingRef = getRenderingRef;
2331
3673
  exports.h = h;
3674
+ exports.plt = plt;
2332
3675
  exports.promiseResolve = promiseResolve;
2333
3676
  exports.registerInstance = registerInstance;
2334
3677
  exports.setNonce = setNonce;
3678
+ exports.win = win;