@everymatrix/blog-articles-grid 1.44.0 → 1.45.2

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