@everymatrix/lottery-ticket 0.1.24 → 1.0.69

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