@stencil/core 2.17.4 → 2.18.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 (88) hide show
  1. package/cli/index.cjs +285 -220
  2. package/cli/index.d.ts +1 -0
  3. package/cli/index.js +285 -220
  4. package/cli/package.json +1 -1
  5. package/compiler/lib.dom.d.ts +620 -89
  6. package/compiler/lib.dom.iterable.d.ts +27 -3
  7. package/compiler/lib.es2015.core.d.ts +3 -3
  8. package/compiler/lib.es2015.iterable.d.ts +2 -1
  9. package/compiler/lib.es2015.reflect.d.ts +1 -1
  10. package/compiler/lib.es2020.bigint.d.ts +7 -5
  11. package/compiler/lib.es2020.d.ts +2 -0
  12. package/compiler/lib.es2020.date.d.ts +44 -0
  13. package/compiler/lib.es2020.intl.d.ts +51 -11
  14. package/compiler/lib.es2020.number.d.ts +30 -0
  15. package/compiler/lib.es2021.intl.d.ts +106 -4
  16. package/compiler/lib.es2022.array.d.ts +123 -0
  17. package/compiler/lib.es2022.d.ts +26 -0
  18. package/compiler/lib.es2022.error.d.ts +75 -0
  19. package/compiler/lib.es2022.full.d.ts +25 -0
  20. package/compiler/lib.es2022.intl.d.ts +111 -0
  21. package/compiler/lib.es2022.object.d.ts +28 -0
  22. package/compiler/lib.es2022.string.d.ts +27 -0
  23. package/compiler/lib.es5.d.ts +25 -19
  24. package/compiler/lib.esnext.d.ts +1 -1
  25. package/compiler/lib.esnext.intl.d.ts +4 -1
  26. package/compiler/lib.webworker.d.ts +236 -40
  27. package/compiler/lib.webworker.iterable.d.ts +10 -3
  28. package/compiler/package.json +1 -1
  29. package/compiler/stencil.d.ts +2 -2
  30. package/compiler/stencil.js +47263 -45624
  31. package/compiler/stencil.min.js +2 -2
  32. package/compiler/sys/in-memory-fs.d.ts +218 -0
  33. package/dependencies.json +10 -1
  34. package/dev-server/client/index.d.ts +2 -2
  35. package/dev-server/client/index.js +241 -241
  36. package/dev-server/client/package.json +1 -1
  37. package/dev-server/connector.html +3 -3
  38. package/dev-server/index.d.ts +1 -1
  39. package/dev-server/index.js +2 -2
  40. package/dev-server/package.json +1 -1
  41. package/dev-server/server-process.js +1198 -1167
  42. package/internal/app-data/package.json +1 -1
  43. package/internal/client/css-shim.js +2 -2
  44. package/internal/client/dom.js +1 -1
  45. package/internal/client/index.js +1022 -824
  46. package/internal/client/package.json +1 -1
  47. package/internal/client/patch-browser.js +1 -1
  48. package/internal/client/patch-esm.js +1 -1
  49. package/internal/client/polyfills/css-shim.js +1 -1
  50. package/internal/client/shadow-css.js +1 -1
  51. package/internal/hydrate/index.js +119 -119
  52. package/internal/hydrate/package.json +1 -1
  53. package/internal/hydrate/runner.d.ts +1 -1
  54. package/internal/hydrate/runner.js +100 -100
  55. package/internal/package.json +1 -1
  56. package/internal/stencil-core/index.d.ts +8 -10
  57. package/internal/stencil-private.d.ts +77 -138
  58. package/internal/stencil-public-compiler.d.ts +44 -10
  59. package/internal/stencil-public-runtime.d.ts +15 -4
  60. package/internal/testing/index.js +148 -148
  61. package/internal/testing/package.json +1 -1
  62. package/mock-doc/index.cjs +534 -518
  63. package/mock-doc/index.d.ts +13 -12
  64. package/mock-doc/index.js +534 -518
  65. package/mock-doc/package.json +1 -1
  66. package/package.json +23 -32
  67. package/readme.md +27 -33
  68. package/screenshot/index.d.ts +1 -1
  69. package/screenshot/index.js +13 -13
  70. package/screenshot/package.json +1 -1
  71. package/screenshot/pixel-match.js +983 -849
  72. package/sys/node/glob.js +1 -1
  73. package/sys/node/index.d.ts +2 -0
  74. package/sys/node/index.js +374 -373
  75. package/sys/node/package.json +1 -1
  76. package/sys/node/worker.js +1 -1
  77. package/testing/index.d.ts +6 -6
  78. package/testing/index.js +427 -441
  79. package/testing/jest/jest-config.d.ts +1 -1
  80. package/testing/matchers/index.d.ts +3 -3
  81. package/testing/mock-fetch.d.ts +1 -1
  82. package/testing/mocks.d.ts +2 -2
  83. package/testing/package.json +1 -1
  84. package/testing/puppeteer/puppeteer-element.d.ts +2 -2
  85. package/testing/puppeteer/puppeteer-events.d.ts +1 -1
  86. package/testing/testing-logger.d.ts +1 -1
  87. package/testing/testing-utils.d.ts +5 -4
  88. package/testing/testing.d.ts +1 -1
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Virtual DOM patching algorithm based on Snabbdom by
3
+ * Simon Friis Vindum (@paldepind)
4
+ * Licensed under the MIT License
5
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
6
+ *
7
+ * Modified for Stencil's renderer and slot projection
8
+ */
1
9
  let scopeId;
2
10
  let contentRef;
3
11
  let hostTagName;
@@ -11,129 +19,21 @@ let renderingRef = null;
11
19
  let queueCongestion = 0;
12
20
  let queuePending = false;
13
21
  /*
14
- Stencil Client Platform v2.17.4 | MIT Licensed | https://stenciljs.com
22
+ Stencil Client Platform v2.18.1 | MIT Licensed | https://stenciljs.com
15
23
  */
16
24
  import { BUILD, NAMESPACE } from '@stencil/core/internal/app-data';
17
- const win = typeof window !== 'undefined' ? window : {};
18
- const CSS = BUILD.cssVarShim ? win.CSS : null;
19
- const doc = win.document || { head: {} };
20
- const H = (win.HTMLElement || class {
21
- });
22
- const plt = {
23
- $flags$: 0,
24
- $resourcesUrl$: '',
25
- jmp: (h) => h(),
26
- raf: (h) => requestAnimationFrame(h),
27
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
28
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
29
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
30
- };
31
- const setPlatformHelpers = (helpers) => {
32
- Object.assign(plt, helpers);
25
+ const Build = {
26
+ isDev: BUILD.isDev ? true : false,
27
+ isBrowser: true,
28
+ isServer: false,
29
+ isTesting: BUILD.isTesting ? true : false,
33
30
  };
34
- const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
35
- ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
36
- : true;
37
- const supportsListenerOptions = /*@__PURE__*/ (() => {
38
- let supportsListenerOptions = false;
39
- try {
40
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
41
- get() {
42
- supportsListenerOptions = true;
43
- },
44
- }));
45
- }
46
- catch (e) { }
47
- return supportsListenerOptions;
48
- })();
49
- const promiseResolve = (v) => Promise.resolve(v);
50
- const supportsConstructableStylesheets = BUILD.constructableCSS
51
- ? /*@__PURE__*/ (() => {
52
- try {
53
- new CSSStyleSheet();
54
- return typeof new CSSStyleSheet().replaceSync === 'function';
55
- }
56
- catch (e) { }
57
- return false;
58
- })()
59
- : false;
60
31
  const Context = {};
61
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
62
- if (BUILD.hostListener && listeners) {
63
- // this is called immediately within the element's constructor
64
- // initialize our event listeners on the host element
65
- // we do this now so that we can listen to events that may
66
- // have fired even before the instance is ready
67
- if (BUILD.hostListenerTargetParent) {
68
- // this component may have event listeners that should be attached to the parent
69
- if (attachParentListeners) {
70
- // this is being ran from within the connectedCallback
71
- // which is important so that we know the host element actually has a parent element
72
- // filter out the listeners to only have the ones that ARE being attached to the parent
73
- listeners = listeners.filter(([flags]) => flags & 32 /* TargetParent */);
74
- }
75
- else {
76
- // this is being ran from within the component constructor
77
- // everything BUT the parent element listeners should be attached at this time
78
- // filter out the listeners that are NOT being attached to the parent
79
- listeners = listeners.filter(([flags]) => !(flags & 32 /* TargetParent */));
80
- }
81
- }
82
- listeners.map(([flags, name, method]) => {
83
- const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
84
- const handler = hostListenerProxy(hostRef, method);
85
- const opts = hostListenerOpts(flags);
86
- plt.ael(target, name, handler, opts);
87
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
88
- });
89
- }
90
- };
91
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
92
- try {
93
- if (BUILD.lazyLoad) {
94
- if (hostRef.$flags$ & 256 /* isListenReady */) {
95
- // instance is ready, let's call it's member method for this event
96
- hostRef.$lazyInstance$[methodName](ev);
97
- }
98
- else {
99
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
100
- }
101
- }
102
- else {
103
- hostRef.$hostElement$[methodName](ev);
104
- }
105
- }
106
- catch (e) {
107
- consoleError(e);
108
- }
109
- };
110
- const getHostListenerTarget = (elm, flags) => {
111
- if (BUILD.hostListenerTargetDocument && flags & 4 /* TargetDocument */)
112
- return doc;
113
- if (BUILD.hostListenerTargetWindow && flags & 8 /* TargetWindow */)
114
- return win;
115
- if (BUILD.hostListenerTargetBody && flags & 16 /* TargetBody */)
116
- return doc.body;
117
- if (BUILD.hostListenerTargetParent && flags & 32 /* TargetParent */)
118
- return elm.parentElement;
119
- return elm;
32
+ const getAssetPath = (path) => {
33
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
34
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
120
35
  };
121
- // prettier-ignore
122
- const hostListenerOpts = (flags) => supportsListenerOptions
123
- ? ({
124
- passive: (flags & 1 /* Passive */) !== 0,
125
- capture: (flags & 2 /* Capture */) !== 0,
126
- })
127
- : (flags & 2 /* Capture */) !== 0;
128
- const CONTENT_REF_ID = 'r';
129
- const ORG_LOCATION_ID = 'o';
130
- const SLOT_NODE_ID = 's';
131
- const TEXT_NODE_ID = 't';
132
- const HYDRATE_ID = 's-id';
133
- const HYDRATED_STYLE_ID = 'sty-id';
134
- const HYDRATE_CHILD_ID = 'c-id';
135
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
136
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
36
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
137
37
  const createTime = (fnName, tagName = '') => {
138
38
  if (BUILD.profile && performance.mark) {
139
39
  const key = `st:${fnName}:${tagName}:${i++}`;
@@ -173,54 +73,528 @@ const inspect = (ref) => {
173
73
  const flags = hostRef.$flags$;
174
74
  const hostElement = hostRef.$hostElement$;
175
75
  return {
176
- renderCount: hostRef.$renderCount$,
177
- flags: {
178
- hasRendered: !!(flags & 2 /* hasRendered */),
179
- hasConnected: !!(flags & 1 /* hasConnected */),
180
- isWaitingForChildren: !!(flags & 4 /* isWaitingForChildren */),
181
- isConstructingInstance: !!(flags & 8 /* isConstructingInstance */),
182
- isQueuedForUpdate: !!(flags & 16 /* isQueuedForUpdate */),
183
- hasInitializedComponent: !!(flags & 32 /* hasInitializedComponent */),
184
- hasLoadedComponent: !!(flags & 64 /* hasLoadedComponent */),
185
- isWatchReady: !!(flags & 128 /* isWatchReady */),
186
- isListenReady: !!(flags & 256 /* isListenReady */),
187
- needsRerender: !!(flags & 512 /* needsRerender */),
76
+ renderCount: hostRef.$renderCount$,
77
+ flags: {
78
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
79
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
80
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
81
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
82
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
83
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
84
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
85
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
86
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
87
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
88
+ },
89
+ instanceValues: hostRef.$instanceValues$,
90
+ ancestorComponent: hostRef.$ancestorComponent$,
91
+ hostElement,
92
+ lazyInstance: hostRef.$lazyInstance$,
93
+ vnode: hostRef.$vnode$,
94
+ modeName: hostRef.$modeName$,
95
+ onReadyPromise: hostRef.$onReadyPromise$,
96
+ onReadyResolve: hostRef.$onReadyResolve$,
97
+ onInstancePromise: hostRef.$onInstancePromise$,
98
+ onInstanceResolve: hostRef.$onInstanceResolve$,
99
+ onRenderResolve: hostRef.$onRenderResolve$,
100
+ queuedListeners: hostRef.$queuedListeners$,
101
+ rmListeners: hostRef.$rmListeners$,
102
+ ['s-id']: hostElement['s-id'],
103
+ ['s-cr']: hostElement['s-cr'],
104
+ ['s-lr']: hostElement['s-lr'],
105
+ ['s-p']: hostElement['s-p'],
106
+ ['s-rc']: hostElement['s-rc'],
107
+ ['s-sc']: hostElement['s-sc'],
108
+ };
109
+ };
110
+ const installDevTools = () => {
111
+ if (BUILD.devTools) {
112
+ const stencil = (win.stencil = win.stencil || {});
113
+ const originalInspect = stencil.inspect;
114
+ stencil.inspect = (ref) => {
115
+ let result = inspect(ref);
116
+ if (!result && typeof originalInspect === 'function') {
117
+ result = originalInspect(ref);
118
+ }
119
+ return result;
120
+ };
121
+ }
122
+ };
123
+ const CONTENT_REF_ID = 'r';
124
+ const ORG_LOCATION_ID = 'o';
125
+ const SLOT_NODE_ID = 's';
126
+ const TEXT_NODE_ID = 't';
127
+ const HYDRATE_ID = 's-id';
128
+ const HYDRATED_STYLE_ID = 'sty-id';
129
+ const HYDRATE_CHILD_ID = 'c-id';
130
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
131
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
132
+ /**
133
+ * Default style mode id
134
+ */
135
+ /**
136
+ * Reusable empty obj/array
137
+ * Don't add values to these!!
138
+ */
139
+ const EMPTY_OBJ = {};
140
+ /**
141
+ * Namespaces
142
+ */
143
+ const SVG_NS = 'http://www.w3.org/2000/svg';
144
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
145
+ const isDef = (v) => v != null;
146
+ const isComplexType = (o) => {
147
+ // https://jsperf.com/typeof-fn-object/5
148
+ o = typeof o;
149
+ return o === 'object' || o === 'function';
150
+ };
151
+ /**
152
+ * Production h() function based on Preact by
153
+ * Jason Miller (@developit)
154
+ * Licensed under the MIT License
155
+ * https://github.com/developit/preact/blob/master/LICENSE
156
+ *
157
+ * Modified for Stencil's compiler and vdom
158
+ */
159
+ // const stack: any[] = [];
160
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
161
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
162
+ const h = (nodeName, vnodeData, ...children) => {
163
+ let child = null;
164
+ let key = null;
165
+ let slotName = null;
166
+ let simple = false;
167
+ let lastSimple = false;
168
+ const vNodeChildren = [];
169
+ const walk = (c) => {
170
+ for (let i = 0; i < c.length; i++) {
171
+ child = c[i];
172
+ if (Array.isArray(child)) {
173
+ walk(child);
174
+ }
175
+ else if (child != null && typeof child !== 'boolean') {
176
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
177
+ child = String(child);
178
+ }
179
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
180
+ consoleDevError(`vNode passed as children has unexpected type.
181
+ Make sure it's using the correct h() function.
182
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
183
+ }
184
+ if (simple && lastSimple) {
185
+ // If the previous child was simple (string), we merge both
186
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
187
+ }
188
+ else {
189
+ // Append a new vNode, if it's text, we create a text vNode
190
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
191
+ }
192
+ lastSimple = simple;
193
+ }
194
+ }
195
+ };
196
+ walk(children);
197
+ if (vnodeData) {
198
+ if (BUILD.isDev && nodeName === 'input') {
199
+ validateInputProperties(vnodeData);
200
+ }
201
+ // normalize class / classname attributes
202
+ if (BUILD.vdomKey && vnodeData.key) {
203
+ key = vnodeData.key;
204
+ }
205
+ if (BUILD.slotRelocation && vnodeData.name) {
206
+ slotName = vnodeData.name;
207
+ }
208
+ if (BUILD.vdomClass) {
209
+ const classData = vnodeData.className || vnodeData.class;
210
+ if (classData) {
211
+ vnodeData.class =
212
+ typeof classData !== 'object'
213
+ ? classData
214
+ : Object.keys(classData)
215
+ .filter((k) => classData[k])
216
+ .join(' ');
217
+ }
218
+ }
219
+ }
220
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
221
+ consoleDevError(`The <Host> must be the single root component. Make sure:
222
+ - You are NOT using hostData() and <Host> in the same component.
223
+ - <Host> is used once, and it's the single root component of the render() function.`);
224
+ }
225
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
226
+ // nodeName is a functional component
227
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
228
+ }
229
+ const vnode = newVNode(nodeName, null);
230
+ vnode.$attrs$ = vnodeData;
231
+ if (vNodeChildren.length > 0) {
232
+ vnode.$children$ = vNodeChildren;
233
+ }
234
+ if (BUILD.vdomKey) {
235
+ vnode.$key$ = key;
236
+ }
237
+ if (BUILD.slotRelocation) {
238
+ vnode.$name$ = slotName;
239
+ }
240
+ return vnode;
241
+ };
242
+ const newVNode = (tag, text) => {
243
+ const vnode = {
244
+ $flags$: 0,
245
+ $tag$: tag,
246
+ $text$: text,
247
+ $elm$: null,
248
+ $children$: null,
249
+ };
250
+ if (BUILD.vdomAttribute) {
251
+ vnode.$attrs$ = null;
252
+ }
253
+ if (BUILD.vdomKey) {
254
+ vnode.$key$ = null;
255
+ }
256
+ if (BUILD.slotRelocation) {
257
+ vnode.$name$ = null;
258
+ }
259
+ return vnode;
260
+ };
261
+ const Host = {};
262
+ const isHost = (node) => node && node.$tag$ === Host;
263
+ const vdomFnUtils = {
264
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
265
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
266
+ };
267
+ const convertToPublic = (node) => ({
268
+ vattrs: node.$attrs$,
269
+ vchildren: node.$children$,
270
+ vkey: node.$key$,
271
+ vname: node.$name$,
272
+ vtag: node.$tag$,
273
+ vtext: node.$text$,
274
+ });
275
+ const convertToPrivate = (node) => {
276
+ if (typeof node.vtag === 'function') {
277
+ const vnodeData = Object.assign({}, node.vattrs);
278
+ if (node.vkey) {
279
+ vnodeData.key = node.vkey;
280
+ }
281
+ if (node.vname) {
282
+ vnodeData.name = node.vname;
283
+ }
284
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
285
+ }
286
+ const vnode = newVNode(node.vtag, node.vtext);
287
+ vnode.$attrs$ = node.vattrs;
288
+ vnode.$children$ = node.vchildren;
289
+ vnode.$key$ = node.vkey;
290
+ vnode.$name$ = node.vname;
291
+ return vnode;
292
+ };
293
+ /**
294
+ * Validates the ordering of attributes on an input element
295
+ * @param inputElm the element to validate
296
+ */
297
+ const validateInputProperties = (inputElm) => {
298
+ const props = Object.keys(inputElm);
299
+ const value = props.indexOf('value');
300
+ if (value === -1) {
301
+ return;
302
+ }
303
+ const typeIndex = props.indexOf('type');
304
+ const minIndex = props.indexOf('min');
305
+ const maxIndex = props.indexOf('max');
306
+ const stepIndex = props.indexOf('step');
307
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
308
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
309
+ }
310
+ };
311
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
312
+ const endHydrate = createTime('hydrateClient', tagName);
313
+ const shadowRoot = hostElm.shadowRoot;
314
+ const childRenderNodes = [];
315
+ const slotNodes = [];
316
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
317
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
318
+ if (!plt.$orgLocNodes$) {
319
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
320
+ }
321
+ hostElm[HYDRATE_ID] = hostId;
322
+ hostElm.removeAttribute(HYDRATE_ID);
323
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
324
+ childRenderNodes.map((c) => {
325
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
326
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
327
+ const node = c.$elm$;
328
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
329
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
330
+ }
331
+ if (!shadowRoot) {
332
+ node['s-hn'] = tagName;
333
+ if (orgLocationNode) {
334
+ node['s-ol'] = orgLocationNode;
335
+ node['s-ol']['s-nr'] = node;
336
+ }
337
+ }
338
+ plt.$orgLocNodes$.delete(orgLocationId);
339
+ });
340
+ if (BUILD.shadowDom && shadowRoot) {
341
+ shadowRootNodes.map((shadowRootNode) => {
342
+ if (shadowRootNode) {
343
+ shadowRoot.appendChild(shadowRootNode);
344
+ }
345
+ });
346
+ }
347
+ endHydrate();
348
+ };
349
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
350
+ let childNodeType;
351
+ let childIdSplt;
352
+ let childVNode;
353
+ let i;
354
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
355
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
356
+ if (childNodeType) {
357
+ // got the node data from the element's attribute
358
+ // `${hostId}.${nodeId}.${depth}.${index}`
359
+ childIdSplt = childNodeType.split('.');
360
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
361
+ childVNode = {
362
+ $flags$: 0,
363
+ $hostId$: childIdSplt[0],
364
+ $nodeId$: childIdSplt[1],
365
+ $depth$: childIdSplt[2],
366
+ $index$: childIdSplt[3],
367
+ $tag$: node.tagName.toLowerCase(),
368
+ $elm$: node,
369
+ $attrs$: null,
370
+ $children$: null,
371
+ $key$: null,
372
+ $name$: null,
373
+ $text$: null,
374
+ };
375
+ childRenderNodes.push(childVNode);
376
+ node.removeAttribute(HYDRATE_CHILD_ID);
377
+ // this is a new child vnode
378
+ // so ensure its parent vnode has the vchildren array
379
+ if (!parentVNode.$children$) {
380
+ parentVNode.$children$ = [];
381
+ }
382
+ // add our child vnode to a specific index of the vnode's children
383
+ parentVNode.$children$[childVNode.$index$] = childVNode;
384
+ // this is now the new parent vnode for all the next child checks
385
+ parentVNode = childVNode;
386
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
387
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
388
+ }
389
+ }
390
+ }
391
+ // recursively drill down, end to start so we can remove nodes
392
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
393
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
394
+ }
395
+ if (node.shadowRoot) {
396
+ // keep drilling down through the shadow root nodes
397
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
398
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
399
+ }
400
+ }
401
+ }
402
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
403
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
404
+ childIdSplt = node.nodeValue.split('.');
405
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
406
+ // comment node for either the host id or a 0 host id
407
+ childNodeType = childIdSplt[0];
408
+ childVNode = {
409
+ $flags$: 0,
410
+ $hostId$: childIdSplt[1],
411
+ $nodeId$: childIdSplt[2],
412
+ $depth$: childIdSplt[3],
413
+ $index$: childIdSplt[4],
414
+ $elm$: node,
415
+ $attrs$: null,
416
+ $children$: null,
417
+ $key$: null,
418
+ $name$: null,
419
+ $tag$: null,
420
+ $text$: null,
421
+ };
422
+ if (childNodeType === TEXT_NODE_ID) {
423
+ childVNode.$elm$ = node.nextSibling;
424
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
425
+ childVNode.$text$ = childVNode.$elm$.textContent;
426
+ childRenderNodes.push(childVNode);
427
+ // remove the text comment since it's no longer needed
428
+ node.remove();
429
+ if (!parentVNode.$children$) {
430
+ parentVNode.$children$ = [];
431
+ }
432
+ parentVNode.$children$[childVNode.$index$] = childVNode;
433
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
434
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
435
+ }
436
+ }
437
+ }
438
+ else if (childVNode.$hostId$ === hostId) {
439
+ // this comment node is specifcally for this host id
440
+ if (childNodeType === SLOT_NODE_ID) {
441
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
442
+ childVNode.$tag$ = 'slot';
443
+ if (childIdSplt[5]) {
444
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
445
+ }
446
+ else {
447
+ node['s-sn'] = '';
448
+ }
449
+ node['s-sr'] = true;
450
+ if (BUILD.shadowDom && shadowRootNodes) {
451
+ // browser support shadowRoot and this is a shadow dom component
452
+ // create an actual slot element
453
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
454
+ if (childVNode.$name$) {
455
+ // add the slot name attribute
456
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
457
+ }
458
+ // insert the new slot element before the slot comment
459
+ node.parentNode.insertBefore(childVNode.$elm$, node);
460
+ // remove the slot comment since it's not needed for shadow
461
+ node.remove();
462
+ if (childVNode.$depth$ === '0') {
463
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
464
+ }
465
+ }
466
+ slotNodes.push(childVNode);
467
+ if (!parentVNode.$children$) {
468
+ parentVNode.$children$ = [];
469
+ }
470
+ parentVNode.$children$[childVNode.$index$] = childVNode;
471
+ }
472
+ else if (childNodeType === CONTENT_REF_ID) {
473
+ // `${CONTENT_REF_ID}.${hostId}`;
474
+ if (BUILD.shadowDom && shadowRootNodes) {
475
+ // remove the content ref comment since it's not needed for shadow
476
+ node.remove();
477
+ }
478
+ else if (BUILD.slotRelocation) {
479
+ hostElm['s-cr'] = node;
480
+ node['s-cn'] = true;
481
+ }
482
+ }
483
+ }
484
+ }
485
+ }
486
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
487
+ const vnode = newVNode(null, node.textContent);
488
+ vnode.$elm$ = node;
489
+ vnode.$index$ = '0';
490
+ parentVNode.$children$ = [vnode];
491
+ }
492
+ };
493
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
494
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
495
+ let i = 0;
496
+ for (; i < node.childNodes.length; i++) {
497
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
498
+ }
499
+ if (node.shadowRoot) {
500
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
501
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
502
+ }
503
+ }
504
+ }
505
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
506
+ const childIdSplt = node.nodeValue.split('.');
507
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
508
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
509
+ node.nodeValue = '';
510
+ // useful to know if the original location is
511
+ // the root light-dom of a shadow dom component
512
+ node['s-en'] = childIdSplt[3];
513
+ }
514
+ }
515
+ };
516
+ // Private
517
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
518
+ // Public
519
+ const setMode = (handler) => modeResolutionChain.push(handler);
520
+ const getMode = (ref) => getHostRef(ref).$modeName$;
521
+ /**
522
+ * Parse a new property value for a given property type.
523
+ *
524
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
525
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
526
+ * 1. `any`, the type given to `propValue` in the function signature
527
+ * 2. the type stored from `propType`.
528
+ *
529
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
530
+ *
531
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
532
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
533
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
534
+ * ```tsx
535
+ * <my-cmp prop-val={0}></my-cmp>
536
+ * ```
537
+ *
538
+ * HTML prop values on the other hand, will always a string
539
+ *
540
+ * @param propValue the new value to coerce to some type
541
+ * @param propType the type of the prop, expressed as a binary number
542
+ * @returns the parsed/coerced value
543
+ */
544
+ const parsePropertyValue = (propValue, propType) => {
545
+ // ensure this value is of the correct prop type
546
+ if (propValue != null && !isComplexType(propValue)) {
547
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
548
+ // per the HTML spec, any string value means it is a boolean true value
549
+ // but we'll cheat here and say that the string "false" is the boolean false
550
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
551
+ }
552
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
553
+ // force it to be a number
554
+ return parseFloat(propValue);
555
+ }
556
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
557
+ // could have been passed as a number or boolean
558
+ // but we still want it as a string
559
+ return String(propValue);
560
+ }
561
+ // redundant return here for better minification
562
+ return propValue;
563
+ }
564
+ // not sure exactly what type we want
565
+ // so no need to change to a different type
566
+ return propValue;
567
+ };
568
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
569
+ const createEvent = (ref, name, flags) => {
570
+ const elm = getElement(ref);
571
+ return {
572
+ emit: (detail) => {
573
+ if (BUILD.isDev && !elm.isConnected) {
574
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
575
+ }
576
+ return emitEvent(elm, name, {
577
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
578
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
579
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
580
+ detail,
581
+ });
188
582
  },
189
- instanceValues: hostRef.$instanceValues$,
190
- ancestorComponent: hostRef.$ancestorComponent$,
191
- hostElement,
192
- lazyInstance: hostRef.$lazyInstance$,
193
- vnode: hostRef.$vnode$,
194
- modeName: hostRef.$modeName$,
195
- onReadyPromise: hostRef.$onReadyPromise$,
196
- onReadyResolve: hostRef.$onReadyResolve$,
197
- onInstancePromise: hostRef.$onInstancePromise$,
198
- onInstanceResolve: hostRef.$onInstanceResolve$,
199
- onRenderResolve: hostRef.$onRenderResolve$,
200
- queuedListeners: hostRef.$queuedListeners$,
201
- rmListeners: hostRef.$rmListeners$,
202
- ['s-id']: hostElement['s-id'],
203
- ['s-cr']: hostElement['s-cr'],
204
- ['s-lr']: hostElement['s-lr'],
205
- ['s-p']: hostElement['s-p'],
206
- ['s-rc']: hostElement['s-rc'],
207
- ['s-sc']: hostElement['s-sc'],
208
583
  };
209
584
  };
210
- const installDevTools = () => {
211
- if (BUILD.devTools) {
212
- const stencil = (win.stencil = win.stencil || {});
213
- const originalInspect = stencil.inspect;
214
- stencil.inspect = (ref) => {
215
- let result = inspect(ref);
216
- if (!result && typeof originalInspect === 'function') {
217
- result = originalInspect(ref);
218
- }
219
- return result;
220
- };
221
- }
585
+ /**
586
+ * Helper function to create & dispatch a custom Event on a provided target
587
+ * @param elm the target of the Event
588
+ * @param name the name to give the custom Event
589
+ * @param opts options for configuring a custom Event
590
+ * @returns the custom Event
591
+ */
592
+ const emitEvent = (elm, name, opts) => {
593
+ const ev = plt.ce(name, opts);
594
+ elm.dispatchEvent(ev);
595
+ return ev;
222
596
  };
223
- const rootAppliedStyles = new WeakMap();
597
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
224
598
  const registerStyle = (scopeId, cssText, allowCS) => {
225
599
  let style = styles.get(scopeId);
226
600
  if (supportsConstructableStylesheets && allowCS) {
@@ -245,7 +619,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
245
619
  }
246
620
  // if an element is NOT connected then getRootNode() will return the wrong root node
247
621
  // so the fallback is to always use the document for the root node in those cases
248
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
622
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
249
623
  if (style) {
250
624
  if (typeof style === 'string') {
251
625
  styleContainerNode = styleContainerNode.head || styleContainerNode;
@@ -263,7 +637,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
263
637
  }
264
638
  else {
265
639
  if (BUILD.cssVarShim && plt.$cssShim$) {
266
- styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
640
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
267
641
  const newScopeId = styleElm['s-sc'];
268
642
  if (newScopeId) {
269
643
  scopeId = newScopeId;
@@ -299,7 +673,7 @@ const attachStyles = (hostRef) => {
299
673
  const flags = cmpMeta.$flags$;
300
674
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
301
675
  const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
302
- if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* needsScopedEncapsulation */) {
676
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
303
677
  // only required when we're NOT using native shadow dom (slot)
304
678
  // or this browser doesn't support native shadow dom
305
679
  // and this host element was NOT created with SSR
@@ -309,198 +683,14 @@ const attachStyles = (hostRef) => {
309
683
  // DOM WRITE!!
310
684
  elm['s-sc'] = scopeId;
311
685
  elm.classList.add(scopeId + '-h');
312
- if (BUILD.scoped && flags & 2 /* scopedCssEncapsulation */) {
686
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
313
687
  elm.classList.add(scopeId + '-s');
314
688
  }
315
689
  }
316
690
  endAttachStyles();
317
691
  };
318
- const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
692
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
319
693
  const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
320
- // Private
321
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
322
- // Public
323
- const setMode = (handler) => modeResolutionChain.push(handler);
324
- const getMode = (ref) => getHostRef(ref).$modeName$;
325
- /**
326
- * Default style mode id
327
- */
328
- /**
329
- * Reusable empty obj/array
330
- * Don't add values to these!!
331
- */
332
- const EMPTY_OBJ = {};
333
- /**
334
- * Namespaces
335
- */
336
- const SVG_NS = 'http://www.w3.org/2000/svg';
337
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
338
- const isDef = (v) => v != null;
339
- const isComplexType = (o) => {
340
- // https://jsperf.com/typeof-fn-object/5
341
- o = typeof o;
342
- return o === 'object' || o === 'function';
343
- };
344
- /**
345
- * Production h() function based on Preact by
346
- * Jason Miller (@developit)
347
- * Licensed under the MIT License
348
- * https://github.com/developit/preact/blob/master/LICENSE
349
- *
350
- * Modified for Stencil's compiler and vdom
351
- */
352
- // const stack: any[] = [];
353
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
354
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
355
- const h = (nodeName, vnodeData, ...children) => {
356
- let child = null;
357
- let key = null;
358
- let slotName = null;
359
- let simple = false;
360
- let lastSimple = false;
361
- const vNodeChildren = [];
362
- const walk = (c) => {
363
- for (let i = 0; i < c.length; i++) {
364
- child = c[i];
365
- if (Array.isArray(child)) {
366
- walk(child);
367
- }
368
- else if (child != null && typeof child !== 'boolean') {
369
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
370
- child = String(child);
371
- }
372
- else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
373
- consoleDevError(`vNode passed as children has unexpected type.
374
- Make sure it's using the correct h() function.
375
- Empty objects can also be the cause, look for JSX comments that became objects.`);
376
- }
377
- if (simple && lastSimple) {
378
- // If the previous child was simple (string), we merge both
379
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
380
- }
381
- else {
382
- // Append a new vNode, if it's text, we create a text vNode
383
- vNodeChildren.push(simple ? newVNode(null, child) : child);
384
- }
385
- lastSimple = simple;
386
- }
387
- }
388
- };
389
- walk(children);
390
- if (vnodeData) {
391
- if (BUILD.isDev && nodeName === 'input') {
392
- validateInputProperties(vnodeData);
393
- }
394
- // normalize class / classname attributes
395
- if (BUILD.vdomKey && vnodeData.key) {
396
- key = vnodeData.key;
397
- }
398
- if (BUILD.slotRelocation && vnodeData.name) {
399
- slotName = vnodeData.name;
400
- }
401
- if (BUILD.vdomClass) {
402
- const classData = vnodeData.className || vnodeData.class;
403
- if (classData) {
404
- vnodeData.class =
405
- typeof classData !== 'object'
406
- ? classData
407
- : Object.keys(classData)
408
- .filter((k) => classData[k])
409
- .join(' ');
410
- }
411
- }
412
- }
413
- if (BUILD.isDev && vNodeChildren.some(isHost)) {
414
- consoleDevError(`The <Host> must be the single root component. Make sure:
415
- - You are NOT using hostData() and <Host> in the same component.
416
- - <Host> is used once, and it's the single root component of the render() function.`);
417
- }
418
- if (BUILD.vdomFunctional && typeof nodeName === 'function') {
419
- // nodeName is a functional component
420
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
421
- }
422
- const vnode = newVNode(nodeName, null);
423
- vnode.$attrs$ = vnodeData;
424
- if (vNodeChildren.length > 0) {
425
- vnode.$children$ = vNodeChildren;
426
- }
427
- if (BUILD.vdomKey) {
428
- vnode.$key$ = key;
429
- }
430
- if (BUILD.slotRelocation) {
431
- vnode.$name$ = slotName;
432
- }
433
- return vnode;
434
- };
435
- const newVNode = (tag, text) => {
436
- const vnode = {
437
- $flags$: 0,
438
- $tag$: tag,
439
- $text$: text,
440
- $elm$: null,
441
- $children$: null,
442
- };
443
- if (BUILD.vdomAttribute) {
444
- vnode.$attrs$ = null;
445
- }
446
- if (BUILD.vdomKey) {
447
- vnode.$key$ = null;
448
- }
449
- if (BUILD.slotRelocation) {
450
- vnode.$name$ = null;
451
- }
452
- return vnode;
453
- };
454
- const Host = {};
455
- const isHost = (node) => node && node.$tag$ === Host;
456
- const vdomFnUtils = {
457
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
458
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
459
- };
460
- const convertToPublic = (node) => ({
461
- vattrs: node.$attrs$,
462
- vchildren: node.$children$,
463
- vkey: node.$key$,
464
- vname: node.$name$,
465
- vtag: node.$tag$,
466
- vtext: node.$text$,
467
- });
468
- const convertToPrivate = (node) => {
469
- if (typeof node.vtag === 'function') {
470
- const vnodeData = Object.assign({}, node.vattrs);
471
- if (node.vkey) {
472
- vnodeData.key = node.vkey;
473
- }
474
- if (node.vname) {
475
- vnodeData.name = node.vname;
476
- }
477
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
478
- }
479
- const vnode = newVNode(node.vtag, node.vtext);
480
- vnode.$attrs$ = node.vattrs;
481
- vnode.$children$ = node.vchildren;
482
- vnode.$key$ = node.vkey;
483
- vnode.$name$ = node.vname;
484
- return vnode;
485
- };
486
- /**
487
- * Validates the ordering of attributes on an input element
488
- * @param inputElm the element to validate
489
- */
490
- const validateInputProperties = (inputElm) => {
491
- const props = Object.keys(inputElm);
492
- const value = props.indexOf('value');
493
- if (value === -1) {
494
- return;
495
- }
496
- const typeIndex = props.indexOf('type');
497
- const minIndex = props.indexOf('min');
498
- const maxIndex = props.indexOf('max');
499
- const stepIndex = props.indexOf('step');
500
- if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
501
- consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
502
- }
503
- };
504
694
  /**
505
695
  * Production setAccessor() function based on Preact by
506
696
  * Jason Miller (@developit)
@@ -638,7 +828,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
638
828
  }
639
829
  }
640
830
  }
641
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
831
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
642
832
  newValue = newValue === true ? '' : newValue;
643
833
  if (BUILD.vdomXlink && xlink) {
644
834
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -656,7 +846,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
656
846
  // if the element passed in is a shadow root, which is a document fragment
657
847
  // then we want to be adding attrs/props to the shadow root's "host" element
658
848
  // if it's not a shadow root, then we add attrs/props to the same element
659
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
849
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
660
850
  ? newVnode.$elm$.host
661
851
  : newVnode.$elm$;
662
852
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -674,6 +864,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
674
864
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
675
865
  }
676
866
  };
867
+ /**
868
+ * Create a DOM Node corresponding to one of the children of a given VNode.
869
+ *
870
+ * @param oldParentVNode the parent VNode from the previous render
871
+ * @param newParentVNode the parent VNode from the current render
872
+ * @param childIndex the index of the VNode, in the _new_ parent node's
873
+ * children, for which we will create a new DOM node
874
+ * @param parentElm the parent DOM node which our new node will be a child of
875
+ * @returns the newly created node
876
+ */
677
877
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
678
878
  // tslint:disable-next-line: prefer-const
679
879
  const newVNode = newParentVNode.$children$[childIndex];
@@ -691,9 +891,9 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
691
891
  }
692
892
  newVNode.$flags$ |= newVNode.$children$
693
893
  ? // slot element has fallback content
694
- 2 /* isSlotFallback */
894
+ 2 /* VNODE_FLAGS.isSlotFallback */
695
895
  : // slot element does not have fallback content
696
- 1 /* isSlotReference */;
896
+ 1 /* VNODE_FLAGS.isSlotReference */;
697
897
  }
698
898
  }
699
899
  if (BUILD.isDev && newVNode.$elm$) {
@@ -703,7 +903,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
703
903
  // create text node
704
904
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
705
905
  }
706
- else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* isSlotReference */) {
906
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
707
907
  // create a slot reference node
708
908
  elm = newVNode.$elm$ =
709
909
  BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
@@ -714,10 +914,10 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
714
914
  }
715
915
  // create element
716
916
  elm = newVNode.$elm$ = (BUILD.svg
717
- ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
917
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
718
918
  ? 'slot-fb'
719
919
  : newVNode.$tag$)
720
- : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* isSlotFallback */
920
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
721
921
  ? 'slot-fb'
722
922
  : newVNode.$tag$));
723
923
  if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
@@ -756,7 +956,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
756
956
  }
757
957
  if (BUILD.slotRelocation) {
758
958
  elm['s-hn'] = hostTagName;
759
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
959
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
760
960
  // remember the content reference comment
761
961
  elm['s-sr'] = true;
762
962
  // remember the content reference comment
@@ -775,7 +975,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
775
975
  return elm;
776
976
  };
777
977
  const putBackInOriginalLocation = (parentElm, recursive) => {
778
- plt.$flags$ |= 1 /* isTmpDisconnected */;
978
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
779
979
  const oldSlotChildNodes = parentElm.childNodes;
780
980
  for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
781
981
  const childNode = oldSlotChildNodes[i];
@@ -796,7 +996,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
796
996
  putBackInOriginalLocation(childNode, recursive);
797
997
  }
798
998
  }
799
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
999
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
800
1000
  };
801
1001
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
802
1002
  let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
@@ -838,6 +1038,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
838
1038
  }
839
1039
  }
840
1040
  };
1041
+ /**
1042
+ * Reconcile the children of a new VNode with the children of an old VNode by
1043
+ * traversing the two collections of children, identifying nodes that are
1044
+ * conserved or changed, calling out to `patch` to make any necessary
1045
+ * updates to the DOM, and rearranging DOM nodes as needed.
1046
+ *
1047
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
1048
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1049
+ * 'windows' by storing start and end indices and references to the
1050
+ * corresponding array entries. Initially the two 'windows' are basically equal
1051
+ * to the entire array, but we progressively narrow the windows until there are
1052
+ * no children left to update by doing the following:
1053
+ *
1054
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1055
+ * that if we have an initial array like the following we'll end up dealing
1056
+ * only with a window bounded by the highlighted elements:
1057
+ *
1058
+ * [null, null, VNode1 , ... , VNode2, null, null]
1059
+ * ^^^^^^ ^^^^^^
1060
+ *
1061
+ * 2. Check to see if the elements at the head and tail positions are equal
1062
+ * across the windows. This will basically detect elements which haven't
1063
+ * been added, removed, or changed position, i.e. if you had the following
1064
+ * VNode elements (represented as HTML):
1065
+ *
1066
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1067
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1068
+ *
1069
+ * Then when comparing the children of the `<div>` tag we check the equality
1070
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1071
+ * same tag in the same position, we'd be able to avoid completely
1072
+ * re-rendering the subtree under them with a new DOM element and would just
1073
+ * call out to `patch` to handle reconciling their children and so on.
1074
+ *
1075
+ * 3. Check, for both windows, to see if the element at the beginning of the
1076
+ * window corresponds to the element at the end of the other window. This is
1077
+ * a heuristic which will let us identify _some_ situations in which
1078
+ * elements have changed position, for instance it _should_ detect that the
1079
+ * children nodes themselves have not changed but merely moved in the
1080
+ * following example:
1081
+ *
1082
+ * oldVNode: `<div><element-one /><element-two /></div>`
1083
+ * newVNode: `<div><element-two /><element-one /></div>`
1084
+ *
1085
+ * If we find cases like this then we also need to move the concrete DOM
1086
+ * elements corresponding to the moved children to write the re-order to the
1087
+ * DOM.
1088
+ *
1089
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1090
+ * nodes in the old children which have the same key as the first element in
1091
+ * our window on the new children. If we find such a node we handle calling
1092
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1093
+ * what we find.
1094
+ *
1095
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1096
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1097
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1098
+ * reflects the new child VNodes. If, for instance, after our window on the old
1099
+ * children has collapsed we still have more nodes on the new children that
1100
+ * we haven't dealt with yet then we need to add them, or if the new children
1101
+ * collapse but we still have unhandled _old_ children then we need to make
1102
+ * sure the corresponding DOM nodes are removed.
1103
+ *
1104
+ * @param parentElm the node into which the parent VNode is rendered
1105
+ * @param oldCh the old children of the parent node
1106
+ * @param newVNode the new VNode which will replace the parent
1107
+ * @param newCh the new children of the parent node
1108
+ */
841
1109
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
842
1110
  let oldStartIdx = 0;
843
1111
  let newStartIdx = 0;
@@ -853,7 +1121,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
853
1121
  let elmToMove;
854
1122
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
855
1123
  if (oldStartVnode == null) {
856
- // Vnode might have been moved left
1124
+ // VNode might have been moved left
857
1125
  oldStartVnode = oldCh[++oldStartIdx];
858
1126
  }
859
1127
  else if (oldEndVnode == null) {
@@ -866,37 +1134,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
866
1134
  newEndVnode = newCh[--newEndIdx];
867
1135
  }
868
1136
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
1137
+ // if the start nodes are the same then we should patch the new VNode
1138
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1139
+ // indices to reflect that. We don't need to move any DOM Nodes around
1140
+ // since things are matched up in order.
869
1141
  patch(oldStartVnode, newStartVnode);
870
1142
  oldStartVnode = oldCh[++oldStartIdx];
871
1143
  newStartVnode = newCh[++newStartIdx];
872
1144
  }
873
1145
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
1146
+ // likewise, if the end nodes are the same we patch new onto old and
1147
+ // decrement our end indices, and also likewise in this case we don't
1148
+ // need to move any DOM Nodes.
874
1149
  patch(oldEndVnode, newEndVnode);
875
1150
  oldEndVnode = oldCh[--oldEndIdx];
876
1151
  newEndVnode = newCh[--newEndIdx];
877
1152
  }
878
1153
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
879
- // Vnode moved right
1154
+ // case: "Vnode moved right"
1155
+ //
1156
+ // We've found that the last node in our window on the new children is
1157
+ // the same VNode as the _first_ node in our window on the old children
1158
+ // we're dealing with now. Visually, this is the layout of these two
1159
+ // nodes:
1160
+ //
1161
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1162
+ // ^^^^^^^^^^^
1163
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1164
+ // ^^^^^^^^^^^^^
1165
+ //
1166
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1167
+ // and move the DOM element for `oldStartVnode`.
880
1168
  if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
881
1169
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
882
1170
  }
883
1171
  patch(oldStartVnode, newEndVnode);
1172
+ // We need to move the element for `oldStartVnode` into a position which
1173
+ // will be appropriate for `newEndVnode`. For this we can use
1174
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1175
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1176
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1177
+ //
1178
+ // <old-start-node />
1179
+ // <some-intervening-node />
1180
+ // <old-end-node />
1181
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1182
+ // <next-sibling />
1183
+ //
1184
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1185
+ // the node for `oldStartVnode` at the end of the children of
1186
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1187
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1188
+ // append it to the children of the parent element.
884
1189
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
885
1190
  oldStartVnode = oldCh[++oldStartIdx];
886
1191
  newEndVnode = newCh[--newEndIdx];
887
1192
  }
888
1193
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
889
- // Vnode moved left
1194
+ // case: "Vnode moved left"
1195
+ //
1196
+ // We've found that the first node in our window on the new children is
1197
+ // the same VNode as the _last_ node in our window on the old children.
1198
+ // Visually, this is the layout of these two nodes:
1199
+ //
1200
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1201
+ // ^^^^^^^^^^^^^
1202
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1203
+ // ^^^^^^^^^^^
1204
+ //
1205
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1206
+ // (which will handle updating any changed attributes, reconciling their
1207
+ // children etc) but we also need to move the DOM node to which
1208
+ // `oldEndVnode` corresponds.
890
1209
  if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
891
1210
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
892
1211
  }
893
1212
  patch(oldEndVnode, newStartVnode);
1213
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1214
+ // the same node, so since we're here we know that they are not. Thus we
1215
+ // can move the element for `oldEndVnode` _before_ the element for
1216
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1217
+ // future.
894
1218
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
895
1219
  oldEndVnode = oldCh[--oldEndIdx];
896
1220
  newStartVnode = newCh[++newStartIdx];
897
1221
  }
898
1222
  else {
899
- // createKeyToOldIdx
1223
+ // Here we do some checks to match up old and new nodes based on the
1224
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1225
+ // in the JSX for a DOM element in the implementation of a Stencil
1226
+ // component.
1227
+ //
1228
+ // First we check to see if there are any nodes in the array of old
1229
+ // children which have the same key as the first node in the new
1230
+ // children.
900
1231
  idxInOld = -1;
901
1232
  if (BUILD.vdomKey) {
902
1233
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -907,23 +1238,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
907
1238
  }
908
1239
  }
909
1240
  if (BUILD.vdomKey && idxInOld >= 0) {
1241
+ // We found a node in the old children which matches up with the first
1242
+ // node in the new children! So let's deal with that
910
1243
  elmToMove = oldCh[idxInOld];
911
1244
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1245
+ // the tag doesn't match so we'll need a new DOM element
912
1246
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
913
1247
  }
914
1248
  else {
915
1249
  patch(elmToMove, newStartVnode);
1250
+ // invalidate the matching old node so that we won't try to update it
1251
+ // again later on
916
1252
  oldCh[idxInOld] = undefined;
917
1253
  node = elmToMove.$elm$;
918
1254
  }
919
1255
  newStartVnode = newCh[++newStartIdx];
920
1256
  }
921
1257
  else {
922
- // new element
1258
+ // We either didn't find an element in the old children that matches
1259
+ // the key of the first new child OR the build is not using `key`
1260
+ // attributes at all. In either case we need to create a new element
1261
+ // for the new node.
923
1262
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
924
1263
  newStartVnode = newCh[++newStartIdx];
925
1264
  }
926
1265
  if (node) {
1266
+ // if we created a new node then handle inserting it to the DOM
927
1267
  if (BUILD.slotRelocation) {
928
1268
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
929
1269
  }
@@ -934,21 +1274,43 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
934
1274
  }
935
1275
  }
936
1276
  if (oldStartIdx > oldEndIdx) {
1277
+ // we have some more new nodes to add which don't match up with old nodes
937
1278
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
938
1279
  }
939
1280
  else if (BUILD.updatable && newStartIdx > newEndIdx) {
1281
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1282
+ // in the new array, so lets remove them (which entails cleaning up the
1283
+ // relevant DOM nodes)
940
1284
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
941
1285
  }
942
1286
  };
943
- const isSameVnode = (vnode1, vnode2) => {
1287
+ /**
1288
+ * Compare two VNodes to determine if they are the same
1289
+ *
1290
+ * **NB**: This function is an equality _heuristic_ based on the available
1291
+ * information set on the two VNodes and can be misleading under certain
1292
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1293
+ * (available under `$key$` on VNodes) then the function falls back on merely
1294
+ * checking that they have the same tag.
1295
+ *
1296
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1297
+ * changing order within a `children` array or something along those lines then
1298
+ * we could obtain a false positive and then have to do needless re-rendering.
1299
+ *
1300
+ * @param leftVNode the first VNode to check
1301
+ * @param rightVNode the second VNode to check
1302
+ * @returns whether they're equal or not
1303
+ */
1304
+ const isSameVnode = (leftVNode, rightVNode) => {
944
1305
  // compare if two vnode to see if they're "technically" the same
945
1306
  // need to have the same element tag, and same key to be the same
946
- if (vnode1.$tag$ === vnode2.$tag$) {
947
- if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
948
- return vnode1.$name$ === vnode2.$name$;
1307
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1308
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1309
+ return leftVNode.$name$ === rightVNode.$name$;
949
1310
  }
1311
+ // this will be set if components in the build have `key` attrs set on them
950
1312
  if (BUILD.vdomKey) {
951
- return vnode1.$key$ === vnode2.$key$;
1313
+ return leftVNode.$key$ === rightVNode.$key$;
952
1314
  }
953
1315
  return true;
954
1316
  }
@@ -962,6 +1324,14 @@ const referenceNode = (node) => {
962
1324
  return (node && node['s-ol']) || node;
963
1325
  };
964
1326
  const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1327
+ /**
1328
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1329
+ * it. This function handles flushing updates to the DOM and reconciling the
1330
+ * children of the two nodes (if any).
1331
+ *
1332
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1333
+ * @param newVNode a new VNode representing an updated version of the old one
1334
+ */
965
1335
  const patch = (oldVNode, newVNode) => {
966
1336
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
967
1337
  const oldChildren = oldVNode.$children$;
@@ -975,7 +1345,6 @@ const patch = (oldVNode, newVNode) => {
975
1345
  // only add this to the when the compiler sees we're using an svg somewhere
976
1346
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
977
1347
  }
978
- // element node
979
1348
  if (BUILD.vdomAttribute || BUILD.reflect) {
980
1349
  if (BUILD.slot && tag === 'slot')
981
1350
  ;
@@ -988,6 +1357,7 @@ const patch = (oldVNode, newVNode) => {
988
1357
  }
989
1358
  if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
990
1359
  // looks like there's child vnodes for both the old and new vnodes
1360
+ // so we need to call `updateChildren` to reconcile them
991
1361
  updateChildren(elm, oldChildren, newVNode, newChildren);
992
1362
  }
993
1363
  else if (newChildren !== null) {
@@ -1028,7 +1398,7 @@ const updateFallbackSlotVisibility = (elm) => {
1028
1398
  let nodeType;
1029
1399
  for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1030
1400
  childNode = childNodes[i];
1031
- if (childNode.nodeType === 1 /* ElementNode */) {
1401
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1032
1402
  if (childNode['s-sr']) {
1033
1403
  // this is a slot fallback node
1034
1404
  // get the slot name for this slot reference node
@@ -1040,7 +1410,7 @@ const updateFallbackSlotVisibility = (elm) => {
1040
1410
  nodeType = childNodes[j].nodeType;
1041
1411
  if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1042
1412
  // this sibling node is from a different component OR is a named fallback slot node
1043
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1413
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1044
1414
  childNode.hidden = true;
1045
1415
  break;
1046
1416
  }
@@ -1049,8 +1419,8 @@ const updateFallbackSlotVisibility = (elm) => {
1049
1419
  // this is a default fallback slot node
1050
1420
  // any element or text node (with content)
1051
1421
  // should hide the default fallback slot node
1052
- if (nodeType === 1 /* ElementNode */ ||
1053
- (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1422
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1423
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1054
1424
  childNode.hidden = true;
1055
1425
  break;
1056
1426
  }
@@ -1128,13 +1498,13 @@ const relocateSlotContent = (elm) => {
1128
1498
  }
1129
1499
  }
1130
1500
  }
1131
- if (childNode.nodeType === 1 /* ElementNode */) {
1501
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1132
1502
  relocateSlotContent(childNode);
1133
1503
  }
1134
1504
  }
1135
1505
  };
1136
1506
  const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1137
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1507
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1138
1508
  if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1139
1509
  return true;
1140
1510
  }
@@ -1180,7 +1550,7 @@ render() {
1180
1550
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1181
1551
  }
1182
1552
  rootVnode.$tag$ = null;
1183
- rootVnode.$flags$ |= 4 /* isHost */;
1553
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1184
1554
  hostRef.$vnode$ = rootVnode;
1185
1555
  rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1186
1556
  if (BUILD.scoped || BUILD.shadowDom) {
@@ -1188,7 +1558,7 @@ render() {
1188
1558
  }
1189
1559
  if (BUILD.slotRelocation) {
1190
1560
  contentRef = hostElm['s-cr'];
1191
- useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1561
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1192
1562
  // always reset
1193
1563
  checkSlotFallbackVisibility = false;
1194
1564
  }
@@ -1197,7 +1567,7 @@ render() {
1197
1567
  if (BUILD.slotRelocation) {
1198
1568
  // while we're moving nodes around existing nodes, temporarily disable
1199
1569
  // the disconnectCallback from working
1200
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1570
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1201
1571
  if (checkSlotRelocate) {
1202
1572
  relocateSlotContent(rootVnode.$elm$);
1203
1573
  let relocateData;
@@ -1257,7 +1627,7 @@ render() {
1257
1627
  }
1258
1628
  else {
1259
1629
  // this node doesn't have a slot home to go to, so let's hide it
1260
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1630
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1261
1631
  nodeToRelocate.hidden = true;
1262
1632
  }
1263
1633
  }
@@ -1268,7 +1638,7 @@ render() {
1268
1638
  }
1269
1639
  // done moving nodes around
1270
1640
  // allow the disconnect callback to work again
1271
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1641
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1272
1642
  // always reset
1273
1643
  relocateNodes.length = 0;
1274
1644
  }
@@ -1280,35 +1650,6 @@ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-loc
1280
1650
  (nodeToRelocate.localName
1281
1651
  ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1282
1652
  : `[${nodeToRelocate.textContent}]`));
1283
- const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
1284
- const createEvent = (ref, name, flags) => {
1285
- const elm = getElement(ref);
1286
- return {
1287
- emit: (detail) => {
1288
- if (BUILD.isDev && !elm.isConnected) {
1289
- consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
1290
- }
1291
- return emitEvent(elm, name, {
1292
- bubbles: !!(flags & 4 /* Bubbles */),
1293
- composed: !!(flags & 2 /* Composed */),
1294
- cancelable: !!(flags & 1 /* Cancellable */),
1295
- detail,
1296
- });
1297
- },
1298
- };
1299
- };
1300
- /**
1301
- * Helper function to create & dispatch a custom Event on a provided target
1302
- * @param elm the target of the Event
1303
- * @param name the name to give the custom Event
1304
- * @param opts options for configuring a custom Event
1305
- * @returns the custom Event
1306
- */
1307
- const emitEvent = (elm, name, opts) => {
1308
- const ev = plt.ce(name, opts);
1309
- elm.dispatchEvent(ev);
1310
- return ev;
1311
- };
1312
1653
  const attachToAncestor = (hostRef, ancestorComponent) => {
1313
1654
  if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1314
1655
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -1316,10 +1657,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
1316
1657
  };
1317
1658
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1318
1659
  if (BUILD.taskQueue && BUILD.updatable) {
1319
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1660
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1320
1661
  }
1321
- if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1322
- hostRef.$flags$ |= 512 /* needsRerender */;
1662
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1663
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1323
1664
  return;
1324
1665
  }
1325
1666
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -1336,7 +1677,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
1336
1677
  let promise;
1337
1678
  if (isInitialLoad) {
1338
1679
  if (BUILD.lazyLoad && BUILD.hostListener) {
1339
- hostRef.$flags$ |= 256 /* isListenReady */;
1680
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1340
1681
  if (hostRef.$queuedListeners$) {
1341
1682
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1342
1683
  hostRef.$queuedListeners$ = null;
@@ -1371,7 +1712,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1371
1712
  }
1372
1713
  const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1373
1714
  if (BUILD.isDev) {
1374
- hostRef.$flags$ |= 1024 /* devOnRender */;
1715
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1375
1716
  }
1376
1717
  if (BUILD.hydrateServerSide) {
1377
1718
  await callRender(hostRef, instance, elm);
@@ -1384,7 +1725,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1384
1725
  }
1385
1726
  if (BUILD.isDev) {
1386
1727
  hostRef.$renderCount$++;
1387
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1728
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1388
1729
  }
1389
1730
  if (BUILD.hydrateServerSide) {
1390
1731
  try {
@@ -1392,10 +1733,10 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1392
1733
  serverSideConnected(elm);
1393
1734
  if (isInitialLoad) {
1394
1735
  // using only during server-side hydrate
1395
- if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
1736
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1396
1737
  elm['s-en'] = '';
1397
1738
  }
1398
- else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
1739
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1399
1740
  elm['s-en'] = 'c';
1400
1741
  }
1401
1742
  }
@@ -1421,7 +1762,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1421
1762
  }
1422
1763
  else {
1423
1764
  Promise.all(childrenPromises).then(postUpdate);
1424
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1765
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1425
1766
  childrenPromises.length = 0;
1426
1767
  }
1427
1768
  }
@@ -1441,10 +1782,10 @@ const callRender = (hostRef, instance, elm) => {
1441
1782
  renderingRef = instance;
1442
1783
  instance = allRenderFn ? instance.render() : instance.render && instance.render();
1443
1784
  if (updatable && taskQueue) {
1444
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1785
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1445
1786
  }
1446
1787
  if (updatable || lazyLoad) {
1447
- hostRef.$flags$ |= 2 /* hasRendered */;
1788
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1448
1789
  }
1449
1790
  if (BUILD.hasRenderFn || BUILD.reflect) {
1450
1791
  if (BUILD.vdomRender || BUILD.reflect) {
@@ -1478,27 +1819,27 @@ const postUpdateComponent = (hostRef) => {
1478
1819
  const ancestorComponent = hostRef.$ancestorComponent$;
1479
1820
  if (BUILD.cmpDidRender) {
1480
1821
  if (BUILD.isDev) {
1481
- hostRef.$flags$ |= 1024 /* devOnRender */;
1822
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1482
1823
  }
1483
1824
  safeCall(instance, 'componentDidRender');
1484
1825
  if (BUILD.isDev) {
1485
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1826
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1486
1827
  }
1487
1828
  }
1488
1829
  emitLifecycleEvent(elm, 'componentDidRender');
1489
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1490
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1830
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1831
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1491
1832
  if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1492
1833
  // DOM WRITE!
1493
1834
  addHydratedFlag(elm);
1494
1835
  }
1495
1836
  if (BUILD.cmpDidLoad) {
1496
1837
  if (BUILD.isDev) {
1497
- hostRef.$flags$ |= 2048 /* devOnDidLoad */;
1838
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1498
1839
  }
1499
1840
  safeCall(instance, 'componentDidLoad');
1500
1841
  if (BUILD.isDev) {
1501
- hostRef.$flags$ &= ~2048 /* devOnDidLoad */;
1842
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1502
1843
  }
1503
1844
  }
1504
1845
  emitLifecycleEvent(elm, 'componentDidLoad');
@@ -1517,11 +1858,11 @@ const postUpdateComponent = (hostRef) => {
1517
1858
  // componentDidUpdate runs AFTER render() has been called
1518
1859
  // and all child components have finished updating
1519
1860
  if (BUILD.isDev) {
1520
- hostRef.$flags$ |= 1024 /* devOnRender */;
1861
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1521
1862
  }
1522
1863
  safeCall(instance, 'componentDidUpdate');
1523
1864
  if (BUILD.isDev) {
1524
- hostRef.$flags$ &= ~1024 /* devOnRender */;
1865
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1525
1866
  }
1526
1867
  }
1527
1868
  emitLifecycleEvent(elm, 'componentDidUpdate');
@@ -1540,10 +1881,10 @@ const postUpdateComponent = (hostRef) => {
1540
1881
  hostRef.$onRenderResolve$();
1541
1882
  hostRef.$onRenderResolve$ = undefined;
1542
1883
  }
1543
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1884
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1544
1885
  nextTick(() => scheduleUpdate(hostRef, false));
1545
1886
  }
1546
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1887
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1547
1888
  }
1548
1889
  // ( •_•)
1549
1890
  // ( •_•)>⌐■-■
@@ -1554,7 +1895,7 @@ const forceUpdate = (ref) => {
1554
1895
  const hostRef = getHostRef(ref);
1555
1896
  const isConnected = hostRef.$hostElement$.isConnected;
1556
1897
  if (isConnected &&
1557
- (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1898
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1558
1899
  scheduleUpdate(hostRef, false);
1559
1900
  }
1560
1901
  // Returns "true" when the forced update was successfully scheduled
@@ -1562,313 +1903,61 @@ const forceUpdate = (ref) => {
1562
1903
  }
1563
1904
  return false;
1564
1905
  };
1565
- const appDidLoad = (who) => {
1566
- // on appload
1567
- // we have finish the first big initial render
1568
- if (BUILD.cssAnnotations) {
1569
- addHydratedFlag(doc.documentElement);
1570
- }
1571
- if (BUILD.asyncQueue) {
1572
- plt.$flags$ |= 2 /* appLoaded */;
1573
- }
1574
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1575
- if (BUILD.profile && performance.measure) {
1576
- performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1577
- }
1578
- };
1579
- const safeCall = (instance, method, arg) => {
1580
- if (instance && instance[method]) {
1581
- try {
1582
- return instance[method](arg);
1583
- }
1584
- catch (e) {
1585
- consoleError(e);
1586
- }
1587
- }
1588
- return undefined;
1589
- };
1590
- const then = (promise, thenFn) => {
1591
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1592
- };
1593
- const emitLifecycleEvent = (elm, lifecycleName) => {
1594
- if (BUILD.lifecycleDOMEvents) {
1595
- emitEvent(elm, 'stencil_' + lifecycleName, {
1596
- bubbles: true,
1597
- composed: true,
1598
- detail: {
1599
- namespace: NAMESPACE,
1600
- },
1601
- });
1602
- }
1603
- };
1604
- const addHydratedFlag = (elm) => BUILD.hydratedClass
1605
- ? elm.classList.add('hydrated')
1606
- : BUILD.hydratedAttribute
1607
- ? elm.setAttribute('hydrated', '')
1608
- : undefined;
1609
- const serverSideConnected = (elm) => {
1610
- const children = elm.children;
1611
- if (children != null) {
1612
- for (let i = 0, ii = children.length; i < ii; i++) {
1613
- const childElm = children[i];
1614
- if (typeof childElm.connectedCallback === 'function') {
1615
- childElm.connectedCallback();
1616
- }
1617
- serverSideConnected(childElm);
1618
- }
1619
- }
1620
- };
1621
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
1622
- const endHydrate = createTime('hydrateClient', tagName);
1623
- const shadowRoot = hostElm.shadowRoot;
1624
- const childRenderNodes = [];
1625
- const slotNodes = [];
1626
- const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
1627
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
1628
- if (!plt.$orgLocNodes$) {
1629
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
1630
- }
1631
- hostElm[HYDRATE_ID] = hostId;
1632
- hostElm.removeAttribute(HYDRATE_ID);
1633
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
1634
- childRenderNodes.map((c) => {
1635
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
1636
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
1637
- const node = c.$elm$;
1638
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
1639
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
1640
- }
1641
- if (!shadowRoot) {
1642
- node['s-hn'] = tagName;
1643
- if (orgLocationNode) {
1644
- node['s-ol'] = orgLocationNode;
1645
- node['s-ol']['s-nr'] = node;
1646
- }
1647
- }
1648
- plt.$orgLocNodes$.delete(orgLocationId);
1649
- });
1650
- if (BUILD.shadowDom && shadowRoot) {
1651
- shadowRootNodes.map((shadowRootNode) => {
1652
- if (shadowRootNode) {
1653
- shadowRoot.appendChild(shadowRootNode);
1654
- }
1655
- });
1656
- }
1657
- endHydrate();
1658
- };
1659
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
1660
- let childNodeType;
1661
- let childIdSplt;
1662
- let childVNode;
1663
- let i;
1664
- if (node.nodeType === 1 /* ElementNode */) {
1665
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
1666
- if (childNodeType) {
1667
- // got the node data from the element's attribute
1668
- // `${hostId}.${nodeId}.${depth}.${index}`
1669
- childIdSplt = childNodeType.split('.');
1670
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
1671
- childVNode = {
1672
- $flags$: 0,
1673
- $hostId$: childIdSplt[0],
1674
- $nodeId$: childIdSplt[1],
1675
- $depth$: childIdSplt[2],
1676
- $index$: childIdSplt[3],
1677
- $tag$: node.tagName.toLowerCase(),
1678
- $elm$: node,
1679
- $attrs$: null,
1680
- $children$: null,
1681
- $key$: null,
1682
- $name$: null,
1683
- $text$: null,
1684
- };
1685
- childRenderNodes.push(childVNode);
1686
- node.removeAttribute(HYDRATE_CHILD_ID);
1687
- // this is a new child vnode
1688
- // so ensure its parent vnode has the vchildren array
1689
- if (!parentVNode.$children$) {
1690
- parentVNode.$children$ = [];
1691
- }
1692
- // add our child vnode to a specific index of the vnode's children
1693
- parentVNode.$children$[childVNode.$index$] = childVNode;
1694
- // this is now the new parent vnode for all the next child checks
1695
- parentVNode = childVNode;
1696
- if (shadowRootNodes && childVNode.$depth$ === '0') {
1697
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1698
- }
1699
- }
1700
- }
1701
- // recursively drill down, end to start so we can remove nodes
1702
- for (i = node.childNodes.length - 1; i >= 0; i--) {
1703
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
1704
- }
1705
- if (node.shadowRoot) {
1706
- // keep drilling down through the shadow root nodes
1707
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
1708
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
1709
- }
1710
- }
1711
- }
1712
- else if (node.nodeType === 8 /* CommentNode */) {
1713
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
1714
- childIdSplt = node.nodeValue.split('.');
1715
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
1716
- // comment node for either the host id or a 0 host id
1717
- childNodeType = childIdSplt[0];
1718
- childVNode = {
1719
- $flags$: 0,
1720
- $hostId$: childIdSplt[1],
1721
- $nodeId$: childIdSplt[2],
1722
- $depth$: childIdSplt[3],
1723
- $index$: childIdSplt[4],
1724
- $elm$: node,
1725
- $attrs$: null,
1726
- $children$: null,
1727
- $key$: null,
1728
- $name$: null,
1729
- $tag$: null,
1730
- $text$: null,
1731
- };
1732
- if (childNodeType === TEXT_NODE_ID) {
1733
- childVNode.$elm$ = node.nextSibling;
1734
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
1735
- childVNode.$text$ = childVNode.$elm$.textContent;
1736
- childRenderNodes.push(childVNode);
1737
- // remove the text comment since it's no longer needed
1738
- node.remove();
1739
- if (!parentVNode.$children$) {
1740
- parentVNode.$children$ = [];
1741
- }
1742
- parentVNode.$children$[childVNode.$index$] = childVNode;
1743
- if (shadowRootNodes && childVNode.$depth$ === '0') {
1744
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1745
- }
1746
- }
1747
- }
1748
- else if (childVNode.$hostId$ === hostId) {
1749
- // this comment node is specifcally for this host id
1750
- if (childNodeType === SLOT_NODE_ID) {
1751
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
1752
- childVNode.$tag$ = 'slot';
1753
- if (childIdSplt[5]) {
1754
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
1755
- }
1756
- else {
1757
- node['s-sn'] = '';
1758
- }
1759
- node['s-sr'] = true;
1760
- if (BUILD.shadowDom && shadowRootNodes) {
1761
- // browser support shadowRoot and this is a shadow dom component
1762
- // create an actual slot element
1763
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
1764
- if (childVNode.$name$) {
1765
- // add the slot name attribute
1766
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
1767
- }
1768
- // insert the new slot element before the slot comment
1769
- node.parentNode.insertBefore(childVNode.$elm$, node);
1770
- // remove the slot comment since it's not needed for shadow
1771
- node.remove();
1772
- if (childVNode.$depth$ === '0') {
1773
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
1774
- }
1775
- }
1776
- slotNodes.push(childVNode);
1777
- if (!parentVNode.$children$) {
1778
- parentVNode.$children$ = [];
1779
- }
1780
- parentVNode.$children$[childVNode.$index$] = childVNode;
1781
- }
1782
- else if (childNodeType === CONTENT_REF_ID) {
1783
- // `${CONTENT_REF_ID}.${hostId}`;
1784
- if (BUILD.shadowDom && shadowRootNodes) {
1785
- // remove the content ref comment since it's not needed for shadow
1786
- node.remove();
1787
- }
1788
- else if (BUILD.slotRelocation) {
1789
- hostElm['s-cr'] = node;
1790
- node['s-cn'] = true;
1791
- }
1792
- }
1793
- }
1794
- }
1906
+ const appDidLoad = (who) => {
1907
+ // on appload
1908
+ // we have finish the first big initial render
1909
+ if (BUILD.cssAnnotations) {
1910
+ addHydratedFlag(doc.documentElement);
1795
1911
  }
1796
- else if (parentVNode && parentVNode.$tag$ === 'style') {
1797
- const vnode = newVNode(null, node.textContent);
1798
- vnode.$elm$ = node;
1799
- vnode.$index$ = '0';
1800
- parentVNode.$children$ = [vnode];
1912
+ if (BUILD.asyncQueue) {
1913
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
1914
+ }
1915
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1916
+ if (BUILD.profile && performance.measure) {
1917
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1801
1918
  }
1802
1919
  };
1803
- const initializeDocumentHydrate = (node, orgLocNodes) => {
1804
- if (node.nodeType === 1 /* ElementNode */) {
1805
- let i = 0;
1806
- for (; i < node.childNodes.length; i++) {
1807
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
1920
+ const safeCall = (instance, method, arg) => {
1921
+ if (instance && instance[method]) {
1922
+ try {
1923
+ return instance[method](arg);
1808
1924
  }
1809
- if (node.shadowRoot) {
1810
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
1811
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
1812
- }
1925
+ catch (e) {
1926
+ consoleError(e);
1813
1927
  }
1814
1928
  }
1815
- else if (node.nodeType === 8 /* CommentNode */) {
1816
- const childIdSplt = node.nodeValue.split('.');
1817
- if (childIdSplt[0] === ORG_LOCATION_ID) {
1818
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
1819
- node.nodeValue = '';
1820
- // useful to know if the original location is
1821
- // the root light-dom of a shadow dom component
1822
- node['s-en'] = childIdSplt[3];
1823
- }
1929
+ return undefined;
1930
+ };
1931
+ const then = (promise, thenFn) => {
1932
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1933
+ };
1934
+ const emitLifecycleEvent = (elm, lifecycleName) => {
1935
+ if (BUILD.lifecycleDOMEvents) {
1936
+ emitEvent(elm, 'stencil_' + lifecycleName, {
1937
+ bubbles: true,
1938
+ composed: true,
1939
+ detail: {
1940
+ namespace: NAMESPACE,
1941
+ },
1942
+ });
1824
1943
  }
1825
1944
  };
1826
- /**
1827
- * Parse a new property value for a given property type.
1828
- *
1829
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1830
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1831
- * 1. `any`, the type given to `propValue` in the function signature
1832
- * 2. the type stored from `propType`.
1833
- *
1834
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1835
- *
1836
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1837
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1838
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1839
- * ```tsx
1840
- * <my-cmp prop-val={0}></my-cmp>
1841
- * ```
1842
- *
1843
- * HTML prop values on the other hand, will always a string
1844
- *
1845
- * @param propValue the new value to coerce to some type
1846
- * @param propType the type of the prop, expressed as a binary number
1847
- * @returns the parsed/coerced value
1848
- */
1849
- const parsePropertyValue = (propValue, propType) => {
1850
- // ensure this value is of the correct prop type
1851
- if (propValue != null && !isComplexType(propValue)) {
1852
- if (BUILD.propBoolean && propType & 4 /* Boolean */) {
1853
- // per the HTML spec, any string value means it is a boolean true value
1854
- // but we'll cheat here and say that the string "false" is the boolean false
1855
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1856
- }
1857
- if (BUILD.propNumber && propType & 2 /* Number */) {
1858
- // force it to be a number
1859
- return parseFloat(propValue);
1860
- }
1861
- if (BUILD.propString && propType & 1 /* String */) {
1862
- // could have been passed as a number or boolean
1863
- // but we still want it as a string
1864
- return String(propValue);
1945
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
1946
+ ? elm.classList.add('hydrated')
1947
+ : BUILD.hydratedAttribute
1948
+ ? elm.setAttribute('hydrated', '')
1949
+ : undefined;
1950
+ const serverSideConnected = (elm) => {
1951
+ const children = elm.children;
1952
+ if (children != null) {
1953
+ for (let i = 0, ii = children.length; i < ii; i++) {
1954
+ const childElm = children[i];
1955
+ if (typeof childElm.connectedCallback === 'function') {
1956
+ childElm.connectedCallback();
1957
+ }
1958
+ serverSideConnected(childElm);
1865
1959
  }
1866
- // redundant return here for better minification
1867
- return propValue;
1868
1960
  }
1869
- // not sure exactly what type we want
1870
- // so no need to change to a different type
1871
- return propValue;
1872
1961
  };
1873
1962
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1874
1963
  const setValue = (ref, propName, newVal, cmpMeta) => {
@@ -1882,21 +1971,21 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1882
1971
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1883
1972
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1884
1973
  const didValueChange = newVal !== oldVal && !areBothNaN;
1885
- if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1974
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1886
1975
  // gadzooks! the property's value has changed!!
1887
1976
  // set our new value!
1888
1977
  hostRef.$instanceValues$.set(propName, newVal);
1889
1978
  if (BUILD.isDev) {
1890
- if (hostRef.$flags$ & 1024 /* devOnRender */) {
1979
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
1891
1980
  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);
1892
1981
  }
1893
- else if (hostRef.$flags$ & 2048 /* devOnDidLoad */) {
1982
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
1894
1983
  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);
1895
1984
  }
1896
1985
  }
1897
1986
  if (!BUILD.lazyLoad || instance) {
1898
1987
  // get an array of method names of watch functions to call
1899
- if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1988
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1900
1989
  const watchMethods = cmpMeta.$watchers$[propName];
1901
1990
  if (watchMethods) {
1902
1991
  // this instance is watching for when this property changed
@@ -1912,7 +2001,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1912
2001
  }
1913
2002
  }
1914
2003
  if (BUILD.updatable &&
1915
- (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
2004
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1916
2005
  if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
1917
2006
  if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1918
2007
  return;
@@ -1927,6 +2016,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1927
2016
  }
1928
2017
  }
1929
2018
  };
2019
+ /**
2020
+ * Attach a series of runtime constructs to a compiled Stencil component
2021
+ * constructor, including getters and setters for the `@Prop` and `@State`
2022
+ * decorators, callbacks for when attributes change, and so on.
2023
+ *
2024
+ * @param Cstr the constructor for a component that we need to process
2025
+ * @param cmpMeta metadata collected previously about the component
2026
+ * @param flags a number used to store a series of bit flags
2027
+ * @returns a reference to the same constructor passed in (but now mutated)
2028
+ */
1930
2029
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1931
2030
  if (BUILD.member && cmpMeta.$members$) {
1932
2031
  if (BUILD.watchCallback && Cstr.watchers) {
@@ -1937,8 +2036,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1937
2036
  const prototype = Cstr.prototype;
1938
2037
  members.map(([memberName, [memberFlags]]) => {
1939
2038
  if ((BUILD.prop || BUILD.state) &&
1940
- (memberFlags & 31 /* Prop */ ||
1941
- ((!BUILD.lazyLoad || flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
2039
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2040
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1942
2041
  // proxyComponent - prop
1943
2042
  Object.defineProperty(prototype, memberName, {
1944
2043
  get() {
@@ -1951,13 +2050,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1951
2050
  const ref = getHostRef(this);
1952
2051
  if (
1953
2052
  // we are proxying the instance (not element)
1954
- (flags & 1 /* isElementConstructor */) === 0 &&
2053
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
1955
2054
  // the element is not constructing
1956
- (ref.$flags$ & 8 /* isConstructingInstance */) === 0 &&
2055
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
1957
2056
  // the member is a prop
1958
- (memberFlags & 31 /* Prop */) !== 0 &&
2057
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
1959
2058
  // the member is not mutable
1960
- (memberFlags & 1024 /* Mutable */) === 0) {
2059
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
1961
2060
  consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
1962
2061
  }
1963
2062
  }
@@ -1970,8 +2069,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1970
2069
  }
1971
2070
  else if (BUILD.lazyLoad &&
1972
2071
  BUILD.method &&
1973
- flags & 1 /* isElementConstructor */ &&
1974
- memberFlags & 64 /* Method */) {
2072
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2073
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1975
2074
  // proxyComponent - method
1976
2075
  Object.defineProperty(prototype, memberName, {
1977
2076
  value(...args) {
@@ -1981,7 +2080,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1981
2080
  });
1982
2081
  }
1983
2082
  });
1984
- if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* isElementConstructor */)) {
2083
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1985
2084
  const attrNameToPropName = new Map();
1986
2085
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1987
2086
  plt.jmp(() => {
@@ -2037,11 +2136,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
2037
2136
  // create an array of attributes to observe
2038
2137
  // and also create a map of html attribute name to js property name
2039
2138
  Cstr.observedAttributes = members
2040
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
2139
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
2041
2140
  .map(([propName, m]) => {
2042
2141
  const attrName = m[1] || propName;
2043
2142
  attrNameToPropName.set(attrName, propName);
2044
- if (BUILD.reflect && m[0] & 512 /* ReflectAttr */) {
2143
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2045
2144
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
2046
2145
  }
2047
2146
  return attrName;
@@ -2053,10 +2152,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
2053
2152
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2054
2153
  // initializeComponent
2055
2154
  if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2056
- (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
2155
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2057
2156
  if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2058
2157
  // we haven't initialized this element yet
2059
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2158
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2060
2159
  // lazy loaded components
2061
2160
  // request the component's implementation to be
2062
2161
  // wired up with the host element
@@ -2077,7 +2176,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2077
2176
  if (BUILD.watchCallback) {
2078
2177
  cmpMeta.$watchers$ = Cstr.watchers;
2079
2178
  }
2080
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
2179
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2081
2180
  Cstr.isProxied = true;
2082
2181
  }
2083
2182
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -2085,7 +2184,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2085
2184
  // but let's keep track of when we start and stop
2086
2185
  // so that the getters/setters don't incorrectly step on data
2087
2186
  if (BUILD.member) {
2088
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
2187
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2089
2188
  }
2090
2189
  // construct the lazy-loaded component implementation
2091
2190
  // passing the hostRef is very important during
@@ -2098,10 +2197,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2098
2197
  consoleError(e);
2099
2198
  }
2100
2199
  if (BUILD.member) {
2101
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
2200
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2102
2201
  }
2103
2202
  if (BUILD.watchCallback) {
2104
- hostRef.$flags$ |= 128 /* isWatchReady */;
2203
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2105
2204
  }
2106
2205
  endNewInstance();
2107
2206
  fireConnectedCallback(hostRef.$lazyInstance$);
@@ -2109,11 +2208,11 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2109
2208
  else {
2110
2209
  // sync constructor component
2111
2210
  Cstr = elm.constructor;
2112
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
2211
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2113
2212
  // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2114
2213
  // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2115
2214
  // Stencil has completed instantiating the component.
2116
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* isWatchReady */));
2215
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2117
2216
  }
2118
2217
  if (BUILD.style && Cstr.style) {
2119
2218
  // this component has styles but we haven't registered them yet
@@ -2130,10 +2229,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
2130
2229
  if (!BUILD.hydrateServerSide &&
2131
2230
  BUILD.shadowDom &&
2132
2231
  BUILD.shadowDomShim &&
2133
- cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2232
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2134
2233
  style = await import('./shadow-css.js').then((m) => m.scopeCss(style, scopeId, false));
2135
2234
  }
2136
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
2235
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2137
2236
  endRegisterStyles();
2138
2237
  }
2139
2238
  }
@@ -2160,7 +2259,7 @@ const fireConnectedCallback = (instance) => {
2160
2259
  }
2161
2260
  };
2162
2261
  const connectedCallback = (elm) => {
2163
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2262
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2164
2263
  const hostRef = getHostRef(elm);
2165
2264
  const cmpMeta = hostRef.$cmpMeta$;
2166
2265
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
@@ -2168,14 +2267,14 @@ const connectedCallback = (elm) => {
2168
2267
  // only run if we have listeners being attached to a parent
2169
2268
  addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2170
2269
  }
2171
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
2270
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2172
2271
  // first time this component has connected
2173
- hostRef.$flags$ |= 1 /* hasConnected */;
2272
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2174
2273
  let hostId;
2175
2274
  if (BUILD.hydrateClientSide) {
2176
2275
  hostId = elm.getAttribute(HYDRATE_ID);
2177
2276
  if (hostId) {
2178
- if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2277
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2179
2278
  const scopeId = BUILD.mode
2180
2279
  ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2181
2280
  : addStyle(elm.shadowRoot, cmpMeta);
@@ -2191,7 +2290,7 @@ const connectedCallback = (elm) => {
2191
2290
  // host element has been connected to the DOM
2192
2291
  if (BUILD.hydrateServerSide ||
2193
2292
  ((BUILD.slot || BUILD.shadowDom) &&
2194
- cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
2293
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2195
2294
  setContentReference(elm);
2196
2295
  }
2197
2296
  }
@@ -2203,7 +2302,7 @@ const connectedCallback = (elm) => {
2203
2302
  // climb up the ancestors looking for the first
2204
2303
  // component that hasn't finished its lifecycle update yet
2205
2304
  if ((BUILD.hydrateClientSide &&
2206
- ancestorComponent.nodeType === 1 /* ElementNode */ &&
2305
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2207
2306
  ancestorComponent.hasAttribute('s-id') &&
2208
2307
  ancestorComponent['s-p']) ||
2209
2308
  ancestorComponent['s-p']) {
@@ -2218,7 +2317,7 @@ const connectedCallback = (elm) => {
2218
2317
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2219
2318
  if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2220
2319
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2221
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
2320
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2222
2321
  const value = elm[memberName];
2223
2322
  delete elm[memberName];
2224
2323
  elm[memberName] = value;
@@ -2259,7 +2358,7 @@ const setContentReference = (elm) => {
2259
2358
  elm.insertBefore(contentRefElm, elm.firstChild);
2260
2359
  };
2261
2360
  const disconnectedCallback = (elm) => {
2262
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
2361
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2263
2362
  const hostRef = getHostRef(elm);
2264
2363
  const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2265
2364
  if (BUILD.hostListener) {
@@ -2300,8 +2399,8 @@ const proxyCustomElement = (Cstr, compactMeta) => {
2300
2399
  if (BUILD.reflect) {
2301
2400
  cmpMeta.$attrsToReflect$ = [];
2302
2401
  }
2303
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2304
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2402
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2403
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2305
2404
  }
2306
2405
  const originalConnectedCallback = Cstr.prototype.connectedCallback;
2307
2406
  const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
@@ -2326,7 +2425,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
2326
2425
  if (BUILD.shadowDelegatesFocus) {
2327
2426
  this.attachShadow({
2328
2427
  mode: 'open',
2329
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2428
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2330
2429
  });
2331
2430
  }
2332
2431
  else {
@@ -2339,7 +2438,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
2339
2438
  },
2340
2439
  });
2341
2440
  Cstr.is = cmpMeta.$tagName$;
2342
- return proxyComponent(Cstr, cmpMeta, 1 /* isElementConstructor */ | 2 /* proxyState */);
2441
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2343
2442
  };
2344
2443
  const forceModeUpdate = (elm) => {
2345
2444
  if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
@@ -2353,7 +2452,7 @@ const forceModeUpdate = (elm) => {
2353
2452
  const flags = cmpMeta.$flags$;
2354
2453
  if (style) {
2355
2454
  if (!styles.has(scopeId)) {
2356
- registerStyle(scopeId, style, !!(flags & 1 /* shadowDomEncapsulation */));
2455
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2357
2456
  }
2358
2457
  hostRef.$modeName$ = mode;
2359
2458
  elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
@@ -2363,23 +2462,6 @@ const forceModeUpdate = (elm) => {
2363
2462
  }
2364
2463
  }
2365
2464
  };
2366
- const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2367
- // ¯\_(ツ)_/¯
2368
- const hostRef = getHostRef(elm);
2369
- // reset state flags to only have been connected
2370
- hostRef.$flags$ = 1 /* hasConnected */;
2371
- // TODO
2372
- // detatch any event listeners that may have been added
2373
- // because we're not passing an exact event name it'll
2374
- // remove all of this element's event, which is good
2375
- // create a callback for when this component finishes hmr
2376
- elm['s-hmr-load'] = () => {
2377
- // finished hmr for this element
2378
- delete elm['s-hmr-load'];
2379
- };
2380
- // re-initialize the component
2381
- initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2382
- };
2383
2465
  const patchCloneNode = (HostElementPrototype) => {
2384
2466
  const orgCloneNode = HostElementPrototype.cloneNode;
2385
2467
  HostElementPrototype.cloneNode = function (deep) {
@@ -2442,7 +2524,7 @@ const patchSlotAppendChild = (HostElementPrototype) => {
2442
2524
  * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2443
2525
  */
2444
2526
  const patchTextContent = (hostElementPrototype, cmpMeta) => {
2445
- if (BUILD.scoped && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
2527
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2446
2528
  const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2447
2529
  Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2448
2530
  Object.defineProperty(hostElementPrototype, 'textContent', {
@@ -2453,7 +2535,7 @@ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2453
2535
  const slotNode = getHostSlotNode(this.childNodes, '');
2454
2536
  // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2455
2537
  // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2456
- if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2538
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2457
2539
  return slotNode.nextSibling.textContent;
2458
2540
  }
2459
2541
  else if (slotNode) {
@@ -2472,7 +2554,7 @@ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2472
2554
  // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2473
2555
  // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2474
2556
  // sibling.
2475
- if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* TEXT_NODE */) {
2557
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2476
2558
  slotNode.nextSibling.textContent = value;
2477
2559
  }
2478
2560
  else if (slotNode) {
@@ -2498,7 +2580,7 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
2498
2580
  return this[n];
2499
2581
  }
2500
2582
  }
2501
- if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
2583
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2502
2584
  const childNodesFn = elm.__lookupGetter__('childNodes');
2503
2585
  Object.defineProperty(elm, 'children', {
2504
2586
  get() {
@@ -2513,8 +2595,8 @@ const patchChildSlotNodes = (elm, cmpMeta) => {
2513
2595
  Object.defineProperty(elm, 'childNodes', {
2514
2596
  get() {
2515
2597
  const childNodes = childNodesFn.call(this);
2516
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 &&
2517
- getHostRef(this).$flags$ & 2 /* hasRendered */) {
2598
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2599
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2518
2600
  const result = new FakeNodeList();
2519
2601
  for (let i = 0; i < childNodes.length; i++) {
2520
2602
  const slot = childNodes[i]['s-nr'];
@@ -2558,6 +2640,23 @@ const getHostSlotChildNodes = (n, slotName) => {
2558
2640
  }
2559
2641
  return childNodes;
2560
2642
  };
2643
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2644
+ // ¯\_(ツ)_/¯
2645
+ const hostRef = getHostRef(elm);
2646
+ // reset state flags to only have been connected
2647
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2648
+ // TODO
2649
+ // detatch any event listeners that may have been added
2650
+ // because we're not passing an exact event name it'll
2651
+ // remove all of this element's event, which is good
2652
+ // create a callback for when this component finishes hmr
2653
+ elm['s-hmr-load'] = () => {
2654
+ // finished hmr for this element
2655
+ delete elm['s-hmr-load'];
2656
+ };
2657
+ // re-initialize the component
2658
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2659
+ };
2561
2660
  const bootstrapLazy = (lazyBundles, options = {}) => {
2562
2661
  if (BUILD.profile && performance.mark) {
2563
2662
  performance.mark('st:app:start');
@@ -2579,13 +2678,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2579
2678
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2580
2679
  if (BUILD.asyncQueue) {
2581
2680
  if (options.syncQueue) {
2582
- plt.$flags$ |= 4 /* queueSync */;
2681
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2583
2682
  }
2584
2683
  }
2585
2684
  if (BUILD.hydrateClientSide) {
2586
2685
  // If the app is already hydrated there is not point to disable the
2587
2686
  // async queue. This will improve the first input delay
2588
- plt.$flags$ |= 2 /* appLoaded */;
2687
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2589
2688
  }
2590
2689
  if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2591
2690
  for (; i < styles.length; i++) {
@@ -2612,8 +2711,8 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2612
2711
  if (BUILD.watchCallback) {
2613
2712
  cmpMeta.$watchers$ = {};
2614
2713
  }
2615
- if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2616
- cmpMeta.$flags$ |= 8 /* needsShadowDomShim */;
2714
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2715
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2617
2716
  }
2618
2717
  const tagName = BUILD.transformTagName && options.transformTagName
2619
2718
  ? options.transformTagName(cmpMeta.$tagName$)
@@ -2625,7 +2724,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2625
2724
  super(self);
2626
2725
  self = this;
2627
2726
  registerHost(self, cmpMeta);
2628
- if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
2727
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2629
2728
  // this component is using shadow dom
2630
2729
  // and this browser supports shadow dom
2631
2730
  // add the read-only property "shadowRoot" to the host element
@@ -2634,7 +2733,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2634
2733
  if (BUILD.shadowDelegatesFocus) {
2635
2734
  self.attachShadow({
2636
2735
  mode: 'open',
2637
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */),
2736
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2638
2737
  });
2639
2738
  }
2640
2739
  else {
@@ -2686,7 +2785,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2686
2785
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
2687
2786
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2688
2787
  cmpTags.push(tagName);
2689
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
2788
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2690
2789
  }
2691
2790
  });
2692
2791
  });
@@ -2711,11 +2810,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
2711
2810
  // Fallback appLoad event
2712
2811
  endBootstrap();
2713
2812
  };
2714
- const getAssetPath = (path) => {
2715
- const assetUrl = new URL(path, plt.$resourcesUrl$);
2716
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
2717
- };
2718
- const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
2719
2813
  const getConnect = (_ref, tagName) => {
2720
2814
  const componentOnReady = () => {
2721
2815
  let elm = doc.querySelector(tagName);
@@ -2765,6 +2859,75 @@ const getContext = (_elm, context) => {
2765
2859
  }
2766
2860
  return undefined;
2767
2861
  };
2862
+ const Fragment = (_, children) => children;
2863
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2864
+ if (BUILD.hostListener && listeners) {
2865
+ // this is called immediately within the element's constructor
2866
+ // initialize our event listeners on the host element
2867
+ // we do this now so that we can listen to events that may
2868
+ // have fired even before the instance is ready
2869
+ if (BUILD.hostListenerTargetParent) {
2870
+ // this component may have event listeners that should be attached to the parent
2871
+ if (attachParentListeners) {
2872
+ // this is being ran from within the connectedCallback
2873
+ // which is important so that we know the host element actually has a parent element
2874
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2875
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
2876
+ }
2877
+ else {
2878
+ // this is being ran from within the component constructor
2879
+ // everything BUT the parent element listeners should be attached at this time
2880
+ // filter out the listeners that are NOT being attached to the parent
2881
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
2882
+ }
2883
+ }
2884
+ listeners.map(([flags, name, method]) => {
2885
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
2886
+ const handler = hostListenerProxy(hostRef, method);
2887
+ const opts = hostListenerOpts(flags);
2888
+ plt.ael(target, name, handler, opts);
2889
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2890
+ });
2891
+ }
2892
+ };
2893
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
2894
+ try {
2895
+ if (BUILD.lazyLoad) {
2896
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2897
+ // instance is ready, let's call it's member method for this event
2898
+ hostRef.$lazyInstance$[methodName](ev);
2899
+ }
2900
+ else {
2901
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2902
+ }
2903
+ }
2904
+ else {
2905
+ hostRef.$hostElement$[methodName](ev);
2906
+ }
2907
+ }
2908
+ catch (e) {
2909
+ consoleError(e);
2910
+ }
2911
+ };
2912
+ const getHostListenerTarget = (elm, flags) => {
2913
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
2914
+ return doc;
2915
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2916
+ return win;
2917
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
2918
+ return doc.body;
2919
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
2920
+ return elm.parentElement;
2921
+ return elm;
2922
+ };
2923
+ // prettier-ignore
2924
+ const hostListenerOpts = (flags) => supportsListenerOptions
2925
+ ? ({
2926
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
2927
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2928
+ })
2929
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2930
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
2768
2931
  const insertVdomAnnotations = (doc, staticComponents) => {
2769
2932
  if (doc != null) {
2770
2933
  const docData = {
@@ -2785,10 +2948,10 @@ const insertVdomAnnotations = (doc, staticComponents) => {
2785
2948
  docData.rootLevelIds++;
2786
2949
  nodeId = docData.rootLevelIds;
2787
2950
  childId = `${hostId}.${nodeId}`;
2788
- if (nodeRef.nodeType === 1 /* ElementNode */) {
2951
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2789
2952
  nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2790
2953
  }
2791
- else if (nodeRef.nodeType === 3 /* TextNode */) {
2954
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
2792
2955
  if (hostId === 0) {
2793
2956
  const textContent = nodeRef.nodeValue.trim();
2794
2957
  if (textContent === '') {
@@ -2830,7 +2993,7 @@ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
2830
2993
  if (node['s-nr'] != null) {
2831
2994
  orgLocationNodes.push(node);
2832
2995
  }
2833
- if (node.nodeType === 1 /* ElementNode */) {
2996
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2834
2997
  node.childNodes.forEach((childNode) => {
2835
2998
  const hostRef = getHostRef(childNode);
2836
2999
  if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
@@ -2860,7 +3023,7 @@ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
2860
3023
  const parent = hostElm.parentElement;
2861
3024
  if (parent && parent.childNodes) {
2862
3025
  const parentChildNodes = Array.from(parent.childNodes);
2863
- const comment = parentChildNodes.find((node) => node.nodeType === 8 /* CommentNode */ && node['s-sr']);
3026
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
2864
3027
  if (comment) {
2865
3028
  const index = parentChildNodes.indexOf(hostElm) - 1;
2866
3029
  vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
@@ -2878,10 +3041,10 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
2878
3041
  const childId = `${hostId}.${nodeId}.${depth}.${index}`;
2879
3042
  childElm['s-host-id'] = hostId;
2880
3043
  childElm['s-node-id'] = nodeId;
2881
- if (childElm.nodeType === 1 /* ElementNode */) {
3044
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2882
3045
  childElm.setAttribute(HYDRATE_CHILD_ID, childId);
2883
3046
  }
2884
- else if (childElm.nodeType === 3 /* TextNode */) {
3047
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
2885
3048
  const parentNode = childElm.parentNode;
2886
3049
  const nodeName = parentNode.nodeName;
2887
3050
  if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
@@ -2890,7 +3053,7 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
2890
3053
  parentNode.insertBefore(commentBeforeTextNode, childElm);
2891
3054
  }
2892
3055
  }
2893
- else if (childElm.nodeType === 8 /* CommentNode */) {
3056
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
2894
3057
  if (childElm['s-sr']) {
2895
3058
  const slotName = childElm['s-sn'] || '';
2896
3059
  const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
@@ -2904,9 +3067,7 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
2904
3067
  });
2905
3068
  }
2906
3069
  };
2907
- const setPlatformOptions = (opts) => Object.assign(plt, opts);
2908
- const Fragment = (_, children) => children;
2909
- const hostRefs = new WeakMap();
3070
+ const hostRefs = /*@__PURE__*/ new WeakMap();
2910
3071
  const getHostRef = (ref) => hostRefs.get(ref);
2911
3072
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2912
3073
  const registerHost = (elm, cmpMeta) => {
@@ -2968,8 +3129,51 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2968
3129
  return importedModule[exportName];
2969
3130
  }, consoleError);
2970
3131
  };
2971
- const styles = new Map();
3132
+ const styles = /*@__PURE__*/ new Map();
2972
3133
  const modeResolutionChain = [];
3134
+ const win = typeof window !== 'undefined' ? window : {};
3135
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
3136
+ const doc = win.document || { head: {} };
3137
+ const H = (win.HTMLElement || class {
3138
+ });
3139
+ const plt = {
3140
+ $flags$: 0,
3141
+ $resourcesUrl$: '',
3142
+ jmp: (h) => h(),
3143
+ raf: (h) => requestAnimationFrame(h),
3144
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3145
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3146
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
3147
+ };
3148
+ const setPlatformHelpers = (helpers) => {
3149
+ Object.assign(plt, helpers);
3150
+ };
3151
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3152
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3153
+ : true;
3154
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3155
+ let supportsListenerOptions = false;
3156
+ try {
3157
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3158
+ get() {
3159
+ supportsListenerOptions = true;
3160
+ },
3161
+ }));
3162
+ }
3163
+ catch (e) { }
3164
+ return supportsListenerOptions;
3165
+ })();
3166
+ const promiseResolve = (v) => Promise.resolve(v);
3167
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3168
+ ? /*@__PURE__*/ (() => {
3169
+ try {
3170
+ new CSSStyleSheet();
3171
+ return typeof new CSSStyleSheet().replaceSync === 'function';
3172
+ }
3173
+ catch (e) { }
3174
+ return false;
3175
+ })()
3176
+ : false;
2973
3177
  const queueDomReads = [];
2974
3178
  const queueDomWrites = [];
2975
3179
  const queueDomWritesLow = [];
@@ -2977,7 +3181,7 @@ const queueTask = (queue, write) => (cb) => {
2977
3181
  queue.push(cb);
2978
3182
  if (!queuePending) {
2979
3183
  queuePending = true;
2980
- if (write && plt.$flags$ & 4 /* queueSync */) {
3184
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2981
3185
  nextTick(flush);
2982
3186
  }
2983
3187
  else {
@@ -3024,7 +3228,7 @@ const flush = () => {
3024
3228
  consume(queueDomReads);
3025
3229
  // DOM WRITES!!!
3026
3230
  if (BUILD.asyncQueue) {
3027
- const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
3231
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3028
3232
  ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3029
3233
  : Infinity;
3030
3234
  consumeTimeout(queueDomWrites, timeout);
@@ -3054,11 +3258,5 @@ const flush = () => {
3054
3258
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3055
3259
  const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3056
3260
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3057
- const Build = {
3058
- isDev: BUILD.isDev ? true : false,
3059
- isBrowser: true,
3060
- isServer: false,
3061
- isTesting: BUILD.isTesting ? true : false,
3062
- };
3063
3261
  export { BUILD, Env, NAMESPACE } from '@stencil/core/internal/app-data';
3064
3262
  export { Build, CSS, Context, Fragment, H, H as HTMLElement, Host, STENCIL_DEV_MODE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, doc, forceModeUpdate, forceUpdate, getAssetPath, getConnect, getContext, getElement, getHostRef, getMode, getRenderingRef, getValue, h, insertVdomAnnotations, isMemberInElement, loadModule, modeResolutionChain, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setPlatformHelpers, setPlatformOptions, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsShadow, win, writeTask };