@mapsindoors/map-template 1.95.0 → 1.95.2

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