@ptcwebops/ptcw-design 0.0.15 → 0.1.1

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 (152) hide show
  1. package/dist/custom-elements/index.d.ts +12 -0
  2. package/dist/ptcw-design/app-globals-0f993ce5.js +3 -0
  3. package/dist/ptcw-design/assets/ptc-sprite.svg +67 -0
  4. package/dist/ptcw-design/css-shim-003e9264.js +4 -0
  5. package/dist/ptcw-design/dom-1b195079.js +73 -0
  6. package/dist/{esm → ptcw-design}/icon-asset.entry.js +2 -2
  7. package/dist/{cjs/index-ac192914.js → ptcw-design/index-f7043a90.js} +1311 -195
  8. package/dist/ptcw-design/index.esm.js +1 -0
  9. package/dist/{esm → ptcw-design}/list-item.entry.js +1 -1
  10. package/dist/{esm → ptcw-design}/lottie-player.entry.js +782 -31
  11. package/dist/{esm → ptcw-design}/my-component.entry.js +1 -1
  12. package/dist/ptcw-design/ptc-announcement.entry.js +31 -0
  13. package/dist/ptcw-design/ptc-button.entry.js +57 -0
  14. package/dist/{esm → ptcw-design}/ptc-card.entry.js +1 -1
  15. package/dist/{esm → ptcw-design}/ptc-date.entry.js +1 -1
  16. package/dist/{esm → ptcw-design}/ptc-footer.entry.js +1 -1
  17. package/dist/{esm → ptcw-design}/ptc-image.entry.js +1 -1
  18. package/dist/{esm → ptcw-design}/ptc-img.entry.js +12 -1
  19. package/dist/{esm → ptcw-design}/ptc-link.entry.js +1 -1
  20. package/dist/{esm → ptcw-design}/ptc-list.entry.js +1 -1
  21. package/dist/{esm → ptcw-design}/ptc-lottie.entry.js +1 -1
  22. package/dist/{esm → ptcw-design}/ptc-nav-item.entry.js +1 -1
  23. package/dist/{esm → ptcw-design}/ptc-nav.entry.js +1 -1
  24. package/dist/{esm → ptcw-design}/ptc-overlay.entry.js +1 -1
  25. package/dist/{esm → ptcw-design}/ptc-para.entry.js +2 -2
  26. package/dist/{esm → ptcw-design}/ptc-picture.entry.js +1 -1
  27. package/dist/{esm → ptcw-design}/ptc-spacer.entry.js +1 -1
  28. package/dist/{esm → ptcw-design}/ptc-span.entry.js +1 -1
  29. package/dist/ptcw-design/ptc-svg-btn.entry.js +27 -0
  30. package/dist/{esm → ptcw-design}/ptc-title.entry.js +1 -1
  31. package/dist/ptcw-design/ptcw-design.css +1030 -2
  32. package/dist/ptcw-design/ptcw-design.esm.js +122 -1
  33. package/dist/ptcw-design/shadow-css-c1ad5fdc.js +383 -0
  34. package/dist/types/components/icon-asset/icon-asset.d.ts +1 -1
  35. package/dist/types/components/ptc-announcement/ptc-announcement.d.ts +27 -0
  36. package/dist/types/components/ptc-button/ptc-button.d.ts +13 -1
  37. package/dist/types/components/ptc-para/ptc-para.d.ts +1 -1
  38. package/dist/types/components/ptc-svg-btn/ptc-svg-btn.d.ts +4 -0
  39. package/dist/types/components.d.ts +94 -6
  40. package/package.json +1 -1
  41. package/dist/cjs/icon-asset.cjs.entry.js +0 -64
  42. package/dist/cjs/index.cjs.js +0 -2
  43. package/dist/cjs/list-item.cjs.entry.js +0 -27
  44. package/dist/cjs/loader.cjs.js +0 -21
  45. package/dist/cjs/lottie-player.cjs.entry.js +0 -13476
  46. package/dist/cjs/my-component.cjs.entry.js +0 -26
  47. package/dist/cjs/ptc-button.cjs.entry.js +0 -48
  48. package/dist/cjs/ptc-card.cjs.entry.js +0 -75
  49. package/dist/cjs/ptc-date.cjs.entry.js +0 -48
  50. package/dist/cjs/ptc-footer.cjs.entry.js +0 -19
  51. package/dist/cjs/ptc-image.cjs.entry.js +0 -58
  52. package/dist/cjs/ptc-img.cjs.entry.js +0 -163
  53. package/dist/cjs/ptc-link.cjs.entry.js +0 -53
  54. package/dist/cjs/ptc-list.cjs.entry.js +0 -32
  55. package/dist/cjs/ptc-lottie.cjs.entry.js +0 -23
  56. package/dist/cjs/ptc-nav-item.cjs.entry.js +0 -94
  57. package/dist/cjs/ptc-nav.cjs.entry.js +0 -19
  58. package/dist/cjs/ptc-overlay.cjs.entry.js +0 -19
  59. package/dist/cjs/ptc-para.cjs.entry.js +0 -40
  60. package/dist/cjs/ptc-picture.cjs.entry.js +0 -26
  61. package/dist/cjs/ptc-spacer.cjs.entry.js +0 -46
  62. package/dist/cjs/ptc-span.cjs.entry.js +0 -31
  63. package/dist/cjs/ptc-title.cjs.entry.js +0 -49
  64. package/dist/cjs/ptcw-design.cjs.js +0 -19
  65. package/dist/collection/assets/responsive-background-image.min.js +0 -1
  66. package/dist/collection/collection-manifest.json +0 -38
  67. package/dist/collection/components/icon-asset/assets/brands.svg +0 -1381
  68. package/dist/collection/components/icon-asset/assets/footer-social.svg +0 -0
  69. package/dist/collection/components/icon-asset/assets/ptc-sprite.svg +0 -77
  70. package/dist/collection/components/icon-asset/assets/regular.svg +0 -463
  71. package/dist/collection/components/icon-asset/assets/solid.svg +0 -3013
  72. package/dist/collection/components/icon-asset/assets/svg-with-js.min.css +0 -5
  73. package/dist/collection/components/icon-asset/icon-asset.css +0 -26
  74. package/dist/collection/components/icon-asset/icon-asset.js +0 -177
  75. package/dist/collection/components/list-item/list-item.css +0 -3
  76. package/dist/collection/components/list-item/list-item.js +0 -63
  77. package/dist/collection/components/my-component/my-component.css +0 -3
  78. package/dist/collection/components/my-component/my-component.js +0 -74
  79. package/dist/collection/components/ptc-button/ptc-button.css +0 -76
  80. package/dist/collection/components/ptc-button/ptc-button.js +0 -153
  81. package/dist/collection/components/ptc-card/ptc-card.css +0 -239
  82. package/dist/collection/components/ptc-card/ptc-card.js +0 -260
  83. package/dist/collection/components/ptc-date/ptc-date.css +0 -3
  84. package/dist/collection/components/ptc-date/ptc-date.js +0 -155
  85. package/dist/collection/components/ptc-footer/ptc-footer.css +0 -40
  86. package/dist/collection/components/ptc-footer/ptc-footer.js +0 -25
  87. package/dist/collection/components/ptc-image/ptc-image.css +0 -4
  88. package/dist/collection/components/ptc-image/ptc-image.js +0 -92
  89. package/dist/collection/components/ptc-img/ptc-img.css +0 -65
  90. package/dist/collection/components/ptc-img/ptc-img.js +0 -318
  91. package/dist/collection/components/ptc-link/ptc-link.css +0 -168
  92. package/dist/collection/components/ptc-link/ptc-link.js +0 -197
  93. package/dist/collection/components/ptc-list/ptc-list.css +0 -24
  94. package/dist/collection/components/ptc-list/ptc-list.js +0 -66
  95. package/dist/collection/components/ptc-lottie/ptc-lottie.css +0 -5
  96. package/dist/collection/components/ptc-lottie/ptc-lottie.js +0 -58
  97. package/dist/collection/components/ptc-nav/ptc-nav.css +0 -29
  98. package/dist/collection/components/ptc-nav/ptc-nav.js +0 -21
  99. package/dist/collection/components/ptc-nav-item/ptc-nav-item.css +0 -81
  100. package/dist/collection/components/ptc-nav-item/ptc-nav-item.js +0 -252
  101. package/dist/collection/components/ptc-overlay/ptc-overlay.css +0 -3
  102. package/dist/collection/components/ptc-overlay/ptc-overlay.js +0 -14
  103. package/dist/collection/components/ptc-para/ptc-para.css +0 -57
  104. package/dist/collection/components/ptc-para/ptc-para.js +0 -111
  105. package/dist/collection/components/ptc-picture/ptc-picture.css +0 -3
  106. package/dist/collection/components/ptc-picture/ptc-picture.js +0 -44
  107. package/dist/collection/components/ptc-spacer/ptc-spacer.css +0 -307
  108. package/dist/collection/components/ptc-spacer/ptc-spacer.js +0 -99
  109. package/dist/collection/components/ptc-span/ptc-span.css +0 -36
  110. package/dist/collection/components/ptc-span/ptc-span.js +0 -86
  111. package/dist/collection/components/ptc-title/ptc-title.css +0 -64
  112. package/dist/collection/components/ptc-title/ptc-title.js +0 -105
  113. package/dist/collection/index.js +0 -1
  114. package/dist/collection/utils/interfaces.js +0 -6
  115. package/dist/collection/utils/utils.js +0 -3
  116. package/dist/custom-elements/index.js +0 -14381
  117. package/dist/esm/index-5b1c792c.js +0 -1687
  118. package/dist/esm/index.js +0 -1
  119. package/dist/esm/loader.js +0 -17
  120. package/dist/esm/polyfills/core-js.js +0 -11
  121. package/dist/esm/polyfills/css-shim.js +0 -1
  122. package/dist/esm/polyfills/dom.js +0 -79
  123. package/dist/esm/polyfills/es5-html-element.js +0 -1
  124. package/dist/esm/polyfills/index.js +0 -34
  125. package/dist/esm/polyfills/system.js +0 -6
  126. package/dist/esm/ptc-button.entry.js +0 -44
  127. package/dist/esm/ptcw-design.js +0 -17
  128. package/dist/index.cjs.js +0 -1
  129. package/dist/index.js +0 -1
  130. package/dist/node_modules/@teamhive/lottie-player/dist/collection/components/lottie-player/lottie-player.css +0 -187
  131. package/dist/ptcw-design/p-00b6c442.entry.js +0 -1
  132. package/dist/ptcw-design/p-01dc360c.entry.js +0 -1
  133. package/dist/ptcw-design/p-07624831.entry.js +0 -1
  134. package/dist/ptcw-design/p-0a44a2f7.entry.js +0 -1
  135. package/dist/ptcw-design/p-1a26bade.entry.js +0 -1
  136. package/dist/ptcw-design/p-2d357f92.entry.js +0 -1
  137. package/dist/ptcw-design/p-31f4bd0c.entry.js +0 -1
  138. package/dist/ptcw-design/p-3af43980.entry.js +0 -1
  139. package/dist/ptcw-design/p-4f366fc3.js +0 -1
  140. package/dist/ptcw-design/p-662ae9b6.entry.js +0 -1
  141. package/dist/ptcw-design/p-70adca2e.entry.js +0 -1
  142. package/dist/ptcw-design/p-76dfa56f.entry.js +0 -1
  143. package/dist/ptcw-design/p-77f87fa3.entry.js +0 -1
  144. package/dist/ptcw-design/p-7a63ca63.entry.js +0 -1
  145. package/dist/ptcw-design/p-83696cae.entry.js +0 -1
  146. package/dist/ptcw-design/p-83d98048.entry.js +0 -1
  147. package/dist/ptcw-design/p-85131a2a.entry.js +0 -1
  148. package/dist/ptcw-design/p-ac0ad25e.entry.js +0 -1
  149. package/dist/ptcw-design/p-c169281f.entry.js +0 -1
  150. package/dist/ptcw-design/p-ce8b8a72.entry.js +0 -1
  151. package/dist/ptcw-design/p-d4f117d2.entry.js +0 -1
  152. package/dist/ptcw-design/p-fe6a3ba5.entry.js +0 -1
@@ -1,37 +1,24 @@
1
- 'use strict';
2
-
3
- function _interopNamespace(e) {
4
- if (e && e.__esModule) return e;
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () {
13
- return e[k];
14
- }
15
- });
16
- }
17
- });
18
- }
19
- n['default'] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
1
  const NAMESPACE = 'ptcw-design';
2
+ const BUILD = /* ptcw-design */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: true, cmpWillUpdate: true, connectedCallback: false, constructableCSS: false, cssAnnotations: true, cssVarShim: false, devTools: true, disconnectedCallback: false, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: true, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, isDebug: false, isDev: true, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: true, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
3
+ const Env = /* ptcw-design */ {};
24
4
 
25
5
  let scopeId;
26
6
  let contentRef;
27
7
  let hostTagName;
8
+ let customError;
9
+ let i = 0;
28
10
  let useNativeShadowDom = false;
29
11
  let checkSlotFallbackVisibility = false;
30
12
  let checkSlotRelocate = false;
31
13
  let isSvgMode = false;
14
+ let renderingRef = null;
15
+ let queueCongestion = 0;
32
16
  let queuePending = false;
33
17
  const win = typeof window !== 'undefined' ? window : {};
18
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
34
19
  const doc = win.document || { head: {} };
20
+ const H = (win.HTMLElement || class {
21
+ });
35
22
  const plt = {
36
23
  $flags$: 0,
37
24
  $resourcesUrl$: '',
@@ -41,8 +28,25 @@ const plt = {
41
28
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
42
29
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
43
30
  };
31
+ const setPlatformHelpers = (helpers) => {
32
+ Object.assign(plt, helpers);
33
+ };
34
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() : true;
35
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
36
+ let supportsListenerOptions = false;
37
+ try {
38
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
39
+ get() {
40
+ supportsListenerOptions = true;
41
+ },
42
+ }));
43
+ }
44
+ catch (e) { }
45
+ return supportsListenerOptions;
46
+ })();
44
47
  const promiseResolve = (v) => Promise.resolve(v);
45
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
48
+ const supportsConstructibleStylesheets = BUILD.constructableCSS
49
+ ? /*@__PURE__*/ (() => {
46
50
  try {
47
51
  new CSSStyleSheet();
48
52
  return typeof (new CSSStyleSheet()).replace === 'function';
@@ -50,11 +54,31 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
50
54
  catch (e) { }
51
55
  return false;
52
56
  })()
53
- ;
57
+ : false;
58
+ const Context = {};
54
59
  const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
55
- if (listeners) {
60
+ if (BUILD.hostListener && listeners) {
61
+ // this is called immediately within the element's constructor
62
+ // initialize our event listeners on the host element
63
+ // we do this now so that we can listen to events that may
64
+ // have fired even before the instance is ready
65
+ if (BUILD.hostListenerTargetParent) {
66
+ // this component may have event listeners that should be attached to the parent
67
+ if (attachParentListeners) {
68
+ // this is being ran from within the connectedCallback
69
+ // which is important so that we know the host element actually has a parent element
70
+ // filter out the listeners to only have the ones that ARE being attached to the parent
71
+ listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
72
+ }
73
+ else {
74
+ // this is being ran from within the component constructor
75
+ // everything BUT the parent element listeners should be attached at this time
76
+ // filter out the listeners that are NOT being attached to the parent
77
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
78
+ }
79
+ }
56
80
  listeners.map(([flags, name, method]) => {
57
- const target = getHostListenerTarget(elm, flags) ;
81
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
58
82
  const handler = hostListenerProxy(hostRef, method);
59
83
  const opts = hostListenerOpts(flags);
60
84
  plt.ael(target, name, handler, opts);
@@ -64,7 +88,7 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
64
88
  };
65
89
  const hostListenerProxy = (hostRef, methodName) => (ev) => {
66
90
  try {
67
- {
91
+ if (BUILD.lazyLoad) {
68
92
  if (hostRef.$flags$ & 256 /* isListenReady */) {
69
93
  // instance is ready, let's call it's member method for this event
70
94
  hostRef.$lazyInstance$[methodName](ev);
@@ -73,34 +97,127 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
73
97
  (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
74
98
  }
75
99
  }
100
+ else {
101
+ hostRef.$hostElement$[methodName](ev);
102
+ }
76
103
  }
77
104
  catch (e) {
78
105
  consoleError(e);
79
106
  }
80
107
  };
81
108
  const getHostListenerTarget = (elm, flags) => {
82
- if (flags & 8 /* TargetWindow */)
109
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
110
+ return doc;
111
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
83
112
  return win;
113
+ if (BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */)
114
+ return doc.body;
115
+ if (BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */)
116
+ return elm.parentElement;
84
117
  return elm;
85
118
  };
86
119
  // prettier-ignore
87
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
120
+ const hostListenerOpts = (flags) => supportsListenerOptions
121
+ ? ({
122
+ passive: (flags & 1 /* Passive */) !== 0,
123
+ capture: (flags & 2 /* Capture */) !== 0,
124
+ })
125
+ : (flags & 2 /* Capture */) !== 0;
126
+ const CONTENT_REF_ID = 'r';
127
+ const ORG_LOCATION_ID = 'o';
128
+ const SLOT_NODE_ID = 's';
129
+ const TEXT_NODE_ID = 't';
130
+ const HYDRATE_ID = 's-id';
131
+ const HYDRATED_STYLE_ID = 'sty-id';
132
+ const HYDRATE_CHILD_ID = 'c-id';
88
133
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
89
134
  const XLINK_NS = 'http://www.w3.org/1999/xlink';
90
135
  const createTime = (fnName, tagName = '') => {
91
- {
136
+ if (BUILD.profile && performance.mark) {
137
+ const key = `st:${fnName}:${tagName}:${i++}`;
138
+ // Start
139
+ performance.mark(key);
140
+ // End
141
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
142
+ }
143
+ else {
92
144
  return () => {
93
145
  return;
94
146
  };
95
147
  }
96
148
  };
97
149
  const uniqueTime = (key, measureText) => {
98
- {
150
+ if (BUILD.profile && performance.mark) {
151
+ if (performance.getEntriesByName(key).length === 0) {
152
+ performance.mark(key);
153
+ }
154
+ return () => {
155
+ if (performance.getEntriesByName(measureText).length === 0) {
156
+ performance.measure(measureText, key);
157
+ }
158
+ };
159
+ }
160
+ else {
99
161
  return () => {
100
162
  return;
101
163
  };
102
164
  }
103
165
  };
166
+ const inspect = (ref) => {
167
+ const hostRef = getHostRef(ref);
168
+ if (!hostRef) {
169
+ return undefined;
170
+ }
171
+ const flags = hostRef.$flags$;
172
+ const hostElement = hostRef.$hostElement$;
173
+ return {
174
+ renderCount: hostRef.$renderCount$,
175
+ flags: {
176
+ hasRendered: !!(flags & 2 /* hasRendered */),
177
+ hasConnected: !!(flags & 1 /* hasConnected */),
178
+ isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
179
+ isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
180
+ isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
181
+ hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
182
+ hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
183
+ isWatchReady: !!(flags & 128 /* isWatchReady */),
184
+ isListenReady: !!(flags & 256 /* isListenReady */),
185
+ needsRerender: !!(flags & 512 /* needsRerender */),
186
+ },
187
+ instanceValues: hostRef.$instanceValues$,
188
+ ancestorComponent: hostRef.$ancestorComponent$,
189
+ hostElement,
190
+ lazyInstance: hostRef.$lazyInstance$,
191
+ vnode: hostRef.$vnode$,
192
+ modeName: hostRef.$modeName$,
193
+ onReadyPromise: hostRef.$onReadyPromise$,
194
+ onReadyResolve: hostRef.$onReadyResolve$,
195
+ onInstancePromise: hostRef.$onInstancePromise$,
196
+ onInstanceResolve: hostRef.$onInstanceResolve$,
197
+ onRenderResolve: hostRef.$onRenderResolve$,
198
+ queuedListeners: hostRef.$queuedListeners$,
199
+ rmListeners: hostRef.$rmListeners$,
200
+ ['s-id']: hostElement['s-id'],
201
+ ['s-cr']: hostElement['s-cr'],
202
+ ['s-lr']: hostElement['s-lr'],
203
+ ['s-p']: hostElement['s-p'],
204
+ ['s-rc']: hostElement['s-rc'],
205
+ ['s-sc']: hostElement['s-sc'],
206
+ };
207
+ };
208
+ const installDevTools = () => {
209
+ if (BUILD.devTools) {
210
+ const stencil = (win.stencil = win.stencil || {});
211
+ const originalInspect = stencil.inspect;
212
+ stencil.inspect = (ref) => {
213
+ let result = inspect(ref);
214
+ if (!result && typeof originalInspect === 'function') {
215
+ result = originalInspect(ref);
216
+ }
217
+ return result;
218
+ };
219
+ }
220
+ };
104
221
  const rootAppliedStyles = new WeakMap();
105
222
  const registerStyle = (scopeId, cssText, allowCS) => {
106
223
  let style = styles.get(scopeId);
@@ -114,8 +231,11 @@ const registerStyle = (scopeId, cssText, allowCS) => {
114
231
  styles.set(scopeId, style);
115
232
  };
116
233
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
117
- let scopeId = getScopeId(cmpMeta);
234
+ let scopeId = getScopeId(cmpMeta, mode);
118
235
  let style = styles.get(scopeId);
236
+ if (!BUILD.attachStyles) {
237
+ return scopeId;
238
+ }
119
239
  // if an element is NOT connected then getRootNode() will return the wrong root node
120
240
  // so the fallback is to always use the document for the root node in those cases
121
241
  styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
@@ -128,11 +248,29 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
128
248
  rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
129
249
  }
130
250
  if (!appliedStyles.has(scopeId)) {
131
- {
132
- {
251
+ if (BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
252
+ // This is only happening on native shadow-dom, do not needs CSS var shim
253
+ styleElm.innerHTML = style;
254
+ }
255
+ else {
256
+ if (BUILD.cssVarShim && plt.$cssShim$) {
257
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
258
+ const newScopeId = styleElm['s-sc'];
259
+ if (newScopeId) {
260
+ scopeId = newScopeId;
261
+ // we don't want to add this styleID to the appliedStyles Set
262
+ // since the cssVarShim might need to apply several different
263
+ // stylesheets for the same component
264
+ appliedStyles = null;
265
+ }
266
+ }
267
+ else {
133
268
  styleElm = doc.createElement('style');
134
269
  styleElm.innerHTML = style;
135
270
  }
271
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
272
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
273
+ }
136
274
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
137
275
  }
138
276
  if (appliedStyles) {
@@ -140,7 +278,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
140
278
  }
141
279
  }
142
280
  }
143
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
281
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
144
282
  styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
145
283
  }
146
284
  }
@@ -151,8 +289,8 @@ const attachStyles = (hostRef) => {
151
289
  const elm = hostRef.$hostElement$;
152
290
  const flags = cmpMeta.$flags$;
153
291
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
154
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
155
- if (flags & 10 /* needsScopedEncapsulation */) {
292
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
293
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
156
294
  // only required when we're NOT using native shadow dom (slot)
157
295
  // or this browser doesn't support native shadow dom
158
296
  // and this host element was NOT created with SSR
@@ -162,10 +300,19 @@ const attachStyles = (hostRef) => {
162
300
  // DOM WRITE!!
163
301
  elm['s-sc'] = scopeId;
164
302
  elm.classList.add(scopeId + '-h');
303
+ if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
304
+ elm.classList.add(scopeId + '-s');
305
+ }
165
306
  }
166
307
  endAttachStyles();
167
308
  };
168
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
309
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
310
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
311
+ // Private
312
+ const computeMode = (elm) => modeResolutionChain.map(h => h(elm)).find(m => !!m);
313
+ // Public
314
+ const setMode = (handler) => modeResolutionChain.push(handler);
315
+ const getMode = (ref) => getHostRef(ref).$modeName$;
169
316
  /**
170
317
  * Default style mode id
171
318
  */
@@ -213,6 +360,11 @@ const h = (nodeName, vnodeData, ...children) => {
213
360
  if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
214
361
  child = String(child);
215
362
  }
363
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
364
+ consoleDevError(`vNode passed as children has unexpected type.
365
+ Make sure it's using the correct h() function.
366
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
367
+ }
216
368
  if (simple && lastSimple) {
217
369
  // If the previous child was simple (string), we merge both
218
370
  vNodeChildren[vNodeChildren.length - 1].$text$ += child;
@@ -227,14 +379,17 @@ const h = (nodeName, vnodeData, ...children) => {
227
379
  };
228
380
  walk(children);
229
381
  if (vnodeData) {
382
+ if (BUILD.isDev && nodeName === 'input') {
383
+ validateInputProperties(vnodeData);
384
+ }
230
385
  // normalize class / classname attributes
231
- if (vnodeData.key) {
386
+ if (BUILD.vdomKey && vnodeData.key) {
232
387
  key = vnodeData.key;
233
388
  }
234
- if (vnodeData.name) {
389
+ if (BUILD.slotRelocation && vnodeData.name) {
235
390
  slotName = vnodeData.name;
236
391
  }
237
- {
392
+ if (BUILD.vdomClass) {
238
393
  const classData = vnodeData.className || vnodeData.class;
239
394
  if (classData) {
240
395
  vnodeData.class =
@@ -246,7 +401,12 @@ const h = (nodeName, vnodeData, ...children) => {
246
401
  }
247
402
  }
248
403
  }
249
- if (typeof nodeName === 'function') {
404
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
405
+ consoleDevError(`The <Host> must be the single root component. Make sure:
406
+ - You are NOT using hostData() and <Host> in the same component.
407
+ - <Host> is used once, and it's the single root component of the render() function.`);
408
+ }
409
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
250
410
  // nodeName is a functional component
251
411
  return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
252
412
  }
@@ -255,10 +415,10 @@ const h = (nodeName, vnodeData, ...children) => {
255
415
  if (vNodeChildren.length > 0) {
256
416
  vnode.$children$ = vNodeChildren;
257
417
  }
258
- {
418
+ if (BUILD.vdomKey) {
259
419
  vnode.$key$ = key;
260
420
  }
261
- {
421
+ if (BUILD.slotRelocation) {
262
422
  vnode.$name$ = slotName;
263
423
  }
264
424
  return vnode;
@@ -271,13 +431,13 @@ const newVNode = (tag, text) => {
271
431
  $elm$: null,
272
432
  $children$: null,
273
433
  };
274
- {
434
+ if (BUILD.vdomAttribute) {
275
435
  vnode.$attrs$ = null;
276
436
  }
277
- {
437
+ if (BUILD.vdomKey) {
278
438
  vnode.$key$ = null;
279
439
  }
280
- {
440
+ if (BUILD.slotRelocation) {
281
441
  vnode.$name$ = null;
282
442
  }
283
443
  return vnode;
@@ -314,6 +474,20 @@ const convertToPrivate = (node) => {
314
474
  vnode.$name$ = node.vname;
315
475
  return vnode;
316
476
  };
477
+ const validateInputProperties = (vnodeData) => {
478
+ const props = Object.keys(vnodeData);
479
+ const typeIndex = props.indexOf('type');
480
+ const minIndex = props.indexOf('min');
481
+ const maxIndex = props.indexOf('max');
482
+ const stepIndex = props.indexOf('min');
483
+ const value = props.indexOf('value');
484
+ if (value === -1) {
485
+ return;
486
+ }
487
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
488
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
489
+ }
490
+ };
317
491
  /**
318
492
  * Production setAccessor() function based on Preact by
319
493
  * Jason Miller (@developit)
@@ -326,19 +500,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
326
500
  if (oldValue !== newValue) {
327
501
  let isProp = isMemberInElement(elm, memberName);
328
502
  let ln = memberName.toLowerCase();
329
- if (memberName === 'class') {
503
+ if (BUILD.vdomClass && memberName === 'class') {
330
504
  const classList = elm.classList;
331
505
  const oldClasses = parseClassList(oldValue);
332
506
  const newClasses = parseClassList(newValue);
333
507
  classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
334
508
  classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
335
509
  }
336
- else if (memberName === 'style') {
510
+ else if (BUILD.vdomStyle && memberName === 'style') {
337
511
  // update style attribute, css properties and values
338
- {
512
+ if (BUILD.updatable) {
339
513
  for (const prop in oldValue) {
340
514
  if (!newValue || newValue[prop] == null) {
341
- if (prop.includes('-')) {
515
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
342
516
  elm.style.removeProperty(prop);
343
517
  }
344
518
  else {
@@ -349,7 +523,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
349
523
  }
350
524
  for (const prop in newValue) {
351
525
  if (!oldValue || newValue[prop] !== oldValue[prop]) {
352
- if (prop.includes('-')) {
526
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
353
527
  elm.style.setProperty(prop, newValue[prop]);
354
528
  }
355
529
  else {
@@ -358,15 +532,15 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
358
532
  }
359
533
  }
360
534
  }
361
- else if (memberName === 'key')
535
+ else if (BUILD.vdomKey && memberName === 'key')
362
536
  ;
363
- else if (memberName === 'ref') {
537
+ else if (BUILD.vdomRef && memberName === 'ref') {
364
538
  // minifier will clean this up
365
539
  if (newValue) {
366
540
  newValue(elm);
367
541
  }
368
542
  }
369
- else if ((!isProp ) && memberName[0] === 'o' && memberName[1] === 'n') {
543
+ else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === 'o' && memberName[1] === 'n') {
370
544
  // Event Handlers
371
545
  // so if the member name starts with "on" and the 3rd characters is
372
546
  // a capital letter, and it's not already a member on the element,
@@ -403,7 +577,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
403
577
  plt.ael(elm, memberName, newValue, false);
404
578
  }
405
579
  }
406
- else {
580
+ else if (BUILD.vdomPropOrAttr) {
407
581
  // Set property if it exists and it's not a SVG
408
582
  const isComplex = isComplexType(newValue);
409
583
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
@@ -433,7 +607,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
433
607
  * - if the newValue is null/undefined or 'false'.
434
608
  */
435
609
  let xlink = false;
436
- {
610
+ if (BUILD.vdomXlink) {
437
611
  if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
438
612
  memberName = ln;
439
613
  xlink = true;
@@ -441,7 +615,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
441
615
  }
442
616
  if (newValue == null || newValue === false) {
443
617
  if (newValue !== false || elm.getAttribute(memberName) === '') {
444
- if (xlink) {
618
+ if (BUILD.vdomXlink && xlink) {
445
619
  elm.removeAttributeNS(XLINK_NS, memberName);
446
620
  }
447
621
  else {
@@ -451,7 +625,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
451
625
  }
452
626
  else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
453
627
  newValue = newValue === true ? '' : newValue;
454
- if (xlink) {
628
+ if (BUILD.vdomXlink && xlink) {
455
629
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
456
630
  }
457
631
  else {
@@ -470,7 +644,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
470
644
  const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
471
645
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
472
646
  const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
473
- {
647
+ if (BUILD.updatable) {
474
648
  // remove attributes no longer present on the vnode by setting them to undefined
475
649
  for (memberName in oldVnodeAttrs) {
476
650
  if (!(memberName in newVnodeAttrs)) {
@@ -490,7 +664,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
490
664
  let elm;
491
665
  let childNode;
492
666
  let oldVNode;
493
- if (!useNativeShadowDom) {
667
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
494
668
  // remember for later we need to check to relocate nodes
495
669
  checkSlotRelocate = true;
496
670
  if (newVNode.$tag$ === 'slot') {
@@ -505,29 +679,33 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
505
679
  1 /* isSlotReference */;
506
680
  }
507
681
  }
508
- if (newVNode.$text$ !== null) {
682
+ if (BUILD.isDev && newVNode.$elm$) {
683
+ 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`);
684
+ }
685
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
509
686
  // create text node
510
687
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
511
688
  }
512
- else if (newVNode.$flags$ & 1 /* isSlotReference */) {
689
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
513
690
  // create a slot reference node
514
- elm = newVNode.$elm$ = doc.createTextNode('');
691
+ elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
515
692
  }
516
693
  else {
517
- if (!isSvgMode) {
694
+ if (BUILD.svg && !isSvgMode) {
518
695
  isSvgMode = newVNode.$tag$ === 'svg';
519
696
  }
520
697
  // create element
521
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$)
522
- );
523
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
698
+ elm = newVNode.$elm$ = (BUILD.svg
699
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$)
700
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$));
701
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
524
702
  isSvgMode = false;
525
703
  }
526
704
  // add css classes, attrs, props, listeners, etc.
527
- {
705
+ if (BUILD.vdomAttribute) {
528
706
  updateElement(null, newVNode, isSvgMode);
529
707
  }
530
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
708
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
531
709
  // if there is a scopeId and this is the initial render
532
710
  // then let's add the scopeId as a css class
533
711
  elm.classList.add((elm['s-si'] = scopeId));
@@ -543,7 +721,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
543
721
  }
544
722
  }
545
723
  }
546
- {
724
+ if (BUILD.svg) {
547
725
  if (newVNode.$tag$ === 'svg') {
548
726
  // Only reset the SVG context when we're exiting <svg> element
549
727
  isSvgMode = false;
@@ -554,7 +732,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
554
732
  }
555
733
  }
556
734
  }
557
- {
735
+ if (BUILD.slotRelocation) {
558
736
  elm['s-hn'] = hostTagName;
559
737
  if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
560
738
  // remember the content reference comment
@@ -599,9 +777,9 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
599
777
  plt.$flags$ &= ~1 /* isTmpDisconnected */;
600
778
  };
601
779
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
602
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
780
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
603
781
  let childNode;
604
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
782
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
605
783
  containerElm = containerElm.shadowRoot;
606
784
  }
607
785
  for (; startIdx <= endIdx; ++startIdx) {
@@ -609,7 +787,7 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
609
787
  childNode = createElm(null, parentVNode, startIdx, parentElm);
610
788
  if (childNode) {
611
789
  vnodes[startIdx].$elm$ = childNode;
612
- containerElm.insertBefore(childNode, referenceNode(before) );
790
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
613
791
  }
614
792
  }
615
793
  }
@@ -619,7 +797,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
619
797
  if ((vnode = vnodes[startIdx])) {
620
798
  elm = vnode.$elm$;
621
799
  callNodeRefs(vnode);
622
- {
800
+ if (BUILD.slotRelocation) {
623
801
  // we're removing this element
624
802
  // so it's possible we need to show slot fallback content now
625
803
  checkSlotFallbackVisibility = true;
@@ -677,7 +855,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
677
855
  }
678
856
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
679
857
  // Vnode moved right
680
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
858
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
681
859
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
682
860
  }
683
861
  patch(oldStartVnode, newEndVnode);
@@ -687,7 +865,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
687
865
  }
688
866
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
689
867
  // Vnode moved left
690
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
868
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
691
869
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
692
870
  }
693
871
  patch(oldEndVnode, newStartVnode);
@@ -698,7 +876,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
698
876
  else {
699
877
  // createKeyToOldIdx
700
878
  idxInOld = -1;
701
- {
879
+ if (BUILD.vdomKey) {
702
880
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
703
881
  if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
704
882
  idxInOld = i;
@@ -706,7 +884,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
706
884
  }
707
885
  }
708
886
  }
709
- if (idxInOld >= 0) {
887
+ if (BUILD.vdomKey && idxInOld >= 0) {
710
888
  elmToMove = oldCh[idxInOld];
711
889
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
712
890
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
@@ -724,16 +902,19 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
724
902
  newStartVnode = newCh[++newStartIdx];
725
903
  }
726
904
  if (node) {
727
- {
905
+ if (BUILD.slotRelocation) {
728
906
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
729
907
  }
908
+ else {
909
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
910
+ }
730
911
  }
731
912
  }
732
913
  }
733
914
  if (oldStartIdx > oldEndIdx) {
734
915
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
735
916
  }
736
- else if (newStartIdx > newEndIdx) {
917
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
737
918
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
738
919
  }
739
920
  };
@@ -741,12 +922,13 @@ const isSameVnode = (vnode1, vnode2) => {
741
922
  // compare if two vnode to see if they're "technically" the same
742
923
  // need to have the same element tag, and same key to be the same
743
924
  if (vnode1.$tag$ === vnode2.$tag$) {
744
- if (vnode1.$tag$ === 'slot') {
925
+ if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
745
926
  return vnode1.$name$ === vnode2.$name$;
746
927
  }
747
- {
928
+ if (BUILD.vdomKey) {
748
929
  return vnode1.$key$ === vnode2.$key$;
749
930
  }
931
+ return true;
750
932
  }
751
933
  return false;
752
934
  };
@@ -765,15 +947,15 @@ const patch = (oldVNode, newVNode) => {
765
947
  const tag = newVNode.$tag$;
766
948
  const text = newVNode.$text$;
767
949
  let defaultHolder;
768
- if (text === null) {
769
- {
950
+ if (!BUILD.vdomText || text === null) {
951
+ if (BUILD.svg) {
770
952
  // test if we're rendering an svg element, or still rendering nodes inside of one
771
953
  // only add this to the when the compiler sees we're using an svg somewhere
772
954
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
773
955
  }
774
956
  // element node
775
- {
776
- if (tag === 'slot')
957
+ if (BUILD.vdomAttribute || BUILD.reflect) {
958
+ if (BUILD.slot && tag === 'slot')
777
959
  ;
778
960
  else {
779
961
  // either this is the first render of an element OR it's an update
@@ -782,32 +964,32 @@ const patch = (oldVNode, newVNode) => {
782
964
  updateElement(oldVNode, newVNode, isSvgMode);
783
965
  }
784
966
  }
785
- if (oldChildren !== null && newChildren !== null) {
967
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
786
968
  // looks like there's child vnodes for both the old and new vnodes
787
969
  updateChildren(elm, oldChildren, newVNode, newChildren);
788
970
  }
789
971
  else if (newChildren !== null) {
790
972
  // no old child vnodes, but there are new child vnodes to add
791
- if (oldVNode.$text$ !== null) {
973
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
792
974
  // the old vnode was text, so be sure to clear it out
793
975
  elm.textContent = '';
794
976
  }
795
977
  // add the new vnode children
796
978
  addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
797
979
  }
798
- else if (oldChildren !== null) {
980
+ else if (BUILD.updatable && oldChildren !== null) {
799
981
  // no new child vnodes, but there are old child vnodes to remove
800
982
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
801
983
  }
802
- if (isSvgMode && tag === 'svg') {
984
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
803
985
  isSvgMode = false;
804
986
  }
805
987
  }
806
- else if ((defaultHolder = elm['s-cr'])) {
988
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
807
989
  // this element has slotted content
808
990
  defaultHolder.parentNode.textContent = text;
809
991
  }
810
- else if (oldVNode.$text$ !== text) {
992
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
811
993
  // update the text content for the text only vnode
812
994
  // and also only if the text is different than before
813
995
  elm.data = text;
@@ -945,7 +1127,7 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
945
1127
  return slotNameAttr === '';
946
1128
  };
947
1129
  const callNodeRefs = (vNode) => {
948
- {
1130
+ if (BUILD.vdomRef) {
949
1131
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
950
1132
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
951
1133
  }
@@ -956,26 +1138,41 @@ const renderVdom = (hostRef, renderFnResults) => {
956
1138
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
957
1139
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
958
1140
  hostTagName = hostElm.tagName;
959
- if (cmpMeta.$attrsToReflect$) {
1141
+ // <Host> runtime check
1142
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1143
+ throw new Error(`The <Host> must be the single root component.
1144
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1145
+
1146
+ The render() function should look like this instead:
1147
+
1148
+ render() {
1149
+ // Do not return an array
1150
+ return (
1151
+ <Host>{content}</Host>
1152
+ );
1153
+ }
1154
+ `);
1155
+ }
1156
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
960
1157
  rootVnode.$attrs$ = rootVnode.$attrs$ || {};
961
1158
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
962
1159
  }
963
1160
  rootVnode.$tag$ = null;
964
1161
  rootVnode.$flags$ |= 4 /* isHost */;
965
1162
  hostRef.$vnode$ = rootVnode;
966
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
967
- {
1163
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1164
+ if (BUILD.scoped || BUILD.shadowDom) {
968
1165
  scopeId = hostElm['s-sc'];
969
1166
  }
970
- {
1167
+ if (BUILD.slotRelocation) {
971
1168
  contentRef = hostElm['s-cr'];
972
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1169
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
973
1170
  // always reset
974
1171
  checkSlotFallbackVisibility = false;
975
1172
  }
976
1173
  // synchronous patch
977
1174
  patch(oldVNode, rootVnode);
978
- {
1175
+ if (BUILD.slotRelocation) {
979
1176
  // while we're moving nodes around existing nodes, temporarily disable
980
1177
  // the disconnectCallback from working
981
1178
  plt.$flags$ |= 1 /* isTmpDisconnected */;
@@ -994,7 +1191,7 @@ const renderVdom = (hostRef, renderFnResults) => {
994
1191
  if (!nodeToRelocate['s-ol']) {
995
1192
  // add a reference node marking this node's original location
996
1193
  // keep a reference to this node for later lookups
997
- orgLocationNode = doc.createTextNode('');
1194
+ orgLocationNode = BUILD.isDebug || BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode('');
998
1195
  orgLocationNode['s-nr'] = nodeToRelocate;
999
1196
  nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1000
1197
  }
@@ -1050,11 +1247,18 @@ const renderVdom = (hostRef, renderFnResults) => {
1050
1247
  relocateNodes.length = 0;
1051
1248
  }
1052
1249
  };
1053
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1250
+ // slot comment debug nodes only created with the `--debug` flag
1251
+ // otherwise these nodes are text nodes w/out content
1252
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1253
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})` : `[${nodeToRelocate.textContent}]`));
1254
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
1054
1255
  const createEvent = (ref, name, flags) => {
1055
1256
  const elm = getElement(ref);
1056
1257
  return {
1057
1258
  emit: (detail) => {
1259
+ if (BUILD.isDev && !elm.isConnected) {
1260
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1261
+ }
1058
1262
  return emitEvent(elm, name, {
1059
1263
  bubbles: !!(flags & 4 /* Bubbles */),
1060
1264
  composed: !!(flags & 2 /* Composed */),
@@ -1070,15 +1274,15 @@ const emitEvent = (elm, name, opts) => {
1070
1274
  return ev;
1071
1275
  };
1072
1276
  const attachToAncestor = (hostRef, ancestorComponent) => {
1073
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1277
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1074
1278
  ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
1075
1279
  }
1076
1280
  };
1077
1281
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1078
- {
1282
+ if (BUILD.taskQueue && BUILD.updatable) {
1079
1283
  hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1080
1284
  }
1081
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1285
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1082
1286
  hostRef.$flags$ |= 512 /* needsRerender */;
1083
1287
  return;
1084
1288
  }
@@ -1087,27 +1291,34 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
1087
1291
  // has already fired off its lifecycle update then
1088
1292
  // fire off the initial update
1089
1293
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1090
- return writeTask(dispatch) ;
1294
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1091
1295
  };
1092
1296
  const dispatchHooks = (hostRef, isInitialLoad) => {
1297
+ const elm = hostRef.$hostElement$;
1093
1298
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1094
- const instance = hostRef.$lazyInstance$ ;
1299
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1095
1300
  let promise;
1096
1301
  if (isInitialLoad) {
1097
- {
1302
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1098
1303
  hostRef.$flags$ |= 256 /* isListenReady */;
1099
1304
  if (hostRef.$queuedListeners$) {
1100
1305
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1101
1306
  hostRef.$queuedListeners$ = null;
1102
1307
  }
1103
1308
  }
1309
+ emitLifecycleEvent(elm, 'componentWillLoad');
1310
+ if (BUILD.cmpWillLoad) {
1311
+ promise = safeCall(instance, 'componentWillLoad');
1312
+ }
1104
1313
  }
1105
1314
  else {
1106
- {
1315
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1316
+ if (BUILD.cmpWillUpdate) {
1107
1317
  promise = safeCall(instance, 'componentWillUpdate');
1108
1318
  }
1109
1319
  }
1110
- {
1320
+ emitLifecycleEvent(elm, 'componentWillRender');
1321
+ if (BUILD.cmpWillRender) {
1111
1322
  promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1112
1323
  }
1113
1324
  endSchedule();
@@ -1118,15 +1329,46 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1118
1329
  const elm = hostRef.$hostElement$;
1119
1330
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1120
1331
  const rc = elm['s-rc'];
1121
- if (isInitialLoad) {
1332
+ if (BUILD.style && isInitialLoad) {
1122
1333
  // DOM WRITE!
1123
1334
  attachStyles(hostRef);
1124
1335
  }
1125
1336
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1126
- {
1127
- callRender(hostRef, instance);
1337
+ if (BUILD.isDev) {
1338
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1339
+ }
1340
+ if (BUILD.hydrateServerSide) {
1341
+ await callRender(hostRef, instance, elm);
1342
+ }
1343
+ else {
1344
+ callRender(hostRef, instance, elm);
1345
+ }
1346
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1347
+ plt.$cssShim$.updateHost(elm);
1128
1348
  }
1129
- if (rc) {
1349
+ if (BUILD.isDev) {
1350
+ hostRef.$renderCount$++;
1351
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1352
+ }
1353
+ if (BUILD.hydrateServerSide) {
1354
+ try {
1355
+ // manually connected child components during server-side hydrate
1356
+ serverSideConnected(elm);
1357
+ if (isInitialLoad) {
1358
+ // using only during server-side hydrate
1359
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1360
+ elm['s-en'] = '';
1361
+ }
1362
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1363
+ elm['s-en'] = 'c';
1364
+ }
1365
+ }
1366
+ }
1367
+ catch (e) {
1368
+ consoleError(e, elm);
1369
+ }
1370
+ }
1371
+ if (BUILD.asyncLoading && rc) {
1130
1372
  // ok, so turns out there are some child host elements
1131
1373
  // waiting on this parent element to load
1132
1374
  // let's fire off all update callbacks waiting
@@ -1135,7 +1377,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1135
1377
  }
1136
1378
  endRender();
1137
1379
  endUpdate();
1138
- {
1380
+ if (BUILD.asyncLoading) {
1139
1381
  const childrenPromises = elm['s-p'];
1140
1382
  const postUpdate = () => postUpdateComponent(hostRef);
1141
1383
  if (childrenPromises.length === 0) {
@@ -1147,64 +1389,117 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1147
1389
  childrenPromises.length = 0;
1148
1390
  }
1149
1391
  }
1392
+ else {
1393
+ postUpdateComponent(hostRef);
1394
+ }
1150
1395
  };
1151
1396
  const callRender = (hostRef, instance, elm) => {
1397
+ // in order for bundlers to correctly treeshake the BUILD object
1398
+ // we need to ensure BUILD is not deoptimized within a try/catch
1399
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1400
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1401
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1402
+ const taskQueue = BUILD.taskQueue ? true : false;
1403
+ const updatable = BUILD.updatable ? true : false;
1152
1404
  try {
1153
- instance = instance.render() ;
1154
- {
1405
+ renderingRef = instance;
1406
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1407
+ if (updatable && taskQueue) {
1155
1408
  hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1156
1409
  }
1157
- {
1410
+ if (updatable || lazyLoad) {
1158
1411
  hostRef.$flags$ |= 2 /* hasRendered */;
1159
1412
  }
1160
- {
1161
- {
1413
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1414
+ if (BUILD.vdomRender || BUILD.reflect) {
1162
1415
  // looks like we've got child nodes to render into this host element
1163
1416
  // or we need to update the css class/attrs on the host element
1164
1417
  // DOM WRITE!
1165
- {
1418
+ if (BUILD.hydrateServerSide) {
1419
+ return Promise.resolve(instance).then(value => renderVdom(hostRef, value));
1420
+ }
1421
+ else {
1166
1422
  renderVdom(hostRef, instance);
1167
1423
  }
1168
1424
  }
1425
+ else {
1426
+ elm.textContent = instance;
1427
+ }
1169
1428
  }
1170
1429
  }
1171
1430
  catch (e) {
1172
1431
  consoleError(e, hostRef.$hostElement$);
1173
1432
  }
1433
+ renderingRef = null;
1174
1434
  return null;
1175
1435
  };
1436
+ const getRenderingRef = () => renderingRef;
1176
1437
  const postUpdateComponent = (hostRef) => {
1177
1438
  const tagName = hostRef.$cmpMeta$.$tagName$;
1178
1439
  const elm = hostRef.$hostElement$;
1179
1440
  const endPostUpdate = createTime('postUpdate', tagName);
1180
- const instance = hostRef.$lazyInstance$ ;
1441
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1181
1442
  const ancestorComponent = hostRef.$ancestorComponent$;
1443
+ if (BUILD.cmpDidRender) {
1444
+ if (BUILD.isDev) {
1445
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1446
+ }
1447
+ safeCall(instance, 'componentDidRender');
1448
+ if (BUILD.isDev) {
1449
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1450
+ }
1451
+ }
1452
+ emitLifecycleEvent(elm, 'componentDidRender');
1182
1453
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1183
1454
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1184
- {
1455
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1185
1456
  // DOM WRITE!
1186
1457
  addHydratedFlag(elm);
1187
1458
  }
1188
- {
1459
+ if (BUILD.cmpDidLoad) {
1460
+ if (BUILD.isDev) {
1461
+ hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1462
+ }
1189
1463
  safeCall(instance, 'componentDidLoad');
1464
+ if (BUILD.isDev) {
1465
+ hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1466
+ }
1190
1467
  }
1468
+ emitLifecycleEvent(elm, 'componentDidLoad');
1191
1469
  endPostUpdate();
1192
- {
1470
+ if (BUILD.asyncLoading) {
1193
1471
  hostRef.$onReadyResolve$(elm);
1194
1472
  if (!ancestorComponent) {
1195
- appDidLoad();
1473
+ appDidLoad(tagName);
1196
1474
  }
1197
1475
  }
1198
1476
  }
1199
1477
  else {
1478
+ if (BUILD.cmpDidUpdate) {
1479
+ // we've already loaded this component
1480
+ // fire off the user's componentDidUpdate method (if one was provided)
1481
+ // componentDidUpdate runs AFTER render() has been called
1482
+ // and all child components have finished updating
1483
+ if (BUILD.isDev) {
1484
+ hostRef.$flags$ |= 1024 /* devOnRender */;
1485
+ }
1486
+ safeCall(instance, 'componentDidUpdate');
1487
+ if (BUILD.isDev) {
1488
+ hostRef.$flags$ &= ~1024 /* devOnRender */;
1489
+ }
1490
+ }
1491
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1200
1492
  endPostUpdate();
1201
1493
  }
1202
- {
1494
+ if (BUILD.hotModuleReplacement) {
1495
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1496
+ }
1497
+ if (BUILD.method && BUILD.lazyLoad) {
1203
1498
  hostRef.$onInstanceResolve$(elm);
1204
1499
  }
1205
1500
  // load events fire from bottom to top
1206
1501
  // the deepest elements load first then bubbles up
1207
- {
1502
+ if (BUILD.asyncLoading) {
1208
1503
  if (hostRef.$onRenderResolve$) {
1209
1504
  hostRef.$onRenderResolve$();
1210
1505
  hostRef.$onRenderResolve$ = undefined;
@@ -1218,13 +1513,31 @@ const postUpdateComponent = (hostRef) => {
1218
1513
  // ( •_•)>⌐■-■
1219
1514
  // (⌐■_■)
1220
1515
  };
1516
+ const forceUpdate = (ref) => {
1517
+ if (BUILD.updatable) {
1518
+ const hostRef = getHostRef(ref);
1519
+ const isConnected = hostRef.$hostElement$.isConnected;
1520
+ if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1521
+ scheduleUpdate(hostRef, false);
1522
+ }
1523
+ // Returns "true" when the forced update was successfully scheduled
1524
+ return isConnected;
1525
+ }
1526
+ return false;
1527
+ };
1221
1528
  const appDidLoad = (who) => {
1222
1529
  // on appload
1223
1530
  // we have finish the first big initial render
1224
- {
1531
+ if (BUILD.cssAnnotations) {
1225
1532
  addHydratedFlag(doc.documentElement);
1226
1533
  }
1534
+ if (BUILD.asyncQueue) {
1535
+ plt.$flags$ |= 2 /* appLoaded */;
1536
+ }
1227
1537
  nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1538
+ if (BUILD.profile && performance.measure) {
1539
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1540
+ }
1228
1541
  };
1229
1542
  const safeCall = (instance, method, arg) => {
1230
1543
  if (instance && instance[method]) {
@@ -1240,20 +1553,248 @@ const safeCall = (instance, method, arg) => {
1240
1553
  const then = (promise, thenFn) => {
1241
1554
  return promise && promise.then ? promise.then(thenFn) : thenFn();
1242
1555
  };
1243
- const addHydratedFlag = (elm) => (elm.classList.add('hydrated') );
1556
+ const emitLifecycleEvent = (elm, lifecycleName) => {
1557
+ if (BUILD.lifecycleDOMEvents) {
1558
+ emitEvent(elm, 'stencil_' + lifecycleName, {
1559
+ bubbles: true,
1560
+ composed: true,
1561
+ detail: {
1562
+ namespace: NAMESPACE,
1563
+ },
1564
+ });
1565
+ }
1566
+ };
1567
+ const addHydratedFlag = (elm) => (BUILD.hydratedClass ? elm.classList.add('hydrated') : BUILD.hydratedAttribute ? elm.setAttribute('hydrated', '') : undefined);
1568
+ const serverSideConnected = (elm) => {
1569
+ const children = elm.children;
1570
+ if (children != null) {
1571
+ for (let i = 0, ii = children.length; i < ii; i++) {
1572
+ const childElm = children[i];
1573
+ if (typeof childElm.connectedCallback === 'function') {
1574
+ childElm.connectedCallback();
1575
+ }
1576
+ serverSideConnected(childElm);
1577
+ }
1578
+ }
1579
+ };
1580
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1581
+ const endHydrate = createTime('hydrateClient', tagName);
1582
+ const shadowRoot = hostElm.shadowRoot;
1583
+ const childRenderNodes = [];
1584
+ const slotNodes = [];
1585
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1586
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1587
+ if (!plt.$orgLocNodes$) {
1588
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1589
+ }
1590
+ hostElm[HYDRATE_ID] = hostId;
1591
+ hostElm.removeAttribute(HYDRATE_ID);
1592
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1593
+ childRenderNodes.map(c => {
1594
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1595
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1596
+ const node = c.$elm$;
1597
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1598
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1599
+ }
1600
+ if (!shadowRoot) {
1601
+ node['s-hn'] = tagName;
1602
+ if (orgLocationNode) {
1603
+ node['s-ol'] = orgLocationNode;
1604
+ node['s-ol']['s-nr'] = node;
1605
+ }
1606
+ }
1607
+ plt.$orgLocNodes$.delete(orgLocationId);
1608
+ });
1609
+ if (BUILD.shadowDom && shadowRoot) {
1610
+ shadowRootNodes.map(shadowRootNode => {
1611
+ if (shadowRootNode) {
1612
+ shadowRoot.appendChild(shadowRootNode);
1613
+ }
1614
+ });
1615
+ }
1616
+ endHydrate();
1617
+ };
1618
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1619
+ let childNodeType;
1620
+ let childIdSplt;
1621
+ let childVNode;
1622
+ let i;
1623
+ if (node.nodeType === 1 /* ElementNode */) {
1624
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1625
+ if (childNodeType) {
1626
+ // got the node data from the element's attribute
1627
+ // `${hostId}.${nodeId}.${depth}.${index}`
1628
+ childIdSplt = childNodeType.split('.');
1629
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1630
+ childVNode = {
1631
+ $flags$: 0,
1632
+ $hostId$: childIdSplt[0],
1633
+ $nodeId$: childIdSplt[1],
1634
+ $depth$: childIdSplt[2],
1635
+ $index$: childIdSplt[3],
1636
+ $tag$: node.tagName.toLowerCase(),
1637
+ $elm$: node,
1638
+ $attrs$: null,
1639
+ $children$: null,
1640
+ $key$: null,
1641
+ $name$: null,
1642
+ $text$: null,
1643
+ };
1644
+ childRenderNodes.push(childVNode);
1645
+ node.removeAttribute(HYDRATE_CHILD_ID);
1646
+ // this is a new child vnode
1647
+ // so ensure its parent vnode has the vchildren array
1648
+ if (!parentVNode.$children$) {
1649
+ parentVNode.$children$ = [];
1650
+ }
1651
+ // add our child vnode to a specific index of the vnode's children
1652
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1653
+ // this is now the new parent vnode for all the next child checks
1654
+ parentVNode = childVNode;
1655
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
1656
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1657
+ }
1658
+ }
1659
+ }
1660
+ // recursively drill down, end to start so we can remove nodes
1661
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
1662
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1663
+ }
1664
+ if (node.shadowRoot) {
1665
+ // keep drilling down through the shadow root nodes
1666
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1667
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1668
+ }
1669
+ }
1670
+ }
1671
+ else if (node.nodeType === 8 /* CommentNode */) {
1672
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1673
+ childIdSplt = node.nodeValue.split('.');
1674
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1675
+ // comment node for either the host id or a 0 host id
1676
+ childNodeType = childIdSplt[0];
1677
+ childVNode = {
1678
+ $flags$: 0,
1679
+ $hostId$: childIdSplt[1],
1680
+ $nodeId$: childIdSplt[2],
1681
+ $depth$: childIdSplt[3],
1682
+ $index$: childIdSplt[4],
1683
+ $elm$: node,
1684
+ $attrs$: null,
1685
+ $children$: null,
1686
+ $key$: null,
1687
+ $name$: null,
1688
+ $tag$: null,
1689
+ $text$: null,
1690
+ };
1691
+ if (childNodeType === TEXT_NODE_ID) {
1692
+ childVNode.$elm$ = node.nextSibling;
1693
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1694
+ childVNode.$text$ = childVNode.$elm$.textContent;
1695
+ childRenderNodes.push(childVNode);
1696
+ // remove the text comment since it's no longer needed
1697
+ node.remove();
1698
+ if (!parentVNode.$children$) {
1699
+ parentVNode.$children$ = [];
1700
+ }
1701
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1702
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
1703
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1704
+ }
1705
+ }
1706
+ }
1707
+ else if (childVNode.$hostId$ === hostId) {
1708
+ // this comment node is specifcally for this host id
1709
+ if (childNodeType === SLOT_NODE_ID) {
1710
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1711
+ childVNode.$tag$ = 'slot';
1712
+ if (childIdSplt[5]) {
1713
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1714
+ }
1715
+ else {
1716
+ node['s-sn'] = '';
1717
+ }
1718
+ node['s-sr'] = true;
1719
+ if (BUILD.shadowDom && shadowRootNodes) {
1720
+ // browser support shadowRoot and this is a shadow dom component
1721
+ // create an actual slot element
1722
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1723
+ if (childVNode.$name$) {
1724
+ // add the slot name attribute
1725
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
1726
+ }
1727
+ // insert the new slot element before the slot comment
1728
+ node.parentNode.insertBefore(childVNode.$elm$, node);
1729
+ // remove the slot comment since it's not needed for shadow
1730
+ node.remove();
1731
+ if (childVNode.$depth$ === '0') {
1732
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1733
+ }
1734
+ }
1735
+ slotNodes.push(childVNode);
1736
+ if (!parentVNode.$children$) {
1737
+ parentVNode.$children$ = [];
1738
+ }
1739
+ parentVNode.$children$[childVNode.$index$] = childVNode;
1740
+ }
1741
+ else if (childNodeType === CONTENT_REF_ID) {
1742
+ // `${CONTENT_REF_ID}.${hostId}`;
1743
+ if (BUILD.shadowDom && shadowRootNodes) {
1744
+ // remove the content ref comment since it's not needed for shadow
1745
+ node.remove();
1746
+ }
1747
+ else if (BUILD.slotRelocation) {
1748
+ hostElm['s-cr'] = node;
1749
+ node['s-cn'] = true;
1750
+ }
1751
+ }
1752
+ }
1753
+ }
1754
+ }
1755
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
1756
+ const vnode = newVNode(null, node.textContent);
1757
+ vnode.$elm$ = node;
1758
+ vnode.$index$ = '0';
1759
+ parentVNode.$children$ = [vnode];
1760
+ }
1761
+ };
1762
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
1763
+ if (node.nodeType === 1 /* ElementNode */) {
1764
+ let i = 0;
1765
+ for (; i < node.childNodes.length; i++) {
1766
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1767
+ }
1768
+ if (node.shadowRoot) {
1769
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1770
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1771
+ }
1772
+ }
1773
+ }
1774
+ else if (node.nodeType === 8 /* CommentNode */) {
1775
+ const childIdSplt = node.nodeValue.split('.');
1776
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
1777
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1778
+ node.nodeValue = '';
1779
+ // useful to know if the original location is
1780
+ // the root light-dom of a shadow dom component
1781
+ node['s-en'] = childIdSplt[3];
1782
+ }
1783
+ }
1784
+ };
1244
1785
  const parsePropertyValue = (propValue, propType) => {
1245
1786
  // ensure this value is of the correct prop type
1246
1787
  if (propValue != null && !isComplexType(propValue)) {
1247
- if (propType & 4 /* Boolean */) {
1788
+ if (BUILD.propBoolean && propType & 4 /* Boolean */) {
1248
1789
  // per the HTML spec, any string value means it is a boolean true value
1249
1790
  // but we'll cheat here and say that the string "false" is the boolean false
1250
1791
  return propValue === 'false' ? false : propValue === '' || !!propValue;
1251
1792
  }
1252
- if (propType & 2 /* Number */) {
1793
+ if (BUILD.propNumber && propType & 2 /* Number */) {
1253
1794
  // force it to be a number
1254
1795
  return parseFloat(propValue);
1255
1796
  }
1256
- if (propType & 1 /* String */) {
1797
+ if (BUILD.propString && propType & 1 /* String */) {
1257
1798
  // could have been passed as a number or boolean
1258
1799
  // but we still want it as a string
1259
1800
  return String(propValue);
@@ -1269,18 +1810,26 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
1269
1810
  const setValue = (ref, propName, newVal, cmpMeta) => {
1270
1811
  // check our new property value against our internal value
1271
1812
  const hostRef = getHostRef(ref);
1272
- const elm = hostRef.$hostElement$ ;
1813
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1273
1814
  const oldVal = hostRef.$instanceValues$.get(propName);
1274
1815
  const flags = hostRef.$flags$;
1275
- const instance = hostRef.$lazyInstance$ ;
1816
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1276
1817
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1277
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1818
+ if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1278
1819
  // gadzooks! the property's value has changed!!
1279
1820
  // set our new value!
1280
1821
  hostRef.$instanceValues$.set(propName, newVal);
1281
- if (instance) {
1822
+ if (BUILD.isDev) {
1823
+ if (hostRef.$flags$ & 1024 /* devOnRender */) {
1824
+ 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);
1825
+ }
1826
+ else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
1827
+ 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);
1828
+ }
1829
+ }
1830
+ if (!BUILD.lazyLoad || instance) {
1282
1831
  // get an array of method names of watch functions to call
1283
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1832
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1284
1833
  const watchMethods = cmpMeta.$watchers$[propName];
1285
1834
  if (watchMethods) {
1286
1835
  // this instance is watching for when this property changed
@@ -1295,7 +1844,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1295
1844
  });
1296
1845
  }
1297
1846
  }
1298
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1847
+ if (BUILD.updatable && (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1848
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1849
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1850
+ return;
1851
+ }
1852
+ }
1299
1853
  // looks like this value actually changed, so we've got work to do!
1300
1854
  // but only if we've already rendered, otherwise just chill out
1301
1855
  // queue that we need to do an update, but don't worry about queuing
@@ -1306,15 +1860,15 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1306
1860
  }
1307
1861
  };
1308
1862
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1309
- if (cmpMeta.$members$) {
1310
- if (Cstr.watchers) {
1863
+ if (BUILD.member && cmpMeta.$members$) {
1864
+ if (BUILD.watchCallback && Cstr.watchers) {
1311
1865
  cmpMeta.$watchers$ = Cstr.watchers;
1312
1866
  }
1313
1867
  // It's better to have a const than two Object.entries()
1314
1868
  const members = Object.entries(cmpMeta.$members$);
1315
1869
  const prototype = Cstr.prototype;
1316
1870
  members.map(([memberName, [memberFlags]]) => {
1317
- if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1871
+ if ((BUILD.prop || BUILD.state) && (memberFlags & 31 /* Prop */ || ((!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1318
1872
  // proxyComponent - prop
1319
1873
  Object.defineProperty(prototype, memberName, {
1320
1874
  get() {
@@ -1322,6 +1876,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1322
1876
  return getValue(this, memberName);
1323
1877
  },
1324
1878
  set(newValue) {
1879
+ // only during dev time
1880
+ if (BUILD.isDev) {
1881
+ const ref = getHostRef(this);
1882
+ if (
1883
+ // we are proxying the instance (not element)
1884
+ (flags & 1 /* isElementConstructor */) === 0 &&
1885
+ // the element is not constructing
1886
+ (ref.$flags$ & 8 /* isConstructingInstance */) === 0 &&
1887
+ // the member is a prop
1888
+ (memberFlags & 31 /* Prop */) !== 0 &&
1889
+ // the member is not mutable
1890
+ (memberFlags & 1024 /* Mutable */) === 0) {
1891
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
1892
+ }
1893
+ }
1325
1894
  // proxyComponent, set value
1326
1895
  setValue(this, memberName, newValue, cmpMeta);
1327
1896
  },
@@ -1329,7 +1898,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1329
1898
  enumerable: true,
1330
1899
  });
1331
1900
  }
1332
- else if (flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1901
+ else if (BUILD.lazyLoad && BUILD.method && flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1333
1902
  // proxyComponent - method
1334
1903
  Object.defineProperty(prototype, memberName, {
1335
1904
  value(...args) {
@@ -1339,7 +1908,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1339
1908
  });
1340
1909
  }
1341
1910
  });
1342
- if ((flags & 1 /* isElementConstructor */)) {
1911
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
1343
1912
  const attrNameToPropName = new Map();
1344
1913
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1345
1914
  plt.jmp(() => {
@@ -1354,7 +1923,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1354
1923
  .map(([propName, m]) => {
1355
1924
  const attrName = m[1] || propName;
1356
1925
  attrNameToPropName.set(attrName, propName);
1357
- if (m[0] & 512 /* ReflectAttr */) {
1926
+ if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
1358
1927
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1359
1928
  }
1360
1929
  return attrName;
@@ -1365,25 +1934,28 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1365
1934
  };
1366
1935
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1367
1936
  // initializeComponent
1368
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1369
- {
1937
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) && (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1938
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
1370
1939
  // we haven't initialized this element yet
1371
1940
  hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1372
1941
  // lazy loaded components
1373
1942
  // request the component's implementation to be
1374
1943
  // wired up with the host element
1375
- Cstr = loadModule(cmpMeta);
1944
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
1376
1945
  if (Cstr.then) {
1377
1946
  // Await creates a micro-task avoid if possible
1378
- const endLoad = uniqueTime();
1947
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
1379
1948
  Cstr = await Cstr;
1380
1949
  endLoad();
1381
1950
  }
1382
- if (!Cstr.isProxied) {
1951
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
1952
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
1953
+ }
1954
+ if (BUILD.member && !Cstr.isProxied) {
1383
1955
  // we'eve never proxied this Constructor before
1384
1956
  // let's add the getters/setters to its prototype before
1385
1957
  // the first time we create an instance of the implementation
1386
- {
1958
+ if (BUILD.watchCallback) {
1387
1959
  cmpMeta.$watchers$ = Cstr.watchers;
1388
1960
  }
1389
1961
  proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
@@ -1393,7 +1965,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1393
1965
  // ok, time to construct the instance
1394
1966
  // but let's keep track of when we start and stop
1395
1967
  // so that the getters/setters don't incorrectly step on data
1396
- {
1968
+ if (BUILD.member) {
1397
1969
  hostRef.$flags$ |= 8 /* isConstructingInstance */;
1398
1970
  }
1399
1971
  // construct the lazy-loaded component implementation
@@ -1406,20 +1978,35 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1406
1978
  catch (e) {
1407
1979
  consoleError(e);
1408
1980
  }
1409
- {
1981
+ if (BUILD.member) {
1410
1982
  hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1411
1983
  }
1412
- {
1984
+ if (BUILD.watchCallback) {
1413
1985
  hostRef.$flags$ |= 128 /* isWatchReady */;
1414
1986
  }
1415
1987
  endNewInstance();
1988
+ fireConnectedCallback(hostRef.$lazyInstance$);
1416
1989
  }
1417
- if (Cstr.style) {
1990
+ else {
1991
+ // sync constructor component
1992
+ Cstr = elm.constructor;
1993
+ hostRef.$flags$ |= 128 /* isWatchReady */ | 32 /* hasInitializedComponent */;
1994
+ }
1995
+ if (BUILD.style && Cstr.style) {
1418
1996
  // this component has styles but we haven't registered them yet
1419
1997
  let style = Cstr.style;
1420
- const scopeId = getScopeId(cmpMeta);
1998
+ if (BUILD.mode && typeof style !== 'string') {
1999
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2000
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2001
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2002
+ }
2003
+ }
2004
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
1421
2005
  if (!styles.has(scopeId)) {
1422
2006
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2007
+ if (!BUILD.hydrateServerSide && BUILD.shadowDom && BUILD.shadowDomShim && cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2008
+ style = await import('./shadow-css-c1ad5fdc.js').then(m => m.scopeCss(style, scopeId, false));
2009
+ }
1423
2010
  registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1424
2011
  endRegisterStyles();
1425
2012
  }
@@ -1428,7 +2015,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1428
2015
  // we've successfully created a lazy instance
1429
2016
  const ancestorComponent = hostRef.$ancestorComponent$;
1430
2017
  const schedule = () => scheduleUpdate(hostRef, true);
1431
- if (ancestorComponent && ancestorComponent['s-rc']) {
2018
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
1432
2019
  // this is the intial load and this component it has an ancestor component
1433
2020
  // but the ancestor component has NOT fired its will update lifecycle yet
1434
2021
  // so let's just cool our jets and wait for the ancestor to continue first
@@ -1441,31 +2028,52 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1441
2028
  schedule();
1442
2029
  }
1443
2030
  };
2031
+ const fireConnectedCallback = (instance) => {
2032
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2033
+ safeCall(instance, 'connectedCallback');
2034
+ }
2035
+ };
1444
2036
  const connectedCallback = (elm) => {
1445
2037
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1446
2038
  const hostRef = getHostRef(elm);
1447
2039
  const cmpMeta = hostRef.$cmpMeta$;
1448
2040
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2041
+ if (BUILD.hostListenerTargetParent) {
2042
+ // only run if we have listeners being attached to a parent
2043
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2044
+ }
1449
2045
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1450
2046
  // first time this component has connected
1451
2047
  hostRef.$flags$ |= 1 /* hasConnected */;
1452
- {
2048
+ let hostId;
2049
+ if (BUILD.hydrateClientSide) {
2050
+ hostId = elm.getAttribute(HYDRATE_ID);
2051
+ if (hostId) {
2052
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2053
+ const scopeId = BUILD.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode')) : addStyle(elm.shadowRoot, cmpMeta);
2054
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2055
+ }
2056
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2057
+ }
2058
+ }
2059
+ if (BUILD.slotRelocation && !hostId) {
1453
2060
  // initUpdate
1454
2061
  // if the slot polyfill is required we'll need to put some nodes
1455
2062
  // in here to act as original content anchors as we move nodes around
1456
2063
  // host element has been connected to the DOM
1457
- if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
2064
+ if (BUILD.hydrateServerSide || ((BUILD.slot || BUILD.shadowDom) && cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1458
2065
  setContentReference(elm);
1459
2066
  }
1460
2067
  }
1461
- {
2068
+ if (BUILD.asyncLoading) {
1462
2069
  // find the first ancestor component (if there is one) and register
1463
2070
  // this component as one of the actively loading child components for its ancestor
1464
2071
  let ancestorComponent = elm;
1465
2072
  while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1466
2073
  // climb up the ancestors looking for the first
1467
2074
  // component that hasn't finished its lifecycle update yet
1468
- if (ancestorComponent['s-p']) {
2075
+ if ((BUILD.hydrateClientSide && ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute('s-id') && ancestorComponent['s-p']) ||
2076
+ ancestorComponent['s-p']) {
1469
2077
  // we found this components first ancestor component
1470
2078
  // keep a reference to this component's ancestor component
1471
2079
  attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
@@ -1475,7 +2083,7 @@ const connectedCallback = (elm) => {
1475
2083
  }
1476
2084
  // Lazy properties
1477
2085
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1478
- if (cmpMeta.$members$) {
2086
+ if (BUILD.prop && BUILD.lazyLoad && !BUILD.hydrateServerSide && cmpMeta.$members$) {
1479
2087
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1480
2088
  if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1481
2089
  const value = elm[memberName];
@@ -1484,7 +2092,14 @@ const connectedCallback = (elm) => {
1484
2092
  }
1485
2093
  });
1486
2094
  }
1487
- {
2095
+ if (BUILD.initializeNextTick) {
2096
+ // connectedCallback, taskQueue, initialLoad
2097
+ // angular sets attribute AFTER connectCallback
2098
+ // https://github.com/angular/angular/issues/18909
2099
+ // https://github.com/angular/angular/issues/19940
2100
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2101
+ }
2102
+ else {
1488
2103
  initializeComponent(elm, hostRef, cmpMeta);
1489
2104
  }
1490
2105
  }
@@ -1492,7 +2107,9 @@ const connectedCallback = (elm) => {
1492
2107
  // not the first time this has connected
1493
2108
  // reattach any event listeners to the host
1494
2109
  // since they would have been removed when disconnected
1495
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2110
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2111
+ // fire off connectedCallback() on component instance
2112
+ fireConnectedCallback(hostRef.$lazyInstance$);
1496
2113
  }
1497
2114
  endConnected();
1498
2115
  }
@@ -1504,23 +2121,231 @@ const setContentReference = (elm) => {
1504
2121
  // let's pick out the inner content for slot projection
1505
2122
  // create a node to represent where the original
1506
2123
  // content was first placed, which is useful later on
1507
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2124
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
1508
2125
  contentRefElm['s-cn'] = true;
1509
2126
  elm.insertBefore(contentRefElm, elm.firstChild);
1510
2127
  };
1511
2128
  const disconnectedCallback = (elm) => {
1512
2129
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1513
2130
  const hostRef = getHostRef(elm);
1514
- {
2131
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2132
+ if (BUILD.hostListener) {
1515
2133
  if (hostRef.$rmListeners$) {
1516
2134
  hostRef.$rmListeners$.map(rmListener => rmListener());
1517
2135
  hostRef.$rmListeners$ = undefined;
1518
2136
  }
1519
2137
  }
2138
+ // clear CSS var-shim tracking
2139
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2140
+ plt.$cssShim$.removeHost(elm);
2141
+ }
2142
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2143
+ safeCall(instance, 'disconnectedCallback');
2144
+ }
2145
+ if (BUILD.cmpDidUnload) {
2146
+ safeCall(instance, 'componentDidUnload');
2147
+ }
2148
+ }
2149
+ };
2150
+ const defineCustomElement = (Cstr, compactMeta) => {
2151
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2152
+ };
2153
+ const proxyCustomElement = (Cstr, compactMeta) => {
2154
+ const cmpMeta = {
2155
+ $flags$: compactMeta[0],
2156
+ $tagName$: compactMeta[1],
2157
+ };
2158
+ if (BUILD.member) {
2159
+ cmpMeta.$members$ = compactMeta[2];
2160
+ }
2161
+ if (BUILD.hostListener) {
2162
+ cmpMeta.$listeners$ = compactMeta[3];
2163
+ }
2164
+ if (BUILD.watchCallback) {
2165
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2166
+ }
2167
+ if (BUILD.reflect) {
2168
+ cmpMeta.$attrsToReflect$ = [];
2169
+ }
2170
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2171
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2172
+ }
2173
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2174
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2175
+ Object.assign(Cstr.prototype, {
2176
+ __registerHost() {
2177
+ registerHost(this, cmpMeta);
2178
+ },
2179
+ connectedCallback() {
2180
+ connectedCallback(this);
2181
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2182
+ originalConnectedCallback.call(this);
2183
+ }
2184
+ },
2185
+ disconnectedCallback() {
2186
+ disconnectedCallback(this);
2187
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2188
+ originalDisconnectedCallback.call(this);
2189
+ }
2190
+ },
2191
+ });
2192
+ Cstr.is = cmpMeta.$tagName$;
2193
+ return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2194
+ };
2195
+ const forceModeUpdate = (elm) => {
2196
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2197
+ const mode = computeMode(elm);
2198
+ const hostRef = getHostRef(elm);
2199
+ if (hostRef.$modeName$ !== mode) {
2200
+ const cmpMeta = hostRef.$cmpMeta$;
2201
+ const oldScopeId = elm['s-sc'];
2202
+ const scopeId = getScopeId(cmpMeta, mode);
2203
+ const style = elm.constructor.style[mode];
2204
+ const flags = cmpMeta.$flags$;
2205
+ if (style) {
2206
+ if (!styles.has(scopeId)) {
2207
+ registerStyle(scopeId, style, !!(flags & 1 /* shadowDomEncapsulation */));
2208
+ }
2209
+ hostRef.$modeName$ = mode;
2210
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2211
+ attachStyles(hostRef);
2212
+ forceUpdate(elm);
2213
+ }
2214
+ }
2215
+ }
2216
+ };
2217
+ const attachShadow = (el) => {
2218
+ if (supportsShadow) {
2219
+ el.attachShadow({ mode: 'open' });
2220
+ }
2221
+ else {
2222
+ el.shadowRoot = el;
2223
+ }
2224
+ };
2225
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2226
+ // ¯\_(ツ)_/¯
2227
+ const hostRef = getHostRef(elm);
2228
+ // reset state flags to only have been connected
2229
+ hostRef.$flags$ = 1 /* hasConnected */;
2230
+ // TODO
2231
+ // detatch any event listeners that may have been added
2232
+ // because we're not passing an exact event name it'll
2233
+ // remove all of this element's event, which is good
2234
+ // create a callback for when this component finishes hmr
2235
+ elm['s-hmr-load'] = () => {
2236
+ // finished hmr for this element
2237
+ delete elm['s-hmr-load'];
2238
+ };
2239
+ // re-initialize the component
2240
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2241
+ };
2242
+ const patchCloneNode = (HostElementPrototype) => {
2243
+ const orgCloneNode = HostElementPrototype.cloneNode;
2244
+ HostElementPrototype.cloneNode = function (deep) {
2245
+ const srcNode = this;
2246
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2247
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2248
+ if (BUILD.slot && !isShadowDom && deep) {
2249
+ let i = 0;
2250
+ let slotted, nonStencilNode;
2251
+ let stencilPrivates = ['s-id', 's-cr', 's-lr', 's-rc', 's-sc', 's-p', 's-cn', 's-sr', 's-sn', 's-hn', 's-ol', 's-nr', 's-si'];
2252
+ for (; i < srcNode.childNodes.length; i++) {
2253
+ slotted = srcNode.childNodes[i]['s-nr'];
2254
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2255
+ if (slotted) {
2256
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2257
+ clonedNode.__appendChild(slotted.cloneNode(true));
2258
+ }
2259
+ else {
2260
+ clonedNode.appendChild(slotted.cloneNode(true));
2261
+ }
2262
+ }
2263
+ if (nonStencilNode) {
2264
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2265
+ }
2266
+ }
2267
+ }
2268
+ return clonedNode;
2269
+ };
2270
+ };
2271
+ const patchSlotAppendChild = (HostElementPrototype) => {
2272
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2273
+ HostElementPrototype.appendChild = function (newChild) {
2274
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2275
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2276
+ if (slotNode) {
2277
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2278
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2279
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2280
+ }
2281
+ return this.__appendChild(newChild);
2282
+ };
2283
+ };
2284
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2285
+ class FakeNodeList extends Array {
2286
+ item(n) {
2287
+ return this[n];
2288
+ }
2289
+ }
2290
+ if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2291
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2292
+ Object.defineProperty(elm, 'children', {
2293
+ get() {
2294
+ return this.childNodes.map((n) => n.nodeType === 1);
2295
+ },
2296
+ });
2297
+ Object.defineProperty(elm, 'childElementCount', {
2298
+ get() {
2299
+ return elm.children.length;
2300
+ },
2301
+ });
2302
+ Object.defineProperty(elm, 'childNodes', {
2303
+ get() {
2304
+ const childNodes = childNodesFn.call(this);
2305
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
2306
+ const result = new FakeNodeList();
2307
+ for (let i = 0; i < childNodes.length; i++) {
2308
+ const slot = childNodes[i]['s-nr'];
2309
+ if (slot) {
2310
+ result.push(slot);
2311
+ }
2312
+ }
2313
+ return result;
2314
+ }
2315
+ return FakeNodeList.from(childNodes);
2316
+ },
2317
+ });
1520
2318
  }
1521
2319
  };
2320
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2321
+ const getHostSlotNode = (childNodes, slotName) => {
2322
+ let i = 0;
2323
+ let childNode;
2324
+ for (; i < childNodes.length; i++) {
2325
+ childNode = childNodes[i];
2326
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2327
+ return childNode;
2328
+ }
2329
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2330
+ if (childNode) {
2331
+ return childNode;
2332
+ }
2333
+ }
2334
+ return null;
2335
+ };
2336
+ const getHostSlotChildNodes = (n, slotName) => {
2337
+ const childNodes = [n];
2338
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2339
+ childNodes.push(n);
2340
+ }
2341
+ return childNodes;
2342
+ };
1522
2343
  const bootstrapLazy = (lazyBundles, options = {}) => {
1523
- const endBootstrap = createTime();
2344
+ if (BUILD.profile && performance.mark) {
2345
+ performance.mark('st:app:start');
2346
+ }
2347
+ installDevTools();
2348
+ const endBootstrap = createTime('bootstrapLazy');
1524
2349
  const cmpTags = [];
1525
2350
  const exclude = options.exclude || [];
1526
2351
  const customElements = win.customElements;
@@ -1528,10 +2353,27 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1528
2353
  const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1529
2354
  const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1530
2355
  const deferredConnectedCallbacks = [];
2356
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
1531
2357
  let appLoadFallback;
1532
2358
  let isBootstrapping = true;
2359
+ let i = 0;
1533
2360
  Object.assign(plt, options);
1534
2361
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2362
+ if (BUILD.asyncQueue) {
2363
+ if (options.syncQueue) {
2364
+ plt.$flags$ |= 4 /* queueSync */;
2365
+ }
2366
+ }
2367
+ if (BUILD.hydrateClientSide) {
2368
+ // If the app is already hydrated there is not point to disable the
2369
+ // async queue. This will improve the first input delay
2370
+ plt.$flags$ |= 2 /* appLoaded */;
2371
+ }
2372
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2373
+ for (; i < styles.length; i++) {
2374
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2375
+ }
2376
+ }
1535
2377
  lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
1536
2378
  const cmpMeta = {
1537
2379
  $flags$: compactMeta[0],
@@ -1539,19 +2381,22 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1539
2381
  $members$: compactMeta[2],
1540
2382
  $listeners$: compactMeta[3],
1541
2383
  };
1542
- {
2384
+ if (BUILD.member) {
1543
2385
  cmpMeta.$members$ = compactMeta[2];
1544
2386
  }
1545
- {
2387
+ if (BUILD.hostListener) {
1546
2388
  cmpMeta.$listeners$ = compactMeta[3];
1547
2389
  }
1548
- {
2390
+ if (BUILD.reflect) {
1549
2391
  cmpMeta.$attrsToReflect$ = [];
1550
2392
  }
1551
- {
2393
+ if (BUILD.watchCallback) {
1552
2394
  cmpMeta.$watchers$ = {};
1553
2395
  }
1554
- const tagName = cmpMeta.$tagName$;
2396
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2397
+ cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2398
+ }
2399
+ const tagName = BUILD.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
1555
2400
  const HostElement = class extends HTMLElement {
1556
2401
  // StencilLazyHost
1557
2402
  constructor(self) {
@@ -1559,16 +2404,28 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1559
2404
  super(self);
1560
2405
  self = this;
1561
2406
  registerHost(self, cmpMeta);
1562
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2407
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1563
2408
  // this component is using shadow dom
1564
2409
  // and this browser supports shadow dom
1565
2410
  // add the read-only property "shadowRoot" to the host element
1566
2411
  // adding the shadow root build conditionals to minimize runtime
1567
- {
1568
- {
2412
+ if (supportsShadow) {
2413
+ if (BUILD.shadowDelegatesFocus) {
2414
+ self.attachShadow({
2415
+ mode: 'open',
2416
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2417
+ });
2418
+ }
2419
+ else {
1569
2420
  self.attachShadow({ mode: 'open' });
1570
2421
  }
1571
2422
  }
2423
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2424
+ self.shadowRoot = self;
2425
+ }
2426
+ }
2427
+ if (BUILD.slotChildNodesFix) {
2428
+ patchChildSlotNodes(self, cmpMeta);
1572
2429
  }
1573
2430
  }
1574
2431
  connectedCallback() {
@@ -1591,13 +2448,24 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1591
2448
  return getHostRef(this).$onReadyPromise$;
1592
2449
  }
1593
2450
  };
2451
+ if (BUILD.cloneNodeFix) {
2452
+ patchCloneNode(HostElement.prototype);
2453
+ }
2454
+ if (BUILD.appendChildSlotFix) {
2455
+ patchSlotAppendChild(HostElement.prototype);
2456
+ }
2457
+ if (BUILD.hotModuleReplacement) {
2458
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2459
+ hmrStart(this, cmpMeta, hmrVersionId);
2460
+ };
2461
+ }
1594
2462
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1595
2463
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1596
2464
  cmpTags.push(tagName);
1597
2465
  customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1598
2466
  }
1599
2467
  }));
1600
- {
2468
+ if (BUILD.hydratedClass || BUILD.hydratedAttribute) {
1601
2469
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1602
2470
  visibilityStyle.setAttribute('data-styles', '');
1603
2471
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
@@ -1608,7 +2476,10 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1608
2476
  deferredConnectedCallbacks.map(host => host.connectedCallback());
1609
2477
  }
1610
2478
  else {
1611
- {
2479
+ if (BUILD.profile) {
2480
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2481
+ }
2482
+ else {
1612
2483
  plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1613
2484
  }
1614
2485
  }
@@ -1619,6 +2490,197 @@ const getAssetPath = (path) => {
1619
2490
  const assetUrl = new URL(path, plt.$resourcesUrl$);
1620
2491
  return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1621
2492
  };
2493
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
2494
+ const getConnect = (_ref, tagName) => {
2495
+ const componentOnReady = () => {
2496
+ let elm = doc.querySelector(tagName);
2497
+ if (!elm) {
2498
+ elm = doc.createElement(tagName);
2499
+ doc.body.appendChild(elm);
2500
+ }
2501
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2502
+ };
2503
+ const create = (...args) => {
2504
+ return componentOnReady().then(el => el.create(...args));
2505
+ };
2506
+ return {
2507
+ create,
2508
+ componentOnReady,
2509
+ };
2510
+ };
2511
+ const getContext = (_elm, context) => {
2512
+ if (context in Context) {
2513
+ return Context[context];
2514
+ }
2515
+ else if (context === 'window') {
2516
+ return win;
2517
+ }
2518
+ else if (context === 'document') {
2519
+ return doc;
2520
+ }
2521
+ else if (context === 'isServer' || context === 'isPrerender') {
2522
+ return BUILD.hydrateServerSide ? true : false;
2523
+ }
2524
+ else if (context === 'isClient') {
2525
+ return BUILD.hydrateServerSide ? false : true;
2526
+ }
2527
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2528
+ return getAssetPath('.');
2529
+ }
2530
+ else if (context === 'queue') {
2531
+ return {
2532
+ write: writeTask,
2533
+ read: readTask,
2534
+ tick: {
2535
+ then(cb) {
2536
+ return nextTick(cb);
2537
+ },
2538
+ },
2539
+ };
2540
+ }
2541
+ return undefined;
2542
+ };
2543
+ const insertVdomAnnotations = (doc, staticComponents) => {
2544
+ if (doc != null) {
2545
+ const docData = {
2546
+ hostIds: 0,
2547
+ rootLevelIds: 0,
2548
+ staticComponents: new Set(staticComponents),
2549
+ };
2550
+ const orgLocationNodes = [];
2551
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
2552
+ orgLocationNodes.forEach(orgLocationNode => {
2553
+ if (orgLocationNode != null) {
2554
+ const nodeRef = orgLocationNode['s-nr'];
2555
+ let hostId = nodeRef['s-host-id'];
2556
+ let nodeId = nodeRef['s-node-id'];
2557
+ let childId = `${hostId}.${nodeId}`;
2558
+ if (hostId == null) {
2559
+ hostId = 0;
2560
+ docData.rootLevelIds++;
2561
+ nodeId = docData.rootLevelIds;
2562
+ childId = `${hostId}.${nodeId}`;
2563
+ if (nodeRef.nodeType === 1 /* ElementNode */) {
2564
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2565
+ }
2566
+ else if (nodeRef.nodeType === 3 /* TextNode */) {
2567
+ if (hostId === 0) {
2568
+ const textContent = nodeRef.nodeValue.trim();
2569
+ if (textContent === '') {
2570
+ // useless whitespace node at the document root
2571
+ orgLocationNode.remove();
2572
+ return;
2573
+ }
2574
+ }
2575
+ const commentBeforeTextNode = doc.createComment(childId);
2576
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2577
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
2578
+ }
2579
+ }
2580
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2581
+ const orgLocationParentNode = orgLocationNode.parentElement;
2582
+ if (orgLocationParentNode) {
2583
+ if (orgLocationParentNode['s-en'] === '') {
2584
+ // ending with a "." means that the parent element
2585
+ // of this node's original location is a SHADOW dom element
2586
+ // and this node is apart of the root level light dom
2587
+ orgLocationNodeId += `.`;
2588
+ }
2589
+ else if (orgLocationParentNode['s-en'] === 'c') {
2590
+ // ending with a ".c" means that the parent element
2591
+ // of this node's original location is a SCOPED element
2592
+ // and this node is apart of the root level light dom
2593
+ orgLocationNodeId += `.c`;
2594
+ }
2595
+ }
2596
+ orgLocationNode.nodeValue = orgLocationNodeId;
2597
+ }
2598
+ });
2599
+ }
2600
+ };
2601
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2602
+ if (node == null) {
2603
+ return;
2604
+ }
2605
+ if (node['s-nr'] != null) {
2606
+ orgLocationNodes.push(node);
2607
+ }
2608
+ if (node.nodeType === 1 /* ElementNode */) {
2609
+ node.childNodes.forEach(childNode => {
2610
+ const hostRef = getHostRef(childNode);
2611
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
2612
+ const cmpData = {
2613
+ nodeIds: 0,
2614
+ };
2615
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
2616
+ }
2617
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
2618
+ });
2619
+ }
2620
+ };
2621
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2622
+ if (vnode != null) {
2623
+ const hostId = ++docData.hostIds;
2624
+ hostElm.setAttribute(HYDRATE_ID, hostId);
2625
+ if (hostElm['s-cr'] != null) {
2626
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
2627
+ }
2628
+ if (vnode.$children$ != null) {
2629
+ const depth = 0;
2630
+ vnode.$children$.forEach((vnodeChild, index) => {
2631
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
2632
+ });
2633
+ }
2634
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
2635
+ const parent = hostElm.parentElement;
2636
+ if (parent && parent.childNodes) {
2637
+ const parentChildNodes = Array.from(parent.childNodes);
2638
+ const comment = parentChildNodes.find(node => node.nodeType === 8 /* CommentNode */ && node['s-sr']);
2639
+ if (comment) {
2640
+ const index = parentChildNodes.indexOf(hostElm) - 1;
2641
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
2642
+ }
2643
+ }
2644
+ }
2645
+ }
2646
+ };
2647
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
2648
+ const childElm = vnodeChild.$elm$;
2649
+ if (childElm == null) {
2650
+ return;
2651
+ }
2652
+ const nodeId = cmpData.nodeIds++;
2653
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2654
+ childElm['s-host-id'] = hostId;
2655
+ childElm['s-node-id'] = nodeId;
2656
+ if (childElm.nodeType === 1 /* ElementNode */) {
2657
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2658
+ }
2659
+ else if (childElm.nodeType === 3 /* TextNode */) {
2660
+ const parentNode = childElm.parentNode;
2661
+ const nodeName = parentNode.nodeName;
2662
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
2663
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
2664
+ const commentBeforeTextNode = doc.createComment(textNodeId);
2665
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
2666
+ }
2667
+ }
2668
+ else if (childElm.nodeType === 8 /* CommentNode */) {
2669
+ if (childElm['s-sr']) {
2670
+ const slotName = childElm['s-sn'] || '';
2671
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
2672
+ childElm.nodeValue = slotNodeId;
2673
+ }
2674
+ }
2675
+ if (vnodeChild.$children$ != null) {
2676
+ const childDepth = depth + 1;
2677
+ vnodeChild.$children$.forEach((vnode, index) => {
2678
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
2679
+ });
2680
+ }
2681
+ };
2682
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
2683
+ const Fragment = (_, children) => children;
1622
2684
  const hostRefs = new WeakMap();
1623
2685
  const getHostRef = (ref) => hostRefs.get(ref);
1624
2686
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1629,42 +2691,58 @@ const registerHost = (elm, cmpMeta) => {
1629
2691
  $cmpMeta$: cmpMeta,
1630
2692
  $instanceValues$: new Map(),
1631
2693
  };
1632
- {
2694
+ if (BUILD.isDev) {
2695
+ hostRef.$renderCount$ = 0;
2696
+ }
2697
+ if (BUILD.method && BUILD.lazyLoad) {
1633
2698
  hostRef.$onInstancePromise$ = new Promise(r => (hostRef.$onInstanceResolve$ = r));
1634
2699
  }
1635
- {
2700
+ if (BUILD.asyncLoading) {
1636
2701
  hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
1637
2702
  elm['s-p'] = [];
1638
2703
  elm['s-rc'] = [];
1639
2704
  }
1640
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2705
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
1641
2706
  return hostRefs.set(elm, hostRef);
1642
2707
  };
1643
2708
  const isMemberInElement = (elm, memberName) => memberName in elm;
1644
- const consoleError = (e, el) => (0, console.error)(e, el);
2709
+ const consoleError = (e, el) => (customError || console.error)(e, el);
2710
+ const STENCIL_DEV_MODE = BUILD.isTesting
2711
+ ? ['STENCIL:'] // E2E testing
2712
+ : ['%cstencil', 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px'];
2713
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
2714
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
2715
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
2716
+ const setErrorHandler = (handler) => customError = handler;
1645
2717
  const cmpModules = /*@__PURE__*/ new Map();
1646
2718
  const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1647
2719
  // loadModuleImport
1648
2720
  const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1649
2721
  const bundleId = cmpMeta.$lazyBundleId$;
1650
- const module = cmpModules.get(bundleId) ;
2722
+ if (BUILD.isDev && typeof bundleId !== 'string') {
2723
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
2724
+ return undefined;
2725
+ }
2726
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
1651
2727
  if (module) {
1652
2728
  return module[exportName];
1653
2729
  }
1654
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2730
+ return import(
1655
2731
  /* webpackInclude: /\.entry\.js$/ */
1656
2732
  /* webpackExclude: /\.system\.entry\.js$/ */
1657
2733
  /* webpackMode: "lazy" */
1658
- `./${bundleId}.entry.js${''}`)); }).then(importedModule => {
1659
- {
2734
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`).then(importedModule => {
2735
+ if (!BUILD.hotModuleReplacement) {
1660
2736
  cmpModules.set(bundleId, importedModule);
1661
2737
  }
1662
2738
  return importedModule[exportName];
1663
2739
  }, consoleError);
1664
2740
  };
1665
2741
  const styles = new Map();
2742
+ const modeResolutionChain = [];
1666
2743
  const queueDomReads = [];
1667
2744
  const queueDomWrites = [];
2745
+ const queueDomWritesLow = [];
1668
2746
  const queueTask = (queue, write) => (cb) => {
1669
2747
  queue.push(cb);
1670
2748
  if (!queuePending) {
@@ -1688,13 +2766,51 @@ const consume = (queue) => {
1688
2766
  }
1689
2767
  queue.length = 0;
1690
2768
  };
2769
+ const consumeTimeout = (queue, timeout) => {
2770
+ let i = 0;
2771
+ let ts = 0;
2772
+ while (i < queue.length && (ts = performance.now()) < timeout) {
2773
+ try {
2774
+ queue[i++](ts);
2775
+ }
2776
+ catch (e) {
2777
+ consoleError(e);
2778
+ }
2779
+ }
2780
+ if (i === queue.length) {
2781
+ queue.length = 0;
2782
+ }
2783
+ else if (i !== 0) {
2784
+ queue.splice(0, i);
2785
+ }
2786
+ };
1691
2787
  const flush = () => {
2788
+ if (BUILD.asyncQueue) {
2789
+ queueCongestion++;
2790
+ }
1692
2791
  // always force a bunch of medium callbacks to run, but still have
1693
2792
  // a throttle on how many can run in a certain time
1694
2793
  // DOM READS!!!
1695
2794
  consume(queueDomReads);
1696
2795
  // DOM WRITES!!!
1697
- {
2796
+ if (BUILD.asyncQueue) {
2797
+ const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0)) : Infinity;
2798
+ consumeTimeout(queueDomWrites, timeout);
2799
+ consumeTimeout(queueDomWritesLow, timeout);
2800
+ if (queueDomWrites.length > 0) {
2801
+ queueDomWritesLow.push(...queueDomWrites);
2802
+ queueDomWrites.length = 0;
2803
+ }
2804
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
2805
+ // still more to do yet, but we've run out of time
2806
+ // let's let this thing cool off and try again in the next tick
2807
+ plt.raf(flush);
2808
+ }
2809
+ else {
2810
+ queueCongestion = 0;
2811
+ }
2812
+ }
2813
+ else {
1698
2814
  consume(queueDomWrites);
1699
2815
  if ((queuePending = queueDomReads.length > 0)) {
1700
2816
  // still more to do yet, but we've run out of time
@@ -1704,13 +2820,13 @@ const flush = () => {
1704
2820
  }
1705
2821
  };
1706
2822
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
2823
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
1707
2824
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2825
+ const Build = {
2826
+ isDev: BUILD.isDev ? true : false,
2827
+ isBrowser: true,
2828
+ isServer: false,
2829
+ isTesting: BUILD.isTesting ? true : false,
2830
+ };
1708
2831
 
1709
- exports.Host = Host;
1710
- exports.bootstrapLazy = bootstrapLazy;
1711
- exports.createEvent = createEvent;
1712
- exports.getAssetPath = getAssetPath;
1713
- exports.getElement = getElement;
1714
- exports.h = h;
1715
- exports.promiseResolve = promiseResolve;
1716
- exports.registerInstance = registerInstance;
2832
+ export { BUILD as B, CSS as C, H, NAMESPACE as N, promiseResolve as a, bootstrapLazy as b, consoleDevInfo as c, doc as d, Host as e, createEvent as f, getElement as g, h, getAssetPath as i, plt as p, registerInstance as r, win as w };