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