@sankhyalabs/sankhyablocks 10.1.0-dev.17 → 10.1.0-dev.19

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 (204) hide show
  1. package/dist/cjs/{PersonalizedFilterUtils-7259cf65.js → PersonalizedFilterUtils-eccb267a.js} +13 -0
  2. package/dist/cjs/{SnkMultiSelectionListDataSource-72925620.js → SnkMultiSelectionListDataSource-03b58f5a.js} +1 -1
  3. package/dist/cjs/config-header.cjs.entry.js +1 -1
  4. package/dist/cjs/configs-button.cjs.entry.js +1 -1
  5. package/dist/cjs/css-shim-a27d231b.js +6 -0
  6. package/dist/cjs/dom-ff96a4bc.js +75 -0
  7. package/dist/cjs/field-config_2.cjs.entry.js +1 -1
  8. package/dist/cjs/fields-layout.cjs.entry.js +1 -1
  9. package/dist/cjs/fields-selector.cjs.entry.js +1 -1
  10. package/dist/cjs/guides-configurator.cjs.entry.js +1 -1
  11. package/dist/cjs/{index-dc83c596.js → index-1894343a.js} +1527 -170
  12. package/dist/cjs/{index-516250fa.js → index-f0fe7e6e.js} +90 -21
  13. package/dist/cjs/loader.cjs.js +15 -1
  14. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
  15. package/dist/cjs/sankhyablocks.cjs.js +131 -3
  16. package/dist/cjs/shadow-css-7e3e0ab1.js +389 -0
  17. package/dist/cjs/snk-actions-button_9.cjs.entry.js +1 -1
  18. package/dist/cjs/snk-actions-form.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-application.cjs.entry.js +19 -2
  20. package/dist/cjs/snk-attach.cjs.entry.js +3 -3
  21. package/dist/cjs/snk-client-confirm.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  23. package/dist/cjs/snk-crud.cjs.entry.js +3 -3
  24. package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +1 -1
  25. package/dist/cjs/snk-custom-slot-guide.cjs.entry.js +1 -1
  26. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  27. package/dist/cjs/{snk-data-unit-47f02b9e.js → snk-data-unit-036ce58c.js} +8 -1
  28. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  29. package/dist/cjs/snk-default-filter.cjs.entry.js +1 -1
  30. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
  31. package/dist/cjs/snk-entity-list.cjs.entry.js +1 -1
  32. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  33. package/dist/cjs/snk-expression-group_2.cjs.entry.js +2 -2
  34. package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +2 -2
  35. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +22 -12
  36. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
  37. package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
  38. package/dist/cjs/snk-filter-detail.cjs.entry.js +2 -2
  39. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +2 -2
  40. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
  41. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
  42. package/dist/cjs/snk-filter-number.cjs.entry.js +1 -1
  43. package/dist/cjs/snk-filter-period.cjs.entry.js +1 -1
  44. package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
  45. package/dist/cjs/snk-filter-text.cjs.entry.js +1 -1
  46. package/dist/cjs/snk-form-summary.cjs.entry.js +1 -1
  47. package/dist/cjs/snk-form-view.cjs.entry.js +1 -1
  48. package/dist/cjs/snk-form_2.cjs.entry.js +1 -1
  49. package/dist/cjs/snk-grid.cjs.entry.js +4 -4
  50. package/dist/cjs/{snk-guides-viewer-41c22d96.js → snk-guides-viewer-164c063e.js} +2 -2
  51. package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
  52. package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
  53. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  54. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  55. package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
  56. package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
  57. package/dist/cjs/snk-simple-crud.cjs.entry.js +4 -4
  58. package/dist/cjs/snk-taskbar.cjs.entry.js +3 -3
  59. package/dist/cjs/{taskbar-elements-756fcbe7.js → taskbar-elements-8a80420e.js} +2 -2
  60. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  61. package/dist/collection/components/snk-application/snk-application.js +18 -1
  62. package/dist/collection/components/snk-data-unit/snk-data-unit.js +7 -0
  63. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +3 -1
  64. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +17 -9
  65. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/utils/PersonalizedFilterUtils.js +13 -0
  66. package/dist/components/PersonalizedFilterUtils.js +13 -0
  67. package/dist/components/index2.js +90 -21
  68. package/dist/components/snk-application2.js +18 -1
  69. package/dist/components/snk-data-unit2.js +7 -0
  70. package/dist/components/snk-filter-bar2.js +17 -9
  71. package/dist/components/snk-filter-item2.js +3 -1
  72. package/dist/esm/{PersonalizedFilterUtils-2db38ff2.js → PersonalizedFilterUtils-d2439a9a.js} +13 -0
  73. package/dist/esm/{SnkMultiSelectionListDataSource-493ae8c8.js → SnkMultiSelectionListDataSource-01b3744b.js} +1 -1
  74. package/dist/esm/config-header.entry.js +1 -1
  75. package/dist/esm/configs-button.entry.js +1 -1
  76. package/dist/esm/css-shim-9f2d321e.js +4 -0
  77. package/dist/esm/dom-64053c71.js +73 -0
  78. package/dist/esm/field-config_2.entry.js +1 -1
  79. package/dist/esm/fields-layout.entry.js +1 -1
  80. package/dist/esm/fields-selector.entry.js +1 -1
  81. package/dist/esm/guides-configurator.entry.js +1 -1
  82. package/dist/esm/{index-7fd74680.js → index-04f73a26.js} +1519 -170
  83. package/dist/esm/{index-3355bd17.js → index-ea250be6.js} +90 -21
  84. package/dist/esm/loader.js +16 -2
  85. package/dist/esm/pesquisa-grid_2.entry.js +1 -1
  86. package/dist/esm/sankhyablocks.js +132 -4
  87. package/dist/esm/shadow-css-98135883.js +387 -0
  88. package/dist/esm/snk-actions-button_9.entry.js +1 -1
  89. package/dist/esm/snk-actions-form.entry.js +1 -1
  90. package/dist/esm/snk-application.entry.js +19 -2
  91. package/dist/esm/snk-attach.entry.js +3 -3
  92. package/dist/esm/snk-client-confirm.entry.js +1 -1
  93. package/dist/esm/snk-configurator.entry.js +1 -1
  94. package/dist/esm/snk-crud.entry.js +3 -3
  95. package/dist/esm/snk-custom-slot-elements.entry.js +1 -1
  96. package/dist/esm/snk-custom-slot-guide.entry.js +1 -1
  97. package/dist/esm/snk-data-exporter.entry.js +2 -2
  98. package/dist/esm/{snk-data-unit-9e9d9d46.js → snk-data-unit-130021b3.js} +8 -1
  99. package/dist/esm/snk-data-unit.entry.js +2 -2
  100. package/dist/esm/snk-default-filter.entry.js +1 -1
  101. package/dist/esm/snk-detail-view.entry.js +4 -4
  102. package/dist/esm/snk-entity-list.entry.js +1 -1
  103. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  104. package/dist/esm/snk-expression-group_2.entry.js +2 -2
  105. package/dist/esm/snk-filter-advanced-mode_2.entry.js +2 -2
  106. package/dist/esm/snk-filter-bar_4.entry.js +22 -12
  107. package/dist/esm/snk-filter-binary-select.entry.js +1 -1
  108. package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
  109. package/dist/esm/snk-filter-detail.entry.js +2 -2
  110. package/dist/esm/snk-filter-field-search_2.entry.js +2 -2
  111. package/dist/esm/snk-filter-modal-item.entry.js +1 -1
  112. package/dist/esm/snk-filter-multi-select.entry.js +1 -1
  113. package/dist/esm/snk-filter-number.entry.js +1 -1
  114. package/dist/esm/snk-filter-period.entry.js +1 -1
  115. package/dist/esm/snk-filter-search.entry.js +1 -1
  116. package/dist/esm/snk-filter-text.entry.js +1 -1
  117. package/dist/esm/snk-form-summary.entry.js +1 -1
  118. package/dist/esm/snk-form-view.entry.js +1 -1
  119. package/dist/esm/snk-form_2.entry.js +1 -1
  120. package/dist/esm/snk-grid.entry.js +4 -4
  121. package/dist/esm/{snk-guides-viewer-31ef5fc6.js → snk-guides-viewer-3fd18298.js} +2 -2
  122. package/dist/esm/snk-guides-viewer.entry.js +4 -4
  123. package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
  124. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  125. package/dist/esm/snk-pesquisa.entry.js +1 -1
  126. package/dist/esm/snk-print-selector.entry.js +1 -1
  127. package/dist/esm/snk-simple-bar.entry.js +1 -1
  128. package/dist/esm/snk-simple-crud.entry.js +4 -4
  129. package/dist/esm/snk-taskbar.entry.js +3 -3
  130. package/dist/esm/{taskbar-elements-bf5b73f1.js → taskbar-elements-d1e63fb2.js} +2 -2
  131. package/dist/esm/teste-pesquisa.entry.js +1 -1
  132. package/dist/sankhyablocks/{p-c60d864f.entry.js → p-0a160fb5.entry.js} +1 -1
  133. package/dist/sankhyablocks/{p-0893a694.entry.js → p-12f595a6.entry.js} +1 -1
  134. package/dist/sankhyablocks/{p-522d36aa.entry.js → p-175c9576.entry.js} +1 -1
  135. package/dist/sankhyablocks/{p-8488fa7e.entry.js → p-18d66638.entry.js} +1 -1
  136. package/dist/sankhyablocks/{p-cfa4c183.entry.js → p-27e0cd68.entry.js} +1 -1
  137. package/dist/sankhyablocks/{p-8d84d6ab.entry.js → p-2b882835.entry.js} +1 -1
  138. package/dist/sankhyablocks/{p-7375bf6a.entry.js → p-2c6be187.entry.js} +1 -1
  139. package/dist/sankhyablocks/p-2c9d0870.js +2 -0
  140. package/dist/sankhyablocks/{p-8783d550.entry.js → p-2cc2526e.entry.js} +1 -1
  141. package/dist/sankhyablocks/{p-82b59a45.entry.js → p-2ebda226.entry.js} +1 -1
  142. package/dist/sankhyablocks/{p-301baf9c.entry.js → p-2f94cf87.entry.js} +1 -1
  143. package/dist/sankhyablocks/{p-35a26068.entry.js → p-3a35917e.entry.js} +1 -1
  144. package/dist/sankhyablocks/{p-4e9e570c.entry.js → p-3b6d8d33.entry.js} +1 -1
  145. package/dist/sankhyablocks/{p-0da30fd9.entry.js → p-3db72758.entry.js} +1 -1
  146. package/dist/sankhyablocks/p-560a9a68.entry.js +1 -0
  147. package/dist/sankhyablocks/{p-4575c4aa.entry.js → p-5aae5c74.entry.js} +1 -1
  148. package/dist/sankhyablocks/p-6564180d.entry.js +1 -0
  149. package/dist/sankhyablocks/p-68c1a093.js +1 -0
  150. package/dist/sankhyablocks/{p-907e96eb.js → p-6d322b0a.js} +1 -1
  151. package/dist/sankhyablocks/{p-cc68a0c1.entry.js → p-7150eacf.entry.js} +1 -1
  152. package/dist/sankhyablocks/{p-56b1b397.entry.js → p-752c57f4.entry.js} +1 -1
  153. package/dist/sankhyablocks/{p-670b8802.entry.js → p-752f4e29.entry.js} +1 -1
  154. package/dist/sankhyablocks/{p-939523b3.entry.js → p-76729994.entry.js} +1 -1
  155. package/dist/sankhyablocks/{p-357e10e0.entry.js → p-877d9614.entry.js} +1 -1
  156. package/dist/sankhyablocks/{p-497ece60.entry.js → p-8d946600.entry.js} +1 -1
  157. package/dist/sankhyablocks/{p-227e82b2.entry.js → p-90ae6c2e.entry.js} +1 -1
  158. package/dist/sankhyablocks/{p-b5832fa0.entry.js → p-94267a30.entry.js} +1 -1
  159. package/dist/sankhyablocks/{p-59158ba4.js → p-998a9d6f.js} +1 -1
  160. package/dist/sankhyablocks/{p-1e469905.entry.js → p-9c1ff75e.entry.js} +1 -1
  161. package/dist/sankhyablocks/{p-abfc9880.entry.js → p-9e109f5e.entry.js} +1 -1
  162. package/dist/sankhyablocks/p-a46ac091.js +1 -0
  163. package/dist/sankhyablocks/p-a73b6b00.js +1 -0
  164. package/dist/sankhyablocks/{p-4deb7f46.entry.js → p-acd2ba28.entry.js} +1 -1
  165. package/dist/sankhyablocks/{p-3671cdd4.entry.js → p-ae326d06.entry.js} +1 -1
  166. package/dist/sankhyablocks/{p-5c9bea92.entry.js → p-b471bfab.entry.js} +1 -1
  167. package/dist/sankhyablocks/{p-2624dfd2.entry.js → p-b533edab.entry.js} +1 -1
  168. package/dist/sankhyablocks/p-b555ce38.entry.js +1 -0
  169. package/dist/sankhyablocks/p-c3ec6642.js +19 -0
  170. package/dist/sankhyablocks/{p-613eb22e.entry.js → p-c8043a53.entry.js} +1 -1
  171. package/dist/sankhyablocks/{p-ce207f2a.entry.js → p-cc64239c.entry.js} +1 -1
  172. package/dist/sankhyablocks/{p-1be69fd4.js → p-cc9935af.js} +1 -1
  173. package/dist/sankhyablocks/{p-8d76a0ca.entry.js → p-cd00a3d1.entry.js} +1 -1
  174. package/dist/sankhyablocks/{p-7961c550.entry.js → p-cd40c8cf.entry.js} +1 -1
  175. package/dist/sankhyablocks/{p-d5d7fe52.entry.js → p-cd412add.entry.js} +1 -1
  176. package/dist/sankhyablocks/{p-959fe522.entry.js → p-d657f71f.entry.js} +1 -1
  177. package/dist/sankhyablocks/{p-c2bb0659.entry.js → p-d6dad5e4.entry.js} +1 -1
  178. package/dist/sankhyablocks/p-d714b6ca.js +1 -0
  179. package/dist/sankhyablocks/{p-dcb096c4.entry.js → p-d8368b17.entry.js} +1 -1
  180. package/dist/sankhyablocks/p-da455c82.js +12 -0
  181. package/dist/sankhyablocks/p-dea58642.entry.js +11 -0
  182. package/dist/sankhyablocks/p-e30acdca.entry.js +1 -0
  183. package/dist/sankhyablocks/{p-1dba30c9.entry.js → p-ec9027a7.entry.js} +1 -1
  184. package/dist/sankhyablocks/p-ef9343c3.entry.js +1 -0
  185. package/dist/sankhyablocks/{p-def17f0e.entry.js → p-f152ef98.entry.js} +1 -1
  186. package/dist/sankhyablocks/{p-98c70173.entry.js → p-f7170e10.entry.js} +1 -1
  187. package/dist/sankhyablocks/{p-02cb4829.entry.js → p-f8c5395a.entry.js} +1 -1
  188. package/dist/sankhyablocks/{p-98e3d0a1.entry.js → p-f8da8569.entry.js} +1 -1
  189. package/dist/sankhyablocks/{p-fd1a5a61.entry.js → p-f921270b.entry.js} +1 -1
  190. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  191. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +1 -0
  192. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +1 -1
  193. package/dist/types/components/snk-personalized-filter/interfaces/IParameter.d.ts +1 -0
  194. package/package.json +1 -1
  195. package/dist/sankhyablocks/p-156c9f38.js +0 -1
  196. package/dist/sankhyablocks/p-1c31f314.entry.js +0 -1
  197. package/dist/sankhyablocks/p-465877ee.entry.js +0 -1
  198. package/dist/sankhyablocks/p-516411de.entry.js +0 -1
  199. package/dist/sankhyablocks/p-67137d7c.entry.js +0 -1
  200. package/dist/sankhyablocks/p-82bb3eda.js +0 -2
  201. package/dist/sankhyablocks/p-8336900b.js +0 -1
  202. package/dist/sankhyablocks/p-988afe78.js +0 -1
  203. package/dist/sankhyablocks/p-cb7c592f.entry.js +0 -11
  204. package/dist/sankhyablocks/p-e47d6f17.entry.js +0 -1
@@ -1,4 +1,6 @@
1
1
  const NAMESPACE = 'sankhyablocks';
2
+ const BUILD = /* sankhyablocks */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: true, cmpShouldUpdate: true, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: true, connectedCallback: true, constructableCSS: true, cssAnnotations: true, cssVarShim: false, devTools: false, disconnectedCallback: true, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: true, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: false, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
3
+ const Env = /* sankhyablocks */ {};
2
4
 
3
5
  /**
4
6
  * Virtual DOM patching algorithm based on Snabbdom by
@@ -11,26 +13,121 @@ const NAMESPACE = 'sankhyablocks';
11
13
  let scopeId;
12
14
  let contentRef;
13
15
  let hostTagName;
16
+ let customError;
17
+ let i = 0;
14
18
  let useNativeShadowDom = false;
15
19
  let checkSlotFallbackVisibility = false;
16
20
  let checkSlotRelocate = false;
17
21
  let isSvgMode = false;
18
22
  let renderingRef = null;
23
+ let queueCongestion = 0;
19
24
  let queuePending = false;
25
+ const Build = {
26
+ isDev: BUILD.isDev ? true : false,
27
+ isBrowser: true,
28
+ isServer: false,
29
+ isTesting: BUILD.isTesting ? true : false,
30
+ };
31
+ const Context = {};
32
+ const getAssetPath = (path) => {
33
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
34
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
35
+ };
36
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
20
37
  const createTime = (fnName, tagName = '') => {
21
- {
38
+ if (BUILD.profile && performance.mark) {
39
+ const key = `st:${fnName}:${tagName}:${i++}`;
40
+ // Start
41
+ performance.mark(key);
42
+ // End
43
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
44
+ }
45
+ else {
22
46
  return () => {
23
47
  return;
24
48
  };
25
49
  }
26
50
  };
27
51
  const uniqueTime = (key, measureText) => {
28
- {
52
+ if (BUILD.profile && performance.mark) {
53
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
54
+ performance.mark(key);
55
+ }
56
+ return () => {
57
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
58
+ performance.measure(measureText, key);
59
+ }
60
+ };
61
+ }
62
+ else {
29
63
  return () => {
30
64
  return;
31
65
  };
32
66
  }
33
67
  };
68
+ const inspect = (ref) => {
69
+ const hostRef = getHostRef(ref);
70
+ if (!hostRef) {
71
+ return undefined;
72
+ }
73
+ const flags = hostRef.$flags$;
74
+ const hostElement = hostRef.$hostElement$;
75
+ return {
76
+ renderCount: hostRef.$renderCount$,
77
+ flags: {
78
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
79
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
80
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
81
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
82
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
83
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
84
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
85
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
86
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
87
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
88
+ },
89
+ instanceValues: hostRef.$instanceValues$,
90
+ ancestorComponent: hostRef.$ancestorComponent$,
91
+ hostElement,
92
+ lazyInstance: hostRef.$lazyInstance$,
93
+ vnode: hostRef.$vnode$,
94
+ modeName: hostRef.$modeName$,
95
+ onReadyPromise: hostRef.$onReadyPromise$,
96
+ onReadyResolve: hostRef.$onReadyResolve$,
97
+ onInstancePromise: hostRef.$onInstancePromise$,
98
+ onInstanceResolve: hostRef.$onInstanceResolve$,
99
+ onRenderResolve: hostRef.$onRenderResolve$,
100
+ queuedListeners: hostRef.$queuedListeners$,
101
+ rmListeners: hostRef.$rmListeners$,
102
+ ['s-id']: hostElement['s-id'],
103
+ ['s-cr']: hostElement['s-cr'],
104
+ ['s-lr']: hostElement['s-lr'],
105
+ ['s-p']: hostElement['s-p'],
106
+ ['s-rc']: hostElement['s-rc'],
107
+ ['s-sc']: hostElement['s-sc'],
108
+ };
109
+ };
110
+ const installDevTools = () => {
111
+ if (BUILD.devTools) {
112
+ const stencil = (win.stencil = win.stencil || {});
113
+ const originalInspect = stencil.inspect;
114
+ stencil.inspect = (ref) => {
115
+ let result = inspect(ref);
116
+ if (!result && typeof originalInspect === 'function') {
117
+ result = originalInspect(ref);
118
+ }
119
+ return result;
120
+ };
121
+ }
122
+ };
123
+ const CONTENT_REF_ID = 'r';
124
+ const ORG_LOCATION_ID = 'o';
125
+ const SLOT_NODE_ID = 's';
126
+ const TEXT_NODE_ID = 't';
127
+ const HYDRATE_ID = 's-id';
128
+ const HYDRATED_STYLE_ID = 'sty-id';
129
+ const HYDRATE_CHILD_ID = 'c-id';
130
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
34
131
  const XLINK_NS = 'http://www.w3.org/1999/xlink';
35
132
  /**
36
133
  * Default style mode id
@@ -40,6 +137,11 @@ const XLINK_NS = 'http://www.w3.org/1999/xlink';
40
137
  * Don't add values to these!!
41
138
  */
42
139
  const EMPTY_OBJ = {};
140
+ /**
141
+ * Namespaces
142
+ */
143
+ const SVG_NS = 'http://www.w3.org/2000/svg';
144
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
43
145
  const isDef = (v) => v != null;
44
146
  const isComplexType = (o) => {
45
147
  // https://jsperf.com/typeof-fn-object/5
@@ -85,6 +187,11 @@ const h = (nodeName, vnodeData, ...children) => {
85
187
  if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
86
188
  child = String(child);
87
189
  }
190
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
191
+ consoleDevError(`vNode passed as children has unexpected type.
192
+ Make sure it's using the correct h() function.
193
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
194
+ }
88
195
  if (simple && lastSimple) {
89
196
  // If the previous child was simple (string), we merge both
90
197
  vNodeChildren[vNodeChildren.length - 1].$text$ += child;
@@ -99,14 +206,17 @@ const h = (nodeName, vnodeData, ...children) => {
99
206
  };
100
207
  walk(children);
101
208
  if (vnodeData) {
209
+ if (BUILD.isDev && nodeName === 'input') {
210
+ validateInputProperties(vnodeData);
211
+ }
102
212
  // normalize class / classname attributes
103
- if (vnodeData.key) {
213
+ if (BUILD.vdomKey && vnodeData.key) {
104
214
  key = vnodeData.key;
105
215
  }
106
- if (vnodeData.name) {
216
+ if (BUILD.slotRelocation && vnodeData.name) {
107
217
  slotName = vnodeData.name;
108
218
  }
109
- {
219
+ if (BUILD.vdomClass) {
110
220
  const classData = vnodeData.className || vnodeData.class;
111
221
  if (classData) {
112
222
  vnodeData.class =
@@ -118,7 +228,12 @@ const h = (nodeName, vnodeData, ...children) => {
118
228
  }
119
229
  }
120
230
  }
121
- if (typeof nodeName === 'function') {
231
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
232
+ consoleDevError(`The <Host> must be the single root component. Make sure:
233
+ - You are NOT using hostData() and <Host> in the same component.
234
+ - <Host> is used once, and it's the single root component of the render() function.`);
235
+ }
236
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
122
237
  // nodeName is a functional component
123
238
  return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
124
239
  }
@@ -127,10 +242,10 @@ const h = (nodeName, vnodeData, ...children) => {
127
242
  if (vNodeChildren.length > 0) {
128
243
  vnode.$children$ = vNodeChildren;
129
244
  }
130
- {
245
+ if (BUILD.vdomKey) {
131
246
  vnode.$key$ = key;
132
247
  }
133
- {
248
+ if (BUILD.slotRelocation) {
134
249
  vnode.$name$ = slotName;
135
250
  }
136
251
  return vnode;
@@ -151,13 +266,13 @@ const newVNode = (tag, text) => {
151
266
  $elm$: null,
152
267
  $children$: null,
153
268
  };
154
- {
269
+ if (BUILD.vdomAttribute) {
155
270
  vnode.$attrs$ = null;
156
271
  }
157
- {
272
+ if (BUILD.vdomKey) {
158
273
  vnode.$key$ = null;
159
274
  }
160
- {
275
+ if (BUILD.slotRelocation) {
161
276
  vnode.$name$ = null;
162
277
  }
163
278
  return vnode;
@@ -223,6 +338,235 @@ const convertToPrivate = (node) => {
223
338
  vnode.$name$ = node.vname;
224
339
  return vnode;
225
340
  };
341
+ /**
342
+ * Validates the ordering of attributes on an input element
343
+ *
344
+ * @param inputElm the element to validate
345
+ */
346
+ const validateInputProperties = (inputElm) => {
347
+ const props = Object.keys(inputElm);
348
+ const value = props.indexOf('value');
349
+ if (value === -1) {
350
+ return;
351
+ }
352
+ const typeIndex = props.indexOf('type');
353
+ const minIndex = props.indexOf('min');
354
+ const maxIndex = props.indexOf('max');
355
+ const stepIndex = props.indexOf('step');
356
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
357
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
358
+ }
359
+ };
360
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
361
+ const endHydrate = createTime('hydrateClient', tagName);
362
+ const shadowRoot = hostElm.shadowRoot;
363
+ const childRenderNodes = [];
364
+ const slotNodes = [];
365
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
366
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
367
+ if (!plt.$orgLocNodes$) {
368
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
369
+ }
370
+ hostElm[HYDRATE_ID] = hostId;
371
+ hostElm.removeAttribute(HYDRATE_ID);
372
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
373
+ childRenderNodes.map((c) => {
374
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
375
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
376
+ const node = c.$elm$;
377
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
378
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
379
+ }
380
+ if (!shadowRoot) {
381
+ node['s-hn'] = tagName;
382
+ if (orgLocationNode) {
383
+ node['s-ol'] = orgLocationNode;
384
+ node['s-ol']['s-nr'] = node;
385
+ }
386
+ }
387
+ plt.$orgLocNodes$.delete(orgLocationId);
388
+ });
389
+ if (BUILD.shadowDom && shadowRoot) {
390
+ shadowRootNodes.map((shadowRootNode) => {
391
+ if (shadowRootNode) {
392
+ shadowRoot.appendChild(shadowRootNode);
393
+ }
394
+ });
395
+ }
396
+ endHydrate();
397
+ };
398
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
399
+ let childNodeType;
400
+ let childIdSplt;
401
+ let childVNode;
402
+ let i;
403
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
404
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
405
+ if (childNodeType) {
406
+ // got the node data from the element's attribute
407
+ // `${hostId}.${nodeId}.${depth}.${index}`
408
+ childIdSplt = childNodeType.split('.');
409
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
410
+ childVNode = {
411
+ $flags$: 0,
412
+ $hostId$: childIdSplt[0],
413
+ $nodeId$: childIdSplt[1],
414
+ $depth$: childIdSplt[2],
415
+ $index$: childIdSplt[3],
416
+ $tag$: node.tagName.toLowerCase(),
417
+ $elm$: node,
418
+ $attrs$: null,
419
+ $children$: null,
420
+ $key$: null,
421
+ $name$: null,
422
+ $text$: null,
423
+ };
424
+ childRenderNodes.push(childVNode);
425
+ node.removeAttribute(HYDRATE_CHILD_ID);
426
+ // this is a new child vnode
427
+ // so ensure its parent vnode has the vchildren array
428
+ if (!parentVNode.$children$) {
429
+ parentVNode.$children$ = [];
430
+ }
431
+ // add our child vnode to a specific index of the vnode's children
432
+ parentVNode.$children$[childVNode.$index$] = childVNode;
433
+ // this is now the new parent vnode for all the next child checks
434
+ parentVNode = childVNode;
435
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
436
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
437
+ }
438
+ }
439
+ }
440
+ // recursively drill down, end to start so we can remove nodes
441
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
442
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
443
+ }
444
+ if (node.shadowRoot) {
445
+ // keep drilling down through the shadow root nodes
446
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
447
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
448
+ }
449
+ }
450
+ }
451
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
452
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
453
+ childIdSplt = node.nodeValue.split('.');
454
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
455
+ // comment node for either the host id or a 0 host id
456
+ childNodeType = childIdSplt[0];
457
+ childVNode = {
458
+ $flags$: 0,
459
+ $hostId$: childIdSplt[1],
460
+ $nodeId$: childIdSplt[2],
461
+ $depth$: childIdSplt[3],
462
+ $index$: childIdSplt[4],
463
+ $elm$: node,
464
+ $attrs$: null,
465
+ $children$: null,
466
+ $key$: null,
467
+ $name$: null,
468
+ $tag$: null,
469
+ $text$: null,
470
+ };
471
+ if (childNodeType === TEXT_NODE_ID) {
472
+ childVNode.$elm$ = node.nextSibling;
473
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
474
+ childVNode.$text$ = childVNode.$elm$.textContent;
475
+ childRenderNodes.push(childVNode);
476
+ // remove the text comment since it's no longer needed
477
+ node.remove();
478
+ if (!parentVNode.$children$) {
479
+ parentVNode.$children$ = [];
480
+ }
481
+ parentVNode.$children$[childVNode.$index$] = childVNode;
482
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
483
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
484
+ }
485
+ }
486
+ }
487
+ else if (childVNode.$hostId$ === hostId) {
488
+ // this comment node is specifcally for this host id
489
+ if (childNodeType === SLOT_NODE_ID) {
490
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
491
+ childVNode.$tag$ = 'slot';
492
+ if (childIdSplt[5]) {
493
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
494
+ }
495
+ else {
496
+ node['s-sn'] = '';
497
+ }
498
+ node['s-sr'] = true;
499
+ if (BUILD.shadowDom && shadowRootNodes) {
500
+ // browser support shadowRoot and this is a shadow dom component
501
+ // create an actual slot element
502
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
503
+ if (childVNode.$name$) {
504
+ // add the slot name attribute
505
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
506
+ }
507
+ // insert the new slot element before the slot comment
508
+ node.parentNode.insertBefore(childVNode.$elm$, node);
509
+ // remove the slot comment since it's not needed for shadow
510
+ node.remove();
511
+ if (childVNode.$depth$ === '0') {
512
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
513
+ }
514
+ }
515
+ slotNodes.push(childVNode);
516
+ if (!parentVNode.$children$) {
517
+ parentVNode.$children$ = [];
518
+ }
519
+ parentVNode.$children$[childVNode.$index$] = childVNode;
520
+ }
521
+ else if (childNodeType === CONTENT_REF_ID) {
522
+ // `${CONTENT_REF_ID}.${hostId}`;
523
+ if (BUILD.shadowDom && shadowRootNodes) {
524
+ // remove the content ref comment since it's not needed for shadow
525
+ node.remove();
526
+ }
527
+ else if (BUILD.slotRelocation) {
528
+ hostElm['s-cr'] = node;
529
+ node['s-cn'] = true;
530
+ }
531
+ }
532
+ }
533
+ }
534
+ }
535
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
536
+ const vnode = newVNode(null, node.textContent);
537
+ vnode.$elm$ = node;
538
+ vnode.$index$ = '0';
539
+ parentVNode.$children$ = [vnode];
540
+ }
541
+ };
542
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
543
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
544
+ let i = 0;
545
+ for (; i < node.childNodes.length; i++) {
546
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
547
+ }
548
+ if (node.shadowRoot) {
549
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
550
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
551
+ }
552
+ }
553
+ }
554
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
555
+ const childIdSplt = node.nodeValue.split('.');
556
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
557
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
558
+ node.nodeValue = '';
559
+ // useful to know if the original location is
560
+ // the root light-dom of a shadow dom component
561
+ node['s-en'] = childIdSplt[3];
562
+ }
563
+ }
564
+ };
565
+ // Private
566
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
567
+ // Public
568
+ const setMode = (handler) => modeResolutionChain.push(handler);
569
+ const getMode = (ref) => getHostRef(ref).$modeName$;
226
570
  /**
227
571
  * Parse a new property value for a given property type.
228
572
  *
@@ -249,16 +593,16 @@ const convertToPrivate = (node) => {
249
593
  const parsePropertyValue = (propValue, propType) => {
250
594
  // ensure this value is of the correct prop type
251
595
  if (propValue != null && !isComplexType(propValue)) {
252
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
596
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
253
597
  // per the HTML spec, any string value means it is a boolean true value
254
598
  // but we'll cheat here and say that the string "false" is the boolean false
255
599
  return propValue === 'false' ? false : propValue === '' || !!propValue;
256
600
  }
257
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
601
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
258
602
  // force it to be a number
259
603
  return parseFloat(propValue);
260
604
  }
261
- if (propType & 1 /* MEMBER_FLAGS.String */) {
605
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
262
606
  // could have been passed as a number or boolean
263
607
  // but we still want it as a string
264
608
  return String(propValue);
@@ -270,11 +614,14 @@ const parsePropertyValue = (propValue, propType) => {
270
614
  // so no need to change to a different type
271
615
  return propValue;
272
616
  };
273
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
617
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
274
618
  const createEvent = (ref, name, flags) => {
275
619
  const elm = getElement(ref);
276
620
  return {
277
621
  emit: (detail) => {
622
+ if (BUILD.isDev && !elm.isConnected) {
623
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
624
+ }
278
625
  return emitEvent(elm, name, {
279
626
  bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
280
627
  composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
@@ -315,8 +662,11 @@ const registerStyle = (scopeId, cssText, allowCS) => {
315
662
  };
316
663
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
317
664
  var _a;
318
- let scopeId = getScopeId(cmpMeta);
665
+ let scopeId = getScopeId(cmpMeta, mode);
319
666
  const style = styles.get(scopeId);
667
+ if (!BUILD.attachStyles) {
668
+ return scopeId;
669
+ }
320
670
  // if an element is NOT connected then getRootNode() will return the wrong root node
321
671
  // so the fallback is to always use the document for the root node in those cases
322
672
  styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
@@ -329,8 +679,25 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
329
679
  rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
330
680
  }
331
681
  if (!appliedStyles.has(scopeId)) {
332
- {
333
- {
682
+ if (BUILD.hydrateClientSide &&
683
+ styleContainerNode.host &&
684
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
685
+ // This is only happening on native shadow-dom, do not needs CSS var shim
686
+ styleElm.innerHTML = style;
687
+ }
688
+ else {
689
+ if (BUILD.cssVarShim && plt.$cssShim$) {
690
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
691
+ const newScopeId = styleElm['s-sc'];
692
+ if (newScopeId) {
693
+ scopeId = newScopeId;
694
+ // we don't want to add this styleID to the appliedStyles Set
695
+ // since the cssVarShim might need to apply several different
696
+ // stylesheets for the same component
697
+ appliedStyles = null;
698
+ }
699
+ }
700
+ else {
334
701
  styleElm = doc.createElement('style');
335
702
  styleElm.innerHTML = style;
336
703
  }
@@ -339,6 +706,9 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
339
706
  if (nonce != null) {
340
707
  styleElm.setAttribute('nonce', nonce);
341
708
  }
709
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
710
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
711
+ }
342
712
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
343
713
  }
344
714
  if (appliedStyles) {
@@ -346,7 +716,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
346
716
  }
347
717
  }
348
718
  }
349
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
719
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
350
720
  styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
351
721
  }
352
722
  }
@@ -357,8 +727,8 @@ const attachStyles = (hostRef) => {
357
727
  const elm = hostRef.$hostElement$;
358
728
  const flags = cmpMeta.$flags$;
359
729
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
360
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
361
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
730
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
731
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
362
732
  // only required when we're NOT using native shadow dom (slot)
363
733
  // or this browser doesn't support native shadow dom
364
734
  // and this host element was NOT created with SSR
@@ -368,13 +738,14 @@ const attachStyles = (hostRef) => {
368
738
  // DOM WRITE!!
369
739
  elm['s-sc'] = scopeId;
370
740
  elm.classList.add(scopeId + '-h');
371
- if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
741
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
372
742
  elm.classList.add(scopeId + '-s');
373
743
  }
374
744
  }
375
745
  endAttachStyles();
376
746
  };
377
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
747
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
748
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
378
749
  /**
379
750
  * Production setAccessor() function based on Preact by
380
751
  * Jason Miller (@developit)
@@ -387,19 +758,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
387
758
  if (oldValue !== newValue) {
388
759
  let isProp = isMemberInElement(elm, memberName);
389
760
  let ln = memberName.toLowerCase();
390
- if (memberName === 'class') {
761
+ if (BUILD.vdomClass && memberName === 'class') {
391
762
  const classList = elm.classList;
392
763
  const oldClasses = parseClassList(oldValue);
393
764
  const newClasses = parseClassList(newValue);
394
765
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
395
766
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
396
767
  }
397
- else if (memberName === 'style') {
768
+ else if (BUILD.vdomStyle && memberName === 'style') {
398
769
  // update style attribute, css properties and values
399
- {
770
+ if (BUILD.updatable) {
400
771
  for (const prop in oldValue) {
401
772
  if (!newValue || newValue[prop] == null) {
402
- if (prop.includes('-')) {
773
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
403
774
  elm.style.removeProperty(prop);
404
775
  }
405
776
  else {
@@ -410,7 +781,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
410
781
  }
411
782
  for (const prop in newValue) {
412
783
  if (!oldValue || newValue[prop] !== oldValue[prop]) {
413
- if (prop.includes('-')) {
784
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
414
785
  elm.style.setProperty(prop, newValue[prop]);
415
786
  }
416
787
  else {
@@ -419,15 +790,16 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
419
790
  }
420
791
  }
421
792
  }
422
- else if (memberName === 'key')
793
+ else if (BUILD.vdomKey && memberName === 'key')
423
794
  ;
424
- else if (memberName === 'ref') {
795
+ else if (BUILD.vdomRef && memberName === 'ref') {
425
796
  // minifier will clean this up
426
797
  if (newValue) {
427
798
  newValue(elm);
428
799
  }
429
800
  }
430
- else if ((!isProp ) &&
801
+ else if (BUILD.vdomListener &&
802
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
431
803
  memberName[0] === 'o' &&
432
804
  memberName[1] === 'n') {
433
805
  // Event Handlers
@@ -466,7 +838,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
466
838
  plt.ael(elm, memberName, newValue, false);
467
839
  }
468
840
  }
469
- else {
841
+ else if (BUILD.vdomPropOrAttr) {
470
842
  // Set property if it exists and it's not a SVG
471
843
  const isComplex = isComplexType(newValue);
472
844
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
@@ -495,7 +867,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
495
867
  * - if the newValue is null/undefined or 'false'.
496
868
  */
497
869
  let xlink = false;
498
- {
870
+ if (BUILD.vdomXlink) {
499
871
  if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
500
872
  memberName = ln;
501
873
  xlink = true;
@@ -503,7 +875,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
503
875
  }
504
876
  if (newValue == null || newValue === false) {
505
877
  if (newValue !== false || elm.getAttribute(memberName) === '') {
506
- if (xlink) {
878
+ if (BUILD.vdomXlink && xlink) {
507
879
  elm.removeAttributeNS(XLINK_NS, memberName);
508
880
  }
509
881
  else {
@@ -513,7 +885,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
513
885
  }
514
886
  else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
515
887
  newValue = newValue === true ? '' : newValue;
516
- if (xlink) {
888
+ if (BUILD.vdomXlink && xlink) {
517
889
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
518
890
  }
519
891
  else {
@@ -534,7 +906,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
534
906
  : newVnode.$elm$;
535
907
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
536
908
  const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
537
- {
909
+ if (BUILD.updatable) {
538
910
  // remove attributes no longer present on the vnode by setting them to undefined
539
911
  for (memberName in oldVnodeAttrs) {
540
912
  if (!(memberName in newVnodeAttrs)) {
@@ -564,7 +936,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
564
936
  let elm;
565
937
  let childNode;
566
938
  let oldVNode;
567
- if (!useNativeShadowDom) {
939
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
568
940
  // remember for later we need to check to relocate nodes
569
941
  checkSlotRelocate = true;
570
942
  if (newVNode.$tag$ === 'slot') {
@@ -579,25 +951,38 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
579
951
  1 /* VNODE_FLAGS.isSlotReference */;
580
952
  }
581
953
  }
582
- if (newVNode.$text$ !== null) {
954
+ if (BUILD.isDev && newVNode.$elm$) {
955
+ consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
956
+ }
957
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
583
958
  // create text node
584
959
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
585
960
  }
586
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
961
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
587
962
  // create a slot reference node
588
963
  elm = newVNode.$elm$ =
589
- doc.createTextNode('');
964
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
590
965
  }
591
966
  else {
967
+ if (BUILD.svg && !isSvgMode) {
968
+ isSvgMode = newVNode.$tag$ === 'svg';
969
+ }
592
970
  // create element
593
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
971
+ elm = newVNode.$elm$ = (BUILD.svg
972
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
973
+ ? 'slot-fb'
974
+ : newVNode.$tag$)
975
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
594
976
  ? 'slot-fb'
595
977
  : newVNode.$tag$));
978
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
979
+ isSvgMode = false;
980
+ }
596
981
  // add css classes, attrs, props, listeners, etc.
597
- {
982
+ if (BUILD.vdomAttribute) {
598
983
  updateElement(null, newVNode, isSvgMode);
599
984
  }
600
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
985
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
601
986
  // if there is a scopeId and this is the initial render
602
987
  // then let's add the scopeId as a css class
603
988
  elm.classList.add((elm['s-si'] = scopeId));
@@ -613,8 +998,18 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
613
998
  }
614
999
  }
615
1000
  }
1001
+ if (BUILD.svg) {
1002
+ if (newVNode.$tag$ === 'svg') {
1003
+ // Only reset the SVG context when we're exiting <svg> element
1004
+ isSvgMode = false;
1005
+ }
1006
+ else if (elm.tagName === 'foreignObject') {
1007
+ // Reenter SVG context when we're exiting <foreignObject> element
1008
+ isSvgMode = true;
1009
+ }
1010
+ }
616
1011
  }
617
- {
1012
+ if (BUILD.slotRelocation) {
618
1013
  elm['s-hn'] = hostTagName;
619
1014
  if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
620
1015
  // remember the content reference comment
@@ -674,9 +1069,9 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
674
1069
  * creating DOM nodes (inclusive)
675
1070
  */
676
1071
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
677
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1072
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
678
1073
  let childNode;
679
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1074
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
680
1075
  containerElm = containerElm.shadowRoot;
681
1076
  }
682
1077
  for (; startIdx <= endIdx; ++startIdx) {
@@ -684,7 +1079,7 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
684
1079
  childNode = createElm(null, parentVNode, startIdx, parentElm);
685
1080
  if (childNode) {
686
1081
  vnodes[startIdx].$elm$ = childNode;
687
- containerElm.insertBefore(childNode, referenceNode(before) );
1082
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
688
1083
  }
689
1084
  }
690
1085
  }
@@ -707,7 +1102,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
707
1102
  if ((vnode = vnodes[startIdx])) {
708
1103
  elm = vnode.$elm$;
709
1104
  callNodeRefs(vnode);
710
- {
1105
+ if (BUILD.slotRelocation) {
711
1106
  // we're removing this element
712
1107
  // so it's possible we need to show slot fallback content now
713
1108
  checkSlotFallbackVisibility = true;
@@ -853,7 +1248,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
853
1248
  //
854
1249
  // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
855
1250
  // and move the DOM element for `oldStartVnode`.
856
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1251
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
857
1252
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
858
1253
  }
859
1254
  patch(oldStartVnode, newEndVnode);
@@ -894,7 +1289,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
894
1289
  // (which will handle updating any changed attributes, reconciling their
895
1290
  // children etc) but we also need to move the DOM node to which
896
1291
  // `oldEndVnode` corresponds.
897
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1292
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
898
1293
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
899
1294
  }
900
1295
  patch(oldEndVnode, newStartVnode);
@@ -917,7 +1312,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
917
1312
  // children which have the same key as the first node in the new
918
1313
  // children.
919
1314
  idxInOld = -1;
920
- {
1315
+ if (BUILD.vdomKey) {
921
1316
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
922
1317
  if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
923
1318
  idxInOld = i;
@@ -925,7 +1320,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
925
1320
  }
926
1321
  }
927
1322
  }
928
- if (idxInOld >= 0) {
1323
+ if (BUILD.vdomKey && idxInOld >= 0) {
929
1324
  // We found a node in the old children which matches up with the first
930
1325
  // node in the new children! So let's deal with that
931
1326
  elmToMove = oldCh[idxInOld];
@@ -952,9 +1347,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
952
1347
  }
953
1348
  if (node) {
954
1349
  // if we created a new node then handle inserting it to the DOM
955
- {
1350
+ if (BUILD.slotRelocation) {
956
1351
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
957
1352
  }
1353
+ else {
1354
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1355
+ }
958
1356
  }
959
1357
  }
960
1358
  }
@@ -962,7 +1360,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
962
1360
  // we have some more new nodes to add which don't match up with old nodes
963
1361
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
964
1362
  }
965
- else if (newStartIdx > newEndIdx) {
1363
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
966
1364
  // there are nodes in the `oldCh` array which no longer correspond to nodes
967
1365
  // in the new array, so lets remove them (which entails cleaning up the
968
1366
  // relevant DOM nodes)
@@ -991,13 +1389,14 @@ const isSameVnode = (leftVNode, rightVNode) => {
991
1389
  // compare if two vnode to see if they're "technically" the same
992
1390
  // need to have the same element tag, and same key to be the same
993
1391
  if (leftVNode.$tag$ === rightVNode.$tag$) {
994
- if (leftVNode.$tag$ === 'slot') {
1392
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
995
1393
  return leftVNode.$name$ === rightVNode.$name$;
996
1394
  }
997
1395
  // this will be set if components in the build have `key` attrs set on them
998
- {
1396
+ if (BUILD.vdomKey) {
999
1397
  return leftVNode.$key$ === rightVNode.$key$;
1000
1398
  }
1399
+ return true;
1001
1400
  }
1002
1401
  return false;
1003
1402
  };
@@ -1024,9 +1423,14 @@ const patch = (oldVNode, newVNode) => {
1024
1423
  const tag = newVNode.$tag$;
1025
1424
  const text = newVNode.$text$;
1026
1425
  let defaultHolder;
1027
- if (text === null) {
1028
- {
1029
- if (tag === 'slot')
1426
+ if (!BUILD.vdomText || text === null) {
1427
+ if (BUILD.svg) {
1428
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1429
+ // only add this to the when the compiler sees we're using an svg somewhere
1430
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1431
+ }
1432
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1433
+ if (BUILD.slot && tag === 'slot')
1030
1434
  ;
1031
1435
  else {
1032
1436
  // either this is the first render of an element OR it's an update
@@ -1035,30 +1439,33 @@ const patch = (oldVNode, newVNode) => {
1035
1439
  updateElement(oldVNode, newVNode, isSvgMode);
1036
1440
  }
1037
1441
  }
1038
- if (oldChildren !== null && newChildren !== null) {
1442
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1039
1443
  // looks like there's child vnodes for both the old and new vnodes
1040
1444
  // so we need to call `updateChildren` to reconcile them
1041
1445
  updateChildren(elm, oldChildren, newVNode, newChildren);
1042
1446
  }
1043
1447
  else if (newChildren !== null) {
1044
1448
  // no old child vnodes, but there are new child vnodes to add
1045
- if (oldVNode.$text$ !== null) {
1449
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1046
1450
  // the old vnode was text, so be sure to clear it out
1047
1451
  elm.textContent = '';
1048
1452
  }
1049
1453
  // add the new vnode children
1050
1454
  addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1051
1455
  }
1052
- else if (oldChildren !== null) {
1456
+ else if (BUILD.updatable && oldChildren !== null) {
1053
1457
  // no new child vnodes, but there are old child vnodes to remove
1054
1458
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
1055
1459
  }
1460
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1461
+ isSvgMode = false;
1462
+ }
1056
1463
  }
1057
- else if ((defaultHolder = elm['s-cr'])) {
1464
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1058
1465
  // this element has slotted content
1059
1466
  defaultHolder.parentNode.textContent = text;
1060
1467
  }
1061
- else if (oldVNode.$text$ !== text) {
1468
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1062
1469
  // update the text content for the text only vnode
1063
1470
  // and also only if the text is different than before
1064
1471
  elm.data = text;
@@ -1196,7 +1603,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1196
1603
  return slotNameAttr === '';
1197
1604
  };
1198
1605
  const callNodeRefs = (vNode) => {
1199
- {
1606
+ if (BUILD.vdomRef) {
1200
1607
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1201
1608
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
1202
1609
  }
@@ -1219,26 +1626,41 @@ const renderVdom = (hostRef, renderFnResults) => {
1219
1626
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1220
1627
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1221
1628
  hostTagName = hostElm.tagName;
1222
- if (cmpMeta.$attrsToReflect$) {
1629
+ // <Host> runtime check
1630
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1631
+ throw new Error(`The <Host> must be the single root component.
1632
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1633
+
1634
+ The render() function should look like this instead:
1635
+
1636
+ render() {
1637
+ // Do not return an array
1638
+ return (
1639
+ <Host>{content}</Host>
1640
+ );
1641
+ }
1642
+ `);
1643
+ }
1644
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1223
1645
  rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1224
1646
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1225
1647
  }
1226
1648
  rootVnode.$tag$ = null;
1227
1649
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1228
1650
  hostRef.$vnode$ = rootVnode;
1229
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1230
- {
1651
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1652
+ if (BUILD.scoped || BUILD.shadowDom) {
1231
1653
  scopeId = hostElm['s-sc'];
1232
1654
  }
1233
- {
1655
+ if (BUILD.slotRelocation) {
1234
1656
  contentRef = hostElm['s-cr'];
1235
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1657
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1236
1658
  // always reset
1237
1659
  checkSlotFallbackVisibility = false;
1238
1660
  }
1239
1661
  // synchronous patch
1240
1662
  patch(oldVNode, rootVnode);
1241
- {
1663
+ if (BUILD.slotRelocation) {
1242
1664
  // while we're moving nodes around existing nodes, temporarily disable
1243
1665
  // the disconnectCallback from working
1244
1666
  plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
@@ -1258,7 +1680,9 @@ const renderVdom = (hostRef, renderFnResults) => {
1258
1680
  // add a reference node marking this node's original location
1259
1681
  // keep a reference to this node for later lookups
1260
1682
  orgLocationNode =
1261
- doc.createTextNode('');
1683
+ BUILD.isDebug || BUILD.hydrateServerSide
1684
+ ? originalLocationDebugNode(nodeToRelocate)
1685
+ : doc.createTextNode('');
1262
1686
  orgLocationNode['s-nr'] = nodeToRelocate;
1263
1687
  nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1264
1688
  }
@@ -1315,16 +1739,23 @@ const renderVdom = (hostRef, renderFnResults) => {
1315
1739
  relocateNodes.length = 0;
1316
1740
  }
1317
1741
  };
1742
+ // slot comment debug nodes only created with the `--debug` flag
1743
+ // otherwise these nodes are text nodes w/out content
1744
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1745
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1746
+ (nodeToRelocate.localName
1747
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1748
+ : `[${nodeToRelocate.textContent}]`));
1318
1749
  const attachToAncestor = (hostRef, ancestorComponent) => {
1319
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1750
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1320
1751
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1321
1752
  }
1322
1753
  };
1323
1754
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1324
- {
1755
+ if (BUILD.taskQueue && BUILD.updatable) {
1325
1756
  hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1326
1757
  }
1327
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1758
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1328
1759
  hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1329
1760
  return;
1330
1761
  }
@@ -1333,30 +1764,34 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
1333
1764
  // has already fired off its lifecycle update then
1334
1765
  // fire off the initial update
1335
1766
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1336
- return writeTask(dispatch) ;
1767
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1337
1768
  };
1338
1769
  const dispatchHooks = (hostRef, isInitialLoad) => {
1770
+ const elm = hostRef.$hostElement$;
1339
1771
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1340
- const instance = hostRef.$lazyInstance$ ;
1772
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1341
1773
  let promise;
1342
1774
  if (isInitialLoad) {
1343
- {
1775
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1344
1776
  hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1345
1777
  if (hostRef.$queuedListeners$) {
1346
1778
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1347
1779
  hostRef.$queuedListeners$ = null;
1348
1780
  }
1349
1781
  }
1350
- {
1782
+ emitLifecycleEvent(elm, 'componentWillLoad');
1783
+ if (BUILD.cmpWillLoad) {
1351
1784
  promise = safeCall(instance, 'componentWillLoad');
1352
1785
  }
1353
1786
  }
1354
1787
  else {
1355
- {
1788
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1789
+ if (BUILD.cmpWillUpdate) {
1356
1790
  promise = safeCall(instance, 'componentWillUpdate');
1357
1791
  }
1358
1792
  }
1359
- {
1793
+ emitLifecycleEvent(elm, 'componentWillRender');
1794
+ if (BUILD.cmpWillRender) {
1360
1795
  promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1361
1796
  }
1362
1797
  endSchedule();
@@ -1367,15 +1802,46 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1367
1802
  const elm = hostRef.$hostElement$;
1368
1803
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1369
1804
  const rc = elm['s-rc'];
1370
- if (isInitialLoad) {
1805
+ if (BUILD.style && isInitialLoad) {
1371
1806
  // DOM WRITE!
1372
1807
  attachStyles(hostRef);
1373
1808
  }
1374
1809
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1375
- {
1376
- callRender(hostRef, instance);
1810
+ if (BUILD.isDev) {
1811
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1812
+ }
1813
+ if (BUILD.hydrateServerSide) {
1814
+ await callRender(hostRef, instance, elm);
1815
+ }
1816
+ else {
1817
+ callRender(hostRef, instance, elm);
1377
1818
  }
1378
- if (rc) {
1819
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1820
+ plt.$cssShim$.updateHost(elm);
1821
+ }
1822
+ if (BUILD.isDev) {
1823
+ hostRef.$renderCount$++;
1824
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1825
+ }
1826
+ if (BUILD.hydrateServerSide) {
1827
+ try {
1828
+ // manually connected child components during server-side hydrate
1829
+ serverSideConnected(elm);
1830
+ if (isInitialLoad) {
1831
+ // using only during server-side hydrate
1832
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1833
+ elm['s-en'] = '';
1834
+ }
1835
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1836
+ elm['s-en'] = 'c';
1837
+ }
1838
+ }
1839
+ }
1840
+ catch (e) {
1841
+ consoleError(e, elm);
1842
+ }
1843
+ }
1844
+ if (BUILD.asyncLoading && rc) {
1379
1845
  // ok, so turns out there are some child host elements
1380
1846
  // waiting on this parent element to load
1381
1847
  // let's fire off all update callbacks waiting
@@ -1384,7 +1850,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1384
1850
  }
1385
1851
  endRender();
1386
1852
  endUpdate();
1387
- {
1853
+ if (BUILD.asyncLoading) {
1388
1854
  const childrenPromises = elm['s-p'];
1389
1855
  const postUpdate = () => postUpdateComponent(hostRef);
1390
1856
  if (childrenPromises.length === 0) {
@@ -1396,26 +1862,42 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1396
1862
  childrenPromises.length = 0;
1397
1863
  }
1398
1864
  }
1865
+ else {
1866
+ postUpdateComponent(hostRef);
1867
+ }
1399
1868
  };
1400
1869
  const callRender = (hostRef, instance, elm) => {
1870
+ // in order for bundlers to correctly treeshake the BUILD object
1871
+ // we need to ensure BUILD is not deoptimized within a try/catch
1872
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1873
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1874
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1875
+ const taskQueue = BUILD.taskQueue ? true : false;
1876
+ const updatable = BUILD.updatable ? true : false;
1401
1877
  try {
1402
1878
  renderingRef = instance;
1403
- instance = instance.render() ;
1404
- {
1879
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1880
+ if (updatable && taskQueue) {
1405
1881
  hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1406
1882
  }
1407
- {
1883
+ if (updatable || lazyLoad) {
1408
1884
  hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1409
1885
  }
1410
- {
1411
- {
1886
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1887
+ if (BUILD.vdomRender || BUILD.reflect) {
1412
1888
  // looks like we've got child nodes to render into this host element
1413
1889
  // or we need to update the css class/attrs on the host element
1414
1890
  // DOM WRITE!
1415
- {
1891
+ if (BUILD.hydrateServerSide) {
1892
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1893
+ }
1894
+ else {
1416
1895
  renderVdom(hostRef, instance);
1417
1896
  }
1418
1897
  }
1898
+ else {
1899
+ elm.textContent = instance;
1900
+ }
1419
1901
  }
1420
1902
  }
1421
1903
  catch (e) {
@@ -1429,40 +1911,68 @@ const postUpdateComponent = (hostRef) => {
1429
1911
  const tagName = hostRef.$cmpMeta$.$tagName$;
1430
1912
  const elm = hostRef.$hostElement$;
1431
1913
  const endPostUpdate = createTime('postUpdate', tagName);
1432
- const instance = hostRef.$lazyInstance$ ;
1914
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1433
1915
  const ancestorComponent = hostRef.$ancestorComponent$;
1434
- {
1916
+ if (BUILD.cmpDidRender) {
1917
+ if (BUILD.isDev) {
1918
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1919
+ }
1435
1920
  safeCall(instance, 'componentDidRender');
1921
+ if (BUILD.isDev) {
1922
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1923
+ }
1436
1924
  }
1925
+ emitLifecycleEvent(elm, 'componentDidRender');
1437
1926
  if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1438
1927
  hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1439
- {
1928
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1440
1929
  // DOM WRITE!
1441
1930
  addHydratedFlag(elm);
1442
1931
  }
1443
- {
1932
+ if (BUILD.cmpDidLoad) {
1933
+ if (BUILD.isDev) {
1934
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1935
+ }
1444
1936
  safeCall(instance, 'componentDidLoad');
1937
+ if (BUILD.isDev) {
1938
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1939
+ }
1445
1940
  }
1941
+ emitLifecycleEvent(elm, 'componentDidLoad');
1446
1942
  endPostUpdate();
1447
- {
1943
+ if (BUILD.asyncLoading) {
1448
1944
  hostRef.$onReadyResolve$(elm);
1449
1945
  if (!ancestorComponent) {
1450
- appDidLoad();
1946
+ appDidLoad(tagName);
1451
1947
  }
1452
1948
  }
1453
1949
  }
1454
1950
  else {
1455
- {
1951
+ if (BUILD.cmpDidUpdate) {
1952
+ // we've already loaded this component
1953
+ // fire off the user's componentDidUpdate method (if one was provided)
1954
+ // componentDidUpdate runs AFTER render() has been called
1955
+ // and all child components have finished updating
1956
+ if (BUILD.isDev) {
1957
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1958
+ }
1456
1959
  safeCall(instance, 'componentDidUpdate');
1960
+ if (BUILD.isDev) {
1961
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1962
+ }
1457
1963
  }
1964
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1458
1965
  endPostUpdate();
1459
1966
  }
1460
- {
1967
+ if (BUILD.hotModuleReplacement) {
1968
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1969
+ }
1970
+ if (BUILD.method && BUILD.lazyLoad) {
1461
1971
  hostRef.$onInstanceResolve$(elm);
1462
1972
  }
1463
1973
  // load events fire from bottom to top
1464
1974
  // the deepest elements load first then bubbles up
1465
- {
1975
+ if (BUILD.asyncLoading) {
1466
1976
  if (hostRef.$onRenderResolve$) {
1467
1977
  hostRef.$onRenderResolve$();
1468
1978
  hostRef.$onRenderResolve$ = undefined;
@@ -1477,7 +1987,7 @@ const postUpdateComponent = (hostRef) => {
1477
1987
  // (⌐■_■)
1478
1988
  };
1479
1989
  const forceUpdate = (ref) => {
1480
- {
1990
+ if (BUILD.updatable) {
1481
1991
  const hostRef = getHostRef(ref);
1482
1992
  const isConnected = hostRef.$hostElement$.isConnected;
1483
1993
  if (isConnected &&
@@ -1487,14 +1997,21 @@ const forceUpdate = (ref) => {
1487
1997
  // Returns "true" when the forced update was successfully scheduled
1488
1998
  return isConnected;
1489
1999
  }
2000
+ return false;
1490
2001
  };
1491
2002
  const appDidLoad = (who) => {
1492
2003
  // on appload
1493
2004
  // we have finish the first big initial render
1494
- {
2005
+ if (BUILD.cssAnnotations) {
1495
2006
  addHydratedFlag(doc.documentElement);
1496
2007
  }
2008
+ if (BUILD.asyncQueue) {
2009
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2010
+ }
1497
2011
  nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2012
+ if (BUILD.profile && performance.measure) {
2013
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
2014
+ }
1498
2015
  };
1499
2016
  const safeCall = (instance, method, arg) => {
1500
2017
  if (instance && instance[method]) {
@@ -1510,27 +2027,61 @@ const safeCall = (instance, method, arg) => {
1510
2027
  const then = (promise, thenFn) => {
1511
2028
  return promise && promise.then ? promise.then(thenFn) : thenFn();
1512
2029
  };
1513
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1514
- ;
2030
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2031
+ if (BUILD.lifecycleDOMEvents) {
2032
+ emitEvent(elm, 'stencil_' + lifecycleName, {
2033
+ bubbles: true,
2034
+ composed: true,
2035
+ detail: {
2036
+ namespace: NAMESPACE,
2037
+ },
2038
+ });
2039
+ }
2040
+ };
2041
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2042
+ ? elm.classList.add('hydrated')
2043
+ : BUILD.hydratedAttribute
2044
+ ? elm.setAttribute('hydrated', '')
2045
+ : undefined;
2046
+ const serverSideConnected = (elm) => {
2047
+ const children = elm.children;
2048
+ if (children != null) {
2049
+ for (let i = 0, ii = children.length; i < ii; i++) {
2050
+ const childElm = children[i];
2051
+ if (typeof childElm.connectedCallback === 'function') {
2052
+ childElm.connectedCallback();
2053
+ }
2054
+ serverSideConnected(childElm);
2055
+ }
2056
+ }
2057
+ };
1515
2058
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1516
2059
  const setValue = (ref, propName, newVal, cmpMeta) => {
1517
2060
  // check our new property value against our internal value
1518
2061
  const hostRef = getHostRef(ref);
1519
- const elm = hostRef.$hostElement$ ;
2062
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1520
2063
  const oldVal = hostRef.$instanceValues$.get(propName);
1521
2064
  const flags = hostRef.$flags$;
1522
- const instance = hostRef.$lazyInstance$ ;
2065
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1523
2066
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1524
2067
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1525
2068
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1526
2069
  const didValueChange = newVal !== oldVal && !areBothNaN;
1527
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2070
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1528
2071
  // gadzooks! the property's value has changed!!
1529
2072
  // set our new value!
1530
2073
  hostRef.$instanceValues$.set(propName, newVal);
1531
- if (instance) {
2074
+ if (BUILD.isDev) {
2075
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2076
+ consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2077
+ }
2078
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2079
+ consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2080
+ }
2081
+ }
2082
+ if (!BUILD.lazyLoad || instance) {
1532
2083
  // get an array of method names of watch functions to call
1533
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2084
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1534
2085
  const watchMethods = cmpMeta.$watchers$[propName];
1535
2086
  if (watchMethods) {
1536
2087
  // this instance is watching for when this property changed
@@ -1545,8 +2096,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1545
2096
  });
1546
2097
  }
1547
2098
  }
1548
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1549
- if (instance.componentShouldUpdate) {
2099
+ if (BUILD.updatable &&
2100
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2101
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1550
2102
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1551
2103
  return;
1552
2104
  }
@@ -1571,16 +2123,17 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1571
2123
  * @returns a reference to the same constructor passed in (but now mutated)
1572
2124
  */
1573
2125
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1574
- if (cmpMeta.$members$) {
1575
- if (Cstr.watchers) {
2126
+ if (BUILD.member && cmpMeta.$members$) {
2127
+ if (BUILD.watchCallback && Cstr.watchers) {
1576
2128
  cmpMeta.$watchers$ = Cstr.watchers;
1577
2129
  }
1578
2130
  // It's better to have a const than two Object.entries()
1579
2131
  const members = Object.entries(cmpMeta.$members$);
1580
2132
  const prototype = Cstr.prototype;
1581
2133
  members.map(([memberName, [memberFlags]]) => {
1582
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1583
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2134
+ if ((BUILD.prop || BUILD.state) &&
2135
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2136
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1584
2137
  // proxyComponent - prop
1585
2138
  Object.defineProperty(prototype, memberName, {
1586
2139
  get() {
@@ -1588,6 +2141,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1588
2141
  return getValue(this, memberName);
1589
2142
  },
1590
2143
  set(newValue) {
2144
+ // only during dev time
2145
+ if (BUILD.isDev) {
2146
+ const ref = getHostRef(this);
2147
+ if (
2148
+ // we are proxying the instance (not element)
2149
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2150
+ // the element is not constructing
2151
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2152
+ // the member is a prop
2153
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2154
+ // the member is not mutable
2155
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2156
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2157
+ }
2158
+ }
1591
2159
  // proxyComponent, set value
1592
2160
  setValue(this, memberName, newValue, cmpMeta);
1593
2161
  },
@@ -1595,7 +2163,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1595
2163
  enumerable: true,
1596
2164
  });
1597
2165
  }
1598
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2166
+ else if (BUILD.lazyLoad &&
2167
+ BUILD.method &&
2168
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1599
2169
  memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1600
2170
  // proxyComponent - method
1601
2171
  Object.defineProperty(prototype, memberName, {
@@ -1606,7 +2176,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1606
2176
  });
1607
2177
  }
1608
2178
  });
1609
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2179
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1610
2180
  const attrNameToPropName = new Map();
1611
2181
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1612
2182
  plt.jmp(() => {
@@ -1666,7 +2236,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1666
2236
  .map(([propName, m]) => {
1667
2237
  const attrName = m[1] || propName;
1668
2238
  attrNameToPropName.set(attrName, propName);
1669
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2239
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1670
2240
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1671
2241
  }
1672
2242
  return attrName;
@@ -1677,25 +2247,29 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1677
2247
  };
1678
2248
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1679
2249
  // initializeComponent
1680
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1681
- {
2250
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2251
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2252
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
1682
2253
  // we haven't initialized this element yet
1683
2254
  hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1684
2255
  // lazy loaded components
1685
2256
  // request the component's implementation to be
1686
2257
  // wired up with the host element
1687
- Cstr = loadModule(cmpMeta);
2258
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
1688
2259
  if (Cstr.then) {
1689
2260
  // Await creates a micro-task avoid if possible
1690
- const endLoad = uniqueTime();
2261
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
1691
2262
  Cstr = await Cstr;
1692
2263
  endLoad();
1693
2264
  }
1694
- if (!Cstr.isProxied) {
2265
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2266
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2267
+ }
2268
+ if (BUILD.member && !Cstr.isProxied) {
1695
2269
  // we've never proxied this Constructor before
1696
2270
  // let's add the getters/setters to its prototype before
1697
2271
  // the first time we create an instance of the implementation
1698
- {
2272
+ if (BUILD.watchCallback) {
1699
2273
  cmpMeta.$watchers$ = Cstr.watchers;
1700
2274
  }
1701
2275
  proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
@@ -1705,7 +2279,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1705
2279
  // ok, time to construct the instance
1706
2280
  // but let's keep track of when we start and stop
1707
2281
  // so that the getters/setters don't incorrectly step on data
1708
- {
2282
+ if (BUILD.member) {
1709
2283
  hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1710
2284
  }
1711
2285
  // construct the lazy-loaded component implementation
@@ -1718,21 +2292,42 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1718
2292
  catch (e) {
1719
2293
  consoleError(e);
1720
2294
  }
1721
- {
2295
+ if (BUILD.member) {
1722
2296
  hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1723
2297
  }
1724
- {
2298
+ if (BUILD.watchCallback) {
1725
2299
  hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1726
2300
  }
1727
2301
  endNewInstance();
1728
2302
  fireConnectedCallback(hostRef.$lazyInstance$);
1729
2303
  }
1730
- if (Cstr.style) {
2304
+ else {
2305
+ // sync constructor component
2306
+ Cstr = elm.constructor;
2307
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2308
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2309
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2310
+ // Stencil has completed instantiating the component.
2311
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2312
+ }
2313
+ if (BUILD.style && Cstr.style) {
1731
2314
  // this component has styles but we haven't registered them yet
1732
2315
  let style = Cstr.style;
1733
- const scopeId = getScopeId(cmpMeta);
2316
+ if (BUILD.mode && typeof style !== 'string') {
2317
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2318
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2319
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2320
+ }
2321
+ }
2322
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
1734
2323
  if (!styles.has(scopeId)) {
1735
2324
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2325
+ if (!BUILD.hydrateServerSide &&
2326
+ BUILD.shadowDom &&
2327
+ BUILD.shadowDomShim &&
2328
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2329
+ style = await import('./shadow-css-98135883.js').then((m) => m.scopeCss(style, scopeId, false));
2330
+ }
1736
2331
  registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1737
2332
  endRegisterStyles();
1738
2333
  }
@@ -1741,7 +2336,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1741
2336
  // we've successfully created a lazy instance
1742
2337
  const ancestorComponent = hostRef.$ancestorComponent$;
1743
2338
  const schedule = () => scheduleUpdate(hostRef, true);
1744
- if (ancestorComponent && ancestorComponent['s-rc']) {
2339
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
1745
2340
  // this is the initial load and this component it has an ancestor component
1746
2341
  // but the ancestor component has NOT fired its will update lifecycle yet
1747
2342
  // so let's just cool our jets and wait for the ancestor to continue first
@@ -1755,7 +2350,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1755
2350
  }
1756
2351
  };
1757
2352
  const fireConnectedCallback = (instance) => {
1758
- {
2353
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
1759
2354
  safeCall(instance, 'connectedCallback');
1760
2355
  }
1761
2356
  };
@@ -1764,26 +2359,49 @@ const connectedCallback = (elm) => {
1764
2359
  const hostRef = getHostRef(elm);
1765
2360
  const cmpMeta = hostRef.$cmpMeta$;
1766
2361
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2362
+ if (BUILD.hostListenerTargetParent) {
2363
+ // only run if we have listeners being attached to a parent
2364
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2365
+ }
1767
2366
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1768
2367
  // first time this component has connected
1769
2368
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1770
- {
2369
+ let hostId;
2370
+ if (BUILD.hydrateClientSide) {
2371
+ hostId = elm.getAttribute(HYDRATE_ID);
2372
+ if (hostId) {
2373
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2374
+ const scopeId = BUILD.mode
2375
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2376
+ : addStyle(elm.shadowRoot, cmpMeta);
2377
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2378
+ }
2379
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2380
+ }
2381
+ }
2382
+ if (BUILD.slotRelocation && !hostId) {
1771
2383
  // initUpdate
1772
2384
  // if the slot polyfill is required we'll need to put some nodes
1773
2385
  // in here to act as original content anchors as we move nodes around
1774
2386
  // host element has been connected to the DOM
1775
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2387
+ if (BUILD.hydrateServerSide ||
2388
+ ((BUILD.slot || BUILD.shadowDom) &&
2389
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1776
2390
  setContentReference(elm);
1777
2391
  }
1778
2392
  }
1779
- {
2393
+ if (BUILD.asyncLoading) {
1780
2394
  // find the first ancestor component (if there is one) and register
1781
2395
  // this component as one of the actively loading child components for its ancestor
1782
2396
  let ancestorComponent = elm;
1783
2397
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1784
2398
  // climb up the ancestors looking for the first
1785
2399
  // component that hasn't finished its lifecycle update yet
1786
- if (ancestorComponent['s-p']) {
2400
+ if ((BUILD.hydrateClientSide &&
2401
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2402
+ ancestorComponent.hasAttribute('s-id') &&
2403
+ ancestorComponent['s-p']) ||
2404
+ ancestorComponent['s-p']) {
1787
2405
  // we found this components first ancestor component
1788
2406
  // keep a reference to this component's ancestor component
1789
2407
  attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
@@ -1793,7 +2411,7 @@ const connectedCallback = (elm) => {
1793
2411
  }
1794
2412
  // Lazy properties
1795
2413
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1796
- if (cmpMeta.$members$) {
2414
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
1797
2415
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1798
2416
  if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1799
2417
  const value = elm[memberName];
@@ -1802,7 +2420,14 @@ const connectedCallback = (elm) => {
1802
2420
  }
1803
2421
  });
1804
2422
  }
1805
- {
2423
+ if (BUILD.initializeNextTick) {
2424
+ // connectedCallback, taskQueue, initialLoad
2425
+ // angular sets attribute AFTER connectCallback
2426
+ // https://github.com/angular/angular/issues/18909
2427
+ // https://github.com/angular/angular/issues/19940
2428
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2429
+ }
2430
+ else {
1806
2431
  initializeComponent(elm, hostRef, cmpMeta);
1807
2432
  }
1808
2433
  }
@@ -1810,7 +2435,7 @@ const connectedCallback = (elm) => {
1810
2435
  // not the first time this has connected
1811
2436
  // reattach any event listeners to the host
1812
2437
  // since they would have been removed when disconnected
1813
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2438
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
1814
2439
  // fire off connectedCallback() on component instance
1815
2440
  fireConnectedCallback(hostRef.$lazyInstance$);
1816
2441
  }
@@ -1824,34 +2449,345 @@ const setContentReference = (elm) => {
1824
2449
  // let's pick out the inner content for slot projection
1825
2450
  // create a node to represent where the original
1826
2451
  // content was first placed, which is useful later on
1827
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2452
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
1828
2453
  contentRefElm['s-cn'] = true;
1829
2454
  elm.insertBefore(contentRefElm, elm.firstChild);
1830
2455
  };
1831
2456
  const disconnectedCallback = (elm) => {
1832
2457
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1833
2458
  const hostRef = getHostRef(elm);
1834
- const instance = hostRef.$lazyInstance$ ;
1835
- {
2459
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2460
+ if (BUILD.hostListener) {
1836
2461
  if (hostRef.$rmListeners$) {
1837
2462
  hostRef.$rmListeners$.map((rmListener) => rmListener());
1838
2463
  hostRef.$rmListeners$ = undefined;
1839
2464
  }
1840
2465
  }
1841
- {
2466
+ // clear CSS var-shim tracking
2467
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2468
+ plt.$cssShim$.removeHost(elm);
2469
+ }
2470
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
1842
2471
  safeCall(instance, 'disconnectedCallback');
1843
2472
  }
2473
+ if (BUILD.cmpDidUnload) {
2474
+ safeCall(instance, 'componentDidUnload');
2475
+ }
1844
2476
  }
1845
2477
  };
2478
+ const defineCustomElement = (Cstr, compactMeta) => {
2479
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2480
+ };
2481
+ const proxyCustomElement = (Cstr, compactMeta) => {
2482
+ const cmpMeta = {
2483
+ $flags$: compactMeta[0],
2484
+ $tagName$: compactMeta[1],
2485
+ };
2486
+ if (BUILD.member) {
2487
+ cmpMeta.$members$ = compactMeta[2];
2488
+ }
2489
+ if (BUILD.hostListener) {
2490
+ cmpMeta.$listeners$ = compactMeta[3];
2491
+ }
2492
+ if (BUILD.watchCallback) {
2493
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2494
+ }
2495
+ if (BUILD.reflect) {
2496
+ cmpMeta.$attrsToReflect$ = [];
2497
+ }
2498
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2499
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2500
+ }
2501
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2502
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2503
+ Object.assign(Cstr.prototype, {
2504
+ __registerHost() {
2505
+ registerHost(this, cmpMeta);
2506
+ },
2507
+ connectedCallback() {
2508
+ connectedCallback(this);
2509
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2510
+ originalConnectedCallback.call(this);
2511
+ }
2512
+ },
2513
+ disconnectedCallback() {
2514
+ disconnectedCallback(this);
2515
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2516
+ originalDisconnectedCallback.call(this);
2517
+ }
2518
+ },
2519
+ __attachShadow() {
2520
+ if (supportsShadow) {
2521
+ if (BUILD.shadowDelegatesFocus) {
2522
+ this.attachShadow({
2523
+ mode: 'open',
2524
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2525
+ });
2526
+ }
2527
+ else {
2528
+ this.attachShadow({ mode: 'open' });
2529
+ }
2530
+ }
2531
+ else {
2532
+ this.shadowRoot = this;
2533
+ }
2534
+ },
2535
+ });
2536
+ Cstr.is = cmpMeta.$tagName$;
2537
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2538
+ };
2539
+ const forceModeUpdate = (elm) => {
2540
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2541
+ const mode = computeMode(elm);
2542
+ const hostRef = getHostRef(elm);
2543
+ if (hostRef.$modeName$ !== mode) {
2544
+ const cmpMeta = hostRef.$cmpMeta$;
2545
+ const oldScopeId = elm['s-sc'];
2546
+ const scopeId = getScopeId(cmpMeta, mode);
2547
+ const style = elm.constructor.style[mode];
2548
+ const flags = cmpMeta.$flags$;
2549
+ if (style) {
2550
+ if (!styles.has(scopeId)) {
2551
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2552
+ }
2553
+ hostRef.$modeName$ = mode;
2554
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2555
+ attachStyles(hostRef);
2556
+ forceUpdate(elm);
2557
+ }
2558
+ }
2559
+ }
2560
+ };
2561
+ const patchCloneNode = (HostElementPrototype) => {
2562
+ const orgCloneNode = HostElementPrototype.cloneNode;
2563
+ HostElementPrototype.cloneNode = function (deep) {
2564
+ const srcNode = this;
2565
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2566
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2567
+ if (BUILD.slot && !isShadowDom && deep) {
2568
+ let i = 0;
2569
+ let slotted, nonStencilNode;
2570
+ const stencilPrivates = [
2571
+ 's-id',
2572
+ 's-cr',
2573
+ 's-lr',
2574
+ 's-rc',
2575
+ 's-sc',
2576
+ 's-p',
2577
+ 's-cn',
2578
+ 's-sr',
2579
+ 's-sn',
2580
+ 's-hn',
2581
+ 's-ol',
2582
+ 's-nr',
2583
+ 's-si',
2584
+ ];
2585
+ for (; i < srcNode.childNodes.length; i++) {
2586
+ slotted = srcNode.childNodes[i]['s-nr'];
2587
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2588
+ if (slotted) {
2589
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2590
+ clonedNode.__appendChild(slotted.cloneNode(true));
2591
+ }
2592
+ else {
2593
+ clonedNode.appendChild(slotted.cloneNode(true));
2594
+ }
2595
+ }
2596
+ if (nonStencilNode) {
2597
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2598
+ }
2599
+ }
2600
+ }
2601
+ return clonedNode;
2602
+ };
2603
+ };
2604
+ const patchSlotAppendChild = (HostElementPrototype) => {
2605
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2606
+ HostElementPrototype.appendChild = function (newChild) {
2607
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2608
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2609
+ if (slotNode) {
2610
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2611
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2612
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2613
+ }
2614
+ return this.__appendChild(newChild);
2615
+ };
2616
+ };
2617
+ /**
2618
+ * Patches the text content of an unnamed slotted node inside a scoped component
2619
+ * @param hostElementPrototype the `Element` to be patched
2620
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2621
+ */
2622
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2623
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2624
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2625
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2626
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2627
+ get() {
2628
+ var _a;
2629
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2630
+ // the empty string
2631
+ const slotNode = getHostSlotNode(this.childNodes, '');
2632
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2633
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2634
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2635
+ return slotNode.nextSibling.textContent;
2636
+ }
2637
+ else if (slotNode) {
2638
+ return slotNode.textContent;
2639
+ }
2640
+ else {
2641
+ // fallback to the original implementation
2642
+ return this.__textContent;
2643
+ }
2644
+ },
2645
+ set(value) {
2646
+ var _a;
2647
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2648
+ // the empty string
2649
+ const slotNode = getHostSlotNode(this.childNodes, '');
2650
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2651
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2652
+ // sibling.
2653
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2654
+ slotNode.nextSibling.textContent = value;
2655
+ }
2656
+ else if (slotNode) {
2657
+ slotNode.textContent = value;
2658
+ }
2659
+ else {
2660
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2661
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2662
+ // it there
2663
+ this.__textContent = value;
2664
+ const contentRefElm = this['s-cr'];
2665
+ if (contentRefElm) {
2666
+ this.insertBefore(contentRefElm, this.firstChild);
2667
+ }
2668
+ }
2669
+ },
2670
+ });
2671
+ }
2672
+ };
2673
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2674
+ class FakeNodeList extends Array {
2675
+ item(n) {
2676
+ return this[n];
2677
+ }
2678
+ }
2679
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2680
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2681
+ Object.defineProperty(elm, 'children', {
2682
+ get() {
2683
+ return this.childNodes.map((n) => n.nodeType === 1);
2684
+ },
2685
+ });
2686
+ Object.defineProperty(elm, 'childElementCount', {
2687
+ get() {
2688
+ return elm.children.length;
2689
+ },
2690
+ });
2691
+ Object.defineProperty(elm, 'childNodes', {
2692
+ get() {
2693
+ const childNodes = childNodesFn.call(this);
2694
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2695
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2696
+ const result = new FakeNodeList();
2697
+ for (let i = 0; i < childNodes.length; i++) {
2698
+ const slot = childNodes[i]['s-nr'];
2699
+ if (slot) {
2700
+ result.push(slot);
2701
+ }
2702
+ }
2703
+ return result;
2704
+ }
2705
+ return FakeNodeList.from(childNodes);
2706
+ },
2707
+ });
2708
+ }
2709
+ };
2710
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2711
+ /**
2712
+ * Recursively searches a series of child nodes for a slot with the provided name.
2713
+ * @param childNodes the nodes to search for a slot with a specific name.
2714
+ * @param slotName the name of the slot to match on.
2715
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2716
+ */
2717
+ const getHostSlotNode = (childNodes, slotName) => {
2718
+ let i = 0;
2719
+ let childNode;
2720
+ for (; i < childNodes.length; i++) {
2721
+ childNode = childNodes[i];
2722
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2723
+ return childNode;
2724
+ }
2725
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2726
+ if (childNode) {
2727
+ return childNode;
2728
+ }
2729
+ }
2730
+ return null;
2731
+ };
2732
+ const getHostSlotChildNodes = (n, slotName) => {
2733
+ const childNodes = [n];
2734
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2735
+ childNodes.push(n);
2736
+ }
2737
+ return childNodes;
2738
+ };
2739
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2740
+ // ¯\_(ツ)_/¯
2741
+ const hostRef = getHostRef(elm);
2742
+ // reset state flags to only have been connected
2743
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2744
+ // TODO
2745
+ // detatch any event listeners that may have been added
2746
+ // because we're not passing an exact event name it'll
2747
+ // remove all of this element's event, which is good
2748
+ // create a callback for when this component finishes hmr
2749
+ elm['s-hmr-load'] = () => {
2750
+ // finished hmr for this element
2751
+ delete elm['s-hmr-load'];
2752
+ };
2753
+ // re-initialize the component
2754
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2755
+ };
1846
2756
  const bootstrapLazy = (lazyBundles, options = {}) => {
1847
- const endBootstrap = createTime();
2757
+ var _a;
2758
+ if (BUILD.profile && performance.mark) {
2759
+ performance.mark('st:app:start');
2760
+ }
2761
+ installDevTools();
2762
+ const endBootstrap = createTime('bootstrapLazy');
2763
+ const cmpTags = [];
1848
2764
  const exclude = options.exclude || [];
1849
2765
  const customElements = win.customElements;
2766
+ const head = doc.head;
2767
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2768
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1850
2769
  const deferredConnectedCallbacks = [];
2770
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1851
2771
  let appLoadFallback;
1852
2772
  let isBootstrapping = true;
2773
+ let i = 0;
1853
2774
  Object.assign(plt, options);
1854
2775
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2776
+ if (BUILD.asyncQueue) {
2777
+ if (options.syncQueue) {
2778
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2779
+ }
2780
+ }
2781
+ if (BUILD.hydrateClientSide) {
2782
+ // If the app is already hydrated there is not point to disable the
2783
+ // async queue. This will improve the first input delay
2784
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2785
+ }
2786
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2787
+ for (; i < styles.length; i++) {
2788
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2789
+ }
2790
+ }
1855
2791
  lazyBundles.map((lazyBundle) => {
1856
2792
  lazyBundle[1].map((compactMeta) => {
1857
2793
  const cmpMeta = {
@@ -1860,19 +2796,24 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1860
2796
  $members$: compactMeta[2],
1861
2797
  $listeners$: compactMeta[3],
1862
2798
  };
1863
- {
2799
+ if (BUILD.member) {
1864
2800
  cmpMeta.$members$ = compactMeta[2];
1865
2801
  }
1866
- {
2802
+ if (BUILD.hostListener) {
1867
2803
  cmpMeta.$listeners$ = compactMeta[3];
1868
2804
  }
1869
- {
2805
+ if (BUILD.reflect) {
1870
2806
  cmpMeta.$attrsToReflect$ = [];
1871
2807
  }
1872
- {
2808
+ if (BUILD.watchCallback) {
1873
2809
  cmpMeta.$watchers$ = {};
1874
2810
  }
1875
- const tagName = cmpMeta.$tagName$;
2811
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2812
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2813
+ }
2814
+ const tagName = BUILD.transformTagName && options.transformTagName
2815
+ ? options.transformTagName(cmpMeta.$tagName$)
2816
+ : cmpMeta.$tagName$;
1876
2817
  const HostElement = class extends HTMLElement {
1877
2818
  // StencilLazyHost
1878
2819
  constructor(self) {
@@ -1880,16 +2821,28 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1880
2821
  super(self);
1881
2822
  self = this;
1882
2823
  registerHost(self, cmpMeta);
1883
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2824
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1884
2825
  // this component is using shadow dom
1885
2826
  // and this browser supports shadow dom
1886
2827
  // add the read-only property "shadowRoot" to the host element
1887
2828
  // adding the shadow root build conditionals to minimize runtime
1888
- {
1889
- {
2829
+ if (supportsShadow) {
2830
+ if (BUILD.shadowDelegatesFocus) {
2831
+ self.attachShadow({
2832
+ mode: 'open',
2833
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2834
+ });
2835
+ }
2836
+ else {
1890
2837
  self.attachShadow({ mode: 'open' });
1891
2838
  }
1892
2839
  }
2840
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2841
+ self.shadowRoot = self;
2842
+ }
2843
+ }
2844
+ if (BUILD.slotChildNodesFix) {
2845
+ patchChildSlotNodes(self, cmpMeta);
1893
2846
  }
1894
2847
  }
1895
2848
  connectedCallback() {
@@ -1912,30 +2865,126 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1912
2865
  return getHostRef(this).$onReadyPromise$;
1913
2866
  }
1914
2867
  };
2868
+ if (BUILD.cloneNodeFix) {
2869
+ patchCloneNode(HostElement.prototype);
2870
+ }
2871
+ if (BUILD.appendChildSlotFix) {
2872
+ patchSlotAppendChild(HostElement.prototype);
2873
+ }
2874
+ if (BUILD.hotModuleReplacement) {
2875
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2876
+ hmrStart(this, cmpMeta, hmrVersionId);
2877
+ };
2878
+ }
2879
+ if (BUILD.scopedSlotTextContentFix) {
2880
+ patchTextContent(HostElement.prototype, cmpMeta);
2881
+ }
1915
2882
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1916
2883
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2884
+ cmpTags.push(tagName);
1917
2885
  customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1918
2886
  }
1919
2887
  });
1920
2888
  });
2889
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2890
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2891
+ visibilityStyle.setAttribute('data-styles', '');
2892
+ // Apply CSP nonce to the style tag if it exists
2893
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2894
+ if (nonce != null) {
2895
+ visibilityStyle.setAttribute('nonce', nonce);
2896
+ }
2897
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2898
+ }
1921
2899
  // Process deferred connectedCallbacks now all components have been registered
1922
2900
  isBootstrapping = false;
1923
2901
  if (deferredConnectedCallbacks.length) {
1924
2902
  deferredConnectedCallbacks.map((host) => host.connectedCallback());
1925
2903
  }
1926
2904
  else {
1927
- {
2905
+ if (BUILD.profile) {
2906
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2907
+ }
2908
+ else {
1928
2909
  plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1929
2910
  }
1930
2911
  }
1931
2912
  // Fallback appLoad event
1932
2913
  endBootstrap();
1933
2914
  };
2915
+ const getConnect = (_ref, tagName) => {
2916
+ const componentOnReady = () => {
2917
+ let elm = doc.querySelector(tagName);
2918
+ if (!elm) {
2919
+ elm = doc.createElement(tagName);
2920
+ doc.body.appendChild(elm);
2921
+ }
2922
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2923
+ };
2924
+ const create = (...args) => {
2925
+ return componentOnReady().then((el) => el.create(...args));
2926
+ };
2927
+ return {
2928
+ create,
2929
+ componentOnReady,
2930
+ };
2931
+ };
2932
+ const getContext = (_elm, context) => {
2933
+ if (context in Context) {
2934
+ return Context[context];
2935
+ }
2936
+ else if (context === 'window') {
2937
+ return win;
2938
+ }
2939
+ else if (context === 'document') {
2940
+ return doc;
2941
+ }
2942
+ else if (context === 'isServer' || context === 'isPrerender') {
2943
+ return BUILD.hydrateServerSide ? true : false;
2944
+ }
2945
+ else if (context === 'isClient') {
2946
+ return BUILD.hydrateServerSide ? false : true;
2947
+ }
2948
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2949
+ return getAssetPath('.');
2950
+ }
2951
+ else if (context === 'queue') {
2952
+ return {
2953
+ write: writeTask,
2954
+ read: readTask,
2955
+ tick: {
2956
+ then(cb) {
2957
+ return nextTick(cb);
2958
+ },
2959
+ },
2960
+ };
2961
+ }
2962
+ return undefined;
2963
+ };
1934
2964
  const Fragment = (_, children) => children;
1935
2965
  const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1936
- if (listeners) {
2966
+ if (BUILD.hostListener && listeners) {
2967
+ // this is called immediately within the element's constructor
2968
+ // initialize our event listeners on the host element
2969
+ // we do this now so that we can listen to events that may
2970
+ // have fired even before the instance is ready
2971
+ if (BUILD.hostListenerTargetParent) {
2972
+ // this component may have event listeners that should be attached to the parent
2973
+ if (attachParentListeners) {
2974
+ // this is being ran from within the connectedCallback
2975
+ // which is important so that we know the host element actually has a parent element
2976
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2977
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
2978
+ }
2979
+ else {
2980
+ // this is being ran from within the component constructor
2981
+ // everything BUT the parent element listeners should be attached at this time
2982
+ // filter out the listeners that are NOT being attached to the parent
2983
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
2984
+ }
2985
+ }
1937
2986
  listeners.map(([flags, name, method]) => {
1938
- const target = getHostListenerTarget(elm, flags) ;
2987
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
1939
2988
  const handler = hostListenerProxy(hostRef, method);
1940
2989
  const opts = hostListenerOpts(flags);
1941
2990
  plt.ael(target, name, handler, opts);
@@ -1945,7 +2994,7 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
1945
2994
  };
1946
2995
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
1947
2996
  try {
1948
- {
2997
+ if (BUILD.lazyLoad) {
1949
2998
  if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1950
2999
  // instance is ready, let's call it's member method for this event
1951
3000
  hostRef.$lazyInstance$[methodName](ev);
@@ -1954,20 +3003,32 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1954
3003
  (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1955
3004
  }
1956
3005
  }
3006
+ else {
3007
+ hostRef.$hostElement$[methodName](ev);
3008
+ }
1957
3009
  }
1958
3010
  catch (e) {
1959
3011
  consoleError(e);
1960
3012
  }
1961
3013
  };
1962
3014
  const getHostListenerTarget = (elm, flags) => {
1963
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3015
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3016
+ return doc;
3017
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1964
3018
  return win;
1965
- if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
3019
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
1966
3020
  return doc.body;
3021
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3022
+ return elm.parentElement;
1967
3023
  return elm;
1968
3024
  };
1969
3025
  // prettier-ignore
1970
- const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3026
+ const hostListenerOpts = (flags) => supportsListenerOptions
3027
+ ? ({
3028
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3029
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3030
+ })
3031
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1971
3032
  /**
1972
3033
  * Assigns the given value to the nonce property on the runtime platform object.
1973
3034
  * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
@@ -1975,6 +3036,146 @@ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !==
1975
3036
  * @returns void
1976
3037
  */
1977
3038
  const setNonce = (nonce) => (plt.$nonce$ = nonce);
3039
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
3040
+ const insertVdomAnnotations = (doc, staticComponents) => {
3041
+ if (doc != null) {
3042
+ const docData = {
3043
+ hostIds: 0,
3044
+ rootLevelIds: 0,
3045
+ staticComponents: new Set(staticComponents),
3046
+ };
3047
+ const orgLocationNodes = [];
3048
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3049
+ orgLocationNodes.forEach((orgLocationNode) => {
3050
+ if (orgLocationNode != null) {
3051
+ const nodeRef = orgLocationNode['s-nr'];
3052
+ let hostId = nodeRef['s-host-id'];
3053
+ let nodeId = nodeRef['s-node-id'];
3054
+ let childId = `${hostId}.${nodeId}`;
3055
+ if (hostId == null) {
3056
+ hostId = 0;
3057
+ docData.rootLevelIds++;
3058
+ nodeId = docData.rootLevelIds;
3059
+ childId = `${hostId}.${nodeId}`;
3060
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3061
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3062
+ }
3063
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
3064
+ if (hostId === 0) {
3065
+ const textContent = nodeRef.nodeValue.trim();
3066
+ if (textContent === '') {
3067
+ // useless whitespace node at the document root
3068
+ orgLocationNode.remove();
3069
+ return;
3070
+ }
3071
+ }
3072
+ const commentBeforeTextNode = doc.createComment(childId);
3073
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3074
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3075
+ }
3076
+ }
3077
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3078
+ const orgLocationParentNode = orgLocationNode.parentElement;
3079
+ if (orgLocationParentNode) {
3080
+ if (orgLocationParentNode['s-en'] === '') {
3081
+ // ending with a "." means that the parent element
3082
+ // of this node's original location is a SHADOW dom element
3083
+ // and this node is apart of the root level light dom
3084
+ orgLocationNodeId += `.`;
3085
+ }
3086
+ else if (orgLocationParentNode['s-en'] === 'c') {
3087
+ // ending with a ".c" means that the parent element
3088
+ // of this node's original location is a SCOPED element
3089
+ // and this node is apart of the root level light dom
3090
+ orgLocationNodeId += `.c`;
3091
+ }
3092
+ }
3093
+ orgLocationNode.nodeValue = orgLocationNodeId;
3094
+ }
3095
+ });
3096
+ }
3097
+ };
3098
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3099
+ if (node == null) {
3100
+ return;
3101
+ }
3102
+ if (node['s-nr'] != null) {
3103
+ orgLocationNodes.push(node);
3104
+ }
3105
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3106
+ node.childNodes.forEach((childNode) => {
3107
+ const hostRef = getHostRef(childNode);
3108
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3109
+ const cmpData = {
3110
+ nodeIds: 0,
3111
+ };
3112
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3113
+ }
3114
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3115
+ });
3116
+ }
3117
+ };
3118
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3119
+ if (vnode != null) {
3120
+ const hostId = ++docData.hostIds;
3121
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3122
+ if (hostElm['s-cr'] != null) {
3123
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3124
+ }
3125
+ if (vnode.$children$ != null) {
3126
+ const depth = 0;
3127
+ vnode.$children$.forEach((vnodeChild, index) => {
3128
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3129
+ });
3130
+ }
3131
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3132
+ const parent = hostElm.parentElement;
3133
+ if (parent && parent.childNodes) {
3134
+ const parentChildNodes = Array.from(parent.childNodes);
3135
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3136
+ if (comment) {
3137
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3138
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3139
+ }
3140
+ }
3141
+ }
3142
+ }
3143
+ };
3144
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3145
+ const childElm = vnodeChild.$elm$;
3146
+ if (childElm == null) {
3147
+ return;
3148
+ }
3149
+ const nodeId = cmpData.nodeIds++;
3150
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3151
+ childElm['s-host-id'] = hostId;
3152
+ childElm['s-node-id'] = nodeId;
3153
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3154
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3155
+ }
3156
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3157
+ const parentNode = childElm.parentNode;
3158
+ const nodeName = parentNode.nodeName;
3159
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3160
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3161
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3162
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3163
+ }
3164
+ }
3165
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3166
+ if (childElm['s-sr']) {
3167
+ const slotName = childElm['s-sn'] || '';
3168
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3169
+ childElm.nodeValue = slotNodeId;
3170
+ }
3171
+ }
3172
+ if (vnodeChild.$children$ != null) {
3173
+ const childDepth = depth + 1;
3174
+ vnodeChild.$children$.forEach((vnode, index) => {
3175
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3176
+ });
3177
+ }
3178
+ };
1978
3179
  const hostRefs = /*@__PURE__*/ new WeakMap();
1979
3180
  const getHostRef = (ref) => hostRefs.get(ref);
1980
3181
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1985,25 +3186,42 @@ const registerHost = (elm, cmpMeta) => {
1985
3186
  $cmpMeta$: cmpMeta,
1986
3187
  $instanceValues$: new Map(),
1987
3188
  };
1988
- {
3189
+ if (BUILD.isDev) {
3190
+ hostRef.$renderCount$ = 0;
3191
+ }
3192
+ if (BUILD.method && BUILD.lazyLoad) {
1989
3193
  hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1990
3194
  }
1991
- {
3195
+ if (BUILD.asyncLoading) {
1992
3196
  hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1993
3197
  elm['s-p'] = [];
1994
3198
  elm['s-rc'] = [];
1995
3199
  }
1996
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
3200
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
1997
3201
  return hostRefs.set(elm, hostRef);
1998
3202
  };
1999
3203
  const isMemberInElement = (elm, memberName) => memberName in elm;
2000
- const consoleError = (e, el) => (0, console.error)(e, el);
3204
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3205
+ const STENCIL_DEV_MODE = BUILD.isTesting
3206
+ ? ['STENCIL:'] // E2E testing
3207
+ : [
3208
+ '%cstencil',
3209
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3210
+ ];
3211
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3212
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3213
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3214
+ const setErrorHandler = (handler) => (customError = handler);
2001
3215
  const cmpModules = /*@__PURE__*/ new Map();
2002
3216
  const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2003
3217
  // loadModuleImport
2004
3218
  const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2005
3219
  const bundleId = cmpMeta.$lazyBundleId$;
2006
- const module = cmpModules.get(bundleId) ;
3220
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3221
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3222
+ return undefined;
3223
+ }
3224
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
2007
3225
  if (module) {
2008
3226
  return module[exportName];
2009
3227
  }
@@ -2214,16 +3432,20 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2214
3432
  /* webpackInclude: /\.entry\.js$/ */
2215
3433
  /* webpackExclude: /\.system\.entry\.js$/ */
2216
3434
  /* webpackMode: "lazy" */
2217
- `./${bundleId}.entry.js${''}`).then((importedModule) => {
2218
- {
3435
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then((importedModule) => {
3436
+ if (!BUILD.hotModuleReplacement) {
2219
3437
  cmpModules.set(bundleId, importedModule);
2220
3438
  }
2221
3439
  return importedModule[exportName];
2222
3440
  }, consoleError);
2223
3441
  };
2224
3442
  const styles = /*@__PURE__*/ new Map();
3443
+ const modeResolutionChain = [];
2225
3444
  const win = typeof window !== 'undefined' ? window : {};
3445
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
2226
3446
  const doc = win.document || { head: {} };
3447
+ const H = (win.HTMLElement || class {
3448
+ });
2227
3449
  const plt = {
2228
3450
  $flags$: 0,
2229
3451
  $resourcesUrl$: '',
@@ -2233,8 +3455,27 @@ const plt = {
2233
3455
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2234
3456
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
2235
3457
  };
3458
+ const setPlatformHelpers = (helpers) => {
3459
+ Object.assign(plt, helpers);
3460
+ };
3461
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3462
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3463
+ : true;
3464
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3465
+ let supportsListenerOptions = false;
3466
+ try {
3467
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3468
+ get() {
3469
+ supportsListenerOptions = true;
3470
+ },
3471
+ }));
3472
+ }
3473
+ catch (e) { }
3474
+ return supportsListenerOptions;
3475
+ })();
2236
3476
  const promiseResolve = (v) => Promise.resolve(v);
2237
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
3477
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3478
+ ? /*@__PURE__*/ (() => {
2238
3479
  try {
2239
3480
  new CSSStyleSheet();
2240
3481
  return typeof new CSSStyleSheet().replaceSync === 'function';
@@ -2242,9 +3483,10 @@ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2242
3483
  catch (e) { }
2243
3484
  return false;
2244
3485
  })()
2245
- ;
3486
+ : false;
2246
3487
  const queueDomReads = [];
2247
3488
  const queueDomWrites = [];
3489
+ const queueDomWritesLow = [];
2248
3490
  const queueTask = (queue, write) => (cb) => {
2249
3491
  queue.push(cb);
2250
3492
  if (!queuePending) {
@@ -2268,13 +3510,53 @@ const consume = (queue) => {
2268
3510
  }
2269
3511
  queue.length = 0;
2270
3512
  };
3513
+ const consumeTimeout = (queue, timeout) => {
3514
+ let i = 0;
3515
+ let ts = 0;
3516
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3517
+ try {
3518
+ queue[i++](ts);
3519
+ }
3520
+ catch (e) {
3521
+ consoleError(e);
3522
+ }
3523
+ }
3524
+ if (i === queue.length) {
3525
+ queue.length = 0;
3526
+ }
3527
+ else if (i !== 0) {
3528
+ queue.splice(0, i);
3529
+ }
3530
+ };
2271
3531
  const flush = () => {
3532
+ if (BUILD.asyncQueue) {
3533
+ queueCongestion++;
3534
+ }
2272
3535
  // always force a bunch of medium callbacks to run, but still have
2273
3536
  // a throttle on how many can run in a certain time
2274
3537
  // DOM READS!!!
2275
3538
  consume(queueDomReads);
2276
3539
  // DOM WRITES!!!
2277
- {
3540
+ if (BUILD.asyncQueue) {
3541
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3542
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3543
+ : Infinity;
3544
+ consumeTimeout(queueDomWrites, timeout);
3545
+ consumeTimeout(queueDomWritesLow, timeout);
3546
+ if (queueDomWrites.length > 0) {
3547
+ queueDomWritesLow.push(...queueDomWrites);
3548
+ queueDomWrites.length = 0;
3549
+ }
3550
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3551
+ // still more to do yet, but we've run out of time
3552
+ // let's let this thing cool off and try again in the next tick
3553
+ plt.raf(flush);
3554
+ }
3555
+ else {
3556
+ queueCongestion = 0;
3557
+ }
3558
+ }
3559
+ else {
2278
3560
  consume(queueDomWrites);
2279
3561
  if ((queuePending = queueDomReads.length > 0)) {
2280
3562
  // still more to do yet, but we've run out of time
@@ -2284,6 +3566,73 @@ const flush = () => {
2284
3566
  }
2285
3567
  };
2286
3568
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3569
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
2287
3570
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2288
3571
 
2289
- export { Fragment as F, Host as H, getRenderingRef as a, bootstrapLazy as b, createEvent as c, forceUpdate as f, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
3572
+ const StencilCore = /*#__PURE__*/Object.freeze({
3573
+ __proto__: null,
3574
+ Build: Build,
3575
+ CSS: CSS,
3576
+ Context: Context,
3577
+ Fragment: Fragment,
3578
+ H: H,
3579
+ HTMLElement: H,
3580
+ Host: Host,
3581
+ STENCIL_DEV_MODE: STENCIL_DEV_MODE,
3582
+ addHostEventListeners: addHostEventListeners,
3583
+ bootstrapLazy: bootstrapLazy,
3584
+ cmpModules: cmpModules,
3585
+ connectedCallback: connectedCallback,
3586
+ consoleDevError: consoleDevError,
3587
+ consoleDevInfo: consoleDevInfo,
3588
+ consoleDevWarn: consoleDevWarn,
3589
+ consoleError: consoleError,
3590
+ createEvent: createEvent,
3591
+ defineCustomElement: defineCustomElement,
3592
+ disconnectedCallback: disconnectedCallback,
3593
+ doc: doc,
3594
+ forceModeUpdate: forceModeUpdate,
3595
+ forceUpdate: forceUpdate,
3596
+ getAssetPath: getAssetPath,
3597
+ getConnect: getConnect,
3598
+ getContext: getContext,
3599
+ getElement: getElement,
3600
+ getHostRef: getHostRef,
3601
+ getMode: getMode,
3602
+ getRenderingRef: getRenderingRef,
3603
+ getValue: getValue,
3604
+ h: h,
3605
+ insertVdomAnnotations: insertVdomAnnotations,
3606
+ isMemberInElement: isMemberInElement,
3607
+ loadModule: loadModule,
3608
+ modeResolutionChain: modeResolutionChain,
3609
+ nextTick: nextTick,
3610
+ parsePropertyValue: parsePropertyValue,
3611
+ plt: plt,
3612
+ postUpdateComponent: postUpdateComponent,
3613
+ promiseResolve: promiseResolve,
3614
+ proxyComponent: proxyComponent,
3615
+ proxyCustomElement: proxyCustomElement,
3616
+ readTask: readTask,
3617
+ registerHost: registerHost,
3618
+ registerInstance: registerInstance,
3619
+ renderVdom: renderVdom,
3620
+ setAssetPath: setAssetPath,
3621
+ setErrorHandler: setErrorHandler,
3622
+ setMode: setMode,
3623
+ setNonce: setNonce,
3624
+ setPlatformHelpers: setPlatformHelpers,
3625
+ setPlatformOptions: setPlatformOptions,
3626
+ setValue: setValue,
3627
+ styles: styles,
3628
+ supportsConstructableStylesheets: supportsConstructableStylesheets,
3629
+ supportsListenerOptions: supportsListenerOptions,
3630
+ supportsShadow: supportsShadow,
3631
+ win: win,
3632
+ writeTask: writeTask,
3633
+ BUILD: BUILD,
3634
+ Env: Env,
3635
+ NAMESPACE: NAMESPACE
3636
+ });
3637
+
3638
+ export { BUILD as B, CSS as C, Fragment as F, H, NAMESPACE as N, StencilCore as S, plt as a, bootstrapLazy as b, consoleDevInfo as c, doc as d, createEvent as e, Host as f, getElement as g, h, forceUpdate as i, promiseResolve as p, registerInstance as r, setNonce as s, win as w };