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