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