favesalon-embed 0.0.3 → 0.0.5

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 (237) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/_commonjsHelpers-5cfcba41.js +36 -0
  3. package/dist/cjs/chat-button.cjs.entry.js +118 -0
  4. package/dist/cjs/colors-38421769.js +69 -0
  5. package/dist/cjs/favesalon-embed.cjs.js +24 -0
  6. package/dist/cjs/google-map_5.cjs.entry.js +310 -0
  7. package/{cjs/index-7d179a70.js → dist/cjs/index-47c2a5f6.js} +587 -199
  8. package/dist/cjs/index-7f190886.js +4396 -0
  9. package/dist/cjs/loader.cjs.js +23 -0
  10. package/dist/cjs/relativeTime-3721080d.js +9 -0
  11. package/dist/cjs/salon-booking-modal.cjs.entry.js +30 -0
  12. package/dist/cjs/salon-booking.cjs.entry.js +51 -0
  13. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +29 -0
  14. package/dist/cjs/salon-gift-card.cjs.entry.js +51 -0
  15. package/dist/cjs/salon-latest-reviews.cjs.entry.js +97 -0
  16. package/dist/cjs/salon-lookbook.cjs.entry.js +222 -0
  17. package/dist/cjs/salon-ranking.cjs.entry.js +60 -0
  18. package/dist/cjs/salon-reviews.cjs.entry.js +193 -0
  19. package/dist/cjs/salon-services.cjs.entry.js +81 -0
  20. package/dist/cjs/salon-stylists.cjs.entry.js +118 -0
  21. package/dist/cjs/services-125c82d8.js +21492 -0
  22. package/dist/cjs/style-detail.cjs.entry.js +312 -0
  23. package/dist/cjs/user-avatar.cjs.entry.js +45 -0
  24. package/dist/cjs/utils-c5a33b3c.js +23 -0
  25. package/{collection → dist/collection}/collection-manifest.json +5 -4
  26. package/dist/collection/components/chat-button/index.css +122 -0
  27. package/dist/collection/components/chat-button/index.js +218 -0
  28. package/dist/collection/components/chat-conversation/index.js +103 -0
  29. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  30. package/{collection → dist/collection}/components/google-map/index.css +0 -1
  31. package/dist/collection/components/google-map/index.js +90 -0
  32. package/{collection → dist/collection}/components/salon-booking/index.css +11 -20
  33. package/dist/collection/components/salon-booking/index.js +126 -0
  34. package/dist/collection/components/salon-booking/salon-booking-modal.js +92 -0
  35. package/dist/collection/components/salon-gift-card/index.css +30 -0
  36. package/dist/collection/components/salon-gift-card/index.js +126 -0
  37. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +73 -0
  38. package/dist/collection/components/salon-info/index.js +77 -0
  39. package/dist/collection/components/salon-latest-reviews/index.js +163 -0
  40. package/dist/collection/components/salon-latest-styles/index.css +12 -0
  41. package/dist/collection/components/salon-latest-styles/index.js +183 -0
  42. package/{collection/components/salon-contact → dist/collection/components/salon-locations}/index.css +7 -4
  43. package/dist/collection/components/salon-locations/index.js +143 -0
  44. package/dist/collection/components/salon-lookbook/index.css +15 -0
  45. package/dist/collection/components/salon-lookbook/index.js +368 -0
  46. package/dist/collection/components/salon-ranking/index.js +117 -0
  47. package/dist/collection/components/salon-reviews/index.css +18 -0
  48. package/dist/collection/components/salon-reviews/index.js +249 -0
  49. package/dist/collection/components/salon-schedules/index.css +18 -0
  50. package/dist/collection/components/salon-schedules/index.js +167 -0
  51. package/dist/collection/components/salon-services/index.css +1 -0
  52. package/dist/collection/components/salon-services/index.js +146 -0
  53. package/dist/collection/components/salon-stylists/index.js +184 -0
  54. package/dist/collection/components/style-detail/index.css +76 -0
  55. package/dist/collection/components/style-detail/index.js +386 -0
  56. package/dist/collection/components/user-avatar/index.js +134 -0
  57. package/dist/collection/constants/colors.js +65 -0
  58. package/dist/collection/mocks/users.js +10 -0
  59. package/dist/collection/services/services.js +295 -0
  60. package/dist/collection/types/chat.js +23 -0
  61. package/dist/collection/types/common.js +11 -0
  62. package/{collection → dist/collection}/types/review.js +9 -5
  63. package/dist/collection/types/salon.js +58 -0
  64. package/dist/collection/types/style.js +128 -0
  65. package/dist/collection/types/stylist.js +30 -0
  66. package/dist/collection/types/user.js +10 -0
  67. package/{custom-elements → dist/custom-elements}/index.d.ts +18 -12
  68. package/dist/custom-elements/index.js +28340 -0
  69. package/dist/esm/_commonjsHelpers-098d5b27.js +32 -0
  70. package/dist/esm/chat-button.entry.js +114 -0
  71. package/dist/esm/colors-ea36347a.js +67 -0
  72. package/dist/esm/favesalon-embed.js +19 -0
  73. package/dist/esm/google-map_5.entry.js +302 -0
  74. package/{esm/index-2160b80b.js → dist/esm/index-3fae868e.js} +586 -200
  75. package/dist/esm/index-80523fec.js +4393 -0
  76. package/dist/esm/index.js +1 -0
  77. package/dist/esm/loader.js +19 -0
  78. package/dist/esm/polyfills/css-shim.js +1 -0
  79. package/dist/esm/relativeTime-cd452e6d.js +7 -0
  80. package/dist/esm/salon-booking-modal.entry.js +26 -0
  81. package/dist/esm/salon-booking.entry.js +47 -0
  82. package/dist/esm/salon-gift-card-modal.entry.js +25 -0
  83. package/dist/esm/salon-gift-card.entry.js +47 -0
  84. package/dist/esm/salon-latest-reviews.entry.js +93 -0
  85. package/dist/esm/salon-lookbook.entry.js +218 -0
  86. package/dist/esm/salon-ranking.entry.js +56 -0
  87. package/dist/esm/salon-reviews.entry.js +189 -0
  88. package/dist/esm/salon-services.entry.js +77 -0
  89. package/dist/esm/salon-stylists.entry.js +114 -0
  90. package/dist/esm/services-40a3e622.js +21485 -0
  91. package/dist/esm/style-detail.entry.js +308 -0
  92. package/dist/esm/user-avatar.entry.js +41 -0
  93. package/dist/esm/utils-e97485e0.js +19 -0
  94. package/dist/favesalon-embed/assets/map--placeholder.jpeg +0 -0
  95. package/{favesalon-embed → dist/favesalon-embed}/favesalon-embed.css +1 -1
  96. package/dist/favesalon-embed/favesalon-embed.esm.js +1 -0
  97. package/dist/favesalon-embed/p-019c5ccd.entry.js +1 -0
  98. package/dist/favesalon-embed/p-083a8821.entry.js +1 -0
  99. package/dist/favesalon-embed/p-0d0ed9ea.entry.js +1 -0
  100. package/dist/favesalon-embed/p-119db8de.entry.js +1 -0
  101. package/dist/favesalon-embed/p-1432c51b.entry.js +1 -0
  102. package/dist/favesalon-embed/p-22093506.entry.js +1 -0
  103. package/dist/favesalon-embed/p-32b314e9.js +2 -0
  104. package/dist/favesalon-embed/p-47e646f8.js +1 -0
  105. package/dist/favesalon-embed/p-4a5eca9a.js +6 -0
  106. package/dist/favesalon-embed/p-58d2e9be.js +1 -0
  107. package/dist/favesalon-embed/p-71404b6a.entry.js +1 -0
  108. package/dist/favesalon-embed/p-857c3a61.entry.js +1 -0
  109. package/dist/favesalon-embed/p-99ec77f7.entry.js +1 -0
  110. package/dist/favesalon-embed/p-a33331cc.js +1 -0
  111. package/dist/favesalon-embed/p-b0c3673a.entry.js +1 -0
  112. package/dist/favesalon-embed/p-b287b1ea.entry.js +1 -0
  113. package/dist/favesalon-embed/p-b3af7842.entry.js +1 -0
  114. package/dist/favesalon-embed/p-b630ae68.js +1580 -0
  115. package/dist/favesalon-embed/p-ce2c1c9a.entry.js +1 -0
  116. package/dist/favesalon-embed/p-d6083940.js +1 -0
  117. package/dist/favesalon-embed/p-d9b7ad58.entry.js +1 -0
  118. package/dist/favesalon-embed/p-fc9a5551.js +6 -0
  119. package/dist/types/components/chat-button/index.d.ts +24 -0
  120. package/dist/types/components/google-map/index.d.ts +5 -0
  121. package/{types → dist/types}/components/salon-booking/salon-booking-modal.d.ts +1 -0
  122. package/{types → dist/types}/components/salon-gift-card/index.d.ts +2 -1
  123. package/{types → dist/types}/components/salon-gift-card/salon-gift-card-modal.d.ts +2 -0
  124. package/{types → dist/types}/components/salon-info/index.d.ts +0 -1
  125. package/{types → dist/types}/components/salon-latest-reviews/index.d.ts +2 -0
  126. package/dist/types/components/salon-latest-styles/index.d.ts +12 -0
  127. package/{types → dist/types}/components/salon-locations/index.d.ts +2 -0
  128. package/{types → dist/types}/components/salon-lookbook/index.d.ts +7 -2
  129. package/dist/types/components/salon-reviews/index.d.ts +24 -0
  130. package/{types → dist/types}/components/salon-schedules/index.d.ts +2 -0
  131. package/{types → dist/types}/components/salon-services/index.d.ts +1 -0
  132. package/{types → dist/types}/components/salon-stylists/index.d.ts +6 -0
  133. package/dist/types/components/style-detail/index.d.ts +24 -0
  134. package/{types → dist/types}/components.d.ts +82 -41
  135. package/dist/types/constants/colors.d.ts +65 -0
  136. package/dist/types/mocks/users.d.ts +10 -0
  137. package/dist/types/services/services.d.ts +75 -0
  138. package/{types → dist/types}/stencil-public-runtime.d.ts +85 -11
  139. package/dist/types/types/chat.d.ts +17 -0
  140. package/dist/types/types/common.d.ts +11 -0
  141. package/{types → dist/types}/types/review.d.ts +4 -0
  142. package/{types → dist/types}/types/salon.d.ts +3 -1
  143. package/dist/types/types/style.d.ts +88 -0
  144. package/{types → dist/types}/types/stylist.d.ts +2 -1
  145. package/{types → dist/types}/types/user.d.ts +2 -2
  146. package/loader/cdn.js +3 -0
  147. package/loader/index.cjs.js +3 -0
  148. package/loader/index.d.ts +21 -0
  149. package/loader/index.es2017.js +3 -0
  150. package/loader/index.js +4 -0
  151. package/loader/package.json +11 -0
  152. package/package.json +19 -14
  153. package/readme.md +25 -2
  154. package/cjs/favesalon-embed.cjs.js +0 -20
  155. package/cjs/google-map_15.cjs.entry.js +0 -6632
  156. package/cjs/loader.cjs.js +0 -22
  157. package/cjs/salon-booking-modal.cjs.entry.js +0 -23
  158. package/cjs/salon-gift-card-modal.cjs.entry.js +0 -20
  159. package/collection/components/google-map/index.js +0 -97
  160. package/collection/components/salon-booking/index.js +0 -103
  161. package/collection/components/salon-booking/salon-booking-modal.js +0 -82
  162. package/collection/components/salon-contact/index.js +0 -88
  163. package/collection/components/salon-gift-card/index.css +0 -25
  164. package/collection/components/salon-gift-card/index.js +0 -83
  165. package/collection/components/salon-gift-card/salon-gift-card-modal.js +0 -43
  166. package/collection/components/salon-info/index.css +0 -3
  167. package/collection/components/salon-info/index.js +0 -97
  168. package/collection/components/salon-latest-reviews/index.js +0 -108
  169. package/collection/components/salon-locations/index.js +0 -80
  170. package/collection/components/salon-lookbook/index.css +0 -12
  171. package/collection/components/salon-lookbook/index.js +0 -303
  172. package/collection/components/salon-ranking/index.js +0 -114
  173. package/collection/components/salon-reviews/index.js +0 -291
  174. package/collection/components/salon-schedules/index.css +0 -14
  175. package/collection/components/salon-schedules/index.js +0 -103
  176. package/collection/components/salon-services/index.css +0 -0
  177. package/collection/components/salon-services/index.js +0 -113
  178. package/collection/components/salon-styles/index.css +0 -23
  179. package/collection/components/salon-styles/index.js +0 -100
  180. package/collection/components/salon-stylists/index.js +0 -96
  181. package/collection/components/user-avatar/index.css +0 -0
  182. package/collection/components/user-avatar/index.js +0 -127
  183. package/collection/constants/colors.js +0 -91
  184. package/collection/services/services.js +0 -203
  185. package/collection/types/common.js +0 -2
  186. package/collection/types/salon.js +0 -52
  187. package/collection/types/style.js +0 -28
  188. package/collection/types/stylist.js +0 -13
  189. package/collection/types/user.js +0 -10
  190. package/custom-elements/index.js +0 -7410
  191. package/esm/favesalon-embed.js +0 -18
  192. package/esm/google-map_15.entry.js +0 -6614
  193. package/esm/loader.js +0 -18
  194. package/esm/polyfills/css-shim.js +0 -1
  195. package/esm/salon-booking-modal.entry.js +0 -19
  196. package/esm/salon-gift-card-modal.entry.js +0 -16
  197. package/favesalon-embed/favesalon-embed.esm.js +0 -1
  198. package/favesalon-embed/p-1432ab16.entry.js +0 -1
  199. package/favesalon-embed/p-2da2ed75.js +0 -1
  200. package/favesalon-embed/p-4a5eca9a.js +0 -6
  201. package/favesalon-embed/p-94a0991e.entry.js +0 -1
  202. package/favesalon-embed/p-f15bcb43.entry.js +0 -1
  203. package/types/components/google-map/index.d.ts +0 -10
  204. package/types/components/salon-contact/index.d.ts +0 -9
  205. package/types/components/salon-reviews/index.d.ts +0 -23
  206. package/types/components/salon-styles/index.d.ts +0 -9
  207. package/types/constants/colors.d.ts +0 -88
  208. package/types/services/services.d.ts +0 -24
  209. package/types/types/common.d.ts +0 -2
  210. package/types/types/style.d.ts +0 -49
  211. package/{cjs → dist/cjs}/global-9073d10e.js +0 -0
  212. package/{cjs → dist/cjs}/index.cjs.js +0 -0
  213. package/{esm/index.js → dist/collection/components/salon-info/index.css} +0 -0
  214. package/{collection → dist/collection}/components/salon-latest-reviews/index.css +0 -0
  215. package/{collection → dist/collection}/components/salon-ranking/index.css +0 -0
  216. package/{collection → dist/collection}/components/salon-stylists/index.css +0 -0
  217. package/{collection/components/salon-locations → dist/collection/components/user-avatar}/index.css +0 -0
  218. package/{collection → dist/collection}/global/global.js +0 -0
  219. package/{collection → dist/collection}/index.js +0 -0
  220. package/{collection → dist/collection}/types/service.js +0 -0
  221. package/{collection → dist/collection}/utils/utils.js +0 -0
  222. package/{esm → dist/esm}/global-e1089ffd.js +0 -0
  223. package/{esm → dist/esm}/polyfills/core-js.js +0 -0
  224. package/{esm → dist/esm}/polyfills/dom.js +0 -0
  225. package/{esm → dist/esm}/polyfills/es5-html-element.js +0 -0
  226. package/{esm → dist/esm}/polyfills/index.js +0 -0
  227. package/{esm → dist/esm}/polyfills/system.js +0 -0
  228. package/{favesalon-embed → dist/favesalon-embed}/index.esm.js +0 -0
  229. package/{index.cjs.js → dist/index.cjs.js} +0 -0
  230. package/{index.js → dist/index.js} +0 -0
  231. package/{collection/components/salon-reviews/index.css → dist/types/components/chat-conversation/index.d.ts} +0 -0
  232. package/{types → dist/types}/components/salon-booking/index.d.ts +1 -1
  233. /package/{types → dist/types}/components/salon-ranking/index.d.ts +0 -0
  234. /package/{types → dist/types}/components/user-avatar/index.d.ts +0 -0
  235. /package/{types → dist/types}/index.d.ts +0 -0
  236. /package/{types → dist/types}/types/service.d.ts +0 -0
  237. /package/{types → dist/types}/utils/utils.d.ts +0 -0
@@ -22,30 +22,20 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'favesalon-embed';
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 isSvgMode = false;
26
34
  let queuePending = false;
27
- const win = typeof window !== 'undefined' ? window : {};
28
- const doc = win.document || { head: {} };
29
- const plt = {
30
- $flags$: 0,
31
- $resourcesUrl$: '',
32
- jmp: (h) => h(),
33
- raf: (h) => requestAnimationFrame(h),
34
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
35
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
36
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
35
+ const getAssetPath = (path) => {
36
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
37
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
37
38
  };
38
- const promiseResolve = (v) => Promise.resolve(v);
39
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
40
- try {
41
- new CSSStyleSheet();
42
- return typeof new CSSStyleSheet().replace === 'function';
43
- }
44
- catch (e) { }
45
- return false;
46
- })()
47
- ;
48
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
49
39
  const createTime = (fnName, tagName = '') => {
50
40
  {
51
41
  return () => {
@@ -60,59 +50,8 @@ const uniqueTime = (key, measureText) => {
60
50
  };
61
51
  }
62
52
  };
63
- const rootAppliedStyles = new WeakMap();
64
- const registerStyle = (scopeId, cssText, allowCS) => {
65
- let style = styles.get(scopeId);
66
- if (supportsConstructibleStylesheets && allowCS) {
67
- style = (style || new CSSStyleSheet());
68
- style.replace(cssText);
69
- }
70
- else {
71
- style = cssText;
72
- }
73
- styles.set(scopeId, style);
74
- };
75
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
76
- let scopeId = getScopeId(cmpMeta);
77
- let style = styles.get(scopeId);
78
- // if an element is NOT connected then getRootNode() will return the wrong root node
79
- // so the fallback is to always use the document for the root node in those cases
80
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
81
- if (style) {
82
- if (typeof style === 'string') {
83
- styleContainerNode = styleContainerNode.head || styleContainerNode;
84
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
85
- let styleElm;
86
- if (!appliedStyles) {
87
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
88
- }
89
- if (!appliedStyles.has(scopeId)) {
90
- {
91
- {
92
- styleElm = doc.createElement('style');
93
- styleElm.innerHTML = style;
94
- }
95
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
96
- }
97
- if (appliedStyles) {
98
- appliedStyles.add(scopeId);
99
- }
100
- }
101
- }
102
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
103
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
104
- }
105
- }
106
- return scopeId;
107
- };
108
- const attachStyles = (hostRef) => {
109
- const cmpMeta = hostRef.$cmpMeta$;
110
- const elm = hostRef.$hostElement$;
111
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
112
- addStyle(elm.getRootNode(), cmpMeta);
113
- endAttachStyles();
114
- };
115
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
53
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
54
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
116
55
  /**
117
56
  * Default style mode id
118
57
  */
@@ -131,6 +70,18 @@ const isComplexType = (o) => {
131
70
  o = typeof o;
132
71
  return o === 'object' || o === 'function';
133
72
  };
73
+ /**
74
+ * Helper method for querying a `meta` tag that contains a nonce value
75
+ * out of a DOM's head.
76
+ *
77
+ * @param doc The DOM containing the `head` to query against
78
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
79
+ * exists or the tag has no content.
80
+ */
81
+ function queryNonceMetaTagContent(doc) {
82
+ var _a, _b, _c;
83
+ 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;
84
+ }
134
85
  /**
135
86
  * Production h() function based on Preact by
136
87
  * Jason Miller (@developit)
@@ -139,14 +90,14 @@ const isComplexType = (o) => {
139
90
  *
140
91
  * Modified for Stencil's compiler and vdom
141
92
  */
142
- // const stack: any[] = [];
143
93
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
144
94
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
145
95
  const h = (nodeName, vnodeData, ...children) => {
146
96
  let child = null;
97
+ let key = null;
147
98
  let simple = false;
148
99
  let lastSimple = false;
149
- let vNodeChildren = [];
100
+ const vNodeChildren = [];
150
101
  const walk = (c) => {
151
102
  for (let i = 0; i < c.length; i++) {
152
103
  child = c[i];
@@ -171,6 +122,10 @@ const h = (nodeName, vnodeData, ...children) => {
171
122
  };
172
123
  walk(children);
173
124
  if (vnodeData) {
125
+ // normalize class / classname attributes
126
+ if (vnodeData.key) {
127
+ key = vnodeData.key;
128
+ }
174
129
  {
175
130
  const classData = vnodeData.className || vnodeData.class;
176
131
  if (classData) {
@@ -188,8 +143,19 @@ const h = (nodeName, vnodeData, ...children) => {
188
143
  if (vNodeChildren.length > 0) {
189
144
  vnode.$children$ = vNodeChildren;
190
145
  }
146
+ {
147
+ vnode.$key$ = key;
148
+ }
191
149
  return vnode;
192
150
  };
151
+ /**
152
+ * A utility function for creating a virtual DOM node from a tag and some
153
+ * possible text content.
154
+ *
155
+ * @param tag the tag for this element
156
+ * @param text possible text content for the node
157
+ * @returns a newly-minted virtual DOM node
158
+ */
193
159
  const newVNode = (tag, text) => {
194
160
  const vnode = {
195
161
  $flags$: 0,
@@ -201,10 +167,142 @@ const newVNode = (tag, text) => {
201
167
  {
202
168
  vnode.$attrs$ = null;
203
169
  }
170
+ {
171
+ vnode.$key$ = null;
172
+ }
204
173
  return vnode;
205
174
  };
206
175
  const Host = {};
176
+ /**
177
+ * Check whether a given node is a Host node or not
178
+ *
179
+ * @param node the virtual DOM node to check
180
+ * @returns whether it's a Host node or not
181
+ */
207
182
  const isHost = (node) => node && node.$tag$ === Host;
183
+ /**
184
+ * Parse a new property value for a given property type.
185
+ *
186
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
187
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
188
+ * 1. `any`, the type given to `propValue` in the function signature
189
+ * 2. the type stored from `propType`.
190
+ *
191
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
192
+ *
193
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
194
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
195
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
196
+ * ```tsx
197
+ * <my-cmp prop-val={0}></my-cmp>
198
+ * ```
199
+ *
200
+ * HTML prop values on the other hand, will always a string
201
+ *
202
+ * @param propValue the new value to coerce to some type
203
+ * @param propType the type of the prop, expressed as a binary number
204
+ * @returns the parsed/coerced value
205
+ */
206
+ const parsePropertyValue = (propValue, propType) => {
207
+ // ensure this value is of the correct prop type
208
+ if (propValue != null && !isComplexType(propValue)) {
209
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
210
+ // per the HTML spec, any string value means it is a boolean true value
211
+ // but we'll cheat here and say that the string "false" is the boolean false
212
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
213
+ }
214
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
215
+ // force it to be a number
216
+ return parseFloat(propValue);
217
+ }
218
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
219
+ // could have been passed as a number or boolean
220
+ // but we still want it as a string
221
+ return String(propValue);
222
+ }
223
+ // redundant return here for better minification
224
+ return propValue;
225
+ }
226
+ // not sure exactly what type we want
227
+ // so no need to change to a different type
228
+ return propValue;
229
+ };
230
+ /**
231
+ * Helper function to create & dispatch a custom Event on a provided target
232
+ * @param elm the target of the Event
233
+ * @param name the name to give the custom Event
234
+ * @param opts options for configuring a custom Event
235
+ * @returns the custom Event
236
+ */
237
+ const emitEvent = (elm, name, opts) => {
238
+ const ev = plt.ce(name, opts);
239
+ elm.dispatchEvent(ev);
240
+ return ev;
241
+ };
242
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
243
+ const registerStyle = (scopeId, cssText, allowCS) => {
244
+ let style = styles.get(scopeId);
245
+ if (supportsConstructableStylesheets && allowCS) {
246
+ style = (style || new CSSStyleSheet());
247
+ if (typeof style === 'string') {
248
+ style = cssText;
249
+ }
250
+ else {
251
+ style.replaceSync(cssText);
252
+ }
253
+ }
254
+ else {
255
+ style = cssText;
256
+ }
257
+ styles.set(scopeId, style);
258
+ };
259
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
260
+ var _a;
261
+ let scopeId = getScopeId(cmpMeta);
262
+ const style = styles.get(scopeId);
263
+ // if an element is NOT connected then getRootNode() will return the wrong root node
264
+ // so the fallback is to always use the document for the root node in those cases
265
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
266
+ if (style) {
267
+ if (typeof style === 'string') {
268
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
269
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
270
+ let styleElm;
271
+ if (!appliedStyles) {
272
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
273
+ }
274
+ if (!appliedStyles.has(scopeId)) {
275
+ {
276
+ {
277
+ styleElm = doc.createElement('style');
278
+ styleElm.innerHTML = style;
279
+ }
280
+ // Apply CSP nonce to the style tag if it exists
281
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
282
+ if (nonce != null) {
283
+ styleElm.setAttribute('nonce', nonce);
284
+ }
285
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
286
+ }
287
+ if (appliedStyles) {
288
+ appliedStyles.add(scopeId);
289
+ }
290
+ }
291
+ }
292
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
293
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
294
+ }
295
+ }
296
+ return scopeId;
297
+ };
298
+ const attachStyles = (hostRef) => {
299
+ const cmpMeta = hostRef.$cmpMeta$;
300
+ const elm = hostRef.$hostElement$;
301
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
302
+ addStyle(elm.getRootNode(), cmpMeta);
303
+ endAttachStyles();
304
+ };
305
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
208
306
  /**
209
307
  * Production setAccessor() function based on Preact by
210
308
  * Jason Miller (@developit)
@@ -249,6 +347,14 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
249
347
  }
250
348
  }
251
349
  }
350
+ else if (memberName === 'key')
351
+ ;
352
+ else if (memberName === 'ref') {
353
+ // minifier will clean this up
354
+ if (newValue) {
355
+ newValue(elm);
356
+ }
357
+ }
252
358
  else if ((!isProp ) &&
253
359
  memberName[0] === 'o' &&
254
360
  memberName[1] === 'n') {
@@ -294,11 +400,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
294
400
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
295
401
  try {
296
402
  if (!elm.tagName.includes('-')) {
297
- let n = newValue == null ? '' : newValue;
403
+ const n = newValue == null ? '' : newValue;
298
404
  // Workaround for Safari, moving the <input> caret when re-assigning the same valued
299
405
  if (memberName === 'list') {
300
406
  isProp = false;
301
- // tslint:disable-next-line: triple-equals
302
407
  }
303
408
  else if (oldValue == null || elm[memberName] != n) {
304
409
  elm[memberName] = n;
@@ -310,16 +415,36 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
310
415
  }
311
416
  catch (e) { }
312
417
  }
418
+ /**
419
+ * Need to manually update attribute if:
420
+ * - memberName is not an attribute
421
+ * - if we are rendering the host element in order to reflect attribute
422
+ * - if it's a SVG, since properties might not work in <svg>
423
+ * - if the newValue is null/undefined or 'false'.
424
+ */
425
+ let xlink = false;
426
+ {
427
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
428
+ memberName = ln;
429
+ xlink = true;
430
+ }
431
+ }
313
432
  if (newValue == null || newValue === false) {
314
433
  if (newValue !== false || elm.getAttribute(memberName) === '') {
315
- {
434
+ if (xlink) {
435
+ elm.removeAttributeNS(XLINK_NS, memberName);
436
+ }
437
+ else {
316
438
  elm.removeAttribute(memberName);
317
439
  }
318
440
  }
319
441
  }
320
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
442
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
321
443
  newValue = newValue === true ? '' : newValue;
322
- {
444
+ if (xlink) {
445
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
446
+ }
447
+ else {
323
448
  elm.setAttribute(memberName, newValue);
324
449
  }
325
450
  }
@@ -332,7 +457,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
332
457
  // if the element passed in is a shadow root, which is a document fragment
333
458
  // then we want to be adding attrs/props to the shadow root's "host" element
334
459
  // if it's not a shadow root, then we add attrs/props to the same element
335
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
460
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
336
461
  ? newVnode.$elm$.host
337
462
  : newVnode.$elm$;
338
463
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -350,9 +475,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
350
475
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
351
476
  }
352
477
  };
478
+ /**
479
+ * Create a DOM Node corresponding to one of the children of a given VNode.
480
+ *
481
+ * @param oldParentVNode the parent VNode from the previous render
482
+ * @param newParentVNode the parent VNode from the current render
483
+ * @param childIndex the index of the VNode, in the _new_ parent node's
484
+ * children, for which we will create a new DOM node
485
+ * @param parentElm the parent DOM node which our new node will be a child of
486
+ * @returns the newly created node
487
+ */
353
488
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
354
489
  // tslint:disable-next-line: prefer-const
355
- let newVNode = newParentVNode.$children$[childIndex];
490
+ const newVNode = newParentVNode.$children$[childIndex];
356
491
  let i = 0;
357
492
  let elm;
358
493
  let childNode;
@@ -398,6 +533,21 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
398
533
  }
399
534
  return elm;
400
535
  };
536
+ /**
537
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
538
+ * add them to the DOM in the appropriate place.
539
+ *
540
+ * @param parentElm the DOM node which should be used as a parent for the new
541
+ * DOM nodes
542
+ * @param before a child of the `parentElm` which the new children should be
543
+ * inserted before (optional)
544
+ * @param parentVNode the parent virtual DOM node
545
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
546
+ * @param startIdx the index in the child virtual DOM nodes at which to start
547
+ * creating DOM nodes (inclusive)
548
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
549
+ * creating DOM nodes (inclusive)
550
+ */
401
551
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
402
552
  let containerElm = (parentElm);
403
553
  let childNode;
@@ -411,18 +561,102 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
411
561
  }
412
562
  }
413
563
  };
564
+ /**
565
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
566
+ * This can be used to, for instance, clean up after a list of children which
567
+ * should no longer be shown.
568
+ *
569
+ * This function also handles some of Stencil's slot relocation logic.
570
+ *
571
+ * @param vnodes a list of virtual DOM nodes to remove
572
+ * @param startIdx the index at which to start removing nodes (inclusive)
573
+ * @param endIdx the index at which to stop removing nodes (inclusive)
574
+ * @param vnode a VNode
575
+ * @param elm an element
576
+ */
414
577
  const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
415
578
  for (; startIdx <= endIdx; ++startIdx) {
416
579
  if ((vnode = vnodes[startIdx])) {
417
580
  elm = vnode.$elm$;
581
+ callNodeRefs(vnode);
418
582
  // remove the vnode's element from the dom
419
583
  elm.remove();
420
584
  }
421
585
  }
422
586
  };
587
+ /**
588
+ * Reconcile the children of a new VNode with the children of an old VNode by
589
+ * traversing the two collections of children, identifying nodes that are
590
+ * conserved or changed, calling out to `patch` to make any necessary
591
+ * updates to the DOM, and rearranging DOM nodes as needed.
592
+ *
593
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
594
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
595
+ * 'windows' by storing start and end indices and references to the
596
+ * corresponding array entries. Initially the two 'windows' are basically equal
597
+ * to the entire array, but we progressively narrow the windows until there are
598
+ * no children left to update by doing the following:
599
+ *
600
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
601
+ * that if we have an initial array like the following we'll end up dealing
602
+ * only with a window bounded by the highlighted elements:
603
+ *
604
+ * [null, null, VNode1 , ... , VNode2, null, null]
605
+ * ^^^^^^ ^^^^^^
606
+ *
607
+ * 2. Check to see if the elements at the head and tail positions are equal
608
+ * across the windows. This will basically detect elements which haven't
609
+ * been added, removed, or changed position, i.e. if you had the following
610
+ * VNode elements (represented as HTML):
611
+ *
612
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
613
+ * newVNode: `<div><p><span>THERE</span></p></div>`
614
+ *
615
+ * Then when comparing the children of the `<div>` tag we check the equality
616
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
617
+ * same tag in the same position, we'd be able to avoid completely
618
+ * re-rendering the subtree under them with a new DOM element and would just
619
+ * call out to `patch` to handle reconciling their children and so on.
620
+ *
621
+ * 3. Check, for both windows, to see if the element at the beginning of the
622
+ * window corresponds to the element at the end of the other window. This is
623
+ * a heuristic which will let us identify _some_ situations in which
624
+ * elements have changed position, for instance it _should_ detect that the
625
+ * children nodes themselves have not changed but merely moved in the
626
+ * following example:
627
+ *
628
+ * oldVNode: `<div><element-one /><element-two /></div>`
629
+ * newVNode: `<div><element-two /><element-one /></div>`
630
+ *
631
+ * If we find cases like this then we also need to move the concrete DOM
632
+ * elements corresponding to the moved children to write the re-order to the
633
+ * DOM.
634
+ *
635
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
636
+ * nodes in the old children which have the same key as the first element in
637
+ * our window on the new children. If we find such a node we handle calling
638
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
639
+ * what we find.
640
+ *
641
+ * Finally, once we've narrowed our 'windows' to the point that either of them
642
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
643
+ * insertion or deletion that needs to happen to get a DOM state that correctly
644
+ * reflects the new child VNodes. If, for instance, after our window on the old
645
+ * children has collapsed we still have more nodes on the new children that
646
+ * we haven't dealt with yet then we need to add them, or if the new children
647
+ * collapse but we still have unhandled _old_ children then we need to make
648
+ * sure the corresponding DOM nodes are removed.
649
+ *
650
+ * @param parentElm the node into which the parent VNode is rendered
651
+ * @param oldCh the old children of the parent node
652
+ * @param newVNode the new VNode which will replace the parent
653
+ * @param newCh the new children of the parent node
654
+ */
423
655
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
424
656
  let oldStartIdx = 0;
425
657
  let newStartIdx = 0;
658
+ let idxInOld = 0;
659
+ let i = 0;
426
660
  let oldEndIdx = oldCh.length - 1;
427
661
  let oldStartVnode = oldCh[0];
428
662
  let oldEndVnode = oldCh[oldEndIdx];
@@ -430,9 +664,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
430
664
  let newStartVnode = newCh[0];
431
665
  let newEndVnode = newCh[newEndIdx];
432
666
  let node;
667
+ let elmToMove;
433
668
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
434
669
  if (oldStartVnode == null) {
435
- // Vnode might have been moved left
670
+ // VNode might have been moved left
436
671
  oldStartVnode = oldCh[++oldStartIdx];
437
672
  }
438
673
  else if (oldEndVnode == null) {
@@ -445,34 +680,101 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
445
680
  newEndVnode = newCh[--newEndIdx];
446
681
  }
447
682
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
683
+ // if the start nodes are the same then we should patch the new VNode
684
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
685
+ // indices to reflect that. We don't need to move any DOM Nodes around
686
+ // since things are matched up in order.
448
687
  patch(oldStartVnode, newStartVnode);
449
688
  oldStartVnode = oldCh[++oldStartIdx];
450
689
  newStartVnode = newCh[++newStartIdx];
451
690
  }
452
691
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
692
+ // likewise, if the end nodes are the same we patch new onto old and
693
+ // decrement our end indices, and also likewise in this case we don't
694
+ // need to move any DOM Nodes.
453
695
  patch(oldEndVnode, newEndVnode);
454
696
  oldEndVnode = oldCh[--oldEndIdx];
455
697
  newEndVnode = newCh[--newEndIdx];
456
698
  }
457
699
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
458
700
  patch(oldStartVnode, newEndVnode);
701
+ // We need to move the element for `oldStartVnode` into a position which
702
+ // will be appropriate for `newEndVnode`. For this we can use
703
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
704
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
705
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
706
+ //
707
+ // <old-start-node />
708
+ // <some-intervening-node />
709
+ // <old-end-node />
710
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
711
+ // <next-sibling />
712
+ //
713
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
714
+ // the node for `oldStartVnode` at the end of the children of
715
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
716
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
717
+ // append it to the children of the parent element.
459
718
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
460
719
  oldStartVnode = oldCh[++oldStartIdx];
461
720
  newEndVnode = newCh[--newEndIdx];
462
721
  }
463
722
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
464
723
  patch(oldEndVnode, newStartVnode);
724
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
725
+ // the same node, so since we're here we know that they are not. Thus we
726
+ // can move the element for `oldEndVnode` _before_ the element for
727
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
728
+ // future.
465
729
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
466
730
  oldEndVnode = oldCh[--oldEndIdx];
467
731
  newStartVnode = newCh[++newStartIdx];
468
732
  }
469
733
  else {
734
+ // Here we do some checks to match up old and new nodes based on the
735
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
736
+ // in the JSX for a DOM element in the implementation of a Stencil
737
+ // component.
738
+ //
739
+ // First we check to see if there are any nodes in the array of old
740
+ // children which have the same key as the first node in the new
741
+ // children.
742
+ idxInOld = -1;
470
743
  {
471
- // new element
744
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
745
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
746
+ idxInOld = i;
747
+ break;
748
+ }
749
+ }
750
+ }
751
+ if (idxInOld >= 0) {
752
+ // We found a node in the old children which matches up with the first
753
+ // node in the new children! So let's deal with that
754
+ elmToMove = oldCh[idxInOld];
755
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
756
+ // the tag doesn't match so we'll need a new DOM element
757
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
758
+ }
759
+ else {
760
+ patch(elmToMove, newStartVnode);
761
+ // invalidate the matching old node so that we won't try to update it
762
+ // again later on
763
+ oldCh[idxInOld] = undefined;
764
+ node = elmToMove.$elm$;
765
+ }
766
+ newStartVnode = newCh[++newStartIdx];
767
+ }
768
+ else {
769
+ // We either didn't find an element in the old children that matches
770
+ // the key of the first new child OR the build is not using `key`
771
+ // attributes at all. In either case we need to create a new element
772
+ // for the new node.
472
773
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
473
774
  newStartVnode = newCh[++newStartIdx];
474
775
  }
475
776
  if (node) {
777
+ // if we created a new node then handle inserting it to the DOM
476
778
  {
477
779
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
478
780
  }
@@ -480,20 +782,53 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
480
782
  }
481
783
  }
482
784
  if (oldStartIdx > oldEndIdx) {
785
+ // we have some more new nodes to add which don't match up with old nodes
483
786
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
484
787
  }
485
788
  else if (newStartIdx > newEndIdx) {
789
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
790
+ // in the new array, so lets remove them (which entails cleaning up the
791
+ // relevant DOM nodes)
486
792
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
487
793
  }
488
794
  };
489
- const isSameVnode = (vnode1, vnode2) => {
795
+ /**
796
+ * Compare two VNodes to determine if they are the same
797
+ *
798
+ * **NB**: This function is an equality _heuristic_ based on the available
799
+ * information set on the two VNodes and can be misleading under certain
800
+ * circumstances. In particular, if the two nodes do not have `key` attrs
801
+ * (available under `$key$` on VNodes) then the function falls back on merely
802
+ * checking that they have the same tag.
803
+ *
804
+ * So, in other words, if `key` attrs are not set on VNodes which may be
805
+ * changing order within a `children` array or something along those lines then
806
+ * we could obtain a false negative and then have to do needless re-rendering
807
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
808
+ *
809
+ * @param leftVNode the first VNode to check
810
+ * @param rightVNode the second VNode to check
811
+ * @returns whether they're equal or not
812
+ */
813
+ const isSameVnode = (leftVNode, rightVNode) => {
490
814
  // compare if two vnode to see if they're "technically" the same
491
815
  // need to have the same element tag, and same key to be the same
492
- if (vnode1.$tag$ === vnode2.$tag$) {
493
- return true;
816
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
817
+ // this will be set if components in the build have `key` attrs set on them
818
+ {
819
+ return leftVNode.$key$ === rightVNode.$key$;
820
+ }
494
821
  }
495
822
  return false;
496
823
  };
824
+ /**
825
+ * Handle reconciling an outdated VNode with a new one which corresponds to
826
+ * it. This function handles flushing updates to the DOM and reconciling the
827
+ * children of the two nodes (if any).
828
+ *
829
+ * @param oldVNode an old VNode whose DOM element and children we want to update
830
+ * @param newVNode a new VNode representing an updated version of the old one
831
+ */
497
832
  const patch = (oldVNode, newVNode) => {
498
833
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
499
834
  const oldChildren = oldVNode.$children$;
@@ -506,7 +841,6 @@ const patch = (oldVNode, newVNode) => {
506
841
  // only add this to the when the compiler sees we're using an svg somewhere
507
842
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
508
843
  }
509
- // element node
510
844
  {
511
845
  {
512
846
  // either this is the first render of an element OR it's an update
@@ -517,6 +851,7 @@ const patch = (oldVNode, newVNode) => {
517
851
  }
518
852
  if (oldChildren !== null && newChildren !== null) {
519
853
  // looks like there's child vnodes for both the old and new vnodes
854
+ // so we need to call `updateChildren` to reconcile them
520
855
  updateChildren(elm, oldChildren, newVNode, newChildren);
521
856
  }
522
857
  else if (newChildren !== null) {
@@ -542,29 +877,35 @@ const patch = (oldVNode, newVNode) => {
542
877
  elm.data = text;
543
878
  }
544
879
  };
880
+ const callNodeRefs = (vNode) => {
881
+ {
882
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
883
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
884
+ }
885
+ };
886
+ /**
887
+ * The main entry point for Stencil's virtual DOM-based rendering engine
888
+ *
889
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
890
+ * function will handle creating a virtual DOM tree with a single root, patching
891
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
892
+ * relocation, and reflecting attributes.
893
+ *
894
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
895
+ * the DOM node into which it should be rendered.
896
+ * @param renderFnResults the virtual DOM nodes to be rendered
897
+ */
545
898
  const renderVdom = (hostRef, renderFnResults) => {
546
899
  const hostElm = hostRef.$hostElement$;
547
900
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
548
901
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
549
902
  rootVnode.$tag$ = null;
550
- rootVnode.$flags$ |= 4 /* isHost */;
903
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
551
904
  hostRef.$vnode$ = rootVnode;
552
905
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
553
906
  // synchronous patch
554
907
  patch(oldVNode, rootVnode);
555
908
  };
556
- /**
557
- * Helper function to create & dispatch a custom Event on a provided target
558
- * @param elm the target of the Event
559
- * @param name the name to give the custom Event
560
- * @param opts options for configuring a custom Event
561
- * @returns the custom Event
562
- */
563
- const emitEvent = (elm, name, opts) => {
564
- const ev = plt.ce(name, opts);
565
- elm.dispatchEvent(ev);
566
- return ev;
567
- };
568
909
  const attachToAncestor = (hostRef, ancestorComponent) => {
569
910
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
570
911
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -572,10 +913,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
572
913
  };
573
914
  const scheduleUpdate = (hostRef, isInitialLoad) => {
574
915
  {
575
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
916
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
576
917
  }
577
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
578
- hostRef.$flags$ |= 512 /* needsRerender */;
918
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
919
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
579
920
  return;
580
921
  }
581
922
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -594,6 +935,11 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
594
935
  promise = safeCall(instance, 'componentWillLoad');
595
936
  }
596
937
  }
938
+ else {
939
+ {
940
+ promise = safeCall(instance, 'componentWillUpdate');
941
+ }
942
+ }
597
943
  endSchedule();
598
944
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
599
945
  };
@@ -627,7 +973,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
627
973
  }
628
974
  else {
629
975
  Promise.all(childrenPromises).then(postUpdate);
630
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
976
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
631
977
  childrenPromises.length = 0;
632
978
  }
633
979
  }
@@ -636,10 +982,10 @@ const callRender = (hostRef, instance, elm) => {
636
982
  try {
637
983
  instance = instance.render() ;
638
984
  {
639
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
985
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
640
986
  }
641
987
  {
642
- hostRef.$flags$ |= 2 /* hasRendered */;
988
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
643
989
  }
644
990
  {
645
991
  {
@@ -666,8 +1012,8 @@ const postUpdateComponent = (hostRef) => {
666
1012
  {
667
1013
  safeCall(instance, 'componentDidRender');
668
1014
  }
669
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
670
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1015
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1016
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
671
1017
  {
672
1018
  // DOM WRITE!
673
1019
  addHydratedFlag(elm);
@@ -696,10 +1042,10 @@ const postUpdateComponent = (hostRef) => {
696
1042
  hostRef.$onRenderResolve$();
697
1043
  hostRef.$onRenderResolve$ = undefined;
698
1044
  }
699
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1045
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
700
1046
  nextTick(() => scheduleUpdate(hostRef, false));
701
1047
  }
702
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1048
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
703
1049
  }
704
1050
  // ( •_•)
705
1051
  // ( •_•)>⌐■-■
@@ -729,25 +1075,6 @@ const then = (promise, thenFn) => {
729
1075
  };
730
1076
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
731
1077
  ;
732
- const parsePropertyValue = (propValue, propType) => {
733
- // ensure this value is of the correct prop type
734
- if (propValue != null && !isComplexType(propValue)) {
735
- if (propType & 2 /* Number */) {
736
- // force it to be a number
737
- return parseFloat(propValue);
738
- }
739
- if (propType & 1 /* String */) {
740
- // could have been passed as a number or boolean
741
- // but we still want it as a string
742
- return String(propValue);
743
- }
744
- // redundant return here for better minification
745
- return propValue;
746
- }
747
- // not sure exactly what type we want
748
- // so no need to change to a different type
749
- return propValue;
750
- };
751
1078
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
752
1079
  const setValue = (ref, propName, newVal, cmpMeta) => {
753
1080
  // check our new property value against our internal value
@@ -756,12 +1083,15 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
756
1083
  const flags = hostRef.$flags$;
757
1084
  const instance = hostRef.$lazyInstance$ ;
758
1085
  newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
759
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1086
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1087
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1088
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1089
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
760
1090
  // gadzooks! the property's value has changed!!
761
1091
  // set our new value!
762
1092
  hostRef.$instanceValues$.set(propName, newVal);
763
1093
  if (instance) {
764
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1094
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
765
1095
  // looks like this value actually changed, so we've got work to do!
766
1096
  // but only if we've already rendered, otherwise just chill out
767
1097
  // queue that we need to do an update, but don't worry about queuing
@@ -771,14 +1101,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
771
1101
  }
772
1102
  }
773
1103
  };
1104
+ /**
1105
+ * Attach a series of runtime constructs to a compiled Stencil component
1106
+ * constructor, including getters and setters for the `@Prop` and `@State`
1107
+ * decorators, callbacks for when attributes change, and so on.
1108
+ *
1109
+ * @param Cstr the constructor for a component that we need to process
1110
+ * @param cmpMeta metadata collected previously about the component
1111
+ * @param flags a number used to store a series of bit flags
1112
+ * @returns a reference to the same constructor passed in (but now mutated)
1113
+ */
774
1114
  const proxyComponent = (Cstr, cmpMeta, flags) => {
775
1115
  if (cmpMeta.$members$) {
776
1116
  // It's better to have a const than two Object.entries()
777
1117
  const members = Object.entries(cmpMeta.$members$);
778
1118
  const prototype = Cstr.prototype;
779
1119
  members.map(([memberName, [memberFlags]]) => {
780
- if ((memberFlags & 31 /* Prop */ ||
781
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1120
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1121
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
782
1122
  // proxyComponent - prop
783
1123
  Object.defineProperty(prototype, memberName, {
784
1124
  get() {
@@ -793,8 +1133,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
793
1133
  enumerable: true,
794
1134
  });
795
1135
  }
796
- else if (flags & 1 /* isElementConstructor */ &&
797
- memberFlags & 64 /* Method */) {
1136
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1137
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
798
1138
  // proxyComponent - method
799
1139
  Object.defineProperty(prototype, memberName, {
800
1140
  value(...args) {
@@ -804,19 +1144,19 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
804
1144
  });
805
1145
  }
806
1146
  });
807
- if ((flags & 1 /* isElementConstructor */)) {
1147
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
808
1148
  const attrNameToPropName = new Map();
809
1149
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
810
1150
  plt.jmp(() => {
811
1151
  const propName = attrNameToPropName.get(attrName);
812
- // In a webcomponent lifecyle the attributeChangedCallback runs prior to connectedCallback
1152
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
813
1153
  // in the case where an attribute was set inline.
814
1154
  // ```html
815
1155
  // <my-component some-attribute="some-value"></my-component>
816
1156
  // ```
817
1157
  //
818
- // There is an edge case where a developer sets the attribute inline on a custom element and then programatically
819
- // changes it before it has been upgraded as shown below:
1158
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1159
+ // programmatically changes it before it has been upgraded as shown below:
820
1160
  //
821
1161
  // ```html
822
1162
  // <!-- this component has _not_ been upgraded yet -->
@@ -826,13 +1166,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
826
1166
  // el = document.querySelector("#test");
827
1167
  // el.someAttribute = "another-value";
828
1168
  // // upgrade component
829
- // cutsomElements.define('my-component', MyComponent);
1169
+ // customElements.define('my-component', MyComponent);
830
1170
  // </script>
831
1171
  // ```
832
1172
  // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
833
1173
  // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
834
1174
  // to the value that was set inline i.e. "some-value" from above example. When
835
- // the connectedCallback attempts to unshadow it will use "some-value" as the intial value rather than "another-value"
1175
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
836
1176
  //
837
1177
  // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
838
1178
  // by connectedCallback as this attributeChangedCallback will not fire.
@@ -846,13 +1186,21 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
846
1186
  newValue = this[propName];
847
1187
  delete this[propName];
848
1188
  }
1189
+ else if (prototype.hasOwnProperty(propName) &&
1190
+ typeof this[propName] === 'number' &&
1191
+ this[propName] == newValue) {
1192
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1193
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1194
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1195
+ return;
1196
+ }
849
1197
  this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
850
1198
  });
851
1199
  };
852
1200
  // create an array of attributes to observe
853
1201
  // and also create a map of html attribute name to js property name
854
1202
  Cstr.observedAttributes = members
855
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1203
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
856
1204
  .map(([propName, m]) => {
857
1205
  const attrName = m[1] || propName;
858
1206
  attrNameToPropName.set(attrName, propName);
@@ -864,10 +1212,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
864
1212
  };
865
1213
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
866
1214
  // initializeComponent
867
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1215
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
868
1216
  {
869
1217
  // we haven't initialized this element yet
870
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1218
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
871
1219
  // lazy loaded components
872
1220
  // request the component's implementation to be
873
1221
  // wired up with the host element
@@ -879,7 +1227,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
879
1227
  endLoad();
880
1228
  }
881
1229
  if (!Cstr.isProxied) {
882
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1230
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
883
1231
  Cstr.isProxied = true;
884
1232
  }
885
1233
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -887,7 +1235,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
887
1235
  // but let's keep track of when we start and stop
888
1236
  // so that the getters/setters don't incorrectly step on data
889
1237
  {
890
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1238
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
891
1239
  }
892
1240
  // construct the lazy-loaded component implementation
893
1241
  // passing the hostRef is very important during
@@ -900,7 +1248,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
900
1248
  consoleError(e);
901
1249
  }
902
1250
  {
903
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1251
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
904
1252
  }
905
1253
  endNewInstance();
906
1254
  }
@@ -910,7 +1258,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
910
1258
  const scopeId = getScopeId(cmpMeta);
911
1259
  if (!styles.has(scopeId)) {
912
1260
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
913
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1261
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
914
1262
  endRegisterStyles();
915
1263
  }
916
1264
  }
@@ -919,7 +1267,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
919
1267
  const ancestorComponent = hostRef.$ancestorComponent$;
920
1268
  const schedule = () => scheduleUpdate(hostRef, true);
921
1269
  if (ancestorComponent && ancestorComponent['s-rc']) {
922
- // this is the intial load and this component it has an ancestor component
1270
+ // this is the initial load and this component it has an ancestor component
923
1271
  // but the ancestor component has NOT fired its will update lifecycle yet
924
1272
  // so let's just cool our jets and wait for the ancestor to continue first
925
1273
  // this will get fired off when the ancestor component
@@ -932,13 +1280,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
932
1280
  }
933
1281
  };
934
1282
  const connectedCallback = (elm) => {
935
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1283
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
936
1284
  const hostRef = getHostRef(elm);
937
1285
  const cmpMeta = hostRef.$cmpMeta$;
938
1286
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
939
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1287
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
940
1288
  // first time this component has connected
941
- hostRef.$flags$ |= 1 /* hasConnected */;
1289
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
942
1290
  {
943
1291
  // find the first ancestor component (if there is one) and register
944
1292
  // this component as one of the actively loading child components for its ancestor
@@ -958,7 +1306,7 @@ const connectedCallback = (elm) => {
958
1306
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
959
1307
  if (cmpMeta.$members$) {
960
1308
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
961
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1309
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
962
1310
  const value = elm[memberName];
963
1311
  delete elm[memberName];
964
1312
  elm[memberName] = value;
@@ -973,11 +1321,12 @@ const connectedCallback = (elm) => {
973
1321
  }
974
1322
  };
975
1323
  const disconnectedCallback = (elm) => {
976
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1324
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
977
1325
  getHostRef(elm);
978
1326
  }
979
1327
  };
980
1328
  const bootstrapLazy = (lazyBundles, options = {}) => {
1329
+ var _a;
981
1330
  const endBootstrap = createTime();
982
1331
  const cmpTags = [];
983
1332
  const exclude = options.exclude || [];
@@ -990,54 +1339,61 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
990
1339
  let isBootstrapping = true;
991
1340
  Object.assign(plt, options);
992
1341
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
993
- lazyBundles.map((lazyBundle) => lazyBundle[1].map((compactMeta) => {
994
- const cmpMeta = {
995
- $flags$: compactMeta[0],
996
- $tagName$: compactMeta[1],
997
- $members$: compactMeta[2],
998
- $listeners$: compactMeta[3],
999
- };
1000
- {
1001
- cmpMeta.$members$ = compactMeta[2];
1002
- }
1003
- const tagName = cmpMeta.$tagName$;
1004
- const HostElement = class extends HTMLElement {
1005
- // StencilLazyHost
1006
- constructor(self) {
1007
- // @ts-ignore
1008
- super(self);
1009
- self = this;
1010
- registerHost(self, cmpMeta);
1342
+ lazyBundles.map((lazyBundle) => {
1343
+ lazyBundle[1].map((compactMeta) => {
1344
+ const cmpMeta = {
1345
+ $flags$: compactMeta[0],
1346
+ $tagName$: compactMeta[1],
1347
+ $members$: compactMeta[2],
1348
+ $listeners$: compactMeta[3],
1349
+ };
1350
+ {
1351
+ cmpMeta.$members$ = compactMeta[2];
1011
1352
  }
1012
- connectedCallback() {
1013
- if (appLoadFallback) {
1014
- clearTimeout(appLoadFallback);
1015
- appLoadFallback = null;
1353
+ const tagName = cmpMeta.$tagName$;
1354
+ const HostElement = class extends HTMLElement {
1355
+ // StencilLazyHost
1356
+ constructor(self) {
1357
+ // @ts-ignore
1358
+ super(self);
1359
+ self = this;
1360
+ registerHost(self, cmpMeta);
1016
1361
  }
1017
- if (isBootstrapping) {
1018
- // connectedCallback will be processed once all components have been registered
1019
- deferredConnectedCallbacks.push(this);
1362
+ connectedCallback() {
1363
+ if (appLoadFallback) {
1364
+ clearTimeout(appLoadFallback);
1365
+ appLoadFallback = null;
1366
+ }
1367
+ if (isBootstrapping) {
1368
+ // connectedCallback will be processed once all components have been registered
1369
+ deferredConnectedCallbacks.push(this);
1370
+ }
1371
+ else {
1372
+ plt.jmp(() => connectedCallback(this));
1373
+ }
1020
1374
  }
1021
- else {
1022
- plt.jmp(() => connectedCallback(this));
1375
+ disconnectedCallback() {
1376
+ plt.jmp(() => disconnectedCallback(this));
1023
1377
  }
1378
+ componentOnReady() {
1379
+ return getHostRef(this).$onReadyPromise$;
1380
+ }
1381
+ };
1382
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1383
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1384
+ cmpTags.push(tagName);
1385
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1024
1386
  }
1025
- disconnectedCallback() {
1026
- plt.jmp(() => disconnectedCallback(this));
1027
- }
1028
- componentOnReady() {
1029
- return getHostRef(this).$onReadyPromise$;
1030
- }
1031
- };
1032
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1033
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1034
- cmpTags.push(tagName);
1035
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1036
- }
1037
- }));
1387
+ });
1388
+ });
1038
1389
  {
1039
1390
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1040
1391
  visibilityStyle.setAttribute('data-styles', '');
1392
+ // Apply CSP nonce to the style tag if it exists
1393
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1394
+ if (nonce != null) {
1395
+ visibilityStyle.setAttribute('nonce', nonce);
1396
+ }
1041
1397
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1042
1398
  }
1043
1399
  // Process deferred connectedCallbacks now all components have been registered
@@ -1053,7 +1409,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1053
1409
  // Fallback appLoad event
1054
1410
  endBootstrap();
1055
1411
  };
1056
- const hostRefs = new WeakMap();
1412
+ /**
1413
+ * Assigns the given value to the nonce property on the runtime platform object.
1414
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1415
+ * @param nonce The value to be assigned to the platform nonce property.
1416
+ * @returns void
1417
+ */
1418
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1419
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1057
1420
  const getHostRef = (ref) => hostRefs.get(ref);
1058
1421
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1059
1422
  const registerHost = (elm, cmpMeta) => {
@@ -1084,7 +1447,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1084
1447
  if (module) {
1085
1448
  return module[exportName];
1086
1449
  }
1450
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1087
1451
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1452
+ /* @vite-ignore */
1088
1453
  /* webpackInclude: /\.entry\.js$/ */
1089
1454
  /* webpackExclude: /\.system\.entry\.js$/ */
1090
1455
  /* webpackMode: "lazy" */
@@ -1095,14 +1460,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1095
1460
  return importedModule[exportName];
1096
1461
  }, consoleError);
1097
1462
  };
1098
- const styles = new Map();
1463
+ const styles = /*@__PURE__*/ new Map();
1464
+ const win = typeof window !== 'undefined' ? window : {};
1465
+ const doc = win.document || { head: {} };
1466
+ const plt = {
1467
+ $flags$: 0,
1468
+ $resourcesUrl$: '',
1469
+ jmp: (h) => h(),
1470
+ raf: (h) => requestAnimationFrame(h),
1471
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1472
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1473
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1474
+ };
1475
+ const promiseResolve = (v) => Promise.resolve(v);
1476
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1477
+ try {
1478
+ new CSSStyleSheet();
1479
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1480
+ }
1481
+ catch (e) { }
1482
+ return false;
1483
+ })()
1484
+ ;
1099
1485
  const queueDomReads = [];
1100
1486
  const queueDomWrites = [];
1101
1487
  const queueTask = (queue, write) => (cb) => {
1102
1488
  queue.push(cb);
1103
1489
  if (!queuePending) {
1104
1490
  queuePending = true;
1105
- if (write && plt.$flags$ & 4 /* queueSync */) {
1491
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1106
1492
  nextTick(flush);
1107
1493
  }
1108
1494
  else {
@@ -1140,6 +1526,8 @@ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1140
1526
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1141
1527
 
1142
1528
  exports.bootstrapLazy = bootstrapLazy;
1529
+ exports.getAssetPath = getAssetPath;
1143
1530
  exports.h = h;
1144
1531
  exports.promiseResolve = promiseResolve;
1145
1532
  exports.registerInstance = registerInstance;
1533
+ exports.setNonce = setNonce;