genesys-spark-chart-components 4.81.3 → 4.83.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 (58) hide show
  1. package/dist/cjs/{color-palette-313d94f7.js → color-palette-7ff76714.js} +6 -7
  2. package/dist/cjs/genesys-chart-webcomponents.cjs.js +9 -9
  3. package/dist/cjs/gux-chart-column-beta.cjs.entry.js +2 -2
  4. package/dist/cjs/gux-chart-donut-beta.cjs.entry.js +2 -2
  5. package/dist/cjs/gux-chart-line-beta.cjs.entry.js +2 -2
  6. package/dist/cjs/gux-chart-pie-beta.cjs.entry.js +2 -2
  7. package/dist/cjs/gux-chart-scatter-plot-beta.cjs.entry.js +2 -2
  8. package/dist/cjs/gux-visualization-beta.cjs.entry.js +4 -4
  9. package/dist/cjs/index-817704d9.js +1198 -0
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/collection/collection-manifest.json +2 -2
  12. package/dist/collection/components/beta/gux-visualization/gux-visualization.js +2 -2
  13. package/dist/collection/test/setupAxeTests.js +3 -11
  14. package/dist/esm/{color-palette-686ee197.js → color-palette-883bdc64.js} +6 -7
  15. package/dist/esm/genesys-chart-webcomponents.js +10 -10
  16. package/dist/esm/gux-chart-column-beta.entry.js +2 -2
  17. package/dist/esm/gux-chart-donut-beta.entry.js +2 -2
  18. package/dist/esm/gux-chart-line-beta.entry.js +2 -2
  19. package/dist/esm/gux-chart-pie-beta.entry.js +2 -2
  20. package/dist/esm/gux-chart-scatter-plot-beta.entry.js +2 -2
  21. package/dist/esm/gux-visualization-beta.entry.js +4 -4
  22. package/dist/esm/index-e1e997ee.js +1170 -0
  23. package/dist/esm/loader.js +2 -2
  24. package/dist/genesys-chart-webcomponents/genesys-chart-webcomponents.esm.js +1 -1
  25. package/dist/genesys-chart-webcomponents/{p-e8cc490f.entry.js → p-2ec9eae2.entry.js} +1 -1
  26. package/dist/genesys-chart-webcomponents/{p-32c90b8d.entry.js → p-3e724248.entry.js} +1 -1
  27. package/dist/genesys-chart-webcomponents/{p-13e52c23.entry.js → p-58f41069.entry.js} +2 -2
  28. package/dist/genesys-chart-webcomponents/{p-4cf542a9.entry.js → p-776540fb.entry.js} +1 -1
  29. package/dist/genesys-chart-webcomponents/p-7f2ebcdb.js +2 -0
  30. package/dist/genesys-chart-webcomponents/{p-dafef2fd.js → p-b836a7d3.js} +1 -1
  31. package/dist/genesys-chart-webcomponents/{p-984c750e.entry.js → p-c690f202.entry.js} +1 -1
  32. package/dist/genesys-chart-webcomponents/{p-028de4aa.entry.js → p-ff2fd38a.entry.js} +1 -1
  33. package/dist/loader/cdn.js +1 -3
  34. package/dist/loader/index.cjs.js +1 -3
  35. package/dist/loader/index.d.ts +3 -0
  36. package/dist/loader/index.es2017.js +1 -3
  37. package/dist/loader/index.js +1 -3
  38. package/dist/stencil-wrapper.js +1 -1
  39. package/dist/types/stencil-public-runtime.d.ts +3 -10
  40. package/dist/types/stencil-wrapper.d.ts +1 -1
  41. package/package.json +6 -7
  42. package/dist/cjs/index-95713c33.js +0 -1795
  43. package/dist/collection/components/beta/gux-chart-column/tests/gux-column-chart.spec.js +0 -22
  44. package/dist/collection/components/beta/gux-chart-donut/tests/gux-chart-donut.spec.js +0 -11
  45. package/dist/collection/components/beta/gux-chart-line/tests/gux-chart-line.e2e.js +0 -17
  46. package/dist/collection/components/beta/gux-chart-line/tests/gux-chart-line.spec.js +0 -22
  47. package/dist/collection/components/beta/gux-chart-pie/tests/gux-chart-pie.spec.js +0 -11
  48. package/dist/collection/components/beta/gux-chart-scatter-plot/tests/gux-chart-scatter-plot.spec.js +0 -33
  49. package/dist/collection/components/beta/gux-visualization/tests/gux-visualization.e2e.js +0 -31
  50. package/dist/collection/components/beta/gux-visualization/tests/gux-visualization.spec.js +0 -35
  51. package/dist/collection/utils/tracking/usage.spec.js +0 -121
  52. package/dist/esm/index-e4944b0d.js +0 -1767
  53. package/dist/esm/polyfills/core-js.js +0 -11
  54. package/dist/esm/polyfills/dom.js +0 -79
  55. package/dist/esm/polyfills/es5-html-element.js +0 -1
  56. package/dist/esm/polyfills/index.js +0 -34
  57. package/dist/esm/polyfills/system.js +0 -6
  58. package/dist/genesys-chart-webcomponents/p-e068d41d.js +0 -2
@@ -1,1795 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopNamespace(e) {
4
- if (e && e.__esModule) return e;
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () {
13
- return e[k];
14
- }
15
- });
16
- }
17
- });
18
- }
19
- n['default'] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- const NAMESPACE = 'genesys-chart-webcomponents';
24
-
25
- /**
26
- * Virtual DOM patching algorithm based on Snabbdom by
27
- * Simon Friis Vindum (@paldepind)
28
- * Licensed under the MIT License
29
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
- *
31
- * Modified for Stencil's renderer and slot projection
32
- */
33
- let scopeId;
34
- let hostTagName;
35
- let isSvgMode = false;
36
- let queuePending = false;
37
- const createTime = (fnName, tagName = '') => {
38
- {
39
- return () => {
40
- return;
41
- };
42
- }
43
- };
44
- const uniqueTime = (key, measureText) => {
45
- {
46
- return () => {
47
- return;
48
- };
49
- }
50
- };
51
- const HYDRATED_CSS = '{visibility:hidden}[hydrated]{visibility:inherit}';
52
- /**
53
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
54
- *
55
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
56
- * support as of Stencil v4.
57
- */
58
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
59
- /**
60
- * Default style mode id
61
- */
62
- /**
63
- * Reusable empty obj/array
64
- * Don't add values to these!!
65
- */
66
- const EMPTY_OBJ = {};
67
- const isDef = (v) => v != null;
68
- /**
69
- * Check whether a value is a 'complex type', defined here as an object or a
70
- * function.
71
- *
72
- * @param o the value to check
73
- * @returns whether it's a complex type or not
74
- */
75
- const isComplexType = (o) => {
76
- // https://jsperf.com/typeof-fn-object/5
77
- o = typeof o;
78
- return o === 'object' || o === 'function';
79
- };
80
- /**
81
- * Helper method for querying a `meta` tag that contains a nonce value
82
- * out of a DOM's head.
83
- *
84
- * @param doc The DOM containing the `head` to query against
85
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
86
- * exists or the tag has no content.
87
- */
88
- function queryNonceMetaTagContent(doc) {
89
- var _a, _b, _c;
90
- return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
91
- }
92
- /**
93
- * Production h() function based on Preact by
94
- * Jason Miller (@developit)
95
- * Licensed under the MIT License
96
- * https://github.com/developit/preact/blob/master/LICENSE
97
- *
98
- * Modified for Stencil's compiler and vdom
99
- */
100
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
101
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
102
- const h = (nodeName, vnodeData, ...children) => {
103
- let child = null;
104
- let key = null;
105
- let simple = false;
106
- let lastSimple = false;
107
- const vNodeChildren = [];
108
- const walk = (c) => {
109
- for (let i = 0; i < c.length; i++) {
110
- child = c[i];
111
- if (Array.isArray(child)) {
112
- walk(child);
113
- }
114
- else if (child != null && typeof child !== 'boolean') {
115
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
116
- child = String(child);
117
- }
118
- if (simple && lastSimple) {
119
- // If the previous child was simple (string), we merge both
120
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
121
- }
122
- else {
123
- // Append a new vNode, if it's text, we create a text vNode
124
- vNodeChildren.push(simple ? newVNode(null, child) : child);
125
- }
126
- lastSimple = simple;
127
- }
128
- }
129
- };
130
- walk(children);
131
- if (vnodeData) {
132
- if (vnodeData.key) {
133
- key = vnodeData.key;
134
- }
135
- // normalize class / className attributes
136
- {
137
- const classData = vnodeData.className || vnodeData.class;
138
- if (classData) {
139
- vnodeData.class =
140
- typeof classData !== 'object'
141
- ? classData
142
- : Object.keys(classData)
143
- .filter((k) => classData[k])
144
- .join(' ');
145
- }
146
- }
147
- }
148
- const vnode = newVNode(nodeName, null);
149
- vnode.$attrs$ = vnodeData;
150
- if (vNodeChildren.length > 0) {
151
- vnode.$children$ = vNodeChildren;
152
- }
153
- {
154
- vnode.$key$ = key;
155
- }
156
- return vnode;
157
- };
158
- /**
159
- * A utility function for creating a virtual DOM node from a tag and some
160
- * possible text content.
161
- *
162
- * @param tag the tag for this element
163
- * @param text possible text content for the node
164
- * @returns a newly-minted virtual DOM node
165
- */
166
- const newVNode = (tag, text) => {
167
- const vnode = {
168
- $flags$: 0,
169
- $tag$: tag,
170
- $text$: text,
171
- $elm$: null,
172
- $children$: null,
173
- };
174
- {
175
- vnode.$attrs$ = null;
176
- }
177
- {
178
- vnode.$key$ = null;
179
- }
180
- return vnode;
181
- };
182
- const Host = {};
183
- /**
184
- * Check whether a given node is a Host node or not
185
- *
186
- * @param node the virtual DOM node to check
187
- * @returns whether it's a Host node or not
188
- */
189
- const isHost = (node) => node && node.$tag$ === Host;
190
- /**
191
- * Parse a new property value for a given property type.
192
- *
193
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
194
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
195
- * 1. `any`, the type given to `propValue` in the function signature
196
- * 2. the type stored from `propType`.
197
- *
198
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
199
- *
200
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
201
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
202
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
203
- * ```tsx
204
- * <my-cmp prop-val={0}></my-cmp>
205
- * ```
206
- *
207
- * HTML prop values on the other hand, will always a string
208
- *
209
- * @param propValue the new value to coerce to some type
210
- * @param propType the type of the prop, expressed as a binary number
211
- * @returns the parsed/coerced value
212
- */
213
- const parsePropertyValue = (propValue, propType) => {
214
- // ensure this value is of the correct prop type
215
- if (propValue != null && !isComplexType(propValue)) {
216
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
217
- // per the HTML spec, any string value means it is a boolean true value
218
- // but we'll cheat here and say that the string "false" is the boolean false
219
- return propValue === 'false' ? false : propValue === '' || !!propValue;
220
- }
221
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
222
- // force it to be a number
223
- return parseFloat(propValue);
224
- }
225
- if (propType & 1 /* MEMBER_FLAGS.String */) {
226
- // could have been passed as a number or boolean
227
- // but we still want it as a string
228
- return String(propValue);
229
- }
230
- // redundant return here for better minification
231
- return propValue;
232
- }
233
- // not sure exactly what type we want
234
- // so no need to change to a different type
235
- return propValue;
236
- };
237
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
238
- const createEvent = (ref, name, flags) => {
239
- const elm = getElement(ref);
240
- return {
241
- emit: (detail) => {
242
- return emitEvent(elm, name, {
243
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
244
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
245
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
246
- detail,
247
- });
248
- },
249
- };
250
- };
251
- /**
252
- * Helper function to create & dispatch a custom Event on a provided target
253
- * @param elm the target of the Event
254
- * @param name the name to give the custom Event
255
- * @param opts options for configuring a custom Event
256
- * @returns the custom Event
257
- */
258
- const emitEvent = (elm, name, opts) => {
259
- const ev = plt.ce(name, opts);
260
- elm.dispatchEvent(ev);
261
- return ev;
262
- };
263
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
264
- const registerStyle = (scopeId, cssText, allowCS) => {
265
- let style = styles.get(scopeId);
266
- if (supportsConstructableStylesheets && allowCS) {
267
- style = (style || new CSSStyleSheet());
268
- if (typeof style === 'string') {
269
- style = cssText;
270
- }
271
- else {
272
- style.replaceSync(cssText);
273
- }
274
- }
275
- else {
276
- style = cssText;
277
- }
278
- styles.set(scopeId, style);
279
- };
280
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
281
- var _a;
282
- const scopeId = getScopeId(cmpMeta);
283
- const style = styles.get(scopeId);
284
- // if an element is NOT connected then getRootNode() will return the wrong root node
285
- // so the fallback is to always use the document for the root node in those cases
286
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
287
- if (style) {
288
- if (typeof style === 'string') {
289
- styleContainerNode = styleContainerNode.head || styleContainerNode;
290
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
291
- let styleElm;
292
- if (!appliedStyles) {
293
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
294
- }
295
- if (!appliedStyles.has(scopeId)) {
296
- {
297
- styleElm = doc.createElement('style');
298
- styleElm.innerHTML = style;
299
- // Apply CSP nonce to the style tag if it exists
300
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
301
- if (nonce != null) {
302
- styleElm.setAttribute('nonce', nonce);
303
- }
304
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
305
- }
306
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
307
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
308
- styleElm.innerHTML += SLOT_FB_CSS;
309
- }
310
- if (appliedStyles) {
311
- appliedStyles.add(scopeId);
312
- }
313
- }
314
- }
315
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
316
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
317
- }
318
- }
319
- return scopeId;
320
- };
321
- const attachStyles = (hostRef) => {
322
- const cmpMeta = hostRef.$cmpMeta$;
323
- const elm = hostRef.$hostElement$;
324
- const flags = cmpMeta.$flags$;
325
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
326
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
327
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
328
- // only required when we're NOT using native shadow dom (slot)
329
- // or this browser doesn't support native shadow dom
330
- // and this host element was NOT created with SSR
331
- // let's pick out the inner content for slot projection
332
- // create a node to represent where the original
333
- // content was first placed, which is useful later on
334
- // DOM WRITE!!
335
- elm['s-sc'] = scopeId;
336
- elm.classList.add(scopeId + '-h');
337
- }
338
- endAttachStyles();
339
- };
340
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
341
- /**
342
- * Production setAccessor() function based on Preact by
343
- * Jason Miller (@developit)
344
- * Licensed under the MIT License
345
- * https://github.com/developit/preact/blob/master/LICENSE
346
- *
347
- * Modified for Stencil's compiler and vdom
348
- */
349
- /**
350
- * When running a VDom render set properties present on a VDom node onto the
351
- * corresponding HTML element.
352
- *
353
- * Note that this function has special functionality for the `class`,
354
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
355
- * `onClick`, etc). All others are just passed through as-is.
356
- *
357
- * @param elm the HTMLElement onto which attributes should be set
358
- * @param memberName the name of the attribute to set
359
- * @param oldValue the old value for the attribute
360
- * @param newValue the new value for the attribute
361
- * @param isSvg whether we're in an svg context or not
362
- * @param flags bitflags for Vdom variables
363
- */
364
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
365
- if (oldValue !== newValue) {
366
- let isProp = isMemberInElement(elm, memberName);
367
- memberName.toLowerCase();
368
- if (memberName === 'class') {
369
- const classList = elm.classList;
370
- const oldClasses = parseClassList(oldValue);
371
- const newClasses = parseClassList(newValue);
372
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
373
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
374
- }
375
- else if (memberName === 'key')
376
- ;
377
- else if (memberName === 'ref') {
378
- // minifier will clean this up
379
- if (newValue) {
380
- newValue(elm);
381
- }
382
- }
383
- else {
384
- // Set property if it exists and it's not a SVG
385
- const isComplex = isComplexType(newValue);
386
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
387
- try {
388
- if (!elm.tagName.includes('-')) {
389
- const n = newValue == null ? '' : newValue;
390
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
391
- if (memberName === 'list') {
392
- isProp = false;
393
- }
394
- else if (oldValue == null || elm[memberName] != n) {
395
- elm[memberName] = n;
396
- }
397
- }
398
- else {
399
- elm[memberName] = newValue;
400
- }
401
- }
402
- catch (e) {
403
- /**
404
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
405
- */
406
- }
407
- }
408
- if (newValue == null || newValue === false) {
409
- if (newValue !== false || elm.getAttribute(memberName) === '') {
410
- {
411
- elm.removeAttribute(memberName);
412
- }
413
- }
414
- }
415
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
416
- newValue = newValue === true ? '' : newValue;
417
- {
418
- elm.setAttribute(memberName, newValue);
419
- }
420
- }
421
- }
422
- }
423
- };
424
- const parseClassListRegex = /\s/;
425
- /**
426
- * Parsed a string of classnames into an array
427
- * @param value className string, e.g. "foo bar baz"
428
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
429
- */
430
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
431
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
432
- // if the element passed in is a shadow root, which is a document fragment
433
- // then we want to be adding attrs/props to the shadow root's "host" element
434
- // if it's not a shadow root, then we add attrs/props to the same element
435
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
436
- ? newVnode.$elm$.host
437
- : newVnode.$elm$;
438
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
439
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
440
- {
441
- // remove attributes no longer present on the vnode by setting them to undefined
442
- for (memberName in oldVnodeAttrs) {
443
- if (!(memberName in newVnodeAttrs)) {
444
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
445
- }
446
- }
447
- }
448
- // add new & update changed attributes
449
- for (memberName in newVnodeAttrs) {
450
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
451
- }
452
- };
453
- /**
454
- * Create a DOM Node corresponding to one of the children of a given VNode.
455
- *
456
- * @param oldParentVNode the parent VNode from the previous render
457
- * @param newParentVNode the parent VNode from the current render
458
- * @param childIndex the index of the VNode, in the _new_ parent node's
459
- * children, for which we will create a new DOM node
460
- * @param parentElm the parent DOM node which our new node will be a child of
461
- * @returns the newly created node
462
- */
463
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
464
- // tslint:disable-next-line: prefer-const
465
- const newVNode = newParentVNode.$children$[childIndex];
466
- let i = 0;
467
- let elm;
468
- let childNode;
469
- {
470
- // create element
471
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
472
- // add css classes, attrs, props, listeners, etc.
473
- {
474
- updateElement(null, newVNode, isSvgMode);
475
- }
476
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
477
- // if there is a scopeId and this is the initial render
478
- // then let's add the scopeId as a css class
479
- elm.classList.add((elm['s-si'] = scopeId));
480
- }
481
- if (newVNode.$children$) {
482
- for (i = 0; i < newVNode.$children$.length; ++i) {
483
- // create the node
484
- childNode = createElm(oldParentVNode, newVNode, i);
485
- // return node could have been null
486
- if (childNode) {
487
- // append our new node
488
- elm.appendChild(childNode);
489
- }
490
- }
491
- }
492
- }
493
- // This needs to always happen so we can hide nodes that are projected
494
- // to another component but don't end up in a slot
495
- elm['s-hn'] = hostTagName;
496
- return elm;
497
- };
498
- /**
499
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
500
- * add them to the DOM in the appropriate place.
501
- *
502
- * @param parentElm the DOM node which should be used as a parent for the new
503
- * DOM nodes
504
- * @param before a child of the `parentElm` which the new children should be
505
- * inserted before (optional)
506
- * @param parentVNode the parent virtual DOM node
507
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
508
- * @param startIdx the index in the child virtual DOM nodes at which to start
509
- * creating DOM nodes (inclusive)
510
- * @param endIdx the index in the child virtual DOM nodes at which to stop
511
- * creating DOM nodes (inclusive)
512
- */
513
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
514
- let containerElm = (parentElm);
515
- let childNode;
516
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
517
- containerElm = containerElm.shadowRoot;
518
- }
519
- for (; startIdx <= endIdx; ++startIdx) {
520
- if (vnodes[startIdx]) {
521
- childNode = createElm(null, parentVNode, startIdx);
522
- if (childNode) {
523
- vnodes[startIdx].$elm$ = childNode;
524
- containerElm.insertBefore(childNode, before);
525
- }
526
- }
527
- }
528
- };
529
- /**
530
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
531
- * This can be used to, for instance, clean up after a list of children which
532
- * should no longer be shown.
533
- *
534
- * This function also handles some of Stencil's slot relocation logic.
535
- *
536
- * @param vnodes a list of virtual DOM nodes to remove
537
- * @param startIdx the index at which to start removing nodes (inclusive)
538
- * @param endIdx the index at which to stop removing nodes (inclusive)
539
- */
540
- const removeVnodes = (vnodes, startIdx, endIdx) => {
541
- for (let index = startIdx; index <= endIdx; ++index) {
542
- const vnode = vnodes[index];
543
- if (vnode) {
544
- const elm = vnode.$elm$;
545
- nullifyVNodeRefs(vnode);
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
- {
811
- {
812
- {
813
- // either this is the first render of an element OR it's an update
814
- // AND we already know it's possible it could have changed
815
- // this updates the element's css classes, attrs, props, listeners, etc.
816
- updateElement(oldVNode, newVNode, isSvgMode);
817
- }
818
- }
819
- if (oldChildren !== null && newChildren !== null) {
820
- // looks like there's child vnodes for both the old and new vnodes
821
- // so we need to call `updateChildren` to reconcile them
822
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
823
- }
824
- else if (newChildren !== null) {
825
- // add the new vnode children
826
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
827
- }
828
- else if (oldChildren !== null) {
829
- // no new child vnodes, but there are old child vnodes to remove
830
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
831
- }
832
- }
833
- };
834
- /**
835
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
836
- * them with `null`. This signals that the DOM element corresponding to the VDom
837
- * node has been removed from the DOM.
838
- *
839
- * @param vNode a virtual DOM node
840
- */
841
- const nullifyVNodeRefs = (vNode) => {
842
- {
843
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
844
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
845
- }
846
- };
847
- /**
848
- * The main entry point for Stencil's virtual DOM-based rendering engine
849
- *
850
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
851
- * function will handle creating a virtual DOM tree with a single root, patching
852
- * the current virtual DOM tree onto an old one (if any), dealing with slot
853
- * relocation, and reflecting attributes.
854
- *
855
- * @param hostRef data needed to root and render the virtual DOM tree, such as
856
- * the DOM node into which it should be rendered.
857
- * @param renderFnResults the virtual DOM nodes to be rendered
858
- * @param isInitialLoad whether or not this is the first call after page load
859
- */
860
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
861
- const hostElm = hostRef.$hostElement$;
862
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
863
- // if `renderFnResults` is a Host node then we can use it directly. If not,
864
- // we need to call `h` again to wrap the children of our component in a
865
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
866
- // implicitly that the top-level vdom node is 1) an only child and 2)
867
- // contains attrs that need to be set on the host element.
868
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
869
- hostTagName = hostElm.tagName;
870
- // On the first render and *only* on the first render we want to check for
871
- // any attributes set on the host element which are also set on the vdom
872
- // node. If we find them, we override the value on the VDom node attrs with
873
- // the value from the host element, which allows developers building apps
874
- // with Stencil components to override e.g. the `role` attribute on a
875
- // component even if it's already set on the `Host`.
876
- if (isInitialLoad && rootVnode.$attrs$) {
877
- for (const key of Object.keys(rootVnode.$attrs$)) {
878
- // We have a special implementation in `setAccessor` for `style` and
879
- // `class` which reconciles values coming from the VDom with values
880
- // already present on the DOM element, so we don't want to override those
881
- // attributes on the VDom tree with values from the host element if they
882
- // are present.
883
- //
884
- // Likewise, `ref` and `key` are special internal values for the Stencil
885
- // runtime and we don't want to override those either.
886
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
887
- rootVnode.$attrs$[key] = hostElm[key];
888
- }
889
- }
890
- }
891
- rootVnode.$tag$ = null;
892
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
893
- hostRef.$vnode$ = rootVnode;
894
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
895
- {
896
- scopeId = hostElm['s-sc'];
897
- }
898
- // synchronous patch
899
- patch(oldVNode, rootVnode, isInitialLoad);
900
- };
901
- const attachToAncestor = (hostRef, ancestorComponent) => {
902
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
903
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
904
- }
905
- };
906
- const scheduleUpdate = (hostRef, isInitialLoad) => {
907
- {
908
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
909
- }
910
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
911
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
912
- return;
913
- }
914
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
915
- // there is no ancestor component or the ancestor component
916
- // has already fired off its lifecycle update then
917
- // fire off the initial update
918
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
919
- return writeTask(dispatch) ;
920
- };
921
- /**
922
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
923
- * component lifecycle methods like `componentWillLoad` as well as
924
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
925
- *
926
- * @param hostRef a reference to a host DOM node
927
- * @param isInitialLoad whether we're on the initial load or not
928
- * @returns an empty Promise which is used to enqueue a series of operations for
929
- * the component
930
- */
931
- const dispatchHooks = (hostRef, isInitialLoad) => {
932
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
933
- const instance = hostRef.$lazyInstance$ ;
934
- // We're going to use this variable together with `enqueue` to implement a
935
- // little promise-based queue. We start out with it `undefined`. When we add
936
- // the first function to the queue we'll set this variable to be that
937
- // function's return value. When we attempt to add subsequent values to the
938
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
939
- // the new function off of that `Promise` using `.then()`. This will give our
940
- // queue two nice properties:
941
- //
942
- // 1. If all functions added to the queue are synchronous they'll be called
943
- // synchronously right away.
944
- // 2. If all functions added to the queue are asynchronous they'll all be
945
- // called in order after `dispatchHooks` exits.
946
- let maybePromise;
947
- if (isInitialLoad) {
948
- {
949
- // If `componentWillLoad` returns a `Promise` then we want to wait on
950
- // whatever's going on in that `Promise` before we launch into
951
- // rendering the component, doing other lifecycle stuff, etc. So
952
- // in that case we assign the returned promise to the variable we
953
- // declared above to hold a possible 'queueing' Promise
954
- maybePromise = safeCall(instance, 'componentWillLoad');
955
- }
956
- }
957
- endSchedule();
958
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
959
- };
960
- /**
961
- * This function uses a Promise to implement a simple first-in, first-out queue
962
- * of functions to be called.
963
- *
964
- * The queue is ordered on the basis of the first argument. If it's
965
- * `undefined`, then nothing is on the queue yet, so the provided function can
966
- * be called synchronously (although note that this function may return a
967
- * `Promise`). The idea is that then the return value of that enqueueing
968
- * operation is kept around, so that if it was a `Promise` then subsequent
969
- * functions can be enqueued by calling this function again with that `Promise`
970
- * as the first argument.
971
- *
972
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
973
- * @param fn a function to enqueue
974
- * @returns either a `Promise` or the return value of the provided function
975
- */
976
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
977
- /**
978
- * Check that a value is a `Promise`. To check, we first see if the value is an
979
- * instance of the `Promise` global. In a few circumstances, in particular if
980
- * the global has been overwritten, this is could be misleading, so we also do
981
- * a little 'duck typing' check to see if the `.then` property of the value is
982
- * defined and a function.
983
- *
984
- * @param maybePromise it might be a promise!
985
- * @returns whether it is or not
986
- */
987
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
988
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
989
- /**
990
- * Update a component given reference to its host elements and so on.
991
- *
992
- * @param hostRef an object containing references to the element's host node,
993
- * VDom nodes, and other metadata
994
- * @param instance a reference to the underlying host element where it will be
995
- * rendered
996
- * @param isInitialLoad whether or not this function is being called as part of
997
- * the first render cycle
998
- */
999
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1000
- var _a;
1001
- const elm = hostRef.$hostElement$;
1002
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1003
- const rc = elm['s-rc'];
1004
- if (isInitialLoad) {
1005
- // DOM WRITE!
1006
- attachStyles(hostRef);
1007
- }
1008
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1009
- {
1010
- callRender(hostRef, instance, elm, isInitialLoad);
1011
- }
1012
- if (rc) {
1013
- // ok, so turns out there are some child host elements
1014
- // waiting on this parent element to load
1015
- // let's fire off all update callbacks waiting
1016
- rc.map((cb) => cb());
1017
- elm['s-rc'] = undefined;
1018
- }
1019
- endRender();
1020
- endUpdate();
1021
- {
1022
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1023
- const postUpdate = () => postUpdateComponent(hostRef);
1024
- if (childrenPromises.length === 0) {
1025
- postUpdate();
1026
- }
1027
- else {
1028
- Promise.all(childrenPromises).then(postUpdate);
1029
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1030
- childrenPromises.length = 0;
1031
- }
1032
- }
1033
- };
1034
- /**
1035
- * Handle making the call to the VDom renderer with the proper context given
1036
- * various build variables
1037
- *
1038
- * @param hostRef an object containing references to the element's host node,
1039
- * VDom nodes, and other metadata
1040
- * @param instance a reference to the underlying host element where it will be
1041
- * rendered
1042
- * @param elm the Host element for the component
1043
- * @param isInitialLoad whether or not this function is being called as part of
1044
- * @returns an empty promise
1045
- */
1046
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1047
- try {
1048
- /**
1049
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1050
- * method, so we can call the method immediately. If not, check before calling it.
1051
- */
1052
- instance = instance.render() ;
1053
- {
1054
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1055
- }
1056
- {
1057
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1058
- }
1059
- {
1060
- {
1061
- // looks like we've got child nodes to render into this host element
1062
- // or we need to update the css class/attrs on the host element
1063
- // DOM WRITE!
1064
- {
1065
- renderVdom(hostRef, instance, isInitialLoad);
1066
- }
1067
- }
1068
- }
1069
- }
1070
- catch (e) {
1071
- consoleError(e, hostRef.$hostElement$);
1072
- }
1073
- return null;
1074
- };
1075
- const postUpdateComponent = (hostRef) => {
1076
- const tagName = hostRef.$cmpMeta$.$tagName$;
1077
- const elm = hostRef.$hostElement$;
1078
- const endPostUpdate = createTime('postUpdate', tagName);
1079
- const instance = hostRef.$lazyInstance$ ;
1080
- const ancestorComponent = hostRef.$ancestorComponent$;
1081
- {
1082
- safeCall(instance, 'componentDidRender');
1083
- }
1084
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1085
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1086
- {
1087
- // DOM WRITE!
1088
- addHydratedFlag(elm);
1089
- }
1090
- {
1091
- safeCall(instance, 'componentDidLoad');
1092
- }
1093
- endPostUpdate();
1094
- {
1095
- hostRef.$onReadyResolve$(elm);
1096
- if (!ancestorComponent) {
1097
- appDidLoad();
1098
- }
1099
- }
1100
- }
1101
- else {
1102
- endPostUpdate();
1103
- }
1104
- // load events fire from bottom to top
1105
- // the deepest elements load first then bubbles up
1106
- {
1107
- if (hostRef.$onRenderResolve$) {
1108
- hostRef.$onRenderResolve$();
1109
- hostRef.$onRenderResolve$ = undefined;
1110
- }
1111
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1112
- nextTick(() => scheduleUpdate(hostRef, false));
1113
- }
1114
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1115
- }
1116
- // ( •_•)
1117
- // ( •_•)>⌐■-■
1118
- // (⌐■_■)
1119
- };
1120
- const appDidLoad = (who) => {
1121
- // on appload
1122
- // we have finish the first big initial render
1123
- {
1124
- addHydratedFlag(doc.documentElement);
1125
- }
1126
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1127
- };
1128
- /**
1129
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1130
- * e.g. custom element node. If a build figures out that e.g. no component
1131
- * has a `componentDidLoad` method, the instance method gets removed from the
1132
- * output bundle and this function returns `undefined`.
1133
- * @param instance any object that may or may not contain methods
1134
- * @param method method name
1135
- * @param arg single arbitrary argument
1136
- * @returns result of method call if it exists, otherwise `undefined`
1137
- */
1138
- const safeCall = (instance, method, arg) => {
1139
- if (instance && instance[method]) {
1140
- try {
1141
- return instance[method](arg);
1142
- }
1143
- catch (e) {
1144
- consoleError(e);
1145
- }
1146
- }
1147
- return undefined;
1148
- };
1149
- const addHydratedFlag = (elm) => elm.setAttribute('hydrated', '')
1150
- ;
1151
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1152
- const setValue = (ref, propName, newVal, cmpMeta) => {
1153
- // check our new property value against our internal value
1154
- const hostRef = getHostRef(ref);
1155
- const elm = hostRef.$hostElement$ ;
1156
- const oldVal = hostRef.$instanceValues$.get(propName);
1157
- const flags = hostRef.$flags$;
1158
- const instance = hostRef.$lazyInstance$ ;
1159
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1160
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1161
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1162
- const didValueChange = newVal !== oldVal && !areBothNaN;
1163
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1164
- // gadzooks! the property's value has changed!!
1165
- // set our new value!
1166
- hostRef.$instanceValues$.set(propName, newVal);
1167
- if (instance) {
1168
- // get an array of method names of watch functions to call
1169
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1170
- const watchMethods = cmpMeta.$watchers$[propName];
1171
- if (watchMethods) {
1172
- // this instance is watching for when this property changed
1173
- watchMethods.map((watchMethodName) => {
1174
- try {
1175
- // fire off each of the watch methods that are watching this property
1176
- instance[watchMethodName](newVal, oldVal, propName);
1177
- }
1178
- catch (e) {
1179
- consoleError(e, elm);
1180
- }
1181
- });
1182
- }
1183
- }
1184
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1185
- // looks like this value actually changed, so we've got work to do!
1186
- // but only if we've already rendered, otherwise just chill out
1187
- // queue that we need to do an update, but don't worry about queuing
1188
- // up millions cuz this function ensures it only runs once
1189
- scheduleUpdate(hostRef, false);
1190
- }
1191
- }
1192
- }
1193
- };
1194
- /**
1195
- * Attach a series of runtime constructs to a compiled Stencil component
1196
- * constructor, including getters and setters for the `@Prop` and `@State`
1197
- * decorators, callbacks for when attributes change, and so on.
1198
- *
1199
- * @param Cstr the constructor for a component that we need to process
1200
- * @param cmpMeta metadata collected previously about the component
1201
- * @param flags a number used to store a series of bit flags
1202
- * @returns a reference to the same constructor passed in (but now mutated)
1203
- */
1204
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1205
- var _a;
1206
- const prototype = Cstr.prototype;
1207
- if (cmpMeta.$members$) {
1208
- if (Cstr.watchers) {
1209
- cmpMeta.$watchers$ = Cstr.watchers;
1210
- }
1211
- // It's better to have a const than two Object.entries()
1212
- const members = Object.entries(cmpMeta.$members$);
1213
- members.map(([memberName, [memberFlags]]) => {
1214
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1215
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1216
- // proxyComponent - prop
1217
- Object.defineProperty(prototype, memberName, {
1218
- get() {
1219
- // proxyComponent, get value
1220
- return getValue(this, memberName);
1221
- },
1222
- set(newValue) {
1223
- // proxyComponent, set value
1224
- setValue(this, memberName, newValue, cmpMeta);
1225
- },
1226
- configurable: true,
1227
- enumerable: true,
1228
- });
1229
- }
1230
- });
1231
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1232
- const attrNameToPropName = new Map();
1233
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1234
- plt.jmp(() => {
1235
- var _a;
1236
- const propName = attrNameToPropName.get(attrName);
1237
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1238
- // in the case where an attribute was set inline.
1239
- // ```html
1240
- // <my-component some-attribute="some-value"></my-component>
1241
- // ```
1242
- //
1243
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1244
- // programmatically changes it before it has been upgraded as shown below:
1245
- //
1246
- // ```html
1247
- // <!-- this component has _not_ been upgraded yet -->
1248
- // <my-component id="test" some-attribute="some-value"></my-component>
1249
- // <script>
1250
- // // grab non-upgraded component
1251
- // el = document.querySelector("#test");
1252
- // el.someAttribute = "another-value";
1253
- // // upgrade component
1254
- // customElements.define('my-component', MyComponent);
1255
- // </script>
1256
- // ```
1257
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1258
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1259
- // to the value that was set inline i.e. "some-value" from above example. When
1260
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1261
- //
1262
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1263
- // by connectedCallback as this attributeChangedCallback will not fire.
1264
- //
1265
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1266
- //
1267
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1268
- // properties here given that this goes against best practices outlined here
1269
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1270
- if (this.hasOwnProperty(propName)) {
1271
- newValue = this[propName];
1272
- delete this[propName];
1273
- }
1274
- else if (prototype.hasOwnProperty(propName) &&
1275
- typeof this[propName] === 'number' &&
1276
- this[propName] == newValue) {
1277
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1278
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1279
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1280
- return;
1281
- }
1282
- else if (propName == null) {
1283
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1284
- // on a vanilla web component
1285
- const hostRef = getHostRef(this);
1286
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1287
- // We only want to trigger the callback(s) if:
1288
- // 1. The instance is ready
1289
- // 2. The watchers are ready
1290
- // 3. The value has changed
1291
- if (flags &&
1292
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1293
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1294
- newValue !== oldValue) {
1295
- const instance = hostRef.$lazyInstance$ ;
1296
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1297
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1298
- if (instance[callbackName] != null) {
1299
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1300
- }
1301
- });
1302
- }
1303
- return;
1304
- }
1305
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1306
- });
1307
- };
1308
- // Create an array of attributes to observe
1309
- // This list in comprised of all strings used within a `@Watch()` decorator
1310
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1311
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1312
- // an invalid attribute.
1313
- Cstr.observedAttributes = Array.from(new Set([
1314
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1315
- ...members
1316
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1317
- .map(([propName, m]) => {
1318
- const attrName = m[1] || propName;
1319
- attrNameToPropName.set(attrName, propName);
1320
- return attrName;
1321
- }),
1322
- ]));
1323
- }
1324
- }
1325
- return Cstr;
1326
- };
1327
- /**
1328
- * Initialize a Stencil component given a reference to its host element, its
1329
- * runtime bookkeeping data structure, runtime metadata about the component,
1330
- * and (optionally) an HMR version ID.
1331
- *
1332
- * @param elm a host element
1333
- * @param hostRef the element's runtime bookkeeping object
1334
- * @param cmpMeta runtime metadata for the Stencil component
1335
- * @param hmrVersionId an (optional) HMR version ID
1336
- */
1337
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1338
- let Cstr;
1339
- // initializeComponent
1340
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1341
- // Let the runtime know that the component has been initialized
1342
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1343
- const bundleId = cmpMeta.$lazyBundleId$;
1344
- if (bundleId) {
1345
- // lazy loaded components
1346
- // request the component's implementation to be
1347
- // wired up with the host element
1348
- Cstr = loadModule(cmpMeta);
1349
- if (Cstr.then) {
1350
- // Await creates a micro-task avoid if possible
1351
- const endLoad = uniqueTime();
1352
- Cstr = await Cstr;
1353
- endLoad();
1354
- }
1355
- if (!Cstr.isProxied) {
1356
- // we've never proxied this Constructor before
1357
- // let's add the getters/setters to its prototype before
1358
- // the first time we create an instance of the implementation
1359
- {
1360
- cmpMeta.$watchers$ = Cstr.watchers;
1361
- }
1362
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1363
- Cstr.isProxied = true;
1364
- }
1365
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1366
- // ok, time to construct the instance
1367
- // but let's keep track of when we start and stop
1368
- // so that the getters/setters don't incorrectly step on data
1369
- {
1370
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1371
- }
1372
- // construct the lazy-loaded component implementation
1373
- // passing the hostRef is very important during
1374
- // construction in order to directly wire together the
1375
- // host element and the lazy-loaded instance
1376
- try {
1377
- new Cstr(hostRef);
1378
- }
1379
- catch (e) {
1380
- consoleError(e);
1381
- }
1382
- {
1383
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1384
- }
1385
- {
1386
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1387
- }
1388
- endNewInstance();
1389
- }
1390
- else {
1391
- // sync constructor component
1392
- Cstr = elm.constructor;
1393
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
1394
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
1395
- // Stencil has completed instantiating the component.
1396
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
1397
- }
1398
- if (Cstr.style) {
1399
- // this component has styles but we haven't registered them yet
1400
- let style = Cstr.style;
1401
- const scopeId = getScopeId(cmpMeta);
1402
- if (!styles.has(scopeId)) {
1403
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1404
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1405
- endRegisterStyles();
1406
- }
1407
- }
1408
- }
1409
- // we've successfully created a lazy instance
1410
- const ancestorComponent = hostRef.$ancestorComponent$;
1411
- const schedule = () => scheduleUpdate(hostRef, true);
1412
- if (ancestorComponent && ancestorComponent['s-rc']) {
1413
- // this is the initial load and this component it has an ancestor component
1414
- // but the ancestor component has NOT fired its will update lifecycle yet
1415
- // so let's just cool our jets and wait for the ancestor to continue first
1416
- // this will get fired off when the ancestor component
1417
- // finally gets around to rendering its lazy self
1418
- // fire off the initial update
1419
- ancestorComponent['s-rc'].push(schedule);
1420
- }
1421
- else {
1422
- schedule();
1423
- }
1424
- };
1425
- const fireConnectedCallback = (instance) => {
1426
- };
1427
- const connectedCallback = (elm) => {
1428
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1429
- const hostRef = getHostRef(elm);
1430
- const cmpMeta = hostRef.$cmpMeta$;
1431
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1432
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1433
- // first time this component has connected
1434
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1435
- {
1436
- // find the first ancestor component (if there is one) and register
1437
- // this component as one of the actively loading child components for its ancestor
1438
- let ancestorComponent = elm;
1439
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1440
- // climb up the ancestors looking for the first
1441
- // component that hasn't finished its lifecycle update yet
1442
- if (ancestorComponent['s-p']) {
1443
- // we found this components first ancestor component
1444
- // keep a reference to this component's ancestor component
1445
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1446
- break;
1447
- }
1448
- }
1449
- }
1450
- // Lazy properties
1451
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1452
- if (cmpMeta.$members$) {
1453
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1454
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1455
- const value = elm[memberName];
1456
- delete elm[memberName];
1457
- elm[memberName] = value;
1458
- }
1459
- });
1460
- }
1461
- {
1462
- initializeComponent(elm, hostRef, cmpMeta);
1463
- }
1464
- }
1465
- else {
1466
- // fire off connectedCallback() on component instance
1467
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
1468
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1469
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
1470
- }
1471
- }
1472
- endConnected();
1473
- }
1474
- };
1475
- const disconnectInstance = (instance) => {
1476
- };
1477
- const disconnectedCallback = async (elm) => {
1478
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1479
- const hostRef = getHostRef(elm);
1480
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
1481
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
1482
- hostRef.$onReadyPromise$.then(() => disconnectInstance());
1483
- }
1484
- }
1485
- };
1486
- const bootstrapLazy = (lazyBundles, options = {}) => {
1487
- var _a;
1488
- const endBootstrap = createTime();
1489
- const cmpTags = [];
1490
- const exclude = options.exclude || [];
1491
- const customElements = win.customElements;
1492
- const head = doc.head;
1493
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1494
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
1495
- const deferredConnectedCallbacks = [];
1496
- let appLoadFallback;
1497
- let isBootstrapping = true;
1498
- Object.assign(plt, options);
1499
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1500
- let hasSlotRelocation = false;
1501
- lazyBundles.map((lazyBundle) => {
1502
- lazyBundle[1].map((compactMeta) => {
1503
- var _a;
1504
- const cmpMeta = {
1505
- $flags$: compactMeta[0],
1506
- $tagName$: compactMeta[1],
1507
- $members$: compactMeta[2],
1508
- $listeners$: compactMeta[3],
1509
- };
1510
- // Check if we are using slots outside the shadow DOM in this component.
1511
- // We'll use this information later to add styles for `slot-fb` elements
1512
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
1513
- hasSlotRelocation = true;
1514
- }
1515
- {
1516
- cmpMeta.$members$ = compactMeta[2];
1517
- }
1518
- {
1519
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
1520
- }
1521
- const tagName = cmpMeta.$tagName$;
1522
- const HostElement = class extends HTMLElement {
1523
- // StencilLazyHost
1524
- constructor(self) {
1525
- // @ts-ignore
1526
- super(self);
1527
- self = this;
1528
- registerHost(self, cmpMeta);
1529
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1530
- // this component is using shadow dom
1531
- // and this browser supports shadow dom
1532
- // add the read-only property "shadowRoot" to the host element
1533
- // adding the shadow root build conditionals to minimize runtime
1534
- {
1535
- {
1536
- self.attachShadow({ mode: 'open' });
1537
- }
1538
- }
1539
- }
1540
- }
1541
- connectedCallback() {
1542
- if (appLoadFallback) {
1543
- clearTimeout(appLoadFallback);
1544
- appLoadFallback = null;
1545
- }
1546
- if (isBootstrapping) {
1547
- // connectedCallback will be processed once all components have been registered
1548
- deferredConnectedCallbacks.push(this);
1549
- }
1550
- else {
1551
- plt.jmp(() => connectedCallback(this));
1552
- }
1553
- }
1554
- disconnectedCallback() {
1555
- plt.jmp(() => disconnectedCallback(this));
1556
- }
1557
- componentOnReady() {
1558
- return getHostRef(this).$onReadyPromise$;
1559
- }
1560
- };
1561
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1562
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1563
- cmpTags.push(tagName);
1564
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1565
- }
1566
- });
1567
- });
1568
- // Only bother generating CSS if we have components
1569
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
1570
- if (cmpTags.length > 0) {
1571
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
1572
- if (hasSlotRelocation) {
1573
- dataStyles.textContent += SLOT_FB_CSS;
1574
- }
1575
- // Add hydration styles
1576
- {
1577
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
1578
- }
1579
- // If we have styles, add them to the DOM
1580
- if (dataStyles.innerHTML.length) {
1581
- dataStyles.setAttribute('data-styles', '');
1582
- // Apply CSP nonce to the style tag if it exists
1583
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1584
- if (nonce != null) {
1585
- dataStyles.setAttribute('nonce', nonce);
1586
- }
1587
- // Insert the styles into the document head
1588
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
1589
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
1590
- }
1591
- }
1592
- // Process deferred connectedCallbacks now all components have been registered
1593
- isBootstrapping = false;
1594
- if (deferredConnectedCallbacks.length) {
1595
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1596
- }
1597
- else {
1598
- {
1599
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1600
- }
1601
- }
1602
- // Fallback appLoad event
1603
- endBootstrap();
1604
- };
1605
- /**
1606
- * Assigns the given value to the nonce property on the runtime platform object.
1607
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1608
- * @param nonce The value to be assigned to the platform nonce property.
1609
- * @returns void
1610
- */
1611
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1612
- /**
1613
- * A WeakMap mapping runtime component references to their corresponding host reference
1614
- * instances.
1615
- *
1616
- * **Note**: If we're in an HMR context we need to store a reference to this
1617
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
1618
- * to {@link d.HostRef} across HMR updates.
1619
- *
1620
- * This is necessary because when HMR updates for a component are processed by
1621
- * the browser-side dev server client the JS bundle for that component is
1622
- * re-fetched. Since the module containing {@link hostRefs} is included in
1623
- * that bundle, if we do not store a reference to it the new iteration of the
1624
- * component will not have access to the previous hostRef map, leading to a
1625
- * bug where the new version of the component cannot properly initialize.
1626
- */
1627
- const hostRefs = new WeakMap();
1628
- /**
1629
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
1630
- *
1631
- * @param ref the runtime ref of interest
1632
- * @returns the Host reference (if found) or undefined
1633
- */
1634
- const getHostRef = (ref) => hostRefs.get(ref);
1635
- /**
1636
- * Register a lazy instance with the {@link hostRefs} object so it's
1637
- * corresponding {@link d.HostRef} can be retrieved later.
1638
- *
1639
- * @param lazyInstance the lazy instance of interest
1640
- * @param hostRef that instances `HostRef` object
1641
- * @returns a reference to the host ref WeakMap
1642
- */
1643
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1644
- /**
1645
- * Register a host element for a Stencil component, setting up various metadata
1646
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
1647
- * metadata.
1648
- *
1649
- * @param hostElement the host element to register
1650
- * @param cmpMeta runtime metadata for that component
1651
- * @returns a reference to the host ref WeakMap
1652
- */
1653
- const registerHost = (hostElement, cmpMeta) => {
1654
- const hostRef = {
1655
- $flags$: 0,
1656
- $hostElement$: hostElement,
1657
- $cmpMeta$: cmpMeta,
1658
- $instanceValues$: new Map(),
1659
- };
1660
- {
1661
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1662
- hostElement['s-p'] = [];
1663
- hostElement['s-rc'] = [];
1664
- }
1665
- return hostRefs.set(hostElement, hostRef);
1666
- };
1667
- const isMemberInElement = (elm, memberName) => memberName in elm;
1668
- const consoleError = (e, el) => (0, console.error)(e, el);
1669
- const cmpModules = /*@__PURE__*/ new Map();
1670
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1671
- // loadModuleImport
1672
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1673
- const bundleId = cmpMeta.$lazyBundleId$;
1674
- const module = cmpModules.get(bundleId) ;
1675
- if (module) {
1676
- return module[exportName];
1677
- }
1678
-
1679
- if (!hmrVersionId || !BUILD.hotModuleReplacement) {
1680
- const processMod = importedModule => {
1681
- cmpModules.set(bundleId, importedModule);
1682
- return importedModule[exportName];
1683
- }
1684
- switch(bundleId) {
1685
-
1686
- case 'gux-chart-column-beta.cjs':
1687
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1688
- /* webpackMode: "lazy" */
1689
- './gux-chart-column-beta.cjs.entry.js')); }).then(processMod, consoleError);
1690
- case 'gux-chart-donut-beta.cjs':
1691
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1692
- /* webpackMode: "lazy" */
1693
- './gux-chart-donut-beta.cjs.entry.js')); }).then(processMod, consoleError);
1694
- case 'gux-chart-line-beta.cjs':
1695
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1696
- /* webpackMode: "lazy" */
1697
- './gux-chart-line-beta.cjs.entry.js')); }).then(processMod, consoleError);
1698
- case 'gux-chart-pie-beta.cjs':
1699
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1700
- /* webpackMode: "lazy" */
1701
- './gux-chart-pie-beta.cjs.entry.js')); }).then(processMod, consoleError);
1702
- case 'gux-chart-scatter-plot-beta.cjs':
1703
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1704
- /* webpackMode: "lazy" */
1705
- './gux-chart-scatter-plot-beta.cjs.entry.js')); }).then(processMod, consoleError);
1706
- case 'gux-visualization-beta.cjs':
1707
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1708
- /* webpackMode: "lazy" */
1709
- './gux-visualization-beta.cjs.entry.js')); }).then(processMod, consoleError);
1710
- }
1711
- }
1712
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1713
- /* @vite-ignore */
1714
- /* webpackInclude: /\.entry\.js$/ */
1715
- /* webpackExclude: /\.system\.entry\.js$/ */
1716
- /* webpackMode: "lazy" */
1717
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1718
- {
1719
- cmpModules.set(bundleId, importedModule);
1720
- }
1721
- return importedModule[exportName];
1722
- }, consoleError);
1723
- };
1724
- const styles = /*@__PURE__*/ new Map();
1725
- const win = typeof window !== 'undefined' ? window : {};
1726
- const doc = win.document || { head: {} };
1727
- const plt = {
1728
- $flags$: 0,
1729
- $resourcesUrl$: '',
1730
- jmp: (h) => h(),
1731
- raf: (h) => requestAnimationFrame(h),
1732
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1733
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1734
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
1735
- };
1736
- const promiseResolve = (v) => Promise.resolve(v);
1737
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1738
- try {
1739
- new CSSStyleSheet();
1740
- return typeof new CSSStyleSheet().replaceSync === 'function';
1741
- }
1742
- catch (e) { }
1743
- return false;
1744
- })()
1745
- ;
1746
- const queueDomReads = [];
1747
- const queueDomWrites = [];
1748
- const queueTask = (queue, write) => (cb) => {
1749
- queue.push(cb);
1750
- if (!queuePending) {
1751
- queuePending = true;
1752
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1753
- nextTick(flush);
1754
- }
1755
- else {
1756
- plt.raf(flush);
1757
- }
1758
- }
1759
- };
1760
- const consume = (queue) => {
1761
- for (let i = 0; i < queue.length; i++) {
1762
- try {
1763
- queue[i](performance.now());
1764
- }
1765
- catch (e) {
1766
- consoleError(e);
1767
- }
1768
- }
1769
- queue.length = 0;
1770
- };
1771
- const flush = () => {
1772
- // always force a bunch of medium callbacks to run, but still have
1773
- // a throttle on how many can run in a certain time
1774
- // DOM READS!!!
1775
- consume(queueDomReads);
1776
- // DOM WRITES!!!
1777
- {
1778
- consume(queueDomWrites);
1779
- if ((queuePending = queueDomReads.length > 0)) {
1780
- // still more to do yet, but we've run out of time
1781
- // let's let this thing cool off and try again in the next tick
1782
- plt.raf(flush);
1783
- }
1784
- }
1785
- };
1786
- const nextTick = (cb) => promiseResolve().then(cb);
1787
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1788
-
1789
- exports.bootstrapLazy = bootstrapLazy;
1790
- exports.createEvent = createEvent;
1791
- exports.getElement = getElement;
1792
- exports.h = h;
1793
- exports.promiseResolve = promiseResolve;
1794
- exports.registerInstance = registerInstance;
1795
- exports.setNonce = setNonce;