proto-float-wc 0.1.0

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