@swisspost/internet-header 1.13.8 → 1.13.10

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 (229) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-e9ddb87b.js +1386 -0
  3. package/dist/cjs/index.cjs.js +15 -15
  4. package/dist/cjs/{language.service-94409b3d.js → language.service-8320b331.js} +1 -1
  5. package/dist/cjs/loader.cjs.js +4 -2
  6. package/dist/cjs/{post-internet-breadcrumbs-d8a0a3e6.js → post-internet-breadcrumbs-09c2485b.js} +26 -11
  7. package/dist/cjs/post-internet-footer-8c6e2179.js +163 -0
  8. package/dist/cjs/{post-internet-header-c487fe28.js → post-internet-header-d7fbc29b.js} +29 -28
  9. package/dist/cjs/post-klp-login-widget-59fa70e2.js +62 -0
  10. package/dist/cjs/post-klp-login-widget.cjs.entry.js +5 -5
  11. package/dist/cjs/{post-language-switch-89769c16.js → post-language-switch-8b73236a.js} +6 -6
  12. package/dist/cjs/post-language-switch.cjs.entry.js +6 -6
  13. package/dist/cjs/{post-logo-0b0d8277.js → post-logo-5ebbdc72.js} +3 -3
  14. package/dist/cjs/post-logo.cjs.entry.js +3 -3
  15. package/dist/cjs/{post-main-navigation-05ac62f4.js → post-main-navigation-ce12e638.js} +6 -6
  16. package/dist/cjs/post-main-navigation.cjs.entry.js +6 -6
  17. package/dist/cjs/{post-meta-navigation-19db7f19.js → post-meta-navigation-0216753f.js} +3 -3
  18. package/dist/cjs/post-meta-navigation.cjs.entry.js +3 -3
  19. package/dist/cjs/post-search-8cdb662e.js +596 -0
  20. package/dist/cjs/post-search.cjs.entry.js +6 -6
  21. package/dist/cjs/{post-skiplinks-b1ea7588.js → post-skiplinks-29c1973b.js} +4 -4
  22. package/dist/cjs/post-skiplinks.cjs.entry.js +5 -5
  23. package/dist/cjs/{store-9f3cc50a.js → store-aac36a39.js} +1 -1
  24. package/dist/cjs/{svg-icon.component-980da2bc.js → svg-icon.component-c5427667.js} +1 -1
  25. package/dist/cjs/{svg-sprite.component-6d4865e1.js → svg-sprite.component-34a4da43.js} +1 -1
  26. package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js +6 -6
  27. package/dist/cjs/swisspost-internet-footer.cjs.entry.js +5 -5
  28. package/dist/cjs/swisspost-internet-header.cjs.entry.js +6 -6
  29. package/dist/cjs/swisspost-internet-header.cjs.js +12 -10
  30. package/dist/collection/collection-manifest.json +2 -2
  31. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.css +2 -2
  32. package/dist/collection/components/post-internet-footer/components/post-footer-block-contact.component.js +7 -4
  33. package/dist/collection/components/post-internet-footer/post-internet-footer.css +1 -1
  34. package/dist/collection/components/post-internet-header/post-internet-header.css +1 -1
  35. package/dist/collection/components/post-internet-header/post-internet-header.js +2 -2
  36. package/dist/collection/components/post-klp-login-widget/post-klp-login-widget.css +2 -2
  37. package/dist/collection/components/post-language-switch/post-language-switch.css +1 -1
  38. package/dist/collection/components/post-logo/post-logo.css +1 -1
  39. package/dist/collection/components/post-main-navigation/post-main-navigation.css +1 -1
  40. package/dist/collection/components/post-meta-navigation/post-meta-navigation.css +1 -1
  41. package/dist/collection/components/post-search/post-search.css +5 -5
  42. package/dist/collection/models/geocode.model.js +8 -9
  43. package/dist/components/post-klp-login-widget2.js +1 -1
  44. package/dist/components/post-language-switch2.js +1 -1
  45. package/dist/components/post-logo2.js +1 -1
  46. package/dist/components/post-main-navigation2.js +1 -1
  47. package/dist/components/post-meta-navigation2.js +1 -1
  48. package/dist/components/post-search2.js +1 -1
  49. package/dist/components/swisspost-internet-breadcrumbs.js +21 -6
  50. package/dist/components/swisspost-internet-footer.js +8 -5
  51. package/dist/components/swisspost-internet-header.js +24 -23
  52. package/dist/docs.d.ts +34 -0
  53. package/dist/docs.json +10 -4
  54. package/dist/esm/app-globals-0f993ce5.js +3 -0
  55. package/dist/esm/index-9deab2c6.js +1355 -0
  56. package/dist/esm/index.js +15 -15
  57. package/dist/esm/{language.service-9ba7302b.js → language.service-e186d7dd.js} +1 -1
  58. package/dist/esm/loader.js +5 -3
  59. package/dist/esm/{post-internet-breadcrumbs-959c559a.js → post-internet-breadcrumbs-7ae97585.js} +26 -11
  60. package/dist/esm/post-internet-footer-c9b6481e.js +161 -0
  61. package/dist/esm/{post-internet-header-3ed27a33.js → post-internet-header-f7d3d57b.js} +29 -28
  62. package/dist/esm/post-klp-login-widget-f138e519.js +60 -0
  63. package/dist/esm/post-klp-login-widget.entry.js +5 -5
  64. package/dist/esm/{post-language-switch-f436d101.js → post-language-switch-313a6a5c.js} +6 -6
  65. package/dist/esm/post-language-switch.entry.js +6 -6
  66. package/dist/esm/{post-logo-9dbcf2ba.js → post-logo-1e5668dc.js} +3 -3
  67. package/dist/esm/post-logo.entry.js +3 -3
  68. package/dist/esm/{post-main-navigation-9fd0b55a.js → post-main-navigation-45e3060f.js} +6 -6
  69. package/dist/esm/post-main-navigation.entry.js +6 -6
  70. package/dist/esm/{post-meta-navigation-8820113b.js → post-meta-navigation-01dc595f.js} +3 -3
  71. package/dist/esm/post-meta-navigation.entry.js +3 -3
  72. package/dist/esm/post-search-3a9f21c4.js +594 -0
  73. package/dist/esm/post-search.entry.js +6 -6
  74. package/dist/esm/{post-skiplinks-e294cb04.js → post-skiplinks-b6f29605.js} +4 -4
  75. package/dist/esm/post-skiplinks.entry.js +5 -5
  76. package/dist/esm/{store-d0d3a586.js → store-29728e96.js} +1 -1
  77. package/dist/esm/{svg-icon.component-bf11f33c.js → svg-icon.component-58139665.js} +1 -1
  78. package/dist/esm/{svg-sprite.component-bc8c39ee.js → svg-sprite.component-f4f3f81e.js} +1 -1
  79. package/dist/esm/swisspost-internet-breadcrumbs.entry.js +6 -6
  80. package/dist/esm/swisspost-internet-footer.entry.js +5 -5
  81. package/dist/esm/swisspost-internet-header.entry.js +6 -6
  82. package/dist/esm/swisspost-internet-header.js +13 -11
  83. package/dist/esm-es5/app-globals-0f993ce5.js +1 -0
  84. package/dist/esm-es5/index-9deab2c6.js +1 -0
  85. package/dist/esm-es5/index.js +1 -1
  86. package/dist/esm-es5/{language.service-9ba7302b.js → language.service-e186d7dd.js} +1 -1
  87. package/dist/esm-es5/loader.js +1 -1
  88. package/dist/esm-es5/post-internet-breadcrumbs-7ae97585.js +6 -0
  89. package/dist/esm-es5/post-internet-footer-c9b6481e.js +1 -0
  90. package/dist/esm-es5/post-internet-header-f7d3d57b.js +1 -0
  91. package/dist/esm-es5/post-klp-login-widget-f138e519.js +1 -0
  92. package/dist/esm-es5/post-klp-login-widget.entry.js +1 -1
  93. package/dist/esm-es5/post-language-switch-313a6a5c.js +1 -0
  94. package/dist/esm-es5/post-language-switch.entry.js +1 -1
  95. package/dist/esm-es5/{post-logo-9dbcf2ba.js → post-logo-1e5668dc.js} +1 -1
  96. package/dist/esm-es5/post-logo.entry.js +1 -1
  97. package/dist/esm-es5/post-main-navigation-45e3060f.js +1 -0
  98. package/dist/esm-es5/post-main-navigation.entry.js +1 -1
  99. package/dist/esm-es5/{post-meta-navigation-8820113b.js → post-meta-navigation-01dc595f.js} +1 -1
  100. package/dist/esm-es5/post-meta-navigation.entry.js +1 -1
  101. package/dist/esm-es5/post-search-3a9f21c4.js +1 -0
  102. package/dist/esm-es5/post-search.entry.js +1 -1
  103. package/dist/esm-es5/{post-skiplinks-e294cb04.js → post-skiplinks-b6f29605.js} +1 -1
  104. package/dist/esm-es5/post-skiplinks.entry.js +1 -1
  105. package/dist/esm-es5/{store-d0d3a586.js → store-29728e96.js} +1 -1
  106. package/dist/esm-es5/svg-icon.component-58139665.js +1 -0
  107. package/dist/esm-es5/{svg-sprite.component-bc8c39ee.js → svg-sprite.component-f4f3f81e.js} +1 -1
  108. package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js +1 -1
  109. package/dist/esm-es5/swisspost-internet-footer.entry.js +1 -1
  110. package/dist/esm-es5/swisspost-internet-header.entry.js +1 -1
  111. package/dist/esm-es5/swisspost-internet-header.js +1 -1
  112. package/dist/swisspost-internet-header/index.esm.js +1 -1
  113. package/dist/swisspost-internet-header/p-033f4fbe.entry.js +1 -0
  114. package/dist/swisspost-internet-header/p-057f32b6.js +1 -0
  115. package/dist/swisspost-internet-header/p-079867d3.system.js +1 -0
  116. package/dist/swisspost-internet-header/p-116b8ff0.system.js +1 -0
  117. package/dist/swisspost-internet-header/p-17c754f2.entry.js +1 -0
  118. package/dist/swisspost-internet-header/p-1b37bb14.js +2 -0
  119. package/dist/swisspost-internet-header/p-24f83792.entry.js +1 -0
  120. package/dist/swisspost-internet-header/p-2afa4d26.system.js +1 -0
  121. package/dist/swisspost-internet-header/{p-d48da09e.system.js → p-2dcaaac5.system.js} +1 -1
  122. package/dist/swisspost-internet-header/{p-925f5e31.js → p-2e00bab4.js} +1 -1
  123. package/dist/swisspost-internet-header/p-3457f6d9.js +1 -0
  124. package/dist/swisspost-internet-header/{p-4ebec8fe.js → p-35a9d4ae.js} +1 -1
  125. package/dist/swisspost-internet-header/p-3b1ccdab.entry.js +1 -0
  126. package/dist/swisspost-internet-header/p-40b1e640.entry.js +1 -0
  127. package/dist/swisspost-internet-header/p-455e3b4e.entry.js +1 -0
  128. package/dist/swisspost-internet-header/p-4d9ca96c.system.entry.js +1 -0
  129. package/dist/swisspost-internet-header/{p-de624726.system.js → p-4eea8bcd.system.js} +1 -1
  130. package/dist/swisspost-internet-header/p-52ab2e14.system.entry.js +1 -0
  131. package/dist/swisspost-internet-header/p-56ba5cbf.system.js +1 -0
  132. package/dist/swisspost-internet-header/p-6262f647.entry.js +1 -0
  133. package/dist/swisspost-internet-header/p-65ba132d.entry.js +1 -0
  134. package/dist/swisspost-internet-header/{p-50db8a7b.js → p-678019cb.js} +1 -1
  135. package/dist/swisspost-internet-header/p-6a8338b7.system.entry.js +1 -0
  136. package/dist/swisspost-internet-header/{p-425336ef.js → p-6ec4bb44.js} +1 -1
  137. package/dist/swisspost-internet-header/p-70bd4f89.system.entry.js +1 -0
  138. package/dist/swisspost-internet-header/p-71b946fc.system.entry.js +1 -0
  139. package/dist/swisspost-internet-header/p-72d70641.js +1 -0
  140. package/dist/swisspost-internet-header/p-752d6e46.system.js +1 -0
  141. package/dist/swisspost-internet-header/p-760b8d08.system.entry.js +1 -0
  142. package/dist/swisspost-internet-header/p-786a288d.system.entry.js +1 -0
  143. package/dist/swisspost-internet-header/{p-28a03b44.system.js → p-7a585242.system.js} +1 -1
  144. package/dist/swisspost-internet-header/{p-a0ddb772.system.js → p-7bd55d1d.system.js} +1 -1
  145. package/dist/swisspost-internet-header/{p-c97c081c.js → p-85813a11.js} +1 -1
  146. package/dist/swisspost-internet-header/p-863de8cb.js +1 -0
  147. package/dist/swisspost-internet-header/p-8983c9bd.system.entry.js +1 -0
  148. package/dist/swisspost-internet-header/p-8b4c6f7c.system.js +2 -0
  149. package/dist/swisspost-internet-header/{p-b180a9c6.js → p-94ddd446.js} +1 -1
  150. package/dist/swisspost-internet-header/p-a4afbf29.system.js +1 -0
  151. package/dist/swisspost-internet-header/{p-1e8226df.system.js → p-a881c817.system.js} +1 -1
  152. package/dist/swisspost-internet-header/p-adbbadae.entry.js +1 -0
  153. package/dist/swisspost-internet-header/p-b9a4af9f.system.js +1 -0
  154. package/dist/swisspost-internet-header/p-bde95a71.system.js +1 -0
  155. package/dist/swisspost-internet-header/p-cb1c5219.js +1 -1
  156. package/dist/swisspost-internet-header/{p-941fb537.system.js → p-d0793471.system.js} +1 -1
  157. package/dist/swisspost-internet-header/p-d11efd7d.system.js +6 -0
  158. package/dist/swisspost-internet-header/p-d7a9b5b7.js +1 -0
  159. package/dist/swisspost-internet-header/{p-c3a2dbaf.js → p-d7b3988c.js} +1 -1
  160. package/dist/swisspost-internet-header/{p-ef26af95.system.js → p-de3a8e62.system.js} +1 -1
  161. package/dist/swisspost-internet-header/{p-2a288ef4.js → p-dfd42dc7.js} +1 -1
  162. package/dist/swisspost-internet-header/p-e04d5ef8.js +6 -0
  163. package/dist/swisspost-internet-header/p-e1255160.js +1 -0
  164. package/dist/swisspost-internet-header/p-e67e39f8.entry.js +1 -0
  165. package/dist/swisspost-internet-header/p-e6b441a6.system.entry.js +1 -0
  166. package/dist/swisspost-internet-header/p-eb8959b3.system.entry.js +1 -0
  167. package/dist/swisspost-internet-header/{p-d3f4cffd.system.js → p-f1bca231.system.js} +1 -1
  168. package/dist/swisspost-internet-header/swisspost-internet-header.css +1 -1
  169. package/dist/swisspost-internet-header/swisspost-internet-header.esm.js +1 -1
  170. package/dist/swisspost-internet-header/swisspost-internet-header.js +1 -1
  171. package/dist/types/components/post-internet-breadcrumbs/components/breadcrumb-list.component.d.ts +4 -4
  172. package/dist/types/components/post-internet-breadcrumbs/components/middle-dropdown.component.d.ts +1 -1
  173. package/dist/types/components/post-internet-breadcrumbs/components/overlay.component.d.ts +1 -1
  174. package/dist/types/models/geocode.model.d.ts +9 -8
  175. package/package.json +21 -20
  176. package/readme.md +2 -1
  177. package/dist/cjs/index-cab594bc.js +0 -2097
  178. package/dist/cjs/post-internet-footer-3e114492.js +0 -160
  179. package/dist/cjs/post-klp-login-widget-7a867072.js +0 -62
  180. package/dist/cjs/post-search-afd1abf7.js +0 -596
  181. package/dist/esm/index-a2152ff5.js +0 -2066
  182. package/dist/esm/post-internet-footer-f4dcfb3b.js +0 -158
  183. package/dist/esm/post-klp-login-widget-519b9ac3.js +0 -60
  184. package/dist/esm/post-search-cf91f27a.js +0 -594
  185. package/dist/esm-es5/index-a2152ff5.js +0 -1
  186. package/dist/esm-es5/post-internet-breadcrumbs-959c559a.js +0 -6
  187. package/dist/esm-es5/post-internet-footer-f4dcfb3b.js +0 -1
  188. package/dist/esm-es5/post-internet-header-3ed27a33.js +0 -1
  189. package/dist/esm-es5/post-klp-login-widget-519b9ac3.js +0 -1
  190. package/dist/esm-es5/post-language-switch-f436d101.js +0 -1
  191. package/dist/esm-es5/post-main-navigation-9fd0b55a.js +0 -1
  192. package/dist/esm-es5/post-search-cf91f27a.js +0 -1
  193. package/dist/esm-es5/svg-icon.component-bf11f33c.js +0 -1
  194. package/dist/swisspost-internet-header/p-041d7100.system.entry.js +0 -1
  195. package/dist/swisspost-internet-header/p-13332cc8.entry.js +0 -1
  196. package/dist/swisspost-internet-header/p-193b3962.js +0 -1
  197. package/dist/swisspost-internet-header/p-1cac596c.system.js +0 -1
  198. package/dist/swisspost-internet-header/p-1efced4f.system.js +0 -1
  199. package/dist/swisspost-internet-header/p-2180a93f.js +0 -6
  200. package/dist/swisspost-internet-header/p-25add306.entry.js +0 -1
  201. package/dist/swisspost-internet-header/p-31171eac.js +0 -1
  202. package/dist/swisspost-internet-header/p-328af556.entry.js +0 -1
  203. package/dist/swisspost-internet-header/p-35d3c0e2.js +0 -1
  204. package/dist/swisspost-internet-header/p-3d03ece0.entry.js +0 -1
  205. package/dist/swisspost-internet-header/p-3ff4fe31.entry.js +0 -1
  206. package/dist/swisspost-internet-header/p-458bd664.system.js +0 -1
  207. package/dist/swisspost-internet-header/p-466371f3.system.entry.js +0 -1
  208. package/dist/swisspost-internet-header/p-4f978679.system.js +0 -1
  209. package/dist/swisspost-internet-header/p-541bd306.system.entry.js +0 -1
  210. package/dist/swisspost-internet-header/p-58d1f7cd.system.js +0 -1
  211. package/dist/swisspost-internet-header/p-82cac3b9.js +0 -1
  212. package/dist/swisspost-internet-header/p-833cd107.js +0 -2
  213. package/dist/swisspost-internet-header/p-8e23a792.system.entry.js +0 -1
  214. package/dist/swisspost-internet-header/p-95753443.system.js +0 -1
  215. package/dist/swisspost-internet-header/p-9a06a83e.entry.js +0 -1
  216. package/dist/swisspost-internet-header/p-ae3759d0.entry.js +0 -1
  217. package/dist/swisspost-internet-header/p-af355dbc.system.js +0 -1
  218. package/dist/swisspost-internet-header/p-b5c47ef8.system.js +0 -2
  219. package/dist/swisspost-internet-header/p-bac2d2ca.system.entry.js +0 -1
  220. package/dist/swisspost-internet-header/p-bbd5ae03.js +0 -1
  221. package/dist/swisspost-internet-header/p-bfb5f92f.system.entry.js +0 -1
  222. package/dist/swisspost-internet-header/p-c47dfca4.entry.js +0 -1
  223. package/dist/swisspost-internet-header/p-ce698eb4.entry.js +0 -1
  224. package/dist/swisspost-internet-header/p-d91c7eb7.system.entry.js +0 -1
  225. package/dist/swisspost-internet-header/p-e0f54a55.system.entry.js +0 -1
  226. package/dist/swisspost-internet-header/p-e7934b4e.system.entry.js +0 -1
  227. package/dist/swisspost-internet-header/p-ec432905.entry.js +0 -1
  228. package/dist/swisspost-internet-header/p-ecb3a8d3.system.entry.js +0 -1
  229. package/dist/swisspost-internet-header/p-f77d823e.system.js +0 -6
@@ -1,2066 +0,0 @@
1
- const NAMESPACE = 'swisspost-internet-header';
2
-
3
- /**
4
- * Virtual DOM patching algorithm based on Snabbdom by
5
- * Simon Friis Vindum (@paldepind)
6
- * Licensed under the MIT License
7
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
8
- *
9
- * Modified for Stencil's renderer and slot projection
10
- */
11
- let scopeId;
12
- let hostTagName;
13
- let isSvgMode = false;
14
- let renderingRef = null;
15
- let queuePending = false;
16
- const createTime = (fnName, tagName = '') => {
17
- {
18
- return () => {
19
- return;
20
- };
21
- }
22
- };
23
- const uniqueTime = (key, measureText) => {
24
- {
25
- return () => {
26
- return;
27
- };
28
- }
29
- };
30
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
31
- /**
32
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
33
- *
34
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
35
- * support as of Stencil v4.
36
- */
37
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
38
- /**
39
- * Default style mode id
40
- */
41
- /**
42
- * Reusable empty obj/array
43
- * Don't add values to these!!
44
- */
45
- const EMPTY_OBJ = {};
46
- /**
47
- * Namespaces
48
- */
49
- const SVG_NS = 'http://www.w3.org/2000/svg';
50
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
51
- const isDef = (v) => v != null;
52
- /**
53
- * Check whether a value is a 'complex type', defined here as an object or a
54
- * function.
55
- *
56
- * @param o the value to check
57
- * @returns whether it's a complex type or not
58
- */
59
- const isComplexType = (o) => {
60
- // https://jsperf.com/typeof-fn-object/5
61
- o = typeof o;
62
- return o === 'object' || o === 'function';
63
- };
64
- /**
65
- * Helper method for querying a `meta` tag that contains a nonce value
66
- * out of a DOM's head.
67
- *
68
- * @param doc The DOM containing the `head` to query against
69
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
70
- * exists or the tag has no content.
71
- */
72
- function queryNonceMetaTagContent(doc) {
73
- var _a, _b, _c;
74
- return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
75
- }
76
- /**
77
- * Production h() function based on Preact by
78
- * Jason Miller (@developit)
79
- * Licensed under the MIT License
80
- * https://github.com/developit/preact/blob/master/LICENSE
81
- *
82
- * Modified for Stencil's compiler and vdom
83
- */
84
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
85
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
86
- const h = (nodeName, vnodeData, ...children) => {
87
- let child = null;
88
- let key = null;
89
- let simple = false;
90
- let lastSimple = false;
91
- const vNodeChildren = [];
92
- const walk = (c) => {
93
- for (let i = 0; i < c.length; i++) {
94
- child = c[i];
95
- if (Array.isArray(child)) {
96
- walk(child);
97
- }
98
- else if (child != null && typeof child !== 'boolean') {
99
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
100
- child = String(child);
101
- }
102
- if (simple && lastSimple) {
103
- // If the previous child was simple (string), we merge both
104
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
105
- }
106
- else {
107
- // Append a new vNode, if it's text, we create a text vNode
108
- vNodeChildren.push(simple ? newVNode(null, child) : child);
109
- }
110
- lastSimple = simple;
111
- }
112
- }
113
- };
114
- walk(children);
115
- if (vnodeData) {
116
- if (vnodeData.key) {
117
- key = vnodeData.key;
118
- }
119
- // normalize class / className attributes
120
- {
121
- const classData = vnodeData.className || vnodeData.class;
122
- if (classData) {
123
- vnodeData.class =
124
- typeof classData !== 'object'
125
- ? classData
126
- : Object.keys(classData)
127
- .filter((k) => classData[k])
128
- .join(' ');
129
- }
130
- }
131
- }
132
- if (typeof nodeName === 'function') {
133
- // nodeName is a functional component
134
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
135
- }
136
- const vnode = newVNode(nodeName, null);
137
- vnode.$attrs$ = vnodeData;
138
- if (vNodeChildren.length > 0) {
139
- vnode.$children$ = vNodeChildren;
140
- }
141
- {
142
- vnode.$key$ = key;
143
- }
144
- return vnode;
145
- };
146
- /**
147
- * A utility function for creating a virtual DOM node from a tag and some
148
- * possible text content.
149
- *
150
- * @param tag the tag for this element
151
- * @param text possible text content for the node
152
- * @returns a newly-minted virtual DOM node
153
- */
154
- const newVNode = (tag, text) => {
155
- const vnode = {
156
- $flags$: 0,
157
- $tag$: tag,
158
- $text$: text,
159
- $elm$: null,
160
- $children$: null,
161
- };
162
- {
163
- vnode.$attrs$ = null;
164
- }
165
- {
166
- vnode.$key$ = null;
167
- }
168
- return vnode;
169
- };
170
- const Host = {};
171
- /**
172
- * Check whether a given node is a Host node or not
173
- *
174
- * @param node the virtual DOM node to check
175
- * @returns whether it's a Host node or not
176
- */
177
- const isHost = (node) => node && node.$tag$ === Host;
178
- /**
179
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
180
- *
181
- * Note that these functions convert from {@link d.VNode} to
182
- * {@link d.ChildNode} to give functional component developers a friendly
183
- * interface.
184
- */
185
- const vdomFnUtils = {
186
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
187
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
188
- };
189
- /**
190
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
191
- * friendlier public interface (hence, 'convertToPublic').
192
- *
193
- * @param node the virtual DOM node to convert
194
- * @returns a converted child node
195
- */
196
- const convertToPublic = (node) => ({
197
- vattrs: node.$attrs$,
198
- vchildren: node.$children$,
199
- vkey: node.$key$,
200
- vname: node.$name$,
201
- vtag: node.$tag$,
202
- vtext: node.$text$,
203
- });
204
- /**
205
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
206
- * order to use the resulting object in the virtual DOM. The initial object was
207
- * likely created as part of presenting a public API, so converting it back
208
- * involved making it 'private' again (hence, `convertToPrivate`).
209
- *
210
- * @param node the child node to convert
211
- * @returns a converted virtual DOM node
212
- */
213
- const convertToPrivate = (node) => {
214
- if (typeof node.vtag === 'function') {
215
- const vnodeData = Object.assign({}, node.vattrs);
216
- if (node.vkey) {
217
- vnodeData.key = node.vkey;
218
- }
219
- if (node.vname) {
220
- vnodeData.name = node.vname;
221
- }
222
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
223
- }
224
- const vnode = newVNode(node.vtag, node.vtext);
225
- vnode.$attrs$ = node.vattrs;
226
- vnode.$children$ = node.vchildren;
227
- vnode.$key$ = node.vkey;
228
- vnode.$name$ = node.vname;
229
- return vnode;
230
- };
231
- /**
232
- * Parse a new property value for a given property type.
233
- *
234
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
235
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
236
- * 1. `any`, the type given to `propValue` in the function signature
237
- * 2. the type stored from `propType`.
238
- *
239
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
240
- *
241
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
242
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
243
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
244
- * ```tsx
245
- * <my-cmp prop-val={0}></my-cmp>
246
- * ```
247
- *
248
- * HTML prop values on the other hand, will always a string
249
- *
250
- * @param propValue the new value to coerce to some type
251
- * @param propType the type of the prop, expressed as a binary number
252
- * @returns the parsed/coerced value
253
- */
254
- const parsePropertyValue = (propValue, propType) => {
255
- // ensure this value is of the correct prop type
256
- if (propValue != null && !isComplexType(propValue)) {
257
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
258
- // per the HTML spec, any string value means it is a boolean true value
259
- // but we'll cheat here and say that the string "false" is the boolean false
260
- return propValue === 'false' ? false : propValue === '' || !!propValue;
261
- }
262
- if (propType & 1 /* MEMBER_FLAGS.String */) {
263
- // could have been passed as a number or boolean
264
- // but we still want it as a string
265
- return String(propValue);
266
- }
267
- // redundant return here for better minification
268
- return propValue;
269
- }
270
- // not sure exactly what type we want
271
- // so no need to change to a different type
272
- return propValue;
273
- };
274
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
275
- const createEvent = (ref, name, flags) => {
276
- const elm = getElement(ref);
277
- return {
278
- emit: (detail) => {
279
- return emitEvent(elm, name, {
280
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
281
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
282
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
283
- detail,
284
- });
285
- },
286
- };
287
- };
288
- /**
289
- * Helper function to create & dispatch a custom Event on a provided target
290
- * @param elm the target of the Event
291
- * @param name the name to give the custom Event
292
- * @param opts options for configuring a custom Event
293
- * @returns the custom Event
294
- */
295
- const emitEvent = (elm, name, opts) => {
296
- const ev = plt.ce(name, opts);
297
- elm.dispatchEvent(ev);
298
- return ev;
299
- };
300
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
301
- const registerStyle = (scopeId, cssText, allowCS) => {
302
- let style = styles.get(scopeId);
303
- if (supportsConstructableStylesheets && allowCS) {
304
- style = (style || new CSSStyleSheet());
305
- if (typeof style === 'string') {
306
- style = cssText;
307
- }
308
- else {
309
- style.replaceSync(cssText);
310
- }
311
- }
312
- else {
313
- style = cssText;
314
- }
315
- styles.set(scopeId, style);
316
- };
317
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
318
- var _a;
319
- const scopeId = getScopeId(cmpMeta);
320
- const style = styles.get(scopeId);
321
- // if an element is NOT connected then getRootNode() will return the wrong root node
322
- // so the fallback is to always use the document for the root node in those cases
323
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
324
- if (style) {
325
- if (typeof style === 'string') {
326
- styleContainerNode = styleContainerNode.head || styleContainerNode;
327
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
328
- let styleElm;
329
- if (!appliedStyles) {
330
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
331
- }
332
- if (!appliedStyles.has(scopeId)) {
333
- {
334
- styleElm = doc.createElement('style');
335
- styleElm.innerHTML = style;
336
- // Apply CSP nonce to the style tag if it exists
337
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
338
- if (nonce != null) {
339
- styleElm.setAttribute('nonce', nonce);
340
- }
341
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
342
- }
343
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
344
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
345
- styleElm.innerHTML += SLOT_FB_CSS;
346
- }
347
- if (appliedStyles) {
348
- appliedStyles.add(scopeId);
349
- }
350
- }
351
- }
352
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
353
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
354
- }
355
- }
356
- return scopeId;
357
- };
358
- const attachStyles = (hostRef) => {
359
- const cmpMeta = hostRef.$cmpMeta$;
360
- const elm = hostRef.$hostElement$;
361
- const flags = cmpMeta.$flags$;
362
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
363
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
364
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
365
- // only required when we're NOT using native shadow dom (slot)
366
- // or this browser doesn't support native shadow dom
367
- // and this host element was NOT created with SSR
368
- // let's pick out the inner content for slot projection
369
- // create a node to represent where the original
370
- // content was first placed, which is useful later on
371
- // DOM WRITE!!
372
- elm['s-sc'] = scopeId;
373
- elm.classList.add(scopeId + '-h');
374
- }
375
- endAttachStyles();
376
- };
377
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
378
- /**
379
- * Production setAccessor() function based on Preact by
380
- * Jason Miller (@developit)
381
- * Licensed under the MIT License
382
- * https://github.com/developit/preact/blob/master/LICENSE
383
- *
384
- * Modified for Stencil's compiler and vdom
385
- */
386
- /**
387
- * When running a VDom render set properties present on a VDom node onto the
388
- * corresponding HTML element.
389
- *
390
- * Note that this function has special functionality for the `class`,
391
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
392
- * `onClick`, etc). All others are just passed through as-is.
393
- *
394
- * @param elm the HTMLElement onto which attributes should be set
395
- * @param memberName the name of the attribute to set
396
- * @param oldValue the old value for the attribute
397
- * @param newValue the new value for the attribute
398
- * @param isSvg whether we're in an svg context or not
399
- * @param flags bitflags for Vdom variables
400
- */
401
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
402
- if (oldValue !== newValue) {
403
- let isProp = isMemberInElement(elm, memberName);
404
- let ln = memberName.toLowerCase();
405
- if (memberName === 'class') {
406
- const classList = elm.classList;
407
- const oldClasses = parseClassList(oldValue);
408
- const newClasses = parseClassList(newValue);
409
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
410
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
411
- }
412
- else if (memberName === 'style') {
413
- // update style attribute, css properties and values
414
- {
415
- for (const prop in oldValue) {
416
- if (!newValue || newValue[prop] == null) {
417
- if (prop.includes('-')) {
418
- elm.style.removeProperty(prop);
419
- }
420
- else {
421
- elm.style[prop] = '';
422
- }
423
- }
424
- }
425
- }
426
- for (const prop in newValue) {
427
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
428
- if (prop.includes('-')) {
429
- elm.style.setProperty(prop, newValue[prop]);
430
- }
431
- else {
432
- elm.style[prop] = newValue[prop];
433
- }
434
- }
435
- }
436
- }
437
- else if (memberName === 'key')
438
- ;
439
- else if (memberName === 'ref') {
440
- // minifier will clean this up
441
- if (newValue) {
442
- newValue(elm);
443
- }
444
- }
445
- else if ((!isProp ) &&
446
- memberName[0] === 'o' &&
447
- memberName[1] === 'n') {
448
- // Event Handlers
449
- // so if the member name starts with "on" and the 3rd characters is
450
- // a capital letter, and it's not already a member on the element,
451
- // then we're assuming it's an event listener
452
- if (memberName[2] === '-') {
453
- // on- prefixed events
454
- // allows to be explicit about the dom event to listen without any magic
455
- // under the hood:
456
- // <my-cmp on-click> // listens for "click"
457
- // <my-cmp on-Click> // listens for "Click"
458
- // <my-cmp on-ionChange> // listens for "ionChange"
459
- // <my-cmp on-EVENTS> // listens for "EVENTS"
460
- memberName = memberName.slice(3);
461
- }
462
- else if (isMemberInElement(win, ln)) {
463
- // standard event
464
- // the JSX attribute could have been "onMouseOver" and the
465
- // member name "onmouseover" is on the window's prototype
466
- // so let's add the listener "mouseover", which is all lowercased
467
- memberName = ln.slice(2);
468
- }
469
- else {
470
- // custom event
471
- // the JSX attribute could have been "onMyCustomEvent"
472
- // so let's trim off the "on" prefix and lowercase the first character
473
- // and add the listener "myCustomEvent"
474
- // except for the first character, we keep the event name case
475
- memberName = ln[2] + memberName.slice(3);
476
- }
477
- if (oldValue || newValue) {
478
- // Need to account for "capture" events.
479
- // If the event name ends with "Capture", we'll update the name to remove
480
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
481
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
482
- // Make sure we only replace the last instance of "Capture"
483
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
484
- if (oldValue) {
485
- plt.rel(elm, memberName, oldValue, capture);
486
- }
487
- if (newValue) {
488
- plt.ael(elm, memberName, newValue, capture);
489
- }
490
- }
491
- }
492
- else {
493
- // Set property if it exists and it's not a SVG
494
- const isComplex = isComplexType(newValue);
495
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
496
- try {
497
- if (!elm.tagName.includes('-')) {
498
- const n = newValue == null ? '' : newValue;
499
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
500
- if (memberName === 'list') {
501
- isProp = false;
502
- }
503
- else if (oldValue == null || elm[memberName] != n) {
504
- elm[memberName] = n;
505
- }
506
- }
507
- else {
508
- elm[memberName] = newValue;
509
- }
510
- }
511
- catch (e) {
512
- /**
513
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
514
- */
515
- }
516
- }
517
- if (newValue == null || newValue === false) {
518
- if (newValue !== false || elm.getAttribute(memberName) === '') {
519
- {
520
- elm.removeAttribute(memberName);
521
- }
522
- }
523
- }
524
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
525
- newValue = newValue === true ? '' : newValue;
526
- {
527
- elm.setAttribute(memberName, newValue);
528
- }
529
- }
530
- }
531
- }
532
- };
533
- const parseClassListRegex = /\s/;
534
- /**
535
- * Parsed a string of classnames into an array
536
- * @param value className string, e.g. "foo bar baz"
537
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
538
- */
539
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
540
- const CAPTURE_EVENT_SUFFIX = 'Capture';
541
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
542
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
543
- // if the element passed in is a shadow root, which is a document fragment
544
- // then we want to be adding attrs/props to the shadow root's "host" element
545
- // if it's not a shadow root, then we add attrs/props to the same element
546
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
547
- ? newVnode.$elm$.host
548
- : newVnode.$elm$;
549
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
550
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
551
- {
552
- // remove attributes no longer present on the vnode by setting them to undefined
553
- for (memberName in oldVnodeAttrs) {
554
- if (!(memberName in newVnodeAttrs)) {
555
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
556
- }
557
- }
558
- }
559
- // add new & update changed attributes
560
- for (memberName in newVnodeAttrs) {
561
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
562
- }
563
- };
564
- /**
565
- * Create a DOM Node corresponding to one of the children of a given VNode.
566
- *
567
- * @param oldParentVNode the parent VNode from the previous render
568
- * @param newParentVNode the parent VNode from the current render
569
- * @param childIndex the index of the VNode, in the _new_ parent node's
570
- * children, for which we will create a new DOM node
571
- * @param parentElm the parent DOM node which our new node will be a child of
572
- * @returns the newly created node
573
- */
574
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
575
- // tslint:disable-next-line: prefer-const
576
- const newVNode = newParentVNode.$children$[childIndex];
577
- let i = 0;
578
- let elm;
579
- let childNode;
580
- if (newVNode.$text$ !== null) {
581
- // create text node
582
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
583
- }
584
- else {
585
- if (!isSvgMode) {
586
- isSvgMode = newVNode.$tag$ === 'svg';
587
- }
588
- // create element
589
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
590
- );
591
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
592
- isSvgMode = false;
593
- }
594
- // add css classes, attrs, props, listeners, etc.
595
- {
596
- updateElement(null, newVNode, isSvgMode);
597
- }
598
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
599
- // if there is a scopeId and this is the initial render
600
- // then let's add the scopeId as a css class
601
- elm.classList.add((elm['s-si'] = scopeId));
602
- }
603
- if (newVNode.$children$) {
604
- for (i = 0; i < newVNode.$children$.length; ++i) {
605
- // create the node
606
- childNode = createElm(oldParentVNode, newVNode, i);
607
- // return node could have been null
608
- if (childNode) {
609
- // append our new node
610
- elm.appendChild(childNode);
611
- }
612
- }
613
- }
614
- {
615
- if (newVNode.$tag$ === 'svg') {
616
- // Only reset the SVG context when we're exiting <svg> element
617
- isSvgMode = false;
618
- }
619
- else if (elm.tagName === 'foreignObject') {
620
- // Reenter SVG context when we're exiting <foreignObject> element
621
- isSvgMode = true;
622
- }
623
- }
624
- }
625
- // This needs to always happen so we can hide nodes that are projected
626
- // to another component but don't end up in a slot
627
- elm['s-hn'] = hostTagName;
628
- return elm;
629
- };
630
- /**
631
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
632
- * add them to the DOM in the appropriate place.
633
- *
634
- * @param parentElm the DOM node which should be used as a parent for the new
635
- * DOM nodes
636
- * @param before a child of the `parentElm` which the new children should be
637
- * inserted before (optional)
638
- * @param parentVNode the parent virtual DOM node
639
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
640
- * @param startIdx the index in the child virtual DOM nodes at which to start
641
- * creating DOM nodes (inclusive)
642
- * @param endIdx the index in the child virtual DOM nodes at which to stop
643
- * creating DOM nodes (inclusive)
644
- */
645
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
646
- let containerElm = (parentElm);
647
- let childNode;
648
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
649
- containerElm = containerElm.shadowRoot;
650
- }
651
- for (; startIdx <= endIdx; ++startIdx) {
652
- if (vnodes[startIdx]) {
653
- childNode = createElm(null, parentVNode, startIdx);
654
- if (childNode) {
655
- vnodes[startIdx].$elm$ = childNode;
656
- containerElm.insertBefore(childNode, before);
657
- }
658
- }
659
- }
660
- };
661
- /**
662
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
663
- * This can be used to, for instance, clean up after a list of children which
664
- * should no longer be shown.
665
- *
666
- * This function also handles some of Stencil's slot relocation logic.
667
- *
668
- * @param vnodes a list of virtual DOM nodes to remove
669
- * @param startIdx the index at which to start removing nodes (inclusive)
670
- * @param endIdx the index at which to stop removing nodes (inclusive)
671
- */
672
- const removeVnodes = (vnodes, startIdx, endIdx) => {
673
- for (let index = startIdx; index <= endIdx; ++index) {
674
- const vnode = vnodes[index];
675
- if (vnode) {
676
- const elm = vnode.$elm$;
677
- nullifyVNodeRefs(vnode);
678
- if (elm) {
679
- // remove the vnode's element from the dom
680
- elm.remove();
681
- }
682
- }
683
- }
684
- };
685
- /**
686
- * Reconcile the children of a new VNode with the children of an old VNode by
687
- * traversing the two collections of children, identifying nodes that are
688
- * conserved or changed, calling out to `patch` to make any necessary
689
- * updates to the DOM, and rearranging DOM nodes as needed.
690
- *
691
- * The algorithm for reconciling children works by analyzing two 'windows' onto
692
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
693
- * 'windows' by storing start and end indices and references to the
694
- * corresponding array entries. Initially the two 'windows' are basically equal
695
- * to the entire array, but we progressively narrow the windows until there are
696
- * no children left to update by doing the following:
697
- *
698
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
699
- * that if we have an initial array like the following we'll end up dealing
700
- * only with a window bounded by the highlighted elements:
701
- *
702
- * [null, null, VNode1 , ... , VNode2, null, null]
703
- * ^^^^^^ ^^^^^^
704
- *
705
- * 2. Check to see if the elements at the head and tail positions are equal
706
- * across the windows. This will basically detect elements which haven't
707
- * been added, removed, or changed position, i.e. if you had the following
708
- * VNode elements (represented as HTML):
709
- *
710
- * oldVNode: `<div><p><span>HEY</span></p></div>`
711
- * newVNode: `<div><p><span>THERE</span></p></div>`
712
- *
713
- * Then when comparing the children of the `<div>` tag we check the equality
714
- * of the VNodes corresponding to the `<p>` tags and, since they are the
715
- * same tag in the same position, we'd be able to avoid completely
716
- * re-rendering the subtree under them with a new DOM element and would just
717
- * call out to `patch` to handle reconciling their children and so on.
718
- *
719
- * 3. Check, for both windows, to see if the element at the beginning of the
720
- * window corresponds to the element at the end of the other window. This is
721
- * a heuristic which will let us identify _some_ situations in which
722
- * elements have changed position, for instance it _should_ detect that the
723
- * children nodes themselves have not changed but merely moved in the
724
- * following example:
725
- *
726
- * oldVNode: `<div><element-one /><element-two /></div>`
727
- * newVNode: `<div><element-two /><element-one /></div>`
728
- *
729
- * If we find cases like this then we also need to move the concrete DOM
730
- * elements corresponding to the moved children to write the re-order to the
731
- * DOM.
732
- *
733
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
734
- * nodes in the old children which have the same key as the first element in
735
- * our window on the new children. If we find such a node we handle calling
736
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
737
- * what we find.
738
- *
739
- * Finally, once we've narrowed our 'windows' to the point that either of them
740
- * collapse (i.e. they have length 0) we then handle any remaining VNode
741
- * insertion or deletion that needs to happen to get a DOM state that correctly
742
- * reflects the new child VNodes. If, for instance, after our window on the old
743
- * children has collapsed we still have more nodes on the new children that
744
- * we haven't dealt with yet then we need to add them, or if the new children
745
- * collapse but we still have unhandled _old_ children then we need to make
746
- * sure the corresponding DOM nodes are removed.
747
- *
748
- * @param parentElm the node into which the parent VNode is rendered
749
- * @param oldCh the old children of the parent node
750
- * @param newVNode the new VNode which will replace the parent
751
- * @param newCh the new children of the parent node
752
- * @param isInitialRender whether or not this is the first render of the vdom
753
- */
754
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
755
- let oldStartIdx = 0;
756
- let newStartIdx = 0;
757
- let idxInOld = 0;
758
- let i = 0;
759
- let oldEndIdx = oldCh.length - 1;
760
- let oldStartVnode = oldCh[0];
761
- let oldEndVnode = oldCh[oldEndIdx];
762
- let newEndIdx = newCh.length - 1;
763
- let newStartVnode = newCh[0];
764
- let newEndVnode = newCh[newEndIdx];
765
- let node;
766
- let elmToMove;
767
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
768
- if (oldStartVnode == null) {
769
- // VNode might have been moved left
770
- oldStartVnode = oldCh[++oldStartIdx];
771
- }
772
- else if (oldEndVnode == null) {
773
- oldEndVnode = oldCh[--oldEndIdx];
774
- }
775
- else if (newStartVnode == null) {
776
- newStartVnode = newCh[++newStartIdx];
777
- }
778
- else if (newEndVnode == null) {
779
- newEndVnode = newCh[--newEndIdx];
780
- }
781
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
782
- // if the start nodes are the same then we should patch the new VNode
783
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
784
- // indices to reflect that. We don't need to move any DOM Nodes around
785
- // since things are matched up in order.
786
- patch(oldStartVnode, newStartVnode, isInitialRender);
787
- oldStartVnode = oldCh[++oldStartIdx];
788
- newStartVnode = newCh[++newStartIdx];
789
- }
790
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
791
- // likewise, if the end nodes are the same we patch new onto old and
792
- // decrement our end indices, and also likewise in this case we don't
793
- // need to move any DOM Nodes.
794
- patch(oldEndVnode, newEndVnode, isInitialRender);
795
- oldEndVnode = oldCh[--oldEndIdx];
796
- newEndVnode = newCh[--newEndIdx];
797
- }
798
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
799
- patch(oldStartVnode, newEndVnode, isInitialRender);
800
- // We need to move the element for `oldStartVnode` into a position which
801
- // will be appropriate for `newEndVnode`. For this we can use
802
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
803
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
804
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
805
- //
806
- // <old-start-node />
807
- // <some-intervening-node />
808
- // <old-end-node />
809
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
810
- // <next-sibling />
811
- //
812
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
813
- // the node for `oldStartVnode` at the end of the children of
814
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
815
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
816
- // append it to the children of the parent element.
817
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
818
- oldStartVnode = oldCh[++oldStartIdx];
819
- newEndVnode = newCh[--newEndIdx];
820
- }
821
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
822
- patch(oldEndVnode, newStartVnode, isInitialRender);
823
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
824
- // the same node, so since we're here we know that they are not. Thus we
825
- // can move the element for `oldEndVnode` _before_ the element for
826
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
827
- // future.
828
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
829
- oldEndVnode = oldCh[--oldEndIdx];
830
- newStartVnode = newCh[++newStartIdx];
831
- }
832
- else {
833
- // Here we do some checks to match up old and new nodes based on the
834
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
835
- // in the JSX for a DOM element in the implementation of a Stencil
836
- // component.
837
- //
838
- // First we check to see if there are any nodes in the array of old
839
- // children which have the same key as the first node in the new
840
- // children.
841
- idxInOld = -1;
842
- {
843
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
844
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
845
- idxInOld = i;
846
- break;
847
- }
848
- }
849
- }
850
- if (idxInOld >= 0) {
851
- // We found a node in the old children which matches up with the first
852
- // node in the new children! So let's deal with that
853
- elmToMove = oldCh[idxInOld];
854
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
855
- // the tag doesn't match so we'll need a new DOM element
856
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
857
- }
858
- else {
859
- patch(elmToMove, newStartVnode, isInitialRender);
860
- // invalidate the matching old node so that we won't try to update it
861
- // again later on
862
- oldCh[idxInOld] = undefined;
863
- node = elmToMove.$elm$;
864
- }
865
- newStartVnode = newCh[++newStartIdx];
866
- }
867
- else {
868
- // We either didn't find an element in the old children that matches
869
- // the key of the first new child OR the build is not using `key`
870
- // attributes at all. In either case we need to create a new element
871
- // for the new node.
872
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
873
- newStartVnode = newCh[++newStartIdx];
874
- }
875
- if (node) {
876
- // if we created a new node then handle inserting it to the DOM
877
- {
878
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
879
- }
880
- }
881
- }
882
- }
883
- if (oldStartIdx > oldEndIdx) {
884
- // we have some more new nodes to add which don't match up with old nodes
885
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
886
- }
887
- else if (newStartIdx > newEndIdx) {
888
- // there are nodes in the `oldCh` array which no longer correspond to nodes
889
- // in the new array, so lets remove them (which entails cleaning up the
890
- // relevant DOM nodes)
891
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
892
- }
893
- };
894
- /**
895
- * Compare two VNodes to determine if they are the same
896
- *
897
- * **NB**: This function is an equality _heuristic_ based on the available
898
- * information set on the two VNodes and can be misleading under certain
899
- * circumstances. In particular, if the two nodes do not have `key` attrs
900
- * (available under `$key$` on VNodes) then the function falls back on merely
901
- * checking that they have the same tag.
902
- *
903
- * So, in other words, if `key` attrs are not set on VNodes which may be
904
- * changing order within a `children` array or something along those lines then
905
- * we could obtain a false negative and then have to do needless re-rendering
906
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
907
- *
908
- * @param leftVNode the first VNode to check
909
- * @param rightVNode the second VNode to check
910
- * @param isInitialRender whether or not this is the first render of the vdom
911
- * @returns whether they're equal or not
912
- */
913
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
914
- // compare if two vnode to see if they're "technically" the same
915
- // need to have the same element tag, and same key to be the same
916
- if (leftVNode.$tag$ === rightVNode.$tag$) {
917
- // this will be set if JSX tags in the build have `key` attrs set on them
918
- // we only want to check this if we're not on the first render since on
919
- // first render `leftVNode.$key$` will always be `null`, so we can be led
920
- // astray and, for instance, accidentally delete a DOM node that we want to
921
- // keep around.
922
- if (!isInitialRender) {
923
- return leftVNode.$key$ === rightVNode.$key$;
924
- }
925
- return true;
926
- }
927
- return false;
928
- };
929
- /**
930
- * Handle reconciling an outdated VNode with a new one which corresponds to
931
- * it. This function handles flushing updates to the DOM and reconciling the
932
- * children of the two nodes (if any).
933
- *
934
- * @param oldVNode an old VNode whose DOM element and children we want to update
935
- * @param newVNode a new VNode representing an updated version of the old one
936
- * @param isInitialRender whether or not this is the first render of the vdom
937
- */
938
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
939
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
940
- const oldChildren = oldVNode.$children$;
941
- const newChildren = newVNode.$children$;
942
- const tag = newVNode.$tag$;
943
- const text = newVNode.$text$;
944
- if (text === null) {
945
- {
946
- // test if we're rendering an svg element, or still rendering nodes inside of one
947
- // only add this to the when the compiler sees we're using an svg somewhere
948
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
949
- }
950
- {
951
- if (tag === 'slot')
952
- ;
953
- else {
954
- // either this is the first render of an element OR it's an update
955
- // AND we already know it's possible it could have changed
956
- // this updates the element's css classes, attrs, props, listeners, etc.
957
- updateElement(oldVNode, newVNode, isSvgMode);
958
- }
959
- }
960
- if (oldChildren !== null && newChildren !== null) {
961
- // looks like there's child vnodes for both the old and new vnodes
962
- // so we need to call `updateChildren` to reconcile them
963
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
964
- }
965
- else if (newChildren !== null) {
966
- // no old child vnodes, but there are new child vnodes to add
967
- if (oldVNode.$text$ !== null) {
968
- // the old vnode was text, so be sure to clear it out
969
- elm.textContent = '';
970
- }
971
- // add the new vnode children
972
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
973
- }
974
- else if (oldChildren !== null) {
975
- // no new child vnodes, but there are old child vnodes to remove
976
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
977
- }
978
- if (isSvgMode && tag === 'svg') {
979
- isSvgMode = false;
980
- }
981
- }
982
- else if (oldVNode.$text$ !== text) {
983
- // update the text content for the text only vnode
984
- // and also only if the text is different than before
985
- elm.data = text;
986
- }
987
- };
988
- /**
989
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
990
- * them with `null`. This signals that the DOM element corresponding to the VDom
991
- * node has been removed from the DOM.
992
- *
993
- * @param vNode a virtual DOM node
994
- */
995
- const nullifyVNodeRefs = (vNode) => {
996
- {
997
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
998
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
999
- }
1000
- };
1001
- /**
1002
- * The main entry point for Stencil's virtual DOM-based rendering engine
1003
- *
1004
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1005
- * function will handle creating a virtual DOM tree with a single root, patching
1006
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1007
- * relocation, and reflecting attributes.
1008
- *
1009
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1010
- * the DOM node into which it should be rendered.
1011
- * @param renderFnResults the virtual DOM nodes to be rendered
1012
- * @param isInitialLoad whether or not this is the first call after page load
1013
- */
1014
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1015
- const hostElm = hostRef.$hostElement$;
1016
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1017
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1018
- // we need to call `h` again to wrap the children of our component in a
1019
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1020
- // implicitly that the top-level vdom node is 1) an only child and 2)
1021
- // contains attrs that need to be set on the host element.
1022
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1023
- hostTagName = hostElm.tagName;
1024
- // On the first render and *only* on the first render we want to check for
1025
- // any attributes set on the host element which are also set on the vdom
1026
- // node. If we find them, we override the value on the VDom node attrs with
1027
- // the value from the host element, which allows developers building apps
1028
- // with Stencil components to override e.g. the `role` attribute on a
1029
- // component even if it's already set on the `Host`.
1030
- if (isInitialLoad && rootVnode.$attrs$) {
1031
- for (const key of Object.keys(rootVnode.$attrs$)) {
1032
- // We have a special implementation in `setAccessor` for `style` and
1033
- // `class` which reconciles values coming from the VDom with values
1034
- // already present on the DOM element, so we don't want to override those
1035
- // attributes on the VDom tree with values from the host element if they
1036
- // are present.
1037
- //
1038
- // Likewise, `ref` and `key` are special internal values for the Stencil
1039
- // runtime and we don't want to override those either.
1040
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1041
- rootVnode.$attrs$[key] = hostElm[key];
1042
- }
1043
- }
1044
- }
1045
- rootVnode.$tag$ = null;
1046
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1047
- hostRef.$vnode$ = rootVnode;
1048
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1049
- {
1050
- scopeId = hostElm['s-sc'];
1051
- }
1052
- // synchronous patch
1053
- patch(oldVNode, rootVnode, isInitialLoad);
1054
- };
1055
- const attachToAncestor = (hostRef, ancestorComponent) => {
1056
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1057
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1058
- }
1059
- };
1060
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1061
- {
1062
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1063
- }
1064
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1065
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1066
- return;
1067
- }
1068
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1069
- // there is no ancestor component or the ancestor component
1070
- // has already fired off its lifecycle update then
1071
- // fire off the initial update
1072
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1073
- return writeTask(dispatch) ;
1074
- };
1075
- /**
1076
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1077
- * component lifecycle methods like `componentWillLoad` as well as
1078
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1079
- *
1080
- * @param hostRef a reference to a host DOM node
1081
- * @param isInitialLoad whether we're on the initial load or not
1082
- * @returns an empty Promise which is used to enqueue a series of operations for
1083
- * the component
1084
- */
1085
- const dispatchHooks = (hostRef, isInitialLoad) => {
1086
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1087
- const instance = hostRef.$lazyInstance$ ;
1088
- // We're going to use this variable together with `enqueue` to implement a
1089
- // little promise-based queue. We start out with it `undefined`. When we add
1090
- // the first function to the queue we'll set this variable to be that
1091
- // function's return value. When we attempt to add subsequent values to the
1092
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1093
- // the new function off of that `Promise` using `.then()`. This will give our
1094
- // queue two nice properties:
1095
- //
1096
- // 1. If all functions added to the queue are synchronous they'll be called
1097
- // synchronously right away.
1098
- // 2. If all functions added to the queue are asynchronous they'll all be
1099
- // called in order after `dispatchHooks` exits.
1100
- let maybePromise;
1101
- if (isInitialLoad) {
1102
- {
1103
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1104
- if (hostRef.$queuedListeners$) {
1105
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1106
- hostRef.$queuedListeners$ = undefined;
1107
- }
1108
- }
1109
- {
1110
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1111
- // whatever's going on in that `Promise` before we launch into
1112
- // rendering the component, doing other lifecycle stuff, etc. So
1113
- // in that case we assign the returned promise to the variable we
1114
- // declared above to hold a possible 'queueing' Promise
1115
- maybePromise = safeCall(instance, 'componentWillLoad');
1116
- }
1117
- }
1118
- else {
1119
- {
1120
- // Like `componentWillLoad` above, we allow Stencil component
1121
- // authors to return a `Promise` from this lifecycle callback, and
1122
- // we specify that our runtime will wait for that `Promise` to
1123
- // resolve before the component re-renders. So if the method
1124
- // returns a `Promise` we need to keep it around!
1125
- maybePromise = safeCall(instance, 'componentWillUpdate');
1126
- }
1127
- }
1128
- endSchedule();
1129
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1130
- };
1131
- /**
1132
- * This function uses a Promise to implement a simple first-in, first-out queue
1133
- * of functions to be called.
1134
- *
1135
- * The queue is ordered on the basis of the first argument. If it's
1136
- * `undefined`, then nothing is on the queue yet, so the provided function can
1137
- * be called synchronously (although note that this function may return a
1138
- * `Promise`). The idea is that then the return value of that enqueueing
1139
- * operation is kept around, so that if it was a `Promise` then subsequent
1140
- * functions can be enqueued by calling this function again with that `Promise`
1141
- * as the first argument.
1142
- *
1143
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1144
- * @param fn a function to enqueue
1145
- * @returns either a `Promise` or the return value of the provided function
1146
- */
1147
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1148
- /**
1149
- * Check that a value is a `Promise`. To check, we first see if the value is an
1150
- * instance of the `Promise` global. In a few circumstances, in particular if
1151
- * the global has been overwritten, this is could be misleading, so we also do
1152
- * a little 'duck typing' check to see if the `.then` property of the value is
1153
- * defined and a function.
1154
- *
1155
- * @param maybePromise it might be a promise!
1156
- * @returns whether it is or not
1157
- */
1158
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1159
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1160
- /**
1161
- * Update a component given reference to its host elements and so on.
1162
- *
1163
- * @param hostRef an object containing references to the element's host node,
1164
- * VDom nodes, and other metadata
1165
- * @param instance a reference to the underlying host element where it will be
1166
- * rendered
1167
- * @param isInitialLoad whether or not this function is being called as part of
1168
- * the first render cycle
1169
- */
1170
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1171
- var _a;
1172
- const elm = hostRef.$hostElement$;
1173
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1174
- const rc = elm['s-rc'];
1175
- if (isInitialLoad) {
1176
- // DOM WRITE!
1177
- attachStyles(hostRef);
1178
- }
1179
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1180
- {
1181
- callRender(hostRef, instance, elm, isInitialLoad);
1182
- }
1183
- if (rc) {
1184
- // ok, so turns out there are some child host elements
1185
- // waiting on this parent element to load
1186
- // let's fire off all update callbacks waiting
1187
- rc.map((cb) => cb());
1188
- elm['s-rc'] = undefined;
1189
- }
1190
- endRender();
1191
- endUpdate();
1192
- {
1193
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1194
- const postUpdate = () => postUpdateComponent(hostRef);
1195
- if (childrenPromises.length === 0) {
1196
- postUpdate();
1197
- }
1198
- else {
1199
- Promise.all(childrenPromises).then(postUpdate);
1200
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1201
- childrenPromises.length = 0;
1202
- }
1203
- }
1204
- };
1205
- /**
1206
- * Handle making the call to the VDom renderer with the proper context given
1207
- * various build variables
1208
- *
1209
- * @param hostRef an object containing references to the element's host node,
1210
- * VDom nodes, and other metadata
1211
- * @param instance a reference to the underlying host element where it will be
1212
- * rendered
1213
- * @param elm the Host element for the component
1214
- * @param isInitialLoad whether or not this function is being called as part of
1215
- * @returns an empty promise
1216
- */
1217
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1218
- try {
1219
- renderingRef = instance;
1220
- /**
1221
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1222
- * method, so we can call the method immediately. If not, check before calling it.
1223
- */
1224
- instance = instance.render() ;
1225
- {
1226
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1227
- }
1228
- {
1229
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1230
- }
1231
- {
1232
- {
1233
- // looks like we've got child nodes to render into this host element
1234
- // or we need to update the css class/attrs on the host element
1235
- // DOM WRITE!
1236
- {
1237
- renderVdom(hostRef, instance, isInitialLoad);
1238
- }
1239
- }
1240
- }
1241
- }
1242
- catch (e) {
1243
- consoleError(e, hostRef.$hostElement$);
1244
- }
1245
- renderingRef = null;
1246
- return null;
1247
- };
1248
- const getRenderingRef = () => renderingRef;
1249
- const postUpdateComponent = (hostRef) => {
1250
- const tagName = hostRef.$cmpMeta$.$tagName$;
1251
- const elm = hostRef.$hostElement$;
1252
- const endPostUpdate = createTime('postUpdate', tagName);
1253
- const instance = hostRef.$lazyInstance$ ;
1254
- const ancestorComponent = hostRef.$ancestorComponent$;
1255
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1256
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1257
- {
1258
- // DOM WRITE!
1259
- addHydratedFlag(elm);
1260
- }
1261
- {
1262
- safeCall(instance, 'componentDidLoad');
1263
- }
1264
- endPostUpdate();
1265
- {
1266
- hostRef.$onReadyResolve$(elm);
1267
- if (!ancestorComponent) {
1268
- appDidLoad();
1269
- }
1270
- }
1271
- }
1272
- else {
1273
- {
1274
- safeCall(instance, 'componentDidUpdate');
1275
- }
1276
- endPostUpdate();
1277
- }
1278
- {
1279
- hostRef.$onInstanceResolve$(elm);
1280
- }
1281
- // load events fire from bottom to top
1282
- // the deepest elements load first then bubbles up
1283
- {
1284
- if (hostRef.$onRenderResolve$) {
1285
- hostRef.$onRenderResolve$();
1286
- hostRef.$onRenderResolve$ = undefined;
1287
- }
1288
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1289
- nextTick(() => scheduleUpdate(hostRef, false));
1290
- }
1291
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1292
- }
1293
- // ( •_•)
1294
- // ( •_•)>⌐■-■
1295
- // (⌐■_■)
1296
- };
1297
- const forceUpdate = (ref) => {
1298
- {
1299
- const hostRef = getHostRef(ref);
1300
- const isConnected = hostRef.$hostElement$.isConnected;
1301
- if (isConnected &&
1302
- (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1303
- scheduleUpdate(hostRef, false);
1304
- }
1305
- // Returns "true" when the forced update was successfully scheduled
1306
- return isConnected;
1307
- }
1308
- };
1309
- const appDidLoad = (who) => {
1310
- // on appload
1311
- // we have finish the first big initial render
1312
- {
1313
- addHydratedFlag(doc.documentElement);
1314
- }
1315
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1316
- };
1317
- /**
1318
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1319
- * e.g. custom element node. If a build figures out that e.g. no component
1320
- * has a `componentDidLoad` method, the instance method gets removed from the
1321
- * output bundle and this function returns `undefined`.
1322
- * @param instance any object that may or may not contain methods
1323
- * @param method method name
1324
- * @param arg single arbitrary argument
1325
- * @returns result of method call if it exists, otherwise `undefined`
1326
- */
1327
- const safeCall = (instance, method, arg) => {
1328
- if (instance && instance[method]) {
1329
- try {
1330
- return instance[method](arg);
1331
- }
1332
- catch (e) {
1333
- consoleError(e);
1334
- }
1335
- }
1336
- return undefined;
1337
- };
1338
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1339
- ;
1340
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1341
- const setValue = (ref, propName, newVal, cmpMeta) => {
1342
- // check our new property value against our internal value
1343
- const hostRef = getHostRef(ref);
1344
- const elm = hostRef.$hostElement$ ;
1345
- const oldVal = hostRef.$instanceValues$.get(propName);
1346
- const flags = hostRef.$flags$;
1347
- const instance = hostRef.$lazyInstance$ ;
1348
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1349
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1350
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1351
- const didValueChange = newVal !== oldVal && !areBothNaN;
1352
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1353
- // gadzooks! the property's value has changed!!
1354
- // set our new value!
1355
- hostRef.$instanceValues$.set(propName, newVal);
1356
- if (instance) {
1357
- // get an array of method names of watch functions to call
1358
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1359
- const watchMethods = cmpMeta.$watchers$[propName];
1360
- if (watchMethods) {
1361
- // this instance is watching for when this property changed
1362
- watchMethods.map((watchMethodName) => {
1363
- try {
1364
- // fire off each of the watch methods that are watching this property
1365
- instance[watchMethodName](newVal, oldVal, propName);
1366
- }
1367
- catch (e) {
1368
- consoleError(e, elm);
1369
- }
1370
- });
1371
- }
1372
- }
1373
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1374
- // looks like this value actually changed, so we've got work to do!
1375
- // but only if we've already rendered, otherwise just chill out
1376
- // queue that we need to do an update, but don't worry about queuing
1377
- // up millions cuz this function ensures it only runs once
1378
- scheduleUpdate(hostRef, false);
1379
- }
1380
- }
1381
- }
1382
- };
1383
- /**
1384
- * Attach a series of runtime constructs to a compiled Stencil component
1385
- * constructor, including getters and setters for the `@Prop` and `@State`
1386
- * decorators, callbacks for when attributes change, and so on.
1387
- *
1388
- * @param Cstr the constructor for a component that we need to process
1389
- * @param cmpMeta metadata collected previously about the component
1390
- * @param flags a number used to store a series of bit flags
1391
- * @returns a reference to the same constructor passed in (but now mutated)
1392
- */
1393
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1394
- var _a;
1395
- const prototype = Cstr.prototype;
1396
- if (cmpMeta.$members$) {
1397
- if (Cstr.watchers) {
1398
- cmpMeta.$watchers$ = Cstr.watchers;
1399
- }
1400
- // It's better to have a const than two Object.entries()
1401
- const members = Object.entries(cmpMeta.$members$);
1402
- members.map(([memberName, [memberFlags]]) => {
1403
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1404
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1405
- // proxyComponent - prop
1406
- Object.defineProperty(prototype, memberName, {
1407
- get() {
1408
- // proxyComponent, get value
1409
- return getValue(this, memberName);
1410
- },
1411
- set(newValue) {
1412
- // proxyComponent, set value
1413
- setValue(this, memberName, newValue, cmpMeta);
1414
- },
1415
- configurable: true,
1416
- enumerable: true,
1417
- });
1418
- }
1419
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1420
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1421
- // proxyComponent - method
1422
- Object.defineProperty(prototype, memberName, {
1423
- value(...args) {
1424
- var _a;
1425
- const ref = getHostRef(this);
1426
- return (_a = ref === null || ref === void 0 ? void 0 : ref.$onInstancePromise$) === null || _a === void 0 ? void 0 : _a.then(() => { var _a; return (_a = ref.$lazyInstance$) === null || _a === void 0 ? void 0 : _a[memberName](...args); });
1427
- },
1428
- });
1429
- }
1430
- });
1431
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1432
- const attrNameToPropName = new Map();
1433
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1434
- plt.jmp(() => {
1435
- var _a;
1436
- const propName = attrNameToPropName.get(attrName);
1437
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1438
- // in the case where an attribute was set inline.
1439
- // ```html
1440
- // <my-component some-attribute="some-value"></my-component>
1441
- // ```
1442
- //
1443
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1444
- // programmatically changes it before it has been upgraded as shown below:
1445
- //
1446
- // ```html
1447
- // <!-- this component has _not_ been upgraded yet -->
1448
- // <my-component id="test" some-attribute="some-value"></my-component>
1449
- // <script>
1450
- // // grab non-upgraded component
1451
- // el = document.querySelector("#test");
1452
- // el.someAttribute = "another-value";
1453
- // // upgrade component
1454
- // customElements.define('my-component', MyComponent);
1455
- // </script>
1456
- // ```
1457
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1458
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1459
- // to the value that was set inline i.e. "some-value" from above example. When
1460
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1461
- //
1462
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1463
- // by connectedCallback as this attributeChangedCallback will not fire.
1464
- //
1465
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1466
- //
1467
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1468
- // properties here given that this goes against best practices outlined here
1469
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1470
- if (this.hasOwnProperty(propName)) {
1471
- newValue = this[propName];
1472
- delete this[propName];
1473
- }
1474
- else if (prototype.hasOwnProperty(propName) &&
1475
- typeof this[propName] === 'number' &&
1476
- this[propName] == newValue) {
1477
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1478
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1479
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1480
- return;
1481
- }
1482
- else if (propName == null) {
1483
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1484
- // on a vanilla web component
1485
- const hostRef = getHostRef(this);
1486
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1487
- // We only want to trigger the callback(s) if:
1488
- // 1. The instance is ready
1489
- // 2. The watchers are ready
1490
- // 3. The value has changed
1491
- if (flags &&
1492
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1493
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1494
- newValue !== oldValue) {
1495
- const instance = hostRef.$lazyInstance$ ;
1496
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1497
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1498
- if (instance[callbackName] != null) {
1499
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1500
- }
1501
- });
1502
- }
1503
- return;
1504
- }
1505
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1506
- });
1507
- };
1508
- // Create an array of attributes to observe
1509
- // This list in comprised of all strings used within a `@Watch()` decorator
1510
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1511
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1512
- // an invalid attribute.
1513
- Cstr.observedAttributes = Array.from(new Set([
1514
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1515
- ...members
1516
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1517
- .map(([propName, m]) => {
1518
- const attrName = m[1] || propName;
1519
- attrNameToPropName.set(attrName, propName);
1520
- return attrName;
1521
- }),
1522
- ]));
1523
- }
1524
- }
1525
- return Cstr;
1526
- };
1527
- /**
1528
- * Initialize a Stencil component given a reference to its host element, its
1529
- * runtime bookkeeping data structure, runtime metadata about the component,
1530
- * and (optionally) an HMR version ID.
1531
- *
1532
- * @param elm a host element
1533
- * @param hostRef the element's runtime bookkeeping object
1534
- * @param cmpMeta runtime metadata for the Stencil component
1535
- * @param hmrVersionId an (optional) HMR version ID
1536
- */
1537
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1538
- let Cstr;
1539
- // initializeComponent
1540
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1541
- // Let the runtime know that the component has been initialized
1542
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1543
- {
1544
- // lazy loaded components
1545
- // request the component's implementation to be
1546
- // wired up with the host element
1547
- Cstr = loadModule(cmpMeta);
1548
- if (Cstr.then) {
1549
- // Await creates a micro-task avoid if possible
1550
- const endLoad = uniqueTime();
1551
- Cstr = await Cstr;
1552
- endLoad();
1553
- }
1554
- if (!Cstr.isProxied) {
1555
- // we've never proxied this Constructor before
1556
- // let's add the getters/setters to its prototype before
1557
- // the first time we create an instance of the implementation
1558
- {
1559
- cmpMeta.$watchers$ = Cstr.watchers;
1560
- }
1561
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1562
- Cstr.isProxied = true;
1563
- }
1564
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1565
- // ok, time to construct the instance
1566
- // but let's keep track of when we start and stop
1567
- // so that the getters/setters don't incorrectly step on data
1568
- {
1569
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1570
- }
1571
- // construct the lazy-loaded component implementation
1572
- // passing the hostRef is very important during
1573
- // construction in order to directly wire together the
1574
- // host element and the lazy-loaded instance
1575
- try {
1576
- new Cstr(hostRef);
1577
- }
1578
- catch (e) {
1579
- consoleError(e);
1580
- }
1581
- {
1582
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1583
- }
1584
- {
1585
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1586
- }
1587
- endNewInstance();
1588
- fireConnectedCallback(hostRef.$lazyInstance$);
1589
- }
1590
- if (Cstr.style) {
1591
- // this component has styles but we haven't registered them yet
1592
- let style = Cstr.style;
1593
- const scopeId = getScopeId(cmpMeta);
1594
- if (!styles.has(scopeId)) {
1595
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1596
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1597
- endRegisterStyles();
1598
- }
1599
- }
1600
- }
1601
- // we've successfully created a lazy instance
1602
- const ancestorComponent = hostRef.$ancestorComponent$;
1603
- const schedule = () => scheduleUpdate(hostRef, true);
1604
- if (ancestorComponent && ancestorComponent['s-rc']) {
1605
- // this is the initial load and this component it has an ancestor component
1606
- // but the ancestor component has NOT fired its will update lifecycle yet
1607
- // so let's just cool our jets and wait for the ancestor to continue first
1608
- // this will get fired off when the ancestor component
1609
- // finally gets around to rendering its lazy self
1610
- // fire off the initial update
1611
- ancestorComponent['s-rc'].push(schedule);
1612
- }
1613
- else {
1614
- schedule();
1615
- }
1616
- };
1617
- const fireConnectedCallback = (instance) => {
1618
- {
1619
- safeCall(instance, 'connectedCallback');
1620
- }
1621
- };
1622
- const connectedCallback = (elm) => {
1623
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1624
- const hostRef = getHostRef(elm);
1625
- const cmpMeta = hostRef.$cmpMeta$;
1626
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1627
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1628
- // first time this component has connected
1629
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1630
- {
1631
- // find the first ancestor component (if there is one) and register
1632
- // this component as one of the actively loading child components for its ancestor
1633
- let ancestorComponent = elm;
1634
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1635
- // climb up the ancestors looking for the first
1636
- // component that hasn't finished its lifecycle update yet
1637
- if (ancestorComponent['s-p']) {
1638
- // we found this components first ancestor component
1639
- // keep a reference to this component's ancestor component
1640
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1641
- break;
1642
- }
1643
- }
1644
- }
1645
- // Lazy properties
1646
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1647
- if (cmpMeta.$members$) {
1648
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1649
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1650
- const value = elm[memberName];
1651
- delete elm[memberName];
1652
- elm[memberName] = value;
1653
- }
1654
- });
1655
- }
1656
- {
1657
- initializeComponent(elm, hostRef, cmpMeta);
1658
- }
1659
- }
1660
- else {
1661
- // not the first time this has connected
1662
- // reattach any event listeners to the host
1663
- // since they would have been removed when disconnected
1664
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1665
- // fire off connectedCallback() on component instance
1666
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
1667
- fireConnectedCallback(hostRef.$lazyInstance$);
1668
- }
1669
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1670
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
1671
- }
1672
- }
1673
- endConnected();
1674
- }
1675
- };
1676
- const disconnectInstance = (instance) => {
1677
- {
1678
- safeCall(instance, 'disconnectedCallback');
1679
- }
1680
- };
1681
- const disconnectedCallback = async (elm) => {
1682
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1683
- const hostRef = getHostRef(elm);
1684
- {
1685
- if (hostRef.$rmListeners$) {
1686
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1687
- hostRef.$rmListeners$ = undefined;
1688
- }
1689
- }
1690
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
1691
- disconnectInstance(hostRef.$lazyInstance$);
1692
- }
1693
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1694
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
1695
- }
1696
- }
1697
- };
1698
- const bootstrapLazy = (lazyBundles, options = {}) => {
1699
- var _a;
1700
- const endBootstrap = createTime();
1701
- const cmpTags = [];
1702
- const exclude = options.exclude || [];
1703
- const customElements = win.customElements;
1704
- const head = doc.head;
1705
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1706
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
1707
- const deferredConnectedCallbacks = [];
1708
- let appLoadFallback;
1709
- let isBootstrapping = true;
1710
- Object.assign(plt, options);
1711
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1712
- let hasSlotRelocation = false;
1713
- lazyBundles.map((lazyBundle) => {
1714
- lazyBundle[1].map((compactMeta) => {
1715
- var _a;
1716
- const cmpMeta = {
1717
- $flags$: compactMeta[0],
1718
- $tagName$: compactMeta[1],
1719
- $members$: compactMeta[2],
1720
- $listeners$: compactMeta[3],
1721
- };
1722
- // Check if we are using slots outside the shadow DOM in this component.
1723
- // We'll use this information later to add styles for `slot-fb` elements
1724
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
1725
- hasSlotRelocation = true;
1726
- }
1727
- {
1728
- cmpMeta.$members$ = compactMeta[2];
1729
- }
1730
- {
1731
- cmpMeta.$listeners$ = compactMeta[3];
1732
- }
1733
- {
1734
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
1735
- }
1736
- const tagName = cmpMeta.$tagName$;
1737
- const HostElement = class extends HTMLElement {
1738
- // StencilLazyHost
1739
- constructor(self) {
1740
- // @ts-ignore
1741
- super(self);
1742
- self = this;
1743
- registerHost(self, cmpMeta);
1744
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1745
- // this component is using shadow dom
1746
- // and this browser supports shadow dom
1747
- // add the read-only property "shadowRoot" to the host element
1748
- // adding the shadow root build conditionals to minimize runtime
1749
- {
1750
- {
1751
- self.attachShadow({ mode: 'open' });
1752
- }
1753
- }
1754
- }
1755
- }
1756
- connectedCallback() {
1757
- if (appLoadFallback) {
1758
- clearTimeout(appLoadFallback);
1759
- appLoadFallback = null;
1760
- }
1761
- if (isBootstrapping) {
1762
- // connectedCallback will be processed once all components have been registered
1763
- deferredConnectedCallbacks.push(this);
1764
- }
1765
- else {
1766
- plt.jmp(() => connectedCallback(this));
1767
- }
1768
- }
1769
- disconnectedCallback() {
1770
- plt.jmp(() => disconnectedCallback(this));
1771
- }
1772
- componentOnReady() {
1773
- return getHostRef(this).$onReadyPromise$;
1774
- }
1775
- };
1776
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1777
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1778
- cmpTags.push(tagName);
1779
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1780
- }
1781
- });
1782
- });
1783
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
1784
- if (hasSlotRelocation) {
1785
- dataStyles.innerHTML += SLOT_FB_CSS;
1786
- }
1787
- // Add hydration styles
1788
- {
1789
- dataStyles.innerHTML += cmpTags + HYDRATED_CSS;
1790
- }
1791
- // If we have styles, add them to the DOM
1792
- if (dataStyles.innerHTML.length) {
1793
- dataStyles.setAttribute('data-styles', '');
1794
- // Apply CSP nonce to the style tag if it exists
1795
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1796
- if (nonce != null) {
1797
- dataStyles.setAttribute('nonce', nonce);
1798
- }
1799
- // Insert the styles into the document head
1800
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
1801
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
1802
- }
1803
- // Process deferred connectedCallbacks now all components have been registered
1804
- isBootstrapping = false;
1805
- if (deferredConnectedCallbacks.length) {
1806
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1807
- }
1808
- else {
1809
- {
1810
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1811
- }
1812
- }
1813
- // Fallback appLoad event
1814
- endBootstrap();
1815
- };
1816
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1817
- if (listeners) {
1818
- listeners.map(([flags, name, method]) => {
1819
- const target = elm;
1820
- const handler = hostListenerProxy(hostRef, method);
1821
- const opts = hostListenerOpts(flags);
1822
- plt.ael(target, name, handler, opts);
1823
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1824
- });
1825
- }
1826
- };
1827
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
1828
- try {
1829
- {
1830
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1831
- // instance is ready, let's call it's member method for this event
1832
- hostRef.$lazyInstance$[methodName](ev);
1833
- }
1834
- else {
1835
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1836
- }
1837
- }
1838
- }
1839
- catch (e) {
1840
- consoleError(e);
1841
- }
1842
- };
1843
- // prettier-ignore
1844
- const hostListenerOpts = (flags) => supportsListenerOptions
1845
- ? ({
1846
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
1847
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
1848
- })
1849
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1850
- /**
1851
- * Assigns the given value to the nonce property on the runtime platform object.
1852
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1853
- * @param nonce The value to be assigned to the platform nonce property.
1854
- * @returns void
1855
- */
1856
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1857
- /**
1858
- * A WeakMap mapping runtime component references to their corresponding host reference
1859
- * instances.
1860
- *
1861
- * **Note**: If we're in an HMR context we need to store a reference to this
1862
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
1863
- * to {@link d.HostRef} across HMR updates.
1864
- *
1865
- * This is necessary because when HMR updates for a component are processed by
1866
- * the browser-side dev server client the JS bundle for that component is
1867
- * re-fetched. Since the module containing {@link hostRefs} is included in
1868
- * that bundle, if we do not store a reference to it the new iteration of the
1869
- * component will not have access to the previous hostRef map, leading to a
1870
- * bug where the new version of the component cannot properly initialize.
1871
- */
1872
- const hostRefs = new WeakMap();
1873
- /**
1874
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
1875
- *
1876
- * @param ref the runtime ref of interest
1877
- * @returns the Host reference (if found) or undefined
1878
- */
1879
- const getHostRef = (ref) => hostRefs.get(ref);
1880
- /**
1881
- * Register a lazy instance with the {@link hostRefs} object so it's
1882
- * corresponding {@link d.HostRef} can be retrieved later.
1883
- *
1884
- * @param lazyInstance the lazy instance of interest
1885
- * @param hostRef that instances `HostRef` object
1886
- * @returns a reference to the host ref WeakMap
1887
- */
1888
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1889
- /**
1890
- * Register a host element for a Stencil component, setting up various metadata
1891
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
1892
- * metadata.
1893
- *
1894
- * @param hostElement the host element to register
1895
- * @param cmpMeta runtime metadata for that component
1896
- * @returns a reference to the host ref WeakMap
1897
- */
1898
- const registerHost = (hostElement, cmpMeta) => {
1899
- const hostRef = {
1900
- $flags$: 0,
1901
- $hostElement$: hostElement,
1902
- $cmpMeta$: cmpMeta,
1903
- $instanceValues$: new Map(),
1904
- };
1905
- {
1906
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1907
- }
1908
- {
1909
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1910
- hostElement['s-p'] = [];
1911
- hostElement['s-rc'] = [];
1912
- }
1913
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
1914
- return hostRefs.set(hostElement, hostRef);
1915
- };
1916
- const isMemberInElement = (elm, memberName) => memberName in elm;
1917
- const consoleError = (e, el) => (0, console.error)(e, el);
1918
- const cmpModules = /*@__PURE__*/ new Map();
1919
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1920
- // loadModuleImport
1921
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1922
- const bundleId = cmpMeta.$lazyBundleId$;
1923
- const module = cmpModules.get(bundleId) ;
1924
- if (module) {
1925
- return module[exportName];
1926
- }
1927
-
1928
- if (!hmrVersionId || !BUILD.hotModuleReplacement) {
1929
- const processMod = importedModule => {
1930
- cmpModules.set(bundleId, importedModule);
1931
- return importedModule[exportName];
1932
- }
1933
- switch(bundleId) {
1934
-
1935
- case 'swisspost-internet-header':
1936
- return import(
1937
- /* webpackMode: "lazy" */
1938
- './swisspost-internet-header.entry.js').then(processMod, consoleError);
1939
- case 'swisspost-internet-breadcrumbs':
1940
- return import(
1941
- /* webpackMode: "lazy" */
1942
- './swisspost-internet-breadcrumbs.entry.js').then(processMod, consoleError);
1943
- case 'swisspost-internet-footer':
1944
- return import(
1945
- /* webpackMode: "lazy" */
1946
- './swisspost-internet-footer.entry.js').then(processMod, consoleError);
1947
- case 'post-klp-login-widget':
1948
- return import(
1949
- /* webpackMode: "lazy" */
1950
- './post-klp-login-widget.entry.js').then(processMod, consoleError);
1951
- case 'post-language-switch':
1952
- return import(
1953
- /* webpackMode: "lazy" */
1954
- './post-language-switch.entry.js').then(processMod, consoleError);
1955
- case 'post-logo':
1956
- return import(
1957
- /* webpackMode: "lazy" */
1958
- './post-logo.entry.js').then(processMod, consoleError);
1959
- case 'post-main-navigation':
1960
- return import(
1961
- /* webpackMode: "lazy" */
1962
- './post-main-navigation.entry.js').then(processMod, consoleError);
1963
- case 'post-meta-navigation':
1964
- return import(
1965
- /* webpackMode: "lazy" */
1966
- './post-meta-navigation.entry.js').then(processMod, consoleError);
1967
- case 'post-search':
1968
- return import(
1969
- /* webpackMode: "lazy" */
1970
- './post-search.entry.js').then(processMod, consoleError);
1971
- case 'post-skiplinks':
1972
- return import(
1973
- /* webpackMode: "lazy" */
1974
- './post-skiplinks.entry.js').then(processMod, consoleError);
1975
- }
1976
- }
1977
- return import(
1978
- /* @vite-ignore */
1979
- /* webpackInclude: /\.entry\.js$/ */
1980
- /* webpackExclude: /\.system\.entry\.js$/ */
1981
- /* webpackMode: "lazy" */
1982
- `./${bundleId}.entry.js${''}`).then((importedModule) => {
1983
- {
1984
- cmpModules.set(bundleId, importedModule);
1985
- }
1986
- return importedModule[exportName];
1987
- }, consoleError);
1988
- };
1989
- const styles = /*@__PURE__*/ new Map();
1990
- const win = typeof window !== 'undefined' ? window : {};
1991
- const doc = win.document || { head: {} };
1992
- const plt = {
1993
- $flags$: 0,
1994
- $resourcesUrl$: '',
1995
- jmp: (h) => h(),
1996
- raf: (h) => requestAnimationFrame(h),
1997
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1998
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1999
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2000
- };
2001
- const supportsListenerOptions = /*@__PURE__*/ (() => {
2002
- let supportsListenerOptions = false;
2003
- try {
2004
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
2005
- get() {
2006
- supportsListenerOptions = true;
2007
- },
2008
- }));
2009
- }
2010
- catch (e) { }
2011
- return supportsListenerOptions;
2012
- })();
2013
- const promiseResolve = (v) => Promise.resolve(v);
2014
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2015
- try {
2016
- new CSSStyleSheet();
2017
- return typeof new CSSStyleSheet().replaceSync === 'function';
2018
- }
2019
- catch (e) { }
2020
- return false;
2021
- })()
2022
- ;
2023
- const queueDomReads = [];
2024
- const queueDomWrites = [];
2025
- const queueTask = (queue, write) => (cb) => {
2026
- queue.push(cb);
2027
- if (!queuePending) {
2028
- queuePending = true;
2029
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2030
- nextTick(flush);
2031
- }
2032
- else {
2033
- plt.raf(flush);
2034
- }
2035
- }
2036
- };
2037
- const consume = (queue) => {
2038
- for (let i = 0; i < queue.length; i++) {
2039
- try {
2040
- queue[i](performance.now());
2041
- }
2042
- catch (e) {
2043
- consoleError(e);
2044
- }
2045
- }
2046
- queue.length = 0;
2047
- };
2048
- const flush = () => {
2049
- // always force a bunch of medium callbacks to run, but still have
2050
- // a throttle on how many can run in a certain time
2051
- // DOM READS!!!
2052
- consume(queueDomReads);
2053
- // DOM WRITES!!!
2054
- {
2055
- consume(queueDomWrites);
2056
- if ((queuePending = queueDomReads.length > 0)) {
2057
- // still more to do yet, but we've run out of time
2058
- // let's let this thing cool off and try again in the next tick
2059
- plt.raf(flush);
2060
- }
2061
- }
2062
- };
2063
- const nextTick = (cb) => promiseResolve().then(cb);
2064
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2065
-
2066
- export { Host as H, getRenderingRef as a, bootstrapLazy as b, createEvent as c, forceUpdate as f, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };