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