favesalon-embed 1.0.4 → 1.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 (177) hide show
  1. package/dist/custom-elements/index.d.ts +6 -0
  2. package/dist/{cjs/_commonjsHelpers-5cfcba41.js → favesalon-embed/_commonjsHelpers-a4f66ccd.js} +14 -6
  3. package/dist/favesalon-embed/app-globals-74127f4b.js +7 -0
  4. package/dist/favesalon-embed/chat-box.entry.js +55 -0
  5. package/dist/{esm → favesalon-embed}/chat-button.entry.js +4 -4
  6. package/dist/favesalon-embed/chat-form.entry.js +39 -0
  7. package/dist/favesalon-embed/chat-messages.entry.js +71 -0
  8. package/dist/favesalon-embed/chat-rooms.entry.js +111 -0
  9. package/dist/favesalon-embed/css-shim-b7d3d95f.js +4 -0
  10. package/dist/favesalon-embed/dom-64053c71.js +73 -0
  11. package/dist/favesalon-embed/favesalon-embed.css +114 -1
  12. package/dist/favesalon-embed/favesalon-embed.esm.js +148 -1
  13. package/dist/{esm → favesalon-embed}/google-map.entry.js +1 -1
  14. package/dist/{esm/index-a1c7583c.js → favesalon-embed/index-00b83e1c.js} +425 -15
  15. package/dist/favesalon-embed/index-888e99e3.js +3371 -0
  16. package/dist/favesalon-embed/index.esm.js +1 -0
  17. package/dist/{esm/chat-box_5.entry.js → favesalon-embed/lodash-d5526b38.js} +27 -243
  18. package/dist/{cjs/chat-button.cjs.entry.js → favesalon-embed/notify-sounds.entry.js} +20 -44
  19. package/dist/favesalon-embed/relativeTime-268e64b0.js +7 -0
  20. package/dist/{esm → favesalon-embed}/salon-booking-modal.entry.js +1 -1
  21. package/dist/{esm → favesalon-embed}/salon-booking.entry.js +3 -3
  22. package/dist/{esm → favesalon-embed}/salon-gift-card-modal.entry.js +1 -1
  23. package/dist/{esm → favesalon-embed}/salon-gift-card.entry.js +3 -3
  24. package/dist/{esm → favesalon-embed}/salon-info.entry.js +3 -3
  25. package/dist/{esm → favesalon-embed}/salon-latest-reviews.entry.js +4 -4
  26. package/dist/{collection/components/salon-latest-styles/index.js → favesalon-embed/salon-latest-styles.entry.js} +14 -99
  27. package/dist/{collection/components/salon-locations/index.js → favesalon-embed/salon-locations.entry.js} +15 -95
  28. package/dist/{esm → favesalon-embed}/salon-lookbook.entry.js +3 -3
  29. package/dist/{esm → favesalon-embed}/salon-ranking.entry.js +1 -1
  30. package/dist/{esm → favesalon-embed}/salon-reviews.entry.js +3 -3
  31. package/dist/{collection/components/salon-schedules/index.js → favesalon-embed/salon-schedules.entry.js} +14 -95
  32. package/dist/{esm → favesalon-embed}/salon-services.entry.js +3 -3
  33. package/dist/{esm → favesalon-embed}/salon-stylists.entry.js +3 -3
  34. package/dist/favesalon-embed/services-122dcf73.js +23886 -0
  35. package/dist/{cjs/services-d1bdf299.js → favesalon-embed/services-23eda072.js} +2487 -104
  36. package/dist/favesalon-embed/services-243eef47.js +23880 -0
  37. package/dist/favesalon-embed/services-260ea6eb.js +23883 -0
  38. package/dist/favesalon-embed/services-27607998.js +23886 -0
  39. package/dist/{esm/services-257442e2.js → favesalon-embed/services-46b2f0aa.js} +2482 -101
  40. package/dist/favesalon-embed/services-65a8cf4a.js +23887 -0
  41. package/dist/favesalon-embed/services-8f52210f.js +23880 -0
  42. package/dist/favesalon-embed/services-de32365e.js +23880 -0
  43. package/dist/favesalon-embed/services-e9cfcd2b.js +23885 -0
  44. package/dist/favesalon-embed/services-f7278483.js +23880 -0
  45. package/dist/favesalon-embed/services-f9872bea.js +23880 -0
  46. package/dist/favesalon-embed/shadow-css-98135883.js +387 -0
  47. package/dist/{esm → favesalon-embed}/style-detail.entry.js +4 -4
  48. package/dist/favesalon-embed/user-avatar.entry.js +50 -0
  49. package/dist/{esm/utils-e97485e0.js → favesalon-embed/utils-2c19db45.js} +6 -0
  50. package/dist/{collection/utils/utils.js → favesalon-embed/utils-89c2cff2.js} +14 -5
  51. package/dist/{cjs/utils-c5a33b3c.js → favesalon-embed/utils-e226fa04.js} +14 -5
  52. package/dist/favesalon-embed/utils-fd30fb29.js +32 -0
  53. package/dist/types/components/chat-box/index.d.ts +1 -0
  54. package/dist/types/components/chat-button/notify-sounds.d.ts +5 -0
  55. package/dist/types/components/chat-rooms/index.d.ts +6 -0
  56. package/dist/types/components.d.ts +21 -0
  57. package/dist/types/services/services.d.ts +1 -0
  58. package/dist/types/types/chat.d.ts +1 -0
  59. package/dist/types/types/user.d.ts +10 -0
  60. package/dist/types/utils/utils.d.ts +1 -0
  61. package/package.json +1 -1
  62. package/dist/cjs/chat-box_5.cjs.entry.js +0 -17439
  63. package/dist/cjs/colors-38421769.js +0 -69
  64. package/dist/cjs/favesalon-embed.cjs.js +0 -23
  65. package/dist/cjs/google-map.cjs.entry.js +0 -52
  66. package/dist/cjs/index-7f190886.js +0 -4396
  67. package/dist/cjs/index-dd8176c4.js +0 -1531
  68. package/dist/cjs/index.cjs.js +0 -2
  69. package/dist/cjs/loader.cjs.js +0 -22
  70. package/dist/cjs/relativeTime-3721080d.js +0 -9
  71. package/dist/cjs/salon-booking-modal.cjs.entry.js +0 -30
  72. package/dist/cjs/salon-booking.cjs.entry.js +0 -51
  73. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +0 -29
  74. package/dist/cjs/salon-gift-card.cjs.entry.js +0 -51
  75. package/dist/cjs/salon-info.cjs.entry.js +0 -33
  76. package/dist/cjs/salon-latest-reviews.cjs.entry.js +0 -97
  77. package/dist/cjs/salon-latest-styles_3.cjs.entry.js +0 -241
  78. package/dist/cjs/salon-lookbook.cjs.entry.js +0 -222
  79. package/dist/cjs/salon-ranking.cjs.entry.js +0 -60
  80. package/dist/cjs/salon-reviews.cjs.entry.js +0 -193
  81. package/dist/cjs/salon-services.cjs.entry.js +0 -81
  82. package/dist/cjs/salon-stylists.cjs.entry.js +0 -118
  83. package/dist/cjs/style-detail.cjs.entry.js +0 -312
  84. package/dist/collection/collection-manifest.json +0 -33
  85. package/dist/collection/components/chat-box/index.css +0 -105
  86. package/dist/collection/components/chat-box/index.js +0 -138
  87. package/dist/collection/components/chat-button/index.css +0 -101
  88. package/dist/collection/components/chat-button/index.js +0 -155
  89. package/dist/collection/components/chat-form/index.css +0 -40
  90. package/dist/collection/components/chat-form/index.js +0 -79
  91. package/dist/collection/components/chat-messages/index.css +0 -48
  92. package/dist/collection/components/chat-messages/index.js +0 -142
  93. package/dist/collection/components/chat-rooms/index.css +0 -102
  94. package/dist/collection/components/chat-rooms/index.js +0 -157
  95. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  96. package/dist/collection/components/google-map/index.css +0 -5
  97. package/dist/collection/components/google-map/index.js +0 -90
  98. package/dist/collection/components/salon-booking/index.css +0 -30
  99. package/dist/collection/components/salon-booking/index.js +0 -126
  100. package/dist/collection/components/salon-booking/salon-booking-modal.js +0 -92
  101. package/dist/collection/components/salon-gift-card/index.css +0 -30
  102. package/dist/collection/components/salon-gift-card/index.js +0 -126
  103. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +0 -73
  104. package/dist/collection/components/salon-info/index.css +0 -1
  105. package/dist/collection/components/salon-info/index.js +0 -77
  106. package/dist/collection/components/salon-latest-reviews/index.css +0 -11
  107. package/dist/collection/components/salon-latest-reviews/index.js +0 -163
  108. package/dist/collection/components/salon-latest-styles/index.css +0 -12
  109. package/dist/collection/components/salon-locations/index.css +0 -24
  110. package/dist/collection/components/salon-lookbook/index.css +0 -15
  111. package/dist/collection/components/salon-lookbook/index.js +0 -368
  112. package/dist/collection/components/salon-ranking/index.css +0 -3
  113. package/dist/collection/components/salon-ranking/index.js +0 -117
  114. package/dist/collection/components/salon-reviews/index.css +0 -18
  115. package/dist/collection/components/salon-reviews/index.js +0 -249
  116. package/dist/collection/components/salon-schedules/index.css +0 -18
  117. package/dist/collection/components/salon-services/index.css +0 -1
  118. package/dist/collection/components/salon-services/index.js +0 -146
  119. package/dist/collection/components/salon-stylists/index.css +0 -43
  120. package/dist/collection/components/salon-stylists/index.js +0 -184
  121. package/dist/collection/components/style-detail/index.css +0 -76
  122. package/dist/collection/components/style-detail/index.js +0 -386
  123. package/dist/collection/components/user-avatar/index.css +0 -0
  124. package/dist/collection/components/user-avatar/index.js +0 -159
  125. package/dist/collection/constants/colors.js +0 -65
  126. package/dist/collection/global/global.js +0 -0
  127. package/dist/collection/index.js +0 -1
  128. package/dist/collection/mocks/users.js +0 -10
  129. package/dist/collection/services/services.js +0 -295
  130. package/dist/collection/types/chat.js +0 -23
  131. package/dist/collection/types/common.js +0 -11
  132. package/dist/collection/types/review.js +0 -39
  133. package/dist/collection/types/salon.js +0 -58
  134. package/dist/collection/types/service.js +0 -24
  135. package/dist/collection/types/style.js +0 -128
  136. package/dist/collection/types/stylist.js +0 -30
  137. package/dist/collection/types/user.js +0 -10
  138. package/dist/custom-elements/index.js +0 -44974
  139. package/dist/esm/_commonjsHelpers-66ac50f5.js +0 -32
  140. package/dist/esm/favesalon-embed.js +0 -18
  141. package/dist/esm/index-0494771f.js +0 -1504
  142. package/dist/esm/index.js +0 -1
  143. package/dist/esm/loader.js +0 -18
  144. package/dist/esm/polyfills/core-js.js +0 -11
  145. package/dist/esm/polyfills/css-shim.js +0 -1
  146. package/dist/esm/polyfills/dom.js +0 -79
  147. package/dist/esm/polyfills/es5-html-element.js +0 -1
  148. package/dist/esm/polyfills/index.js +0 -34
  149. package/dist/esm/polyfills/system.js +0 -6
  150. package/dist/esm/relativeTime-baa50aa2.js +0 -7
  151. package/dist/esm/salon-latest-styles_3.entry.js +0 -235
  152. package/dist/favesalon-embed/p-05a1c88a.entry.js +0 -1
  153. package/dist/favesalon-embed/p-0acf0447.entry.js +0 -1
  154. package/dist/favesalon-embed/p-0bc4f624.js +0 -1
  155. package/dist/favesalon-embed/p-1af1515f.entry.js +0 -1
  156. package/dist/favesalon-embed/p-1cba5fc9.entry.js +0 -1
  157. package/dist/favesalon-embed/p-39a4ef15.entry.js +0 -1
  158. package/dist/favesalon-embed/p-3e2cb05b.entry.js +0 -1
  159. package/dist/favesalon-embed/p-47e646f8.js +0 -1
  160. package/dist/favesalon-embed/p-487b311f.entry.js +0 -1
  161. package/dist/favesalon-embed/p-55387c2f.entry.js +0 -1
  162. package/dist/favesalon-embed/p-566f05b4.entry.js +0 -1
  163. package/dist/favesalon-embed/p-862a0de0.entry.js +0 -1
  164. package/dist/favesalon-embed/p-9fe0cbeb.js +0 -2
  165. package/dist/favesalon-embed/p-a33331cc.js +0 -1
  166. package/dist/favesalon-embed/p-aeeb7b5f.entry.js +0 -1
  167. package/dist/favesalon-embed/p-b08e5b54.js +0 -6
  168. package/dist/favesalon-embed/p-b5cca5fc.entry.js +0 -1
  169. package/dist/favesalon-embed/p-c7fb7af5.js +0 -1580
  170. package/dist/favesalon-embed/p-ccab56d8.js +0 -1
  171. package/dist/favesalon-embed/p-d6e13053.entry.js +0 -1
  172. package/dist/favesalon-embed/p-dee42d34.entry.js +0 -1
  173. package/dist/favesalon-embed/p-e661ca1d.entry.js +0 -1
  174. package/dist/favesalon-embed/p-eeceab9c.entry.js +0 -1
  175. package/dist/index.cjs.js +0 -1
  176. package/dist/index.js +0 -1
  177. /package/dist/{esm → favesalon-embed}/colors-ea36347a.js +0 -0
@@ -1,1531 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopNamespace(e) {
4
- if (e && e.__esModule) return e;
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () {
13
- return e[k];
14
- }
15
- });
16
- }
17
- });
18
- }
19
- n['default'] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- const NAMESPACE = 'favesalon-embed';
24
-
25
- /**
26
- * Virtual DOM patching algorithm based on Snabbdom by
27
- * Simon Friis Vindum (@paldepind)
28
- * Licensed under the MIT License
29
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
- *
31
- * Modified for Stencil's renderer and slot projection
32
- */
33
- let isSvgMode = false;
34
- let queuePending = false;
35
- const getAssetPath = (path) => {
36
- const assetUrl = new URL(path, plt.$resourcesUrl$);
37
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
38
- };
39
- const createTime = (fnName, tagName = '') => {
40
- {
41
- return () => {
42
- return;
43
- };
44
- }
45
- };
46
- const uniqueTime = (key, measureText) => {
47
- {
48
- return () => {
49
- return;
50
- };
51
- }
52
- };
53
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
54
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
55
- /**
56
- * Default style mode id
57
- */
58
- /**
59
- * Reusable empty obj/array
60
- * Don't add values to these!!
61
- */
62
- const EMPTY_OBJ = {};
63
- /**
64
- * Namespaces
65
- */
66
- const SVG_NS = 'http://www.w3.org/2000/svg';
67
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
68
- const isComplexType = (o) => {
69
- // https://jsperf.com/typeof-fn-object/5
70
- o = typeof o;
71
- return o === 'object' || o === 'function';
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
- }
85
- /**
86
- * Production h() function based on Preact by
87
- * Jason Miller (@developit)
88
- * Licensed under the MIT License
89
- * https://github.com/developit/preact/blob/master/LICENSE
90
- *
91
- * Modified for Stencil's compiler and vdom
92
- */
93
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
94
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
95
- const h = (nodeName, vnodeData, ...children) => {
96
- let child = null;
97
- let key = null;
98
- let simple = false;
99
- let lastSimple = false;
100
- const vNodeChildren = [];
101
- const walk = (c) => {
102
- for (let i = 0; i < c.length; i++) {
103
- child = c[i];
104
- if (Array.isArray(child)) {
105
- walk(child);
106
- }
107
- else if (child != null && typeof child !== 'boolean') {
108
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
109
- child = String(child);
110
- }
111
- if (simple && lastSimple) {
112
- // If the previous child was simple (string), we merge both
113
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
114
- }
115
- else {
116
- // Append a new vNode, if it's text, we create a text vNode
117
- vNodeChildren.push(simple ? newVNode(null, child) : child);
118
- }
119
- lastSimple = simple;
120
- }
121
- }
122
- };
123
- walk(children);
124
- if (vnodeData) {
125
- // normalize class / classname attributes
126
- if (vnodeData.key) {
127
- key = vnodeData.key;
128
- }
129
- {
130
- const classData = vnodeData.className || vnodeData.class;
131
- if (classData) {
132
- vnodeData.class =
133
- typeof classData !== 'object'
134
- ? classData
135
- : Object.keys(classData)
136
- .filter((k) => classData[k])
137
- .join(' ');
138
- }
139
- }
140
- }
141
- const vnode = newVNode(nodeName, null);
142
- vnode.$attrs$ = vnodeData;
143
- if (vNodeChildren.length > 0) {
144
- vnode.$children$ = vNodeChildren;
145
- }
146
- {
147
- vnode.$key$ = key;
148
- }
149
- return vnode;
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
- */
159
- const newVNode = (tag, text) => {
160
- const vnode = {
161
- $flags$: 0,
162
- $tag$: tag,
163
- $text$: text,
164
- $elm$: null,
165
- $children$: null,
166
- };
167
- {
168
- vnode.$attrs$ = null;
169
- }
170
- {
171
- vnode.$key$ = null;
172
- }
173
- return vnode;
174
- };
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
- */
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$);
306
- /**
307
- * Production setAccessor() function based on Preact by
308
- * Jason Miller (@developit)
309
- * Licensed under the MIT License
310
- * https://github.com/developit/preact/blob/master/LICENSE
311
- *
312
- * Modified for Stencil's compiler and vdom
313
- */
314
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
315
- if (oldValue !== newValue) {
316
- let isProp = isMemberInElement(elm, memberName);
317
- let ln = memberName.toLowerCase();
318
- if (memberName === 'class') {
319
- const classList = elm.classList;
320
- const oldClasses = parseClassList(oldValue);
321
- const newClasses = parseClassList(newValue);
322
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
323
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
324
- }
325
- else if (memberName === 'style') {
326
- // update style attribute, css properties and values
327
- {
328
- for (const prop in oldValue) {
329
- if (!newValue || newValue[prop] == null) {
330
- if (prop.includes('-')) {
331
- elm.style.removeProperty(prop);
332
- }
333
- else {
334
- elm.style[prop] = '';
335
- }
336
- }
337
- }
338
- }
339
- for (const prop in newValue) {
340
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
341
- if (prop.includes('-')) {
342
- elm.style.setProperty(prop, newValue[prop]);
343
- }
344
- else {
345
- elm.style[prop] = newValue[prop];
346
- }
347
- }
348
- }
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
- }
358
- else if ((!isProp ) &&
359
- memberName[0] === 'o' &&
360
- memberName[1] === 'n') {
361
- // Event Handlers
362
- // so if the member name starts with "on" and the 3rd characters is
363
- // a capital letter, and it's not already a member on the element,
364
- // then we're assuming it's an event listener
365
- if (memberName[2] === '-') {
366
- // on- prefixed events
367
- // allows to be explicit about the dom event to listen without any magic
368
- // under the hood:
369
- // <my-cmp on-click> // listens for "click"
370
- // <my-cmp on-Click> // listens for "Click"
371
- // <my-cmp on-ionChange> // listens for "ionChange"
372
- // <my-cmp on-EVENTS> // listens for "EVENTS"
373
- memberName = memberName.slice(3);
374
- }
375
- else if (isMemberInElement(win, ln)) {
376
- // standard event
377
- // the JSX attribute could have been "onMouseOver" and the
378
- // member name "onmouseover" is on the window's prototype
379
- // so let's add the listener "mouseover", which is all lowercased
380
- memberName = ln.slice(2);
381
- }
382
- else {
383
- // custom event
384
- // the JSX attribute could have been "onMyCustomEvent"
385
- // so let's trim off the "on" prefix and lowercase the first character
386
- // and add the listener "myCustomEvent"
387
- // except for the first character, we keep the event name case
388
- memberName = ln[2] + memberName.slice(3);
389
- }
390
- if (oldValue) {
391
- plt.rel(elm, memberName, oldValue, false);
392
- }
393
- if (newValue) {
394
- plt.ael(elm, memberName, newValue, false);
395
- }
396
- }
397
- else {
398
- // Set property if it exists and it's not a SVG
399
- const isComplex = isComplexType(newValue);
400
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
401
- try {
402
- if (!elm.tagName.includes('-')) {
403
- const n = newValue == null ? '' : newValue;
404
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
405
- if (memberName === 'list') {
406
- isProp = false;
407
- }
408
- else if (oldValue == null || elm[memberName] != n) {
409
- elm[memberName] = n;
410
- }
411
- }
412
- else {
413
- elm[memberName] = newValue;
414
- }
415
- }
416
- catch (e) { }
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
- }
432
- if (newValue == null || newValue === false) {
433
- if (newValue !== false || elm.getAttribute(memberName) === '') {
434
- if (xlink) {
435
- elm.removeAttributeNS(XLINK_NS, memberName);
436
- }
437
- else {
438
- elm.removeAttribute(memberName);
439
- }
440
- }
441
- }
442
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
443
- newValue = newValue === true ? '' : newValue;
444
- if (xlink) {
445
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
446
- }
447
- else {
448
- elm.setAttribute(memberName, newValue);
449
- }
450
- }
451
- }
452
- }
453
- };
454
- const parseClassListRegex = /\s/;
455
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
456
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
457
- // if the element passed in is a shadow root, which is a document fragment
458
- // then we want to be adding attrs/props to the shadow root's "host" element
459
- // if it's not a shadow root, then we add attrs/props to the same element
460
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
461
- ? newVnode.$elm$.host
462
- : newVnode.$elm$;
463
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
464
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
465
- {
466
- // remove attributes no longer present on the vnode by setting them to undefined
467
- for (memberName in oldVnodeAttrs) {
468
- if (!(memberName in newVnodeAttrs)) {
469
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
470
- }
471
- }
472
- }
473
- // add new & update changed attributes
474
- for (memberName in newVnodeAttrs) {
475
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
476
- }
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
- */
488
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
489
- // tslint:disable-next-line: prefer-const
490
- const newVNode = newParentVNode.$children$[childIndex];
491
- let i = 0;
492
- let elm;
493
- let childNode;
494
- if (newVNode.$text$ !== null) {
495
- // create text node
496
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
497
- }
498
- else {
499
- if (!isSvgMode) {
500
- isSvgMode = newVNode.$tag$ === 'svg';
501
- }
502
- // create element
503
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
504
- );
505
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
506
- isSvgMode = false;
507
- }
508
- // add css classes, attrs, props, listeners, etc.
509
- {
510
- updateElement(null, newVNode, isSvgMode);
511
- }
512
- if (newVNode.$children$) {
513
- for (i = 0; i < newVNode.$children$.length; ++i) {
514
- // create the node
515
- childNode = createElm(oldParentVNode, newVNode, i);
516
- // return node could have been null
517
- if (childNode) {
518
- // append our new node
519
- elm.appendChild(childNode);
520
- }
521
- }
522
- }
523
- {
524
- if (newVNode.$tag$ === 'svg') {
525
- // Only reset the SVG context when we're exiting <svg> element
526
- isSvgMode = false;
527
- }
528
- else if (elm.tagName === 'foreignObject') {
529
- // Reenter SVG context when we're exiting <foreignObject> element
530
- isSvgMode = true;
531
- }
532
- }
533
- }
534
- return elm;
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
- */
551
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
552
- let containerElm = (parentElm);
553
- let childNode;
554
- for (; startIdx <= endIdx; ++startIdx) {
555
- if (vnodes[startIdx]) {
556
- childNode = createElm(null, parentVNode, startIdx);
557
- if (childNode) {
558
- vnodes[startIdx].$elm$ = childNode;
559
- containerElm.insertBefore(childNode, before);
560
- }
561
- }
562
- }
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
- */
577
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
578
- for (; startIdx <= endIdx; ++startIdx) {
579
- if ((vnode = vnodes[startIdx])) {
580
- elm = vnode.$elm$;
581
- callNodeRefs(vnode);
582
- // remove the vnode's element from the dom
583
- elm.remove();
584
- }
585
- }
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
- */
655
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
656
- let oldStartIdx = 0;
657
- let newStartIdx = 0;
658
- let idxInOld = 0;
659
- let i = 0;
660
- let oldEndIdx = oldCh.length - 1;
661
- let oldStartVnode = oldCh[0];
662
- let oldEndVnode = oldCh[oldEndIdx];
663
- let newEndIdx = newCh.length - 1;
664
- let newStartVnode = newCh[0];
665
- let newEndVnode = newCh[newEndIdx];
666
- let node;
667
- let elmToMove;
668
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
669
- if (oldStartVnode == null) {
670
- // VNode might have been moved left
671
- oldStartVnode = oldCh[++oldStartIdx];
672
- }
673
- else if (oldEndVnode == null) {
674
- oldEndVnode = oldCh[--oldEndIdx];
675
- }
676
- else if (newStartVnode == null) {
677
- newStartVnode = newCh[++newStartIdx];
678
- }
679
- else if (newEndVnode == null) {
680
- newEndVnode = newCh[--newEndIdx];
681
- }
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.
687
- patch(oldStartVnode, newStartVnode);
688
- oldStartVnode = oldCh[++oldStartIdx];
689
- newStartVnode = newCh[++newStartIdx];
690
- }
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.
695
- patch(oldEndVnode, newEndVnode);
696
- oldEndVnode = oldCh[--oldEndIdx];
697
- newEndVnode = newCh[--newEndIdx];
698
- }
699
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
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.
718
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
719
- oldStartVnode = oldCh[++oldStartIdx];
720
- newEndVnode = newCh[--newEndIdx];
721
- }
722
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
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.
729
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
730
- oldEndVnode = oldCh[--oldEndIdx];
731
- newStartVnode = newCh[++newStartIdx];
732
- }
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;
743
- {
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.
773
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
774
- newStartVnode = newCh[++newStartIdx];
775
- }
776
- if (node) {
777
- // if we created a new node then handle inserting it to the DOM
778
- {
779
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
780
- }
781
- }
782
- }
783
- }
784
- if (oldStartIdx > oldEndIdx) {
785
- // we have some more new nodes to add which don't match up with old nodes
786
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
787
- }
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)
792
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
793
- }
794
- };
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) => {
814
- // compare if two vnode to see if they're "technically" the same
815
- // need to have the same element tag, and same key to be the same
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
- }
821
- }
822
- return false;
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
- */
832
- const patch = (oldVNode, newVNode) => {
833
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
834
- const oldChildren = oldVNode.$children$;
835
- const newChildren = newVNode.$children$;
836
- const tag = newVNode.$tag$;
837
- const text = newVNode.$text$;
838
- if (text === null) {
839
- {
840
- // test if we're rendering an svg element, or still rendering nodes inside of one
841
- // only add this to the when the compiler sees we're using an svg somewhere
842
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
843
- }
844
- {
845
- {
846
- // either this is the first render of an element OR it's an update
847
- // AND we already know it's possible it could have changed
848
- // this updates the element's css classes, attrs, props, listeners, etc.
849
- updateElement(oldVNode, newVNode, isSvgMode);
850
- }
851
- }
852
- if (oldChildren !== null && newChildren !== null) {
853
- // looks like there's child vnodes for both the old and new vnodes
854
- // so we need to call `updateChildren` to reconcile them
855
- updateChildren(elm, oldChildren, newVNode, newChildren);
856
- }
857
- else if (newChildren !== null) {
858
- // no old child vnodes, but there are new child vnodes to add
859
- if (oldVNode.$text$ !== null) {
860
- // the old vnode was text, so be sure to clear it out
861
- elm.textContent = '';
862
- }
863
- // add the new vnode children
864
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
865
- }
866
- else if (oldChildren !== null) {
867
- // no new child vnodes, but there are old child vnodes to remove
868
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
869
- }
870
- if (isSvgMode && tag === 'svg') {
871
- isSvgMode = false;
872
- }
873
- }
874
- else if (oldVNode.$text$ !== text) {
875
- // update the text content for the text only vnode
876
- // and also only if the text is different than before
877
- elm.data = text;
878
- }
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
- */
898
- const renderVdom = (hostRef, renderFnResults) => {
899
- const hostElm = hostRef.$hostElement$;
900
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
901
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
902
- rootVnode.$tag$ = null;
903
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
904
- hostRef.$vnode$ = rootVnode;
905
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
906
- // synchronous patch
907
- patch(oldVNode, rootVnode);
908
- };
909
- const attachToAncestor = (hostRef, ancestorComponent) => {
910
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
911
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
912
- }
913
- };
914
- const scheduleUpdate = (hostRef, isInitialLoad) => {
915
- {
916
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
917
- }
918
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
919
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
920
- return;
921
- }
922
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
923
- // there is no ancestor component or the ancestor component
924
- // has already fired off its lifecycle update then
925
- // fire off the initial update
926
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
927
- return writeTask(dispatch) ;
928
- };
929
- const dispatchHooks = (hostRef, isInitialLoad) => {
930
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
931
- const instance = hostRef.$lazyInstance$ ;
932
- let promise;
933
- if (isInitialLoad) {
934
- {
935
- promise = safeCall(instance, 'componentWillLoad');
936
- }
937
- }
938
- endSchedule();
939
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
940
- };
941
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
942
- // updateComponent
943
- const elm = hostRef.$hostElement$;
944
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
945
- const rc = elm['s-rc'];
946
- if (isInitialLoad) {
947
- // DOM WRITE!
948
- attachStyles(hostRef);
949
- }
950
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
951
- {
952
- callRender(hostRef, instance);
953
- }
954
- if (rc) {
955
- // ok, so turns out there are some child host elements
956
- // waiting on this parent element to load
957
- // let's fire off all update callbacks waiting
958
- rc.map((cb) => cb());
959
- elm['s-rc'] = undefined;
960
- }
961
- endRender();
962
- endUpdate();
963
- {
964
- const childrenPromises = elm['s-p'];
965
- const postUpdate = () => postUpdateComponent(hostRef);
966
- if (childrenPromises.length === 0) {
967
- postUpdate();
968
- }
969
- else {
970
- Promise.all(childrenPromises).then(postUpdate);
971
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
972
- childrenPromises.length = 0;
973
- }
974
- }
975
- };
976
- const callRender = (hostRef, instance, elm) => {
977
- try {
978
- instance = instance.render() ;
979
- {
980
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
981
- }
982
- {
983
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
984
- }
985
- {
986
- {
987
- // looks like we've got child nodes to render into this host element
988
- // or we need to update the css class/attrs on the host element
989
- // DOM WRITE!
990
- {
991
- renderVdom(hostRef, instance);
992
- }
993
- }
994
- }
995
- }
996
- catch (e) {
997
- consoleError(e, hostRef.$hostElement$);
998
- }
999
- return null;
1000
- };
1001
- const postUpdateComponent = (hostRef) => {
1002
- const tagName = hostRef.$cmpMeta$.$tagName$;
1003
- const elm = hostRef.$hostElement$;
1004
- const endPostUpdate = createTime('postUpdate', tagName);
1005
- const instance = hostRef.$lazyInstance$ ;
1006
- const ancestorComponent = hostRef.$ancestorComponent$;
1007
- {
1008
- safeCall(instance, 'componentDidRender');
1009
- }
1010
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1011
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1012
- {
1013
- // DOM WRITE!
1014
- addHydratedFlag(elm);
1015
- }
1016
- {
1017
- safeCall(instance, 'componentDidLoad');
1018
- }
1019
- endPostUpdate();
1020
- {
1021
- hostRef.$onReadyResolve$(elm);
1022
- if (!ancestorComponent) {
1023
- appDidLoad();
1024
- }
1025
- }
1026
- }
1027
- else {
1028
- {
1029
- safeCall(instance, 'componentDidUpdate');
1030
- }
1031
- endPostUpdate();
1032
- }
1033
- {
1034
- hostRef.$onInstanceResolve$(elm);
1035
- }
1036
- // load events fire from bottom to top
1037
- // the deepest elements load first then bubbles up
1038
- {
1039
- if (hostRef.$onRenderResolve$) {
1040
- hostRef.$onRenderResolve$();
1041
- hostRef.$onRenderResolve$ = undefined;
1042
- }
1043
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1044
- nextTick(() => scheduleUpdate(hostRef, false));
1045
- }
1046
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1047
- }
1048
- // ( •_•)
1049
- // ( •_•)>⌐■-■
1050
- // (⌐■_■)
1051
- };
1052
- const appDidLoad = (who) => {
1053
- // on appload
1054
- // we have finish the first big initial render
1055
- {
1056
- addHydratedFlag(doc.documentElement);
1057
- }
1058
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1059
- };
1060
- const safeCall = (instance, method, arg) => {
1061
- if (instance && instance[method]) {
1062
- try {
1063
- return instance[method](arg);
1064
- }
1065
- catch (e) {
1066
- consoleError(e);
1067
- }
1068
- }
1069
- return undefined;
1070
- };
1071
- const then = (promise, thenFn) => {
1072
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1073
- };
1074
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1075
- ;
1076
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1077
- const setValue = (ref, propName, newVal, cmpMeta) => {
1078
- // check our new property value against our internal value
1079
- const hostRef = getHostRef(ref);
1080
- const oldVal = hostRef.$instanceValues$.get(propName);
1081
- const flags = hostRef.$flags$;
1082
- const instance = hostRef.$lazyInstance$ ;
1083
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1084
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1085
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1086
- const didValueChange = newVal !== oldVal && !areBothNaN;
1087
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1088
- // gadzooks! the property's value has changed!!
1089
- // set our new value!
1090
- hostRef.$instanceValues$.set(propName, newVal);
1091
- if (instance) {
1092
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1093
- // looks like this value actually changed, so we've got work to do!
1094
- // but only if we've already rendered, otherwise just chill out
1095
- // queue that we need to do an update, but don't worry about queuing
1096
- // up millions cuz this function ensures it only runs once
1097
- scheduleUpdate(hostRef, false);
1098
- }
1099
- }
1100
- }
1101
- };
1102
- /**
1103
- * Attach a series of runtime constructs to a compiled Stencil component
1104
- * constructor, including getters and setters for the `@Prop` and `@State`
1105
- * decorators, callbacks for when attributes change, and so on.
1106
- *
1107
- * @param Cstr the constructor for a component that we need to process
1108
- * @param cmpMeta metadata collected previously about the component
1109
- * @param flags a number used to store a series of bit flags
1110
- * @returns a reference to the same constructor passed in (but now mutated)
1111
- */
1112
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1113
- if (cmpMeta.$members$) {
1114
- // It's better to have a const than two Object.entries()
1115
- const members = Object.entries(cmpMeta.$members$);
1116
- const prototype = Cstr.prototype;
1117
- members.map(([memberName, [memberFlags]]) => {
1118
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1119
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1120
- // proxyComponent - prop
1121
- Object.defineProperty(prototype, memberName, {
1122
- get() {
1123
- // proxyComponent, get value
1124
- return getValue(this, memberName);
1125
- },
1126
- set(newValue) {
1127
- // proxyComponent, set value
1128
- setValue(this, memberName, newValue, cmpMeta);
1129
- },
1130
- configurable: true,
1131
- enumerable: true,
1132
- });
1133
- }
1134
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1135
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1136
- // proxyComponent - method
1137
- Object.defineProperty(prototype, memberName, {
1138
- value(...args) {
1139
- const ref = getHostRef(this);
1140
- return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1141
- },
1142
- });
1143
- }
1144
- });
1145
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1146
- const attrNameToPropName = new Map();
1147
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1148
- plt.jmp(() => {
1149
- const propName = attrNameToPropName.get(attrName);
1150
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1151
- // in the case where an attribute was set inline.
1152
- // ```html
1153
- // <my-component some-attribute="some-value"></my-component>
1154
- // ```
1155
- //
1156
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1157
- // programmatically changes it before it has been upgraded as shown below:
1158
- //
1159
- // ```html
1160
- // <!-- this component has _not_ been upgraded yet -->
1161
- // <my-component id="test" some-attribute="some-value"></my-component>
1162
- // <script>
1163
- // // grab non-upgraded component
1164
- // el = document.querySelector("#test");
1165
- // el.someAttribute = "another-value";
1166
- // // upgrade component
1167
- // customElements.define('my-component', MyComponent);
1168
- // </script>
1169
- // ```
1170
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1171
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1172
- // to the value that was set inline i.e. "some-value" from above example. When
1173
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1174
- //
1175
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1176
- // by connectedCallback as this attributeChangedCallback will not fire.
1177
- //
1178
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1179
- //
1180
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1181
- // properties here given that this goes against best practices outlined here
1182
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1183
- if (this.hasOwnProperty(propName)) {
1184
- newValue = this[propName];
1185
- delete this[propName];
1186
- }
1187
- else if (prototype.hasOwnProperty(propName) &&
1188
- typeof this[propName] === 'number' &&
1189
- this[propName] == newValue) {
1190
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1191
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1192
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1193
- return;
1194
- }
1195
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1196
- });
1197
- };
1198
- // create an array of attributes to observe
1199
- // and also create a map of html attribute name to js property name
1200
- Cstr.observedAttributes = members
1201
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1202
- .map(([propName, m]) => {
1203
- const attrName = m[1] || propName;
1204
- attrNameToPropName.set(attrName, propName);
1205
- return attrName;
1206
- });
1207
- }
1208
- }
1209
- return Cstr;
1210
- };
1211
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1212
- // initializeComponent
1213
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1214
- {
1215
- // we haven't initialized this element yet
1216
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1217
- // lazy loaded components
1218
- // request the component's implementation to be
1219
- // wired up with the host element
1220
- Cstr = loadModule(cmpMeta);
1221
- if (Cstr.then) {
1222
- // Await creates a micro-task avoid if possible
1223
- const endLoad = uniqueTime();
1224
- Cstr = await Cstr;
1225
- endLoad();
1226
- }
1227
- if (!Cstr.isProxied) {
1228
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1229
- Cstr.isProxied = true;
1230
- }
1231
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1232
- // ok, time to construct the instance
1233
- // but let's keep track of when we start and stop
1234
- // so that the getters/setters don't incorrectly step on data
1235
- {
1236
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1237
- }
1238
- // construct the lazy-loaded component implementation
1239
- // passing the hostRef is very important during
1240
- // construction in order to directly wire together the
1241
- // host element and the lazy-loaded instance
1242
- try {
1243
- new Cstr(hostRef);
1244
- }
1245
- catch (e) {
1246
- consoleError(e);
1247
- }
1248
- {
1249
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1250
- }
1251
- endNewInstance();
1252
- }
1253
- if (Cstr.style) {
1254
- // this component has styles but we haven't registered them yet
1255
- let style = Cstr.style;
1256
- const scopeId = getScopeId(cmpMeta);
1257
- if (!styles.has(scopeId)) {
1258
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1259
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1260
- endRegisterStyles();
1261
- }
1262
- }
1263
- }
1264
- // we've successfully created a lazy instance
1265
- const ancestorComponent = hostRef.$ancestorComponent$;
1266
- const schedule = () => scheduleUpdate(hostRef, true);
1267
- if (ancestorComponent && ancestorComponent['s-rc']) {
1268
- // this is the initial load and this component it has an ancestor component
1269
- // but the ancestor component has NOT fired its will update lifecycle yet
1270
- // so let's just cool our jets and wait for the ancestor to continue first
1271
- // this will get fired off when the ancestor component
1272
- // finally gets around to rendering its lazy self
1273
- // fire off the initial update
1274
- ancestorComponent['s-rc'].push(schedule);
1275
- }
1276
- else {
1277
- schedule();
1278
- }
1279
- };
1280
- const connectedCallback = (elm) => {
1281
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1282
- const hostRef = getHostRef(elm);
1283
- const cmpMeta = hostRef.$cmpMeta$;
1284
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1285
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1286
- // first time this component has connected
1287
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1288
- {
1289
- // find the first ancestor component (if there is one) and register
1290
- // this component as one of the actively loading child components for its ancestor
1291
- let ancestorComponent = elm;
1292
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1293
- // climb up the ancestors looking for the first
1294
- // component that hasn't finished its lifecycle update yet
1295
- if (ancestorComponent['s-p']) {
1296
- // we found this components first ancestor component
1297
- // keep a reference to this component's ancestor component
1298
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1299
- break;
1300
- }
1301
- }
1302
- }
1303
- // Lazy properties
1304
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1305
- if (cmpMeta.$members$) {
1306
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1307
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1308
- const value = elm[memberName];
1309
- delete elm[memberName];
1310
- elm[memberName] = value;
1311
- }
1312
- });
1313
- }
1314
- {
1315
- initializeComponent(elm, hostRef, cmpMeta);
1316
- }
1317
- }
1318
- endConnected();
1319
- }
1320
- };
1321
- const disconnectedCallback = (elm) => {
1322
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1323
- getHostRef(elm);
1324
- }
1325
- };
1326
- const bootstrapLazy = (lazyBundles, options = {}) => {
1327
- var _a;
1328
- const endBootstrap = createTime();
1329
- const cmpTags = [];
1330
- const exclude = options.exclude || [];
1331
- const customElements = win.customElements;
1332
- const head = doc.head;
1333
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1334
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1335
- const deferredConnectedCallbacks = [];
1336
- let appLoadFallback;
1337
- let isBootstrapping = true;
1338
- Object.assign(plt, options);
1339
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1340
- lazyBundles.map((lazyBundle) => {
1341
- lazyBundle[1].map((compactMeta) => {
1342
- const cmpMeta = {
1343
- $flags$: compactMeta[0],
1344
- $tagName$: compactMeta[1],
1345
- $members$: compactMeta[2],
1346
- $listeners$: compactMeta[3],
1347
- };
1348
- {
1349
- cmpMeta.$members$ = compactMeta[2];
1350
- }
1351
- const tagName = cmpMeta.$tagName$;
1352
- const HostElement = class extends HTMLElement {
1353
- // StencilLazyHost
1354
- constructor(self) {
1355
- // @ts-ignore
1356
- super(self);
1357
- self = this;
1358
- registerHost(self, cmpMeta);
1359
- }
1360
- connectedCallback() {
1361
- if (appLoadFallback) {
1362
- clearTimeout(appLoadFallback);
1363
- appLoadFallback = null;
1364
- }
1365
- if (isBootstrapping) {
1366
- // connectedCallback will be processed once all components have been registered
1367
- deferredConnectedCallbacks.push(this);
1368
- }
1369
- else {
1370
- plt.jmp(() => connectedCallback(this));
1371
- }
1372
- }
1373
- disconnectedCallback() {
1374
- plt.jmp(() => disconnectedCallback(this));
1375
- }
1376
- componentOnReady() {
1377
- return getHostRef(this).$onReadyPromise$;
1378
- }
1379
- };
1380
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1381
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1382
- cmpTags.push(tagName);
1383
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1384
- }
1385
- });
1386
- });
1387
- {
1388
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1389
- visibilityStyle.setAttribute('data-styles', '');
1390
- // Apply CSP nonce to the style tag if it exists
1391
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1392
- if (nonce != null) {
1393
- visibilityStyle.setAttribute('nonce', nonce);
1394
- }
1395
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1396
- }
1397
- // Process deferred connectedCallbacks now all components have been registered
1398
- isBootstrapping = false;
1399
- if (deferredConnectedCallbacks.length) {
1400
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1401
- }
1402
- else {
1403
- {
1404
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1405
- }
1406
- }
1407
- // Fallback appLoad event
1408
- endBootstrap();
1409
- };
1410
- /**
1411
- * Assigns the given value to the nonce property on the runtime platform object.
1412
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1413
- * @param nonce The value to be assigned to the platform nonce property.
1414
- * @returns void
1415
- */
1416
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1417
- const hostRefs = /*@__PURE__*/ new WeakMap();
1418
- const getHostRef = (ref) => hostRefs.get(ref);
1419
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1420
- const registerHost = (elm, cmpMeta) => {
1421
- const hostRef = {
1422
- $flags$: 0,
1423
- $hostElement$: elm,
1424
- $cmpMeta$: cmpMeta,
1425
- $instanceValues$: new Map(),
1426
- };
1427
- {
1428
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1429
- }
1430
- {
1431
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1432
- elm['s-p'] = [];
1433
- elm['s-rc'] = [];
1434
- }
1435
- return hostRefs.set(elm, hostRef);
1436
- };
1437
- const isMemberInElement = (elm, memberName) => memberName in elm;
1438
- const consoleError = (e, el) => (0, console.error)(e, el);
1439
- const cmpModules = /*@__PURE__*/ new Map();
1440
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1441
- // loadModuleImport
1442
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1443
- const bundleId = cmpMeta.$lazyBundleId$;
1444
- const module = cmpModules.get(bundleId) ;
1445
- if (module) {
1446
- return module[exportName];
1447
- }
1448
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1449
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1450
- /* @vite-ignore */
1451
- /* webpackInclude: /\.entry\.js$/ */
1452
- /* webpackExclude: /\.system\.entry\.js$/ */
1453
- /* webpackMode: "lazy" */
1454
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1455
- {
1456
- cmpModules.set(bundleId, importedModule);
1457
- }
1458
- return importedModule[exportName];
1459
- }, consoleError);
1460
- };
1461
- const styles = /*@__PURE__*/ new Map();
1462
- const win = typeof window !== 'undefined' ? window : {};
1463
- const doc = win.document || { head: {} };
1464
- const plt = {
1465
- $flags$: 0,
1466
- $resourcesUrl$: '',
1467
- jmp: (h) => h(),
1468
- raf: (h) => requestAnimationFrame(h),
1469
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1470
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1471
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
1472
- };
1473
- const promiseResolve = (v) => Promise.resolve(v);
1474
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1475
- try {
1476
- new CSSStyleSheet();
1477
- return typeof new CSSStyleSheet().replaceSync === 'function';
1478
- }
1479
- catch (e) { }
1480
- return false;
1481
- })()
1482
- ;
1483
- const queueDomReads = [];
1484
- const queueDomWrites = [];
1485
- const queueTask = (queue, write) => (cb) => {
1486
- queue.push(cb);
1487
- if (!queuePending) {
1488
- queuePending = true;
1489
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1490
- nextTick(flush);
1491
- }
1492
- else {
1493
- plt.raf(flush);
1494
- }
1495
- }
1496
- };
1497
- const consume = (queue) => {
1498
- for (let i = 0; i < queue.length; i++) {
1499
- try {
1500
- queue[i](performance.now());
1501
- }
1502
- catch (e) {
1503
- consoleError(e);
1504
- }
1505
- }
1506
- queue.length = 0;
1507
- };
1508
- const flush = () => {
1509
- // always force a bunch of medium callbacks to run, but still have
1510
- // a throttle on how many can run in a certain time
1511
- // DOM READS!!!
1512
- consume(queueDomReads);
1513
- // DOM WRITES!!!
1514
- {
1515
- consume(queueDomWrites);
1516
- if ((queuePending = queueDomReads.length > 0)) {
1517
- // still more to do yet, but we've run out of time
1518
- // let's let this thing cool off and try again in the next tick
1519
- plt.raf(flush);
1520
- }
1521
- }
1522
- };
1523
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1524
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1525
-
1526
- exports.bootstrapLazy = bootstrapLazy;
1527
- exports.getAssetPath = getAssetPath;
1528
- exports.h = h;
1529
- exports.promiseResolve = promiseResolve;
1530
- exports.registerInstance = registerInstance;
1531
- exports.setNonce = setNonce;