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