@rijkshuisstijl-community/web-components-stencil 1.0.0-alpha.5 → 1.0.0-alpha.6

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