@swisspost/design-system-components 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +40 -0
  3. package/dist/cjs/index-5c30acf6.js +1140 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/my-component.cjs.entry.js +35 -0
  7. package/dist/cjs/post-components.cjs.js +19 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/my-component/my-component.css +3 -0
  10. package/dist/collection/components/my-component/my-component.js +129 -0
  11. package/dist/collection/components/my-component/my-component.stories.js +19 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/stories/Button.js +21 -0
  14. package/dist/collection/stories/Button.stories.js +48 -0
  15. package/dist/collection/stories/Header.js +45 -0
  16. package/dist/collection/stories/Header.stories.js +20 -0
  17. package/dist/collection/stories/Page.js +67 -0
  18. package/dist/collection/stories/Page.stories.js +24 -0
  19. package/dist/collection/stories/assets/code-brackets.svg +1 -0
  20. package/dist/collection/stories/assets/colors.svg +1 -0
  21. package/dist/collection/stories/assets/comments.svg +1 -0
  22. package/dist/collection/stories/assets/direction.svg +1 -0
  23. package/dist/collection/stories/assets/flow.svg +1 -0
  24. package/dist/collection/stories/assets/plugin.svg +1 -0
  25. package/dist/collection/stories/assets/repo.svg +1 -0
  26. package/dist/collection/stories/assets/stackalt.svg +1 -0
  27. package/dist/collection/utils/utils.js +3 -0
  28. package/dist/components/index.d.ts +22 -0
  29. package/dist/components/index.js +2 -0
  30. package/dist/components/my-component.d.ts +11 -0
  31. package/dist/components/my-component.js +54 -0
  32. package/dist/docs.d.ts +124 -0
  33. package/dist/docs.json +101 -0
  34. package/dist/esm/index-865c32d6.js +1114 -0
  35. package/dist/esm/index.js +1 -0
  36. package/dist/esm/loader.js +17 -0
  37. package/dist/esm/my-component.entry.js +31 -0
  38. package/dist/esm/polyfills/core-js.js +11 -0
  39. package/dist/esm/polyfills/css-shim.js +1 -0
  40. package/dist/esm/polyfills/dom.js +79 -0
  41. package/dist/esm/polyfills/es5-html-element.js +1 -0
  42. package/dist/esm/polyfills/index.js +34 -0
  43. package/dist/esm/polyfills/system.js +6 -0
  44. package/dist/esm/post-components.js +17 -0
  45. package/dist/index.cjs.js +1 -0
  46. package/dist/index.js +1 -0
  47. package/dist/post-components/index.esm.js +0 -0
  48. package/dist/post-components/p-89fc10d3.js +2 -0
  49. package/dist/post-components/p-e4e802f7.entry.js +1 -0
  50. package/dist/post-components/post-components.esm.js +1 -0
  51. package/dist/types/components/my-component/my-component.d.ts +22 -0
  52. package/dist/types/components/my-component/my-component.stories.d.ts +12 -0
  53. package/dist/types/components.d.ts +70 -0
  54. package/dist/types/index.d.ts +1 -0
  55. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  56. package/dist/types/utils/utils.d.ts +1 -0
  57. package/loader/cdn.js +3 -0
  58. package/loader/index.cjs.js +3 -0
  59. package/loader/index.d.ts +12 -0
  60. package/loader/index.es2017.js +3 -0
  61. package/loader/index.js +4 -0
  62. package/loader/package.json +11 -0
  63. package/package.json +69 -0
@@ -0,0 +1,1140 @@
1
+ 'use strict';
2
+
3
+ function _interopNamespace(e) {
4
+ if (e && e.__esModule) return e;
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n['default'] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const NAMESPACE = 'post-components';
24
+
25
+ let scopeId;
26
+ let hostTagName;
27
+ let queuePending = false;
28
+ const win = typeof window !== 'undefined' ? window : {};
29
+ const doc = win.document || { head: {} };
30
+ const plt = {
31
+ $flags$: 0,
32
+ $resourcesUrl$: '',
33
+ jmp: (h) => h(),
34
+ raf: (h) => requestAnimationFrame(h),
35
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
36
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
37
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
38
+ };
39
+ const promiseResolve = (v) => Promise.resolve(v);
40
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
41
+ try {
42
+ new CSSStyleSheet();
43
+ return typeof new CSSStyleSheet().replaceSync === 'function';
44
+ }
45
+ catch (e) { }
46
+ return false;
47
+ })()
48
+ ;
49
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
50
+ const createTime = (fnName, tagName = '') => {
51
+ {
52
+ return () => {
53
+ return;
54
+ };
55
+ }
56
+ };
57
+ const uniqueTime = (key, measureText) => {
58
+ {
59
+ return () => {
60
+ return;
61
+ };
62
+ }
63
+ };
64
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
65
+ const registerStyle = (scopeId, cssText, allowCS) => {
66
+ let style = styles.get(scopeId);
67
+ if (supportsConstructableStylesheets && allowCS) {
68
+ style = (style || new CSSStyleSheet());
69
+ if (typeof style === 'string') {
70
+ style = cssText;
71
+ }
72
+ else {
73
+ style.replaceSync(cssText);
74
+ }
75
+ }
76
+ else {
77
+ style = cssText;
78
+ }
79
+ styles.set(scopeId, style);
80
+ };
81
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
82
+ let scopeId = getScopeId(cmpMeta);
83
+ const style = styles.get(scopeId);
84
+ // if an element is NOT connected then getRootNode() will return the wrong root node
85
+ // so the fallback is to always use the document for the root node in those cases
86
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
87
+ if (style) {
88
+ if (typeof style === 'string') {
89
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
90
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
91
+ let styleElm;
92
+ if (!appliedStyles) {
93
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
94
+ }
95
+ if (!appliedStyles.has(scopeId)) {
96
+ {
97
+ {
98
+ styleElm = doc.createElement('style');
99
+ styleElm.innerHTML = style;
100
+ }
101
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
102
+ }
103
+ if (appliedStyles) {
104
+ appliedStyles.add(scopeId);
105
+ }
106
+ }
107
+ }
108
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
109
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
110
+ }
111
+ }
112
+ return scopeId;
113
+ };
114
+ const attachStyles = (hostRef) => {
115
+ const cmpMeta = hostRef.$cmpMeta$;
116
+ const elm = hostRef.$hostElement$;
117
+ const flags = cmpMeta.$flags$;
118
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
119
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
120
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
121
+ // only required when we're NOT using native shadow dom (slot)
122
+ // or this browser doesn't support native shadow dom
123
+ // and this host element was NOT created with SSR
124
+ // let's pick out the inner content for slot projection
125
+ // create a node to represent where the original
126
+ // content was first placed, which is useful later on
127
+ // DOM WRITE!!
128
+ elm['s-sc'] = scopeId;
129
+ elm.classList.add(scopeId + '-h');
130
+ }
131
+ endAttachStyles();
132
+ };
133
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
134
+ const isDef = (v) => v != null;
135
+ const isComplexType = (o) => {
136
+ // https://jsperf.com/typeof-fn-object/5
137
+ o = typeof o;
138
+ return o === 'object' || o === 'function';
139
+ };
140
+ /**
141
+ * Production h() function based on Preact by
142
+ * Jason Miller (@developit)
143
+ * Licensed under the MIT License
144
+ * https://github.com/developit/preact/blob/master/LICENSE
145
+ *
146
+ * Modified for Stencil's compiler and vdom
147
+ */
148
+ // const stack: any[] = [];
149
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
150
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
151
+ const h = (nodeName, vnodeData, ...children) => {
152
+ let child = null;
153
+ let simple = false;
154
+ let lastSimple = false;
155
+ const vNodeChildren = [];
156
+ const walk = (c) => {
157
+ for (let i = 0; i < c.length; i++) {
158
+ child = c[i];
159
+ if (Array.isArray(child)) {
160
+ walk(child);
161
+ }
162
+ else if (child != null && typeof child !== 'boolean') {
163
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
164
+ child = String(child);
165
+ }
166
+ if (simple && lastSimple) {
167
+ // If the previous child was simple (string), we merge both
168
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
169
+ }
170
+ else {
171
+ // Append a new vNode, if it's text, we create a text vNode
172
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
173
+ }
174
+ lastSimple = simple;
175
+ }
176
+ }
177
+ };
178
+ walk(children);
179
+ const vnode = newVNode(nodeName, null);
180
+ vnode.$attrs$ = vnodeData;
181
+ if (vNodeChildren.length > 0) {
182
+ vnode.$children$ = vNodeChildren;
183
+ }
184
+ return vnode;
185
+ };
186
+ const newVNode = (tag, text) => {
187
+ const vnode = {
188
+ $flags$: 0,
189
+ $tag$: tag,
190
+ $text$: text,
191
+ $elm$: null,
192
+ $children$: null,
193
+ };
194
+ return vnode;
195
+ };
196
+ const Host = {};
197
+ const isHost = (node) => node && node.$tag$ === Host;
198
+ /**
199
+ * Create a DOM Node corresponding to one of the children of a given VNode.
200
+ *
201
+ * @param oldParentVNode the parent VNode from the previous render
202
+ * @param newParentVNode the parent VNode from the current render
203
+ * @param childIndex the index of the VNode, in the _new_ parent node's
204
+ * children, for which we will create a new DOM node
205
+ * @param parentElm the parent DOM node which our new node will be a child of
206
+ * @returns the newly created node
207
+ */
208
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
209
+ // tslint:disable-next-line: prefer-const
210
+ const newVNode = newParentVNode.$children$[childIndex];
211
+ let i = 0;
212
+ let elm;
213
+ let childNode;
214
+ if (newVNode.$text$ !== null) {
215
+ // create text node
216
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
217
+ }
218
+ else {
219
+ // create element
220
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
221
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
222
+ // if there is a scopeId and this is the initial render
223
+ // then let's add the scopeId as a css class
224
+ elm.classList.add((elm['s-si'] = scopeId));
225
+ }
226
+ if (newVNode.$children$) {
227
+ for (i = 0; i < newVNode.$children$.length; ++i) {
228
+ // create the node
229
+ childNode = createElm(oldParentVNode, newVNode, i);
230
+ // return node could have been null
231
+ if (childNode) {
232
+ // append our new node
233
+ elm.appendChild(childNode);
234
+ }
235
+ }
236
+ }
237
+ }
238
+ return elm;
239
+ };
240
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
241
+ let containerElm = (parentElm);
242
+ let childNode;
243
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
244
+ containerElm = containerElm.shadowRoot;
245
+ }
246
+ for (; startIdx <= endIdx; ++startIdx) {
247
+ if (vnodes[startIdx]) {
248
+ childNode = createElm(null, parentVNode, startIdx);
249
+ if (childNode) {
250
+ vnodes[startIdx].$elm$ = childNode;
251
+ containerElm.insertBefore(childNode, before);
252
+ }
253
+ }
254
+ }
255
+ };
256
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
257
+ for (; startIdx <= endIdx; ++startIdx) {
258
+ if ((vnode = vnodes[startIdx])) {
259
+ elm = vnode.$elm$;
260
+ // remove the vnode's element from the dom
261
+ elm.remove();
262
+ }
263
+ }
264
+ };
265
+ /**
266
+ * Reconcile the children of a new VNode with the children of an old VNode by
267
+ * traversing the two collections of children, identifying nodes that are
268
+ * conserved or changed, calling out to `patch` to make any necessary
269
+ * updates to the DOM, and rearranging DOM nodes as needed.
270
+ *
271
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
272
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
273
+ * 'windows' by storing start and end indices and references to the
274
+ * corresponding array entries. Initially the two 'windows' are basically equal
275
+ * to the entire array, but we progressively narrow the windows until there are
276
+ * no children left to update by doing the following:
277
+ *
278
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
279
+ * that if we have an initial array like the following we'll end up dealing
280
+ * only with a window bounded by the highlighted elements:
281
+ *
282
+ * [null, null, VNode1 , ... , VNode2, null, null]
283
+ * ^^^^^^ ^^^^^^
284
+ *
285
+ * 2. Check to see if the elements at the head and tail positions are equal
286
+ * across the windows. This will basically detect elements which haven't
287
+ * been added, removed, or changed position, i.e. if you had the following
288
+ * VNode elements (represented as HTML):
289
+ *
290
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
291
+ * newVNode: `<div><p><span>THERE</span></p></div>`
292
+ *
293
+ * Then when comparing the children of the `<div>` tag we check the equality
294
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
295
+ * same tag in the same position, we'd be able to avoid completely
296
+ * re-rendering the subtree under them with a new DOM element and would just
297
+ * call out to `patch` to handle reconciling their children and so on.
298
+ *
299
+ * 3. Check, for both windows, to see if the element at the beginning of the
300
+ * window corresponds to the element at the end of the other window. This is
301
+ * a heuristic which will let us identify _some_ situations in which
302
+ * elements have changed position, for instance it _should_ detect that the
303
+ * children nodes themselves have not changed but merely moved in the
304
+ * following example:
305
+ *
306
+ * oldVNode: `<div><element-one /><element-two /></div>`
307
+ * newVNode: `<div><element-two /><element-one /></div>`
308
+ *
309
+ * If we find cases like this then we also need to move the concrete DOM
310
+ * elements corresponding to the moved children to write the re-order to the
311
+ * DOM.
312
+ *
313
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
314
+ * nodes in the old children which have the same key as the first element in
315
+ * our window on the new children. If we find such a node we handle calling
316
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
317
+ * what we find.
318
+ *
319
+ * Finally, once we've narrowed our 'windows' to the point that either of them
320
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
321
+ * insertion or deletion that needs to happen to get a DOM state that correctly
322
+ * reflects the new child VNodes. If, for instance, after our window on the old
323
+ * children has collapsed we still have more nodes on the new children that
324
+ * we haven't dealt with yet then we need to add them, or if the new children
325
+ * collapse but we still have unhandled _old_ children then we need to make
326
+ * sure the corresponding DOM nodes are removed.
327
+ *
328
+ * @param parentElm the node into which the parent VNode is rendered
329
+ * @param oldCh the old children of the parent node
330
+ * @param newVNode the new VNode which will replace the parent
331
+ * @param newCh the new children of the parent node
332
+ */
333
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
334
+ let oldStartIdx = 0;
335
+ let newStartIdx = 0;
336
+ let oldEndIdx = oldCh.length - 1;
337
+ let oldStartVnode = oldCh[0];
338
+ let oldEndVnode = oldCh[oldEndIdx];
339
+ let newEndIdx = newCh.length - 1;
340
+ let newStartVnode = newCh[0];
341
+ let newEndVnode = newCh[newEndIdx];
342
+ let node;
343
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
344
+ if (oldStartVnode == null) {
345
+ // VNode might have been moved left
346
+ oldStartVnode = oldCh[++oldStartIdx];
347
+ }
348
+ else if (oldEndVnode == null) {
349
+ oldEndVnode = oldCh[--oldEndIdx];
350
+ }
351
+ else if (newStartVnode == null) {
352
+ newStartVnode = newCh[++newStartIdx];
353
+ }
354
+ else if (newEndVnode == null) {
355
+ newEndVnode = newCh[--newEndIdx];
356
+ }
357
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
358
+ // if the start nodes are the same then we should patch the new VNode
359
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
360
+ // indices to reflect that. We don't need to move any DOM Nodes around
361
+ // since things are matched up in order.
362
+ patch(oldStartVnode, newStartVnode);
363
+ oldStartVnode = oldCh[++oldStartIdx];
364
+ newStartVnode = newCh[++newStartIdx];
365
+ }
366
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
367
+ // likewise, if the end nodes are the same we patch new onto old and
368
+ // decrement our end indices, and also likewise in this case we don't
369
+ // need to move any DOM Nodes.
370
+ patch(oldEndVnode, newEndVnode);
371
+ oldEndVnode = oldCh[--oldEndIdx];
372
+ newEndVnode = newCh[--newEndIdx];
373
+ }
374
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
375
+ patch(oldStartVnode, newEndVnode);
376
+ // We need to move the element for `oldStartVnode` into a position which
377
+ // will be appropriate for `newEndVnode`. For this we can use
378
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
379
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
380
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
381
+ //
382
+ // <old-start-node />
383
+ // <some-intervening-node />
384
+ // <old-end-node />
385
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
386
+ // <next-sibling />
387
+ //
388
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
389
+ // the node for `oldStartVnode` at the end of the children of
390
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
391
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
392
+ // append it to the children of the parent element.
393
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
394
+ oldStartVnode = oldCh[++oldStartIdx];
395
+ newEndVnode = newCh[--newEndIdx];
396
+ }
397
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
398
+ patch(oldEndVnode, newStartVnode);
399
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
400
+ // the same node, so since we're here we know that they are not. Thus we
401
+ // can move the element for `oldEndVnode` _before_ the element for
402
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
403
+ // future.
404
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
405
+ oldEndVnode = oldCh[--oldEndIdx];
406
+ newStartVnode = newCh[++newStartIdx];
407
+ }
408
+ else {
409
+ {
410
+ // We either didn't find an element in the old children that matches
411
+ // the key of the first new child OR the build is not using `key`
412
+ // attributes at all. In either case we need to create a new element
413
+ // for the new node.
414
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
415
+ newStartVnode = newCh[++newStartIdx];
416
+ }
417
+ if (node) {
418
+ // if we created a new node then handle inserting it to the DOM
419
+ {
420
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
421
+ }
422
+ }
423
+ }
424
+ }
425
+ if (oldStartIdx > oldEndIdx) {
426
+ // we have some more new nodes to add which don't match up with old nodes
427
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
428
+ }
429
+ else if (newStartIdx > newEndIdx) {
430
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
431
+ // in the new array, so lets remove them (which entails cleaning up the
432
+ // relevant DOM nodes)
433
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
434
+ }
435
+ };
436
+ /**
437
+ * Compare two VNodes to determine if they are the same
438
+ *
439
+ * **NB**: This function is an equality _heuristic_ based on the available
440
+ * information set on the two VNodes and can be misleading under certain
441
+ * circumstances. In particular, if the two nodes do not have `key` attrs
442
+ * (available under `$key$` on VNodes) then the function falls back on merely
443
+ * checking that they have the same tag.
444
+ *
445
+ * So, in other words, if `key` attrs are not set on VNodes which may be
446
+ * changing order within a `children` array or something along those lines then
447
+ * we could obtain a false positive and then have to do needless re-rendering.
448
+ *
449
+ * @param leftVNode the first VNode to check
450
+ * @param rightVNode the second VNode to check
451
+ * @returns whether they're equal or not
452
+ */
453
+ const isSameVnode = (leftVNode, rightVNode) => {
454
+ // compare if two vnode to see if they're "technically" the same
455
+ // need to have the same element tag, and same key to be the same
456
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
457
+ return true;
458
+ }
459
+ return false;
460
+ };
461
+ /**
462
+ * Handle reconciling an outdated VNode with a new one which corresponds to
463
+ * it. This function handles flushing updates to the DOM and reconciling the
464
+ * children of the two nodes (if any).
465
+ *
466
+ * @param oldVNode an old VNode whose DOM element and children we want to update
467
+ * @param newVNode a new VNode representing an updated version of the old one
468
+ */
469
+ const patch = (oldVNode, newVNode) => {
470
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
471
+ const oldChildren = oldVNode.$children$;
472
+ const newChildren = newVNode.$children$;
473
+ const text = newVNode.$text$;
474
+ if (text === null) {
475
+ if (oldChildren !== null && newChildren !== null) {
476
+ // looks like there's child vnodes for both the old and new vnodes
477
+ // so we need to call `updateChildren` to reconcile them
478
+ updateChildren(elm, oldChildren, newVNode, newChildren);
479
+ }
480
+ else if (newChildren !== null) {
481
+ // no old child vnodes, but there are new child vnodes to add
482
+ if (oldVNode.$text$ !== null) {
483
+ // the old vnode was text, so be sure to clear it out
484
+ elm.textContent = '';
485
+ }
486
+ // add the new vnode children
487
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
488
+ }
489
+ else if (oldChildren !== null) {
490
+ // no new child vnodes, but there are old child vnodes to remove
491
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
492
+ }
493
+ }
494
+ else if (oldVNode.$text$ !== text) {
495
+ // update the text content for the text only vnode
496
+ // and also only if the text is different than before
497
+ elm.data = text;
498
+ }
499
+ };
500
+ const renderVdom = (hostRef, renderFnResults) => {
501
+ const hostElm = hostRef.$hostElement$;
502
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
503
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
504
+ hostTagName = hostElm.tagName;
505
+ rootVnode.$tag$ = null;
506
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
507
+ hostRef.$vnode$ = rootVnode;
508
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
509
+ {
510
+ scopeId = hostElm['s-sc'];
511
+ }
512
+ // synchronous patch
513
+ patch(oldVNode, rootVnode);
514
+ };
515
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
516
+ const createEvent = (ref, name, flags) => {
517
+ const elm = getElement(ref);
518
+ return {
519
+ emit: (detail) => {
520
+ return emitEvent(elm, name, {
521
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
522
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
523
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
524
+ detail,
525
+ });
526
+ },
527
+ };
528
+ };
529
+ /**
530
+ * Helper function to create & dispatch a custom Event on a provided target
531
+ * @param elm the target of the Event
532
+ * @param name the name to give the custom Event
533
+ * @param opts options for configuring a custom Event
534
+ * @returns the custom Event
535
+ */
536
+ const emitEvent = (elm, name, opts) => {
537
+ const ev = plt.ce(name, opts);
538
+ elm.dispatchEvent(ev);
539
+ return ev;
540
+ };
541
+ const attachToAncestor = (hostRef, ancestorComponent) => {
542
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
543
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
544
+ }
545
+ };
546
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
547
+ {
548
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
549
+ }
550
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
551
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
552
+ return;
553
+ }
554
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
555
+ // there is no ancestor component or the ancestor component
556
+ // has already fired off its lifecycle update then
557
+ // fire off the initial update
558
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
559
+ return writeTask(dispatch) ;
560
+ };
561
+ const dispatchHooks = (hostRef, isInitialLoad) => {
562
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
563
+ const instance = hostRef.$lazyInstance$ ;
564
+ let promise;
565
+ endSchedule();
566
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
567
+ };
568
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
569
+ // updateComponent
570
+ const elm = hostRef.$hostElement$;
571
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
572
+ const rc = elm['s-rc'];
573
+ if (isInitialLoad) {
574
+ // DOM WRITE!
575
+ attachStyles(hostRef);
576
+ }
577
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
578
+ {
579
+ callRender(hostRef, instance);
580
+ }
581
+ if (rc) {
582
+ // ok, so turns out there are some child host elements
583
+ // waiting on this parent element to load
584
+ // let's fire off all update callbacks waiting
585
+ rc.map((cb) => cb());
586
+ elm['s-rc'] = undefined;
587
+ }
588
+ endRender();
589
+ endUpdate();
590
+ {
591
+ const childrenPromises = elm['s-p'];
592
+ const postUpdate = () => postUpdateComponent(hostRef);
593
+ if (childrenPromises.length === 0) {
594
+ postUpdate();
595
+ }
596
+ else {
597
+ Promise.all(childrenPromises).then(postUpdate);
598
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
599
+ childrenPromises.length = 0;
600
+ }
601
+ }
602
+ };
603
+ const callRender = (hostRef, instance, elm) => {
604
+ try {
605
+ instance = instance.render() ;
606
+ {
607
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
608
+ }
609
+ {
610
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
611
+ }
612
+ {
613
+ {
614
+ // looks like we've got child nodes to render into this host element
615
+ // or we need to update the css class/attrs on the host element
616
+ // DOM WRITE!
617
+ {
618
+ renderVdom(hostRef, instance);
619
+ }
620
+ }
621
+ }
622
+ }
623
+ catch (e) {
624
+ consoleError(e, hostRef.$hostElement$);
625
+ }
626
+ return null;
627
+ };
628
+ const postUpdateComponent = (hostRef) => {
629
+ const tagName = hostRef.$cmpMeta$.$tagName$;
630
+ const elm = hostRef.$hostElement$;
631
+ const endPostUpdate = createTime('postUpdate', tagName);
632
+ const ancestorComponent = hostRef.$ancestorComponent$;
633
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
634
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
635
+ {
636
+ // DOM WRITE!
637
+ addHydratedFlag(elm);
638
+ }
639
+ endPostUpdate();
640
+ {
641
+ hostRef.$onReadyResolve$(elm);
642
+ if (!ancestorComponent) {
643
+ appDidLoad();
644
+ }
645
+ }
646
+ }
647
+ else {
648
+ endPostUpdate();
649
+ }
650
+ {
651
+ hostRef.$onInstanceResolve$(elm);
652
+ }
653
+ // load events fire from bottom to top
654
+ // the deepest elements load first then bubbles up
655
+ {
656
+ if (hostRef.$onRenderResolve$) {
657
+ hostRef.$onRenderResolve$();
658
+ hostRef.$onRenderResolve$ = undefined;
659
+ }
660
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
661
+ nextTick(() => scheduleUpdate(hostRef, false));
662
+ }
663
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
664
+ }
665
+ // ( •_•)
666
+ // ( •_•)>⌐■-■
667
+ // (⌐■_■)
668
+ };
669
+ const appDidLoad = (who) => {
670
+ // on appload
671
+ // we have finish the first big initial render
672
+ {
673
+ addHydratedFlag(doc.documentElement);
674
+ }
675
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
676
+ };
677
+ const then = (promise, thenFn) => {
678
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
679
+ };
680
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
681
+ ;
682
+ /**
683
+ * Parse a new property value for a given property type.
684
+ *
685
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
686
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
687
+ * 1. `any`, the type given to `propValue` in the function signature
688
+ * 2. the type stored from `propType`.
689
+ *
690
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
691
+ *
692
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
693
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
694
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
695
+ * ```tsx
696
+ * <my-cmp prop-val={0}></my-cmp>
697
+ * ```
698
+ *
699
+ * HTML prop values on the other hand, will always a string
700
+ *
701
+ * @param propValue the new value to coerce to some type
702
+ * @param propType the type of the prop, expressed as a binary number
703
+ * @returns the parsed/coerced value
704
+ */
705
+ const parsePropertyValue = (propValue, propType) => {
706
+ // ensure this value is of the correct prop type
707
+ if (propValue != null && !isComplexType(propValue)) {
708
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
709
+ // could have been passed as a number or boolean
710
+ // but we still want it as a string
711
+ return String(propValue);
712
+ }
713
+ // redundant return here for better minification
714
+ return propValue;
715
+ }
716
+ // not sure exactly what type we want
717
+ // so no need to change to a different type
718
+ return propValue;
719
+ };
720
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
721
+ const setValue = (ref, propName, newVal, cmpMeta) => {
722
+ // check our new property value against our internal value
723
+ const hostRef = getHostRef(ref);
724
+ const oldVal = hostRef.$instanceValues$.get(propName);
725
+ const flags = hostRef.$flags$;
726
+ const instance = hostRef.$lazyInstance$ ;
727
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
728
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
729
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
730
+ const didValueChange = newVal !== oldVal && !areBothNaN;
731
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
732
+ // gadzooks! the property's value has changed!!
733
+ // set our new value!
734
+ hostRef.$instanceValues$.set(propName, newVal);
735
+ if (instance) {
736
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
737
+ // looks like this value actually changed, so we've got work to do!
738
+ // but only if we've already rendered, otherwise just chill out
739
+ // queue that we need to do an update, but don't worry about queuing
740
+ // up millions cuz this function ensures it only runs once
741
+ scheduleUpdate(hostRef, false);
742
+ }
743
+ }
744
+ }
745
+ };
746
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
747
+ if (cmpMeta.$members$) {
748
+ // It's better to have a const than two Object.entries()
749
+ const members = Object.entries(cmpMeta.$members$);
750
+ const prototype = Cstr.prototype;
751
+ members.map(([memberName, [memberFlags]]) => {
752
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
753
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
754
+ // proxyComponent - prop
755
+ Object.defineProperty(prototype, memberName, {
756
+ get() {
757
+ // proxyComponent, get value
758
+ return getValue(this, memberName);
759
+ },
760
+ set(newValue) {
761
+ // proxyComponent, set value
762
+ setValue(this, memberName, newValue, cmpMeta);
763
+ },
764
+ configurable: true,
765
+ enumerable: true,
766
+ });
767
+ }
768
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
769
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
770
+ // proxyComponent - method
771
+ Object.defineProperty(prototype, memberName, {
772
+ value(...args) {
773
+ const ref = getHostRef(this);
774
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
775
+ },
776
+ });
777
+ }
778
+ });
779
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
780
+ const attrNameToPropName = new Map();
781
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
782
+ plt.jmp(() => {
783
+ const propName = attrNameToPropName.get(attrName);
784
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
785
+ // in the case where an attribute was set inline.
786
+ // ```html
787
+ // <my-component some-attribute="some-value"></my-component>
788
+ // ```
789
+ //
790
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
791
+ // programmatically changes it before it has been upgraded as shown below:
792
+ //
793
+ // ```html
794
+ // <!-- this component has _not_ been upgraded yet -->
795
+ // <my-component id="test" some-attribute="some-value"></my-component>
796
+ // <script>
797
+ // // grab non-upgraded component
798
+ // el = document.querySelector("#test");
799
+ // el.someAttribute = "another-value";
800
+ // // upgrade component
801
+ // customElements.define('my-component', MyComponent);
802
+ // </script>
803
+ // ```
804
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
805
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
806
+ // to the value that was set inline i.e. "some-value" from above example. When
807
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
808
+ //
809
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
810
+ // by connectedCallback as this attributeChangedCallback will not fire.
811
+ //
812
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
813
+ //
814
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
815
+ // properties here given that this goes against best practices outlined here
816
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
817
+ if (this.hasOwnProperty(propName)) {
818
+ newValue = this[propName];
819
+ delete this[propName];
820
+ }
821
+ else if (prototype.hasOwnProperty(propName) &&
822
+ typeof this[propName] === 'number' &&
823
+ this[propName] == newValue) {
824
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
825
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
826
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
827
+ return;
828
+ }
829
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
830
+ });
831
+ };
832
+ // create an array of attributes to observe
833
+ // and also create a map of html attribute name to js property name
834
+ Cstr.observedAttributes = members
835
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
836
+ .map(([propName, m]) => {
837
+ const attrName = m[1] || propName;
838
+ attrNameToPropName.set(attrName, propName);
839
+ return attrName;
840
+ });
841
+ }
842
+ }
843
+ return Cstr;
844
+ };
845
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
846
+ // initializeComponent
847
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
848
+ {
849
+ // we haven't initialized this element yet
850
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
851
+ // lazy loaded components
852
+ // request the component's implementation to be
853
+ // wired up with the host element
854
+ Cstr = loadModule(cmpMeta);
855
+ if (Cstr.then) {
856
+ // Await creates a micro-task avoid if possible
857
+ const endLoad = uniqueTime();
858
+ Cstr = await Cstr;
859
+ endLoad();
860
+ }
861
+ if (!Cstr.isProxied) {
862
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
863
+ Cstr.isProxied = true;
864
+ }
865
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
866
+ // ok, time to construct the instance
867
+ // but let's keep track of when we start and stop
868
+ // so that the getters/setters don't incorrectly step on data
869
+ {
870
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
871
+ }
872
+ // construct the lazy-loaded component implementation
873
+ // passing the hostRef is very important during
874
+ // construction in order to directly wire together the
875
+ // host element and the lazy-loaded instance
876
+ try {
877
+ new Cstr(hostRef);
878
+ }
879
+ catch (e) {
880
+ consoleError(e);
881
+ }
882
+ {
883
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
884
+ }
885
+ endNewInstance();
886
+ }
887
+ if (Cstr.style) {
888
+ // this component has styles but we haven't registered them yet
889
+ let style = Cstr.style;
890
+ const scopeId = getScopeId(cmpMeta);
891
+ if (!styles.has(scopeId)) {
892
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
893
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
894
+ endRegisterStyles();
895
+ }
896
+ }
897
+ }
898
+ // we've successfully created a lazy instance
899
+ const ancestorComponent = hostRef.$ancestorComponent$;
900
+ const schedule = () => scheduleUpdate(hostRef, true);
901
+ if (ancestorComponent && ancestorComponent['s-rc']) {
902
+ // this is the initial load and this component it has an ancestor component
903
+ // but the ancestor component has NOT fired its will update lifecycle yet
904
+ // so let's just cool our jets and wait for the ancestor to continue first
905
+ // this will get fired off when the ancestor component
906
+ // finally gets around to rendering its lazy self
907
+ // fire off the initial update
908
+ ancestorComponent['s-rc'].push(schedule);
909
+ }
910
+ else {
911
+ schedule();
912
+ }
913
+ };
914
+ const connectedCallback = (elm) => {
915
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
916
+ const hostRef = getHostRef(elm);
917
+ const cmpMeta = hostRef.$cmpMeta$;
918
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
919
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
920
+ // first time this component has connected
921
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
922
+ {
923
+ // find the first ancestor component (if there is one) and register
924
+ // this component as one of the actively loading child components for its ancestor
925
+ let ancestorComponent = elm;
926
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
927
+ // climb up the ancestors looking for the first
928
+ // component that hasn't finished its lifecycle update yet
929
+ if (ancestorComponent['s-p']) {
930
+ // we found this components first ancestor component
931
+ // keep a reference to this component's ancestor component
932
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
933
+ break;
934
+ }
935
+ }
936
+ }
937
+ // Lazy properties
938
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
939
+ if (cmpMeta.$members$) {
940
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
941
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
942
+ const value = elm[memberName];
943
+ delete elm[memberName];
944
+ elm[memberName] = value;
945
+ }
946
+ });
947
+ }
948
+ {
949
+ initializeComponent(elm, hostRef, cmpMeta);
950
+ }
951
+ }
952
+ endConnected();
953
+ }
954
+ };
955
+ const disconnectedCallback = (elm) => {
956
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
957
+ getHostRef(elm);
958
+ }
959
+ };
960
+ const bootstrapLazy = (lazyBundles, options = {}) => {
961
+ const endBootstrap = createTime();
962
+ const cmpTags = [];
963
+ const exclude = options.exclude || [];
964
+ const customElements = win.customElements;
965
+ const head = doc.head;
966
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
967
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
968
+ const deferredConnectedCallbacks = [];
969
+ let appLoadFallback;
970
+ let isBootstrapping = true;
971
+ Object.assign(plt, options);
972
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
973
+ lazyBundles.map((lazyBundle) => {
974
+ lazyBundle[1].map((compactMeta) => {
975
+ const cmpMeta = {
976
+ $flags$: compactMeta[0],
977
+ $tagName$: compactMeta[1],
978
+ $members$: compactMeta[2],
979
+ $listeners$: compactMeta[3],
980
+ };
981
+ {
982
+ cmpMeta.$members$ = compactMeta[2];
983
+ }
984
+ const tagName = cmpMeta.$tagName$;
985
+ const HostElement = class extends HTMLElement {
986
+ // StencilLazyHost
987
+ constructor(self) {
988
+ // @ts-ignore
989
+ super(self);
990
+ self = this;
991
+ registerHost(self, cmpMeta);
992
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
993
+ // this component is using shadow dom
994
+ // and this browser supports shadow dom
995
+ // add the read-only property "shadowRoot" to the host element
996
+ // adding the shadow root build conditionals to minimize runtime
997
+ {
998
+ {
999
+ self.attachShadow({ mode: 'open' });
1000
+ }
1001
+ }
1002
+ }
1003
+ }
1004
+ connectedCallback() {
1005
+ if (appLoadFallback) {
1006
+ clearTimeout(appLoadFallback);
1007
+ appLoadFallback = null;
1008
+ }
1009
+ if (isBootstrapping) {
1010
+ // connectedCallback will be processed once all components have been registered
1011
+ deferredConnectedCallbacks.push(this);
1012
+ }
1013
+ else {
1014
+ plt.jmp(() => connectedCallback(this));
1015
+ }
1016
+ }
1017
+ disconnectedCallback() {
1018
+ plt.jmp(() => disconnectedCallback(this));
1019
+ }
1020
+ componentOnReady() {
1021
+ return getHostRef(this).$onReadyPromise$;
1022
+ }
1023
+ };
1024
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1025
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1026
+ cmpTags.push(tagName);
1027
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1028
+ }
1029
+ });
1030
+ });
1031
+ {
1032
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1033
+ visibilityStyle.setAttribute('data-styles', '');
1034
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1035
+ }
1036
+ // Process deferred connectedCallbacks now all components have been registered
1037
+ isBootstrapping = false;
1038
+ if (deferredConnectedCallbacks.length) {
1039
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1040
+ }
1041
+ else {
1042
+ {
1043
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1044
+ }
1045
+ }
1046
+ // Fallback appLoad event
1047
+ endBootstrap();
1048
+ };
1049
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1050
+ const getHostRef = (ref) => hostRefs.get(ref);
1051
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1052
+ const registerHost = (elm, cmpMeta) => {
1053
+ const hostRef = {
1054
+ $flags$: 0,
1055
+ $hostElement$: elm,
1056
+ $cmpMeta$: cmpMeta,
1057
+ $instanceValues$: new Map(),
1058
+ };
1059
+ {
1060
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1061
+ }
1062
+ {
1063
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1064
+ elm['s-p'] = [];
1065
+ elm['s-rc'] = [];
1066
+ }
1067
+ return hostRefs.set(elm, hostRef);
1068
+ };
1069
+ const consoleError = (e, el) => (0, console.error)(e, el);
1070
+ const cmpModules = /*@__PURE__*/ new Map();
1071
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1072
+ // loadModuleImport
1073
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1074
+ const bundleId = cmpMeta.$lazyBundleId$;
1075
+ const module = cmpModules.get(bundleId) ;
1076
+ if (module) {
1077
+ return module[exportName];
1078
+ }
1079
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1080
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1081
+ /* @vite-ignore */
1082
+ /* webpackInclude: /\.entry\.js$/ */
1083
+ /* webpackExclude: /\.system\.entry\.js$/ */
1084
+ /* webpackMode: "lazy" */
1085
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1086
+ {
1087
+ cmpModules.set(bundleId, importedModule);
1088
+ }
1089
+ return importedModule[exportName];
1090
+ }, consoleError);
1091
+ };
1092
+ const styles = /*@__PURE__*/ new Map();
1093
+ const queueDomReads = [];
1094
+ const queueDomWrites = [];
1095
+ const queueTask = (queue, write) => (cb) => {
1096
+ queue.push(cb);
1097
+ if (!queuePending) {
1098
+ queuePending = true;
1099
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1100
+ nextTick(flush);
1101
+ }
1102
+ else {
1103
+ plt.raf(flush);
1104
+ }
1105
+ }
1106
+ };
1107
+ const consume = (queue) => {
1108
+ for (let i = 0; i < queue.length; i++) {
1109
+ try {
1110
+ queue[i](performance.now());
1111
+ }
1112
+ catch (e) {
1113
+ consoleError(e);
1114
+ }
1115
+ }
1116
+ queue.length = 0;
1117
+ };
1118
+ const flush = () => {
1119
+ // always force a bunch of medium callbacks to run, but still have
1120
+ // a throttle on how many can run in a certain time
1121
+ // DOM READS!!!
1122
+ consume(queueDomReads);
1123
+ // DOM WRITES!!!
1124
+ {
1125
+ consume(queueDomWrites);
1126
+ if ((queuePending = queueDomReads.length > 0)) {
1127
+ // still more to do yet, but we've run out of time
1128
+ // let's let this thing cool off and try again in the next tick
1129
+ plt.raf(flush);
1130
+ }
1131
+ }
1132
+ };
1133
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1134
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1135
+
1136
+ exports.bootstrapLazy = bootstrapLazy;
1137
+ exports.createEvent = createEvent;
1138
+ exports.h = h;
1139
+ exports.promiseResolve = promiseResolve;
1140
+ exports.registerInstance = registerInstance;