@usecapsule/core-components 3.0.1 → 3.1.0

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