@everymatrix/general-registration 1.31.2 → 1.32.4

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