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