proto-ikons-wc 0.0.145 → 0.0.147

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