@everymatrix/casino-game-thumb-view 1.43.4 → 1.45.0

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