pushfeedback 0.0.12 → 0.0.13

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