1 | 'use strict';
|
2 |
|
3 | function _interopNamespace(e) {
|
4 | if (e && e.__esModule) return e;
|
5 | var n = Object.create(null);
|
6 | if (e) {
|
7 | Object.keys(e).forEach(function (k) {
|
8 | if (k !== 'default') {
|
9 | var d = Object.getOwnPropertyDescriptor(e, k);
|
10 | Object.defineProperty(n, k, d.get ? d : {
|
11 | enumerable: true,
|
12 | get: function () {
|
13 | return e[k];
|
14 | }
|
15 | });
|
16 | }
|
17 | });
|
18 | }
|
19 | n['default'] = e;
|
20 | return Object.freeze(n);
|
21 | }
|
22 |
|
23 | const NAMESPACE = 'ionic';
|
24 |
|
25 | let scopeId;
|
26 | let contentRef;
|
27 | let hostTagName;
|
28 | let useNativeShadowDom = false;
|
29 | let checkSlotFallbackVisibility = false;
|
30 | let checkSlotRelocate = false;
|
31 | let isSvgMode = false;
|
32 | let queuePending = false;
|
33 | const win = typeof window !== 'undefined' ? window : {};
|
34 | const CSS = win.CSS ;
|
35 | const doc = win.document || { head: {} };
|
36 | const plt = {
|
37 | $flags$: 0,
|
38 | $resourcesUrl$: '',
|
39 | jmp: h => h(),
|
40 | raf: h => requestAnimationFrame(h),
|
41 | ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
42 | rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
43 | ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
44 | };
|
45 | const supportsShadow = (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() ;
|
46 | const promiseResolve = (v) => Promise.resolve(v);
|
47 | const supportsConstructibleStylesheets = (() => {
|
48 | try {
|
49 | new CSSStyleSheet();
|
50 | return typeof (new CSSStyleSheet()).replace === 'function';
|
51 | }
|
52 | catch (e) { }
|
53 | return false;
|
54 | })()
|
55 | ;
|
56 | const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
57 | if (listeners) {
|
58 | listeners.map(([flags, name, method]) => {
|
59 | const target = getHostListenerTarget(elm, flags) ;
|
60 | const handler = hostListenerProxy(hostRef, method);
|
61 | const opts = hostListenerOpts(flags);
|
62 | plt.ael(target, name, handler, opts);
|
63 | (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
64 | });
|
65 | }
|
66 | };
|
67 | const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
68 | try {
|
69 | {
|
70 | if (hostRef.$flags$ & 256 ) {
|
71 |
|
72 | hostRef.$lazyInstance$[methodName](ev);
|
73 | }
|
74 | else {
|
75 | (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
76 | }
|
77 | }
|
78 | }
|
79 | catch (e) {
|
80 | consoleError(e);
|
81 | }
|
82 | };
|
83 | const getHostListenerTarget = (elm, flags) => {
|
84 | if (flags & 4 )
|
85 | return doc;
|
86 | if (flags & 8 )
|
87 | return win;
|
88 | if (flags & 16 )
|
89 | return doc.body;
|
90 | return elm;
|
91 | };
|
92 |
|
93 | const hostListenerOpts = (flags) => (flags & 2 ) !== 0;
|
94 | const CONTENT_REF_ID = 'r';
|
95 | const ORG_LOCATION_ID = 'o';
|
96 | const SLOT_NODE_ID = 's';
|
97 | const TEXT_NODE_ID = 't';
|
98 | const HYDRATE_ID = 's-id';
|
99 | const HYDRATED_STYLE_ID = 'sty-id';
|
100 | const HYDRATE_CHILD_ID = 'c-id';
|
101 | const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
102 | const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
103 | const createTime = (fnName, tagName = '') => {
|
104 | {
|
105 | return () => {
|
106 | return;
|
107 | };
|
108 | }
|
109 | };
|
110 | const uniqueTime = (key, measureText) => {
|
111 | {
|
112 | return () => {
|
113 | return;
|
114 | };
|
115 | }
|
116 | };
|
117 | const rootAppliedStyles = new WeakMap();
|
118 | const registerStyle = (scopeId, cssText, allowCS) => {
|
119 | let style = styles.get(scopeId);
|
120 | if (supportsConstructibleStylesheets && allowCS) {
|
121 | style = (style || new CSSStyleSheet());
|
122 | style.replace(cssText);
|
123 | }
|
124 | else {
|
125 | style = cssText;
|
126 | }
|
127 | styles.set(scopeId, style);
|
128 | };
|
129 | const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
130 | let scopeId = getScopeId(cmpMeta, mode);
|
131 | let style = styles.get(scopeId);
|
132 |
|
133 |
|
134 | styleContainerNode = styleContainerNode.nodeType === 11 ? styleContainerNode : doc;
|
135 | if (style) {
|
136 | if (typeof style === 'string') {
|
137 | styleContainerNode = styleContainerNode.head || styleContainerNode;
|
138 | let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
139 | let styleElm;
|
140 | if (!appliedStyles) {
|
141 | rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
142 | }
|
143 | if (!appliedStyles.has(scopeId)) {
|
144 | if (styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
145 |
|
146 | styleElm.innerHTML = style;
|
147 | }
|
148 | else {
|
149 | if (plt.$cssShim$) {
|
150 | styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 ));
|
151 | const newScopeId = styleElm['s-sc'];
|
152 | if (newScopeId) {
|
153 | scopeId = newScopeId;
|
154 |
|
155 |
|
156 |
|
157 | appliedStyles = null;
|
158 | }
|
159 | }
|
160 | else {
|
161 | styleElm = doc.createElement('style');
|
162 | styleElm.innerHTML = style;
|
163 | }
|
164 | styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
165 | }
|
166 | if (appliedStyles) {
|
167 | appliedStyles.add(scopeId);
|
168 | }
|
169 | }
|
170 | }
|
171 | else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
172 | styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
173 | }
|
174 | }
|
175 | return scopeId;
|
176 | };
|
177 | const attachStyles = (hostRef) => {
|
178 | const cmpMeta = hostRef.$cmpMeta$;
|
179 | const elm = hostRef.$hostElement$;
|
180 | const flags = cmpMeta.$flags$;
|
181 | const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
182 | const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
183 | if (flags & 10 ) {
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 | elm['s-sc'] = scopeId;
|
192 | elm.classList.add(scopeId + '-h');
|
193 | if (flags & 2 ) {
|
194 | elm.classList.add(scopeId + '-s');
|
195 | }
|
196 | }
|
197 | endAttachStyles();
|
198 | };
|
199 | const getScopeId = (cmp, mode) => 'sc-' + (mode && cmp.$flags$ & 32 ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
|
200 | const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
201 |
|
202 | const computeMode = (elm) => modeResolutionChain.map(h => h(elm)).find(m => !!m);
|
203 |
|
204 | const setMode = (handler) => modeResolutionChain.push(handler);
|
205 | const getMode = (ref) => getHostRef(ref).$modeName$;
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | const EMPTY_OBJ = {};
|
214 |
|
215 |
|
216 |
|
217 | const SVG_NS = 'http://www.w3.org/2000/svg';
|
218 | const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
219 | const isDef = (v) => v != null;
|
220 | const isComplexType = (o) => {
|
221 |
|
222 | o = typeof o;
|
223 | return o === 'object' || o === 'function';
|
224 | };
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 | const h = (nodeName, vnodeData, ...children) => {
|
237 | let child = null;
|
238 | let key = null;
|
239 | let slotName = null;
|
240 | let simple = false;
|
241 | let lastSimple = false;
|
242 | let vNodeChildren = [];
|
243 | const walk = (c) => {
|
244 | for (let i = 0; i < c.length; i++) {
|
245 | child = c[i];
|
246 | if (Array.isArray(child)) {
|
247 | walk(child);
|
248 | }
|
249 | else if (child != null && typeof child !== 'boolean') {
|
250 | if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
|
251 | child = String(child);
|
252 | }
|
253 | if (simple && lastSimple) {
|
254 |
|
255 | vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
256 | }
|
257 | else {
|
258 |
|
259 | vNodeChildren.push(simple ? newVNode(null, child) : child);
|
260 | }
|
261 | lastSimple = simple;
|
262 | }
|
263 | }
|
264 | };
|
265 | walk(children);
|
266 | if (vnodeData) {
|
267 |
|
268 | if (vnodeData.key) {
|
269 | key = vnodeData.key;
|
270 | }
|
271 | if (vnodeData.name) {
|
272 | slotName = vnodeData.name;
|
273 | }
|
274 | {
|
275 | const classData = vnodeData.className || vnodeData.class;
|
276 | if (classData) {
|
277 | vnodeData.class =
|
278 | typeof classData !== 'object'
|
279 | ? classData
|
280 | : Object.keys(classData)
|
281 | .filter(k => classData[k])
|
282 | .join(' ');
|
283 | }
|
284 | }
|
285 | }
|
286 | if (typeof nodeName === 'function') {
|
287 |
|
288 | return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
289 | }
|
290 | const vnode = newVNode(nodeName, null);
|
291 | vnode.$attrs$ = vnodeData;
|
292 | if (vNodeChildren.length > 0) {
|
293 | vnode.$children$ = vNodeChildren;
|
294 | }
|
295 | {
|
296 | vnode.$key$ = key;
|
297 | }
|
298 | {
|
299 | vnode.$name$ = slotName;
|
300 | }
|
301 | return vnode;
|
302 | };
|
303 | const newVNode = (tag, text) => {
|
304 | const vnode = {
|
305 | $flags$: 0,
|
306 | $tag$: tag,
|
307 | $text$: text,
|
308 | $elm$: null,
|
309 | $children$: null,
|
310 | };
|
311 | {
|
312 | vnode.$attrs$ = null;
|
313 | }
|
314 | {
|
315 | vnode.$key$ = null;
|
316 | }
|
317 | {
|
318 | vnode.$name$ = null;
|
319 | }
|
320 | return vnode;
|
321 | };
|
322 | const Host = {};
|
323 | const isHost = (node) => node && node.$tag$ === Host;
|
324 | const vdomFnUtils = {
|
325 | forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
326 | map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
327 | };
|
328 | const convertToPublic = (node) => ({
|
329 | vattrs: node.$attrs$,
|
330 | vchildren: node.$children$,
|
331 | vkey: node.$key$,
|
332 | vname: node.$name$,
|
333 | vtag: node.$tag$,
|
334 | vtext: node.$text$,
|
335 | });
|
336 | const convertToPrivate = (node) => {
|
337 | if (typeof node.vtag === 'function') {
|
338 | const vnodeData = Object.assign({}, node.vattrs);
|
339 | if (node.vkey) {
|
340 | vnodeData.key = node.vkey;
|
341 | }
|
342 | if (node.vname) {
|
343 | vnodeData.name = node.vname;
|
344 | }
|
345 | return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
346 | }
|
347 | const vnode = newVNode(node.vtag, node.vtext);
|
348 | vnode.$attrs$ = node.vattrs;
|
349 | vnode.$children$ = node.vchildren;
|
350 | vnode.$key$ = node.vkey;
|
351 | vnode.$name$ = node.vname;
|
352 | return vnode;
|
353 | };
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 | const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
363 | if (oldValue !== newValue) {
|
364 | let isProp = isMemberInElement(elm, memberName);
|
365 | let ln = memberName.toLowerCase();
|
366 | if (memberName === 'class') {
|
367 | const classList = elm.classList;
|
368 | const oldClasses = parseClassList(oldValue);
|
369 | const newClasses = parseClassList(newValue);
|
370 | classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
|
371 | classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
|
372 | }
|
373 | else if (memberName === 'style') {
|
374 |
|
375 | {
|
376 | for (const prop in oldValue) {
|
377 | if (!newValue || newValue[prop] == null) {
|
378 | if (prop.includes('-')) {
|
379 | elm.style.removeProperty(prop);
|
380 | }
|
381 | else {
|
382 | elm.style[prop] = '';
|
383 | }
|
384 | }
|
385 | }
|
386 | }
|
387 | for (const prop in newValue) {
|
388 | if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
389 | if (prop.includes('-')) {
|
390 | elm.style.setProperty(prop, newValue[prop]);
|
391 | }
|
392 | else {
|
393 | elm.style[prop] = newValue[prop];
|
394 | }
|
395 | }
|
396 | }
|
397 | }
|
398 | else if (memberName === 'key')
|
399 | ;
|
400 | else if (memberName === 'ref') {
|
401 |
|
402 | if (newValue) {
|
403 | newValue(elm);
|
404 | }
|
405 | }
|
406 | else if ((!isProp ) && memberName[0] === 'o' && memberName[1] === 'n') {
|
407 |
|
408 |
|
409 |
|
410 |
|
411 | if (memberName[2] === '-') {
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 | memberName = memberName.slice(3);
|
420 | }
|
421 | else if (isMemberInElement(win, ln)) {
|
422 |
|
423 |
|
424 |
|
425 |
|
426 | memberName = ln.slice(2);
|
427 | }
|
428 | else {
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 | memberName = ln[2] + memberName.slice(3);
|
435 | }
|
436 | if (oldValue) {
|
437 | plt.rel(elm, memberName, oldValue, false);
|
438 | }
|
439 | if (newValue) {
|
440 | plt.ael(elm, memberName, newValue, false);
|
441 | }
|
442 | }
|
443 | else {
|
444 |
|
445 | const isComplex = isComplexType(newValue);
|
446 | if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
447 | try {
|
448 | if (!elm.tagName.includes('-')) {
|
449 | let n = newValue == null ? '' : newValue;
|
450 |
|
451 | if (memberName === 'list') {
|
452 | isProp = false;
|
453 |
|
454 | }
|
455 | else if (oldValue == null || elm[memberName] != n) {
|
456 | elm[memberName] = n;
|
457 | }
|
458 | }
|
459 | else {
|
460 | elm[memberName] = newValue;
|
461 | }
|
462 | }
|
463 | catch (e) { }
|
464 | }
|
465 | |
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 | let xlink = false;
|
473 | {
|
474 | if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
475 | memberName = ln;
|
476 | xlink = true;
|
477 | }
|
478 | }
|
479 | if (newValue == null || newValue === false) {
|
480 | if (newValue !== false || elm.getAttribute(memberName) === '') {
|
481 | if (xlink) {
|
482 | elm.removeAttributeNS(XLINK_NS, memberName);
|
483 | }
|
484 | else {
|
485 | elm.removeAttribute(memberName);
|
486 | }
|
487 | }
|
488 | }
|
489 | else if ((!isProp || flags & 4 || isSvg) && !isComplex) {
|
490 | newValue = newValue === true ? '' : newValue;
|
491 | if (xlink) {
|
492 | elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
493 | }
|
494 | else {
|
495 | elm.setAttribute(memberName, newValue);
|
496 | }
|
497 | }
|
498 | }
|
499 | }
|
500 | };
|
501 | const parseClassListRegex = /\s/;
|
502 | const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
503 | const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
504 |
|
505 |
|
506 |
|
507 | const elm = newVnode.$elm$.nodeType === 11 && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
|
508 | const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
509 | const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
510 | {
|
511 |
|
512 | for (memberName in oldVnodeAttrs) {
|
513 | if (!(memberName in newVnodeAttrs)) {
|
514 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
515 | }
|
516 | }
|
517 | }
|
518 |
|
519 | for (memberName in newVnodeAttrs) {
|
520 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
521 | }
|
522 | };
|
523 | const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
524 |
|
525 | let newVNode = newParentVNode.$children$[childIndex];
|
526 | let i = 0;
|
527 | let elm;
|
528 | let childNode;
|
529 | let oldVNode;
|
530 | if (!useNativeShadowDom) {
|
531 |
|
532 | checkSlotRelocate = true;
|
533 | if (newVNode.$tag$ === 'slot') {
|
534 | if (scopeId) {
|
535 |
|
536 | parentElm.classList.add(scopeId + '-s');
|
537 | }
|
538 | newVNode.$flags$ |= newVNode.$children$
|
539 | ?
|
540 | 2
|
541 | :
|
542 | 1 ;
|
543 | }
|
544 | }
|
545 | if (newVNode.$text$ !== null) {
|
546 |
|
547 | elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
548 | }
|
549 | else if (newVNode.$flags$ & 1 ) {
|
550 |
|
551 | elm = newVNode.$elm$ = doc.createTextNode('');
|
552 | }
|
553 | else {
|
554 | if (!isSvgMode) {
|
555 | isSvgMode = newVNode.$tag$ === 'svg';
|
556 | }
|
557 |
|
558 | elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 ? 'slot-fb' : newVNode.$tag$)
|
559 | );
|
560 | if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
561 | isSvgMode = false;
|
562 | }
|
563 |
|
564 | {
|
565 | updateElement(null, newVNode, isSvgMode);
|
566 | }
|
567 | if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
568 |
|
569 |
|
570 | elm.classList.add((elm['s-si'] = scopeId));
|
571 | }
|
572 | if (newVNode.$children$) {
|
573 | for (i = 0; i < newVNode.$children$.length; ++i) {
|
574 |
|
575 | childNode = createElm(oldParentVNode, newVNode, i, elm);
|
576 |
|
577 | if (childNode) {
|
578 |
|
579 | elm.appendChild(childNode);
|
580 | }
|
581 | }
|
582 | }
|
583 | {
|
584 | if (newVNode.$tag$ === 'svg') {
|
585 |
|
586 | isSvgMode = false;
|
587 | }
|
588 | else if (elm.tagName === 'foreignObject') {
|
589 |
|
590 | isSvgMode = true;
|
591 | }
|
592 | }
|
593 | }
|
594 | {
|
595 | elm['s-hn'] = hostTagName;
|
596 | if (newVNode.$flags$ & (2 | 1 )) {
|
597 |
|
598 | elm['s-sr'] = true;
|
599 |
|
600 | elm['s-cr'] = contentRef;
|
601 |
|
602 | elm['s-sn'] = newVNode.$name$ || '';
|
603 |
|
604 | oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
605 | if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
606 |
|
607 |
|
608 | putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
609 | }
|
610 | }
|
611 | }
|
612 | return elm;
|
613 | };
|
614 | const putBackInOriginalLocation = (parentElm, recursive) => {
|
615 | plt.$flags$ |= 1 ;
|
616 | const oldSlotChildNodes = parentElm.childNodes;
|
617 | for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
618 | const childNode = oldSlotChildNodes[i];
|
619 | if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
620 |
|
621 |
|
622 |
|
623 |
|
624 | parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
625 |
|
626 |
|
627 |
|
628 | childNode['s-ol'].remove();
|
629 | childNode['s-ol'] = undefined;
|
630 | checkSlotRelocate = true;
|
631 | }
|
632 | if (recursive) {
|
633 | putBackInOriginalLocation(childNode, recursive);
|
634 | }
|
635 | }
|
636 | plt.$flags$ &= ~1 ;
|
637 | };
|
638 | const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
639 | let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
640 | let childNode;
|
641 | if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
642 | containerElm = containerElm.shadowRoot;
|
643 | }
|
644 | for (; startIdx <= endIdx; ++startIdx) {
|
645 | if (vnodes[startIdx]) {
|
646 | childNode = createElm(null, parentVNode, startIdx, parentElm);
|
647 | if (childNode) {
|
648 | vnodes[startIdx].$elm$ = childNode;
|
649 | containerElm.insertBefore(childNode, referenceNode(before) );
|
650 | }
|
651 | }
|
652 | }
|
653 | };
|
654 | const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
655 | for (; startIdx <= endIdx; ++startIdx) {
|
656 | if ((vnode = vnodes[startIdx])) {
|
657 | elm = vnode.$elm$;
|
658 | callNodeRefs(vnode);
|
659 | {
|
660 |
|
661 |
|
662 | checkSlotFallbackVisibility = true;
|
663 | if (elm['s-ol']) {
|
664 |
|
665 | elm['s-ol'].remove();
|
666 | }
|
667 | else {
|
668 |
|
669 |
|
670 | putBackInOriginalLocation(elm, true);
|
671 | }
|
672 | }
|
673 |
|
674 | elm.remove();
|
675 | }
|
676 | }
|
677 | };
|
678 | const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
679 | let oldStartIdx = 0;
|
680 | let newStartIdx = 0;
|
681 | let idxInOld = 0;
|
682 | let i = 0;
|
683 | let oldEndIdx = oldCh.length - 1;
|
684 | let oldStartVnode = oldCh[0];
|
685 | let oldEndVnode = oldCh[oldEndIdx];
|
686 | let newEndIdx = newCh.length - 1;
|
687 | let newStartVnode = newCh[0];
|
688 | let newEndVnode = newCh[newEndIdx];
|
689 | let node;
|
690 | let elmToMove;
|
691 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
692 | if (oldStartVnode == null) {
|
693 |
|
694 | oldStartVnode = oldCh[++oldStartIdx];
|
695 | }
|
696 | else if (oldEndVnode == null) {
|
697 | oldEndVnode = oldCh[--oldEndIdx];
|
698 | }
|
699 | else if (newStartVnode == null) {
|
700 | newStartVnode = newCh[++newStartIdx];
|
701 | }
|
702 | else if (newEndVnode == null) {
|
703 | newEndVnode = newCh[--newEndIdx];
|
704 | }
|
705 | else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
706 | patch(oldStartVnode, newStartVnode);
|
707 | oldStartVnode = oldCh[++oldStartIdx];
|
708 | newStartVnode = newCh[++newStartIdx];
|
709 | }
|
710 | else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
711 | patch(oldEndVnode, newEndVnode);
|
712 | oldEndVnode = oldCh[--oldEndIdx];
|
713 | newEndVnode = newCh[--newEndIdx];
|
714 | }
|
715 | else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
716 |
|
717 | if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
718 | putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
719 | }
|
720 | patch(oldStartVnode, newEndVnode);
|
721 | parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
722 | oldStartVnode = oldCh[++oldStartIdx];
|
723 | newEndVnode = newCh[--newEndIdx];
|
724 | }
|
725 | else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
726 |
|
727 | if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
728 | putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
729 | }
|
730 | patch(oldEndVnode, newStartVnode);
|
731 | parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
732 | oldEndVnode = oldCh[--oldEndIdx];
|
733 | newStartVnode = newCh[++newStartIdx];
|
734 | }
|
735 | else {
|
736 |
|
737 | idxInOld = -1;
|
738 | {
|
739 | for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
740 | if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
741 | idxInOld = i;
|
742 | break;
|
743 | }
|
744 | }
|
745 | }
|
746 | if (idxInOld >= 0) {
|
747 | elmToMove = oldCh[idxInOld];
|
748 | if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
749 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
750 | }
|
751 | else {
|
752 | patch(elmToMove, newStartVnode);
|
753 | oldCh[idxInOld] = undefined;
|
754 | node = elmToMove.$elm$;
|
755 | }
|
756 | newStartVnode = newCh[++newStartIdx];
|
757 | }
|
758 | else {
|
759 |
|
760 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
761 | newStartVnode = newCh[++newStartIdx];
|
762 | }
|
763 | if (node) {
|
764 | {
|
765 | parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
766 | }
|
767 | }
|
768 | }
|
769 | }
|
770 | if (oldStartIdx > oldEndIdx) {
|
771 | addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
772 | }
|
773 | else if (newStartIdx > newEndIdx) {
|
774 | removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
775 | }
|
776 | };
|
777 | const isSameVnode = (vnode1, vnode2) => {
|
778 |
|
779 |
|
780 | if (vnode1.$tag$ === vnode2.$tag$) {
|
781 | if (vnode1.$tag$ === 'slot') {
|
782 | return vnode1.$name$ === vnode2.$name$;
|
783 | }
|
784 | {
|
785 | return vnode1.$key$ === vnode2.$key$;
|
786 | }
|
787 | }
|
788 | return false;
|
789 | };
|
790 | const referenceNode = (node) => {
|
791 |
|
792 |
|
793 |
|
794 |
|
795 | return (node && node['s-ol']) || node;
|
796 | };
|
797 | const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
798 | const patch = (oldVNode, newVNode) => {
|
799 | const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
800 | const oldChildren = oldVNode.$children$;
|
801 | const newChildren = newVNode.$children$;
|
802 | const tag = newVNode.$tag$;
|
803 | const text = newVNode.$text$;
|
804 | let defaultHolder;
|
805 | if (text === null) {
|
806 | {
|
807 |
|
808 |
|
809 | isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
810 | }
|
811 |
|
812 | {
|
813 | if (tag === 'slot')
|
814 | ;
|
815 | else {
|
816 |
|
817 |
|
818 |
|
819 | updateElement(oldVNode, newVNode, isSvgMode);
|
820 | }
|
821 | }
|
822 | if (oldChildren !== null && newChildren !== null) {
|
823 |
|
824 | updateChildren(elm, oldChildren, newVNode, newChildren);
|
825 | }
|
826 | else if (newChildren !== null) {
|
827 |
|
828 | if (oldVNode.$text$ !== null) {
|
829 |
|
830 | elm.textContent = '';
|
831 | }
|
832 |
|
833 | addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
834 | }
|
835 | else if (oldChildren !== null) {
|
836 |
|
837 | removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
838 | }
|
839 | if (isSvgMode && tag === 'svg') {
|
840 | isSvgMode = false;
|
841 | }
|
842 | }
|
843 | else if ((defaultHolder = elm['s-cr'])) {
|
844 |
|
845 | defaultHolder.parentNode.textContent = text;
|
846 | }
|
847 | else if (oldVNode.$text$ !== text) {
|
848 |
|
849 |
|
850 | elm.data = text;
|
851 | }
|
852 | };
|
853 | const updateFallbackSlotVisibility = (elm) => {
|
854 |
|
855 | let childNodes = elm.childNodes;
|
856 | let childNode;
|
857 | let i;
|
858 | let ilen;
|
859 | let j;
|
860 | let slotNameAttr;
|
861 | let nodeType;
|
862 | for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
863 | childNode = childNodes[i];
|
864 | if (childNode.nodeType === 1 ) {
|
865 | if (childNode['s-sr']) {
|
866 |
|
867 |
|
868 | slotNameAttr = childNode['s-sn'];
|
869 |
|
870 |
|
871 | childNode.hidden = false;
|
872 | for (j = 0; j < ilen; j++) {
|
873 | nodeType = childNodes[j].nodeType;
|
874 | if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
875 |
|
876 | if (nodeType === 1 && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
877 | childNode.hidden = true;
|
878 | break;
|
879 | }
|
880 | }
|
881 | else {
|
882 |
|
883 |
|
884 |
|
885 | if (nodeType === 1 ||
|
886 | (nodeType === 3 && childNodes[j].textContent.trim() !== '')) {
|
887 | childNode.hidden = true;
|
888 | break;
|
889 | }
|
890 | }
|
891 | }
|
892 | }
|
893 |
|
894 | updateFallbackSlotVisibility(childNode);
|
895 | }
|
896 | }
|
897 | };
|
898 | const relocateNodes = [];
|
899 | const relocateSlotContent = (elm) => {
|
900 |
|
901 | let childNode;
|
902 | let node;
|
903 | let hostContentNodes;
|
904 | let slotNameAttr;
|
905 | let relocateNodeData;
|
906 | let j;
|
907 | let i = 0;
|
908 | let childNodes = elm.childNodes;
|
909 | let ilen = childNodes.length;
|
910 | for (; i < ilen; i++) {
|
911 | childNode = childNodes[i];
|
912 | if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
913 |
|
914 |
|
915 | hostContentNodes = node.parentNode.childNodes;
|
916 | slotNameAttr = childNode['s-sn'];
|
917 | for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
918 | node = hostContentNodes[j];
|
919 | if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
920 |
|
921 |
|
922 |
|
923 | if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
924 |
|
925 | relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
|
926 |
|
927 |
|
928 |
|
929 | checkSlotFallbackVisibility = true;
|
930 | node['s-sn'] = node['s-sn'] || slotNameAttr;
|
931 | if (relocateNodeData) {
|
932 |
|
933 |
|
934 | relocateNodeData.$slotRefNode$ = childNode;
|
935 | }
|
936 | else {
|
937 |
|
938 | relocateNodes.push({
|
939 | $slotRefNode$: childNode,
|
940 | $nodeToRelocate$: node,
|
941 | });
|
942 | }
|
943 | if (node['s-sr']) {
|
944 | relocateNodes.map(relocateNode => {
|
945 | if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
946 | relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
|
947 | if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
948 | relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
949 | }
|
950 | }
|
951 | });
|
952 | }
|
953 | }
|
954 | else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
|
955 |
|
956 |
|
957 | relocateNodes.push({
|
958 | $nodeToRelocate$: node,
|
959 | });
|
960 | }
|
961 | }
|
962 | }
|
963 | }
|
964 | if (childNode.nodeType === 1 ) {
|
965 | relocateSlotContent(childNode);
|
966 | }
|
967 | }
|
968 | };
|
969 | const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
970 | if (nodeToRelocate.nodeType === 1 ) {
|
971 | if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
972 | return true;
|
973 | }
|
974 | if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
975 | return true;
|
976 | }
|
977 | return false;
|
978 | }
|
979 | if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
980 | return true;
|
981 | }
|
982 | return slotNameAttr === '';
|
983 | };
|
984 | const callNodeRefs = (vNode) => {
|
985 | {
|
986 | vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
987 | vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
988 | }
|
989 | };
|
990 | const renderVdom = (hostRef, renderFnResults) => {
|
991 | const hostElm = hostRef.$hostElement$;
|
992 | const cmpMeta = hostRef.$cmpMeta$;
|
993 | const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
994 | const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
995 | hostTagName = hostElm.tagName;
|
996 | if (cmpMeta.$attrsToReflect$) {
|
997 | rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
998 | cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
999 | }
|
1000 | rootVnode.$tag$ = null;
|
1001 | rootVnode.$flags$ |= 4 ;
|
1002 | hostRef.$vnode$ = rootVnode;
|
1003 | rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
1004 | {
|
1005 | scopeId = hostElm['s-sc'];
|
1006 | }
|
1007 | {
|
1008 | contentRef = hostElm['s-cr'];
|
1009 | useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 ) !== 0;
|
1010 |
|
1011 | checkSlotFallbackVisibility = false;
|
1012 | }
|
1013 |
|
1014 | patch(oldVNode, rootVnode);
|
1015 | {
|
1016 |
|
1017 |
|
1018 | plt.$flags$ |= 1 ;
|
1019 | if (checkSlotRelocate) {
|
1020 | relocateSlotContent(rootVnode.$elm$);
|
1021 | let relocateData;
|
1022 | let nodeToRelocate;
|
1023 | let orgLocationNode;
|
1024 | let parentNodeRef;
|
1025 | let insertBeforeNode;
|
1026 | let refNode;
|
1027 | let i = 0;
|
1028 | for (; i < relocateNodes.length; i++) {
|
1029 | relocateData = relocateNodes[i];
|
1030 | nodeToRelocate = relocateData.$nodeToRelocate$;
|
1031 | if (!nodeToRelocate['s-ol']) {
|
1032 |
|
1033 |
|
1034 | orgLocationNode = doc.createTextNode('');
|
1035 | orgLocationNode['s-nr'] = nodeToRelocate;
|
1036 | nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
1037 | }
|
1038 | }
|
1039 | for (i = 0; i < relocateNodes.length; i++) {
|
1040 | relocateData = relocateNodes[i];
|
1041 | nodeToRelocate = relocateData.$nodeToRelocate$;
|
1042 | if (relocateData.$slotRefNode$) {
|
1043 |
|
1044 |
|
1045 | parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
1046 | insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
1047 | orgLocationNode = nodeToRelocate['s-ol'];
|
1048 | while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
1049 | refNode = orgLocationNode['s-nr'];
|
1050 | if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
1051 | refNode = refNode.nextSibling;
|
1052 | if (!refNode || !refNode['s-nr']) {
|
1053 | insertBeforeNode = refNode;
|
1054 | break;
|
1055 | }
|
1056 | }
|
1057 | }
|
1058 | if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
|
1059 |
|
1060 |
|
1061 |
|
1062 | if (nodeToRelocate !== insertBeforeNode) {
|
1063 | if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
1064 |
|
1065 | nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
1066 | }
|
1067 |
|
1068 | parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
1069 | }
|
1070 | }
|
1071 | }
|
1072 | else {
|
1073 |
|
1074 | if (nodeToRelocate.nodeType === 1 ) {
|
1075 | nodeToRelocate.hidden = true;
|
1076 | }
|
1077 | }
|
1078 | }
|
1079 | }
|
1080 | if (checkSlotFallbackVisibility) {
|
1081 | updateFallbackSlotVisibility(rootVnode.$elm$);
|
1082 | }
|
1083 |
|
1084 |
|
1085 | plt.$flags$ &= ~1 ;
|
1086 |
|
1087 | relocateNodes.length = 0;
|
1088 | }
|
1089 | };
|
1090 | const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
1091 | const createEvent = (ref, name, flags) => {
|
1092 | const elm = getElement(ref);
|
1093 | return {
|
1094 | emit: (detail) => {
|
1095 | return emitEvent(elm, name, {
|
1096 | bubbles: !!(flags & 4 ),
|
1097 | composed: !!(flags & 2 ),
|
1098 | cancelable: !!(flags & 1 ),
|
1099 | detail,
|
1100 | });
|
1101 | },
|
1102 | };
|
1103 | };
|
1104 | const emitEvent = (elm, name, opts) => {
|
1105 | const ev = plt.ce(name, opts);
|
1106 | elm.dispatchEvent(ev);
|
1107 | return ev;
|
1108 | };
|
1109 | const attachToAncestor = (hostRef, ancestorComponent) => {
|
1110 | if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
1111 | ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
|
1112 | }
|
1113 | };
|
1114 | const scheduleUpdate = (hostRef, isInitialLoad) => {
|
1115 | {
|
1116 | hostRef.$flags$ |= 16 ;
|
1117 | }
|
1118 | if (hostRef.$flags$ & 4 ) {
|
1119 | hostRef.$flags$ |= 512 ;
|
1120 | return;
|
1121 | }
|
1122 | attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
1123 |
|
1124 |
|
1125 |
|
1126 | const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
1127 | return writeTask(dispatch) ;
|
1128 | };
|
1129 | const dispatchHooks = (hostRef, isInitialLoad) => {
|
1130 | const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
1131 | const instance = hostRef.$lazyInstance$ ;
|
1132 | let promise;
|
1133 | if (isInitialLoad) {
|
1134 | {
|
1135 | hostRef.$flags$ |= 256 ;
|
1136 | if (hostRef.$queuedListeners$) {
|
1137 | hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
1138 | hostRef.$queuedListeners$ = null;
|
1139 | }
|
1140 | }
|
1141 | {
|
1142 | promise = safeCall(instance, 'componentWillLoad');
|
1143 | }
|
1144 | }
|
1145 | {
|
1146 | promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
1147 | }
|
1148 | endSchedule();
|
1149 | return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
1150 | };
|
1151 | const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
1152 |
|
1153 | const elm = hostRef.$hostElement$;
|
1154 | const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
1155 | const rc = elm['s-rc'];
|
1156 | if (isInitialLoad) {
|
1157 |
|
1158 | attachStyles(hostRef);
|
1159 | }
|
1160 | const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
1161 | {
|
1162 | callRender(hostRef, instance);
|
1163 | }
|
1164 | if (plt.$cssShim$) {
|
1165 | plt.$cssShim$.updateHost(elm);
|
1166 | }
|
1167 | if (rc) {
|
1168 |
|
1169 |
|
1170 |
|
1171 | rc.map(cb => cb());
|
1172 | elm['s-rc'] = undefined;
|
1173 | }
|
1174 | endRender();
|
1175 | endUpdate();
|
1176 | {
|
1177 | const childrenPromises = elm['s-p'];
|
1178 | const postUpdate = () => postUpdateComponent(hostRef);
|
1179 | if (childrenPromises.length === 0) {
|
1180 | postUpdate();
|
1181 | }
|
1182 | else {
|
1183 | Promise.all(childrenPromises).then(postUpdate);
|
1184 | hostRef.$flags$ |= 4 ;
|
1185 | childrenPromises.length = 0;
|
1186 | }
|
1187 | }
|
1188 | };
|
1189 | const callRender = (hostRef, instance, elm) => {
|
1190 | try {
|
1191 | instance = instance.render && instance.render();
|
1192 | {
|
1193 | hostRef.$flags$ &= ~16 ;
|
1194 | }
|
1195 | {
|
1196 | hostRef.$flags$ |= 2 ;
|
1197 | }
|
1198 | {
|
1199 | {
|
1200 |
|
1201 |
|
1202 |
|
1203 | {
|
1204 | renderVdom(hostRef, instance);
|
1205 | }
|
1206 | }
|
1207 | }
|
1208 | }
|
1209 | catch (e) {
|
1210 | consoleError(e, hostRef.$hostElement$);
|
1211 | }
|
1212 | return null;
|
1213 | };
|
1214 | const postUpdateComponent = (hostRef) => {
|
1215 | const tagName = hostRef.$cmpMeta$.$tagName$;
|
1216 | const elm = hostRef.$hostElement$;
|
1217 | const endPostUpdate = createTime('postUpdate', tagName);
|
1218 | const instance = hostRef.$lazyInstance$ ;
|
1219 | const ancestorComponent = hostRef.$ancestorComponent$;
|
1220 | if (!(hostRef.$flags$ & 64 )) {
|
1221 | hostRef.$flags$ |= 64 ;
|
1222 | {
|
1223 |
|
1224 | addHydratedFlag(elm);
|
1225 | }
|
1226 | {
|
1227 | safeCall(instance, 'componentDidLoad');
|
1228 | }
|
1229 | endPostUpdate();
|
1230 | {
|
1231 | hostRef.$onReadyResolve$(elm);
|
1232 | if (!ancestorComponent) {
|
1233 | appDidLoad();
|
1234 | }
|
1235 | }
|
1236 | }
|
1237 | else {
|
1238 | {
|
1239 | safeCall(instance, 'componentDidUpdate');
|
1240 | }
|
1241 | endPostUpdate();
|
1242 | }
|
1243 | {
|
1244 | hostRef.$onInstanceResolve$(elm);
|
1245 | }
|
1246 |
|
1247 |
|
1248 | {
|
1249 | if (hostRef.$onRenderResolve$) {
|
1250 | hostRef.$onRenderResolve$();
|
1251 | hostRef.$onRenderResolve$ = undefined;
|
1252 | }
|
1253 | if (hostRef.$flags$ & 512 ) {
|
1254 | nextTick(() => scheduleUpdate(hostRef, false));
|
1255 | }
|
1256 | hostRef.$flags$ &= ~(4 | 512 );
|
1257 | }
|
1258 |
|
1259 |
|
1260 |
|
1261 | };
|
1262 | const forceUpdate = (ref) => {
|
1263 | {
|
1264 | const hostRef = getHostRef(ref);
|
1265 | const isConnected = hostRef.$hostElement$.isConnected;
|
1266 | if (isConnected && (hostRef.$flags$ & (2 | 16 )) === 2 ) {
|
1267 | scheduleUpdate(hostRef, false);
|
1268 | }
|
1269 |
|
1270 | return isConnected;
|
1271 | }
|
1272 | };
|
1273 | const appDidLoad = (who) => {
|
1274 |
|
1275 |
|
1276 | {
|
1277 | addHydratedFlag(doc.documentElement);
|
1278 | }
|
1279 | nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
1280 | };
|
1281 | const safeCall = (instance, method, arg) => {
|
1282 | if (instance && instance[method]) {
|
1283 | try {
|
1284 | return instance[method](arg);
|
1285 | }
|
1286 | catch (e) {
|
1287 | consoleError(e);
|
1288 | }
|
1289 | }
|
1290 | return undefined;
|
1291 | };
|
1292 | const then = (promise, thenFn) => {
|
1293 | return promise && promise.then ? promise.then(thenFn) : thenFn();
|
1294 | };
|
1295 | const addHydratedFlag = (elm) => (elm.classList.add('hydrated') );
|
1296 | const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
1297 | const endHydrate = createTime('hydrateClient', tagName);
|
1298 | const shadowRoot = hostElm.shadowRoot;
|
1299 | const childRenderNodes = [];
|
1300 | const slotNodes = [];
|
1301 | const shadowRootNodes = shadowRoot ? [] : null;
|
1302 | const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
1303 | if (!plt.$orgLocNodes$) {
|
1304 | initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
1305 | }
|
1306 | hostElm[HYDRATE_ID] = hostId;
|
1307 | hostElm.removeAttribute(HYDRATE_ID);
|
1308 | clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
1309 | childRenderNodes.map(c => {
|
1310 | const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
1311 | const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
1312 | const node = c.$elm$;
|
1313 | if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
1314 | orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
1315 | }
|
1316 | if (!shadowRoot) {
|
1317 | node['s-hn'] = tagName;
|
1318 | if (orgLocationNode) {
|
1319 | node['s-ol'] = orgLocationNode;
|
1320 | node['s-ol']['s-nr'] = node;
|
1321 | }
|
1322 | }
|
1323 | plt.$orgLocNodes$.delete(orgLocationId);
|
1324 | });
|
1325 | if (shadowRoot) {
|
1326 | shadowRootNodes.map(shadowRootNode => {
|
1327 | if (shadowRootNode) {
|
1328 | shadowRoot.appendChild(shadowRootNode);
|
1329 | }
|
1330 | });
|
1331 | }
|
1332 | endHydrate();
|
1333 | };
|
1334 | const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
1335 | let childNodeType;
|
1336 | let childIdSplt;
|
1337 | let childVNode;
|
1338 | let i;
|
1339 | if (node.nodeType === 1 ) {
|
1340 | childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
1341 | if (childNodeType) {
|
1342 |
|
1343 |
|
1344 | childIdSplt = childNodeType.split('.');
|
1345 | if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
1346 | childVNode = {
|
1347 | $flags$: 0,
|
1348 | $hostId$: childIdSplt[0],
|
1349 | $nodeId$: childIdSplt[1],
|
1350 | $depth$: childIdSplt[2],
|
1351 | $index$: childIdSplt[3],
|
1352 | $tag$: node.tagName.toLowerCase(),
|
1353 | $elm$: node,
|
1354 | $attrs$: null,
|
1355 | $children$: null,
|
1356 | $key$: null,
|
1357 | $name$: null,
|
1358 | $text$: null,
|
1359 | };
|
1360 | childRenderNodes.push(childVNode);
|
1361 | node.removeAttribute(HYDRATE_CHILD_ID);
|
1362 |
|
1363 |
|
1364 | if (!parentVNode.$children$) {
|
1365 | parentVNode.$children$ = [];
|
1366 | }
|
1367 |
|
1368 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1369 |
|
1370 | parentVNode = childVNode;
|
1371 | if (shadowRootNodes && childVNode.$depth$ === '0') {
|
1372 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1373 | }
|
1374 | }
|
1375 | }
|
1376 |
|
1377 | for (i = node.childNodes.length - 1; i >= 0; i--) {
|
1378 | clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
1379 | }
|
1380 | if (node.shadowRoot) {
|
1381 |
|
1382 | for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
1383 | clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
1384 | }
|
1385 | }
|
1386 | }
|
1387 | else if (node.nodeType === 8 ) {
|
1388 |
|
1389 | childIdSplt = node.nodeValue.split('.');
|
1390 | if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
1391 |
|
1392 | childNodeType = childIdSplt[0];
|
1393 | childVNode = {
|
1394 | $flags$: 0,
|
1395 | $hostId$: childIdSplt[1],
|
1396 | $nodeId$: childIdSplt[2],
|
1397 | $depth$: childIdSplt[3],
|
1398 | $index$: childIdSplt[4],
|
1399 | $elm$: node,
|
1400 | $attrs$: null,
|
1401 | $children$: null,
|
1402 | $key$: null,
|
1403 | $name$: null,
|
1404 | $tag$: null,
|
1405 | $text$: null,
|
1406 | };
|
1407 | if (childNodeType === TEXT_NODE_ID) {
|
1408 | childVNode.$elm$ = node.nextSibling;
|
1409 | if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 ) {
|
1410 | childVNode.$text$ = childVNode.$elm$.textContent;
|
1411 | childRenderNodes.push(childVNode);
|
1412 |
|
1413 | node.remove();
|
1414 | if (!parentVNode.$children$) {
|
1415 | parentVNode.$children$ = [];
|
1416 | }
|
1417 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1418 | if (shadowRootNodes && childVNode.$depth$ === '0') {
|
1419 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1420 | }
|
1421 | }
|
1422 | }
|
1423 | else if (childVNode.$hostId$ === hostId) {
|
1424 |
|
1425 | if (childNodeType === SLOT_NODE_ID) {
|
1426 |
|
1427 | childVNode.$tag$ = 'slot';
|
1428 | if (childIdSplt[5]) {
|
1429 | node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
1430 | }
|
1431 | else {
|
1432 | node['s-sn'] = '';
|
1433 | }
|
1434 | node['s-sr'] = true;
|
1435 | if (shadowRootNodes) {
|
1436 |
|
1437 |
|
1438 | childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
1439 | if (childVNode.$name$) {
|
1440 |
|
1441 | childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
1442 | }
|
1443 |
|
1444 | node.parentNode.insertBefore(childVNode.$elm$, node);
|
1445 |
|
1446 | node.remove();
|
1447 | if (childVNode.$depth$ === '0') {
|
1448 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1449 | }
|
1450 | }
|
1451 | slotNodes.push(childVNode);
|
1452 | if (!parentVNode.$children$) {
|
1453 | parentVNode.$children$ = [];
|
1454 | }
|
1455 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1456 | }
|
1457 | else if (childNodeType === CONTENT_REF_ID) {
|
1458 |
|
1459 | if (shadowRootNodes) {
|
1460 |
|
1461 | node.remove();
|
1462 | }
|
1463 | else {
|
1464 | hostElm['s-cr'] = node;
|
1465 | node['s-cn'] = true;
|
1466 | }
|
1467 | }
|
1468 | }
|
1469 | }
|
1470 | }
|
1471 | else if (parentVNode && parentVNode.$tag$ === 'style') {
|
1472 | const vnode = newVNode(null, node.textContent);
|
1473 | vnode.$elm$ = node;
|
1474 | vnode.$index$ = '0';
|
1475 | parentVNode.$children$ = [vnode];
|
1476 | }
|
1477 | };
|
1478 | const initializeDocumentHydrate = (node, orgLocNodes) => {
|
1479 | if (node.nodeType === 1 ) {
|
1480 | let i = 0;
|
1481 | for (; i < node.childNodes.length; i++) {
|
1482 | initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
1483 | }
|
1484 | if (node.shadowRoot) {
|
1485 | for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
1486 | initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
1487 | }
|
1488 | }
|
1489 | }
|
1490 | else if (node.nodeType === 8 ) {
|
1491 | const childIdSplt = node.nodeValue.split('.');
|
1492 | if (childIdSplt[0] === ORG_LOCATION_ID) {
|
1493 | orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
1494 | node.nodeValue = '';
|
1495 |
|
1496 |
|
1497 | node['s-en'] = childIdSplt[3];
|
1498 | }
|
1499 | }
|
1500 | };
|
1501 | const parsePropertyValue = (propValue, propType) => {
|
1502 |
|
1503 | if (propValue != null && !isComplexType(propValue)) {
|
1504 | if (propType & 4 ) {
|
1505 |
|
1506 |
|
1507 | return propValue === 'false' ? false : propValue === '' || !!propValue;
|
1508 | }
|
1509 | if (propType & 2 ) {
|
1510 |
|
1511 | return parseFloat(propValue);
|
1512 | }
|
1513 | if (propType & 1 ) {
|
1514 |
|
1515 |
|
1516 | return String(propValue);
|
1517 | }
|
1518 |
|
1519 | return propValue;
|
1520 | }
|
1521 |
|
1522 |
|
1523 | return propValue;
|
1524 | };
|
1525 | const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
1526 | const setValue = (ref, propName, newVal, cmpMeta) => {
|
1527 |
|
1528 | const hostRef = getHostRef(ref);
|
1529 | const elm = hostRef.$hostElement$ ;
|
1530 | const oldVal = hostRef.$instanceValues$.get(propName);
|
1531 | const flags = hostRef.$flags$;
|
1532 | const instance = hostRef.$lazyInstance$ ;
|
1533 | newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
1534 | if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
|
1535 |
|
1536 |
|
1537 | hostRef.$instanceValues$.set(propName, newVal);
|
1538 | if (instance) {
|
1539 |
|
1540 | if (cmpMeta.$watchers$ && flags & 128 ) {
|
1541 | const watchMethods = cmpMeta.$watchers$[propName];
|
1542 | if (watchMethods) {
|
1543 |
|
1544 | watchMethods.map(watchMethodName => {
|
1545 | try {
|
1546 |
|
1547 | instance[watchMethodName](newVal, oldVal, propName);
|
1548 | }
|
1549 | catch (e) {
|
1550 | consoleError(e, elm);
|
1551 | }
|
1552 | });
|
1553 | }
|
1554 | }
|
1555 | if ((flags & (2 | 16 )) === 2 ) {
|
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 | scheduleUpdate(hostRef, false);
|
1561 | }
|
1562 | }
|
1563 | }
|
1564 | };
|
1565 | const proxyComponent = (Cstr, cmpMeta, flags) => {
|
1566 | if (cmpMeta.$members$) {
|
1567 | if (Cstr.watchers) {
|
1568 | cmpMeta.$watchers$ = Cstr.watchers;
|
1569 | }
|
1570 |
|
1571 | const members = Object.entries(cmpMeta.$members$);
|
1572 | const prototype = Cstr.prototype;
|
1573 | members.map(([memberName, [memberFlags]]) => {
|
1574 | if ((memberFlags & 31 || ((flags & 2 ) && memberFlags & 32 ))) {
|
1575 |
|
1576 | Object.defineProperty(prototype, memberName, {
|
1577 | get() {
|
1578 |
|
1579 | return getValue(this, memberName);
|
1580 | },
|
1581 | set(newValue) {
|
1582 |
|
1583 | setValue(this, memberName, newValue, cmpMeta);
|
1584 | },
|
1585 | configurable: true,
|
1586 | enumerable: true,
|
1587 | });
|
1588 | }
|
1589 | else if (flags & 1 && memberFlags & 64 ) {
|
1590 |
|
1591 | Object.defineProperty(prototype, memberName, {
|
1592 | value(...args) {
|
1593 | const ref = getHostRef(this);
|
1594 | return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
|
1595 | },
|
1596 | });
|
1597 | }
|
1598 | });
|
1599 | if ((flags & 1 )) {
|
1600 | const attrNameToPropName = new Map();
|
1601 | prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
1602 | plt.jmp(() => {
|
1603 | const propName = attrNameToPropName.get(attrName);
|
1604 | this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
1605 | });
|
1606 | };
|
1607 |
|
1608 |
|
1609 | Cstr.observedAttributes = members
|
1610 | .filter(([_, m]) => m[0] & 15 )
|
1611 | .map(([propName, m]) => {
|
1612 | const attrName = m[1] || propName;
|
1613 | attrNameToPropName.set(attrName, propName);
|
1614 | if (m[0] & 512 ) {
|
1615 | cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
1616 | }
|
1617 | return attrName;
|
1618 | });
|
1619 | }
|
1620 | }
|
1621 | return Cstr;
|
1622 | };
|
1623 | const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
1624 |
|
1625 | if ((hostRef.$flags$ & 32 ) === 0) {
|
1626 | {
|
1627 |
|
1628 | hostRef.$flags$ |= 32 ;
|
1629 |
|
1630 |
|
1631 |
|
1632 | Cstr = loadModule(cmpMeta);
|
1633 | if (Cstr.then) {
|
1634 |
|
1635 | const endLoad = uniqueTime();
|
1636 | Cstr = await Cstr;
|
1637 | endLoad();
|
1638 | }
|
1639 | if (!Cstr.isProxied) {
|
1640 |
|
1641 |
|
1642 |
|
1643 | {
|
1644 | cmpMeta.$watchers$ = Cstr.watchers;
|
1645 | }
|
1646 | proxyComponent(Cstr, cmpMeta, 2 );
|
1647 | Cstr.isProxied = true;
|
1648 | }
|
1649 | const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
1650 |
|
1651 |
|
1652 |
|
1653 | {
|
1654 | hostRef.$flags$ |= 8 ;
|
1655 | }
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 | try {
|
1661 | new Cstr(hostRef);
|
1662 | }
|
1663 | catch (e) {
|
1664 | consoleError(e);
|
1665 | }
|
1666 | {
|
1667 | hostRef.$flags$ &= ~8 ;
|
1668 | }
|
1669 | {
|
1670 | hostRef.$flags$ |= 128 ;
|
1671 | }
|
1672 | endNewInstance();
|
1673 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1674 | }
|
1675 | if (Cstr.style) {
|
1676 |
|
1677 | let style = Cstr.style;
|
1678 | if (typeof style !== 'string') {
|
1679 | style = style[(hostRef.$modeName$ = computeMode(elm))];
|
1680 | }
|
1681 | const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
|
1682 | if (!styles.has(scopeId)) {
|
1683 | const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
1684 | if (cmpMeta.$flags$ & 8 ) {
|
1685 | style = await Promise.resolve().then(function () { return require('./shadow-css-c4152736.js'); }).then(m => m.scopeCss(style, scopeId, false));
|
1686 | }
|
1687 | registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 ));
|
1688 | endRegisterStyles();
|
1689 | }
|
1690 | }
|
1691 | }
|
1692 |
|
1693 | const ancestorComponent = hostRef.$ancestorComponent$;
|
1694 | const schedule = () => scheduleUpdate(hostRef, true);
|
1695 | if (ancestorComponent && ancestorComponent['s-rc']) {
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 | ancestorComponent['s-rc'].push(schedule);
|
1703 | }
|
1704 | else {
|
1705 | schedule();
|
1706 | }
|
1707 | };
|
1708 | const fireConnectedCallback = (instance) => {
|
1709 | {
|
1710 | safeCall(instance, 'connectedCallback');
|
1711 | }
|
1712 | };
|
1713 | const connectedCallback = (elm) => {
|
1714 | if ((plt.$flags$ & 1 ) === 0) {
|
1715 | const hostRef = getHostRef(elm);
|
1716 | const cmpMeta = hostRef.$cmpMeta$;
|
1717 | const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
1718 | if (!(hostRef.$flags$ & 1 )) {
|
1719 |
|
1720 | hostRef.$flags$ |= 1 ;
|
1721 | let hostId;
|
1722 | {
|
1723 | hostId = elm.getAttribute(HYDRATE_ID);
|
1724 | if (hostId) {
|
1725 | if (supportsShadow && cmpMeta.$flags$ & 1 ) {
|
1726 | const scopeId = addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode')) ;
|
1727 | elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
1728 | }
|
1729 | initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
1730 | }
|
1731 | }
|
1732 | if (!hostId) {
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 | if ((cmpMeta.$flags$ & (4 | 8 ))) {
|
1738 | setContentReference(elm);
|
1739 | }
|
1740 | }
|
1741 | {
|
1742 |
|
1743 |
|
1744 | let ancestorComponent = elm;
|
1745 | while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
1746 |
|
1747 |
|
1748 | if ((ancestorComponent.nodeType === 1 && ancestorComponent.hasAttribute('s-id') && ancestorComponent['s-p']) ||
|
1749 | ancestorComponent['s-p']) {
|
1750 |
|
1751 |
|
1752 | attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
1753 | break;
|
1754 | }
|
1755 | }
|
1756 | }
|
1757 |
|
1758 |
|
1759 | if (cmpMeta.$members$) {
|
1760 | Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
1761 | if (memberFlags & 31 && elm.hasOwnProperty(memberName)) {
|
1762 | const value = elm[memberName];
|
1763 | delete elm[memberName];
|
1764 | elm[memberName] = value;
|
1765 | }
|
1766 | });
|
1767 | }
|
1768 | {
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 | nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
|
1774 | }
|
1775 | }
|
1776 | else {
|
1777 |
|
1778 |
|
1779 |
|
1780 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
1781 |
|
1782 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1783 | }
|
1784 | endConnected();
|
1785 | }
|
1786 | };
|
1787 | const setContentReference = (elm) => {
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 | const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
1795 | contentRefElm['s-cn'] = true;
|
1796 | elm.insertBefore(contentRefElm, elm.firstChild);
|
1797 | };
|
1798 | const disconnectedCallback = (elm) => {
|
1799 | if ((plt.$flags$ & 1 ) === 0) {
|
1800 | const hostRef = getHostRef(elm);
|
1801 | const instance = hostRef.$lazyInstance$ ;
|
1802 | {
|
1803 | if (hostRef.$rmListeners$) {
|
1804 | hostRef.$rmListeners$.map(rmListener => rmListener());
|
1805 | hostRef.$rmListeners$ = undefined;
|
1806 | }
|
1807 | }
|
1808 |
|
1809 | if (plt.$cssShim$) {
|
1810 | plt.$cssShim$.removeHost(elm);
|
1811 | }
|
1812 | {
|
1813 | safeCall(instance, 'disconnectedCallback');
|
1814 | }
|
1815 | }
|
1816 | };
|
1817 | const bootstrapLazy = (lazyBundles, options = {}) => {
|
1818 | const endBootstrap = createTime();
|
1819 | const cmpTags = [];
|
1820 | const exclude = options.exclude || [];
|
1821 | const customElements = win.customElements;
|
1822 | const head = doc.head;
|
1823 | const metaCharset = head.querySelector('meta[charset]');
|
1824 | const visibilityStyle = doc.createElement('style');
|
1825 | const deferredConnectedCallbacks = [];
|
1826 | const styles = doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
1827 | let appLoadFallback;
|
1828 | let isBootstrapping = true;
|
1829 | let i = 0;
|
1830 | Object.assign(plt, options);
|
1831 | plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
1832 | {
|
1833 |
|
1834 |
|
1835 | plt.$flags$ |= 2 ;
|
1836 | }
|
1837 | {
|
1838 | for (; i < styles.length; i++) {
|
1839 | registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
1840 | }
|
1841 | }
|
1842 | lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
|
1843 | const cmpMeta = {
|
1844 | $flags$: compactMeta[0],
|
1845 | $tagName$: compactMeta[1],
|
1846 | $members$: compactMeta[2],
|
1847 | $listeners$: compactMeta[3],
|
1848 | };
|
1849 | {
|
1850 | cmpMeta.$members$ = compactMeta[2];
|
1851 | }
|
1852 | {
|
1853 | cmpMeta.$listeners$ = compactMeta[3];
|
1854 | }
|
1855 | {
|
1856 | cmpMeta.$attrsToReflect$ = [];
|
1857 | }
|
1858 | {
|
1859 | cmpMeta.$watchers$ = {};
|
1860 | }
|
1861 | if (!supportsShadow && cmpMeta.$flags$ & 1 ) {
|
1862 | cmpMeta.$flags$ |= 8 ;
|
1863 | }
|
1864 | const tagName = cmpMeta.$tagName$;
|
1865 | const HostElement = class extends HTMLElement {
|
1866 |
|
1867 | constructor(self) {
|
1868 |
|
1869 | super(self);
|
1870 | self = this;
|
1871 | registerHost(self, cmpMeta);
|
1872 | if (cmpMeta.$flags$ & 1 ) {
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 | if (supportsShadow) {
|
1878 | {
|
1879 | self.attachShadow({
|
1880 | mode: 'open',
|
1881 | delegatesFocus: !!(cmpMeta.$flags$ & 16 ),
|
1882 | });
|
1883 | }
|
1884 | }
|
1885 | else if (!('shadowRoot' in self)) {
|
1886 | self.shadowRoot = self;
|
1887 | }
|
1888 | }
|
1889 | }
|
1890 | connectedCallback() {
|
1891 | if (appLoadFallback) {
|
1892 | clearTimeout(appLoadFallback);
|
1893 | appLoadFallback = null;
|
1894 | }
|
1895 | if (isBootstrapping) {
|
1896 |
|
1897 | deferredConnectedCallbacks.push(this);
|
1898 | }
|
1899 | else {
|
1900 | plt.jmp(() => connectedCallback(this));
|
1901 | }
|
1902 | }
|
1903 | disconnectedCallback() {
|
1904 | plt.jmp(() => disconnectedCallback(this));
|
1905 | }
|
1906 | componentOnReady() {
|
1907 | return getHostRef(this).$onReadyPromise$;
|
1908 | }
|
1909 | };
|
1910 | cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
1911 | if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
1912 | cmpTags.push(tagName);
|
1913 | customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 ));
|
1914 | }
|
1915 | }));
|
1916 | {
|
1917 | visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
1918 | visibilityStyle.setAttribute('data-styles', '');
|
1919 | head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
1920 | }
|
1921 |
|
1922 | isBootstrapping = false;
|
1923 | if (deferredConnectedCallbacks.length) {
|
1924 | deferredConnectedCallbacks.map(host => host.connectedCallback());
|
1925 | }
|
1926 | else {
|
1927 | {
|
1928 | plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
|
1929 | }
|
1930 | }
|
1931 |
|
1932 | endBootstrap();
|
1933 | };
|
1934 | const getAssetPath = (path) => {
|
1935 | const assetUrl = new URL(path, plt.$resourcesUrl$);
|
1936 | return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
1937 | };
|
1938 | const hostRefs = new WeakMap();
|
1939 | const getHostRef = (ref) => hostRefs.get(ref);
|
1940 | const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
1941 | const registerHost = (elm, cmpMeta) => {
|
1942 | const hostRef = {
|
1943 | $flags$: 0,
|
1944 | $hostElement$: elm,
|
1945 | $cmpMeta$: cmpMeta,
|
1946 | $instanceValues$: new Map(),
|
1947 | };
|
1948 | {
|
1949 | hostRef.$onInstancePromise$ = new Promise(r => (hostRef.$onInstanceResolve$ = r));
|
1950 | }
|
1951 | {
|
1952 | hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
|
1953 | elm['s-p'] = [];
|
1954 | elm['s-rc'] = [];
|
1955 | }
|
1956 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
1957 | return hostRefs.set(elm, hostRef);
|
1958 | };
|
1959 | const isMemberInElement = (elm, memberName) => memberName in elm;
|
1960 | const consoleError = (e, el) => (0, console.error)(e, el);
|
1961 | const cmpModules = new Map();
|
1962 | const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
1963 |
|
1964 | const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
1965 | const bundleId = cmpMeta.$lazyBundleId$;
|
1966 | const module = cmpModules.get(bundleId) ;
|
1967 | if (module) {
|
1968 | return module[exportName];
|
1969 | }
|
1970 | return Promise.resolve().then(function () { return _interopNamespace(require(
|
1971 |
|
1972 |
|
1973 |
|
1974 | `./${bundleId}.entry.js${''}`)); }).then(importedModule => {
|
1975 | {
|
1976 | cmpModules.set(bundleId, importedModule);
|
1977 | }
|
1978 | return importedModule[exportName];
|
1979 | }, consoleError);
|
1980 | };
|
1981 | const styles = new Map();
|
1982 | const modeResolutionChain = [];
|
1983 | const queueDomReads = [];
|
1984 | const queueDomWrites = [];
|
1985 | const queueTask = (queue, write) => (cb) => {
|
1986 | queue.push(cb);
|
1987 | if (!queuePending) {
|
1988 | queuePending = true;
|
1989 | if (write && plt.$flags$ & 4 ) {
|
1990 | nextTick(flush);
|
1991 | }
|
1992 | else {
|
1993 | plt.raf(flush);
|
1994 | }
|
1995 | }
|
1996 | };
|
1997 | const consume = (queue) => {
|
1998 | for (let i = 0; i < queue.length; i++) {
|
1999 | try {
|
2000 | queue[i](performance.now());
|
2001 | }
|
2002 | catch (e) {
|
2003 | consoleError(e);
|
2004 | }
|
2005 | }
|
2006 | queue.length = 0;
|
2007 | };
|
2008 | const flush = () => {
|
2009 |
|
2010 |
|
2011 |
|
2012 | consume(queueDomReads);
|
2013 |
|
2014 | {
|
2015 | consume(queueDomWrites);
|
2016 | if ((queuePending = queueDomReads.length > 0)) {
|
2017 |
|
2018 |
|
2019 | plt.raf(flush);
|
2020 | }
|
2021 | }
|
2022 | };
|
2023 | const nextTick = (cb) => promiseResolve().then(cb);
|
2024 | const readTask = queueTask(queueDomReads, false);
|
2025 | const writeTask = queueTask(queueDomWrites, true);
|
2026 | const Build = {
|
2027 | isDev: false,
|
2028 | isBrowser: true,
|
2029 | isServer: false,
|
2030 | isTesting: false,
|
2031 | };
|
2032 |
|
2033 | exports.Build = Build;
|
2034 | exports.CSS = CSS;
|
2035 | exports.Host = Host;
|
2036 | exports.NAMESPACE = NAMESPACE;
|
2037 | exports.bootstrapLazy = bootstrapLazy;
|
2038 | exports.createEvent = createEvent;
|
2039 | exports.doc = doc;
|
2040 | exports.forceUpdate = forceUpdate;
|
2041 | exports.getAssetPath = getAssetPath;
|
2042 | exports.getElement = getElement;
|
2043 | exports.getMode = getMode;
|
2044 | exports.h = h;
|
2045 | exports.plt = plt;
|
2046 | exports.promiseResolve = promiseResolve;
|
2047 | exports.readTask = readTask;
|
2048 | exports.registerInstance = registerInstance;
|
2049 | exports.setMode = setMode;
|
2050 | exports.win = win;
|
2051 | exports.writeTask = writeTask;
|