pushfeedback 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/feedback-button_2.cjs.entry.js +1024 -0
  3. package/dist/cjs/index-ecaab1ef.js +1466 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/pushfeedback.cjs.js +19 -0
  7. package/dist/collection/collection-manifest.json +13 -0
  8. package/dist/collection/components/feedback-button/feedback-button.css +16 -0
  9. package/dist/collection/components/feedback-button/feedback-button.js +263 -0
  10. package/dist/collection/components/feedback-modal/feedback-modal.css +209 -0
  11. package/dist/collection/components/feedback-modal/feedback-modal.js +462 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/components/feedback-button.d.ts +11 -0
  14. package/dist/components/feedback-button.js +88 -0
  15. package/dist/components/feedback-modal.d.ts +11 -0
  16. package/dist/components/feedback-modal.js +6 -0
  17. package/dist/components/feedback-modal2.js +1007 -0
  18. package/dist/components/index.d.ts +23 -0
  19. package/dist/components/index.js +3 -0
  20. package/dist/esm/feedback-button_2.entry.js +1019 -0
  21. package/dist/esm/index-4051fc1e.js +1440 -0
  22. package/dist/esm/index.js +1 -0
  23. package/dist/esm/loader.js +17 -0
  24. package/dist/esm/polyfills/core-js.js +11 -0
  25. package/dist/esm/polyfills/css-shim.js +1 -0
  26. package/dist/esm/polyfills/dom.js +79 -0
  27. package/dist/esm/polyfills/es5-html-element.js +1 -0
  28. package/dist/esm/polyfills/index.js +34 -0
  29. package/dist/esm/polyfills/system.js +6 -0
  30. package/dist/esm/pushfeedback.js +17 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/pushfeedback/index.esm.js +0 -0
  34. package/dist/pushfeedback/p-a5896889.entry.js +1 -0
  35. package/dist/pushfeedback/p-e53ad7c2.js +2 -0
  36. package/dist/pushfeedback/pushfeedback.css +1 -0
  37. package/dist/pushfeedback/pushfeedback.esm.js +1 -0
  38. package/dist/types/components/feedback-button/feedback-button.d.ts +18 -0
  39. package/dist/types/components/feedback-modal/feedback-modal.d.ts +40 -0
  40. package/dist/types/components.d.ts +100 -0
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1581 -0
  43. package/loader/cdn.js +3 -0
  44. package/loader/index.cjs.js +3 -0
  45. package/loader/index.d.ts +12 -0
  46. package/loader/index.es2017.js +3 -0
  47. package/loader/index.js +4 -0
  48. package/loader/package.json +11 -0
  49. package/package.json +39 -0
  50. package/readme.md +75 -0
@@ -0,0 +1,1466 @@
1
+ 'use strict';
2
+
3
+ function _interopNamespace(e) {
4
+ if (e && e.__esModule) return e;
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n['default'] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const NAMESPACE = 'pushfeedback';
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
+ */
33
+ let scopeId;
34
+ let hostTagName;
35
+ let isSvgMode = false;
36
+ let queuePending = false;
37
+ const createTime = (fnName, tagName = '') => {
38
+ {
39
+ return () => {
40
+ return;
41
+ };
42
+ }
43
+ };
44
+ const uniqueTime = (key, measureText) => {
45
+ {
46
+ return () => {
47
+ return;
48
+ };
49
+ }
50
+ };
51
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
52
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
53
+ /**
54
+ * Default style mode id
55
+ */
56
+ /**
57
+ * Reusable empty obj/array
58
+ * Don't add values to these!!
59
+ */
60
+ const EMPTY_OBJ = {};
61
+ /**
62
+ * Namespaces
63
+ */
64
+ const SVG_NS = 'http://www.w3.org/2000/svg';
65
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
66
+ const isDef = (v) => v != null;
67
+ const isComplexType = (o) => {
68
+ // https://jsperf.com/typeof-fn-object/5
69
+ o = typeof o;
70
+ return o === 'object' || o === 'function';
71
+ };
72
+ /**
73
+ * Production h() function based on Preact by
74
+ * Jason Miller (@developit)
75
+ * Licensed under the MIT License
76
+ * https://github.com/developit/preact/blob/master/LICENSE
77
+ *
78
+ * Modified for Stencil's compiler and vdom
79
+ */
80
+ // const stack: any[] = [];
81
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
82
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
83
+ const h = (nodeName, vnodeData, ...children) => {
84
+ let child = null;
85
+ let key = null;
86
+ let simple = false;
87
+ let lastSimple = false;
88
+ const vNodeChildren = [];
89
+ const walk = (c) => {
90
+ for (let i = 0; i < c.length; i++) {
91
+ child = c[i];
92
+ if (Array.isArray(child)) {
93
+ walk(child);
94
+ }
95
+ else if (child != null && typeof child !== 'boolean') {
96
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
97
+ child = String(child);
98
+ }
99
+ if (simple && lastSimple) {
100
+ // If the previous child was simple (string), we merge both
101
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
102
+ }
103
+ else {
104
+ // Append a new vNode, if it's text, we create a text vNode
105
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
106
+ }
107
+ lastSimple = simple;
108
+ }
109
+ }
110
+ };
111
+ walk(children);
112
+ if (vnodeData) {
113
+ // normalize class / classname attributes
114
+ if (vnodeData.key) {
115
+ key = vnodeData.key;
116
+ }
117
+ {
118
+ const classData = vnodeData.className || vnodeData.class;
119
+ if (classData) {
120
+ vnodeData.class =
121
+ typeof classData !== 'object'
122
+ ? classData
123
+ : Object.keys(classData)
124
+ .filter((k) => classData[k])
125
+ .join(' ');
126
+ }
127
+ }
128
+ }
129
+ const vnode = newVNode(nodeName, null);
130
+ vnode.$attrs$ = vnodeData;
131
+ if (vNodeChildren.length > 0) {
132
+ vnode.$children$ = vNodeChildren;
133
+ }
134
+ {
135
+ vnode.$key$ = key;
136
+ }
137
+ return vnode;
138
+ };
139
+ const newVNode = (tag, text) => {
140
+ const vnode = {
141
+ $flags$: 0,
142
+ $tag$: tag,
143
+ $text$: text,
144
+ $elm$: null,
145
+ $children$: null,
146
+ };
147
+ {
148
+ vnode.$attrs$ = null;
149
+ }
150
+ {
151
+ vnode.$key$ = null;
152
+ }
153
+ return vnode;
154
+ };
155
+ const Host = {};
156
+ const isHost = (node) => node && node.$tag$ === Host;
157
+ /**
158
+ * Parse a new property value for a given property type.
159
+ *
160
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
161
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
162
+ * 1. `any`, the type given to `propValue` in the function signature
163
+ * 2. the type stored from `propType`.
164
+ *
165
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
166
+ *
167
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
168
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
169
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
170
+ * ```tsx
171
+ * <my-cmp prop-val={0}></my-cmp>
172
+ * ```
173
+ *
174
+ * HTML prop values on the other hand, will always a string
175
+ *
176
+ * @param propValue the new value to coerce to some type
177
+ * @param propType the type of the prop, expressed as a binary number
178
+ * @returns the parsed/coerced value
179
+ */
180
+ const parsePropertyValue = (propValue, propType) => {
181
+ // ensure this value is of the correct prop type
182
+ if (propValue != null && !isComplexType(propValue)) {
183
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
184
+ // per the HTML spec, any string value means it is a boolean true value
185
+ // but we'll cheat here and say that the string "false" is the boolean false
186
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
187
+ }
188
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
189
+ // could have been passed as a number or boolean
190
+ // but we still want it as a string
191
+ return String(propValue);
192
+ }
193
+ // redundant return here for better minification
194
+ return propValue;
195
+ }
196
+ // not sure exactly what type we want
197
+ // so no need to change to a different type
198
+ return propValue;
199
+ };
200
+ /**
201
+ * Helper function to create & dispatch a custom Event on a provided target
202
+ * @param elm the target of the Event
203
+ * @param name the name to give the custom Event
204
+ * @param opts options for configuring a custom Event
205
+ * @returns the custom Event
206
+ */
207
+ const emitEvent = (elm, name, opts) => {
208
+ const ev = plt.ce(name, opts);
209
+ elm.dispatchEvent(ev);
210
+ return ev;
211
+ };
212
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
213
+ const registerStyle = (scopeId, cssText, allowCS) => {
214
+ let style = styles.get(scopeId);
215
+ if (supportsConstructableStylesheets && allowCS) {
216
+ style = (style || new CSSStyleSheet());
217
+ if (typeof style === 'string') {
218
+ style = cssText;
219
+ }
220
+ else {
221
+ style.replaceSync(cssText);
222
+ }
223
+ }
224
+ else {
225
+ style = cssText;
226
+ }
227
+ styles.set(scopeId, style);
228
+ };
229
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
230
+ let scopeId = getScopeId(cmpMeta);
231
+ const style = styles.get(scopeId);
232
+ // if an element is NOT connected then getRootNode() will return the wrong root node
233
+ // so the fallback is to always use the document for the root node in those cases
234
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
235
+ if (style) {
236
+ if (typeof style === 'string') {
237
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
238
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
239
+ let styleElm;
240
+ if (!appliedStyles) {
241
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
242
+ }
243
+ if (!appliedStyles.has(scopeId)) {
244
+ {
245
+ {
246
+ styleElm = doc.createElement('style');
247
+ styleElm.innerHTML = style;
248
+ }
249
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
250
+ }
251
+ if (appliedStyles) {
252
+ appliedStyles.add(scopeId);
253
+ }
254
+ }
255
+ }
256
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
257
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
258
+ }
259
+ }
260
+ return scopeId;
261
+ };
262
+ const attachStyles = (hostRef) => {
263
+ const cmpMeta = hostRef.$cmpMeta$;
264
+ const elm = hostRef.$hostElement$;
265
+ const flags = cmpMeta.$flags$;
266
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
267
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
268
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
269
+ // only required when we're NOT using native shadow dom (slot)
270
+ // or this browser doesn't support native shadow dom
271
+ // and this host element was NOT created with SSR
272
+ // let's pick out the inner content for slot projection
273
+ // create a node to represent where the original
274
+ // content was first placed, which is useful later on
275
+ // DOM WRITE!!
276
+ elm['s-sc'] = scopeId;
277
+ elm.classList.add(scopeId + '-h');
278
+ }
279
+ endAttachStyles();
280
+ };
281
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
282
+ /**
283
+ * Production setAccessor() function based on Preact by
284
+ * Jason Miller (@developit)
285
+ * Licensed under the MIT License
286
+ * https://github.com/developit/preact/blob/master/LICENSE
287
+ *
288
+ * Modified for Stencil's compiler and vdom
289
+ */
290
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
291
+ if (oldValue !== newValue) {
292
+ let isProp = isMemberInElement(elm, memberName);
293
+ let ln = memberName.toLowerCase();
294
+ if (memberName === 'class') {
295
+ const classList = elm.classList;
296
+ const oldClasses = parseClassList(oldValue);
297
+ const newClasses = parseClassList(newValue);
298
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
299
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
300
+ }
301
+ else if (memberName === 'style') {
302
+ // update style attribute, css properties and values
303
+ {
304
+ for (const prop in oldValue) {
305
+ if (!newValue || newValue[prop] == null) {
306
+ if (prop.includes('-')) {
307
+ elm.style.removeProperty(prop);
308
+ }
309
+ else {
310
+ elm.style[prop] = '';
311
+ }
312
+ }
313
+ }
314
+ }
315
+ for (const prop in newValue) {
316
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
317
+ if (prop.includes('-')) {
318
+ elm.style.setProperty(prop, newValue[prop]);
319
+ }
320
+ else {
321
+ elm.style[prop] = newValue[prop];
322
+ }
323
+ }
324
+ }
325
+ }
326
+ else if (memberName === 'key')
327
+ ;
328
+ else if (memberName === 'ref') {
329
+ // minifier will clean this up
330
+ if (newValue) {
331
+ newValue(elm);
332
+ }
333
+ }
334
+ else if ((!isProp ) &&
335
+ memberName[0] === 'o' &&
336
+ memberName[1] === 'n') {
337
+ // Event Handlers
338
+ // so if the member name starts with "on" and the 3rd characters is
339
+ // a capital letter, and it's not already a member on the element,
340
+ // then we're assuming it's an event listener
341
+ if (memberName[2] === '-') {
342
+ // on- prefixed events
343
+ // allows to be explicit about the dom event to listen without any magic
344
+ // under the hood:
345
+ // <my-cmp on-click> // listens for "click"
346
+ // <my-cmp on-Click> // listens for "Click"
347
+ // <my-cmp on-ionChange> // listens for "ionChange"
348
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
349
+ memberName = memberName.slice(3);
350
+ }
351
+ else if (isMemberInElement(win, ln)) {
352
+ // standard event
353
+ // the JSX attribute could have been "onMouseOver" and the
354
+ // member name "onmouseover" is on the window's prototype
355
+ // so let's add the listener "mouseover", which is all lowercased
356
+ memberName = ln.slice(2);
357
+ }
358
+ else {
359
+ // custom event
360
+ // the JSX attribute could have been "onMyCustomEvent"
361
+ // so let's trim off the "on" prefix and lowercase the first character
362
+ // and add the listener "myCustomEvent"
363
+ // except for the first character, we keep the event name case
364
+ memberName = ln[2] + memberName.slice(3);
365
+ }
366
+ if (oldValue) {
367
+ plt.rel(elm, memberName, oldValue, false);
368
+ }
369
+ if (newValue) {
370
+ plt.ael(elm, memberName, newValue, false);
371
+ }
372
+ }
373
+ else {
374
+ // Set property if it exists and it's not a SVG
375
+ const isComplex = isComplexType(newValue);
376
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
377
+ try {
378
+ if (!elm.tagName.includes('-')) {
379
+ const n = newValue == null ? '' : newValue;
380
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
381
+ if (memberName === 'list') {
382
+ isProp = false;
383
+ }
384
+ else if (oldValue == null || elm[memberName] != n) {
385
+ elm[memberName] = n;
386
+ }
387
+ }
388
+ else {
389
+ elm[memberName] = newValue;
390
+ }
391
+ }
392
+ catch (e) { }
393
+ }
394
+ /**
395
+ * Need to manually update attribute if:
396
+ * - memberName is not an attribute
397
+ * - if we are rendering the host element in order to reflect attribute
398
+ * - if it's a SVG, since properties might not work in <svg>
399
+ * - if the newValue is null/undefined or 'false'.
400
+ */
401
+ let xlink = false;
402
+ {
403
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
404
+ memberName = ln;
405
+ xlink = true;
406
+ }
407
+ }
408
+ if (newValue == null || newValue === false) {
409
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
410
+ if (xlink) {
411
+ elm.removeAttributeNS(XLINK_NS, memberName);
412
+ }
413
+ else {
414
+ elm.removeAttribute(memberName);
415
+ }
416
+ }
417
+ }
418
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
419
+ newValue = newValue === true ? '' : newValue;
420
+ if (xlink) {
421
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
422
+ }
423
+ else {
424
+ elm.setAttribute(memberName, newValue);
425
+ }
426
+ }
427
+ }
428
+ }
429
+ };
430
+ const parseClassListRegex = /\s/;
431
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
432
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
433
+ // if the element passed in is a shadow root, which is a document fragment
434
+ // then we want to be adding attrs/props to the shadow root's "host" element
435
+ // if it's not a shadow root, then we add attrs/props to the same element
436
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
437
+ ? newVnode.$elm$.host
438
+ : newVnode.$elm$;
439
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
440
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
441
+ {
442
+ // remove attributes no longer present on the vnode by setting them to undefined
443
+ for (memberName in oldVnodeAttrs) {
444
+ if (!(memberName in newVnodeAttrs)) {
445
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
446
+ }
447
+ }
448
+ }
449
+ // add new & update changed attributes
450
+ for (memberName in newVnodeAttrs) {
451
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
452
+ }
453
+ };
454
+ /**
455
+ * Create a DOM Node corresponding to one of the children of a given VNode.
456
+ *
457
+ * @param oldParentVNode the parent VNode from the previous render
458
+ * @param newParentVNode the parent VNode from the current render
459
+ * @param childIndex the index of the VNode, in the _new_ parent node's
460
+ * children, for which we will create a new DOM node
461
+ * @param parentElm the parent DOM node which our new node will be a child of
462
+ * @returns the newly created node
463
+ */
464
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
465
+ // tslint:disable-next-line: prefer-const
466
+ const newVNode = newParentVNode.$children$[childIndex];
467
+ let i = 0;
468
+ let elm;
469
+ let childNode;
470
+ if (newVNode.$text$ !== null) {
471
+ // create text node
472
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
473
+ }
474
+ else {
475
+ if (!isSvgMode) {
476
+ isSvgMode = newVNode.$tag$ === 'svg';
477
+ }
478
+ // create element
479
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
480
+ );
481
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
482
+ isSvgMode = false;
483
+ }
484
+ // add css classes, attrs, props, listeners, etc.
485
+ {
486
+ updateElement(null, newVNode, isSvgMode);
487
+ }
488
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
489
+ // if there is a scopeId and this is the initial render
490
+ // then let's add the scopeId as a css class
491
+ elm.classList.add((elm['s-si'] = scopeId));
492
+ }
493
+ if (newVNode.$children$) {
494
+ for (i = 0; i < newVNode.$children$.length; ++i) {
495
+ // create the node
496
+ childNode = createElm(oldParentVNode, newVNode, i);
497
+ // return node could have been null
498
+ if (childNode) {
499
+ // append our new node
500
+ elm.appendChild(childNode);
501
+ }
502
+ }
503
+ }
504
+ {
505
+ if (newVNode.$tag$ === 'svg') {
506
+ // Only reset the SVG context when we're exiting <svg> element
507
+ isSvgMode = false;
508
+ }
509
+ else if (elm.tagName === 'foreignObject') {
510
+ // Reenter SVG context when we're exiting <foreignObject> element
511
+ isSvgMode = true;
512
+ }
513
+ }
514
+ }
515
+ return elm;
516
+ };
517
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
518
+ let containerElm = (parentElm);
519
+ let childNode;
520
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
521
+ containerElm = containerElm.shadowRoot;
522
+ }
523
+ for (; startIdx <= endIdx; ++startIdx) {
524
+ if (vnodes[startIdx]) {
525
+ childNode = createElm(null, parentVNode, startIdx);
526
+ if (childNode) {
527
+ vnodes[startIdx].$elm$ = childNode;
528
+ containerElm.insertBefore(childNode, before);
529
+ }
530
+ }
531
+ }
532
+ };
533
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
534
+ for (; startIdx <= endIdx; ++startIdx) {
535
+ if ((vnode = vnodes[startIdx])) {
536
+ elm = vnode.$elm$;
537
+ callNodeRefs(vnode);
538
+ // remove the vnode's element from the dom
539
+ elm.remove();
540
+ }
541
+ }
542
+ };
543
+ /**
544
+ * Reconcile the children of a new VNode with the children of an old VNode by
545
+ * traversing the two collections of children, identifying nodes that are
546
+ * conserved or changed, calling out to `patch` to make any necessary
547
+ * updates to the DOM, and rearranging DOM nodes as needed.
548
+ *
549
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
550
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
551
+ * 'windows' by storing start and end indices and references to the
552
+ * corresponding array entries. Initially the two 'windows' are basically equal
553
+ * to the entire array, but we progressively narrow the windows until there are
554
+ * no children left to update by doing the following:
555
+ *
556
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
557
+ * that if we have an initial array like the following we'll end up dealing
558
+ * only with a window bounded by the highlighted elements:
559
+ *
560
+ * [null, null, VNode1 , ... , VNode2, null, null]
561
+ * ^^^^^^ ^^^^^^
562
+ *
563
+ * 2. Check to see if the elements at the head and tail positions are equal
564
+ * across the windows. This will basically detect elements which haven't
565
+ * been added, removed, or changed position, i.e. if you had the following
566
+ * VNode elements (represented as HTML):
567
+ *
568
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
569
+ * newVNode: `<div><p><span>THERE</span></p></div>`
570
+ *
571
+ * Then when comparing the children of the `<div>` tag we check the equality
572
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
573
+ * same tag in the same position, we'd be able to avoid completely
574
+ * re-rendering the subtree under them with a new DOM element and would just
575
+ * call out to `patch` to handle reconciling their children and so on.
576
+ *
577
+ * 3. Check, for both windows, to see if the element at the beginning of the
578
+ * window corresponds to the element at the end of the other window. This is
579
+ * a heuristic which will let us identify _some_ situations in which
580
+ * elements have changed position, for instance it _should_ detect that the
581
+ * children nodes themselves have not changed but merely moved in the
582
+ * following example:
583
+ *
584
+ * oldVNode: `<div><element-one /><element-two /></div>`
585
+ * newVNode: `<div><element-two /><element-one /></div>`
586
+ *
587
+ * If we find cases like this then we also need to move the concrete DOM
588
+ * elements corresponding to the moved children to write the re-order to the
589
+ * DOM.
590
+ *
591
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
592
+ * nodes in the old children which have the same key as the first element in
593
+ * our window on the new children. If we find such a node we handle calling
594
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
595
+ * what we find.
596
+ *
597
+ * Finally, once we've narrowed our 'windows' to the point that either of them
598
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
599
+ * insertion or deletion that needs to happen to get a DOM state that correctly
600
+ * reflects the new child VNodes. If, for instance, after our window on the old
601
+ * children has collapsed we still have more nodes on the new children that
602
+ * we haven't dealt with yet then we need to add them, or if the new children
603
+ * collapse but we still have unhandled _old_ children then we need to make
604
+ * sure the corresponding DOM nodes are removed.
605
+ *
606
+ * @param parentElm the node into which the parent VNode is rendered
607
+ * @param oldCh the old children of the parent node
608
+ * @param newVNode the new VNode which will replace the parent
609
+ * @param newCh the new children of the parent node
610
+ */
611
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
612
+ let oldStartIdx = 0;
613
+ let newStartIdx = 0;
614
+ let idxInOld = 0;
615
+ let i = 0;
616
+ let oldEndIdx = oldCh.length - 1;
617
+ let oldStartVnode = oldCh[0];
618
+ let oldEndVnode = oldCh[oldEndIdx];
619
+ let newEndIdx = newCh.length - 1;
620
+ let newStartVnode = newCh[0];
621
+ let newEndVnode = newCh[newEndIdx];
622
+ let node;
623
+ let elmToMove;
624
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
625
+ if (oldStartVnode == null) {
626
+ // VNode might have been moved left
627
+ oldStartVnode = oldCh[++oldStartIdx];
628
+ }
629
+ else if (oldEndVnode == null) {
630
+ oldEndVnode = oldCh[--oldEndIdx];
631
+ }
632
+ else if (newStartVnode == null) {
633
+ newStartVnode = newCh[++newStartIdx];
634
+ }
635
+ else if (newEndVnode == null) {
636
+ newEndVnode = newCh[--newEndIdx];
637
+ }
638
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
639
+ // if the start nodes are the same then we should patch the new VNode
640
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
641
+ // indices to reflect that. We don't need to move any DOM Nodes around
642
+ // since things are matched up in order.
643
+ patch(oldStartVnode, newStartVnode);
644
+ oldStartVnode = oldCh[++oldStartIdx];
645
+ newStartVnode = newCh[++newStartIdx];
646
+ }
647
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
648
+ // likewise, if the end nodes are the same we patch new onto old and
649
+ // decrement our end indices, and also likewise in this case we don't
650
+ // need to move any DOM Nodes.
651
+ patch(oldEndVnode, newEndVnode);
652
+ oldEndVnode = oldCh[--oldEndIdx];
653
+ newEndVnode = newCh[--newEndIdx];
654
+ }
655
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
656
+ patch(oldStartVnode, newEndVnode);
657
+ // We need to move the element for `oldStartVnode` into a position which
658
+ // will be appropriate for `newEndVnode`. For this we can use
659
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
660
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
661
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
662
+ //
663
+ // <old-start-node />
664
+ // <some-intervening-node />
665
+ // <old-end-node />
666
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
667
+ // <next-sibling />
668
+ //
669
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
670
+ // the node for `oldStartVnode` at the end of the children of
671
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
672
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
673
+ // append it to the children of the parent element.
674
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
675
+ oldStartVnode = oldCh[++oldStartIdx];
676
+ newEndVnode = newCh[--newEndIdx];
677
+ }
678
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
679
+ patch(oldEndVnode, newStartVnode);
680
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
681
+ // the same node, so since we're here we know that they are not. Thus we
682
+ // can move the element for `oldEndVnode` _before_ the element for
683
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
684
+ // future.
685
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
686
+ oldEndVnode = oldCh[--oldEndIdx];
687
+ newStartVnode = newCh[++newStartIdx];
688
+ }
689
+ else {
690
+ // Here we do some checks to match up old and new nodes based on the
691
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
692
+ // in the JSX for a DOM element in the implementation of a Stencil
693
+ // component.
694
+ //
695
+ // First we check to see if there are any nodes in the array of old
696
+ // children which have the same key as the first node in the new
697
+ // children.
698
+ idxInOld = -1;
699
+ {
700
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
701
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
702
+ idxInOld = i;
703
+ break;
704
+ }
705
+ }
706
+ }
707
+ if (idxInOld >= 0) {
708
+ // We found a node in the old children which matches up with the first
709
+ // node in the new children! So let's deal with that
710
+ elmToMove = oldCh[idxInOld];
711
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
712
+ // the tag doesn't match so we'll need a new DOM element
713
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
714
+ }
715
+ else {
716
+ patch(elmToMove, newStartVnode);
717
+ // invalidate the matching old node so that we won't try to update it
718
+ // again later on
719
+ oldCh[idxInOld] = undefined;
720
+ node = elmToMove.$elm$;
721
+ }
722
+ newStartVnode = newCh[++newStartIdx];
723
+ }
724
+ else {
725
+ // We either didn't find an element in the old children that matches
726
+ // the key of the first new child OR the build is not using `key`
727
+ // attributes at all. In either case we need to create a new element
728
+ // for the new node.
729
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
730
+ newStartVnode = newCh[++newStartIdx];
731
+ }
732
+ if (node) {
733
+ // if we created a new node then handle inserting it to the DOM
734
+ {
735
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
736
+ }
737
+ }
738
+ }
739
+ }
740
+ if (oldStartIdx > oldEndIdx) {
741
+ // we have some more new nodes to add which don't match up with old nodes
742
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
743
+ }
744
+ else if (newStartIdx > newEndIdx) {
745
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
746
+ // in the new array, so lets remove them (which entails cleaning up the
747
+ // relevant DOM nodes)
748
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
749
+ }
750
+ };
751
+ /**
752
+ * Compare two VNodes to determine if they are the same
753
+ *
754
+ * **NB**: This function is an equality _heuristic_ based on the available
755
+ * information set on the two VNodes and can be misleading under certain
756
+ * circumstances. In particular, if the two nodes do not have `key` attrs
757
+ * (available under `$key$` on VNodes) then the function falls back on merely
758
+ * checking that they have the same tag.
759
+ *
760
+ * So, in other words, if `key` attrs are not set on VNodes which may be
761
+ * changing order within a `children` array or something along those lines then
762
+ * we could obtain a false positive and then have to do needless re-rendering.
763
+ *
764
+ * @param leftVNode the first VNode to check
765
+ * @param rightVNode the second VNode to check
766
+ * @returns whether they're equal or not
767
+ */
768
+ const isSameVnode = (leftVNode, rightVNode) => {
769
+ // compare if two vnode to see if they're "technically" the same
770
+ // need to have the same element tag, and same key to be the same
771
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
772
+ // this will be set if components in the build have `key` attrs set on them
773
+ {
774
+ return leftVNode.$key$ === rightVNode.$key$;
775
+ }
776
+ }
777
+ return false;
778
+ };
779
+ /**
780
+ * Handle reconciling an outdated VNode with a new one which corresponds to
781
+ * it. This function handles flushing updates to the DOM and reconciling the
782
+ * children of the two nodes (if any).
783
+ *
784
+ * @param oldVNode an old VNode whose DOM element and children we want to update
785
+ * @param newVNode a new VNode representing an updated version of the old one
786
+ */
787
+ const patch = (oldVNode, newVNode) => {
788
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
789
+ const oldChildren = oldVNode.$children$;
790
+ const newChildren = newVNode.$children$;
791
+ const tag = newVNode.$tag$;
792
+ const text = newVNode.$text$;
793
+ if (text === null) {
794
+ {
795
+ // test if we're rendering an svg element, or still rendering nodes inside of one
796
+ // only add this to the when the compiler sees we're using an svg somewhere
797
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
798
+ }
799
+ {
800
+ if (tag === 'slot')
801
+ ;
802
+ else {
803
+ // either this is the first render of an element OR it's an update
804
+ // AND we already know it's possible it could have changed
805
+ // this updates the element's css classes, attrs, props, listeners, etc.
806
+ updateElement(oldVNode, newVNode, isSvgMode);
807
+ }
808
+ }
809
+ if (oldChildren !== null && newChildren !== null) {
810
+ // looks like there's child vnodes for both the old and new vnodes
811
+ // so we need to call `updateChildren` to reconcile them
812
+ updateChildren(elm, oldChildren, newVNode, newChildren);
813
+ }
814
+ else if (newChildren !== null) {
815
+ // no old child vnodes, but there are new child vnodes to add
816
+ if (oldVNode.$text$ !== null) {
817
+ // the old vnode was text, so be sure to clear it out
818
+ elm.textContent = '';
819
+ }
820
+ // add the new vnode children
821
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
822
+ }
823
+ else if (oldChildren !== null) {
824
+ // no new child vnodes, but there are old child vnodes to remove
825
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
826
+ }
827
+ if (isSvgMode && tag === 'svg') {
828
+ isSvgMode = false;
829
+ }
830
+ }
831
+ else if (oldVNode.$text$ !== text) {
832
+ // update the text content for the text only vnode
833
+ // and also only if the text is different than before
834
+ elm.data = text;
835
+ }
836
+ };
837
+ const callNodeRefs = (vNode) => {
838
+ {
839
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
840
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
841
+ }
842
+ };
843
+ const renderVdom = (hostRef, renderFnResults) => {
844
+ const hostElm = hostRef.$hostElement$;
845
+ const cmpMeta = hostRef.$cmpMeta$;
846
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
847
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
848
+ hostTagName = hostElm.tagName;
849
+ if (cmpMeta.$attrsToReflect$) {
850
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
851
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
852
+ }
853
+ rootVnode.$tag$ = null;
854
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
855
+ hostRef.$vnode$ = rootVnode;
856
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
857
+ {
858
+ scopeId = hostElm['s-sc'];
859
+ }
860
+ // synchronous patch
861
+ patch(oldVNode, rootVnode);
862
+ };
863
+ const attachToAncestor = (hostRef, ancestorComponent) => {
864
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
865
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
866
+ }
867
+ };
868
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
869
+ {
870
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
871
+ }
872
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
873
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
874
+ return;
875
+ }
876
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
877
+ // there is no ancestor component or the ancestor component
878
+ // has already fired off its lifecycle update then
879
+ // fire off the initial update
880
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
881
+ return writeTask(dispatch) ;
882
+ };
883
+ const dispatchHooks = (hostRef, isInitialLoad) => {
884
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
885
+ const instance = hostRef.$lazyInstance$ ;
886
+ let promise;
887
+ if (isInitialLoad) {
888
+ {
889
+ promise = safeCall(instance, 'componentWillLoad');
890
+ }
891
+ }
892
+ endSchedule();
893
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
894
+ };
895
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
896
+ // updateComponent
897
+ const elm = hostRef.$hostElement$;
898
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
899
+ const rc = elm['s-rc'];
900
+ if (isInitialLoad) {
901
+ // DOM WRITE!
902
+ attachStyles(hostRef);
903
+ }
904
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
905
+ {
906
+ callRender(hostRef, instance);
907
+ }
908
+ if (rc) {
909
+ // ok, so turns out there are some child host elements
910
+ // waiting on this parent element to load
911
+ // let's fire off all update callbacks waiting
912
+ rc.map((cb) => cb());
913
+ elm['s-rc'] = undefined;
914
+ }
915
+ endRender();
916
+ endUpdate();
917
+ {
918
+ const childrenPromises = elm['s-p'];
919
+ const postUpdate = () => postUpdateComponent(hostRef);
920
+ if (childrenPromises.length === 0) {
921
+ postUpdate();
922
+ }
923
+ else {
924
+ Promise.all(childrenPromises).then(postUpdate);
925
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
926
+ childrenPromises.length = 0;
927
+ }
928
+ }
929
+ };
930
+ const callRender = (hostRef, instance, elm) => {
931
+ try {
932
+ instance = instance.render() ;
933
+ {
934
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
935
+ }
936
+ {
937
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
938
+ }
939
+ {
940
+ {
941
+ // looks like we've got child nodes to render into this host element
942
+ // or we need to update the css class/attrs on the host element
943
+ // DOM WRITE!
944
+ {
945
+ renderVdom(hostRef, instance);
946
+ }
947
+ }
948
+ }
949
+ }
950
+ catch (e) {
951
+ consoleError(e, hostRef.$hostElement$);
952
+ }
953
+ return null;
954
+ };
955
+ const postUpdateComponent = (hostRef) => {
956
+ const tagName = hostRef.$cmpMeta$.$tagName$;
957
+ const elm = hostRef.$hostElement$;
958
+ const endPostUpdate = createTime('postUpdate', tagName);
959
+ const instance = hostRef.$lazyInstance$ ;
960
+ const ancestorComponent = hostRef.$ancestorComponent$;
961
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
962
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
963
+ {
964
+ // DOM WRITE!
965
+ addHydratedFlag(elm);
966
+ }
967
+ {
968
+ safeCall(instance, 'componentDidLoad');
969
+ }
970
+ endPostUpdate();
971
+ {
972
+ hostRef.$onReadyResolve$(elm);
973
+ if (!ancestorComponent) {
974
+ appDidLoad();
975
+ }
976
+ }
977
+ }
978
+ else {
979
+ endPostUpdate();
980
+ }
981
+ // load events fire from bottom to top
982
+ // the deepest elements load first then bubbles up
983
+ {
984
+ if (hostRef.$onRenderResolve$) {
985
+ hostRef.$onRenderResolve$();
986
+ hostRef.$onRenderResolve$ = undefined;
987
+ }
988
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
989
+ nextTick(() => scheduleUpdate(hostRef, false));
990
+ }
991
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
992
+ }
993
+ // ( •_•)
994
+ // ( •_•)>⌐■-■
995
+ // (⌐■_■)
996
+ };
997
+ const appDidLoad = (who) => {
998
+ // on appload
999
+ // we have finish the first big initial render
1000
+ {
1001
+ addHydratedFlag(doc.documentElement);
1002
+ }
1003
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1004
+ };
1005
+ const safeCall = (instance, method, arg) => {
1006
+ if (instance && instance[method]) {
1007
+ try {
1008
+ return instance[method](arg);
1009
+ }
1010
+ catch (e) {
1011
+ consoleError(e);
1012
+ }
1013
+ }
1014
+ return undefined;
1015
+ };
1016
+ const then = (promise, thenFn) => {
1017
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1018
+ };
1019
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1020
+ ;
1021
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1022
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1023
+ // check our new property value against our internal value
1024
+ const hostRef = getHostRef(ref);
1025
+ const oldVal = hostRef.$instanceValues$.get(propName);
1026
+ const flags = hostRef.$flags$;
1027
+ const instance = hostRef.$lazyInstance$ ;
1028
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1029
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1030
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1031
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1032
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1033
+ // gadzooks! the property's value has changed!!
1034
+ // set our new value!
1035
+ hostRef.$instanceValues$.set(propName, newVal);
1036
+ if (instance) {
1037
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1038
+ // looks like this value actually changed, so we've got work to do!
1039
+ // but only if we've already rendered, otherwise just chill out
1040
+ // queue that we need to do an update, but don't worry about queuing
1041
+ // up millions cuz this function ensures it only runs once
1042
+ scheduleUpdate(hostRef, false);
1043
+ }
1044
+ }
1045
+ }
1046
+ };
1047
+ /**
1048
+ * Attach a series of runtime constructs to a compiled Stencil component
1049
+ * constructor, including getters and setters for the `@Prop` and `@State`
1050
+ * decorators, callbacks for when attributes change, and so on.
1051
+ *
1052
+ * @param Cstr the constructor for a component that we need to process
1053
+ * @param cmpMeta metadata collected previously about the component
1054
+ * @param flags a number used to store a series of bit flags
1055
+ * @returns a reference to the same constructor passed in (but now mutated)
1056
+ */
1057
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1058
+ if (cmpMeta.$members$) {
1059
+ // It's better to have a const than two Object.entries()
1060
+ const members = Object.entries(cmpMeta.$members$);
1061
+ const prototype = Cstr.prototype;
1062
+ members.map(([memberName, [memberFlags]]) => {
1063
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1064
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1065
+ // proxyComponent - prop
1066
+ Object.defineProperty(prototype, memberName, {
1067
+ get() {
1068
+ // proxyComponent, get value
1069
+ return getValue(this, memberName);
1070
+ },
1071
+ set(newValue) {
1072
+ // proxyComponent, set value
1073
+ setValue(this, memberName, newValue, cmpMeta);
1074
+ },
1075
+ configurable: true,
1076
+ enumerable: true,
1077
+ });
1078
+ }
1079
+ });
1080
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1081
+ const attrNameToPropName = new Map();
1082
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1083
+ plt.jmp(() => {
1084
+ const propName = attrNameToPropName.get(attrName);
1085
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1086
+ // in the case where an attribute was set inline.
1087
+ // ```html
1088
+ // <my-component some-attribute="some-value"></my-component>
1089
+ // ```
1090
+ //
1091
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1092
+ // programmatically changes it before it has been upgraded as shown below:
1093
+ //
1094
+ // ```html
1095
+ // <!-- this component has _not_ been upgraded yet -->
1096
+ // <my-component id="test" some-attribute="some-value"></my-component>
1097
+ // <script>
1098
+ // // grab non-upgraded component
1099
+ // el = document.querySelector("#test");
1100
+ // el.someAttribute = "another-value";
1101
+ // // upgrade component
1102
+ // customElements.define('my-component', MyComponent);
1103
+ // </script>
1104
+ // ```
1105
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1106
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1107
+ // to the value that was set inline i.e. "some-value" from above example. When
1108
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1109
+ //
1110
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1111
+ // by connectedCallback as this attributeChangedCallback will not fire.
1112
+ //
1113
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1114
+ //
1115
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1116
+ // properties here given that this goes against best practices outlined here
1117
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1118
+ if (this.hasOwnProperty(propName)) {
1119
+ newValue = this[propName];
1120
+ delete this[propName];
1121
+ }
1122
+ else if (prototype.hasOwnProperty(propName) &&
1123
+ typeof this[propName] === 'number' &&
1124
+ this[propName] == newValue) {
1125
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1126
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1127
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1128
+ return;
1129
+ }
1130
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1131
+ });
1132
+ };
1133
+ // create an array of attributes to observe
1134
+ // and also create a map of html attribute name to js property name
1135
+ Cstr.observedAttributes = members
1136
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1137
+ .map(([propName, m]) => {
1138
+ const attrName = m[1] || propName;
1139
+ attrNameToPropName.set(attrName, propName);
1140
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1141
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1142
+ }
1143
+ return attrName;
1144
+ });
1145
+ }
1146
+ }
1147
+ return Cstr;
1148
+ };
1149
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1150
+ // initializeComponent
1151
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1152
+ {
1153
+ // we haven't initialized this element yet
1154
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1155
+ // lazy loaded components
1156
+ // request the component's implementation to be
1157
+ // wired up with the host element
1158
+ Cstr = loadModule(cmpMeta);
1159
+ if (Cstr.then) {
1160
+ // Await creates a micro-task avoid if possible
1161
+ const endLoad = uniqueTime();
1162
+ Cstr = await Cstr;
1163
+ endLoad();
1164
+ }
1165
+ if (!Cstr.isProxied) {
1166
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1167
+ Cstr.isProxied = true;
1168
+ }
1169
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1170
+ // ok, time to construct the instance
1171
+ // but let's keep track of when we start and stop
1172
+ // so that the getters/setters don't incorrectly step on data
1173
+ {
1174
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1175
+ }
1176
+ // construct the lazy-loaded component implementation
1177
+ // passing the hostRef is very important during
1178
+ // construction in order to directly wire together the
1179
+ // host element and the lazy-loaded instance
1180
+ try {
1181
+ new Cstr(hostRef);
1182
+ }
1183
+ catch (e) {
1184
+ consoleError(e);
1185
+ }
1186
+ {
1187
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1188
+ }
1189
+ endNewInstance();
1190
+ }
1191
+ if (Cstr.style) {
1192
+ // this component has styles but we haven't registered them yet
1193
+ let style = Cstr.style;
1194
+ const scopeId = getScopeId(cmpMeta);
1195
+ if (!styles.has(scopeId)) {
1196
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1197
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1198
+ endRegisterStyles();
1199
+ }
1200
+ }
1201
+ }
1202
+ // we've successfully created a lazy instance
1203
+ const ancestorComponent = hostRef.$ancestorComponent$;
1204
+ const schedule = () => scheduleUpdate(hostRef, true);
1205
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1206
+ // this is the initial load and this component it has an ancestor component
1207
+ // but the ancestor component has NOT fired its will update lifecycle yet
1208
+ // so let's just cool our jets and wait for the ancestor to continue first
1209
+ // this will get fired off when the ancestor component
1210
+ // finally gets around to rendering its lazy self
1211
+ // fire off the initial update
1212
+ ancestorComponent['s-rc'].push(schedule);
1213
+ }
1214
+ else {
1215
+ schedule();
1216
+ }
1217
+ };
1218
+ const connectedCallback = (elm) => {
1219
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1220
+ const hostRef = getHostRef(elm);
1221
+ const cmpMeta = hostRef.$cmpMeta$;
1222
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1223
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1224
+ // first time this component has connected
1225
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1226
+ {
1227
+ // find the first ancestor component (if there is one) and register
1228
+ // this component as one of the actively loading child components for its ancestor
1229
+ let ancestorComponent = elm;
1230
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1231
+ // climb up the ancestors looking for the first
1232
+ // component that hasn't finished its lifecycle update yet
1233
+ if (ancestorComponent['s-p']) {
1234
+ // we found this components first ancestor component
1235
+ // keep a reference to this component's ancestor component
1236
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1237
+ break;
1238
+ }
1239
+ }
1240
+ }
1241
+ // Lazy properties
1242
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1243
+ if (cmpMeta.$members$) {
1244
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1245
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1246
+ const value = elm[memberName];
1247
+ delete elm[memberName];
1248
+ elm[memberName] = value;
1249
+ }
1250
+ });
1251
+ }
1252
+ {
1253
+ initializeComponent(elm, hostRef, cmpMeta);
1254
+ }
1255
+ }
1256
+ endConnected();
1257
+ }
1258
+ };
1259
+ const disconnectedCallback = (elm) => {
1260
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1261
+ getHostRef(elm);
1262
+ }
1263
+ };
1264
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1265
+ const endBootstrap = createTime();
1266
+ const cmpTags = [];
1267
+ const exclude = options.exclude || [];
1268
+ const customElements = win.customElements;
1269
+ const head = doc.head;
1270
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1271
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1272
+ const deferredConnectedCallbacks = [];
1273
+ let appLoadFallback;
1274
+ let isBootstrapping = true;
1275
+ Object.assign(plt, options);
1276
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1277
+ lazyBundles.map((lazyBundle) => {
1278
+ lazyBundle[1].map((compactMeta) => {
1279
+ const cmpMeta = {
1280
+ $flags$: compactMeta[0],
1281
+ $tagName$: compactMeta[1],
1282
+ $members$: compactMeta[2],
1283
+ $listeners$: compactMeta[3],
1284
+ };
1285
+ {
1286
+ cmpMeta.$members$ = compactMeta[2];
1287
+ }
1288
+ {
1289
+ cmpMeta.$attrsToReflect$ = [];
1290
+ }
1291
+ const tagName = cmpMeta.$tagName$;
1292
+ const HostElement = class extends HTMLElement {
1293
+ // StencilLazyHost
1294
+ constructor(self) {
1295
+ // @ts-ignore
1296
+ super(self);
1297
+ self = this;
1298
+ registerHost(self, cmpMeta);
1299
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1300
+ // this component is using shadow dom
1301
+ // and this browser supports shadow dom
1302
+ // add the read-only property "shadowRoot" to the host element
1303
+ // adding the shadow root build conditionals to minimize runtime
1304
+ {
1305
+ {
1306
+ self.attachShadow({ mode: 'open' });
1307
+ }
1308
+ }
1309
+ }
1310
+ }
1311
+ connectedCallback() {
1312
+ if (appLoadFallback) {
1313
+ clearTimeout(appLoadFallback);
1314
+ appLoadFallback = null;
1315
+ }
1316
+ if (isBootstrapping) {
1317
+ // connectedCallback will be processed once all components have been registered
1318
+ deferredConnectedCallbacks.push(this);
1319
+ }
1320
+ else {
1321
+ plt.jmp(() => connectedCallback(this));
1322
+ }
1323
+ }
1324
+ disconnectedCallback() {
1325
+ plt.jmp(() => disconnectedCallback(this));
1326
+ }
1327
+ componentOnReady() {
1328
+ return getHostRef(this).$onReadyPromise$;
1329
+ }
1330
+ };
1331
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1332
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1333
+ cmpTags.push(tagName);
1334
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1335
+ }
1336
+ });
1337
+ });
1338
+ {
1339
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1340
+ visibilityStyle.setAttribute('data-styles', '');
1341
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1342
+ }
1343
+ // Process deferred connectedCallbacks now all components have been registered
1344
+ isBootstrapping = false;
1345
+ if (deferredConnectedCallbacks.length) {
1346
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1347
+ }
1348
+ else {
1349
+ {
1350
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1351
+ }
1352
+ }
1353
+ // Fallback appLoad event
1354
+ endBootstrap();
1355
+ };
1356
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1357
+ const getHostRef = (ref) => hostRefs.get(ref);
1358
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1359
+ const registerHost = (elm, cmpMeta) => {
1360
+ const hostRef = {
1361
+ $flags$: 0,
1362
+ $hostElement$: elm,
1363
+ $cmpMeta$: cmpMeta,
1364
+ $instanceValues$: new Map(),
1365
+ };
1366
+ {
1367
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1368
+ elm['s-p'] = [];
1369
+ elm['s-rc'] = [];
1370
+ }
1371
+ return hostRefs.set(elm, hostRef);
1372
+ };
1373
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1374
+ const consoleError = (e, el) => (0, console.error)(e, el);
1375
+ const cmpModules = /*@__PURE__*/ new Map();
1376
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1377
+ // loadModuleImport
1378
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1379
+ const bundleId = cmpMeta.$lazyBundleId$;
1380
+ const module = cmpModules.get(bundleId) ;
1381
+ if (module) {
1382
+ return module[exportName];
1383
+ }
1384
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1385
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1386
+ /* @vite-ignore */
1387
+ /* webpackInclude: /\.entry\.js$/ */
1388
+ /* webpackExclude: /\.system\.entry\.js$/ */
1389
+ /* webpackMode: "lazy" */
1390
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1391
+ {
1392
+ cmpModules.set(bundleId, importedModule);
1393
+ }
1394
+ return importedModule[exportName];
1395
+ }, consoleError);
1396
+ };
1397
+ const styles = /*@__PURE__*/ new Map();
1398
+ const win = typeof window !== 'undefined' ? window : {};
1399
+ const doc = win.document || { head: {} };
1400
+ const plt = {
1401
+ $flags$: 0,
1402
+ $resourcesUrl$: '',
1403
+ jmp: (h) => h(),
1404
+ raf: (h) => requestAnimationFrame(h),
1405
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1406
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1407
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1408
+ };
1409
+ const promiseResolve = (v) => Promise.resolve(v);
1410
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1411
+ try {
1412
+ new CSSStyleSheet();
1413
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1414
+ }
1415
+ catch (e) { }
1416
+ return false;
1417
+ })()
1418
+ ;
1419
+ const queueDomReads = [];
1420
+ const queueDomWrites = [];
1421
+ const queueTask = (queue, write) => (cb) => {
1422
+ queue.push(cb);
1423
+ if (!queuePending) {
1424
+ queuePending = true;
1425
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1426
+ nextTick(flush);
1427
+ }
1428
+ else {
1429
+ plt.raf(flush);
1430
+ }
1431
+ }
1432
+ };
1433
+ const consume = (queue) => {
1434
+ for (let i = 0; i < queue.length; i++) {
1435
+ try {
1436
+ queue[i](performance.now());
1437
+ }
1438
+ catch (e) {
1439
+ consoleError(e);
1440
+ }
1441
+ }
1442
+ queue.length = 0;
1443
+ };
1444
+ const flush = () => {
1445
+ // always force a bunch of medium callbacks to run, but still have
1446
+ // a throttle on how many can run in a certain time
1447
+ // DOM READS!!!
1448
+ consume(queueDomReads);
1449
+ // DOM WRITES!!!
1450
+ {
1451
+ consume(queueDomWrites);
1452
+ if ((queuePending = queueDomReads.length > 0)) {
1453
+ // still more to do yet, but we've run out of time
1454
+ // let's let this thing cool off and try again in the next tick
1455
+ plt.raf(flush);
1456
+ }
1457
+ }
1458
+ };
1459
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1460
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1461
+
1462
+ exports.Host = Host;
1463
+ exports.bootstrapLazy = bootstrapLazy;
1464
+ exports.h = h;
1465
+ exports.promiseResolve = promiseResolve;
1466
+ exports.registerInstance = registerInstance;