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