@everymatrix/user-action-controller 1.44.0 → 1.45.2

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