@everymatrix/lottery-ticket-controller 1.44.0 → 1.45.0

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