smoothly 0.3.5 → 0.3.6

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 (103) hide show
  1. package/dist/cjs/{index-3efe2a41.js → index-3fb97927.js} +467 -269
  2. package/dist/cjs/{index-2a011313.js → index-7b75b331.js} +1 -1
  3. package/dist/cjs/index.cjs.js +2 -2
  4. package/dist/cjs/loader.cjs.js +3 -3
  5. package/dist/cjs/smoothly-accordion_53.cjs.entry.js +68 -26
  6. package/dist/cjs/smoothly-google-font.cjs.entry.js +1 -1
  7. package/dist/cjs/smoothly-radio-group.cjs.entry.js +1 -1
  8. package/dist/cjs/smoothly-reorder.cjs.entry.js +1 -1
  9. package/dist/cjs/smoothly-trigger-sink.cjs.entry.js +1 -1
  10. package/dist/cjs/smoothly-trigger-source.cjs.entry.js +1 -1
  11. package/dist/cjs/smoothly.cjs.js +3 -3
  12. package/dist/collection/collection-manifest.json +2 -2
  13. package/dist/collection/components/App.js +38 -46
  14. package/dist/collection/components/accordion/index.js +65 -55
  15. package/dist/collection/components/accordion-item/index.js +133 -131
  16. package/dist/collection/components/app/index.js +37 -32
  17. package/dist/collection/components/app-demo/index.js +39 -68
  18. package/dist/collection/components/backtotop/index.js +73 -66
  19. package/dist/collection/components/button/index.js +144 -141
  20. package/dist/collection/components/calendar/index.js +277 -268
  21. package/dist/collection/components/checkbox/index.js +120 -110
  22. package/dist/collection/components/dialog/index.js +97 -93
  23. package/dist/collection/components/dialog-demo/index.js +2 -3
  24. package/dist/collection/components/display/index.js +108 -102
  25. package/dist/collection/components/display-amount/index.js +68 -63
  26. package/dist/collection/components/display-date-time/index.js +35 -30
  27. package/dist/collection/components/display-demo/index.js +23 -129
  28. package/dist/collection/components/frame/index.js +134 -124
  29. package/dist/collection/components/google-font/index.js +26 -24
  30. package/dist/collection/components/icon/index.js +116 -107
  31. package/dist/collection/components/icon-demo/index.js +11 -7
  32. package/dist/collection/components/input/index.js +364 -355
  33. package/dist/collection/components/input-date/index.js +165 -156
  34. package/dist/collection/components/input-date-range/index.js +220 -213
  35. package/dist/collection/components/input-demo/index.js +2 -87
  36. package/dist/collection/components/input-month/index.js +65 -57
  37. package/dist/collection/components/item/index.js +101 -87
  38. package/dist/collection/components/menu-options/index.js +287 -275
  39. package/dist/collection/components/notification/index.js +74 -63
  40. package/dist/collection/components/notifier/index.js +31 -23
  41. package/dist/collection/components/option/index.js +227 -223
  42. package/dist/collection/components/picker/index.js +404 -397
  43. package/dist/collection/components/popup/index.js +73 -69
  44. package/dist/collection/components/quiet/index.js +33 -28
  45. package/dist/collection/components/radio/index.js +98 -91
  46. package/dist/collection/components/radio-button/index.js +92 -83
  47. package/dist/collection/components/radio-button/item/index.js +91 -66
  48. package/dist/collection/components/radio-button/item/style.css +11 -14
  49. package/dist/collection/components/radio-group/index.js +33 -27
  50. package/dist/collection/components/reorder/index.js +28 -23
  51. package/dist/collection/components/room/index.js +73 -71
  52. package/dist/collection/components/select/index.js +82 -75
  53. package/dist/collection/components/select-demo/index.js +24 -42
  54. package/dist/collection/components/selector/index.js +71 -68
  55. package/dist/collection/components/skeleton/index.js +112 -106
  56. package/dist/collection/components/spinner/index.js +50 -46
  57. package/dist/collection/components/submit/index.js +174 -163
  58. package/dist/collection/components/svg/index.js +65 -60
  59. package/dist/collection/components/tab/index.js +84 -75
  60. package/dist/collection/components/tab-switch/index.js +32 -23
  61. package/dist/collection/components/table/cell/index.js +12 -9
  62. package/dist/collection/components/table/demo/index.js +13 -59
  63. package/dist/collection/components/table/expandable/cell/index.js +100 -95
  64. package/dist/collection/components/table/expandable/row/index.js +85 -79
  65. package/dist/collection/components/table/header/index.js +33 -28
  66. package/dist/collection/components/table/index.js +44 -36
  67. package/dist/collection/components/table/row/index.js +26 -20
  68. package/dist/collection/components/trigger/index.js +174 -166
  69. package/dist/collection/components/trigger-sink/index.js +73 -65
  70. package/dist/collection/components/trigger-source/index.js +71 -63
  71. package/dist/collection/components/tuple/index.js +19 -17
  72. package/dist/collection/components/urlencoded/index.js +22 -20
  73. package/dist/collection/model/Listenable.js +4 -2
  74. package/dist/custom-elements/index.js +67 -25
  75. package/dist/esm/{index-1d438ba2.js → index-3b463176.js} +1 -1
  76. package/dist/esm/{index-4d9efff8.js → index-fcf8bdd3.js} +467 -269
  77. package/dist/esm/index.js +2 -2
  78. package/dist/esm/loader.js +3 -3
  79. package/dist/esm/polyfills/css-shim.js +1 -1
  80. package/dist/esm/smoothly-accordion_53.entry.js +68 -26
  81. package/dist/esm/smoothly-google-font.entry.js +1 -1
  82. package/dist/esm/smoothly-radio-group.entry.js +1 -1
  83. package/dist/esm/smoothly-reorder.entry.js +1 -1
  84. package/dist/esm/smoothly-trigger-sink.entry.js +1 -1
  85. package/dist/esm/smoothly-trigger-source.entry.js +1 -1
  86. package/dist/esm/smoothly.js +3 -3
  87. package/dist/smoothly/index.esm.js +1 -1
  88. package/dist/smoothly/{p-d5d4832d.entry.js → p-0833f25c.entry.js} +1 -1
  89. package/dist/smoothly/{p-919ae3e8.entry.js → p-2bf8c660.entry.js} +1 -1
  90. package/dist/smoothly/{p-8e4e941e.entry.js → p-3bd18eea.entry.js} +1 -1
  91. package/dist/smoothly/p-8ab82f55.entry.js +1 -0
  92. package/dist/smoothly/{p-9bc77fba.entry.js → p-a1c137fc.entry.js} +1 -1
  93. package/dist/smoothly/p-af90d05a.js +2 -0
  94. package/dist/smoothly/{p-76e88859.js → p-e5191036.js} +1 -1
  95. package/dist/smoothly/{p-7a5eda51.entry.js → p-f67259c5.entry.js} +1 -1
  96. package/dist/smoothly/smoothly.esm.js +1 -1
  97. package/dist/types/components/radio-button/item/index.d.ts +2 -0
  98. package/dist/types/components.d.ts +3 -1
  99. package/dist/types/stencil-public-runtime.d.ts +15 -4
  100. package/loader/package.json +1 -0
  101. package/package.json +6 -6
  102. package/dist/smoothly/p-191ee4b8.js +0 -2
  103. package/dist/smoothly/p-78b676aa.entry.js +0 -1
@@ -22,6 +22,14 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'smoothly';
24
24
 
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
25
33
  let scopeId;
26
34
  let contentRef;
27
35
  let hostTagName;
@@ -31,58 +39,6 @@ let checkSlotRelocate = false;
31
39
  let isSvgMode = false;
32
40
  let renderingRef = null;
33
41
  let queuePending = false;
34
- const win = typeof window !== 'undefined' ? window : {};
35
- const doc = win.document || { head: {} };
36
- const plt = {
37
- $flags$: 0,
38
- $resourcesUrl$: '',
39
- jmp: (h) => h(),
40
- raf: (h) => requestAnimationFrame(h),
41
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
42
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
43
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
44
- };
45
- const promiseResolve = (v) => Promise.resolve(v);
46
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
47
- try {
48
- new CSSStyleSheet();
49
- return typeof new CSSStyleSheet().replaceSync === 'function';
50
- }
51
- catch (e) { }
52
- return false;
53
- })()
54
- ;
55
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
56
- if (listeners) {
57
- listeners.map(([flags, name, method]) => {
58
- const target = elm;
59
- const handler = hostListenerProxy(hostRef, method);
60
- const opts = hostListenerOpts(flags);
61
- plt.ael(target, name, handler, opts);
62
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
63
- });
64
- }
65
- };
66
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
67
- try {
68
- {
69
- if (hostRef.$flags$ & 256 /* isListenReady */) {
70
- // instance is ready, let's call it's member method for this event
71
- hostRef.$lazyInstance$[methodName](ev);
72
- }
73
- else {
74
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
75
- }
76
- }
77
- }
78
- catch (e) {
79
- consoleError(e);
80
- }
81
- };
82
- // prettier-ignore
83
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
84
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
85
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
86
42
  const createTime = (fnName, tagName = '') => {
87
43
  {
88
44
  return () => {
@@ -97,79 +53,8 @@ const uniqueTime = (key, measureText) => {
97
53
  };
98
54
  }
99
55
  };
100
- const rootAppliedStyles = new WeakMap();
101
- const registerStyle = (scopeId, cssText, allowCS) => {
102
- let style = styles.get(scopeId);
103
- if (supportsConstructableStylesheets && allowCS) {
104
- style = (style || new CSSStyleSheet());
105
- if (typeof style === 'string') {
106
- style = cssText;
107
- }
108
- else {
109
- style.replaceSync(cssText);
110
- }
111
- }
112
- else {
113
- style = cssText;
114
- }
115
- styles.set(scopeId, style);
116
- };
117
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
118
- let scopeId = getScopeId(cmpMeta);
119
- const style = styles.get(scopeId);
120
- // if an element is NOT connected then getRootNode() will return the wrong root node
121
- // so the fallback is to always use the document for the root node in those cases
122
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
123
- if (style) {
124
- if (typeof style === 'string') {
125
- styleContainerNode = styleContainerNode.head || styleContainerNode;
126
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
127
- let styleElm;
128
- if (!appliedStyles) {
129
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
130
- }
131
- if (!appliedStyles.has(scopeId)) {
132
- {
133
- {
134
- styleElm = doc.createElement('style');
135
- styleElm.innerHTML = style;
136
- }
137
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
138
- }
139
- if (appliedStyles) {
140
- appliedStyles.add(scopeId);
141
- }
142
- }
143
- }
144
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
145
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
146
- }
147
- }
148
- return scopeId;
149
- };
150
- const attachStyles = (hostRef) => {
151
- const cmpMeta = hostRef.$cmpMeta$;
152
- const elm = hostRef.$hostElement$;
153
- const flags = cmpMeta.$flags$;
154
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
155
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
156
- if (flags & 10 /* needsScopedEncapsulation */) {
157
- // only required when we're NOT using native shadow dom (slot)
158
- // or this browser doesn't support native shadow dom
159
- // and this host element was NOT created with SSR
160
- // let's pick out the inner content for slot projection
161
- // create a node to represent where the original
162
- // content was first placed, which is useful later on
163
- // DOM WRITE!!
164
- elm['s-sc'] = scopeId;
165
- elm.classList.add(scopeId + '-h');
166
- if (flags & 2 /* scopedCssEncapsulation */) {
167
- elm.classList.add(scopeId + '-s');
168
- }
169
- }
170
- endAttachStyles();
171
- };
172
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
56
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
57
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
173
58
  /**
174
59
  * Default style mode id
175
60
  */
@@ -318,6 +203,152 @@ const convertToPrivate = (node) => {
318
203
  vnode.$name$ = node.vname;
319
204
  return vnode;
320
205
  };
206
+ /**
207
+ * Parse a new property value for a given property type.
208
+ *
209
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
210
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
211
+ * 1. `any`, the type given to `propValue` in the function signature
212
+ * 2. the type stored from `propType`.
213
+ *
214
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
215
+ *
216
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
217
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
218
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
219
+ * ```tsx
220
+ * <my-cmp prop-val={0}></my-cmp>
221
+ * ```
222
+ *
223
+ * HTML prop values on the other hand, will always a string
224
+ *
225
+ * @param propValue the new value to coerce to some type
226
+ * @param propType the type of the prop, expressed as a binary number
227
+ * @returns the parsed/coerced value
228
+ */
229
+ const parsePropertyValue = (propValue, propType) => {
230
+ // ensure this value is of the correct prop type
231
+ if (propValue != null && !isComplexType(propValue)) {
232
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
233
+ // per the HTML spec, any string value means it is a boolean true value
234
+ // but we'll cheat here and say that the string "false" is the boolean false
235
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
236
+ }
237
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
238
+ // force it to be a number
239
+ return parseFloat(propValue);
240
+ }
241
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
242
+ // could have been passed as a number or boolean
243
+ // but we still want it as a string
244
+ return String(propValue);
245
+ }
246
+ // redundant return here for better minification
247
+ return propValue;
248
+ }
249
+ // not sure exactly what type we want
250
+ // so no need to change to a different type
251
+ return propValue;
252
+ };
253
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
254
+ const createEvent = (ref, name, flags) => {
255
+ const elm = getElement(ref);
256
+ return {
257
+ emit: (detail) => {
258
+ return emitEvent(elm, name, {
259
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
260
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
261
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
262
+ detail,
263
+ });
264
+ },
265
+ };
266
+ };
267
+ /**
268
+ * Helper function to create & dispatch a custom Event on a provided target
269
+ * @param elm the target of the Event
270
+ * @param name the name to give the custom Event
271
+ * @param opts options for configuring a custom Event
272
+ * @returns the custom Event
273
+ */
274
+ const emitEvent = (elm, name, opts) => {
275
+ const ev = plt.ce(name, opts);
276
+ elm.dispatchEvent(ev);
277
+ return ev;
278
+ };
279
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
280
+ const registerStyle = (scopeId, cssText, allowCS) => {
281
+ let style = styles.get(scopeId);
282
+ if (supportsConstructableStylesheets && allowCS) {
283
+ style = (style || new CSSStyleSheet());
284
+ if (typeof style === 'string') {
285
+ style = cssText;
286
+ }
287
+ else {
288
+ style.replaceSync(cssText);
289
+ }
290
+ }
291
+ else {
292
+ style = cssText;
293
+ }
294
+ styles.set(scopeId, style);
295
+ };
296
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
297
+ let scopeId = getScopeId(cmpMeta);
298
+ const style = styles.get(scopeId);
299
+ // if an element is NOT connected then getRootNode() will return the wrong root node
300
+ // so the fallback is to always use the document for the root node in those cases
301
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
302
+ if (style) {
303
+ if (typeof style === 'string') {
304
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
305
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
306
+ let styleElm;
307
+ if (!appliedStyles) {
308
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
309
+ }
310
+ if (!appliedStyles.has(scopeId)) {
311
+ {
312
+ {
313
+ styleElm = doc.createElement('style');
314
+ styleElm.innerHTML = style;
315
+ }
316
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
317
+ }
318
+ if (appliedStyles) {
319
+ appliedStyles.add(scopeId);
320
+ }
321
+ }
322
+ }
323
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
324
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
325
+ }
326
+ }
327
+ return scopeId;
328
+ };
329
+ const attachStyles = (hostRef) => {
330
+ const cmpMeta = hostRef.$cmpMeta$;
331
+ const elm = hostRef.$hostElement$;
332
+ const flags = cmpMeta.$flags$;
333
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
334
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
335
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
336
+ // only required when we're NOT using native shadow dom (slot)
337
+ // or this browser doesn't support native shadow dom
338
+ // and this host element was NOT created with SSR
339
+ // let's pick out the inner content for slot projection
340
+ // create a node to represent where the original
341
+ // content was first placed, which is useful later on
342
+ // DOM WRITE!!
343
+ elm['s-sc'] = scopeId;
344
+ elm.classList.add(scopeId + '-h');
345
+ if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
346
+ elm.classList.add(scopeId + '-s');
347
+ }
348
+ }
349
+ endAttachStyles();
350
+ };
351
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
321
352
  /**
322
353
  * Production setAccessor() function based on Preact by
323
354
  * Jason Miller (@developit)
@@ -454,7 +485,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
454
485
  }
455
486
  }
456
487
  }
457
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
488
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
458
489
  newValue = newValue === true ? '' : newValue;
459
490
  if (xlink) {
460
491
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -472,7 +503,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
472
503
  // if the element passed in is a shadow root, which is a document fragment
473
504
  // then we want to be adding attrs/props to the shadow root's "host" element
474
505
  // if it's not a shadow root, then we add attrs/props to the same element
475
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
506
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
476
507
  ? newVnode.$elm$.host
477
508
  : newVnode.$elm$;
478
509
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -490,6 +521,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
490
521
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
491
522
  }
492
523
  };
524
+ /**
525
+ * Create a DOM Node corresponding to one of the children of a given VNode.
526
+ *
527
+ * @param oldParentVNode the parent VNode from the previous render
528
+ * @param newParentVNode the parent VNode from the current render
529
+ * @param childIndex the index of the VNode, in the _new_ parent node's
530
+ * children, for which we will create a new DOM node
531
+ * @param parentElm the parent DOM node which our new node will be a child of
532
+ * @returns the newly created node
533
+ */
493
534
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
494
535
  // tslint:disable-next-line: prefer-const
495
536
  const newVNode = newParentVNode.$children$[childIndex];
@@ -507,16 +548,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
507
548
  }
508
549
  newVNode.$flags$ |= newVNode.$children$
509
550
  ? // slot element has fallback content
510
- 2 /* isSlotFallback */
551
+ 2 /* VNODE_FLAGS.isSlotFallback */
511
552
  : // slot element does not have fallback content
512
- 1 /* isSlotReference */;
553
+ 1 /* VNODE_FLAGS.isSlotReference */;
513
554
  }
514
555
  }
515
556
  if (newVNode.$text$ !== null) {
516
557
  // create text node
517
558
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
518
559
  }
519
- else if (newVNode.$flags$ & 1 /* isSlotReference */) {
560
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
520
561
  // create a slot reference node
521
562
  elm = newVNode.$elm$ =
522
563
  doc.createTextNode('');
@@ -526,7 +567,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
526
567
  isSvgMode = newVNode.$tag$ === 'svg';
527
568
  }
528
569
  // create element
529
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
570
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
530
571
  ? 'slot-fb'
531
572
  : newVNode.$tag$)
532
573
  );
@@ -566,7 +607,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
566
607
  }
567
608
  {
568
609
  elm['s-hn'] = hostTagName;
569
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
610
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
570
611
  // remember the content reference comment
571
612
  elm['s-sr'] = true;
572
613
  // remember the content reference comment
@@ -585,7 +626,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
585
626
  return elm;
586
627
  };
587
628
  const putBackInOriginalLocation = (parentElm, recursive) => {
588
- plt.$flags$ |= 1 /* isTmpDisconnected */;
629
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
589
630
  const oldSlotChildNodes = parentElm.childNodes;
590
631
  for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
591
632
  const childNode = oldSlotChildNodes[i];
@@ -606,7 +647,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
606
647
  putBackInOriginalLocation(childNode, recursive);
607
648
  }
608
649
  }
609
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
650
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
610
651
  };
611
652
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
612
653
  let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
@@ -648,6 +689,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
648
689
  }
649
690
  }
650
691
  };
692
+ /**
693
+ * Reconcile the children of a new VNode with the children of an old VNode by
694
+ * traversing the two collections of children, identifying nodes that are
695
+ * conserved or changed, calling out to `patch` to make any necessary
696
+ * updates to the DOM, and rearranging DOM nodes as needed.
697
+ *
698
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
699
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
700
+ * 'windows' by storing start and end indices and references to the
701
+ * corresponding array entries. Initially the two 'windows' are basically equal
702
+ * to the entire array, but we progressively narrow the windows until there are
703
+ * no children left to update by doing the following:
704
+ *
705
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
706
+ * that if we have an initial array like the following we'll end up dealing
707
+ * only with a window bounded by the highlighted elements:
708
+ *
709
+ * [null, null, VNode1 , ... , VNode2, null, null]
710
+ * ^^^^^^ ^^^^^^
711
+ *
712
+ * 2. Check to see if the elements at the head and tail positions are equal
713
+ * across the windows. This will basically detect elements which haven't
714
+ * been added, removed, or changed position, i.e. if you had the following
715
+ * VNode elements (represented as HTML):
716
+ *
717
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
718
+ * newVNode: `<div><p><span>THERE</span></p></div>`
719
+ *
720
+ * Then when comparing the children of the `<div>` tag we check the equality
721
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
722
+ * same tag in the same position, we'd be able to avoid completely
723
+ * re-rendering the subtree under them with a new DOM element and would just
724
+ * call out to `patch` to handle reconciling their children and so on.
725
+ *
726
+ * 3. Check, for both windows, to see if the element at the beginning of the
727
+ * window corresponds to the element at the end of the other window. This is
728
+ * a heuristic which will let us identify _some_ situations in which
729
+ * elements have changed position, for instance it _should_ detect that the
730
+ * children nodes themselves have not changed but merely moved in the
731
+ * following example:
732
+ *
733
+ * oldVNode: `<div><element-one /><element-two /></div>`
734
+ * newVNode: `<div><element-two /><element-one /></div>`
735
+ *
736
+ * If we find cases like this then we also need to move the concrete DOM
737
+ * elements corresponding to the moved children to write the re-order to the
738
+ * DOM.
739
+ *
740
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
741
+ * nodes in the old children which have the same key as the first element in
742
+ * our window on the new children. If we find such a node we handle calling
743
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
744
+ * what we find.
745
+ *
746
+ * Finally, once we've narrowed our 'windows' to the point that either of them
747
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
748
+ * insertion or deletion that needs to happen to get a DOM state that correctly
749
+ * reflects the new child VNodes. If, for instance, after our window on the old
750
+ * children has collapsed we still have more nodes on the new children that
751
+ * we haven't dealt with yet then we need to add them, or if the new children
752
+ * collapse but we still have unhandled _old_ children then we need to make
753
+ * sure the corresponding DOM nodes are removed.
754
+ *
755
+ * @param parentElm the node into which the parent VNode is rendered
756
+ * @param oldCh the old children of the parent node
757
+ * @param newVNode the new VNode which will replace the parent
758
+ * @param newCh the new children of the parent node
759
+ */
651
760
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
652
761
  let oldStartIdx = 0;
653
762
  let newStartIdx = 0;
@@ -663,7 +772,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
663
772
  let elmToMove;
664
773
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
665
774
  if (oldStartVnode == null) {
666
- // Vnode might have been moved left
775
+ // VNode might have been moved left
667
776
  oldStartVnode = oldCh[++oldStartIdx];
668
777
  }
669
778
  else if (oldEndVnode == null) {
@@ -676,37 +785,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
676
785
  newEndVnode = newCh[--newEndIdx];
677
786
  }
678
787
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
788
+ // if the start nodes are the same then we should patch the new VNode
789
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
790
+ // indices to reflect that. We don't need to move any DOM Nodes around
791
+ // since things are matched up in order.
679
792
  patch(oldStartVnode, newStartVnode);
680
793
  oldStartVnode = oldCh[++oldStartIdx];
681
794
  newStartVnode = newCh[++newStartIdx];
682
795
  }
683
796
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
797
+ // likewise, if the end nodes are the same we patch new onto old and
798
+ // decrement our end indices, and also likewise in this case we don't
799
+ // need to move any DOM Nodes.
684
800
  patch(oldEndVnode, newEndVnode);
685
801
  oldEndVnode = oldCh[--oldEndIdx];
686
802
  newEndVnode = newCh[--newEndIdx];
687
803
  }
688
804
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
689
- // Vnode moved right
805
+ // case: "Vnode moved right"
806
+ //
807
+ // We've found that the last node in our window on the new children is
808
+ // the same VNode as the _first_ node in our window on the old children
809
+ // we're dealing with now. Visually, this is the layout of these two
810
+ // nodes:
811
+ //
812
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
813
+ // ^^^^^^^^^^^
814
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
815
+ // ^^^^^^^^^^^^^
816
+ //
817
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
818
+ // and move the DOM element for `oldStartVnode`.
690
819
  if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
691
820
  putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
692
821
  }
693
822
  patch(oldStartVnode, newEndVnode);
823
+ // We need to move the element for `oldStartVnode` into a position which
824
+ // will be appropriate for `newEndVnode`. For this we can use
825
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
826
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
827
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
828
+ //
829
+ // <old-start-node />
830
+ // <some-intervening-node />
831
+ // <old-end-node />
832
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
833
+ // <next-sibling />
834
+ //
835
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
836
+ // the node for `oldStartVnode` at the end of the children of
837
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
838
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
839
+ // append it to the children of the parent element.
694
840
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
695
841
  oldStartVnode = oldCh[++oldStartIdx];
696
842
  newEndVnode = newCh[--newEndIdx];
697
843
  }
698
844
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
699
- // Vnode moved left
845
+ // case: "Vnode moved left"
846
+ //
847
+ // We've found that the first node in our window on the new children is
848
+ // the same VNode as the _last_ node in our window on the old children.
849
+ // Visually, this is the layout of these two nodes:
850
+ //
851
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
852
+ // ^^^^^^^^^^^^^
853
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
854
+ // ^^^^^^^^^^^
855
+ //
856
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
857
+ // (which will handle updating any changed attributes, reconciling their
858
+ // children etc) but we also need to move the DOM node to which
859
+ // `oldEndVnode` corresponds.
700
860
  if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
701
861
  putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
702
862
  }
703
863
  patch(oldEndVnode, newStartVnode);
864
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
865
+ // the same node, so since we're here we know that they are not. Thus we
866
+ // can move the element for `oldEndVnode` _before_ the element for
867
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
868
+ // future.
704
869
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
705
870
  oldEndVnode = oldCh[--oldEndIdx];
706
871
  newStartVnode = newCh[++newStartIdx];
707
872
  }
708
873
  else {
709
- // createKeyToOldIdx
874
+ // Here we do some checks to match up old and new nodes based on the
875
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
876
+ // in the JSX for a DOM element in the implementation of a Stencil
877
+ // component.
878
+ //
879
+ // First we check to see if there are any nodes in the array of old
880
+ // children which have the same key as the first node in the new
881
+ // children.
710
882
  idxInOld = -1;
711
883
  {
712
884
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -717,23 +889,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
717
889
  }
718
890
  }
719
891
  if (idxInOld >= 0) {
892
+ // We found a node in the old children which matches up with the first
893
+ // node in the new children! So let's deal with that
720
894
  elmToMove = oldCh[idxInOld];
721
895
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
896
+ // the tag doesn't match so we'll need a new DOM element
722
897
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
723
898
  }
724
899
  else {
725
900
  patch(elmToMove, newStartVnode);
901
+ // invalidate the matching old node so that we won't try to update it
902
+ // again later on
726
903
  oldCh[idxInOld] = undefined;
727
904
  node = elmToMove.$elm$;
728
905
  }
729
906
  newStartVnode = newCh[++newStartIdx];
730
907
  }
731
908
  else {
732
- // new element
909
+ // We either didn't find an element in the old children that matches
910
+ // the key of the first new child OR the build is not using `key`
911
+ // attributes at all. In either case we need to create a new element
912
+ // for the new node.
733
913
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
734
914
  newStartVnode = newCh[++newStartIdx];
735
915
  }
736
916
  if (node) {
917
+ // if we created a new node then handle inserting it to the DOM
737
918
  {
738
919
  parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
739
920
  }
@@ -741,21 +922,43 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
741
922
  }
742
923
  }
743
924
  if (oldStartIdx > oldEndIdx) {
925
+ // we have some more new nodes to add which don't match up with old nodes
744
926
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
745
927
  }
746
928
  else if (newStartIdx > newEndIdx) {
929
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
930
+ // in the new array, so lets remove them (which entails cleaning up the
931
+ // relevant DOM nodes)
747
932
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
748
933
  }
749
934
  };
750
- const isSameVnode = (vnode1, vnode2) => {
935
+ /**
936
+ * Compare two VNodes to determine if they are the same
937
+ *
938
+ * **NB**: This function is an equality _heuristic_ based on the available
939
+ * information set on the two VNodes and can be misleading under certain
940
+ * circumstances. In particular, if the two nodes do not have `key` attrs
941
+ * (available under `$key$` on VNodes) then the function falls back on merely
942
+ * checking that they have the same tag.
943
+ *
944
+ * So, in other words, if `key` attrs are not set on VNodes which may be
945
+ * changing order within a `children` array or something along those lines then
946
+ * we could obtain a false positive and then have to do needless re-rendering.
947
+ *
948
+ * @param leftVNode the first VNode to check
949
+ * @param rightVNode the second VNode to check
950
+ * @returns whether they're equal or not
951
+ */
952
+ const isSameVnode = (leftVNode, rightVNode) => {
751
953
  // compare if two vnode to see if they're "technically" the same
752
954
  // need to have the same element tag, and same key to be the same
753
- if (vnode1.$tag$ === vnode2.$tag$) {
754
- if (vnode1.$tag$ === 'slot') {
755
- return vnode1.$name$ === vnode2.$name$;
955
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
956
+ if (leftVNode.$tag$ === 'slot') {
957
+ return leftVNode.$name$ === rightVNode.$name$;
756
958
  }
959
+ // this will be set if components in the build have `key` attrs set on them
757
960
  {
758
- return vnode1.$key$ === vnode2.$key$;
961
+ return leftVNode.$key$ === rightVNode.$key$;
759
962
  }
760
963
  }
761
964
  return false;
@@ -768,6 +971,14 @@ const referenceNode = (node) => {
768
971
  return (node && node['s-ol']) || node;
769
972
  };
770
973
  const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
974
+ /**
975
+ * Handle reconciling an outdated VNode with a new one which corresponds to
976
+ * it. This function handles flushing updates to the DOM and reconciling the
977
+ * children of the two nodes (if any).
978
+ *
979
+ * @param oldVNode an old VNode whose DOM element and children we want to update
980
+ * @param newVNode a new VNode representing an updated version of the old one
981
+ */
771
982
  const patch = (oldVNode, newVNode) => {
772
983
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
773
984
  const oldChildren = oldVNode.$children$;
@@ -781,7 +992,6 @@ const patch = (oldVNode, newVNode) => {
781
992
  // only add this to the when the compiler sees we're using an svg somewhere
782
993
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
783
994
  }
784
- // element node
785
995
  {
786
996
  if (tag === 'slot')
787
997
  ;
@@ -794,6 +1004,7 @@ const patch = (oldVNode, newVNode) => {
794
1004
  }
795
1005
  if (oldChildren !== null && newChildren !== null) {
796
1006
  // looks like there's child vnodes for both the old and new vnodes
1007
+ // so we need to call `updateChildren` to reconcile them
797
1008
  updateChildren(elm, oldChildren, newVNode, newChildren);
798
1009
  }
799
1010
  else if (newChildren !== null) {
@@ -834,7 +1045,7 @@ const updateFallbackSlotVisibility = (elm) => {
834
1045
  let nodeType;
835
1046
  for (i = 0, ilen = childNodes.length; i < ilen; i++) {
836
1047
  childNode = childNodes[i];
837
- if (childNode.nodeType === 1 /* ElementNode */) {
1048
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
838
1049
  if (childNode['s-sr']) {
839
1050
  // this is a slot fallback node
840
1051
  // get the slot name for this slot reference node
@@ -846,7 +1057,7 @@ const updateFallbackSlotVisibility = (elm) => {
846
1057
  nodeType = childNodes[j].nodeType;
847
1058
  if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
848
1059
  // this sibling node is from a different component OR is a named fallback slot node
849
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1060
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
850
1061
  childNode.hidden = true;
851
1062
  break;
852
1063
  }
@@ -855,8 +1066,8 @@ const updateFallbackSlotVisibility = (elm) => {
855
1066
  // this is a default fallback slot node
856
1067
  // any element or text node (with content)
857
1068
  // should hide the default fallback slot node
858
- if (nodeType === 1 /* ElementNode */ ||
859
- (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
1069
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1070
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
860
1071
  childNode.hidden = true;
861
1072
  break;
862
1073
  }
@@ -934,13 +1145,13 @@ const relocateSlotContent = (elm) => {
934
1145
  }
935
1146
  }
936
1147
  }
937
- if (childNode.nodeType === 1 /* ElementNode */) {
1148
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
938
1149
  relocateSlotContent(childNode);
939
1150
  }
940
1151
  }
941
1152
  };
942
1153
  const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
943
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1154
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
944
1155
  if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
945
1156
  return true;
946
1157
  }
@@ -971,7 +1182,7 @@ const renderVdom = (hostRef, renderFnResults) => {
971
1182
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
972
1183
  }
973
1184
  rootVnode.$tag$ = null;
974
- rootVnode.$flags$ |= 4 /* isHost */;
1185
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
975
1186
  hostRef.$vnode$ = rootVnode;
976
1187
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
977
1188
  {
@@ -979,7 +1190,7 @@ const renderVdom = (hostRef, renderFnResults) => {
979
1190
  }
980
1191
  {
981
1192
  contentRef = hostElm['s-cr'];
982
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
1193
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
983
1194
  // always reset
984
1195
  checkSlotFallbackVisibility = false;
985
1196
  }
@@ -988,7 +1199,7 @@ const renderVdom = (hostRef, renderFnResults) => {
988
1199
  {
989
1200
  // while we're moving nodes around existing nodes, temporarily disable
990
1201
  // the disconnectCallback from working
991
- plt.$flags$ |= 1 /* isTmpDisconnected */;
1202
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
992
1203
  if (checkSlotRelocate) {
993
1204
  relocateSlotContent(rootVnode.$elm$);
994
1205
  let relocateData;
@@ -1046,7 +1257,7 @@ const renderVdom = (hostRef, renderFnResults) => {
1046
1257
  }
1047
1258
  else {
1048
1259
  // this node doesn't have a slot home to go to, so let's hide it
1049
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1260
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1050
1261
  nodeToRelocate.hidden = true;
1051
1262
  }
1052
1263
  }
@@ -1057,37 +1268,11 @@ const renderVdom = (hostRef, renderFnResults) => {
1057
1268
  }
1058
1269
  // done moving nodes around
1059
1270
  // allow the disconnect callback to work again
1060
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1271
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1061
1272
  // always reset
1062
1273
  relocateNodes.length = 0;
1063
1274
  }
1064
1275
  };
1065
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1066
- const createEvent = (ref, name, flags) => {
1067
- const elm = getElement(ref);
1068
- return {
1069
- emit: (detail) => {
1070
- return emitEvent(elm, name, {
1071
- bubbles: !!(flags & 4 /* Bubbles */),
1072
- composed: !!(flags & 2 /* Composed */),
1073
- cancelable: !!(flags & 1 /* Cancellable */),
1074
- detail,
1075
- });
1076
- },
1077
- };
1078
- };
1079
- /**
1080
- * Helper function to create & dispatch a custom Event on a provided target
1081
- * @param elm the target of the Event
1082
- * @param name the name to give the custom Event
1083
- * @param opts options for configuring a custom Event
1084
- * @returns the custom Event
1085
- */
1086
- const emitEvent = (elm, name, opts) => {
1087
- const ev = plt.ce(name, opts);
1088
- elm.dispatchEvent(ev);
1089
- return ev;
1090
- };
1091
1276
  const attachToAncestor = (hostRef, ancestorComponent) => {
1092
1277
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1093
1278
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -1095,10 +1280,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
1095
1280
  };
1096
1281
  const scheduleUpdate = (hostRef, isInitialLoad) => {
1097
1282
  {
1098
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1283
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1099
1284
  }
1100
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1101
- hostRef.$flags$ |= 512 /* needsRerender */;
1285
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1286
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1102
1287
  return;
1103
1288
  }
1104
1289
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -1114,7 +1299,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
1114
1299
  let promise;
1115
1300
  if (isInitialLoad) {
1116
1301
  {
1117
- hostRef.$flags$ |= 256 /* isListenReady */;
1302
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1118
1303
  if (hostRef.$queuedListeners$) {
1119
1304
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1120
1305
  hostRef.$queuedListeners$ = null;
@@ -1157,7 +1342,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1157
1342
  }
1158
1343
  else {
1159
1344
  Promise.all(childrenPromises).then(postUpdate);
1160
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1345
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1161
1346
  childrenPromises.length = 0;
1162
1347
  }
1163
1348
  }
@@ -1167,10 +1352,10 @@ const callRender = (hostRef, instance, elm) => {
1167
1352
  renderingRef = instance;
1168
1353
  instance = instance.render && instance.render();
1169
1354
  {
1170
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1355
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1171
1356
  }
1172
1357
  {
1173
- hostRef.$flags$ |= 2 /* hasRendered */;
1358
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1174
1359
  }
1175
1360
  {
1176
1361
  {
@@ -1199,8 +1384,8 @@ const postUpdateComponent = (hostRef) => {
1199
1384
  {
1200
1385
  safeCall(instance, 'componentDidRender');
1201
1386
  }
1202
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1203
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1387
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1388
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1204
1389
  {
1205
1390
  // DOM WRITE!
1206
1391
  addHydratedFlag(elm);
@@ -1229,10 +1414,10 @@ const postUpdateComponent = (hostRef) => {
1229
1414
  hostRef.$onRenderResolve$();
1230
1415
  hostRef.$onRenderResolve$ = undefined;
1231
1416
  }
1232
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1417
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1233
1418
  nextTick(() => scheduleUpdate(hostRef, false));
1234
1419
  }
1235
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1420
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1236
1421
  }
1237
1422
  // ( •_•)
1238
1423
  // ( •_•)>⌐■-■
@@ -1243,7 +1428,7 @@ const forceUpdate = (ref) => {
1243
1428
  const hostRef = getHostRef(ref);
1244
1429
  const isConnected = hostRef.$hostElement$.isConnected;
1245
1430
  if (isConnected &&
1246
- (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1431
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1247
1432
  scheduleUpdate(hostRef, false);
1248
1433
  }
1249
1434
  // Returns "true" when the forced update was successfully scheduled
@@ -1274,53 +1459,6 @@ const then = (promise, thenFn) => {
1274
1459
  };
1275
1460
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1276
1461
  ;
1277
- /**
1278
- * Parse a new property value for a given property type.
1279
- *
1280
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1281
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1282
- * 1. `any`, the type given to `propValue` in the function signature
1283
- * 2. the type stored from `propType`.
1284
- *
1285
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1286
- *
1287
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1288
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1289
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1290
- * ```tsx
1291
- * <my-cmp prop-val={0}></my-cmp>
1292
- * ```
1293
- *
1294
- * HTML prop values on the other hand, will always a string
1295
- *
1296
- * @param propValue the new value to coerce to some type
1297
- * @param propType the type of the prop, expressed as a binary number
1298
- * @returns the parsed/coerced value
1299
- */
1300
- const parsePropertyValue = (propValue, propType) => {
1301
- // ensure this value is of the correct prop type
1302
- if (propValue != null && !isComplexType(propValue)) {
1303
- if (propType & 4 /* Boolean */) {
1304
- // per the HTML spec, any string value means it is a boolean true value
1305
- // but we'll cheat here and say that the string "false" is the boolean false
1306
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1307
- }
1308
- if (propType & 2 /* Number */) {
1309
- // force it to be a number
1310
- return parseFloat(propValue);
1311
- }
1312
- if (propType & 1 /* String */) {
1313
- // could have been passed as a number or boolean
1314
- // but we still want it as a string
1315
- return String(propValue);
1316
- }
1317
- // redundant return here for better minification
1318
- return propValue;
1319
- }
1320
- // not sure exactly what type we want
1321
- // so no need to change to a different type
1322
- return propValue;
1323
- };
1324
1462
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1325
1463
  const setValue = (ref, propName, newVal, cmpMeta) => {
1326
1464
  // check our new property value against our internal value
@@ -1333,13 +1471,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1333
1471
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1334
1472
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1335
1473
  const didValueChange = newVal !== oldVal && !areBothNaN;
1336
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1474
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1337
1475
  // gadzooks! the property's value has changed!!
1338
1476
  // set our new value!
1339
1477
  hostRef.$instanceValues$.set(propName, newVal);
1340
1478
  if (instance) {
1341
1479
  // get an array of method names of watch functions to call
1342
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1480
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1343
1481
  const watchMethods = cmpMeta.$watchers$[propName];
1344
1482
  if (watchMethods) {
1345
1483
  // this instance is watching for when this property changed
@@ -1354,7 +1492,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1354
1492
  });
1355
1493
  }
1356
1494
  }
1357
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1495
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1358
1496
  // looks like this value actually changed, so we've got work to do!
1359
1497
  // but only if we've already rendered, otherwise just chill out
1360
1498
  // queue that we need to do an update, but don't worry about queuing
@@ -1364,6 +1502,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1364
1502
  }
1365
1503
  }
1366
1504
  };
1505
+ /**
1506
+ * Attach a series of runtime constructs to a compiled Stencil component
1507
+ * constructor, including getters and setters for the `@Prop` and `@State`
1508
+ * decorators, callbacks for when attributes change, and so on.
1509
+ *
1510
+ * @param Cstr the constructor for a component that we need to process
1511
+ * @param cmpMeta metadata collected previously about the component
1512
+ * @param flags a number used to store a series of bit flags
1513
+ * @returns a reference to the same constructor passed in (but now mutated)
1514
+ */
1367
1515
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1368
1516
  if (cmpMeta.$members$) {
1369
1517
  if (Cstr.watchers) {
@@ -1373,8 +1521,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1373
1521
  const members = Object.entries(cmpMeta.$members$);
1374
1522
  const prototype = Cstr.prototype;
1375
1523
  members.map(([memberName, [memberFlags]]) => {
1376
- if ((memberFlags & 31 /* Prop */ ||
1377
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1524
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1525
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1378
1526
  // proxyComponent - prop
1379
1527
  Object.defineProperty(prototype, memberName, {
1380
1528
  get() {
@@ -1389,8 +1537,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1389
1537
  enumerable: true,
1390
1538
  });
1391
1539
  }
1392
- else if (flags & 1 /* isElementConstructor */ &&
1393
- memberFlags & 64 /* Method */) {
1540
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1541
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1394
1542
  // proxyComponent - method
1395
1543
  Object.defineProperty(prototype, memberName, {
1396
1544
  value(...args) {
@@ -1400,7 +1548,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1400
1548
  });
1401
1549
  }
1402
1550
  });
1403
- if ((flags & 1 /* isElementConstructor */)) {
1551
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1404
1552
  const attrNameToPropName = new Map();
1405
1553
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1406
1554
  plt.jmp(() => {
@@ -1456,11 +1604,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1456
1604
  // create an array of attributes to observe
1457
1605
  // and also create a map of html attribute name to js property name
1458
1606
  Cstr.observedAttributes = members
1459
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1607
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1460
1608
  .map(([propName, m]) => {
1461
1609
  const attrName = m[1] || propName;
1462
1610
  attrNameToPropName.set(attrName, propName);
1463
- if (m[0] & 512 /* ReflectAttr */) {
1611
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1464
1612
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1465
1613
  }
1466
1614
  return attrName;
@@ -1471,10 +1619,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1471
1619
  };
1472
1620
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1473
1621
  // initializeComponent
1474
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1622
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1475
1623
  {
1476
1624
  // we haven't initialized this element yet
1477
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1625
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1478
1626
  // lazy loaded components
1479
1627
  // request the component's implementation to be
1480
1628
  // wired up with the host element
@@ -1492,7 +1640,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1492
1640
  {
1493
1641
  cmpMeta.$watchers$ = Cstr.watchers;
1494
1642
  }
1495
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1643
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1496
1644
  Cstr.isProxied = true;
1497
1645
  }
1498
1646
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1500,7 +1648,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1500
1648
  // but let's keep track of when we start and stop
1501
1649
  // so that the getters/setters don't incorrectly step on data
1502
1650
  {
1503
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1651
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1504
1652
  }
1505
1653
  // construct the lazy-loaded component implementation
1506
1654
  // passing the hostRef is very important during
@@ -1513,10 +1661,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1513
1661
  consoleError(e);
1514
1662
  }
1515
1663
  {
1516
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1664
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1517
1665
  }
1518
1666
  {
1519
- hostRef.$flags$ |= 128 /* isWatchReady */;
1667
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1520
1668
  }
1521
1669
  endNewInstance();
1522
1670
  }
@@ -1526,7 +1674,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1526
1674
  const scopeId = getScopeId(cmpMeta);
1527
1675
  if (!styles.has(scopeId)) {
1528
1676
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1529
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1677
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1530
1678
  endRegisterStyles();
1531
1679
  }
1532
1680
  }
@@ -1548,19 +1696,19 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1548
1696
  }
1549
1697
  };
1550
1698
  const connectedCallback = (elm) => {
1551
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1699
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1552
1700
  const hostRef = getHostRef(elm);
1553
1701
  const cmpMeta = hostRef.$cmpMeta$;
1554
1702
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1555
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1703
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1556
1704
  // first time this component has connected
1557
- hostRef.$flags$ |= 1 /* hasConnected */;
1705
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1558
1706
  {
1559
1707
  // initUpdate
1560
1708
  // if the slot polyfill is required we'll need to put some nodes
1561
1709
  // in here to act as original content anchors as we move nodes around
1562
1710
  // host element has been connected to the DOM
1563
- if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1711
+ if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1564
1712
  setContentReference(elm);
1565
1713
  }
1566
1714
  }
@@ -1583,7 +1731,7 @@ const connectedCallback = (elm) => {
1583
1731
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1584
1732
  if (cmpMeta.$members$) {
1585
1733
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1586
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1734
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1587
1735
  const value = elm[memberName];
1588
1736
  delete elm[memberName];
1589
1737
  elm[memberName] = value;
@@ -1615,7 +1763,7 @@ const setContentReference = (elm) => {
1615
1763
  elm.insertBefore(contentRefElm, elm.firstChild);
1616
1764
  };
1617
1765
  const disconnectedCallback = (elm) => {
1618
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1766
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1619
1767
  const hostRef = getHostRef(elm);
1620
1768
  const instance = hostRef.$lazyInstance$ ;
1621
1769
  {
@@ -1670,7 +1818,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1670
1818
  super(self);
1671
1819
  self = this;
1672
1820
  registerHost(self, cmpMeta);
1673
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1821
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1674
1822
  // this component is using shadow dom
1675
1823
  // and this browser supports shadow dom
1676
1824
  // add the read-only property "shadowRoot" to the host element
@@ -1705,7 +1853,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1705
1853
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1706
1854
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1707
1855
  cmpTags.push(tagName);
1708
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1856
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1709
1857
  }
1710
1858
  });
1711
1859
  });
@@ -1727,7 +1875,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1727
1875
  // Fallback appLoad event
1728
1876
  endBootstrap();
1729
1877
  };
1730
- const hostRefs = new WeakMap();
1878
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1879
+ if (listeners) {
1880
+ listeners.map(([flags, name, method]) => {
1881
+ const target = elm;
1882
+ const handler = hostListenerProxy(hostRef, method);
1883
+ const opts = hostListenerOpts(flags);
1884
+ plt.ael(target, name, handler, opts);
1885
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1886
+ });
1887
+ }
1888
+ };
1889
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1890
+ try {
1891
+ {
1892
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1893
+ // instance is ready, let's call it's member method for this event
1894
+ hostRef.$lazyInstance$[methodName](ev);
1895
+ }
1896
+ else {
1897
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1898
+ }
1899
+ }
1900
+ }
1901
+ catch (e) {
1902
+ consoleError(e);
1903
+ }
1904
+ };
1905
+ // prettier-ignore
1906
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1907
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1731
1908
  const getHostRef = (ref) => hostRefs.get(ref);
1732
1909
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1733
1910
  const registerHost = (elm, cmpMeta) => {
@@ -1772,14 +1949,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1772
1949
  return importedModule[exportName];
1773
1950
  }, consoleError);
1774
1951
  };
1775
- const styles = new Map();
1952
+ const styles = /*@__PURE__*/ new Map();
1953
+ const win = typeof window !== 'undefined' ? window : {};
1954
+ const doc = win.document || { head: {} };
1955
+ const plt = {
1956
+ $flags$: 0,
1957
+ $resourcesUrl$: '',
1958
+ jmp: (h) => h(),
1959
+ raf: (h) => requestAnimationFrame(h),
1960
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1961
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1962
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1963
+ };
1964
+ const promiseResolve = (v) => Promise.resolve(v);
1965
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1966
+ try {
1967
+ new CSSStyleSheet();
1968
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1969
+ }
1970
+ catch (e) { }
1971
+ return false;
1972
+ })()
1973
+ ;
1776
1974
  const queueDomReads = [];
1777
1975
  const queueDomWrites = [];
1778
1976
  const queueTask = (queue, write) => (cb) => {
1779
1977
  queue.push(cb);
1780
1978
  if (!queuePending) {
1781
1979
  queuePending = true;
1782
- if (write && plt.$flags$ & 4 /* queueSync */) {
1980
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1783
1981
  nextTick(flush);
1784
1982
  }
1785
1983
  else {