@xplortech/apollo-core 0.0.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 (49) hide show
  1. package/README.md +1 -0
  2. package/build/style.css +1129 -0
  3. package/dist/apollo-core/apollo-core.esm.js +1 -0
  4. package/dist/apollo-core/index.esm.js +0 -0
  5. package/dist/apollo-core/p-1c829417.js +1 -0
  6. package/dist/apollo-core/p-64ea0ce6.entry.js +1 -0
  7. package/dist/apollo-core/p-b76559ae.entry.js +1 -0
  8. package/dist/cjs/apollo-core.cjs.js +19 -0
  9. package/dist/cjs/index-3ceb30c2.js +980 -0
  10. package/dist/cjs/index.cjs.js +2 -0
  11. package/dist/cjs/loader.cjs.js +21 -0
  12. package/dist/cjs/xpl-pagination.cjs.entry.js +16 -0
  13. package/dist/cjs/xpl-table.cjs.entry.js +54 -0
  14. package/dist/collection/collection-manifest.json +13 -0
  15. package/dist/collection/components/xpl-pagination/xpl-pagination.js +9 -0
  16. package/dist/collection/components/xpl-table/xpl-table.js +157 -0
  17. package/dist/custom-elements/index.d.ts +51 -0
  18. package/dist/custom-elements/index.js +78 -0
  19. package/dist/esm/apollo-core.js +17 -0
  20. package/dist/esm/index-52844266.js +953 -0
  21. package/dist/esm/index.js +1 -0
  22. package/dist/esm/loader.js +17 -0
  23. package/dist/esm/polyfills/core-js.js +11 -0
  24. package/dist/esm/polyfills/css-shim.js +1 -0
  25. package/dist/esm/polyfills/dom.js +79 -0
  26. package/dist/esm/polyfills/es5-html-element.js +1 -0
  27. package/dist/esm/polyfills/index.js +34 -0
  28. package/dist/esm/polyfills/system.js +6 -0
  29. package/dist/esm/xpl-pagination.entry.js +12 -0
  30. package/dist/esm/xpl-table.entry.js +50 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/loader/cdn.js +3 -0
  34. package/dist/loader/index.cjs.js +3 -0
  35. package/dist/loader/index.d.ts +13 -0
  36. package/dist/loader/index.es2017.js +3 -0
  37. package/dist/loader/index.js +4 -0
  38. package/dist/loader/package.json +10 -0
  39. package/dist/types/.stencil/xpl-pagination/xpl-pagination.d.ts +3 -0
  40. package/dist/types/.stencil/xpl-table/xpl-table.d.ts +16 -0
  41. package/dist/types/components.d.ts +61 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1562 -0
  43. package/loader/cdn.js +3 -0
  44. package/loader/index.cjs.js +3 -0
  45. package/loader/index.d.ts +13 -0
  46. package/loader/index.es2017.js +3 -0
  47. package/loader/index.js +4 -0
  48. package/loader/package.json +10 -0
  49. package/package.json +56 -0
@@ -0,0 +1,953 @@
1
+ const NAMESPACE = 'apollo-core';
2
+
3
+ let scopeId;
4
+ let hostTagName;
5
+ let isSvgMode = false;
6
+ let queuePending = false;
7
+ const win = typeof window !== 'undefined' ? window : {};
8
+ const doc = win.document || { head: {} };
9
+ const plt = {
10
+ $flags$: 0,
11
+ $resourcesUrl$: '',
12
+ jmp: h => h(),
13
+ raf: h => requestAnimationFrame(h),
14
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
15
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
16
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
17
+ };
18
+ const promiseResolve = (v) => Promise.resolve(v);
19
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
20
+ const createTime = (fnName, tagName = '') => {
21
+ {
22
+ return () => {
23
+ return;
24
+ };
25
+ }
26
+ };
27
+ const uniqueTime = (key, measureText) => {
28
+ {
29
+ return () => {
30
+ return;
31
+ };
32
+ }
33
+ };
34
+ /**
35
+ * Default style mode id
36
+ */
37
+ /**
38
+ * Reusable empty obj/array
39
+ * Don't add values to these!!
40
+ */
41
+ const EMPTY_OBJ = {};
42
+ const isDef = (v) => v != null;
43
+ const isComplexType = (o) => {
44
+ // https://jsperf.com/typeof-fn-object/5
45
+ o = typeof o;
46
+ return o === 'object' || o === 'function';
47
+ };
48
+ /**
49
+ * Production h() function based on Preact by
50
+ * Jason Miller (@developit)
51
+ * Licensed under the MIT License
52
+ * https://github.com/developit/preact/blob/master/LICENSE
53
+ *
54
+ * Modified for Stencil's compiler and vdom
55
+ */
56
+ // const stack: any[] = [];
57
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
58
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
59
+ const h = (nodeName, vnodeData, ...children) => {
60
+ let child = null;
61
+ let simple = false;
62
+ let lastSimple = false;
63
+ let vNodeChildren = [];
64
+ const walk = (c) => {
65
+ for (let i = 0; i < c.length; i++) {
66
+ child = c[i];
67
+ if (Array.isArray(child)) {
68
+ walk(child);
69
+ }
70
+ else if (child != null && typeof child !== 'boolean') {
71
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
72
+ child = String(child);
73
+ }
74
+ if (simple && lastSimple) {
75
+ // If the previous child was simple (string), we merge both
76
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
77
+ }
78
+ else {
79
+ // Append a new vNode, if it's text, we create a text vNode
80
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
81
+ }
82
+ lastSimple = simple;
83
+ }
84
+ }
85
+ };
86
+ walk(children);
87
+ if (vnodeData) {
88
+ {
89
+ const classData = vnodeData.className || vnodeData.class;
90
+ if (classData) {
91
+ vnodeData.class =
92
+ typeof classData !== 'object'
93
+ ? classData
94
+ : Object.keys(classData)
95
+ .filter(k => classData[k])
96
+ .join(' ');
97
+ }
98
+ }
99
+ }
100
+ const vnode = newVNode(nodeName, null);
101
+ vnode.$attrs$ = vnodeData;
102
+ if (vNodeChildren.length > 0) {
103
+ vnode.$children$ = vNodeChildren;
104
+ }
105
+ return vnode;
106
+ };
107
+ const newVNode = (tag, text) => {
108
+ const vnode = {
109
+ $flags$: 0,
110
+ $tag$: tag,
111
+ $text$: text,
112
+ $elm$: null,
113
+ $children$: null,
114
+ };
115
+ {
116
+ vnode.$attrs$ = null;
117
+ }
118
+ return vnode;
119
+ };
120
+ const Host = {};
121
+ const isHost = (node) => node && node.$tag$ === Host;
122
+ /**
123
+ * Production setAccessor() function based on Preact by
124
+ * Jason Miller (@developit)
125
+ * Licensed under the MIT License
126
+ * https://github.com/developit/preact/blob/master/LICENSE
127
+ *
128
+ * Modified for Stencil's compiler and vdom
129
+ */
130
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
131
+ if (oldValue !== newValue) {
132
+ let isProp = isMemberInElement(elm, memberName);
133
+ let ln = memberName.toLowerCase();
134
+ if (memberName === 'class') {
135
+ const classList = elm.classList;
136
+ const oldClasses = parseClassList(oldValue);
137
+ const newClasses = parseClassList(newValue);
138
+ classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
139
+ classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
140
+ }
141
+ else if ((!isProp ) && memberName[0] === 'o' && memberName[1] === 'n') {
142
+ // Event Handlers
143
+ // so if the member name starts with "on" and the 3rd characters is
144
+ // a capital letter, and it's not already a member on the element,
145
+ // then we're assuming it's an event listener
146
+ if (memberName[2] === '-') {
147
+ // on- prefixed events
148
+ // allows to be explicit about the dom event to listen without any magic
149
+ // under the hood:
150
+ // <my-cmp on-click> // listens for "click"
151
+ // <my-cmp on-Click> // listens for "Click"
152
+ // <my-cmp on-ionChange> // listens for "ionChange"
153
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
154
+ memberName = memberName.slice(3);
155
+ }
156
+ else if (isMemberInElement(win, ln)) {
157
+ // standard event
158
+ // the JSX attribute could have been "onMouseOver" and the
159
+ // member name "onmouseover" is on the window's prototype
160
+ // so let's add the listener "mouseover", which is all lowercased
161
+ memberName = ln.slice(2);
162
+ }
163
+ else {
164
+ // custom event
165
+ // the JSX attribute could have been "onMyCustomEvent"
166
+ // so let's trim off the "on" prefix and lowercase the first character
167
+ // and add the listener "myCustomEvent"
168
+ // except for the first character, we keep the event name case
169
+ memberName = ln[2] + memberName.slice(3);
170
+ }
171
+ if (oldValue) {
172
+ plt.rel(elm, memberName, oldValue, false);
173
+ }
174
+ if (newValue) {
175
+ plt.ael(elm, memberName, newValue, false);
176
+ }
177
+ }
178
+ else {
179
+ // Set property if it exists and it's not a SVG
180
+ const isComplex = isComplexType(newValue);
181
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
182
+ try {
183
+ if (!elm.tagName.includes('-')) {
184
+ let n = newValue == null ? '' : newValue;
185
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
186
+ if (memberName === 'list') {
187
+ isProp = false;
188
+ // tslint:disable-next-line: triple-equals
189
+ }
190
+ else if (oldValue == null || elm[memberName] != n) {
191
+ elm[memberName] = n;
192
+ }
193
+ }
194
+ else {
195
+ elm[memberName] = newValue;
196
+ }
197
+ }
198
+ catch (e) { }
199
+ }
200
+ if (newValue == null || newValue === false) {
201
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
202
+ {
203
+ elm.removeAttribute(memberName);
204
+ }
205
+ }
206
+ }
207
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
208
+ newValue = newValue === true ? '' : newValue;
209
+ {
210
+ elm.setAttribute(memberName, newValue);
211
+ }
212
+ }
213
+ }
214
+ }
215
+ };
216
+ const parseClassListRegex = /\s/;
217
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
218
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
219
+ // if the element passed in is a shadow root, which is a document fragment
220
+ // then we want to be adding attrs/props to the shadow root's "host" element
221
+ // if it's not a shadow root, then we add attrs/props to the same element
222
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
223
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
224
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
225
+ {
226
+ // remove attributes no longer present on the vnode by setting them to undefined
227
+ for (memberName in oldVnodeAttrs) {
228
+ if (!(memberName in newVnodeAttrs)) {
229
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
230
+ }
231
+ }
232
+ }
233
+ // add new & update changed attributes
234
+ for (memberName in newVnodeAttrs) {
235
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
236
+ }
237
+ };
238
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
239
+ // tslint:disable-next-line: prefer-const
240
+ let newVNode = newParentVNode.$children$[childIndex];
241
+ let i = 0;
242
+ let elm;
243
+ let childNode;
244
+ if (newVNode.$text$ !== null) {
245
+ // create text node
246
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
247
+ }
248
+ else {
249
+ // create element
250
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
251
+ // add css classes, attrs, props, listeners, etc.
252
+ {
253
+ updateElement(null, newVNode, isSvgMode);
254
+ }
255
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
256
+ // if there is a scopeId and this is the initial render
257
+ // then let's add the scopeId as a css class
258
+ elm.classList.add((elm['s-si'] = scopeId));
259
+ }
260
+ if (newVNode.$children$) {
261
+ for (i = 0; i < newVNode.$children$.length; ++i) {
262
+ // create the node
263
+ childNode = createElm(oldParentVNode, newVNode, i);
264
+ // return node could have been null
265
+ if (childNode) {
266
+ // append our new node
267
+ elm.appendChild(childNode);
268
+ }
269
+ }
270
+ }
271
+ }
272
+ return elm;
273
+ };
274
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
275
+ let containerElm = (parentElm);
276
+ let childNode;
277
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
278
+ containerElm = containerElm.shadowRoot;
279
+ }
280
+ for (; startIdx <= endIdx; ++startIdx) {
281
+ if (vnodes[startIdx]) {
282
+ childNode = createElm(null, parentVNode, startIdx);
283
+ if (childNode) {
284
+ vnodes[startIdx].$elm$ = childNode;
285
+ containerElm.insertBefore(childNode, before);
286
+ }
287
+ }
288
+ }
289
+ };
290
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
291
+ for (; startIdx <= endIdx; ++startIdx) {
292
+ if ((vnode = vnodes[startIdx])) {
293
+ elm = vnode.$elm$;
294
+ // remove the vnode's element from the dom
295
+ elm.remove();
296
+ }
297
+ }
298
+ };
299
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
300
+ let oldStartIdx = 0;
301
+ let newStartIdx = 0;
302
+ let oldEndIdx = oldCh.length - 1;
303
+ let oldStartVnode = oldCh[0];
304
+ let oldEndVnode = oldCh[oldEndIdx];
305
+ let newEndIdx = newCh.length - 1;
306
+ let newStartVnode = newCh[0];
307
+ let newEndVnode = newCh[newEndIdx];
308
+ let node;
309
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
310
+ if (oldStartVnode == null) {
311
+ // Vnode might have been moved left
312
+ oldStartVnode = oldCh[++oldStartIdx];
313
+ }
314
+ else if (oldEndVnode == null) {
315
+ oldEndVnode = oldCh[--oldEndIdx];
316
+ }
317
+ else if (newStartVnode == null) {
318
+ newStartVnode = newCh[++newStartIdx];
319
+ }
320
+ else if (newEndVnode == null) {
321
+ newEndVnode = newCh[--newEndIdx];
322
+ }
323
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
324
+ patch(oldStartVnode, newStartVnode);
325
+ oldStartVnode = oldCh[++oldStartIdx];
326
+ newStartVnode = newCh[++newStartIdx];
327
+ }
328
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
329
+ patch(oldEndVnode, newEndVnode);
330
+ oldEndVnode = oldCh[--oldEndIdx];
331
+ newEndVnode = newCh[--newEndIdx];
332
+ }
333
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
334
+ patch(oldStartVnode, newEndVnode);
335
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
336
+ oldStartVnode = oldCh[++oldStartIdx];
337
+ newEndVnode = newCh[--newEndIdx];
338
+ }
339
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
340
+ patch(oldEndVnode, newStartVnode);
341
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
342
+ oldEndVnode = oldCh[--oldEndIdx];
343
+ newStartVnode = newCh[++newStartIdx];
344
+ }
345
+ else {
346
+ {
347
+ // new element
348
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
349
+ newStartVnode = newCh[++newStartIdx];
350
+ }
351
+ if (node) {
352
+ {
353
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
354
+ }
355
+ }
356
+ }
357
+ }
358
+ if (oldStartIdx > oldEndIdx) {
359
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
360
+ }
361
+ else if (newStartIdx > newEndIdx) {
362
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
363
+ }
364
+ };
365
+ const isSameVnode = (vnode1, vnode2) => {
366
+ // compare if two vnode to see if they're "technically" the same
367
+ // need to have the same element tag, and same key to be the same
368
+ if (vnode1.$tag$ === vnode2.$tag$) {
369
+ return true;
370
+ }
371
+ return false;
372
+ };
373
+ const patch = (oldVNode, newVNode) => {
374
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
375
+ const oldChildren = oldVNode.$children$;
376
+ const newChildren = newVNode.$children$;
377
+ const tag = newVNode.$tag$;
378
+ const text = newVNode.$text$;
379
+ if (text === null) {
380
+ // element node
381
+ {
382
+ if (tag === 'slot')
383
+ ;
384
+ else {
385
+ // either this is the first render of an element OR it's an update
386
+ // AND we already know it's possible it could have changed
387
+ // this updates the element's css classes, attrs, props, listeners, etc.
388
+ updateElement(oldVNode, newVNode, isSvgMode);
389
+ }
390
+ }
391
+ if (oldChildren !== null && newChildren !== null) {
392
+ // looks like there's child vnodes for both the old and new vnodes
393
+ updateChildren(elm, oldChildren, newVNode, newChildren);
394
+ }
395
+ else if (newChildren !== null) {
396
+ // no old child vnodes, but there are new child vnodes to add
397
+ if (oldVNode.$text$ !== null) {
398
+ // the old vnode was text, so be sure to clear it out
399
+ elm.textContent = '';
400
+ }
401
+ // add the new vnode children
402
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
403
+ }
404
+ else if (oldChildren !== null) {
405
+ // no new child vnodes, but there are old child vnodes to remove
406
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
407
+ }
408
+ }
409
+ else if (oldVNode.$text$ !== text) {
410
+ // update the text content for the text only vnode
411
+ // and also only if the text is different than before
412
+ elm.data = text;
413
+ }
414
+ };
415
+ const renderVdom = (hostRef, renderFnResults) => {
416
+ const hostElm = hostRef.$hostElement$;
417
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
418
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
419
+ hostTagName = hostElm.tagName;
420
+ rootVnode.$tag$ = null;
421
+ rootVnode.$flags$ |= 4 /* isHost */;
422
+ hostRef.$vnode$ = rootVnode;
423
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
424
+ {
425
+ scopeId = hostElm['s-sc'];
426
+ }
427
+ // synchronous patch
428
+ patch(oldVNode, rootVnode);
429
+ };
430
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
431
+ const createEvent = (ref, name, flags) => {
432
+ const elm = getElement(ref);
433
+ return {
434
+ emit: (detail) => {
435
+ return emitEvent(elm, name, {
436
+ bubbles: !!(flags & 4 /* Bubbles */),
437
+ composed: !!(flags & 2 /* Composed */),
438
+ cancelable: !!(flags & 1 /* Cancellable */),
439
+ detail,
440
+ });
441
+ },
442
+ };
443
+ };
444
+ const emitEvent = (elm, name, opts) => {
445
+ const ev = plt.ce(name, opts);
446
+ elm.dispatchEvent(ev);
447
+ return ev;
448
+ };
449
+ const attachToAncestor = (hostRef, ancestorComponent) => {
450
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
451
+ ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
452
+ }
453
+ };
454
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
455
+ {
456
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
457
+ }
458
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
459
+ hostRef.$flags$ |= 512 /* needsRerender */;
460
+ return;
461
+ }
462
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
463
+ // there is no ancestor component or the ancestor component
464
+ // has already fired off its lifecycle update then
465
+ // fire off the initial update
466
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
467
+ return writeTask(dispatch) ;
468
+ };
469
+ const dispatchHooks = (hostRef, isInitialLoad) => {
470
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
471
+ const instance = hostRef.$lazyInstance$ ;
472
+ let promise;
473
+ if (isInitialLoad) {
474
+ {
475
+ promise = safeCall(instance, 'componentWillLoad');
476
+ }
477
+ }
478
+ endSchedule();
479
+ return then(promise, () => updateComponent(hostRef, instance));
480
+ };
481
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
482
+ // updateComponent
483
+ const elm = hostRef.$hostElement$;
484
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
485
+ const rc = elm['s-rc'];
486
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
487
+ {
488
+ callRender(hostRef, instance);
489
+ }
490
+ if (rc) {
491
+ // ok, so turns out there are some child host elements
492
+ // waiting on this parent element to load
493
+ // let's fire off all update callbacks waiting
494
+ rc.map(cb => cb());
495
+ elm['s-rc'] = undefined;
496
+ }
497
+ endRender();
498
+ endUpdate();
499
+ {
500
+ const childrenPromises = elm['s-p'];
501
+ const postUpdate = () => postUpdateComponent(hostRef);
502
+ if (childrenPromises.length === 0) {
503
+ postUpdate();
504
+ }
505
+ else {
506
+ Promise.all(childrenPromises).then(postUpdate);
507
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
508
+ childrenPromises.length = 0;
509
+ }
510
+ }
511
+ };
512
+ const callRender = (hostRef, instance, elm) => {
513
+ try {
514
+ instance = instance.render() ;
515
+ {
516
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
517
+ }
518
+ {
519
+ hostRef.$flags$ |= 2 /* hasRendered */;
520
+ }
521
+ {
522
+ {
523
+ // looks like we've got child nodes to render into this host element
524
+ // or we need to update the css class/attrs on the host element
525
+ // DOM WRITE!
526
+ {
527
+ renderVdom(hostRef, instance);
528
+ }
529
+ }
530
+ }
531
+ }
532
+ catch (e) {
533
+ consoleError(e, hostRef.$hostElement$);
534
+ }
535
+ return null;
536
+ };
537
+ const postUpdateComponent = (hostRef) => {
538
+ const tagName = hostRef.$cmpMeta$.$tagName$;
539
+ const elm = hostRef.$hostElement$;
540
+ const endPostUpdate = createTime('postUpdate', tagName);
541
+ const ancestorComponent = hostRef.$ancestorComponent$;
542
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
543
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
544
+ {
545
+ // DOM WRITE!
546
+ addHydratedFlag(elm);
547
+ }
548
+ endPostUpdate();
549
+ {
550
+ hostRef.$onReadyResolve$(elm);
551
+ if (!ancestorComponent) {
552
+ appDidLoad();
553
+ }
554
+ }
555
+ }
556
+ else {
557
+ endPostUpdate();
558
+ }
559
+ // load events fire from bottom to top
560
+ // the deepest elements load first then bubbles up
561
+ {
562
+ if (hostRef.$onRenderResolve$) {
563
+ hostRef.$onRenderResolve$();
564
+ hostRef.$onRenderResolve$ = undefined;
565
+ }
566
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
567
+ nextTick(() => scheduleUpdate(hostRef, false));
568
+ }
569
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
570
+ }
571
+ // ( •_•)
572
+ // ( •_•)>⌐■-■
573
+ // (⌐■_■)
574
+ };
575
+ const appDidLoad = (who) => {
576
+ // on appload
577
+ // we have finish the first big initial render
578
+ {
579
+ addHydratedFlag(doc.documentElement);
580
+ }
581
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
582
+ };
583
+ const safeCall = (instance, method, arg) => {
584
+ if (instance && instance[method]) {
585
+ try {
586
+ return instance[method](arg);
587
+ }
588
+ catch (e) {
589
+ consoleError(e);
590
+ }
591
+ }
592
+ return undefined;
593
+ };
594
+ const then = (promise, thenFn) => {
595
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
596
+ };
597
+ const addHydratedFlag = (elm) => (elm.classList.add('hydrated') );
598
+ const parsePropertyValue = (propValue, propType) => {
599
+ // ensure this value is of the correct prop type
600
+ if (propValue != null && !isComplexType(propValue)) {
601
+ if (propType & 4 /* Boolean */) {
602
+ // per the HTML spec, any string value means it is a boolean true value
603
+ // but we'll cheat here and say that the string "false" is the boolean false
604
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
605
+ }
606
+ // redundant return here for better minification
607
+ return propValue;
608
+ }
609
+ // not sure exactly what type we want
610
+ // so no need to change to a different type
611
+ return propValue;
612
+ };
613
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
614
+ const setValue = (ref, propName, newVal, cmpMeta) => {
615
+ // check our new property value against our internal value
616
+ const hostRef = getHostRef(ref);
617
+ const oldVal = hostRef.$instanceValues$.get(propName);
618
+ const flags = hostRef.$flags$;
619
+ const instance = hostRef.$lazyInstance$ ;
620
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
621
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
622
+ // gadzooks! the property's value has changed!!
623
+ // set our new value!
624
+ hostRef.$instanceValues$.set(propName, newVal);
625
+ if (instance) {
626
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
627
+ // looks like this value actually changed, so we've got work to do!
628
+ // but only if we've already rendered, otherwise just chill out
629
+ // queue that we need to do an update, but don't worry about queuing
630
+ // up millions cuz this function ensures it only runs once
631
+ scheduleUpdate(hostRef, false);
632
+ }
633
+ }
634
+ }
635
+ };
636
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
637
+ if (cmpMeta.$members$) {
638
+ // It's better to have a const than two Object.entries()
639
+ const members = Object.entries(cmpMeta.$members$);
640
+ const prototype = Cstr.prototype;
641
+ members.map(([memberName, [memberFlags]]) => {
642
+ if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
643
+ // proxyComponent - prop
644
+ Object.defineProperty(prototype, memberName, {
645
+ get() {
646
+ // proxyComponent, get value
647
+ return getValue(this, memberName);
648
+ },
649
+ set(newValue) {
650
+ // proxyComponent, set value
651
+ setValue(this, memberName, newValue, cmpMeta);
652
+ },
653
+ configurable: true,
654
+ enumerable: true,
655
+ });
656
+ }
657
+ });
658
+ if ((flags & 1 /* isElementConstructor */)) {
659
+ const attrNameToPropName = new Map();
660
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
661
+ plt.jmp(() => {
662
+ const propName = attrNameToPropName.get(attrName);
663
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
664
+ });
665
+ };
666
+ // create an array of attributes to observe
667
+ // and also create a map of html attribute name to js property name
668
+ Cstr.observedAttributes = members
669
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
670
+ .map(([propName, m]) => {
671
+ const attrName = m[1] || propName;
672
+ attrNameToPropName.set(attrName, propName);
673
+ return attrName;
674
+ });
675
+ }
676
+ }
677
+ return Cstr;
678
+ };
679
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
680
+ // initializeComponent
681
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
682
+ {
683
+ // we haven't initialized this element yet
684
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
685
+ // lazy loaded components
686
+ // request the component's implementation to be
687
+ // wired up with the host element
688
+ Cstr = loadModule(cmpMeta);
689
+ if (Cstr.then) {
690
+ // Await creates a micro-task avoid if possible
691
+ const endLoad = uniqueTime();
692
+ Cstr = await Cstr;
693
+ endLoad();
694
+ }
695
+ if (!Cstr.isProxied) {
696
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
697
+ Cstr.isProxied = true;
698
+ }
699
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
700
+ // ok, time to construct the instance
701
+ // but let's keep track of when we start and stop
702
+ // so that the getters/setters don't incorrectly step on data
703
+ {
704
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
705
+ }
706
+ // construct the lazy-loaded component implementation
707
+ // passing the hostRef is very important during
708
+ // construction in order to directly wire together the
709
+ // host element and the lazy-loaded instance
710
+ try {
711
+ new Cstr(hostRef);
712
+ }
713
+ catch (e) {
714
+ consoleError(e);
715
+ }
716
+ {
717
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
718
+ }
719
+ endNewInstance();
720
+ }
721
+ }
722
+ // we've successfully created a lazy instance
723
+ const ancestorComponent = hostRef.$ancestorComponent$;
724
+ const schedule = () => scheduleUpdate(hostRef, true);
725
+ if (ancestorComponent && ancestorComponent['s-rc']) {
726
+ // this is the intial load and this component it has an ancestor component
727
+ // but the ancestor component has NOT fired its will update lifecycle yet
728
+ // so let's just cool our jets and wait for the ancestor to continue first
729
+ // this will get fired off when the ancestor component
730
+ // finally gets around to rendering its lazy self
731
+ // fire off the initial update
732
+ ancestorComponent['s-rc'].push(schedule);
733
+ }
734
+ else {
735
+ schedule();
736
+ }
737
+ };
738
+ const connectedCallback = (elm) => {
739
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
740
+ const hostRef = getHostRef(elm);
741
+ const cmpMeta = hostRef.$cmpMeta$;
742
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
743
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
744
+ // first time this component has connected
745
+ hostRef.$flags$ |= 1 /* hasConnected */;
746
+ {
747
+ // find the first ancestor component (if there is one) and register
748
+ // this component as one of the actively loading child components for its ancestor
749
+ let ancestorComponent = elm;
750
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
751
+ // climb up the ancestors looking for the first
752
+ // component that hasn't finished its lifecycle update yet
753
+ if (ancestorComponent['s-p']) {
754
+ // we found this components first ancestor component
755
+ // keep a reference to this component's ancestor component
756
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
757
+ break;
758
+ }
759
+ }
760
+ }
761
+ // Lazy properties
762
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
763
+ if (cmpMeta.$members$) {
764
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
765
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
766
+ const value = elm[memberName];
767
+ delete elm[memberName];
768
+ elm[memberName] = value;
769
+ }
770
+ });
771
+ }
772
+ {
773
+ initializeComponent(elm, hostRef, cmpMeta);
774
+ }
775
+ }
776
+ endConnected();
777
+ }
778
+ };
779
+ const disconnectedCallback = (elm) => {
780
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
781
+ getHostRef(elm);
782
+ }
783
+ };
784
+ const bootstrapLazy = (lazyBundles, options = {}) => {
785
+ const endBootstrap = createTime();
786
+ const cmpTags = [];
787
+ const exclude = options.exclude || [];
788
+ const customElements = win.customElements;
789
+ const head = doc.head;
790
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
791
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
792
+ const deferredConnectedCallbacks = [];
793
+ let appLoadFallback;
794
+ let isBootstrapping = true;
795
+ Object.assign(plt, options);
796
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
797
+ lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
798
+ const cmpMeta = {
799
+ $flags$: compactMeta[0],
800
+ $tagName$: compactMeta[1],
801
+ $members$: compactMeta[2],
802
+ $listeners$: compactMeta[3],
803
+ };
804
+ {
805
+ cmpMeta.$members$ = compactMeta[2];
806
+ }
807
+ const tagName = cmpMeta.$tagName$;
808
+ const HostElement = class extends HTMLElement {
809
+ // StencilLazyHost
810
+ constructor(self) {
811
+ // @ts-ignore
812
+ super(self);
813
+ self = this;
814
+ registerHost(self, cmpMeta);
815
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
816
+ // this component is using shadow dom
817
+ // and this browser supports shadow dom
818
+ // add the read-only property "shadowRoot" to the host element
819
+ // adding the shadow root build conditionals to minimize runtime
820
+ {
821
+ {
822
+ self.attachShadow({ mode: 'open' });
823
+ }
824
+ }
825
+ }
826
+ }
827
+ connectedCallback() {
828
+ if (appLoadFallback) {
829
+ clearTimeout(appLoadFallback);
830
+ appLoadFallback = null;
831
+ }
832
+ if (isBootstrapping) {
833
+ // connectedCallback will be processed once all components have been registered
834
+ deferredConnectedCallbacks.push(this);
835
+ }
836
+ else {
837
+ plt.jmp(() => connectedCallback(this));
838
+ }
839
+ }
840
+ disconnectedCallback() {
841
+ plt.jmp(() => disconnectedCallback(this));
842
+ }
843
+ componentOnReady() {
844
+ return getHostRef(this).$onReadyPromise$;
845
+ }
846
+ };
847
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
848
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
849
+ cmpTags.push(tagName);
850
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
851
+ }
852
+ }));
853
+ {
854
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
855
+ visibilityStyle.setAttribute('data-styles', '');
856
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
857
+ }
858
+ // Process deferred connectedCallbacks now all components have been registered
859
+ isBootstrapping = false;
860
+ if (deferredConnectedCallbacks.length) {
861
+ deferredConnectedCallbacks.map(host => host.connectedCallback());
862
+ }
863
+ else {
864
+ {
865
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
866
+ }
867
+ }
868
+ // Fallback appLoad event
869
+ endBootstrap();
870
+ };
871
+ const hostRefs = new WeakMap();
872
+ const getHostRef = (ref) => hostRefs.get(ref);
873
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
874
+ const registerHost = (elm, cmpMeta) => {
875
+ const hostRef = {
876
+ $flags$: 0,
877
+ $hostElement$: elm,
878
+ $cmpMeta$: cmpMeta,
879
+ $instanceValues$: new Map(),
880
+ };
881
+ {
882
+ hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
883
+ elm['s-p'] = [];
884
+ elm['s-rc'] = [];
885
+ }
886
+ return hostRefs.set(elm, hostRef);
887
+ };
888
+ const isMemberInElement = (elm, memberName) => memberName in elm;
889
+ const consoleError = (e, el) => (0, console.error)(e, el);
890
+ const cmpModules = /*@__PURE__*/ new Map();
891
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
892
+ // loadModuleImport
893
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
894
+ const bundleId = cmpMeta.$lazyBundleId$;
895
+ const module = cmpModules.get(bundleId) ;
896
+ if (module) {
897
+ return module[exportName];
898
+ }
899
+ return import(
900
+ /* webpackInclude: /\.entry\.js$/ */
901
+ /* webpackExclude: /\.system\.entry\.js$/ */
902
+ /* webpackMode: "lazy" */
903
+ `./${bundleId}.entry.js${''}`).then(importedModule => {
904
+ {
905
+ cmpModules.set(bundleId, importedModule);
906
+ }
907
+ return importedModule[exportName];
908
+ }, consoleError);
909
+ };
910
+ const queueDomReads = [];
911
+ const queueDomWrites = [];
912
+ const queueTask = (queue, write) => (cb) => {
913
+ queue.push(cb);
914
+ if (!queuePending) {
915
+ queuePending = true;
916
+ if (write && plt.$flags$ & 4 /* queueSync */) {
917
+ nextTick(flush);
918
+ }
919
+ else {
920
+ plt.raf(flush);
921
+ }
922
+ }
923
+ };
924
+ const consume = (queue) => {
925
+ for (let i = 0; i < queue.length; i++) {
926
+ try {
927
+ queue[i](performance.now());
928
+ }
929
+ catch (e) {
930
+ consoleError(e);
931
+ }
932
+ }
933
+ queue.length = 0;
934
+ };
935
+ const flush = () => {
936
+ // always force a bunch of medium callbacks to run, but still have
937
+ // a throttle on how many can run in a certain time
938
+ // DOM READS!!!
939
+ consume(queueDomReads);
940
+ // DOM WRITES!!!
941
+ {
942
+ consume(queueDomWrites);
943
+ if ((queuePending = queueDomReads.length > 0)) {
944
+ // still more to do yet, but we've run out of time
945
+ // let's let this thing cool off and try again in the next tick
946
+ plt.raf(flush);
947
+ }
948
+ }
949
+ };
950
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
951
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
952
+
953
+ export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };