1 | const BUILD = {"allRenderFn":false,"cmpDidLoad":true,"cmpDidUnload":true,"cmpDidUpdate":true,"cmpDidRender":false,"cmpWillLoad":true,"cmpWillUpdate":false,"cmpWillRender":false,"connectedCallback":true,"disconnectedCallback":true,"element":false,"event":false,"hasRenderFn":true,"lifecycle":true,"hostListener":false,"hostListenerTargetWindow":false,"hostListenerTargetDocument":false,"hostListenerTargetBody":false,"hostListenerTargetParent":false,"hostListenerTarget":false,"member":true,"method":false,"mode":false,"noVdomRender":false,"observeAttribute":true,"prop":true,"propBoolean":true,"propNumber":true,"propString":true,"propMutable":true,"reflect":true,"scoped":false,"shadowDom":false,"slot":true,"slotRelocation":true,"state":true,"style":true,"svg":false,"updatable":true,"vdomAttribute":true,"vdomClass":true,"vdomFunctional":true,"vdomKey":true,"vdomListener":true,"vdomRef":true,"vdomRender":true,"vdomStyle":true,"vdomText":true,"watchCallback":true,"taskQueue":true,"lazyLoad":true,"hydrateServerSide":false,"cssVarShim":true,"hydrateClientSide":false,"isDebug":false,"isDev":false,"lifecycleDOMEvents":false,"profile":false,"hotModuleReplacement":false,"constructableCSS":true,"cssAnnotations":true};
|
2 | const NAMESPACE = 'stencilrouter';
|
3 |
|
4 | const win = window;
|
5 | const doc = document;
|
6 | const plt = {
|
7 | $flags$: 0,
|
8 | $resourcesUrl$: '',
|
9 | raf: (h) => requestAnimationFrame(h),
|
10 | ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
11 | rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
12 | };
|
13 | const supportsShadowDom = false;
|
14 | const supportsConstructibleStylesheets = (() => {
|
15 | try {
|
16 | new CSSStyleSheet();
|
17 | return true;
|
18 | }
|
19 | catch (e) { }
|
20 | return false;
|
21 | })();
|
22 |
|
23 | const Context = {};
|
24 |
|
25 | const hostRefs = new WeakMap();
|
26 | const getHostRef = (ref) => hostRefs.get(ref);
|
27 | const registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
|
28 | const registerHost = (elm) => {
|
29 | {
|
30 | const hostRef = {
|
31 | $flags$: 0,
|
32 | $hostElement$: elm,
|
33 | $instanceValues$: new Map()
|
34 | };
|
35 | hostRef.$onReadyPromise$ = new Promise(r => hostRef.$onReadyResolve$ = r);
|
36 | return hostRefs.set(elm, hostRef);
|
37 | }
|
38 | };
|
39 | const isMemberInElement = (elm, memberName) => memberName in elm;
|
40 |
|
41 | const consoleError = (e) => console.error(e);
|
42 |
|
43 | const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
44 |
|
45 | const bundleId = cmpMeta.$lazyBundleIds$;
|
46 | return import(
|
47 |
|
48 |
|
49 |
|
50 | `./${bundleId}.entry.js${''}`).then(importedModule => importedModule[cmpMeta.$tagName$.replace(/-/g, '_')], consoleError);
|
51 | };
|
52 |
|
53 | const styles = new Map();
|
54 | const cssVarShim = win.__stencil_cssshim;
|
55 |
|
56 | let queueCongestion = 0;
|
57 | let queuePending = false;
|
58 | const queueDomReads = [];
|
59 | const queueDomWrites = [];
|
60 | const queueDomWritesLow = [];
|
61 | const queueTask = (queue) => (cb) => {
|
62 |
|
63 | queue.push(cb);
|
64 | if (!queuePending) {
|
65 | queuePending = true;
|
66 | plt.raf(flush);
|
67 | }
|
68 | };
|
69 | const consume = (queue) => {
|
70 | for (let i = 0; i < queue.length; i++) {
|
71 | try {
|
72 | queue[i](performance.now());
|
73 | }
|
74 | catch (e) {
|
75 | consoleError(e);
|
76 | }
|
77 | }
|
78 | queue.length = 0;
|
79 | };
|
80 | const consumeTimeout = (queue, timeout) => {
|
81 | let i = 0;
|
82 | let ts = 0;
|
83 | while (i < queue.length && (ts = performance.now()) < timeout) {
|
84 | try {
|
85 | queue[i++](ts);
|
86 | }
|
87 | catch (e) {
|
88 | consoleError(e);
|
89 | }
|
90 | }
|
91 | if (i === queue.length) {
|
92 | queue.length = 0;
|
93 | }
|
94 | else if (i !== 0) {
|
95 | queue.splice(0, i);
|
96 | }
|
97 | };
|
98 | const flush = () => {
|
99 | queueCongestion++;
|
100 |
|
101 |
|
102 |
|
103 | consume(queueDomReads);
|
104 | const timeout = (plt.$flags$ & 6 ) === 2
|
105 | ? performance.now() + (7 * Math.ceil(queueCongestion * (1.0 / 22.0)))
|
106 | : Infinity;
|
107 |
|
108 | consumeTimeout(queueDomWrites, timeout);
|
109 | consumeTimeout(queueDomWritesLow, timeout);
|
110 | if (queueDomWrites.length > 0) {
|
111 | queueDomWritesLow.push(...queueDomWrites);
|
112 | queueDomWrites.length = 0;
|
113 | }
|
114 | if (queuePending = ((queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length) > 0)) {
|
115 |
|
116 |
|
117 | plt.raf(flush);
|
118 | }
|
119 | else {
|
120 | queueCongestion = 0;
|
121 | }
|
122 | };
|
123 | const nextTick = (cb) => Promise.resolve().then(cb);
|
124 | const readTask = queueTask(queueDomReads);
|
125 | const writeTask = queueTask(queueDomWrites);
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 | const EMPTY_OBJ = {};
|
135 |
|
136 | const isDef = (v) => v != null;
|
137 | const toLowerCase = (str) => str.toLowerCase();
|
138 | const isComplexType = (o) => ['object', 'function'].includes(typeof o);
|
139 |
|
140 | function getDynamicImportFunction(namespace) {
|
141 | return `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
|
142 | }
|
143 |
|
144 | const patchEsm = () => {
|
145 |
|
146 | if (!(win.CSS && win.CSS.supports && win.CSS.supports('color', 'var(--c)'))) {
|
147 |
|
148 | return import('./css-shim-f7ddb189-f7ddb189.js');
|
149 | }
|
150 | return Promise.resolve();
|
151 | };
|
152 | const patchBrowser = async () => {
|
153 |
|
154 | const importMeta = "";
|
155 | if (importMeta !== '') {
|
156 | return Promise.resolve(new URL('.', importMeta).href);
|
157 | }
|
158 | else {
|
159 | const scriptElm = Array.from(doc.querySelectorAll('script')).find(s => (s.src.includes(`/${NAMESPACE}.esm.js`) ||
|
160 | s.getAttribute('data-namespace') === NAMESPACE));
|
161 | const resourcesUrl = new URL('.', new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href));
|
162 | patchDynamicImport(resourcesUrl.href);
|
163 | if (!window.customElements) {
|
164 |
|
165 | await import('./dom-a0c82e31-a0c82e31.js');
|
166 | }
|
167 | return resourcesUrl.href;
|
168 | }
|
169 | };
|
170 | const patchDynamicImport = (base) => {
|
171 | const importFunctionName = getDynamicImportFunction(NAMESPACE);
|
172 | try {
|
173 | win[importFunctionName] = new Function('w', 'return import(w);');
|
174 | }
|
175 | catch (e) {
|
176 | const moduleMap = new Map();
|
177 | win[importFunctionName] = (src) => {
|
178 | const url = new URL(src, base).href;
|
179 | let mod = moduleMap.get(url);
|
180 | if (!mod) {
|
181 | const script = doc.createElement('script');
|
182 | script.type = 'module';
|
183 | script.src = URL.createObjectURL(new Blob([`import * as m from '${url}'; window.${importFunctionName}.m = m;`], { type: 'application/javascript' }));
|
184 | mod = new Promise(resolve => {
|
185 | script.onload = () => {
|
186 | resolve(win[importFunctionName].m);
|
187 | script.remove();
|
188 | };
|
189 | });
|
190 | moduleMap.set(url, mod);
|
191 | doc.head.appendChild(script);
|
192 | }
|
193 | return mod;
|
194 | };
|
195 | }
|
196 | };
|
197 | const HYDRATED_CLASS = 'hydrated';
|
198 |
|
199 | const rootAppliedStyles = new WeakMap();
|
200 | const registerStyle = (scopeId, cssText) => {
|
201 | let style = styles.get(scopeId);
|
202 | if (supportsConstructibleStylesheets) {
|
203 | style = (style || new CSSStyleSheet());
|
204 | style.replace(cssText);
|
205 | }
|
206 | else {
|
207 | style = cssText;
|
208 | }
|
209 | styles.set(scopeId, style);
|
210 | };
|
211 | const addStyle = (styleContainerNode, tagName, mode, hostElm) => {
|
212 | let scopeId = getScopeId(tagName);
|
213 | let style = styles.get(scopeId);
|
214 |
|
215 |
|
216 | styleContainerNode = (styleContainerNode.nodeType === 11 ? styleContainerNode : doc);
|
217 | if (style) {
|
218 | if (typeof style === 'string') {
|
219 | styleContainerNode = styleContainerNode.head || styleContainerNode;
|
220 | let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
221 | let styleElm;
|
222 | if (!appliedStyles) {
|
223 | rootAppliedStyles.set(styleContainerNode, appliedStyles = new Set());
|
224 | }
|
225 | if (!appliedStyles.has(scopeId)) {
|
226 | {
|
227 | if (cssVarShim) {
|
228 | styleElm = cssVarShim.createHostStyle(hostElm, scopeId, style);
|
229 | const newScopeId = styleElm['s-sc'];
|
230 | if (newScopeId) {
|
231 | scopeId = newScopeId;
|
232 |
|
233 |
|
234 |
|
235 | appliedStyles = null;
|
236 | }
|
237 | }
|
238 | else {
|
239 | styleElm = doc.createElement('style');
|
240 | styleElm.innerHTML = style;
|
241 | }
|
242 | styleContainerNode.appendChild(styleElm);
|
243 | }
|
244 | if (appliedStyles) {
|
245 | appliedStyles.add(scopeId);
|
246 | }
|
247 | }
|
248 | }
|
249 | else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
250 | styleContainerNode.adoptedStyleSheets = [
|
251 | ...styleContainerNode.adoptedStyleSheets,
|
252 | style
|
253 | ];
|
254 | }
|
255 | }
|
256 | return scopeId;
|
257 | };
|
258 | const attachStyles = (elm, cmpMeta, mode) => {
|
259 | const styleId = addStyle(elm.getRootNode(), cmpMeta.$tagName$, mode, elm);
|
260 | };
|
261 | const getScopeId = (tagName, mode) => 'sc-' + (tagName);
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 | const h = (nodeName, vnodeData, ...children) => {
|
275 | let child = null;
|
276 | let simple = false;
|
277 | let lastSimple = false;
|
278 | let key;
|
279 | let slotName;
|
280 | let vNodeChildren = [];
|
281 | const walk = (c) => {
|
282 | for (let i = 0; i < c.length; i++) {
|
283 | child = c[i];
|
284 | if (Array.isArray(child)) {
|
285 | walk(child);
|
286 | }
|
287 | else if (child != null && typeof child !== 'boolean') {
|
288 | if (simple = typeof nodeName !== 'function' && !isComplexType(child)) {
|
289 | child = String(child);
|
290 | }
|
291 | if (simple && lastSimple) {
|
292 |
|
293 | vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
294 | }
|
295 | else {
|
296 |
|
297 | vNodeChildren.push(simple ? { $flags$: 0, $text$: child } : child);
|
298 | }
|
299 | lastSimple = simple;
|
300 | }
|
301 | }
|
302 | };
|
303 | walk(children);
|
304 | if (vnodeData) {
|
305 |
|
306 | {
|
307 | key = vnodeData.key || undefined;
|
308 | }
|
309 | {
|
310 | slotName = vnodeData.name;
|
311 | }
|
312 | {
|
313 | const classData = vnodeData.className || vnodeData.class;
|
314 | if (classData) {
|
315 | vnodeData.class = typeof classData !== 'object'
|
316 | ? classData
|
317 | : Object.keys(classData)
|
318 | .filter(k => classData[k])
|
319 | .join(' ');
|
320 | }
|
321 | }
|
322 | }
|
323 | if (typeof nodeName === 'function') {
|
324 |
|
325 | return nodeName(vnodeData, vNodeChildren, vdomFnUtils);
|
326 | }
|
327 | const vnode = {
|
328 | $flags$: 0,
|
329 | $tag$: nodeName,
|
330 | $children$: vNodeChildren.length > 0 ? vNodeChildren : null,
|
331 | $elm$: undefined,
|
332 | $attrs$: vnodeData,
|
333 | };
|
334 | {
|
335 | vnode.$key$ = key;
|
336 | }
|
337 | {
|
338 | vnode.$name$ = slotName;
|
339 | }
|
340 | return vnode;
|
341 | };
|
342 | const Host = {};
|
343 | const vdomFnUtils = {
|
344 | 'forEach': (children, cb) => children.map(convertToPublic).forEach(cb),
|
345 | 'map': (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
|
346 | };
|
347 | const convertToPublic = (node) => {
|
348 | return {
|
349 | vattrs: node.$attrs$,
|
350 | vchildren: node.$children$,
|
351 | vkey: node.$key$,
|
352 | vname: node.$name$,
|
353 | vtag: node.$tag$,
|
354 | vtext: node.$text$
|
355 | };
|
356 | };
|
357 | const convertToPrivate = (node) => {
|
358 | return {
|
359 | $flags$: 0,
|
360 | $attrs$: node.vattrs,
|
361 | $children$: node.vchildren,
|
362 | $key$: node.vkey,
|
363 | $name$: node.vname,
|
364 | $tag$: node.vtag,
|
365 | $text$: node.vtext
|
366 | };
|
367 | };
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 | const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
378 | if (oldValue === newValue) {
|
379 | return;
|
380 | }
|
381 | if (memberName === 'class' && !isSvg) {
|
382 |
|
383 | {
|
384 | const oldList = parseClassList(oldValue);
|
385 | const baseList = parseClassList(elm.className).filter(item => !oldList.includes(item));
|
386 | elm.className = baseList.concat(parseClassList(newValue).filter(item => !baseList.includes(item))).join(' ');
|
387 | }
|
388 | }
|
389 | else if (memberName === 'style') {
|
390 |
|
391 | {
|
392 | for (const prop in oldValue) {
|
393 | if (!newValue || newValue[prop] == null) {
|
394 | if (prop.includes('-')) {
|
395 | elm.style.removeProperty(prop);
|
396 | }
|
397 | else {
|
398 | elm.style[prop] = '';
|
399 | }
|
400 | }
|
401 | }
|
402 | }
|
403 | for (const prop in newValue) {
|
404 | if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
405 | if (prop.includes('-')) {
|
406 | elm.style.setProperty(prop, newValue[prop]);
|
407 | }
|
408 | else {
|
409 | elm.style[prop] = newValue[prop];
|
410 | }
|
411 | }
|
412 | }
|
413 | }
|
414 | else if (memberName === 'key') ;
|
415 | else if (memberName === 'ref') {
|
416 |
|
417 | if (newValue) {
|
418 | newValue(elm);
|
419 | }
|
420 | }
|
421 | else if (memberName.startsWith('on') && !isMemberInElement(elm, memberName)) {
|
422 |
|
423 |
|
424 |
|
425 |
|
426 | if (isMemberInElement(elm, toLowerCase(memberName))) {
|
427 |
|
428 |
|
429 |
|
430 |
|
431 | memberName = toLowerCase(memberName.substring(2));
|
432 | }
|
433 | else {
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 | memberName = toLowerCase(memberName[2]) + memberName.substring(3);
|
440 | }
|
441 | if (oldValue) {
|
442 | plt.rel(elm, memberName, oldValue, false);
|
443 | }
|
444 | if (newValue) {
|
445 | plt.ael(elm, memberName, newValue, false);
|
446 | }
|
447 | }
|
448 | else {
|
449 |
|
450 | const isProp = isMemberInElement(elm, memberName);
|
451 | const isComplex = isComplexType(newValue);
|
452 | if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
453 | try {
|
454 | elm[memberName] = newValue == null && elm.tagName.indexOf('-') === -1 ? '' : newValue;
|
455 | }
|
456 | catch (e) { }
|
457 | }
|
458 | if (newValue == null || newValue === false) {
|
459 | {
|
460 | elm.removeAttribute(memberName);
|
461 | }
|
462 | }
|
463 | else if ((!isProp || (flags & 4 ) || isSvg) && !isComplex) {
|
464 | newValue = newValue === true ? '' : newValue.toString();
|
465 | {
|
466 | elm.setAttribute(memberName, newValue);
|
467 | }
|
468 | }
|
469 | }
|
470 | };
|
471 | const parseClassList = (value) => (!value) ? [] : value.split(' ');
|
472 |
|
473 | const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
474 |
|
475 |
|
476 |
|
477 | const elm = (newVnode.$elm$.nodeType === 11 && newVnode.$elm$.host) ? newVnode.$elm$.host : newVnode.$elm$;
|
478 | const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
479 | const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
480 | {
|
481 |
|
482 | for (memberName in oldVnodeAttrs) {
|
483 | if (newVnodeAttrs[memberName] == null && oldVnodeAttrs[memberName] != null) {
|
484 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
485 | }
|
486 | }
|
487 | }
|
488 |
|
489 | for (memberName in newVnodeAttrs) {
|
490 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
491 | }
|
492 | };
|
493 |
|
494 | let scopeId;
|
495 | let contentRef;
|
496 | let hostTagName;
|
497 | let useNativeShadowDom = false;
|
498 | let checkSlotFallbackVisibility = false;
|
499 | let checkSlotRelocate = false;
|
500 | let isSvgMode = false;
|
501 | const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
502 |
|
503 | let newVNode = newParentVNode.$children$[childIndex];
|
504 | let i = 0;
|
505 | let elm;
|
506 | let childNode;
|
507 | let oldVNode;
|
508 | if (!useNativeShadowDom) {
|
509 |
|
510 | checkSlotRelocate = true;
|
511 | if (newVNode.$tag$ === 'slot') {
|
512 | if (scopeId) {
|
513 |
|
514 | parentElm.classList.add(scopeId + '-s');
|
515 | }
|
516 | if (!newVNode.$children$) {
|
517 |
|
518 |
|
519 |
|
520 | newVNode.$flags$ |= 1 ;
|
521 | }
|
522 | else {
|
523 |
|
524 |
|
525 | newVNode.$flags$ |= 2 ;
|
526 | }
|
527 | }
|
528 | }
|
529 | if (isDef(newVNode.$text$)) {
|
530 |
|
531 | newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
532 | }
|
533 | else if (newVNode.$flags$ & 1 ) {
|
534 |
|
535 | newVNode.$elm$ = doc.createTextNode('');
|
536 | }
|
537 | else {
|
538 |
|
539 | elm = newVNode.$elm$ = (doc.createElement((newVNode.$flags$ & 2 ) ? 'slot-fb' : newVNode.$tag$));
|
540 |
|
541 | {
|
542 | updateElement(null, newVNode, isSvgMode);
|
543 | }
|
544 | if (newVNode.$children$) {
|
545 | for (i = 0; i < newVNode.$children$.length; ++i) {
|
546 |
|
547 | childNode = createElm(oldParentVNode, newVNode, i, elm);
|
548 |
|
549 | if (childNode) {
|
550 |
|
551 | elm.appendChild(childNode);
|
552 | }
|
553 | }
|
554 | }
|
555 | }
|
556 | {
|
557 | newVNode.$elm$['s-hn'] = hostTagName;
|
558 | if (newVNode.$flags$ & (2 | 1 )) {
|
559 |
|
560 | newVNode.$elm$['s-sr'] = true;
|
561 |
|
562 | newVNode.$elm$['s-cr'] = contentRef;
|
563 |
|
564 | newVNode.$elm$['s-sn'] = newVNode.$name$ || '';
|
565 |
|
566 | oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
567 | if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
568 |
|
569 |
|
570 | putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
571 | }
|
572 | }
|
573 | }
|
574 | return newVNode.$elm$;
|
575 | };
|
576 | const putBackInOriginalLocation = (parentElm, recursive) => {
|
577 | plt.$flags$ |= 1 ;
|
578 | const oldSlotChildNodes = parentElm.childNodes;
|
579 | for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
580 | const childNode = oldSlotChildNodes[i];
|
581 | if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
582 |
|
583 |
|
584 |
|
585 |
|
586 | parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
587 |
|
588 |
|
589 |
|
590 | childNode['s-ol'].remove();
|
591 | childNode['s-ol'] = undefined;
|
592 | checkSlotRelocate = true;
|
593 | }
|
594 | if (recursive) {
|
595 | putBackInOriginalLocation(childNode, recursive);
|
596 | }
|
597 | }
|
598 | plt.$flags$ &= ~1 ;
|
599 | };
|
600 | const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
601 | let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
602 | let childNode;
|
603 | for (; startIdx <= endIdx; ++startIdx) {
|
604 | if (vnodes[startIdx]) {
|
605 | childNode = createElm(null, parentVNode, startIdx, parentElm);
|
606 | if (childNode) {
|
607 | vnodes[startIdx].$elm$ = childNode;
|
608 | containerElm.insertBefore(childNode, referenceNode(before));
|
609 | }
|
610 | }
|
611 | }
|
612 | };
|
613 | const removeVnodes = (vnodes, startIdx, endIdx, elm) => {
|
614 | for (; startIdx <= endIdx; ++startIdx) {
|
615 | if (isDef(vnodes[startIdx])) {
|
616 | elm = vnodes[startIdx].$elm$;
|
617 | callNodeRefs(vnodes[startIdx], true);
|
618 | {
|
619 |
|
620 |
|
621 | checkSlotFallbackVisibility = true;
|
622 | if (elm['s-ol']) {
|
623 |
|
624 | elm['s-ol'].remove();
|
625 | }
|
626 | else {
|
627 |
|
628 |
|
629 | putBackInOriginalLocation(elm, true);
|
630 | }
|
631 | }
|
632 |
|
633 | elm.remove();
|
634 | }
|
635 | }
|
636 | };
|
637 | const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
638 | let oldStartIdx = 0;
|
639 | let newStartIdx = 0;
|
640 | let idxInOld = 0;
|
641 | let i = 0;
|
642 | let oldEndIdx = oldCh.length - 1;
|
643 | let oldStartVnode = oldCh[0];
|
644 | let oldEndVnode = oldCh[oldEndIdx];
|
645 | let newEndIdx = newCh.length - 1;
|
646 | let newStartVnode = newCh[0];
|
647 | let newEndVnode = newCh[newEndIdx];
|
648 | let node;
|
649 | let elmToMove;
|
650 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
651 | if (oldStartVnode == null) {
|
652 |
|
653 | oldStartVnode = oldCh[++oldStartIdx];
|
654 | }
|
655 | else if (oldEndVnode == null) {
|
656 | oldEndVnode = oldCh[--oldEndIdx];
|
657 | }
|
658 | else if (newStartVnode == null) {
|
659 | newStartVnode = newCh[++newStartIdx];
|
660 | }
|
661 | else if (newEndVnode == null) {
|
662 | newEndVnode = newCh[--newEndIdx];
|
663 | }
|
664 | else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
665 | patch(oldStartVnode, newStartVnode);
|
666 | oldStartVnode = oldCh[++oldStartIdx];
|
667 | newStartVnode = newCh[++newStartIdx];
|
668 | }
|
669 | else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
670 | patch(oldEndVnode, newEndVnode);
|
671 | oldEndVnode = oldCh[--oldEndIdx];
|
672 | newEndVnode = newCh[--newEndIdx];
|
673 | }
|
674 | else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
675 |
|
676 | if (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot') {
|
677 | putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
678 | }
|
679 | patch(oldStartVnode, newEndVnode);
|
680 | parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
681 | oldStartVnode = oldCh[++oldStartIdx];
|
682 | newEndVnode = newCh[--newEndIdx];
|
683 | }
|
684 | else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
685 |
|
686 | if (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot') {
|
687 | putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
688 | }
|
689 | patch(oldEndVnode, newStartVnode);
|
690 | parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
691 | oldEndVnode = oldCh[--oldEndIdx];
|
692 | newStartVnode = newCh[++newStartIdx];
|
693 | }
|
694 | else {
|
695 |
|
696 | idxInOld = -1;
|
697 | {
|
698 | for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
699 | if (oldCh[i] && isDef(oldCh[i].$key$) && oldCh[i].$key$ === newStartVnode.$key$) {
|
700 | idxInOld = i;
|
701 | break;
|
702 | }
|
703 | }
|
704 | }
|
705 | if (idxInOld >= 0) {
|
706 | elmToMove = oldCh[idxInOld];
|
707 | if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
708 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
709 | }
|
710 | else {
|
711 | patch(elmToMove, newStartVnode);
|
712 | oldCh[idxInOld] = undefined;
|
713 | node = elmToMove.$elm$;
|
714 | }
|
715 | newStartVnode = newCh[++newStartIdx];
|
716 | }
|
717 | else {
|
718 |
|
719 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
720 | newStartVnode = newCh[++newStartIdx];
|
721 | }
|
722 | if (node) {
|
723 | {
|
724 | parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
725 | }
|
726 | }
|
727 | }
|
728 | }
|
729 | if (oldStartIdx > oldEndIdx) {
|
730 | addVnodes(parentElm, (newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$), newVNode, newCh, newStartIdx, newEndIdx);
|
731 | }
|
732 | else if (newStartIdx > newEndIdx) {
|
733 | removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
734 | }
|
735 | };
|
736 | const isSameVnode = (vnode1, vnode2) => {
|
737 |
|
738 |
|
739 | if (vnode1.$tag$ === vnode2.$tag$) {
|
740 | if (vnode1.$tag$ === 'slot') {
|
741 | return vnode1.$name$ === vnode2.$name$;
|
742 | }
|
743 | {
|
744 | return vnode1.$key$ === vnode2.$key$;
|
745 | }
|
746 | return true;
|
747 | }
|
748 | return false;
|
749 | };
|
750 | const referenceNode = (node) => {
|
751 |
|
752 |
|
753 |
|
754 |
|
755 | return (node && node['s-ol']) || node;
|
756 | };
|
757 | const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
758 | const patch = (oldVNode, newVNode) => {
|
759 | const elm = newVNode.$elm$ = oldVNode.$elm$;
|
760 | const oldChildren = oldVNode.$children$;
|
761 | const newChildren = newVNode.$children$;
|
762 | let defaultHolder;
|
763 | if (!isDef(newVNode.$text$)) {
|
764 |
|
765 | {
|
766 | if (newVNode.$tag$ === 'slot') ;
|
767 | else {
|
768 |
|
769 |
|
770 |
|
771 | updateElement(oldVNode, newVNode, isSvgMode);
|
772 | }
|
773 | }
|
774 | if (isDef(oldChildren) && isDef(newChildren)) {
|
775 |
|
776 | updateChildren(elm, oldChildren, newVNode, newChildren);
|
777 | }
|
778 | else if (isDef(newChildren)) {
|
779 |
|
780 | if (isDef(oldVNode.$text$)) {
|
781 |
|
782 | elm.textContent = '';
|
783 | }
|
784 |
|
785 | addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
786 | }
|
787 | else if (isDef(oldChildren)) {
|
788 |
|
789 | removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
790 | }
|
791 | }
|
792 | else if (defaultHolder = elm['s-cr']) {
|
793 |
|
794 | defaultHolder.parentNode.textContent = newVNode.$text$;
|
795 | }
|
796 | else if (oldVNode.$text$ !== newVNode.$text$) {
|
797 |
|
798 |
|
799 | elm.textContent = newVNode.$text$;
|
800 | }
|
801 | };
|
802 | const updateFallbackSlotVisibility = (elm, childNode, childNodes, i, ilen, j, slotNameAttr, nodeType) => {
|
803 | childNodes = elm.childNodes;
|
804 | for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
805 | childNode = childNodes[i];
|
806 | if (childNode.nodeType === 1 ) {
|
807 | if (childNode['s-sr']) {
|
808 |
|
809 |
|
810 | slotNameAttr = childNode['s-sn'];
|
811 |
|
812 |
|
813 | childNode.hidden = false;
|
814 | for (j = 0; j < ilen; j++) {
|
815 | if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
|
816 |
|
817 | nodeType = childNodes[j].nodeType;
|
818 | if (slotNameAttr !== '') {
|
819 |
|
820 | if (nodeType === 1 && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
821 | childNode.hidden = true;
|
822 | break;
|
823 | }
|
824 | }
|
825 | else {
|
826 |
|
827 |
|
828 |
|
829 | if (nodeType === 1 || (nodeType === 3 && childNodes[j].textContent.trim() !== '')) {
|
830 | childNode.hidden = true;
|
831 | break;
|
832 | }
|
833 | }
|
834 | }
|
835 | }
|
836 | }
|
837 |
|
838 | updateFallbackSlotVisibility(childNode);
|
839 | }
|
840 | }
|
841 | };
|
842 | const relocateNodes = [];
|
843 | const relocateSlotContent = (elm) => {
|
844 |
|
845 | let childNodes = elm.childNodes;
|
846 | let ilen = childNodes.length;
|
847 | let i = 0;
|
848 | let j = 0;
|
849 | let nodeType = 0;
|
850 | let childNode;
|
851 | let node;
|
852 | let hostContentNodes;
|
853 | let slotNameAttr;
|
854 | for (ilen = childNodes.length; i < ilen; i++) {
|
855 | childNode = childNodes[i];
|
856 | if (childNode['s-sr'] && (node = childNode['s-cr'])) {
|
857 |
|
858 |
|
859 | hostContentNodes = node.parentNode.childNodes;
|
860 | slotNameAttr = childNode['s-sn'];
|
861 | for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
862 | node = hostContentNodes[j];
|
863 | if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
864 |
|
865 |
|
866 |
|
867 | nodeType = node.nodeType;
|
868 | if (((nodeType === 3 || nodeType === 8 ) && slotNameAttr === '') ||
|
869 | (nodeType === 1 && node.getAttribute('slot') === null && slotNameAttr === '') ||
|
870 | (nodeType === 1 && node.getAttribute('slot') === slotNameAttr)) {
|
871 |
|
872 | if (!relocateNodes.some(r => r.nodeToRelocate === node)) {
|
873 |
|
874 |
|
875 |
|
876 | checkSlotFallbackVisibility = true;
|
877 | node['s-sn'] = slotNameAttr;
|
878 |
|
879 | relocateNodes.push({
|
880 | slotRefNode: childNode,
|
881 | nodeToRelocate: node
|
882 | });
|
883 | }
|
884 | }
|
885 | }
|
886 | }
|
887 | }
|
888 | if (childNode.nodeType === 1 ) {
|
889 | relocateSlotContent(childNode);
|
890 | }
|
891 | }
|
892 | };
|
893 | const callNodeRefs = (vNode, isDestroy) => {
|
894 | if (vNode) {
|
895 | vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(isDestroy ? null : vNode.$elm$);
|
896 | vNode.$children$ && vNode.$children$.forEach(vChild => {
|
897 | callNodeRefs(vChild, isDestroy);
|
898 | });
|
899 | }
|
900 | };
|
901 | const isHost = (node) => {
|
902 | return node && node.$tag$ === Host;
|
903 | };
|
904 | const renderVdom = (hostElm, hostRef, cmpMeta, renderFnResults) => {
|
905 | const oldVNode = hostRef.$vnode$ || { $flags$: 0 };
|
906 | hostTagName = toLowerCase(hostElm.tagName);
|
907 | if (isHost(renderFnResults)) {
|
908 | renderFnResults.$tag$ = null;
|
909 | }
|
910 | else {
|
911 | renderFnResults = h(null, null, renderFnResults);
|
912 | }
|
913 | if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
|
914 | renderFnResults.$attrs$ = renderFnResults.$attrs$ || {};
|
915 | cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => renderFnResults.$attrs$[attribute] = hostElm[propName]);
|
916 | }
|
917 | renderFnResults.$flags$ |= 4 ;
|
918 | hostRef.$vnode$ = renderFnResults;
|
919 | renderFnResults.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
|
920 | if (BUILD.scoped || BUILD.shadowDom) {
|
921 | scopeId = hostElm['s-sc'];
|
922 | }
|
923 | if (BUILD.slotRelocation) {
|
924 | contentRef = hostElm['s-cr'];
|
925 | useNativeShadowDom = supportsShadowDom && (cmpMeta.$flags$ & 1 ) !== 0;
|
926 |
|
927 | checkSlotRelocate = checkSlotFallbackVisibility = false;
|
928 | }
|
929 |
|
930 | patch(oldVNode, renderFnResults);
|
931 | if (BUILD.slotRelocation) {
|
932 | if (checkSlotRelocate) {
|
933 | relocateSlotContent(renderFnResults.$elm$);
|
934 | for (let i = 0; i < relocateNodes.length; i++) {
|
935 | const relocateNode = relocateNodes[i];
|
936 | if (!relocateNode.nodeToRelocate['s-ol']) {
|
937 |
|
938 |
|
939 | const orgLocationNode = (BUILD.isDebug || BUILD.hydrateServerSide)
|
940 | ? doc.createComment(`org-loc`)
|
941 | : doc.createTextNode('');
|
942 | orgLocationNode['s-nr'] = relocateNode.nodeToRelocate;
|
943 | relocateNode.nodeToRelocate.parentNode.insertBefore((relocateNode.nodeToRelocate['s-ol'] = orgLocationNode), relocateNode.nodeToRelocate);
|
944 | }
|
945 | }
|
946 |
|
947 |
|
948 | plt.$flags$ |= 1 ;
|
949 | for (let i = 0; i < relocateNodes.length; i++) {
|
950 | const relocateNode = relocateNodes[i];
|
951 |
|
952 |
|
953 | const parentNodeRef = relocateNode.slotRefNode.parentNode;
|
954 | let insertBeforeNode = relocateNode.slotRefNode.nextSibling;
|
955 | let orgLocationNode = relocateNode.nodeToRelocate['s-ol'];
|
956 | while (orgLocationNode = orgLocationNode.previousSibling) {
|
957 | let refNode = orgLocationNode['s-nr'];
|
958 | if (refNode && refNode) {
|
959 | if (refNode['s-sn'] === relocateNode.nodeToRelocate['s-sn']) {
|
960 | if (parentNodeRef === refNode.parentNode) {
|
961 | if ((refNode = refNode.nextSibling) && refNode && !refNode['s-nr']) {
|
962 | insertBeforeNode = refNode;
|
963 | break;
|
964 | }
|
965 | }
|
966 | }
|
967 | }
|
968 | }
|
969 | if ((!insertBeforeNode && parentNodeRef !== relocateNode.nodeToRelocate.parentNode) ||
|
970 | (relocateNode.nodeToRelocate.nextSibling !== insertBeforeNode)) {
|
971 |
|
972 |
|
973 |
|
974 | if (relocateNode.nodeToRelocate !== insertBeforeNode) {
|
975 |
|
976 | parentNodeRef.insertBefore(relocateNode.nodeToRelocate, insertBeforeNode);
|
977 | }
|
978 | }
|
979 | }
|
980 |
|
981 |
|
982 | plt.$flags$ &= ~1 ;
|
983 | }
|
984 | if (checkSlotFallbackVisibility) {
|
985 | updateFallbackSlotVisibility(renderFnResults.$elm$);
|
986 | }
|
987 |
|
988 | relocateNodes.length = 0;
|
989 | }
|
990 | };
|
991 |
|
992 | const safeCall = async (instance, method) => {
|
993 | if (instance && instance[method]) {
|
994 | try {
|
995 | await instance[method]();
|
996 | }
|
997 | catch (e) {
|
998 | consoleError(e);
|
999 | }
|
1000 | }
|
1001 | };
|
1002 | const scheduleUpdate = async (elm, hostRef, cmpMeta, isInitialLoad) => {
|
1003 | {
|
1004 | hostRef.$flags$ |= 16 ;
|
1005 | }
|
1006 | const instance = hostRef.$lazyInstance$;
|
1007 | if (isInitialLoad) {
|
1008 | {
|
1009 | await safeCall(instance, 'componentWillLoad');
|
1010 | }
|
1011 | }
|
1012 |
|
1013 |
|
1014 |
|
1015 | {
|
1016 | writeTask(() => updateComponent(elm, hostRef, cmpMeta, instance, isInitialLoad));
|
1017 | }
|
1018 | };
|
1019 | const updateComponent = (elm, hostRef, cmpMeta, instance, isInitialLoad) => {
|
1020 |
|
1021 | {
|
1022 | hostRef.$flags$ &= ~16 ;
|
1023 | }
|
1024 | {
|
1025 | elm['s-lr'] = false;
|
1026 | }
|
1027 | if (isInitialLoad) {
|
1028 |
|
1029 | attachStyles(elm, cmpMeta, hostRef.$modeName$);
|
1030 | }
|
1031 | {
|
1032 | {
|
1033 |
|
1034 |
|
1035 |
|
1036 | hostRef.$flags$ |= 4 ;
|
1037 | try {
|
1038 |
|
1039 |
|
1040 |
|
1041 | renderVdom(elm, hostRef, cmpMeta, (BUILD.allRenderFn) ? instance.render() : (instance.render && instance.render()));
|
1042 | }
|
1043 | catch (e) {
|
1044 | consoleError(e);
|
1045 | }
|
1046 | hostRef.$flags$ &= ~4 ;
|
1047 | }
|
1048 | }
|
1049 | if (cssVarShim) {
|
1050 | cssVarShim.updateHost(elm);
|
1051 | }
|
1052 |
|
1053 | {
|
1054 | elm['s-lr'] = true;
|
1055 | }
|
1056 | {
|
1057 | hostRef.$flags$ |= 2 ;
|
1058 | }
|
1059 | if (elm['s-rc'].length > 0) {
|
1060 |
|
1061 |
|
1062 |
|
1063 | elm['s-rc'].forEach(cb => cb());
|
1064 | elm['s-rc'].length = 0;
|
1065 | }
|
1066 | postUpdateComponent(elm, hostRef);
|
1067 | };
|
1068 | const postUpdateComponent = (elm, hostRef, ancestorsActivelyLoadingChildren) => {
|
1069 | if (!elm['s-al']) {
|
1070 | const instance = hostRef.$lazyInstance$;
|
1071 | const ancestorComponent = hostRef.$ancestorComponent$;
|
1072 | if (!(hostRef.$flags$ & 512 )) {
|
1073 | hostRef.$flags$ |= 512 ;
|
1074 | {
|
1075 |
|
1076 |
|
1077 | elm.classList.add(HYDRATED_CLASS);
|
1078 | }
|
1079 | {
|
1080 | safeCall(instance, 'componentDidLoad');
|
1081 | }
|
1082 | {
|
1083 | hostRef.$onReadyResolve$(elm);
|
1084 | }
|
1085 | if (!ancestorComponent) {
|
1086 |
|
1087 |
|
1088 | doc.documentElement.classList.add(HYDRATED_CLASS);
|
1089 | {
|
1090 | setTimeout(() => plt.$flags$ |= 2 , 999);
|
1091 | }
|
1092 | }
|
1093 | }
|
1094 | else {
|
1095 | {
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 | safeCall(instance, 'componentDidUpdate');
|
1101 | }
|
1102 | }
|
1103 |
|
1104 |
|
1105 | if (ancestorComponent) {
|
1106 |
|
1107 |
|
1108 |
|
1109 | if (ancestorsActivelyLoadingChildren = ancestorComponent['s-al']) {
|
1110 |
|
1111 | ancestorsActivelyLoadingChildren.delete(elm);
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 | if (ancestorsActivelyLoadingChildren.size === 0) {
|
1117 | ancestorComponent['s-al'] = undefined;
|
1118 | ancestorComponent['s-init']();
|
1119 | }
|
1120 | }
|
1121 | hostRef.$ancestorComponent$ = undefined;
|
1122 | }
|
1123 |
|
1124 |
|
1125 |
|
1126 | }
|
1127 | };
|
1128 |
|
1129 | const disconnectedCallback = (elm) => {
|
1130 | if ((plt.$flags$ & 1 ) === 0) {
|
1131 | const hostRef = getHostRef(elm);
|
1132 |
|
1133 | if (cssVarShim) {
|
1134 | cssVarShim.removeHost(elm);
|
1135 | }
|
1136 | const instance = hostRef.$lazyInstance$;
|
1137 | {
|
1138 | safeCall(instance, 'disconnectedCallback');
|
1139 | }
|
1140 | {
|
1141 | safeCall(instance, 'componentDidUnload');
|
1142 | }
|
1143 | }
|
1144 | };
|
1145 |
|
1146 | const parsePropertyValue = (propValue, propType) => {
|
1147 |
|
1148 | if (propValue != null && !isComplexType(propValue)) {
|
1149 | if (propType & 4 ) {
|
1150 |
|
1151 |
|
1152 | return (propValue === 'false' ? false : propValue === '' || !!propValue);
|
1153 | }
|
1154 | if (propType & 2 ) {
|
1155 |
|
1156 | return parseFloat(propValue);
|
1157 | }
|
1158 | if (propType & 1 ) {
|
1159 |
|
1160 |
|
1161 | return String(propValue);
|
1162 | }
|
1163 |
|
1164 | return propValue;
|
1165 | }
|
1166 |
|
1167 |
|
1168 | return propValue;
|
1169 | };
|
1170 |
|
1171 | const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
1172 | const setValue = (ref, propName, newVal, cmpMeta) => {
|
1173 |
|
1174 | const hostRef = getHostRef(ref);
|
1175 | const elm = hostRef.$hostElement$;
|
1176 | const oldVal = hostRef.$instanceValues$.get(propName);
|
1177 | const flags = hostRef.$flags$;
|
1178 | newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
1179 | if (newVal !== oldVal && (!(flags & 8 /* isConstructingInstance */) || oldVal === undefined)) {
|
1180 |
|
1181 |
|
1182 | hostRef.$instanceValues$.set(propName, newVal);
|
1183 | if (hostRef.$lazyInstance$) {
|
1184 |
|
1185 | if (cmpMeta.$watchers$ &&
|
1186 | (flags & (1 | 8 )) === 1 ) {
|
1187 | const watchMethods = cmpMeta.$watchers$[propName];
|
1188 | if (watchMethods) {
|
1189 |
|
1190 | watchMethods.forEach(watchMethodName => {
|
1191 | try {
|
1192 |
|
1193 | (BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm)[watchMethodName].call((BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm), newVal, oldVal, propName);
|
1194 | }
|
1195 | catch (e) {
|
1196 | consoleError(e);
|
1197 | }
|
1198 | });
|
1199 | }
|
1200 | }
|
1201 | if ((flags & (4 | 2 | 16 )) === 2 ) {
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 | scheduleUpdate(elm, hostRef, cmpMeta, false);
|
1207 | }
|
1208 | }
|
1209 | }
|
1210 | };
|
1211 |
|
1212 | const proxyComponent = (Cstr, cmpMeta, flags) => {
|
1213 | if (cmpMeta.$members$) {
|
1214 | if (Cstr.watchers) {
|
1215 | cmpMeta.$watchers$ = Cstr.watchers;
|
1216 | }
|
1217 |
|
1218 | const members = Object.entries(cmpMeta.$members$);
|
1219 | const prototype = Cstr.prototype;
|
1220 | members.forEach(([memberName, [memberFlags]]) => {
|
1221 | if ((memberFlags & 31) || (flags & 2 && (memberFlags & 32 ))) {
|
1222 |
|
1223 | Object.defineProperty(prototype, memberName, {
|
1224 | get() {
|
1225 |
|
1226 | return getValue(this, memberName);
|
1227 | },
|
1228 | set(newValue) {
|
1229 |
|
1230 | setValue(this, memberName, newValue, cmpMeta);
|
1231 | },
|
1232 | configurable: true,
|
1233 | enumerable: true
|
1234 | });
|
1235 | }
|
1236 | });
|
1237 | if (flags & 1) {
|
1238 | const attrNameToPropName = new Map();
|
1239 | prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
1240 | const propName = attrNameToPropName.get(attrName);
|
1241 | this[propName] = newValue === null && typeof this[propName] === 'boolean'
|
1242 | ? false
|
1243 | : newValue;
|
1244 | };
|
1245 |
|
1246 |
|
1247 | Cstr.observedAttributes = members
|
1248 | .filter(([_, m]) => m[0] & 15 )
|
1249 | .map(([propName, m]) => {
|
1250 | const attrName = m[1] || propName;
|
1251 | attrNameToPropName.set(attrName, propName);
|
1252 | if (m[0] & 512 ) {
|
1253 | cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
1254 | }
|
1255 | return attrName;
|
1256 | });
|
1257 | }
|
1258 | }
|
1259 | return Cstr;
|
1260 | };
|
1261 |
|
1262 | const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
1263 |
|
1264 | if ((hostRef.$flags$ & 256 ) === 0) {
|
1265 |
|
1266 | hostRef.$flags$ |= 256 ;
|
1267 | {
|
1268 |
|
1269 |
|
1270 |
|
1271 | Cstr = await loadModule(cmpMeta);
|
1272 | if (!Cstr.isProxied) {
|
1273 |
|
1274 |
|
1275 |
|
1276 | {
|
1277 | cmpMeta.$watchers$ = Cstr.watchers;
|
1278 | }
|
1279 | proxyComponent(Cstr, cmpMeta, 2 );
|
1280 | Cstr.isProxied = true;
|
1281 | }
|
1282 |
|
1283 |
|
1284 |
|
1285 | {
|
1286 | hostRef.$flags$ |= 8 ;
|
1287 | }
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 | try {
|
1293 | new Cstr(hostRef);
|
1294 | }
|
1295 | catch (e) {
|
1296 | consoleError(e);
|
1297 | }
|
1298 | {
|
1299 | hostRef.$flags$ &= ~8 ;
|
1300 | }
|
1301 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1302 | }
|
1303 | if (!Cstr.isStyleRegistered && Cstr.style) {
|
1304 |
|
1305 | let style = Cstr.style;
|
1306 | let scopeId = getScopeId(cmpMeta.$tagName$);
|
1307 | registerStyle(scopeId, style);
|
1308 | Cstr.isStyleRegistered = true;
|
1309 | }
|
1310 | }
|
1311 |
|
1312 | const ancestorComponent = hostRef.$ancestorComponent$;
|
1313 | if (ancestorComponent && !ancestorComponent['s-lr'] && ancestorComponent['s-rc']) {
|
1314 |
|
1315 |
|
1316 |
|
1317 | ancestorComponent['s-rc'].push(() =>
|
1318 |
|
1319 |
|
1320 |
|
1321 | initializeComponent(elm, hostRef, cmpMeta));
|
1322 | }
|
1323 | else {
|
1324 | scheduleUpdate(elm, hostRef, cmpMeta, true);
|
1325 | }
|
1326 | };
|
1327 |
|
1328 | const fireConnectedCallback = (instance) => {
|
1329 | {
|
1330 | safeCall(instance, 'connectedCallback');
|
1331 | }
|
1332 | };
|
1333 | const connectedCallback = (elm, cmpMeta) => {
|
1334 | if ((plt.$flags$ & 1 ) === 0) {
|
1335 |
|
1336 | const hostRef = getHostRef(elm);
|
1337 | if (!(hostRef.$flags$ & 1 )) {
|
1338 |
|
1339 | hostRef.$flags$ |= 1 ;
|
1340 | let hostId;
|
1341 | if (!hostId) {
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 | if (cmpMeta.$flags$ & 4 ||
|
1347 | (BUILD.shadowDom && cmpMeta.$flags$ & 8 )) {
|
1348 | setContentReference(elm);
|
1349 | }
|
1350 | }
|
1351 | {
|
1352 |
|
1353 |
|
1354 | let ancestorComponent = elm;
|
1355 | while ((ancestorComponent = (ancestorComponent.parentNode || ancestorComponent.host))) {
|
1356 |
|
1357 |
|
1358 | if ((ancestorComponent['s-init'] && !ancestorComponent['s-lr']) || (BUILD.hydrateClientSide && ancestorComponent.nodeType === 1 && ancestorComponent.hasAttribute('s-id'))) {
|
1359 |
|
1360 |
|
1361 | hostRef.$ancestorComponent$ = ancestorComponent;
|
1362 |
|
1363 |
|
1364 | (ancestorComponent['s-al'] = ancestorComponent['s-al'] || new Set()).add(elm);
|
1365 | break;
|
1366 | }
|
1367 | }
|
1368 | }
|
1369 |
|
1370 |
|
1371 | if (cmpMeta.$members$) {
|
1372 | Object.entries(cmpMeta.$members$).forEach(([memberName, [memberFlags]]) => {
|
1373 | if (memberFlags & 31 && elm.hasOwnProperty(memberName)) {
|
1374 | const value = elm[memberName];
|
1375 | delete elm[memberName];
|
1376 | elm[memberName] = value;
|
1377 | }
|
1378 | });
|
1379 | }
|
1380 | {
|
1381 | initializeComponent(elm, hostRef, cmpMeta);
|
1382 | }
|
1383 | }
|
1384 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1385 | }
|
1386 | };
|
1387 | const setContentReference = (elm, contentRefElm) => {
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 | let crName;
|
1395 | {
|
1396 | crName = '';
|
1397 | }
|
1398 | contentRefElm = elm['s-cr'] = doc.createComment(crName);
|
1399 | contentRefElm['s-cn'] = true;
|
1400 | elm.insertBefore(contentRefElm, elm.firstChild);
|
1401 | };
|
1402 |
|
1403 | const bootstrapLazy = (lazyBundles, options = {}) => {
|
1404 | const cmpTags = [];
|
1405 | const exclude = options.exclude || [];
|
1406 | const head = doc.head;
|
1407 | const customElements = win.customElements;
|
1408 | const y = head.querySelector('meta[charset]');
|
1409 | const visibilityStyle = doc.createElement('style');
|
1410 | Object.assign(plt, options);
|
1411 | plt.$resourcesUrl$ = new URL(options.resourcesUrl || '/', win.location.href).href;
|
1412 | if (options.syncQueue) {
|
1413 | plt.$flags$ |= 4 ;
|
1414 | }
|
1415 | lazyBundles.forEach(lazyBundle => lazyBundle[1].forEach(compactMeta => {
|
1416 | const cmpMeta = {
|
1417 | $flags$: compactMeta[0],
|
1418 | $tagName$: compactMeta[1],
|
1419 | $members$: compactMeta[2],
|
1420 | $listeners$: compactMeta[3],
|
1421 | };
|
1422 | {
|
1423 | cmpMeta.$attrsToReflect$ = [];
|
1424 | }
|
1425 | {
|
1426 | cmpMeta.$watchers$ = {};
|
1427 | }
|
1428 | const tagName = cmpMeta.$tagName$;
|
1429 | const HostElement = class extends HTMLElement {
|
1430 |
|
1431 | constructor(self) {
|
1432 |
|
1433 | super(self);
|
1434 | self = this;
|
1435 | {
|
1436 | this['s-lr'] = false;
|
1437 | this['s-rc'] = [];
|
1438 | }
|
1439 | registerHost(self);
|
1440 | }
|
1441 | connectedCallback() {
|
1442 | connectedCallback(this, cmpMeta);
|
1443 | }
|
1444 | disconnectedCallback() {
|
1445 | disconnectedCallback(this);
|
1446 | }
|
1447 | 's-init'() {
|
1448 | const hostRef = getHostRef(this);
|
1449 | if (hostRef.$lazyInstance$) {
|
1450 | postUpdateComponent(this, hostRef);
|
1451 | }
|
1452 | }
|
1453 | 's-hmr'(hmrVersionId) {
|
1454 | }
|
1455 | forceUpdate() {
|
1456 | {
|
1457 | const hostRef = getHostRef(this);
|
1458 | scheduleUpdate(this, hostRef, cmpMeta, false);
|
1459 | }
|
1460 | }
|
1461 | componentOnReady() {
|
1462 | return getHostRef(this).$onReadyPromise$;
|
1463 | }
|
1464 | };
|
1465 | cmpMeta.$lazyBundleIds$ = lazyBundle[0];
|
1466 | if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
1467 | cmpTags.push(tagName);
|
1468 | customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 ));
|
1469 | }
|
1470 | }));
|
1471 |
|
1472 | visibilityStyle.innerHTML = cmpTags + '{visibility:hidden}.hydrated{visibility:inherit}';
|
1473 | visibilityStyle.setAttribute('data-styles', '');
|
1474 | head.insertBefore(visibilityStyle, y ? y.nextSibling : head.firstChild);
|
1475 | };
|
1476 |
|
1477 | const getAssetPath = (path) => {
|
1478 | const assetUrl = new URL(path, plt.$resourcesUrl$);
|
1479 | return (assetUrl.origin !== win.location.origin)
|
1480 | ? assetUrl.href
|
1481 | : assetUrl.pathname;
|
1482 | };
|
1483 |
|
1484 | const getContext = (_elm, context) => {
|
1485 | if (context in Context) {
|
1486 | return Context[context];
|
1487 | }
|
1488 | else if (context === 'window') {
|
1489 | return win;
|
1490 | }
|
1491 | else if (context === 'document') {
|
1492 | return doc;
|
1493 | }
|
1494 | else if (context === 'isServer' || context === 'isPrerender') {
|
1495 | return !!BUILD.hydrateServerSide;
|
1496 | }
|
1497 | else if (context === 'isClient') {
|
1498 | return !BUILD.hydrateServerSide;
|
1499 | }
|
1500 | else if (context === 'resourcesUrl' || context === 'publicPath') {
|
1501 | return getAssetPath('.');
|
1502 | }
|
1503 | else if (context === 'queue') {
|
1504 | return {
|
1505 | write: writeTask,
|
1506 | read: readTask,
|
1507 | tick: {
|
1508 | then(cb) {
|
1509 | return nextTick(cb);
|
1510 | }
|
1511 | }
|
1512 | };
|
1513 | }
|
1514 | return undefined;
|
1515 | };
|
1516 |
|
1517 | const getElement = (ref) => getHostRef(ref).$hostElement$;
|
1518 |
|
1519 | export { patchEsm as a, bootstrapLazy as b, getContext as c, getElement as g, h, patchBrowser as p, registerInstance as r };
|