@everymatrix/lottery-ticket-controller 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 (58) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/helper-accordion_5.cjs.entry.js +574 -671
  3. package/dist/cjs/index-2275f129.js +1304 -0
  4. package/dist/cjs/loader.cjs.js +7 -13
  5. package/dist/cjs/lottery-ticket-controller.cjs.js +17 -11
  6. package/dist/collection/collection-manifest.json +3 -3
  7. package/dist/collection/components/lottery-ticket-controller/index.js +1 -0
  8. package/dist/collection/components/lottery-ticket-controller/lottery-ticket-controller.css +182 -0
  9. package/dist/collection/components/lottery-ticket-controller/lottery-ticket-controller.js +371 -376
  10. package/dist/collection/utils/locale.utils.js +18 -15
  11. package/dist/collection/utils/utils.js +1 -1
  12. package/dist/esm/app-globals-0f993ce5.js +3 -0
  13. package/dist/esm/helper-accordion_5.entry.js +574 -671
  14. package/dist/esm/index-cf1a7f99.js +1277 -0
  15. package/dist/esm/loader.js +7 -13
  16. package/dist/esm/lottery-ticket-controller.js +14 -11
  17. package/dist/lottery-ticket-controller/lottery-ticket-controller.esm.js +1 -1
  18. package/dist/lottery-ticket-controller/p-1846ecd7.entry.js +1 -0
  19. package/dist/lottery-ticket-controller/p-e1255160.js +1 -0
  20. package/dist/lottery-ticket-controller/p-ee226061.js +2 -0
  21. package/dist/stencil.config.dev.js +17 -0
  22. package/dist/stencil.config.js +14 -19
  23. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/lottery-ticket-controller/.stencil/packages/stencil/lottery-ticket-controller/stencil.config.d.ts +2 -0
  24. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/lottery-ticket-controller/.stencil/packages/stencil/lottery-ticket-controller/stencil.config.dev.d.ts +2 -0
  25. package/dist/types/components/lottery-ticket-controller/index.d.ts +1 -0
  26. package/dist/types/components/lottery-ticket-controller/lottery-ticket-controller.d.ts +70 -66
  27. package/dist/types/components.d.ts +24 -1
  28. package/dist/types/stencil-public-runtime.d.ts +142 -33
  29. package/loader/cdn.js +1 -3
  30. package/loader/index.cjs.js +1 -3
  31. package/loader/index.d.ts +13 -1
  32. package/loader/index.es2017.js +1 -3
  33. package/loader/index.js +1 -3
  34. package/loader/package.json +1 -0
  35. package/package.json +11 -4
  36. package/dist/cjs/index-dd94b8db.js +0 -1275
  37. package/dist/components/helper-accordion.js +0 -6
  38. package/dist/components/helper-accordion2.js +0 -156
  39. package/dist/components/index.d.ts +0 -26
  40. package/dist/components/index.js +0 -1
  41. package/dist/components/lottery-bullet.js +0 -6
  42. package/dist/components/lottery-bullet2.js +0 -91
  43. package/dist/components/lottery-grid.js +0 -6
  44. package/dist/components/lottery-grid2.js +0 -236
  45. package/dist/components/lottery-ticket-controller.d.ts +0 -11
  46. package/dist/components/lottery-ticket-controller.js +0 -176
  47. package/dist/components/lottery-ticket.js +0 -6
  48. package/dist/components/lottery-ticket2.js +0 -263
  49. package/dist/esm/index-74cef6d4.js +0 -1249
  50. package/dist/esm/polyfills/core-js.js +0 -11
  51. package/dist/esm/polyfills/css-shim.js +0 -1
  52. package/dist/esm/polyfills/dom.js +0 -79
  53. package/dist/esm/polyfills/es5-html-element.js +0 -1
  54. package/dist/esm/polyfills/index.js +0 -34
  55. package/dist/esm/polyfills/system.js +0 -6
  56. package/dist/lottery-ticket-controller/p-72e48800.js +0 -1
  57. package/dist/lottery-ticket-controller/p-9a5da031.entry.js +0 -1
  58. package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/stencil/widgets-stencil/packages/lottery-ticket-controller/.stencil/packages/lottery-ticket-controller/stencil.config.d.ts +0 -2
@@ -1,1249 +0,0 @@
1
- const NAMESPACE = 'lottery-ticket-controller';
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 tag = newVNode.$tag$;
498
- const text = newVNode.$text$;
499
- if (text === null) {
500
- // element node
501
- {
502
- if (tag === 'slot')
503
- ;
504
- else {
505
- // either this is the first render of an element OR it's an update
506
- // AND we already know it's possible it could have changed
507
- // this updates the element's css classes, attrs, props, listeners, etc.
508
- updateElement(oldVNode, newVNode, isSvgMode);
509
- }
510
- }
511
- if (oldChildren !== null && newChildren !== null) {
512
- // looks like there's child vnodes for both the old and new vnodes
513
- updateChildren(elm, oldChildren, newVNode, newChildren);
514
- }
515
- else if (newChildren !== null) {
516
- // no old child vnodes, but there are new child vnodes to add
517
- if (oldVNode.$text$ !== null) {
518
- // the old vnode was text, so be sure to clear it out
519
- elm.textContent = '';
520
- }
521
- // add the new vnode children
522
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
523
- }
524
- else if (oldChildren !== null) {
525
- // no new child vnodes, but there are old child vnodes to remove
526
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
527
- }
528
- }
529
- else if (oldVNode.$text$ !== text) {
530
- // update the text content for the text only vnode
531
- // and also only if the text is different than before
532
- elm.data = text;
533
- }
534
- };
535
- const callNodeRefs = (vNode) => {
536
- {
537
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
538
- vNode.$children$ && vNode.$children$.map(callNodeRefs);
539
- }
540
- };
541
- const renderVdom = (hostRef, renderFnResults) => {
542
- const hostElm = hostRef.$hostElement$;
543
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
544
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
545
- hostTagName = hostElm.tagName;
546
- rootVnode.$tag$ = null;
547
- rootVnode.$flags$ |= 4 /* isHost */;
548
- hostRef.$vnode$ = rootVnode;
549
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
550
- {
551
- scopeId = hostElm['s-sc'];
552
- }
553
- // synchronous patch
554
- patch(oldVNode, rootVnode);
555
- };
556
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
557
- const createEvent = (ref, name, flags) => {
558
- const elm = getElement(ref);
559
- return {
560
- emit: (detail) => {
561
- return emitEvent(elm, name, {
562
- bubbles: !!(flags & 4 /* Bubbles */),
563
- composed: !!(flags & 2 /* Composed */),
564
- cancelable: !!(flags & 1 /* Cancellable */),
565
- detail,
566
- });
567
- },
568
- };
569
- };
570
- /**
571
- * Helper function to create & dispatch a custom Event on a provided target
572
- * @param elm the target of the Event
573
- * @param name the name to give the custom Event
574
- * @param opts options for configuring a custom Event
575
- * @returns the custom Event
576
- */
577
- const emitEvent = (elm, name, opts) => {
578
- const ev = plt.ce(name, opts);
579
- elm.dispatchEvent(ev);
580
- return ev;
581
- };
582
- const attachToAncestor = (hostRef, ancestorComponent) => {
583
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
584
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
585
- }
586
- };
587
- const scheduleUpdate = (hostRef, isInitialLoad) => {
588
- {
589
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
590
- }
591
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
592
- hostRef.$flags$ |= 512 /* needsRerender */;
593
- return;
594
- }
595
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
596
- // there is no ancestor component or the ancestor component
597
- // has already fired off its lifecycle update then
598
- // fire off the initial update
599
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
600
- return writeTask(dispatch) ;
601
- };
602
- const dispatchHooks = (hostRef, isInitialLoad) => {
603
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
604
- const instance = hostRef.$lazyInstance$ ;
605
- let promise;
606
- if (isInitialLoad) {
607
- {
608
- hostRef.$flags$ |= 256 /* isListenReady */;
609
- if (hostRef.$queuedListeners$) {
610
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
611
- hostRef.$queuedListeners$ = null;
612
- }
613
- }
614
- }
615
- endSchedule();
616
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
617
- };
618
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
619
- // updateComponent
620
- const elm = hostRef.$hostElement$;
621
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
622
- const rc = elm['s-rc'];
623
- if (isInitialLoad) {
624
- // DOM WRITE!
625
- attachStyles(hostRef);
626
- }
627
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
628
- {
629
- callRender(hostRef, instance);
630
- }
631
- if (rc) {
632
- // ok, so turns out there are some child host elements
633
- // waiting on this parent element to load
634
- // let's fire off all update callbacks waiting
635
- rc.map((cb) => cb());
636
- elm['s-rc'] = undefined;
637
- }
638
- endRender();
639
- endUpdate();
640
- {
641
- const childrenPromises = elm['s-p'];
642
- const postUpdate = () => postUpdateComponent(hostRef);
643
- if (childrenPromises.length === 0) {
644
- postUpdate();
645
- }
646
- else {
647
- Promise.all(childrenPromises).then(postUpdate);
648
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
649
- childrenPromises.length = 0;
650
- }
651
- }
652
- };
653
- const callRender = (hostRef, instance, elm) => {
654
- try {
655
- instance = instance.render() ;
656
- {
657
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
658
- }
659
- {
660
- hostRef.$flags$ |= 2 /* hasRendered */;
661
- }
662
- {
663
- {
664
- // looks like we've got child nodes to render into this host element
665
- // or we need to update the css class/attrs on the host element
666
- // DOM WRITE!
667
- {
668
- renderVdom(hostRef, instance);
669
- }
670
- }
671
- }
672
- }
673
- catch (e) {
674
- consoleError(e, hostRef.$hostElement$);
675
- }
676
- return null;
677
- };
678
- const postUpdateComponent = (hostRef) => {
679
- const tagName = hostRef.$cmpMeta$.$tagName$;
680
- const elm = hostRef.$hostElement$;
681
- const endPostUpdate = createTime('postUpdate', tagName);
682
- const instance = hostRef.$lazyInstance$ ;
683
- const ancestorComponent = hostRef.$ancestorComponent$;
684
- {
685
- safeCall(instance, 'componentDidRender');
686
- }
687
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
688
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
689
- {
690
- // DOM WRITE!
691
- addHydratedFlag(elm);
692
- }
693
- endPostUpdate();
694
- {
695
- hostRef.$onReadyResolve$(elm);
696
- if (!ancestorComponent) {
697
- appDidLoad();
698
- }
699
- }
700
- }
701
- else {
702
- endPostUpdate();
703
- }
704
- // load events fire from bottom to top
705
- // the deepest elements load first then bubbles up
706
- {
707
- if (hostRef.$onRenderResolve$) {
708
- hostRef.$onRenderResolve$();
709
- hostRef.$onRenderResolve$ = undefined;
710
- }
711
- if (hostRef.$flags$ & 512 /* needsRerender */) {
712
- nextTick(() => scheduleUpdate(hostRef, false));
713
- }
714
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
715
- }
716
- // ( •_•)
717
- // ( •_•)>⌐■-■
718
- // (⌐■_■)
719
- };
720
- const appDidLoad = (who) => {
721
- // on appload
722
- // we have finish the first big initial render
723
- {
724
- addHydratedFlag(doc.documentElement);
725
- }
726
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
727
- };
728
- const safeCall = (instance, method, arg) => {
729
- if (instance && instance[method]) {
730
- try {
731
- return instance[method](arg);
732
- }
733
- catch (e) {
734
- consoleError(e);
735
- }
736
- }
737
- return undefined;
738
- };
739
- const then = (promise, thenFn) => {
740
- return promise && promise.then ? promise.then(thenFn) : thenFn();
741
- };
742
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
743
- ;
744
- /**
745
- * Parse a new property value for a given property type.
746
- *
747
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
748
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
749
- * 1. `any`, the type given to `propValue` in the function signature
750
- * 2. the type stored from `propType`.
751
- *
752
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
753
- *
754
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
755
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
756
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
757
- * ```tsx
758
- * <my-cmp prop-val={0}></my-cmp>
759
- * ```
760
- *
761
- * HTML prop values on the other hand, will always a string
762
- *
763
- * @param propValue the new value to coerce to some type
764
- * @param propType the type of the prop, expressed as a binary number
765
- * @returns the parsed/coerced value
766
- */
767
- const parsePropertyValue = (propValue, propType) => {
768
- // ensure this value is of the correct prop type
769
- if (propValue != null && !isComplexType(propValue)) {
770
- if (propType & 4 /* Boolean */) {
771
- // per the HTML spec, any string value means it is a boolean true value
772
- // but we'll cheat here and say that the string "false" is the boolean false
773
- return propValue === 'false' ? false : propValue === '' || !!propValue;
774
- }
775
- if (propType & 2 /* Number */) {
776
- // force it to be a number
777
- return parseFloat(propValue);
778
- }
779
- if (propType & 1 /* String */) {
780
- // could have been passed as a number or boolean
781
- // but we still want it as a string
782
- return String(propValue);
783
- }
784
- // redundant return here for better minification
785
- return propValue;
786
- }
787
- // not sure exactly what type we want
788
- // so no need to change to a different type
789
- return propValue;
790
- };
791
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
792
- const setValue = (ref, propName, newVal, cmpMeta) => {
793
- // check our new property value against our internal value
794
- const hostRef = getHostRef(ref);
795
- const elm = hostRef.$hostElement$ ;
796
- const oldVal = hostRef.$instanceValues$.get(propName);
797
- const flags = hostRef.$flags$;
798
- const instance = hostRef.$lazyInstance$ ;
799
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
800
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
801
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
802
- const didValueChange = newVal !== oldVal && !areBothNaN;
803
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
804
- // gadzooks! the property's value has changed!!
805
- // set our new value!
806
- hostRef.$instanceValues$.set(propName, newVal);
807
- if (instance) {
808
- // get an array of method names of watch functions to call
809
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
810
- const watchMethods = cmpMeta.$watchers$[propName];
811
- if (watchMethods) {
812
- // this instance is watching for when this property changed
813
- watchMethods.map((watchMethodName) => {
814
- try {
815
- // fire off each of the watch methods that are watching this property
816
- instance[watchMethodName](newVal, oldVal, propName);
817
- }
818
- catch (e) {
819
- consoleError(e, elm);
820
- }
821
- });
822
- }
823
- }
824
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
825
- // looks like this value actually changed, so we've got work to do!
826
- // but only if we've already rendered, otherwise just chill out
827
- // queue that we need to do an update, but don't worry about queuing
828
- // up millions cuz this function ensures it only runs once
829
- scheduleUpdate(hostRef, false);
830
- }
831
- }
832
- }
833
- };
834
- const proxyComponent = (Cstr, cmpMeta, flags) => {
835
- if (cmpMeta.$members$) {
836
- if (Cstr.watchers) {
837
- cmpMeta.$watchers$ = Cstr.watchers;
838
- }
839
- // It's better to have a const than two Object.entries()
840
- const members = Object.entries(cmpMeta.$members$);
841
- const prototype = Cstr.prototype;
842
- members.map(([memberName, [memberFlags]]) => {
843
- if ((memberFlags & 31 /* Prop */ ||
844
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
845
- // proxyComponent - prop
846
- Object.defineProperty(prototype, memberName, {
847
- get() {
848
- // proxyComponent, get value
849
- return getValue(this, memberName);
850
- },
851
- set(newValue) {
852
- // proxyComponent, set value
853
- setValue(this, memberName, newValue, cmpMeta);
854
- },
855
- configurable: true,
856
- enumerable: true,
857
- });
858
- }
859
- });
860
- if ((flags & 1 /* isElementConstructor */)) {
861
- const attrNameToPropName = new Map();
862
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
863
- plt.jmp(() => {
864
- const propName = attrNameToPropName.get(attrName);
865
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
866
- // in the case where an attribute was set inline.
867
- // ```html
868
- // <my-component some-attribute="some-value"></my-component>
869
- // ```
870
- //
871
- // There is an edge case where a developer sets the attribute inline on a custom element and then
872
- // programmatically changes it before it has been upgraded as shown below:
873
- //
874
- // ```html
875
- // <!-- this component has _not_ been upgraded yet -->
876
- // <my-component id="test" some-attribute="some-value"></my-component>
877
- // <script>
878
- // // grab non-upgraded component
879
- // el = document.querySelector("#test");
880
- // el.someAttribute = "another-value";
881
- // // upgrade component
882
- // customElements.define('my-component', MyComponent);
883
- // </script>
884
- // ```
885
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
886
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
887
- // to the value that was set inline i.e. "some-value" from above example. When
888
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
889
- //
890
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
891
- // by connectedCallback as this attributeChangedCallback will not fire.
892
- //
893
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
894
- //
895
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
896
- // properties here given that this goes against best practices outlined here
897
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
898
- if (this.hasOwnProperty(propName)) {
899
- newValue = this[propName];
900
- delete this[propName];
901
- }
902
- else if (prototype.hasOwnProperty(propName) &&
903
- typeof this[propName] === 'number' &&
904
- this[propName] == newValue) {
905
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
906
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
907
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
908
- return;
909
- }
910
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
911
- });
912
- };
913
- // create an array of attributes to observe
914
- // and also create a map of html attribute name to js property name
915
- Cstr.observedAttributes = members
916
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
917
- .map(([propName, m]) => {
918
- const attrName = m[1] || propName;
919
- attrNameToPropName.set(attrName, propName);
920
- return attrName;
921
- });
922
- }
923
- }
924
- return Cstr;
925
- };
926
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
927
- // initializeComponent
928
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
929
- {
930
- // we haven't initialized this element yet
931
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
932
- // lazy loaded components
933
- // request the component's implementation to be
934
- // wired up with the host element
935
- Cstr = loadModule(cmpMeta);
936
- if (Cstr.then) {
937
- // Await creates a micro-task avoid if possible
938
- const endLoad = uniqueTime();
939
- Cstr = await Cstr;
940
- endLoad();
941
- }
942
- if (!Cstr.isProxied) {
943
- // we've never proxied this Constructor before
944
- // let's add the getters/setters to its prototype before
945
- // the first time we create an instance of the implementation
946
- {
947
- cmpMeta.$watchers$ = Cstr.watchers;
948
- }
949
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
950
- Cstr.isProxied = true;
951
- }
952
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
953
- // ok, time to construct the instance
954
- // but let's keep track of when we start and stop
955
- // so that the getters/setters don't incorrectly step on data
956
- {
957
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
958
- }
959
- // construct the lazy-loaded component implementation
960
- // passing the hostRef is very important during
961
- // construction in order to directly wire together the
962
- // host element and the lazy-loaded instance
963
- try {
964
- new Cstr(hostRef);
965
- }
966
- catch (e) {
967
- consoleError(e);
968
- }
969
- {
970
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
971
- }
972
- {
973
- hostRef.$flags$ |= 128 /* isWatchReady */;
974
- }
975
- endNewInstance();
976
- fireConnectedCallback(hostRef.$lazyInstance$);
977
- }
978
- if (Cstr.style) {
979
- // this component has styles but we haven't registered them yet
980
- let style = Cstr.style;
981
- const scopeId = getScopeId(cmpMeta);
982
- if (!styles.has(scopeId)) {
983
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
984
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
985
- endRegisterStyles();
986
- }
987
- }
988
- }
989
- // we've successfully created a lazy instance
990
- const ancestorComponent = hostRef.$ancestorComponent$;
991
- const schedule = () => scheduleUpdate(hostRef, true);
992
- if (ancestorComponent && ancestorComponent['s-rc']) {
993
- // this is the initial load and this component it has an ancestor component
994
- // but the ancestor component has NOT fired its will update lifecycle yet
995
- // so let's just cool our jets and wait for the ancestor to continue first
996
- // this will get fired off when the ancestor component
997
- // finally gets around to rendering its lazy self
998
- // fire off the initial update
999
- ancestorComponent['s-rc'].push(schedule);
1000
- }
1001
- else {
1002
- schedule();
1003
- }
1004
- };
1005
- const fireConnectedCallback = (instance) => {
1006
- {
1007
- safeCall(instance, 'connectedCallback');
1008
- }
1009
- };
1010
- const connectedCallback = (elm) => {
1011
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1012
- const hostRef = getHostRef(elm);
1013
- const cmpMeta = hostRef.$cmpMeta$;
1014
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1015
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1016
- // first time this component has connected
1017
- hostRef.$flags$ |= 1 /* hasConnected */;
1018
- {
1019
- // find the first ancestor component (if there is one) and register
1020
- // this component as one of the actively loading child components for its ancestor
1021
- let ancestorComponent = elm;
1022
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1023
- // climb up the ancestors looking for the first
1024
- // component that hasn't finished its lifecycle update yet
1025
- if (ancestorComponent['s-p']) {
1026
- // we found this components first ancestor component
1027
- // keep a reference to this component's ancestor component
1028
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1029
- break;
1030
- }
1031
- }
1032
- }
1033
- // Lazy properties
1034
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1035
- if (cmpMeta.$members$) {
1036
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1037
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1038
- const value = elm[memberName];
1039
- delete elm[memberName];
1040
- elm[memberName] = value;
1041
- }
1042
- });
1043
- }
1044
- {
1045
- initializeComponent(elm, hostRef, cmpMeta);
1046
- }
1047
- }
1048
- else {
1049
- // not the first time this has connected
1050
- // reattach any event listeners to the host
1051
- // since they would have been removed when disconnected
1052
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1053
- // fire off connectedCallback() on component instance
1054
- fireConnectedCallback(hostRef.$lazyInstance$);
1055
- }
1056
- endConnected();
1057
- }
1058
- };
1059
- const disconnectedCallback = (elm) => {
1060
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1061
- const hostRef = getHostRef(elm);
1062
- {
1063
- if (hostRef.$rmListeners$) {
1064
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1065
- hostRef.$rmListeners$ = undefined;
1066
- }
1067
- }
1068
- }
1069
- };
1070
- const bootstrapLazy = (lazyBundles, options = {}) => {
1071
- const endBootstrap = createTime();
1072
- const cmpTags = [];
1073
- const exclude = options.exclude || [];
1074
- const customElements = win.customElements;
1075
- const head = doc.head;
1076
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1077
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1078
- const deferredConnectedCallbacks = [];
1079
- let appLoadFallback;
1080
- let isBootstrapping = true;
1081
- Object.assign(plt, options);
1082
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1083
- lazyBundles.map((lazyBundle) => {
1084
- lazyBundle[1].map((compactMeta) => {
1085
- const cmpMeta = {
1086
- $flags$: compactMeta[0],
1087
- $tagName$: compactMeta[1],
1088
- $members$: compactMeta[2],
1089
- $listeners$: compactMeta[3],
1090
- };
1091
- {
1092
- cmpMeta.$members$ = compactMeta[2];
1093
- }
1094
- {
1095
- cmpMeta.$listeners$ = compactMeta[3];
1096
- }
1097
- {
1098
- cmpMeta.$watchers$ = {};
1099
- }
1100
- const tagName = cmpMeta.$tagName$;
1101
- const HostElement = class extends HTMLElement {
1102
- // StencilLazyHost
1103
- constructor(self) {
1104
- // @ts-ignore
1105
- super(self);
1106
- self = this;
1107
- registerHost(self, cmpMeta);
1108
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1109
- // this component is using shadow dom
1110
- // and this browser supports shadow dom
1111
- // add the read-only property "shadowRoot" to the host element
1112
- // adding the shadow root build conditionals to minimize runtime
1113
- {
1114
- {
1115
- self.attachShadow({ mode: 'open' });
1116
- }
1117
- }
1118
- }
1119
- }
1120
- connectedCallback() {
1121
- if (appLoadFallback) {
1122
- clearTimeout(appLoadFallback);
1123
- appLoadFallback = null;
1124
- }
1125
- if (isBootstrapping) {
1126
- // connectedCallback will be processed once all components have been registered
1127
- deferredConnectedCallbacks.push(this);
1128
- }
1129
- else {
1130
- plt.jmp(() => connectedCallback(this));
1131
- }
1132
- }
1133
- disconnectedCallback() {
1134
- plt.jmp(() => disconnectedCallback(this));
1135
- }
1136
- componentOnReady() {
1137
- return getHostRef(this).$onReadyPromise$;
1138
- }
1139
- };
1140
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1141
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1142
- cmpTags.push(tagName);
1143
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1144
- }
1145
- });
1146
- });
1147
- {
1148
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1149
- visibilityStyle.setAttribute('data-styles', '');
1150
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1151
- }
1152
- // Process deferred connectedCallbacks now all components have been registered
1153
- isBootstrapping = false;
1154
- if (deferredConnectedCallbacks.length) {
1155
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1156
- }
1157
- else {
1158
- {
1159
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1160
- }
1161
- }
1162
- // Fallback appLoad event
1163
- endBootstrap();
1164
- };
1165
- const hostRefs = new WeakMap();
1166
- const getHostRef = (ref) => hostRefs.get(ref);
1167
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1168
- const registerHost = (elm, cmpMeta) => {
1169
- const hostRef = {
1170
- $flags$: 0,
1171
- $hostElement$: elm,
1172
- $cmpMeta$: cmpMeta,
1173
- $instanceValues$: new Map(),
1174
- };
1175
- {
1176
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1177
- elm['s-p'] = [];
1178
- elm['s-rc'] = [];
1179
- }
1180
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1181
- return hostRefs.set(elm, hostRef);
1182
- };
1183
- const isMemberInElement = (elm, memberName) => memberName in elm;
1184
- const consoleError = (e, el) => (0, console.error)(e, el);
1185
- const cmpModules = /*@__PURE__*/ new Map();
1186
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1187
- // loadModuleImport
1188
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1189
- const bundleId = cmpMeta.$lazyBundleId$;
1190
- const module = cmpModules.get(bundleId) ;
1191
- if (module) {
1192
- return module[exportName];
1193
- }
1194
- return import(
1195
- /* webpackInclude: /\.entry\.js$/ */
1196
- /* webpackExclude: /\.system\.entry\.js$/ */
1197
- /* webpackMode: "lazy" */
1198
- `./${bundleId}.entry.js${''}`).then((importedModule) => {
1199
- {
1200
- cmpModules.set(bundleId, importedModule);
1201
- }
1202
- return importedModule[exportName];
1203
- }, consoleError);
1204
- };
1205
- const styles = new Map();
1206
- const queueDomReads = [];
1207
- const queueDomWrites = [];
1208
- const queueTask = (queue, write) => (cb) => {
1209
- queue.push(cb);
1210
- if (!queuePending) {
1211
- queuePending = true;
1212
- if (write && plt.$flags$ & 4 /* queueSync */) {
1213
- nextTick(flush);
1214
- }
1215
- else {
1216
- plt.raf(flush);
1217
- }
1218
- }
1219
- };
1220
- const consume = (queue) => {
1221
- for (let i = 0; i < queue.length; i++) {
1222
- try {
1223
- queue[i](performance.now());
1224
- }
1225
- catch (e) {
1226
- consoleError(e);
1227
- }
1228
- }
1229
- queue.length = 0;
1230
- };
1231
- const flush = () => {
1232
- // always force a bunch of medium callbacks to run, but still have
1233
- // a throttle on how many can run in a certain time
1234
- // DOM READS!!!
1235
- consume(queueDomReads);
1236
- // DOM WRITES!!!
1237
- {
1238
- consume(queueDomWrites);
1239
- if ((queuePending = queueDomReads.length > 0)) {
1240
- // still more to do yet, but we've run out of time
1241
- // let's let this thing cool off and try again in the next tick
1242
- plt.raf(flush);
1243
- }
1244
- }
1245
- };
1246
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1247
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1248
-
1249
- export { bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };