@maggioli-design-system/mds-input-tip 1.0.0 → 1.1.1

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