@everymatrix/general-styling-wrapper 1.15.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 (45) hide show
  1. package/dist/cjs/general-styling-wrapper.cjs.entry.js +87 -0
  2. package/dist/cjs/general-styling-wrapper.cjs.js +19 -0
  3. package/dist/cjs/index-38077f5d.js +1407 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/general-styling-wrapper/general-styling-wrapper.css +3 -0
  8. package/dist/collection/components/general-styling-wrapper/general-styling-wrapper.js +145 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/locale.utils.js +15 -0
  11. package/dist/components/general-styling-wrapper.d.ts +11 -0
  12. package/dist/components/general-styling-wrapper.js +105 -0
  13. package/dist/components/index.d.ts +26 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/esm/general-styling-wrapper.entry.js +83 -0
  16. package/dist/esm/general-styling-wrapper.js +17 -0
  17. package/dist/esm/index-10c47fc0.js +1382 -0
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/loader.js +17 -0
  20. package/dist/esm/polyfills/core-js.js +11 -0
  21. package/dist/esm/polyfills/css-shim.js +1 -0
  22. package/dist/esm/polyfills/dom.js +79 -0
  23. package/dist/esm/polyfills/es5-html-element.js +1 -0
  24. package/dist/esm/polyfills/index.js +34 -0
  25. package/dist/esm/polyfills/system.js +6 -0
  26. package/dist/general-styling-wrapper/general-styling-wrapper.esm.js +1 -0
  27. package/dist/general-styling-wrapper/index.esm.js +0 -0
  28. package/dist/general-styling-wrapper/p-05de0679.js +1 -0
  29. package/dist/general-styling-wrapper/p-69081248.entry.js +1 -0
  30. package/dist/index.cjs.js +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/stencil.config.js +22 -0
  33. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-styling-wrapper/.stencil/packages/general-styling-wrapper/stencil.config.d.ts +2 -0
  34. package/dist/types/components/general-styling-wrapper/general-styling-wrapper.d.ts +26 -0
  35. package/dist/types/components.d.ts +70 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  38. package/dist/types/utils/locale.utils.d.ts +8 -0
  39. package/loader/cdn.js +3 -0
  40. package/loader/index.cjs.js +3 -0
  41. package/loader/index.d.ts +12 -0
  42. package/loader/index.es2017.js +3 -0
  43. package/loader/index.js +4 -0
  44. package/loader/package.json +10 -0
  45. package/package.json +19 -0
@@ -0,0 +1,1407 @@
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 = 'general-styling-wrapper';
24
+
25
+ let contentRef;
26
+ let hostTagName;
27
+ let useNativeShadowDom = false;
28
+ let checkSlotFallbackVisibility = false;
29
+ let checkSlotRelocate = false;
30
+ let isSvgMode = false;
31
+ let queuePending = false;
32
+ const win = typeof window !== 'undefined' ? window : {};
33
+ const doc = win.document || { head: {} };
34
+ const plt = {
35
+ $flags$: 0,
36
+ $resourcesUrl$: '',
37
+ jmp: (h) => h(),
38
+ raf: (h) => requestAnimationFrame(h),
39
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
40
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
41
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
42
+ };
43
+ const promiseResolve = (v) => Promise.resolve(v);
44
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
45
+ try {
46
+ new CSSStyleSheet();
47
+ return typeof new CSSStyleSheet().replace === 'function';
48
+ }
49
+ catch (e) { }
50
+ return false;
51
+ })()
52
+ ;
53
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
54
+ const createTime = (fnName, tagName = '') => {
55
+ {
56
+ return () => {
57
+ return;
58
+ };
59
+ }
60
+ };
61
+ const uniqueTime = (key, measureText) => {
62
+ {
63
+ return () => {
64
+ return;
65
+ };
66
+ }
67
+ };
68
+ const rootAppliedStyles = new WeakMap();
69
+ const registerStyle = (scopeId, cssText, allowCS) => {
70
+ let style = styles.get(scopeId);
71
+ if (supportsConstructibleStylesheets && allowCS) {
72
+ style = (style || new CSSStyleSheet());
73
+ style.replace(cssText);
74
+ }
75
+ else {
76
+ style = cssText;
77
+ }
78
+ styles.set(scopeId, style);
79
+ };
80
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
81
+ let scopeId = getScopeId(cmpMeta);
82
+ let style = styles.get(scopeId);
83
+ // if an element is NOT connected then getRootNode() will return the wrong root node
84
+ // so the fallback is to always use the document for the root node in those cases
85
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
86
+ if (style) {
87
+ if (typeof style === 'string') {
88
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
89
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
90
+ let styleElm;
91
+ if (!appliedStyles) {
92
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
93
+ }
94
+ if (!appliedStyles.has(scopeId)) {
95
+ {
96
+ {
97
+ styleElm = doc.createElement('style');
98
+ styleElm.innerHTML = style;
99
+ }
100
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
101
+ }
102
+ if (appliedStyles) {
103
+ appliedStyles.add(scopeId);
104
+ }
105
+ }
106
+ }
107
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
108
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
109
+ }
110
+ }
111
+ return scopeId;
112
+ };
113
+ const attachStyles = (hostRef) => {
114
+ const cmpMeta = hostRef.$cmpMeta$;
115
+ const elm = hostRef.$hostElement$;
116
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
117
+ addStyle(elm.getRootNode(), cmpMeta);
118
+ endAttachStyles();
119
+ };
120
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
121
+ /**
122
+ * Default style mode id
123
+ */
124
+ /**
125
+ * Reusable empty obj/array
126
+ * Don't add values to these!!
127
+ */
128
+ const EMPTY_OBJ = {};
129
+ const isComplexType = (o) => {
130
+ // https://jsperf.com/typeof-fn-object/5
131
+ o = typeof o;
132
+ return o === 'object' || o === 'function';
133
+ };
134
+ /**
135
+ * Production h() function based on Preact by
136
+ * Jason Miller (@developit)
137
+ * Licensed under the MIT License
138
+ * https://github.com/developit/preact/blob/master/LICENSE
139
+ *
140
+ * Modified for Stencil's compiler and vdom
141
+ */
142
+ // const stack: any[] = [];
143
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
144
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
145
+ const h = (nodeName, vnodeData, ...children) => {
146
+ let child = null;
147
+ let slotName = null;
148
+ let simple = false;
149
+ let lastSimple = false;
150
+ let vNodeChildren = [];
151
+ const walk = (c) => {
152
+ for (let i = 0; i < c.length; i++) {
153
+ child = c[i];
154
+ if (Array.isArray(child)) {
155
+ walk(child);
156
+ }
157
+ else if (child != null && typeof child !== 'boolean') {
158
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
159
+ child = String(child);
160
+ }
161
+ if (simple && lastSimple) {
162
+ // If the previous child was simple (string), we merge both
163
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
164
+ }
165
+ else {
166
+ // Append a new vNode, if it's text, we create a text vNode
167
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
168
+ }
169
+ lastSimple = simple;
170
+ }
171
+ }
172
+ };
173
+ walk(children);
174
+ if (vnodeData) {
175
+ if (vnodeData.name) {
176
+ slotName = vnodeData.name;
177
+ }
178
+ {
179
+ const classData = vnodeData.className || vnodeData.class;
180
+ if (classData) {
181
+ vnodeData.class =
182
+ typeof classData !== 'object'
183
+ ? classData
184
+ : Object.keys(classData)
185
+ .filter((k) => classData[k])
186
+ .join(' ');
187
+ }
188
+ }
189
+ }
190
+ const vnode = newVNode(nodeName, null);
191
+ vnode.$attrs$ = vnodeData;
192
+ if (vNodeChildren.length > 0) {
193
+ vnode.$children$ = vNodeChildren;
194
+ }
195
+ {
196
+ vnode.$name$ = slotName;
197
+ }
198
+ return vnode;
199
+ };
200
+ const newVNode = (tag, text) => {
201
+ const vnode = {
202
+ $flags$: 0,
203
+ $tag$: tag,
204
+ $text$: text,
205
+ $elm$: null,
206
+ $children$: null,
207
+ };
208
+ {
209
+ vnode.$attrs$ = null;
210
+ }
211
+ {
212
+ vnode.$name$ = null;
213
+ }
214
+ return vnode;
215
+ };
216
+ const Host = {};
217
+ const isHost = (node) => node && node.$tag$ === Host;
218
+ /**
219
+ * Production setAccessor() function based on Preact by
220
+ * Jason Miller (@developit)
221
+ * Licensed under the MIT License
222
+ * https://github.com/developit/preact/blob/master/LICENSE
223
+ *
224
+ * Modified for Stencil's compiler and vdom
225
+ */
226
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
227
+ if (oldValue !== newValue) {
228
+ let isProp = isMemberInElement(elm, memberName);
229
+ memberName.toLowerCase();
230
+ if (memberName === 'class') {
231
+ const classList = elm.classList;
232
+ const oldClasses = parseClassList(oldValue);
233
+ const newClasses = parseClassList(newValue);
234
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
235
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
236
+ }
237
+ else if (memberName === 'ref') {
238
+ // minifier will clean this up
239
+ if (newValue) {
240
+ newValue(elm);
241
+ }
242
+ }
243
+ else {
244
+ // Set property if it exists and it's not a SVG
245
+ const isComplex = isComplexType(newValue);
246
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
247
+ try {
248
+ if (!elm.tagName.includes('-')) {
249
+ let n = newValue == null ? '' : newValue;
250
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
251
+ if (memberName === 'list') {
252
+ isProp = false;
253
+ }
254
+ else if (oldValue == null || elm[memberName] != n) {
255
+ elm[memberName] = n;
256
+ }
257
+ }
258
+ else {
259
+ elm[memberName] = newValue;
260
+ }
261
+ }
262
+ catch (e) { }
263
+ }
264
+ if (newValue == null || newValue === false) {
265
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
266
+ {
267
+ elm.removeAttribute(memberName);
268
+ }
269
+ }
270
+ }
271
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
272
+ newValue = newValue === true ? '' : newValue;
273
+ {
274
+ elm.setAttribute(memberName, newValue);
275
+ }
276
+ }
277
+ }
278
+ }
279
+ };
280
+ const parseClassListRegex = /\s/;
281
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
282
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
283
+ // if the element passed in is a shadow root, which is a document fragment
284
+ // then we want to be adding attrs/props to the shadow root's "host" element
285
+ // if it's not a shadow root, then we add attrs/props to the same element
286
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
287
+ ? newVnode.$elm$.host
288
+ : newVnode.$elm$;
289
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
290
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
291
+ {
292
+ // remove attributes no longer present on the vnode by setting them to undefined
293
+ for (memberName in oldVnodeAttrs) {
294
+ if (!(memberName in newVnodeAttrs)) {
295
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
296
+ }
297
+ }
298
+ }
299
+ // add new & update changed attributes
300
+ for (memberName in newVnodeAttrs) {
301
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
302
+ }
303
+ };
304
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
305
+ // tslint:disable-next-line: prefer-const
306
+ let newVNode = newParentVNode.$children$[childIndex];
307
+ let i = 0;
308
+ let elm;
309
+ let childNode;
310
+ let oldVNode;
311
+ if (!useNativeShadowDom) {
312
+ // remember for later we need to check to relocate nodes
313
+ checkSlotRelocate = true;
314
+ if (newVNode.$tag$ === 'slot') {
315
+ newVNode.$flags$ |= newVNode.$children$
316
+ ? // slot element has fallback content
317
+ 2 /* isSlotFallback */
318
+ : // slot element does not have fallback content
319
+ 1 /* isSlotReference */;
320
+ }
321
+ }
322
+ if (newVNode.$flags$ & 1 /* isSlotReference */) {
323
+ // create a slot reference node
324
+ elm = newVNode.$elm$ =
325
+ doc.createTextNode('');
326
+ }
327
+ else {
328
+ // create element
329
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
330
+ ? 'slot-fb'
331
+ : newVNode.$tag$));
332
+ // add css classes, attrs, props, listeners, etc.
333
+ {
334
+ updateElement(null, newVNode, isSvgMode);
335
+ }
336
+ if (newVNode.$children$) {
337
+ for (i = 0; i < newVNode.$children$.length; ++i) {
338
+ // create the node
339
+ childNode = createElm(oldParentVNode, newVNode, i);
340
+ // return node could have been null
341
+ if (childNode) {
342
+ // append our new node
343
+ elm.appendChild(childNode);
344
+ }
345
+ }
346
+ }
347
+ }
348
+ {
349
+ elm['s-hn'] = hostTagName;
350
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
351
+ // remember the content reference comment
352
+ elm['s-sr'] = true;
353
+ // remember the content reference comment
354
+ elm['s-cr'] = contentRef;
355
+ // remember the slot name, or empty string for default slot
356
+ elm['s-sn'] = newVNode.$name$ || '';
357
+ // check if we've got an old vnode for this slot
358
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
359
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
360
+ // we've got an old slot vnode and the wrapper is being replaced
361
+ // so let's move the old slot content back to it's original location
362
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
363
+ }
364
+ }
365
+ }
366
+ return elm;
367
+ };
368
+ const putBackInOriginalLocation = (parentElm, recursive) => {
369
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
370
+ const oldSlotChildNodes = parentElm.childNodes;
371
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
372
+ const childNode = oldSlotChildNodes[i];
373
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
374
+ // // this child node in the old element is from another component
375
+ // // remove this node from the old slot's parent
376
+ // childNode.remove();
377
+ // and relocate it back to it's original location
378
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
379
+ // remove the old original location comment entirely
380
+ // later on the patch function will know what to do
381
+ // and move this to the correct spot in need be
382
+ childNode['s-ol'].remove();
383
+ childNode['s-ol'] = undefined;
384
+ checkSlotRelocate = true;
385
+ }
386
+ if (recursive) {
387
+ putBackInOriginalLocation(childNode, recursive);
388
+ }
389
+ }
390
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
391
+ };
392
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
393
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
394
+ let childNode;
395
+ for (; startIdx <= endIdx; ++startIdx) {
396
+ if (vnodes[startIdx]) {
397
+ childNode = createElm(null, parentVNode, startIdx);
398
+ if (childNode) {
399
+ vnodes[startIdx].$elm$ = childNode;
400
+ containerElm.insertBefore(childNode, referenceNode(before) );
401
+ }
402
+ }
403
+ }
404
+ };
405
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
406
+ for (; startIdx <= endIdx; ++startIdx) {
407
+ if ((vnode = vnodes[startIdx])) {
408
+ elm = vnode.$elm$;
409
+ callNodeRefs(vnode);
410
+ {
411
+ // we're removing this element
412
+ // so it's possible we need to show slot fallback content now
413
+ checkSlotFallbackVisibility = true;
414
+ if (elm['s-ol']) {
415
+ // remove the original location comment
416
+ elm['s-ol'].remove();
417
+ }
418
+ else {
419
+ // it's possible that child nodes of the node
420
+ // that's being removed are slot nodes
421
+ putBackInOriginalLocation(elm, true);
422
+ }
423
+ }
424
+ // remove the vnode's element from the dom
425
+ elm.remove();
426
+ }
427
+ }
428
+ };
429
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
430
+ let oldStartIdx = 0;
431
+ let newStartIdx = 0;
432
+ let oldEndIdx = oldCh.length - 1;
433
+ let oldStartVnode = oldCh[0];
434
+ let oldEndVnode = oldCh[oldEndIdx];
435
+ let newEndIdx = newCh.length - 1;
436
+ let newStartVnode = newCh[0];
437
+ let newEndVnode = newCh[newEndIdx];
438
+ let node;
439
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
440
+ if (oldStartVnode == null) {
441
+ // Vnode might have been moved left
442
+ oldStartVnode = oldCh[++oldStartIdx];
443
+ }
444
+ else if (oldEndVnode == null) {
445
+ oldEndVnode = oldCh[--oldEndIdx];
446
+ }
447
+ else if (newStartVnode == null) {
448
+ newStartVnode = newCh[++newStartIdx];
449
+ }
450
+ else if (newEndVnode == null) {
451
+ newEndVnode = newCh[--newEndIdx];
452
+ }
453
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
454
+ patch(oldStartVnode, newStartVnode);
455
+ oldStartVnode = oldCh[++oldStartIdx];
456
+ newStartVnode = newCh[++newStartIdx];
457
+ }
458
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
459
+ patch(oldEndVnode, newEndVnode);
460
+ oldEndVnode = oldCh[--oldEndIdx];
461
+ newEndVnode = newCh[--newEndIdx];
462
+ }
463
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
464
+ // Vnode moved right
465
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
466
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
467
+ }
468
+ patch(oldStartVnode, newEndVnode);
469
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
470
+ oldStartVnode = oldCh[++oldStartIdx];
471
+ newEndVnode = newCh[--newEndIdx];
472
+ }
473
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
474
+ // Vnode moved left
475
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
476
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
477
+ }
478
+ patch(oldEndVnode, newStartVnode);
479
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
480
+ oldEndVnode = oldCh[--oldEndIdx];
481
+ newStartVnode = newCh[++newStartIdx];
482
+ }
483
+ else {
484
+ {
485
+ // new element
486
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
487
+ newStartVnode = newCh[++newStartIdx];
488
+ }
489
+ if (node) {
490
+ {
491
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
492
+ }
493
+ }
494
+ }
495
+ }
496
+ if (oldStartIdx > oldEndIdx) {
497
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
498
+ }
499
+ else if (newStartIdx > newEndIdx) {
500
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
501
+ }
502
+ };
503
+ const isSameVnode = (vnode1, vnode2) => {
504
+ // compare if two vnode to see if they're "technically" the same
505
+ // need to have the same element tag, and same key to be the same
506
+ if (vnode1.$tag$ === vnode2.$tag$) {
507
+ if (vnode1.$tag$ === 'slot') {
508
+ return vnode1.$name$ === vnode2.$name$;
509
+ }
510
+ return true;
511
+ }
512
+ return false;
513
+ };
514
+ const referenceNode = (node) => {
515
+ // this node was relocated to a new location in the dom
516
+ // because of some other component's slot
517
+ // but we still have an html comment in place of where
518
+ // it's original location was according to it's original vdom
519
+ return (node && node['s-ol']) || node;
520
+ };
521
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
522
+ const patch = (oldVNode, newVNode) => {
523
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
524
+ const oldChildren = oldVNode.$children$;
525
+ const newChildren = newVNode.$children$;
526
+ const tag = newVNode.$tag$;
527
+ {
528
+ // element node
529
+ {
530
+ if (tag === 'slot')
531
+ ;
532
+ else {
533
+ // either this is the first render of an element OR it's an update
534
+ // AND we already know it's possible it could have changed
535
+ // this updates the element's css classes, attrs, props, listeners, etc.
536
+ updateElement(oldVNode, newVNode, isSvgMode);
537
+ }
538
+ }
539
+ if (oldChildren !== null && newChildren !== null) {
540
+ // looks like there's child vnodes for both the old and new vnodes
541
+ updateChildren(elm, oldChildren, newVNode, newChildren);
542
+ }
543
+ else if (newChildren !== null) {
544
+ // add the new vnode children
545
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
546
+ }
547
+ else if (oldChildren !== null) {
548
+ // no new child vnodes, but there are old child vnodes to remove
549
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
550
+ }
551
+ }
552
+ };
553
+ const updateFallbackSlotVisibility = (elm) => {
554
+ // tslint:disable-next-line: prefer-const
555
+ let childNodes = elm.childNodes;
556
+ let childNode;
557
+ let i;
558
+ let ilen;
559
+ let j;
560
+ let slotNameAttr;
561
+ let nodeType;
562
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
563
+ childNode = childNodes[i];
564
+ if (childNode.nodeType === 1 /* ElementNode */) {
565
+ if (childNode['s-sr']) {
566
+ // this is a slot fallback node
567
+ // get the slot name for this slot reference node
568
+ slotNameAttr = childNode['s-sn'];
569
+ // by default always show a fallback slot node
570
+ // then hide it if there are other slots in the light dom
571
+ childNode.hidden = false;
572
+ for (j = 0; j < ilen; j++) {
573
+ nodeType = childNodes[j].nodeType;
574
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
575
+ // this sibling node is from a different component OR is a named fallback slot node
576
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
577
+ childNode.hidden = true;
578
+ break;
579
+ }
580
+ }
581
+ else {
582
+ // this is a default fallback slot node
583
+ // any element or text node (with content)
584
+ // should hide the default fallback slot node
585
+ if (nodeType === 1 /* ElementNode */ ||
586
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
587
+ childNode.hidden = true;
588
+ break;
589
+ }
590
+ }
591
+ }
592
+ }
593
+ // keep drilling down
594
+ updateFallbackSlotVisibility(childNode);
595
+ }
596
+ }
597
+ };
598
+ const relocateNodes = [];
599
+ const relocateSlotContent = (elm) => {
600
+ // tslint:disable-next-line: prefer-const
601
+ let childNode;
602
+ let node;
603
+ let hostContentNodes;
604
+ let slotNameAttr;
605
+ let relocateNodeData;
606
+ let j;
607
+ let i = 0;
608
+ let childNodes = elm.childNodes;
609
+ let ilen = childNodes.length;
610
+ for (; i < ilen; i++) {
611
+ childNode = childNodes[i];
612
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
613
+ // first got the content reference comment node
614
+ // then we got it's parent, which is where all the host content is in now
615
+ hostContentNodes = node.parentNode.childNodes;
616
+ slotNameAttr = childNode['s-sn'];
617
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
618
+ node = hostContentNodes[j];
619
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
620
+ // let's do some relocating to its new home
621
+ // but never relocate a content reference node
622
+ // that is suppose to always represent the original content location
623
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
624
+ // it's possible we've already decided to relocate this node
625
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
626
+ // made some changes to slots
627
+ // let's make sure we also double check
628
+ // fallbacks are correctly hidden or shown
629
+ checkSlotFallbackVisibility = true;
630
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
631
+ if (relocateNodeData) {
632
+ // previously we never found a slot home for this node
633
+ // but turns out we did, so let's remember it now
634
+ relocateNodeData.$slotRefNode$ = childNode;
635
+ }
636
+ else {
637
+ // add to our list of nodes to relocate
638
+ relocateNodes.push({
639
+ $slotRefNode$: childNode,
640
+ $nodeToRelocate$: node,
641
+ });
642
+ }
643
+ if (node['s-sr']) {
644
+ relocateNodes.map((relocateNode) => {
645
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
646
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
647
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
648
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
649
+ }
650
+ }
651
+ });
652
+ }
653
+ }
654
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
655
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
656
+ // if we never find a home for this element then we'll need to hide it
657
+ relocateNodes.push({
658
+ $nodeToRelocate$: node,
659
+ });
660
+ }
661
+ }
662
+ }
663
+ }
664
+ if (childNode.nodeType === 1 /* ElementNode */) {
665
+ relocateSlotContent(childNode);
666
+ }
667
+ }
668
+ };
669
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
670
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
671
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
672
+ return true;
673
+ }
674
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
675
+ return true;
676
+ }
677
+ return false;
678
+ }
679
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
680
+ return true;
681
+ }
682
+ return slotNameAttr === '';
683
+ };
684
+ const callNodeRefs = (vNode) => {
685
+ {
686
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
687
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
688
+ }
689
+ };
690
+ const renderVdom = (hostRef, renderFnResults) => {
691
+ const hostElm = hostRef.$hostElement$;
692
+ const cmpMeta = hostRef.$cmpMeta$;
693
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
694
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
695
+ hostTagName = hostElm.tagName;
696
+ rootVnode.$tag$ = null;
697
+ rootVnode.$flags$ |= 4 /* isHost */;
698
+ hostRef.$vnode$ = rootVnode;
699
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
700
+ {
701
+ contentRef = hostElm['s-cr'];
702
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
703
+ // always reset
704
+ checkSlotFallbackVisibility = false;
705
+ }
706
+ // synchronous patch
707
+ patch(oldVNode, rootVnode);
708
+ {
709
+ // while we're moving nodes around existing nodes, temporarily disable
710
+ // the disconnectCallback from working
711
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
712
+ if (checkSlotRelocate) {
713
+ relocateSlotContent(rootVnode.$elm$);
714
+ let relocateData;
715
+ let nodeToRelocate;
716
+ let orgLocationNode;
717
+ let parentNodeRef;
718
+ let insertBeforeNode;
719
+ let refNode;
720
+ let i = 0;
721
+ for (; i < relocateNodes.length; i++) {
722
+ relocateData = relocateNodes[i];
723
+ nodeToRelocate = relocateData.$nodeToRelocate$;
724
+ if (!nodeToRelocate['s-ol']) {
725
+ // add a reference node marking this node's original location
726
+ // keep a reference to this node for later lookups
727
+ orgLocationNode =
728
+ doc.createTextNode('');
729
+ orgLocationNode['s-nr'] = nodeToRelocate;
730
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
731
+ }
732
+ }
733
+ for (i = 0; i < relocateNodes.length; i++) {
734
+ relocateData = relocateNodes[i];
735
+ nodeToRelocate = relocateData.$nodeToRelocate$;
736
+ if (relocateData.$slotRefNode$) {
737
+ // by default we're just going to insert it directly
738
+ // after the slot reference node
739
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
740
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
741
+ orgLocationNode = nodeToRelocate['s-ol'];
742
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
743
+ refNode = orgLocationNode['s-nr'];
744
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
745
+ refNode = refNode.nextSibling;
746
+ if (!refNode || !refNode['s-nr']) {
747
+ insertBeforeNode = refNode;
748
+ break;
749
+ }
750
+ }
751
+ }
752
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
753
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
754
+ // we've checked that it's worth while to relocate
755
+ // since that the node to relocate
756
+ // has a different next sibling or parent relocated
757
+ if (nodeToRelocate !== insertBeforeNode) {
758
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
759
+ // probably a component in the index.html that doesn't have it's hostname set
760
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
761
+ }
762
+ // add it back to the dom but in its new home
763
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
764
+ }
765
+ }
766
+ }
767
+ else {
768
+ // this node doesn't have a slot home to go to, so let's hide it
769
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
770
+ nodeToRelocate.hidden = true;
771
+ }
772
+ }
773
+ }
774
+ }
775
+ if (checkSlotFallbackVisibility) {
776
+ updateFallbackSlotVisibility(rootVnode.$elm$);
777
+ }
778
+ // done moving nodes around
779
+ // allow the disconnect callback to work again
780
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
781
+ // always reset
782
+ relocateNodes.length = 0;
783
+ }
784
+ };
785
+ /**
786
+ * Helper function to create & dispatch a custom Event on a provided target
787
+ * @param elm the target of the Event
788
+ * @param name the name to give the custom Event
789
+ * @param opts options for configuring a custom Event
790
+ * @returns the custom Event
791
+ */
792
+ const emitEvent = (elm, name, opts) => {
793
+ const ev = plt.ce(name, opts);
794
+ elm.dispatchEvent(ev);
795
+ return ev;
796
+ };
797
+ const attachToAncestor = (hostRef, ancestorComponent) => {
798
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
799
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
800
+ }
801
+ };
802
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
803
+ {
804
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
805
+ }
806
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
807
+ hostRef.$flags$ |= 512 /* needsRerender */;
808
+ return;
809
+ }
810
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
811
+ // there is no ancestor component or the ancestor component
812
+ // has already fired off its lifecycle update then
813
+ // fire off the initial update
814
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
815
+ return writeTask(dispatch) ;
816
+ };
817
+ const dispatchHooks = (hostRef, isInitialLoad) => {
818
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
819
+ const instance = hostRef.$lazyInstance$ ;
820
+ let promise;
821
+ if (isInitialLoad) {
822
+ {
823
+ promise = safeCall(instance, 'componentWillLoad');
824
+ }
825
+ }
826
+ endSchedule();
827
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
828
+ };
829
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
830
+ // updateComponent
831
+ const elm = hostRef.$hostElement$;
832
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
833
+ const rc = elm['s-rc'];
834
+ if (isInitialLoad) {
835
+ // DOM WRITE!
836
+ attachStyles(hostRef);
837
+ }
838
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
839
+ {
840
+ callRender(hostRef, instance);
841
+ }
842
+ if (rc) {
843
+ // ok, so turns out there are some child host elements
844
+ // waiting on this parent element to load
845
+ // let's fire off all update callbacks waiting
846
+ rc.map((cb) => cb());
847
+ elm['s-rc'] = undefined;
848
+ }
849
+ endRender();
850
+ endUpdate();
851
+ {
852
+ const childrenPromises = elm['s-p'];
853
+ const postUpdate = () => postUpdateComponent(hostRef);
854
+ if (childrenPromises.length === 0) {
855
+ postUpdate();
856
+ }
857
+ else {
858
+ Promise.all(childrenPromises).then(postUpdate);
859
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
860
+ childrenPromises.length = 0;
861
+ }
862
+ }
863
+ };
864
+ const callRender = (hostRef, instance, elm) => {
865
+ try {
866
+ instance = instance.render() ;
867
+ {
868
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
869
+ }
870
+ {
871
+ hostRef.$flags$ |= 2 /* hasRendered */;
872
+ }
873
+ {
874
+ {
875
+ // looks like we've got child nodes to render into this host element
876
+ // or we need to update the css class/attrs on the host element
877
+ // DOM WRITE!
878
+ {
879
+ renderVdom(hostRef, instance);
880
+ }
881
+ }
882
+ }
883
+ }
884
+ catch (e) {
885
+ consoleError(e, hostRef.$hostElement$);
886
+ }
887
+ return null;
888
+ };
889
+ const postUpdateComponent = (hostRef) => {
890
+ const tagName = hostRef.$cmpMeta$.$tagName$;
891
+ const elm = hostRef.$hostElement$;
892
+ const endPostUpdate = createTime('postUpdate', tagName);
893
+ const instance = hostRef.$lazyInstance$ ;
894
+ const ancestorComponent = hostRef.$ancestorComponent$;
895
+ {
896
+ safeCall(instance, 'componentDidRender');
897
+ }
898
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
899
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
900
+ {
901
+ // DOM WRITE!
902
+ addHydratedFlag(elm);
903
+ }
904
+ endPostUpdate();
905
+ {
906
+ hostRef.$onReadyResolve$(elm);
907
+ if (!ancestorComponent) {
908
+ appDidLoad();
909
+ }
910
+ }
911
+ }
912
+ else {
913
+ endPostUpdate();
914
+ }
915
+ // load events fire from bottom to top
916
+ // the deepest elements load first then bubbles up
917
+ {
918
+ if (hostRef.$onRenderResolve$) {
919
+ hostRef.$onRenderResolve$();
920
+ hostRef.$onRenderResolve$ = undefined;
921
+ }
922
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
923
+ nextTick(() => scheduleUpdate(hostRef, false));
924
+ }
925
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
926
+ }
927
+ // ( •_•)
928
+ // ( •_•)>⌐■-■
929
+ // (⌐■_■)
930
+ };
931
+ const appDidLoad = (who) => {
932
+ // on appload
933
+ // we have finish the first big initial render
934
+ {
935
+ addHydratedFlag(doc.documentElement);
936
+ }
937
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
938
+ };
939
+ const safeCall = (instance, method, arg) => {
940
+ if (instance && instance[method]) {
941
+ try {
942
+ return instance[method](arg);
943
+ }
944
+ catch (e) {
945
+ consoleError(e);
946
+ }
947
+ }
948
+ return undefined;
949
+ };
950
+ const then = (promise, thenFn) => {
951
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
952
+ };
953
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
954
+ ;
955
+ /**
956
+ * Parse a new property value for a given property type.
957
+ *
958
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
959
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
960
+ * 1. `any`, the type given to `propValue` in the function signature
961
+ * 2. the type stored from `propType`.
962
+ *
963
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
964
+ *
965
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
966
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
967
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
968
+ * ```tsx
969
+ * <my-cmp prop-val={0}></my-cmp>
970
+ * ```
971
+ *
972
+ * HTML prop values on the other hand, will always a string
973
+ *
974
+ * @param propValue the new value to coerce to some type
975
+ * @param propType the type of the prop, expressed as a binary number
976
+ * @returns the parsed/coerced value
977
+ */
978
+ const parsePropertyValue = (propValue, propType) => {
979
+ // ensure this value is of the correct prop type
980
+ if (propValue != null && !isComplexType(propValue)) {
981
+ if (propType & 1 /* String */) {
982
+ // could have been passed as a number or boolean
983
+ // but we still want it as a string
984
+ return String(propValue);
985
+ }
986
+ // redundant return here for better minification
987
+ return propValue;
988
+ }
989
+ // not sure exactly what type we want
990
+ // so no need to change to a different type
991
+ return propValue;
992
+ };
993
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
994
+ const setValue = (ref, propName, newVal, cmpMeta) => {
995
+ // check our new property value against our internal value
996
+ const hostRef = getHostRef(ref);
997
+ const oldVal = hostRef.$instanceValues$.get(propName);
998
+ const flags = hostRef.$flags$;
999
+ const instance = hostRef.$lazyInstance$ ;
1000
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1001
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1002
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1003
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1004
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1005
+ // gadzooks! the property's value has changed!!
1006
+ // set our new value!
1007
+ hostRef.$instanceValues$.set(propName, newVal);
1008
+ if (instance) {
1009
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1010
+ // looks like this value actually changed, so we've got work to do!
1011
+ // but only if we've already rendered, otherwise just chill out
1012
+ // queue that we need to do an update, but don't worry about queuing
1013
+ // up millions cuz this function ensures it only runs once
1014
+ scheduleUpdate(hostRef, false);
1015
+ }
1016
+ }
1017
+ }
1018
+ };
1019
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1020
+ if (cmpMeta.$members$) {
1021
+ // It's better to have a const than two Object.entries()
1022
+ const members = Object.entries(cmpMeta.$members$);
1023
+ const prototype = Cstr.prototype;
1024
+ members.map(([memberName, [memberFlags]]) => {
1025
+ if ((memberFlags & 31 /* Prop */ ||
1026
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1027
+ // proxyComponent - prop
1028
+ Object.defineProperty(prototype, memberName, {
1029
+ get() {
1030
+ // proxyComponent, get value
1031
+ return getValue(this, memberName);
1032
+ },
1033
+ set(newValue) {
1034
+ // proxyComponent, set value
1035
+ setValue(this, memberName, newValue, cmpMeta);
1036
+ },
1037
+ configurable: true,
1038
+ enumerable: true,
1039
+ });
1040
+ }
1041
+ });
1042
+ if ((flags & 1 /* isElementConstructor */)) {
1043
+ const attrNameToPropName = new Map();
1044
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1045
+ plt.jmp(() => {
1046
+ const propName = attrNameToPropName.get(attrName);
1047
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1048
+ // in the case where an attribute was set inline.
1049
+ // ```html
1050
+ // <my-component some-attribute="some-value"></my-component>
1051
+ // ```
1052
+ //
1053
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1054
+ // programmatically changes it before it has been upgraded as shown below:
1055
+ //
1056
+ // ```html
1057
+ // <!-- this component has _not_ been upgraded yet -->
1058
+ // <my-component id="test" some-attribute="some-value"></my-component>
1059
+ // <script>
1060
+ // // grab non-upgraded component
1061
+ // el = document.querySelector("#test");
1062
+ // el.someAttribute = "another-value";
1063
+ // // upgrade component
1064
+ // customElements.define('my-component', MyComponent);
1065
+ // </script>
1066
+ // ```
1067
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1068
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1069
+ // to the value that was set inline i.e. "some-value" from above example. When
1070
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1071
+ //
1072
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1073
+ // by connectedCallback as this attributeChangedCallback will not fire.
1074
+ //
1075
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1076
+ //
1077
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1078
+ // properties here given that this goes against best practices outlined here
1079
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1080
+ if (this.hasOwnProperty(propName)) {
1081
+ newValue = this[propName];
1082
+ delete this[propName];
1083
+ }
1084
+ else if (prototype.hasOwnProperty(propName) &&
1085
+ typeof this[propName] === 'number' &&
1086
+ this[propName] == newValue) {
1087
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1088
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1089
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1090
+ return;
1091
+ }
1092
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1093
+ });
1094
+ };
1095
+ // create an array of attributes to observe
1096
+ // and also create a map of html attribute name to js property name
1097
+ Cstr.observedAttributes = members
1098
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1099
+ .map(([propName, m]) => {
1100
+ const attrName = m[1] || propName;
1101
+ attrNameToPropName.set(attrName, propName);
1102
+ return attrName;
1103
+ });
1104
+ }
1105
+ }
1106
+ return Cstr;
1107
+ };
1108
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1109
+ // initializeComponent
1110
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1111
+ {
1112
+ // we haven't initialized this element yet
1113
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1114
+ // lazy loaded components
1115
+ // request the component's implementation to be
1116
+ // wired up with the host element
1117
+ Cstr = loadModule(cmpMeta);
1118
+ if (Cstr.then) {
1119
+ // Await creates a micro-task avoid if possible
1120
+ const endLoad = uniqueTime();
1121
+ Cstr = await Cstr;
1122
+ endLoad();
1123
+ }
1124
+ if (!Cstr.isProxied) {
1125
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1126
+ Cstr.isProxied = true;
1127
+ }
1128
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1129
+ // ok, time to construct the instance
1130
+ // but let's keep track of when we start and stop
1131
+ // so that the getters/setters don't incorrectly step on data
1132
+ {
1133
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1134
+ }
1135
+ // construct the lazy-loaded component implementation
1136
+ // passing the hostRef is very important during
1137
+ // construction in order to directly wire together the
1138
+ // host element and the lazy-loaded instance
1139
+ try {
1140
+ new Cstr(hostRef);
1141
+ }
1142
+ catch (e) {
1143
+ consoleError(e);
1144
+ }
1145
+ {
1146
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1147
+ }
1148
+ endNewInstance();
1149
+ }
1150
+ if (Cstr.style) {
1151
+ // this component has styles but we haven't registered them yet
1152
+ let style = Cstr.style;
1153
+ const scopeId = getScopeId(cmpMeta);
1154
+ if (!styles.has(scopeId)) {
1155
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1156
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1157
+ endRegisterStyles();
1158
+ }
1159
+ }
1160
+ }
1161
+ // we've successfully created a lazy instance
1162
+ const ancestorComponent = hostRef.$ancestorComponent$;
1163
+ const schedule = () => scheduleUpdate(hostRef, true);
1164
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1165
+ // this is the initial load and this component it has an ancestor component
1166
+ // but the ancestor component has NOT fired its will update lifecycle yet
1167
+ // so let's just cool our jets and wait for the ancestor to continue first
1168
+ // this will get fired off when the ancestor component
1169
+ // finally gets around to rendering its lazy self
1170
+ // fire off the initial update
1171
+ ancestorComponent['s-rc'].push(schedule);
1172
+ }
1173
+ else {
1174
+ schedule();
1175
+ }
1176
+ };
1177
+ const connectedCallback = (elm) => {
1178
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1179
+ const hostRef = getHostRef(elm);
1180
+ const cmpMeta = hostRef.$cmpMeta$;
1181
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1182
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1183
+ // first time this component has connected
1184
+ hostRef.$flags$ |= 1 /* hasConnected */;
1185
+ {
1186
+ // initUpdate
1187
+ // if the slot polyfill is required we'll need to put some nodes
1188
+ // in here to act as original content anchors as we move nodes around
1189
+ // host element has been connected to the DOM
1190
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1191
+ setContentReference(elm);
1192
+ }
1193
+ }
1194
+ {
1195
+ // find the first ancestor component (if there is one) and register
1196
+ // this component as one of the actively loading child components for its ancestor
1197
+ let ancestorComponent = elm;
1198
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1199
+ // climb up the ancestors looking for the first
1200
+ // component that hasn't finished its lifecycle update yet
1201
+ if (ancestorComponent['s-p']) {
1202
+ // we found this components first ancestor component
1203
+ // keep a reference to this component's ancestor component
1204
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1205
+ break;
1206
+ }
1207
+ }
1208
+ }
1209
+ // Lazy properties
1210
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1211
+ if (cmpMeta.$members$) {
1212
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1213
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1214
+ const value = elm[memberName];
1215
+ delete elm[memberName];
1216
+ elm[memberName] = value;
1217
+ }
1218
+ });
1219
+ }
1220
+ {
1221
+ initializeComponent(elm, hostRef, cmpMeta);
1222
+ }
1223
+ }
1224
+ endConnected();
1225
+ }
1226
+ };
1227
+ const setContentReference = (elm) => {
1228
+ // only required when we're NOT using native shadow dom (slot)
1229
+ // or this browser doesn't support native shadow dom
1230
+ // and this host element was NOT created with SSR
1231
+ // let's pick out the inner content for slot projection
1232
+ // create a node to represent where the original
1233
+ // content was first placed, which is useful later on
1234
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1235
+ contentRefElm['s-cn'] = true;
1236
+ elm.insertBefore(contentRefElm, elm.firstChild);
1237
+ };
1238
+ const disconnectedCallback = (elm) => {
1239
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1240
+ getHostRef(elm);
1241
+ }
1242
+ };
1243
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1244
+ const endBootstrap = createTime();
1245
+ const cmpTags = [];
1246
+ const exclude = options.exclude || [];
1247
+ const customElements = win.customElements;
1248
+ const head = doc.head;
1249
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1250
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1251
+ const deferredConnectedCallbacks = [];
1252
+ let appLoadFallback;
1253
+ let isBootstrapping = true;
1254
+ Object.assign(plt, options);
1255
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1256
+ lazyBundles.map((lazyBundle) => {
1257
+ lazyBundle[1].map((compactMeta) => {
1258
+ const cmpMeta = {
1259
+ $flags$: compactMeta[0],
1260
+ $tagName$: compactMeta[1],
1261
+ $members$: compactMeta[2],
1262
+ $listeners$: compactMeta[3],
1263
+ };
1264
+ {
1265
+ cmpMeta.$members$ = compactMeta[2];
1266
+ }
1267
+ const tagName = cmpMeta.$tagName$;
1268
+ const HostElement = class extends HTMLElement {
1269
+ // StencilLazyHost
1270
+ constructor(self) {
1271
+ // @ts-ignore
1272
+ super(self);
1273
+ self = this;
1274
+ registerHost(self, cmpMeta);
1275
+ }
1276
+ connectedCallback() {
1277
+ if (appLoadFallback) {
1278
+ clearTimeout(appLoadFallback);
1279
+ appLoadFallback = null;
1280
+ }
1281
+ if (isBootstrapping) {
1282
+ // connectedCallback will be processed once all components have been registered
1283
+ deferredConnectedCallbacks.push(this);
1284
+ }
1285
+ else {
1286
+ plt.jmp(() => connectedCallback(this));
1287
+ }
1288
+ }
1289
+ disconnectedCallback() {
1290
+ plt.jmp(() => disconnectedCallback(this));
1291
+ }
1292
+ componentOnReady() {
1293
+ return getHostRef(this).$onReadyPromise$;
1294
+ }
1295
+ };
1296
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1297
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1298
+ cmpTags.push(tagName);
1299
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1300
+ }
1301
+ });
1302
+ });
1303
+ {
1304
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1305
+ visibilityStyle.setAttribute('data-styles', '');
1306
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1307
+ }
1308
+ // Process deferred connectedCallbacks now all components have been registered
1309
+ isBootstrapping = false;
1310
+ if (deferredConnectedCallbacks.length) {
1311
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1312
+ }
1313
+ else {
1314
+ {
1315
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1316
+ }
1317
+ }
1318
+ // Fallback appLoad event
1319
+ endBootstrap();
1320
+ };
1321
+ const hostRefs = new WeakMap();
1322
+ const getHostRef = (ref) => hostRefs.get(ref);
1323
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1324
+ const registerHost = (elm, cmpMeta) => {
1325
+ const hostRef = {
1326
+ $flags$: 0,
1327
+ $hostElement$: elm,
1328
+ $cmpMeta$: cmpMeta,
1329
+ $instanceValues$: new Map(),
1330
+ };
1331
+ {
1332
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1333
+ elm['s-p'] = [];
1334
+ elm['s-rc'] = [];
1335
+ }
1336
+ return hostRefs.set(elm, hostRef);
1337
+ };
1338
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1339
+ const consoleError = (e, el) => (0, console.error)(e, el);
1340
+ const cmpModules = /*@__PURE__*/ new Map();
1341
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1342
+ // loadModuleImport
1343
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1344
+ const bundleId = cmpMeta.$lazyBundleId$;
1345
+ const module = cmpModules.get(bundleId) ;
1346
+ if (module) {
1347
+ return module[exportName];
1348
+ }
1349
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1350
+ /* webpackInclude: /\.entry\.js$/ */
1351
+ /* webpackExclude: /\.system\.entry\.js$/ */
1352
+ /* webpackMode: "lazy" */
1353
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1354
+ {
1355
+ cmpModules.set(bundleId, importedModule);
1356
+ }
1357
+ return importedModule[exportName];
1358
+ }, consoleError);
1359
+ };
1360
+ const styles = new Map();
1361
+ const queueDomReads = [];
1362
+ const queueDomWrites = [];
1363
+ const queueTask = (queue, write) => (cb) => {
1364
+ queue.push(cb);
1365
+ if (!queuePending) {
1366
+ queuePending = true;
1367
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1368
+ nextTick(flush);
1369
+ }
1370
+ else {
1371
+ plt.raf(flush);
1372
+ }
1373
+ }
1374
+ };
1375
+ const consume = (queue) => {
1376
+ for (let i = 0; i < queue.length; i++) {
1377
+ try {
1378
+ queue[i](performance.now());
1379
+ }
1380
+ catch (e) {
1381
+ consoleError(e);
1382
+ }
1383
+ }
1384
+ queue.length = 0;
1385
+ };
1386
+ const flush = () => {
1387
+ // always force a bunch of medium callbacks to run, but still have
1388
+ // a throttle on how many can run in a certain time
1389
+ // DOM READS!!!
1390
+ consume(queueDomReads);
1391
+ // DOM WRITES!!!
1392
+ {
1393
+ consume(queueDomWrites);
1394
+ if ((queuePending = queueDomReads.length > 0)) {
1395
+ // still more to do yet, but we've run out of time
1396
+ // let's let this thing cool off and try again in the next tick
1397
+ plt.raf(flush);
1398
+ }
1399
+ }
1400
+ };
1401
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1402
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1403
+
1404
+ exports.bootstrapLazy = bootstrapLazy;
1405
+ exports.h = h;
1406
+ exports.promiseResolve = promiseResolve;
1407
+ exports.registerInstance = registerInstance;