@scania/tegel 0.0.1-beta.2 → 0.0.1-beta.3

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