genesys-spark-chart-components 4.12.1-beta.1

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