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