@beeq/core 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/beeq/beeq.esm.js +1 -1
  2. package/dist/beeq/beeq.esm.js.map +1 -1
  3. package/dist/beeq/{p-69d93e10.entry.js → p-0af526fc.entry.js} +2 -2
  4. package/dist/beeq/{p-c483c17e.entry.js → p-0b6e3137.entry.js} +2 -2
  5. package/dist/beeq/{p-a7c6f797.entry.js → p-1c789890.entry.js} +2 -2
  6. package/dist/beeq/{p-29717d60.entry.js → p-1f370b12.entry.js} +2 -2
  7. package/dist/beeq/{p-b7b80227.entry.js → p-250b8476.entry.js} +2 -2
  8. package/dist/beeq/{p-4ea77b47.entry.js → p-28a9a23d.entry.js} +2 -2
  9. package/dist/beeq/{p-1dcff407.entry.js → p-29f90224.entry.js} +2 -2
  10. package/dist/beeq/{p-cf565f6a.entry.js → p-2f7137e0.entry.js} +2 -2
  11. package/dist/beeq/{p-ff6101a7.entry.js → p-31472c1f.entry.js} +2 -2
  12. package/dist/beeq/{p-dc08e1c5.entry.js → p-32134085.entry.js} +2 -2
  13. package/dist/beeq/{p-a35b19f0.entry.js → p-354f52d1.entry.js} +2 -2
  14. package/dist/beeq/{p-b0a999d6.entry.js → p-36eb59f9.entry.js} +2 -2
  15. package/dist/beeq/{p-22a2bf4a.entry.js → p-3c37a62d.entry.js} +2 -2
  16. package/dist/beeq/{p-69c47479.entry.js → p-42c5530c.entry.js} +2 -2
  17. package/dist/beeq/{p-6b12a365.entry.js → p-47d89d61.entry.js} +2 -2
  18. package/dist/beeq/{p-15ef27e9.entry.js → p-51603d69.entry.js} +2 -2
  19. package/dist/beeq/{p-a15f79c5.entry.js → p-6c1ddc44.entry.js} +2 -2
  20. package/dist/beeq/{p-58fdd13f.entry.js → p-6d5d2460.entry.js} +2 -2
  21. package/dist/beeq/{p-94039fe7.entry.js → p-70d07837.entry.js} +2 -2
  22. package/dist/beeq/p-70d07837.entry.js.map +1 -0
  23. package/dist/beeq/{p-c9fb7a30.entry.js → p-7d3c9c9a.entry.js} +2 -2
  24. package/dist/beeq/{p-126c2d19.entry.js → p-81a34a07.entry.js} +2 -2
  25. package/dist/beeq/{p-30db348f.entry.js → p-852c54d8.entry.js} +2 -2
  26. package/dist/beeq/{p-adbd57e8.entry.js → p-8593ad98.entry.js} +2 -2
  27. package/dist/beeq/{p-aaa76f94.entry.js → p-8b57cd5e.entry.js} +2 -2
  28. package/dist/beeq/{p-8cc8ac11.entry.js → p-981797b1.entry.js} +2 -2
  29. package/dist/beeq/{p-c69c58b8.entry.js → p-a30ba2bd.entry.js} +2 -2
  30. package/dist/beeq/{p-10ed463d.entry.js → p-ab632829.entry.js} +2 -2
  31. package/dist/beeq/{p-3de3223c.entry.js → p-ada3ca0a.entry.js} +2 -2
  32. package/dist/beeq/{p-c3228970.entry.js → p-bb8f8b78.entry.js} +2 -2
  33. package/dist/beeq/{p-3fe9aa19.entry.js → p-c14e94e0.entry.js} +2 -2
  34. package/dist/beeq/p-c6dd73ea.js +6 -0
  35. package/dist/beeq/p-c6dd73ea.js.map +1 -0
  36. package/dist/beeq/{p-35dba65d.entry.js → p-c893951f.entry.js} +2 -2
  37. package/dist/beeq/{p-167c3774.entry.js → p-cbca544b.entry.js} +2 -2
  38. package/dist/beeq/{p-5666c9c1.entry.js → p-d11fafe0.entry.js} +2 -2
  39. package/dist/beeq/{p-a91e6eab.entry.js → p-d27ad8a0.entry.js} +2 -2
  40. package/dist/beeq/p-d27ad8a0.entry.js.map +1 -0
  41. package/dist/beeq/{p-56a53f77.entry.js → p-d58a7c27.entry.js} +2 -2
  42. package/dist/beeq/p-d5c5b299.entry.js +6 -0
  43. package/dist/beeq/p-d5c5b299.entry.js.map +1 -0
  44. package/dist/beeq/{p-0595abce.entry.js → p-de827971.entry.js} +2 -2
  45. package/dist/beeq/{p-2cc2ca42.entry.js → p-e2b64861.entry.js} +2 -2
  46. package/dist/beeq/p-fbd8dd21.js +7 -0
  47. package/dist/beeq/p-fbd8dd21.js.map +1 -0
  48. package/dist/cjs/beeq.cjs.js +28 -30
  49. package/dist/cjs/beeq.cjs.js.map +1 -1
  50. package/dist/cjs/bq-accordion-group.cjs.entry.js +1 -1
  51. package/dist/cjs/bq-accordion.cjs.entry.js +1 -1
  52. package/dist/cjs/bq-alert.cjs.entry.js +1 -1
  53. package/dist/cjs/bq-avatar.cjs.entry.js +1 -1
  54. package/dist/cjs/bq-badge.cjs.entry.js +1 -1
  55. package/dist/cjs/bq-breadcrumb-item.cjs.entry.js +1 -1
  56. package/dist/cjs/bq-breadcrumb.cjs.entry.js +1 -1
  57. package/dist/cjs/bq-button.cjs.entry.js +2 -2
  58. package/dist/cjs/bq-button.cjs.entry.js.map +1 -1
  59. package/dist/cjs/bq-card.cjs.entry.js +1 -1
  60. package/dist/cjs/bq-checkbox.cjs.entry.js +1 -1
  61. package/dist/cjs/bq-dialog.cjs.entry.js +1 -1
  62. package/dist/cjs/bq-divider.cjs.entry.js +1 -1
  63. package/dist/cjs/bq-drawer.cjs.entry.js +2 -2
  64. package/dist/cjs/bq-dropdown_3.cjs.entry.js +1 -1
  65. package/dist/cjs/bq-empty-state.cjs.entry.js +1 -1
  66. package/dist/cjs/bq-icon.cjs.entry.js +5 -7
  67. package/dist/cjs/bq-icon.cjs.entry.js.map +1 -1
  68. package/dist/cjs/bq-input.cjs.entry.js +1 -1
  69. package/dist/cjs/bq-notification.cjs.entry.js +1 -1
  70. package/dist/cjs/bq-option-group.cjs.entry.js +1 -1
  71. package/dist/cjs/bq-option.cjs.entry.js +1 -1
  72. package/dist/cjs/bq-panel.cjs.entry.js +2 -2
  73. package/dist/cjs/bq-progress.cjs.entry.js +1 -1
  74. package/dist/cjs/bq-radio-group.cjs.entry.js +1 -1
  75. package/dist/cjs/bq-radio.cjs.entry.js +1 -1
  76. package/dist/cjs/bq-select.cjs.entry.js +1 -1
  77. package/dist/cjs/bq-side-menu-item.cjs.entry.js +1 -1
  78. package/dist/cjs/bq-side-menu.cjs.entry.js +1 -1
  79. package/dist/cjs/bq-slider.cjs.entry.js +7 -5
  80. package/dist/cjs/bq-slider.cjs.entry.js.map +1 -1
  81. package/dist/cjs/bq-spinner.cjs.entry.js +1 -1
  82. package/dist/cjs/bq-status.cjs.entry.js +1 -1
  83. package/dist/cjs/bq-step-item.cjs.entry.js +1 -1
  84. package/dist/cjs/bq-steps.cjs.entry.js +1 -1
  85. package/dist/cjs/bq-switch.cjs.entry.js +1 -1
  86. package/dist/cjs/bq-tab-group.cjs.entry.js +1 -1
  87. package/dist/cjs/bq-tab.cjs.entry.js +1 -1
  88. package/dist/cjs/bq-textarea.cjs.entry.js +1 -1
  89. package/dist/cjs/bq-toast.cjs.entry.js +1 -1
  90. package/dist/cjs/bq-tooltip.cjs.entry.js +2 -2
  91. package/dist/cjs/{index-cf0d9d4d.js → index-32f757ed.js} +61 -23
  92. package/dist/cjs/index-32f757ed.js.map +1 -0
  93. package/dist/cjs/index-d55cdb65.js +1792 -0
  94. package/dist/cjs/index-d55cdb65.js.map +1 -0
  95. package/dist/cjs/loader.cjs.js +1 -1
  96. package/dist/collection/collection-manifest.json +1 -1
  97. package/dist/collection/components/button/scss/bq-button.css +1 -1
  98. package/dist/collection/components/drawer/scss/bq-drawer.css +1 -1
  99. package/dist/collection/components/icon/__tests__/bq-icon.e2e.js +18 -12
  100. package/dist/collection/components/icon/__tests__/bq-icon.e2e.js.map +1 -1
  101. package/dist/collection/components/icon/bq-icon.js +4 -6
  102. package/dist/collection/components/icon/bq-icon.js.map +1 -1
  103. package/dist/collection/components/icon/helper/request.js +1 -2
  104. package/dist/collection/components/icon/helper/request.js.map +1 -1
  105. package/dist/collection/components/slider/bq-slider.js +7 -5
  106. package/dist/collection/components/slider/bq-slider.js.map +1 -1
  107. package/dist/collection/components/slider/bq-slider.types.js.map +1 -1
  108. package/dist/collection/components/slider/scss/bq-slider.css +1 -1
  109. package/dist/collection/tools/angular-value-accessor-config.js +2 -2
  110. package/dist/collection/tools/angular-value-accessor-config.js.map +1 -1
  111. package/dist/components/bq-button2.js +1 -1
  112. package/dist/components/bq-button2.js.map +1 -1
  113. package/dist/components/bq-drawer.js +1 -1
  114. package/dist/components/bq-icon2.js +5 -7
  115. package/dist/components/bq-icon2.js.map +1 -1
  116. package/dist/components/bq-slider.js +6 -4
  117. package/dist/components/bq-slider.js.map +1 -1
  118. package/dist/components/index2.js +60 -22
  119. package/dist/components/index2.js.map +1 -1
  120. package/dist/esm/beeq.js +29 -31
  121. package/dist/esm/beeq.js.map +1 -1
  122. package/dist/esm/bq-accordion-group.entry.js +1 -1
  123. package/dist/esm/bq-accordion.entry.js +1 -1
  124. package/dist/esm/bq-alert.entry.js +1 -1
  125. package/dist/esm/bq-avatar.entry.js +1 -1
  126. package/dist/esm/bq-badge.entry.js +1 -1
  127. package/dist/esm/bq-breadcrumb-item.entry.js +1 -1
  128. package/dist/esm/bq-breadcrumb.entry.js +1 -1
  129. package/dist/esm/bq-button.entry.js +2 -2
  130. package/dist/esm/bq-button.entry.js.map +1 -1
  131. package/dist/esm/bq-card.entry.js +1 -1
  132. package/dist/esm/bq-checkbox.entry.js +1 -1
  133. package/dist/esm/bq-dialog.entry.js +1 -1
  134. package/dist/esm/bq-divider.entry.js +1 -1
  135. package/dist/esm/bq-drawer.entry.js +2 -2
  136. package/dist/esm/bq-dropdown_3.entry.js +1 -1
  137. package/dist/esm/bq-empty-state.entry.js +1 -1
  138. package/dist/esm/bq-icon.entry.js +5 -7
  139. package/dist/esm/bq-icon.entry.js.map +1 -1
  140. package/dist/esm/bq-input.entry.js +1 -1
  141. package/dist/esm/bq-notification.entry.js +1 -1
  142. package/dist/esm/bq-option-group.entry.js +1 -1
  143. package/dist/esm/bq-option.entry.js +1 -1
  144. package/dist/esm/bq-panel.entry.js +2 -2
  145. package/dist/esm/bq-progress.entry.js +1 -1
  146. package/dist/esm/bq-radio-group.entry.js +1 -1
  147. package/dist/esm/bq-radio.entry.js +1 -1
  148. package/dist/esm/bq-select.entry.js +1 -1
  149. package/dist/esm/bq-side-menu-item.entry.js +1 -1
  150. package/dist/esm/bq-side-menu.entry.js +1 -1
  151. package/dist/esm/bq-slider.entry.js +7 -5
  152. package/dist/esm/bq-slider.entry.js.map +1 -1
  153. package/dist/esm/bq-spinner.entry.js +1 -1
  154. package/dist/esm/bq-status.entry.js +1 -1
  155. package/dist/esm/bq-step-item.entry.js +1 -1
  156. package/dist/esm/bq-steps.entry.js +1 -1
  157. package/dist/esm/bq-switch.entry.js +1 -1
  158. package/dist/esm/bq-tab-group.entry.js +1 -1
  159. package/dist/esm/bq-tab.entry.js +1 -1
  160. package/dist/esm/bq-textarea.entry.js +1 -1
  161. package/dist/esm/bq-toast.entry.js +1 -1
  162. package/dist/esm/bq-tooltip.entry.js +2 -2
  163. package/dist/esm/{index-506c67d0.js → index-5aabdd11.js} +61 -23
  164. package/dist/esm/index-5aabdd11.js.map +1 -0
  165. package/dist/esm/index-d71ec085.js +1762 -0
  166. package/dist/esm/index-d71ec085.js.map +1 -0
  167. package/dist/esm/loader.js +2 -2
  168. package/dist/hydrate/index.d.ts +1 -1
  169. package/dist/hydrate/index.js +25041 -15795
  170. package/dist/loader/cdn.js +1 -2
  171. package/dist/loader/index.cjs.js +1 -2
  172. package/dist/loader/index.es2017.js +1 -2
  173. package/dist/loader/index.js +1 -2
  174. package/dist/stencil.config.js +0 -3
  175. package/dist/stencil.config.js.map +1 -1
  176. package/dist/types/components/slider/bq-slider.types.d.ts +1 -1
  177. package/dist/types/shared/test-utils/setProperties.d.ts +1 -1
  178. package/dist/types/stencil-public-runtime.d.ts +1 -0
  179. package/package.json +1 -1
  180. package/dist/beeq/p-4b1d6824.entry.js +0 -6
  181. package/dist/beeq/p-4b1d6824.entry.js.map +0 -1
  182. package/dist/beeq/p-704c7a0a.js +0 -7
  183. package/dist/beeq/p-704c7a0a.js.map +0 -1
  184. package/dist/beeq/p-94039fe7.entry.js.map +0 -1
  185. package/dist/beeq/p-a91e6eab.entry.js.map +0 -1
  186. package/dist/beeq/p-c5d2619c.js +0 -6
  187. package/dist/beeq/p-c5d2619c.js.map +0 -1
  188. package/dist/cjs/index-3e03656c.js +0 -2601
  189. package/dist/cjs/index-3e03656c.js.map +0 -1
  190. package/dist/cjs/index-cf0d9d4d.js.map +0 -1
  191. package/dist/esm/index-506c67d0.js.map +0 -1
  192. package/dist/esm/index-8e584dd6.js +0 -2570
  193. package/dist/esm/index-8e584dd6.js.map +0 -1
  194. package/dist/esm/polyfills/core-js.js +0 -11
  195. package/dist/esm/polyfills/dom.js +0 -79
  196. package/dist/esm/polyfills/es5-html-element.js +0 -1
  197. package/dist/esm/polyfills/index.js +0 -34
  198. package/dist/esm/polyfills/system.js +0 -6
  199. /package/dist/beeq/{p-69d93e10.entry.js.map → p-0af526fc.entry.js.map} +0 -0
  200. /package/dist/beeq/{p-c483c17e.entry.js.map → p-0b6e3137.entry.js.map} +0 -0
  201. /package/dist/beeq/{p-a7c6f797.entry.js.map → p-1c789890.entry.js.map} +0 -0
  202. /package/dist/beeq/{p-29717d60.entry.js.map → p-1f370b12.entry.js.map} +0 -0
  203. /package/dist/beeq/{p-b7b80227.entry.js.map → p-250b8476.entry.js.map} +0 -0
  204. /package/dist/beeq/{p-4ea77b47.entry.js.map → p-28a9a23d.entry.js.map} +0 -0
  205. /package/dist/beeq/{p-1dcff407.entry.js.map → p-29f90224.entry.js.map} +0 -0
  206. /package/dist/beeq/{p-cf565f6a.entry.js.map → p-2f7137e0.entry.js.map} +0 -0
  207. /package/dist/beeq/{p-ff6101a7.entry.js.map → p-31472c1f.entry.js.map} +0 -0
  208. /package/dist/beeq/{p-dc08e1c5.entry.js.map → p-32134085.entry.js.map} +0 -0
  209. /package/dist/beeq/{p-a35b19f0.entry.js.map → p-354f52d1.entry.js.map} +0 -0
  210. /package/dist/beeq/{p-b0a999d6.entry.js.map → p-36eb59f9.entry.js.map} +0 -0
  211. /package/dist/beeq/{p-22a2bf4a.entry.js.map → p-3c37a62d.entry.js.map} +0 -0
  212. /package/dist/beeq/{p-69c47479.entry.js.map → p-42c5530c.entry.js.map} +0 -0
  213. /package/dist/beeq/{p-6b12a365.entry.js.map → p-47d89d61.entry.js.map} +0 -0
  214. /package/dist/beeq/{p-15ef27e9.entry.js.map → p-51603d69.entry.js.map} +0 -0
  215. /package/dist/beeq/{p-a15f79c5.entry.js.map → p-6c1ddc44.entry.js.map} +0 -0
  216. /package/dist/beeq/{p-58fdd13f.entry.js.map → p-6d5d2460.entry.js.map} +0 -0
  217. /package/dist/beeq/{p-c9fb7a30.entry.js.map → p-7d3c9c9a.entry.js.map} +0 -0
  218. /package/dist/beeq/{p-126c2d19.entry.js.map → p-81a34a07.entry.js.map} +0 -0
  219. /package/dist/beeq/{p-30db348f.entry.js.map → p-852c54d8.entry.js.map} +0 -0
  220. /package/dist/beeq/{p-adbd57e8.entry.js.map → p-8593ad98.entry.js.map} +0 -0
  221. /package/dist/beeq/{p-aaa76f94.entry.js.map → p-8b57cd5e.entry.js.map} +0 -0
  222. /package/dist/beeq/{p-8cc8ac11.entry.js.map → p-981797b1.entry.js.map} +0 -0
  223. /package/dist/beeq/{p-c69c58b8.entry.js.map → p-a30ba2bd.entry.js.map} +0 -0
  224. /package/dist/beeq/{p-10ed463d.entry.js.map → p-ab632829.entry.js.map} +0 -0
  225. /package/dist/beeq/{p-3de3223c.entry.js.map → p-ada3ca0a.entry.js.map} +0 -0
  226. /package/dist/beeq/{p-c3228970.entry.js.map → p-bb8f8b78.entry.js.map} +0 -0
  227. /package/dist/beeq/{p-3fe9aa19.entry.js.map → p-c14e94e0.entry.js.map} +0 -0
  228. /package/dist/beeq/{p-35dba65d.entry.js.map → p-c893951f.entry.js.map} +0 -0
  229. /package/dist/beeq/{p-167c3774.entry.js.map → p-cbca544b.entry.js.map} +0 -0
  230. /package/dist/beeq/{p-5666c9c1.entry.js.map → p-d11fafe0.entry.js.map} +0 -0
  231. /package/dist/beeq/{p-56a53f77.entry.js.map → p-d58a7c27.entry.js.map} +0 -0
  232. /package/dist/beeq/{p-0595abce.entry.js.map → p-de827971.entry.js.map} +0 -0
  233. /package/dist/beeq/{p-2cc2ca42.entry.js.map → p-e2b64861.entry.js.map} +0 -0
@@ -1,2601 +0,0 @@
1
- /*!
2
- * Built by Endavans
3
- * © https://beeq.design - Apache 2 License.
4
- */
5
- 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- const NAMESPACE = 'beeq';
28
- const Env = /* beeq */ {};
29
-
30
- /**
31
- * Virtual DOM patching algorithm based on Snabbdom by
32
- * Simon Friis Vindum (@paldepind)
33
- * Licensed under the MIT License
34
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
35
- *
36
- * Modified for Stencil's renderer and slot projection
37
- */
38
- let scopeId;
39
- let hostTagName;
40
- let useNativeShadowDom = false;
41
- let isSvgMode = false;
42
- let queuePending = false;
43
- const createTime = (fnName, tagName = '') => {
44
- {
45
- return () => {
46
- return;
47
- };
48
- }
49
- };
50
- const uniqueTime = (key, measureText) => {
51
- {
52
- return () => {
53
- return;
54
- };
55
- }
56
- };
57
- const CONTENT_REF_ID = 'r';
58
- const ORG_LOCATION_ID = 'o';
59
- const SLOT_NODE_ID = 's';
60
- const TEXT_NODE_ID = 't';
61
- const HYDRATE_ID = 's-id';
62
- const HYDRATED_STYLE_ID = 'sty-id';
63
- const HYDRATE_CHILD_ID = 'c-id';
64
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
65
- /**
66
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
67
- *
68
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
69
- * support as of Stencil v4.
70
- */
71
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
72
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
73
- /**
74
- * Default style mode id
75
- */
76
- /**
77
- * Reusable empty obj/array
78
- * Don't add values to these!!
79
- */
80
- const EMPTY_OBJ = {};
81
- /**
82
- * Namespaces
83
- */
84
- const SVG_NS = 'http://www.w3.org/2000/svg';
85
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
86
- const isDef = (v) => v != null;
87
- /**
88
- * Check whether a value is a 'complex type', defined here as an object or a
89
- * function.
90
- *
91
- * @param o the value to check
92
- * @returns whether it's a complex type or not
93
- */
94
- const isComplexType = (o) => {
95
- // https://jsperf.com/typeof-fn-object/5
96
- o = typeof o;
97
- return o === 'object' || o === 'function';
98
- };
99
- /**
100
- * Helper method for querying a `meta` tag that contains a nonce value
101
- * out of a DOM's head.
102
- *
103
- * @param doc The DOM containing the `head` to query against
104
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
105
- * exists or the tag has no content.
106
- */
107
- function queryNonceMetaTagContent(doc) {
108
- var _a, _b, _c;
109
- 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;
110
- }
111
- /**
112
- * Production h() function based on Preact by
113
- * Jason Miller (@developit)
114
- * Licensed under the MIT License
115
- * https://github.com/developit/preact/blob/master/LICENSE
116
- *
117
- * Modified for Stencil's compiler and vdom
118
- */
119
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
120
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
121
- const h = (nodeName, vnodeData, ...children) => {
122
- let child = null;
123
- let key = null;
124
- let simple = false;
125
- let lastSimple = false;
126
- const vNodeChildren = [];
127
- const walk = (c) => {
128
- for (let i = 0; i < c.length; i++) {
129
- child = c[i];
130
- if (Array.isArray(child)) {
131
- walk(child);
132
- }
133
- else if (child != null && typeof child !== 'boolean') {
134
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
135
- child = String(child);
136
- }
137
- if (simple && lastSimple) {
138
- // If the previous child was simple (string), we merge both
139
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
140
- }
141
- else {
142
- // Append a new vNode, if it's text, we create a text vNode
143
- vNodeChildren.push(simple ? newVNode(null, child) : child);
144
- }
145
- lastSimple = simple;
146
- }
147
- }
148
- };
149
- walk(children);
150
- if (vnodeData) {
151
- if (vnodeData.key) {
152
- key = vnodeData.key;
153
- }
154
- // normalize class / className attributes
155
- {
156
- const classData = vnodeData.className || vnodeData.class;
157
- if (classData) {
158
- vnodeData.class =
159
- typeof classData !== 'object'
160
- ? classData
161
- : Object.keys(classData)
162
- .filter((k) => classData[k])
163
- .join(' ');
164
- }
165
- }
166
- }
167
- if (typeof nodeName === 'function') {
168
- // nodeName is a functional component
169
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
170
- }
171
- const vnode = newVNode(nodeName, null);
172
- vnode.$attrs$ = vnodeData;
173
- if (vNodeChildren.length > 0) {
174
- vnode.$children$ = vNodeChildren;
175
- }
176
- {
177
- vnode.$key$ = key;
178
- }
179
- return vnode;
180
- };
181
- /**
182
- * A utility function for creating a virtual DOM node from a tag and some
183
- * possible text content.
184
- *
185
- * @param tag the tag for this element
186
- * @param text possible text content for the node
187
- * @returns a newly-minted virtual DOM node
188
- */
189
- const newVNode = (tag, text) => {
190
- const vnode = {
191
- $flags$: 0,
192
- $tag$: tag,
193
- $text$: text,
194
- $elm$: null,
195
- $children$: null,
196
- };
197
- {
198
- vnode.$attrs$ = null;
199
- }
200
- {
201
- vnode.$key$ = null;
202
- }
203
- return vnode;
204
- };
205
- const Host = {};
206
- /**
207
- * Check whether a given node is a Host node or not
208
- *
209
- * @param node the virtual DOM node to check
210
- * @returns whether it's a Host node or not
211
- */
212
- const isHost = (node) => node && node.$tag$ === Host;
213
- /**
214
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
215
- *
216
- * Note that these functions convert from {@link d.VNode} to
217
- * {@link d.ChildNode} to give functional component developers a friendly
218
- * interface.
219
- */
220
- const vdomFnUtils = {
221
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
222
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
223
- };
224
- /**
225
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
226
- * friendlier public interface (hence, 'convertToPublic').
227
- *
228
- * @param node the virtual DOM node to convert
229
- * @returns a converted child node
230
- */
231
- const convertToPublic = (node) => ({
232
- vattrs: node.$attrs$,
233
- vchildren: node.$children$,
234
- vkey: node.$key$,
235
- vname: node.$name$,
236
- vtag: node.$tag$,
237
- vtext: node.$text$,
238
- });
239
- /**
240
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
241
- * order to use the resulting object in the virtual DOM. The initial object was
242
- * likely created as part of presenting a public API, so converting it back
243
- * involved making it 'private' again (hence, `convertToPrivate`).
244
- *
245
- * @param node the child node to convert
246
- * @returns a converted virtual DOM node
247
- */
248
- const convertToPrivate = (node) => {
249
- if (typeof node.vtag === 'function') {
250
- const vnodeData = Object.assign({}, node.vattrs);
251
- if (node.vkey) {
252
- vnodeData.key = node.vkey;
253
- }
254
- if (node.vname) {
255
- vnodeData.name = node.vname;
256
- }
257
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
258
- }
259
- const vnode = newVNode(node.vtag, node.vtext);
260
- vnode.$attrs$ = node.vattrs;
261
- vnode.$children$ = node.vchildren;
262
- vnode.$key$ = node.vkey;
263
- vnode.$name$ = node.vname;
264
- return vnode;
265
- };
266
- /**
267
- * Entrypoint of the client-side hydration process. Facilitates calls to hydrate the
268
- * document and all its nodes.
269
- *
270
- * This process will also reconstruct the shadow root and slot DOM nodes for components using shadow DOM.
271
- *
272
- * @param hostElm The element to hydrate.
273
- * @param tagName The element's tag name.
274
- * @param hostId The host ID assigned to the element by the server.
275
- * @param hostRef The host reference for the element.
276
- */
277
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
278
- const endHydrate = createTime('hydrateClient', tagName);
279
- const shadowRoot = hostElm.shadowRoot;
280
- const childRenderNodes = [];
281
- const slotNodes = [];
282
- const shadowRootNodes = shadowRoot ? [] : null;
283
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
284
- if (!plt.$orgLocNodes$) {
285
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
286
- }
287
- hostElm[HYDRATE_ID] = hostId;
288
- hostElm.removeAttribute(HYDRATE_ID);
289
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
290
- childRenderNodes.map((c) => {
291
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
292
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
293
- const node = c.$elm$;
294
- // Put the node back in its original location since the native Shadow DOM
295
- // can handle rendering it its correct location now
296
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
297
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
298
- }
299
- if (!shadowRoot) {
300
- node['s-hn'] = tagName;
301
- if (orgLocationNode) {
302
- node['s-ol'] = orgLocationNode;
303
- node['s-ol']['s-nr'] = node;
304
- }
305
- }
306
- plt.$orgLocNodes$.delete(orgLocationId);
307
- });
308
- if (shadowRoot) {
309
- shadowRootNodes.map((shadowRootNode) => {
310
- if (shadowRootNode) {
311
- shadowRoot.appendChild(shadowRootNode);
312
- }
313
- });
314
- }
315
- endHydrate();
316
- };
317
- /**
318
- * Recursively constructs the virtual node tree for a host element and its children.
319
- * The tree is constructed by parsing the annotations set on the nodes by the server.
320
- *
321
- * In addition to constructing the vNode tree, we also track information about the node's
322
- * descendants like which are slots, which should exist in the shadow root, and which
323
- * are nodes that should be rendered as children of the parent node.
324
- *
325
- * @param parentVNode The vNode representing the parent node.
326
- * @param childRenderNodes An array of all child nodes in the parent's node tree.
327
- * @param slotNodes An array of all slot nodes in the parent's node tree.
328
- * @param shadowRootNodes An array all nodes that should be rendered in the shadow root in the parent's node tree.
329
- * @param hostElm The parent element.
330
- * @param node The node to construct the vNode tree for.
331
- * @param hostId The host ID assigned to the element by the server.
332
- */
333
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
334
- let childNodeType;
335
- let childIdSplt;
336
- let childVNode;
337
- let i;
338
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
339
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
340
- if (childNodeType) {
341
- // got the node data from the element's attribute
342
- // `${hostId}.${nodeId}.${depth}.${index}`
343
- childIdSplt = childNodeType.split('.');
344
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
345
- childVNode = {
346
- $flags$: 0,
347
- $hostId$: childIdSplt[0],
348
- $nodeId$: childIdSplt[1],
349
- $depth$: childIdSplt[2],
350
- $index$: childIdSplt[3],
351
- $tag$: node.tagName.toLowerCase(),
352
- $elm$: node,
353
- $attrs$: null,
354
- $children$: null,
355
- $key$: null,
356
- $name$: null,
357
- $text$: null,
358
- };
359
- childRenderNodes.push(childVNode);
360
- node.removeAttribute(HYDRATE_CHILD_ID);
361
- // this is a new child vnode
362
- // so ensure its parent vnode has the vchildren array
363
- if (!parentVNode.$children$) {
364
- parentVNode.$children$ = [];
365
- }
366
- // add our child vnode to a specific index of the vnode's children
367
- parentVNode.$children$[childVNode.$index$] = childVNode;
368
- // this is now the new parent vnode for all the next child checks
369
- parentVNode = childVNode;
370
- if (shadowRootNodes && childVNode.$depth$ === '0') {
371
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
372
- }
373
- }
374
- }
375
- // recursively drill down, end to start so we can remove nodes
376
- for (i = node.childNodes.length - 1; i >= 0; i--) {
377
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
378
- }
379
- if (node.shadowRoot) {
380
- // keep drilling down through the shadow root nodes
381
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
382
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
383
- }
384
- }
385
- }
386
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
387
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
388
- childIdSplt = node.nodeValue.split('.');
389
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
390
- // comment node for either the host id or a 0 host id
391
- childNodeType = childIdSplt[0];
392
- childVNode = {
393
- $flags$: 0,
394
- $hostId$: childIdSplt[1],
395
- $nodeId$: childIdSplt[2],
396
- $depth$: childIdSplt[3],
397
- $index$: childIdSplt[4],
398
- $elm$: node,
399
- $attrs$: null,
400
- $children$: null,
401
- $key$: null,
402
- $name$: null,
403
- $tag$: null,
404
- $text$: null,
405
- };
406
- if (childNodeType === TEXT_NODE_ID) {
407
- childVNode.$elm$ = node.nextSibling;
408
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
409
- childVNode.$text$ = childVNode.$elm$.textContent;
410
- childRenderNodes.push(childVNode);
411
- // remove the text comment since it's no longer needed
412
- node.remove();
413
- if (!parentVNode.$children$) {
414
- parentVNode.$children$ = [];
415
- }
416
- parentVNode.$children$[childVNode.$index$] = childVNode;
417
- if (shadowRootNodes && childVNode.$depth$ === '0') {
418
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
419
- }
420
- }
421
- }
422
- else if (childVNode.$hostId$ === hostId) {
423
- // this comment node is specifically for this host id
424
- if (childNodeType === SLOT_NODE_ID) {
425
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
426
- childVNode.$tag$ = 'slot';
427
- if (childIdSplt[5]) {
428
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
429
- }
430
- else {
431
- node['s-sn'] = '';
432
- }
433
- node['s-sr'] = true;
434
- if (shadowRootNodes) {
435
- // browser support shadowRoot and this is a shadow dom component
436
- // create an actual slot element
437
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
438
- if (childVNode.$name$) {
439
- // add the slot name attribute
440
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
441
- }
442
- // insert the new slot element before the slot comment
443
- node.parentNode.insertBefore(childVNode.$elm$, node);
444
- // remove the slot comment since it's not needed for shadow
445
- node.remove();
446
- if (childVNode.$depth$ === '0') {
447
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
448
- }
449
- }
450
- slotNodes.push(childVNode);
451
- if (!parentVNode.$children$) {
452
- parentVNode.$children$ = [];
453
- }
454
- parentVNode.$children$[childVNode.$index$] = childVNode;
455
- }
456
- else if (childNodeType === CONTENT_REF_ID) {
457
- // `${CONTENT_REF_ID}.${hostId}`;
458
- if (shadowRootNodes) {
459
- // remove the content ref comment since it's not needed for shadow
460
- node.remove();
461
- }
462
- }
463
- }
464
- }
465
- }
466
- else if (parentVNode && parentVNode.$tag$ === 'style') {
467
- const vnode = newVNode(null, node.textContent);
468
- vnode.$elm$ = node;
469
- vnode.$index$ = '0';
470
- parentVNode.$children$ = [vnode];
471
- }
472
- };
473
- /**
474
- * Recursively locate any comments representing an original location for a node in a node's
475
- * children or shadowRoot children.
476
- *
477
- * @param node The node to search.
478
- * @param orgLocNodes A map of the original location annotation and the current node being searched.
479
- */
480
- const initializeDocumentHydrate = (node, orgLocNodes) => {
481
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
482
- let i = 0;
483
- for (; i < node.childNodes.length; i++) {
484
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
485
- }
486
- if (node.shadowRoot) {
487
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
488
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
489
- }
490
- }
491
- }
492
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
493
- const childIdSplt = node.nodeValue.split('.');
494
- if (childIdSplt[0] === ORG_LOCATION_ID) {
495
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
496
- node.nodeValue = '';
497
- // useful to know if the original location is
498
- // the root light-dom of a shadow dom component
499
- node['s-en'] = childIdSplt[3];
500
- }
501
- }
502
- };
503
- /**
504
- * Parse a new property value for a given property type.
505
- *
506
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
507
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
508
- * 1. `any`, the type given to `propValue` in the function signature
509
- * 2. the type stored from `propType`.
510
- *
511
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
512
- *
513
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
514
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
515
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
516
- * ```tsx
517
- * <my-cmp prop-val={0}></my-cmp>
518
- * ```
519
- *
520
- * HTML prop values on the other hand, will always a string
521
- *
522
- * @param propValue the new value to coerce to some type
523
- * @param propType the type of the prop, expressed as a binary number
524
- * @returns the parsed/coerced value
525
- */
526
- const parsePropertyValue = (propValue, propType) => {
527
- // ensure this value is of the correct prop type
528
- if (propValue != null && !isComplexType(propValue)) {
529
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
530
- // per the HTML spec, any string value means it is a boolean true value
531
- // but we'll cheat here and say that the string "false" is the boolean false
532
- return propValue === 'false' ? false : propValue === '' || !!propValue;
533
- }
534
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
535
- // force it to be a number
536
- return parseFloat(propValue);
537
- }
538
- if (propType & 1 /* MEMBER_FLAGS.String */) {
539
- // could have been passed as a number or boolean
540
- // but we still want it as a string
541
- return String(propValue);
542
- }
543
- // redundant return here for better minification
544
- return propValue;
545
- }
546
- // not sure exactly what type we want
547
- // so no need to change to a different type
548
- return propValue;
549
- };
550
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
551
- const createEvent = (ref, name, flags) => {
552
- const elm = getElement(ref);
553
- return {
554
- emit: (detail) => {
555
- return emitEvent(elm, name, {
556
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
557
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
558
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
559
- detail,
560
- });
561
- },
562
- };
563
- };
564
- /**
565
- * Helper function to create & dispatch a custom Event on a provided target
566
- * @param elm the target of the Event
567
- * @param name the name to give the custom Event
568
- * @param opts options for configuring a custom Event
569
- * @returns the custom Event
570
- */
571
- const emitEvent = (elm, name, opts) => {
572
- const ev = plt.ce(name, opts);
573
- elm.dispatchEvent(ev);
574
- return ev;
575
- };
576
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
577
- const registerStyle = (scopeId, cssText, allowCS) => {
578
- let style = styles.get(scopeId);
579
- if (supportsConstructableStylesheets && allowCS) {
580
- style = (style || new CSSStyleSheet());
581
- if (typeof style === 'string') {
582
- style = cssText;
583
- }
584
- else {
585
- style.replaceSync(cssText);
586
- }
587
- }
588
- else {
589
- style = cssText;
590
- }
591
- styles.set(scopeId, style);
592
- };
593
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
594
- var _a;
595
- const scopeId = getScopeId(cmpMeta);
596
- const style = styles.get(scopeId);
597
- // if an element is NOT connected then getRootNode() will return the wrong root node
598
- // so the fallback is to always use the document for the root node in those cases
599
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
600
- if (style) {
601
- if (typeof style === 'string') {
602
- styleContainerNode = styleContainerNode.head || styleContainerNode;
603
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
604
- let styleElm;
605
- if (!appliedStyles) {
606
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
607
- }
608
- if (!appliedStyles.has(scopeId)) {
609
- if (styleContainerNode.host &&
610
- (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
611
- // This is only happening on native shadow-dom, do not needs CSS var shim
612
- styleElm.innerHTML = style;
613
- }
614
- else {
615
- styleElm = doc.createElement('style');
616
- styleElm.innerHTML = style;
617
- // Apply CSP nonce to the style tag if it exists
618
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
619
- if (nonce != null) {
620
- styleElm.setAttribute('nonce', nonce);
621
- }
622
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
623
- }
624
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
625
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
626
- styleElm.innerHTML += SLOT_FB_CSS;
627
- }
628
- if (appliedStyles) {
629
- appliedStyles.add(scopeId);
630
- }
631
- }
632
- }
633
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
634
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
635
- }
636
- }
637
- return scopeId;
638
- };
639
- const attachStyles = (hostRef) => {
640
- const cmpMeta = hostRef.$cmpMeta$;
641
- const elm = hostRef.$hostElement$;
642
- const flags = cmpMeta.$flags$;
643
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
644
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
645
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
646
- // only required when we're NOT using native shadow dom (slot)
647
- // or this browser doesn't support native shadow dom
648
- // and this host element was NOT created with SSR
649
- // let's pick out the inner content for slot projection
650
- // create a node to represent where the original
651
- // content was first placed, which is useful later on
652
- // DOM WRITE!!
653
- elm['s-sc'] = scopeId;
654
- elm.classList.add(scopeId + '-h');
655
- }
656
- endAttachStyles();
657
- };
658
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
659
- const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
660
- /**
661
- * Production setAccessor() function based on Preact by
662
- * Jason Miller (@developit)
663
- * Licensed under the MIT License
664
- * https://github.com/developit/preact/blob/master/LICENSE
665
- *
666
- * Modified for Stencil's compiler and vdom
667
- */
668
- /**
669
- * When running a VDom render set properties present on a VDom node onto the
670
- * corresponding HTML element.
671
- *
672
- * Note that this function has special functionality for the `class`,
673
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
674
- * `onClick`, etc). All others are just passed through as-is.
675
- *
676
- * @param elm the HTMLElement onto which attributes should be set
677
- * @param memberName the name of the attribute to set
678
- * @param oldValue the old value for the attribute
679
- * @param newValue the new value for the attribute
680
- * @param isSvg whether we're in an svg context or not
681
- * @param flags bitflags for Vdom variables
682
- */
683
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
684
- if (oldValue !== newValue) {
685
- let isProp = isMemberInElement(elm, memberName);
686
- let ln = memberName.toLowerCase();
687
- if (memberName === 'class') {
688
- const classList = elm.classList;
689
- const oldClasses = parseClassList(oldValue);
690
- const newClasses = parseClassList(newValue);
691
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
692
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
693
- }
694
- else if (memberName === 'style') {
695
- // update style attribute, css properties and values
696
- {
697
- for (const prop in oldValue) {
698
- if (!newValue || newValue[prop] == null) {
699
- if (prop.includes('-')) {
700
- elm.style.removeProperty(prop);
701
- }
702
- else {
703
- elm.style[prop] = '';
704
- }
705
- }
706
- }
707
- }
708
- for (const prop in newValue) {
709
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
710
- if (prop.includes('-')) {
711
- elm.style.setProperty(prop, newValue[prop]);
712
- }
713
- else {
714
- elm.style[prop] = newValue[prop];
715
- }
716
- }
717
- }
718
- }
719
- else if (memberName === 'key')
720
- ;
721
- else if (memberName === 'ref') {
722
- // minifier will clean this up
723
- if (newValue) {
724
- newValue(elm);
725
- }
726
- }
727
- else if ((!isProp ) &&
728
- memberName[0] === 'o' &&
729
- memberName[1] === 'n') {
730
- // Event Handlers
731
- // so if the member name starts with "on" and the 3rd characters is
732
- // a capital letter, and it's not already a member on the element,
733
- // then we're assuming it's an event listener
734
- if (memberName[2] === '-') {
735
- // on- prefixed events
736
- // allows to be explicit about the dom event to listen without any magic
737
- // under the hood:
738
- // <my-cmp on-click> // listens for "click"
739
- // <my-cmp on-Click> // listens for "Click"
740
- // <my-cmp on-ionChange> // listens for "ionChange"
741
- // <my-cmp on-EVENTS> // listens for "EVENTS"
742
- memberName = memberName.slice(3);
743
- }
744
- else if (isMemberInElement(win, ln)) {
745
- // standard event
746
- // the JSX attribute could have been "onMouseOver" and the
747
- // member name "onmouseover" is on the window's prototype
748
- // so let's add the listener "mouseover", which is all lowercased
749
- memberName = ln.slice(2);
750
- }
751
- else {
752
- // custom event
753
- // the JSX attribute could have been "onMyCustomEvent"
754
- // so let's trim off the "on" prefix and lowercase the first character
755
- // and add the listener "myCustomEvent"
756
- // except for the first character, we keep the event name case
757
- memberName = ln[2] + memberName.slice(3);
758
- }
759
- if (oldValue || newValue) {
760
- // Need to account for "capture" events.
761
- // If the event name ends with "Capture", we'll update the name to remove
762
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
763
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
764
- // Make sure we only replace the last instance of "Capture"
765
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
766
- if (oldValue) {
767
- plt.rel(elm, memberName, oldValue, capture);
768
- }
769
- if (newValue) {
770
- plt.ael(elm, memberName, newValue, capture);
771
- }
772
- }
773
- }
774
- else {
775
- // Set property if it exists and it's not a SVG
776
- const isComplex = isComplexType(newValue);
777
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
778
- try {
779
- if (!elm.tagName.includes('-')) {
780
- const n = newValue == null ? '' : newValue;
781
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
782
- if (memberName === 'list') {
783
- isProp = false;
784
- }
785
- else if (oldValue == null || elm[memberName] != n) {
786
- elm[memberName] = n;
787
- }
788
- }
789
- else {
790
- elm[memberName] = newValue;
791
- }
792
- }
793
- catch (e) {
794
- /**
795
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
796
- */
797
- }
798
- }
799
- /**
800
- * Need to manually update attribute if:
801
- * - memberName is not an attribute
802
- * - if we are rendering the host element in order to reflect attribute
803
- * - if it's a SVG, since properties might not work in <svg>
804
- * - if the newValue is null/undefined or 'false'.
805
- */
806
- let xlink = false;
807
- {
808
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
809
- memberName = ln;
810
- xlink = true;
811
- }
812
- }
813
- if (newValue == null || newValue === false) {
814
- if (newValue !== false || elm.getAttribute(memberName) === '') {
815
- if (xlink) {
816
- elm.removeAttributeNS(XLINK_NS, memberName);
817
- }
818
- else {
819
- elm.removeAttribute(memberName);
820
- }
821
- }
822
- }
823
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
824
- newValue = newValue === true ? '' : newValue;
825
- if (xlink) {
826
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
827
- }
828
- else {
829
- elm.setAttribute(memberName, newValue);
830
- }
831
- }
832
- }
833
- }
834
- };
835
- const parseClassListRegex = /\s/;
836
- /**
837
- * Parsed a string of classnames into an array
838
- * @param value className string, e.g. "foo bar baz"
839
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
840
- */
841
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
842
- const CAPTURE_EVENT_SUFFIX = 'Capture';
843
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
844
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
845
- // if the element passed in is a shadow root, which is a document fragment
846
- // then we want to be adding attrs/props to the shadow root's "host" element
847
- // if it's not a shadow root, then we add attrs/props to the same element
848
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
849
- ? newVnode.$elm$.host
850
- : newVnode.$elm$;
851
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
852
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
853
- {
854
- // remove attributes no longer present on the vnode by setting them to undefined
855
- for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
856
- if (!(memberName in newVnodeAttrs)) {
857
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
858
- }
859
- }
860
- }
861
- // add new & update changed attributes
862
- for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
863
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
864
- }
865
- };
866
- /**
867
- * Sort a list of attribute names to ensure that all the attribute names which
868
- * are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
869
- * attributes.
870
- *
871
- * **Note**: if the supplied attributes do not include `'ref'` then the same
872
- * (by reference) array will be returned without modification.
873
- *
874
- * @param attrNames attribute names to sort
875
- * @returns a list of attribute names, sorted if they include `"ref"`
876
- */
877
- function sortedAttrNames(attrNames) {
878
- return attrNames.includes('ref')
879
- ? // we need to sort these to ensure that `'ref'` is the last attr
880
- [...attrNames.filter((attr) => attr !== 'ref'), 'ref']
881
- : // no need to sort, return the original array
882
- attrNames;
883
- }
884
- /**
885
- * Create a DOM Node corresponding to one of the children of a given VNode.
886
- *
887
- * @param oldParentVNode the parent VNode from the previous render
888
- * @param newParentVNode the parent VNode from the current render
889
- * @param childIndex the index of the VNode, in the _new_ parent node's
890
- * children, for which we will create a new DOM node
891
- * @param parentElm the parent DOM node which our new node will be a child of
892
- * @returns the newly created node
893
- */
894
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
895
- // tslint:disable-next-line: prefer-const
896
- const newVNode = newParentVNode.$children$[childIndex];
897
- let i = 0;
898
- let elm;
899
- let childNode;
900
- if (newVNode.$text$ !== null) {
901
- // create text node
902
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
903
- }
904
- else {
905
- if (!isSvgMode) {
906
- isSvgMode = newVNode.$tag$ === 'svg';
907
- }
908
- // create element
909
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
910
- );
911
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
912
- isSvgMode = false;
913
- }
914
- // add css classes, attrs, props, listeners, etc.
915
- {
916
- updateElement(null, newVNode, isSvgMode);
917
- }
918
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
919
- // if there is a scopeId and this is the initial render
920
- // then let's add the scopeId as a css class
921
- elm.classList.add((elm['s-si'] = scopeId));
922
- }
923
- if (newVNode.$children$) {
924
- for (i = 0; i < newVNode.$children$.length; ++i) {
925
- // create the node
926
- childNode = createElm(oldParentVNode, newVNode, i);
927
- // return node could have been null
928
- if (childNode) {
929
- // append our new node
930
- elm.appendChild(childNode);
931
- }
932
- }
933
- }
934
- {
935
- if (newVNode.$tag$ === 'svg') {
936
- // Only reset the SVG context when we're exiting <svg> element
937
- isSvgMode = false;
938
- }
939
- else if (elm.tagName === 'foreignObject') {
940
- // Reenter SVG context when we're exiting <foreignObject> element
941
- isSvgMode = true;
942
- }
943
- }
944
- }
945
- // This needs to always happen so we can hide nodes that are projected
946
- // to another component but don't end up in a slot
947
- elm['s-hn'] = hostTagName;
948
- return elm;
949
- };
950
- /**
951
- * Relocates all child nodes of an element that were a part of a previous slot relocation
952
- * to the root of the Stencil component currently being rendered. This happens when a parent
953
- * element of a slot reference node dynamically changes and triggers a re-render. We cannot use
954
- * `putBackInOriginalLocation()` because that may relocate nodes to elements that will not be re-rendered
955
- * and so they will not be relocated again.
956
- *
957
- * @param parentElm The element potentially containing relocated nodes.
958
- */
959
- const relocateToHostRoot = (parentElm) => {
960
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
961
- const host = parentElm.closest(hostTagName.toLowerCase());
962
- if (host != null) {
963
- const contentRefNode = Array.from(host.childNodes).find((ref) => ref['s-cr']);
964
- const childNodeArray = Array.from(parentElm.childNodes);
965
- // If we have a content ref, we need to invert the order of the nodes we're relocating
966
- // to preserve the correct order of elements in the DOM on future relocations
967
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
968
- // Only relocate nodes that were slotted in
969
- if (childNode['s-sh'] != null) {
970
- host.insertBefore(childNode, contentRefNode !== null && contentRefNode !== void 0 ? contentRefNode : null);
971
- // Reset so we can correctly move the node around again.
972
- childNode['s-sh'] = undefined;
973
- }
974
- }
975
- }
976
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
977
- };
978
- /**
979
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
980
- * add them to the DOM in the appropriate place.
981
- *
982
- * @param parentElm the DOM node which should be used as a parent for the new
983
- * DOM nodes
984
- * @param before a child of the `parentElm` which the new children should be
985
- * inserted before (optional)
986
- * @param parentVNode the parent virtual DOM node
987
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
988
- * @param startIdx the index in the child virtual DOM nodes at which to start
989
- * creating DOM nodes (inclusive)
990
- * @param endIdx the index in the child virtual DOM nodes at which to stop
991
- * creating DOM nodes (inclusive)
992
- */
993
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
994
- let containerElm = (parentElm);
995
- let childNode;
996
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
997
- containerElm = containerElm.shadowRoot;
998
- }
999
- for (; startIdx <= endIdx; ++startIdx) {
1000
- if (vnodes[startIdx]) {
1001
- childNode = createElm(null, parentVNode, startIdx);
1002
- if (childNode) {
1003
- vnodes[startIdx].$elm$ = childNode;
1004
- containerElm.insertBefore(childNode, before);
1005
- }
1006
- }
1007
- }
1008
- };
1009
- /**
1010
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1011
- * This can be used to, for instance, clean up after a list of children which
1012
- * should no longer be shown.
1013
- *
1014
- * This function also handles some of Stencil's slot relocation logic.
1015
- *
1016
- * @param vnodes a list of virtual DOM nodes to remove
1017
- * @param startIdx the index at which to start removing nodes (inclusive)
1018
- * @param endIdx the index at which to stop removing nodes (inclusive)
1019
- */
1020
- const removeVnodes = (vnodes, startIdx, endIdx) => {
1021
- for (let index = startIdx; index <= endIdx; ++index) {
1022
- const vnode = vnodes[index];
1023
- if (vnode) {
1024
- const elm = vnode.$elm$;
1025
- nullifyVNodeRefs(vnode);
1026
- if (elm) {
1027
- // remove the vnode's element from the dom
1028
- elm.remove();
1029
- }
1030
- }
1031
- }
1032
- };
1033
- /**
1034
- * Reconcile the children of a new VNode with the children of an old VNode by
1035
- * traversing the two collections of children, identifying nodes that are
1036
- * conserved or changed, calling out to `patch` to make any necessary
1037
- * updates to the DOM, and rearranging DOM nodes as needed.
1038
- *
1039
- * The algorithm for reconciling children works by analyzing two 'windows' onto
1040
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1041
- * 'windows' by storing start and end indices and references to the
1042
- * corresponding array entries. Initially the two 'windows' are basically equal
1043
- * to the entire array, but we progressively narrow the windows until there are
1044
- * no children left to update by doing the following:
1045
- *
1046
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1047
- * that if we have an initial array like the following we'll end up dealing
1048
- * only with a window bounded by the highlighted elements:
1049
- *
1050
- * [null, null, VNode1 , ... , VNode2, null, null]
1051
- * ^^^^^^ ^^^^^^
1052
- *
1053
- * 2. Check to see if the elements at the head and tail positions are equal
1054
- * across the windows. This will basically detect elements which haven't
1055
- * been added, removed, or changed position, i.e. if you had the following
1056
- * VNode elements (represented as HTML):
1057
- *
1058
- * oldVNode: `<div><p><span>HEY</span></p></div>`
1059
- * newVNode: `<div><p><span>THERE</span></p></div>`
1060
- *
1061
- * Then when comparing the children of the `<div>` tag we check the equality
1062
- * of the VNodes corresponding to the `<p>` tags and, since they are the
1063
- * same tag in the same position, we'd be able to avoid completely
1064
- * re-rendering the subtree under them with a new DOM element and would just
1065
- * call out to `patch` to handle reconciling their children and so on.
1066
- *
1067
- * 3. Check, for both windows, to see if the element at the beginning of the
1068
- * window corresponds to the element at the end of the other window. This is
1069
- * a heuristic which will let us identify _some_ situations in which
1070
- * elements have changed position, for instance it _should_ detect that the
1071
- * children nodes themselves have not changed but merely moved in the
1072
- * following example:
1073
- *
1074
- * oldVNode: `<div><element-one /><element-two /></div>`
1075
- * newVNode: `<div><element-two /><element-one /></div>`
1076
- *
1077
- * If we find cases like this then we also need to move the concrete DOM
1078
- * elements corresponding to the moved children to write the re-order to the
1079
- * DOM.
1080
- *
1081
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1082
- * nodes in the old children which have the same key as the first element in
1083
- * our window on the new children. If we find such a node we handle calling
1084
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1085
- * what we find.
1086
- *
1087
- * Finally, once we've narrowed our 'windows' to the point that either of them
1088
- * collapse (i.e. they have length 0) we then handle any remaining VNode
1089
- * insertion or deletion that needs to happen to get a DOM state that correctly
1090
- * reflects the new child VNodes. If, for instance, after our window on the old
1091
- * children has collapsed we still have more nodes on the new children that
1092
- * we haven't dealt with yet then we need to add them, or if the new children
1093
- * collapse but we still have unhandled _old_ children then we need to make
1094
- * sure the corresponding DOM nodes are removed.
1095
- *
1096
- * @param parentElm the node into which the parent VNode is rendered
1097
- * @param oldCh the old children of the parent node
1098
- * @param newVNode the new VNode which will replace the parent
1099
- * @param newCh the new children of the parent node
1100
- * @param isInitialRender whether or not this is the first render of the vdom
1101
- */
1102
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
1103
- let oldStartIdx = 0;
1104
- let newStartIdx = 0;
1105
- let idxInOld = 0;
1106
- let i = 0;
1107
- let oldEndIdx = oldCh.length - 1;
1108
- let oldStartVnode = oldCh[0];
1109
- let oldEndVnode = oldCh[oldEndIdx];
1110
- let newEndIdx = newCh.length - 1;
1111
- let newStartVnode = newCh[0];
1112
- let newEndVnode = newCh[newEndIdx];
1113
- let node;
1114
- let elmToMove;
1115
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1116
- if (oldStartVnode == null) {
1117
- // VNode might have been moved left
1118
- oldStartVnode = oldCh[++oldStartIdx];
1119
- }
1120
- else if (oldEndVnode == null) {
1121
- oldEndVnode = oldCh[--oldEndIdx];
1122
- }
1123
- else if (newStartVnode == null) {
1124
- newStartVnode = newCh[++newStartIdx];
1125
- }
1126
- else if (newEndVnode == null) {
1127
- newEndVnode = newCh[--newEndIdx];
1128
- }
1129
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1130
- // if the start nodes are the same then we should patch the new VNode
1131
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1132
- // indices to reflect that. We don't need to move any DOM Nodes around
1133
- // since things are matched up in order.
1134
- patch(oldStartVnode, newStartVnode, isInitialRender);
1135
- oldStartVnode = oldCh[++oldStartIdx];
1136
- newStartVnode = newCh[++newStartIdx];
1137
- }
1138
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1139
- // likewise, if the end nodes are the same we patch new onto old and
1140
- // decrement our end indices, and also likewise in this case we don't
1141
- // need to move any DOM Nodes.
1142
- patch(oldEndVnode, newEndVnode, isInitialRender);
1143
- oldEndVnode = oldCh[--oldEndIdx];
1144
- newEndVnode = newCh[--newEndIdx];
1145
- }
1146
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1147
- patch(oldStartVnode, newEndVnode, isInitialRender);
1148
- // We need to move the element for `oldStartVnode` into a position which
1149
- // will be appropriate for `newEndVnode`. For this we can use
1150
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1151
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1152
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1153
- //
1154
- // <old-start-node />
1155
- // <some-intervening-node />
1156
- // <old-end-node />
1157
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1158
- // <next-sibling />
1159
- //
1160
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1161
- // the node for `oldStartVnode` at the end of the children of
1162
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1163
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
1164
- // append it to the children of the parent element.
1165
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1166
- oldStartVnode = oldCh[++oldStartIdx];
1167
- newEndVnode = newCh[--newEndIdx];
1168
- }
1169
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1170
- patch(oldEndVnode, newStartVnode, isInitialRender);
1171
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
1172
- // the same node, so since we're here we know that they are not. Thus we
1173
- // can move the element for `oldEndVnode` _before_ the element for
1174
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1175
- // future.
1176
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1177
- oldEndVnode = oldCh[--oldEndIdx];
1178
- newStartVnode = newCh[++newStartIdx];
1179
- }
1180
- else {
1181
- // Here we do some checks to match up old and new nodes based on the
1182
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1183
- // in the JSX for a DOM element in the implementation of a Stencil
1184
- // component.
1185
- //
1186
- // First we check to see if there are any nodes in the array of old
1187
- // children which have the same key as the first node in the new
1188
- // children.
1189
- idxInOld = -1;
1190
- {
1191
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1192
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1193
- idxInOld = i;
1194
- break;
1195
- }
1196
- }
1197
- }
1198
- if (idxInOld >= 0) {
1199
- // We found a node in the old children which matches up with the first
1200
- // node in the new children! So let's deal with that
1201
- elmToMove = oldCh[idxInOld];
1202
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1203
- // the tag doesn't match so we'll need a new DOM element
1204
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
1205
- }
1206
- else {
1207
- patch(elmToMove, newStartVnode, isInitialRender);
1208
- // invalidate the matching old node so that we won't try to update it
1209
- // again later on
1210
- oldCh[idxInOld] = undefined;
1211
- node = elmToMove.$elm$;
1212
- }
1213
- newStartVnode = newCh[++newStartIdx];
1214
- }
1215
- else {
1216
- // We either didn't find an element in the old children that matches
1217
- // the key of the first new child OR the build is not using `key`
1218
- // attributes at all. In either case we need to create a new element
1219
- // for the new node.
1220
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1221
- newStartVnode = newCh[++newStartIdx];
1222
- }
1223
- if (node) {
1224
- // if we created a new node then handle inserting it to the DOM
1225
- {
1226
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1227
- }
1228
- }
1229
- }
1230
- }
1231
- if (oldStartIdx > oldEndIdx) {
1232
- // we have some more new nodes to add which don't match up with old nodes
1233
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1234
- }
1235
- else if (newStartIdx > newEndIdx) {
1236
- // there are nodes in the `oldCh` array which no longer correspond to nodes
1237
- // in the new array, so lets remove them (which entails cleaning up the
1238
- // relevant DOM nodes)
1239
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1240
- }
1241
- };
1242
- /**
1243
- * Compare two VNodes to determine if they are the same
1244
- *
1245
- * **NB**: This function is an equality _heuristic_ based on the available
1246
- * information set on the two VNodes and can be misleading under certain
1247
- * circumstances. In particular, if the two nodes do not have `key` attrs
1248
- * (available under `$key$` on VNodes) then the function falls back on merely
1249
- * checking that they have the same tag.
1250
- *
1251
- * So, in other words, if `key` attrs are not set on VNodes which may be
1252
- * changing order within a `children` array or something along those lines then
1253
- * we could obtain a false negative and then have to do needless re-rendering
1254
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1255
- *
1256
- * @param leftVNode the first VNode to check
1257
- * @param rightVNode the second VNode to check
1258
- * @param isInitialRender whether or not this is the first render of the vdom
1259
- * @returns whether they're equal or not
1260
- */
1261
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1262
- // compare if two vnode to see if they're "technically" the same
1263
- // need to have the same element tag, and same key to be the same
1264
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1265
- // this will be set if JSX tags in the build have `key` attrs set on them
1266
- // we only want to check this if we're not on the first render since on
1267
- // first render `leftVNode.$key$` will always be `null`, so we can be led
1268
- // astray and, for instance, accidentally delete a DOM node that we want to
1269
- // keep around.
1270
- if (!isInitialRender) {
1271
- return leftVNode.$key$ === rightVNode.$key$;
1272
- }
1273
- return true;
1274
- }
1275
- return false;
1276
- };
1277
- /**
1278
- * Handle reconciling an outdated VNode with a new one which corresponds to
1279
- * it. This function handles flushing updates to the DOM and reconciling the
1280
- * children of the two nodes (if any).
1281
- *
1282
- * @param oldVNode an old VNode whose DOM element and children we want to update
1283
- * @param newVNode a new VNode representing an updated version of the old one
1284
- * @param isInitialRender whether or not this is the first render of the vdom
1285
- */
1286
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
1287
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
1288
- const oldChildren = oldVNode.$children$;
1289
- const newChildren = newVNode.$children$;
1290
- const tag = newVNode.$tag$;
1291
- const text = newVNode.$text$;
1292
- if (text === null) {
1293
- {
1294
- // test if we're rendering an svg element, or still rendering nodes inside of one
1295
- // only add this to the when the compiler sees we're using an svg somewhere
1296
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1297
- }
1298
- {
1299
- if (tag === 'slot' && !useNativeShadowDom) {
1300
- if (oldVNode.$name$ !== newVNode.$name$) {
1301
- newVNode.$elm$['s-sn'] = newVNode.$name$ || '';
1302
- relocateToHostRoot(newVNode.$elm$.parentElement);
1303
- }
1304
- }
1305
- else {
1306
- // either this is the first render of an element OR it's an update
1307
- // AND we already know it's possible it could have changed
1308
- // this updates the element's css classes, attrs, props, listeners, etc.
1309
- updateElement(oldVNode, newVNode, isSvgMode);
1310
- }
1311
- }
1312
- if (oldChildren !== null && newChildren !== null) {
1313
- // looks like there's child vnodes for both the old and new vnodes
1314
- // so we need to call `updateChildren` to reconcile them
1315
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1316
- }
1317
- else if (newChildren !== null) {
1318
- // no old child vnodes, but there are new child vnodes to add
1319
- if (oldVNode.$text$ !== null) {
1320
- // the old vnode was text, so be sure to clear it out
1321
- elm.textContent = '';
1322
- }
1323
- // add the new vnode children
1324
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1325
- }
1326
- else if (oldChildren !== null) {
1327
- // no new child vnodes, but there are old child vnodes to remove
1328
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1329
- }
1330
- if (isSvgMode && tag === 'svg') {
1331
- isSvgMode = false;
1332
- }
1333
- }
1334
- else if (oldVNode.$text$ !== text) {
1335
- // update the text content for the text only vnode
1336
- // and also only if the text is different than before
1337
- elm.data = text;
1338
- }
1339
- };
1340
- /**
1341
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1342
- * them with `null`. This signals that the DOM element corresponding to the VDom
1343
- * node has been removed from the DOM.
1344
- *
1345
- * @param vNode a virtual DOM node
1346
- */
1347
- const nullifyVNodeRefs = (vNode) => {
1348
- {
1349
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1350
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1351
- }
1352
- };
1353
- /**
1354
- * The main entry point for Stencil's virtual DOM-based rendering engine
1355
- *
1356
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1357
- * function will handle creating a virtual DOM tree with a single root, patching
1358
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1359
- * relocation, and reflecting attributes.
1360
- *
1361
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1362
- * the DOM node into which it should be rendered.
1363
- * @param renderFnResults the virtual DOM nodes to be rendered
1364
- * @param isInitialLoad whether or not this is the first call after page load
1365
- */
1366
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1367
- var _e;
1368
- const hostElm = hostRef.$hostElement$;
1369
- const cmpMeta = hostRef.$cmpMeta$;
1370
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1371
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1372
- // we need to call `h` again to wrap the children of our component in a
1373
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1374
- // implicitly that the top-level vdom node is 1) an only child and 2)
1375
- // contains attrs that need to be set on the host element.
1376
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1377
- hostTagName = hostElm.tagName;
1378
- if (cmpMeta.$attrsToReflect$) {
1379
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1380
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1381
- }
1382
- // On the first render and *only* on the first render we want to check for
1383
- // any attributes set on the host element which are also set on the vdom
1384
- // node. If we find them, we override the value on the VDom node attrs with
1385
- // the value from the host element, which allows developers building apps
1386
- // with Stencil components to override e.g. the `role` attribute on a
1387
- // component even if it's already set on the `Host`.
1388
- if (isInitialLoad && rootVnode.$attrs$) {
1389
- for (const key of Object.keys(rootVnode.$attrs$)) {
1390
- // We have a special implementation in `setAccessor` for `style` and
1391
- // `class` which reconciles values coming from the VDom with values
1392
- // already present on the DOM element, so we don't want to override those
1393
- // attributes on the VDom tree with values from the host element if they
1394
- // are present.
1395
- //
1396
- // Likewise, `ref` and `key` are special internal values for the Stencil
1397
- // runtime and we don't want to override those either.
1398
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1399
- rootVnode.$attrs$[key] = hostElm[key];
1400
- }
1401
- }
1402
- }
1403
- rootVnode.$tag$ = null;
1404
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1405
- hostRef.$vnode$ = rootVnode;
1406
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1407
- {
1408
- scopeId = hostElm['s-sc'];
1409
- }
1410
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1411
- // synchronous patch
1412
- patch(oldVNode, rootVnode, isInitialLoad);
1413
- // Hide any elements that were projected through, but don't have a slot to go to.
1414
- // Only an issue if there were no "slots" rendered. Otherwise, nodes are hidden correctly.
1415
- // This _only_ happens for `scoped` components!
1416
- if (cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1417
- for (const childNode of rootVnode.$elm$.childNodes) {
1418
- if (childNode['s-hn'] !== hostTagName && !childNode['s-sh']) {
1419
- // Store the initial value of `hidden` so we can reset it later when
1420
- // moving nodes around.
1421
- if (isInitialLoad && childNode['s-ih'] == null) {
1422
- childNode['s-ih'] = (_e = childNode.hidden) !== null && _e !== void 0 ? _e : false;
1423
- }
1424
- childNode.hidden = true;
1425
- }
1426
- }
1427
- }
1428
- };
1429
- const attachToAncestor = (hostRef, ancestorComponent) => {
1430
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1431
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1432
- }
1433
- };
1434
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1435
- {
1436
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1437
- }
1438
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1439
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1440
- return;
1441
- }
1442
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1443
- // there is no ancestor component or the ancestor component
1444
- // has already fired off its lifecycle update then
1445
- // fire off the initial update
1446
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1447
- return writeTask(dispatch) ;
1448
- };
1449
- /**
1450
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1451
- * component lifecycle methods like `componentWillLoad` as well as
1452
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1453
- *
1454
- * @param hostRef a reference to a host DOM node
1455
- * @param isInitialLoad whether we're on the initial load or not
1456
- * @returns an empty Promise which is used to enqueue a series of operations for
1457
- * the component
1458
- */
1459
- const dispatchHooks = (hostRef, isInitialLoad) => {
1460
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1461
- const instance = hostRef.$lazyInstance$ ;
1462
- // We're going to use this variable together with `enqueue` to implement a
1463
- // little promise-based queue. We start out with it `undefined`. When we add
1464
- // the first function to the queue we'll set this variable to be that
1465
- // function's return value. When we attempt to add subsequent values to the
1466
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1467
- // the new function off of that `Promise` using `.then()`. This will give our
1468
- // queue two nice properties:
1469
- //
1470
- // 1. If all functions added to the queue are synchronous they'll be called
1471
- // synchronously right away.
1472
- // 2. If all functions added to the queue are asynchronous they'll all be
1473
- // called in order after `dispatchHooks` exits.
1474
- let maybePromise;
1475
- if (isInitialLoad) {
1476
- {
1477
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1478
- if (hostRef.$queuedListeners$) {
1479
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1480
- hostRef.$queuedListeners$ = undefined;
1481
- }
1482
- }
1483
- {
1484
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1485
- // whatever's going on in that `Promise` before we launch into
1486
- // rendering the component, doing other lifecycle stuff, etc. So
1487
- // in that case we assign the returned promise to the variable we
1488
- // declared above to hold a possible 'queueing' Promise
1489
- maybePromise = safeCall(instance, 'componentWillLoad');
1490
- }
1491
- }
1492
- endSchedule();
1493
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1494
- };
1495
- /**
1496
- * This function uses a Promise to implement a simple first-in, first-out queue
1497
- * of functions to be called.
1498
- *
1499
- * The queue is ordered on the basis of the first argument. If it's
1500
- * `undefined`, then nothing is on the queue yet, so the provided function can
1501
- * be called synchronously (although note that this function may return a
1502
- * `Promise`). The idea is that then the return value of that enqueueing
1503
- * operation is kept around, so that if it was a `Promise` then subsequent
1504
- * functions can be enqueued by calling this function again with that `Promise`
1505
- * as the first argument.
1506
- *
1507
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1508
- * @param fn a function to enqueue
1509
- * @returns either a `Promise` or the return value of the provided function
1510
- */
1511
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1512
- /**
1513
- * Check that a value is a `Promise`. To check, we first see if the value is an
1514
- * instance of the `Promise` global. In a few circumstances, in particular if
1515
- * the global has been overwritten, this is could be misleading, so we also do
1516
- * a little 'duck typing' check to see if the `.then` property of the value is
1517
- * defined and a function.
1518
- *
1519
- * @param maybePromise it might be a promise!
1520
- * @returns whether it is or not
1521
- */
1522
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1523
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1524
- /**
1525
- * Update a component given reference to its host elements and so on.
1526
- *
1527
- * @param hostRef an object containing references to the element's host node,
1528
- * VDom nodes, and other metadata
1529
- * @param instance a reference to the underlying host element where it will be
1530
- * rendered
1531
- * @param isInitialLoad whether or not this function is being called as part of
1532
- * the first render cycle
1533
- */
1534
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1535
- var _a;
1536
- const elm = hostRef.$hostElement$;
1537
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1538
- const rc = elm['s-rc'];
1539
- if (isInitialLoad) {
1540
- // DOM WRITE!
1541
- attachStyles(hostRef);
1542
- }
1543
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1544
- {
1545
- callRender(hostRef, instance, elm, isInitialLoad);
1546
- }
1547
- if (rc) {
1548
- // ok, so turns out there are some child host elements
1549
- // waiting on this parent element to load
1550
- // let's fire off all update callbacks waiting
1551
- rc.map((cb) => cb());
1552
- elm['s-rc'] = undefined;
1553
- }
1554
- endRender();
1555
- endUpdate();
1556
- {
1557
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1558
- const postUpdate = () => postUpdateComponent(hostRef);
1559
- if (childrenPromises.length === 0) {
1560
- postUpdate();
1561
- }
1562
- else {
1563
- Promise.all(childrenPromises).then(postUpdate);
1564
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1565
- childrenPromises.length = 0;
1566
- }
1567
- }
1568
- };
1569
- /**
1570
- * Handle making the call to the VDom renderer with the proper context given
1571
- * various build variables
1572
- *
1573
- * @param hostRef an object containing references to the element's host node,
1574
- * VDom nodes, and other metadata
1575
- * @param instance a reference to the underlying host element where it will be
1576
- * rendered
1577
- * @param elm the Host element for the component
1578
- * @param isInitialLoad whether or not this function is being called as part of
1579
- * @returns an empty promise
1580
- */
1581
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1582
- try {
1583
- /**
1584
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1585
- * method, so we can call the method immediately. If not, check before calling it.
1586
- */
1587
- instance = instance.render() ;
1588
- {
1589
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1590
- }
1591
- {
1592
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1593
- }
1594
- {
1595
- {
1596
- // looks like we've got child nodes to render into this host element
1597
- // or we need to update the css class/attrs on the host element
1598
- // DOM WRITE!
1599
- {
1600
- renderVdom(hostRef, instance, isInitialLoad);
1601
- }
1602
- }
1603
- }
1604
- }
1605
- catch (e) {
1606
- consoleError(e, hostRef.$hostElement$);
1607
- }
1608
- return null;
1609
- };
1610
- const postUpdateComponent = (hostRef) => {
1611
- const tagName = hostRef.$cmpMeta$.$tagName$;
1612
- const elm = hostRef.$hostElement$;
1613
- const endPostUpdate = createTime('postUpdate', tagName);
1614
- const instance = hostRef.$lazyInstance$ ;
1615
- const ancestorComponent = hostRef.$ancestorComponent$;
1616
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1617
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1618
- {
1619
- // DOM WRITE!
1620
- addHydratedFlag(elm);
1621
- }
1622
- {
1623
- safeCall(instance, 'componentDidLoad');
1624
- }
1625
- endPostUpdate();
1626
- {
1627
- hostRef.$onReadyResolve$(elm);
1628
- if (!ancestorComponent) {
1629
- appDidLoad();
1630
- }
1631
- }
1632
- }
1633
- else {
1634
- {
1635
- safeCall(instance, 'componentDidUpdate');
1636
- }
1637
- endPostUpdate();
1638
- }
1639
- {
1640
- hostRef.$onInstanceResolve$(elm);
1641
- }
1642
- // load events fire from bottom to top
1643
- // the deepest elements load first then bubbles up
1644
- {
1645
- if (hostRef.$onRenderResolve$) {
1646
- hostRef.$onRenderResolve$();
1647
- hostRef.$onRenderResolve$ = undefined;
1648
- }
1649
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1650
- nextTick(() => scheduleUpdate(hostRef, false));
1651
- }
1652
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1653
- }
1654
- // ( •_•)
1655
- // ( •_•)>⌐■-■
1656
- // (⌐■_■)
1657
- };
1658
- const appDidLoad = (who) => {
1659
- // on appload
1660
- // we have finish the first big initial render
1661
- {
1662
- addHydratedFlag(doc.documentElement);
1663
- }
1664
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1665
- };
1666
- /**
1667
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1668
- * e.g. custom element node. If a build figures out that e.g. no component
1669
- * has a `componentDidLoad` method, the instance method gets removed from the
1670
- * output bundle and this function returns `undefined`.
1671
- * @param instance any object that may or may not contain methods
1672
- * @param method method name
1673
- * @param arg single arbitrary argument
1674
- * @returns result of method call if it exists, otherwise `undefined`
1675
- */
1676
- const safeCall = (instance, method, arg) => {
1677
- if (instance && instance[method]) {
1678
- try {
1679
- return instance[method](arg);
1680
- }
1681
- catch (e) {
1682
- consoleError(e);
1683
- }
1684
- }
1685
- return undefined;
1686
- };
1687
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1688
- ;
1689
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1690
- const setValue = (ref, propName, newVal, cmpMeta) => {
1691
- // check our new property value against our internal value
1692
- const hostRef = getHostRef(ref);
1693
- const elm = hostRef.$hostElement$ ;
1694
- const oldVal = hostRef.$instanceValues$.get(propName);
1695
- const flags = hostRef.$flags$;
1696
- const instance = hostRef.$lazyInstance$ ;
1697
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1698
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1699
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1700
- const didValueChange = newVal !== oldVal && !areBothNaN;
1701
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1702
- // gadzooks! the property's value has changed!!
1703
- // set our new value!
1704
- hostRef.$instanceValues$.set(propName, newVal);
1705
- if (instance) {
1706
- // get an array of method names of watch functions to call
1707
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1708
- const watchMethods = cmpMeta.$watchers$[propName];
1709
- if (watchMethods) {
1710
- // this instance is watching for when this property changed
1711
- watchMethods.map((watchMethodName) => {
1712
- try {
1713
- // fire off each of the watch methods that are watching this property
1714
- instance[watchMethodName](newVal, oldVal, propName);
1715
- }
1716
- catch (e) {
1717
- consoleError(e, elm);
1718
- }
1719
- });
1720
- }
1721
- }
1722
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1723
- // looks like this value actually changed, so we've got work to do!
1724
- // but only if we've already rendered, otherwise just chill out
1725
- // queue that we need to do an update, but don't worry about queuing
1726
- // up millions cuz this function ensures it only runs once
1727
- scheduleUpdate(hostRef, false);
1728
- }
1729
- }
1730
- }
1731
- };
1732
- /**
1733
- * Attach a series of runtime constructs to a compiled Stencil component
1734
- * constructor, including getters and setters for the `@Prop` and `@State`
1735
- * decorators, callbacks for when attributes change, and so on.
1736
- *
1737
- * @param Cstr the constructor for a component that we need to process
1738
- * @param cmpMeta metadata collected previously about the component
1739
- * @param flags a number used to store a series of bit flags
1740
- * @returns a reference to the same constructor passed in (but now mutated)
1741
- */
1742
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1743
- var _a;
1744
- const prototype = Cstr.prototype;
1745
- if (cmpMeta.$members$) {
1746
- if (Cstr.watchers) {
1747
- cmpMeta.$watchers$ = Cstr.watchers;
1748
- }
1749
- // It's better to have a const than two Object.entries()
1750
- const members = Object.entries(cmpMeta.$members$);
1751
- members.map(([memberName, [memberFlags]]) => {
1752
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1753
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1754
- // proxyComponent - prop
1755
- Object.defineProperty(prototype, memberName, {
1756
- get() {
1757
- // proxyComponent, get value
1758
- return getValue(this, memberName);
1759
- },
1760
- set(newValue) {
1761
- // proxyComponent, set value
1762
- setValue(this, memberName, newValue, cmpMeta);
1763
- },
1764
- configurable: true,
1765
- enumerable: true,
1766
- });
1767
- }
1768
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1769
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1770
- // proxyComponent - method
1771
- Object.defineProperty(prototype, memberName, {
1772
- value(...args) {
1773
- var _a;
1774
- const ref = getHostRef(this);
1775
- 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); });
1776
- },
1777
- });
1778
- }
1779
- });
1780
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1781
- const attrNameToPropName = new Map();
1782
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1783
- plt.jmp(() => {
1784
- var _a;
1785
- const propName = attrNameToPropName.get(attrName);
1786
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1787
- // in the case where an attribute was set inline.
1788
- // ```html
1789
- // <my-component some-attribute="some-value"></my-component>
1790
- // ```
1791
- //
1792
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1793
- // programmatically changes it before it has been upgraded as shown below:
1794
- //
1795
- // ```html
1796
- // <!-- this component has _not_ been upgraded yet -->
1797
- // <my-component id="test" some-attribute="some-value"></my-component>
1798
- // <script>
1799
- // // grab non-upgraded component
1800
- // el = document.querySelector("#test");
1801
- // el.someAttribute = "another-value";
1802
- // // upgrade component
1803
- // customElements.define('my-component', MyComponent);
1804
- // </script>
1805
- // ```
1806
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1807
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1808
- // to the value that was set inline i.e. "some-value" from above example. When
1809
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1810
- //
1811
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1812
- // by connectedCallback as this attributeChangedCallback will not fire.
1813
- //
1814
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1815
- //
1816
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1817
- // properties here given that this goes against best practices outlined here
1818
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1819
- if (this.hasOwnProperty(propName)) {
1820
- newValue = this[propName];
1821
- delete this[propName];
1822
- }
1823
- else if (prototype.hasOwnProperty(propName) &&
1824
- typeof this[propName] === 'number' &&
1825
- this[propName] == newValue) {
1826
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1827
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1828
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1829
- return;
1830
- }
1831
- else if (propName == null) {
1832
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1833
- // on a vanilla web component
1834
- const hostRef = getHostRef(this);
1835
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1836
- // We only want to trigger the callback(s) if:
1837
- // 1. The instance is ready
1838
- // 2. The watchers are ready
1839
- // 3. The value has changed
1840
- if (flags &&
1841
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1842
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1843
- newValue !== oldValue) {
1844
- const instance = hostRef.$lazyInstance$ ;
1845
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1846
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1847
- if (instance[callbackName] != null) {
1848
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1849
- }
1850
- });
1851
- }
1852
- return;
1853
- }
1854
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1855
- });
1856
- };
1857
- // Create an array of attributes to observe
1858
- // This list in comprised of all strings used within a `@Watch()` decorator
1859
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1860
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1861
- // an invalid attribute.
1862
- Cstr.observedAttributes = Array.from(new Set([
1863
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1864
- ...members
1865
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1866
- .map(([propName, m]) => {
1867
- var _a;
1868
- const attrName = m[1] || propName;
1869
- attrNameToPropName.set(attrName, propName);
1870
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1871
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
1872
- }
1873
- return attrName;
1874
- }),
1875
- ]));
1876
- }
1877
- }
1878
- return Cstr;
1879
- };
1880
- /**
1881
- * Initialize a Stencil component given a reference to its host element, its
1882
- * runtime bookkeeping data structure, runtime metadata about the component,
1883
- * and (optionally) an HMR version ID.
1884
- *
1885
- * @param elm a host element
1886
- * @param hostRef the element's runtime bookkeeping object
1887
- * @param cmpMeta runtime metadata for the Stencil component
1888
- * @param hmrVersionId an (optional) HMR version ID
1889
- */
1890
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1891
- let Cstr;
1892
- // initializeComponent
1893
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1894
- // Let the runtime know that the component has been initialized
1895
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1896
- const bundleId = cmpMeta.$lazyBundleId$;
1897
- if (bundleId) {
1898
- // lazy loaded components
1899
- // request the component's implementation to be
1900
- // wired up with the host element
1901
- Cstr = loadModule(cmpMeta);
1902
- if (Cstr.then) {
1903
- // Await creates a micro-task avoid if possible
1904
- const endLoad = uniqueTime();
1905
- Cstr = await Cstr;
1906
- endLoad();
1907
- }
1908
- if (!Cstr.isProxied) {
1909
- // we've never proxied this Constructor before
1910
- // let's add the getters/setters to its prototype before
1911
- // the first time we create an instance of the implementation
1912
- {
1913
- cmpMeta.$watchers$ = Cstr.watchers;
1914
- }
1915
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1916
- Cstr.isProxied = true;
1917
- }
1918
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1919
- // ok, time to construct the instance
1920
- // but let's keep track of when we start and stop
1921
- // so that the getters/setters don't incorrectly step on data
1922
- {
1923
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1924
- }
1925
- // construct the lazy-loaded component implementation
1926
- // passing the hostRef is very important during
1927
- // construction in order to directly wire together the
1928
- // host element and the lazy-loaded instance
1929
- try {
1930
- new Cstr(hostRef);
1931
- }
1932
- catch (e) {
1933
- consoleError(e);
1934
- }
1935
- {
1936
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1937
- }
1938
- {
1939
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1940
- }
1941
- endNewInstance();
1942
- fireConnectedCallback(hostRef.$lazyInstance$);
1943
- }
1944
- else {
1945
- // sync constructor component
1946
- Cstr = elm.constructor;
1947
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
1948
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
1949
- // Stencil has completed instantiating the component.
1950
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
1951
- }
1952
- if (Cstr.style) {
1953
- // this component has styles but we haven't registered them yet
1954
- let style = Cstr.style;
1955
- const scopeId = getScopeId(cmpMeta);
1956
- if (!styles.has(scopeId)) {
1957
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1958
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1959
- endRegisterStyles();
1960
- }
1961
- }
1962
- }
1963
- // we've successfully created a lazy instance
1964
- const ancestorComponent = hostRef.$ancestorComponent$;
1965
- const schedule = () => scheduleUpdate(hostRef, true);
1966
- if (ancestorComponent && ancestorComponent['s-rc']) {
1967
- // this is the initial load and this component it has an ancestor component
1968
- // but the ancestor component has NOT fired its will update lifecycle yet
1969
- // so let's just cool our jets and wait for the ancestor to continue first
1970
- // this will get fired off when the ancestor component
1971
- // finally gets around to rendering its lazy self
1972
- // fire off the initial update
1973
- ancestorComponent['s-rc'].push(schedule);
1974
- }
1975
- else {
1976
- schedule();
1977
- }
1978
- };
1979
- const fireConnectedCallback = (instance) => {
1980
- {
1981
- safeCall(instance, 'connectedCallback');
1982
- }
1983
- };
1984
- const connectedCallback = (elm) => {
1985
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1986
- const hostRef = getHostRef(elm);
1987
- const cmpMeta = hostRef.$cmpMeta$;
1988
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1989
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1990
- // first time this component has connected
1991
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1992
- let hostId;
1993
- {
1994
- hostId = elm.getAttribute(HYDRATE_ID);
1995
- if (hostId) {
1996
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1997
- const scopeId = addStyle(elm.shadowRoot, cmpMeta);
1998
- elm.classList.remove(scopeId + '-h', scopeId + '-s');
1999
- }
2000
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2001
- }
2002
- }
2003
- {
2004
- // find the first ancestor component (if there is one) and register
2005
- // this component as one of the actively loading child components for its ancestor
2006
- let ancestorComponent = elm;
2007
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2008
- // climb up the ancestors looking for the first
2009
- // component that hasn't finished its lifecycle update yet
2010
- if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2011
- ancestorComponent.hasAttribute('s-id') &&
2012
- ancestorComponent['s-p']) ||
2013
- ancestorComponent['s-p']) {
2014
- // we found this components first ancestor component
2015
- // keep a reference to this component's ancestor component
2016
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2017
- break;
2018
- }
2019
- }
2020
- }
2021
- // Lazy properties
2022
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2023
- if (cmpMeta.$members$) {
2024
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2025
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2026
- const value = elm[memberName];
2027
- delete elm[memberName];
2028
- elm[memberName] = value;
2029
- }
2030
- });
2031
- }
2032
- {
2033
- initializeComponent(elm, hostRef, cmpMeta);
2034
- }
2035
- }
2036
- else {
2037
- // not the first time this has connected
2038
- // reattach any event listeners to the host
2039
- // since they would have been removed when disconnected
2040
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2041
- // fire off connectedCallback() on component instance
2042
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2043
- fireConnectedCallback(hostRef.$lazyInstance$);
2044
- }
2045
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2046
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
2047
- }
2048
- }
2049
- endConnected();
2050
- }
2051
- };
2052
- const disconnectInstance = (instance) => {
2053
- {
2054
- safeCall(instance, 'disconnectedCallback');
2055
- }
2056
- };
2057
- const disconnectedCallback = async (elm) => {
2058
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2059
- const hostRef = getHostRef(elm);
2060
- {
2061
- if (hostRef.$rmListeners$) {
2062
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2063
- hostRef.$rmListeners$ = undefined;
2064
- }
2065
- }
2066
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2067
- disconnectInstance(hostRef.$lazyInstance$);
2068
- }
2069
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2070
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2071
- }
2072
- }
2073
- };
2074
- const bootstrapLazy = (lazyBundles, options = {}) => {
2075
- var _a;
2076
- const endBootstrap = createTime();
2077
- const cmpTags = [];
2078
- const exclude = options.exclude || [];
2079
- const customElements = win.customElements;
2080
- const head = doc.head;
2081
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2082
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
2083
- const deferredConnectedCallbacks = [];
2084
- const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2085
- let appLoadFallback;
2086
- let isBootstrapping = true;
2087
- let i = 0;
2088
- Object.assign(plt, options);
2089
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2090
- {
2091
- // If the app is already hydrated there is not point to disable the
2092
- // async queue. This will improve the first input delay
2093
- plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2094
- }
2095
- {
2096
- for (; i < styles.length; i++) {
2097
- registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2098
- }
2099
- }
2100
- let hasSlotRelocation = false;
2101
- lazyBundles.map((lazyBundle) => {
2102
- lazyBundle[1].map((compactMeta) => {
2103
- var _a;
2104
- const cmpMeta = {
2105
- $flags$: compactMeta[0],
2106
- $tagName$: compactMeta[1],
2107
- $members$: compactMeta[2],
2108
- $listeners$: compactMeta[3],
2109
- };
2110
- // Check if we are using slots outside the shadow DOM in this component.
2111
- // We'll use this information later to add styles for `slot-fb` elements
2112
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
2113
- hasSlotRelocation = true;
2114
- }
2115
- {
2116
- cmpMeta.$members$ = compactMeta[2];
2117
- }
2118
- {
2119
- cmpMeta.$listeners$ = compactMeta[3];
2120
- }
2121
- {
2122
- cmpMeta.$attrsToReflect$ = [];
2123
- }
2124
- {
2125
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
2126
- }
2127
- const tagName = cmpMeta.$tagName$;
2128
- const HostElement = class extends HTMLElement {
2129
- // StencilLazyHost
2130
- constructor(self) {
2131
- // @ts-ignore
2132
- super(self);
2133
- self = this;
2134
- registerHost(self, cmpMeta);
2135
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2136
- // this component is using shadow dom
2137
- // and this browser supports shadow dom
2138
- // add the read-only property "shadowRoot" to the host element
2139
- // adding the shadow root build conditionals to minimize runtime
2140
- {
2141
- {
2142
- self.attachShadow({
2143
- mode: 'open',
2144
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2145
- });
2146
- }
2147
- }
2148
- }
2149
- }
2150
- connectedCallback() {
2151
- if (appLoadFallback) {
2152
- clearTimeout(appLoadFallback);
2153
- appLoadFallback = null;
2154
- }
2155
- if (isBootstrapping) {
2156
- // connectedCallback will be processed once all components have been registered
2157
- deferredConnectedCallbacks.push(this);
2158
- }
2159
- else {
2160
- plt.jmp(() => connectedCallback(this));
2161
- }
2162
- }
2163
- disconnectedCallback() {
2164
- plt.jmp(() => disconnectedCallback(this));
2165
- }
2166
- componentOnReady() {
2167
- return getHostRef(this).$onReadyPromise$;
2168
- }
2169
- };
2170
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2171
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2172
- cmpTags.push(tagName);
2173
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2174
- }
2175
- });
2176
- });
2177
- // Only bother generating CSS if we have components
2178
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
2179
- if (cmpTags.length > 0) {
2180
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
2181
- if (hasSlotRelocation) {
2182
- dataStyles.textContent += SLOT_FB_CSS;
2183
- }
2184
- // Add hydration styles
2185
- {
2186
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
2187
- }
2188
- // If we have styles, add them to the DOM
2189
- if (dataStyles.innerHTML.length) {
2190
- dataStyles.setAttribute('data-styles', '');
2191
- // Apply CSP nonce to the style tag if it exists
2192
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2193
- if (nonce != null) {
2194
- dataStyles.setAttribute('nonce', nonce);
2195
- }
2196
- // Insert the styles into the document head
2197
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
2198
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2199
- }
2200
- }
2201
- // Process deferred connectedCallbacks now all components have been registered
2202
- isBootstrapping = false;
2203
- if (deferredConnectedCallbacks.length) {
2204
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2205
- }
2206
- else {
2207
- {
2208
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2209
- }
2210
- }
2211
- // Fallback appLoad event
2212
- endBootstrap();
2213
- };
2214
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2215
- if (listeners) {
2216
- listeners.map(([flags, name, method]) => {
2217
- const target = getHostListenerTarget(elm, flags) ;
2218
- const handler = hostListenerProxy(hostRef, method);
2219
- const opts = hostListenerOpts(flags);
2220
- plt.ael(target, name, handler, opts);
2221
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2222
- });
2223
- }
2224
- };
2225
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
2226
- try {
2227
- {
2228
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2229
- // instance is ready, let's call it's member method for this event
2230
- hostRef.$lazyInstance$[methodName](ev);
2231
- }
2232
- else {
2233
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2234
- }
2235
- }
2236
- }
2237
- catch (e) {
2238
- consoleError(e);
2239
- }
2240
- };
2241
- const getHostListenerTarget = (elm, flags) => {
2242
- if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
2243
- return doc;
2244
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2245
- return win;
2246
- if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
2247
- return doc.body;
2248
- return elm;
2249
- };
2250
- // prettier-ignore
2251
- const hostListenerOpts = (flags) => supportsListenerOptions
2252
- ? ({
2253
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
2254
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2255
- })
2256
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2257
- /**
2258
- * Assigns the given value to the nonce property on the runtime platform object.
2259
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2260
- * @param nonce The value to be assigned to the platform nonce property.
2261
- * @returns void
2262
- */
2263
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
2264
- /**
2265
- * A WeakMap mapping runtime component references to their corresponding host reference
2266
- * instances.
2267
- *
2268
- * **Note**: If we're in an HMR context we need to store a reference to this
2269
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
2270
- * to {@link d.HostRef} across HMR updates.
2271
- *
2272
- * This is necessary because when HMR updates for a component are processed by
2273
- * the browser-side dev server client the JS bundle for that component is
2274
- * re-fetched. Since the module containing {@link hostRefs} is included in
2275
- * that bundle, if we do not store a reference to it the new iteration of the
2276
- * component will not have access to the previous hostRef map, leading to a
2277
- * bug where the new version of the component cannot properly initialize.
2278
- */
2279
- const hostRefs = new WeakMap();
2280
- /**
2281
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
2282
- *
2283
- * @param ref the runtime ref of interest
2284
- * @returns the Host reference (if found) or undefined
2285
- */
2286
- const getHostRef = (ref) => hostRefs.get(ref);
2287
- /**
2288
- * Register a lazy instance with the {@link hostRefs} object so it's
2289
- * corresponding {@link d.HostRef} can be retrieved later.
2290
- *
2291
- * @param lazyInstance the lazy instance of interest
2292
- * @param hostRef that instances `HostRef` object
2293
- * @returns a reference to the host ref WeakMap
2294
- */
2295
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2296
- /**
2297
- * Register a host element for a Stencil component, setting up various metadata
2298
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
2299
- * metadata.
2300
- *
2301
- * @param hostElement the host element to register
2302
- * @param cmpMeta runtime metadata for that component
2303
- * @returns a reference to the host ref WeakMap
2304
- */
2305
- const registerHost = (hostElement, cmpMeta) => {
2306
- const hostRef = {
2307
- $flags$: 0,
2308
- $hostElement$: hostElement,
2309
- $cmpMeta$: cmpMeta,
2310
- $instanceValues$: new Map(),
2311
- };
2312
- {
2313
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2314
- }
2315
- {
2316
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2317
- hostElement['s-p'] = [];
2318
- hostElement['s-rc'] = [];
2319
- }
2320
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
2321
- return hostRefs.set(hostElement, hostRef);
2322
- };
2323
- const isMemberInElement = (elm, memberName) => memberName in elm;
2324
- const consoleError = (e, el) => (0, console.error)(e, el);
2325
- const cmpModules = /*@__PURE__*/ new Map();
2326
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2327
- // loadModuleImport
2328
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2329
- const bundleId = cmpMeta.$lazyBundleId$;
2330
- const module = cmpModules.get(bundleId) ;
2331
- if (module) {
2332
- return module[exportName];
2333
- }
2334
-
2335
- if (!hmrVersionId || !BUILD.hotModuleReplacement) {
2336
- const processMod = importedModule => {
2337
- cmpModules.set(bundleId, importedModule);
2338
- return importedModule[exportName];
2339
- }
2340
- switch(bundleId) {
2341
-
2342
- case 'bq-accordion.cjs':
2343
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2344
- /* webpackMode: "lazy" */
2345
- './bq-accordion.cjs.entry.js')); }).then(processMod, consoleError);
2346
- case 'bq-accordion-group.cjs':
2347
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2348
- /* webpackMode: "lazy" */
2349
- './bq-accordion-group.cjs.entry.js')); }).then(processMod, consoleError);
2350
- case 'bq-alert.cjs':
2351
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2352
- /* webpackMode: "lazy" */
2353
- './bq-alert.cjs.entry.js')); }).then(processMod, consoleError);
2354
- case 'bq-avatar.cjs':
2355
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2356
- /* webpackMode: "lazy" */
2357
- './bq-avatar.cjs.entry.js')); }).then(processMod, consoleError);
2358
- case 'bq-breadcrumb.cjs':
2359
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2360
- /* webpackMode: "lazy" */
2361
- './bq-breadcrumb.cjs.entry.js')); }).then(processMod, consoleError);
2362
- case 'bq-breadcrumb-item.cjs':
2363
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2364
- /* webpackMode: "lazy" */
2365
- './bq-breadcrumb-item.cjs.entry.js')); }).then(processMod, consoleError);
2366
- case 'bq-card.cjs':
2367
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2368
- /* webpackMode: "lazy" */
2369
- './bq-card.cjs.entry.js')); }).then(processMod, consoleError);
2370
- case 'bq-checkbox.cjs':
2371
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2372
- /* webpackMode: "lazy" */
2373
- './bq-checkbox.cjs.entry.js')); }).then(processMod, consoleError);
2374
- case 'bq-dialog.cjs':
2375
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2376
- /* webpackMode: "lazy" */
2377
- './bq-dialog.cjs.entry.js')); }).then(processMod, consoleError);
2378
- case 'bq-drawer.cjs':
2379
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2380
- /* webpackMode: "lazy" */
2381
- './bq-drawer.cjs.entry.js')); }).then(processMod, consoleError);
2382
- case 'bq-empty-state.cjs':
2383
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2384
- /* webpackMode: "lazy" */
2385
- './bq-empty-state.cjs.entry.js')); }).then(processMod, consoleError);
2386
- case 'bq-input.cjs':
2387
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2388
- /* webpackMode: "lazy" */
2389
- './bq-input.cjs.entry.js')); }).then(processMod, consoleError);
2390
- case 'bq-notification.cjs':
2391
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2392
- /* webpackMode: "lazy" */
2393
- './bq-notification.cjs.entry.js')); }).then(processMod, consoleError);
2394
- case 'bq-option.cjs':
2395
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2396
- /* webpackMode: "lazy" */
2397
- './bq-option.cjs.entry.js')); }).then(processMod, consoleError);
2398
- case 'bq-option-group.cjs':
2399
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2400
- /* webpackMode: "lazy" */
2401
- './bq-option-group.cjs.entry.js')); }).then(processMod, consoleError);
2402
- case 'bq-progress.cjs':
2403
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2404
- /* webpackMode: "lazy" */
2405
- './bq-progress.cjs.entry.js')); }).then(processMod, consoleError);
2406
- case 'bq-radio.cjs':
2407
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2408
- /* webpackMode: "lazy" */
2409
- './bq-radio.cjs.entry.js')); }).then(processMod, consoleError);
2410
- case 'bq-radio-group.cjs':
2411
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2412
- /* webpackMode: "lazy" */
2413
- './bq-radio-group.cjs.entry.js')); }).then(processMod, consoleError);
2414
- case 'bq-select.cjs':
2415
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2416
- /* webpackMode: "lazy" */
2417
- './bq-select.cjs.entry.js')); }).then(processMod, consoleError);
2418
- case 'bq-side-menu.cjs':
2419
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2420
- /* webpackMode: "lazy" */
2421
- './bq-side-menu.cjs.entry.js')); }).then(processMod, consoleError);
2422
- case 'bq-side-menu-item.cjs':
2423
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2424
- /* webpackMode: "lazy" */
2425
- './bq-side-menu-item.cjs.entry.js')); }).then(processMod, consoleError);
2426
- case 'bq-slider.cjs':
2427
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2428
- /* webpackMode: "lazy" */
2429
- './bq-slider.cjs.entry.js')); }).then(processMod, consoleError);
2430
- case 'bq-spinner.cjs':
2431
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2432
- /* webpackMode: "lazy" */
2433
- './bq-spinner.cjs.entry.js')); }).then(processMod, consoleError);
2434
- case 'bq-status.cjs':
2435
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2436
- /* webpackMode: "lazy" */
2437
- './bq-status.cjs.entry.js')); }).then(processMod, consoleError);
2438
- case 'bq-step-item.cjs':
2439
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2440
- /* webpackMode: "lazy" */
2441
- './bq-step-item.cjs.entry.js')); }).then(processMod, consoleError);
2442
- case 'bq-steps.cjs':
2443
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2444
- /* webpackMode: "lazy" */
2445
- './bq-steps.cjs.entry.js')); }).then(processMod, consoleError);
2446
- case 'bq-switch.cjs':
2447
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2448
- /* webpackMode: "lazy" */
2449
- './bq-switch.cjs.entry.js')); }).then(processMod, consoleError);
2450
- case 'bq-tab.cjs':
2451
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2452
- /* webpackMode: "lazy" */
2453
- './bq-tab.cjs.entry.js')); }).then(processMod, consoleError);
2454
- case 'bq-tab-group.cjs':
2455
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2456
- /* webpackMode: "lazy" */
2457
- './bq-tab-group.cjs.entry.js')); }).then(processMod, consoleError);
2458
- case 'bq-textarea.cjs':
2459
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2460
- /* webpackMode: "lazy" */
2461
- './bq-textarea.cjs.entry.js')); }).then(processMod, consoleError);
2462
- case 'bq-toast.cjs':
2463
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2464
- /* webpackMode: "lazy" */
2465
- './bq-toast.cjs.entry.js')); }).then(processMod, consoleError);
2466
- case 'bq-badge.cjs':
2467
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2468
- /* webpackMode: "lazy" */
2469
- './bq-badge.cjs.entry.js')); }).then(processMod, consoleError);
2470
- case 'bq-dropdown_3.cjs':
2471
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2472
- /* webpackMode: "lazy" */
2473
- './bq-dropdown_3.cjs.entry.js')); }).then(processMod, consoleError);
2474
- case 'bq-divider.cjs':
2475
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2476
- /* webpackMode: "lazy" */
2477
- './bq-divider.cjs.entry.js')); }).then(processMod, consoleError);
2478
- case 'bq-panel.cjs':
2479
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2480
- /* webpackMode: "lazy" */
2481
- './bq-panel.cjs.entry.js')); }).then(processMod, consoleError);
2482
- case 'bq-tooltip.cjs':
2483
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2484
- /* webpackMode: "lazy" */
2485
- './bq-tooltip.cjs.entry.js')); }).then(processMod, consoleError);
2486
- case 'bq-button.cjs':
2487
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2488
- /* webpackMode: "lazy" */
2489
- './bq-button.cjs.entry.js')); }).then(processMod, consoleError);
2490
- case 'bq-icon.cjs':
2491
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2492
- /* webpackMode: "lazy" */
2493
- './bq-icon.cjs.entry.js')); }).then(processMod, consoleError);
2494
- }
2495
- }
2496
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2497
- /* @vite-ignore */
2498
- /* webpackInclude: /\.entry\.js$/ */
2499
- /* webpackExclude: /\.system\.entry\.js$/ */
2500
- /* webpackMode: "lazy" */
2501
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
2502
- {
2503
- cmpModules.set(bundleId, importedModule);
2504
- }
2505
- return importedModule[exportName];
2506
- }, consoleError);
2507
- };
2508
- const styles = /*@__PURE__*/ new Map();
2509
- const win = typeof window !== 'undefined' ? window : {};
2510
- const doc = win.document || { head: {} };
2511
- const H = (win.HTMLElement || class {
2512
- });
2513
- const plt = {
2514
- $flags$: 0,
2515
- $resourcesUrl$: '',
2516
- jmp: (h) => h(),
2517
- raf: (h) => requestAnimationFrame(h),
2518
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2519
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2520
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2521
- };
2522
- const supportsShadow =
2523
- // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2524
- true;
2525
- const supportsListenerOptions = /*@__PURE__*/ (() => {
2526
- let supportsListenerOptions = false;
2527
- try {
2528
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
2529
- get() {
2530
- supportsListenerOptions = true;
2531
- },
2532
- }));
2533
- }
2534
- catch (e) { }
2535
- return supportsListenerOptions;
2536
- })();
2537
- const promiseResolve = (v) => Promise.resolve(v);
2538
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2539
- try {
2540
- new CSSStyleSheet();
2541
- return typeof new CSSStyleSheet().replaceSync === 'function';
2542
- }
2543
- catch (e) { }
2544
- return false;
2545
- })()
2546
- ;
2547
- const queueDomReads = [];
2548
- const queueDomWrites = [];
2549
- const queueTask = (queue, write) => (cb) => {
2550
- queue.push(cb);
2551
- if (!queuePending) {
2552
- queuePending = true;
2553
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2554
- nextTick(flush);
2555
- }
2556
- else {
2557
- plt.raf(flush);
2558
- }
2559
- }
2560
- };
2561
- const consume = (queue) => {
2562
- for (let i = 0; i < queue.length; i++) {
2563
- try {
2564
- queue[i](performance.now());
2565
- }
2566
- catch (e) {
2567
- consoleError(e);
2568
- }
2569
- }
2570
- queue.length = 0;
2571
- };
2572
- const flush = () => {
2573
- // always force a bunch of medium callbacks to run, but still have
2574
- // a throttle on how many can run in a certain time
2575
- // DOM READS!!!
2576
- consume(queueDomReads);
2577
- // DOM WRITES!!!
2578
- {
2579
- consume(queueDomWrites);
2580
- if ((queuePending = queueDomReads.length > 0)) {
2581
- // still more to do yet, but we've run out of time
2582
- // let's let this thing cool off and try again in the next tick
2583
- plt.raf(flush);
2584
- }
2585
- }
2586
- };
2587
- const nextTick = (cb) => promiseResolve().then(cb);
2588
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2589
-
2590
- exports.Env = Env;
2591
- exports.H = H;
2592
- exports.Host = Host;
2593
- exports.bootstrapLazy = bootstrapLazy;
2594
- exports.createEvent = createEvent;
2595
- exports.getElement = getElement;
2596
- exports.h = h;
2597
- exports.promiseResolve = promiseResolve;
2598
- exports.registerInstance = registerInstance;
2599
- exports.setNonce = setNonce;
2600
-
2601
- //# sourceMappingURL=index-3e03656c.js.map