vviinn-widgets 2.18.21 → 2.19.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 (183) hide show
  1. package/dist/cjs/{index-cb410762.js → Campaign-a94a827a.js} +17 -1
  2. package/dist/cjs/cropper-handler_29.cjs.entry.js +1418 -0
  3. package/dist/cjs/{imageSearch.store-98824653.js → index-48c94264.js} +16016 -11171
  4. package/dist/cjs/{index-7f1325a7.js → index-a4becaff.js} +683 -303
  5. package/dist/cjs/loader.cjs.js +4 -3
  6. package/dist/cjs/{vviinn-carousel_3.cjs.entry.js → vviinn-carousel_2.cjs.entry.js} +150 -270
  7. package/dist/cjs/vviinn-recommendations-sidebar.cjs.entry.js +14 -8
  8. package/dist/cjs/vviinn-vpr-button.cjs.entry.js +12 -14
  9. package/dist/cjs/vviinn-widgets.cjs.js +10 -3
  10. package/dist/collection/Image/sizing.spec.js +66 -0
  11. package/dist/collection/collection-manifest.json +2 -2
  12. package/dist/collection/components/image-search/image-view/highlight-box/highlight-box.css +2 -16
  13. package/dist/collection/components/image-search/image-view/highlight-box/highlight-box.js +11 -7
  14. package/dist/collection/components/image-search/image-view/image-cropper/cropper-handler/cropper-handler.css +0 -1
  15. package/dist/collection/components/image-search/image-view/image-cropper/cropper-handler/cropper-handler.js +40 -37
  16. package/dist/collection/components/image-search/image-view/image-cropper/image-cropper.js +73 -67
  17. package/dist/collection/components/image-search/search-filters/search-filters.css +4 -23
  18. package/dist/collection/components/image-search/search-filters/search-filters.js +97 -91
  19. package/dist/collection/components/vviinn-button/vviinn-button.js +34 -31
  20. package/dist/collection/components/vviinn-carousel/vviinn-carousel.css +1 -2
  21. package/dist/collection/components/vviinn-carousel/vviinn-carousel.js +161 -156
  22. package/dist/collection/components/vviinn-error/vviinn-empty-results/vviinn-empty-results.js +12 -14
  23. package/dist/collection/components/vviinn-error/vviinn-error.js +12 -12
  24. package/dist/collection/components/vviinn-error/vviinn-server-error/vviinn-server-error.js +35 -30
  25. package/dist/collection/components/vviinn-error/vviinn-wrong-format/vviinn-wrong-format.js +35 -30
  26. package/dist/collection/components/vviinn-example-images/vviinn-example-image/vviinn-example-image.js +129 -121
  27. package/dist/collection/components/vviinn-example-images/vviinn-example-images.js +75 -75
  28. package/dist/collection/components/vviinn-icons/index.js +10 -27
  29. package/dist/collection/components/vviinn-image-selector/vviinn-image-selector.js +120 -67
  30. package/dist/collection/components/vviinn-image-view/vviinn-detected-object/vviinn-detected-object.js +81 -69
  31. package/dist/collection/components/vviinn-image-view/vviinn-image-view.css +0 -1
  32. package/dist/collection/components/vviinn-image-view/vviinn-image-view.js +27 -28
  33. package/dist/collection/components/vviinn-modal/vviinn-modal.css +7 -36
  34. package/dist/collection/components/vviinn-modal/vviinn-modal.js +115 -93
  35. package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-1/vviinn-onboarding-card-1.js +12 -14
  36. package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-2/vviinn-onboarding-card-2.js +12 -14
  37. package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-3/vviinn-onboarding-card-3.js +12 -14
  38. package/dist/collection/components/vviinn-onboarding/vviinn-onboarding.js +12 -17
  39. package/dist/collection/components/vviinn-overlay/vviinn-overlay.css +1 -12
  40. package/dist/collection/components/vviinn-overlay/vviinn-overlay.js +12 -9
  41. package/dist/collection/components/vviinn-overlayed-modal/vviinn-overlayed-modal.js +107 -78
  42. package/dist/collection/components/vviinn-preloader/vviinn-preloader.css +1 -11
  43. package/dist/collection/components/vviinn-preloader/vviinn-preloader.js +11 -7
  44. package/dist/collection/components/vviinn-privacy-badge/vviinn-privacy-badge.css +0 -1
  45. package/dist/collection/components/vviinn-privacy-badge/vviinn-privacy-badge.js +12 -16
  46. package/dist/collection/components/vviinn-product-card/render-helpers.js +6 -14
  47. package/dist/collection/components/vviinn-product-card/vviinn-product-card.js +425 -415
  48. package/dist/collection/components/vviinn-slider/arrow.js +1 -2
  49. package/dist/collection/components/vviinn-slider/vviinn-slide/vviinn-slide.js +12 -9
  50. package/dist/collection/components/vviinn-slider/vviinn-slider.css +0 -1
  51. package/dist/collection/components/vviinn-slider/vviinn-slider.js +87 -82
  52. package/dist/collection/components/vviinn-teaser/vviinn-teaser.js +12 -18
  53. package/dist/collection/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.css +12 -64
  54. package/dist/collection/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.js +371 -360
  55. package/dist/collection/components/vviinn-vpr-button/vviinn-vpr-button.js +448 -444
  56. package/dist/collection/components/vviinn-vpr-widget/vviinn-vpr-vidget.js +545 -542
  57. package/dist/collection/components/vviinn-vps-button/stories/vviinn-vps-button.stories.js +2 -0
  58. package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +368 -332
  59. package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.css +0 -5
  60. package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.e2e.js +26 -0
  61. package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.js +502 -425
  62. package/dist/collection/geometry/Clip.spec.js +16 -0
  63. package/dist/collection/geometry/Rectangle.spec.js +66 -0
  64. package/dist/collection/geometry/Sized.spec.js +16 -0
  65. package/dist/collection/interfaces/generated.js +0 -4
  66. package/dist/collection/network/ion/Form.spec.js +43 -0
  67. package/dist/esm/{index-b31d86ce.js → Campaign-4aa53f29.js} +15 -2
  68. package/dist/esm/cropper-handler_29.entry.js +1386 -0
  69. package/dist/esm/{index-590cb67e.js → index-48ef9564.js} +683 -304
  70. package/dist/esm/{imageSearch.store-9dde5360.js → index-976acf7e.js} +16124 -11292
  71. package/dist/esm/loader.js +4 -3
  72. package/dist/esm/polyfills/css-shim.js +1 -1
  73. package/dist/esm/{vviinn-carousel_3.entry.js → vviinn-carousel_2.entry.js} +106 -225
  74. package/dist/esm/vviinn-recommendations-sidebar.entry.js +13 -7
  75. package/dist/esm/vviinn-vpr-button.entry.js +11 -13
  76. package/dist/esm/vviinn-widgets.js +7 -3
  77. package/dist/loader/index.d.ts +9 -0
  78. package/dist/loader/package.json +1 -0
  79. package/dist/types/Image/sizing.d.ts +4 -4
  80. package/dist/types/campaign/Campaign.d.ts +5 -5
  81. package/dist/types/campaign/VCSCampaignResponse.d.ts +1 -1
  82. package/dist/types/components/vviinn-carousel/vviinn-carousel.d.ts +2 -2
  83. package/dist/types/components/vviinn-image-selector/vviinn-image-selector.d.ts +4 -0
  84. package/dist/types/components/vviinn-modal/vviinn-modal.d.ts +2 -0
  85. package/dist/types/components/vviinn-overlayed-modal/vviinn-overlayed-modal.d.ts +2 -0
  86. package/dist/types/components/vviinn-product-card/render-helpers.d.ts +3 -3
  87. package/dist/types/components/vviinn-slider/arrow.d.ts +2 -2
  88. package/dist/types/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.d.ts +2 -2
  89. package/dist/types/components/vviinn-vps-button/vviinn-vps-button.d.ts +9 -4
  90. package/dist/types/components/vviinn-vps-widget/vviinn-vps-widget.d.ts +8 -0
  91. package/dist/types/components.d.ts +154 -54
  92. package/dist/types/error.d.ts +1 -1
  93. package/dist/types/geometry/Point.d.ts +1 -1
  94. package/dist/types/geometry/Rectangle.d.ts +1 -1
  95. package/dist/types/geometry/Sized.d.ts +1 -1
  96. package/dist/types/interfaces/generated.d.ts +192 -371
  97. package/dist/types/network/ion/File.d.ts +2 -2
  98. package/dist/types/network/ion/Form.d.ts +5 -5
  99. package/dist/types/network/ion/Link.d.ts +1 -1
  100. package/dist/types/network/ion/ValueObject.d.ts +4 -4
  101. package/dist/types/network/utils.d.ts +3 -3
  102. package/dist/types/recommendation/events.d.ts +5 -5
  103. package/dist/types/recommendation/recommendation.d.ts +1 -1
  104. package/dist/types/searchSession/searchSession.d.ts +7 -7
  105. package/dist/types/slider/GridMode.d.ts +1 -1
  106. package/dist/types/stencil-public-runtime.d.ts +98 -23
  107. package/dist/types/store/imageSearch.store.d.ts +1 -1
  108. package/dist/types/tracking/models.d.ts +2 -2
  109. package/dist/types/utils/event/Events.d.ts +1 -1
  110. package/dist/vviinn-widgets/p-312b0eb7.entry.js +1 -0
  111. package/dist/vviinn-widgets/p-414b2291.js +1 -0
  112. package/dist/vviinn-widgets/p-5b50c7e5.entry.js +1 -0
  113. package/dist/vviinn-widgets/p-8deaa5da.entry.js +1 -0
  114. package/dist/vviinn-widgets/p-c6209bc1.entry.js +1 -0
  115. package/{www/build/p-2f9ee951.js → dist/vviinn-widgets/p-d08ce429.js} +1 -1
  116. package/dist/vviinn-widgets/p-fa17e81f.js +2 -0
  117. package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
  118. package/package.json +12 -12
  119. package/www/build/p-312b0eb7.entry.js +1 -0
  120. package/www/build/p-414b2291.js +1 -0
  121. package/www/build/p-5b50c7e5.entry.js +1 -0
  122. package/www/build/p-8deaa5da.entry.js +1 -0
  123. package/www/build/p-c6209bc1.entry.js +1 -0
  124. package/{dist/vviinn-widgets/p-2f9ee951.js → www/build/p-d08ce429.js} +1 -1
  125. package/www/build/p-d39b7d70.js +161 -0
  126. package/www/build/p-fa17e81f.js +2 -0
  127. package/www/build/vviinn-widgets.esm.js +1 -1
  128. package/www/index.html +2 -2
  129. package/dist/cjs/Campaign-13258569.js +0 -18
  130. package/dist/cjs/Handler-176539c8.js +0 -331
  131. package/dist/cjs/cropper-handler.cjs.entry.js +0 -27
  132. package/dist/cjs/customized-slots-6e56c354.js +0 -54
  133. package/dist/cjs/highlight-box_22.cjs.entry.js +0 -770
  134. package/dist/cjs/index-a99edb90.js +0 -3235
  135. package/dist/cjs/vviinn-button.cjs.entry.js +0 -21
  136. package/dist/cjs/vviinn-error.cjs.entry.js +0 -19
  137. package/dist/cjs/vviinn-preloader.cjs.entry.js +0 -26
  138. package/dist/cjs/vviinn-vps-button.cjs.entry.js +0 -65
  139. package/dist/cjs/vviinn-vps-widget.cjs.entry.js +0 -251
  140. package/dist/esm/Campaign-90ba7e06.js +0 -14
  141. package/dist/esm/Handler-f9b8735c.js +0 -309
  142. package/dist/esm/cropper-handler.entry.js +0 -23
  143. package/dist/esm/customized-slots-00afe247.js +0 -51
  144. package/dist/esm/highlight-box_22.entry.js +0 -745
  145. package/dist/esm/index-4d5b52ba.js +0 -3224
  146. package/dist/esm/vviinn-button.entry.js +0 -17
  147. package/dist/esm/vviinn-error.entry.js +0 -15
  148. package/dist/esm/vviinn-preloader.entry.js +0 -22
  149. package/dist/esm/vviinn-vps-button.entry.js +0 -61
  150. package/dist/esm/vviinn-vps-widget.entry.js +0 -247
  151. package/dist/vviinn-widgets/p-11f61564.js +0 -1
  152. package/dist/vviinn-widgets/p-12851e97.entry.js +0 -1
  153. package/dist/vviinn-widgets/p-18fd769b.js +0 -1
  154. package/dist/vviinn-widgets/p-339c6838.js +0 -1
  155. package/dist/vviinn-widgets/p-3b2c91c0.entry.js +0 -1
  156. package/dist/vviinn-widgets/p-45df9f28.entry.js +0 -1
  157. package/dist/vviinn-widgets/p-57ed5303.entry.js +0 -1
  158. package/dist/vviinn-widgets/p-69850e5b.js +0 -1
  159. package/dist/vviinn-widgets/p-7c2f762a.entry.js +0 -1
  160. package/dist/vviinn-widgets/p-7c3b7388.entry.js +0 -1
  161. package/dist/vviinn-widgets/p-85006f41.entry.js +0 -1
  162. package/dist/vviinn-widgets/p-8a3dd76d.entry.js +0 -1
  163. package/dist/vviinn-widgets/p-99e58be7.entry.js +0 -1
  164. package/dist/vviinn-widgets/p-a2b450b6.entry.js +0 -1
  165. package/dist/vviinn-widgets/p-bcc1ccf0.js +0 -1
  166. package/dist/vviinn-widgets/p-e6fee8d2.js +0 -1
  167. package/www/build/p-11f61564.js +0 -1
  168. package/www/build/p-12851e97.entry.js +0 -1
  169. package/www/build/p-18fd769b.js +0 -1
  170. package/www/build/p-339c6838.js +0 -1
  171. package/www/build/p-3b2c91c0.entry.js +0 -1
  172. package/www/build/p-45df9f28.entry.js +0 -1
  173. package/www/build/p-57ed5303.entry.js +0 -1
  174. package/www/build/p-69850e5b.js +0 -1
  175. package/www/build/p-7c2f762a.entry.js +0 -1
  176. package/www/build/p-7c3b7388.entry.js +0 -1
  177. package/www/build/p-85006f41.entry.js +0 -1
  178. package/www/build/p-8a3dd76d.entry.js +0 -1
  179. package/www/build/p-99e58be7.entry.js +0 -1
  180. package/www/build/p-9e2c131a.js +0 -125
  181. package/www/build/p-a2b450b6.entry.js +0 -1
  182. package/www/build/p-bcc1ccf0.js +0 -1
  183. package/www/build/p-e6fee8d2.js +0 -1
@@ -22,67 +22,19 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'vviinn-widgets';
24
24
 
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
25
33
  let scopeId;
26
34
  let hostTagName;
27
35
  let isSvgMode = false;
28
36
  let renderingRef = null;
29
37
  let queuePending = false;
30
- const win = typeof window !== 'undefined' ? window : {};
31
- const doc = win.document || { head: {} };
32
- const plt = {
33
- $flags$: 0,
34
- $resourcesUrl$: '',
35
- jmp: (h) => h(),
36
- raf: (h) => requestAnimationFrame(h),
37
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
38
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
39
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
40
- };
41
- const promiseResolve = (v) => Promise.resolve(v);
42
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
43
- try {
44
- new CSSStyleSheet();
45
- return typeof new CSSStyleSheet().replace === 'function';
46
- }
47
- catch (e) { }
48
- return false;
49
- })()
50
- ;
51
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
52
- if (listeners) {
53
- listeners.map(([flags, name, method]) => {
54
- const target = getHostListenerTarget(elm, flags) ;
55
- const handler = hostListenerProxy(hostRef, method);
56
- const opts = hostListenerOpts(flags);
57
- plt.ael(target, name, handler, opts);
58
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
59
- });
60
- }
61
- };
62
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
63
- try {
64
- {
65
- if (hostRef.$flags$ & 256 /* isListenReady */) {
66
- // instance is ready, let's call it's member method for this event
67
- hostRef.$lazyInstance$[methodName](ev);
68
- }
69
- else {
70
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
71
- }
72
- }
73
- }
74
- catch (e) {
75
- consoleError(e);
76
- }
77
- };
78
- const getHostListenerTarget = (elm, flags) => {
79
- if (flags & 16 /* TargetBody */)
80
- return doc.body;
81
- return elm;
82
- };
83
- // prettier-ignore
84
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
85
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
86
38
  const createTime = (fnName, tagName = '') => {
87
39
  {
88
40
  return () => {
@@ -97,71 +49,7 @@ const uniqueTime = (key, measureText) => {
97
49
  };
98
50
  }
99
51
  };
100
- const rootAppliedStyles = new WeakMap();
101
- const registerStyle = (scopeId, cssText, allowCS) => {
102
- let style = styles.get(scopeId);
103
- if (supportsConstructibleStylesheets && allowCS) {
104
- style = (style || new CSSStyleSheet());
105
- style.replace(cssText);
106
- }
107
- else {
108
- style = cssText;
109
- }
110
- styles.set(scopeId, style);
111
- };
112
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
113
- let scopeId = getScopeId(cmpMeta);
114
- let style = styles.get(scopeId);
115
- // if an element is NOT connected then getRootNode() will return the wrong root node
116
- // so the fallback is to always use the document for the root node in those cases
117
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
118
- if (style) {
119
- if (typeof style === 'string') {
120
- styleContainerNode = styleContainerNode.head || styleContainerNode;
121
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
122
- let styleElm;
123
- if (!appliedStyles) {
124
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
125
- }
126
- if (!appliedStyles.has(scopeId)) {
127
- {
128
- {
129
- styleElm = doc.createElement('style');
130
- styleElm.innerHTML = style;
131
- }
132
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
133
- }
134
- if (appliedStyles) {
135
- appliedStyles.add(scopeId);
136
- }
137
- }
138
- }
139
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
140
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
141
- }
142
- }
143
- return scopeId;
144
- };
145
- const attachStyles = (hostRef) => {
146
- const cmpMeta = hostRef.$cmpMeta$;
147
- const elm = hostRef.$hostElement$;
148
- const flags = cmpMeta.$flags$;
149
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
150
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
151
- if (flags & 10 /* needsScopedEncapsulation */) {
152
- // only required when we're NOT using native shadow dom (slot)
153
- // or this browser doesn't support native shadow dom
154
- // and this host element was NOT created with SSR
155
- // let's pick out the inner content for slot projection
156
- // create a node to represent where the original
157
- // content was first placed, which is useful later on
158
- // DOM WRITE!!
159
- elm['s-sc'] = scopeId;
160
- elm.classList.add(scopeId + '-h');
161
- }
162
- endAttachStyles();
163
- };
164
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
52
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
165
53
  /**
166
54
  * Default style mode id
167
55
  */
@@ -176,11 +64,30 @@ const EMPTY_OBJ = {};
176
64
  const SVG_NS = 'http://www.w3.org/2000/svg';
177
65
  const HTML_NS = 'http://www.w3.org/1999/xhtml';
178
66
  const isDef = (v) => v != null;
67
+ /**
68
+ * Check whether a value is a 'complex type', defined here as an object or a
69
+ * function.
70
+ *
71
+ * @param o the value to check
72
+ * @returns whether it's a complex type or not
73
+ */
179
74
  const isComplexType = (o) => {
180
75
  // https://jsperf.com/typeof-fn-object/5
181
76
  o = typeof o;
182
77
  return o === 'object' || o === 'function';
183
78
  };
79
+ /**
80
+ * Helper method for querying a `meta` tag that contains a nonce value
81
+ * out of a DOM's head.
82
+ *
83
+ * @param doc The DOM containing the `head` to query against
84
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
85
+ * exists or the tag has no content.
86
+ */
87
+ function queryNonceMetaTagContent(doc) {
88
+ var _a, _b, _c;
89
+ 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;
90
+ }
184
91
  /**
185
92
  * Production h() function based on Preact by
186
93
  * Jason Miller (@developit)
@@ -189,7 +96,6 @@ const isComplexType = (o) => {
189
96
  *
190
97
  * Modified for Stencil's compiler and vdom
191
98
  */
192
- // const stack: any[] = [];
193
99
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
194
100
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
195
101
  const h = (nodeName, vnodeData, ...children) => {
@@ -197,7 +103,7 @@ const h = (nodeName, vnodeData, ...children) => {
197
103
  let key = null;
198
104
  let simple = false;
199
105
  let lastSimple = false;
200
- let vNodeChildren = [];
106
+ const vNodeChildren = [];
201
107
  const walk = (c) => {
202
108
  for (let i = 0; i < c.length; i++) {
203
109
  child = c[i];
@@ -252,6 +158,14 @@ const h = (nodeName, vnodeData, ...children) => {
252
158
  }
253
159
  return vnode;
254
160
  };
161
+ /**
162
+ * A utility function for creating a virtual DOM node from a tag and some
163
+ * possible text content.
164
+ *
165
+ * @param tag the tag for this element
166
+ * @param text possible text content for the node
167
+ * @returns a newly-minted virtual DOM node
168
+ */
255
169
  const newVNode = (tag, text) => {
256
170
  const vnode = {
257
171
  $flags$: 0,
@@ -269,11 +183,31 @@ const newVNode = (tag, text) => {
269
183
  return vnode;
270
184
  };
271
185
  const Host = {};
186
+ /**
187
+ * Check whether a given node is a Host node or not
188
+ *
189
+ * @param node the virtual DOM node to check
190
+ * @returns whether it's a Host node or not
191
+ */
272
192
  const isHost = (node) => node && node.$tag$ === Host;
193
+ /**
194
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
195
+ *
196
+ * Note that these functions convert from {@link d.VNode} to
197
+ * {@link d.ChildNode} to give functional component developers a friendly
198
+ * interface.
199
+ */
273
200
  const vdomFnUtils = {
274
201
  forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
275
202
  map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
276
203
  };
204
+ /**
205
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
206
+ * friendlier public interface (hence, 'convertToPublic').
207
+ *
208
+ * @param node the virtual DOM node to convert
209
+ * @returns a converted child node
210
+ */
277
211
  const convertToPublic = (node) => ({
278
212
  vattrs: node.$attrs$,
279
213
  vchildren: node.$children$,
@@ -282,6 +216,15 @@ const convertToPublic = (node) => ({
282
216
  vtag: node.$tag$,
283
217
  vtext: node.$text$,
284
218
  });
219
+ /**
220
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
221
+ * order to use the resulting object in the virtual DOM. The initial object was
222
+ * likely created as part of presenting a public API, so converting it back
223
+ * involved making it 'private' again (hence, `convertToPrivate`).
224
+ *
225
+ * @param node the child node to convert
226
+ * @returns a converted virtual DOM node
227
+ */
285
228
  const convertToPrivate = (node) => {
286
229
  if (typeof node.vtag === 'function') {
287
230
  const vnodeData = Object.assign({}, node.vattrs);
@@ -300,6 +243,157 @@ const convertToPrivate = (node) => {
300
243
  vnode.$name$ = node.vname;
301
244
  return vnode;
302
245
  };
246
+ /**
247
+ * Parse a new property value for a given property type.
248
+ *
249
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
250
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
251
+ * 1. `any`, the type given to `propValue` in the function signature
252
+ * 2. the type stored from `propType`.
253
+ *
254
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
255
+ *
256
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
257
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
258
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
259
+ * ```tsx
260
+ * <my-cmp prop-val={0}></my-cmp>
261
+ * ```
262
+ *
263
+ * HTML prop values on the other hand, will always a string
264
+ *
265
+ * @param propValue the new value to coerce to some type
266
+ * @param propType the type of the prop, expressed as a binary number
267
+ * @returns the parsed/coerced value
268
+ */
269
+ const parsePropertyValue = (propValue, propType) => {
270
+ // ensure this value is of the correct prop type
271
+ if (propValue != null && !isComplexType(propValue)) {
272
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
273
+ // per the HTML spec, any string value means it is a boolean true value
274
+ // but we'll cheat here and say that the string "false" is the boolean false
275
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
276
+ }
277
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
278
+ // force it to be a number
279
+ return parseFloat(propValue);
280
+ }
281
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
282
+ // could have been passed as a number or boolean
283
+ // but we still want it as a string
284
+ return String(propValue);
285
+ }
286
+ // redundant return here for better minification
287
+ return propValue;
288
+ }
289
+ // not sure exactly what type we want
290
+ // so no need to change to a different type
291
+ return propValue;
292
+ };
293
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
294
+ const createEvent = (ref, name, flags) => {
295
+ const elm = getElement(ref);
296
+ return {
297
+ emit: (detail) => {
298
+ return emitEvent(elm, name, {
299
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
300
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
301
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
302
+ detail,
303
+ });
304
+ },
305
+ };
306
+ };
307
+ /**
308
+ * Helper function to create & dispatch a custom Event on a provided target
309
+ * @param elm the target of the Event
310
+ * @param name the name to give the custom Event
311
+ * @param opts options for configuring a custom Event
312
+ * @returns the custom Event
313
+ */
314
+ const emitEvent = (elm, name, opts) => {
315
+ const ev = plt.ce(name, opts);
316
+ elm.dispatchEvent(ev);
317
+ return ev;
318
+ };
319
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
320
+ const registerStyle = (scopeId, cssText, allowCS) => {
321
+ let style = styles.get(scopeId);
322
+ if (supportsConstructableStylesheets && allowCS) {
323
+ style = (style || new CSSStyleSheet());
324
+ if (typeof style === 'string') {
325
+ style = cssText;
326
+ }
327
+ else {
328
+ style.replaceSync(cssText);
329
+ }
330
+ }
331
+ else {
332
+ style = cssText;
333
+ }
334
+ styles.set(scopeId, style);
335
+ };
336
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
337
+ var _a;
338
+ let scopeId = getScopeId(cmpMeta);
339
+ const style = styles.get(scopeId);
340
+ // if an element is NOT connected then getRootNode() will return the wrong root node
341
+ // so the fallback is to always use the document for the root node in those cases
342
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
343
+ if (style) {
344
+ if (typeof style === 'string') {
345
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
346
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
347
+ let styleElm;
348
+ if (!appliedStyles) {
349
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
350
+ }
351
+ if (!appliedStyles.has(scopeId)) {
352
+ {
353
+ // TODO(STENCIL-659): Remove code implementing the CSS variable shim
354
+ {
355
+ styleElm = doc.createElement('style');
356
+ styleElm.innerHTML = style;
357
+ }
358
+ // Apply CSP nonce to the style tag if it exists
359
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
360
+ if (nonce != null) {
361
+ styleElm.setAttribute('nonce', nonce);
362
+ }
363
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
364
+ }
365
+ if (appliedStyles) {
366
+ appliedStyles.add(scopeId);
367
+ }
368
+ }
369
+ }
370
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
371
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
372
+ }
373
+ }
374
+ return scopeId;
375
+ };
376
+ const attachStyles = (hostRef) => {
377
+ const cmpMeta = hostRef.$cmpMeta$;
378
+ const elm = hostRef.$hostElement$;
379
+ const flags = cmpMeta.$flags$;
380
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
381
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
382
+ // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
383
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
384
+ // only required when we're NOT using native shadow dom (slot)
385
+ // or this browser doesn't support native shadow dom
386
+ // and this host element was NOT created with SSR
387
+ // let's pick out the inner content for slot projection
388
+ // create a node to represent where the original
389
+ // content was first placed, which is useful later on
390
+ // DOM WRITE!!
391
+ elm['s-sc'] = scopeId;
392
+ elm.classList.add(scopeId + '-h');
393
+ }
394
+ endAttachStyles();
395
+ };
396
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
303
397
  /**
304
398
  * Production setAccessor() function based on Preact by
305
399
  * Jason Miller (@developit)
@@ -397,11 +491,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
397
491
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
398
492
  try {
399
493
  if (!elm.tagName.includes('-')) {
400
- let n = newValue == null ? '' : newValue;
494
+ const n = newValue == null ? '' : newValue;
401
495
  // Workaround for Safari, moving the <input> caret when re-assigning the same valued
402
496
  if (memberName === 'list') {
403
497
  isProp = false;
404
- // tslint:disable-next-line: triple-equals
405
498
  }
406
499
  else if (oldValue == null || elm[memberName] != n) {
407
500
  elm[memberName] = n;
@@ -420,7 +513,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
420
513
  }
421
514
  }
422
515
  }
423
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
516
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
424
517
  newValue = newValue === true ? '' : newValue;
425
518
  {
426
519
  elm.setAttribute(memberName, newValue);
@@ -435,7 +528,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
435
528
  // if the element passed in is a shadow root, which is a document fragment
436
529
  // then we want to be adding attrs/props to the shadow root's "host" element
437
530
  // if it's not a shadow root, then we add attrs/props to the same element
438
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
531
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
439
532
  ? newVnode.$elm$.host
440
533
  : newVnode.$elm$;
441
534
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -453,9 +546,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
453
546
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
454
547
  }
455
548
  };
549
+ /**
550
+ * Create a DOM Node corresponding to one of the children of a given VNode.
551
+ *
552
+ * @param oldParentVNode the parent VNode from the previous render
553
+ * @param newParentVNode the parent VNode from the current render
554
+ * @param childIndex the index of the VNode, in the _new_ parent node's
555
+ * children, for which we will create a new DOM node
556
+ * @param parentElm the parent DOM node which our new node will be a child of
557
+ * @returns the newly created node
558
+ */
456
559
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
457
560
  // tslint:disable-next-line: prefer-const
458
- let newVNode = newParentVNode.$children$[childIndex];
561
+ const newVNode = newParentVNode.$children$[childIndex];
459
562
  let i = 0;
460
563
  let elm;
461
564
  let childNode;
@@ -506,6 +609,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
506
609
  }
507
610
  return elm;
508
611
  };
612
+ /**
613
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
614
+ * add them to the DOM in the appropriate place.
615
+ *
616
+ * @param parentElm the DOM node which should be used as a parent for the new
617
+ * DOM nodes
618
+ * @param before a child of the `parentElm` which the new children should be
619
+ * inserted before (optional)
620
+ * @param parentVNode the parent virtual DOM node
621
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
622
+ * @param startIdx the index in the child virtual DOM nodes at which to start
623
+ * creating DOM nodes (inclusive)
624
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
625
+ * creating DOM nodes (inclusive)
626
+ */
509
627
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
510
628
  let containerElm = (parentElm);
511
629
  let childNode;
@@ -522,16 +640,98 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
522
640
  }
523
641
  }
524
642
  };
525
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
526
- for (; startIdx <= endIdx; ++startIdx) {
527
- if ((vnode = vnodes[startIdx])) {
528
- elm = vnode.$elm$;
529
- callNodeRefs(vnode);
530
- // remove the vnode's element from the dom
531
- elm.remove();
643
+ /**
644
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
645
+ * This can be used to, for instance, clean up after a list of children which
646
+ * should no longer be shown.
647
+ *
648
+ * This function also handles some of Stencil's slot relocation logic.
649
+ *
650
+ * @param vnodes a list of virtual DOM nodes to remove
651
+ * @param startIdx the index at which to start removing nodes (inclusive)
652
+ * @param endIdx the index at which to stop removing nodes (inclusive)
653
+ */
654
+ const removeVnodes = (vnodes, startIdx, endIdx) => {
655
+ for (let index = startIdx; index <= endIdx; ++index) {
656
+ const vnode = vnodes[index];
657
+ if (vnode) {
658
+ const elm = vnode.$elm$;
659
+ nullifyVNodeRefs(vnode);
660
+ if (elm) {
661
+ // remove the vnode's element from the dom
662
+ elm.remove();
663
+ }
532
664
  }
533
665
  }
534
666
  };
667
+ /**
668
+ * Reconcile the children of a new VNode with the children of an old VNode by
669
+ * traversing the two collections of children, identifying nodes that are
670
+ * conserved or changed, calling out to `patch` to make any necessary
671
+ * updates to the DOM, and rearranging DOM nodes as needed.
672
+ *
673
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
674
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
675
+ * 'windows' by storing start and end indices and references to the
676
+ * corresponding array entries. Initially the two 'windows' are basically equal
677
+ * to the entire array, but we progressively narrow the windows until there are
678
+ * no children left to update by doing the following:
679
+ *
680
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
681
+ * that if we have an initial array like the following we'll end up dealing
682
+ * only with a window bounded by the highlighted elements:
683
+ *
684
+ * [null, null, VNode1 , ... , VNode2, null, null]
685
+ * ^^^^^^ ^^^^^^
686
+ *
687
+ * 2. Check to see if the elements at the head and tail positions are equal
688
+ * across the windows. This will basically detect elements which haven't
689
+ * been added, removed, or changed position, i.e. if you had the following
690
+ * VNode elements (represented as HTML):
691
+ *
692
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
693
+ * newVNode: `<div><p><span>THERE</span></p></div>`
694
+ *
695
+ * Then when comparing the children of the `<div>` tag we check the equality
696
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
697
+ * same tag in the same position, we'd be able to avoid completely
698
+ * re-rendering the subtree under them with a new DOM element and would just
699
+ * call out to `patch` to handle reconciling their children and so on.
700
+ *
701
+ * 3. Check, for both windows, to see if the element at the beginning of the
702
+ * window corresponds to the element at the end of the other window. This is
703
+ * a heuristic which will let us identify _some_ situations in which
704
+ * elements have changed position, for instance it _should_ detect that the
705
+ * children nodes themselves have not changed but merely moved in the
706
+ * following example:
707
+ *
708
+ * oldVNode: `<div><element-one /><element-two /></div>`
709
+ * newVNode: `<div><element-two /><element-one /></div>`
710
+ *
711
+ * If we find cases like this then we also need to move the concrete DOM
712
+ * elements corresponding to the moved children to write the re-order to the
713
+ * DOM.
714
+ *
715
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
716
+ * nodes in the old children which have the same key as the first element in
717
+ * our window on the new children. If we find such a node we handle calling
718
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
719
+ * what we find.
720
+ *
721
+ * Finally, once we've narrowed our 'windows' to the point that either of them
722
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
723
+ * insertion or deletion that needs to happen to get a DOM state that correctly
724
+ * reflects the new child VNodes. If, for instance, after our window on the old
725
+ * children has collapsed we still have more nodes on the new children that
726
+ * we haven't dealt with yet then we need to add them, or if the new children
727
+ * collapse but we still have unhandled _old_ children then we need to make
728
+ * sure the corresponding DOM nodes are removed.
729
+ *
730
+ * @param parentElm the node into which the parent VNode is rendered
731
+ * @param oldCh the old children of the parent node
732
+ * @param newVNode the new VNode which will replace the parent
733
+ * @param newCh the new children of the parent node
734
+ */
535
735
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
536
736
  let oldStartIdx = 0;
537
737
  let newStartIdx = 0;
@@ -547,7 +747,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
547
747
  let elmToMove;
548
748
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
549
749
  if (oldStartVnode == null) {
550
- // Vnode might have been moved left
750
+ // VNode might have been moved left
551
751
  oldStartVnode = oldCh[++oldStartIdx];
552
752
  }
553
753
  else if (oldEndVnode == null) {
@@ -560,29 +760,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
560
760
  newEndVnode = newCh[--newEndIdx];
561
761
  }
562
762
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
763
+ // if the start nodes are the same then we should patch the new VNode
764
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
765
+ // indices to reflect that. We don't need to move any DOM Nodes around
766
+ // since things are matched up in order.
563
767
  patch(oldStartVnode, newStartVnode);
564
768
  oldStartVnode = oldCh[++oldStartIdx];
565
769
  newStartVnode = newCh[++newStartIdx];
566
770
  }
567
771
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
772
+ // likewise, if the end nodes are the same we patch new onto old and
773
+ // decrement our end indices, and also likewise in this case we don't
774
+ // need to move any DOM Nodes.
568
775
  patch(oldEndVnode, newEndVnode);
569
776
  oldEndVnode = oldCh[--oldEndIdx];
570
777
  newEndVnode = newCh[--newEndIdx];
571
778
  }
572
779
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
573
780
  patch(oldStartVnode, newEndVnode);
781
+ // We need to move the element for `oldStartVnode` into a position which
782
+ // will be appropriate for `newEndVnode`. For this we can use
783
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
784
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
785
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
786
+ //
787
+ // <old-start-node />
788
+ // <some-intervening-node />
789
+ // <old-end-node />
790
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
791
+ // <next-sibling />
792
+ //
793
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
794
+ // the node for `oldStartVnode` at the end of the children of
795
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
796
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
797
+ // append it to the children of the parent element.
574
798
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
575
799
  oldStartVnode = oldCh[++oldStartIdx];
576
800
  newEndVnode = newCh[--newEndIdx];
577
801
  }
578
802
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
579
803
  patch(oldEndVnode, newStartVnode);
804
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
805
+ // the same node, so since we're here we know that they are not. Thus we
806
+ // can move the element for `oldEndVnode` _before_ the element for
807
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
808
+ // future.
580
809
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
581
810
  oldEndVnode = oldCh[--oldEndIdx];
582
811
  newStartVnode = newCh[++newStartIdx];
583
812
  }
584
813
  else {
585
- // createKeyToOldIdx
814
+ // Here we do some checks to match up old and new nodes based on the
815
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
816
+ // in the JSX for a DOM element in the implementation of a Stencil
817
+ // component.
818
+ //
819
+ // First we check to see if there are any nodes in the array of old
820
+ // children which have the same key as the first node in the new
821
+ // children.
586
822
  idxInOld = -1;
587
823
  {
588
824
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -593,23 +829,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
593
829
  }
594
830
  }
595
831
  if (idxInOld >= 0) {
832
+ // We found a node in the old children which matches up with the first
833
+ // node in the new children! So let's deal with that
596
834
  elmToMove = oldCh[idxInOld];
597
835
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
836
+ // the tag doesn't match so we'll need a new DOM element
598
837
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
599
838
  }
600
839
  else {
601
840
  patch(elmToMove, newStartVnode);
841
+ // invalidate the matching old node so that we won't try to update it
842
+ // again later on
602
843
  oldCh[idxInOld] = undefined;
603
844
  node = elmToMove.$elm$;
604
845
  }
605
846
  newStartVnode = newCh[++newStartIdx];
606
847
  }
607
848
  else {
608
- // new element
849
+ // We either didn't find an element in the old children that matches
850
+ // the key of the first new child OR the build is not using `key`
851
+ // attributes at all. In either case we need to create a new element
852
+ // for the new node.
609
853
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
610
854
  newStartVnode = newCh[++newStartIdx];
611
855
  }
612
856
  if (node) {
857
+ // if we created a new node then handle inserting it to the DOM
613
858
  {
614
859
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
615
860
  }
@@ -617,22 +862,53 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
617
862
  }
618
863
  }
619
864
  if (oldStartIdx > oldEndIdx) {
865
+ // we have some more new nodes to add which don't match up with old nodes
620
866
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
621
867
  }
622
868
  else if (newStartIdx > newEndIdx) {
869
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
870
+ // in the new array, so lets remove them (which entails cleaning up the
871
+ // relevant DOM nodes)
623
872
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
624
873
  }
625
874
  };
626
- const isSameVnode = (vnode1, vnode2) => {
875
+ /**
876
+ * Compare two VNodes to determine if they are the same
877
+ *
878
+ * **NB**: This function is an equality _heuristic_ based on the available
879
+ * information set on the two VNodes and can be misleading under certain
880
+ * circumstances. In particular, if the two nodes do not have `key` attrs
881
+ * (available under `$key$` on VNodes) then the function falls back on merely
882
+ * checking that they have the same tag.
883
+ *
884
+ * So, in other words, if `key` attrs are not set on VNodes which may be
885
+ * changing order within a `children` array or something along those lines then
886
+ * we could obtain a false negative and then have to do needless re-rendering
887
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
888
+ *
889
+ * @param leftVNode the first VNode to check
890
+ * @param rightVNode the second VNode to check
891
+ * @returns whether they're equal or not
892
+ */
893
+ const isSameVnode = (leftVNode, rightVNode) => {
627
894
  // compare if two vnode to see if they're "technically" the same
628
895
  // need to have the same element tag, and same key to be the same
629
- if (vnode1.$tag$ === vnode2.$tag$) {
896
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
897
+ // this will be set if components in the build have `key` attrs set on them
630
898
  {
631
- return vnode1.$key$ === vnode2.$key$;
899
+ return leftVNode.$key$ === rightVNode.$key$;
632
900
  }
633
901
  }
634
902
  return false;
635
903
  };
904
+ /**
905
+ * Handle reconciling an outdated VNode with a new one which corresponds to
906
+ * it. This function handles flushing updates to the DOM and reconciling the
907
+ * children of the two nodes (if any).
908
+ *
909
+ * @param oldVNode an old VNode whose DOM element and children we want to update
910
+ * @param newVNode a new VNode representing an updated version of the old one
911
+ */
636
912
  const patch = (oldVNode, newVNode) => {
637
913
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
638
914
  const oldChildren = oldVNode.$children$;
@@ -645,7 +921,6 @@ const patch = (oldVNode, newVNode) => {
645
921
  // only add this to the when the compiler sees we're using an svg somewhere
646
922
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
647
923
  }
648
- // element node
649
924
  {
650
925
  if (tag === 'slot')
651
926
  ;
@@ -658,6 +933,7 @@ const patch = (oldVNode, newVNode) => {
658
933
  }
659
934
  if (oldChildren !== null && newChildren !== null) {
660
935
  // looks like there's child vnodes for both the old and new vnodes
936
+ // so we need to call `updateChildren` to reconcile them
661
937
  updateChildren(elm, oldChildren, newVNode, newChildren);
662
938
  }
663
939
  else if (newChildren !== null) {
@@ -683,12 +959,31 @@ const patch = (oldVNode, newVNode) => {
683
959
  elm.data = text;
684
960
  }
685
961
  };
686
- const callNodeRefs = (vNode) => {
962
+ /**
963
+ * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
964
+ * calling them with `null`. This signals that the DOM element corresponding to
965
+ * the VDom node has been removed from the DOM.
966
+ *
967
+ * @param vNode a virtual DOM node
968
+ */
969
+ const nullifyVNodeRefs = (vNode) => {
687
970
  {
688
971
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
689
- vNode.$children$ && vNode.$children$.map(callNodeRefs);
972
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
690
973
  }
691
974
  };
975
+ /**
976
+ * The main entry point for Stencil's virtual DOM-based rendering engine
977
+ *
978
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
979
+ * function will handle creating a virtual DOM tree with a single root, patching
980
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
981
+ * relocation, and reflecting attributes.
982
+ *
983
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
984
+ * the DOM node into which it should be rendered.
985
+ * @param renderFnResults the virtual DOM nodes to be rendered
986
+ */
692
987
  const renderVdom = (hostRef, renderFnResults) => {
693
988
  const hostElm = hostRef.$hostElement$;
694
989
  const cmpMeta = hostRef.$cmpMeta$;
@@ -700,7 +995,7 @@ const renderVdom = (hostRef, renderFnResults) => {
700
995
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
701
996
  }
702
997
  rootVnode.$tag$ = null;
703
- rootVnode.$flags$ |= 4 /* isHost */;
998
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
704
999
  hostRef.$vnode$ = rootVnode;
705
1000
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
706
1001
  {
@@ -709,32 +1004,6 @@ const renderVdom = (hostRef, renderFnResults) => {
709
1004
  // synchronous patch
710
1005
  patch(oldVNode, rootVnode);
711
1006
  };
712
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
713
- const createEvent = (ref, name, flags) => {
714
- const elm = getElement(ref);
715
- return {
716
- emit: (detail) => {
717
- return emitEvent(elm, name, {
718
- bubbles: !!(flags & 4 /* Bubbles */),
719
- composed: !!(flags & 2 /* Composed */),
720
- cancelable: !!(flags & 1 /* Cancellable */),
721
- detail,
722
- });
723
- },
724
- };
725
- };
726
- /**
727
- * Helper function to create & dispatch a custom Event on a provided target
728
- * @param elm the target of the Event
729
- * @param name the name to give the custom Event
730
- * @param opts options for configuring a custom Event
731
- * @returns the custom Event
732
- */
733
- const emitEvent = (elm, name, opts) => {
734
- const ev = plt.ce(name, opts);
735
- elm.dispatchEvent(ev);
736
- return ev;
737
- };
738
1007
  const attachToAncestor = (hostRef, ancestorComponent) => {
739
1008
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
740
1009
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -742,10 +1011,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
742
1011
  };
743
1012
  const scheduleUpdate = (hostRef, isInitialLoad) => {
744
1013
  {
745
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1014
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
746
1015
  }
747
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
748
- hostRef.$flags$ |= 512 /* needsRerender */;
1016
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1017
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
749
1018
  return;
750
1019
  }
751
1020
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -755,27 +1024,71 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
755
1024
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
756
1025
  return writeTask(dispatch) ;
757
1026
  };
1027
+ /**
1028
+ * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1029
+ * component lifecycle methods like `componentWillLoad` as well as
1030
+ * {@link updateComponent}, which will kick off the virtual DOM re-render.
1031
+ *
1032
+ * @param hostRef a reference to a host DOM node
1033
+ * @param isInitialLoad whether we're on the initial load or not
1034
+ * @returns an empty Promise which is used to enqueue a series of operations for
1035
+ * the component
1036
+ */
758
1037
  const dispatchHooks = (hostRef, isInitialLoad) => {
759
1038
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
760
1039
  const instance = hostRef.$lazyInstance$ ;
761
- let promise;
1040
+ // We're going to use this variable together with `enqueue` to implement a
1041
+ // little promise-based queue. We start out with it `undefined`. When we add
1042
+ // the first function to the queue we'll set this variable to be that
1043
+ // function's return value. When we attempt to add subsequent values to the
1044
+ // queue we'll check that value and, if it was a `Promise`, we'll then chain
1045
+ // the new function off of that `Promise` using `.then()`. This will give our
1046
+ // queue two nice properties:
1047
+ //
1048
+ // 1. If all functions added to the queue are synchronous they'll be called
1049
+ // synchronously right away.
1050
+ // 2. If all functions added to the queue are asynchronous they'll all be
1051
+ // called in order after `dispatchHooks` exits.
1052
+ let maybePromise;
762
1053
  if (isInitialLoad) {
763
1054
  {
764
- hostRef.$flags$ |= 256 /* isListenReady */;
1055
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
765
1056
  if (hostRef.$queuedListeners$) {
766
1057
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
767
- hostRef.$queuedListeners$ = null;
1058
+ hostRef.$queuedListeners$ = undefined;
768
1059
  }
769
1060
  }
770
1061
  {
771
- promise = safeCall(instance, 'componentWillLoad');
1062
+ // If `componentWillLoad` returns a `Promise` then we want to wait on
1063
+ // whatever's going on in that `Promise` before we launch into
1064
+ // rendering the component, doing other lifecycle stuff, etc. So
1065
+ // in that case we assign the returned promise to the variable we
1066
+ // declared above to hold a possible 'queueing' Promise
1067
+ maybePromise = safeCall(instance, 'componentWillLoad');
772
1068
  }
773
1069
  }
774
1070
  endSchedule();
775
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1071
+ return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
776
1072
  };
1073
+ /**
1074
+ * This function uses a Promise to implement a simple first-in, first-out queue
1075
+ * of functions to be called.
1076
+ *
1077
+ * The queue is ordered on the basis of the first argument. If it's
1078
+ * `undefined`, then nothing is on the queue yet, so the provided function can
1079
+ * be called synchronously (although note that this function may return a
1080
+ * `Promise`). The idea is that then the return value of that enqueueing
1081
+ * operation is kept around, so that if it was a `Promise` then subsequent
1082
+ * functions can be enqueued by calling this function again with that `Promise`
1083
+ * as the first argument.
1084
+ *
1085
+ * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1086
+ * @param fn a function to enqueue
1087
+ * @returns either a `Promise` or the return value of the provided function
1088
+ */
1089
+ const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
777
1090
  const updateComponent = async (hostRef, instance, isInitialLoad) => {
778
- // updateComponent
1091
+ var _a;
779
1092
  const elm = hostRef.$hostElement$;
780
1093
  const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
781
1094
  const rc = elm['s-rc'];
@@ -797,14 +1110,14 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
797
1110
  endRender();
798
1111
  endUpdate();
799
1112
  {
800
- const childrenPromises = elm['s-p'];
1113
+ const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
801
1114
  const postUpdate = () => postUpdateComponent(hostRef);
802
1115
  if (childrenPromises.length === 0) {
803
1116
  postUpdate();
804
1117
  }
805
1118
  else {
806
1119
  Promise.all(childrenPromises).then(postUpdate);
807
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1120
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
808
1121
  childrenPromises.length = 0;
809
1122
  }
810
1123
  }
@@ -814,10 +1127,10 @@ const callRender = (hostRef, instance, elm) => {
814
1127
  renderingRef = instance;
815
1128
  instance = instance.render() ;
816
1129
  {
817
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1130
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
818
1131
  }
819
1132
  {
820
- hostRef.$flags$ |= 2 /* hasRendered */;
1133
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
821
1134
  }
822
1135
  {
823
1136
  {
@@ -843,8 +1156,8 @@ const postUpdateComponent = (hostRef) => {
843
1156
  const endPostUpdate = createTime('postUpdate', tagName);
844
1157
  const instance = hostRef.$lazyInstance$ ;
845
1158
  const ancestorComponent = hostRef.$ancestorComponent$;
846
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
847
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1159
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1160
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
848
1161
  {
849
1162
  // DOM WRITE!
850
1163
  addHydratedFlag(elm);
@@ -870,10 +1183,10 @@ const postUpdateComponent = (hostRef) => {
870
1183
  hostRef.$onRenderResolve$();
871
1184
  hostRef.$onRenderResolve$ = undefined;
872
1185
  }
873
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1186
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
874
1187
  nextTick(() => scheduleUpdate(hostRef, false));
875
1188
  }
876
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1189
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
877
1190
  }
878
1191
  // ( •_•)
879
1192
  // ( •_•)>⌐■-■
@@ -884,7 +1197,7 @@ const forceUpdate = (ref) => {
884
1197
  const hostRef = getHostRef(ref);
885
1198
  const isConnected = hostRef.$hostElement$.isConnected;
886
1199
  if (isConnected &&
887
- (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1200
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
888
1201
  scheduleUpdate(hostRef, false);
889
1202
  }
890
1203
  // Returns "true" when the forced update was successfully scheduled
@@ -910,35 +1223,8 @@ const safeCall = (instance, method, arg) => {
910
1223
  }
911
1224
  return undefined;
912
1225
  };
913
- const then = (promise, thenFn) => {
914
- return promise && promise.then ? promise.then(thenFn) : thenFn();
915
- };
916
1226
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
917
1227
  ;
918
- const parsePropertyValue = (propValue, propType) => {
919
- // ensure this value is of the correct prop type
920
- if (propValue != null && !isComplexType(propValue)) {
921
- if (propType & 4 /* Boolean */) {
922
- // per the HTML spec, any string value means it is a boolean true value
923
- // but we'll cheat here and say that the string "false" is the boolean false
924
- return propValue === 'false' ? false : propValue === '' || !!propValue;
925
- }
926
- if (propType & 2 /* Number */) {
927
- // force it to be a number
928
- return parseFloat(propValue);
929
- }
930
- if (propType & 1 /* String */) {
931
- // could have been passed as a number or boolean
932
- // but we still want it as a string
933
- return String(propValue);
934
- }
935
- // redundant return here for better minification
936
- return propValue;
937
- }
938
- // not sure exactly what type we want
939
- // so no need to change to a different type
940
- return propValue;
941
- };
942
1228
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
943
1229
  const setValue = (ref, propName, newVal, cmpMeta) => {
944
1230
  // check our new property value against our internal value
@@ -948,13 +1234,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
948
1234
  const flags = hostRef.$flags$;
949
1235
  const instance = hostRef.$lazyInstance$ ;
950
1236
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
951
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1237
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1238
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1239
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1240
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
952
1241
  // gadzooks! the property's value has changed!!
953
1242
  // set our new value!
954
1243
  hostRef.$instanceValues$.set(propName, newVal);
955
1244
  if (instance) {
956
1245
  // get an array of method names of watch functions to call
957
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1246
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
958
1247
  const watchMethods = cmpMeta.$watchers$[propName];
959
1248
  if (watchMethods) {
960
1249
  // this instance is watching for when this property changed
@@ -969,7 +1258,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
969
1258
  });
970
1259
  }
971
1260
  }
972
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1261
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
973
1262
  // looks like this value actually changed, so we've got work to do!
974
1263
  // but only if we've already rendered, otherwise just chill out
975
1264
  // queue that we need to do an update, but don't worry about queuing
@@ -979,6 +1268,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
979
1268
  }
980
1269
  }
981
1270
  };
1271
+ /**
1272
+ * Attach a series of runtime constructs to a compiled Stencil component
1273
+ * constructor, including getters and setters for the `@Prop` and `@State`
1274
+ * decorators, callbacks for when attributes change, and so on.
1275
+ *
1276
+ * @param Cstr the constructor for a component that we need to process
1277
+ * @param cmpMeta metadata collected previously about the component
1278
+ * @param flags a number used to store a series of bit flags
1279
+ * @returns a reference to the same constructor passed in (but now mutated)
1280
+ */
982
1281
  const proxyComponent = (Cstr, cmpMeta, flags) => {
983
1282
  if (cmpMeta.$members$) {
984
1283
  if (Cstr.watchers) {
@@ -988,8 +1287,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
988
1287
  const members = Object.entries(cmpMeta.$members$);
989
1288
  const prototype = Cstr.prototype;
990
1289
  members.map(([memberName, [memberFlags]]) => {
991
- if ((memberFlags & 31 /* Prop */ ||
992
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1290
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1291
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
993
1292
  // proxyComponent - prop
994
1293
  Object.defineProperty(prototype, memberName, {
995
1294
  get() {
@@ -1005,19 +1304,19 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1005
1304
  });
1006
1305
  }
1007
1306
  });
1008
- if ((flags & 1 /* isElementConstructor */)) {
1307
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1009
1308
  const attrNameToPropName = new Map();
1010
1309
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1011
1310
  plt.jmp(() => {
1012
1311
  const propName = attrNameToPropName.get(attrName);
1013
- // In a webcomponent lifecyle the attributeChangedCallback runs prior to connectedCallback
1312
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1014
1313
  // in the case where an attribute was set inline.
1015
1314
  // ```html
1016
1315
  // <my-component some-attribute="some-value"></my-component>
1017
1316
  // ```
1018
1317
  //
1019
- // There is an edge case where a developer sets the attribute inline on a custom element and then programatically
1020
- // changes it before it has been upgraded as shown below:
1318
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1319
+ // programmatically changes it before it has been upgraded as shown below:
1021
1320
  //
1022
1321
  // ```html
1023
1322
  // <!-- this component has _not_ been upgraded yet -->
@@ -1027,13 +1326,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1027
1326
  // el = document.querySelector("#test");
1028
1327
  // el.someAttribute = "another-value";
1029
1328
  // // upgrade component
1030
- // cutsomElements.define('my-component', MyComponent);
1329
+ // customElements.define('my-component', MyComponent);
1031
1330
  // </script>
1032
1331
  // ```
1033
1332
  // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1034
1333
  // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1035
1334
  // to the value that was set inline i.e. "some-value" from above example. When
1036
- // the connectedCallback attempts to unshadow it will use "some-value" as the intial value rather than "another-value"
1335
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1037
1336
  //
1038
1337
  // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1039
1338
  // by connectedCallback as this attributeChangedCallback will not fire.
@@ -1047,17 +1346,25 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1047
1346
  newValue = this[propName];
1048
1347
  delete this[propName];
1049
1348
  }
1349
+ else if (prototype.hasOwnProperty(propName) &&
1350
+ typeof this[propName] === 'number' &&
1351
+ this[propName] == newValue) {
1352
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1353
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1354
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1355
+ return;
1356
+ }
1050
1357
  this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1051
1358
  });
1052
1359
  };
1053
1360
  // create an array of attributes to observe
1054
1361
  // and also create a map of html attribute name to js property name
1055
1362
  Cstr.observedAttributes = members
1056
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1363
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1057
1364
  .map(([propName, m]) => {
1058
1365
  const attrName = m[1] || propName;
1059
1366
  attrNameToPropName.set(attrName, propName);
1060
- if (m[0] & 512 /* ReflectAttr */) {
1367
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1061
1368
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1062
1369
  }
1063
1370
  return attrName;
@@ -1068,10 +1375,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1068
1375
  };
1069
1376
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1070
1377
  // initializeComponent
1071
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1378
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1379
+ // Let the runtime know that the component has been initialized
1380
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1072
1381
  {
1073
- // we haven't initialized this element yet
1074
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1075
1382
  // lazy loaded components
1076
1383
  // request the component's implementation to be
1077
1384
  // wired up with the host element
@@ -1089,7 +1396,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1089
1396
  {
1090
1397
  cmpMeta.$watchers$ = Cstr.watchers;
1091
1398
  }
1092
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1399
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1093
1400
  Cstr.isProxied = true;
1094
1401
  }
1095
1402
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1097,7 +1404,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1097
1404
  // but let's keep track of when we start and stop
1098
1405
  // so that the getters/setters don't incorrectly step on data
1099
1406
  {
1100
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1407
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1101
1408
  }
1102
1409
  // construct the lazy-loaded component implementation
1103
1410
  // passing the hostRef is very important during
@@ -1110,10 +1417,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1110
1417
  consoleError(e);
1111
1418
  }
1112
1419
  {
1113
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1420
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1114
1421
  }
1115
1422
  {
1116
- hostRef.$flags$ |= 128 /* isWatchReady */;
1423
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1117
1424
  }
1118
1425
  endNewInstance();
1119
1426
  fireConnectedCallback(hostRef.$lazyInstance$);
@@ -1124,7 +1431,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1124
1431
  const scopeId = getScopeId(cmpMeta);
1125
1432
  if (!styles.has(scopeId)) {
1126
1433
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1127
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1434
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1128
1435
  endRegisterStyles();
1129
1436
  }
1130
1437
  }
@@ -1133,7 +1440,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1133
1440
  const ancestorComponent = hostRef.$ancestorComponent$;
1134
1441
  const schedule = () => scheduleUpdate(hostRef, true);
1135
1442
  if (ancestorComponent && ancestorComponent['s-rc']) {
1136
- // this is the intial load and this component it has an ancestor component
1443
+ // this is the initial load and this component it has an ancestor component
1137
1444
  // but the ancestor component has NOT fired its will update lifecycle yet
1138
1445
  // so let's just cool our jets and wait for the ancestor to continue first
1139
1446
  // this will get fired off when the ancestor component
@@ -1151,13 +1458,13 @@ const fireConnectedCallback = (instance) => {
1151
1458
  }
1152
1459
  };
1153
1460
  const connectedCallback = (elm) => {
1154
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1461
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1155
1462
  const hostRef = getHostRef(elm);
1156
1463
  const cmpMeta = hostRef.$cmpMeta$;
1157
1464
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1158
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1465
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1159
1466
  // first time this component has connected
1160
- hostRef.$flags$ |= 1 /* hasConnected */;
1467
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1161
1468
  {
1162
1469
  // find the first ancestor component (if there is one) and register
1163
1470
  // this component as one of the actively loading child components for its ancestor
@@ -1177,7 +1484,7 @@ const connectedCallback = (elm) => {
1177
1484
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1178
1485
  if (cmpMeta.$members$) {
1179
1486
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1180
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1487
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1181
1488
  const value = elm[memberName];
1182
1489
  delete elm[memberName];
1183
1490
  elm[memberName] = value;
@@ -1200,7 +1507,7 @@ const connectedCallback = (elm) => {
1200
1507
  }
1201
1508
  };
1202
1509
  const disconnectedCallback = (elm) => {
1203
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1510
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1204
1511
  const hostRef = getHostRef(elm);
1205
1512
  const instance = hostRef.$lazyInstance$ ;
1206
1513
  {
@@ -1215,6 +1522,7 @@ const disconnectedCallback = (elm) => {
1215
1522
  }
1216
1523
  };
1217
1524
  const bootstrapLazy = (lazyBundles, options = {}) => {
1525
+ var _a;
1218
1526
  const endBootstrap = createTime();
1219
1527
  const cmpTags = [];
1220
1528
  const exclude = options.exclude || [];
@@ -1227,74 +1535,81 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1227
1535
  let isBootstrapping = true;
1228
1536
  Object.assign(plt, options);
1229
1537
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1230
- lazyBundles.map((lazyBundle) => lazyBundle[1].map((compactMeta) => {
1231
- const cmpMeta = {
1232
- $flags$: compactMeta[0],
1233
- $tagName$: compactMeta[1],
1234
- $members$: compactMeta[2],
1235
- $listeners$: compactMeta[3],
1236
- };
1237
- {
1238
- cmpMeta.$members$ = compactMeta[2];
1239
- }
1240
- {
1241
- cmpMeta.$listeners$ = compactMeta[3];
1242
- }
1243
- {
1244
- cmpMeta.$attrsToReflect$ = [];
1245
- }
1246
- {
1247
- cmpMeta.$watchers$ = {};
1248
- }
1249
- const tagName = cmpMeta.$tagName$;
1250
- const HostElement = class extends HTMLElement {
1251
- // StencilLazyHost
1252
- constructor(self) {
1253
- // @ts-ignore
1254
- super(self);
1255
- self = this;
1256
- registerHost(self, cmpMeta);
1257
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1258
- // this component is using shadow dom
1259
- // and this browser supports shadow dom
1260
- // add the read-only property "shadowRoot" to the host element
1261
- // adding the shadow root build conditionals to minimize runtime
1262
- {
1538
+ lazyBundles.map((lazyBundle) => {
1539
+ lazyBundle[1].map((compactMeta) => {
1540
+ const cmpMeta = {
1541
+ $flags$: compactMeta[0],
1542
+ $tagName$: compactMeta[1],
1543
+ $members$: compactMeta[2],
1544
+ $listeners$: compactMeta[3],
1545
+ };
1546
+ {
1547
+ cmpMeta.$members$ = compactMeta[2];
1548
+ }
1549
+ {
1550
+ cmpMeta.$listeners$ = compactMeta[3];
1551
+ }
1552
+ {
1553
+ cmpMeta.$attrsToReflect$ = [];
1554
+ }
1555
+ {
1556
+ cmpMeta.$watchers$ = {};
1557
+ }
1558
+ const tagName = cmpMeta.$tagName$;
1559
+ const HostElement = class extends HTMLElement {
1560
+ // StencilLazyHost
1561
+ constructor(self) {
1562
+ // @ts-ignore
1563
+ super(self);
1564
+ self = this;
1565
+ registerHost(self, cmpMeta);
1566
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1567
+ // this component is using shadow dom
1568
+ // and this browser supports shadow dom
1569
+ // add the read-only property "shadowRoot" to the host element
1570
+ // adding the shadow root build conditionals to minimize runtime
1263
1571
  {
1264
- self.attachShadow({ mode: 'open' });
1572
+ {
1573
+ self.attachShadow({ mode: 'open' });
1574
+ }
1265
1575
  }
1266
1576
  }
1267
1577
  }
1268
- }
1269
- connectedCallback() {
1270
- if (appLoadFallback) {
1271
- clearTimeout(appLoadFallback);
1272
- appLoadFallback = null;
1578
+ connectedCallback() {
1579
+ if (appLoadFallback) {
1580
+ clearTimeout(appLoadFallback);
1581
+ appLoadFallback = null;
1582
+ }
1583
+ if (isBootstrapping) {
1584
+ // connectedCallback will be processed once all components have been registered
1585
+ deferredConnectedCallbacks.push(this);
1586
+ }
1587
+ else {
1588
+ plt.jmp(() => connectedCallback(this));
1589
+ }
1273
1590
  }
1274
- if (isBootstrapping) {
1275
- // connectedCallback will be processed once all components have been registered
1276
- deferredConnectedCallbacks.push(this);
1591
+ disconnectedCallback() {
1592
+ plt.jmp(() => disconnectedCallback(this));
1277
1593
  }
1278
- else {
1279
- plt.jmp(() => connectedCallback(this));
1594
+ componentOnReady() {
1595
+ return getHostRef(this).$onReadyPromise$;
1280
1596
  }
1597
+ };
1598
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1599
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1600
+ cmpTags.push(tagName);
1601
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1281
1602
  }
1282
- disconnectedCallback() {
1283
- plt.jmp(() => disconnectedCallback(this));
1284
- }
1285
- componentOnReady() {
1286
- return getHostRef(this).$onReadyPromise$;
1287
- }
1288
- };
1289
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1290
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1291
- cmpTags.push(tagName);
1292
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1293
- }
1294
- }));
1603
+ });
1604
+ });
1295
1605
  {
1296
1606
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1297
1607
  visibilityStyle.setAttribute('data-styles', '');
1608
+ // Apply CSP nonce to the style tag if it exists
1609
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1610
+ if (nonce != null) {
1611
+ visibilityStyle.setAttribute('nonce', nonce);
1612
+ }
1298
1613
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1299
1614
  }
1300
1615
  // Process deferred connectedCallbacks now all components have been registered
@@ -1311,7 +1626,48 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1311
1626
  endBootstrap();
1312
1627
  };
1313
1628
  const Fragment = (_, children) => children;
1314
- const hostRefs = new WeakMap();
1629
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1630
+ if (listeners) {
1631
+ listeners.map(([flags, name, method]) => {
1632
+ const target = getHostListenerTarget(elm, flags) ;
1633
+ const handler = hostListenerProxy(hostRef, method);
1634
+ const opts = hostListenerOpts(flags);
1635
+ plt.ael(target, name, handler, opts);
1636
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1637
+ });
1638
+ }
1639
+ };
1640
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1641
+ try {
1642
+ {
1643
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1644
+ // instance is ready, let's call it's member method for this event
1645
+ hostRef.$lazyInstance$[methodName](ev);
1646
+ }
1647
+ else {
1648
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1649
+ }
1650
+ }
1651
+ }
1652
+ catch (e) {
1653
+ consoleError(e);
1654
+ }
1655
+ };
1656
+ const getHostListenerTarget = (elm, flags) => {
1657
+ if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
1658
+ return doc.body;
1659
+ return elm;
1660
+ };
1661
+ // prettier-ignore
1662
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1663
+ /**
1664
+ * Assigns the given value to the nonce property on the runtime platform object.
1665
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1666
+ * @param nonce The value to be assigned to the platform nonce property.
1667
+ * @returns void
1668
+ */
1669
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1670
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1315
1671
  const getHostRef = (ref) => hostRefs.get(ref);
1316
1672
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1317
1673
  const registerHost = (elm, cmpMeta) => {
@@ -1340,7 +1696,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1340
1696
  if (module) {
1341
1697
  return module[exportName];
1342
1698
  }
1699
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1343
1700
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1701
+ /* @vite-ignore */
1344
1702
  /* webpackInclude: /\.entry\.js$/ */
1345
1703
  /* webpackExclude: /\.system\.entry\.js$/ */
1346
1704
  /* webpackMode: "lazy" */
@@ -1351,14 +1709,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1351
1709
  return importedModule[exportName];
1352
1710
  }, consoleError);
1353
1711
  };
1354
- const styles = new Map();
1712
+ const styles = /*@__PURE__*/ new Map();
1713
+ const win = typeof window !== 'undefined' ? window : {};
1714
+ const doc = win.document || { head: {} };
1715
+ const plt = {
1716
+ $flags$: 0,
1717
+ $resourcesUrl$: '',
1718
+ jmp: (h) => h(),
1719
+ raf: (h) => requestAnimationFrame(h),
1720
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1721
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1722
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1723
+ };
1724
+ const promiseResolve = (v) => Promise.resolve(v);
1725
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1726
+ try {
1727
+ new CSSStyleSheet();
1728
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1729
+ }
1730
+ catch (e) { }
1731
+ return false;
1732
+ })()
1733
+ ;
1355
1734
  const queueDomReads = [];
1356
1735
  const queueDomWrites = [];
1357
1736
  const queueTask = (queue, write) => (cb) => {
1358
1737
  queue.push(cb);
1359
1738
  if (!queuePending) {
1360
1739
  queuePending = true;
1361
- if (write && plt.$flags$ & 4 /* queueSync */) {
1740
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1362
1741
  nextTick(flush);
1363
1742
  }
1364
1743
  else {
@@ -1405,3 +1784,4 @@ exports.getRenderingRef = getRenderingRef;
1405
1784
  exports.h = h;
1406
1785
  exports.promiseResolve = promiseResolve;
1407
1786
  exports.registerInstance = registerInstance;
1787
+ exports.setNonce = setNonce;