@haiilo/catalyst 4.1.2 → 5.0.1

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 (277) hide show
  1. package/README.md +0 -2
  2. package/dist/catalyst/assets/fonts/Lato-Black.woff +0 -0
  3. package/dist/catalyst/assets/fonts/Lato-Black.woff2 +0 -0
  4. package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff +0 -0
  5. package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff2 +0 -0
  6. package/dist/catalyst/assets/fonts/Lato-Bold.woff +0 -0
  7. package/dist/catalyst/assets/fonts/Lato-Bold.woff2 +0 -0
  8. package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff +0 -0
  9. package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  10. package/dist/catalyst/assets/fonts/Lato-Hairline.woff +0 -0
  11. package/dist/catalyst/assets/fonts/Lato-Hairline.woff2 +0 -0
  12. package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff +0 -0
  13. package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
  14. package/dist/catalyst/assets/fonts/Lato-Heavy.woff +0 -0
  15. package/dist/catalyst/assets/fonts/Lato-Heavy.woff2 +0 -0
  16. package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff +0 -0
  17. package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
  18. package/dist/catalyst/assets/fonts/Lato-Italic.woff +0 -0
  19. package/dist/catalyst/assets/fonts/Lato-Italic.woff2 +0 -0
  20. package/dist/catalyst/assets/fonts/Lato-Light.woff +0 -0
  21. package/dist/catalyst/assets/fonts/Lato-Light.woff2 +0 -0
  22. package/dist/catalyst/assets/fonts/Lato-LightItalic.woff +0 -0
  23. package/dist/catalyst/assets/fonts/Lato-LightItalic.woff2 +0 -0
  24. package/dist/catalyst/assets/fonts/Lato-Medium.woff +0 -0
  25. package/dist/catalyst/assets/fonts/Lato-Medium.woff2 +0 -0
  26. package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff +0 -0
  27. package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff2 +0 -0
  28. package/dist/catalyst/assets/fonts/Lato-Regular.woff +0 -0
  29. package/dist/catalyst/assets/fonts/Lato-Regular.woff2 +0 -0
  30. package/dist/catalyst/assets/fonts/Lato-Semibold.woff +0 -0
  31. package/dist/catalyst/assets/fonts/Lato-Semibold.woff2 +0 -0
  32. package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff +0 -0
  33. package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
  34. package/dist/catalyst/assets/fonts/Lato-Thin.woff +0 -0
  35. package/dist/catalyst/assets/fonts/Lato-Thin.woff2 +0 -0
  36. package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff +0 -0
  37. package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff2 +0 -0
  38. package/dist/catalyst/catalyst.css +6 -27
  39. package/dist/catalyst/catalyst.esm.js +1 -1
  40. package/dist/catalyst/catalyst.esm.js.map +1 -1
  41. package/dist/catalyst/index.esm.js.map +1 -1
  42. package/dist/catalyst/p-ccfebe33.js.map +1 -1
  43. package/dist/catalyst/p-d1ee6a09.entry.js +10 -0
  44. package/dist/catalyst/p-d1ee6a09.entry.js.map +1 -0
  45. package/dist/catalyst/p-d1fb9d96.js +3 -0
  46. package/dist/catalyst/p-d1fb9d96.js.map +1 -0
  47. package/dist/catalyst/scss/fonts/_fonts-mixins.scss +0 -10
  48. package/dist/cjs/cat-alert_24.cjs.entry.js +933 -1135
  49. package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -1
  50. package/dist/cjs/catalyst.cjs.js +10 -3
  51. package/dist/cjs/catalyst.cjs.js.map +1 -1
  52. package/dist/cjs/{index-c4542095.js → index-01312a2e.js} +527 -245
  53. package/dist/cjs/index-01312a2e.js.map +1 -0
  54. package/dist/cjs/index.cjs.js.map +1 -1
  55. package/dist/cjs/loader.cjs.js +4 -3
  56. package/dist/cjs/loader.cjs.js.map +1 -1
  57. package/dist/collection/assets/fonts/Lato-Black.woff +0 -0
  58. package/dist/collection/assets/fonts/Lato-Black.woff2 +0 -0
  59. package/dist/collection/assets/fonts/Lato-BlackItalic.woff +0 -0
  60. package/dist/collection/assets/fonts/Lato-BlackItalic.woff2 +0 -0
  61. package/dist/collection/assets/fonts/Lato-Bold.woff +0 -0
  62. package/dist/collection/assets/fonts/Lato-Bold.woff2 +0 -0
  63. package/dist/collection/assets/fonts/Lato-BoldItalic.woff +0 -0
  64. package/dist/collection/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  65. package/dist/collection/assets/fonts/Lato-Hairline.woff +0 -0
  66. package/dist/collection/assets/fonts/Lato-Hairline.woff2 +0 -0
  67. package/dist/collection/assets/fonts/Lato-HairlineItalic.woff +0 -0
  68. package/dist/collection/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
  69. package/dist/collection/assets/fonts/Lato-Heavy.woff +0 -0
  70. package/dist/collection/assets/fonts/Lato-Heavy.woff2 +0 -0
  71. package/dist/collection/assets/fonts/Lato-HeavyItalic.woff +0 -0
  72. package/dist/collection/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
  73. package/dist/collection/assets/fonts/Lato-Italic.woff +0 -0
  74. package/dist/collection/assets/fonts/Lato-Italic.woff2 +0 -0
  75. package/dist/collection/assets/fonts/Lato-Light.woff +0 -0
  76. package/dist/collection/assets/fonts/Lato-Light.woff2 +0 -0
  77. package/dist/collection/assets/fonts/Lato-LightItalic.woff +0 -0
  78. package/dist/collection/assets/fonts/Lato-LightItalic.woff2 +0 -0
  79. package/dist/collection/assets/fonts/Lato-Medium.woff +0 -0
  80. package/dist/collection/assets/fonts/Lato-Medium.woff2 +0 -0
  81. package/dist/collection/assets/fonts/Lato-MediumItalic.woff +0 -0
  82. package/dist/collection/assets/fonts/Lato-MediumItalic.woff2 +0 -0
  83. package/dist/collection/assets/fonts/Lato-Regular.woff +0 -0
  84. package/dist/collection/assets/fonts/Lato-Regular.woff2 +0 -0
  85. package/dist/collection/assets/fonts/Lato-Semibold.woff +0 -0
  86. package/dist/collection/assets/fonts/Lato-Semibold.woff2 +0 -0
  87. package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff +0 -0
  88. package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
  89. package/dist/collection/assets/fonts/Lato-Thin.woff +0 -0
  90. package/dist/collection/assets/fonts/Lato-Thin.woff2 +0 -0
  91. package/dist/collection/assets/fonts/Lato-ThinItalic.woff +0 -0
  92. package/dist/collection/assets/fonts/Lato-ThinItalic.woff2 +0 -0
  93. package/dist/collection/collection-manifest.json +2 -2
  94. package/dist/collection/components/cat-alert/cat-alert.js +69 -71
  95. package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
  96. package/dist/collection/components/cat-avatar/cat-avatar.js +172 -165
  97. package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
  98. package/dist/collection/components/cat-badge/cat-badge.js +102 -111
  99. package/dist/collection/components/cat-badge/cat-badge.js.map +1 -1
  100. package/dist/collection/components/cat-button/cat-button.js +526 -537
  101. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  102. package/dist/collection/components/cat-card/cat-card.js +12 -8
  103. package/dist/collection/components/cat-checkbox/cat-checkbox.js +336 -350
  104. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  105. package/dist/collection/components/cat-dropdown/cat-dropdown.js +137 -137
  106. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  107. package/dist/collection/components/cat-form-group/cat-form-group.js +58 -40
  108. package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
  109. package/dist/collection/components/cat-form-hint/cat-form-hint.js +14 -7
  110. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -1
  111. package/dist/collection/components/cat-i18n/cat-i18n-registry.js +1 -1
  112. package/dist/collection/components/cat-icon/cat-icon-registry.js +1 -1
  113. package/dist/collection/components/cat-icon/cat-icon.js +85 -79
  114. package/dist/collection/components/cat-icon/cat-icon.js.map +1 -1
  115. package/dist/collection/components/cat-input/cat-input.css +32 -3
  116. package/dist/collection/components/cat-input/cat-input.js +662 -660
  117. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  118. package/dist/collection/components/cat-input/input-type.js +1 -1
  119. package/dist/collection/components/cat-label/cat-label.js +69 -78
  120. package/dist/collection/components/cat-label/cat-label.js.map +1 -1
  121. package/dist/collection/components/cat-notification/cat-notification.js +1 -1
  122. package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
  123. package/dist/collection/components/cat-pagination/cat-pagination.js +192 -226
  124. package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -1
  125. package/dist/collection/components/cat-radio/cat-radio.js +319 -327
  126. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  127. package/dist/collection/components/cat-radio-group/cat-radio-group.js +173 -165
  128. package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
  129. package/dist/collection/components/cat-scrollable/cat-scrollable.js +200 -208
  130. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
  131. package/dist/collection/components/cat-select/cat-select.js +556 -593
  132. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  133. package/dist/collection/components/cat-select-demo/cat-select-demo.js +3 -28
  134. package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
  135. package/dist/collection/components/cat-skeleton/cat-skeleton.js +85 -88
  136. package/dist/collection/components/cat-skeleton/cat-skeleton.js.map +1 -1
  137. package/dist/collection/components/cat-spinner/cat-spinner.js +52 -50
  138. package/dist/collection/components/cat-spinner/cat-spinner.js.map +1 -1
  139. package/dist/collection/components/cat-tab/cat-tab.js +169 -168
  140. package/dist/collection/components/cat-tab/cat-tab.js.map +1 -1
  141. package/dist/collection/components/cat-tabs/cat-tabs.js +73 -66
  142. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
  143. package/dist/collection/components/cat-textarea/cat-textarea.css +32 -1
  144. package/dist/collection/components/cat-textarea/cat-textarea.js +479 -468
  145. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  146. package/dist/collection/components/cat-toggle/cat-toggle.js +319 -326
  147. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  148. package/dist/collection/components/cat-tooltip/cat-tooltip.css +7 -1
  149. package/dist/collection/components/cat-tooltip/cat-tooltip.js +187 -198
  150. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  151. package/dist/collection/index.js +1 -1
  152. package/dist/collection/scss/fonts/_fonts-mixins.scss +0 -10
  153. package/dist/collection/utils/breakpoints.js +1 -1
  154. package/dist/collection/utils/breakpoints.js.map +1 -1
  155. package/dist/collection/utils/coerce.js +11 -0
  156. package/dist/collection/utils/coerce.js.map +1 -0
  157. package/dist/collection/utils/first-tabbable.js +1 -1
  158. package/dist/collection/utils/is-touch-screen.js +1 -1
  159. package/dist/collection/utils/load-img.js +1 -1
  160. package/dist/collection/utils/media-matcher.js +1 -1
  161. package/dist/collection/utils/platform.js +4 -4
  162. package/dist/collection/utils/setDefault.js +1 -1
  163. package/dist/components/cat-alert.js +1 -6
  164. package/dist/components/cat-alert.js.map +1 -1
  165. package/dist/components/cat-avatar2.js +6 -9
  166. package/dist/components/cat-avatar2.js.map +1 -1
  167. package/dist/components/cat-badge.js +0 -15
  168. package/dist/components/cat-badge.js.map +1 -1
  169. package/dist/components/cat-button2.js +10 -36
  170. package/dist/components/cat-button2.js.map +1 -1
  171. package/dist/components/cat-checkbox2.js +9 -26
  172. package/dist/components/cat-checkbox2.js.map +1 -1
  173. package/dist/components/cat-dropdown2.js +139 -176
  174. package/dist/components/cat-dropdown2.js.map +1 -1
  175. package/dist/components/cat-form-group.js +4 -9
  176. package/dist/components/cat-form-group.js.map +1 -1
  177. package/dist/components/cat-form-hint.js +13 -6
  178. package/dist/components/cat-form-hint.js.map +1 -1
  179. package/dist/components/cat-icon-registry.js +71 -0
  180. package/dist/components/cat-icon-registry.js.map +1 -0
  181. package/dist/components/cat-icon.js +1 -1
  182. package/dist/components/cat-icon2.js +5 -71
  183. package/dist/components/cat-icon2.js.map +1 -1
  184. package/dist/components/cat-input.js +33 -41
  185. package/dist/components/cat-input.js.map +1 -1
  186. package/dist/components/cat-label.js +1 -6
  187. package/dist/components/cat-label.js.map +1 -1
  188. package/dist/components/cat-pagination.js +0 -30
  189. package/dist/components/cat-pagination.js.map +1 -1
  190. package/dist/components/cat-radio-group.js +3 -6
  191. package/dist/components/cat-radio-group.js.map +1 -1
  192. package/dist/components/cat-radio.js +9 -23
  193. package/dist/components/cat-radio.js.map +1 -1
  194. package/dist/components/cat-scrollable2.js +1 -12
  195. package/dist/components/cat-scrollable2.js.map +1 -1
  196. package/dist/components/cat-select-demo.js +2 -12
  197. package/dist/components/cat-select-demo.js.map +1 -1
  198. package/dist/components/cat-select2.js +41 -50
  199. package/dist/components/cat-select2.js.map +1 -1
  200. package/dist/components/cat-skeleton2.js +1 -10
  201. package/dist/components/cat-skeleton2.js.map +1 -1
  202. package/dist/components/cat-spinner2.js +1 -3
  203. package/dist/components/cat-spinner2.js.map +1 -1
  204. package/dist/components/cat-tab.js +3 -12
  205. package/dist/components/cat-tab.js.map +1 -1
  206. package/dist/components/cat-tabs.js +1 -6
  207. package/dist/components/cat-tabs.js.map +1 -1
  208. package/dist/components/cat-textarea.js +28 -33
  209. package/dist/components/cat-textarea.js.map +1 -1
  210. package/dist/components/cat-toggle.js +9 -23
  211. package/dist/components/cat-toggle.js.map +1 -1
  212. package/dist/components/cat-tooltip.js +14 -34
  213. package/dist/components/cat-tooltip.js.map +1 -1
  214. package/dist/components/first-tabbable.js +51 -113
  215. package/dist/components/first-tabbable.js.map +1 -1
  216. package/dist/components/floating-ui.dom.esm.js +577 -441
  217. package/dist/components/floating-ui.dom.esm.js.map +1 -1
  218. package/dist/components/index.d.ts +9 -27
  219. package/dist/components/index.js +2 -26
  220. package/dist/components/index.js.map +1 -1
  221. package/dist/esm/cat-alert_24.entry.js +934 -1136
  222. package/dist/esm/cat-alert_24.entry.js.map +1 -1
  223. package/dist/esm/catalyst.js +7 -3
  224. package/dist/esm/catalyst.js.map +1 -1
  225. package/dist/esm/{index-524906f7.js → index-fc2f91a4.js} +527 -246
  226. package/dist/esm/index-fc2f91a4.js.map +1 -0
  227. package/dist/esm/index.js.map +1 -1
  228. package/dist/esm/loader.js +4 -3
  229. package/dist/esm/loader.js.map +1 -1
  230. package/dist/esm/polyfills/css-shim.js +1 -1
  231. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +1 -1
  232. package/dist/types/components/cat-form-group/cat-form-group.d.ts +4 -0
  233. package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +5 -0
  234. package/dist/types/components/cat-input/cat-input.d.ts +6 -1
  235. package/dist/types/components/cat-input/input-type.d.ts +1 -1
  236. package/dist/types/components/cat-radio/cat-radio.d.ts +1 -1
  237. package/dist/types/components/cat-select/cat-select.d.ts +2 -1
  238. package/dist/types/components/cat-textarea/cat-textarea.d.ts +6 -1
  239. package/dist/types/components/cat-toggle/cat-toggle.d.ts +1 -1
  240. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +3 -0
  241. package/dist/types/components.d.ts +353 -7
  242. package/dist/types/stencil-public-runtime.d.ts +91 -19
  243. package/dist/types/utils/breakpoints.d.ts +1 -1
  244. package/dist/types/utils/coerce.d.ts +3 -0
  245. package/dist/types/utils/first-tabbable.d.ts +2 -2
  246. package/loader/index.d.ts +9 -0
  247. package/loader/package.json +1 -0
  248. package/package.json +19 -19
  249. package/dist/catalyst/assets/fonts/AzeretMono-Regular.woff2 +0 -0
  250. package/dist/catalyst/assets/fonts/DMSans-Bold.woff2 +0 -0
  251. package/dist/catalyst/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
  252. package/dist/catalyst/assets/fonts/DMSans-Italic.woff2 +0 -0
  253. package/dist/catalyst/assets/fonts/DMSans-Medium.woff2 +0 -0
  254. package/dist/catalyst/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
  255. package/dist/catalyst/assets/fonts/DMSans-Regular.woff2 +0 -0
  256. package/dist/catalyst/p-919eea27.js +0 -3
  257. package/dist/catalyst/p-919eea27.js.map +0 -1
  258. package/dist/catalyst/p-cd8f8639.entry.js +0 -10
  259. package/dist/catalyst/p-cd8f8639.entry.js.map +0 -1
  260. package/dist/catalyst/scss/fonts/_fonts.mixins.azeret.scss +0 -14
  261. package/dist/catalyst/scss/fonts/_fonts.mixins.dm.scss +0 -53
  262. package/dist/cjs/index-c4542095.js.map +0 -1
  263. package/dist/collection/assets/fonts/AzeretMono-Regular.woff2 +0 -0
  264. package/dist/collection/assets/fonts/DMSans-Bold.woff2 +0 -0
  265. package/dist/collection/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
  266. package/dist/collection/assets/fonts/DMSans-Italic.woff2 +0 -0
  267. package/dist/collection/assets/fonts/DMSans-Medium.woff2 +0 -0
  268. package/dist/collection/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
  269. package/dist/collection/assets/fonts/DMSans-Regular.woff2 +0 -0
  270. package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js +0 -13
  271. package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js.map +0 -1
  272. package/dist/collection/scss/fonts/_fonts.mixins.azeret.scss +0 -14
  273. package/dist/collection/scss/fonts/_fonts.mixins.dm.scss +0 -53
  274. package/dist/components/cat-form-hint-utils.js +0 -17
  275. package/dist/components/cat-form-hint-utils.js.map +0 -1
  276. package/dist/esm/index-524906f7.js.map +0 -1
  277. package/dist/types/components/cat-form-hint/cat-form-hint-utils.d.ts +0 -4
@@ -22,62 +22,18 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'catalyst';
24
24
 
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
25
33
  let scopeId;
26
34
  let hostTagName;
27
35
  let isSvgMode = false;
28
36
  let queuePending = false;
29
- const win = typeof window !== 'undefined' ? window : {};
30
- const doc = win.document || { head: {} };
31
- const plt = {
32
- $flags$: 0,
33
- $resourcesUrl$: '',
34
- jmp: (h) => h(),
35
- raf: (h) => requestAnimationFrame(h),
36
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
37
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
38
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
39
- };
40
- const promiseResolve = (v) => Promise.resolve(v);
41
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
42
- try {
43
- new CSSStyleSheet();
44
- return typeof new CSSStyleSheet().replaceSync === 'function';
45
- }
46
- catch (e) { }
47
- return false;
48
- })()
49
- ;
50
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
51
- if (listeners) {
52
- listeners.map(([flags, name, method]) => {
53
- const target = elm;
54
- const handler = hostListenerProxy(hostRef, method);
55
- const opts = hostListenerOpts(flags);
56
- plt.ael(target, name, handler, opts);
57
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
58
- });
59
- }
60
- };
61
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
62
- try {
63
- {
64
- if (hostRef.$flags$ & 256 /* isListenReady */) {
65
- // instance is ready, let's call it's member method for this event
66
- hostRef.$lazyInstance$[methodName](ev);
67
- }
68
- else {
69
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
70
- }
71
- }
72
- }
73
- catch (e) {
74
- consoleError(e);
75
- }
76
- };
77
- // prettier-ignore
78
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
79
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
80
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
81
37
  const createTime = (fnName, tagName = '') => {
82
38
  {
83
39
  return () => {
@@ -92,76 +48,8 @@ const uniqueTime = (key, measureText) => {
92
48
  };
93
49
  }
94
50
  };
95
- const rootAppliedStyles = new WeakMap();
96
- const registerStyle = (scopeId, cssText, allowCS) => {
97
- let style = styles.get(scopeId);
98
- if (supportsConstructableStylesheets && allowCS) {
99
- style = (style || new CSSStyleSheet());
100
- if (typeof style === 'string') {
101
- style = cssText;
102
- }
103
- else {
104
- style.replaceSync(cssText);
105
- }
106
- }
107
- else {
108
- style = cssText;
109
- }
110
- styles.set(scopeId, style);
111
- };
112
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
113
- let scopeId = getScopeId(cmpMeta);
114
- const style = styles.get(scopeId);
115
- // if an element is NOT connected then getRootNode() will return the wrong root node
116
- // so the fallback is to always use the document for the root node in those cases
117
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
118
- if (style) {
119
- if (typeof style === 'string') {
120
- styleContainerNode = styleContainerNode.head || styleContainerNode;
121
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
122
- let styleElm;
123
- if (!appliedStyles) {
124
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
125
- }
126
- if (!appliedStyles.has(scopeId)) {
127
- {
128
- {
129
- styleElm = doc.createElement('style');
130
- styleElm.innerHTML = style;
131
- }
132
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
133
- }
134
- if (appliedStyles) {
135
- appliedStyles.add(scopeId);
136
- }
137
- }
138
- }
139
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
140
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
141
- }
142
- }
143
- return scopeId;
144
- };
145
- const attachStyles = (hostRef) => {
146
- const cmpMeta = hostRef.$cmpMeta$;
147
- const elm = hostRef.$hostElement$;
148
- const flags = cmpMeta.$flags$;
149
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
150
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
151
- if (flags & 10 /* needsScopedEncapsulation */) {
152
- // only required when we're NOT using native shadow dom (slot)
153
- // or this browser doesn't support native shadow dom
154
- // and this host element was NOT created with SSR
155
- // let's pick out the inner content for slot projection
156
- // create a node to represent where the original
157
- // content was first placed, which is useful later on
158
- // DOM WRITE!!
159
- elm['s-sc'] = scopeId;
160
- elm.classList.add(scopeId + '-h');
161
- }
162
- endAttachStyles();
163
- };
164
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
51
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
52
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
165
53
  /**
166
54
  * Default style mode id
167
55
  */
@@ -181,6 +69,18 @@ const isComplexType = (o) => {
181
69
  o = typeof o;
182
70
  return o === 'object' || o === 'function';
183
71
  };
72
+ /**
73
+ * Helper method for querying a `meta` tag that contains a nonce value
74
+ * out of a DOM's head.
75
+ *
76
+ * @param doc The DOM containing the `head` to query against
77
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
78
+ * exists or the tag has no content.
79
+ */
80
+ function queryNonceMetaTagContent(doc) {
81
+ var _a, _b, _c;
82
+ 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;
83
+ }
184
84
  /**
185
85
  * Production h() function based on Preact by
186
86
  * Jason Miller (@developit)
@@ -189,7 +89,6 @@ const isComplexType = (o) => {
189
89
  *
190
90
  * Modified for Stencil's compiler and vdom
191
91
  */
192
- // const stack: any[] = [];
193
92
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
194
93
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
195
94
  const h = (nodeName, vnodeData, ...children) => {
@@ -252,6 +151,14 @@ const h = (nodeName, vnodeData, ...children) => {
252
151
  }
253
152
  return vnode;
254
153
  };
154
+ /**
155
+ * A utility function for creating a virtual DOM node from a tag and some
156
+ * possible text content.
157
+ *
158
+ * @param tag the tag for this element
159
+ * @param text possible text content for the node
160
+ * @returns a newly-minted virtual DOM node
161
+ */
255
162
  const newVNode = (tag, text) => {
256
163
  const vnode = {
257
164
  $flags$: 0,
@@ -269,11 +176,31 @@ const newVNode = (tag, text) => {
269
176
  return vnode;
270
177
  };
271
178
  const Host = {};
179
+ /**
180
+ * Check whether a given node is a Host node or not
181
+ *
182
+ * @param node the virtual DOM node to check
183
+ * @returns whether it's a Host node or not
184
+ */
272
185
  const isHost = (node) => node && node.$tag$ === Host;
186
+ /**
187
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
188
+ *
189
+ * Note that these functions convert from {@link d.VNode} to
190
+ * {@link d.ChildNode} to give functional component developers a friendly
191
+ * interface.
192
+ */
273
193
  const vdomFnUtils = {
274
194
  forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
275
195
  map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
276
196
  };
197
+ /**
198
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
199
+ * friendlier public interface (hence, 'convertToPublic').
200
+ *
201
+ * @param node the virtual DOM node to convert
202
+ * @returns a converted child node
203
+ */
277
204
  const convertToPublic = (node) => ({
278
205
  vattrs: node.$attrs$,
279
206
  vchildren: node.$children$,
@@ -282,6 +209,15 @@ const convertToPublic = (node) => ({
282
209
  vtag: node.$tag$,
283
210
  vtext: node.$text$,
284
211
  });
212
+ /**
213
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
214
+ * order to use the resulting object in the virtual DOM. The initial object was
215
+ * likely created as part of presenting a public API, so converting it back
216
+ * involved making it 'private' again (hence, `convertToPrivate`).
217
+ *
218
+ * @param node the child node to convert
219
+ * @returns a converted virtual DOM node
220
+ */
285
221
  const convertToPrivate = (node) => {
286
222
  if (typeof node.vtag === 'function') {
287
223
  const vnodeData = Object.assign({}, node.vattrs);
@@ -300,6 +236,157 @@ const convertToPrivate = (node) => {
300
236
  vnode.$name$ = node.vname;
301
237
  return vnode;
302
238
  };
239
+ /**
240
+ * Parse a new property value for a given property type.
241
+ *
242
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
243
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
244
+ * 1. `any`, the type given to `propValue` in the function signature
245
+ * 2. the type stored from `propType`.
246
+ *
247
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
248
+ *
249
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
250
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
251
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
252
+ * ```tsx
253
+ * <my-cmp prop-val={0}></my-cmp>
254
+ * ```
255
+ *
256
+ * HTML prop values on the other hand, will always a string
257
+ *
258
+ * @param propValue the new value to coerce to some type
259
+ * @param propType the type of the prop, expressed as a binary number
260
+ * @returns the parsed/coerced value
261
+ */
262
+ const parsePropertyValue = (propValue, propType) => {
263
+ // ensure this value is of the correct prop type
264
+ if (propValue != null && !isComplexType(propValue)) {
265
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
266
+ // per the HTML spec, any string value means it is a boolean true value
267
+ // but we'll cheat here and say that the string "false" is the boolean false
268
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
269
+ }
270
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
271
+ // force it to be a number
272
+ return parseFloat(propValue);
273
+ }
274
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
275
+ // could have been passed as a number or boolean
276
+ // but we still want it as a string
277
+ return String(propValue);
278
+ }
279
+ // redundant return here for better minification
280
+ return propValue;
281
+ }
282
+ // not sure exactly what type we want
283
+ // so no need to change to a different type
284
+ return propValue;
285
+ };
286
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
287
+ const createEvent = (ref, name, flags) => {
288
+ const elm = getElement(ref);
289
+ return {
290
+ emit: (detail) => {
291
+ return emitEvent(elm, name, {
292
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
293
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
294
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
295
+ detail,
296
+ });
297
+ },
298
+ };
299
+ };
300
+ /**
301
+ * Helper function to create & dispatch a custom Event on a provided target
302
+ * @param elm the target of the Event
303
+ * @param name the name to give the custom Event
304
+ * @param opts options for configuring a custom Event
305
+ * @returns the custom Event
306
+ */
307
+ const emitEvent = (elm, name, opts) => {
308
+ const ev = plt.ce(name, opts);
309
+ elm.dispatchEvent(ev);
310
+ return ev;
311
+ };
312
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
313
+ const registerStyle = (scopeId, cssText, allowCS) => {
314
+ let style = styles.get(scopeId);
315
+ if (supportsConstructableStylesheets && allowCS) {
316
+ style = (style || new CSSStyleSheet());
317
+ if (typeof style === 'string') {
318
+ style = cssText;
319
+ }
320
+ else {
321
+ style.replaceSync(cssText);
322
+ }
323
+ }
324
+ else {
325
+ style = cssText;
326
+ }
327
+ styles.set(scopeId, style);
328
+ };
329
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
330
+ var _a;
331
+ let scopeId = getScopeId(cmpMeta);
332
+ const style = styles.get(scopeId);
333
+ // if an element is NOT connected then getRootNode() will return the wrong root node
334
+ // so the fallback is to always use the document for the root node in those cases
335
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
336
+ if (style) {
337
+ if (typeof style === 'string') {
338
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
339
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
340
+ let styleElm;
341
+ if (!appliedStyles) {
342
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
343
+ }
344
+ if (!appliedStyles.has(scopeId)) {
345
+ {
346
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
347
+ {
348
+ styleElm = doc.createElement('style');
349
+ styleElm.innerHTML = style;
350
+ }
351
+ // Apply CSP nonce to the style tag if it exists
352
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
353
+ if (nonce != null) {
354
+ styleElm.setAttribute('nonce', nonce);
355
+ }
356
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
357
+ }
358
+ if (appliedStyles) {
359
+ appliedStyles.add(scopeId);
360
+ }
361
+ }
362
+ }
363
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
364
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
365
+ }
366
+ }
367
+ return scopeId;
368
+ };
369
+ const attachStyles = (hostRef) => {
370
+ const cmpMeta = hostRef.$cmpMeta$;
371
+ const elm = hostRef.$hostElement$;
372
+ const flags = cmpMeta.$flags$;
373
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
374
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
375
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
376
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
377
+ // only required when we're NOT using native shadow dom (slot)
378
+ // or this browser doesn't support native shadow dom
379
+ // and this host element was NOT created with SSR
380
+ // let's pick out the inner content for slot projection
381
+ // create a node to represent where the original
382
+ // content was first placed, which is useful later on
383
+ // DOM WRITE!!
384
+ elm['s-sc'] = scopeId;
385
+ elm.classList.add(scopeId + '-h');
386
+ }
387
+ endAttachStyles();
388
+ };
389
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
303
390
  /**
304
391
  * Production setAccessor() function based on Preact by
305
392
  * Jason Miller (@developit)
@@ -436,7 +523,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
436
523
  }
437
524
  }
438
525
  }
439
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
526
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
440
527
  newValue = newValue === true ? '' : newValue;
441
528
  if (xlink) {
442
529
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -454,7 +541,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
454
541
  // if the element passed in is a shadow root, which is a document fragment
455
542
  // then we want to be adding attrs/props to the shadow root's "host" element
456
543
  // if it's not a shadow root, then we add attrs/props to the same element
457
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
544
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
458
545
  ? newVnode.$elm$.host
459
546
  : newVnode.$elm$;
460
547
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -472,6 +559,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
472
559
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
473
560
  }
474
561
  };
562
+ /**
563
+ * Create a DOM Node corresponding to one of the children of a given VNode.
564
+ *
565
+ * @param oldParentVNode the parent VNode from the previous render
566
+ * @param newParentVNode the parent VNode from the current render
567
+ * @param childIndex the index of the VNode, in the _new_ parent node's
568
+ * children, for which we will create a new DOM node
569
+ * @param parentElm the parent DOM node which our new node will be a child of
570
+ * @returns the newly created node
571
+ */
475
572
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
476
573
  // tslint:disable-next-line: prefer-const
477
574
  const newVNode = newParentVNode.$children$[childIndex];
@@ -525,6 +622,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
525
622
  }
526
623
  return elm;
527
624
  };
625
+ /**
626
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
627
+ * add them to the DOM in the appropriate place.
628
+ *
629
+ * @param parentElm the DOM node which should be used as a parent for the new
630
+ * DOM nodes
631
+ * @param before a child of the `parentElm` which the new children should be
632
+ * inserted before (optional)
633
+ * @param parentVNode the parent virtual DOM node
634
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
635
+ * @param startIdx the index in the child virtual DOM nodes at which to start
636
+ * creating DOM nodes (inclusive)
637
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
638
+ * creating DOM nodes (inclusive)
639
+ */
528
640
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
529
641
  let containerElm = (parentElm);
530
642
  let childNode;
@@ -541,6 +653,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
541
653
  }
542
654
  }
543
655
  };
656
+ /**
657
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
658
+ * This can be used to, for instance, clean up after a list of children which
659
+ * should no longer be shown.
660
+ *
661
+ * This function also handles some of Stencil's slot relocation logic.
662
+ *
663
+ * @param vnodes a list of virtual DOM nodes to remove
664
+ * @param startIdx the index at which to start removing nodes (inclusive)
665
+ * @param endIdx the index at which to stop removing nodes (inclusive)
666
+ * @param vnode a VNode
667
+ * @param elm an element
668
+ */
544
669
  const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
545
670
  for (; startIdx <= endIdx; ++startIdx) {
546
671
  if ((vnode = vnodes[startIdx])) {
@@ -551,6 +676,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
551
676
  }
552
677
  }
553
678
  };
679
+ /**
680
+ * Reconcile the children of a new VNode with the children of an old VNode by
681
+ * traversing the two collections of children, identifying nodes that are
682
+ * conserved or changed, calling out to `patch` to make any necessary
683
+ * updates to the DOM, and rearranging DOM nodes as needed.
684
+ *
685
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
686
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
687
+ * 'windows' by storing start and end indices and references to the
688
+ * corresponding array entries. Initially the two 'windows' are basically equal
689
+ * to the entire array, but we progressively narrow the windows until there are
690
+ * no children left to update by doing the following:
691
+ *
692
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
693
+ * that if we have an initial array like the following we'll end up dealing
694
+ * only with a window bounded by the highlighted elements:
695
+ *
696
+ * [null, null, VNode1 , ... , VNode2, null, null]
697
+ * ^^^^^^ ^^^^^^
698
+ *
699
+ * 2. Check to see if the elements at the head and tail positions are equal
700
+ * across the windows. This will basically detect elements which haven't
701
+ * been added, removed, or changed position, i.e. if you had the following
702
+ * VNode elements (represented as HTML):
703
+ *
704
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
705
+ * newVNode: `<div><p><span>THERE</span></p></div>`
706
+ *
707
+ * Then when comparing the children of the `<div>` tag we check the equality
708
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
709
+ * same tag in the same position, we'd be able to avoid completely
710
+ * re-rendering the subtree under them with a new DOM element and would just
711
+ * call out to `patch` to handle reconciling their children and so on.
712
+ *
713
+ * 3. Check, for both windows, to see if the element at the beginning of the
714
+ * window corresponds to the element at the end of the other window. This is
715
+ * a heuristic which will let us identify _some_ situations in which
716
+ * elements have changed position, for instance it _should_ detect that the
717
+ * children nodes themselves have not changed but merely moved in the
718
+ * following example:
719
+ *
720
+ * oldVNode: `<div><element-one /><element-two /></div>`
721
+ * newVNode: `<div><element-two /><element-one /></div>`
722
+ *
723
+ * If we find cases like this then we also need to move the concrete DOM
724
+ * elements corresponding to the moved children to write the re-order to the
725
+ * DOM.
726
+ *
727
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
728
+ * nodes in the old children which have the same key as the first element in
729
+ * our window on the new children. If we find such a node we handle calling
730
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
731
+ * what we find.
732
+ *
733
+ * Finally, once we've narrowed our 'windows' to the point that either of them
734
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
735
+ * insertion or deletion that needs to happen to get a DOM state that correctly
736
+ * reflects the new child VNodes. If, for instance, after our window on the old
737
+ * children has collapsed we still have more nodes on the new children that
738
+ * we haven't dealt with yet then we need to add them, or if the new children
739
+ * collapse but we still have unhandled _old_ children then we need to make
740
+ * sure the corresponding DOM nodes are removed.
741
+ *
742
+ * @param parentElm the node into which the parent VNode is rendered
743
+ * @param oldCh the old children of the parent node
744
+ * @param newVNode the new VNode which will replace the parent
745
+ * @param newCh the new children of the parent node
746
+ */
554
747
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
555
748
  let oldStartIdx = 0;
556
749
  let newStartIdx = 0;
@@ -566,7 +759,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
566
759
  let elmToMove;
567
760
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
568
761
  if (oldStartVnode == null) {
569
- // Vnode might have been moved left
762
+ // VNode might have been moved left
570
763
  oldStartVnode = oldCh[++oldStartIdx];
571
764
  }
572
765
  else if (oldEndVnode == null) {
@@ -579,29 +772,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
579
772
  newEndVnode = newCh[--newEndIdx];
580
773
  }
581
774
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
775
+ // if the start nodes are the same then we should patch the new VNode
776
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
777
+ // indices to reflect that. We don't need to move any DOM Nodes around
778
+ // since things are matched up in order.
582
779
  patch(oldStartVnode, newStartVnode);
583
780
  oldStartVnode = oldCh[++oldStartIdx];
584
781
  newStartVnode = newCh[++newStartIdx];
585
782
  }
586
783
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
784
+ // likewise, if the end nodes are the same we patch new onto old and
785
+ // decrement our end indices, and also likewise in this case we don't
786
+ // need to move any DOM Nodes.
587
787
  patch(oldEndVnode, newEndVnode);
588
788
  oldEndVnode = oldCh[--oldEndIdx];
589
789
  newEndVnode = newCh[--newEndIdx];
590
790
  }
591
791
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
592
792
  patch(oldStartVnode, newEndVnode);
793
+ // We need to move the element for `oldStartVnode` into a position which
794
+ // will be appropriate for `newEndVnode`. For this we can use
795
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
796
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
797
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
798
+ //
799
+ // <old-start-node />
800
+ // <some-intervening-node />
801
+ // <old-end-node />
802
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
803
+ // <next-sibling />
804
+ //
805
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
806
+ // the node for `oldStartVnode` at the end of the children of
807
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
808
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
809
+ // append it to the children of the parent element.
593
810
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
594
811
  oldStartVnode = oldCh[++oldStartIdx];
595
812
  newEndVnode = newCh[--newEndIdx];
596
813
  }
597
814
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
598
815
  patch(oldEndVnode, newStartVnode);
816
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
817
+ // the same node, so since we're here we know that they are not. Thus we
818
+ // can move the element for `oldEndVnode` _before_ the element for
819
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
820
+ // future.
599
821
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
600
822
  oldEndVnode = oldCh[--oldEndIdx];
601
823
  newStartVnode = newCh[++newStartIdx];
602
824
  }
603
825
  else {
604
- // createKeyToOldIdx
826
+ // Here we do some checks to match up old and new nodes based on the
827
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
828
+ // in the JSX for a DOM element in the implementation of a Stencil
829
+ // component.
830
+ //
831
+ // First we check to see if there are any nodes in the array of old
832
+ // children which have the same key as the first node in the new
833
+ // children.
605
834
  idxInOld = -1;
606
835
  {
607
836
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -612,23 +841,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
612
841
  }
613
842
  }
614
843
  if (idxInOld >= 0) {
844
+ // We found a node in the old children which matches up with the first
845
+ // node in the new children! So let's deal with that
615
846
  elmToMove = oldCh[idxInOld];
616
847
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
848
+ // the tag doesn't match so we'll need a new DOM element
617
849
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
618
850
  }
619
851
  else {
620
852
  patch(elmToMove, newStartVnode);
853
+ // invalidate the matching old node so that we won't try to update it
854
+ // again later on
621
855
  oldCh[idxInOld] = undefined;
622
856
  node = elmToMove.$elm$;
623
857
  }
624
858
  newStartVnode = newCh[++newStartIdx];
625
859
  }
626
860
  else {
627
- // new element
861
+ // We either didn't find an element in the old children that matches
862
+ // the key of the first new child OR the build is not using `key`
863
+ // attributes at all. In either case we need to create a new element
864
+ // for the new node.
628
865
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
629
866
  newStartVnode = newCh[++newStartIdx];
630
867
  }
631
868
  if (node) {
869
+ // if we created a new node then handle inserting it to the DOM
632
870
  {
633
871
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
634
872
  }
@@ -636,22 +874,53 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
636
874
  }
637
875
  }
638
876
  if (oldStartIdx > oldEndIdx) {
877
+ // we have some more new nodes to add which don't match up with old nodes
639
878
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
640
879
  }
641
880
  else if (newStartIdx > newEndIdx) {
881
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
882
+ // in the new array, so lets remove them (which entails cleaning up the
883
+ // relevant DOM nodes)
642
884
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
643
885
  }
644
886
  };
645
- const isSameVnode = (vnode1, vnode2) => {
887
+ /**
888
+ * Compare two VNodes to determine if they are the same
889
+ *
890
+ * **NB**: This function is an equality _heuristic_ based on the available
891
+ * information set on the two VNodes and can be misleading under certain
892
+ * circumstances. In particular, if the two nodes do not have `key` attrs
893
+ * (available under `$key$` on VNodes) then the function falls back on merely
894
+ * checking that they have the same tag.
895
+ *
896
+ * So, in other words, if `key` attrs are not set on VNodes which may be
897
+ * changing order within a `children` array or something along those lines then
898
+ * we could obtain a false negative and then have to do needless re-rendering
899
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
900
+ *
901
+ * @param leftVNode the first VNode to check
902
+ * @param rightVNode the second VNode to check
903
+ * @returns whether they're equal or not
904
+ */
905
+ const isSameVnode = (leftVNode, rightVNode) => {
646
906
  // compare if two vnode to see if they're "technically" the same
647
907
  // need to have the same element tag, and same key to be the same
648
- if (vnode1.$tag$ === vnode2.$tag$) {
908
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
909
+ // this will be set if components in the build have `key` attrs set on them
649
910
  {
650
- return vnode1.$key$ === vnode2.$key$;
911
+ return leftVNode.$key$ === rightVNode.$key$;
651
912
  }
652
913
  }
653
914
  return false;
654
915
  };
916
+ /**
917
+ * Handle reconciling an outdated VNode with a new one which corresponds to
918
+ * it. This function handles flushing updates to the DOM and reconciling the
919
+ * children of the two nodes (if any).
920
+ *
921
+ * @param oldVNode an old VNode whose DOM element and children we want to update
922
+ * @param newVNode a new VNode representing an updated version of the old one
923
+ */
655
924
  const patch = (oldVNode, newVNode) => {
656
925
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
657
926
  const oldChildren = oldVNode.$children$;
@@ -664,7 +933,6 @@ const patch = (oldVNode, newVNode) => {
664
933
  // only add this to the when the compiler sees we're using an svg somewhere
665
934
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
666
935
  }
667
- // element node
668
936
  {
669
937
  if (tag === 'slot')
670
938
  ;
@@ -677,6 +945,7 @@ const patch = (oldVNode, newVNode) => {
677
945
  }
678
946
  if (oldChildren !== null && newChildren !== null) {
679
947
  // looks like there's child vnodes for both the old and new vnodes
948
+ // so we need to call `updateChildren` to reconcile them
680
949
  updateChildren(elm, oldChildren, newVNode, newChildren);
681
950
  }
682
951
  else if (newChildren !== null) {
@@ -708,6 +977,18 @@ const callNodeRefs = (vNode) => {
708
977
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
709
978
  }
710
979
  };
980
+ /**
981
+ * The main entry point for Stencil's virtual DOM-based rendering engine
982
+ *
983
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
984
+ * function will handle creating a virtual DOM tree with a single root, patching
985
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
986
+ * relocation, and reflecting attributes.
987
+ *
988
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
989
+ * the DOM node into which it should be rendered.
990
+ * @param renderFnResults the virtual DOM nodes to be rendered
991
+ */
711
992
  const renderVdom = (hostRef, renderFnResults) => {
712
993
  const hostElm = hostRef.$hostElement$;
713
994
  const cmpMeta = hostRef.$cmpMeta$;
@@ -719,7 +1000,7 @@ const renderVdom = (hostRef, renderFnResults) => {
719
1000
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
720
1001
  }
721
1002
  rootVnode.$tag$ = null;
722
- rootVnode.$flags$ |= 4 /* isHost */;
1003
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
723
1004
  hostRef.$vnode$ = rootVnode;
724
1005
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
725
1006
  {
@@ -728,32 +1009,6 @@ const renderVdom = (hostRef, renderFnResults) => {
728
1009
  // synchronous patch
729
1010
  patch(oldVNode, rootVnode);
730
1011
  };
731
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
732
- const createEvent = (ref, name, flags) => {
733
- const elm = getElement(ref);
734
- return {
735
- emit: (detail) => {
736
- return emitEvent(elm, name, {
737
- bubbles: !!(flags & 4 /* Bubbles */),
738
- composed: !!(flags & 2 /* Composed */),
739
- cancelable: !!(flags & 1 /* Cancellable */),
740
- detail,
741
- });
742
- },
743
- };
744
- };
745
- /**
746
- * Helper function to create & dispatch a custom Event on a provided target
747
- * @param elm the target of the Event
748
- * @param name the name to give the custom Event
749
- * @param opts options for configuring a custom Event
750
- * @returns the custom Event
751
- */
752
- const emitEvent = (elm, name, opts) => {
753
- const ev = plt.ce(name, opts);
754
- elm.dispatchEvent(ev);
755
- return ev;
756
- };
757
1012
  const attachToAncestor = (hostRef, ancestorComponent) => {
758
1013
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
759
1014
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -761,10 +1016,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
761
1016
  };
762
1017
  const scheduleUpdate = (hostRef, isInitialLoad) => {
763
1018
  {
764
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1019
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
765
1020
  }
766
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
767
- hostRef.$flags$ |= 512 /* needsRerender */;
1021
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1022
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
768
1023
  return;
769
1024
  }
770
1025
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -780,7 +1035,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
780
1035
  let promise;
781
1036
  if (isInitialLoad) {
782
1037
  {
783
- hostRef.$flags$ |= 256 /* isListenReady */;
1038
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
784
1039
  if (hostRef.$queuedListeners$) {
785
1040
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
786
1041
  hostRef.$queuedListeners$ = null;
@@ -826,7 +1081,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
826
1081
  }
827
1082
  else {
828
1083
  Promise.all(childrenPromises).then(postUpdate);
829
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1084
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
830
1085
  childrenPromises.length = 0;
831
1086
  }
832
1087
  }
@@ -835,10 +1090,10 @@ const callRender = (hostRef, instance, elm) => {
835
1090
  try {
836
1091
  instance = instance.render() ;
837
1092
  {
838
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1093
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
839
1094
  }
840
1095
  {
841
- hostRef.$flags$ |= 2 /* hasRendered */;
1096
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
842
1097
  }
843
1098
  {
844
1099
  {
@@ -865,8 +1120,8 @@ const postUpdateComponent = (hostRef) => {
865
1120
  {
866
1121
  safeCall(instance, 'componentDidRender');
867
1122
  }
868
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
869
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1123
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1124
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
870
1125
  {
871
1126
  // DOM WRITE!
872
1127
  addHydratedFlag(elm);
@@ -895,10 +1150,10 @@ const postUpdateComponent = (hostRef) => {
895
1150
  hostRef.$onRenderResolve$();
896
1151
  hostRef.$onRenderResolve$ = undefined;
897
1152
  }
898
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1153
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
899
1154
  nextTick(() => scheduleUpdate(hostRef, false));
900
1155
  }
901
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1156
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
902
1157
  }
903
1158
  // ( •_•)
904
1159
  // ( •_•)>⌐■-■
@@ -928,53 +1183,6 @@ const then = (promise, thenFn) => {
928
1183
  };
929
1184
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
930
1185
  ;
931
- /**
932
- * Parse a new property value for a given property type.
933
- *
934
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
935
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
936
- * 1. `any`, the type given to `propValue` in the function signature
937
- * 2. the type stored from `propType`.
938
- *
939
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
940
- *
941
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
942
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
943
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
944
- * ```tsx
945
- * <my-cmp prop-val={0}></my-cmp>
946
- * ```
947
- *
948
- * HTML prop values on the other hand, will always a string
949
- *
950
- * @param propValue the new value to coerce to some type
951
- * @param propType the type of the prop, expressed as a binary number
952
- * @returns the parsed/coerced value
953
- */
954
- const parsePropertyValue = (propValue, propType) => {
955
- // ensure this value is of the correct prop type
956
- if (propValue != null && !isComplexType(propValue)) {
957
- if (propType & 4 /* Boolean */) {
958
- // per the HTML spec, any string value means it is a boolean true value
959
- // but we'll cheat here and say that the string "false" is the boolean false
960
- return propValue === 'false' ? false : propValue === '' || !!propValue;
961
- }
962
- if (propType & 2 /* Number */) {
963
- // force it to be a number
964
- return parseFloat(propValue);
965
- }
966
- if (propType & 1 /* String */) {
967
- // could have been passed as a number or boolean
968
- // but we still want it as a string
969
- return String(propValue);
970
- }
971
- // redundant return here for better minification
972
- return propValue;
973
- }
974
- // not sure exactly what type we want
975
- // so no need to change to a different type
976
- return propValue;
977
- };
978
1186
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
979
1187
  const setValue = (ref, propName, newVal, cmpMeta) => {
980
1188
  // check our new property value against our internal value
@@ -987,13 +1195,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
987
1195
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
988
1196
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
989
1197
  const didValueChange = newVal !== oldVal && !areBothNaN;
990
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1198
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
991
1199
  // gadzooks! the property's value has changed!!
992
1200
  // set our new value!
993
1201
  hostRef.$instanceValues$.set(propName, newVal);
994
1202
  if (instance) {
995
1203
  // get an array of method names of watch functions to call
996
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1204
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
997
1205
  const watchMethods = cmpMeta.$watchers$[propName];
998
1206
  if (watchMethods) {
999
1207
  // this instance is watching for when this property changed
@@ -1008,7 +1216,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1008
1216
  });
1009
1217
  }
1010
1218
  }
1011
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1219
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1012
1220
  // looks like this value actually changed, so we've got work to do!
1013
1221
  // but only if we've already rendered, otherwise just chill out
1014
1222
  // queue that we need to do an update, but don't worry about queuing
@@ -1018,6 +1226,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1018
1226
  }
1019
1227
  }
1020
1228
  };
1229
+ /**
1230
+ * Attach a series of runtime constructs to a compiled Stencil component
1231
+ * constructor, including getters and setters for the `@Prop` and `@State`
1232
+ * decorators, callbacks for when attributes change, and so on.
1233
+ *
1234
+ * @param Cstr the constructor for a component that we need to process
1235
+ * @param cmpMeta metadata collected previously about the component
1236
+ * @param flags a number used to store a series of bit flags
1237
+ * @returns a reference to the same constructor passed in (but now mutated)
1238
+ */
1021
1239
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1022
1240
  if (cmpMeta.$members$) {
1023
1241
  if (Cstr.watchers) {
@@ -1027,8 +1245,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1027
1245
  const members = Object.entries(cmpMeta.$members$);
1028
1246
  const prototype = Cstr.prototype;
1029
1247
  members.map(([memberName, [memberFlags]]) => {
1030
- if ((memberFlags & 31 /* Prop */ ||
1031
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1248
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1249
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1032
1250
  // proxyComponent - prop
1033
1251
  Object.defineProperty(prototype, memberName, {
1034
1252
  get() {
@@ -1043,8 +1261,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1043
1261
  enumerable: true,
1044
1262
  });
1045
1263
  }
1046
- else if (flags & 1 /* isElementConstructor */ &&
1047
- memberFlags & 64 /* Method */) {
1264
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1265
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1048
1266
  // proxyComponent - method
1049
1267
  Object.defineProperty(prototype, memberName, {
1050
1268
  value(...args) {
@@ -1054,7 +1272,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1054
1272
  });
1055
1273
  }
1056
1274
  });
1057
- if ((flags & 1 /* isElementConstructor */)) {
1275
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1058
1276
  const attrNameToPropName = new Map();
1059
1277
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1060
1278
  plt.jmp(() => {
@@ -1110,11 +1328,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1110
1328
  // create an array of attributes to observe
1111
1329
  // and also create a map of html attribute name to js property name
1112
1330
  Cstr.observedAttributes = members
1113
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1331
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1114
1332
  .map(([propName, m]) => {
1115
1333
  const attrName = m[1] || propName;
1116
1334
  attrNameToPropName.set(attrName, propName);
1117
- if (m[0] & 512 /* ReflectAttr */) {
1335
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1118
1336
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1119
1337
  }
1120
1338
  return attrName;
@@ -1125,10 +1343,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1125
1343
  };
1126
1344
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1127
1345
  // initializeComponent
1128
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1346
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1129
1347
  {
1130
1348
  // we haven't initialized this element yet
1131
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1349
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1132
1350
  // lazy loaded components
1133
1351
  // request the component's implementation to be
1134
1352
  // wired up with the host element
@@ -1146,7 +1364,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1146
1364
  {
1147
1365
  cmpMeta.$watchers$ = Cstr.watchers;
1148
1366
  }
1149
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1367
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1150
1368
  Cstr.isProxied = true;
1151
1369
  }
1152
1370
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1154,7 +1372,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1154
1372
  // but let's keep track of when we start and stop
1155
1373
  // so that the getters/setters don't incorrectly step on data
1156
1374
  {
1157
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1375
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1158
1376
  }
1159
1377
  // construct the lazy-loaded component implementation
1160
1378
  // passing the hostRef is very important during
@@ -1167,10 +1385,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1167
1385
  consoleError(e);
1168
1386
  }
1169
1387
  {
1170
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1388
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1171
1389
  }
1172
1390
  {
1173
- hostRef.$flags$ |= 128 /* isWatchReady */;
1391
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1174
1392
  }
1175
1393
  endNewInstance();
1176
1394
  fireConnectedCallback(hostRef.$lazyInstance$);
@@ -1181,7 +1399,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1181
1399
  const scopeId = getScopeId(cmpMeta);
1182
1400
  if (!styles.has(scopeId)) {
1183
1401
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1184
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1402
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1185
1403
  endRegisterStyles();
1186
1404
  }
1187
1405
  }
@@ -1208,13 +1426,13 @@ const fireConnectedCallback = (instance) => {
1208
1426
  }
1209
1427
  };
1210
1428
  const connectedCallback = (elm) => {
1211
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1429
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1212
1430
  const hostRef = getHostRef(elm);
1213
1431
  const cmpMeta = hostRef.$cmpMeta$;
1214
1432
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1215
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1433
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1216
1434
  // first time this component has connected
1217
- hostRef.$flags$ |= 1 /* hasConnected */;
1435
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1218
1436
  {
1219
1437
  // find the first ancestor component (if there is one) and register
1220
1438
  // this component as one of the actively loading child components for its ancestor
@@ -1234,7 +1452,7 @@ const connectedCallback = (elm) => {
1234
1452
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1235
1453
  if (cmpMeta.$members$) {
1236
1454
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1237
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1455
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1238
1456
  const value = elm[memberName];
1239
1457
  delete elm[memberName];
1240
1458
  elm[memberName] = value;
@@ -1257,7 +1475,7 @@ const connectedCallback = (elm) => {
1257
1475
  }
1258
1476
  };
1259
1477
  const disconnectedCallback = (elm) => {
1260
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1478
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1261
1479
  const hostRef = getHostRef(elm);
1262
1480
  const instance = hostRef.$lazyInstance$ ;
1263
1481
  {
@@ -1272,6 +1490,7 @@ const disconnectedCallback = (elm) => {
1272
1490
  }
1273
1491
  };
1274
1492
  const bootstrapLazy = (lazyBundles, options = {}) => {
1493
+ var _a;
1275
1494
  const endBootstrap = createTime();
1276
1495
  const cmpTags = [];
1277
1496
  const exclude = options.exclude || [];
@@ -1312,7 +1531,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1312
1531
  super(self);
1313
1532
  self = this;
1314
1533
  registerHost(self, cmpMeta);
1315
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1534
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1316
1535
  // this component is using shadow dom
1317
1536
  // and this browser supports shadow dom
1318
1537
  // add the read-only property "shadowRoot" to the host element
@@ -1347,13 +1566,18 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1347
1566
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1348
1567
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1349
1568
  cmpTags.push(tagName);
1350
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1569
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1351
1570
  }
1352
1571
  });
1353
1572
  });
1354
1573
  {
1355
1574
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1356
1575
  visibilityStyle.setAttribute('data-styles', '');
1576
+ // Apply CSP nonce to the style tag if it exists
1577
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1578
+ if (nonce != null) {
1579
+ visibilityStyle.setAttribute('nonce', nonce);
1580
+ }
1357
1581
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1358
1582
  }
1359
1583
  // Process deferred connectedCallbacks now all components have been registered
@@ -1369,7 +1593,43 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1369
1593
  // Fallback appLoad event
1370
1594
  endBootstrap();
1371
1595
  };
1372
- const hostRefs = new WeakMap();
1596
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1597
+ if (listeners) {
1598
+ listeners.map(([flags, name, method]) => {
1599
+ const target = elm;
1600
+ const handler = hostListenerProxy(hostRef, method);
1601
+ const opts = hostListenerOpts(flags);
1602
+ plt.ael(target, name, handler, opts);
1603
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1604
+ });
1605
+ }
1606
+ };
1607
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1608
+ try {
1609
+ {
1610
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1611
+ // instance is ready, let's call it's member method for this event
1612
+ hostRef.$lazyInstance$[methodName](ev);
1613
+ }
1614
+ else {
1615
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1616
+ }
1617
+ }
1618
+ }
1619
+ catch (e) {
1620
+ consoleError(e);
1621
+ }
1622
+ };
1623
+ // prettier-ignore
1624
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1625
+ /**
1626
+ * Assigns the given value to the nonce property on the runtime platform object.
1627
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1628
+ * @param nonce The value to be assigned to the platform nonce property.
1629
+ * @returns void
1630
+ */
1631
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1632
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1373
1633
  const getHostRef = (ref) => hostRefs.get(ref);
1374
1634
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1375
1635
  const registerHost = (elm, cmpMeta) => {
@@ -1414,14 +1674,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1414
1674
  return importedModule[exportName];
1415
1675
  }, consoleError);
1416
1676
  };
1417
- const styles = new Map();
1677
+ const styles = /*@__PURE__*/ new Map();
1678
+ const win = typeof window !== 'undefined' ? window : {};
1679
+ const doc = win.document || { head: {} };
1680
+ const plt = {
1681
+ $flags$: 0,
1682
+ $resourcesUrl$: '',
1683
+ jmp: (h) => h(),
1684
+ raf: (h) => requestAnimationFrame(h),
1685
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1686
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1687
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1688
+ };
1689
+ const promiseResolve = (v) => Promise.resolve(v);
1690
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1691
+ try {
1692
+ new CSSStyleSheet();
1693
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1694
+ }
1695
+ catch (e) { }
1696
+ return false;
1697
+ })()
1698
+ ;
1418
1699
  const queueDomReads = [];
1419
1700
  const queueDomWrites = [];
1420
1701
  const queueTask = (queue, write) => (cb) => {
1421
1702
  queue.push(cb);
1422
1703
  if (!queuePending) {
1423
1704
  queuePending = true;
1424
- if (write && plt.$flags$ & 4 /* queueSync */) {
1705
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1425
1706
  nextTick(flush);
1426
1707
  }
1427
1708
  else {
@@ -1465,5 +1746,6 @@ exports.getElement = getElement;
1465
1746
  exports.h = h;
1466
1747
  exports.promiseResolve = promiseResolve;
1467
1748
  exports.registerInstance = registerInstance;
1749
+ exports.setNonce = setNonce;
1468
1750
 
1469
- //# sourceMappingURL=index-c4542095.js.map
1751
+ //# sourceMappingURL=index-01312a2e.js.map