@everymatrix/user-action-controller 1.0.0 → 1.0.69

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 (57) 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 +504 -0
  5. package/dist/cjs/user-action-controller.cjs.js +17 -11
  6. package/dist/collection/collection-manifest.json +5 -11
  7. package/dist/collection/components/user-action-controller/index.js +1 -0
  8. package/dist/collection/components/user-action-controller/user-action-controller.css +37 -0
  9. package/dist/collection/components/user-action-controller/user-action-controller.js +418 -328
  10. package/dist/collection/utils/locale.utils.js +66 -0
  11. package/dist/collection/utils/utils.js +1 -1
  12. package/dist/esm/app-globals-0f993ce5.js +3 -0
  13. package/dist/esm/index-02b86e76.js +1288 -0
  14. package/dist/esm/loader.js +7 -13
  15. package/dist/esm/player-user-consents_2.entry.js +499 -0
  16. package/dist/esm/user-action-controller.js +14 -11
  17. package/dist/stencil.config.dev.js +17 -0
  18. package/dist/stencil.config.js +14 -19
  19. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-action-controller/.stencil/packages/stencil/user-action-controller/stencil.config.d.ts +2 -0
  20. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-action-controller/.stencil/packages/stencil/user-action-controller/stencil.config.dev.d.ts +2 -0
  21. package/dist/types/components/user-action-controller/index.d.ts +1 -0
  22. package/dist/types/components/user-action-controller/user-action-controller.d.ts +68 -68
  23. package/dist/types/components.d.ts +28 -40
  24. package/dist/types/stencil-public-runtime.d.ts +142 -33
  25. package/dist/types/utils/locale.utils.d.ts +2 -0
  26. package/dist/user-action-controller/p-4bd71dba.entry.js +1 -0
  27. package/dist/user-action-controller/p-b996e8b8.js +2 -0
  28. package/dist/user-action-controller/p-e1255160.js +1 -0
  29. package/dist/user-action-controller/user-action-controller.esm.js +1 -1
  30. package/loader/cdn.js +1 -3
  31. package/loader/index.cjs.js +1 -3
  32. package/loader/index.d.ts +13 -1
  33. package/loader/index.es2017.js +1 -3
  34. package/loader/index.js +1 -3
  35. package/loader/package.json +1 -0
  36. package/package.json +16 -3
  37. package/dist/cjs/generic-user-consent_3.cjs.entry.js +0 -210
  38. package/dist/cjs/index-5b463836.js +0 -1285
  39. package/dist/components/generic-user-consent.js +0 -6
  40. package/dist/components/generic-user-consent2.js +0 -93
  41. package/dist/components/index.d.ts +0 -26
  42. package/dist/components/index.js +0 -1
  43. package/dist/components/legislation-wrapper.js +0 -6
  44. package/dist/components/legislation-wrapper2.js +0 -33
  45. package/dist/components/user-action-controller.d.ts +0 -11
  46. package/dist/components/user-action-controller.js +0 -168
  47. package/dist/esm/generic-user-consent_3.entry.js +0 -204
  48. package/dist/esm/index-e34db4b0.js +0 -1259
  49. package/dist/esm/polyfills/core-js.js +0 -11
  50. package/dist/esm/polyfills/css-shim.js +0 -1
  51. package/dist/esm/polyfills/dom.js +0 -79
  52. package/dist/esm/polyfills/es5-html-element.js +0 -1
  53. package/dist/esm/polyfills/index.js +0 -34
  54. package/dist/esm/polyfills/system.js +0 -6
  55. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +0 -2
  56. package/dist/user-action-controller/p-20213f37.js +0 -1
  57. package/dist/user-action-controller/p-2a14a5fe.entry.js +0 -1
@@ -1,1285 +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 oldVNode = hostRef.$vnode$ || newVNode(null, null);
589
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
590
- hostTagName = hostElm.tagName;
591
- rootVnode.$tag$ = null;
592
- rootVnode.$flags$ |= 4 /* isHost */;
593
- hostRef.$vnode$ = rootVnode;
594
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
595
- {
596
- scopeId = hostElm['s-sc'];
597
- }
598
- // synchronous patch
599
- patch(oldVNode, rootVnode);
600
- };
601
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
602
- const createEvent = (ref, name, flags) => {
603
- const elm = getElement(ref);
604
- return {
605
- emit: (detail) => {
606
- return emitEvent(elm, name, {
607
- bubbles: !!(flags & 4 /* Bubbles */),
608
- composed: !!(flags & 2 /* Composed */),
609
- cancelable: !!(flags & 1 /* Cancellable */),
610
- detail,
611
- });
612
- },
613
- };
614
- };
615
- /**
616
- * Helper function to create & dispatch a custom Event on a provided target
617
- * @param elm the target of the Event
618
- * @param name the name to give the custom Event
619
- * @param opts options for configuring a custom Event
620
- * @returns the custom Event
621
- */
622
- const emitEvent = (elm, name, opts) => {
623
- const ev = plt.ce(name, opts);
624
- elm.dispatchEvent(ev);
625
- return ev;
626
- };
627
- const attachToAncestor = (hostRef, ancestorComponent) => {
628
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
629
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
630
- }
631
- };
632
- const scheduleUpdate = (hostRef, isInitialLoad) => {
633
- {
634
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
635
- }
636
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
637
- hostRef.$flags$ |= 512 /* needsRerender */;
638
- return;
639
- }
640
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
641
- // there is no ancestor component or the ancestor component
642
- // has already fired off its lifecycle update then
643
- // fire off the initial update
644
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
645
- return writeTask(dispatch) ;
646
- };
647
- const dispatchHooks = (hostRef, isInitialLoad) => {
648
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
649
- const instance = hostRef.$lazyInstance$ ;
650
- let promise;
651
- if (isInitialLoad) {
652
- {
653
- hostRef.$flags$ |= 256 /* isListenReady */;
654
- if (hostRef.$queuedListeners$) {
655
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
656
- hostRef.$queuedListeners$ = null;
657
- }
658
- }
659
- {
660
- promise = safeCall(instance, 'componentWillLoad');
661
- }
662
- }
663
- endSchedule();
664
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
665
- };
666
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
667
- // updateComponent
668
- const elm = hostRef.$hostElement$;
669
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
670
- const rc = elm['s-rc'];
671
- if (isInitialLoad) {
672
- // DOM WRITE!
673
- attachStyles(hostRef);
674
- }
675
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
676
- {
677
- callRender(hostRef, instance);
678
- }
679
- if (rc) {
680
- // ok, so turns out there are some child host elements
681
- // waiting on this parent element to load
682
- // let's fire off all update callbacks waiting
683
- rc.map((cb) => cb());
684
- elm['s-rc'] = undefined;
685
- }
686
- endRender();
687
- endUpdate();
688
- {
689
- const childrenPromises = elm['s-p'];
690
- const postUpdate = () => postUpdateComponent(hostRef);
691
- if (childrenPromises.length === 0) {
692
- postUpdate();
693
- }
694
- else {
695
- Promise.all(childrenPromises).then(postUpdate);
696
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
697
- childrenPromises.length = 0;
698
- }
699
- }
700
- };
701
- const callRender = (hostRef, instance, elm) => {
702
- try {
703
- instance = instance.render() ;
704
- {
705
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
706
- }
707
- {
708
- hostRef.$flags$ |= 2 /* hasRendered */;
709
- }
710
- {
711
- {
712
- // looks like we've got child nodes to render into this host element
713
- // or we need to update the css class/attrs on the host element
714
- // DOM WRITE!
715
- {
716
- renderVdom(hostRef, instance);
717
- }
718
- }
719
- }
720
- }
721
- catch (e) {
722
- consoleError(e, hostRef.$hostElement$);
723
- }
724
- return null;
725
- };
726
- const postUpdateComponent = (hostRef) => {
727
- const tagName = hostRef.$cmpMeta$.$tagName$;
728
- const elm = hostRef.$hostElement$;
729
- const endPostUpdate = createTime('postUpdate', tagName);
730
- const ancestorComponent = hostRef.$ancestorComponent$;
731
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
732
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
733
- {
734
- // DOM WRITE!
735
- addHydratedFlag(elm);
736
- }
737
- endPostUpdate();
738
- {
739
- hostRef.$onReadyResolve$(elm);
740
- if (!ancestorComponent) {
741
- appDidLoad();
742
- }
743
- }
744
- }
745
- else {
746
- endPostUpdate();
747
- }
748
- // load events fire from bottom to top
749
- // the deepest elements load first then bubbles up
750
- {
751
- if (hostRef.$onRenderResolve$) {
752
- hostRef.$onRenderResolve$();
753
- hostRef.$onRenderResolve$ = undefined;
754
- }
755
- if (hostRef.$flags$ & 512 /* needsRerender */) {
756
- nextTick(() => scheduleUpdate(hostRef, false));
757
- }
758
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
759
- }
760
- // ( •_•)
761
- // ( •_•)>⌐■-■
762
- // (⌐■_■)
763
- };
764
- const appDidLoad = (who) => {
765
- // on appload
766
- // we have finish the first big initial render
767
- {
768
- addHydratedFlag(doc.documentElement);
769
- }
770
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
771
- };
772
- const safeCall = (instance, method, arg) => {
773
- if (instance && instance[method]) {
774
- try {
775
- return instance[method](arg);
776
- }
777
- catch (e) {
778
- consoleError(e);
779
- }
780
- }
781
- return undefined;
782
- };
783
- const then = (promise, thenFn) => {
784
- return promise && promise.then ? promise.then(thenFn) : thenFn();
785
- };
786
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
787
- ;
788
- /**
789
- * Parse a new property value for a given property type.
790
- *
791
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
792
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
793
- * 1. `any`, the type given to `propValue` in the function signature
794
- * 2. the type stored from `propType`.
795
- *
796
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
797
- *
798
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
799
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
800
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
801
- * ```tsx
802
- * <my-cmp prop-val={0}></my-cmp>
803
- * ```
804
- *
805
- * HTML prop values on the other hand, will always a string
806
- *
807
- * @param propValue the new value to coerce to some type
808
- * @param propType the type of the prop, expressed as a binary number
809
- * @returns the parsed/coerced value
810
- */
811
- const parsePropertyValue = (propValue, propType) => {
812
- // ensure this value is of the correct prop type
813
- if (propValue != null && !isComplexType(propValue)) {
814
- if (propType & 4 /* Boolean */) {
815
- // per the HTML spec, any string value means it is a boolean true value
816
- // but we'll cheat here and say that the string "false" is the boolean false
817
- return propValue === 'false' ? false : propValue === '' || !!propValue;
818
- }
819
- if (propType & 1 /* String */) {
820
- // could have been passed as a number or boolean
821
- // but we still want it as a string
822
- return String(propValue);
823
- }
824
- // redundant return here for better minification
825
- return propValue;
826
- }
827
- // not sure exactly what type we want
828
- // so no need to change to a different type
829
- return propValue;
830
- };
831
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
832
- const setValue = (ref, propName, newVal, cmpMeta) => {
833
- // check our new property value against our internal value
834
- const hostRef = getHostRef(ref);
835
- const elm = hostRef.$hostElement$ ;
836
- const oldVal = hostRef.$instanceValues$.get(propName);
837
- const flags = hostRef.$flags$;
838
- const instance = hostRef.$lazyInstance$ ;
839
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
840
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
841
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
842
- const didValueChange = newVal !== oldVal && !areBothNaN;
843
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
844
- // gadzooks! the property's value has changed!!
845
- // set our new value!
846
- hostRef.$instanceValues$.set(propName, newVal);
847
- if (instance) {
848
- // get an array of method names of watch functions to call
849
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
850
- const watchMethods = cmpMeta.$watchers$[propName];
851
- if (watchMethods) {
852
- // this instance is watching for when this property changed
853
- watchMethods.map((watchMethodName) => {
854
- try {
855
- // fire off each of the watch methods that are watching this property
856
- instance[watchMethodName](newVal, oldVal, propName);
857
- }
858
- catch (e) {
859
- consoleError(e, elm);
860
- }
861
- });
862
- }
863
- }
864
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
865
- // looks like this value actually changed, so we've got work to do!
866
- // but only if we've already rendered, otherwise just chill out
867
- // queue that we need to do an update, but don't worry about queuing
868
- // up millions cuz this function ensures it only runs once
869
- scheduleUpdate(hostRef, false);
870
- }
871
- }
872
- }
873
- };
874
- const proxyComponent = (Cstr, cmpMeta, flags) => {
875
- if (cmpMeta.$members$) {
876
- if (Cstr.watchers) {
877
- cmpMeta.$watchers$ = Cstr.watchers;
878
- }
879
- // It's better to have a const than two Object.entries()
880
- const members = Object.entries(cmpMeta.$members$);
881
- const prototype = Cstr.prototype;
882
- members.map(([memberName, [memberFlags]]) => {
883
- if ((memberFlags & 31 /* Prop */ ||
884
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
885
- // proxyComponent - prop
886
- Object.defineProperty(prototype, memberName, {
887
- get() {
888
- // proxyComponent, get value
889
- return getValue(this, memberName);
890
- },
891
- set(newValue) {
892
- // proxyComponent, set value
893
- setValue(this, memberName, newValue, cmpMeta);
894
- },
895
- configurable: true,
896
- enumerable: true,
897
- });
898
- }
899
- });
900
- if ((flags & 1 /* isElementConstructor */)) {
901
- const attrNameToPropName = new Map();
902
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
903
- plt.jmp(() => {
904
- const propName = attrNameToPropName.get(attrName);
905
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
906
- // in the case where an attribute was set inline.
907
- // ```html
908
- // <my-component some-attribute="some-value"></my-component>
909
- // ```
910
- //
911
- // There is an edge case where a developer sets the attribute inline on a custom element and then
912
- // programmatically changes it before it has been upgraded as shown below:
913
- //
914
- // ```html
915
- // <!-- this component has _not_ been upgraded yet -->
916
- // <my-component id="test" some-attribute="some-value"></my-component>
917
- // <script>
918
- // // grab non-upgraded component
919
- // el = document.querySelector("#test");
920
- // el.someAttribute = "another-value";
921
- // // upgrade component
922
- // customElements.define('my-component', MyComponent);
923
- // </script>
924
- // ```
925
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
926
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
927
- // to the value that was set inline i.e. "some-value" from above example. When
928
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
929
- //
930
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
931
- // by connectedCallback as this attributeChangedCallback will not fire.
932
- //
933
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
934
- //
935
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
936
- // properties here given that this goes against best practices outlined here
937
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
938
- if (this.hasOwnProperty(propName)) {
939
- newValue = this[propName];
940
- delete this[propName];
941
- }
942
- else if (prototype.hasOwnProperty(propName) &&
943
- typeof this[propName] === 'number' &&
944
- this[propName] == newValue) {
945
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
946
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
947
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
948
- return;
949
- }
950
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
951
- });
952
- };
953
- // create an array of attributes to observe
954
- // and also create a map of html attribute name to js property name
955
- Cstr.observedAttributes = members
956
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
957
- .map(([propName, m]) => {
958
- const attrName = m[1] || propName;
959
- attrNameToPropName.set(attrName, propName);
960
- return attrName;
961
- });
962
- }
963
- }
964
- return Cstr;
965
- };
966
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
967
- // initializeComponent
968
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
969
- {
970
- // we haven't initialized this element yet
971
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
972
- // lazy loaded components
973
- // request the component's implementation to be
974
- // wired up with the host element
975
- Cstr = loadModule(cmpMeta);
976
- if (Cstr.then) {
977
- // Await creates a micro-task avoid if possible
978
- const endLoad = uniqueTime();
979
- Cstr = await Cstr;
980
- endLoad();
981
- }
982
- if (!Cstr.isProxied) {
983
- // we've never proxied this Constructor before
984
- // let's add the getters/setters to its prototype before
985
- // the first time we create an instance of the implementation
986
- {
987
- cmpMeta.$watchers$ = Cstr.watchers;
988
- }
989
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
990
- Cstr.isProxied = true;
991
- }
992
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
993
- // ok, time to construct the instance
994
- // but let's keep track of when we start and stop
995
- // so that the getters/setters don't incorrectly step on data
996
- {
997
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
998
- }
999
- // construct the lazy-loaded component implementation
1000
- // passing the hostRef is very important during
1001
- // construction in order to directly wire together the
1002
- // host element and the lazy-loaded instance
1003
- try {
1004
- new Cstr(hostRef);
1005
- }
1006
- catch (e) {
1007
- consoleError(e);
1008
- }
1009
- {
1010
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1011
- }
1012
- {
1013
- hostRef.$flags$ |= 128 /* isWatchReady */;
1014
- }
1015
- endNewInstance();
1016
- }
1017
- if (Cstr.style) {
1018
- // this component has styles but we haven't registered them yet
1019
- let style = Cstr.style;
1020
- const scopeId = getScopeId(cmpMeta);
1021
- if (!styles.has(scopeId)) {
1022
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1023
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1024
- endRegisterStyles();
1025
- }
1026
- }
1027
- }
1028
- // we've successfully created a lazy instance
1029
- const ancestorComponent = hostRef.$ancestorComponent$;
1030
- const schedule = () => scheduleUpdate(hostRef, true);
1031
- if (ancestorComponent && ancestorComponent['s-rc']) {
1032
- // this is the initial load and this component it has an ancestor component
1033
- // but the ancestor component has NOT fired its will update lifecycle yet
1034
- // so let's just cool our jets and wait for the ancestor to continue first
1035
- // this will get fired off when the ancestor component
1036
- // finally gets around to rendering its lazy self
1037
- // fire off the initial update
1038
- ancestorComponent['s-rc'].push(schedule);
1039
- }
1040
- else {
1041
- schedule();
1042
- }
1043
- };
1044
- const connectedCallback = (elm) => {
1045
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1046
- const hostRef = getHostRef(elm);
1047
- const cmpMeta = hostRef.$cmpMeta$;
1048
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1049
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1050
- // first time this component has connected
1051
- hostRef.$flags$ |= 1 /* hasConnected */;
1052
- {
1053
- // find the first ancestor component (if there is one) and register
1054
- // this component as one of the actively loading child components for its ancestor
1055
- let ancestorComponent = elm;
1056
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1057
- // climb up the ancestors looking for the first
1058
- // component that hasn't finished its lifecycle update yet
1059
- if (ancestorComponent['s-p']) {
1060
- // we found this components first ancestor component
1061
- // keep a reference to this component's ancestor component
1062
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1063
- break;
1064
- }
1065
- }
1066
- }
1067
- // Lazy properties
1068
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1069
- if (cmpMeta.$members$) {
1070
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1071
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1072
- const value = elm[memberName];
1073
- delete elm[memberName];
1074
- elm[memberName] = value;
1075
- }
1076
- });
1077
- }
1078
- {
1079
- initializeComponent(elm, hostRef, cmpMeta);
1080
- }
1081
- }
1082
- else {
1083
- // not the first time this has connected
1084
- // reattach any event listeners to the host
1085
- // since they would have been removed when disconnected
1086
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1087
- }
1088
- endConnected();
1089
- }
1090
- };
1091
- const disconnectedCallback = (elm) => {
1092
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1093
- const hostRef = getHostRef(elm);
1094
- {
1095
- if (hostRef.$rmListeners$) {
1096
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1097
- hostRef.$rmListeners$ = undefined;
1098
- }
1099
- }
1100
- }
1101
- };
1102
- const bootstrapLazy = (lazyBundles, options = {}) => {
1103
- const endBootstrap = createTime();
1104
- const cmpTags = [];
1105
- const exclude = options.exclude || [];
1106
- const customElements = win.customElements;
1107
- const head = doc.head;
1108
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1109
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1110
- const deferredConnectedCallbacks = [];
1111
- let appLoadFallback;
1112
- let isBootstrapping = true;
1113
- Object.assign(plt, options);
1114
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1115
- lazyBundles.map((lazyBundle) => {
1116
- lazyBundle[1].map((compactMeta) => {
1117
- const cmpMeta = {
1118
- $flags$: compactMeta[0],
1119
- $tagName$: compactMeta[1],
1120
- $members$: compactMeta[2],
1121
- $listeners$: compactMeta[3],
1122
- };
1123
- {
1124
- cmpMeta.$members$ = compactMeta[2];
1125
- }
1126
- {
1127
- cmpMeta.$listeners$ = compactMeta[3];
1128
- }
1129
- {
1130
- cmpMeta.$watchers$ = {};
1131
- }
1132
- const tagName = cmpMeta.$tagName$;
1133
- const HostElement = class extends HTMLElement {
1134
- // StencilLazyHost
1135
- constructor(self) {
1136
- // @ts-ignore
1137
- super(self);
1138
- self = this;
1139
- registerHost(self, cmpMeta);
1140
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1141
- // this component is using shadow dom
1142
- // and this browser supports shadow dom
1143
- // add the read-only property "shadowRoot" to the host element
1144
- // adding the shadow root build conditionals to minimize runtime
1145
- {
1146
- {
1147
- self.attachShadow({ mode: 'open' });
1148
- }
1149
- }
1150
- }
1151
- }
1152
- connectedCallback() {
1153
- if (appLoadFallback) {
1154
- clearTimeout(appLoadFallback);
1155
- appLoadFallback = null;
1156
- }
1157
- if (isBootstrapping) {
1158
- // connectedCallback will be processed once all components have been registered
1159
- deferredConnectedCallbacks.push(this);
1160
- }
1161
- else {
1162
- plt.jmp(() => connectedCallback(this));
1163
- }
1164
- }
1165
- disconnectedCallback() {
1166
- plt.jmp(() => disconnectedCallback(this));
1167
- }
1168
- componentOnReady() {
1169
- return getHostRef(this).$onReadyPromise$;
1170
- }
1171
- };
1172
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1173
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1174
- cmpTags.push(tagName);
1175
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1176
- }
1177
- });
1178
- });
1179
- {
1180
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1181
- visibilityStyle.setAttribute('data-styles', '');
1182
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1183
- }
1184
- // Process deferred connectedCallbacks now all components have been registered
1185
- isBootstrapping = false;
1186
- if (deferredConnectedCallbacks.length) {
1187
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1188
- }
1189
- else {
1190
- {
1191
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1192
- }
1193
- }
1194
- // Fallback appLoad event
1195
- endBootstrap();
1196
- };
1197
- const hostRefs = new WeakMap();
1198
- const getHostRef = (ref) => hostRefs.get(ref);
1199
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1200
- const registerHost = (elm, cmpMeta) => {
1201
- const hostRef = {
1202
- $flags$: 0,
1203
- $hostElement$: elm,
1204
- $cmpMeta$: cmpMeta,
1205
- $instanceValues$: new Map(),
1206
- };
1207
- {
1208
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1209
- elm['s-p'] = [];
1210
- elm['s-rc'] = [];
1211
- }
1212
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1213
- return hostRefs.set(elm, hostRef);
1214
- };
1215
- const isMemberInElement = (elm, memberName) => memberName in elm;
1216
- const consoleError = (e, el) => (0, console.error)(e, el);
1217
- const cmpModules = /*@__PURE__*/ new Map();
1218
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1219
- // loadModuleImport
1220
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1221
- const bundleId = cmpMeta.$lazyBundleId$;
1222
- const module = cmpModules.get(bundleId) ;
1223
- if (module) {
1224
- return module[exportName];
1225
- }
1226
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1227
- /* webpackInclude: /\.entry\.js$/ */
1228
- /* webpackExclude: /\.system\.entry\.js$/ */
1229
- /* webpackMode: "lazy" */
1230
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1231
- {
1232
- cmpModules.set(bundleId, importedModule);
1233
- }
1234
- return importedModule[exportName];
1235
- }, consoleError);
1236
- };
1237
- const styles = new Map();
1238
- const queueDomReads = [];
1239
- const queueDomWrites = [];
1240
- const queueTask = (queue, write) => (cb) => {
1241
- queue.push(cb);
1242
- if (!queuePending) {
1243
- queuePending = true;
1244
- if (write && plt.$flags$ & 4 /* queueSync */) {
1245
- nextTick(flush);
1246
- }
1247
- else {
1248
- plt.raf(flush);
1249
- }
1250
- }
1251
- };
1252
- const consume = (queue) => {
1253
- for (let i = 0; i < queue.length; i++) {
1254
- try {
1255
- queue[i](performance.now());
1256
- }
1257
- catch (e) {
1258
- consoleError(e);
1259
- }
1260
- }
1261
- queue.length = 0;
1262
- };
1263
- const flush = () => {
1264
- // always force a bunch of medium callbacks to run, but still have
1265
- // a throttle on how many can run in a certain time
1266
- // DOM READS!!!
1267
- consume(queueDomReads);
1268
- // DOM WRITES!!!
1269
- {
1270
- consume(queueDomWrites);
1271
- if ((queuePending = queueDomReads.length > 0)) {
1272
- // still more to do yet, but we've run out of time
1273
- // let's let this thing cool off and try again in the next tick
1274
- plt.raf(flush);
1275
- }
1276
- }
1277
- };
1278
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1279
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1280
-
1281
- exports.bootstrapLazy = bootstrapLazy;
1282
- exports.createEvent = createEvent;
1283
- exports.h = h;
1284
- exports.promiseResolve = promiseResolve;
1285
- exports.registerInstance = registerInstance;