@gataca/qr 4.1.0 → 4.2.1

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