@everymatrix/bonus-elevate-shop-item 1.44.0 → 1.45.0

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