q2-tecton-elements 1.18.0 → 1.19.0

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 (255) hide show
  1. package/dist/cjs/click-elsewhere.cjs.entry.js +1 -1
  2. package/dist/cjs/{icons-e2bc9ee9.js → icons-afbdf88a.js} +1 -1
  3. package/dist/cjs/{index-eccd5617.js → index-3518c78c.js} +1 -1
  4. package/dist/cjs/{index-0128397d.js → index-734296a7.js} +476 -271
  5. package/dist/cjs/loader.cjs.js +3 -3
  6. package/dist/cjs/q2-avatar.cjs.entry.js +9 -6
  7. package/dist/cjs/q2-badge_2.cjs.entry.js +46 -7
  8. package/dist/cjs/q2-btn_2.cjs.entry.js +30 -5
  9. package/dist/cjs/q2-calendar.cjs.entry.js +89 -62
  10. package/dist/cjs/q2-card.cjs.entry.js +17 -6
  11. package/dist/cjs/q2-carousel-pane.cjs.entry.js +7 -3
  12. package/dist/cjs/q2-carousel.cjs.entry.js +196 -285
  13. package/dist/cjs/q2-chart-donut.cjs.entry.js +583 -504
  14. package/dist/cjs/q2-checkbox-group.cjs.entry.js +9 -7
  15. package/dist/cjs/q2-checkbox.cjs.entry.js +17 -4
  16. package/dist/cjs/q2-dropdown-item.cjs.entry.js +9 -3
  17. package/dist/cjs/q2-dropdown.cjs.entry.js +16 -5
  18. package/dist/cjs/q2-editable-field.cjs.entry.js +16 -6
  19. package/dist/cjs/q2-icon.cjs.entry.js +6 -4
  20. package/dist/cjs/q2-loading-element.cjs.entry.js +6 -2
  21. package/dist/cjs/q2-loc.cjs.entry.js +5 -3
  22. package/dist/cjs/q2-message.cjs.entry.js +4 -3
  23. package/dist/cjs/q2-month-picker.cjs.entry.js +9 -7
  24. package/dist/cjs/q2-optgroup.cjs.entry.js +6 -5
  25. package/dist/cjs/q2-option-list_2.cjs.entry.js +21 -7
  26. package/dist/cjs/q2-option.cjs.entry.js +12 -2
  27. package/dist/cjs/q2-pagination.cjs.entry.js +11 -3
  28. package/dist/cjs/q2-pill.cjs.entry.js +25 -7
  29. package/dist/cjs/q2-radio-group.cjs.entry.js +13 -6
  30. package/dist/cjs/q2-radio.cjs.entry.js +13 -8
  31. package/dist/cjs/q2-section.cjs.entry.js +9 -4
  32. package/dist/cjs/q2-select.cjs.entry.js +26 -17
  33. package/dist/cjs/q2-stepper-pane.cjs.entry.js +8 -3
  34. package/dist/cjs/q2-stepper-vertical.cjs.entry.js +5 -4
  35. package/dist/cjs/q2-stepper.cjs.entry.js +9 -7
  36. package/dist/cjs/q2-tab-container.cjs.entry.js +14 -9
  37. package/dist/cjs/q2-tab-pane.cjs.entry.js +10 -2
  38. package/dist/cjs/q2-tag.cjs.entry.js +20 -7
  39. package/dist/cjs/q2-tecton-elements.cjs.js +3 -3
  40. package/dist/cjs/q2-textarea.cjs.entry.js +20 -4
  41. package/dist/cjs/q2-tooltip.cjs.entry.js +9 -3
  42. package/dist/cjs/{shapes-c1a60d46.js → shapes-aad2b98f.js} +1 -1
  43. package/dist/cjs/tecton-tab-pane.cjs.entry.js +17 -2
  44. package/dist/collection/collection-manifest.json +2 -2
  45. package/dist/collection/components/click-elsewhere/index.js +18 -17
  46. package/dist/collection/components/q2-avatar/index.js +100 -92
  47. package/dist/collection/components/q2-avatar/styles.css +1 -1
  48. package/dist/collection/components/q2-badge/index.js +119 -111
  49. package/dist/collection/components/q2-badge/styles.css +1 -1
  50. package/dist/collection/components/q2-btn/index.js +349 -322
  51. package/dist/collection/components/q2-btn/styles.css +7 -7
  52. package/dist/collection/components/q2-calendar/index.js +565 -551
  53. package/dist/collection/components/q2-calendar/q2-month-picker.css +1 -1
  54. package/dist/collection/components/q2-calendar/q2-month-picker.js +112 -116
  55. package/dist/collection/components/q2-calendar/styles.css +1 -1
  56. package/dist/collection/components/q2-card/index.js +262 -244
  57. package/dist/collection/components/q2-card/styles.css +9 -2
  58. package/dist/collection/components/q2-carousel/index.js +249 -253
  59. package/dist/collection/components/q2-carousel/styles.css +1 -1
  60. package/dist/collection/components/q2-carousel-pane/index.js +108 -96
  61. package/dist/collection/components/q2-carousel-pane/styles.css +5 -4
  62. package/dist/collection/components/q2-chart-donut/index.js +350 -334
  63. package/dist/collection/components/q2-chart-donut/styles.css +3 -3
  64. package/dist/collection/components/q2-checkbox/index.js +296 -287
  65. package/dist/collection/components/q2-checkbox/styles.css +2 -2
  66. package/dist/collection/components/q2-checkbox-group/index.js +156 -152
  67. package/dist/collection/components/q2-checkbox-group/styles.css +1 -1
  68. package/dist/collection/components/q2-dropdown/index.js +255 -240
  69. package/dist/collection/components/q2-dropdown/styles.css +1 -1
  70. package/dist/collection/components/q2-dropdown-item/index.js +134 -123
  71. package/dist/collection/components/q2-dropdown-item/styles.css +12 -10
  72. package/dist/collection/components/q2-editable-field/index.js +300 -293
  73. package/dist/collection/components/q2-editable-field/styles.css +1 -1
  74. package/dist/collection/components/q2-icon/icons.js +358 -2158
  75. package/dist/collection/components/q2-icon/index.js +59 -49
  76. package/dist/collection/components/q2-icon/styles.css +1 -1
  77. package/dist/collection/components/q2-input/index.js +729 -705
  78. package/dist/collection/components/q2-input/styles.css +2 -2
  79. package/dist/collection/components/q2-loading/index.js +143 -132
  80. package/dist/collection/components/q2-loading/skeleton/q2-loading-element/index.js +85 -74
  81. package/dist/collection/components/q2-loading/skeleton/shapes.js +23 -36
  82. package/dist/collection/components/q2-loading/styles.css +1 -1
  83. package/dist/collection/components/q2-loc/index.js +49 -39
  84. package/dist/collection/components/q2-loc/styles.css +1 -1
  85. package/dist/collection/components/q2-message/index.js +101 -92
  86. package/dist/collection/components/q2-message/styles.css +1 -1
  87. package/dist/collection/components/q2-optgroup/index.js +64 -56
  88. package/dist/collection/components/q2-optgroup/styles.css +1 -1
  89. package/dist/collection/components/q2-option/index.js +244 -229
  90. package/dist/collection/components/q2-option/styles.css +5 -1
  91. package/dist/collection/components/q2-option-list/index.js +291 -270
  92. package/dist/collection/components/q2-option-list/styles.css +1 -1
  93. package/dist/collection/components/q2-pagination/index.js +183 -179
  94. package/dist/collection/components/q2-pagination/styles.css +1 -1
  95. package/dist/collection/components/q2-pill/index.js +260 -208
  96. package/dist/collection/components/q2-pill/styles.css +1 -1
  97. package/dist/collection/components/q2-popover/index.js +169 -151
  98. package/dist/collection/components/q2-popover/styles.css +2 -2
  99. package/dist/collection/components/q2-radio/index.js +233 -224
  100. package/dist/collection/components/q2-radio/styles.css +3 -3
  101. package/dist/collection/components/q2-radio-group/index.js +252 -244
  102. package/dist/collection/components/q2-radio-group/styles.css +1 -1
  103. package/dist/collection/components/q2-section/index.js +134 -125
  104. package/dist/collection/components/q2-section/styles.css +12 -1
  105. package/dist/collection/components/q2-select/index.js +393 -381
  106. package/dist/collection/components/q2-select/styles.css +1 -1
  107. package/dist/collection/components/q2-stepper/index.js +124 -126
  108. package/dist/collection/components/q2-stepper/styles.css +2 -1
  109. package/dist/collection/components/q2-stepper-pane/index.js +165 -149
  110. package/dist/collection/components/q2-stepper-pane/styles.css +1 -1
  111. package/dist/collection/components/q2-stepper-vertical/index.js +86 -85
  112. package/dist/collection/components/q2-stepper-vertical/styles.css +1 -1
  113. package/dist/collection/components/q2-tab-container/index.js +189 -184
  114. package/dist/collection/components/q2-tab-container/styles.css +1 -1
  115. package/dist/collection/components/q2-tab-pane/index.js +185 -166
  116. package/dist/collection/components/q2-tab-pane/styles.css +1 -1
  117. package/dist/collection/components/q2-tag/index.js +168 -116
  118. package/dist/collection/components/q2-tag/styles.css +1 -1
  119. package/dist/collection/components/q2-textarea/index.js +344 -327
  120. package/dist/collection/components/q2-textarea/styles.css +2 -2
  121. package/dist/collection/components/q2-tooltip/index.js +147 -133
  122. package/dist/collection/components/q2-tooltip/styles.css +1 -1
  123. package/dist/collection/components/tecton-tab-pane/index.js +287 -266
  124. package/dist/collection/components/tecton-tab-pane/styles.css +1 -1
  125. package/dist/collection/utils/index.js +2 -6
  126. package/dist/esm/click-elsewhere.entry.js +1 -1
  127. package/dist/esm/{icons-ed54e307.js → icons-78da5dd2.js} +1 -1
  128. package/dist/esm/{index-eac6b89e.js → index-9c591682.js} +1 -1
  129. package/dist/esm/{index-6d5ed7cc.js → index-bb1c8c7f.js} +476 -271
  130. package/dist/esm/loader.js +3 -3
  131. package/dist/esm/polyfills/css-shim.js +1 -1
  132. package/dist/esm/q2-avatar.entry.js +9 -6
  133. package/dist/esm/q2-badge_2.entry.js +46 -7
  134. package/dist/esm/q2-btn_2.entry.js +30 -5
  135. package/dist/esm/q2-calendar.entry.js +89 -62
  136. package/dist/esm/q2-card.entry.js +17 -6
  137. package/dist/esm/q2-carousel-pane.entry.js +7 -3
  138. package/dist/esm/q2-carousel.entry.js +196 -285
  139. package/dist/esm/q2-chart-donut.entry.js +583 -504
  140. package/dist/esm/q2-checkbox-group.entry.js +9 -7
  141. package/dist/esm/q2-checkbox.entry.js +17 -4
  142. package/dist/esm/q2-dropdown-item.entry.js +9 -3
  143. package/dist/esm/q2-dropdown.entry.js +16 -5
  144. package/dist/esm/q2-editable-field.entry.js +16 -6
  145. package/dist/esm/q2-icon.entry.js +6 -4
  146. package/dist/esm/q2-loading-element.entry.js +6 -2
  147. package/dist/esm/q2-loc.entry.js +5 -3
  148. package/dist/esm/q2-message.entry.js +4 -3
  149. package/dist/esm/q2-month-picker.entry.js +9 -7
  150. package/dist/esm/q2-optgroup.entry.js +6 -5
  151. package/dist/esm/q2-option-list_2.entry.js +21 -7
  152. package/dist/esm/q2-option.entry.js +12 -2
  153. package/dist/esm/q2-pagination.entry.js +11 -3
  154. package/dist/esm/q2-pill.entry.js +25 -7
  155. package/dist/esm/q2-radio-group.entry.js +13 -6
  156. package/dist/esm/q2-radio.entry.js +13 -8
  157. package/dist/esm/q2-section.entry.js +9 -4
  158. package/dist/esm/q2-select.entry.js +26 -17
  159. package/dist/esm/q2-stepper-pane.entry.js +8 -3
  160. package/dist/esm/q2-stepper-vertical.entry.js +5 -4
  161. package/dist/esm/q2-stepper.entry.js +9 -7
  162. package/dist/esm/q2-tab-container.entry.js +14 -9
  163. package/dist/esm/q2-tab-pane.entry.js +10 -2
  164. package/dist/esm/q2-tag.entry.js +20 -7
  165. package/dist/esm/q2-tecton-elements.js +3 -3
  166. package/dist/esm/q2-textarea.entry.js +20 -4
  167. package/dist/esm/q2-tooltip.entry.js +9 -3
  168. package/dist/esm/{shapes-c32e3ba2.js → shapes-62b8a431.js} +1 -1
  169. package/dist/esm/tecton-tab-pane.entry.js +17 -2
  170. package/dist/loader/package.json +1 -0
  171. package/dist/q2-tecton-elements/p-0ba564b1.entry.js +1 -0
  172. package/dist/q2-tecton-elements/p-0fad9c5a.entry.js +1 -0
  173. package/dist/q2-tecton-elements/{p-73154834.js → p-13a639cf.js} +1 -1
  174. package/dist/q2-tecton-elements/p-16c11d74.entry.js +1 -0
  175. package/dist/q2-tecton-elements/p-17e0cbf1.entry.js +1 -0
  176. package/dist/q2-tecton-elements/p-18e095af.entry.js +1 -0
  177. package/dist/q2-tecton-elements/p-2c9b1308.entry.js +1 -0
  178. package/dist/q2-tecton-elements/p-2e832e42.entry.js +1 -0
  179. package/dist/q2-tecton-elements/p-315fdb74.entry.js +1 -0
  180. package/dist/q2-tecton-elements/{p-c608e3c9.entry.js → p-444415b5.entry.js} +1 -1
  181. package/dist/q2-tecton-elements/p-4d700630.entry.js +1 -0
  182. package/dist/q2-tecton-elements/p-4f0f45e7.entry.js +1 -0
  183. package/dist/q2-tecton-elements/p-54e792bd.entry.js +1 -0
  184. package/dist/q2-tecton-elements/{p-80014da0.js → p-5e374fbd.js} +1 -1
  185. package/dist/q2-tecton-elements/p-5f064e1e.entry.js +39 -0
  186. package/dist/q2-tecton-elements/p-692f2d09.entry.js +1 -0
  187. package/dist/q2-tecton-elements/p-6e6b5b80.entry.js +1 -0
  188. package/dist/q2-tecton-elements/p-7e8f43d1.entry.js +1 -0
  189. package/dist/q2-tecton-elements/p-8e380edf.entry.js +1 -0
  190. package/dist/q2-tecton-elements/p-926a3e80.js +2 -0
  191. package/dist/q2-tecton-elements/{p-93c00587.js → p-92e1faf8.js} +1 -1
  192. package/dist/q2-tecton-elements/p-9772b15f.entry.js +1 -0
  193. package/dist/q2-tecton-elements/p-97aa8423.entry.js +1 -0
  194. package/dist/q2-tecton-elements/{p-17cffd7d.entry.js → p-a987402e.entry.js} +1 -1
  195. package/dist/q2-tecton-elements/p-aaf42539.entry.js +1 -0
  196. package/dist/q2-tecton-elements/p-ac674c20.entry.js +1 -0
  197. package/dist/q2-tecton-elements/p-b8b00394.entry.js +1 -0
  198. package/dist/q2-tecton-elements/p-c444a60b.entry.js +1 -0
  199. package/dist/q2-tecton-elements/p-c6c489fe.entry.js +1 -0
  200. package/dist/q2-tecton-elements/p-ce015552.entry.js +1 -0
  201. package/dist/q2-tecton-elements/p-d464fccc.entry.js +1 -0
  202. package/dist/q2-tecton-elements/p-de164483.entry.js +1 -0
  203. package/dist/q2-tecton-elements/p-df91e954.entry.js +1 -0
  204. package/dist/q2-tecton-elements/p-e6d26f39.entry.js +1 -0
  205. package/dist/q2-tecton-elements/p-e8e113c2.entry.js +1 -0
  206. package/dist/q2-tecton-elements/p-f1d06917.entry.js +1 -0
  207. package/dist/q2-tecton-elements/p-f800fd1e.entry.js +1 -0
  208. package/dist/q2-tecton-elements/p-fb37e67e.entry.js +1 -0
  209. package/dist/q2-tecton-elements/p-fc134a5d.entry.js +1 -0
  210. package/dist/q2-tecton-elements/p-fe88e979.entry.js +1 -0
  211. package/dist/q2-tecton-elements/p-ffb48ccc.entry.js +1 -0
  212. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  213. package/dist/test/helpers.js +6 -0
  214. package/dist/types/components/q2-pill/index.d.ts +3 -0
  215. package/dist/types/components/q2-tag/index.d.ts +3 -0
  216. package/dist/types/components.d.ts +154 -38
  217. package/dist/types/stencil-public-runtime.d.ts +20 -4
  218. package/dist/types/workspace/workspace/Tecton_tecton-production_master/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +2 -0
  219. package/package.json +6 -6
  220. package/dist/q2-tecton-elements/p-02c1b7fd.entry.js +0 -1
  221. package/dist/q2-tecton-elements/p-04c743f2.entry.js +0 -1
  222. package/dist/q2-tecton-elements/p-07dc509c.entry.js +0 -1
  223. package/dist/q2-tecton-elements/p-12caa479.entry.js +0 -1
  224. package/dist/q2-tecton-elements/p-160dd1c2.entry.js +0 -1
  225. package/dist/q2-tecton-elements/p-1a3de749.entry.js +0 -1
  226. package/dist/q2-tecton-elements/p-2061c3fd.entry.js +0 -1
  227. package/dist/q2-tecton-elements/p-2a217895.entry.js +0 -1
  228. package/dist/q2-tecton-elements/p-2b94ae62.entry.js +0 -1
  229. package/dist/q2-tecton-elements/p-2e54f9a0.entry.js +0 -1
  230. package/dist/q2-tecton-elements/p-375569ff.entry.js +0 -1
  231. package/dist/q2-tecton-elements/p-3766cc6c.entry.js +0 -1
  232. package/dist/q2-tecton-elements/p-3eda2714.entry.js +0 -1
  233. package/dist/q2-tecton-elements/p-421af42d.entry.js +0 -1
  234. package/dist/q2-tecton-elements/p-4c53713d.entry.js +0 -1
  235. package/dist/q2-tecton-elements/p-4fd405f5.entry.js +0 -1
  236. package/dist/q2-tecton-elements/p-509c8924.entry.js +0 -1
  237. package/dist/q2-tecton-elements/p-55dc3dc1.entry.js +0 -1
  238. package/dist/q2-tecton-elements/p-5fffb28a.entry.js +0 -1
  239. package/dist/q2-tecton-elements/p-612e9974.entry.js +0 -1
  240. package/dist/q2-tecton-elements/p-64ca8c59.entry.js +0 -1
  241. package/dist/q2-tecton-elements/p-796c2bb5.entry.js +0 -1
  242. package/dist/q2-tecton-elements/p-86887866.entry.js +0 -1
  243. package/dist/q2-tecton-elements/p-9204c34d.entry.js +0 -1
  244. package/dist/q2-tecton-elements/p-9725d55f.entry.js +0 -1
  245. package/dist/q2-tecton-elements/p-a0fa416d.entry.js +0 -39
  246. package/dist/q2-tecton-elements/p-bd83e8e2.entry.js +0 -1
  247. package/dist/q2-tecton-elements/p-be0f2539.entry.js +0 -1
  248. package/dist/q2-tecton-elements/p-c05b0b55.entry.js +0 -1
  249. package/dist/q2-tecton-elements/p-c5691700.js +0 -1
  250. package/dist/q2-tecton-elements/p-d826d7ad.entry.js +0 -1
  251. package/dist/q2-tecton-elements/p-d9e9340c.entry.js +0 -1
  252. package/dist/q2-tecton-elements/p-e5757895.entry.js +0 -1
  253. package/dist/q2-tecton-elements/p-e68c9ef0.entry.js +0 -1
  254. package/dist/q2-tecton-elements/p-eb33bda4.entry.js +0 -1
  255. package/dist/q2-tecton-elements/p-f319549d.entry.js +0 -1
@@ -1,5 +1,13 @@
1
1
  const NAMESPACE = 'q2-tecton-elements';
2
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
+ */
3
11
  let scopeId;
4
12
  let contentRef;
5
13
  let hostTagName;
@@ -8,63 +16,6 @@ let checkSlotFallbackVisibility = false;
8
16
  let checkSlotRelocate = false;
9
17
  let isSvgMode = false;
10
18
  let queuePending = false;
11
- const win = typeof window !== 'undefined' ? window : {};
12
- const doc = win.document || { head: {} };
13
- const plt = {
14
- $flags$: 0,
15
- $resourcesUrl$: '',
16
- jmp: (h) => h(),
17
- raf: (h) => requestAnimationFrame(h),
18
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
19
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
20
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
21
- };
22
- const promiseResolve = (v) => Promise.resolve(v);
23
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
24
- try {
25
- new CSSStyleSheet();
26
- return typeof new CSSStyleSheet().replace === 'function';
27
- }
28
- catch (e) { }
29
- return false;
30
- })()
31
- ;
32
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
33
- if (listeners) {
34
- listeners.map(([flags, name, method]) => {
35
- const target = getHostListenerTarget(elm, flags) ;
36
- const handler = hostListenerProxy(hostRef, method);
37
- const opts = hostListenerOpts(flags);
38
- plt.ael(target, name, handler, opts);
39
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
40
- });
41
- }
42
- };
43
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
44
- try {
45
- {
46
- if (hostRef.$flags$ & 256 /* isListenReady */) {
47
- // instance is ready, let's call it's member method for this event
48
- hostRef.$lazyInstance$[methodName](ev);
49
- }
50
- else {
51
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
52
- }
53
- }
54
- }
55
- catch (e) {
56
- consoleError(e);
57
- }
58
- };
59
- const getHostListenerTarget = (elm, flags) => {
60
- if (flags & 8 /* TargetWindow */)
61
- return win;
62
- return elm;
63
- };
64
- // prettier-ignore
65
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
66
- const HYDRATED_CSS = '{visibility:hidden}[stencil-hydrated]{visibility:inherit}';
67
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
68
19
  const createTime = (fnName, tagName = '') => {
69
20
  {
70
21
  return () => {
@@ -79,71 +30,8 @@ const uniqueTime = (key, measureText) => {
79
30
  };
80
31
  }
81
32
  };
82
- const rootAppliedStyles = new WeakMap();
83
- const registerStyle = (scopeId, cssText, allowCS) => {
84
- let style = styles.get(scopeId);
85
- if (supportsConstructibleStylesheets && allowCS) {
86
- style = (style || new CSSStyleSheet());
87
- style.replace(cssText);
88
- }
89
- else {
90
- style = cssText;
91
- }
92
- styles.set(scopeId, style);
93
- };
94
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
95
- let scopeId = getScopeId(cmpMeta);
96
- let style = styles.get(scopeId);
97
- // if an element is NOT connected then getRootNode() will return the wrong root node
98
- // so the fallback is to always use the document for the root node in those cases
99
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
100
- if (style) {
101
- if (typeof style === 'string') {
102
- styleContainerNode = styleContainerNode.head || styleContainerNode;
103
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
104
- let styleElm;
105
- if (!appliedStyles) {
106
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
107
- }
108
- if (!appliedStyles.has(scopeId)) {
109
- {
110
- {
111
- styleElm = doc.createElement('style');
112
- styleElm.innerHTML = style;
113
- }
114
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
115
- }
116
- if (appliedStyles) {
117
- appliedStyles.add(scopeId);
118
- }
119
- }
120
- }
121
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
122
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
123
- }
124
- }
125
- return scopeId;
126
- };
127
- const attachStyles = (hostRef) => {
128
- const cmpMeta = hostRef.$cmpMeta$;
129
- const elm = hostRef.$hostElement$;
130
- const flags = cmpMeta.$flags$;
131
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
132
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
133
- if (flags & 10 /* needsScopedEncapsulation */) {
134
- // only required when we're NOT using native shadow dom (slot)
135
- // or this browser doesn't support native shadow dom
136
- // and this host element was NOT created with SSR
137
- // let's pick out the inner content for slot projection
138
- // create a node to represent where the original
139
- // content was first placed, which is useful later on
140
- // DOM WRITE!!
141
- elm['s-sc'] = scopeId;
142
- elm.classList.add(scopeId + '-h');
143
- }
144
- endAttachStyles();
145
- };
146
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
33
+ const HYDRATED_CSS = '{visibility:hidden}[stencil-hydrated]{visibility:inherit}';
34
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
147
35
  /**
148
36
  * Default style mode id
149
37
  */
@@ -180,7 +68,7 @@ const h = (nodeName, vnodeData, ...children) => {
180
68
  let slotName = null;
181
69
  let simple = false;
182
70
  let lastSimple = false;
183
- let vNodeChildren = [];
71
+ const vNodeChildren = [];
184
72
  const walk = (c) => {
185
73
  for (let i = 0; i < c.length; i++) {
186
74
  child = c[i];
@@ -292,6 +180,149 @@ const convertToPrivate = (node) => {
292
180
  vnode.$name$ = node.vname;
293
181
  return vnode;
294
182
  };
183
+ /**
184
+ * Parse a new property value for a given property type.
185
+ *
186
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
187
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
188
+ * 1. `any`, the type given to `propValue` in the function signature
189
+ * 2. the type stored from `propType`.
190
+ *
191
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
192
+ *
193
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
194
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
195
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
196
+ * ```tsx
197
+ * <my-cmp prop-val={0}></my-cmp>
198
+ * ```
199
+ *
200
+ * HTML prop values on the other hand, will always a string
201
+ *
202
+ * @param propValue the new value to coerce to some type
203
+ * @param propType the type of the prop, expressed as a binary number
204
+ * @returns the parsed/coerced value
205
+ */
206
+ const parsePropertyValue = (propValue, propType) => {
207
+ // ensure this value is of the correct prop type
208
+ if (propValue != null && !isComplexType(propValue)) {
209
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
210
+ // per the HTML spec, any string value means it is a boolean true value
211
+ // but we'll cheat here and say that the string "false" is the boolean false
212
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
213
+ }
214
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
215
+ // force it to be a number
216
+ return parseFloat(propValue);
217
+ }
218
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
219
+ // could have been passed as a number or boolean
220
+ // but we still want it as a string
221
+ return String(propValue);
222
+ }
223
+ // redundant return here for better minification
224
+ return propValue;
225
+ }
226
+ // not sure exactly what type we want
227
+ // so no need to change to a different type
228
+ return propValue;
229
+ };
230
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
231
+ const createEvent = (ref, name, flags) => {
232
+ const elm = getElement(ref);
233
+ return {
234
+ emit: (detail) => {
235
+ return emitEvent(elm, name, {
236
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
237
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
238
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
239
+ detail,
240
+ });
241
+ },
242
+ };
243
+ };
244
+ /**
245
+ * Helper function to create & dispatch a custom Event on a provided target
246
+ * @param elm the target of the Event
247
+ * @param name the name to give the custom Event
248
+ * @param opts options for configuring a custom Event
249
+ * @returns the custom Event
250
+ */
251
+ const emitEvent = (elm, name, opts) => {
252
+ const ev = plt.ce(name, opts);
253
+ elm.dispatchEvent(ev);
254
+ return ev;
255
+ };
256
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
257
+ const registerStyle = (scopeId, cssText, allowCS) => {
258
+ let style = styles.get(scopeId);
259
+ if (supportsConstructableStylesheets && allowCS) {
260
+ style = (style || new CSSStyleSheet());
261
+ if (typeof style === 'string') {
262
+ style = cssText;
263
+ }
264
+ else {
265
+ style.replaceSync(cssText);
266
+ }
267
+ }
268
+ else {
269
+ style = cssText;
270
+ }
271
+ styles.set(scopeId, style);
272
+ };
273
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
274
+ let scopeId = getScopeId(cmpMeta);
275
+ const style = styles.get(scopeId);
276
+ // if an element is NOT connected then getRootNode() will return the wrong root node
277
+ // so the fallback is to always use the document for the root node in those cases
278
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
279
+ if (style) {
280
+ if (typeof style === 'string') {
281
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
282
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
283
+ let styleElm;
284
+ if (!appliedStyles) {
285
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
286
+ }
287
+ if (!appliedStyles.has(scopeId)) {
288
+ {
289
+ {
290
+ styleElm = doc.createElement('style');
291
+ styleElm.innerHTML = style;
292
+ }
293
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
294
+ }
295
+ if (appliedStyles) {
296
+ appliedStyles.add(scopeId);
297
+ }
298
+ }
299
+ }
300
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
301
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
302
+ }
303
+ }
304
+ return scopeId;
305
+ };
306
+ const attachStyles = (hostRef) => {
307
+ const cmpMeta = hostRef.$cmpMeta$;
308
+ const elm = hostRef.$hostElement$;
309
+ const flags = cmpMeta.$flags$;
310
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
311
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
312
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
313
+ // only required when we're NOT using native shadow dom (slot)
314
+ // or this browser doesn't support native shadow dom
315
+ // and this host element was NOT created with SSR
316
+ // let's pick out the inner content for slot projection
317
+ // create a node to represent where the original
318
+ // content was first placed, which is useful later on
319
+ // DOM WRITE!!
320
+ elm['s-sc'] = scopeId;
321
+ elm.classList.add(scopeId + '-h');
322
+ }
323
+ endAttachStyles();
324
+ };
325
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
295
326
  /**
296
327
  * Production setAccessor() function based on Preact by
297
328
  * Jason Miller (@developit)
@@ -389,7 +420,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
389
420
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
390
421
  try {
391
422
  if (!elm.tagName.includes('-')) {
392
- let n = newValue == null ? '' : newValue;
423
+ const n = newValue == null ? '' : newValue;
393
424
  // Workaround for Safari, moving the <input> caret when re-assigning the same valued
394
425
  if (memberName === 'list') {
395
426
  isProp = false;
@@ -428,7 +459,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
428
459
  }
429
460
  }
430
461
  }
431
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
462
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
432
463
  newValue = newValue === true ? '' : newValue;
433
464
  if (xlink) {
434
465
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -446,7 +477,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
446
477
  // if the element passed in is a shadow root, which is a document fragment
447
478
  // then we want to be adding attrs/props to the shadow root's "host" element
448
479
  // if it's not a shadow root, then we add attrs/props to the same element
449
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
480
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
450
481
  ? newVnode.$elm$.host
451
482
  : newVnode.$elm$;
452
483
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -464,9 +495,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
464
495
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
465
496
  }
466
497
  };
498
+ /**
499
+ * Create a DOM Node corresponding to one of the children of a given VNode.
500
+ *
501
+ * @param oldParentVNode the parent VNode from the previous render
502
+ * @param newParentVNode the parent VNode from the current render
503
+ * @param childIndex the index of the VNode, in the _new_ parent node's
504
+ * children, for which we will create a new DOM node
505
+ * @param parentElm the parent DOM node which our new node will be a child of
506
+ * @returns the newly created node
507
+ */
467
508
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
468
509
  // tslint:disable-next-line: prefer-const
469
- let newVNode = newParentVNode.$children$[childIndex];
510
+ const newVNode = newParentVNode.$children$[childIndex];
470
511
  let i = 0;
471
512
  let elm;
472
513
  let childNode;
@@ -481,16 +522,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
481
522
  }
482
523
  newVNode.$flags$ |= newVNode.$children$
483
524
  ? // slot element has fallback content
484
- 2 /* isSlotFallback */
525
+ 2 /* VNODE_FLAGS.isSlotFallback */
485
526
  : // slot element does not have fallback content
486
- 1 /* isSlotReference */;
527
+ 1 /* VNODE_FLAGS.isSlotReference */;
487
528
  }
488
529
  }
489
530
  if (newVNode.$text$ !== null) {
490
531
  // create text node
491
532
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
492
533
  }
493
- else if (newVNode.$flags$ & 1 /* isSlotReference */) {
534
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
494
535
  // create a slot reference node
495
536
  elm = newVNode.$elm$ =
496
537
  doc.createTextNode('');
@@ -500,7 +541,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
500
541
  isSvgMode = newVNode.$tag$ === 'svg';
501
542
  }
502
543
  // create element
503
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
544
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
504
545
  ? 'slot-fb'
505
546
  : newVNode.$tag$)
506
547
  );
@@ -540,7 +581,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
540
581
  }
541
582
  {
542
583
  elm['s-hn'] = hostTagName;
543
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
584
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
544
585
  // remember the content reference comment
545
586
  elm['s-sr'] = true;
546
587
  // remember the content reference comment
@@ -559,7 +600,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
559
600
  return elm;
560
601
  };
561
602
  const putBackInOriginalLocation = (parentElm, recursive) => {
562
- plt.$flags$ |= 1 /* isTmpDisconnected */;
603
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
563
604
  const oldSlotChildNodes = parentElm.childNodes;
564
605
  for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
565
606
  const childNode = oldSlotChildNodes[i];
@@ -580,7 +621,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
580
621
  putBackInOriginalLocation(childNode, recursive);
581
622
  }
582
623
  }
583
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
624
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
584
625
  };
585
626
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
586
627
  let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
@@ -622,6 +663,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
622
663
  }
623
664
  }
624
665
  };
666
+ /**
667
+ * Reconcile the children of a new VNode with the children of an old VNode by
668
+ * traversing the two collections of children, identifying nodes that are
669
+ * conserved or changed, calling out to `patch` to make any necessary
670
+ * updates to the DOM, and rearranging DOM nodes as needed.
671
+ *
672
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
673
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
674
+ * 'windows' by storing start and end indices and references to the
675
+ * corresponding array entries. Initially the two 'windows' are basically equal
676
+ * to the entire array, but we progressively narrow the windows until there are
677
+ * no children left to update by doing the following:
678
+ *
679
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
680
+ * that if we have an initial array like the following we'll end up dealing
681
+ * only with a window bounded by the highlighted elements:
682
+ *
683
+ * [null, null, VNode1 , ... , VNode2, null, null]
684
+ * ^^^^^^ ^^^^^^
685
+ *
686
+ * 2. Check to see if the elements at the head and tail positions are equal
687
+ * across the windows. This will basically detect elements which haven't
688
+ * been added, removed, or changed position, i.e. if you had the following
689
+ * VNode elements (represented as HTML):
690
+ *
691
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
692
+ * newVNode: `<div><p><span>THERE</span></p></div>`
693
+ *
694
+ * Then when comparing the children of the `<div>` tag we check the equality
695
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
696
+ * same tag in the same position, we'd be able to avoid completely
697
+ * re-rendering the subtree under them with a new DOM element and would just
698
+ * call out to `patch` to handle reconciling their children and so on.
699
+ *
700
+ * 3. Check, for both windows, to see if the element at the beginning of the
701
+ * window corresponds to the element at the end of the other window. This is
702
+ * a heuristic which will let us identify _some_ situations in which
703
+ * elements have changed position, for instance it _should_ detect that the
704
+ * children nodes themselves have not changed but merely moved in the
705
+ * following example:
706
+ *
707
+ * oldVNode: `<div><element-one /><element-two /></div>`
708
+ * newVNode: `<div><element-two /><element-one /></div>`
709
+ *
710
+ * If we find cases like this then we also need to move the concrete DOM
711
+ * elements corresponding to the moved children to write the re-order to the
712
+ * DOM.
713
+ *
714
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
715
+ * nodes in the old children which have the same key as the first element in
716
+ * our window on the new children. If we find such a node we handle calling
717
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
718
+ * what we find.
719
+ *
720
+ * Finally, once we've narrowed our 'windows' to the point that either of them
721
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
722
+ * insertion or deletion that needs to happen to get a DOM state that correctly
723
+ * reflects the new child VNodes. If, for instance, after our window on the old
724
+ * children has collapsed we still have more nodes on the new children that
725
+ * we haven't dealt with yet then we need to add them, or if the new children
726
+ * collapse but we still have unhandled _old_ children then we need to make
727
+ * sure the corresponding DOM nodes are removed.
728
+ *
729
+ * @param parentElm the node into which the parent VNode is rendered
730
+ * @param oldCh the old children of the parent node
731
+ * @param newVNode the new VNode which will replace the parent
732
+ * @param newCh the new children of the parent node
733
+ */
625
734
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
626
735
  let oldStartIdx = 0;
627
736
  let newStartIdx = 0;
@@ -637,7 +746,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
637
746
  let elmToMove;
638
747
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
639
748
  if (oldStartVnode == null) {
640
- // Vnode might have been moved left
749
+ // VNode might have been moved left
641
750
  oldStartVnode = oldCh[++oldStartIdx];
642
751
  }
643
752
  else if (oldEndVnode == null) {
@@ -650,37 +759,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
650
759
  newEndVnode = newCh[--newEndIdx];
651
760
  }
652
761
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
762
+ // if the start nodes are the same then we should patch the new VNode
763
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
764
+ // indices to reflect that. We don't need to move any DOM Nodes around
765
+ // since things are matched up in order.
653
766
  patch(oldStartVnode, newStartVnode);
654
767
  oldStartVnode = oldCh[++oldStartIdx];
655
768
  newStartVnode = newCh[++newStartIdx];
656
769
  }
657
770
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
771
+ // likewise, if the end nodes are the same we patch new onto old and
772
+ // decrement our end indices, and also likewise in this case we don't
773
+ // need to move any DOM Nodes.
658
774
  patch(oldEndVnode, newEndVnode);
659
775
  oldEndVnode = oldCh[--oldEndIdx];
660
776
  newEndVnode = newCh[--newEndIdx];
661
777
  }
662
778
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
663
- // Vnode moved right
779
+ // case: "Vnode moved right"
780
+ //
781
+ // We've found that the last node in our window on the new children is
782
+ // the same VNode as the _first_ node in our window on the old children
783
+ // we're dealing with now. Visually, this is the layout of these two
784
+ // nodes:
785
+ //
786
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
787
+ // ^^^^^^^^^^^
788
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
789
+ // ^^^^^^^^^^^^^
790
+ //
791
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
792
+ // and move the DOM element for `oldStartVnode`.
664
793
  if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
665
794
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
666
795
  }
667
796
  patch(oldStartVnode, newEndVnode);
797
+ // We need to move the element for `oldStartVnode` into a position which
798
+ // will be appropriate for `newEndVnode`. For this we can use
799
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
800
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
801
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
802
+ //
803
+ // <old-start-node />
804
+ // <some-intervening-node />
805
+ // <old-end-node />
806
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
807
+ // <next-sibling />
808
+ //
809
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
810
+ // the node for `oldStartVnode` at the end of the children of
811
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
812
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
813
+ // append it to the children of the parent element.
668
814
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
669
815
  oldStartVnode = oldCh[++oldStartIdx];
670
816
  newEndVnode = newCh[--newEndIdx];
671
817
  }
672
818
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
673
- // Vnode moved left
819
+ // case: "Vnode moved left"
820
+ //
821
+ // We've found that the first node in our window on the new children is
822
+ // the same VNode as the _last_ node in our window on the old children.
823
+ // Visually, this is the layout of these two nodes:
824
+ //
825
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
826
+ // ^^^^^^^^^^^^^
827
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
828
+ // ^^^^^^^^^^^
829
+ //
830
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
831
+ // (which will handle updating any changed attributes, reconciling their
832
+ // children etc) but we also need to move the DOM node to which
833
+ // `oldEndVnode` corresponds.
674
834
  if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
675
835
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
676
836
  }
677
837
  patch(oldEndVnode, newStartVnode);
838
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
839
+ // the same node, so since we're here we know that they are not. Thus we
840
+ // can move the element for `oldEndVnode` _before_ the element for
841
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
842
+ // future.
678
843
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
679
844
  oldEndVnode = oldCh[--oldEndIdx];
680
845
  newStartVnode = newCh[++newStartIdx];
681
846
  }
682
847
  else {
683
- // createKeyToOldIdx
848
+ // Here we do some checks to match up old and new nodes based on the
849
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
850
+ // in the JSX for a DOM element in the implementation of a Stencil
851
+ // component.
852
+ //
853
+ // First we check to see if there are any nodes in the array of old
854
+ // children which have the same key as the first node in the new
855
+ // children.
684
856
  idxInOld = -1;
685
857
  {
686
858
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -691,23 +863,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
691
863
  }
692
864
  }
693
865
  if (idxInOld >= 0) {
866
+ // We found a node in the old children which matches up with the first
867
+ // node in the new children! So let's deal with that
694
868
  elmToMove = oldCh[idxInOld];
695
869
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
870
+ // the tag doesn't match so we'll need a new DOM element
696
871
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
697
872
  }
698
873
  else {
699
874
  patch(elmToMove, newStartVnode);
875
+ // invalidate the matching old node so that we won't try to update it
876
+ // again later on
700
877
  oldCh[idxInOld] = undefined;
701
878
  node = elmToMove.$elm$;
702
879
  }
703
880
  newStartVnode = newCh[++newStartIdx];
704
881
  }
705
882
  else {
706
- // new element
883
+ // We either didn't find an element in the old children that matches
884
+ // the key of the first new child OR the build is not using `key`
885
+ // attributes at all. In either case we need to create a new element
886
+ // for the new node.
707
887
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
708
888
  newStartVnode = newCh[++newStartIdx];
709
889
  }
710
890
  if (node) {
891
+ // if we created a new node then handle inserting it to the DOM
711
892
  {
712
893
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
713
894
  }
@@ -715,21 +896,43 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
715
896
  }
716
897
  }
717
898
  if (oldStartIdx > oldEndIdx) {
899
+ // we have some more new nodes to add which don't match up with old nodes
718
900
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
719
901
  }
720
902
  else if (newStartIdx > newEndIdx) {
903
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
904
+ // in the new array, so lets remove them (which entails cleaning up the
905
+ // relevant DOM nodes)
721
906
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
722
907
  }
723
908
  };
724
- const isSameVnode = (vnode1, vnode2) => {
909
+ /**
910
+ * Compare two VNodes to determine if they are the same
911
+ *
912
+ * **NB**: This function is an equality _heuristic_ based on the available
913
+ * information set on the two VNodes and can be misleading under certain
914
+ * circumstances. In particular, if the two nodes do not have `key` attrs
915
+ * (available under `$key$` on VNodes) then the function falls back on merely
916
+ * checking that they have the same tag.
917
+ *
918
+ * So, in other words, if `key` attrs are not set on VNodes which may be
919
+ * changing order within a `children` array or something along those lines then
920
+ * we could obtain a false positive and then have to do needless re-rendering.
921
+ *
922
+ * @param leftVNode the first VNode to check
923
+ * @param rightVNode the second VNode to check
924
+ * @returns whether they're equal or not
925
+ */
926
+ const isSameVnode = (leftVNode, rightVNode) => {
725
927
  // compare if two vnode to see if they're "technically" the same
726
928
  // need to have the same element tag, and same key to be the same
727
- if (vnode1.$tag$ === vnode2.$tag$) {
728
- if (vnode1.$tag$ === 'slot') {
729
- return vnode1.$name$ === vnode2.$name$;
929
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
930
+ if (leftVNode.$tag$ === 'slot') {
931
+ return leftVNode.$name$ === rightVNode.$name$;
730
932
  }
933
+ // this will be set if components in the build have `key` attrs set on them
731
934
  {
732
- return vnode1.$key$ === vnode2.$key$;
935
+ return leftVNode.$key$ === rightVNode.$key$;
733
936
  }
734
937
  }
735
938
  return false;
@@ -742,6 +945,14 @@ const referenceNode = (node) => {
742
945
  return (node && node['s-ol']) || node;
743
946
  };
744
947
  const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
948
+ /**
949
+ * Handle reconciling an outdated VNode with a new one which corresponds to
950
+ * it. This function handles flushing updates to the DOM and reconciling the
951
+ * children of the two nodes (if any).
952
+ *
953
+ * @param oldVNode an old VNode whose DOM element and children we want to update
954
+ * @param newVNode a new VNode representing an updated version of the old one
955
+ */
745
956
  const patch = (oldVNode, newVNode) => {
746
957
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
747
958
  const oldChildren = oldVNode.$children$;
@@ -755,7 +966,6 @@ const patch = (oldVNode, newVNode) => {
755
966
  // only add this to the when the compiler sees we're using an svg somewhere
756
967
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
757
968
  }
758
- // element node
759
969
  {
760
970
  if (tag === 'slot')
761
971
  ;
@@ -768,6 +978,7 @@ const patch = (oldVNode, newVNode) => {
768
978
  }
769
979
  if (oldChildren !== null && newChildren !== null) {
770
980
  // looks like there's child vnodes for both the old and new vnodes
981
+ // so we need to call `updateChildren` to reconcile them
771
982
  updateChildren(elm, oldChildren, newVNode, newChildren);
772
983
  }
773
984
  else if (newChildren !== null) {
@@ -799,7 +1010,7 @@ const patch = (oldVNode, newVNode) => {
799
1010
  };
800
1011
  const updateFallbackSlotVisibility = (elm) => {
801
1012
  // tslint:disable-next-line: prefer-const
802
- let childNodes = elm.childNodes;
1013
+ const childNodes = elm.childNodes;
803
1014
  let childNode;
804
1015
  let i;
805
1016
  let ilen;
@@ -808,7 +1019,7 @@ const updateFallbackSlotVisibility = (elm) => {
808
1019
  let nodeType;
809
1020
  for (i = 0, ilen = childNodes.length; i < ilen; i++) {
810
1021
  childNode = childNodes[i];
811
- if (childNode.nodeType === 1 /* ElementNode */) {
1022
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
812
1023
  if (childNode['s-sr']) {
813
1024
  // this is a slot fallback node
814
1025
  // get the slot name for this slot reference node
@@ -820,7 +1031,7 @@ const updateFallbackSlotVisibility = (elm) => {
820
1031
  nodeType = childNodes[j].nodeType;
821
1032
  if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
822
1033
  // this sibling node is from a different component OR is a named fallback slot node
823
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1034
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
824
1035
  childNode.hidden = true;
825
1036
  break;
826
1037
  }
@@ -829,8 +1040,8 @@ const updateFallbackSlotVisibility = (elm) => {
829
1040
  // this is a default fallback slot node
830
1041
  // any element or text node (with content)
831
1042
  // should hide the default fallback slot node
832
- if (nodeType === 1 /* ElementNode */ ||
833
- (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1043
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1044
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
834
1045
  childNode.hidden = true;
835
1046
  break;
836
1047
  }
@@ -852,8 +1063,8 @@ const relocateSlotContent = (elm) => {
852
1063
  let relocateNodeData;
853
1064
  let j;
854
1065
  let i = 0;
855
- let childNodes = elm.childNodes;
856
- let ilen = childNodes.length;
1066
+ const childNodes = elm.childNodes;
1067
+ const ilen = childNodes.length;
857
1068
  for (; i < ilen; i++) {
858
1069
  childNode = childNodes[i];
859
1070
  if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
@@ -908,13 +1119,13 @@ const relocateSlotContent = (elm) => {
908
1119
  }
909
1120
  }
910
1121
  }
911
- if (childNode.nodeType === 1 /* ElementNode */) {
1122
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
912
1123
  relocateSlotContent(childNode);
913
1124
  }
914
1125
  }
915
1126
  };
916
1127
  const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
917
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1128
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
918
1129
  if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
919
1130
  return true;
920
1131
  }
@@ -945,7 +1156,7 @@ const renderVdom = (hostRef, renderFnResults) => {
945
1156
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
946
1157
  }
947
1158
  rootVnode.$tag$ = null;
948
- rootVnode.$flags$ |= 4 /* isHost */;
1159
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
949
1160
  hostRef.$vnode$ = rootVnode;
950
1161
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
951
1162
  {
@@ -953,7 +1164,7 @@ const renderVdom = (hostRef, renderFnResults) => {
953
1164
  }
954
1165
  {
955
1166
  contentRef = hostElm['s-cr'];
956
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1167
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
957
1168
  // always reset
958
1169
  checkSlotFallbackVisibility = false;
959
1170
  }
@@ -962,7 +1173,7 @@ const renderVdom = (hostRef, renderFnResults) => {
962
1173
  {
963
1174
  // while we're moving nodes around existing nodes, temporarily disable
964
1175
  // the disconnectCallback from working
965
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1176
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
966
1177
  if (checkSlotRelocate) {
967
1178
  relocateSlotContent(rootVnode.$elm$);
968
1179
  let relocateData;
@@ -1020,7 +1231,7 @@ const renderVdom = (hostRef, renderFnResults) => {
1020
1231
  }
1021
1232
  else {
1022
1233
  // this node doesn't have a slot home to go to, so let's hide it
1023
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1234
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1024
1235
  nodeToRelocate.hidden = true;
1025
1236
  }
1026
1237
  }
@@ -1031,37 +1242,11 @@ const renderVdom = (hostRef, renderFnResults) => {
1031
1242
  }
1032
1243
  // done moving nodes around
1033
1244
  // allow the disconnect callback to work again
1034
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1245
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1035
1246
  // always reset
1036
1247
  relocateNodes.length = 0;
1037
1248
  }
1038
1249
  };
1039
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1040
- const createEvent = (ref, name, flags) => {
1041
- const elm = getElement(ref);
1042
- return {
1043
- emit: (detail) => {
1044
- return emitEvent(elm, name, {
1045
- bubbles: !!(flags & 4 /* Bubbles */),
1046
- composed: !!(flags & 2 /* Composed */),
1047
- cancelable: !!(flags & 1 /* Cancellable */),
1048
- detail,
1049
- });
1050
- },
1051
- };
1052
- };
1053
- /**
1054
- * Helper function to create & dispatch a custom Event on a provided target
1055
- * @param elm the target of the Event
1056
- * @param name the name to give the custom Event
1057
- * @param opts options for configuring a custom Event
1058
- * @returns the custom Event
1059
- */
1060
- const emitEvent = (elm, name, opts) => {
1061
- const ev = plt.ce(name, opts);
1062
- elm.dispatchEvent(ev);
1063
- return ev;
1064
- };
1065
1250
  const attachToAncestor = (hostRef, ancestorComponent) => {
1066
1251
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1067
1252
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -1069,10 +1254,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
1069
1254
  };
1070
1255
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1071
1256
  {
1072
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1257
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1073
1258
  }
1074
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1075
- hostRef.$flags$ |= 512 /* needsRerender */;
1259
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1260
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1076
1261
  return;
1077
1262
  }
1078
1263
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -1088,7 +1273,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
1088
1273
  let promise;
1089
1274
  if (isInitialLoad) {
1090
1275
  {
1091
- hostRef.$flags$ |= 256 /* isListenReady */;
1276
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1092
1277
  if (hostRef.$queuedListeners$) {
1093
1278
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1094
1279
  hostRef.$queuedListeners$ = null;
@@ -1139,7 +1324,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1139
1324
  }
1140
1325
  else {
1141
1326
  Promise.all(childrenPromises).then(postUpdate);
1142
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1327
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1143
1328
  childrenPromises.length = 0;
1144
1329
  }
1145
1330
  }
@@ -1148,10 +1333,10 @@ const callRender = (hostRef, instance, elm) => {
1148
1333
  try {
1149
1334
  instance = instance.render && instance.render();
1150
1335
  {
1151
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1336
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1152
1337
  }
1153
1338
  {
1154
- hostRef.$flags$ |= 2 /* hasRendered */;
1339
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1155
1340
  }
1156
1341
  {
1157
1342
  {
@@ -1178,8 +1363,8 @@ const postUpdateComponent = (hostRef) => {
1178
1363
  {
1179
1364
  safeCall(instance, 'componentDidRender');
1180
1365
  }
1181
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1182
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1366
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1367
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1183
1368
  {
1184
1369
  // DOM WRITE!
1185
1370
  addHydratedFlag(elm);
@@ -1208,10 +1393,10 @@ const postUpdateComponent = (hostRef) => {
1208
1393
  hostRef.$onRenderResolve$();
1209
1394
  hostRef.$onRenderResolve$ = undefined;
1210
1395
  }
1211
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1396
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1212
1397
  nextTick(() => scheduleUpdate(hostRef, false));
1213
1398
  }
1214
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1399
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1215
1400
  }
1216
1401
  // ( •_•)
1217
1402
  // ( •_•)>⌐■-■
@@ -1241,53 +1426,6 @@ const then = (promise, thenFn) => {
1241
1426
  };
1242
1427
  const addHydratedFlag = (elm) => elm.setAttribute('stencil-hydrated', '')
1243
1428
  ;
1244
- /**
1245
- * Parse a new property value for a given property type.
1246
- *
1247
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1248
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1249
- * 1. `any`, the type given to `propValue` in the function signature
1250
- * 2. the type stored from `propType`.
1251
- *
1252
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1253
- *
1254
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1255
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1256
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1257
- * ```tsx
1258
- * <my-cmp prop-val={0}></my-cmp>
1259
- * ```
1260
- *
1261
- * HTML prop values on the other hand, will always a string
1262
- *
1263
- * @param propValue the new value to coerce to some type
1264
- * @param propType the type of the prop, expressed as a binary number
1265
- * @returns the parsed/coerced value
1266
- */
1267
- const parsePropertyValue = (propValue, propType) => {
1268
- // ensure this value is of the correct prop type
1269
- if (propValue != null && !isComplexType(propValue)) {
1270
- if (propType & 4 /* Boolean */) {
1271
- // per the HTML spec, any string value means it is a boolean true value
1272
- // but we'll cheat here and say that the string "false" is the boolean false
1273
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1274
- }
1275
- if (propType & 2 /* Number */) {
1276
- // force it to be a number
1277
- return parseFloat(propValue);
1278
- }
1279
- if (propType & 1 /* String */) {
1280
- // could have been passed as a number or boolean
1281
- // but we still want it as a string
1282
- return String(propValue);
1283
- }
1284
- // redundant return here for better minification
1285
- return propValue;
1286
- }
1287
- // not sure exactly what type we want
1288
- // so no need to change to a different type
1289
- return propValue;
1290
- };
1291
1429
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1292
1430
  const setValue = (ref, propName, newVal, cmpMeta) => {
1293
1431
  // check our new property value against our internal value
@@ -1300,13 +1438,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1300
1438
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1301
1439
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1302
1440
  const didValueChange = newVal !== oldVal && !areBothNaN;
1303
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1441
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1304
1442
  // gadzooks! the property's value has changed!!
1305
1443
  // set our new value!
1306
1444
  hostRef.$instanceValues$.set(propName, newVal);
1307
1445
  if (instance) {
1308
1446
  // get an array of method names of watch functions to call
1309
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1447
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1310
1448
  const watchMethods = cmpMeta.$watchers$[propName];
1311
1449
  if (watchMethods) {
1312
1450
  // this instance is watching for when this property changed
@@ -1321,7 +1459,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1321
1459
  });
1322
1460
  }
1323
1461
  }
1324
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1462
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1325
1463
  // looks like this value actually changed, so we've got work to do!
1326
1464
  // but only if we've already rendered, otherwise just chill out
1327
1465
  // queue that we need to do an update, but don't worry about queuing
@@ -1331,6 +1469,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1331
1469
  }
1332
1470
  }
1333
1471
  };
1472
+ /**
1473
+ * Attach a series of runtime constructs to a compiled Stencil component
1474
+ * constructor, including getters and setters for the `@Prop` and `@State`
1475
+ * decorators, callbacks for when attributes change, and so on.
1476
+ *
1477
+ * @param Cstr the constructor for a component that we need to process
1478
+ * @param cmpMeta metadata collected previously about the component
1479
+ * @param flags a number used to store a series of bit flags
1480
+ * @returns a reference to the same constructor passed in (but now mutated)
1481
+ */
1334
1482
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1335
1483
  if (cmpMeta.$members$) {
1336
1484
  if (Cstr.watchers) {
@@ -1340,8 +1488,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1340
1488
  const members = Object.entries(cmpMeta.$members$);
1341
1489
  const prototype = Cstr.prototype;
1342
1490
  members.map(([memberName, [memberFlags]]) => {
1343
- if ((memberFlags & 31 /* Prop */ ||
1344
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1491
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1492
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1345
1493
  // proxyComponent - prop
1346
1494
  Object.defineProperty(prototype, memberName, {
1347
1495
  get() {
@@ -1356,8 +1504,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1356
1504
  enumerable: true,
1357
1505
  });
1358
1506
  }
1359
- else if (flags & 1 /* isElementConstructor */ &&
1360
- memberFlags & 64 /* Method */) {
1507
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1508
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1361
1509
  // proxyComponent - method
1362
1510
  Object.defineProperty(prototype, memberName, {
1363
1511
  value(...args) {
@@ -1367,7 +1515,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1367
1515
  });
1368
1516
  }
1369
1517
  });
1370
- if ((flags & 1 /* isElementConstructor */)) {
1518
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1371
1519
  const attrNameToPropName = new Map();
1372
1520
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1373
1521
  plt.jmp(() => {
@@ -1423,11 +1571,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1423
1571
  // create an array of attributes to observe
1424
1572
  // and also create a map of html attribute name to js property name
1425
1573
  Cstr.observedAttributes = members
1426
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1574
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1427
1575
  .map(([propName, m]) => {
1428
1576
  const attrName = m[1] || propName;
1429
1577
  attrNameToPropName.set(attrName, propName);
1430
- if (m[0] & 512 /* ReflectAttr */) {
1578
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1431
1579
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1432
1580
  }
1433
1581
  return attrName;
@@ -1438,10 +1586,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1438
1586
  };
1439
1587
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1440
1588
  // initializeComponent
1441
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1589
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1442
1590
  {
1443
1591
  // we haven't initialized this element yet
1444
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1592
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1445
1593
  // lazy loaded components
1446
1594
  // request the component's implementation to be
1447
1595
  // wired up with the host element
@@ -1459,7 +1607,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1459
1607
  {
1460
1608
  cmpMeta.$watchers$ = Cstr.watchers;
1461
1609
  }
1462
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1610
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1463
1611
  Cstr.isProxied = true;
1464
1612
  }
1465
1613
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1467,7 +1615,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1467
1615
  // but let's keep track of when we start and stop
1468
1616
  // so that the getters/setters don't incorrectly step on data
1469
1617
  {
1470
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1618
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1471
1619
  }
1472
1620
  // construct the lazy-loaded component implementation
1473
1621
  // passing the hostRef is very important during
@@ -1480,10 +1628,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1480
1628
  consoleError(e);
1481
1629
  }
1482
1630
  {
1483
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1631
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1484
1632
  }
1485
1633
  {
1486
- hostRef.$flags$ |= 128 /* isWatchReady */;
1634
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1487
1635
  }
1488
1636
  endNewInstance();
1489
1637
  fireConnectedCallback(hostRef.$lazyInstance$);
@@ -1494,7 +1642,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1494
1642
  const scopeId = getScopeId(cmpMeta);
1495
1643
  if (!styles.has(scopeId)) {
1496
1644
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1497
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1645
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1498
1646
  endRegisterStyles();
1499
1647
  }
1500
1648
  }
@@ -1521,19 +1669,19 @@ const fireConnectedCallback = (instance) => {
1521
1669
  }
1522
1670
  };
1523
1671
  const connectedCallback = (elm) => {
1524
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1672
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1525
1673
  const hostRef = getHostRef(elm);
1526
1674
  const cmpMeta = hostRef.$cmpMeta$;
1527
1675
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1528
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1676
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1529
1677
  // first time this component has connected
1530
- hostRef.$flags$ |= 1 /* hasConnected */;
1678
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1531
1679
  {
1532
1680
  // initUpdate
1533
1681
  // if the slot polyfill is required we'll need to put some nodes
1534
1682
  // in here to act as original content anchors as we move nodes around
1535
1683
  // host element has been connected to the DOM
1536
- if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1684
+ if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1537
1685
  setContentReference(elm);
1538
1686
  }
1539
1687
  }
@@ -1556,7 +1704,7 @@ const connectedCallback = (elm) => {
1556
1704
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1557
1705
  if (cmpMeta.$members$) {
1558
1706
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1559
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1707
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1560
1708
  const value = elm[memberName];
1561
1709
  delete elm[memberName];
1562
1710
  elm[memberName] = value;
@@ -1590,7 +1738,7 @@ const setContentReference = (elm) => {
1590
1738
  elm.insertBefore(contentRefElm, elm.firstChild);
1591
1739
  };
1592
1740
  const disconnectedCallback = (elm) => {
1593
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1741
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1594
1742
  const hostRef = getHostRef(elm);
1595
1743
  const instance = hostRef.$lazyInstance$ ;
1596
1744
  {
@@ -1645,7 +1793,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1645
1793
  super(self);
1646
1794
  self = this;
1647
1795
  registerHost(self, cmpMeta);
1648
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1796
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1649
1797
  // this component is using shadow dom
1650
1798
  // and this browser supports shadow dom
1651
1799
  // add the read-only property "shadowRoot" to the host element
@@ -1680,7 +1828,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1680
1828
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1681
1829
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1682
1830
  cmpTags.push(tagName);
1683
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1831
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1684
1832
  }
1685
1833
  });
1686
1834
  });
@@ -1703,7 +1851,41 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1703
1851
  endBootstrap();
1704
1852
  };
1705
1853
  const Fragment = (_, children) => children;
1706
- const hostRefs = new WeakMap();
1854
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1855
+ if (listeners) {
1856
+ listeners.map(([flags, name, method]) => {
1857
+ const target = getHostListenerTarget(elm, flags) ;
1858
+ const handler = hostListenerProxy(hostRef, method);
1859
+ const opts = hostListenerOpts(flags);
1860
+ plt.ael(target, name, handler, opts);
1861
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1862
+ });
1863
+ }
1864
+ };
1865
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1866
+ try {
1867
+ {
1868
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1869
+ // instance is ready, let's call it's member method for this event
1870
+ hostRef.$lazyInstance$[methodName](ev);
1871
+ }
1872
+ else {
1873
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1874
+ }
1875
+ }
1876
+ }
1877
+ catch (e) {
1878
+ consoleError(e);
1879
+ }
1880
+ };
1881
+ const getHostListenerTarget = (elm, flags) => {
1882
+ if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1883
+ return win;
1884
+ return elm;
1885
+ };
1886
+ // prettier-ignore
1887
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1888
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1707
1889
  const getHostRef = (ref) => hostRefs.get(ref);
1708
1890
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1709
1891
  const registerHost = (elm, cmpMeta) => {
@@ -1735,7 +1917,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1735
1917
  if (module) {
1736
1918
  return module[exportName];
1737
1919
  }
1920
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1738
1921
  return import(
1922
+ /* @vite-ignore */
1739
1923
  /* webpackInclude: /\.entry\.js$/ */
1740
1924
  /* webpackExclude: /\.system\.entry\.js$/ */
1741
1925
  /* webpackMode: "lazy" */
@@ -1746,14 +1930,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1746
1930
  return importedModule[exportName];
1747
1931
  }, consoleError);
1748
1932
  };
1749
- const styles = new Map();
1933
+ const styles = /*@__PURE__*/ new Map();
1934
+ const win = typeof window !== 'undefined' ? window : {};
1935
+ const doc = win.document || { head: {} };
1936
+ const plt = {
1937
+ $flags$: 0,
1938
+ $resourcesUrl$: '',
1939
+ jmp: (h) => h(),
1940
+ raf: (h) => requestAnimationFrame(h),
1941
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1942
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1943
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1944
+ };
1945
+ const promiseResolve = (v) => Promise.resolve(v);
1946
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1947
+ try {
1948
+ new CSSStyleSheet();
1949
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1950
+ }
1951
+ catch (e) { }
1952
+ return false;
1953
+ })()
1954
+ ;
1750
1955
  const queueDomReads = [];
1751
1956
  const queueDomWrites = [];
1752
1957
  const queueTask = (queue, write) => (cb) => {
1753
1958
  queue.push(cb);
1754
1959
  if (!queuePending) {
1755
1960
  queuePending = true;
1756
- if (write && plt.$flags$ & 4 /* queueSync */) {
1961
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1757
1962
  nextTick(flush);
1758
1963
  }
1759
1964
  else {