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