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