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