@everymatrix/lottery-ticket 1.44.0 → 1.45.2

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