@salla.sa/twilight-components 1.0.19 → 1.0.21

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