@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
@@ -21,6 +21,8 @@ function _interopNamespace(e) {
21
21
  }
22
22
 
23
23
  const NAMESPACE = 'sankhyablocks';
24
+ 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 };
25
+ const Env = /* sankhyablocks */ {};
24
26
 
25
27
  /**
26
28
  * Virtual DOM patching algorithm based on Snabbdom by
@@ -33,26 +35,121 @@ const NAMESPACE = 'sankhyablocks';
33
35
  let scopeId;
34
36
  let contentRef;
35
37
  let hostTagName;
38
+ let customError;
39
+ let i = 0;
36
40
  let useNativeShadowDom = false;
37
41
  let checkSlotFallbackVisibility = false;
38
42
  let checkSlotRelocate = false;
39
43
  let isSvgMode = false;
40
44
  let renderingRef = null;
45
+ let queueCongestion = 0;
41
46
  let queuePending = false;
47
+ const Build = {
48
+ isDev: BUILD.isDev ? true : false,
49
+ isBrowser: true,
50
+ isServer: false,
51
+ isTesting: BUILD.isTesting ? true : false,
52
+ };
53
+ const Context = {};
54
+ const getAssetPath = (path) => {
55
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
56
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
57
+ };
58
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
42
59
  const createTime = (fnName, tagName = '') => {
43
- {
60
+ if (BUILD.profile && performance.mark) {
61
+ const key = `st:${fnName}:${tagName}:${i++}`;
62
+ // Start
63
+ performance.mark(key);
64
+ // End
65
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
66
+ }
67
+ else {
44
68
  return () => {
45
69
  return;
46
70
  };
47
71
  }
48
72
  };
49
73
  const uniqueTime = (key, measureText) => {
50
- {
74
+ if (BUILD.profile && performance.mark) {
75
+ if (performance.getEntriesByName(key, 'mark').length === 0) {
76
+ performance.mark(key);
77
+ }
78
+ return () => {
79
+ if (performance.getEntriesByName(measureText, 'measure').length === 0) {
80
+ performance.measure(measureText, key);
81
+ }
82
+ };
83
+ }
84
+ else {
51
85
  return () => {
52
86
  return;
53
87
  };
54
88
  }
55
89
  };
90
+ const inspect = (ref) => {
91
+ const hostRef = getHostRef(ref);
92
+ if (!hostRef) {
93
+ return undefined;
94
+ }
95
+ const flags = hostRef.$flags$;
96
+ const hostElement = hostRef.$hostElement$;
97
+ return {
98
+ renderCount: hostRef.$renderCount$,
99
+ flags: {
100
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
101
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
102
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
103
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
104
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
105
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
106
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
107
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
108
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
109
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
110
+ },
111
+ instanceValues: hostRef.$instanceValues$,
112
+ ancestorComponent: hostRef.$ancestorComponent$,
113
+ hostElement,
114
+ lazyInstance: hostRef.$lazyInstance$,
115
+ vnode: hostRef.$vnode$,
116
+ modeName: hostRef.$modeName$,
117
+ onReadyPromise: hostRef.$onReadyPromise$,
118
+ onReadyResolve: hostRef.$onReadyResolve$,
119
+ onInstancePromise: hostRef.$onInstancePromise$,
120
+ onInstanceResolve: hostRef.$onInstanceResolve$,
121
+ onRenderResolve: hostRef.$onRenderResolve$,
122
+ queuedListeners: hostRef.$queuedListeners$,
123
+ rmListeners: hostRef.$rmListeners$,
124
+ ['s-id']: hostElement['s-id'],
125
+ ['s-cr']: hostElement['s-cr'],
126
+ ['s-lr']: hostElement['s-lr'],
127
+ ['s-p']: hostElement['s-p'],
128
+ ['s-rc']: hostElement['s-rc'],
129
+ ['s-sc']: hostElement['s-sc'],
130
+ };
131
+ };
132
+ const installDevTools = () => {
133
+ if (BUILD.devTools) {
134
+ const stencil = (win.stencil = win.stencil || {});
135
+ const originalInspect = stencil.inspect;
136
+ stencil.inspect = (ref) => {
137
+ let result = inspect(ref);
138
+ if (!result && typeof originalInspect === 'function') {
139
+ result = originalInspect(ref);
140
+ }
141
+ return result;
142
+ };
143
+ }
144
+ };
145
+ const CONTENT_REF_ID = 'r';
146
+ const ORG_LOCATION_ID = 'o';
147
+ const SLOT_NODE_ID = 's';
148
+ const TEXT_NODE_ID = 't';
149
+ const HYDRATE_ID = 's-id';
150
+ const HYDRATED_STYLE_ID = 'sty-id';
151
+ const HYDRATE_CHILD_ID = 'c-id';
152
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
56
153
  const XLINK_NS = 'http://www.w3.org/1999/xlink';
57
154
  /**
58
155
  * Default style mode id
@@ -62,6 +159,11 @@ const XLINK_NS = 'http://www.w3.org/1999/xlink';
62
159
  * Don't add values to these!!
63
160
  */
64
161
  const EMPTY_OBJ = {};
162
+ /**
163
+ * Namespaces
164
+ */
165
+ const SVG_NS = 'http://www.w3.org/2000/svg';
166
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
65
167
  const isDef = (v) => v != null;
66
168
  const isComplexType = (o) => {
67
169
  // https://jsperf.com/typeof-fn-object/5
@@ -107,6 +209,11 @@ const h = (nodeName, vnodeData, ...children) => {
107
209
  if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
108
210
  child = String(child);
109
211
  }
212
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
213
+ consoleDevError(`vNode passed as children has unexpected type.
214
+ Make sure it's using the correct h() function.
215
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
216
+ }
110
217
  if (simple && lastSimple) {
111
218
  // If the previous child was simple (string), we merge both
112
219
  vNodeChildren[vNodeChildren.length - 1].$text$ += child;
@@ -121,14 +228,17 @@ const h = (nodeName, vnodeData, ...children) => {
121
228
  };
122
229
  walk(children);
123
230
  if (vnodeData) {
231
+ if (BUILD.isDev && nodeName === 'input') {
232
+ validateInputProperties(vnodeData);
233
+ }
124
234
  // normalize class / classname attributes
125
- if (vnodeData.key) {
235
+ if (BUILD.vdomKey && vnodeData.key) {
126
236
  key = vnodeData.key;
127
237
  }
128
- if (vnodeData.name) {
238
+ if (BUILD.slotRelocation && vnodeData.name) {
129
239
  slotName = vnodeData.name;
130
240
  }
131
- {
241
+ if (BUILD.vdomClass) {
132
242
  const classData = vnodeData.className || vnodeData.class;
133
243
  if (classData) {
134
244
  vnodeData.class =
@@ -140,7 +250,12 @@ const h = (nodeName, vnodeData, ...children) => {
140
250
  }
141
251
  }
142
252
  }
143
- if (typeof nodeName === 'function') {
253
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
254
+ consoleDevError(`The <Host> must be the single root component. Make sure:
255
+ - You are NOT using hostData() and <Host> in the same component.
256
+ - <Host> is used once, and it's the single root component of the render() function.`);
257
+ }
258
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
144
259
  // nodeName is a functional component
145
260
  return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
146
261
  }
@@ -149,10 +264,10 @@ const h = (nodeName, vnodeData, ...children) => {
149
264
  if (vNodeChildren.length > 0) {
150
265
  vnode.$children$ = vNodeChildren;
151
266
  }
152
- {
267
+ if (BUILD.vdomKey) {
153
268
  vnode.$key$ = key;
154
269
  }
155
- {
270
+ if (BUILD.slotRelocation) {
156
271
  vnode.$name$ = slotName;
157
272
  }
158
273
  return vnode;
@@ -173,13 +288,13 @@ const newVNode = (tag, text) => {
173
288
  $elm$: null,
174
289
  $children$: null,
175
290
  };
176
- {
291
+ if (BUILD.vdomAttribute) {
177
292
  vnode.$attrs$ = null;
178
293
  }
179
- {
294
+ if (BUILD.vdomKey) {
180
295
  vnode.$key$ = null;
181
296
  }
182
- {
297
+ if (BUILD.slotRelocation) {
183
298
  vnode.$name$ = null;
184
299
  }
185
300
  return vnode;
@@ -245,6 +360,235 @@ const convertToPrivate = (node) => {
245
360
  vnode.$name$ = node.vname;
246
361
  return vnode;
247
362
  };
363
+ /**
364
+ * Validates the ordering of attributes on an input element
365
+ *
366
+ * @param inputElm the element to validate
367
+ */
368
+ const validateInputProperties = (inputElm) => {
369
+ const props = Object.keys(inputElm);
370
+ const value = props.indexOf('value');
371
+ if (value === -1) {
372
+ return;
373
+ }
374
+ const typeIndex = props.indexOf('type');
375
+ const minIndex = props.indexOf('min');
376
+ const maxIndex = props.indexOf('max');
377
+ const stepIndex = props.indexOf('step');
378
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
379
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
380
+ }
381
+ };
382
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
383
+ const endHydrate = createTime('hydrateClient', tagName);
384
+ const shadowRoot = hostElm.shadowRoot;
385
+ const childRenderNodes = [];
386
+ const slotNodes = [];
387
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
388
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
389
+ if (!plt.$orgLocNodes$) {
390
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
391
+ }
392
+ hostElm[HYDRATE_ID] = hostId;
393
+ hostElm.removeAttribute(HYDRATE_ID);
394
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
395
+ childRenderNodes.map((c) => {
396
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
397
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
398
+ const node = c.$elm$;
399
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
400
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
401
+ }
402
+ if (!shadowRoot) {
403
+ node['s-hn'] = tagName;
404
+ if (orgLocationNode) {
405
+ node['s-ol'] = orgLocationNode;
406
+ node['s-ol']['s-nr'] = node;
407
+ }
408
+ }
409
+ plt.$orgLocNodes$.delete(orgLocationId);
410
+ });
411
+ if (BUILD.shadowDom && shadowRoot) {
412
+ shadowRootNodes.map((shadowRootNode) => {
413
+ if (shadowRootNode) {
414
+ shadowRoot.appendChild(shadowRootNode);
415
+ }
416
+ });
417
+ }
418
+ endHydrate();
419
+ };
420
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
421
+ let childNodeType;
422
+ let childIdSplt;
423
+ let childVNode;
424
+ let i;
425
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
426
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
427
+ if (childNodeType) {
428
+ // got the node data from the element's attribute
429
+ // `${hostId}.${nodeId}.${depth}.${index}`
430
+ childIdSplt = childNodeType.split('.');
431
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
432
+ childVNode = {
433
+ $flags$: 0,
434
+ $hostId$: childIdSplt[0],
435
+ $nodeId$: childIdSplt[1],
436
+ $depth$: childIdSplt[2],
437
+ $index$: childIdSplt[3],
438
+ $tag$: node.tagName.toLowerCase(),
439
+ $elm$: node,
440
+ $attrs$: null,
441
+ $children$: null,
442
+ $key$: null,
443
+ $name$: null,
444
+ $text$: null,
445
+ };
446
+ childRenderNodes.push(childVNode);
447
+ node.removeAttribute(HYDRATE_CHILD_ID);
448
+ // this is a new child vnode
449
+ // so ensure its parent vnode has the vchildren array
450
+ if (!parentVNode.$children$) {
451
+ parentVNode.$children$ = [];
452
+ }
453
+ // add our child vnode to a specific index of the vnode's children
454
+ parentVNode.$children$[childVNode.$index$] = childVNode;
455
+ // this is now the new parent vnode for all the next child checks
456
+ parentVNode = childVNode;
457
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
458
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
459
+ }
460
+ }
461
+ }
462
+ // recursively drill down, end to start so we can remove nodes
463
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
464
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
465
+ }
466
+ if (node.shadowRoot) {
467
+ // keep drilling down through the shadow root nodes
468
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
469
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
470
+ }
471
+ }
472
+ }
473
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
474
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
475
+ childIdSplt = node.nodeValue.split('.');
476
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
477
+ // comment node for either the host id or a 0 host id
478
+ childNodeType = childIdSplt[0];
479
+ childVNode = {
480
+ $flags$: 0,
481
+ $hostId$: childIdSplt[1],
482
+ $nodeId$: childIdSplt[2],
483
+ $depth$: childIdSplt[3],
484
+ $index$: childIdSplt[4],
485
+ $elm$: node,
486
+ $attrs$: null,
487
+ $children$: null,
488
+ $key$: null,
489
+ $name$: null,
490
+ $tag$: null,
491
+ $text$: null,
492
+ };
493
+ if (childNodeType === TEXT_NODE_ID) {
494
+ childVNode.$elm$ = node.nextSibling;
495
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
496
+ childVNode.$text$ = childVNode.$elm$.textContent;
497
+ childRenderNodes.push(childVNode);
498
+ // remove the text comment since it's no longer needed
499
+ node.remove();
500
+ if (!parentVNode.$children$) {
501
+ parentVNode.$children$ = [];
502
+ }
503
+ parentVNode.$children$[childVNode.$index$] = childVNode;
504
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
505
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
506
+ }
507
+ }
508
+ }
509
+ else if (childVNode.$hostId$ === hostId) {
510
+ // this comment node is specifcally for this host id
511
+ if (childNodeType === SLOT_NODE_ID) {
512
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
513
+ childVNode.$tag$ = 'slot';
514
+ if (childIdSplt[5]) {
515
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
516
+ }
517
+ else {
518
+ node['s-sn'] = '';
519
+ }
520
+ node['s-sr'] = true;
521
+ if (BUILD.shadowDom && shadowRootNodes) {
522
+ // browser support shadowRoot and this is a shadow dom component
523
+ // create an actual slot element
524
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
525
+ if (childVNode.$name$) {
526
+ // add the slot name attribute
527
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
528
+ }
529
+ // insert the new slot element before the slot comment
530
+ node.parentNode.insertBefore(childVNode.$elm$, node);
531
+ // remove the slot comment since it's not needed for shadow
532
+ node.remove();
533
+ if (childVNode.$depth$ === '0') {
534
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
535
+ }
536
+ }
537
+ slotNodes.push(childVNode);
538
+ if (!parentVNode.$children$) {
539
+ parentVNode.$children$ = [];
540
+ }
541
+ parentVNode.$children$[childVNode.$index$] = childVNode;
542
+ }
543
+ else if (childNodeType === CONTENT_REF_ID) {
544
+ // `${CONTENT_REF_ID}.${hostId}`;
545
+ if (BUILD.shadowDom && shadowRootNodes) {
546
+ // remove the content ref comment since it's not needed for shadow
547
+ node.remove();
548
+ }
549
+ else if (BUILD.slotRelocation) {
550
+ hostElm['s-cr'] = node;
551
+ node['s-cn'] = true;
552
+ }
553
+ }
554
+ }
555
+ }
556
+ }
557
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
558
+ const vnode = newVNode(null, node.textContent);
559
+ vnode.$elm$ = node;
560
+ vnode.$index$ = '0';
561
+ parentVNode.$children$ = [vnode];
562
+ }
563
+ };
564
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
565
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
566
+ let i = 0;
567
+ for (; i < node.childNodes.length; i++) {
568
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
569
+ }
570
+ if (node.shadowRoot) {
571
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
572
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
573
+ }
574
+ }
575
+ }
576
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
577
+ const childIdSplt = node.nodeValue.split('.');
578
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
579
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
580
+ node.nodeValue = '';
581
+ // useful to know if the original location is
582
+ // the root light-dom of a shadow dom component
583
+ node['s-en'] = childIdSplt[3];
584
+ }
585
+ }
586
+ };
587
+ // Private
588
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
589
+ // Public
590
+ const setMode = (handler) => modeResolutionChain.push(handler);
591
+ const getMode = (ref) => getHostRef(ref).$modeName$;
248
592
  /**
249
593
  * Parse a new property value for a given property type.
250
594
  *
@@ -271,16 +615,16 @@ const convertToPrivate = (node) => {
271
615
  const parsePropertyValue = (propValue, propType) => {
272
616
  // ensure this value is of the correct prop type
273
617
  if (propValue != null && !isComplexType(propValue)) {
274
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
618
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
275
619
  // per the HTML spec, any string value means it is a boolean true value
276
620
  // but we'll cheat here and say that the string "false" is the boolean false
277
621
  return propValue === 'false' ? false : propValue === '' || !!propValue;
278
622
  }
279
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
623
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
280
624
  // force it to be a number
281
625
  return parseFloat(propValue);
282
626
  }
283
- if (propType & 1 /* MEMBER_FLAGS.String */) {
627
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
284
628
  // could have been passed as a number or boolean
285
629
  // but we still want it as a string
286
630
  return String(propValue);
@@ -292,11 +636,14 @@ const parsePropertyValue = (propValue, propType) => {
292
636
  // so no need to change to a different type
293
637
  return propValue;
294
638
  };
295
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
639
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
296
640
  const createEvent = (ref, name, flags) => {
297
641
  const elm = getElement(ref);
298
642
  return {
299
643
  emit: (detail) => {
644
+ if (BUILD.isDev && !elm.isConnected) {
645
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
646
+ }
300
647
  return emitEvent(elm, name, {
301
648
  bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
302
649
  composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
@@ -337,8 +684,11 @@ const registerStyle = (scopeId, cssText, allowCS) => {
337
684
  };
338
685
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
339
686
  var _a;
340
- let scopeId = getScopeId(cmpMeta);
687
+ let scopeId = getScopeId(cmpMeta, mode);
341
688
  const style = styles.get(scopeId);
689
+ if (!BUILD.attachStyles) {
690
+ return scopeId;
691
+ }
342
692
  // if an element is NOT connected then getRootNode() will return the wrong root node
343
693
  // so the fallback is to always use the document for the root node in those cases
344
694
  styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
@@ -351,8 +701,25 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
351
701
  rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
352
702
  }
353
703
  if (!appliedStyles.has(scopeId)) {
354
- {
355
- {
704
+ if (BUILD.hydrateClientSide &&
705
+ styleContainerNode.host &&
706
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
707
+ // This is only happening on native shadow-dom, do not needs CSS var shim
708
+ styleElm.innerHTML = style;
709
+ }
710
+ else {
711
+ if (BUILD.cssVarShim && plt.$cssShim$) {
712
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
713
+ const newScopeId = styleElm['s-sc'];
714
+ if (newScopeId) {
715
+ scopeId = newScopeId;
716
+ // we don't want to add this styleID to the appliedStyles Set
717
+ // since the cssVarShim might need to apply several different
718
+ // stylesheets for the same component
719
+ appliedStyles = null;
720
+ }
721
+ }
722
+ else {
356
723
  styleElm = doc.createElement('style');
357
724
  styleElm.innerHTML = style;
358
725
  }
@@ -361,6 +728,9 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
361
728
  if (nonce != null) {
362
729
  styleElm.setAttribute('nonce', nonce);
363
730
  }
731
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
732
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
733
+ }
364
734
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
365
735
  }
366
736
  if (appliedStyles) {
@@ -368,7 +738,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
368
738
  }
369
739
  }
370
740
  }
371
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
741
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
372
742
  styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
373
743
  }
374
744
  }
@@ -379,8 +749,8 @@ const attachStyles = (hostRef) => {
379
749
  const elm = hostRef.$hostElement$;
380
750
  const flags = cmpMeta.$flags$;
381
751
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
382
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
383
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
752
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
753
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
384
754
  // only required when we're NOT using native shadow dom (slot)
385
755
  // or this browser doesn't support native shadow dom
386
756
  // and this host element was NOT created with SSR
@@ -390,13 +760,14 @@ const attachStyles = (hostRef) => {
390
760
  // DOM WRITE!!
391
761
  elm['s-sc'] = scopeId;
392
762
  elm.classList.add(scopeId + '-h');
393
- if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
763
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
394
764
  elm.classList.add(scopeId + '-s');
395
765
  }
396
766
  }
397
767
  endAttachStyles();
398
768
  };
399
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
769
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
770
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
400
771
  /**
401
772
  * Production setAccessor() function based on Preact by
402
773
  * Jason Miller (@developit)
@@ -409,19 +780,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
409
780
  if (oldValue !== newValue) {
410
781
  let isProp = isMemberInElement(elm, memberName);
411
782
  let ln = memberName.toLowerCase();
412
- if (memberName === 'class') {
783
+ if (BUILD.vdomClass && memberName === 'class') {
413
784
  const classList = elm.classList;
414
785
  const oldClasses = parseClassList(oldValue);
415
786
  const newClasses = parseClassList(newValue);
416
787
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
417
788
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
418
789
  }
419
- else if (memberName === 'style') {
790
+ else if (BUILD.vdomStyle && memberName === 'style') {
420
791
  // update style attribute, css properties and values
421
- {
792
+ if (BUILD.updatable) {
422
793
  for (const prop in oldValue) {
423
794
  if (!newValue || newValue[prop] == null) {
424
- if (prop.includes('-')) {
795
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
425
796
  elm.style.removeProperty(prop);
426
797
  }
427
798
  else {
@@ -432,7 +803,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
432
803
  }
433
804
  for (const prop in newValue) {
434
805
  if (!oldValue || newValue[prop] !== oldValue[prop]) {
435
- if (prop.includes('-')) {
806
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
436
807
  elm.style.setProperty(prop, newValue[prop]);
437
808
  }
438
809
  else {
@@ -441,15 +812,16 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
441
812
  }
442
813
  }
443
814
  }
444
- else if (memberName === 'key')
815
+ else if (BUILD.vdomKey && memberName === 'key')
445
816
  ;
446
- else if (memberName === 'ref') {
817
+ else if (BUILD.vdomRef && memberName === 'ref') {
447
818
  // minifier will clean this up
448
819
  if (newValue) {
449
820
  newValue(elm);
450
821
  }
451
822
  }
452
- else if ((!isProp ) &&
823
+ else if (BUILD.vdomListener &&
824
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
453
825
  memberName[0] === 'o' &&
454
826
  memberName[1] === 'n') {
455
827
  // Event Handlers
@@ -488,7 +860,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
488
860
  plt.ael(elm, memberName, newValue, false);
489
861
  }
490
862
  }
491
- else {
863
+ else if (BUILD.vdomPropOrAttr) {
492
864
  // Set property if it exists and it's not a SVG
493
865
  const isComplex = isComplexType(newValue);
494
866
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
@@ -517,7 +889,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
517
889
  * - if the newValue is null/undefined or 'false'.
518
890
  */
519
891
  let xlink = false;
520
- {
892
+ if (BUILD.vdomXlink) {
521
893
  if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
522
894
  memberName = ln;
523
895
  xlink = true;
@@ -525,7 +897,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
525
897
  }
526
898
  if (newValue == null || newValue === false) {
527
899
  if (newValue !== false || elm.getAttribute(memberName) === '') {
528
- if (xlink) {
900
+ if (BUILD.vdomXlink && xlink) {
529
901
  elm.removeAttributeNS(XLINK_NS, memberName);
530
902
  }
531
903
  else {
@@ -535,7 +907,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
535
907
  }
536
908
  else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
537
909
  newValue = newValue === true ? '' : newValue;
538
- if (xlink) {
910
+ if (BUILD.vdomXlink && xlink) {
539
911
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
540
912
  }
541
913
  else {
@@ -556,7 +928,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
556
928
  : newVnode.$elm$;
557
929
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
558
930
  const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
559
- {
931
+ if (BUILD.updatable) {
560
932
  // remove attributes no longer present on the vnode by setting them to undefined
561
933
  for (memberName in oldVnodeAttrs) {
562
934
  if (!(memberName in newVnodeAttrs)) {
@@ -586,7 +958,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
586
958
  let elm;
587
959
  let childNode;
588
960
  let oldVNode;
589
- if (!useNativeShadowDom) {
961
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
590
962
  // remember for later we need to check to relocate nodes
591
963
  checkSlotRelocate = true;
592
964
  if (newVNode.$tag$ === 'slot') {
@@ -601,25 +973,38 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
601
973
  1 /* VNODE_FLAGS.isSlotReference */;
602
974
  }
603
975
  }
604
- if (newVNode.$text$ !== null) {
976
+ if (BUILD.isDev && newVNode.$elm$) {
977
+ 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`);
978
+ }
979
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
605
980
  // create text node
606
981
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
607
982
  }
608
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
983
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
609
984
  // create a slot reference node
610
985
  elm = newVNode.$elm$ =
611
- doc.createTextNode('');
986
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
612
987
  }
613
988
  else {
989
+ if (BUILD.svg && !isSvgMode) {
990
+ isSvgMode = newVNode.$tag$ === 'svg';
991
+ }
614
992
  // create element
615
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
993
+ elm = newVNode.$elm$ = (BUILD.svg
994
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
995
+ ? 'slot-fb'
996
+ : newVNode.$tag$)
997
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
616
998
  ? 'slot-fb'
617
999
  : newVNode.$tag$));
1000
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
1001
+ isSvgMode = false;
1002
+ }
618
1003
  // add css classes, attrs, props, listeners, etc.
619
- {
1004
+ if (BUILD.vdomAttribute) {
620
1005
  updateElement(null, newVNode, isSvgMode);
621
1006
  }
622
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
1007
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
623
1008
  // if there is a scopeId and this is the initial render
624
1009
  // then let's add the scopeId as a css class
625
1010
  elm.classList.add((elm['s-si'] = scopeId));
@@ -635,8 +1020,18 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
635
1020
  }
636
1021
  }
637
1022
  }
1023
+ if (BUILD.svg) {
1024
+ if (newVNode.$tag$ === 'svg') {
1025
+ // Only reset the SVG context when we're exiting <svg> element
1026
+ isSvgMode = false;
1027
+ }
1028
+ else if (elm.tagName === 'foreignObject') {
1029
+ // Reenter SVG context when we're exiting <foreignObject> element
1030
+ isSvgMode = true;
1031
+ }
1032
+ }
638
1033
  }
639
- {
1034
+ if (BUILD.slotRelocation) {
640
1035
  elm['s-hn'] = hostTagName;
641
1036
  if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
642
1037
  // remember the content reference comment
@@ -696,9 +1091,9 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
696
1091
  * creating DOM nodes (inclusive)
697
1092
  */
698
1093
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
699
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1094
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
700
1095
  let childNode;
701
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1096
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
702
1097
  containerElm = containerElm.shadowRoot;
703
1098
  }
704
1099
  for (; startIdx <= endIdx; ++startIdx) {
@@ -706,7 +1101,7 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
706
1101
  childNode = createElm(null, parentVNode, startIdx, parentElm);
707
1102
  if (childNode) {
708
1103
  vnodes[startIdx].$elm$ = childNode;
709
- containerElm.insertBefore(childNode, referenceNode(before) );
1104
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
710
1105
  }
711
1106
  }
712
1107
  }
@@ -729,7 +1124,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
729
1124
  if ((vnode = vnodes[startIdx])) {
730
1125
  elm = vnode.$elm$;
731
1126
  callNodeRefs(vnode);
732
- {
1127
+ if (BUILD.slotRelocation) {
733
1128
  // we're removing this element
734
1129
  // so it's possible we need to show slot fallback content now
735
1130
  checkSlotFallbackVisibility = true;
@@ -875,7 +1270,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
875
1270
  //
876
1271
  // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
877
1272
  // and move the DOM element for `oldStartVnode`.
878
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1273
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
879
1274
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
880
1275
  }
881
1276
  patch(oldStartVnode, newEndVnode);
@@ -916,7 +1311,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
916
1311
  // (which will handle updating any changed attributes, reconciling their
917
1312
  // children etc) but we also need to move the DOM node to which
918
1313
  // `oldEndVnode` corresponds.
919
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1314
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
920
1315
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
921
1316
  }
922
1317
  patch(oldEndVnode, newStartVnode);
@@ -939,7 +1334,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
939
1334
  // children which have the same key as the first node in the new
940
1335
  // children.
941
1336
  idxInOld = -1;
942
- {
1337
+ if (BUILD.vdomKey) {
943
1338
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
944
1339
  if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
945
1340
  idxInOld = i;
@@ -947,7 +1342,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
947
1342
  }
948
1343
  }
949
1344
  }
950
- if (idxInOld >= 0) {
1345
+ if (BUILD.vdomKey && idxInOld >= 0) {
951
1346
  // We found a node in the old children which matches up with the first
952
1347
  // node in the new children! So let's deal with that
953
1348
  elmToMove = oldCh[idxInOld];
@@ -974,9 +1369,12 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
974
1369
  }
975
1370
  if (node) {
976
1371
  // if we created a new node then handle inserting it to the DOM
977
- {
1372
+ if (BUILD.slotRelocation) {
978
1373
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
979
1374
  }
1375
+ else {
1376
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1377
+ }
980
1378
  }
981
1379
  }
982
1380
  }
@@ -984,7 +1382,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
984
1382
  // we have some more new nodes to add which don't match up with old nodes
985
1383
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
986
1384
  }
987
- else if (newStartIdx > newEndIdx) {
1385
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
988
1386
  // there are nodes in the `oldCh` array which no longer correspond to nodes
989
1387
  // in the new array, so lets remove them (which entails cleaning up the
990
1388
  // relevant DOM nodes)
@@ -1013,13 +1411,14 @@ const isSameVnode = (leftVNode, rightVNode) => {
1013
1411
  // compare if two vnode to see if they're "technically" the same
1014
1412
  // need to have the same element tag, and same key to be the same
1015
1413
  if (leftVNode.$tag$ === rightVNode.$tag$) {
1016
- if (leftVNode.$tag$ === 'slot') {
1414
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1017
1415
  return leftVNode.$name$ === rightVNode.$name$;
1018
1416
  }
1019
1417
  // this will be set if components in the build have `key` attrs set on them
1020
- {
1418
+ if (BUILD.vdomKey) {
1021
1419
  return leftVNode.$key$ === rightVNode.$key$;
1022
1420
  }
1421
+ return true;
1023
1422
  }
1024
1423
  return false;
1025
1424
  };
@@ -1046,9 +1445,14 @@ const patch = (oldVNode, newVNode) => {
1046
1445
  const tag = newVNode.$tag$;
1047
1446
  const text = newVNode.$text$;
1048
1447
  let defaultHolder;
1049
- if (text === null) {
1050
- {
1051
- if (tag === 'slot')
1448
+ if (!BUILD.vdomText || text === null) {
1449
+ if (BUILD.svg) {
1450
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1451
+ // only add this to the when the compiler sees we're using an svg somewhere
1452
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1453
+ }
1454
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1455
+ if (BUILD.slot && tag === 'slot')
1052
1456
  ;
1053
1457
  else {
1054
1458
  // either this is the first render of an element OR it's an update
@@ -1057,30 +1461,33 @@ const patch = (oldVNode, newVNode) => {
1057
1461
  updateElement(oldVNode, newVNode, isSvgMode);
1058
1462
  }
1059
1463
  }
1060
- if (oldChildren !== null && newChildren !== null) {
1464
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1061
1465
  // looks like there's child vnodes for both the old and new vnodes
1062
1466
  // so we need to call `updateChildren` to reconcile them
1063
1467
  updateChildren(elm, oldChildren, newVNode, newChildren);
1064
1468
  }
1065
1469
  else if (newChildren !== null) {
1066
1470
  // no old child vnodes, but there are new child vnodes to add
1067
- if (oldVNode.$text$ !== null) {
1471
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1068
1472
  // the old vnode was text, so be sure to clear it out
1069
1473
  elm.textContent = '';
1070
1474
  }
1071
1475
  // add the new vnode children
1072
1476
  addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1073
1477
  }
1074
- else if (oldChildren !== null) {
1478
+ else if (BUILD.updatable && oldChildren !== null) {
1075
1479
  // no new child vnodes, but there are old child vnodes to remove
1076
1480
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
1077
1481
  }
1482
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1483
+ isSvgMode = false;
1484
+ }
1078
1485
  }
1079
- else if ((defaultHolder = elm['s-cr'])) {
1486
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1080
1487
  // this element has slotted content
1081
1488
  defaultHolder.parentNode.textContent = text;
1082
1489
  }
1083
- else if (oldVNode.$text$ !== text) {
1490
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1084
1491
  // update the text content for the text only vnode
1085
1492
  // and also only if the text is different than before
1086
1493
  elm.data = text;
@@ -1218,7 +1625,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1218
1625
  return slotNameAttr === '';
1219
1626
  };
1220
1627
  const callNodeRefs = (vNode) => {
1221
- {
1628
+ if (BUILD.vdomRef) {
1222
1629
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1223
1630
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
1224
1631
  }
@@ -1241,26 +1648,41 @@ const renderVdom = (hostRef, renderFnResults) => {
1241
1648
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1242
1649
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1243
1650
  hostTagName = hostElm.tagName;
1244
- if (cmpMeta.$attrsToReflect$) {
1651
+ // <Host> runtime check
1652
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1653
+ throw new Error(`The <Host> must be the single root component.
1654
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1655
+
1656
+ The render() function should look like this instead:
1657
+
1658
+ render() {
1659
+ // Do not return an array
1660
+ return (
1661
+ <Host>{content}</Host>
1662
+ );
1663
+ }
1664
+ `);
1665
+ }
1666
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1245
1667
  rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1246
1668
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1247
1669
  }
1248
1670
  rootVnode.$tag$ = null;
1249
1671
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1250
1672
  hostRef.$vnode$ = rootVnode;
1251
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1252
- {
1673
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1674
+ if (BUILD.scoped || BUILD.shadowDom) {
1253
1675
  scopeId = hostElm['s-sc'];
1254
1676
  }
1255
- {
1677
+ if (BUILD.slotRelocation) {
1256
1678
  contentRef = hostElm['s-cr'];
1257
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1679
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1258
1680
  // always reset
1259
1681
  checkSlotFallbackVisibility = false;
1260
1682
  }
1261
1683
  // synchronous patch
1262
1684
  patch(oldVNode, rootVnode);
1263
- {
1685
+ if (BUILD.slotRelocation) {
1264
1686
  // while we're moving nodes around existing nodes, temporarily disable
1265
1687
  // the disconnectCallback from working
1266
1688
  plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
@@ -1280,7 +1702,9 @@ const renderVdom = (hostRef, renderFnResults) => {
1280
1702
  // add a reference node marking this node's original location
1281
1703
  // keep a reference to this node for later lookups
1282
1704
  orgLocationNode =
1283
- doc.createTextNode('');
1705
+ BUILD.isDebug || BUILD.hydrateServerSide
1706
+ ? originalLocationDebugNode(nodeToRelocate)
1707
+ : doc.createTextNode('');
1284
1708
  orgLocationNode['s-nr'] = nodeToRelocate;
1285
1709
  nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1286
1710
  }
@@ -1337,16 +1761,23 @@ const renderVdom = (hostRef, renderFnResults) => {
1337
1761
  relocateNodes.length = 0;
1338
1762
  }
1339
1763
  };
1764
+ // slot comment debug nodes only created with the `--debug` flag
1765
+ // otherwise these nodes are text nodes w/out content
1766
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1767
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1768
+ (nodeToRelocate.localName
1769
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1770
+ : `[${nodeToRelocate.textContent}]`));
1340
1771
  const attachToAncestor = (hostRef, ancestorComponent) => {
1341
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1772
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1342
1773
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1343
1774
  }
1344
1775
  };
1345
1776
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1346
- {
1777
+ if (BUILD.taskQueue && BUILD.updatable) {
1347
1778
  hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1348
1779
  }
1349
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1780
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1350
1781
  hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1351
1782
  return;
1352
1783
  }
@@ -1355,30 +1786,34 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
1355
1786
  // has already fired off its lifecycle update then
1356
1787
  // fire off the initial update
1357
1788
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1358
- return writeTask(dispatch) ;
1789
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1359
1790
  };
1360
1791
  const dispatchHooks = (hostRef, isInitialLoad) => {
1792
+ const elm = hostRef.$hostElement$;
1361
1793
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1362
- const instance = hostRef.$lazyInstance$ ;
1794
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1363
1795
  let promise;
1364
1796
  if (isInitialLoad) {
1365
- {
1797
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1366
1798
  hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1367
1799
  if (hostRef.$queuedListeners$) {
1368
1800
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1369
1801
  hostRef.$queuedListeners$ = null;
1370
1802
  }
1371
1803
  }
1372
- {
1804
+ emitLifecycleEvent(elm, 'componentWillLoad');
1805
+ if (BUILD.cmpWillLoad) {
1373
1806
  promise = safeCall(instance, 'componentWillLoad');
1374
1807
  }
1375
1808
  }
1376
1809
  else {
1377
- {
1810
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1811
+ if (BUILD.cmpWillUpdate) {
1378
1812
  promise = safeCall(instance, 'componentWillUpdate');
1379
1813
  }
1380
1814
  }
1381
- {
1815
+ emitLifecycleEvent(elm, 'componentWillRender');
1816
+ if (BUILD.cmpWillRender) {
1382
1817
  promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1383
1818
  }
1384
1819
  endSchedule();
@@ -1389,15 +1824,46 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1389
1824
  const elm = hostRef.$hostElement$;
1390
1825
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1391
1826
  const rc = elm['s-rc'];
1392
- if (isInitialLoad) {
1827
+ if (BUILD.style && isInitialLoad) {
1393
1828
  // DOM WRITE!
1394
1829
  attachStyles(hostRef);
1395
1830
  }
1396
1831
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1397
- {
1398
- callRender(hostRef, instance);
1832
+ if (BUILD.isDev) {
1833
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1834
+ }
1835
+ if (BUILD.hydrateServerSide) {
1836
+ await callRender(hostRef, instance, elm);
1837
+ }
1838
+ else {
1839
+ callRender(hostRef, instance, elm);
1399
1840
  }
1400
- if (rc) {
1841
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1842
+ plt.$cssShim$.updateHost(elm);
1843
+ }
1844
+ if (BUILD.isDev) {
1845
+ hostRef.$renderCount$++;
1846
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1847
+ }
1848
+ if (BUILD.hydrateServerSide) {
1849
+ try {
1850
+ // manually connected child components during server-side hydrate
1851
+ serverSideConnected(elm);
1852
+ if (isInitialLoad) {
1853
+ // using only during server-side hydrate
1854
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1855
+ elm['s-en'] = '';
1856
+ }
1857
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1858
+ elm['s-en'] = 'c';
1859
+ }
1860
+ }
1861
+ }
1862
+ catch (e) {
1863
+ consoleError(e, elm);
1864
+ }
1865
+ }
1866
+ if (BUILD.asyncLoading && rc) {
1401
1867
  // ok, so turns out there are some child host elements
1402
1868
  // waiting on this parent element to load
1403
1869
  // let's fire off all update callbacks waiting
@@ -1406,7 +1872,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1406
1872
  }
1407
1873
  endRender();
1408
1874
  endUpdate();
1409
- {
1875
+ if (BUILD.asyncLoading) {
1410
1876
  const childrenPromises = elm['s-p'];
1411
1877
  const postUpdate = () => postUpdateComponent(hostRef);
1412
1878
  if (childrenPromises.length === 0) {
@@ -1418,26 +1884,42 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1418
1884
  childrenPromises.length = 0;
1419
1885
  }
1420
1886
  }
1887
+ else {
1888
+ postUpdateComponent(hostRef);
1889
+ }
1421
1890
  };
1422
1891
  const callRender = (hostRef, instance, elm) => {
1892
+ // in order for bundlers to correctly treeshake the BUILD object
1893
+ // we need to ensure BUILD is not deoptimized within a try/catch
1894
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1895
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1896
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1897
+ const taskQueue = BUILD.taskQueue ? true : false;
1898
+ const updatable = BUILD.updatable ? true : false;
1423
1899
  try {
1424
1900
  renderingRef = instance;
1425
- instance = instance.render() ;
1426
- {
1901
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1902
+ if (updatable && taskQueue) {
1427
1903
  hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1428
1904
  }
1429
- {
1905
+ if (updatable || lazyLoad) {
1430
1906
  hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1431
1907
  }
1432
- {
1433
- {
1908
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1909
+ if (BUILD.vdomRender || BUILD.reflect) {
1434
1910
  // looks like we've got child nodes to render into this host element
1435
1911
  // or we need to update the css class/attrs on the host element
1436
1912
  // DOM WRITE!
1437
- {
1913
+ if (BUILD.hydrateServerSide) {
1914
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1915
+ }
1916
+ else {
1438
1917
  renderVdom(hostRef, instance);
1439
1918
  }
1440
1919
  }
1920
+ else {
1921
+ elm.textContent = instance;
1922
+ }
1441
1923
  }
1442
1924
  }
1443
1925
  catch (e) {
@@ -1451,40 +1933,68 @@ const postUpdateComponent = (hostRef) => {
1451
1933
  const tagName = hostRef.$cmpMeta$.$tagName$;
1452
1934
  const elm = hostRef.$hostElement$;
1453
1935
  const endPostUpdate = createTime('postUpdate', tagName);
1454
- const instance = hostRef.$lazyInstance$ ;
1936
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1455
1937
  const ancestorComponent = hostRef.$ancestorComponent$;
1456
- {
1938
+ if (BUILD.cmpDidRender) {
1939
+ if (BUILD.isDev) {
1940
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1941
+ }
1457
1942
  safeCall(instance, 'componentDidRender');
1943
+ if (BUILD.isDev) {
1944
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1945
+ }
1458
1946
  }
1947
+ emitLifecycleEvent(elm, 'componentDidRender');
1459
1948
  if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1460
1949
  hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1461
- {
1950
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1462
1951
  // DOM WRITE!
1463
1952
  addHydratedFlag(elm);
1464
1953
  }
1465
- {
1954
+ if (BUILD.cmpDidLoad) {
1955
+ if (BUILD.isDev) {
1956
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1957
+ }
1466
1958
  safeCall(instance, 'componentDidLoad');
1959
+ if (BUILD.isDev) {
1960
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1961
+ }
1467
1962
  }
1963
+ emitLifecycleEvent(elm, 'componentDidLoad');
1468
1964
  endPostUpdate();
1469
- {
1965
+ if (BUILD.asyncLoading) {
1470
1966
  hostRef.$onReadyResolve$(elm);
1471
1967
  if (!ancestorComponent) {
1472
- appDidLoad();
1968
+ appDidLoad(tagName);
1473
1969
  }
1474
1970
  }
1475
1971
  }
1476
1972
  else {
1477
- {
1973
+ if (BUILD.cmpDidUpdate) {
1974
+ // we've already loaded this component
1975
+ // fire off the user's componentDidUpdate method (if one was provided)
1976
+ // componentDidUpdate runs AFTER render() has been called
1977
+ // and all child components have finished updating
1978
+ if (BUILD.isDev) {
1979
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1980
+ }
1478
1981
  safeCall(instance, 'componentDidUpdate');
1982
+ if (BUILD.isDev) {
1983
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1984
+ }
1479
1985
  }
1986
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1480
1987
  endPostUpdate();
1481
1988
  }
1482
- {
1989
+ if (BUILD.hotModuleReplacement) {
1990
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1991
+ }
1992
+ if (BUILD.method && BUILD.lazyLoad) {
1483
1993
  hostRef.$onInstanceResolve$(elm);
1484
1994
  }
1485
1995
  // load events fire from bottom to top
1486
1996
  // the deepest elements load first then bubbles up
1487
- {
1997
+ if (BUILD.asyncLoading) {
1488
1998
  if (hostRef.$onRenderResolve$) {
1489
1999
  hostRef.$onRenderResolve$();
1490
2000
  hostRef.$onRenderResolve$ = undefined;
@@ -1499,7 +2009,7 @@ const postUpdateComponent = (hostRef) => {
1499
2009
  // (⌐■_■)
1500
2010
  };
1501
2011
  const forceUpdate = (ref) => {
1502
- {
2012
+ if (BUILD.updatable) {
1503
2013
  const hostRef = getHostRef(ref);
1504
2014
  const isConnected = hostRef.$hostElement$.isConnected;
1505
2015
  if (isConnected &&
@@ -1509,14 +2019,21 @@ const forceUpdate = (ref) => {
1509
2019
  // Returns "true" when the forced update was successfully scheduled
1510
2020
  return isConnected;
1511
2021
  }
2022
+ return false;
1512
2023
  };
1513
2024
  const appDidLoad = (who) => {
1514
2025
  // on appload
1515
2026
  // we have finish the first big initial render
1516
- {
2027
+ if (BUILD.cssAnnotations) {
1517
2028
  addHydratedFlag(doc.documentElement);
1518
2029
  }
2030
+ if (BUILD.asyncQueue) {
2031
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2032
+ }
1519
2033
  nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2034
+ if (BUILD.profile && performance.measure) {
2035
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
2036
+ }
1520
2037
  };
1521
2038
  const safeCall = (instance, method, arg) => {
1522
2039
  if (instance && instance[method]) {
@@ -1532,27 +2049,61 @@ const safeCall = (instance, method, arg) => {
1532
2049
  const then = (promise, thenFn) => {
1533
2050
  return promise && promise.then ? promise.then(thenFn) : thenFn();
1534
2051
  };
1535
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1536
- ;
2052
+ const emitLifecycleEvent = (elm, lifecycleName) => {
2053
+ if (BUILD.lifecycleDOMEvents) {
2054
+ emitEvent(elm, 'stencil_' + lifecycleName, {
2055
+ bubbles: true,
2056
+ composed: true,
2057
+ detail: {
2058
+ namespace: NAMESPACE,
2059
+ },
2060
+ });
2061
+ }
2062
+ };
2063
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
2064
+ ? elm.classList.add('hydrated')
2065
+ : BUILD.hydratedAttribute
2066
+ ? elm.setAttribute('hydrated', '')
2067
+ : undefined;
2068
+ const serverSideConnected = (elm) => {
2069
+ const children = elm.children;
2070
+ if (children != null) {
2071
+ for (let i = 0, ii = children.length; i < ii; i++) {
2072
+ const childElm = children[i];
2073
+ if (typeof childElm.connectedCallback === 'function') {
2074
+ childElm.connectedCallback();
2075
+ }
2076
+ serverSideConnected(childElm);
2077
+ }
2078
+ }
2079
+ };
1537
2080
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1538
2081
  const setValue = (ref, propName, newVal, cmpMeta) => {
1539
2082
  // check our new property value against our internal value
1540
2083
  const hostRef = getHostRef(ref);
1541
- const elm = hostRef.$hostElement$ ;
2084
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1542
2085
  const oldVal = hostRef.$instanceValues$.get(propName);
1543
2086
  const flags = hostRef.$flags$;
1544
- const instance = hostRef.$lazyInstance$ ;
2087
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1545
2088
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1546
2089
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1547
2090
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1548
2091
  const didValueChange = newVal !== oldVal && !areBothNaN;
1549
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2092
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1550
2093
  // gadzooks! the property's value has changed!!
1551
2094
  // set our new value!
1552
2095
  hostRef.$instanceValues$.set(propName, newVal);
1553
- if (instance) {
2096
+ if (BUILD.isDev) {
2097
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2098
+ 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);
2099
+ }
2100
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2101
+ 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);
2102
+ }
2103
+ }
2104
+ if (!BUILD.lazyLoad || instance) {
1554
2105
  // get an array of method names of watch functions to call
1555
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2106
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1556
2107
  const watchMethods = cmpMeta.$watchers$[propName];
1557
2108
  if (watchMethods) {
1558
2109
  // this instance is watching for when this property changed
@@ -1567,8 +2118,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1567
2118
  });
1568
2119
  }
1569
2120
  }
1570
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1571
- if (instance.componentShouldUpdate) {
2121
+ if (BUILD.updatable &&
2122
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2123
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1572
2124
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1573
2125
  return;
1574
2126
  }
@@ -1593,16 +2145,17 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1593
2145
  * @returns a reference to the same constructor passed in (but now mutated)
1594
2146
  */
1595
2147
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1596
- if (cmpMeta.$members$) {
1597
- if (Cstr.watchers) {
2148
+ if (BUILD.member && cmpMeta.$members$) {
2149
+ if (BUILD.watchCallback && Cstr.watchers) {
1598
2150
  cmpMeta.$watchers$ = Cstr.watchers;
1599
2151
  }
1600
2152
  // It's better to have a const than two Object.entries()
1601
2153
  const members = Object.entries(cmpMeta.$members$);
1602
2154
  const prototype = Cstr.prototype;
1603
2155
  members.map(([memberName, [memberFlags]]) => {
1604
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1605
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2156
+ if ((BUILD.prop || BUILD.state) &&
2157
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2158
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1606
2159
  // proxyComponent - prop
1607
2160
  Object.defineProperty(prototype, memberName, {
1608
2161
  get() {
@@ -1610,6 +2163,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1610
2163
  return getValue(this, memberName);
1611
2164
  },
1612
2165
  set(newValue) {
2166
+ // only during dev time
2167
+ if (BUILD.isDev) {
2168
+ const ref = getHostRef(this);
2169
+ if (
2170
+ // we are proxying the instance (not element)
2171
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2172
+ // the element is not constructing
2173
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2174
+ // the member is a prop
2175
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2176
+ // the member is not mutable
2177
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2178
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2179
+ }
2180
+ }
1613
2181
  // proxyComponent, set value
1614
2182
  setValue(this, memberName, newValue, cmpMeta);
1615
2183
  },
@@ -1617,7 +2185,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1617
2185
  enumerable: true,
1618
2186
  });
1619
2187
  }
1620
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2188
+ else if (BUILD.lazyLoad &&
2189
+ BUILD.method &&
2190
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1621
2191
  memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1622
2192
  // proxyComponent - method
1623
2193
  Object.defineProperty(prototype, memberName, {
@@ -1628,7 +2198,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1628
2198
  });
1629
2199
  }
1630
2200
  });
1631
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2201
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1632
2202
  const attrNameToPropName = new Map();
1633
2203
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1634
2204
  plt.jmp(() => {
@@ -1688,7 +2258,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1688
2258
  .map(([propName, m]) => {
1689
2259
  const attrName = m[1] || propName;
1690
2260
  attrNameToPropName.set(attrName, propName);
1691
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2261
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1692
2262
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1693
2263
  }
1694
2264
  return attrName;
@@ -1699,25 +2269,29 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1699
2269
  };
1700
2270
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1701
2271
  // initializeComponent
1702
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1703
- {
2272
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2273
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2274
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
1704
2275
  // we haven't initialized this element yet
1705
2276
  hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1706
2277
  // lazy loaded components
1707
2278
  // request the component's implementation to be
1708
2279
  // wired up with the host element
1709
- Cstr = loadModule(cmpMeta);
2280
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
1710
2281
  if (Cstr.then) {
1711
2282
  // Await creates a micro-task avoid if possible
1712
- const endLoad = uniqueTime();
2283
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
1713
2284
  Cstr = await Cstr;
1714
2285
  endLoad();
1715
2286
  }
1716
- if (!Cstr.isProxied) {
2287
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2288
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2289
+ }
2290
+ if (BUILD.member && !Cstr.isProxied) {
1717
2291
  // we've never proxied this Constructor before
1718
2292
  // let's add the getters/setters to its prototype before
1719
2293
  // the first time we create an instance of the implementation
1720
- {
2294
+ if (BUILD.watchCallback) {
1721
2295
  cmpMeta.$watchers$ = Cstr.watchers;
1722
2296
  }
1723
2297
  proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
@@ -1727,7 +2301,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1727
2301
  // ok, time to construct the instance
1728
2302
  // but let's keep track of when we start and stop
1729
2303
  // so that the getters/setters don't incorrectly step on data
1730
- {
2304
+ if (BUILD.member) {
1731
2305
  hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1732
2306
  }
1733
2307
  // construct the lazy-loaded component implementation
@@ -1740,21 +2314,42 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1740
2314
  catch (e) {
1741
2315
  consoleError(e);
1742
2316
  }
1743
- {
2317
+ if (BUILD.member) {
1744
2318
  hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1745
2319
  }
1746
- {
2320
+ if (BUILD.watchCallback) {
1747
2321
  hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1748
2322
  }
1749
2323
  endNewInstance();
1750
2324
  fireConnectedCallback(hostRef.$lazyInstance$);
1751
2325
  }
1752
- if (Cstr.style) {
2326
+ else {
2327
+ // sync constructor component
2328
+ Cstr = elm.constructor;
2329
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2330
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2331
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2332
+ // Stencil has completed instantiating the component.
2333
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2334
+ }
2335
+ if (BUILD.style && Cstr.style) {
1753
2336
  // this component has styles but we haven't registered them yet
1754
2337
  let style = Cstr.style;
1755
- const scopeId = getScopeId(cmpMeta);
2338
+ if (BUILD.mode && typeof style !== 'string') {
2339
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2340
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2341
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2342
+ }
2343
+ }
2344
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
1756
2345
  if (!styles.has(scopeId)) {
1757
2346
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2347
+ if (!BUILD.hydrateServerSide &&
2348
+ BUILD.shadowDom &&
2349
+ BUILD.shadowDomShim &&
2350
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2351
+ style = await Promise.resolve().then(function () { return require('./shadow-css-7e3e0ab1.js'); }).then((m) => m.scopeCss(style, scopeId, false));
2352
+ }
1758
2353
  registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1759
2354
  endRegisterStyles();
1760
2355
  }
@@ -1763,7 +2358,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1763
2358
  // we've successfully created a lazy instance
1764
2359
  const ancestorComponent = hostRef.$ancestorComponent$;
1765
2360
  const schedule = () => scheduleUpdate(hostRef, true);
1766
- if (ancestorComponent && ancestorComponent['s-rc']) {
2361
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
1767
2362
  // this is the initial load and this component it has an ancestor component
1768
2363
  // but the ancestor component has NOT fired its will update lifecycle yet
1769
2364
  // so let's just cool our jets and wait for the ancestor to continue first
@@ -1777,7 +2372,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1777
2372
  }
1778
2373
  };
1779
2374
  const fireConnectedCallback = (instance) => {
1780
- {
2375
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
1781
2376
  safeCall(instance, 'connectedCallback');
1782
2377
  }
1783
2378
  };
@@ -1786,26 +2381,49 @@ const connectedCallback = (elm) => {
1786
2381
  const hostRef = getHostRef(elm);
1787
2382
  const cmpMeta = hostRef.$cmpMeta$;
1788
2383
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2384
+ if (BUILD.hostListenerTargetParent) {
2385
+ // only run if we have listeners being attached to a parent
2386
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2387
+ }
1789
2388
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1790
2389
  // first time this component has connected
1791
2390
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1792
- {
2391
+ let hostId;
2392
+ if (BUILD.hydrateClientSide) {
2393
+ hostId = elm.getAttribute(HYDRATE_ID);
2394
+ if (hostId) {
2395
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2396
+ const scopeId = BUILD.mode
2397
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2398
+ : addStyle(elm.shadowRoot, cmpMeta);
2399
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2400
+ }
2401
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2402
+ }
2403
+ }
2404
+ if (BUILD.slotRelocation && !hostId) {
1793
2405
  // initUpdate
1794
2406
  // if the slot polyfill is required we'll need to put some nodes
1795
2407
  // in here to act as original content anchors as we move nodes around
1796
2408
  // host element has been connected to the DOM
1797
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2409
+ if (BUILD.hydrateServerSide ||
2410
+ ((BUILD.slot || BUILD.shadowDom) &&
2411
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1798
2412
  setContentReference(elm);
1799
2413
  }
1800
2414
  }
1801
- {
2415
+ if (BUILD.asyncLoading) {
1802
2416
  // find the first ancestor component (if there is one) and register
1803
2417
  // this component as one of the actively loading child components for its ancestor
1804
2418
  let ancestorComponent = elm;
1805
2419
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1806
2420
  // climb up the ancestors looking for the first
1807
2421
  // component that hasn't finished its lifecycle update yet
1808
- if (ancestorComponent['s-p']) {
2422
+ if ((BUILD.hydrateClientSide &&
2423
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2424
+ ancestorComponent.hasAttribute('s-id') &&
2425
+ ancestorComponent['s-p']) ||
2426
+ ancestorComponent['s-p']) {
1809
2427
  // we found this components first ancestor component
1810
2428
  // keep a reference to this component's ancestor component
1811
2429
  attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
@@ -1815,7 +2433,7 @@ const connectedCallback = (elm) => {
1815
2433
  }
1816
2434
  // Lazy properties
1817
2435
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1818
- if (cmpMeta.$members$) {
2436
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
1819
2437
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1820
2438
  if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1821
2439
  const value = elm[memberName];
@@ -1824,7 +2442,14 @@ const connectedCallback = (elm) => {
1824
2442
  }
1825
2443
  });
1826
2444
  }
1827
- {
2445
+ if (BUILD.initializeNextTick) {
2446
+ // connectedCallback, taskQueue, initialLoad
2447
+ // angular sets attribute AFTER connectCallback
2448
+ // https://github.com/angular/angular/issues/18909
2449
+ // https://github.com/angular/angular/issues/19940
2450
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2451
+ }
2452
+ else {
1828
2453
  initializeComponent(elm, hostRef, cmpMeta);
1829
2454
  }
1830
2455
  }
@@ -1832,7 +2457,7 @@ const connectedCallback = (elm) => {
1832
2457
  // not the first time this has connected
1833
2458
  // reattach any event listeners to the host
1834
2459
  // since they would have been removed when disconnected
1835
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2460
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
1836
2461
  // fire off connectedCallback() on component instance
1837
2462
  fireConnectedCallback(hostRef.$lazyInstance$);
1838
2463
  }
@@ -1846,34 +2471,345 @@ const setContentReference = (elm) => {
1846
2471
  // let's pick out the inner content for slot projection
1847
2472
  // create a node to represent where the original
1848
2473
  // content was first placed, which is useful later on
1849
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2474
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
1850
2475
  contentRefElm['s-cn'] = true;
1851
2476
  elm.insertBefore(contentRefElm, elm.firstChild);
1852
2477
  };
1853
2478
  const disconnectedCallback = (elm) => {
1854
2479
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1855
2480
  const hostRef = getHostRef(elm);
1856
- const instance = hostRef.$lazyInstance$ ;
1857
- {
2481
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2482
+ if (BUILD.hostListener) {
1858
2483
  if (hostRef.$rmListeners$) {
1859
2484
  hostRef.$rmListeners$.map((rmListener) => rmListener());
1860
2485
  hostRef.$rmListeners$ = undefined;
1861
2486
  }
1862
2487
  }
1863
- {
2488
+ // clear CSS var-shim tracking
2489
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2490
+ plt.$cssShim$.removeHost(elm);
2491
+ }
2492
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
1864
2493
  safeCall(instance, 'disconnectedCallback');
1865
2494
  }
2495
+ if (BUILD.cmpDidUnload) {
2496
+ safeCall(instance, 'componentDidUnload');
2497
+ }
1866
2498
  }
1867
2499
  };
2500
+ const defineCustomElement = (Cstr, compactMeta) => {
2501
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2502
+ };
2503
+ const proxyCustomElement = (Cstr, compactMeta) => {
2504
+ const cmpMeta = {
2505
+ $flags$: compactMeta[0],
2506
+ $tagName$: compactMeta[1],
2507
+ };
2508
+ if (BUILD.member) {
2509
+ cmpMeta.$members$ = compactMeta[2];
2510
+ }
2511
+ if (BUILD.hostListener) {
2512
+ cmpMeta.$listeners$ = compactMeta[3];
2513
+ }
2514
+ if (BUILD.watchCallback) {
2515
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2516
+ }
2517
+ if (BUILD.reflect) {
2518
+ cmpMeta.$attrsToReflect$ = [];
2519
+ }
2520
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2521
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2522
+ }
2523
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2524
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2525
+ Object.assign(Cstr.prototype, {
2526
+ __registerHost() {
2527
+ registerHost(this, cmpMeta);
2528
+ },
2529
+ connectedCallback() {
2530
+ connectedCallback(this);
2531
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2532
+ originalConnectedCallback.call(this);
2533
+ }
2534
+ },
2535
+ disconnectedCallback() {
2536
+ disconnectedCallback(this);
2537
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2538
+ originalDisconnectedCallback.call(this);
2539
+ }
2540
+ },
2541
+ __attachShadow() {
2542
+ if (supportsShadow) {
2543
+ if (BUILD.shadowDelegatesFocus) {
2544
+ this.attachShadow({
2545
+ mode: 'open',
2546
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2547
+ });
2548
+ }
2549
+ else {
2550
+ this.attachShadow({ mode: 'open' });
2551
+ }
2552
+ }
2553
+ else {
2554
+ this.shadowRoot = this;
2555
+ }
2556
+ },
2557
+ });
2558
+ Cstr.is = cmpMeta.$tagName$;
2559
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2560
+ };
2561
+ const forceModeUpdate = (elm) => {
2562
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2563
+ const mode = computeMode(elm);
2564
+ const hostRef = getHostRef(elm);
2565
+ if (hostRef.$modeName$ !== mode) {
2566
+ const cmpMeta = hostRef.$cmpMeta$;
2567
+ const oldScopeId = elm['s-sc'];
2568
+ const scopeId = getScopeId(cmpMeta, mode);
2569
+ const style = elm.constructor.style[mode];
2570
+ const flags = cmpMeta.$flags$;
2571
+ if (style) {
2572
+ if (!styles.has(scopeId)) {
2573
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2574
+ }
2575
+ hostRef.$modeName$ = mode;
2576
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2577
+ attachStyles(hostRef);
2578
+ forceUpdate(elm);
2579
+ }
2580
+ }
2581
+ }
2582
+ };
2583
+ const patchCloneNode = (HostElementPrototype) => {
2584
+ const orgCloneNode = HostElementPrototype.cloneNode;
2585
+ HostElementPrototype.cloneNode = function (deep) {
2586
+ const srcNode = this;
2587
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2588
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2589
+ if (BUILD.slot && !isShadowDom && deep) {
2590
+ let i = 0;
2591
+ let slotted, nonStencilNode;
2592
+ const stencilPrivates = [
2593
+ 's-id',
2594
+ 's-cr',
2595
+ 's-lr',
2596
+ 's-rc',
2597
+ 's-sc',
2598
+ 's-p',
2599
+ 's-cn',
2600
+ 's-sr',
2601
+ 's-sn',
2602
+ 's-hn',
2603
+ 's-ol',
2604
+ 's-nr',
2605
+ 's-si',
2606
+ ];
2607
+ for (; i < srcNode.childNodes.length; i++) {
2608
+ slotted = srcNode.childNodes[i]['s-nr'];
2609
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2610
+ if (slotted) {
2611
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2612
+ clonedNode.__appendChild(slotted.cloneNode(true));
2613
+ }
2614
+ else {
2615
+ clonedNode.appendChild(slotted.cloneNode(true));
2616
+ }
2617
+ }
2618
+ if (nonStencilNode) {
2619
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2620
+ }
2621
+ }
2622
+ }
2623
+ return clonedNode;
2624
+ };
2625
+ };
2626
+ const patchSlotAppendChild = (HostElementPrototype) => {
2627
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2628
+ HostElementPrototype.appendChild = function (newChild) {
2629
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2630
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2631
+ if (slotNode) {
2632
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2633
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2634
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2635
+ }
2636
+ return this.__appendChild(newChild);
2637
+ };
2638
+ };
2639
+ /**
2640
+ * Patches the text content of an unnamed slotted node inside a scoped component
2641
+ * @param hostElementPrototype the `Element` to be patched
2642
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2643
+ */
2644
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2645
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2646
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2647
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2648
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2649
+ get() {
2650
+ var _a;
2651
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2652
+ // the empty string
2653
+ const slotNode = getHostSlotNode(this.childNodes, '');
2654
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2655
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2656
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2657
+ return slotNode.nextSibling.textContent;
2658
+ }
2659
+ else if (slotNode) {
2660
+ return slotNode.textContent;
2661
+ }
2662
+ else {
2663
+ // fallback to the original implementation
2664
+ return this.__textContent;
2665
+ }
2666
+ },
2667
+ set(value) {
2668
+ var _a;
2669
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2670
+ // the empty string
2671
+ const slotNode = getHostSlotNode(this.childNodes, '');
2672
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2673
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2674
+ // sibling.
2675
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2676
+ slotNode.nextSibling.textContent = value;
2677
+ }
2678
+ else if (slotNode) {
2679
+ slotNode.textContent = value;
2680
+ }
2681
+ else {
2682
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2683
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2684
+ // it there
2685
+ this.__textContent = value;
2686
+ const contentRefElm = this['s-cr'];
2687
+ if (contentRefElm) {
2688
+ this.insertBefore(contentRefElm, this.firstChild);
2689
+ }
2690
+ }
2691
+ },
2692
+ });
2693
+ }
2694
+ };
2695
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2696
+ class FakeNodeList extends Array {
2697
+ item(n) {
2698
+ return this[n];
2699
+ }
2700
+ }
2701
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2702
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2703
+ Object.defineProperty(elm, 'children', {
2704
+ get() {
2705
+ return this.childNodes.map((n) => n.nodeType === 1);
2706
+ },
2707
+ });
2708
+ Object.defineProperty(elm, 'childElementCount', {
2709
+ get() {
2710
+ return elm.children.length;
2711
+ },
2712
+ });
2713
+ Object.defineProperty(elm, 'childNodes', {
2714
+ get() {
2715
+ const childNodes = childNodesFn.call(this);
2716
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2717
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2718
+ const result = new FakeNodeList();
2719
+ for (let i = 0; i < childNodes.length; i++) {
2720
+ const slot = childNodes[i]['s-nr'];
2721
+ if (slot) {
2722
+ result.push(slot);
2723
+ }
2724
+ }
2725
+ return result;
2726
+ }
2727
+ return FakeNodeList.from(childNodes);
2728
+ },
2729
+ });
2730
+ }
2731
+ };
2732
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2733
+ /**
2734
+ * Recursively searches a series of child nodes for a slot with the provided name.
2735
+ * @param childNodes the nodes to search for a slot with a specific name.
2736
+ * @param slotName the name of the slot to match on.
2737
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2738
+ */
2739
+ const getHostSlotNode = (childNodes, slotName) => {
2740
+ let i = 0;
2741
+ let childNode;
2742
+ for (; i < childNodes.length; i++) {
2743
+ childNode = childNodes[i];
2744
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2745
+ return childNode;
2746
+ }
2747
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2748
+ if (childNode) {
2749
+ return childNode;
2750
+ }
2751
+ }
2752
+ return null;
2753
+ };
2754
+ const getHostSlotChildNodes = (n, slotName) => {
2755
+ const childNodes = [n];
2756
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2757
+ childNodes.push(n);
2758
+ }
2759
+ return childNodes;
2760
+ };
2761
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2762
+ // ¯\_(ツ)_/¯
2763
+ const hostRef = getHostRef(elm);
2764
+ // reset state flags to only have been connected
2765
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2766
+ // TODO
2767
+ // detatch any event listeners that may have been added
2768
+ // because we're not passing an exact event name it'll
2769
+ // remove all of this element's event, which is good
2770
+ // create a callback for when this component finishes hmr
2771
+ elm['s-hmr-load'] = () => {
2772
+ // finished hmr for this element
2773
+ delete elm['s-hmr-load'];
2774
+ };
2775
+ // re-initialize the component
2776
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2777
+ };
1868
2778
  const bootstrapLazy = (lazyBundles, options = {}) => {
1869
- const endBootstrap = createTime();
2779
+ var _a;
2780
+ if (BUILD.profile && performance.mark) {
2781
+ performance.mark('st:app:start');
2782
+ }
2783
+ installDevTools();
2784
+ const endBootstrap = createTime('bootstrapLazy');
2785
+ const cmpTags = [];
1870
2786
  const exclude = options.exclude || [];
1871
2787
  const customElements = win.customElements;
2788
+ const head = doc.head;
2789
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2790
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1872
2791
  const deferredConnectedCallbacks = [];
2792
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1873
2793
  let appLoadFallback;
1874
2794
  let isBootstrapping = true;
2795
+ let i = 0;
1875
2796
  Object.assign(plt, options);
1876
2797
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2798
+ if (BUILD.asyncQueue) {
2799
+ if (options.syncQueue) {
2800
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2801
+ }
2802
+ }
2803
+ if (BUILD.hydrateClientSide) {
2804
+ // If the app is already hydrated there is not point to disable the
2805
+ // async queue. This will improve the first input delay
2806
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2807
+ }
2808
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2809
+ for (; i < styles.length; i++) {
2810
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2811
+ }
2812
+ }
1877
2813
  lazyBundles.map((lazyBundle) => {
1878
2814
  lazyBundle[1].map((compactMeta) => {
1879
2815
  const cmpMeta = {
@@ -1882,19 +2818,24 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1882
2818
  $members$: compactMeta[2],
1883
2819
  $listeners$: compactMeta[3],
1884
2820
  };
1885
- {
2821
+ if (BUILD.member) {
1886
2822
  cmpMeta.$members$ = compactMeta[2];
1887
2823
  }
1888
- {
2824
+ if (BUILD.hostListener) {
1889
2825
  cmpMeta.$listeners$ = compactMeta[3];
1890
2826
  }
1891
- {
2827
+ if (BUILD.reflect) {
1892
2828
  cmpMeta.$attrsToReflect$ = [];
1893
2829
  }
1894
- {
2830
+ if (BUILD.watchCallback) {
1895
2831
  cmpMeta.$watchers$ = {};
1896
2832
  }
1897
- const tagName = cmpMeta.$tagName$;
2833
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2834
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2835
+ }
2836
+ const tagName = BUILD.transformTagName && options.transformTagName
2837
+ ? options.transformTagName(cmpMeta.$tagName$)
2838
+ : cmpMeta.$tagName$;
1898
2839
  const HostElement = class extends HTMLElement {
1899
2840
  // StencilLazyHost
1900
2841
  constructor(self) {
@@ -1902,16 +2843,28 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1902
2843
  super(self);
1903
2844
  self = this;
1904
2845
  registerHost(self, cmpMeta);
1905
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2846
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1906
2847
  // this component is using shadow dom
1907
2848
  // and this browser supports shadow dom
1908
2849
  // add the read-only property "shadowRoot" to the host element
1909
2850
  // adding the shadow root build conditionals to minimize runtime
1910
- {
1911
- {
2851
+ if (supportsShadow) {
2852
+ if (BUILD.shadowDelegatesFocus) {
2853
+ self.attachShadow({
2854
+ mode: 'open',
2855
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2856
+ });
2857
+ }
2858
+ else {
1912
2859
  self.attachShadow({ mode: 'open' });
1913
2860
  }
1914
2861
  }
2862
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2863
+ self.shadowRoot = self;
2864
+ }
2865
+ }
2866
+ if (BUILD.slotChildNodesFix) {
2867
+ patchChildSlotNodes(self, cmpMeta);
1915
2868
  }
1916
2869
  }
1917
2870
  connectedCallback() {
@@ -1934,30 +2887,126 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1934
2887
  return getHostRef(this).$onReadyPromise$;
1935
2888
  }
1936
2889
  };
2890
+ if (BUILD.cloneNodeFix) {
2891
+ patchCloneNode(HostElement.prototype);
2892
+ }
2893
+ if (BUILD.appendChildSlotFix) {
2894
+ patchSlotAppendChild(HostElement.prototype);
2895
+ }
2896
+ if (BUILD.hotModuleReplacement) {
2897
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2898
+ hmrStart(this, cmpMeta, hmrVersionId);
2899
+ };
2900
+ }
2901
+ if (BUILD.scopedSlotTextContentFix) {
2902
+ patchTextContent(HostElement.prototype, cmpMeta);
2903
+ }
1937
2904
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1938
2905
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2906
+ cmpTags.push(tagName);
1939
2907
  customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1940
2908
  }
1941
2909
  });
1942
2910
  });
2911
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2912
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2913
+ visibilityStyle.setAttribute('data-styles', '');
2914
+ // Apply CSP nonce to the style tag if it exists
2915
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2916
+ if (nonce != null) {
2917
+ visibilityStyle.setAttribute('nonce', nonce);
2918
+ }
2919
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2920
+ }
1943
2921
  // Process deferred connectedCallbacks now all components have been registered
1944
2922
  isBootstrapping = false;
1945
2923
  if (deferredConnectedCallbacks.length) {
1946
2924
  deferredConnectedCallbacks.map((host) => host.connectedCallback());
1947
2925
  }
1948
2926
  else {
1949
- {
2927
+ if (BUILD.profile) {
2928
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2929
+ }
2930
+ else {
1950
2931
  plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1951
2932
  }
1952
2933
  }
1953
2934
  // Fallback appLoad event
1954
2935
  endBootstrap();
1955
2936
  };
2937
+ const getConnect = (_ref, tagName) => {
2938
+ const componentOnReady = () => {
2939
+ let elm = doc.querySelector(tagName);
2940
+ if (!elm) {
2941
+ elm = doc.createElement(tagName);
2942
+ doc.body.appendChild(elm);
2943
+ }
2944
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2945
+ };
2946
+ const create = (...args) => {
2947
+ return componentOnReady().then((el) => el.create(...args));
2948
+ };
2949
+ return {
2950
+ create,
2951
+ componentOnReady,
2952
+ };
2953
+ };
2954
+ const getContext = (_elm, context) => {
2955
+ if (context in Context) {
2956
+ return Context[context];
2957
+ }
2958
+ else if (context === 'window') {
2959
+ return win;
2960
+ }
2961
+ else if (context === 'document') {
2962
+ return doc;
2963
+ }
2964
+ else if (context === 'isServer' || context === 'isPrerender') {
2965
+ return BUILD.hydrateServerSide ? true : false;
2966
+ }
2967
+ else if (context === 'isClient') {
2968
+ return BUILD.hydrateServerSide ? false : true;
2969
+ }
2970
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2971
+ return getAssetPath('.');
2972
+ }
2973
+ else if (context === 'queue') {
2974
+ return {
2975
+ write: writeTask,
2976
+ read: readTask,
2977
+ tick: {
2978
+ then(cb) {
2979
+ return nextTick(cb);
2980
+ },
2981
+ },
2982
+ };
2983
+ }
2984
+ return undefined;
2985
+ };
1956
2986
  const Fragment = (_, children) => children;
1957
2987
  const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1958
- if (listeners) {
2988
+ if (BUILD.hostListener && listeners) {
2989
+ // this is called immediately within the element's constructor
2990
+ // initialize our event listeners on the host element
2991
+ // we do this now so that we can listen to events that may
2992
+ // have fired even before the instance is ready
2993
+ if (BUILD.hostListenerTargetParent) {
2994
+ // this component may have event listeners that should be attached to the parent
2995
+ if (attachParentListeners) {
2996
+ // this is being ran from within the connectedCallback
2997
+ // which is important so that we know the host element actually has a parent element
2998
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2999
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
3000
+ }
3001
+ else {
3002
+ // this is being ran from within the component constructor
3003
+ // everything BUT the parent element listeners should be attached at this time
3004
+ // filter out the listeners that are NOT being attached to the parent
3005
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
3006
+ }
3007
+ }
1959
3008
  listeners.map(([flags, name, method]) => {
1960
- const target = getHostListenerTarget(elm, flags) ;
3009
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
1961
3010
  const handler = hostListenerProxy(hostRef, method);
1962
3011
  const opts = hostListenerOpts(flags);
1963
3012
  plt.ael(target, name, handler, opts);
@@ -1967,7 +3016,7 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
1967
3016
  };
1968
3017
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
1969
3018
  try {
1970
- {
3019
+ if (BUILD.lazyLoad) {
1971
3020
  if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1972
3021
  // instance is ready, let's call it's member method for this event
1973
3022
  hostRef.$lazyInstance$[methodName](ev);
@@ -1976,20 +3025,32 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1976
3025
  (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1977
3026
  }
1978
3027
  }
3028
+ else {
3029
+ hostRef.$hostElement$[methodName](ev);
3030
+ }
1979
3031
  }
1980
3032
  catch (e) {
1981
3033
  consoleError(e);
1982
3034
  }
1983
3035
  };
1984
3036
  const getHostListenerTarget = (elm, flags) => {
1985
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3037
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3038
+ return doc;
3039
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1986
3040
  return win;
1987
- if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
3041
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
1988
3042
  return doc.body;
3043
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
3044
+ return elm.parentElement;
1989
3045
  return elm;
1990
3046
  };
1991
3047
  // prettier-ignore
1992
- const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3048
+ const hostListenerOpts = (flags) => supportsListenerOptions
3049
+ ? ({
3050
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3051
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3052
+ })
3053
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1993
3054
  /**
1994
3055
  * Assigns the given value to the nonce property on the runtime platform object.
1995
3056
  * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
@@ -1997,6 +3058,146 @@ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !==
1997
3058
  * @returns void
1998
3059
  */
1999
3060
  const setNonce = (nonce) => (plt.$nonce$ = nonce);
3061
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
3062
+ const insertVdomAnnotations = (doc, staticComponents) => {
3063
+ if (doc != null) {
3064
+ const docData = {
3065
+ hostIds: 0,
3066
+ rootLevelIds: 0,
3067
+ staticComponents: new Set(staticComponents),
3068
+ };
3069
+ const orgLocationNodes = [];
3070
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
3071
+ orgLocationNodes.forEach((orgLocationNode) => {
3072
+ if (orgLocationNode != null) {
3073
+ const nodeRef = orgLocationNode['s-nr'];
3074
+ let hostId = nodeRef['s-host-id'];
3075
+ let nodeId = nodeRef['s-node-id'];
3076
+ let childId = `${hostId}.${nodeId}`;
3077
+ if (hostId == null) {
3078
+ hostId = 0;
3079
+ docData.rootLevelIds++;
3080
+ nodeId = docData.rootLevelIds;
3081
+ childId = `${hostId}.${nodeId}`;
3082
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3083
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
3084
+ }
3085
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
3086
+ if (hostId === 0) {
3087
+ const textContent = nodeRef.nodeValue.trim();
3088
+ if (textContent === '') {
3089
+ // useless whitespace node at the document root
3090
+ orgLocationNode.remove();
3091
+ return;
3092
+ }
3093
+ }
3094
+ const commentBeforeTextNode = doc.createComment(childId);
3095
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
3096
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
3097
+ }
3098
+ }
3099
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
3100
+ const orgLocationParentNode = orgLocationNode.parentElement;
3101
+ if (orgLocationParentNode) {
3102
+ if (orgLocationParentNode['s-en'] === '') {
3103
+ // ending with a "." means that the parent element
3104
+ // of this node's original location is a SHADOW dom element
3105
+ // and this node is apart of the root level light dom
3106
+ orgLocationNodeId += `.`;
3107
+ }
3108
+ else if (orgLocationParentNode['s-en'] === 'c') {
3109
+ // ending with a ".c" means that the parent element
3110
+ // of this node's original location is a SCOPED element
3111
+ // and this node is apart of the root level light dom
3112
+ orgLocationNodeId += `.c`;
3113
+ }
3114
+ }
3115
+ orgLocationNode.nodeValue = orgLocationNodeId;
3116
+ }
3117
+ });
3118
+ }
3119
+ };
3120
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3121
+ if (node == null) {
3122
+ return;
3123
+ }
3124
+ if (node['s-nr'] != null) {
3125
+ orgLocationNodes.push(node);
3126
+ }
3127
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3128
+ node.childNodes.forEach((childNode) => {
3129
+ const hostRef = getHostRef(childNode);
3130
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3131
+ const cmpData = {
3132
+ nodeIds: 0,
3133
+ };
3134
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3135
+ }
3136
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3137
+ });
3138
+ }
3139
+ };
3140
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3141
+ if (vnode != null) {
3142
+ const hostId = ++docData.hostIds;
3143
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3144
+ if (hostElm['s-cr'] != null) {
3145
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3146
+ }
3147
+ if (vnode.$children$ != null) {
3148
+ const depth = 0;
3149
+ vnode.$children$.forEach((vnodeChild, index) => {
3150
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3151
+ });
3152
+ }
3153
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3154
+ const parent = hostElm.parentElement;
3155
+ if (parent && parent.childNodes) {
3156
+ const parentChildNodes = Array.from(parent.childNodes);
3157
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3158
+ if (comment) {
3159
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3160
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3161
+ }
3162
+ }
3163
+ }
3164
+ }
3165
+ };
3166
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3167
+ const childElm = vnodeChild.$elm$;
3168
+ if (childElm == null) {
3169
+ return;
3170
+ }
3171
+ const nodeId = cmpData.nodeIds++;
3172
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3173
+ childElm['s-host-id'] = hostId;
3174
+ childElm['s-node-id'] = nodeId;
3175
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3176
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3177
+ }
3178
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3179
+ const parentNode = childElm.parentNode;
3180
+ const nodeName = parentNode.nodeName;
3181
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3182
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3183
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3184
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3185
+ }
3186
+ }
3187
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3188
+ if (childElm['s-sr']) {
3189
+ const slotName = childElm['s-sn'] || '';
3190
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3191
+ childElm.nodeValue = slotNodeId;
3192
+ }
3193
+ }
3194
+ if (vnodeChild.$children$ != null) {
3195
+ const childDepth = depth + 1;
3196
+ vnodeChild.$children$.forEach((vnode, index) => {
3197
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3198
+ });
3199
+ }
3200
+ };
2000
3201
  const hostRefs = /*@__PURE__*/ new WeakMap();
2001
3202
  const getHostRef = (ref) => hostRefs.get(ref);
2002
3203
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -2007,25 +3208,42 @@ const registerHost = (elm, cmpMeta) => {
2007
3208
  $cmpMeta$: cmpMeta,
2008
3209
  $instanceValues$: new Map(),
2009
3210
  };
2010
- {
3211
+ if (BUILD.isDev) {
3212
+ hostRef.$renderCount$ = 0;
3213
+ }
3214
+ if (BUILD.method && BUILD.lazyLoad) {
2011
3215
  hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2012
3216
  }
2013
- {
3217
+ if (BUILD.asyncLoading) {
2014
3218
  hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2015
3219
  elm['s-p'] = [];
2016
3220
  elm['s-rc'] = [];
2017
3221
  }
2018
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
3222
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2019
3223
  return hostRefs.set(elm, hostRef);
2020
3224
  };
2021
3225
  const isMemberInElement = (elm, memberName) => memberName in elm;
2022
- const consoleError = (e, el) => (0, console.error)(e, el);
3226
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3227
+ const STENCIL_DEV_MODE = BUILD.isTesting
3228
+ ? ['STENCIL:'] // E2E testing
3229
+ : [
3230
+ '%cstencil',
3231
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3232
+ ];
3233
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3234
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3235
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3236
+ const setErrorHandler = (handler) => (customError = handler);
2023
3237
  const cmpModules = /*@__PURE__*/ new Map();
2024
3238
  const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2025
3239
  // loadModuleImport
2026
3240
  const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2027
3241
  const bundleId = cmpMeta.$lazyBundleId$;
2028
- const module = cmpModules.get(bundleId) ;
3242
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3243
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3244
+ return undefined;
3245
+ }
3246
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
2029
3247
  if (module) {
2030
3248
  return module[exportName];
2031
3249
  }
@@ -2236,16 +3454,20 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2236
3454
  /* webpackInclude: /\.entry\.js$/ */
2237
3455
  /* webpackExclude: /\.system\.entry\.js$/ */
2238
3456
  /* webpackMode: "lazy" */
2239
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
2240
- {
3457
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then((importedModule) => {
3458
+ if (!BUILD.hotModuleReplacement) {
2241
3459
  cmpModules.set(bundleId, importedModule);
2242
3460
  }
2243
3461
  return importedModule[exportName];
2244
3462
  }, consoleError);
2245
3463
  };
2246
3464
  const styles = /*@__PURE__*/ new Map();
3465
+ const modeResolutionChain = [];
2247
3466
  const win = typeof window !== 'undefined' ? window : {};
3467
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
2248
3468
  const doc = win.document || { head: {} };
3469
+ const H = (win.HTMLElement || class {
3470
+ });
2249
3471
  const plt = {
2250
3472
  $flags$: 0,
2251
3473
  $resourcesUrl$: '',
@@ -2255,8 +3477,27 @@ const plt = {
2255
3477
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2256
3478
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
2257
3479
  };
3480
+ const setPlatformHelpers = (helpers) => {
3481
+ Object.assign(plt, helpers);
3482
+ };
3483
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3484
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3485
+ : true;
3486
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3487
+ let supportsListenerOptions = false;
3488
+ try {
3489
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3490
+ get() {
3491
+ supportsListenerOptions = true;
3492
+ },
3493
+ }));
3494
+ }
3495
+ catch (e) { }
3496
+ return supportsListenerOptions;
3497
+ })();
2258
3498
  const promiseResolve = (v) => Promise.resolve(v);
2259
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
3499
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3500
+ ? /*@__PURE__*/ (() => {
2260
3501
  try {
2261
3502
  new CSSStyleSheet();
2262
3503
  return typeof new CSSStyleSheet().replaceSync === 'function';
@@ -2264,9 +3505,10 @@ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2264
3505
  catch (e) { }
2265
3506
  return false;
2266
3507
  })()
2267
- ;
3508
+ : false;
2268
3509
  const queueDomReads = [];
2269
3510
  const queueDomWrites = [];
3511
+ const queueDomWritesLow = [];
2270
3512
  const queueTask = (queue, write) => (cb) => {
2271
3513
  queue.push(cb);
2272
3514
  if (!queuePending) {
@@ -2290,13 +3532,53 @@ const consume = (queue) => {
2290
3532
  }
2291
3533
  queue.length = 0;
2292
3534
  };
3535
+ const consumeTimeout = (queue, timeout) => {
3536
+ let i = 0;
3537
+ let ts = 0;
3538
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3539
+ try {
3540
+ queue[i++](ts);
3541
+ }
3542
+ catch (e) {
3543
+ consoleError(e);
3544
+ }
3545
+ }
3546
+ if (i === queue.length) {
3547
+ queue.length = 0;
3548
+ }
3549
+ else if (i !== 0) {
3550
+ queue.splice(0, i);
3551
+ }
3552
+ };
2293
3553
  const flush = () => {
3554
+ if (BUILD.asyncQueue) {
3555
+ queueCongestion++;
3556
+ }
2294
3557
  // always force a bunch of medium callbacks to run, but still have
2295
3558
  // a throttle on how many can run in a certain time
2296
3559
  // DOM READS!!!
2297
3560
  consume(queueDomReads);
2298
3561
  // DOM WRITES!!!
2299
- {
3562
+ if (BUILD.asyncQueue) {
3563
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3564
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3565
+ : Infinity;
3566
+ consumeTimeout(queueDomWrites, timeout);
3567
+ consumeTimeout(queueDomWritesLow, timeout);
3568
+ if (queueDomWrites.length > 0) {
3569
+ queueDomWritesLow.push(...queueDomWrites);
3570
+ queueDomWrites.length = 0;
3571
+ }
3572
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3573
+ // still more to do yet, but we've run out of time
3574
+ // let's let this thing cool off and try again in the next tick
3575
+ plt.raf(flush);
3576
+ }
3577
+ else {
3578
+ queueCongestion = 0;
3579
+ }
3580
+ }
3581
+ else {
2300
3582
  consume(queueDomWrites);
2301
3583
  if ((queuePending = queueDomReads.length > 0)) {
2302
3584
  // still more to do yet, but we've run out of time
@@ -2306,16 +3588,91 @@ const flush = () => {
2306
3588
  }
2307
3589
  };
2308
3590
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3591
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
2309
3592
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2310
3593
 
3594
+ const StencilCore = /*#__PURE__*/Object.freeze({
3595
+ __proto__: null,
3596
+ Build: Build,
3597
+ CSS: CSS,
3598
+ Context: Context,
3599
+ Fragment: Fragment,
3600
+ H: H,
3601
+ HTMLElement: H,
3602
+ Host: Host,
3603
+ STENCIL_DEV_MODE: STENCIL_DEV_MODE,
3604
+ addHostEventListeners: addHostEventListeners,
3605
+ bootstrapLazy: bootstrapLazy,
3606
+ cmpModules: cmpModules,
3607
+ connectedCallback: connectedCallback,
3608
+ consoleDevError: consoleDevError,
3609
+ consoleDevInfo: consoleDevInfo,
3610
+ consoleDevWarn: consoleDevWarn,
3611
+ consoleError: consoleError,
3612
+ createEvent: createEvent,
3613
+ defineCustomElement: defineCustomElement,
3614
+ disconnectedCallback: disconnectedCallback,
3615
+ doc: doc,
3616
+ forceModeUpdate: forceModeUpdate,
3617
+ forceUpdate: forceUpdate,
3618
+ getAssetPath: getAssetPath,
3619
+ getConnect: getConnect,
3620
+ getContext: getContext,
3621
+ getElement: getElement,
3622
+ getHostRef: getHostRef,
3623
+ getMode: getMode,
3624
+ getRenderingRef: getRenderingRef,
3625
+ getValue: getValue,
3626
+ h: h,
3627
+ insertVdomAnnotations: insertVdomAnnotations,
3628
+ isMemberInElement: isMemberInElement,
3629
+ loadModule: loadModule,
3630
+ modeResolutionChain: modeResolutionChain,
3631
+ nextTick: nextTick,
3632
+ parsePropertyValue: parsePropertyValue,
3633
+ plt: plt,
3634
+ postUpdateComponent: postUpdateComponent,
3635
+ promiseResolve: promiseResolve,
3636
+ proxyComponent: proxyComponent,
3637
+ proxyCustomElement: proxyCustomElement,
3638
+ readTask: readTask,
3639
+ registerHost: registerHost,
3640
+ registerInstance: registerInstance,
3641
+ renderVdom: renderVdom,
3642
+ setAssetPath: setAssetPath,
3643
+ setErrorHandler: setErrorHandler,
3644
+ setMode: setMode,
3645
+ setNonce: setNonce,
3646
+ setPlatformHelpers: setPlatformHelpers,
3647
+ setPlatformOptions: setPlatformOptions,
3648
+ setValue: setValue,
3649
+ styles: styles,
3650
+ supportsConstructableStylesheets: supportsConstructableStylesheets,
3651
+ supportsListenerOptions: supportsListenerOptions,
3652
+ supportsShadow: supportsShadow,
3653
+ win: win,
3654
+ writeTask: writeTask,
3655
+ BUILD: BUILD,
3656
+ Env: Env,
3657
+ NAMESPACE: NAMESPACE
3658
+ });
3659
+
3660
+ exports.BUILD = BUILD;
3661
+ exports.CSS = CSS;
2311
3662
  exports.Fragment = Fragment;
3663
+ exports.H = H;
2312
3664
  exports.Host = Host;
3665
+ exports.NAMESPACE = NAMESPACE;
3666
+ exports.StencilCore = StencilCore;
2313
3667
  exports.bootstrapLazy = bootstrapLazy;
3668
+ exports.consoleDevInfo = consoleDevInfo;
2314
3669
  exports.createEvent = createEvent;
3670
+ exports.doc = doc;
2315
3671
  exports.forceUpdate = forceUpdate;
2316
3672
  exports.getElement = getElement;
2317
- exports.getRenderingRef = getRenderingRef;
2318
3673
  exports.h = h;
3674
+ exports.plt = plt;
2319
3675
  exports.promiseResolve = promiseResolve;
2320
3676
  exports.registerInstance = registerInstance;
2321
3677
  exports.setNonce = setNonce;
3678
+ exports.win = win;