@siemens/ix-icons 1.0.4 → 1.1.0-beta.0

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