@haiilo/catalyst 10.11.1 → 10.13.0

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 (157) hide show
  1. package/dist/catalyst/catalyst.css +1 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.esm.js +1 -1
  5. package/dist/catalyst/index.esm.js.map +1 -1
  6. package/dist/catalyst/p-751d92ed.js +3 -0
  7. package/dist/catalyst/p-751d92ed.js.map +1 -0
  8. package/dist/catalyst/p-8f350146.entry.js +10 -0
  9. package/dist/catalyst/p-8f350146.entry.js.map +1 -0
  10. package/dist/catalyst/p-e1255160.js.map +1 -1
  11. package/dist/catalyst/p-f4873629.js +2 -0
  12. package/dist/catalyst/{p-2c8ac8cf.js.map → p-f4873629.js.map} +1 -1
  13. package/dist/catalyst/scss/core/_dialog.scss +1 -1
  14. package/dist/cjs/cat-alert_29.cjs.entry.js +584 -122
  15. package/dist/cjs/cat-alert_29.cjs.entry.js.map +1 -1
  16. package/dist/cjs/catalyst.cjs.js +10 -10
  17. package/dist/cjs/catalyst.cjs.js.map +1 -1
  18. package/dist/cjs/index-a45dd7c9.js +1383 -0
  19. package/dist/cjs/index-a45dd7c9.js.map +1 -0
  20. package/dist/cjs/index.cjs.js +1 -1
  21. package/dist/cjs/loader.cjs.js +2 -2
  22. package/dist/cjs/{of-f2844da8.js → of-5cd84f84.js} +22 -22
  23. package/dist/cjs/{of-f2844da8.js.map → of-5cd84f84.js.map} +1 -1
  24. package/dist/collection/collection-manifest.json +2 -2
  25. package/dist/collection/components/cat-alert/cat-alert.js +1 -1
  26. package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
  27. package/dist/collection/components/cat-avatar/cat-avatar.js +0 -4
  28. package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
  29. package/dist/collection/components/cat-badge/cat-badge.js +1 -1
  30. package/dist/collection/components/cat-button/cat-button.js +0 -4
  31. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  32. package/dist/collection/components/cat-button-group/cat-button-group.js +1 -1
  33. package/dist/collection/components/cat-card/cat-card.js +1 -1
  34. package/dist/collection/components/cat-checkbox/cat-checkbox.js +1 -9
  35. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  36. package/dist/collection/components/cat-date/cat-date.js +3 -3
  37. package/dist/collection/components/cat-date-inline/cat-date-inline.js +4 -12
  38. package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -1
  39. package/dist/collection/components/cat-datepicker/cat-datepicker.js +4 -4
  40. package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
  41. package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
  42. package/dist/collection/components/cat-dropdown/cat-dropdown.js +22 -3
  43. package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
  44. package/dist/collection/components/cat-form-group/cat-form-group.js +1 -1
  45. package/dist/collection/components/cat-icon/cat-icon.js +1 -1
  46. package/dist/collection/components/cat-input/cat-input.js +4 -10
  47. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  48. package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
  49. package/dist/collection/components/cat-radio/cat-radio.js +1 -9
  50. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  51. package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
  52. package/dist/collection/components/cat-scrollable/cat-scrollable.js +3 -3
  53. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
  54. package/dist/collection/components/cat-select/cat-select.js +6 -12
  55. package/dist/collection/components/cat-select/cat-select.js.map +1 -1
  56. package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
  57. package/dist/collection/components/cat-skeleton/cat-skeleton.js +1 -1
  58. package/dist/collection/components/cat-spinner/cat-spinner.js +2 -2
  59. package/dist/collection/components/cat-tab/cat-tab.js +1 -1
  60. package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
  61. package/dist/collection/components/cat-textarea/cat-textarea.js +3 -9
  62. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  63. package/dist/collection/components/cat-time/cat-time.js +3 -3
  64. package/dist/collection/components/cat-time/cat-time.js.map +1 -1
  65. package/dist/collection/components/cat-toggle/cat-toggle.js +1 -9
  66. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  67. package/dist/collection/components/cat-tooltip/cat-tooltip.js +3 -3
  68. package/dist/collection/scss/core/_dialog.scss +1 -1
  69. package/dist/components/cat-alert.js +1 -1
  70. package/dist/components/cat-alert.js.map +1 -1
  71. package/dist/components/cat-avatar2.js +0 -4
  72. package/dist/components/cat-avatar2.js.map +1 -1
  73. package/dist/components/cat-badge.js +1 -1
  74. package/dist/components/cat-button-group.js +1 -1
  75. package/dist/components/cat-button2.js +0 -4
  76. package/dist/components/cat-button2.js.map +1 -1
  77. package/dist/components/cat-card.js +1 -1
  78. package/dist/components/cat-checkbox2.js +1 -9
  79. package/dist/components/cat-checkbox2.js.map +1 -1
  80. package/dist/components/cat-date-inline2.js +4 -12
  81. package/dist/components/cat-date-inline2.js.map +1 -1
  82. package/dist/components/cat-date.js +2 -2
  83. package/dist/components/cat-datepicker-inline.js +2 -2
  84. package/dist/components/cat-datepicker.js +3 -3
  85. package/dist/components/cat-datepicker.js.map +1 -1
  86. package/dist/components/cat-dropdown2.js +4 -2
  87. package/dist/components/cat-dropdown2.js.map +1 -1
  88. package/dist/components/cat-form-group.js +1 -1
  89. package/dist/components/cat-icon-registry.js +21 -21
  90. package/dist/components/cat-icon2.js +1 -1
  91. package/dist/components/cat-input2.js +4 -10
  92. package/dist/components/cat-input2.js.map +1 -1
  93. package/dist/components/cat-pagination.js +2 -2
  94. package/dist/components/cat-radio-group.js +1 -1
  95. package/dist/components/cat-radio.js +1 -9
  96. package/dist/components/cat-radio.js.map +1 -1
  97. package/dist/components/cat-scrollable2.js +3 -3
  98. package/dist/components/cat-scrollable2.js.map +1 -1
  99. package/dist/components/cat-select-demo.js +1 -1
  100. package/dist/components/cat-select2.js +5 -11
  101. package/dist/components/cat-select2.js.map +1 -1
  102. package/dist/components/cat-skeleton2.js +1 -1
  103. package/dist/components/cat-spinner2.js +2 -2
  104. package/dist/components/cat-tab.js +1 -1
  105. package/dist/components/cat-tabs.js +1 -1
  106. package/dist/components/cat-textarea.js +3 -9
  107. package/dist/components/cat-textarea.js.map +1 -1
  108. package/dist/components/cat-time.js +2 -2
  109. package/dist/components/cat-time.js.map +1 -1
  110. package/dist/components/cat-toggle.js +1 -9
  111. package/dist/components/cat-toggle.js.map +1 -1
  112. package/dist/components/cat-tooltip.js +2 -2
  113. package/dist/components/floating-ui.dom.esm.js +531 -13
  114. package/dist/components/floating-ui.dom.esm.js.map +1 -1
  115. package/dist/esm/cat-alert_29.entry.js +584 -122
  116. package/dist/esm/cat-alert_29.entry.js.map +1 -1
  117. package/dist/esm/catalyst.js +11 -11
  118. package/dist/esm/catalyst.js.map +1 -1
  119. package/dist/esm/index-3059296e.js +1354 -0
  120. package/dist/esm/index-3059296e.js.map +1 -0
  121. package/dist/esm/index.js +2 -2
  122. package/dist/esm/loader.js +3 -3
  123. package/dist/esm/{of-53334b95.js → of-625babef.js} +22 -22
  124. package/dist/esm/{of-53334b95.js.map → of-625babef.js.map} +1 -1
  125. package/dist/types/components/cat-avatar/cat-avatar.d.ts +0 -1
  126. package/dist/types/components/cat-button/cat-button.d.ts +0 -1
  127. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +0 -1
  128. package/dist/types/components/cat-date-inline/cat-date-inline.d.ts +0 -1
  129. package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +4 -0
  130. package/dist/types/components/cat-radio/cat-radio.d.ts +0 -1
  131. package/dist/types/components/cat-toggle/cat-toggle.d.ts +0 -1
  132. package/dist/types/components.d.ts +8 -0
  133. package/dist/types/stencil-public-runtime.d.ts +3 -8
  134. package/loader/cdn.js +1 -3
  135. package/loader/index.cjs.js +1 -3
  136. package/loader/index.es2017.js +1 -3
  137. package/loader/index.js +1 -3
  138. package/package.json +16 -16
  139. package/dist/catalyst/p-22f0435a.js +0 -3
  140. package/dist/catalyst/p-22f0435a.js.map +0 -1
  141. package/dist/catalyst/p-2c8ac8cf.js +0 -2
  142. package/dist/catalyst/p-7da486bb.entry.js +0 -10
  143. package/dist/catalyst/p-7da486bb.entry.js.map +0 -1
  144. package/dist/cjs/index-66a60071.js +0 -2081
  145. package/dist/cjs/index-66a60071.js.map +0 -1
  146. package/dist/collection/utils/assert.js +0 -9
  147. package/dist/collection/utils/assert.js.map +0 -1
  148. package/dist/components/assert.js +0 -13
  149. package/dist/components/assert.js.map +0 -1
  150. package/dist/esm/index-b7832dfc.js +0 -2052
  151. package/dist/esm/index-b7832dfc.js.map +0 -1
  152. package/dist/esm/polyfills/core-js.js +0 -11
  153. package/dist/esm/polyfills/dom.js +0 -79
  154. package/dist/esm/polyfills/es5-html-element.js +0 -1
  155. package/dist/esm/polyfills/index.js +0 -34
  156. package/dist/esm/polyfills/system.js +0 -6
  157. package/dist/types/utils/assert.d.ts +0 -1
@@ -1,2081 +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 = 'catalyst';
24
-
25
- /**
26
- * Virtual DOM patching algorithm based on Snabbdom by
27
- * Simon Friis Vindum (@paldepind)
28
- * Licensed under the MIT License
29
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
- *
31
- * Modified for Stencil's renderer and slot projection
32
- */
33
- let scopeId;
34
- let hostTagName;
35
- let useNativeShadowDom = false;
36
- let isSvgMode = false;
37
- let queuePending = false;
38
- const createTime = (fnName, tagName = '') => {
39
- {
40
- return () => {
41
- return;
42
- };
43
- }
44
- };
45
- const uniqueTime = (key, measureText) => {
46
- {
47
- return () => {
48
- return;
49
- };
50
- }
51
- };
52
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
53
- /**
54
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
55
- *
56
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
57
- * support as of Stencil v4.
58
- */
59
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
60
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
61
- /**
62
- * Default style mode id
63
- */
64
- /**
65
- * Reusable empty obj/array
66
- * Don't add values to these!!
67
- */
68
- const EMPTY_OBJ = {};
69
- /**
70
- * Namespaces
71
- */
72
- const SVG_NS = 'http://www.w3.org/2000/svg';
73
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
74
- const isDef = (v) => v != null;
75
- /**
76
- * Check whether a value is a 'complex type', defined here as an object or a
77
- * function.
78
- *
79
- * @param o the value to check
80
- * @returns whether it's a complex type or not
81
- */
82
- const isComplexType = (o) => {
83
- // https://jsperf.com/typeof-fn-object/5
84
- o = typeof o;
85
- return o === 'object' || o === 'function';
86
- };
87
- /**
88
- * Helper method for querying a `meta` tag that contains a nonce value
89
- * out of a DOM's head.
90
- *
91
- * @param doc The DOM containing the `head` to query against
92
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
93
- * exists or the tag has no content.
94
- */
95
- function queryNonceMetaTagContent(doc) {
96
- var _a, _b, _c;
97
- 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;
98
- }
99
- /**
100
- * Production h() function based on Preact by
101
- * Jason Miller (@developit)
102
- * Licensed under the MIT License
103
- * https://github.com/developit/preact/blob/master/LICENSE
104
- *
105
- * Modified for Stencil's compiler and vdom
106
- */
107
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
108
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
109
- const h = (nodeName, vnodeData, ...children) => {
110
- let child = null;
111
- let key = null;
112
- let simple = false;
113
- let lastSimple = false;
114
- const vNodeChildren = [];
115
- const walk = (c) => {
116
- for (let i = 0; i < c.length; i++) {
117
- child = c[i];
118
- if (Array.isArray(child)) {
119
- walk(child);
120
- }
121
- else if (child != null && typeof child !== 'boolean') {
122
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
123
- child = String(child);
124
- }
125
- if (simple && lastSimple) {
126
- // If the previous child was simple (string), we merge both
127
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
128
- }
129
- else {
130
- // Append a new vNode, if it's text, we create a text vNode
131
- vNodeChildren.push(simple ? newVNode(null, child) : child);
132
- }
133
- lastSimple = simple;
134
- }
135
- }
136
- };
137
- walk(children);
138
- if (vnodeData) {
139
- if (vnodeData.key) {
140
- key = vnodeData.key;
141
- }
142
- // normalize class / className attributes
143
- {
144
- const classData = vnodeData.className || vnodeData.class;
145
- if (classData) {
146
- vnodeData.class =
147
- typeof classData !== 'object'
148
- ? classData
149
- : Object.keys(classData)
150
- .filter((k) => classData[k])
151
- .join(' ');
152
- }
153
- }
154
- }
155
- if (typeof nodeName === 'function') {
156
- // nodeName is a functional component
157
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
158
- }
159
- const vnode = newVNode(nodeName, null);
160
- vnode.$attrs$ = vnodeData;
161
- if (vNodeChildren.length > 0) {
162
- vnode.$children$ = vNodeChildren;
163
- }
164
- {
165
- vnode.$key$ = key;
166
- }
167
- return vnode;
168
- };
169
- /**
170
- * A utility function for creating a virtual DOM node from a tag and some
171
- * possible text content.
172
- *
173
- * @param tag the tag for this element
174
- * @param text possible text content for the node
175
- * @returns a newly-minted virtual DOM node
176
- */
177
- const newVNode = (tag, text) => {
178
- const vnode = {
179
- $flags$: 0,
180
- $tag$: tag,
181
- $text$: text,
182
- $elm$: null,
183
- $children$: null,
184
- };
185
- {
186
- vnode.$attrs$ = null;
187
- }
188
- {
189
- vnode.$key$ = null;
190
- }
191
- return vnode;
192
- };
193
- const Host = {};
194
- /**
195
- * Check whether a given node is a Host node or not
196
- *
197
- * @param node the virtual DOM node to check
198
- * @returns whether it's a Host node or not
199
- */
200
- const isHost = (node) => node && node.$tag$ === Host;
201
- /**
202
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
203
- *
204
- * Note that these functions convert from {@link d.VNode} to
205
- * {@link d.ChildNode} to give functional component developers a friendly
206
- * interface.
207
- */
208
- const vdomFnUtils = {
209
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
210
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
211
- };
212
- /**
213
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
214
- * friendlier public interface (hence, 'convertToPublic').
215
- *
216
- * @param node the virtual DOM node to convert
217
- * @returns a converted child node
218
- */
219
- const convertToPublic = (node) => ({
220
- vattrs: node.$attrs$,
221
- vchildren: node.$children$,
222
- vkey: node.$key$,
223
- vname: node.$name$,
224
- vtag: node.$tag$,
225
- vtext: node.$text$,
226
- });
227
- /**
228
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
229
- * order to use the resulting object in the virtual DOM. The initial object was
230
- * likely created as part of presenting a public API, so converting it back
231
- * involved making it 'private' again (hence, `convertToPrivate`).
232
- *
233
- * @param node the child node to convert
234
- * @returns a converted virtual DOM node
235
- */
236
- const convertToPrivate = (node) => {
237
- if (typeof node.vtag === 'function') {
238
- const vnodeData = Object.assign({}, node.vattrs);
239
- if (node.vkey) {
240
- vnodeData.key = node.vkey;
241
- }
242
- if (node.vname) {
243
- vnodeData.name = node.vname;
244
- }
245
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
246
- }
247
- const vnode = newVNode(node.vtag, node.vtext);
248
- vnode.$attrs$ = node.vattrs;
249
- vnode.$children$ = node.vchildren;
250
- vnode.$key$ = node.vkey;
251
- vnode.$name$ = node.vname;
252
- return vnode;
253
- };
254
- /**
255
- * Parse a new property value for a given property type.
256
- *
257
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
258
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
259
- * 1. `any`, the type given to `propValue` in the function signature
260
- * 2. the type stored from `propType`.
261
- *
262
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
263
- *
264
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
265
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
266
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
267
- * ```tsx
268
- * <my-cmp prop-val={0}></my-cmp>
269
- * ```
270
- *
271
- * HTML prop values on the other hand, will always a string
272
- *
273
- * @param propValue the new value to coerce to some type
274
- * @param propType the type of the prop, expressed as a binary number
275
- * @returns the parsed/coerced value
276
- */
277
- const parsePropertyValue = (propValue, propType) => {
278
- // ensure this value is of the correct prop type
279
- if (propValue != null && !isComplexType(propValue)) {
280
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
281
- // per the HTML spec, any string value means it is a boolean true value
282
- // but we'll cheat here and say that the string "false" is the boolean false
283
- return propValue === 'false' ? false : propValue === '' || !!propValue;
284
- }
285
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
286
- // force it to be a number
287
- return parseFloat(propValue);
288
- }
289
- if (propType & 1 /* MEMBER_FLAGS.String */) {
290
- // could have been passed as a number or boolean
291
- // but we still want it as a string
292
- return String(propValue);
293
- }
294
- // redundant return here for better minification
295
- return propValue;
296
- }
297
- // not sure exactly what type we want
298
- // so no need to change to a different type
299
- return propValue;
300
- };
301
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
302
- const createEvent = (ref, name, flags) => {
303
- const elm = getElement(ref);
304
- return {
305
- emit: (detail) => {
306
- return emitEvent(elm, name, {
307
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
308
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
309
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
310
- detail,
311
- });
312
- },
313
- };
314
- };
315
- /**
316
- * Helper function to create & dispatch a custom Event on a provided target
317
- * @param elm the target of the Event
318
- * @param name the name to give the custom Event
319
- * @param opts options for configuring a custom Event
320
- * @returns the custom Event
321
- */
322
- const emitEvent = (elm, name, opts) => {
323
- const ev = plt.ce(name, opts);
324
- elm.dispatchEvent(ev);
325
- return ev;
326
- };
327
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
328
- const registerStyle = (scopeId, cssText, allowCS) => {
329
- let style = styles.get(scopeId);
330
- if (supportsConstructableStylesheets && allowCS) {
331
- style = (style || new CSSStyleSheet());
332
- if (typeof style === 'string') {
333
- style = cssText;
334
- }
335
- else {
336
- style.replaceSync(cssText);
337
- }
338
- }
339
- else {
340
- style = cssText;
341
- }
342
- styles.set(scopeId, style);
343
- };
344
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
345
- var _a;
346
- const scopeId = getScopeId(cmpMeta);
347
- const style = styles.get(scopeId);
348
- // if an element is NOT connected then getRootNode() will return the wrong root node
349
- // so the fallback is to always use the document for the root node in those cases
350
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
351
- if (style) {
352
- if (typeof style === 'string') {
353
- styleContainerNode = styleContainerNode.head || styleContainerNode;
354
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
355
- let styleElm;
356
- if (!appliedStyles) {
357
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
358
- }
359
- if (!appliedStyles.has(scopeId)) {
360
- {
361
- styleElm = doc.createElement('style');
362
- styleElm.innerHTML = style;
363
- // Apply CSP nonce to the style tag if it exists
364
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
365
- if (nonce != null) {
366
- styleElm.setAttribute('nonce', nonce);
367
- }
368
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
369
- }
370
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
371
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
372
- styleElm.innerHTML += SLOT_FB_CSS;
373
- }
374
- if (appliedStyles) {
375
- appliedStyles.add(scopeId);
376
- }
377
- }
378
- }
379
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
380
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
381
- }
382
- }
383
- return scopeId;
384
- };
385
- const attachStyles = (hostRef) => {
386
- const cmpMeta = hostRef.$cmpMeta$;
387
- const elm = hostRef.$hostElement$;
388
- const flags = cmpMeta.$flags$;
389
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
390
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
391
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
392
- // only required when we're NOT using native shadow dom (slot)
393
- // or this browser doesn't support native shadow dom
394
- // and this host element was NOT created with SSR
395
- // let's pick out the inner content for slot projection
396
- // create a node to represent where the original
397
- // content was first placed, which is useful later on
398
- // DOM WRITE!!
399
- elm['s-sc'] = scopeId;
400
- elm.classList.add(scopeId + '-h');
401
- }
402
- endAttachStyles();
403
- };
404
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
405
- /**
406
- * Production setAccessor() function based on Preact by
407
- * Jason Miller (@developit)
408
- * Licensed under the MIT License
409
- * https://github.com/developit/preact/blob/master/LICENSE
410
- *
411
- * Modified for Stencil's compiler and vdom
412
- */
413
- /**
414
- * When running a VDom render set properties present on a VDom node onto the
415
- * corresponding HTML element.
416
- *
417
- * Note that this function has special functionality for the `class`,
418
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
419
- * `onClick`, etc). All others are just passed through as-is.
420
- *
421
- * @param elm the HTMLElement onto which attributes should be set
422
- * @param memberName the name of the attribute to set
423
- * @param oldValue the old value for the attribute
424
- * @param newValue the new value for the attribute
425
- * @param isSvg whether we're in an svg context or not
426
- * @param flags bitflags for Vdom variables
427
- */
428
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
429
- if (oldValue !== newValue) {
430
- let isProp = isMemberInElement(elm, memberName);
431
- let ln = memberName.toLowerCase();
432
- if (memberName === 'class') {
433
- const classList = elm.classList;
434
- const oldClasses = parseClassList(oldValue);
435
- const newClasses = parseClassList(newValue);
436
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
437
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
438
- }
439
- else if (memberName === 'style') {
440
- // update style attribute, css properties and values
441
- {
442
- for (const prop in oldValue) {
443
- if (!newValue || newValue[prop] == null) {
444
- if (prop.includes('-')) {
445
- elm.style.removeProperty(prop);
446
- }
447
- else {
448
- elm.style[prop] = '';
449
- }
450
- }
451
- }
452
- }
453
- for (const prop in newValue) {
454
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
455
- if (prop.includes('-')) {
456
- elm.style.setProperty(prop, newValue[prop]);
457
- }
458
- else {
459
- elm.style[prop] = newValue[prop];
460
- }
461
- }
462
- }
463
- }
464
- else if (memberName === 'key')
465
- ;
466
- else if (memberName === 'ref') {
467
- // minifier will clean this up
468
- if (newValue) {
469
- newValue(elm);
470
- }
471
- }
472
- else if ((!isProp ) &&
473
- memberName[0] === 'o' &&
474
- memberName[1] === 'n') {
475
- // Event Handlers
476
- // so if the member name starts with "on" and the 3rd characters is
477
- // a capital letter, and it's not already a member on the element,
478
- // then we're assuming it's an event listener
479
- if (memberName[2] === '-') {
480
- // on- prefixed events
481
- // allows to be explicit about the dom event to listen without any magic
482
- // under the hood:
483
- // <my-cmp on-click> // listens for "click"
484
- // <my-cmp on-Click> // listens for "Click"
485
- // <my-cmp on-ionChange> // listens for "ionChange"
486
- // <my-cmp on-EVENTS> // listens for "EVENTS"
487
- memberName = memberName.slice(3);
488
- }
489
- else if (isMemberInElement(win, ln)) {
490
- // standard event
491
- // the JSX attribute could have been "onMouseOver" and the
492
- // member name "onmouseover" is on the window's prototype
493
- // so let's add the listener "mouseover", which is all lowercased
494
- memberName = ln.slice(2);
495
- }
496
- else {
497
- // custom event
498
- // the JSX attribute could have been "onMyCustomEvent"
499
- // so let's trim off the "on" prefix and lowercase the first character
500
- // and add the listener "myCustomEvent"
501
- // except for the first character, we keep the event name case
502
- memberName = ln[2] + memberName.slice(3);
503
- }
504
- if (oldValue || newValue) {
505
- // Need to account for "capture" events.
506
- // If the event name ends with "Capture", we'll update the name to remove
507
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
508
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
509
- // Make sure we only replace the last instance of "Capture"
510
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
511
- if (oldValue) {
512
- plt.rel(elm, memberName, oldValue, capture);
513
- }
514
- if (newValue) {
515
- plt.ael(elm, memberName, newValue, capture);
516
- }
517
- }
518
- }
519
- else {
520
- // Set property if it exists and it's not a SVG
521
- const isComplex = isComplexType(newValue);
522
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
523
- try {
524
- if (!elm.tagName.includes('-')) {
525
- const n = newValue == null ? '' : newValue;
526
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
527
- if (memberName === 'list') {
528
- isProp = false;
529
- }
530
- else if (oldValue == null || elm[memberName] != n) {
531
- elm[memberName] = n;
532
- }
533
- }
534
- else {
535
- elm[memberName] = newValue;
536
- }
537
- }
538
- catch (e) {
539
- /**
540
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
541
- */
542
- }
543
- }
544
- /**
545
- * Need to manually update attribute if:
546
- * - memberName is not an attribute
547
- * - if we are rendering the host element in order to reflect attribute
548
- * - if it's a SVG, since properties might not work in <svg>
549
- * - if the newValue is null/undefined or 'false'.
550
- */
551
- let xlink = false;
552
- {
553
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
554
- memberName = ln;
555
- xlink = true;
556
- }
557
- }
558
- if (newValue == null || newValue === false) {
559
- if (newValue !== false || elm.getAttribute(memberName) === '') {
560
- if (xlink) {
561
- elm.removeAttributeNS(XLINK_NS, memberName);
562
- }
563
- else {
564
- elm.removeAttribute(memberName);
565
- }
566
- }
567
- }
568
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
569
- newValue = newValue === true ? '' : newValue;
570
- if (xlink) {
571
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
572
- }
573
- else {
574
- elm.setAttribute(memberName, newValue);
575
- }
576
- }
577
- }
578
- }
579
- };
580
- const parseClassListRegex = /\s/;
581
- /**
582
- * Parsed a string of classnames into an array
583
- * @param value className string, e.g. "foo bar baz"
584
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
585
- */
586
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
587
- const CAPTURE_EVENT_SUFFIX = 'Capture';
588
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
589
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
590
- // if the element passed in is a shadow root, which is a document fragment
591
- // then we want to be adding attrs/props to the shadow root's "host" element
592
- // if it's not a shadow root, then we add attrs/props to the same element
593
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
594
- ? newVnode.$elm$.host
595
- : newVnode.$elm$;
596
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
597
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
598
- {
599
- // remove attributes no longer present on the vnode by setting them to undefined
600
- for (memberName in oldVnodeAttrs) {
601
- if (!(memberName in newVnodeAttrs)) {
602
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
603
- }
604
- }
605
- }
606
- // add new & update changed attributes
607
- for (memberName in newVnodeAttrs) {
608
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
609
- }
610
- };
611
- /**
612
- * Create a DOM Node corresponding to one of the children of a given VNode.
613
- *
614
- * @param oldParentVNode the parent VNode from the previous render
615
- * @param newParentVNode the parent VNode from the current render
616
- * @param childIndex the index of the VNode, in the _new_ parent node's
617
- * children, for which we will create a new DOM node
618
- * @param parentElm the parent DOM node which our new node will be a child of
619
- * @returns the newly created node
620
- */
621
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
622
- // tslint:disable-next-line: prefer-const
623
- const newVNode = newParentVNode.$children$[childIndex];
624
- let i = 0;
625
- let elm;
626
- let childNode;
627
- if (newVNode.$text$ !== null) {
628
- // create text node
629
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
630
- }
631
- else {
632
- if (!isSvgMode) {
633
- isSvgMode = newVNode.$tag$ === 'svg';
634
- }
635
- // create element
636
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
637
- );
638
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
639
- isSvgMode = false;
640
- }
641
- // add css classes, attrs, props, listeners, etc.
642
- {
643
- updateElement(null, newVNode, isSvgMode);
644
- }
645
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
646
- // if there is a scopeId and this is the initial render
647
- // then let's add the scopeId as a css class
648
- elm.classList.add((elm['s-si'] = scopeId));
649
- }
650
- if (newVNode.$children$) {
651
- for (i = 0; i < newVNode.$children$.length; ++i) {
652
- // create the node
653
- childNode = createElm(oldParentVNode, newVNode, i);
654
- // return node could have been null
655
- if (childNode) {
656
- // append our new node
657
- elm.appendChild(childNode);
658
- }
659
- }
660
- }
661
- {
662
- if (newVNode.$tag$ === 'svg') {
663
- // Only reset the SVG context when we're exiting <svg> element
664
- isSvgMode = false;
665
- }
666
- else if (elm.tagName === 'foreignObject') {
667
- // Reenter SVG context when we're exiting <foreignObject> element
668
- isSvgMode = true;
669
- }
670
- }
671
- }
672
- // This needs to always happen so we can hide nodes that are projected
673
- // to another component but don't end up in a slot
674
- elm['s-hn'] = hostTagName;
675
- return elm;
676
- };
677
- /**
678
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
679
- * add them to the DOM in the appropriate place.
680
- *
681
- * @param parentElm the DOM node which should be used as a parent for the new
682
- * DOM nodes
683
- * @param before a child of the `parentElm` which the new children should be
684
- * inserted before (optional)
685
- * @param parentVNode the parent virtual DOM node
686
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
687
- * @param startIdx the index in the child virtual DOM nodes at which to start
688
- * creating DOM nodes (inclusive)
689
- * @param endIdx the index in the child virtual DOM nodes at which to stop
690
- * creating DOM nodes (inclusive)
691
- */
692
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
693
- let containerElm = (parentElm);
694
- let childNode;
695
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
696
- containerElm = containerElm.shadowRoot;
697
- }
698
- for (; startIdx <= endIdx; ++startIdx) {
699
- if (vnodes[startIdx]) {
700
- childNode = createElm(null, parentVNode, startIdx);
701
- if (childNode) {
702
- vnodes[startIdx].$elm$ = childNode;
703
- containerElm.insertBefore(childNode, before);
704
- }
705
- }
706
- }
707
- };
708
- /**
709
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
710
- * This can be used to, for instance, clean up after a list of children which
711
- * should no longer be shown.
712
- *
713
- * This function also handles some of Stencil's slot relocation logic.
714
- *
715
- * @param vnodes a list of virtual DOM nodes to remove
716
- * @param startIdx the index at which to start removing nodes (inclusive)
717
- * @param endIdx the index at which to stop removing nodes (inclusive)
718
- */
719
- const removeVnodes = (vnodes, startIdx, endIdx) => {
720
- for (let index = startIdx; index <= endIdx; ++index) {
721
- const vnode = vnodes[index];
722
- if (vnode) {
723
- const elm = vnode.$elm$;
724
- nullifyVNodeRefs(vnode);
725
- if (elm) {
726
- // remove the vnode's element from the dom
727
- elm.remove();
728
- }
729
- }
730
- }
731
- };
732
- /**
733
- * Reconcile the children of a new VNode with the children of an old VNode by
734
- * traversing the two collections of children, identifying nodes that are
735
- * conserved or changed, calling out to `patch` to make any necessary
736
- * updates to the DOM, and rearranging DOM nodes as needed.
737
- *
738
- * The algorithm for reconciling children works by analyzing two 'windows' onto
739
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
740
- * 'windows' by storing start and end indices and references to the
741
- * corresponding array entries. Initially the two 'windows' are basically equal
742
- * to the entire array, but we progressively narrow the windows until there are
743
- * no children left to update by doing the following:
744
- *
745
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
746
- * that if we have an initial array like the following we'll end up dealing
747
- * only with a window bounded by the highlighted elements:
748
- *
749
- * [null, null, VNode1 , ... , VNode2, null, null]
750
- * ^^^^^^ ^^^^^^
751
- *
752
- * 2. Check to see if the elements at the head and tail positions are equal
753
- * across the windows. This will basically detect elements which haven't
754
- * been added, removed, or changed position, i.e. if you had the following
755
- * VNode elements (represented as HTML):
756
- *
757
- * oldVNode: `<div><p><span>HEY</span></p></div>`
758
- * newVNode: `<div><p><span>THERE</span></p></div>`
759
- *
760
- * Then when comparing the children of the `<div>` tag we check the equality
761
- * of the VNodes corresponding to the `<p>` tags and, since they are the
762
- * same tag in the same position, we'd be able to avoid completely
763
- * re-rendering the subtree under them with a new DOM element and would just
764
- * call out to `patch` to handle reconciling their children and so on.
765
- *
766
- * 3. Check, for both windows, to see if the element at the beginning of the
767
- * window corresponds to the element at the end of the other window. This is
768
- * a heuristic which will let us identify _some_ situations in which
769
- * elements have changed position, for instance it _should_ detect that the
770
- * children nodes themselves have not changed but merely moved in the
771
- * following example:
772
- *
773
- * oldVNode: `<div><element-one /><element-two /></div>`
774
- * newVNode: `<div><element-two /><element-one /></div>`
775
- *
776
- * If we find cases like this then we also need to move the concrete DOM
777
- * elements corresponding to the moved children to write the re-order to the
778
- * DOM.
779
- *
780
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
781
- * nodes in the old children which have the same key as the first element in
782
- * our window on the new children. If we find such a node we handle calling
783
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
784
- * what we find.
785
- *
786
- * Finally, once we've narrowed our 'windows' to the point that either of them
787
- * collapse (i.e. they have length 0) we then handle any remaining VNode
788
- * insertion or deletion that needs to happen to get a DOM state that correctly
789
- * reflects the new child VNodes. If, for instance, after our window on the old
790
- * children has collapsed we still have more nodes on the new children that
791
- * we haven't dealt with yet then we need to add them, or if the new children
792
- * collapse but we still have unhandled _old_ children then we need to make
793
- * sure the corresponding DOM nodes are removed.
794
- *
795
- * @param parentElm the node into which the parent VNode is rendered
796
- * @param oldCh the old children of the parent node
797
- * @param newVNode the new VNode which will replace the parent
798
- * @param newCh the new children of the parent node
799
- * @param isInitialRender whether or not this is the first render of the vdom
800
- */
801
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
802
- let oldStartIdx = 0;
803
- let newStartIdx = 0;
804
- let idxInOld = 0;
805
- let i = 0;
806
- let oldEndIdx = oldCh.length - 1;
807
- let oldStartVnode = oldCh[0];
808
- let oldEndVnode = oldCh[oldEndIdx];
809
- let newEndIdx = newCh.length - 1;
810
- let newStartVnode = newCh[0];
811
- let newEndVnode = newCh[newEndIdx];
812
- let node;
813
- let elmToMove;
814
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
815
- if (oldStartVnode == null) {
816
- // VNode might have been moved left
817
- oldStartVnode = oldCh[++oldStartIdx];
818
- }
819
- else if (oldEndVnode == null) {
820
- oldEndVnode = oldCh[--oldEndIdx];
821
- }
822
- else if (newStartVnode == null) {
823
- newStartVnode = newCh[++newStartIdx];
824
- }
825
- else if (newEndVnode == null) {
826
- newEndVnode = newCh[--newEndIdx];
827
- }
828
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
829
- // if the start nodes are the same then we should patch the new VNode
830
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
831
- // indices to reflect that. We don't need to move any DOM Nodes around
832
- // since things are matched up in order.
833
- patch(oldStartVnode, newStartVnode, isInitialRender);
834
- oldStartVnode = oldCh[++oldStartIdx];
835
- newStartVnode = newCh[++newStartIdx];
836
- }
837
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
838
- // likewise, if the end nodes are the same we patch new onto old and
839
- // decrement our end indices, and also likewise in this case we don't
840
- // need to move any DOM Nodes.
841
- patch(oldEndVnode, newEndVnode, isInitialRender);
842
- oldEndVnode = oldCh[--oldEndIdx];
843
- newEndVnode = newCh[--newEndIdx];
844
- }
845
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
846
- patch(oldStartVnode, newEndVnode, isInitialRender);
847
- // We need to move the element for `oldStartVnode` into a position which
848
- // will be appropriate for `newEndVnode`. For this we can use
849
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
850
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
851
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
852
- //
853
- // <old-start-node />
854
- // <some-intervening-node />
855
- // <old-end-node />
856
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
857
- // <next-sibling />
858
- //
859
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
860
- // the node for `oldStartVnode` at the end of the children of
861
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
862
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
863
- // append it to the children of the parent element.
864
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
865
- oldStartVnode = oldCh[++oldStartIdx];
866
- newEndVnode = newCh[--newEndIdx];
867
- }
868
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
869
- patch(oldEndVnode, newStartVnode, isInitialRender);
870
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
871
- // the same node, so since we're here we know that they are not. Thus we
872
- // can move the element for `oldEndVnode` _before_ the element for
873
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
874
- // future.
875
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
876
- oldEndVnode = oldCh[--oldEndIdx];
877
- newStartVnode = newCh[++newStartIdx];
878
- }
879
- else {
880
- // Here we do some checks to match up old and new nodes based on the
881
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
882
- // in the JSX for a DOM element in the implementation of a Stencil
883
- // component.
884
- //
885
- // First we check to see if there are any nodes in the array of old
886
- // children which have the same key as the first node in the new
887
- // children.
888
- idxInOld = -1;
889
- {
890
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
891
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
892
- idxInOld = i;
893
- break;
894
- }
895
- }
896
- }
897
- if (idxInOld >= 0) {
898
- // We found a node in the old children which matches up with the first
899
- // node in the new children! So let's deal with that
900
- elmToMove = oldCh[idxInOld];
901
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
902
- // the tag doesn't match so we'll need a new DOM element
903
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
904
- }
905
- else {
906
- patch(elmToMove, newStartVnode, isInitialRender);
907
- // invalidate the matching old node so that we won't try to update it
908
- // again later on
909
- oldCh[idxInOld] = undefined;
910
- node = elmToMove.$elm$;
911
- }
912
- newStartVnode = newCh[++newStartIdx];
913
- }
914
- else {
915
- // We either didn't find an element in the old children that matches
916
- // the key of the first new child OR the build is not using `key`
917
- // attributes at all. In either case we need to create a new element
918
- // for the new node.
919
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
920
- newStartVnode = newCh[++newStartIdx];
921
- }
922
- if (node) {
923
- // if we created a new node then handle inserting it to the DOM
924
- {
925
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
926
- }
927
- }
928
- }
929
- }
930
- if (oldStartIdx > oldEndIdx) {
931
- // we have some more new nodes to add which don't match up with old nodes
932
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
933
- }
934
- else if (newStartIdx > newEndIdx) {
935
- // there are nodes in the `oldCh` array which no longer correspond to nodes
936
- // in the new array, so lets remove them (which entails cleaning up the
937
- // relevant DOM nodes)
938
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
939
- }
940
- };
941
- /**
942
- * Compare two VNodes to determine if they are the same
943
- *
944
- * **NB**: This function is an equality _heuristic_ based on the available
945
- * information set on the two VNodes and can be misleading under certain
946
- * circumstances. In particular, if the two nodes do not have `key` attrs
947
- * (available under `$key$` on VNodes) then the function falls back on merely
948
- * checking that they have the same tag.
949
- *
950
- * So, in other words, if `key` attrs are not set on VNodes which may be
951
- * changing order within a `children` array or something along those lines then
952
- * we could obtain a false negative and then have to do needless re-rendering
953
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
954
- *
955
- * @param leftVNode the first VNode to check
956
- * @param rightVNode the second VNode to check
957
- * @param isInitialRender whether or not this is the first render of the vdom
958
- * @returns whether they're equal or not
959
- */
960
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
961
- // compare if two vnode to see if they're "technically" the same
962
- // need to have the same element tag, and same key to be the same
963
- if (leftVNode.$tag$ === rightVNode.$tag$) {
964
- // this will be set if JSX tags in the build have `key` attrs set on them
965
- // we only want to check this if we're not on the first render since on
966
- // first render `leftVNode.$key$` will always be `null`, so we can be led
967
- // astray and, for instance, accidentally delete a DOM node that we want to
968
- // keep around.
969
- if (!isInitialRender) {
970
- return leftVNode.$key$ === rightVNode.$key$;
971
- }
972
- return true;
973
- }
974
- return false;
975
- };
976
- /**
977
- * Handle reconciling an outdated VNode with a new one which corresponds to
978
- * it. This function handles flushing updates to the DOM and reconciling the
979
- * children of the two nodes (if any).
980
- *
981
- * @param oldVNode an old VNode whose DOM element and children we want to update
982
- * @param newVNode a new VNode representing an updated version of the old one
983
- * @param isInitialRender whether or not this is the first render of the vdom
984
- */
985
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
986
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
987
- const oldChildren = oldVNode.$children$;
988
- const newChildren = newVNode.$children$;
989
- const tag = newVNode.$tag$;
990
- const text = newVNode.$text$;
991
- if (text === null) {
992
- {
993
- // test if we're rendering an svg element, or still rendering nodes inside of one
994
- // only add this to the when the compiler sees we're using an svg somewhere
995
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
996
- }
997
- {
998
- if (tag === 'slot' && !useNativeShadowDom) ;
999
- else {
1000
- // either this is the first render of an element OR it's an update
1001
- // AND we already know it's possible it could have changed
1002
- // this updates the element's css classes, attrs, props, listeners, etc.
1003
- updateElement(oldVNode, newVNode, isSvgMode);
1004
- }
1005
- }
1006
- if (oldChildren !== null && newChildren !== null) {
1007
- // looks like there's child vnodes for both the old and new vnodes
1008
- // so we need to call `updateChildren` to reconcile them
1009
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1010
- }
1011
- else if (newChildren !== null) {
1012
- // no old child vnodes, but there are new child vnodes to add
1013
- if (oldVNode.$text$ !== null) {
1014
- // the old vnode was text, so be sure to clear it out
1015
- elm.textContent = '';
1016
- }
1017
- // add the new vnode children
1018
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1019
- }
1020
- else if (oldChildren !== null) {
1021
- // no new child vnodes, but there are old child vnodes to remove
1022
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1023
- }
1024
- if (isSvgMode && tag === 'svg') {
1025
- isSvgMode = false;
1026
- }
1027
- }
1028
- else if (oldVNode.$text$ !== text) {
1029
- // update the text content for the text only vnode
1030
- // and also only if the text is different than before
1031
- elm.data = text;
1032
- }
1033
- };
1034
- /**
1035
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1036
- * them with `null`. This signals that the DOM element corresponding to the VDom
1037
- * node has been removed from the DOM.
1038
- *
1039
- * @param vNode a virtual DOM node
1040
- */
1041
- const nullifyVNodeRefs = (vNode) => {
1042
- {
1043
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1044
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1045
- }
1046
- };
1047
- /**
1048
- * The main entry point for Stencil's virtual DOM-based rendering engine
1049
- *
1050
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1051
- * function will handle creating a virtual DOM tree with a single root, patching
1052
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1053
- * relocation, and reflecting attributes.
1054
- *
1055
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1056
- * the DOM node into which it should be rendered.
1057
- * @param renderFnResults the virtual DOM nodes to be rendered
1058
- * @param isInitialLoad whether or not this is the first call after page load
1059
- */
1060
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1061
- const hostElm = hostRef.$hostElement$;
1062
- const cmpMeta = hostRef.$cmpMeta$;
1063
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1064
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1065
- // we need to call `h` again to wrap the children of our component in a
1066
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1067
- // implicitly that the top-level vdom node is 1) an only child and 2)
1068
- // contains attrs that need to be set on the host element.
1069
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1070
- hostTagName = hostElm.tagName;
1071
- if (cmpMeta.$attrsToReflect$) {
1072
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1073
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1074
- }
1075
- // On the first render and *only* on the first render we want to check for
1076
- // any attributes set on the host element which are also set on the vdom
1077
- // node. If we find them, we override the value on the VDom node attrs with
1078
- // the value from the host element, which allows developers building apps
1079
- // with Stencil components to override e.g. the `role` attribute on a
1080
- // component even if it's already set on the `Host`.
1081
- if (isInitialLoad && rootVnode.$attrs$) {
1082
- for (const key of Object.keys(rootVnode.$attrs$)) {
1083
- // We have a special implementation in `setAccessor` for `style` and
1084
- // `class` which reconciles values coming from the VDom with values
1085
- // already present on the DOM element, so we don't want to override those
1086
- // attributes on the VDom tree with values from the host element if they
1087
- // are present.
1088
- //
1089
- // Likewise, `ref` and `key` are special internal values for the Stencil
1090
- // runtime and we don't want to override those either.
1091
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1092
- rootVnode.$attrs$[key] = hostElm[key];
1093
- }
1094
- }
1095
- }
1096
- rootVnode.$tag$ = null;
1097
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1098
- hostRef.$vnode$ = rootVnode;
1099
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1100
- {
1101
- scopeId = hostElm['s-sc'];
1102
- }
1103
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1104
- // synchronous patch
1105
- patch(oldVNode, rootVnode, isInitialLoad);
1106
- };
1107
- const attachToAncestor = (hostRef, ancestorComponent) => {
1108
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1109
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1110
- }
1111
- };
1112
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1113
- {
1114
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1115
- }
1116
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1117
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1118
- return;
1119
- }
1120
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1121
- // there is no ancestor component or the ancestor component
1122
- // has already fired off its lifecycle update then
1123
- // fire off the initial update
1124
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1125
- return writeTask(dispatch) ;
1126
- };
1127
- /**
1128
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1129
- * component lifecycle methods like `componentWillLoad` as well as
1130
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1131
- *
1132
- * @param hostRef a reference to a host DOM node
1133
- * @param isInitialLoad whether we're on the initial load or not
1134
- * @returns an empty Promise which is used to enqueue a series of operations for
1135
- * the component
1136
- */
1137
- const dispatchHooks = (hostRef, isInitialLoad) => {
1138
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1139
- const instance = hostRef.$lazyInstance$ ;
1140
- // We're going to use this variable together with `enqueue` to implement a
1141
- // little promise-based queue. We start out with it `undefined`. When we add
1142
- // the first function to the queue we'll set this variable to be that
1143
- // function's return value. When we attempt to add subsequent values to the
1144
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1145
- // the new function off of that `Promise` using `.then()`. This will give our
1146
- // queue two nice properties:
1147
- //
1148
- // 1. If all functions added to the queue are synchronous they'll be called
1149
- // synchronously right away.
1150
- // 2. If all functions added to the queue are asynchronous they'll all be
1151
- // called in order after `dispatchHooks` exits.
1152
- let maybePromise;
1153
- if (isInitialLoad) {
1154
- {
1155
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1156
- if (hostRef.$queuedListeners$) {
1157
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1158
- hostRef.$queuedListeners$ = undefined;
1159
- }
1160
- }
1161
- {
1162
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1163
- // whatever's going on in that `Promise` before we launch into
1164
- // rendering the component, doing other lifecycle stuff, etc. So
1165
- // in that case we assign the returned promise to the variable we
1166
- // declared above to hold a possible 'queueing' Promise
1167
- maybePromise = safeCall(instance, 'componentWillLoad');
1168
- }
1169
- }
1170
- {
1171
- maybePromise = enqueue(maybePromise, () => safeCall(instance, 'componentWillRender'));
1172
- }
1173
- endSchedule();
1174
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1175
- };
1176
- /**
1177
- * This function uses a Promise to implement a simple first-in, first-out queue
1178
- * of functions to be called.
1179
- *
1180
- * The queue is ordered on the basis of the first argument. If it's
1181
- * `undefined`, then nothing is on the queue yet, so the provided function can
1182
- * be called synchronously (although note that this function may return a
1183
- * `Promise`). The idea is that then the return value of that enqueueing
1184
- * operation is kept around, so that if it was a `Promise` then subsequent
1185
- * functions can be enqueued by calling this function again with that `Promise`
1186
- * as the first argument.
1187
- *
1188
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1189
- * @param fn a function to enqueue
1190
- * @returns either a `Promise` or the return value of the provided function
1191
- */
1192
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1193
- /**
1194
- * Check that a value is a `Promise`. To check, we first see if the value is an
1195
- * instance of the `Promise` global. In a few circumstances, in particular if
1196
- * the global has been overwritten, this is could be misleading, so we also do
1197
- * a little 'duck typing' check to see if the `.then` property of the value is
1198
- * defined and a function.
1199
- *
1200
- * @param maybePromise it might be a promise!
1201
- * @returns whether it is or not
1202
- */
1203
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1204
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1205
- /**
1206
- * Update a component given reference to its host elements and so on.
1207
- *
1208
- * @param hostRef an object containing references to the element's host node,
1209
- * VDom nodes, and other metadata
1210
- * @param instance a reference to the underlying host element where it will be
1211
- * rendered
1212
- * @param isInitialLoad whether or not this function is being called as part of
1213
- * the first render cycle
1214
- */
1215
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1216
- var _a;
1217
- const elm = hostRef.$hostElement$;
1218
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1219
- const rc = elm['s-rc'];
1220
- if (isInitialLoad) {
1221
- // DOM WRITE!
1222
- attachStyles(hostRef);
1223
- }
1224
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1225
- {
1226
- callRender(hostRef, instance, elm, isInitialLoad);
1227
- }
1228
- if (rc) {
1229
- // ok, so turns out there are some child host elements
1230
- // waiting on this parent element to load
1231
- // let's fire off all update callbacks waiting
1232
- rc.map((cb) => cb());
1233
- elm['s-rc'] = undefined;
1234
- }
1235
- endRender();
1236
- endUpdate();
1237
- {
1238
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1239
- const postUpdate = () => postUpdateComponent(hostRef);
1240
- if (childrenPromises.length === 0) {
1241
- postUpdate();
1242
- }
1243
- else {
1244
- Promise.all(childrenPromises).then(postUpdate);
1245
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1246
- childrenPromises.length = 0;
1247
- }
1248
- }
1249
- };
1250
- /**
1251
- * Handle making the call to the VDom renderer with the proper context given
1252
- * various build variables
1253
- *
1254
- * @param hostRef an object containing references to the element's host node,
1255
- * VDom nodes, and other metadata
1256
- * @param instance a reference to the underlying host element where it will be
1257
- * rendered
1258
- * @param elm the Host element for the component
1259
- * @param isInitialLoad whether or not this function is being called as part of
1260
- * @returns an empty promise
1261
- */
1262
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1263
- try {
1264
- /**
1265
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1266
- * method, so we can call the method immediately. If not, check before calling it.
1267
- */
1268
- instance = instance.render() ;
1269
- {
1270
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1271
- }
1272
- {
1273
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1274
- }
1275
- {
1276
- {
1277
- // looks like we've got child nodes to render into this host element
1278
- // or we need to update the css class/attrs on the host element
1279
- // DOM WRITE!
1280
- {
1281
- renderVdom(hostRef, instance, isInitialLoad);
1282
- }
1283
- }
1284
- }
1285
- }
1286
- catch (e) {
1287
- consoleError(e, hostRef.$hostElement$);
1288
- }
1289
- return null;
1290
- };
1291
- const postUpdateComponent = (hostRef) => {
1292
- const tagName = hostRef.$cmpMeta$.$tagName$;
1293
- const elm = hostRef.$hostElement$;
1294
- const endPostUpdate = createTime('postUpdate', tagName);
1295
- const instance = hostRef.$lazyInstance$ ;
1296
- const ancestorComponent = hostRef.$ancestorComponent$;
1297
- {
1298
- safeCall(instance, 'componentDidRender');
1299
- }
1300
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1301
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1302
- {
1303
- // DOM WRITE!
1304
- addHydratedFlag(elm);
1305
- }
1306
- {
1307
- safeCall(instance, 'componentDidLoad');
1308
- }
1309
- endPostUpdate();
1310
- {
1311
- hostRef.$onReadyResolve$(elm);
1312
- if (!ancestorComponent) {
1313
- appDidLoad();
1314
- }
1315
- }
1316
- }
1317
- else {
1318
- endPostUpdate();
1319
- }
1320
- {
1321
- hostRef.$onInstanceResolve$(elm);
1322
- }
1323
- // load events fire from bottom to top
1324
- // the deepest elements load first then bubbles up
1325
- {
1326
- if (hostRef.$onRenderResolve$) {
1327
- hostRef.$onRenderResolve$();
1328
- hostRef.$onRenderResolve$ = undefined;
1329
- }
1330
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1331
- nextTick(() => scheduleUpdate(hostRef, false));
1332
- }
1333
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1334
- }
1335
- // ( •_•)
1336
- // ( •_•)>⌐■-■
1337
- // (⌐■_■)
1338
- };
1339
- const appDidLoad = (who) => {
1340
- // on appload
1341
- // we have finish the first big initial render
1342
- {
1343
- addHydratedFlag(doc.documentElement);
1344
- }
1345
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1346
- };
1347
- /**
1348
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1349
- * e.g. custom element node. If a build figures out that e.g. no component
1350
- * has a `componentDidLoad` method, the instance method gets removed from the
1351
- * output bundle and this function returns `undefined`.
1352
- * @param instance any object that may or may not contain methods
1353
- * @param method method name
1354
- * @param arg single arbitrary argument
1355
- * @returns result of method call if it exists, otherwise `undefined`
1356
- */
1357
- const safeCall = (instance, method, arg) => {
1358
- if (instance && instance[method]) {
1359
- try {
1360
- return instance[method](arg);
1361
- }
1362
- catch (e) {
1363
- consoleError(e);
1364
- }
1365
- }
1366
- return undefined;
1367
- };
1368
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1369
- ;
1370
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1371
- const setValue = (ref, propName, newVal, cmpMeta) => {
1372
- // check our new property value against our internal value
1373
- const hostRef = getHostRef(ref);
1374
- const elm = hostRef.$hostElement$ ;
1375
- const oldVal = hostRef.$instanceValues$.get(propName);
1376
- const flags = hostRef.$flags$;
1377
- const instance = hostRef.$lazyInstance$ ;
1378
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1379
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1380
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1381
- const didValueChange = newVal !== oldVal && !areBothNaN;
1382
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1383
- // gadzooks! the property's value has changed!!
1384
- // set our new value!
1385
- hostRef.$instanceValues$.set(propName, newVal);
1386
- if (instance) {
1387
- // get an array of method names of watch functions to call
1388
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1389
- const watchMethods = cmpMeta.$watchers$[propName];
1390
- if (watchMethods) {
1391
- // this instance is watching for when this property changed
1392
- watchMethods.map((watchMethodName) => {
1393
- try {
1394
- // fire off each of the watch methods that are watching this property
1395
- instance[watchMethodName](newVal, oldVal, propName);
1396
- }
1397
- catch (e) {
1398
- consoleError(e, elm);
1399
- }
1400
- });
1401
- }
1402
- }
1403
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1404
- // looks like this value actually changed, so we've got work to do!
1405
- // but only if we've already rendered, otherwise just chill out
1406
- // queue that we need to do an update, but don't worry about queuing
1407
- // up millions cuz this function ensures it only runs once
1408
- scheduleUpdate(hostRef, false);
1409
- }
1410
- }
1411
- }
1412
- };
1413
- /**
1414
- * Attach a series of runtime constructs to a compiled Stencil component
1415
- * constructor, including getters and setters for the `@Prop` and `@State`
1416
- * decorators, callbacks for when attributes change, and so on.
1417
- *
1418
- * @param Cstr the constructor for a component that we need to process
1419
- * @param cmpMeta metadata collected previously about the component
1420
- * @param flags a number used to store a series of bit flags
1421
- * @returns a reference to the same constructor passed in (but now mutated)
1422
- */
1423
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1424
- var _a;
1425
- const prototype = Cstr.prototype;
1426
- if (cmpMeta.$members$) {
1427
- if (Cstr.watchers) {
1428
- cmpMeta.$watchers$ = Cstr.watchers;
1429
- }
1430
- // It's better to have a const than two Object.entries()
1431
- const members = Object.entries(cmpMeta.$members$);
1432
- members.map(([memberName, [memberFlags]]) => {
1433
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1434
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1435
- // proxyComponent - prop
1436
- Object.defineProperty(prototype, memberName, {
1437
- get() {
1438
- // proxyComponent, get value
1439
- return getValue(this, memberName);
1440
- },
1441
- set(newValue) {
1442
- // proxyComponent, set value
1443
- setValue(this, memberName, newValue, cmpMeta);
1444
- },
1445
- configurable: true,
1446
- enumerable: true,
1447
- });
1448
- }
1449
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1450
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1451
- // proxyComponent - method
1452
- Object.defineProperty(prototype, memberName, {
1453
- value(...args) {
1454
- var _a;
1455
- const ref = getHostRef(this);
1456
- return (_a = ref === null || ref === void 0 ? void 0 : ref.$onInstancePromise$) === null || _a === void 0 ? void 0 : _a.then(() => { var _a; return (_a = ref.$lazyInstance$) === null || _a === void 0 ? void 0 : _a[memberName](...args); });
1457
- },
1458
- });
1459
- }
1460
- });
1461
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1462
- const attrNameToPropName = new Map();
1463
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1464
- plt.jmp(() => {
1465
- var _a;
1466
- const propName = attrNameToPropName.get(attrName);
1467
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1468
- // in the case where an attribute was set inline.
1469
- // ```html
1470
- // <my-component some-attribute="some-value"></my-component>
1471
- // ```
1472
- //
1473
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1474
- // programmatically changes it before it has been upgraded as shown below:
1475
- //
1476
- // ```html
1477
- // <!-- this component has _not_ been upgraded yet -->
1478
- // <my-component id="test" some-attribute="some-value"></my-component>
1479
- // <script>
1480
- // // grab non-upgraded component
1481
- // el = document.querySelector("#test");
1482
- // el.someAttribute = "another-value";
1483
- // // upgrade component
1484
- // customElements.define('my-component', MyComponent);
1485
- // </script>
1486
- // ```
1487
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1488
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1489
- // to the value that was set inline i.e. "some-value" from above example. When
1490
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1491
- //
1492
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1493
- // by connectedCallback as this attributeChangedCallback will not fire.
1494
- //
1495
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1496
- //
1497
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1498
- // properties here given that this goes against best practices outlined here
1499
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1500
- if (this.hasOwnProperty(propName)) {
1501
- newValue = this[propName];
1502
- delete this[propName];
1503
- }
1504
- else if (prototype.hasOwnProperty(propName) &&
1505
- typeof this[propName] === 'number' &&
1506
- this[propName] == newValue) {
1507
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1508
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1509
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1510
- return;
1511
- }
1512
- else if (propName == null) {
1513
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1514
- // on a vanilla web component
1515
- const hostRef = getHostRef(this);
1516
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1517
- // We only want to trigger the callback(s) if:
1518
- // 1. The instance is ready
1519
- // 2. The watchers are ready
1520
- // 3. The value has changed
1521
- if (flags &&
1522
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1523
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1524
- newValue !== oldValue) {
1525
- const instance = hostRef.$lazyInstance$ ;
1526
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1527
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1528
- if (instance[callbackName] != null) {
1529
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1530
- }
1531
- });
1532
- }
1533
- return;
1534
- }
1535
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1536
- });
1537
- };
1538
- // Create an array of attributes to observe
1539
- // This list in comprised of all strings used within a `@Watch()` decorator
1540
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1541
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1542
- // an invalid attribute.
1543
- Cstr.observedAttributes = Array.from(new Set([
1544
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1545
- ...members
1546
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1547
- .map(([propName, m]) => {
1548
- var _a;
1549
- const attrName = m[1] || propName;
1550
- attrNameToPropName.set(attrName, propName);
1551
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1552
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
1553
- }
1554
- return attrName;
1555
- }),
1556
- ]));
1557
- }
1558
- }
1559
- return Cstr;
1560
- };
1561
- /**
1562
- * Initialize a Stencil component given a reference to its host element, its
1563
- * runtime bookkeeping data structure, runtime metadata about the component,
1564
- * and (optionally) an HMR version ID.
1565
- *
1566
- * @param elm a host element
1567
- * @param hostRef the element's runtime bookkeeping object
1568
- * @param cmpMeta runtime metadata for the Stencil component
1569
- * @param hmrVersionId an (optional) HMR version ID
1570
- */
1571
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1572
- let Cstr;
1573
- // initializeComponent
1574
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1575
- // Let the runtime know that the component has been initialized
1576
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1577
- const bundleId = cmpMeta.$lazyBundleId$;
1578
- if (bundleId) {
1579
- // lazy loaded components
1580
- // request the component's implementation to be
1581
- // wired up with the host element
1582
- Cstr = loadModule(cmpMeta);
1583
- if (Cstr.then) {
1584
- // Await creates a micro-task avoid if possible
1585
- const endLoad = uniqueTime();
1586
- Cstr = await Cstr;
1587
- endLoad();
1588
- }
1589
- if (!Cstr.isProxied) {
1590
- // we've never proxied this Constructor before
1591
- // let's add the getters/setters to its prototype before
1592
- // the first time we create an instance of the implementation
1593
- {
1594
- cmpMeta.$watchers$ = Cstr.watchers;
1595
- }
1596
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1597
- Cstr.isProxied = true;
1598
- }
1599
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1600
- // ok, time to construct the instance
1601
- // but let's keep track of when we start and stop
1602
- // so that the getters/setters don't incorrectly step on data
1603
- {
1604
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1605
- }
1606
- // construct the lazy-loaded component implementation
1607
- // passing the hostRef is very important during
1608
- // construction in order to directly wire together the
1609
- // host element and the lazy-loaded instance
1610
- try {
1611
- new Cstr(hostRef);
1612
- }
1613
- catch (e) {
1614
- consoleError(e);
1615
- }
1616
- {
1617
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1618
- }
1619
- {
1620
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1621
- }
1622
- endNewInstance();
1623
- fireConnectedCallback(hostRef.$lazyInstance$);
1624
- }
1625
- else {
1626
- // sync constructor component
1627
- Cstr = elm.constructor;
1628
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
1629
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
1630
- // Stencil has completed instantiating the component.
1631
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
1632
- }
1633
- if (Cstr.style) {
1634
- // this component has styles but we haven't registered them yet
1635
- let style = Cstr.style;
1636
- const scopeId = getScopeId(cmpMeta);
1637
- if (!styles.has(scopeId)) {
1638
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1639
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1640
- endRegisterStyles();
1641
- }
1642
- }
1643
- }
1644
- // we've successfully created a lazy instance
1645
- const ancestorComponent = hostRef.$ancestorComponent$;
1646
- const schedule = () => scheduleUpdate(hostRef, true);
1647
- if (ancestorComponent && ancestorComponent['s-rc']) {
1648
- // this is the initial load and this component it has an ancestor component
1649
- // but the ancestor component has NOT fired its will update lifecycle yet
1650
- // so let's just cool our jets and wait for the ancestor to continue first
1651
- // this will get fired off when the ancestor component
1652
- // finally gets around to rendering its lazy self
1653
- // fire off the initial update
1654
- ancestorComponent['s-rc'].push(schedule);
1655
- }
1656
- else {
1657
- schedule();
1658
- }
1659
- };
1660
- const fireConnectedCallback = (instance) => {
1661
- {
1662
- safeCall(instance, 'connectedCallback');
1663
- }
1664
- };
1665
- const connectedCallback = (elm) => {
1666
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1667
- const hostRef = getHostRef(elm);
1668
- const cmpMeta = hostRef.$cmpMeta$;
1669
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1670
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1671
- // first time this component has connected
1672
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1673
- {
1674
- // find the first ancestor component (if there is one) and register
1675
- // this component as one of the actively loading child components for its ancestor
1676
- let ancestorComponent = elm;
1677
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1678
- // climb up the ancestors looking for the first
1679
- // component that hasn't finished its lifecycle update yet
1680
- if (ancestorComponent['s-p']) {
1681
- // we found this components first ancestor component
1682
- // keep a reference to this component's ancestor component
1683
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1684
- break;
1685
- }
1686
- }
1687
- }
1688
- // Lazy properties
1689
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1690
- if (cmpMeta.$members$) {
1691
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1692
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1693
- const value = elm[memberName];
1694
- delete elm[memberName];
1695
- elm[memberName] = value;
1696
- }
1697
- });
1698
- }
1699
- {
1700
- initializeComponent(elm, hostRef, cmpMeta);
1701
- }
1702
- }
1703
- else {
1704
- // not the first time this has connected
1705
- // reattach any event listeners to the host
1706
- // since they would have been removed when disconnected
1707
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1708
- // fire off connectedCallback() on component instance
1709
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
1710
- fireConnectedCallback(hostRef.$lazyInstance$);
1711
- }
1712
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1713
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
1714
- }
1715
- }
1716
- endConnected();
1717
- }
1718
- };
1719
- const disconnectInstance = (instance) => {
1720
- {
1721
- safeCall(instance, 'disconnectedCallback');
1722
- }
1723
- };
1724
- const disconnectedCallback = async (elm) => {
1725
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1726
- const hostRef = getHostRef(elm);
1727
- {
1728
- if (hostRef.$rmListeners$) {
1729
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1730
- hostRef.$rmListeners$ = undefined;
1731
- }
1732
- }
1733
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
1734
- disconnectInstance(hostRef.$lazyInstance$);
1735
- }
1736
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1737
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
1738
- }
1739
- }
1740
- };
1741
- const bootstrapLazy = (lazyBundles, options = {}) => {
1742
- var _a;
1743
- const endBootstrap = createTime();
1744
- const cmpTags = [];
1745
- const exclude = options.exclude || [];
1746
- const customElements = win.customElements;
1747
- const head = doc.head;
1748
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1749
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
1750
- const deferredConnectedCallbacks = [];
1751
- let appLoadFallback;
1752
- let isBootstrapping = true;
1753
- Object.assign(plt, options);
1754
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1755
- let hasSlotRelocation = false;
1756
- lazyBundles.map((lazyBundle) => {
1757
- lazyBundle[1].map((compactMeta) => {
1758
- var _a;
1759
- const cmpMeta = {
1760
- $flags$: compactMeta[0],
1761
- $tagName$: compactMeta[1],
1762
- $members$: compactMeta[2],
1763
- $listeners$: compactMeta[3],
1764
- };
1765
- // Check if we are using slots outside the shadow DOM in this component.
1766
- // We'll use this information later to add styles for `slot-fb` elements
1767
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
1768
- hasSlotRelocation = true;
1769
- }
1770
- {
1771
- cmpMeta.$members$ = compactMeta[2];
1772
- }
1773
- {
1774
- cmpMeta.$listeners$ = compactMeta[3];
1775
- }
1776
- {
1777
- cmpMeta.$attrsToReflect$ = [];
1778
- }
1779
- {
1780
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
1781
- }
1782
- const tagName = cmpMeta.$tagName$;
1783
- const HostElement = class extends HTMLElement {
1784
- // StencilLazyHost
1785
- constructor(self) {
1786
- // @ts-ignore
1787
- super(self);
1788
- self = this;
1789
- registerHost(self, cmpMeta);
1790
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1791
- // this component is using shadow dom
1792
- // and this browser supports shadow dom
1793
- // add the read-only property "shadowRoot" to the host element
1794
- // adding the shadow root build conditionals to minimize runtime
1795
- {
1796
- {
1797
- self.attachShadow({ mode: 'open' });
1798
- }
1799
- }
1800
- }
1801
- }
1802
- connectedCallback() {
1803
- if (appLoadFallback) {
1804
- clearTimeout(appLoadFallback);
1805
- appLoadFallback = null;
1806
- }
1807
- if (isBootstrapping) {
1808
- // connectedCallback will be processed once all components have been registered
1809
- deferredConnectedCallbacks.push(this);
1810
- }
1811
- else {
1812
- plt.jmp(() => connectedCallback(this));
1813
- }
1814
- }
1815
- disconnectedCallback() {
1816
- plt.jmp(() => disconnectedCallback(this));
1817
- }
1818
- componentOnReady() {
1819
- return getHostRef(this).$onReadyPromise$;
1820
- }
1821
- };
1822
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1823
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1824
- cmpTags.push(tagName);
1825
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1826
- }
1827
- });
1828
- });
1829
- // Only bother generating CSS if we have components
1830
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
1831
- if (cmpTags.length > 0) {
1832
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
1833
- if (hasSlotRelocation) {
1834
- dataStyles.textContent += SLOT_FB_CSS;
1835
- }
1836
- // Add hydration styles
1837
- {
1838
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
1839
- }
1840
- // If we have styles, add them to the DOM
1841
- if (dataStyles.innerHTML.length) {
1842
- dataStyles.setAttribute('data-styles', '');
1843
- // Apply CSP nonce to the style tag if it exists
1844
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1845
- if (nonce != null) {
1846
- dataStyles.setAttribute('nonce', nonce);
1847
- }
1848
- // Insert the styles into the document head
1849
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
1850
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
1851
- }
1852
- }
1853
- // Process deferred connectedCallbacks now all components have been registered
1854
- isBootstrapping = false;
1855
- if (deferredConnectedCallbacks.length) {
1856
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1857
- }
1858
- else {
1859
- {
1860
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1861
- }
1862
- }
1863
- // Fallback appLoad event
1864
- endBootstrap();
1865
- };
1866
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1867
- if (listeners) {
1868
- listeners.map(([flags, name, method]) => {
1869
- const target = getHostListenerTarget(elm, flags) ;
1870
- const handler = hostListenerProxy(hostRef, method);
1871
- const opts = hostListenerOpts(flags);
1872
- plt.ael(target, name, handler, opts);
1873
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1874
- });
1875
- }
1876
- };
1877
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
1878
- try {
1879
- {
1880
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1881
- // instance is ready, let's call it's member method for this event
1882
- hostRef.$lazyInstance$[methodName](ev);
1883
- }
1884
- else {
1885
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1886
- }
1887
- }
1888
- }
1889
- catch (e) {
1890
- consoleError(e);
1891
- }
1892
- };
1893
- const getHostListenerTarget = (elm, flags) => {
1894
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1895
- return win;
1896
- return elm;
1897
- };
1898
- // prettier-ignore
1899
- const hostListenerOpts = (flags) => supportsListenerOptions
1900
- ? ({
1901
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
1902
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
1903
- })
1904
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1905
- /**
1906
- * Assigns the given value to the nonce property on the runtime platform object.
1907
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1908
- * @param nonce The value to be assigned to the platform nonce property.
1909
- * @returns void
1910
- */
1911
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1912
- /**
1913
- * A WeakMap mapping runtime component references to their corresponding host reference
1914
- * instances.
1915
- *
1916
- * **Note**: If we're in an HMR context we need to store a reference to this
1917
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
1918
- * to {@link d.HostRef} across HMR updates.
1919
- *
1920
- * This is necessary because when HMR updates for a component are processed by
1921
- * the browser-side dev server client the JS bundle for that component is
1922
- * re-fetched. Since the module containing {@link hostRefs} is included in
1923
- * that bundle, if we do not store a reference to it the new iteration of the
1924
- * component will not have access to the previous hostRef map, leading to a
1925
- * bug where the new version of the component cannot properly initialize.
1926
- */
1927
- const hostRefs = new WeakMap();
1928
- /**
1929
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
1930
- *
1931
- * @param ref the runtime ref of interest
1932
- * @returns the Host reference (if found) or undefined
1933
- */
1934
- const getHostRef = (ref) => hostRefs.get(ref);
1935
- /**
1936
- * Register a lazy instance with the {@link hostRefs} object so it's
1937
- * corresponding {@link d.HostRef} can be retrieved later.
1938
- *
1939
- * @param lazyInstance the lazy instance of interest
1940
- * @param hostRef that instances `HostRef` object
1941
- * @returns a reference to the host ref WeakMap
1942
- */
1943
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1944
- /**
1945
- * Register a host element for a Stencil component, setting up various metadata
1946
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
1947
- * metadata.
1948
- *
1949
- * @param hostElement the host element to register
1950
- * @param cmpMeta runtime metadata for that component
1951
- * @returns a reference to the host ref WeakMap
1952
- */
1953
- const registerHost = (hostElement, cmpMeta) => {
1954
- const hostRef = {
1955
- $flags$: 0,
1956
- $hostElement$: hostElement,
1957
- $cmpMeta$: cmpMeta,
1958
- $instanceValues$: new Map(),
1959
- };
1960
- {
1961
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1962
- }
1963
- {
1964
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1965
- hostElement['s-p'] = [];
1966
- hostElement['s-rc'] = [];
1967
- }
1968
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
1969
- return hostRefs.set(hostElement, hostRef);
1970
- };
1971
- const isMemberInElement = (elm, memberName) => memberName in elm;
1972
- const consoleError = (e, el) => (0, console.error)(e, el);
1973
- const cmpModules = /*@__PURE__*/ new Map();
1974
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1975
- // loadModuleImport
1976
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1977
- const bundleId = cmpMeta.$lazyBundleId$;
1978
- const module = cmpModules.get(bundleId) ;
1979
- if (module) {
1980
- return module[exportName];
1981
- }
1982
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1983
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1984
- /* @vite-ignore */
1985
- /* webpackInclude: /\.entry\.js$/ */
1986
- /* webpackExclude: /\.system\.entry\.js$/ */
1987
- /* webpackMode: "lazy" */
1988
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1989
- {
1990
- cmpModules.set(bundleId, importedModule);
1991
- }
1992
- return importedModule[exportName];
1993
- }, consoleError);
1994
- };
1995
- const styles = /*@__PURE__*/ new Map();
1996
- const win = typeof window !== 'undefined' ? window : {};
1997
- const doc = win.document || { head: {} };
1998
- const plt = {
1999
- $flags$: 0,
2000
- $resourcesUrl$: '',
2001
- jmp: (h) => h(),
2002
- raf: (h) => requestAnimationFrame(h),
2003
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2004
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2005
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2006
- };
2007
- const supportsListenerOptions = /*@__PURE__*/ (() => {
2008
- let supportsListenerOptions = false;
2009
- try {
2010
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
2011
- get() {
2012
- supportsListenerOptions = true;
2013
- },
2014
- }));
2015
- }
2016
- catch (e) { }
2017
- return supportsListenerOptions;
2018
- })();
2019
- const promiseResolve = (v) => Promise.resolve(v);
2020
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2021
- try {
2022
- new CSSStyleSheet();
2023
- return typeof new CSSStyleSheet().replaceSync === 'function';
2024
- }
2025
- catch (e) { }
2026
- return false;
2027
- })()
2028
- ;
2029
- const queueDomReads = [];
2030
- const queueDomWrites = [];
2031
- const queueTask = (queue, write) => (cb) => {
2032
- queue.push(cb);
2033
- if (!queuePending) {
2034
- queuePending = true;
2035
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2036
- nextTick(flush);
2037
- }
2038
- else {
2039
- plt.raf(flush);
2040
- }
2041
- }
2042
- };
2043
- const consume = (queue) => {
2044
- for (let i = 0; i < queue.length; i++) {
2045
- try {
2046
- queue[i](performance.now());
2047
- }
2048
- catch (e) {
2049
- consoleError(e);
2050
- }
2051
- }
2052
- queue.length = 0;
2053
- };
2054
- const flush = () => {
2055
- // always force a bunch of medium callbacks to run, but still have
2056
- // a throttle on how many can run in a certain time
2057
- // DOM READS!!!
2058
- consume(queueDomReads);
2059
- // DOM WRITES!!!
2060
- {
2061
- consume(queueDomWrites);
2062
- if ((queuePending = queueDomReads.length > 0)) {
2063
- // still more to do yet, but we've run out of time
2064
- // let's let this thing cool off and try again in the next tick
2065
- plt.raf(flush);
2066
- }
2067
- }
2068
- };
2069
- const nextTick = (cb) => promiseResolve().then(cb);
2070
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2071
-
2072
- exports.Host = Host;
2073
- exports.bootstrapLazy = bootstrapLazy;
2074
- exports.createEvent = createEvent;
2075
- exports.getElement = getElement;
2076
- exports.h = h;
2077
- exports.promiseResolve = promiseResolve;
2078
- exports.registerInstance = registerInstance;
2079
- exports.setNonce = setNonce;
2080
-
2081
- //# sourceMappingURL=index-66a60071.js.map