@biggive/components 1.0.96 → 1.0.97

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 (243) hide show
  1. package/dist/biggive/assets/images/biggive-triangle-green.svg +21 -0
  2. package/dist/biggive/assets/images/cross.svg +11 -0
  3. package/dist/biggive/assets/images/menu.svg +11 -0
  4. package/dist/biggive/biggive.esm.js +1 -1
  5. package/dist/biggive/p-063c44ce.entry.js +1 -0
  6. package/dist/biggive/p-0892aade.entry.js +1 -0
  7. package/dist/biggive/{p-e39db89c.entry.js → p-38b36bc6.entry.js} +1 -1
  8. package/dist/biggive/p-41c6f1f3.entry.js +1 -0
  9. package/dist/biggive/p-60872399.entry.js +1 -0
  10. package/dist/biggive/p-6d144f96.js +2 -0
  11. package/dist/biggive/p-8742102b.entry.js +1 -0
  12. package/dist/biggive/p-88faca11.js +1 -0
  13. package/dist/biggive/p-9916d987.entry.js +1 -0
  14. package/dist/biggive/p-99f15121.entry.js +1 -0
  15. package/dist/biggive/p-9fa2a9b2.entry.js +1 -0
  16. package/dist/biggive/p-a13e0f3e.entry.js +1 -0
  17. package/dist/biggive/p-aa4e1a2a.js +1 -0
  18. package/dist/biggive/p-bfaf1239.entry.js +1 -0
  19. package/dist/biggive/p-c1570c9f.entry.js +1 -0
  20. package/dist/biggive/p-d1c2b64d.entry.js +1 -0
  21. package/dist/biggive/p-da0a4725.entry.js +1 -0
  22. package/dist/biggive/p-de0f70ee.entry.js +1 -0
  23. package/dist/biggive/p-e3b0c4ae.entry.js +1 -0
  24. package/dist/biggive/p-e546fe69.entry.js +1 -0
  25. package/dist/cjs/biggive-article-card.cjs.entry.js +2 -35
  26. package/dist/cjs/biggive-back-to-top_23.cjs.entry.js +625 -0
  27. package/dist/cjs/biggive-basic-card.cjs.entry.js +2 -35
  28. package/dist/cjs/biggive-beneficiary-icon.cjs.entry.js +4 -19
  29. package/dist/cjs/biggive-boxed-content.cjs.entry.js +2 -17
  30. package/dist/cjs/biggive-branded-image.cjs.entry.js +2 -14
  31. package/dist/cjs/biggive-category-icon.cjs.entry.js +4 -19
  32. package/dist/cjs/biggive-form.cjs.entry.js +1 -1
  33. package/dist/cjs/biggive-formatted-text.cjs.entry.js +2 -8
  34. package/dist/cjs/biggive-icon-group.cjs.entry.js +2 -8
  35. package/dist/cjs/biggive-image.cjs.entry.js +2 -20
  36. package/dist/cjs/biggive-quote.cjs.entry.js +2 -14
  37. package/dist/cjs/biggive-search.cjs.entry.js +7 -5
  38. package/dist/cjs/biggive-tab.cjs.entry.js +2 -5
  39. package/dist/cjs/biggive-tabbed-content.cjs.entry.js +2 -8
  40. package/dist/cjs/biggive-text-input.cjs.entry.js +1 -1
  41. package/dist/cjs/biggive-video.cjs.entry.js +2 -11
  42. package/dist/cjs/biggive.cjs.js +3 -3
  43. package/dist/cjs/{fontawesome-icons-110f532d.js → fontawesome-icons-f33263c4.js} +45 -55
  44. package/dist/cjs/index-1fa2bbc6.js +196 -0
  45. package/dist/cjs/{index-87518c3f.js → index-ecfc2713.js} +734 -495
  46. package/dist/cjs/loader.cjs.js +3 -3
  47. package/dist/collection/assets/images/biggive-triangle-green.svg +21 -0
  48. package/dist/collection/assets/images/cross.svg +11 -0
  49. package/dist/collection/assets/images/menu.svg +11 -0
  50. package/dist/collection/collection-manifest.json +4 -2
  51. package/dist/collection/components/biggive-article-card/biggive-article-card.css +20 -0
  52. package/dist/collection/components/biggive-article-card/biggive-article-card.js +214 -253
  53. package/dist/collection/components/biggive-back-to-top/biggive-back-to-top.css +20 -0
  54. package/dist/collection/components/biggive-back-to-top/biggive-back-to-top.js +12 -11
  55. package/dist/collection/components/biggive-basic-card/biggive-basic-card.css +20 -0
  56. package/dist/collection/components/biggive-basic-card/biggive-basic-card.js +214 -251
  57. package/dist/collection/components/biggive-beneficiary-icon/biggive-beneficiary-icon.css +20 -0
  58. package/dist/collection/components/biggive-beneficiary-icon/biggive-beneficiary-icon.js +102 -116
  59. package/dist/collection/components/biggive-boxed-content/biggive-boxed-content.css +20 -0
  60. package/dist/collection/components/biggive-boxed-content/biggive-boxed-content.js +102 -112
  61. package/dist/collection/components/biggive-branded-image/biggive-branded-image.css +20 -0
  62. package/dist/collection/components/biggive-branded-image/biggive-branded-image.js +85 -96
  63. package/dist/collection/components/biggive-button/biggive-button.css +20 -0
  64. package/dist/collection/components/biggive-button/biggive-button.js +137 -153
  65. package/dist/collection/components/biggive-call-to-action/biggive-call-to-action.css +20 -0
  66. package/dist/collection/components/biggive-call-to-action/biggive-call-to-action.js +376 -440
  67. package/dist/collection/components/biggive-campaign-card/biggive-campaign-card.css +22 -0
  68. package/dist/collection/components/biggive-campaign-card/biggive-campaign-card.js +322 -385
  69. package/dist/collection/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.css +57 -0
  70. package/dist/collection/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.js +123 -124
  71. package/dist/collection/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.stories.js +6 -0
  72. package/dist/collection/components/biggive-campaign-highlights/biggive-campaign-highlights.css +20 -0
  73. package/dist/collection/components/biggive-campaign-highlights/biggive-campaign-highlights.js +238 -292
  74. package/dist/collection/components/biggive-category-icon/biggive-category-icon.css +20 -0
  75. package/dist/collection/components/biggive-category-icon/biggive-category-icon.js +102 -116
  76. package/dist/collection/components/biggive-footer/biggive-footer.css +54 -1
  77. package/dist/collection/components/biggive-footer/biggive-footer.js +15 -39
  78. package/dist/collection/components/biggive-footer/biggive-footer.stories.js +8 -1
  79. package/dist/collection/components/biggive-form/biggive-form.js +12 -9
  80. package/dist/collection/components/biggive-form-field-select/biggive-form-field-select.css +557 -0
  81. package/dist/collection/components/biggive-form-field-select/biggive-form-field-select.js +95 -9
  82. package/dist/collection/components/biggive-form-field-select/biggive-form-field-select.stories.js +9 -0
  83. package/dist/collection/components/biggive-form-field-select-option/biggive-form-field-select-option.css +520 -0
  84. package/dist/collection/components/biggive-form-field-select-option/biggive-form-field-select-option.js +94 -0
  85. package/dist/collection/components/biggive-form-field-select-option/biggive-form-field-select-option.stories.js +23 -0
  86. package/dist/collection/components/biggive-form-field-text-input/biggive-text-input.js +12 -9
  87. package/dist/collection/components/biggive-formatted-text/biggive-formatted-text.css +20 -0
  88. package/dist/collection/components/biggive-formatted-text/biggive-formatted-text.js +51 -52
  89. package/dist/collection/components/biggive-grid/biggive-grid.css +35 -0
  90. package/dist/collection/components/biggive-grid/biggive-grid.js +68 -72
  91. package/dist/collection/components/biggive-header/biggive-header.css +90 -2
  92. package/dist/collection/components/biggive-header/biggive-header.js +64 -69
  93. package/dist/collection/components/biggive-header/biggive-header.stories.js +2 -1
  94. package/dist/collection/components/biggive-heading/biggive-heading.css +20 -0
  95. package/dist/collection/components/biggive-heading/biggive-heading.js +136 -152
  96. package/dist/collection/components/biggive-hero-image/biggive-hero-image.css +44 -11
  97. package/dist/collection/components/biggive-hero-image/biggive-hero-image.js +240 -283
  98. package/dist/collection/components/biggive-icon-group/biggive-icon-group.css +20 -0
  99. package/dist/collection/components/biggive-icon-group/biggive-icon-group.js +51 -54
  100. package/dist/collection/components/biggive-image/biggive-image.css +20 -0
  101. package/dist/collection/components/biggive-image/biggive-image.js +119 -133
  102. package/dist/collection/components/biggive-image-feature/biggive-image-feature.css +39 -5
  103. package/dist/collection/components/biggive-image-feature/biggive-image-feature.js +232 -270
  104. package/dist/collection/components/biggive-misc-icon/biggive-misc-icon.css +20 -0
  105. package/dist/collection/components/biggive-misc-icon/biggive-misc-icon.js +85 -94
  106. package/dist/collection/components/biggive-page-column/biggive-page-column.css +506 -1
  107. package/dist/collection/components/biggive-page-column/biggive-page-column.js +11 -7
  108. package/dist/collection/components/biggive-page-columns/biggive-page-columns.css +30 -1
  109. package/dist/collection/components/biggive-page-columns/biggive-page-columns.js +34 -36
  110. package/dist/collection/components/biggive-page-section/biggive-page-section.css +20 -0
  111. package/dist/collection/components/biggive-page-section/biggive-page-section.js +85 -93
  112. package/dist/collection/components/biggive-popup/biggive-popup.css +547 -0
  113. package/dist/collection/components/biggive-popup/biggive-popup.js +47 -0
  114. package/dist/collection/components/biggive-popup/biggive-popup.stories.js +8 -0
  115. package/dist/collection/components/biggive-progress-bar/biggive-progress-bar.css +20 -0
  116. package/dist/collection/components/biggive-progress-bar/biggive-progress-bar.js +68 -76
  117. package/dist/collection/components/biggive-quote/biggive-quote.css +20 -0
  118. package/dist/collection/components/biggive-quote/biggive-quote.js +85 -93
  119. package/dist/collection/components/biggive-search/biggive-search.css +20 -0
  120. package/dist/collection/components/biggive-search/biggive-search.js +74 -74
  121. package/dist/collection/components/biggive-social-icon/biggive-social-icon.css +20 -0
  122. package/dist/collection/components/biggive-social-icon/biggive-social-icon.js +85 -94
  123. package/dist/collection/components/biggive-tab/biggive-tab.css +20 -0
  124. package/dist/collection/components/biggive-tab/biggive-tab.js +34 -34
  125. package/dist/collection/components/biggive-tabbed-content/biggive-tabbed-content.css +20 -0
  126. package/dist/collection/components/biggive-tabbed-content/biggive-tabbed-content.js +51 -52
  127. package/dist/collection/components/biggive-totalizer/biggive-totalizer.css +29 -1
  128. package/dist/collection/components/biggive-totalizer/biggive-totalizer.js +178 -208
  129. package/dist/collection/components/biggive-video/biggive-video.css +20 -0
  130. package/dist/collection/components/biggive-video/biggive-video.js +68 -72
  131. package/dist/collection/components/biggive-video-feature/biggive-video-feature.css +39 -5
  132. package/dist/collection/components/biggive-video-feature/biggive-video-feature.js +238 -278
  133. package/dist/components/biggive-article-card.js +1 -34
  134. package/dist/components/biggive-back-to-top.js +1 -1
  135. package/dist/components/biggive-basic-card.js +1 -34
  136. package/dist/components/biggive-beneficiary-icon.js +1 -16
  137. package/dist/components/biggive-boxed-content.js +1 -16
  138. package/dist/components/biggive-branded-image.js +1 -13
  139. package/dist/components/biggive-button2.js +2 -23
  140. package/dist/components/biggive-call-to-action.js +1 -61
  141. package/dist/components/biggive-campaign-card-filter-grid.js +55 -22
  142. package/dist/components/biggive-campaign-card.js +2 -49
  143. package/dist/components/biggive-campaign-highlights.js +1 -40
  144. package/dist/components/biggive-category-icon.js +1 -16
  145. package/dist/components/biggive-footer.js +4 -10
  146. package/dist/components/biggive-form-field-select-option.d.ts +11 -0
  147. package/dist/components/biggive-form-field-select-option.js +6 -0
  148. package/dist/components/biggive-form-field-select-option2.js +46 -0
  149. package/dist/components/biggive-form-field-select.js +1 -28
  150. package/dist/components/biggive-form-field-select2.js +44 -0
  151. package/dist/components/biggive-formatted-text.js +1 -7
  152. package/dist/components/biggive-grid.js +1 -10
  153. package/dist/components/biggive-header.js +13 -8
  154. package/dist/components/biggive-heading.js +1 -22
  155. package/dist/components/biggive-hero-image.js +1 -40
  156. package/dist/components/biggive-icon-group.js +1 -7
  157. package/dist/components/biggive-image-feature.js +1 -37
  158. package/dist/components/biggive-image.js +1 -19
  159. package/dist/components/biggive-misc-icon2.js +1 -13
  160. package/dist/components/biggive-page-column.js +1 -1
  161. package/dist/components/biggive-page-columns.js +1 -4
  162. package/dist/components/biggive-page-section.js +1 -13
  163. package/dist/components/biggive-popup.d.ts +11 -0
  164. package/dist/components/biggive-popup.js +6 -0
  165. package/dist/components/biggive-popup2.js +41 -0
  166. package/dist/components/biggive-progress-bar2.js +1 -10
  167. package/dist/components/biggive-quote.js +1 -13
  168. package/dist/components/biggive-search.js +5 -3
  169. package/dist/components/biggive-social-icon.js +41 -1
  170. package/dist/components/biggive-tab.js +1 -4
  171. package/dist/components/biggive-tabbed-content.js +1 -7
  172. package/dist/components/biggive-totalizer.js +1 -28
  173. package/dist/components/biggive-video-feature.js +1 -40
  174. package/dist/components/biggive-video.js +1 -10
  175. package/dist/components/fontawesome-icons.js +11 -21
  176. package/dist/components/index.d.ts +2 -0
  177. package/dist/components/index.js +2 -0
  178. package/dist/components/index2.js +164 -0
  179. package/dist/esm/biggive-article-card.entry.js +2 -35
  180. package/dist/esm/biggive-back-to-top_23.entry.js +599 -0
  181. package/dist/esm/biggive-basic-card.entry.js +2 -35
  182. package/dist/esm/biggive-beneficiary-icon.entry.js +4 -19
  183. package/dist/esm/biggive-boxed-content.entry.js +2 -17
  184. package/dist/esm/biggive-branded-image.entry.js +2 -14
  185. package/dist/esm/biggive-category-icon.entry.js +4 -19
  186. package/dist/esm/biggive-form.entry.js +1 -1
  187. package/dist/esm/biggive-formatted-text.entry.js +2 -8
  188. package/dist/esm/biggive-icon-group.entry.js +2 -8
  189. package/dist/esm/biggive-image.entry.js +2 -20
  190. package/dist/esm/biggive-quote.entry.js +2 -14
  191. package/dist/esm/biggive-search.entry.js +6 -4
  192. package/dist/esm/biggive-tab.entry.js +2 -5
  193. package/dist/esm/biggive-tabbed-content.entry.js +2 -8
  194. package/dist/esm/biggive-text-input.entry.js +1 -1
  195. package/dist/esm/biggive-video.entry.js +2 -11
  196. package/dist/esm/biggive.js +3 -3
  197. package/dist/esm/{fontawesome-icons-562459be.js → fontawesome-icons-ff9155ca.js} +11 -21
  198. package/dist/esm/index-7cfe62c2.js +164 -0
  199. package/dist/esm/{index-4395d470.js → index-b3c47751.js} +734 -495
  200. package/dist/esm/loader.js +3 -3
  201. package/dist/esm/polyfills/css-shim.js +1 -1
  202. package/dist/types/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.d.ts +2 -6
  203. package/dist/types/components/biggive-form-field-select/biggive-form-field-select.d.ts +17 -0
  204. package/dist/types/components/biggive-form-field-select/biggive-form-field-select.stories.d.ts +5 -0
  205. package/dist/types/components/biggive-form-field-select-option/biggive-form-field-select-option.d.ts +20 -0
  206. package/dist/types/components/biggive-form-field-select-option/biggive-form-field-select-option.stories.d.ts +13 -0
  207. package/dist/types/components/biggive-header/biggive-header.d.ts +1 -0
  208. package/dist/types/components/biggive-popup/biggive-popup.d.ts +6 -0
  209. package/dist/types/components/biggive-popup/biggive-popup.stories.d.ts +5 -0
  210. package/dist/types/components.d.ts +73 -6
  211. package/dist/types/stencil-public-runtime.d.ts +20 -4
  212. package/hydrate/index.d.ts +1 -1
  213. package/hydrate/index.js +1133 -1561
  214. package/loader/package.json +1 -0
  215. package/package.json +4 -2
  216. package/dist/biggive/p-10ba977a.entry.js +0 -1
  217. package/dist/biggive/p-114fac7c.entry.js +0 -1
  218. package/dist/biggive/p-1788f27c.entry.js +0 -1
  219. package/dist/biggive/p-1805f9ab.js +0 -2
  220. package/dist/biggive/p-1bf2e39d.entry.js +0 -1
  221. package/dist/biggive/p-26de9586.entry.js +0 -1
  222. package/dist/biggive/p-3116f3df.entry.js +0 -1
  223. package/dist/biggive/p-4368caaa.entry.js +0 -1
  224. package/dist/biggive/p-512c15ed.entry.js +0 -1
  225. package/dist/biggive/p-78406754.entry.js +0 -1
  226. package/dist/biggive/p-871707f4.js +0 -6
  227. package/dist/biggive/p-9125d753.entry.js +0 -1
  228. package/dist/biggive/p-96ddb8d1.entry.js +0 -1
  229. package/dist/biggive/p-a423663d.entry.js +0 -1
  230. package/dist/biggive/p-afde0b4b.entry.js +0 -1
  231. package/dist/biggive/p-b15292fe.entry.js +0 -1
  232. package/dist/biggive/p-ec9b42b3.js +0 -6
  233. package/dist/biggive/p-faa619ad.entry.js +0 -1
  234. package/dist/biggive/p-faa6817c.entry.js +0 -1
  235. package/dist/biggive/p-fb8447d1.entry.js +0 -1
  236. package/dist/cjs/biggive-back-to-top_20.cjs.entry.js +0 -923
  237. package/dist/cjs/biggive-form-field-select.cjs.entry.js +0 -19
  238. package/dist/cjs/index.es-d3570170.js +0 -201
  239. package/dist/components/biggive-social-icon2.js +0 -55
  240. package/dist/components/index.es.js +0 -169
  241. package/dist/esm/biggive-back-to-top_20.entry.js +0 -900
  242. package/dist/esm/biggive-form-field-select.entry.js +0 -15
  243. package/dist/esm/index.es-5777380a.js +0 -169
@@ -22,40 +22,22 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'biggive';
24
24
 
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
25
33
  let scopeId;
26
34
  let hostTagName;
27
35
  let isSvgMode = false;
28
36
  let queuePending = false;
29
- const win = typeof window !== 'undefined' ? window : {};
30
- const doc = win.document || { head: {} };
31
- const plt = {
32
- $flags$: 0,
33
- $resourcesUrl$: '',
34
- jmp: (h) => h(),
35
- raf: (h) => requestAnimationFrame(h),
36
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
37
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
38
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
37
+ const getAssetPath = (path) => {
38
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
39
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
39
40
  };
40
- const supportsShadow = true;
41
- const promiseResolve = (v) => Promise.resolve(v);
42
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
43
- try {
44
- new CSSStyleSheet();
45
- return typeof new CSSStyleSheet().replaceSync === 'function';
46
- }
47
- catch (e) { }
48
- return false;
49
- })()
50
- ;
51
- const CONTENT_REF_ID = 'r';
52
- const ORG_LOCATION_ID = 'o';
53
- const SLOT_NODE_ID = 's';
54
- const TEXT_NODE_ID = 't';
55
- const HYDRATE_ID = 's-id';
56
- const HYDRATED_STYLE_ID = 'sty-id';
57
- const HYDRATE_CHILD_ID = 'c-id';
58
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
59
41
  const createTime = (fnName, tagName = '') => {
60
42
  {
61
43
  return () => {
@@ -70,82 +52,14 @@ const uniqueTime = (key, measureText) => {
70
52
  };
71
53
  }
72
54
  };
73
- const rootAppliedStyles = new WeakMap();
74
- const registerStyle = (scopeId, cssText, allowCS) => {
75
- let style = styles.get(scopeId);
76
- if (supportsConstructableStylesheets && allowCS) {
77
- style = (style || new CSSStyleSheet());
78
- if (typeof style === 'string') {
79
- style = cssText;
80
- }
81
- else {
82
- style.replaceSync(cssText);
83
- }
84
- }
85
- else {
86
- style = cssText;
87
- }
88
- styles.set(scopeId, style);
89
- };
90
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
91
- let scopeId = getScopeId(cmpMeta);
92
- const style = styles.get(scopeId);
93
- // if an element is NOT connected then getRootNode() will return the wrong root node
94
- // so the fallback is to always use the document for the root node in those cases
95
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
96
- if (style) {
97
- if (typeof style === 'string') {
98
- styleContainerNode = styleContainerNode.head || styleContainerNode;
99
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
100
- let styleElm;
101
- if (!appliedStyles) {
102
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
103
- }
104
- if (!appliedStyles.has(scopeId)) {
105
- if (styleContainerNode.host &&
106
- (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
107
- // This is only happening on native shadow-dom, do not needs CSS var shim
108
- styleElm.innerHTML = style;
109
- }
110
- else {
111
- {
112
- styleElm = doc.createElement('style');
113
- styleElm.innerHTML = style;
114
- }
115
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
116
- }
117
- if (appliedStyles) {
118
- appliedStyles.add(scopeId);
119
- }
120
- }
121
- }
122
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
123
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
124
- }
125
- }
126
- return scopeId;
127
- };
128
- const attachStyles = (hostRef) => {
129
- const cmpMeta = hostRef.$cmpMeta$;
130
- const elm = hostRef.$hostElement$;
131
- const flags = cmpMeta.$flags$;
132
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
133
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
134
- if (flags & 10 /* needsScopedEncapsulation */) {
135
- // only required when we're NOT using native shadow dom (slot)
136
- // or this browser doesn't support native shadow dom
137
- // and this host element was NOT created with SSR
138
- // let's pick out the inner content for slot projection
139
- // create a node to represent where the original
140
- // content was first placed, which is useful later on
141
- // DOM WRITE!!
142
- elm['s-sc'] = scopeId;
143
- elm.classList.add(scopeId + '-h');
144
- }
145
- endAttachStyles();
146
- };
147
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
148
- const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
55
+ const CONTENT_REF_ID = 'r';
56
+ const ORG_LOCATION_ID = 'o';
57
+ const SLOT_NODE_ID = 's';
58
+ const TEXT_NODE_ID = 't';
59
+ const HYDRATE_ID = 's-id';
60
+ const HYDRATED_STYLE_ID = 'sty-id';
61
+ const HYDRATE_CHILD_ID = 'c-id';
62
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
149
63
  /**
150
64
  * Default style mode id
151
65
  */
@@ -261,18 +175,368 @@ const convertToPrivate = (node) => {
261
175
  if (node.vkey) {
262
176
  vnodeData.key = node.vkey;
263
177
  }
264
- if (node.vname) {
265
- vnodeData.name = node.vname;
178
+ if (node.vname) {
179
+ vnodeData.name = node.vname;
180
+ }
181
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
182
+ }
183
+ const vnode = newVNode(node.vtag, node.vtext);
184
+ vnode.$attrs$ = node.vattrs;
185
+ vnode.$children$ = node.vchildren;
186
+ vnode.$key$ = node.vkey;
187
+ vnode.$name$ = node.vname;
188
+ return vnode;
189
+ };
190
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
191
+ const endHydrate = createTime('hydrateClient', tagName);
192
+ const shadowRoot = hostElm.shadowRoot;
193
+ const childRenderNodes = [];
194
+ const slotNodes = [];
195
+ const shadowRootNodes = shadowRoot ? [] : null;
196
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
197
+ if (!plt.$orgLocNodes$) {
198
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
199
+ }
200
+ hostElm[HYDRATE_ID] = hostId;
201
+ hostElm.removeAttribute(HYDRATE_ID);
202
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
203
+ childRenderNodes.map((c) => {
204
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
205
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
206
+ const node = c.$elm$;
207
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
208
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
209
+ }
210
+ if (!shadowRoot) {
211
+ node['s-hn'] = tagName;
212
+ if (orgLocationNode) {
213
+ node['s-ol'] = orgLocationNode;
214
+ node['s-ol']['s-nr'] = node;
215
+ }
216
+ }
217
+ plt.$orgLocNodes$.delete(orgLocationId);
218
+ });
219
+ if (shadowRoot) {
220
+ shadowRootNodes.map((shadowRootNode) => {
221
+ if (shadowRootNode) {
222
+ shadowRoot.appendChild(shadowRootNode);
223
+ }
224
+ });
225
+ }
226
+ endHydrate();
227
+ };
228
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
229
+ let childNodeType;
230
+ let childIdSplt;
231
+ let childVNode;
232
+ let i;
233
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
234
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
235
+ if (childNodeType) {
236
+ // got the node data from the element's attribute
237
+ // `${hostId}.${nodeId}.${depth}.${index}`
238
+ childIdSplt = childNodeType.split('.');
239
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
240
+ childVNode = {
241
+ $flags$: 0,
242
+ $hostId$: childIdSplt[0],
243
+ $nodeId$: childIdSplt[1],
244
+ $depth$: childIdSplt[2],
245
+ $index$: childIdSplt[3],
246
+ $tag$: node.tagName.toLowerCase(),
247
+ $elm$: node,
248
+ $attrs$: null,
249
+ $children$: null,
250
+ $key$: null,
251
+ $name$: null,
252
+ $text$: null,
253
+ };
254
+ childRenderNodes.push(childVNode);
255
+ node.removeAttribute(HYDRATE_CHILD_ID);
256
+ // this is a new child vnode
257
+ // so ensure its parent vnode has the vchildren array
258
+ if (!parentVNode.$children$) {
259
+ parentVNode.$children$ = [];
260
+ }
261
+ // add our child vnode to a specific index of the vnode's children
262
+ parentVNode.$children$[childVNode.$index$] = childVNode;
263
+ // this is now the new parent vnode for all the next child checks
264
+ parentVNode = childVNode;
265
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
266
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
267
+ }
268
+ }
269
+ }
270
+ // recursively drill down, end to start so we can remove nodes
271
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
272
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
273
+ }
274
+ if (node.shadowRoot) {
275
+ // keep drilling down through the shadow root nodes
276
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
277
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
278
+ }
279
+ }
280
+ }
281
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
282
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
283
+ childIdSplt = node.nodeValue.split('.');
284
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
285
+ // comment node for either the host id or a 0 host id
286
+ childNodeType = childIdSplt[0];
287
+ childVNode = {
288
+ $flags$: 0,
289
+ $hostId$: childIdSplt[1],
290
+ $nodeId$: childIdSplt[2],
291
+ $depth$: childIdSplt[3],
292
+ $index$: childIdSplt[4],
293
+ $elm$: node,
294
+ $attrs$: null,
295
+ $children$: null,
296
+ $key$: null,
297
+ $name$: null,
298
+ $tag$: null,
299
+ $text$: null,
300
+ };
301
+ if (childNodeType === TEXT_NODE_ID) {
302
+ childVNode.$elm$ = node.nextSibling;
303
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
304
+ childVNode.$text$ = childVNode.$elm$.textContent;
305
+ childRenderNodes.push(childVNode);
306
+ // remove the text comment since it's no longer needed
307
+ node.remove();
308
+ if (!parentVNode.$children$) {
309
+ parentVNode.$children$ = [];
310
+ }
311
+ parentVNode.$children$[childVNode.$index$] = childVNode;
312
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
313
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
314
+ }
315
+ }
316
+ }
317
+ else if (childVNode.$hostId$ === hostId) {
318
+ // this comment node is specifcally for this host id
319
+ if (childNodeType === SLOT_NODE_ID) {
320
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
321
+ childVNode.$tag$ = 'slot';
322
+ if (childIdSplt[5]) {
323
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
324
+ }
325
+ else {
326
+ node['s-sn'] = '';
327
+ }
328
+ node['s-sr'] = true;
329
+ if (shadowRootNodes) {
330
+ // browser support shadowRoot and this is a shadow dom component
331
+ // create an actual slot element
332
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
333
+ if (childVNode.$name$) {
334
+ // add the slot name attribute
335
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
336
+ }
337
+ // insert the new slot element before the slot comment
338
+ node.parentNode.insertBefore(childVNode.$elm$, node);
339
+ // remove the slot comment since it's not needed for shadow
340
+ node.remove();
341
+ if (childVNode.$depth$ === '0') {
342
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
343
+ }
344
+ }
345
+ slotNodes.push(childVNode);
346
+ if (!parentVNode.$children$) {
347
+ parentVNode.$children$ = [];
348
+ }
349
+ parentVNode.$children$[childVNode.$index$] = childVNode;
350
+ }
351
+ else if (childNodeType === CONTENT_REF_ID) {
352
+ // `${CONTENT_REF_ID}.${hostId}`;
353
+ if (shadowRootNodes) {
354
+ // remove the content ref comment since it's not needed for shadow
355
+ node.remove();
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
362
+ const vnode = newVNode(null, node.textContent);
363
+ vnode.$elm$ = node;
364
+ vnode.$index$ = '0';
365
+ parentVNode.$children$ = [vnode];
366
+ }
367
+ };
368
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
369
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
370
+ let i = 0;
371
+ for (; i < node.childNodes.length; i++) {
372
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
373
+ }
374
+ if (node.shadowRoot) {
375
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
376
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
377
+ }
378
+ }
379
+ }
380
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
381
+ const childIdSplt = node.nodeValue.split('.');
382
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
383
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
384
+ node.nodeValue = '';
385
+ // useful to know if the original location is
386
+ // the root light-dom of a shadow dom component
387
+ node['s-en'] = childIdSplt[3];
388
+ }
389
+ }
390
+ };
391
+ /**
392
+ * Parse a new property value for a given property type.
393
+ *
394
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
395
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
396
+ * 1. `any`, the type given to `propValue` in the function signature
397
+ * 2. the type stored from `propType`.
398
+ *
399
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
400
+ *
401
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
402
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
403
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
404
+ * ```tsx
405
+ * <my-cmp prop-val={0}></my-cmp>
406
+ * ```
407
+ *
408
+ * HTML prop values on the other hand, will always a string
409
+ *
410
+ * @param propValue the new value to coerce to some type
411
+ * @param propType the type of the prop, expressed as a binary number
412
+ * @returns the parsed/coerced value
413
+ */
414
+ const parsePropertyValue = (propValue, propType) => {
415
+ // ensure this value is of the correct prop type
416
+ if (propValue != null && !isComplexType(propValue)) {
417
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
418
+ // per the HTML spec, any string value means it is a boolean true value
419
+ // but we'll cheat here and say that the string "false" is the boolean false
420
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
421
+ }
422
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
423
+ // force it to be a number
424
+ return parseFloat(propValue);
425
+ }
426
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
427
+ // could have been passed as a number or boolean
428
+ // but we still want it as a string
429
+ return String(propValue);
430
+ }
431
+ // redundant return here for better minification
432
+ return propValue;
433
+ }
434
+ // not sure exactly what type we want
435
+ // so no need to change to a different type
436
+ return propValue;
437
+ };
438
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
439
+ const createEvent = (ref, name, flags) => {
440
+ const elm = getElement(ref);
441
+ return {
442
+ emit: (detail) => {
443
+ return emitEvent(elm, name, {
444
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
445
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
446
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
447
+ detail,
448
+ });
449
+ },
450
+ };
451
+ };
452
+ /**
453
+ * Helper function to create & dispatch a custom Event on a provided target
454
+ * @param elm the target of the Event
455
+ * @param name the name to give the custom Event
456
+ * @param opts options for configuring a custom Event
457
+ * @returns the custom Event
458
+ */
459
+ const emitEvent = (elm, name, opts) => {
460
+ const ev = plt.ce(name, opts);
461
+ elm.dispatchEvent(ev);
462
+ return ev;
463
+ };
464
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
465
+ const registerStyle = (scopeId, cssText, allowCS) => {
466
+ let style = styles.get(scopeId);
467
+ if (supportsConstructableStylesheets && allowCS) {
468
+ style = (style || new CSSStyleSheet());
469
+ if (typeof style === 'string') {
470
+ style = cssText;
471
+ }
472
+ else {
473
+ style.replaceSync(cssText);
474
+ }
475
+ }
476
+ else {
477
+ style = cssText;
478
+ }
479
+ styles.set(scopeId, style);
480
+ };
481
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
482
+ let scopeId = getScopeId(cmpMeta);
483
+ const style = styles.get(scopeId);
484
+ // if an element is NOT connected then getRootNode() will return the wrong root node
485
+ // so the fallback is to always use the document for the root node in those cases
486
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
487
+ if (style) {
488
+ if (typeof style === 'string') {
489
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
490
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
491
+ let styleElm;
492
+ if (!appliedStyles) {
493
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
494
+ }
495
+ if (!appliedStyles.has(scopeId)) {
496
+ if (styleContainerNode.host &&
497
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
498
+ // This is only happening on native shadow-dom, do not needs CSS var shim
499
+ styleElm.innerHTML = style;
500
+ }
501
+ else {
502
+ {
503
+ styleElm = doc.createElement('style');
504
+ styleElm.innerHTML = style;
505
+ }
506
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
507
+ }
508
+ if (appliedStyles) {
509
+ appliedStyles.add(scopeId);
510
+ }
511
+ }
512
+ }
513
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
514
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
266
515
  }
267
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
268
516
  }
269
- const vnode = newVNode(node.vtag, node.vtext);
270
- vnode.$attrs$ = node.vattrs;
271
- vnode.$children$ = node.vchildren;
272
- vnode.$key$ = node.vkey;
273
- vnode.$name$ = node.vname;
274
- return vnode;
517
+ return scopeId;
518
+ };
519
+ const attachStyles = (hostRef) => {
520
+ const cmpMeta = hostRef.$cmpMeta$;
521
+ const elm = hostRef.$hostElement$;
522
+ const flags = cmpMeta.$flags$;
523
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
524
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
525
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
526
+ // only required when we're NOT using native shadow dom (slot)
527
+ // or this browser doesn't support native shadow dom
528
+ // and this host element was NOT created with SSR
529
+ // let's pick out the inner content for slot projection
530
+ // create a node to represent where the original
531
+ // content was first placed, which is useful later on
532
+ // DOM WRITE!!
533
+ elm['s-sc'] = scopeId;
534
+ elm.classList.add(scopeId + '-h');
535
+ }
536
+ endAttachStyles();
275
537
  };
538
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
539
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
276
540
  /**
277
541
  * Production setAccessor() function based on Preact by
278
542
  * Jason Miller (@developit)
@@ -384,7 +648,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
384
648
  }
385
649
  }
386
650
  }
387
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
651
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
388
652
  newValue = newValue === true ? '' : newValue;
389
653
  {
390
654
  elm.setAttribute(memberName, newValue);
@@ -399,7 +663,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
399
663
  // if the element passed in is a shadow root, which is a document fragment
400
664
  // then we want to be adding attrs/props to the shadow root's "host" element
401
665
  // if it's not a shadow root, then we add attrs/props to the same element
402
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
666
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
403
667
  ? newVnode.$elm$.host
404
668
  : newVnode.$elm$;
405
669
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -417,6 +681,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
417
681
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
418
682
  }
419
683
  };
684
+ /**
685
+ * Create a DOM Node corresponding to one of the children of a given VNode.
686
+ *
687
+ * @param oldParentVNode the parent VNode from the previous render
688
+ * @param newParentVNode the parent VNode from the current render
689
+ * @param childIndex the index of the VNode, in the _new_ parent node's
690
+ * children, for which we will create a new DOM node
691
+ * @param parentElm the parent DOM node which our new node will be a child of
692
+ * @returns the newly created node
693
+ */
420
694
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
421
695
  // tslint:disable-next-line: prefer-const
422
696
  const newVNode = newParentVNode.$children$[childIndex];
@@ -495,6 +769,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
495
769
  }
496
770
  }
497
771
  };
772
+ /**
773
+ * Reconcile the children of a new VNode with the children of an old VNode by
774
+ * traversing the two collections of children, identifying nodes that are
775
+ * conserved or changed, calling out to `patch` to make any necessary
776
+ * updates to the DOM, and rearranging DOM nodes as needed.
777
+ *
778
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
779
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
780
+ * 'windows' by storing start and end indices and references to the
781
+ * corresponding array entries. Initially the two 'windows' are basically equal
782
+ * to the entire array, but we progressively narrow the windows until there are
783
+ * no children left to update by doing the following:
784
+ *
785
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
786
+ * that if we have an initial array like the following we'll end up dealing
787
+ * only with a window bounded by the highlighted elements:
788
+ *
789
+ * [null, null, VNode1 , ... , VNode2, null, null]
790
+ * ^^^^^^ ^^^^^^
791
+ *
792
+ * 2. Check to see if the elements at the head and tail positions are equal
793
+ * across the windows. This will basically detect elements which haven't
794
+ * been added, removed, or changed position, i.e. if you had the following
795
+ * VNode elements (represented as HTML):
796
+ *
797
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
798
+ * newVNode: `<div><p><span>THERE</span></p></div>`
799
+ *
800
+ * Then when comparing the children of the `<div>` tag we check the equality
801
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
802
+ * same tag in the same position, we'd be able to avoid completely
803
+ * re-rendering the subtree under them with a new DOM element and would just
804
+ * call out to `patch` to handle reconciling their children and so on.
805
+ *
806
+ * 3. Check, for both windows, to see if the element at the beginning of the
807
+ * window corresponds to the element at the end of the other window. This is
808
+ * a heuristic which will let us identify _some_ situations in which
809
+ * elements have changed position, for instance it _should_ detect that the
810
+ * children nodes themselves have not changed but merely moved in the
811
+ * following example:
812
+ *
813
+ * oldVNode: `<div><element-one /><element-two /></div>`
814
+ * newVNode: `<div><element-two /><element-one /></div>`
815
+ *
816
+ * If we find cases like this then we also need to move the concrete DOM
817
+ * elements corresponding to the moved children to write the re-order to the
818
+ * DOM.
819
+ *
820
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
821
+ * nodes in the old children which have the same key as the first element in
822
+ * our window on the new children. If we find such a node we handle calling
823
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
824
+ * what we find.
825
+ *
826
+ * Finally, once we've narrowed our 'windows' to the point that either of them
827
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
828
+ * insertion or deletion that needs to happen to get a DOM state that correctly
829
+ * reflects the new child VNodes. If, for instance, after our window on the old
830
+ * children has collapsed we still have more nodes on the new children that
831
+ * we haven't dealt with yet then we need to add them, or if the new children
832
+ * collapse but we still have unhandled _old_ children then we need to make
833
+ * sure the corresponding DOM nodes are removed.
834
+ *
835
+ * @param parentElm the node into which the parent VNode is rendered
836
+ * @param oldCh the old children of the parent node
837
+ * @param newVNode the new VNode which will replace the parent
838
+ * @param newCh the new children of the parent node
839
+ */
498
840
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
499
841
  let oldStartIdx = 0;
500
842
  let newStartIdx = 0;
@@ -507,7 +849,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
507
849
  let node;
508
850
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
509
851
  if (oldStartVnode == null) {
510
- // Vnode might have been moved left
852
+ // VNode might have been moved left
511
853
  oldStartVnode = oldCh[++oldStartIdx];
512
854
  }
513
855
  else if (oldEndVnode == null) {
@@ -520,34 +862,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
520
862
  newEndVnode = newCh[--newEndIdx];
521
863
  }
522
864
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
865
+ // if the start nodes are the same then we should patch the new VNode
866
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
867
+ // indices to reflect that. We don't need to move any DOM Nodes around
868
+ // since things are matched up in order.
523
869
  patch(oldStartVnode, newStartVnode);
524
870
  oldStartVnode = oldCh[++oldStartIdx];
525
871
  newStartVnode = newCh[++newStartIdx];
526
872
  }
527
873
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
874
+ // likewise, if the end nodes are the same we patch new onto old and
875
+ // decrement our end indices, and also likewise in this case we don't
876
+ // need to move any DOM Nodes.
528
877
  patch(oldEndVnode, newEndVnode);
529
878
  oldEndVnode = oldCh[--oldEndIdx];
530
879
  newEndVnode = newCh[--newEndIdx];
531
880
  }
532
881
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
533
882
  patch(oldStartVnode, newEndVnode);
883
+ // We need to move the element for `oldStartVnode` into a position which
884
+ // will be appropriate for `newEndVnode`. For this we can use
885
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
886
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
887
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
888
+ //
889
+ // <old-start-node />
890
+ // <some-intervening-node />
891
+ // <old-end-node />
892
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
893
+ // <next-sibling />
894
+ //
895
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
896
+ // the node for `oldStartVnode` at the end of the children of
897
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
898
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
899
+ // append it to the children of the parent element.
534
900
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
535
901
  oldStartVnode = oldCh[++oldStartIdx];
536
902
  newEndVnode = newCh[--newEndIdx];
537
903
  }
538
904
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
539
905
  patch(oldEndVnode, newStartVnode);
906
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
907
+ // the same node, so since we're here we know that they are not. Thus we
908
+ // can move the element for `oldEndVnode` _before_ the element for
909
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
910
+ // future.
540
911
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
541
912
  oldEndVnode = oldCh[--oldEndIdx];
542
913
  newStartVnode = newCh[++newStartIdx];
543
914
  }
544
915
  else {
545
916
  {
546
- // new element
917
+ // We either didn't find an element in the old children that matches
918
+ // the key of the first new child OR the build is not using `key`
919
+ // attributes at all. In either case we need to create a new element
920
+ // for the new node.
547
921
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
548
922
  newStartVnode = newCh[++newStartIdx];
549
923
  }
550
924
  if (node) {
925
+ // if we created a new node then handle inserting it to the DOM
551
926
  {
552
927
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
553
928
  }
@@ -555,20 +930,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
555
930
  }
556
931
  }
557
932
  if (oldStartIdx > oldEndIdx) {
933
+ // we have some more new nodes to add which don't match up with old nodes
558
934
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
559
935
  }
560
936
  else if (newStartIdx > newEndIdx) {
937
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
938
+ // in the new array, so lets remove them (which entails cleaning up the
939
+ // relevant DOM nodes)
561
940
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
562
941
  }
563
942
  };
564
- const isSameVnode = (vnode1, vnode2) => {
943
+ /**
944
+ * Compare two VNodes to determine if they are the same
945
+ *
946
+ * **NB**: This function is an equality _heuristic_ based on the available
947
+ * information set on the two VNodes and can be misleading under certain
948
+ * circumstances. In particular, if the two nodes do not have `key` attrs
949
+ * (available under `$key$` on VNodes) then the function falls back on merely
950
+ * checking that they have the same tag.
951
+ *
952
+ * So, in other words, if `key` attrs are not set on VNodes which may be
953
+ * changing order within a `children` array or something along those lines then
954
+ * we could obtain a false positive and then have to do needless re-rendering.
955
+ *
956
+ * @param leftVNode the first VNode to check
957
+ * @param rightVNode the second VNode to check
958
+ * @returns whether they're equal or not
959
+ */
960
+ const isSameVnode = (leftVNode, rightVNode) => {
565
961
  // compare if two vnode to see if they're "technically" the same
566
962
  // need to have the same element tag, and same key to be the same
567
- if (vnode1.$tag$ === vnode2.$tag$) {
963
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
568
964
  return true;
569
965
  }
570
966
  return false;
571
967
  };
968
+ /**
969
+ * Handle reconciling an outdated VNode with a new one which corresponds to
970
+ * it. This function handles flushing updates to the DOM and reconciling the
971
+ * children of the two nodes (if any).
972
+ *
973
+ * @param oldVNode an old VNode whose DOM element and children we want to update
974
+ * @param newVNode a new VNode representing an updated version of the old one
975
+ */
572
976
  const patch = (oldVNode, newVNode) => {
573
977
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
574
978
  const oldChildren = oldVNode.$children$;
@@ -581,7 +985,6 @@ const patch = (oldVNode, newVNode) => {
581
985
  // only add this to the when the compiler sees we're using an svg somewhere
582
986
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
583
987
  }
584
- // element node
585
988
  {
586
989
  if (tag === 'slot')
587
990
  ;
@@ -594,6 +997,7 @@ const patch = (oldVNode, newVNode) => {
594
997
  }
595
998
  if (oldChildren !== null && newChildren !== null) {
596
999
  // looks like there's child vnodes for both the old and new vnodes
1000
+ // so we need to call `updateChildren` to reconcile them
597
1001
  updateChildren(elm, oldChildren, newVNode, newChildren);
598
1002
  }
599
1003
  else if (newChildren !== null) {
@@ -625,7 +1029,7 @@ const renderVdom = (hostRef, renderFnResults) => {
625
1029
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
626
1030
  hostTagName = hostElm.tagName;
627
1031
  rootVnode.$tag$ = null;
628
- rootVnode.$flags$ |= 4 /* isHost */;
1032
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
629
1033
  hostRef.$vnode$ = rootVnode;
630
1034
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
631
1035
  {
@@ -634,32 +1038,6 @@ const renderVdom = (hostRef, renderFnResults) => {
634
1038
  // synchronous patch
635
1039
  patch(oldVNode, rootVnode);
636
1040
  };
637
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
638
- const createEvent = (ref, name, flags) => {
639
- const elm = getElement(ref);
640
- return {
641
- emit: (detail) => {
642
- return emitEvent(elm, name, {
643
- bubbles: !!(flags & 4 /* Bubbles */),
644
- composed: !!(flags & 2 /* Composed */),
645
- cancelable: !!(flags & 1 /* Cancellable */),
646
- detail,
647
- });
648
- },
649
- };
650
- };
651
- /**
652
- * Helper function to create & dispatch a custom Event on a provided target
653
- * @param elm the target of the Event
654
- * @param name the name to give the custom Event
655
- * @param opts options for configuring a custom Event
656
- * @returns the custom Event
657
- */
658
- const emitEvent = (elm, name, opts) => {
659
- const ev = plt.ce(name, opts);
660
- elm.dispatchEvent(ev);
661
- return ev;
662
- };
663
1041
  const attachToAncestor = (hostRef, ancestorComponent) => {
664
1042
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
665
1043
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -667,10 +1045,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
667
1045
  };
668
1046
  const scheduleUpdate = (hostRef, isInitialLoad) => {
669
1047
  {
670
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1048
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
671
1049
  }
672
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
673
- hostRef.$flags$ |= 512 /* needsRerender */;
1050
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1051
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
674
1052
  return;
675
1053
  }
676
1054
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -684,6 +1062,15 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
684
1062
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
685
1063
  const instance = hostRef.$lazyInstance$ ;
686
1064
  let promise;
1065
+ if (isInitialLoad) {
1066
+ {
1067
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1068
+ if (hostRef.$queuedListeners$) {
1069
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1070
+ hostRef.$queuedListeners$ = null;
1071
+ }
1072
+ }
1073
+ }
687
1074
  endSchedule();
688
1075
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
689
1076
  };
@@ -712,340 +1099,106 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
712
1099
  {
713
1100
  const childrenPromises = elm['s-p'];
714
1101
  const postUpdate = () => postUpdateComponent(hostRef);
715
- if (childrenPromises.length === 0) {
716
- postUpdate();
717
- }
718
- else {
719
- Promise.all(childrenPromises).then(postUpdate);
720
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
721
- childrenPromises.length = 0;
722
- }
723
- }
724
- };
725
- const callRender = (hostRef, instance, elm) => {
726
- try {
727
- instance = instance.render() ;
728
- {
729
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
730
- }
731
- {
732
- hostRef.$flags$ |= 2 /* hasRendered */;
733
- }
734
- {
735
- {
736
- // looks like we've got child nodes to render into this host element
737
- // or we need to update the css class/attrs on the host element
738
- // DOM WRITE!
739
- {
740
- renderVdom(hostRef, instance);
741
- }
742
- }
743
- }
744
- }
745
- catch (e) {
746
- consoleError(e, hostRef.$hostElement$);
747
- }
748
- return null;
749
- };
750
- const postUpdateComponent = (hostRef) => {
751
- const tagName = hostRef.$cmpMeta$.$tagName$;
752
- const elm = hostRef.$hostElement$;
753
- const endPostUpdate = createTime('postUpdate', tagName);
754
- const ancestorComponent = hostRef.$ancestorComponent$;
755
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
756
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
757
- {
758
- // DOM WRITE!
759
- addHydratedFlag(elm);
760
- }
761
- endPostUpdate();
762
- {
763
- hostRef.$onReadyResolve$(elm);
764
- if (!ancestorComponent) {
765
- appDidLoad();
766
- }
767
- }
768
- }
769
- else {
770
- endPostUpdate();
771
- }
772
- // load events fire from bottom to top
773
- // the deepest elements load first then bubbles up
774
- {
775
- if (hostRef.$onRenderResolve$) {
776
- hostRef.$onRenderResolve$();
777
- hostRef.$onRenderResolve$ = undefined;
778
- }
779
- if (hostRef.$flags$ & 512 /* needsRerender */) {
780
- nextTick(() => scheduleUpdate(hostRef, false));
781
- }
782
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
783
- }
784
- // ( •_•)
785
- // ( •_•)>⌐■-■
786
- // (⌐■_■)
787
- };
788
- const appDidLoad = (who) => {
789
- // on appload
790
- // we have finish the first big initial render
791
- {
792
- addHydratedFlag(doc.documentElement);
793
- }
794
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
795
- };
796
- const then = (promise, thenFn) => {
797
- return promise && promise.then ? promise.then(thenFn) : thenFn();
798
- };
799
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
800
- ;
801
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
802
- const endHydrate = createTime('hydrateClient', tagName);
803
- const shadowRoot = hostElm.shadowRoot;
804
- const childRenderNodes = [];
805
- const slotNodes = [];
806
- const shadowRootNodes = shadowRoot ? [] : null;
807
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
808
- if (!plt.$orgLocNodes$) {
809
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
810
- }
811
- hostElm[HYDRATE_ID] = hostId;
812
- hostElm.removeAttribute(HYDRATE_ID);
813
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
814
- childRenderNodes.map((c) => {
815
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
816
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
817
- const node = c.$elm$;
818
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
819
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
820
- }
821
- if (!shadowRoot) {
822
- node['s-hn'] = tagName;
823
- if (orgLocationNode) {
824
- node['s-ol'] = orgLocationNode;
825
- node['s-ol']['s-nr'] = node;
826
- }
827
- }
828
- plt.$orgLocNodes$.delete(orgLocationId);
829
- });
830
- if (shadowRoot) {
831
- shadowRootNodes.map((shadowRootNode) => {
832
- if (shadowRootNode) {
833
- shadowRoot.appendChild(shadowRootNode);
834
- }
835
- });
836
- }
837
- endHydrate();
838
- };
839
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
840
- let childNodeType;
841
- let childIdSplt;
842
- let childVNode;
843
- let i;
844
- if (node.nodeType === 1 /* ElementNode */) {
845
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
846
- if (childNodeType) {
847
- // got the node data from the element's attribute
848
- // `${hostId}.${nodeId}.${depth}.${index}`
849
- childIdSplt = childNodeType.split('.');
850
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
851
- childVNode = {
852
- $flags$: 0,
853
- $hostId$: childIdSplt[0],
854
- $nodeId$: childIdSplt[1],
855
- $depth$: childIdSplt[2],
856
- $index$: childIdSplt[3],
857
- $tag$: node.tagName.toLowerCase(),
858
- $elm$: node,
859
- $attrs$: null,
860
- $children$: null,
861
- $key$: null,
862
- $name$: null,
863
- $text$: null,
864
- };
865
- childRenderNodes.push(childVNode);
866
- node.removeAttribute(HYDRATE_CHILD_ID);
867
- // this is a new child vnode
868
- // so ensure its parent vnode has the vchildren array
869
- if (!parentVNode.$children$) {
870
- parentVNode.$children$ = [];
871
- }
872
- // add our child vnode to a specific index of the vnode's children
873
- parentVNode.$children$[childVNode.$index$] = childVNode;
874
- // this is now the new parent vnode for all the next child checks
875
- parentVNode = childVNode;
876
- if (shadowRootNodes && childVNode.$depth$ === '0') {
877
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
878
- }
879
- }
880
- }
881
- // recursively drill down, end to start so we can remove nodes
882
- for (i = node.childNodes.length - 1; i >= 0; i--) {
883
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
884
- }
885
- if (node.shadowRoot) {
886
- // keep drilling down through the shadow root nodes
887
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
888
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
889
- }
1102
+ if (childrenPromises.length === 0) {
1103
+ postUpdate();
1104
+ }
1105
+ else {
1106
+ Promise.all(childrenPromises).then(postUpdate);
1107
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1108
+ childrenPromises.length = 0;
890
1109
  }
891
1110
  }
892
- else if (node.nodeType === 8 /* CommentNode */) {
893
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
894
- childIdSplt = node.nodeValue.split('.');
895
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
896
- // comment node for either the host id or a 0 host id
897
- childNodeType = childIdSplt[0];
898
- childVNode = {
899
- $flags$: 0,
900
- $hostId$: childIdSplt[1],
901
- $nodeId$: childIdSplt[2],
902
- $depth$: childIdSplt[3],
903
- $index$: childIdSplt[4],
904
- $elm$: node,
905
- $attrs$: null,
906
- $children$: null,
907
- $key$: null,
908
- $name$: null,
909
- $tag$: null,
910
- $text$: null,
911
- };
912
- if (childNodeType === TEXT_NODE_ID) {
913
- childVNode.$elm$ = node.nextSibling;
914
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
915
- childVNode.$text$ = childVNode.$elm$.textContent;
916
- childRenderNodes.push(childVNode);
917
- // remove the text comment since it's no longer needed
918
- node.remove();
919
- if (!parentVNode.$children$) {
920
- parentVNode.$children$ = [];
921
- }
922
- parentVNode.$children$[childVNode.$index$] = childVNode;
923
- if (shadowRootNodes && childVNode.$depth$ === '0') {
924
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
925
- }
926
- }
927
- }
928
- else if (childVNode.$hostId$ === hostId) {
929
- // this comment node is specifcally for this host id
930
- if (childNodeType === SLOT_NODE_ID) {
931
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
932
- childVNode.$tag$ = 'slot';
933
- if (childIdSplt[5]) {
934
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
935
- }
936
- else {
937
- node['s-sn'] = '';
938
- }
939
- node['s-sr'] = true;
940
- if (shadowRootNodes) {
941
- // browser support shadowRoot and this is a shadow dom component
942
- // create an actual slot element
943
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
944
- if (childVNode.$name$) {
945
- // add the slot name attribute
946
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
947
- }
948
- // insert the new slot element before the slot comment
949
- node.parentNode.insertBefore(childVNode.$elm$, node);
950
- // remove the slot comment since it's not needed for shadow
951
- node.remove();
952
- if (childVNode.$depth$ === '0') {
953
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
954
- }
955
- }
956
- slotNodes.push(childVNode);
957
- if (!parentVNode.$children$) {
958
- parentVNode.$children$ = [];
959
- }
960
- parentVNode.$children$[childVNode.$index$] = childVNode;
961
- }
962
- else if (childNodeType === CONTENT_REF_ID) {
963
- // `${CONTENT_REF_ID}.${hostId}`;
964
- if (shadowRootNodes) {
965
- // remove the content ref comment since it's not needed for shadow
966
- node.remove();
967
- }
1111
+ };
1112
+ const callRender = (hostRef, instance, elm) => {
1113
+ try {
1114
+ instance = instance.render() ;
1115
+ {
1116
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1117
+ }
1118
+ {
1119
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1120
+ }
1121
+ {
1122
+ {
1123
+ // looks like we've got child nodes to render into this host element
1124
+ // or we need to update the css class/attrs on the host element
1125
+ // DOM WRITE!
1126
+ {
1127
+ renderVdom(hostRef, instance);
968
1128
  }
969
1129
  }
970
1130
  }
971
1131
  }
972
- else if (parentVNode && parentVNode.$tag$ === 'style') {
973
- const vnode = newVNode(null, node.textContent);
974
- vnode.$elm$ = node;
975
- vnode.$index$ = '0';
976
- parentVNode.$children$ = [vnode];
1132
+ catch (e) {
1133
+ consoleError(e, hostRef.$hostElement$);
977
1134
  }
1135
+ return null;
978
1136
  };
979
- const initializeDocumentHydrate = (node, orgLocNodes) => {
980
- if (node.nodeType === 1 /* ElementNode */) {
981
- let i = 0;
982
- for (; i < node.childNodes.length; i++) {
983
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1137
+ const postUpdateComponent = (hostRef) => {
1138
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1139
+ const elm = hostRef.$hostElement$;
1140
+ const endPostUpdate = createTime('postUpdate', tagName);
1141
+ const ancestorComponent = hostRef.$ancestorComponent$;
1142
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1143
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1144
+ {
1145
+ // DOM WRITE!
1146
+ addHydratedFlag(elm);
984
1147
  }
985
- if (node.shadowRoot) {
986
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
987
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1148
+ endPostUpdate();
1149
+ {
1150
+ hostRef.$onReadyResolve$(elm);
1151
+ if (!ancestorComponent) {
1152
+ appDidLoad();
988
1153
  }
989
1154
  }
990
1155
  }
991
- else if (node.nodeType === 8 /* CommentNode */) {
992
- const childIdSplt = node.nodeValue.split('.');
993
- if (childIdSplt[0] === ORG_LOCATION_ID) {
994
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
995
- node.nodeValue = '';
996
- // useful to know if the original location is
997
- // the root light-dom of a shadow dom component
998
- node['s-en'] = childIdSplt[3];
1156
+ else {
1157
+ endPostUpdate();
1158
+ }
1159
+ {
1160
+ hostRef.$onInstanceResolve$(elm);
1161
+ }
1162
+ // load events fire from bottom to top
1163
+ // the deepest elements load first then bubbles up
1164
+ {
1165
+ if (hostRef.$onRenderResolve$) {
1166
+ hostRef.$onRenderResolve$();
1167
+ hostRef.$onRenderResolve$ = undefined;
1168
+ }
1169
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1170
+ nextTick(() => scheduleUpdate(hostRef, false));
999
1171
  }
1172
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1000
1173
  }
1174
+ // ( •_•)
1175
+ // ( •_•)>⌐■-■
1176
+ // (⌐■_■)
1001
1177
  };
1002
- /**
1003
- * Parse a new property value for a given property type.
1004
- *
1005
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1006
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1007
- * 1. `any`, the type given to `propValue` in the function signature
1008
- * 2. the type stored from `propType`.
1009
- *
1010
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1011
- *
1012
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1013
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1014
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1015
- * ```tsx
1016
- * <my-cmp prop-val={0}></my-cmp>
1017
- * ```
1018
- *
1019
- * HTML prop values on the other hand, will always a string
1020
- *
1021
- * @param propValue the new value to coerce to some type
1022
- * @param propType the type of the prop, expressed as a binary number
1023
- * @returns the parsed/coerced value
1024
- */
1025
- const parsePropertyValue = (propValue, propType) => {
1026
- // ensure this value is of the correct prop type
1027
- if (propValue != null && !isComplexType(propValue)) {
1028
- if (propType & 4 /* Boolean */) {
1029
- // per the HTML spec, any string value means it is a boolean true value
1030
- // but we'll cheat here and say that the string "false" is the boolean false
1031
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1032
- }
1033
- if (propType & 2 /* Number */) {
1034
- // force it to be a number
1035
- return parseFloat(propValue);
1178
+ const appDidLoad = (who) => {
1179
+ // on appload
1180
+ // we have finish the first big initial render
1181
+ {
1182
+ addHydratedFlag(doc.documentElement);
1183
+ }
1184
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1185
+ };
1186
+ const safeCall = (instance, method, arg) => {
1187
+ if (instance && instance[method]) {
1188
+ try {
1189
+ return instance[method](arg);
1036
1190
  }
1037
- if (propType & 1 /* String */) {
1038
- // could have been passed as a number or boolean
1039
- // but we still want it as a string
1040
- return String(propValue);
1191
+ catch (e) {
1192
+ consoleError(e);
1041
1193
  }
1042
- // redundant return here for better minification
1043
- return propValue;
1044
1194
  }
1045
- // not sure exactly what type we want
1046
- // so no need to change to a different type
1047
- return propValue;
1195
+ return undefined;
1196
+ };
1197
+ const then = (promise, thenFn) => {
1198
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1048
1199
  };
1200
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1201
+ ;
1049
1202
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1050
1203
  const setValue = (ref, propName, newVal, cmpMeta) => {
1051
1204
  // check our new property value against our internal value
@@ -1057,12 +1210,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1057
1210
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1058
1211
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1059
1212
  const didValueChange = newVal !== oldVal && !areBothNaN;
1060
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1213
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1061
1214
  // gadzooks! the property's value has changed!!
1062
1215
  // set our new value!
1063
1216
  hostRef.$instanceValues$.set(propName, newVal);
1064
1217
  if (instance) {
1065
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1218
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1066
1219
  // looks like this value actually changed, so we've got work to do!
1067
1220
  // but only if we've already rendered, otherwise just chill out
1068
1221
  // queue that we need to do an update, but don't worry about queuing
@@ -1072,14 +1225,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1072
1225
  }
1073
1226
  }
1074
1227
  };
1228
+ /**
1229
+ * Attach a series of runtime constructs to a compiled Stencil component
1230
+ * constructor, including getters and setters for the `@Prop` and `@State`
1231
+ * decorators, callbacks for when attributes change, and so on.
1232
+ *
1233
+ * @param Cstr the constructor for a component that we need to process
1234
+ * @param cmpMeta metadata collected previously about the component
1235
+ * @param flags a number used to store a series of bit flags
1236
+ * @returns a reference to the same constructor passed in (but now mutated)
1237
+ */
1075
1238
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1076
1239
  if (cmpMeta.$members$) {
1077
1240
  // It's better to have a const than two Object.entries()
1078
1241
  const members = Object.entries(cmpMeta.$members$);
1079
1242
  const prototype = Cstr.prototype;
1080
1243
  members.map(([memberName, [memberFlags]]) => {
1081
- if ((memberFlags & 31 /* Prop */ ||
1082
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1244
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1245
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1083
1246
  // proxyComponent - prop
1084
1247
  Object.defineProperty(prototype, memberName, {
1085
1248
  get() {
@@ -1094,8 +1257,18 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1094
1257
  enumerable: true,
1095
1258
  });
1096
1259
  }
1260
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1261
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1262
+ // proxyComponent - method
1263
+ Object.defineProperty(prototype, memberName, {
1264
+ value(...args) {
1265
+ const ref = getHostRef(this);
1266
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1267
+ },
1268
+ });
1269
+ }
1097
1270
  });
1098
- if ((flags & 1 /* isElementConstructor */)) {
1271
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1099
1272
  const attrNameToPropName = new Map();
1100
1273
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1101
1274
  plt.jmp(() => {
@@ -1151,7 +1324,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1151
1324
  // create an array of attributes to observe
1152
1325
  // and also create a map of html attribute name to js property name
1153
1326
  Cstr.observedAttributes = members
1154
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1327
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1155
1328
  .map(([propName, m]) => {
1156
1329
  const attrName = m[1] || propName;
1157
1330
  attrNameToPropName.set(attrName, propName);
@@ -1163,10 +1336,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1163
1336
  };
1164
1337
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1165
1338
  // initializeComponent
1166
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1339
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1167
1340
  {
1168
1341
  // we haven't initialized this element yet
1169
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1342
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1170
1343
  // lazy loaded components
1171
1344
  // request the component's implementation to be
1172
1345
  // wired up with the host element
@@ -1178,7 +1351,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1178
1351
  endLoad();
1179
1352
  }
1180
1353
  if (!Cstr.isProxied) {
1181
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1354
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1182
1355
  Cstr.isProxied = true;
1183
1356
  }
1184
1357
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1186,7 +1359,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1186
1359
  // but let's keep track of when we start and stop
1187
1360
  // so that the getters/setters don't incorrectly step on data
1188
1361
  {
1189
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1362
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1190
1363
  }
1191
1364
  // construct the lazy-loaded component implementation
1192
1365
  // passing the hostRef is very important during
@@ -1199,7 +1372,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1199
1372
  consoleError(e);
1200
1373
  }
1201
1374
  {
1202
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1375
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1203
1376
  }
1204
1377
  endNewInstance();
1205
1378
  }
@@ -1209,7 +1382,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1209
1382
  const scopeId = getScopeId(cmpMeta);
1210
1383
  if (!styles.has(scopeId)) {
1211
1384
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1212
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1385
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1213
1386
  endRegisterStyles();
1214
1387
  }
1215
1388
  }
@@ -1231,18 +1404,18 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1231
1404
  }
1232
1405
  };
1233
1406
  const connectedCallback = (elm) => {
1234
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1407
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1235
1408
  const hostRef = getHostRef(elm);
1236
1409
  const cmpMeta = hostRef.$cmpMeta$;
1237
1410
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1238
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1411
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1239
1412
  // first time this component has connected
1240
- hostRef.$flags$ |= 1 /* hasConnected */;
1413
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1241
1414
  let hostId;
1242
1415
  {
1243
1416
  hostId = elm.getAttribute(HYDRATE_ID);
1244
1417
  if (hostId) {
1245
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1418
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1246
1419
  const scopeId = addStyle(elm.shadowRoot, cmpMeta);
1247
1420
  elm.classList.remove(scopeId + '-h', scopeId + '-s');
1248
1421
  }
@@ -1256,7 +1429,7 @@ const connectedCallback = (elm) => {
1256
1429
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1257
1430
  // climb up the ancestors looking for the first
1258
1431
  // component that hasn't finished its lifecycle update yet
1259
- if ((ancestorComponent.nodeType === 1 /* ElementNode */ &&
1432
+ if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1260
1433
  ancestorComponent.hasAttribute('s-id') &&
1261
1434
  ancestorComponent['s-p']) ||
1262
1435
  ancestorComponent['s-p']) {
@@ -1271,7 +1444,7 @@ const connectedCallback = (elm) => {
1271
1444
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1272
1445
  if (cmpMeta.$members$) {
1273
1446
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1274
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1447
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1275
1448
  const value = elm[memberName];
1276
1449
  delete elm[memberName];
1277
1450
  elm[memberName] = value;
@@ -1282,12 +1455,24 @@ const connectedCallback = (elm) => {
1282
1455
  initializeComponent(elm, hostRef, cmpMeta);
1283
1456
  }
1284
1457
  }
1458
+ else {
1459
+ // not the first time this has connected
1460
+ // reattach any event listeners to the host
1461
+ // since they would have been removed when disconnected
1462
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1463
+ }
1285
1464
  endConnected();
1286
1465
  }
1287
1466
  };
1288
1467
  const disconnectedCallback = (elm) => {
1289
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1290
- getHostRef(elm);
1468
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1469
+ const hostRef = getHostRef(elm);
1470
+ {
1471
+ if (hostRef.$rmListeners$) {
1472
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1473
+ hostRef.$rmListeners$ = undefined;
1474
+ }
1475
+ }
1291
1476
  }
1292
1477
  };
1293
1478
  const bootstrapLazy = (lazyBundles, options = {}) => {
@@ -1308,7 +1493,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1308
1493
  {
1309
1494
  // If the app is already hydrated there is not point to disable the
1310
1495
  // async queue. This will improve the first input delay
1311
- plt.$flags$ |= 2 /* appLoaded */;
1496
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
1312
1497
  }
1313
1498
  {
1314
1499
  for (; i < styles.length; i++) {
@@ -1326,6 +1511,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1326
1511
  {
1327
1512
  cmpMeta.$members$ = compactMeta[2];
1328
1513
  }
1514
+ {
1515
+ cmpMeta.$listeners$ = compactMeta[3];
1516
+ }
1329
1517
  const tagName = cmpMeta.$tagName$;
1330
1518
  const HostElement = class extends HTMLElement {
1331
1519
  // StencilLazyHost
@@ -1334,7 +1522,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1334
1522
  super(self);
1335
1523
  self = this;
1336
1524
  registerHost(self, cmpMeta);
1337
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1525
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1338
1526
  // this component is using shadow dom
1339
1527
  // and this browser supports shadow dom
1340
1528
  // add the read-only property "shadowRoot" to the host element
@@ -1369,7 +1557,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1369
1557
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1370
1558
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1371
1559
  cmpTags.push(tagName);
1372
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1560
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1373
1561
  }
1374
1562
  });
1375
1563
  });
@@ -1391,11 +1579,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1391
1579
  // Fallback appLoad event
1392
1580
  endBootstrap();
1393
1581
  };
1394
- const getAssetPath = (path) => {
1395
- const assetUrl = new URL(path, plt.$resourcesUrl$);
1396
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1582
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1583
+ if (listeners) {
1584
+ listeners.map(([flags, name, method]) => {
1585
+ const target = elm;
1586
+ const handler = hostListenerProxy(hostRef, method);
1587
+ const opts = hostListenerOpts(flags);
1588
+ plt.ael(target, name, handler, opts);
1589
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1590
+ });
1591
+ }
1592
+ };
1593
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1594
+ try {
1595
+ {
1596
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1597
+ // instance is ready, let's call it's member method for this event
1598
+ hostRef.$lazyInstance$[methodName](ev);
1599
+ }
1600
+ else {
1601
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1602
+ }
1603
+ }
1604
+ }
1605
+ catch (e) {
1606
+ consoleError(e);
1607
+ }
1397
1608
  };
1398
- const hostRefs = new WeakMap();
1609
+ // prettier-ignore
1610
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1611
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1399
1612
  const getHostRef = (ref) => hostRefs.get(ref);
1400
1613
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1401
1614
  const registerHost = (elm, cmpMeta) => {
@@ -1405,11 +1618,15 @@ const registerHost = (elm, cmpMeta) => {
1405
1618
  $cmpMeta$: cmpMeta,
1406
1619
  $instanceValues$: new Map(),
1407
1620
  };
1621
+ {
1622
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1623
+ }
1408
1624
  {
1409
1625
  hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1410
1626
  elm['s-p'] = [];
1411
1627
  elm['s-rc'] = [];
1412
1628
  }
1629
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1413
1630
  return hostRefs.set(elm, hostRef);
1414
1631
  };
1415
1632
  const isMemberInElement = (elm, memberName) => memberName in elm;
@@ -1436,14 +1653,36 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1436
1653
  return importedModule[exportName];
1437
1654
  }, consoleError);
1438
1655
  };
1439
- const styles = new Map();
1656
+ const styles = /*@__PURE__*/ new Map();
1657
+ const win = typeof window !== 'undefined' ? window : {};
1658
+ const doc = win.document || { head: {} };
1659
+ const plt = {
1660
+ $flags$: 0,
1661
+ $resourcesUrl$: '',
1662
+ jmp: (h) => h(),
1663
+ raf: (h) => requestAnimationFrame(h),
1664
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1665
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1666
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1667
+ };
1668
+ const supportsShadow = true;
1669
+ const promiseResolve = (v) => Promise.resolve(v);
1670
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1671
+ try {
1672
+ new CSSStyleSheet();
1673
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1674
+ }
1675
+ catch (e) { }
1676
+ return false;
1677
+ })()
1678
+ ;
1440
1679
  const queueDomReads = [];
1441
1680
  const queueDomWrites = [];
1442
1681
  const queueTask = (queue, write) => (cb) => {
1443
1682
  queue.push(cb);
1444
1683
  if (!queuePending) {
1445
1684
  queuePending = true;
1446
- if (write && plt.$flags$ & 4 /* queueSync */) {
1685
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1447
1686
  nextTick(flush);
1448
1687
  }
1449
1688
  else {