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