@maggioli-design-system/mds-table-row 2.0.0 → 2.0.2

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 (53) hide show
  1. package/dist/cjs/{index-2159a30d.js → index-516d954b.js} +376 -213
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/mds-table-row.cjs.entry.js +2 -1
  4. package/dist/cjs/mds-table-row.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +2 -2
  6. package/dist/collection/common/aria.js +19 -0
  7. package/dist/collection/components/mds-table-row/mds-table-row.js +45 -35
  8. package/dist/collection/dictionary/typography.js +16 -5
  9. package/dist/components/index.d.ts +1 -5
  10. package/dist/components/index.js +1 -0
  11. package/dist/components/mds-table-row.js +1 -0
  12. package/dist/esm/{index-1e8e95d7.js → index-e2bb9874.js} +376 -213
  13. package/dist/esm/loader.js +2 -2
  14. package/dist/esm/mds-table-row.entry.js +2 -1
  15. package/dist/esm/mds-table-row.js +2 -2
  16. package/dist/esm/polyfills/css-shim.js +1 -1
  17. package/dist/esm-es5/index-e2bb9874.js +2 -0
  18. package/dist/esm-es5/loader.js +1 -1
  19. package/dist/esm-es5/mds-table-row.entry.js +1 -1
  20. package/dist/esm-es5/mds-table-row.js +1 -1
  21. package/dist/mds-table-row/mds-table-row.esm.js +1 -1
  22. package/dist/mds-table-row/mds-table-row.js +2 -1
  23. package/dist/mds-table-row/p-2689570a.system.js +2 -0
  24. package/dist/mds-table-row/{p-c8145b7b.system.entry.js → p-2a317845.system.entry.js} +1 -1
  25. package/dist/mds-table-row/{p-caab8e1e.system.js → p-2ca79ad0.system.js} +1 -1
  26. package/dist/mds-table-row/p-a14f9222.js +2 -0
  27. package/dist/mds-table-row/p-c9a97ed3.entry.js +1 -0
  28. package/dist/stats.json +36 -34
  29. package/dist/types/common/aria.d.ts +4 -0
  30. package/dist/types/dictionary/typography.d.ts +5 -3
  31. package/dist/types/stencil-public-runtime.d.ts +20 -4
  32. package/dist/types/types/typography.d.ts +6 -4
  33. package/loader/package.json +1 -0
  34. package/package.json +4 -4
  35. package/src/common/aria.ts +27 -0
  36. package/src/components/mds-table-row/.gitlab-ci.yml +2 -2
  37. package/src/dictionary/typography.ts +21 -6
  38. package/src/fixtures/icons.json +2 -2
  39. package/src/types/typography.ts +15 -4
  40. package/www/build/mds-table-row.esm.js +1 -1
  41. package/www/build/mds-table-row.js +2 -1
  42. package/www/build/p-2689570a.system.js +2 -0
  43. package/www/build/{p-c8145b7b.system.entry.js → p-2a317845.system.entry.js} +1 -1
  44. package/www/build/{p-caab8e1e.system.js → p-2ca79ad0.system.js} +1 -1
  45. package/www/build/p-a14f9222.js +2 -0
  46. package/www/build/p-c9a97ed3.entry.js +1 -0
  47. package/dist/esm-es5/index-1e8e95d7.js +0 -2
  48. package/dist/mds-table-row/p-c6fbd532.system.js +0 -2
  49. package/dist/mds-table-row/p-ca70a50c.entry.js +0 -1
  50. package/dist/mds-table-row/p-f5a4be35.js +0 -2
  51. package/www/build/p-c6fbd532.system.js +0 -2
  52. package/www/build/p-ca70a50c.entry.js +0 -1
  53. package/www/build/p-f5a4be35.js +0 -2
@@ -22,66 +22,18 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'mds-table-row';
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 hostTagName;
27
35
  let isSvgMode = false;
28
36
  let queuePending = false;
29
- const win = typeof window !== 'undefined' ? window : {};
30
- const doc = win.document || { head: {} };
31
- const plt = {
32
- $flags$: 0,
33
- $resourcesUrl$: '',
34
- jmp: (h) => h(),
35
- raf: (h) => requestAnimationFrame(h),
36
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
37
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
38
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
39
- };
40
- const promiseResolve = (v) => Promise.resolve(v);
41
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
42
- try {
43
- new CSSStyleSheet();
44
- return typeof new CSSStyleSheet().replace === 'function';
45
- }
46
- catch (e) { }
47
- return false;
48
- })()
49
- ;
50
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
51
- if (listeners) {
52
- listeners.map(([flags, name, method]) => {
53
- const target = getHostListenerTarget(elm, flags) ;
54
- const handler = hostListenerProxy(hostRef, method);
55
- const opts = hostListenerOpts(flags);
56
- plt.ael(target, name, handler, opts);
57
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
58
- });
59
- }
60
- };
61
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
62
- try {
63
- {
64
- if (hostRef.$flags$ & 256 /* isListenReady */) {
65
- // instance is ready, let's call it's member method for this event
66
- hostRef.$lazyInstance$[methodName](ev);
67
- }
68
- else {
69
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
70
- }
71
- }
72
- }
73
- catch (e) {
74
- consoleError(e);
75
- }
76
- };
77
- const getHostListenerTarget = (elm, flags) => {
78
- if (flags & 16 /* TargetBody */)
79
- return doc.body;
80
- return elm;
81
- };
82
- // prettier-ignore
83
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
84
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
85
37
  const createTime = (fnName, tagName = '') => {
86
38
  {
87
39
  return () => {
@@ -96,71 +48,7 @@ const uniqueTime = (key, measureText) => {
96
48
  };
97
49
  }
98
50
  };
99
- const rootAppliedStyles = new WeakMap();
100
- const registerStyle = (scopeId, cssText, allowCS) => {
101
- let style = styles.get(scopeId);
102
- if (supportsConstructibleStylesheets && allowCS) {
103
- style = (style || new CSSStyleSheet());
104
- style.replace(cssText);
105
- }
106
- else {
107
- style = cssText;
108
- }
109
- styles.set(scopeId, style);
110
- };
111
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
112
- let scopeId = getScopeId(cmpMeta);
113
- const style = styles.get(scopeId);
114
- // if an element is NOT connected then getRootNode() will return the wrong root node
115
- // so the fallback is to always use the document for the root node in those cases
116
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
117
- if (style) {
118
- if (typeof style === 'string') {
119
- styleContainerNode = styleContainerNode.head || styleContainerNode;
120
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
121
- let styleElm;
122
- if (!appliedStyles) {
123
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
124
- }
125
- if (!appliedStyles.has(scopeId)) {
126
- {
127
- {
128
- styleElm = doc.createElement('style');
129
- styleElm.innerHTML = style;
130
- }
131
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
132
- }
133
- if (appliedStyles) {
134
- appliedStyles.add(scopeId);
135
- }
136
- }
137
- }
138
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
139
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
140
- }
141
- }
142
- return scopeId;
143
- };
144
- const attachStyles = (hostRef) => {
145
- const cmpMeta = hostRef.$cmpMeta$;
146
- const elm = hostRef.$hostElement$;
147
- const flags = cmpMeta.$flags$;
148
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
149
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
150
- if (flags & 10 /* needsScopedEncapsulation */) {
151
- // only required when we're NOT using native shadow dom (slot)
152
- // or this browser doesn't support native shadow dom
153
- // and this host element was NOT created with SSR
154
- // let's pick out the inner content for slot projection
155
- // create a node to represent where the original
156
- // content was first placed, which is useful later on
157
- // DOM WRITE!!
158
- elm['s-sc'] = scopeId;
159
- elm.classList.add(scopeId + '-h');
160
- }
161
- endAttachStyles();
162
- };
163
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
51
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
164
52
  /**
165
53
  * Default style mode id
166
54
  */
@@ -236,6 +124,126 @@ const newVNode = (tag, text) => {
236
124
  };
237
125
  const Host = {};
238
126
  const isHost = (node) => node && node.$tag$ === Host;
127
+ /**
128
+ * Parse a new property value for a given property type.
129
+ *
130
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
131
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
132
+ * 1. `any`, the type given to `propValue` in the function signature
133
+ * 2. the type stored from `propType`.
134
+ *
135
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
136
+ *
137
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
138
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
139
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
140
+ * ```tsx
141
+ * <my-cmp prop-val={0}></my-cmp>
142
+ * ```
143
+ *
144
+ * HTML prop values on the other hand, will always a string
145
+ *
146
+ * @param propValue the new value to coerce to some type
147
+ * @param propType the type of the prop, expressed as a binary number
148
+ * @returns the parsed/coerced value
149
+ */
150
+ const parsePropertyValue = (propValue, propType) => {
151
+ // ensure this value is of the correct prop type
152
+ if (propValue != null && !isComplexType(propValue)) {
153
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
154
+ // per the HTML spec, any string value means it is a boolean true value
155
+ // but we'll cheat here and say that the string "false" is the boolean false
156
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
157
+ }
158
+ // redundant return here for better minification
159
+ return propValue;
160
+ }
161
+ // not sure exactly what type we want
162
+ // so no need to change to a different type
163
+ return propValue;
164
+ };
165
+ /**
166
+ * Helper function to create & dispatch a custom Event on a provided target
167
+ * @param elm the target of the Event
168
+ * @param name the name to give the custom Event
169
+ * @param opts options for configuring a custom Event
170
+ * @returns the custom Event
171
+ */
172
+ const emitEvent = (elm, name, opts) => {
173
+ const ev = plt.ce(name, opts);
174
+ elm.dispatchEvent(ev);
175
+ return ev;
176
+ };
177
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
178
+ const registerStyle = (scopeId, cssText, allowCS) => {
179
+ let style = styles.get(scopeId);
180
+ if (supportsConstructableStylesheets && allowCS) {
181
+ style = (style || new CSSStyleSheet());
182
+ if (typeof style === 'string') {
183
+ style = cssText;
184
+ }
185
+ else {
186
+ style.replaceSync(cssText);
187
+ }
188
+ }
189
+ else {
190
+ style = cssText;
191
+ }
192
+ styles.set(scopeId, style);
193
+ };
194
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
195
+ let scopeId = getScopeId(cmpMeta);
196
+ const style = styles.get(scopeId);
197
+ // if an element is NOT connected then getRootNode() will return the wrong root node
198
+ // so the fallback is to always use the document for the root node in those cases
199
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
200
+ if (style) {
201
+ if (typeof style === 'string') {
202
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
203
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
204
+ let styleElm;
205
+ if (!appliedStyles) {
206
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
207
+ }
208
+ if (!appliedStyles.has(scopeId)) {
209
+ {
210
+ {
211
+ styleElm = doc.createElement('style');
212
+ styleElm.innerHTML = style;
213
+ }
214
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
215
+ }
216
+ if (appliedStyles) {
217
+ appliedStyles.add(scopeId);
218
+ }
219
+ }
220
+ }
221
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
222
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
223
+ }
224
+ }
225
+ return scopeId;
226
+ };
227
+ const attachStyles = (hostRef) => {
228
+ const cmpMeta = hostRef.$cmpMeta$;
229
+ const elm = hostRef.$hostElement$;
230
+ const flags = cmpMeta.$flags$;
231
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
232
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
233
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
234
+ // only required when we're NOT using native shadow dom (slot)
235
+ // or this browser doesn't support native shadow dom
236
+ // and this host element was NOT created with SSR
237
+ // let's pick out the inner content for slot projection
238
+ // create a node to represent where the original
239
+ // content was first placed, which is useful later on
240
+ // DOM WRITE!!
241
+ elm['s-sc'] = scopeId;
242
+ elm.classList.add(scopeId + '-h');
243
+ }
244
+ endAttachStyles();
245
+ };
246
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
239
247
  /**
240
248
  * Production setAccessor() function based on Preact by
241
249
  * Jason Miller (@developit)
@@ -276,7 +284,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
276
284
  }
277
285
  }
278
286
  }
279
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
287
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
280
288
  newValue = newValue === true ? '' : newValue;
281
289
  {
282
290
  elm.setAttribute(memberName, newValue);
@@ -289,7 +297,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
289
297
  // if the element passed in is a shadow root, which is a document fragment
290
298
  // then we want to be adding attrs/props to the shadow root's "host" element
291
299
  // if it's not a shadow root, then we add attrs/props to the same element
292
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
300
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
293
301
  ? newVnode.$elm$.host
294
302
  : newVnode.$elm$;
295
303
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -307,6 +315,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
307
315
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
308
316
  }
309
317
  };
318
+ /**
319
+ * Create a DOM Node corresponding to one of the children of a given VNode.
320
+ *
321
+ * @param oldParentVNode the parent VNode from the previous render
322
+ * @param newParentVNode the parent VNode from the current render
323
+ * @param childIndex the index of the VNode, in the _new_ parent node's
324
+ * children, for which we will create a new DOM node
325
+ * @param parentElm the parent DOM node which our new node will be a child of
326
+ * @returns the newly created node
327
+ */
310
328
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
311
329
  // tslint:disable-next-line: prefer-const
312
330
  const newVNode = newParentVNode.$children$[childIndex];
@@ -364,6 +382,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
364
382
  }
365
383
  }
366
384
  };
385
+ /**
386
+ * Reconcile the children of a new VNode with the children of an old VNode by
387
+ * traversing the two collections of children, identifying nodes that are
388
+ * conserved or changed, calling out to `patch` to make any necessary
389
+ * updates to the DOM, and rearranging DOM nodes as needed.
390
+ *
391
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
392
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
393
+ * 'windows' by storing start and end indices and references to the
394
+ * corresponding array entries. Initially the two 'windows' are basically equal
395
+ * to the entire array, but we progressively narrow the windows until there are
396
+ * no children left to update by doing the following:
397
+ *
398
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
399
+ * that if we have an initial array like the following we'll end up dealing
400
+ * only with a window bounded by the highlighted elements:
401
+ *
402
+ * [null, null, VNode1 , ... , VNode2, null, null]
403
+ * ^^^^^^ ^^^^^^
404
+ *
405
+ * 2. Check to see if the elements at the head and tail positions are equal
406
+ * across the windows. This will basically detect elements which haven't
407
+ * been added, removed, or changed position, i.e. if you had the following
408
+ * VNode elements (represented as HTML):
409
+ *
410
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
411
+ * newVNode: `<div><p><span>THERE</span></p></div>`
412
+ *
413
+ * Then when comparing the children of the `<div>` tag we check the equality
414
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
415
+ * same tag in the same position, we'd be able to avoid completely
416
+ * re-rendering the subtree under them with a new DOM element and would just
417
+ * call out to `patch` to handle reconciling their children and so on.
418
+ *
419
+ * 3. Check, for both windows, to see if the element at the beginning of the
420
+ * window corresponds to the element at the end of the other window. This is
421
+ * a heuristic which will let us identify _some_ situations in which
422
+ * elements have changed position, for instance it _should_ detect that the
423
+ * children nodes themselves have not changed but merely moved in the
424
+ * following example:
425
+ *
426
+ * oldVNode: `<div><element-one /><element-two /></div>`
427
+ * newVNode: `<div><element-two /><element-one /></div>`
428
+ *
429
+ * If we find cases like this then we also need to move the concrete DOM
430
+ * elements corresponding to the moved children to write the re-order to the
431
+ * DOM.
432
+ *
433
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
434
+ * nodes in the old children which have the same key as the first element in
435
+ * our window on the new children. If we find such a node we handle calling
436
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
437
+ * what we find.
438
+ *
439
+ * Finally, once we've narrowed our 'windows' to the point that either of them
440
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
441
+ * insertion or deletion that needs to happen to get a DOM state that correctly
442
+ * reflects the new child VNodes. If, for instance, after our window on the old
443
+ * children has collapsed we still have more nodes on the new children that
444
+ * we haven't dealt with yet then we need to add them, or if the new children
445
+ * collapse but we still have unhandled _old_ children then we need to make
446
+ * sure the corresponding DOM nodes are removed.
447
+ *
448
+ * @param parentElm the node into which the parent VNode is rendered
449
+ * @param oldCh the old children of the parent node
450
+ * @param newVNode the new VNode which will replace the parent
451
+ * @param newCh the new children of the parent node
452
+ */
367
453
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
368
454
  let oldStartIdx = 0;
369
455
  let newStartIdx = 0;
@@ -376,7 +462,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
376
462
  let node;
377
463
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
378
464
  if (oldStartVnode == null) {
379
- // Vnode might have been moved left
465
+ // VNode might have been moved left
380
466
  oldStartVnode = oldCh[++oldStartIdx];
381
467
  }
382
468
  else if (oldEndVnode == null) {
@@ -389,34 +475,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
389
475
  newEndVnode = newCh[--newEndIdx];
390
476
  }
391
477
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
478
+ // if the start nodes are the same then we should patch the new VNode
479
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
480
+ // indices to reflect that. We don't need to move any DOM Nodes around
481
+ // since things are matched up in order.
392
482
  patch(oldStartVnode, newStartVnode);
393
483
  oldStartVnode = oldCh[++oldStartIdx];
394
484
  newStartVnode = newCh[++newStartIdx];
395
485
  }
396
486
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
487
+ // likewise, if the end nodes are the same we patch new onto old and
488
+ // decrement our end indices, and also likewise in this case we don't
489
+ // need to move any DOM Nodes.
397
490
  patch(oldEndVnode, newEndVnode);
398
491
  oldEndVnode = oldCh[--oldEndIdx];
399
492
  newEndVnode = newCh[--newEndIdx];
400
493
  }
401
494
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
402
495
  patch(oldStartVnode, newEndVnode);
496
+ // We need to move the element for `oldStartVnode` into a position which
497
+ // will be appropriate for `newEndVnode`. For this we can use
498
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
499
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
500
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
501
+ //
502
+ // <old-start-node />
503
+ // <some-intervening-node />
504
+ // <old-end-node />
505
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
506
+ // <next-sibling />
507
+ //
508
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
509
+ // the node for `oldStartVnode` at the end of the children of
510
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
511
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
512
+ // append it to the children of the parent element.
403
513
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
404
514
  oldStartVnode = oldCh[++oldStartIdx];
405
515
  newEndVnode = newCh[--newEndIdx];
406
516
  }
407
517
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
408
518
  patch(oldEndVnode, newStartVnode);
519
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
520
+ // the same node, so since we're here we know that they are not. Thus we
521
+ // can move the element for `oldEndVnode` _before_ the element for
522
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
523
+ // future.
409
524
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
410
525
  oldEndVnode = oldCh[--oldEndIdx];
411
526
  newStartVnode = newCh[++newStartIdx];
412
527
  }
413
528
  else {
414
529
  {
415
- // new element
530
+ // We either didn't find an element in the old children that matches
531
+ // the key of the first new child OR the build is not using `key`
532
+ // attributes at all. In either case we need to create a new element
533
+ // for the new node.
416
534
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
417
535
  newStartVnode = newCh[++newStartIdx];
418
536
  }
419
537
  if (node) {
538
+ // if we created a new node then handle inserting it to the DOM
420
539
  {
421
540
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
422
541
  }
@@ -424,27 +543,55 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
424
543
  }
425
544
  }
426
545
  if (oldStartIdx > oldEndIdx) {
546
+ // we have some more new nodes to add which don't match up with old nodes
427
547
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
428
548
  }
429
549
  else if (newStartIdx > newEndIdx) {
550
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
551
+ // in the new array, so lets remove them (which entails cleaning up the
552
+ // relevant DOM nodes)
430
553
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
431
554
  }
432
555
  };
433
- const isSameVnode = (vnode1, vnode2) => {
556
+ /**
557
+ * Compare two VNodes to determine if they are the same
558
+ *
559
+ * **NB**: This function is an equality _heuristic_ based on the available
560
+ * information set on the two VNodes and can be misleading under certain
561
+ * circumstances. In particular, if the two nodes do not have `key` attrs
562
+ * (available under `$key$` on VNodes) then the function falls back on merely
563
+ * checking that they have the same tag.
564
+ *
565
+ * So, in other words, if `key` attrs are not set on VNodes which may be
566
+ * changing order within a `children` array or something along those lines then
567
+ * we could obtain a false positive and then have to do needless re-rendering.
568
+ *
569
+ * @param leftVNode the first VNode to check
570
+ * @param rightVNode the second VNode to check
571
+ * @returns whether they're equal or not
572
+ */
573
+ const isSameVnode = (leftVNode, rightVNode) => {
434
574
  // compare if two vnode to see if they're "technically" the same
435
575
  // need to have the same element tag, and same key to be the same
436
- if (vnode1.$tag$ === vnode2.$tag$) {
576
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
437
577
  return true;
438
578
  }
439
579
  return false;
440
580
  };
581
+ /**
582
+ * Handle reconciling an outdated VNode with a new one which corresponds to
583
+ * it. This function handles flushing updates to the DOM and reconciling the
584
+ * children of the two nodes (if any).
585
+ *
586
+ * @param oldVNode an old VNode whose DOM element and children we want to update
587
+ * @param newVNode a new VNode representing an updated version of the old one
588
+ */
441
589
  const patch = (oldVNode, newVNode) => {
442
590
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
443
591
  const oldChildren = oldVNode.$children$;
444
592
  const newChildren = newVNode.$children$;
445
593
  const tag = newVNode.$tag$;
446
594
  {
447
- // element node
448
595
  {
449
596
  if (tag === 'slot')
450
597
  ;
@@ -457,6 +604,7 @@ const patch = (oldVNode, newVNode) => {
457
604
  }
458
605
  if (oldChildren !== null && newChildren !== null) {
459
606
  // looks like there's child vnodes for both the old and new vnodes
607
+ // so we need to call `updateChildren` to reconcile them
460
608
  updateChildren(elm, oldChildren, newVNode, newChildren);
461
609
  }
462
610
  else if (newChildren !== null) {
@@ -480,7 +628,7 @@ const renderVdom = (hostRef, renderFnResults) => {
480
628
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
481
629
  }
482
630
  rootVnode.$tag$ = null;
483
- rootVnode.$flags$ |= 4 /* isHost */;
631
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
484
632
  hostRef.$vnode$ = rootVnode;
485
633
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
486
634
  {
@@ -489,18 +637,6 @@ const renderVdom = (hostRef, renderFnResults) => {
489
637
  // synchronous patch
490
638
  patch(oldVNode, rootVnode);
491
639
  };
492
- /**
493
- * Helper function to create & dispatch a custom Event on a provided target
494
- * @param elm the target of the Event
495
- * @param name the name to give the custom Event
496
- * @param opts options for configuring a custom Event
497
- * @returns the custom Event
498
- */
499
- const emitEvent = (elm, name, opts) => {
500
- const ev = plt.ce(name, opts);
501
- elm.dispatchEvent(ev);
502
- return ev;
503
- };
504
640
  const attachToAncestor = (hostRef, ancestorComponent) => {
505
641
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
506
642
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -508,10 +644,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
508
644
  };
509
645
  const scheduleUpdate = (hostRef, isInitialLoad) => {
510
646
  {
511
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
647
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
512
648
  }
513
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
514
- hostRef.$flags$ |= 512 /* needsRerender */;
649
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
650
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
515
651
  return;
516
652
  }
517
653
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -527,7 +663,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
527
663
  let promise;
528
664
  if (isInitialLoad) {
529
665
  {
530
- hostRef.$flags$ |= 256 /* isListenReady */;
666
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
531
667
  if (hostRef.$queuedListeners$) {
532
668
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
533
669
  hostRef.$queuedListeners$ = null;
@@ -567,7 +703,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
567
703
  }
568
704
  else {
569
705
  Promise.all(childrenPromises).then(postUpdate);
570
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
706
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
571
707
  childrenPromises.length = 0;
572
708
  }
573
709
  }
@@ -576,10 +712,10 @@ const callRender = (hostRef, instance, elm) => {
576
712
  try {
577
713
  instance = instance.render() ;
578
714
  {
579
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
715
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
580
716
  }
581
717
  {
582
- hostRef.$flags$ |= 2 /* hasRendered */;
718
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
583
719
  }
584
720
  {
585
721
  {
@@ -602,8 +738,8 @@ const postUpdateComponent = (hostRef) => {
602
738
  const elm = hostRef.$hostElement$;
603
739
  const endPostUpdate = createTime('postUpdate', tagName);
604
740
  const ancestorComponent = hostRef.$ancestorComponent$;
605
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
606
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
741
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
742
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
607
743
  {
608
744
  // DOM WRITE!
609
745
  addHydratedFlag(elm);
@@ -626,10 +762,10 @@ const postUpdateComponent = (hostRef) => {
626
762
  hostRef.$onRenderResolve$();
627
763
  hostRef.$onRenderResolve$ = undefined;
628
764
  }
629
- if (hostRef.$flags$ & 512 /* needsRerender */) {
765
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
630
766
  nextTick(() => scheduleUpdate(hostRef, false));
631
767
  }
632
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
768
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
633
769
  }
634
770
  // ( •_•)
635
771
  // ( •_•)>⌐■-■
@@ -659,44 +795,6 @@ const then = (promise, thenFn) => {
659
795
  };
660
796
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
661
797
  ;
662
- /**
663
- * Parse a new property value for a given property type.
664
- *
665
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
666
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
667
- * 1. `any`, the type given to `propValue` in the function signature
668
- * 2. the type stored from `propType`.
669
- *
670
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
671
- *
672
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
673
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
674
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
675
- * ```tsx
676
- * <my-cmp prop-val={0}></my-cmp>
677
- * ```
678
- *
679
- * HTML prop values on the other hand, will always a string
680
- *
681
- * @param propValue the new value to coerce to some type
682
- * @param propType the type of the prop, expressed as a binary number
683
- * @returns the parsed/coerced value
684
- */
685
- const parsePropertyValue = (propValue, propType) => {
686
- // ensure this value is of the correct prop type
687
- if (propValue != null && !isComplexType(propValue)) {
688
- if (propType & 4 /* Boolean */) {
689
- // per the HTML spec, any string value means it is a boolean true value
690
- // but we'll cheat here and say that the string "false" is the boolean false
691
- return propValue === 'false' ? false : propValue === '' || !!propValue;
692
- }
693
- // redundant return here for better minification
694
- return propValue;
695
- }
696
- // not sure exactly what type we want
697
- // so no need to change to a different type
698
- return propValue;
699
- };
700
798
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
701
799
  const setValue = (ref, propName, newVal, cmpMeta) => {
702
800
  // check our new property value against our internal value
@@ -708,12 +806,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
708
806
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
709
807
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
710
808
  const didValueChange = newVal !== oldVal && !areBothNaN;
711
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
809
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
712
810
  // gadzooks! the property's value has changed!!
713
811
  // set our new value!
714
812
  hostRef.$instanceValues$.set(propName, newVal);
715
813
  if (instance) {
716
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
814
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
717
815
  // looks like this value actually changed, so we've got work to do!
718
816
  // but only if we've already rendered, otherwise just chill out
719
817
  // queue that we need to do an update, but don't worry about queuing
@@ -723,14 +821,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
723
821
  }
724
822
  }
725
823
  };
824
+ /**
825
+ * Attach a series of runtime constructs to a compiled Stencil component
826
+ * constructor, including getters and setters for the `@Prop` and `@State`
827
+ * decorators, callbacks for when attributes change, and so on.
828
+ *
829
+ * @param Cstr the constructor for a component that we need to process
830
+ * @param cmpMeta metadata collected previously about the component
831
+ * @param flags a number used to store a series of bit flags
832
+ * @returns a reference to the same constructor passed in (but now mutated)
833
+ */
726
834
  const proxyComponent = (Cstr, cmpMeta, flags) => {
727
835
  if (cmpMeta.$members$) {
728
836
  // It's better to have a const than two Object.entries()
729
837
  const members = Object.entries(cmpMeta.$members$);
730
838
  const prototype = Cstr.prototype;
731
839
  members.map(([memberName, [memberFlags]]) => {
732
- if ((memberFlags & 31 /* Prop */ ||
733
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
840
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
841
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
734
842
  // proxyComponent - prop
735
843
  Object.defineProperty(prototype, memberName, {
736
844
  get() {
@@ -746,7 +854,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
746
854
  });
747
855
  }
748
856
  });
749
- if ((flags & 1 /* isElementConstructor */)) {
857
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
750
858
  const attrNameToPropName = new Map();
751
859
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
752
860
  plt.jmp(() => {
@@ -802,11 +910,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
802
910
  // create an array of attributes to observe
803
911
  // and also create a map of html attribute name to js property name
804
912
  Cstr.observedAttributes = members
805
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
913
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
806
914
  .map(([propName, m]) => {
807
915
  const attrName = m[1] || propName;
808
916
  attrNameToPropName.set(attrName, propName);
809
- if (m[0] & 512 /* ReflectAttr */) {
917
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
810
918
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
811
919
  }
812
920
  return attrName;
@@ -817,10 +925,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
817
925
  };
818
926
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
819
927
  // initializeComponent
820
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
928
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
821
929
  {
822
930
  // we haven't initialized this element yet
823
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
931
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
824
932
  // lazy loaded components
825
933
  // request the component's implementation to be
826
934
  // wired up with the host element
@@ -832,7 +940,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
832
940
  endLoad();
833
941
  }
834
942
  if (!Cstr.isProxied) {
835
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
943
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
836
944
  Cstr.isProxied = true;
837
945
  }
838
946
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -840,7 +948,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
840
948
  // but let's keep track of when we start and stop
841
949
  // so that the getters/setters don't incorrectly step on data
842
950
  {
843
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
951
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
844
952
  }
845
953
  // construct the lazy-loaded component implementation
846
954
  // passing the hostRef is very important during
@@ -853,7 +961,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
853
961
  consoleError(e);
854
962
  }
855
963
  {
856
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
964
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
857
965
  }
858
966
  endNewInstance();
859
967
  }
@@ -863,7 +971,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
863
971
  const scopeId = getScopeId(cmpMeta);
864
972
  if (!styles.has(scopeId)) {
865
973
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
866
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
974
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
867
975
  endRegisterStyles();
868
976
  }
869
977
  }
@@ -885,13 +993,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
885
993
  }
886
994
  };
887
995
  const connectedCallback = (elm) => {
888
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
996
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
889
997
  const hostRef = getHostRef(elm);
890
998
  const cmpMeta = hostRef.$cmpMeta$;
891
999
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
892
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1000
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
893
1001
  // first time this component has connected
894
- hostRef.$flags$ |= 1 /* hasConnected */;
1002
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
895
1003
  {
896
1004
  // find the first ancestor component (if there is one) and register
897
1005
  // this component as one of the actively loading child components for its ancestor
@@ -911,7 +1019,7 @@ const connectedCallback = (elm) => {
911
1019
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
912
1020
  if (cmpMeta.$members$) {
913
1021
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
914
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1022
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
915
1023
  const value = elm[memberName];
916
1024
  delete elm[memberName];
917
1025
  elm[memberName] = value;
@@ -932,7 +1040,7 @@ const connectedCallback = (elm) => {
932
1040
  }
933
1041
  };
934
1042
  const disconnectedCallback = (elm) => {
935
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1043
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
936
1044
  const hostRef = getHostRef(elm);
937
1045
  {
938
1046
  if (hostRef.$rmListeners$) {
@@ -980,7 +1088,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
980
1088
  super(self);
981
1089
  self = this;
982
1090
  registerHost(self, cmpMeta);
983
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1091
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
984
1092
  // this component is using shadow dom
985
1093
  // and this browser supports shadow dom
986
1094
  // add the read-only property "shadowRoot" to the host element
@@ -1015,7 +1123,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1015
1123
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1016
1124
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1017
1125
  cmpTags.push(tagName);
1018
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1126
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1019
1127
  }
1020
1128
  });
1021
1129
  });
@@ -1037,7 +1145,41 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1037
1145
  // Fallback appLoad event
1038
1146
  endBootstrap();
1039
1147
  };
1040
- const hostRefs = new WeakMap();
1148
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1149
+ if (listeners) {
1150
+ listeners.map(([flags, name, method]) => {
1151
+ const target = getHostListenerTarget(elm, flags) ;
1152
+ const handler = hostListenerProxy(hostRef, method);
1153
+ const opts = hostListenerOpts(flags);
1154
+ plt.ael(target, name, handler, opts);
1155
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1156
+ });
1157
+ }
1158
+ };
1159
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1160
+ try {
1161
+ {
1162
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1163
+ // instance is ready, let's call it's member method for this event
1164
+ hostRef.$lazyInstance$[methodName](ev);
1165
+ }
1166
+ else {
1167
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1168
+ }
1169
+ }
1170
+ }
1171
+ catch (e) {
1172
+ consoleError(e);
1173
+ }
1174
+ };
1175
+ const getHostListenerTarget = (elm, flags) => {
1176
+ if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
1177
+ return doc.body;
1178
+ return elm;
1179
+ };
1180
+ // prettier-ignore
1181
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1182
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1041
1183
  const getHostRef = (ref) => hostRefs.get(ref);
1042
1184
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1043
1185
  const registerHost = (elm, cmpMeta) => {
@@ -1079,14 +1221,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1079
1221
  return importedModule[exportName];
1080
1222
  }, consoleError);
1081
1223
  };
1082
- const styles = new Map();
1224
+ const styles = /*@__PURE__*/ new Map();
1225
+ const win = typeof window !== 'undefined' ? window : {};
1226
+ const doc = win.document || { head: {} };
1227
+ const plt = {
1228
+ $flags$: 0,
1229
+ $resourcesUrl$: '',
1230
+ jmp: (h) => h(),
1231
+ raf: (h) => requestAnimationFrame(h),
1232
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1233
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1234
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1235
+ };
1236
+ const promiseResolve = (v) => Promise.resolve(v);
1237
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1238
+ try {
1239
+ new CSSStyleSheet();
1240
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1241
+ }
1242
+ catch (e) { }
1243
+ return false;
1244
+ })()
1245
+ ;
1083
1246
  const queueDomReads = [];
1084
1247
  const queueDomWrites = [];
1085
1248
  const queueTask = (queue, write) => (cb) => {
1086
1249
  queue.push(cb);
1087
1250
  if (!queuePending) {
1088
1251
  queuePending = true;
1089
- if (write && plt.$flags$ & 4 /* queueSync */) {
1252
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1090
1253
  nextTick(flush);
1091
1254
  }
1092
1255
  else {