@gataca/qr 0.0.20 → 0.0.21

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