@everymatrix/casino-game-thumb-view 1.31.1 → 1.32.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +3 -2
  3. package/dist/assets/baccarat.svg +0 -43
  4. package/dist/assets/fav.svg +0 -9
  5. package/dist/assets/favorite.svg +0 -12
  6. package/dist/assets/seat.svg +0 -6
  7. package/dist/assets/unfav.svg +0 -20
  8. package/dist/casino-game-thumb-view/casino-game-thumb-view.esm.js +0 -1
  9. package/dist/casino-game-thumb-view/index.esm.js +0 -0
  10. package/dist/casino-game-thumb-view/p-1bbf4b70.entry.js +0 -1
  11. package/dist/casino-game-thumb-view/p-1e63a1ab.js +0 -1
  12. package/dist/casino-game-thumb-view/p-2d5f59fe.js +0 -1
  13. package/dist/casino-game-thumb-view/p-42bf2034.entry.js +0 -1
  14. package/dist/casino-game-thumb-view/p-46dbb1cb.js +0 -1
  15. package/dist/casino-game-thumb-view/p-6a6b2a78.js +0 -8
  16. package/dist/casino-game-thumb-view/p-7ae107ed.entry.js +0 -1
  17. package/dist/casino-game-thumb-view/p-9cbfffbc.entry.js +0 -1
  18. package/dist/casino-game-thumb-view/p-d961aec4.entry.js +0 -1
  19. package/dist/casino-game-thumb-view/p-db43bb56.entry.js +0 -7
  20. package/dist/cjs/casino-extrainfo-baccarat.cjs.entry.js +0 -366
  21. package/dist/cjs/casino-extrainfo-blackjack.cjs.entry.js +0 -58
  22. package/dist/cjs/casino-extrainfo-roulette.cjs.entry.js +0 -45
  23. package/dist/cjs/casino-game-thumb-view.cjs.js +0 -19
  24. package/dist/cjs/casino-game-thumb-view_2.cjs.entry.js +0 -1612
  25. package/dist/cjs/casino-game-thumbnail-betlimit_2.cjs.entry.js +0 -278
  26. package/dist/cjs/casino-normal-game-thumbnail.cjs.entry.js +0 -23
  27. package/dist/cjs/game-thumbnail-31d518f0.js +0 -78
  28. package/dist/cjs/index-65a1d768.js +0 -1796
  29. package/dist/cjs/index.cjs.js +0 -2
  30. package/dist/cjs/loader.cjs.js +0 -21
  31. package/dist/cjs/locale.utils-aa160787.js +0 -132
  32. package/dist/cjs/utils-a0afc0a9.js +0 -5745
  33. package/dist/collection/collection-manifest.json +0 -19
  34. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.css +0 -116
  35. package/dist/collection/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.js +0 -240
  36. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.css +0 -64
  37. package/dist/collection/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.js +0 -119
  38. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.css +0 -40
  39. package/dist/collection/components/casino-extrainfo-roulette/casino-extrainfo-roulette.js +0 -123
  40. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.css +0 -361
  41. package/dist/collection/components/casino-game-thumb-view/casino-game-thumb-view.js +0 -1064
  42. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.css +0 -3
  43. package/dist/collection/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.js +0 -86
  44. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.css +0 -154
  45. package/dist/collection/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.js +0 -158
  46. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.css +0 -58
  47. package/dist/collection/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.js +0 -209
  48. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.css +0 -3
  49. package/dist/collection/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.js +0 -62
  50. package/dist/collection/constants/game-thumbnail.js +0 -85
  51. package/dist/collection/index.js +0 -1
  52. package/dist/collection/models/casino-game-thumb-view.js +0 -12
  53. package/dist/collection/models/currency-symbols.js +0 -173
  54. package/dist/collection/static/baccarat.svg +0 -43
  55. package/dist/collection/static/fav.svg +0 -9
  56. package/dist/collection/static/favorite.svg +0 -12
  57. package/dist/collection/static/seat.svg +0 -6
  58. package/dist/collection/static/unfav.svg +0 -20
  59. package/dist/collection/utils/baccarat-board-svg.js +0 -234
  60. package/dist/collection/utils/locale.utils.js +0 -128
  61. package/dist/collection/utils/utils.js +0 -65
  62. package/dist/components/casino-extrainfo-baccarat.d.ts +0 -11
  63. package/dist/components/casino-extrainfo-baccarat.js +0 -400
  64. package/dist/components/casino-extrainfo-blackjack.d.ts +0 -11
  65. package/dist/components/casino-extrainfo-blackjack.js +0 -92
  66. package/dist/components/casino-extrainfo-roulette.d.ts +0 -11
  67. package/dist/components/casino-extrainfo-roulette.js +0 -78
  68. package/dist/components/casino-game-thumb-view.d.ts +0 -11
  69. package/dist/components/casino-game-thumb-view.js +0 -1625
  70. package/dist/components/casino-game-thumbnail-betlimit.d.ts +0 -11
  71. package/dist/components/casino-game-thumbnail-betlimit.js +0 -6
  72. package/dist/components/casino-game-thumbnail-betlimit2.js +0 -227
  73. package/dist/components/casino-game-thumbnail-extrainfo.d.ts +0 -11
  74. package/dist/components/casino-game-thumbnail-extrainfo.js +0 -6
  75. package/dist/components/casino-game-thumbnail-extrainfo2.js +0 -96
  76. package/dist/components/casino-game-thumbnail-overlay.d.ts +0 -11
  77. package/dist/components/casino-game-thumbnail-overlay.js +0 -6
  78. package/dist/components/casino-game-thumbnail-overlay2.js +0 -69
  79. package/dist/components/casino-normal-game-thumbnail.d.ts +0 -11
  80. package/dist/components/casino-normal-game-thumbnail.js +0 -52
  81. package/dist/components/game-thumbnail.js +0 -72
  82. package/dist/components/index.d.ts +0 -26
  83. package/dist/components/index.js +0 -1
  84. package/dist/components/locale.utils.js +0 -130
  85. package/dist/components/utils.js +0 -5739
  86. package/dist/esm/casino-extrainfo-baccarat.entry.js +0 -362
  87. package/dist/esm/casino-extrainfo-blackjack.entry.js +0 -54
  88. package/dist/esm/casino-extrainfo-roulette.entry.js +0 -41
  89. package/dist/esm/casino-game-thumb-view.js +0 -17
  90. package/dist/esm/casino-game-thumb-view_2.entry.js +0 -1607
  91. package/dist/esm/casino-game-thumbnail-betlimit_2.entry.js +0 -273
  92. package/dist/esm/casino-normal-game-thumbnail.entry.js +0 -19
  93. package/dist/esm/game-thumbnail-0a56ee03.js +0 -72
  94. package/dist/esm/index-1e44dd9f.js +0 -1769
  95. package/dist/esm/index.js +0 -1
  96. package/dist/esm/loader.js +0 -17
  97. package/dist/esm/locale.utils-e0cf897e.js +0 -130
  98. package/dist/esm/polyfills/core-js.js +0 -11
  99. package/dist/esm/polyfills/css-shim.js +0 -1
  100. package/dist/esm/polyfills/dom.js +0 -79
  101. package/dist/esm/polyfills/es5-html-element.js +0 -1
  102. package/dist/esm/polyfills/index.js +0 -34
  103. package/dist/esm/polyfills/system.js +0 -6
  104. package/dist/esm/utils-e9314132.js +0 -5739
  105. package/dist/index.cjs.js +0 -1
  106. package/dist/index.js +0 -1
  107. package/dist/stencil.config.js +0 -40
  108. package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/casino-game-thumb-view/.stencil/packages/casino-game-thumb-view/stencil.config.d.ts +0 -2
  109. package/dist/types/components/casino-extrainfo-baccarat/casino-extrainfo-baccarat.d.ts +0 -40
  110. package/dist/types/components/casino-extrainfo-blackjack/casino-extrainfo-blackjack.d.ts +0 -36
  111. package/dist/types/components/casino-extrainfo-roulette/casino-extrainfo-roulette.d.ts +0 -21
  112. package/dist/types/components/casino-game-thumb-view/casino-game-thumb-view.d.ts +0 -221
  113. package/dist/types/components/casino-game-thumbnail-betlimit/casino-game-thumbnail-betlimit.d.ts +0 -17
  114. package/dist/types/components/casino-game-thumbnail-extrainfo/casino-game-thumbnail-extrainfo.d.ts +0 -16
  115. package/dist/types/components/casino-game-thumbnail-overlay/casino-game-thumbnail-overlay.d.ts +0 -31
  116. package/dist/types/components/casino-normal-game-thumbnail/casino-normal-game-thumbnail.d.ts +0 -7
  117. package/dist/types/components.d.ts +0 -480
  118. package/dist/types/constants/game-thumbnail.d.ts +0 -83
  119. package/dist/types/index.d.ts +0 -1
  120. package/dist/types/models/casino-game-thumb-view.d.ts +0 -132
  121. package/dist/types/models/currency-symbols.d.ts +0 -172
  122. package/dist/types/stencil-public-runtime.d.ts +0 -1565
  123. package/dist/types/utils/baccarat-board-svg.d.ts +0 -31
  124. package/dist/types/utils/locale.utils.d.ts +0 -1
  125. package/dist/types/utils/utils.d.ts +0 -19
  126. package/loader/cdn.js +0 -3
  127. package/loader/index.cjs.js +0 -3
  128. package/loader/index.d.ts +0 -12
  129. package/loader/index.es2017.js +0 -3
  130. package/loader/index.js +0 -4
  131. package/loader/package.json +0 -10
@@ -1,1796 +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 = 'casino-game-thumb-view';
24
-
25
- let scopeId;
26
- let contentRef;
27
- let hostTagName;
28
- let useNativeShadowDom = false;
29
- let checkSlotFallbackVisibility = false;
30
- let checkSlotRelocate = false;
31
- let isSvgMode = false;
32
- let queuePending = false;
33
- const win = typeof window !== 'undefined' ? window : {};
34
- const doc = win.document || { head: {} };
35
- const plt = {
36
- $flags$: 0,
37
- $resourcesUrl$: '',
38
- jmp: (h) => h(),
39
- raf: (h) => requestAnimationFrame(h),
40
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
41
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
42
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
43
- };
44
- const promiseResolve = (v) => Promise.resolve(v);
45
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
46
- try {
47
- new CSSStyleSheet();
48
- return typeof new CSSStyleSheet().replace === 'function';
49
- }
50
- catch (e) { }
51
- return false;
52
- })()
53
- ;
54
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
55
- if (listeners) {
56
- listeners.map(([flags, name, method]) => {
57
- const target = getHostListenerTarget(elm, flags) ;
58
- const handler = hostListenerProxy(hostRef, method);
59
- const opts = hostListenerOpts(flags);
60
- plt.ael(target, name, handler, opts);
61
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
62
- });
63
- }
64
- };
65
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
66
- try {
67
- {
68
- if (hostRef.$flags$ & 256 /* isListenReady */) {
69
- // instance is ready, let's call it's member method for this event
70
- hostRef.$lazyInstance$[methodName](ev);
71
- }
72
- else {
73
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
74
- }
75
- }
76
- }
77
- catch (e) {
78
- consoleError(e);
79
- }
80
- };
81
- const getHostListenerTarget = (elm, flags) => {
82
- if (flags & 4 /* TargetDocument */)
83
- return doc;
84
- return elm;
85
- };
86
- // prettier-ignore
87
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
88
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
89
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
90
- const createTime = (fnName, tagName = '') => {
91
- {
92
- return () => {
93
- return;
94
- };
95
- }
96
- };
97
- const uniqueTime = (key, measureText) => {
98
- {
99
- return () => {
100
- return;
101
- };
102
- }
103
- };
104
- const rootAppliedStyles = new WeakMap();
105
- const registerStyle = (scopeId, cssText, allowCS) => {
106
- let style = styles.get(scopeId);
107
- if (supportsConstructibleStylesheets && allowCS) {
108
- style = (style || new CSSStyleSheet());
109
- style.replace(cssText);
110
- }
111
- else {
112
- style = cssText;
113
- }
114
- styles.set(scopeId, style);
115
- };
116
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
117
- let scopeId = getScopeId(cmpMeta);
118
- let style = styles.get(scopeId);
119
- // if an element is NOT connected then getRootNode() will return the wrong root node
120
- // so the fallback is to always use the document for the root node in those cases
121
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
122
- if (style) {
123
- if (typeof style === 'string') {
124
- styleContainerNode = styleContainerNode.head || styleContainerNode;
125
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
126
- let styleElm;
127
- if (!appliedStyles) {
128
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
129
- }
130
- if (!appliedStyles.has(scopeId)) {
131
- {
132
- {
133
- styleElm = doc.createElement('style');
134
- styleElm.innerHTML = style;
135
- }
136
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
137
- }
138
- if (appliedStyles) {
139
- appliedStyles.add(scopeId);
140
- }
141
- }
142
- }
143
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
144
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
145
- }
146
- }
147
- return scopeId;
148
- };
149
- const attachStyles = (hostRef) => {
150
- const cmpMeta = hostRef.$cmpMeta$;
151
- const elm = hostRef.$hostElement$;
152
- const flags = cmpMeta.$flags$;
153
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
154
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
155
- if (flags & 10 /* needsScopedEncapsulation */) {
156
- // only required when we're NOT using native shadow dom (slot)
157
- // or this browser doesn't support native shadow dom
158
- // and this host element was NOT created with SSR
159
- // let's pick out the inner content for slot projection
160
- // create a node to represent where the original
161
- // content was first placed, which is useful later on
162
- // DOM WRITE!!
163
- elm['s-sc'] = scopeId;
164
- elm.classList.add(scopeId + '-h');
165
- }
166
- endAttachStyles();
167
- };
168
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
169
- /**
170
- * Default style mode id
171
- */
172
- /**
173
- * Reusable empty obj/array
174
- * Don't add values to these!!
175
- */
176
- const EMPTY_OBJ = {};
177
- /**
178
- * Namespaces
179
- */
180
- const SVG_NS = 'http://www.w3.org/2000/svg';
181
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
182
- const isDef = (v) => v != null;
183
- const isComplexType = (o) => {
184
- // https://jsperf.com/typeof-fn-object/5
185
- o = typeof o;
186
- return o === 'object' || o === 'function';
187
- };
188
- /**
189
- * Production h() function based on Preact by
190
- * Jason Miller (@developit)
191
- * Licensed under the MIT License
192
- * https://github.com/developit/preact/blob/master/LICENSE
193
- *
194
- * Modified for Stencil's compiler and vdom
195
- */
196
- // const stack: any[] = [];
197
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
198
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
199
- const h = (nodeName, vnodeData, ...children) => {
200
- let child = null;
201
- let key = null;
202
- let slotName = null;
203
- let simple = false;
204
- let lastSimple = false;
205
- let vNodeChildren = [];
206
- const walk = (c) => {
207
- for (let i = 0; i < c.length; i++) {
208
- child = c[i];
209
- if (Array.isArray(child)) {
210
- walk(child);
211
- }
212
- else if (child != null && typeof child !== 'boolean') {
213
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
214
- child = String(child);
215
- }
216
- if (simple && lastSimple) {
217
- // If the previous child was simple (string), we merge both
218
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
219
- }
220
- else {
221
- // Append a new vNode, if it's text, we create a text vNode
222
- vNodeChildren.push(simple ? newVNode(null, child) : child);
223
- }
224
- lastSimple = simple;
225
- }
226
- }
227
- };
228
- walk(children);
229
- if (vnodeData) {
230
- // normalize class / classname attributes
231
- if (vnodeData.key) {
232
- key = vnodeData.key;
233
- }
234
- if (vnodeData.name) {
235
- slotName = vnodeData.name;
236
- }
237
- {
238
- const classData = vnodeData.className || vnodeData.class;
239
- if (classData) {
240
- vnodeData.class =
241
- typeof classData !== 'object'
242
- ? classData
243
- : Object.keys(classData)
244
- .filter((k) => classData[k])
245
- .join(' ');
246
- }
247
- }
248
- }
249
- if (typeof nodeName === 'function') {
250
- // nodeName is a functional component
251
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
252
- }
253
- const vnode = newVNode(nodeName, null);
254
- vnode.$attrs$ = vnodeData;
255
- if (vNodeChildren.length > 0) {
256
- vnode.$children$ = vNodeChildren;
257
- }
258
- {
259
- vnode.$key$ = key;
260
- }
261
- {
262
- vnode.$name$ = slotName;
263
- }
264
- return vnode;
265
- };
266
- const newVNode = (tag, text) => {
267
- const vnode = {
268
- $flags$: 0,
269
- $tag$: tag,
270
- $text$: text,
271
- $elm$: null,
272
- $children$: null,
273
- };
274
- {
275
- vnode.$attrs$ = null;
276
- }
277
- {
278
- vnode.$key$ = null;
279
- }
280
- {
281
- vnode.$name$ = null;
282
- }
283
- return vnode;
284
- };
285
- const Host = {};
286
- const isHost = (node) => node && node.$tag$ === Host;
287
- const vdomFnUtils = {
288
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
289
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
290
- };
291
- const convertToPublic = (node) => ({
292
- vattrs: node.$attrs$,
293
- vchildren: node.$children$,
294
- vkey: node.$key$,
295
- vname: node.$name$,
296
- vtag: node.$tag$,
297
- vtext: node.$text$,
298
- });
299
- const convertToPrivate = (node) => {
300
- if (typeof node.vtag === 'function') {
301
- const vnodeData = Object.assign({}, node.vattrs);
302
- if (node.vkey) {
303
- vnodeData.key = node.vkey;
304
- }
305
- if (node.vname) {
306
- vnodeData.name = node.vname;
307
- }
308
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
309
- }
310
- const vnode = newVNode(node.vtag, node.vtext);
311
- vnode.$attrs$ = node.vattrs;
312
- vnode.$children$ = node.vchildren;
313
- vnode.$key$ = node.vkey;
314
- vnode.$name$ = node.vname;
315
- return vnode;
316
- };
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 === 'key')
362
- ;
363
- else if (memberName === 'ref') {
364
- // minifier will clean this up
365
- if (newValue) {
366
- newValue(elm);
367
- }
368
- }
369
- else if ((!isProp ) &&
370
- memberName[0] === 'o' &&
371
- memberName[1] === 'n') {
372
- // Event Handlers
373
- // so if the member name starts with "on" and the 3rd characters is
374
- // a capital letter, and it's not already a member on the element,
375
- // then we're assuming it's an event listener
376
- if (memberName[2] === '-') {
377
- // on- prefixed events
378
- // allows to be explicit about the dom event to listen without any magic
379
- // under the hood:
380
- // <my-cmp on-click> // listens for "click"
381
- // <my-cmp on-Click> // listens for "Click"
382
- // <my-cmp on-ionChange> // listens for "ionChange"
383
- // <my-cmp on-EVENTS> // listens for "EVENTS"
384
- memberName = memberName.slice(3);
385
- }
386
- else if (isMemberInElement(win, ln)) {
387
- // standard event
388
- // the JSX attribute could have been "onMouseOver" and the
389
- // member name "onmouseover" is on the window's prototype
390
- // so let's add the listener "mouseover", which is all lowercased
391
- memberName = ln.slice(2);
392
- }
393
- else {
394
- // custom event
395
- // the JSX attribute could have been "onMyCustomEvent"
396
- // so let's trim off the "on" prefix and lowercase the first character
397
- // and add the listener "myCustomEvent"
398
- // except for the first character, we keep the event name case
399
- memberName = ln[2] + memberName.slice(3);
400
- }
401
- if (oldValue) {
402
- plt.rel(elm, memberName, oldValue, false);
403
- }
404
- if (newValue) {
405
- plt.ael(elm, memberName, newValue, false);
406
- }
407
- }
408
- else {
409
- // Set property if it exists and it's not a SVG
410
- const isComplex = isComplexType(newValue);
411
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
412
- try {
413
- if (!elm.tagName.includes('-')) {
414
- let n = newValue == null ? '' : newValue;
415
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
416
- if (memberName === 'list') {
417
- isProp = false;
418
- }
419
- else if (oldValue == null || elm[memberName] != n) {
420
- elm[memberName] = n;
421
- }
422
- }
423
- else {
424
- elm[memberName] = newValue;
425
- }
426
- }
427
- catch (e) { }
428
- }
429
- /**
430
- * Need to manually update attribute if:
431
- * - memberName is not an attribute
432
- * - if we are rendering the host element in order to reflect attribute
433
- * - if it's a SVG, since properties might not work in <svg>
434
- * - if the newValue is null/undefined or 'false'.
435
- */
436
- let xlink = false;
437
- {
438
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
439
- memberName = ln;
440
- xlink = true;
441
- }
442
- }
443
- if (newValue == null || newValue === false) {
444
- if (newValue !== false || elm.getAttribute(memberName) === '') {
445
- if (xlink) {
446
- elm.removeAttributeNS(XLINK_NS, memberName);
447
- }
448
- else {
449
- elm.removeAttribute(memberName);
450
- }
451
- }
452
- }
453
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
454
- newValue = newValue === true ? '' : newValue;
455
- if (xlink) {
456
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
457
- }
458
- else {
459
- elm.setAttribute(memberName, newValue);
460
- }
461
- }
462
- }
463
- }
464
- };
465
- const parseClassListRegex = /\s/;
466
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
467
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
468
- // if the element passed in is a shadow root, which is a document fragment
469
- // then we want to be adding attrs/props to the shadow root's "host" element
470
- // if it's not a shadow root, then we add attrs/props to the same element
471
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
472
- ? newVnode.$elm$.host
473
- : newVnode.$elm$;
474
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
475
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
476
- {
477
- // remove attributes no longer present on the vnode by setting them to undefined
478
- for (memberName in oldVnodeAttrs) {
479
- if (!(memberName in newVnodeAttrs)) {
480
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
481
- }
482
- }
483
- }
484
- // add new & update changed attributes
485
- for (memberName in newVnodeAttrs) {
486
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
487
- }
488
- };
489
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
490
- // tslint:disable-next-line: prefer-const
491
- let newVNode = newParentVNode.$children$[childIndex];
492
- let i = 0;
493
- let elm;
494
- let childNode;
495
- let oldVNode;
496
- if (!useNativeShadowDom) {
497
- // remember for later we need to check to relocate nodes
498
- checkSlotRelocate = true;
499
- if (newVNode.$tag$ === 'slot') {
500
- if (scopeId) {
501
- // scoped css needs to add its scoped id to the parent element
502
- parentElm.classList.add(scopeId + '-s');
503
- }
504
- newVNode.$flags$ |= newVNode.$children$
505
- ? // slot element has fallback content
506
- 2 /* isSlotFallback */
507
- : // slot element does not have fallback content
508
- 1 /* isSlotReference */;
509
- }
510
- }
511
- if (newVNode.$text$ !== null) {
512
- // create text node
513
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
514
- }
515
- else if (newVNode.$flags$ & 1 /* isSlotReference */) {
516
- // create a slot reference node
517
- elm = newVNode.$elm$ =
518
- doc.createTextNode('');
519
- }
520
- else {
521
- if (!isSvgMode) {
522
- isSvgMode = newVNode.$tag$ === 'svg';
523
- }
524
- // create element
525
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
526
- ? 'slot-fb'
527
- : newVNode.$tag$)
528
- );
529
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
530
- isSvgMode = false;
531
- }
532
- // add css classes, attrs, props, listeners, etc.
533
- {
534
- updateElement(null, newVNode, isSvgMode);
535
- }
536
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
537
- // if there is a scopeId and this is the initial render
538
- // then let's add the scopeId as a css class
539
- elm.classList.add((elm['s-si'] = scopeId));
540
- }
541
- if (newVNode.$children$) {
542
- for (i = 0; i < newVNode.$children$.length; ++i) {
543
- // create the node
544
- childNode = createElm(oldParentVNode, newVNode, i, elm);
545
- // return node could have been null
546
- if (childNode) {
547
- // append our new node
548
- elm.appendChild(childNode);
549
- }
550
- }
551
- }
552
- {
553
- if (newVNode.$tag$ === 'svg') {
554
- // Only reset the SVG context when we're exiting <svg> element
555
- isSvgMode = false;
556
- }
557
- else if (elm.tagName === 'foreignObject') {
558
- // Reenter SVG context when we're exiting <foreignObject> element
559
- isSvgMode = true;
560
- }
561
- }
562
- }
563
- {
564
- elm['s-hn'] = hostTagName;
565
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
566
- // remember the content reference comment
567
- elm['s-sr'] = true;
568
- // remember the content reference comment
569
- elm['s-cr'] = contentRef;
570
- // remember the slot name, or empty string for default slot
571
- elm['s-sn'] = newVNode.$name$ || '';
572
- // check if we've got an old vnode for this slot
573
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
574
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
575
- // we've got an old slot vnode and the wrapper is being replaced
576
- // so let's move the old slot content back to it's original location
577
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
578
- }
579
- }
580
- }
581
- return elm;
582
- };
583
- const putBackInOriginalLocation = (parentElm, recursive) => {
584
- plt.$flags$ |= 1 /* isTmpDisconnected */;
585
- const oldSlotChildNodes = parentElm.childNodes;
586
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
587
- const childNode = oldSlotChildNodes[i];
588
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
589
- // // this child node in the old element is from another component
590
- // // remove this node from the old slot's parent
591
- // childNode.remove();
592
- // and relocate it back to it's original location
593
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
594
- // remove the old original location comment entirely
595
- // later on the patch function will know what to do
596
- // and move this to the correct spot in need be
597
- childNode['s-ol'].remove();
598
- childNode['s-ol'] = undefined;
599
- checkSlotRelocate = true;
600
- }
601
- if (recursive) {
602
- putBackInOriginalLocation(childNode, recursive);
603
- }
604
- }
605
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
606
- };
607
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
608
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
609
- let childNode;
610
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
611
- containerElm = containerElm.shadowRoot;
612
- }
613
- for (; startIdx <= endIdx; ++startIdx) {
614
- if (vnodes[startIdx]) {
615
- childNode = createElm(null, parentVNode, startIdx, parentElm);
616
- if (childNode) {
617
- vnodes[startIdx].$elm$ = childNode;
618
- containerElm.insertBefore(childNode, referenceNode(before) );
619
- }
620
- }
621
- }
622
- };
623
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
624
- for (; startIdx <= endIdx; ++startIdx) {
625
- if ((vnode = vnodes[startIdx])) {
626
- elm = vnode.$elm$;
627
- callNodeRefs(vnode);
628
- {
629
- // we're removing this element
630
- // so it's possible we need to show slot fallback content now
631
- checkSlotFallbackVisibility = true;
632
- if (elm['s-ol']) {
633
- // remove the original location comment
634
- elm['s-ol'].remove();
635
- }
636
- else {
637
- // it's possible that child nodes of the node
638
- // that's being removed are slot nodes
639
- putBackInOriginalLocation(elm, true);
640
- }
641
- }
642
- // remove the vnode's element from the dom
643
- elm.remove();
644
- }
645
- }
646
- };
647
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
648
- let oldStartIdx = 0;
649
- let newStartIdx = 0;
650
- let idxInOld = 0;
651
- let i = 0;
652
- let oldEndIdx = oldCh.length - 1;
653
- let oldStartVnode = oldCh[0];
654
- let oldEndVnode = oldCh[oldEndIdx];
655
- let newEndIdx = newCh.length - 1;
656
- let newStartVnode = newCh[0];
657
- let newEndVnode = newCh[newEndIdx];
658
- let node;
659
- let elmToMove;
660
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
661
- if (oldStartVnode == null) {
662
- // Vnode might have been moved left
663
- oldStartVnode = oldCh[++oldStartIdx];
664
- }
665
- else if (oldEndVnode == null) {
666
- oldEndVnode = oldCh[--oldEndIdx];
667
- }
668
- else if (newStartVnode == null) {
669
- newStartVnode = newCh[++newStartIdx];
670
- }
671
- else if (newEndVnode == null) {
672
- newEndVnode = newCh[--newEndIdx];
673
- }
674
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
675
- patch(oldStartVnode, newStartVnode);
676
- oldStartVnode = oldCh[++oldStartIdx];
677
- newStartVnode = newCh[++newStartIdx];
678
- }
679
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
680
- patch(oldEndVnode, newEndVnode);
681
- oldEndVnode = oldCh[--oldEndIdx];
682
- newEndVnode = newCh[--newEndIdx];
683
- }
684
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
685
- // Vnode moved right
686
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
687
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
688
- }
689
- patch(oldStartVnode, newEndVnode);
690
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
691
- oldStartVnode = oldCh[++oldStartIdx];
692
- newEndVnode = newCh[--newEndIdx];
693
- }
694
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
695
- // Vnode moved left
696
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
697
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
698
- }
699
- patch(oldEndVnode, newStartVnode);
700
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
701
- oldEndVnode = oldCh[--oldEndIdx];
702
- newStartVnode = newCh[++newStartIdx];
703
- }
704
- else {
705
- // createKeyToOldIdx
706
- idxInOld = -1;
707
- {
708
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
709
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
710
- idxInOld = i;
711
- break;
712
- }
713
- }
714
- }
715
- if (idxInOld >= 0) {
716
- elmToMove = oldCh[idxInOld];
717
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
718
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
719
- }
720
- else {
721
- patch(elmToMove, newStartVnode);
722
- oldCh[idxInOld] = undefined;
723
- node = elmToMove.$elm$;
724
- }
725
- newStartVnode = newCh[++newStartIdx];
726
- }
727
- else {
728
- // new element
729
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
730
- newStartVnode = newCh[++newStartIdx];
731
- }
732
- if (node) {
733
- {
734
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
735
- }
736
- }
737
- }
738
- }
739
- if (oldStartIdx > oldEndIdx) {
740
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
741
- }
742
- else if (newStartIdx > newEndIdx) {
743
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
744
- }
745
- };
746
- const isSameVnode = (vnode1, vnode2) => {
747
- // compare if two vnode to see if they're "technically" the same
748
- // need to have the same element tag, and same key to be the same
749
- if (vnode1.$tag$ === vnode2.$tag$) {
750
- if (vnode1.$tag$ === 'slot') {
751
- return vnode1.$name$ === vnode2.$name$;
752
- }
753
- {
754
- return vnode1.$key$ === vnode2.$key$;
755
- }
756
- }
757
- return false;
758
- };
759
- const referenceNode = (node) => {
760
- // this node was relocated to a new location in the dom
761
- // because of some other component's slot
762
- // but we still have an html comment in place of where
763
- // it's original location was according to it's original vdom
764
- return (node && node['s-ol']) || node;
765
- };
766
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
767
- const patch = (oldVNode, newVNode) => {
768
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
769
- const oldChildren = oldVNode.$children$;
770
- const newChildren = newVNode.$children$;
771
- const tag = newVNode.$tag$;
772
- const text = newVNode.$text$;
773
- let defaultHolder;
774
- if (text === null) {
775
- {
776
- // test if we're rendering an svg element, or still rendering nodes inside of one
777
- // only add this to the when the compiler sees we're using an svg somewhere
778
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
779
- }
780
- // element node
781
- {
782
- if (tag === 'slot')
783
- ;
784
- else {
785
- // either this is the first render of an element OR it's an update
786
- // AND we already know it's possible it could have changed
787
- // this updates the element's css classes, attrs, props, listeners, etc.
788
- updateElement(oldVNode, newVNode, isSvgMode);
789
- }
790
- }
791
- if (oldChildren !== null && newChildren !== null) {
792
- // looks like there's child vnodes for both the old and new vnodes
793
- updateChildren(elm, oldChildren, newVNode, newChildren);
794
- }
795
- else if (newChildren !== null) {
796
- // no old child vnodes, but there are new child vnodes to add
797
- if (oldVNode.$text$ !== null) {
798
- // the old vnode was text, so be sure to clear it out
799
- elm.textContent = '';
800
- }
801
- // add the new vnode children
802
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
803
- }
804
- else if (oldChildren !== null) {
805
- // no new child vnodes, but there are old child vnodes to remove
806
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
807
- }
808
- if (isSvgMode && tag === 'svg') {
809
- isSvgMode = false;
810
- }
811
- }
812
- else if ((defaultHolder = elm['s-cr'])) {
813
- // this element has slotted content
814
- defaultHolder.parentNode.textContent = text;
815
- }
816
- else if (oldVNode.$text$ !== text) {
817
- // update the text content for the text only vnode
818
- // and also only if the text is different than before
819
- elm.data = text;
820
- }
821
- };
822
- const updateFallbackSlotVisibility = (elm) => {
823
- // tslint:disable-next-line: prefer-const
824
- let childNodes = elm.childNodes;
825
- let childNode;
826
- let i;
827
- let ilen;
828
- let j;
829
- let slotNameAttr;
830
- let nodeType;
831
- for (i = 0, ilen = childNodes.length; i < ilen; i++) {
832
- childNode = childNodes[i];
833
- if (childNode.nodeType === 1 /* ElementNode */) {
834
- if (childNode['s-sr']) {
835
- // this is a slot fallback node
836
- // get the slot name for this slot reference node
837
- slotNameAttr = childNode['s-sn'];
838
- // by default always show a fallback slot node
839
- // then hide it if there are other slots in the light dom
840
- childNode.hidden = false;
841
- for (j = 0; j < ilen; j++) {
842
- nodeType = childNodes[j].nodeType;
843
- if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
844
- // this sibling node is from a different component OR is a named fallback slot node
845
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
846
- childNode.hidden = true;
847
- break;
848
- }
849
- }
850
- else {
851
- // this is a default fallback slot node
852
- // any element or text node (with content)
853
- // should hide the default fallback slot node
854
- if (nodeType === 1 /* ElementNode */ ||
855
- (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
856
- childNode.hidden = true;
857
- break;
858
- }
859
- }
860
- }
861
- }
862
- // keep drilling down
863
- updateFallbackSlotVisibility(childNode);
864
- }
865
- }
866
- };
867
- const relocateNodes = [];
868
- const relocateSlotContent = (elm) => {
869
- // tslint:disable-next-line: prefer-const
870
- let childNode;
871
- let node;
872
- let hostContentNodes;
873
- let slotNameAttr;
874
- let relocateNodeData;
875
- let j;
876
- let i = 0;
877
- let childNodes = elm.childNodes;
878
- let ilen = childNodes.length;
879
- for (; i < ilen; i++) {
880
- childNode = childNodes[i];
881
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
882
- // first got the content reference comment node
883
- // then we got it's parent, which is where all the host content is in now
884
- hostContentNodes = node.parentNode.childNodes;
885
- slotNameAttr = childNode['s-sn'];
886
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
887
- node = hostContentNodes[j];
888
- if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
889
- // let's do some relocating to its new home
890
- // but never relocate a content reference node
891
- // that is suppose to always represent the original content location
892
- if (isNodeLocatedInSlot(node, slotNameAttr)) {
893
- // it's possible we've already decided to relocate this node
894
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
895
- // made some changes to slots
896
- // let's make sure we also double check
897
- // fallbacks are correctly hidden or shown
898
- checkSlotFallbackVisibility = true;
899
- node['s-sn'] = node['s-sn'] || slotNameAttr;
900
- if (relocateNodeData) {
901
- // previously we never found a slot home for this node
902
- // but turns out we did, so let's remember it now
903
- relocateNodeData.$slotRefNode$ = childNode;
904
- }
905
- else {
906
- // add to our list of nodes to relocate
907
- relocateNodes.push({
908
- $slotRefNode$: childNode,
909
- $nodeToRelocate$: node,
910
- });
911
- }
912
- if (node['s-sr']) {
913
- relocateNodes.map((relocateNode) => {
914
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
915
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
916
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
917
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
918
- }
919
- }
920
- });
921
- }
922
- }
923
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
924
- // so far this element does not have a slot home, not setting slotRefNode on purpose
925
- // if we never find a home for this element then we'll need to hide it
926
- relocateNodes.push({
927
- $nodeToRelocate$: node,
928
- });
929
- }
930
- }
931
- }
932
- }
933
- if (childNode.nodeType === 1 /* ElementNode */) {
934
- relocateSlotContent(childNode);
935
- }
936
- }
937
- };
938
- const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
939
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
940
- if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
941
- return true;
942
- }
943
- if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
944
- return true;
945
- }
946
- return false;
947
- }
948
- if (nodeToRelocate['s-sn'] === slotNameAttr) {
949
- return true;
950
- }
951
- return slotNameAttr === '';
952
- };
953
- const callNodeRefs = (vNode) => {
954
- {
955
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
956
- vNode.$children$ && vNode.$children$.map(callNodeRefs);
957
- }
958
- };
959
- const renderVdom = (hostRef, renderFnResults) => {
960
- const hostElm = hostRef.$hostElement$;
961
- const cmpMeta = hostRef.$cmpMeta$;
962
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
963
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
964
- hostTagName = hostElm.tagName;
965
- rootVnode.$tag$ = null;
966
- rootVnode.$flags$ |= 4 /* isHost */;
967
- hostRef.$vnode$ = rootVnode;
968
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
969
- {
970
- scopeId = hostElm['s-sc'];
971
- }
972
- {
973
- contentRef = hostElm['s-cr'];
974
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
975
- // always reset
976
- checkSlotFallbackVisibility = false;
977
- }
978
- // synchronous patch
979
- patch(oldVNode, rootVnode);
980
- {
981
- // while we're moving nodes around existing nodes, temporarily disable
982
- // the disconnectCallback from working
983
- plt.$flags$ |= 1 /* isTmpDisconnected */;
984
- if (checkSlotRelocate) {
985
- relocateSlotContent(rootVnode.$elm$);
986
- let relocateData;
987
- let nodeToRelocate;
988
- let orgLocationNode;
989
- let parentNodeRef;
990
- let insertBeforeNode;
991
- let refNode;
992
- let i = 0;
993
- for (; i < relocateNodes.length; i++) {
994
- relocateData = relocateNodes[i];
995
- nodeToRelocate = relocateData.$nodeToRelocate$;
996
- if (!nodeToRelocate['s-ol']) {
997
- // add a reference node marking this node's original location
998
- // keep a reference to this node for later lookups
999
- orgLocationNode =
1000
- doc.createTextNode('');
1001
- orgLocationNode['s-nr'] = nodeToRelocate;
1002
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1003
- }
1004
- }
1005
- for (i = 0; i < relocateNodes.length; i++) {
1006
- relocateData = relocateNodes[i];
1007
- nodeToRelocate = relocateData.$nodeToRelocate$;
1008
- if (relocateData.$slotRefNode$) {
1009
- // by default we're just going to insert it directly
1010
- // after the slot reference node
1011
- parentNodeRef = relocateData.$slotRefNode$.parentNode;
1012
- insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1013
- orgLocationNode = nodeToRelocate['s-ol'];
1014
- while ((orgLocationNode = orgLocationNode.previousSibling)) {
1015
- refNode = orgLocationNode['s-nr'];
1016
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1017
- refNode = refNode.nextSibling;
1018
- if (!refNode || !refNode['s-nr']) {
1019
- insertBeforeNode = refNode;
1020
- break;
1021
- }
1022
- }
1023
- }
1024
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1025
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1026
- // we've checked that it's worth while to relocate
1027
- // since that the node to relocate
1028
- // has a different next sibling or parent relocated
1029
- if (nodeToRelocate !== insertBeforeNode) {
1030
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1031
- // probably a component in the index.html that doesn't have it's hostname set
1032
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1033
- }
1034
- // add it back to the dom but in its new home
1035
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1036
- }
1037
- }
1038
- }
1039
- else {
1040
- // this node doesn't have a slot home to go to, so let's hide it
1041
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1042
- nodeToRelocate.hidden = true;
1043
- }
1044
- }
1045
- }
1046
- }
1047
- if (checkSlotFallbackVisibility) {
1048
- updateFallbackSlotVisibility(rootVnode.$elm$);
1049
- }
1050
- // done moving nodes around
1051
- // allow the disconnect callback to work again
1052
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
1053
- // always reset
1054
- relocateNodes.length = 0;
1055
- }
1056
- };
1057
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1058
- const createEvent = (ref, name, flags) => {
1059
- const elm = getElement(ref);
1060
- return {
1061
- emit: (detail) => {
1062
- return emitEvent(elm, name, {
1063
- bubbles: !!(flags & 4 /* Bubbles */),
1064
- composed: !!(flags & 2 /* Composed */),
1065
- cancelable: !!(flags & 1 /* Cancellable */),
1066
- detail,
1067
- });
1068
- },
1069
- };
1070
- };
1071
- /**
1072
- * Helper function to create & dispatch a custom Event on a provided target
1073
- * @param elm the target of the Event
1074
- * @param name the name to give the custom Event
1075
- * @param opts options for configuring a custom Event
1076
- * @returns the custom Event
1077
- */
1078
- const emitEvent = (elm, name, opts) => {
1079
- const ev = plt.ce(name, opts);
1080
- elm.dispatchEvent(ev);
1081
- return ev;
1082
- };
1083
- const attachToAncestor = (hostRef, ancestorComponent) => {
1084
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1085
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1086
- }
1087
- };
1088
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1089
- {
1090
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1091
- }
1092
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1093
- hostRef.$flags$ |= 512 /* needsRerender */;
1094
- return;
1095
- }
1096
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1097
- // there is no ancestor component or the ancestor component
1098
- // has already fired off its lifecycle update then
1099
- // fire off the initial update
1100
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1101
- return writeTask(dispatch) ;
1102
- };
1103
- const dispatchHooks = (hostRef, isInitialLoad) => {
1104
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1105
- const instance = hostRef.$lazyInstance$ ;
1106
- let promise;
1107
- if (isInitialLoad) {
1108
- {
1109
- hostRef.$flags$ |= 256 /* isListenReady */;
1110
- if (hostRef.$queuedListeners$) {
1111
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1112
- hostRef.$queuedListeners$ = null;
1113
- }
1114
- }
1115
- {
1116
- promise = safeCall(instance, 'componentWillLoad');
1117
- }
1118
- }
1119
- {
1120
- promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1121
- }
1122
- endSchedule();
1123
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1124
- };
1125
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1126
- // updateComponent
1127
- const elm = hostRef.$hostElement$;
1128
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1129
- const rc = elm['s-rc'];
1130
- if (isInitialLoad) {
1131
- // DOM WRITE!
1132
- attachStyles(hostRef);
1133
- }
1134
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1135
- {
1136
- callRender(hostRef, instance);
1137
- }
1138
- if (rc) {
1139
- // ok, so turns out there are some child host elements
1140
- // waiting on this parent element to load
1141
- // let's fire off all update callbacks waiting
1142
- rc.map((cb) => cb());
1143
- elm['s-rc'] = undefined;
1144
- }
1145
- endRender();
1146
- endUpdate();
1147
- {
1148
- const childrenPromises = elm['s-p'];
1149
- const postUpdate = () => postUpdateComponent(hostRef);
1150
- if (childrenPromises.length === 0) {
1151
- postUpdate();
1152
- }
1153
- else {
1154
- Promise.all(childrenPromises).then(postUpdate);
1155
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1156
- childrenPromises.length = 0;
1157
- }
1158
- }
1159
- };
1160
- const callRender = (hostRef, instance, elm) => {
1161
- try {
1162
- instance = instance.render() ;
1163
- {
1164
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1165
- }
1166
- {
1167
- hostRef.$flags$ |= 2 /* hasRendered */;
1168
- }
1169
- {
1170
- {
1171
- // looks like we've got child nodes to render into this host element
1172
- // or we need to update the css class/attrs on the host element
1173
- // DOM WRITE!
1174
- {
1175
- renderVdom(hostRef, instance);
1176
- }
1177
- }
1178
- }
1179
- }
1180
- catch (e) {
1181
- consoleError(e, hostRef.$hostElement$);
1182
- }
1183
- return null;
1184
- };
1185
- const postUpdateComponent = (hostRef) => {
1186
- const tagName = hostRef.$cmpMeta$.$tagName$;
1187
- const elm = hostRef.$hostElement$;
1188
- const endPostUpdate = createTime('postUpdate', tagName);
1189
- const instance = hostRef.$lazyInstance$ ;
1190
- const ancestorComponent = hostRef.$ancestorComponent$;
1191
- {
1192
- safeCall(instance, 'componentDidRender');
1193
- }
1194
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1195
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1196
- {
1197
- // DOM WRITE!
1198
- addHydratedFlag(elm);
1199
- }
1200
- {
1201
- safeCall(instance, 'componentDidLoad');
1202
- }
1203
- endPostUpdate();
1204
- {
1205
- hostRef.$onReadyResolve$(elm);
1206
- if (!ancestorComponent) {
1207
- appDidLoad();
1208
- }
1209
- }
1210
- }
1211
- else {
1212
- endPostUpdate();
1213
- }
1214
- {
1215
- hostRef.$onInstanceResolve$(elm);
1216
- }
1217
- // load events fire from bottom to top
1218
- // the deepest elements load first then bubbles up
1219
- {
1220
- if (hostRef.$onRenderResolve$) {
1221
- hostRef.$onRenderResolve$();
1222
- hostRef.$onRenderResolve$ = undefined;
1223
- }
1224
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1225
- nextTick(() => scheduleUpdate(hostRef, false));
1226
- }
1227
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1228
- }
1229
- // ( •_•)
1230
- // ( •_•)>⌐■-■
1231
- // (⌐■_■)
1232
- };
1233
- const appDidLoad = (who) => {
1234
- // on appload
1235
- // we have finish the first big initial render
1236
- {
1237
- addHydratedFlag(doc.documentElement);
1238
- }
1239
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1240
- };
1241
- const safeCall = (instance, method, arg) => {
1242
- if (instance && instance[method]) {
1243
- try {
1244
- return instance[method](arg);
1245
- }
1246
- catch (e) {
1247
- consoleError(e);
1248
- }
1249
- }
1250
- return undefined;
1251
- };
1252
- const then = (promise, thenFn) => {
1253
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1254
- };
1255
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1256
- ;
1257
- /**
1258
- * Parse a new property value for a given property type.
1259
- *
1260
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1261
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1262
- * 1. `any`, the type given to `propValue` in the function signature
1263
- * 2. the type stored from `propType`.
1264
- *
1265
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1266
- *
1267
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1268
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1269
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1270
- * ```tsx
1271
- * <my-cmp prop-val={0}></my-cmp>
1272
- * ```
1273
- *
1274
- * HTML prop values on the other hand, will always a string
1275
- *
1276
- * @param propValue the new value to coerce to some type
1277
- * @param propType the type of the prop, expressed as a binary number
1278
- * @returns the parsed/coerced value
1279
- */
1280
- const parsePropertyValue = (propValue, propType) => {
1281
- // ensure this value is of the correct prop type
1282
- if (propValue != null && !isComplexType(propValue)) {
1283
- if (propType & 4 /* Boolean */) {
1284
- // per the HTML spec, any string value means it is a boolean true value
1285
- // but we'll cheat here and say that the string "false" is the boolean false
1286
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1287
- }
1288
- if (propType & 2 /* Number */) {
1289
- // force it to be a number
1290
- return parseFloat(propValue);
1291
- }
1292
- if (propType & 1 /* String */) {
1293
- // could have been passed as a number or boolean
1294
- // but we still want it as a string
1295
- return String(propValue);
1296
- }
1297
- // redundant return here for better minification
1298
- return propValue;
1299
- }
1300
- // not sure exactly what type we want
1301
- // so no need to change to a different type
1302
- return propValue;
1303
- };
1304
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1305
- const setValue = (ref, propName, newVal, cmpMeta) => {
1306
- // check our new property value against our internal value
1307
- const hostRef = getHostRef(ref);
1308
- const elm = hostRef.$hostElement$ ;
1309
- const oldVal = hostRef.$instanceValues$.get(propName);
1310
- const flags = hostRef.$flags$;
1311
- const instance = hostRef.$lazyInstance$ ;
1312
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1313
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1314
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1315
- const didValueChange = newVal !== oldVal && !areBothNaN;
1316
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1317
- // gadzooks! the property's value has changed!!
1318
- // set our new value!
1319
- hostRef.$instanceValues$.set(propName, newVal);
1320
- if (instance) {
1321
- // get an array of method names of watch functions to call
1322
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1323
- const watchMethods = cmpMeta.$watchers$[propName];
1324
- if (watchMethods) {
1325
- // this instance is watching for when this property changed
1326
- watchMethods.map((watchMethodName) => {
1327
- try {
1328
- // fire off each of the watch methods that are watching this property
1329
- instance[watchMethodName](newVal, oldVal, propName);
1330
- }
1331
- catch (e) {
1332
- consoleError(e, elm);
1333
- }
1334
- });
1335
- }
1336
- }
1337
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1338
- // looks like this value actually changed, so we've got work to do!
1339
- // but only if we've already rendered, otherwise just chill out
1340
- // queue that we need to do an update, but don't worry about queuing
1341
- // up millions cuz this function ensures it only runs once
1342
- scheduleUpdate(hostRef, false);
1343
- }
1344
- }
1345
- }
1346
- };
1347
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1348
- if (cmpMeta.$members$) {
1349
- if (Cstr.watchers) {
1350
- cmpMeta.$watchers$ = Cstr.watchers;
1351
- }
1352
- // It's better to have a const than two Object.entries()
1353
- const members = Object.entries(cmpMeta.$members$);
1354
- const prototype = Cstr.prototype;
1355
- members.map(([memberName, [memberFlags]]) => {
1356
- if ((memberFlags & 31 /* Prop */ ||
1357
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1358
- // proxyComponent - prop
1359
- Object.defineProperty(prototype, memberName, {
1360
- get() {
1361
- // proxyComponent, get value
1362
- return getValue(this, memberName);
1363
- },
1364
- set(newValue) {
1365
- // proxyComponent, set value
1366
- setValue(this, memberName, newValue, cmpMeta);
1367
- },
1368
- configurable: true,
1369
- enumerable: true,
1370
- });
1371
- }
1372
- else if (flags & 1 /* isElementConstructor */ &&
1373
- memberFlags & 64 /* Method */) {
1374
- // proxyComponent - method
1375
- Object.defineProperty(prototype, memberName, {
1376
- value(...args) {
1377
- const ref = getHostRef(this);
1378
- return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1379
- },
1380
- });
1381
- }
1382
- });
1383
- if ((flags & 1 /* isElementConstructor */)) {
1384
- const attrNameToPropName = new Map();
1385
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1386
- plt.jmp(() => {
1387
- const propName = attrNameToPropName.get(attrName);
1388
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1389
- // in the case where an attribute was set inline.
1390
- // ```html
1391
- // <my-component some-attribute="some-value"></my-component>
1392
- // ```
1393
- //
1394
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1395
- // programmatically changes it before it has been upgraded as shown below:
1396
- //
1397
- // ```html
1398
- // <!-- this component has _not_ been upgraded yet -->
1399
- // <my-component id="test" some-attribute="some-value"></my-component>
1400
- // <script>
1401
- // // grab non-upgraded component
1402
- // el = document.querySelector("#test");
1403
- // el.someAttribute = "another-value";
1404
- // // upgrade component
1405
- // customElements.define('my-component', MyComponent);
1406
- // </script>
1407
- // ```
1408
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1409
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1410
- // to the value that was set inline i.e. "some-value" from above example. When
1411
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1412
- //
1413
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1414
- // by connectedCallback as this attributeChangedCallback will not fire.
1415
- //
1416
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1417
- //
1418
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1419
- // properties here given that this goes against best practices outlined here
1420
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1421
- if (this.hasOwnProperty(propName)) {
1422
- newValue = this[propName];
1423
- delete this[propName];
1424
- }
1425
- else if (prototype.hasOwnProperty(propName) &&
1426
- typeof this[propName] === 'number' &&
1427
- this[propName] == newValue) {
1428
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1429
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1430
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1431
- return;
1432
- }
1433
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1434
- });
1435
- };
1436
- // create an array of attributes to observe
1437
- // and also create a map of html attribute name to js property name
1438
- Cstr.observedAttributes = members
1439
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1440
- .map(([propName, m]) => {
1441
- const attrName = m[1] || propName;
1442
- attrNameToPropName.set(attrName, propName);
1443
- return attrName;
1444
- });
1445
- }
1446
- }
1447
- return Cstr;
1448
- };
1449
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1450
- // initializeComponent
1451
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1452
- {
1453
- // we haven't initialized this element yet
1454
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1455
- // lazy loaded components
1456
- // request the component's implementation to be
1457
- // wired up with the host element
1458
- Cstr = loadModule(cmpMeta);
1459
- if (Cstr.then) {
1460
- // Await creates a micro-task avoid if possible
1461
- const endLoad = uniqueTime();
1462
- Cstr = await Cstr;
1463
- endLoad();
1464
- }
1465
- if (!Cstr.isProxied) {
1466
- // we've never proxied this Constructor before
1467
- // let's add the getters/setters to its prototype before
1468
- // the first time we create an instance of the implementation
1469
- {
1470
- cmpMeta.$watchers$ = Cstr.watchers;
1471
- }
1472
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1473
- Cstr.isProxied = true;
1474
- }
1475
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1476
- // ok, time to construct the instance
1477
- // but let's keep track of when we start and stop
1478
- // so that the getters/setters don't incorrectly step on data
1479
- {
1480
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1481
- }
1482
- // construct the lazy-loaded component implementation
1483
- // passing the hostRef is very important during
1484
- // construction in order to directly wire together the
1485
- // host element and the lazy-loaded instance
1486
- try {
1487
- new Cstr(hostRef);
1488
- }
1489
- catch (e) {
1490
- consoleError(e);
1491
- }
1492
- {
1493
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1494
- }
1495
- {
1496
- hostRef.$flags$ |= 128 /* isWatchReady */;
1497
- }
1498
- endNewInstance();
1499
- }
1500
- if (Cstr.style) {
1501
- // this component has styles but we haven't registered them yet
1502
- let style = Cstr.style;
1503
- const scopeId = getScopeId(cmpMeta);
1504
- if (!styles.has(scopeId)) {
1505
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1506
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1507
- endRegisterStyles();
1508
- }
1509
- }
1510
- }
1511
- // we've successfully created a lazy instance
1512
- const ancestorComponent = hostRef.$ancestorComponent$;
1513
- const schedule = () => scheduleUpdate(hostRef, true);
1514
- if (ancestorComponent && ancestorComponent['s-rc']) {
1515
- // this is the initial load and this component it has an ancestor component
1516
- // but the ancestor component has NOT fired its will update lifecycle yet
1517
- // so let's just cool our jets and wait for the ancestor to continue first
1518
- // this will get fired off when the ancestor component
1519
- // finally gets around to rendering its lazy self
1520
- // fire off the initial update
1521
- ancestorComponent['s-rc'].push(schedule);
1522
- }
1523
- else {
1524
- schedule();
1525
- }
1526
- };
1527
- const connectedCallback = (elm) => {
1528
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1529
- const hostRef = getHostRef(elm);
1530
- const cmpMeta = hostRef.$cmpMeta$;
1531
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1532
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1533
- // first time this component has connected
1534
- hostRef.$flags$ |= 1 /* hasConnected */;
1535
- {
1536
- // initUpdate
1537
- // if the slot polyfill is required we'll need to put some nodes
1538
- // in here to act as original content anchors as we move nodes around
1539
- // host element has been connected to the DOM
1540
- if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1541
- setContentReference(elm);
1542
- }
1543
- }
1544
- {
1545
- // find the first ancestor component (if there is one) and register
1546
- // this component as one of the actively loading child components for its ancestor
1547
- let ancestorComponent = elm;
1548
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1549
- // climb up the ancestors looking for the first
1550
- // component that hasn't finished its lifecycle update yet
1551
- if (ancestorComponent['s-p']) {
1552
- // we found this components first ancestor component
1553
- // keep a reference to this component's ancestor component
1554
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1555
- break;
1556
- }
1557
- }
1558
- }
1559
- // Lazy properties
1560
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1561
- if (cmpMeta.$members$) {
1562
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1563
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1564
- const value = elm[memberName];
1565
- delete elm[memberName];
1566
- elm[memberName] = value;
1567
- }
1568
- });
1569
- }
1570
- {
1571
- initializeComponent(elm, hostRef, cmpMeta);
1572
- }
1573
- }
1574
- else {
1575
- // not the first time this has connected
1576
- // reattach any event listeners to the host
1577
- // since they would have been removed when disconnected
1578
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1579
- }
1580
- endConnected();
1581
- }
1582
- };
1583
- const setContentReference = (elm) => {
1584
- // only required when we're NOT using native shadow dom (slot)
1585
- // or this browser doesn't support native shadow dom
1586
- // and this host element was NOT created with SSR
1587
- // let's pick out the inner content for slot projection
1588
- // create a node to represent where the original
1589
- // content was first placed, which is useful later on
1590
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1591
- contentRefElm['s-cn'] = true;
1592
- elm.insertBefore(contentRefElm, elm.firstChild);
1593
- };
1594
- const disconnectedCallback = (elm) => {
1595
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1596
- const hostRef = getHostRef(elm);
1597
- const instance = hostRef.$lazyInstance$ ;
1598
- {
1599
- if (hostRef.$rmListeners$) {
1600
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1601
- hostRef.$rmListeners$ = undefined;
1602
- }
1603
- }
1604
- {
1605
- safeCall(instance, 'disconnectedCallback');
1606
- }
1607
- }
1608
- };
1609
- const bootstrapLazy = (lazyBundles, options = {}) => {
1610
- const endBootstrap = createTime();
1611
- const cmpTags = [];
1612
- const exclude = options.exclude || [];
1613
- const customElements = win.customElements;
1614
- const head = doc.head;
1615
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1616
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1617
- const deferredConnectedCallbacks = [];
1618
- let appLoadFallback;
1619
- let isBootstrapping = true;
1620
- Object.assign(plt, options);
1621
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1622
- lazyBundles.map((lazyBundle) => {
1623
- lazyBundle[1].map((compactMeta) => {
1624
- const cmpMeta = {
1625
- $flags$: compactMeta[0],
1626
- $tagName$: compactMeta[1],
1627
- $members$: compactMeta[2],
1628
- $listeners$: compactMeta[3],
1629
- };
1630
- {
1631
- cmpMeta.$members$ = compactMeta[2];
1632
- }
1633
- {
1634
- cmpMeta.$listeners$ = compactMeta[3];
1635
- }
1636
- {
1637
- cmpMeta.$watchers$ = {};
1638
- }
1639
- const tagName = cmpMeta.$tagName$;
1640
- const HostElement = class extends HTMLElement {
1641
- // StencilLazyHost
1642
- constructor(self) {
1643
- // @ts-ignore
1644
- super(self);
1645
- self = this;
1646
- registerHost(self, cmpMeta);
1647
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1648
- // this component is using shadow dom
1649
- // and this browser supports shadow dom
1650
- // add the read-only property "shadowRoot" to the host element
1651
- // adding the shadow root build conditionals to minimize runtime
1652
- {
1653
- {
1654
- self.attachShadow({ mode: 'open' });
1655
- }
1656
- }
1657
- }
1658
- }
1659
- connectedCallback() {
1660
- if (appLoadFallback) {
1661
- clearTimeout(appLoadFallback);
1662
- appLoadFallback = null;
1663
- }
1664
- if (isBootstrapping) {
1665
- // connectedCallback will be processed once all components have been registered
1666
- deferredConnectedCallbacks.push(this);
1667
- }
1668
- else {
1669
- plt.jmp(() => connectedCallback(this));
1670
- }
1671
- }
1672
- disconnectedCallback() {
1673
- plt.jmp(() => disconnectedCallback(this));
1674
- }
1675
- componentOnReady() {
1676
- return getHostRef(this).$onReadyPromise$;
1677
- }
1678
- };
1679
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1680
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1681
- cmpTags.push(tagName);
1682
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1683
- }
1684
- });
1685
- });
1686
- {
1687
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1688
- visibilityStyle.setAttribute('data-styles', '');
1689
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1690
- }
1691
- // Process deferred connectedCallbacks now all components have been registered
1692
- isBootstrapping = false;
1693
- if (deferredConnectedCallbacks.length) {
1694
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1695
- }
1696
- else {
1697
- {
1698
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1699
- }
1700
- }
1701
- // Fallback appLoad event
1702
- endBootstrap();
1703
- };
1704
- const hostRefs = new WeakMap();
1705
- const getHostRef = (ref) => hostRefs.get(ref);
1706
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1707
- const registerHost = (elm, cmpMeta) => {
1708
- const hostRef = {
1709
- $flags$: 0,
1710
- $hostElement$: elm,
1711
- $cmpMeta$: cmpMeta,
1712
- $instanceValues$: new Map(),
1713
- };
1714
- {
1715
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1716
- }
1717
- {
1718
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1719
- elm['s-p'] = [];
1720
- elm['s-rc'] = [];
1721
- }
1722
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1723
- return hostRefs.set(elm, hostRef);
1724
- };
1725
- const isMemberInElement = (elm, memberName) => memberName in elm;
1726
- const consoleError = (e, el) => (0, console.error)(e, el);
1727
- const cmpModules = /*@__PURE__*/ new Map();
1728
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1729
- // loadModuleImport
1730
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1731
- const bundleId = cmpMeta.$lazyBundleId$;
1732
- const module = cmpModules.get(bundleId) ;
1733
- if (module) {
1734
- return module[exportName];
1735
- }
1736
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1737
- /* webpackInclude: /\.entry\.js$/ */
1738
- /* webpackExclude: /\.system\.entry\.js$/ */
1739
- /* webpackMode: "lazy" */
1740
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1741
- {
1742
- cmpModules.set(bundleId, importedModule);
1743
- }
1744
- return importedModule[exportName];
1745
- }, consoleError);
1746
- };
1747
- const styles = new Map();
1748
- const queueDomReads = [];
1749
- const queueDomWrites = [];
1750
- const queueTask = (queue, write) => (cb) => {
1751
- queue.push(cb);
1752
- if (!queuePending) {
1753
- queuePending = true;
1754
- if (write && plt.$flags$ & 4 /* queueSync */) {
1755
- nextTick(flush);
1756
- }
1757
- else {
1758
- plt.raf(flush);
1759
- }
1760
- }
1761
- };
1762
- const consume = (queue) => {
1763
- for (let i = 0; i < queue.length; i++) {
1764
- try {
1765
- queue[i](performance.now());
1766
- }
1767
- catch (e) {
1768
- consoleError(e);
1769
- }
1770
- }
1771
- queue.length = 0;
1772
- };
1773
- const flush = () => {
1774
- // always force a bunch of medium callbacks to run, but still have
1775
- // a throttle on how many can run in a certain time
1776
- // DOM READS!!!
1777
- consume(queueDomReads);
1778
- // DOM WRITES!!!
1779
- {
1780
- consume(queueDomWrites);
1781
- if ((queuePending = queueDomReads.length > 0)) {
1782
- // still more to do yet, but we've run out of time
1783
- // let's let this thing cool off and try again in the next tick
1784
- plt.raf(flush);
1785
- }
1786
- }
1787
- };
1788
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1789
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1790
-
1791
- exports.Host = Host;
1792
- exports.bootstrapLazy = bootstrapLazy;
1793
- exports.createEvent = createEvent;
1794
- exports.h = h;
1795
- exports.promiseResolve = promiseResolve;
1796
- exports.registerInstance = registerInstance;