@siemens/ix-icons 0.0.0-20240827131228 → 0.0.0-20250114162200

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