UNPKG

65.7 kBJavaScriptView Raw
1const 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};
2const NAMESPACE = 'anjuna-docs';
3
4let queueCongestion = 0;
5let queuePending = false;
6let scopeId;
7let contentRef;
8let hostTagName;
9let useNativeShadowDom = false;
10let checkSlotFallbackVisibility = false;
11let checkSlotRelocate = false;
12let isSvgMode = false;
13const win = window;
14const doc = document;
15const 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};
23const supportsShadowDom = false;
24const supportsListenerOptions = /*@__PURE__*/ (() => {
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})();
34const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
35 try {
36 new CSSStyleSheet();
37 return true;
38 }
39 catch (e) { }
40 return false;
41})() ;
42const hostRefs = new WeakMap();
43const getHostRef = (ref) => hostRefs.get(ref);
44const registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
45const 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};
58const isMemberInElement = (elm, memberName) => memberName in elm;
59const consoleError = (e) => console.error(e);
60const moduleCache = /*@__PURE__*/ new Map();
61const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
62 // loadModuleImport
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 /* webpackInclude: /\.entry\.js$/ */
71 /* webpackExclude: /\.system\.entry\.js$/ */
72 /* webpackMode: "lazy" */
73 `./${bundleId}.entry.js${ ''}`).then(importedModule => {
74 {
75 moduleCache.set(bundleId, importedModule);
76 }
77 return importedModule[exportName];
78 }, consoleError);
79};
80const styles = new Map();
81const queueDomReads = [];
82const queueDomWrites = [];
83const queueDomWritesLow = [];
84const queueTask = (queue, write) => (cb) => {
85 queue.push(cb);
86 if (!queuePending) {
87 queuePending = true;
88 if (write && plt.$flags$ & 4 /* queueSync */) {
89 nextTick(flush);
90 }
91 else {
92 plt.raf(flush);
93 }
94 }
95};
96const 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};
107const 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};
125const flush = () => {
126 queueCongestion++;
127 // always force a bunch of medium callbacks to run, but still have
128 // a throttle on how many can run in a certain time
129 // DOM READS!!!
130 consume(queueDomReads);
131 const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
132 ? performance.now() + (10 * Math.ceil(queueCongestion * (1.0 / 22.0)))
133 : Infinity;
134 // DOM WRITES!!!
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 // still more to do yet, but we've run out of time
143 // let's let this thing cool off and try again in the next tick
144 plt.raf(flush);
145 }
146 else {
147 queueCongestion = 0;
148 }
149};
150const nextTick = /*@__PURE__*/ (cb) => Promise.resolve().then(cb);
151const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
152/**
153 * Default style mode id
154 */
155/**
156 * Reusable empty obj/array
157 * Don't add values to these!!
158 */
159const EMPTY_OBJ = {};
160/**
161 * Namespaces
162 */
163const SVG_NS = 'http://www.w3.org/2000/svg';
164const HTML_NS = 'http://www.w3.org/1999/xhtml';
165const isDef = (v) => v != null;
166const isComplexType = (o) => {
167 // https://jsperf.com/typeof-fn-object/5
168 o = typeof o;
169 return o === 'object' || o === 'function';
170};
171const getDynamicImportFunction = (namespace) => {
172 return `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
173};
174const patchEsm = () => {
175 // @ts-ignore
176 if ( !(win.CSS && win.CSS.supports && win.CSS.supports('color', 'var(--c)'))) {
177 // @ts-ignore
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};
187const patchBrowser = async () => {
188 {
189 plt.$cssShim$ = win.__stencil_cssshim;
190 }
191 // @ts-ignore
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 // @ts-ignore
205 await import('./dom-96781eef-a2fb04dd.js');
206 }
207 return Object.assign(Object.assign({}, opts), { resourcesUrl: resourcesUrl.href });
208 }
209};
210const patchDynamicImport = (base) => {
211 const importFunctionName = getDynamicImportFunction(NAMESPACE);
212 try {
213 // There is a caching issue in V8, that breaks using import() in Function
214 // By generating a random string, we can workaround it
215 // Check https://bugs.chromium.org/p/v8/issues/detail?id=9558 for more info
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};
240const parsePropertyValue = (propValue, propType) => {
241 // ensure this value is of the correct prop type
242 if (propValue != null && !isComplexType(propValue)) {
243 if ( propType & 4 /* Boolean */) {
244 // per the HTML spec, any string value means it is a boolean true value
245 // but we'll cheat here and say that the string "false" is the boolean false
246 return (propValue === 'false' ? false : propValue === '' || !!propValue);
247 }
248 if ( propType & 1 /* String */) {
249 // could have been passed as a number or boolean
250 // but we still want it as a string
251 return String(propValue);
252 }
253 // redundant return here for better minification
254 return propValue;
255 }
256 // not sure exactly what type we want
257 // so no need to change to a different type
258 return propValue;
259};
260const HYDRATED_CLASS = 'hydrated';
261const createTime = (fnName, tagName = '') => {
262 {
263 return () => { return; };
264 }
265};
266const uniqueTime = (key, measureText) => {
267 {
268 return () => { return; };
269 }
270};
271const rootAppliedStyles = new WeakMap();
272const 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};
283const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
284 let scopeId = getScopeId(cmpMeta.$tagName$);
285 let style = styles.get(scopeId);
286 // if an element is NOT connected then getRootNode() will return the wrong root node
287 // so the fallback is to always use the document for the root node in those cases
288 styleContainerNode = (styleContainerNode.nodeType === 11 /* DocumentFragment */ ? 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 /* needsScopedEncapsulation */));
301 const newScopeId = styleElm['s-sc'];
302 if (newScopeId) {
303 scopeId = newScopeId;
304 // we don't want to add this styleID to the appliedStyles Set
305 // since the cssVarShim might need to apply several different
306 // stylesheets for the same component
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};
330const 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 /* needsScopedEncapsulation */) {
334 // only required when we're NOT using native shadow dom (slot)
335 // or this browser doesn't support native shadow dom
336 // and this host element was NOT created with SSR
337 // let's pick out the inner content for slot projection
338 // create a node to represent where the original
339 // content was first placed, which is useful later on
340 // DOM WRITE!!
341 elm['s-sc'] = scopeId;
342 elm.classList.add(scopeId + '-h');
343 if ( cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
344 elm.classList.add(scopeId + '-s');
345 }
346 }
347 endAttachStyles();
348};
349const getScopeId = (tagName, mode) => 'sc-' + ( tagName);
350/**
351 * Production h() function based on Preact by
352 * Jason Miller (@developit)
353 * Licensed under the MIT License
354 * https://github.com/developit/preact/blob/master/LICENSE
355 *
356 * Modified for Stencil's compiler and vdom
357 */
358// const stack: any[] = [];
359// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
360// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
361const 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 // If the previous child was simple (string), we merge both
379 vNodeChildren[vNodeChildren.length - 1].$text$ += child;
380 }
381 else {
382 // Append a new vNode, if it's text, we create a text vNode
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};
415const 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};
431const Host = {};
432const isHost = (node) => node && node.$tag$ === Host;
433/**
434 * Production setAccessor() function based on Preact by
435 * Jason Miller (@developit)
436 * Licensed under the MIT License
437 * https://github.com/developit/preact/blob/master/LICENSE
438 *
439 * Modified for Stencil's compiler and vdom
440 */
441const 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 // update style attribute, css properties and values
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 // Event Handlers
481 // so if the member name starts with "on" and the 3rd characters is
482 // a capital letter, and it's not already a member on the element,
483 // then we're assuming it's an event listener
484 if (memberName[2] === '-') {
485 // on- prefixed events
486 // allows to be explicit about the dom event to listen without any magic
487 // under the hood:
488 // <my-cmp on-click> // listens for "click"
489 // <my-cmp on-Click> // listens for "Click"
490 // <my-cmp on-ionChange> // listens for "ionChange"
491 // <my-cmp on-EVENTS> // listens for "EVENTS"
492 memberName = memberName.slice(3);
493 }
494 else if (isMemberInElement(win, ln)) {
495 // standard event
496 // the JSX attribute could have been "onMouseOver" and the
497 // member name "onmouseover" is on the window's prototype
498 // so let's add the listener "mouseover", which is all lowercased
499 memberName = ln.slice(2);
500 }
501 else {
502 // custom event
503 // the JSX attribute could have been "onMyCustomEvent"
504 // so let's trim off the "on" prefix and lowercase the first character
505 // and add the listener "myCustomEvent"
506 // except for the first character, we keep the event name case
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 // Set property if it exists and it's not a SVG
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 // Workaround for Safari, moving the <input> caret when re-assigning the same valued
524 if (memberName === 'list') {
525 isProp = false;
526 // tslint:disable-next-line: triple-equals
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 /* isHost */) || isSvg) && !isComplex) {
544 newValue = newValue === true ? '' : newValue;
545 {
546 elm.setAttribute(memberName, newValue);
547 }
548 }
549 }
550};
551const parseClassListRegex = /\s/;
552const parseClassList = (value) => (!value) ? [] : value.split(parseClassListRegex);
553const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
554 // if the element passed in is a shadow root, which is a document fragment
555 // then we want to be adding attrs/props to the shadow root's "host" element
556 // if it's not a shadow root, then we add attrs/props to the same element
557 const elm = (newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && 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 // remove attributes no longer present on the vnode by setting them to undefined
562 for (memberName in oldVnodeAttrs) {
563 if (!(memberName in newVnodeAttrs)) {
564 setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
565 }
566 }
567 }
568 // add new & update changed attributes
569 for (memberName in newVnodeAttrs) {
570 setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
571 }
572};
573const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
574 // tslint:disable-next-line: prefer-const
575 let newVNode = newParentVNode.$children$[childIndex];
576 let i = 0;
577 let elm;
578 let childNode;
579 let oldVNode;
580 if ( !useNativeShadowDom) {
581 // remember for later we need to check to relocate nodes
582 checkSlotRelocate = true;
583 if (newVNode.$tag$ === 'slot') {
584 if (scopeId) {
585 // scoped css needs to add its scoped id to the parent element
586 parentElm.classList.add(scopeId + '-s');
587 }
588 newVNode.$flags$ |= (newVNode.$children$)
589 // slot element has fallback content
590 // still create an element that "mocks" the slot element
591 ? 2 /* isSlotFallback */
592 // slot element does not have fallback content
593 // create an html comment we'll use to always reference
594 // where actual slot content should sit next to
595 : 1 /* isSlotReference */;
596 }
597 }
598 if ( newVNode.$text$ !== null) {
599 // create text node
600 elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
601 }
602 else if ( newVNode.$flags$ & 1 /* isSlotReference */) {
603 // create a slot reference node
604 elm = newVNode.$elm$ = doc.createTextNode('');
605 }
606 else {
607 if ( !isSvgMode) {
608 isSvgMode = newVNode.$tag$ === 'svg';
609 }
610 // create element
611 elm = newVNode.$elm$ = ( doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, ( newVNode.$flags$ & 2 /* isSlotFallback */) ? 'slot-fb' : newVNode.$tag$)
612 );
613 if ( isSvgMode && newVNode.$tag$ === 'foreignObject') {
614 isSvgMode = false;
615 }
616 // add css classes, attrs, props, listeners, etc.
617 {
618 updateElement(null, newVNode, isSvgMode);
619 }
620 if ( isDef(scopeId) && elm['s-si'] !== scopeId) {
621 // if there is a scopeId and this is the initial render
622 // then let's add the scopeId as a css class
623 elm.classList.add((elm['s-si'] = scopeId));
624 }
625 if (newVNode.$children$) {
626 for (i = 0; i < newVNode.$children$.length; ++i) {
627 // create the node
628 childNode = createElm(oldParentVNode, newVNode, i, elm);
629 // return node could have been null
630 if (childNode) {
631 // append our new node
632 elm.appendChild(childNode);
633 }
634 }
635 }
636 {
637 if (newVNode.$tag$ === 'svg') {
638 // Only reset the SVG context when we're exiting <svg> element
639 isSvgMode = false;
640 }
641 else if (elm.tagName === 'foreignObject') {
642 // Reenter SVG context when we're exiting <foreignObject> element
643 isSvgMode = true;
644 }
645 }
646 }
647 {
648 elm['s-hn'] = hostTagName;
649 if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
650 // remember the content reference comment
651 elm['s-sr'] = true;
652 // remember the content reference comment
653 elm['s-cr'] = contentRef;
654 // remember the slot name, or empty string for default slot
655 elm['s-sn'] = newVNode.$name$ || '';
656 // check if we've got an old vnode for this slot
657 oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
658 if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
659 // we've got an old slot vnode and the wrapper is being replaced
660 // so let's move the old slot content back to it's original location
661 putBackInOriginalLocation(oldParentVNode.$elm$, false);
662 }
663 }
664 }
665 return elm;
666};
667const putBackInOriginalLocation = (parentElm, recursive) => {
668 plt.$flags$ |= 1 /* isTmpDisconnected */;
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 // // this child node in the old element is from another component
674 // // remove this node from the old slot's parent
675 // childNode.remove();
676 // and relocate it back to it's original location
677 parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
678 // remove the old original location comment entirely
679 // later on the patch function will know what to do
680 // and move this to the correct spot in need be
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 /* isTmpDisconnected */;
690};
691const 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};
704const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
705 for (; startIdx <= endIdx; ++startIdx) {
706 if (vnode = vnodes[startIdx]) {
707 elm = vnode.$elm$;
708 {
709 // we're removing this element
710 // so it's possible we need to show slot fallback content now
711 checkSlotFallbackVisibility = true;
712 if (elm['s-ol']) {
713 // remove the original location comment
714 elm['s-ol'].remove();
715 }
716 else {
717 // it's possible that child nodes of the node
718 // that's being removed are slot nodes
719 putBackInOriginalLocation(elm, true);
720 }
721 }
722 // remove the vnode's element from the dom
723 elm.remove();
724 }
725 }
726};
727const 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 // Vnode might have been moved left
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 // Vnode moved right
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 // Vnode moved left
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 // new element
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};
801const isSameVnode = (vnode1, vnode2) => {
802 // compare if two vnode to see if they're "technically" the same
803 // need to have the same element tag, and same key to be the same
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};
812const referenceNode = (node) => {
813 // this node was relocated to a new location in the dom
814 // because of some other component's slot
815 // but we still have an html comment in place of where
816 // it's original location was according to it's original vdom
817 return (node && node['s-ol']) || node;
818};
819const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
820const 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 // test if we're rendering an svg element, or still rendering nodes inside of one
827 // only add this to the when the compiler sees we're using an svg somewhere
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 // element node
834 {
835 if ( newVNode.$tag$ === 'slot')
836 ;
837 else {
838 // either this is the first render of an element OR it's an update
839 // AND we already know it's possible it could have changed
840 // this updates the element's css classes, attrs, props, listeners, etc.
841 updateElement(oldVNode, newVNode, isSvgMode);
842 }
843 }
844 if ( oldChildren !== null && newChildren !== null) {
845 // looks like there's child vnodes for both the old and new vnodes
846 updateChildren(elm, oldChildren, newVNode, newChildren);
847 }
848 else if (newChildren !== null) {
849 // no old child vnodes, but there are new child vnodes to add
850 if ( oldVNode.$text$ !== null) {
851 // the old vnode was text, so be sure to clear it out
852 elm.textContent = '';
853 }
854 // add the new vnode children
855 addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
856 }
857 else if ( oldChildren !== null) {
858 // no new child vnodes, but there are old child vnodes to remove
859 removeVnodes(oldChildren, 0, oldChildren.length - 1);
860 }
861 }
862 else if ( (defaultHolder = elm['s-cr'])) {
863 // this element has slotted content
864 defaultHolder.parentNode.textContent = newVNode.$text$;
865 }
866 else if ( oldVNode.$text$ !== newVNode.$text$) {
867 // update the text content for the text only vnode
868 // and also only if the text is different than before
869 elm.data = newVNode.$text$;
870 }
871 if ( isSvgMode && newVNode.$tag$ === 'svg') {
872 isSvgMode = false;
873 }
874};
875const updateFallbackSlotVisibility = (elm) => {
876 // tslint:disable-next-line: prefer-const
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 /* ElementNode */) {
887 if (childNode['s-sr']) {
888 // this is a slot fallback node
889 // get the slot name for this slot reference node
890 slotNameAttr = childNode['s-sn'];
891 // by default always show a fallback slot node
892 // then hide it if there are other slots in the light dom
893 childNode.hidden = false;
894 for (j = 0; j < ilen; j++) {
895 if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
896 // this sibling node is from a different component
897 nodeType = childNodes[j].nodeType;
898 if (slotNameAttr !== '') {
899 // this is a named fallback slot node
900 if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
901 childNode.hidden = true;
902 break;
903 }
904 }
905 else {
906 // this is a default fallback slot node
907 // any element or text node (with content)
908 // should hide the default fallback slot node
909 if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
910 childNode.hidden = true;
911 break;
912 }
913 }
914 }
915 }
916 }
917 // keep drilling down
918 updateFallbackSlotVisibility(childNode);
919 }
920 }
921};
922const relocateNodes = [];
923const relocateSlotContent = (elm) => {
924 // tslint:disable-next-line: prefer-const
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 // first got the content reference comment node
938 // then we got it's parent, which is where all the host content is in now
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 // let's do some relocating to its new home
945 // but never relocate a content reference node
946 // that is suppose to always represent the original content location
947 nodeType = node.nodeType;
948 if (((nodeType === 3 /* TextNode */ || nodeType === 8 /* CommentNode */) && slotNameAttr === '') ||
949 (nodeType === 1 /* ElementNode */ && node.getAttribute('slot') === null && slotNameAttr === '') ||
950 (nodeType === 1 /* ElementNode */ && node.getAttribute('slot') === slotNameAttr)) {
951 // it's possible we've already decided to relocate this node
952 if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
953 // made some changes to slots
954 // let's make sure we also double check
955 // fallbacks are correctly hidden or shown
956 checkSlotFallbackVisibility = true;
957 node['s-sn'] = slotNameAttr;
958 // add to our list of nodes to relocate
959 relocateNodes.push({
960 $slotRefNode$: childNode,
961 $nodeToRelocate$: node
962 });
963 }
964 }
965 }
966 }
967 }
968 if (childNode.nodeType === 1 /* ElementNode */) {
969 relocateSlotContent(childNode);
970 }
971 }
972};
973const 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 /* isHost */;
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 // always reset
994 checkSlotFallbackVisibility = false;
995 }
996 // synchronous patch
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 // add a reference node marking this node's original location
1005 // keep a reference to this node for later lookups
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 // while we're moving nodes around existing nodes, temporarily disable
1012 // the disconnectCallback from working
1013 plt.$flags$ |= 1 /* isTmpDisconnected */;
1014 for (let i = 0; i < relocateNodes.length; i++) {
1015 const relocateNode = relocateNodes[i];
1016 // by default we're just going to insert it directly
1017 // after the slot reference node
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 // we've checked that it's worth while to relocate
1036 // since that the node to relocate
1037 // has a different next sibling or parent relocated
1038 if (relocateNode.$nodeToRelocate$ !== insertBeforeNode) {
1039 // add it back to the dom but in its new home
1040 parentNodeRef.insertBefore(relocateNode.$nodeToRelocate$, insertBeforeNode);
1041 }
1042 }
1043 }
1044 // done moving nodes around
1045 // allow the disconnect callback to work again
1046 plt.$flags$ &= ~1 /* isTmpDisconnected */;
1047 }
1048 if (checkSlotFallbackVisibility) {
1049 updateFallbackSlotVisibility(rootVnode.$elm$);
1050 }
1051 // always reset
1052 relocateNodes.length = 0;
1053 }
1054};
1055const attachToAncestor = (hostRef, ancestorComponent) => {
1056 if ( ancestorComponent && !hostRef.$onRenderResolve$) {
1057 ancestorComponent['s-p'].push(new Promise(r => hostRef.$onRenderResolve$ = r));
1058 }
1059};
1060const scheduleUpdate = (elm, hostRef, cmpMeta, isInitialLoad) => {
1061 {
1062 hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1063 }
1064 if ( hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1065 hostRef.$flags$ |= 512 /* needsRerender */;
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 /* isListenReady */;
1077 if (hostRef.$queuedListeners$) {
1078 hostRef.$queuedListeners$.forEach(([methodName, event]) => safeCall(instance, methodName, event));
1079 hostRef.$queuedListeners$ = null;
1080 }
1081 }
1082 }
1083 endSchedule();
1084 // there is no ancestorc omponent or the ancestor component
1085 // has already fired off its lifecycle update then
1086 // fire off the initial update
1087 return then(promise, () => writeTask(update)
1088 );
1089};
1090const updateComponent = (elm, hostRef, cmpMeta, instance, isInitialLoad) => {
1091 // updateComponent
1092 const endUpdate = createTime('update', cmpMeta.$tagName$);
1093 const rc = elm['s-rc'];
1094 if ( isInitialLoad) {
1095 // DOM WRITE!
1096 attachStyles(elm, cmpMeta, hostRef.$modeName$);
1097 }
1098 const endRender = createTime('render', cmpMeta.$tagName$);
1099 {
1100 {
1101 try {
1102 // looks like we've got child nodes to render into this host element
1103 // or we need to update the css class/attrs on the host element
1104 // DOM WRITE!
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 /* isQueuedForUpdate */;
1117 }
1118 {
1119 hostRef.$flags$ |= 2 /* hasRendered */;
1120 }
1121 if ( rc) {
1122 // ok, so turns out there are some child host elements
1123 // waiting on this parent element to load
1124 // let's fire off all update callbacks waiting
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 /* isWaitingForChildren */;
1139 childrenPromises.length = 0;
1140 }
1141 }
1142};
1143const 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 /* hasLoadedComponent */)) {
1151 hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1152 {
1153 // DOM WRITE!
1154 // add the css class that this element has officially hydrated
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 // load events fire from bottom to top
1169 // the deepest elements load first then bubbles up
1170 {
1171 if (hostRef.$onRenderResolve$) {
1172 hostRef.$onRenderResolve$();
1173 hostRef.$onRenderResolve$ = undefined;
1174 }
1175 if (hostRef.$flags$ & 512 /* needsRerender */) {
1176 nextTick(() => scheduleUpdate(elm, hostRef, cmpMeta, false));
1177 }
1178 hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1179 }
1180 // ( •_•)
1181 // ( •_•)>⌐■-■
1182 // (⌐■_■)
1183};
1184const forceUpdate = (elm, cmpMeta) => {
1185 {
1186 const hostRef = getHostRef(elm);
1187 if ((hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1188 scheduleUpdate(elm, hostRef, cmpMeta, false);
1189 }
1190 }
1191};
1192const appDidLoad = (who) => {
1193 // on appload
1194 // we have finish the first big initial render
1195 {
1196 doc.documentElement.classList.add(HYDRATED_CLASS);
1197 }
1198 {
1199 plt.$flags$ |= 2 /* appLoaded */;
1200 }
1201};
1202const 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};
1213const then = (promise, thenFn) => {
1214 return promise && promise.then ? promise.then(thenFn) : thenFn();
1215};
1216const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1217const setValue = (ref, propName, newVal, cmpMeta) => {
1218 // check our new property value against our internal value
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 // gadzooks! the property's value has changed!!
1227 // set our new value!
1228 hostRef.$instanceValues$.set(propName, newVal);
1229 if ( instance) {
1230 // get an array of method names of watch functions to call
1231 if ( cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1232 const watchMethods = cmpMeta.$watchers$[propName];
1233 if (watchMethods) {
1234 // this instance is watching for when this property changed
1235 watchMethods.forEach(watchMethodName => {
1236 try {
1237 // fire off each of the watch methods that are watching this property
1238 instance[watchMethodName](newVal, oldVal, propName);
1239 }
1240 catch (e) {
1241 consoleError(e);
1242 }
1243 });
1244 }
1245 }
1246 if ( (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1247 // looks like this value actually changed, so we've got work to do!
1248 // but only if we've already rendered, otherwise just chill out
1249 // queue that we need to do an update, but don't worry about queuing
1250 // up millions cuz this function ensures it only runs once
1251 scheduleUpdate(elm, hostRef, cmpMeta, false);
1252 }
1253 }
1254 }
1255};
1256const proxyComponent = (Cstr, cmpMeta, flags) => {
1257 if ( cmpMeta.$members$) {
1258 if ( Cstr.watchers) {
1259 cmpMeta.$watchers$ = Cstr.watchers;
1260 }
1261 // It's better to have a const than two Object.entries()
1262 const members = Object.entries(cmpMeta.$members$);
1263 const prototype = Cstr.prototype;
1264 members.forEach(([memberName, [memberFlags]]) => {
1265 if ( ((memberFlags & 31 /* Prop */) ||
1266 (( flags & 2 /* proxyState */) &&
1267 (memberFlags & 32 /* State */)))) {
1268 // proxyComponent - prop
1269 Object.defineProperty(prototype, memberName, {
1270 get() {
1271 // proxyComponent, get value
1272 return getValue(this, memberName);
1273 },
1274 set(newValue) {
1275 // proxyComponent, set value
1276 setValue(this, memberName, newValue, cmpMeta);
1277 },
1278 configurable: true,
1279 enumerable: true
1280 });
1281 }
1282 });
1283 if ( ( flags & 1 /* isElementConstructor */)) {
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 // create an array of attributes to observe
1294 // and also create a map of html attribute name to js property name
1295 Cstr.observedAttributes = members
1296 .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1297 .map(([propName, m]) => {
1298 const attrName = m[1] || propName;
1299 attrNameToPropName.set(attrName, propName);
1300 if ( m[0] & 512 /* ReflectAttr */) {
1301 cmpMeta.$attrsToReflect$.push([propName, attrName]);
1302 }
1303 return attrName;
1304 });
1305 }
1306 }
1307 return Cstr;
1308};
1309const 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};
1320const hostListenerProxy = (hostRef, methodName) => {
1321 return (ev) => {
1322 {
1323 if (hostRef.$flags$ & 256 /* isListenReady */) {
1324 // instance is ready, let's call it's member method for this event
1325 hostRef.$lazyInstance$[methodName](ev);
1326 }
1327 else {
1328 hostRef.$queuedListeners$.push([methodName, ev]);
1329 }
1330 }
1331 };
1332};
1333const getHostListenerTarget = (elm, flags) => {
1334 if ( flags & 8 /* TargetWindow */)
1335 return win;
1336 return elm;
1337};
1338const hostListenerOpts = (flags) => supportsListenerOptions ?
1339 {
1340 'passive': (flags & 1 /* Passive */) !== 0,
1341 'capture': (flags & 2 /* Capture */) !== 0,
1342 }
1343 : (flags & 2 /* Capture */) !== 0;
1344const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1345 // initializeComponent
1346 if ( (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1347 // we haven't initialized this element yet
1348 hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1349 {
1350 // lazy loaded components
1351 // request the component's implementation to be
1352 // wired up with the host element
1353 Cstr = loadModule(cmpMeta);
1354 if (Cstr.then) {
1355 // Await creates a micro-task avoid if possible
1356 const endLoad = uniqueTime();
1357 Cstr = await Cstr;
1358 endLoad();
1359 }
1360 if ( !Cstr.isProxied) {
1361 // we'eve never proxied this Constructor before
1362 // let's add the getters/setters to its prototype before
1363 // the first time we create an instance of the implementation
1364 {
1365 cmpMeta.$watchers$ = Cstr.watchers;
1366 }
1367 proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1368 Cstr.isProxied = true;
1369 }
1370 const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1371 // ok, time to construct the instance
1372 // but let's keep track of when we start and stop
1373 // so that the getters/setters don't incorrectly step on data
1374 {
1375 hostRef.$flags$ |= 8 /* isConstructingInstance */;
1376 }
1377 // construct the lazy-loaded component implementation
1378 // passing the hostRef is very important during
1379 // construction in order to directly wire together the
1380 // host element and the lazy-loaded instance
1381 try {
1382 new Cstr(hostRef);
1383 }
1384 catch (e) {
1385 consoleError(e);
1386 }
1387 {
1388 hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1389 }
1390 {
1391 hostRef.$flags$ |= 128 /* isWatchReady */;
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 // this component has styles but we haven't registered them yet
1400 let style = Cstr.style;
1401 registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1402 endRegisterStyles();
1403 }
1404 }
1405 // we've successfully created a lazy instance
1406 const ancestorComponent = hostRef.$ancestorComponent$;
1407 const schedule = () => scheduleUpdate(elm, hostRef, cmpMeta, true);
1408 if ( ancestorComponent && ancestorComponent['s-rc']) {
1409 // this is the intial load and this component it has an ancestor component
1410 // but the ancestor component has NOT fired its will update lifecycle yet
1411 // so let's just cool our jets and wait for the ancestor to continue first
1412 // this will get fired off when the ancestor component
1413 // finally gets around to rendering its lazy self
1414 // fire off the initial update
1415 ancestorComponent['s-rc'].push(schedule);
1416 }
1417 else {
1418 schedule();
1419 }
1420};
1421const fireConnectedCallback = (instance) => {
1422 {
1423 safeCall(instance, 'connectedCallback');
1424 }
1425};
1426const connectedCallback = (elm, cmpMeta) => {
1427 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1428 const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1429 // connectedCallback
1430 const hostRef = getHostRef(elm);
1431 if ( cmpMeta.$listeners$) {
1432 // initialize our event listeners on the host element
1433 // we do this now so that we can listening to events that may
1434 // have fired even before the instance is ready
1435 hostRef.$rmListeners$ = addEventListeners(elm, hostRef, cmpMeta.$listeners$);
1436 }
1437 if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1438 // first time this component has connected
1439 hostRef.$flags$ |= 1 /* hasConnected */;
1440 let hostId;
1441 if ( !hostId) {
1442 // initUpdate
1443 // if the slot polyfill is required we'll need to put some nodes
1444 // in here to act as original content anchors as we move nodes around
1445 // host element has been connected to the DOM
1446 if (
1447 ( cmpMeta.$flags$ & 4 /* hasSlotRelocation */) ||
1448 (BUILD.shadowDom /* needsShadowDomShim */)) {
1449 setContentReference(elm);
1450 }
1451 }
1452 {
1453 // find the first ancestor component (if there is one) and register
1454 // this component as one of the actively loading child components for its ancestor
1455 let ancestorComponent = elm;
1456 while ((ancestorComponent = (ancestorComponent.parentNode || ancestorComponent.host))) {
1457 // climb up the ancestors looking for the first
1458 // component that hasn't finished its lifecycle update yet
1459 if (
1460 (ancestorComponent['s-p'])) {
1461 // we found this components first ancestor component
1462 // keep a reference to this component's ancestor component
1463 attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1464 break;
1465 }
1466 }
1467 }
1468 // Lazy properties
1469 // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1470 if ( cmpMeta.$members$) {
1471 Object.entries(cmpMeta.$members$).forEach(([memberName, [memberFlags]]) => {
1472 if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1473 const value = elm[memberName];
1474 delete elm[memberName];
1475 elm[memberName] = value;
1476 }
1477 });
1478 }
1479 {
1480 // connectedCallback, taskQueue, initialLoad
1481 // angular sets attribute AFTER connectCallback
1482 // https://github.com/angular/angular/issues/18909
1483 // https://github.com/angular/angular/issues/19940
1484 nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
1485 }
1486 }
1487 fireConnectedCallback(hostRef.$lazyInstance$);
1488 endConnected();
1489 }
1490};
1491const setContentReference = (elm) => {
1492 // only required when we're NOT using native shadow dom (slot)
1493 // or this browser doesn't support native shadow dom
1494 // and this host element was NOT created with SSR
1495 // let's pick out the inner content for slot projection
1496 // create a node to represent where the original
1497 // content was first placed, which is useful later on
1498 const crName = '';
1499 const contentRefElm = elm['s-cr'] = doc.createComment(crName);
1500 contentRefElm['s-cn'] = true;
1501 elm.insertBefore(contentRefElm, elm.firstChild);
1502};
1503const disconnectedCallback = (elm) => {
1504 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1505 const hostRef = getHostRef(elm);
1506 {
1507 if (hostRef.$rmListeners$) {
1508 hostRef.$rmListeners$();
1509 hostRef.$rmListeners$ = undefined;
1510 }
1511 }
1512 // clear CSS var-shim tracking
1513 if ( plt.$cssShim$) {
1514 plt.$cssShim$.removeHost(elm);
1515 }
1516 }
1517};
1518const 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 = /*@__PURE__*/ head.querySelector('meta[charset]');
1525 const visibilityStyle = /*@__PURE__*/ 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 /* queueSync */;
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 // StencilLazyHost
1556 constructor(self) {
1557 // @ts-ignore
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 // connectedCallback will be processed once all components have been registered
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 /* isElementConstructor */));
1591 }
1592 }));
1593 // visibilityStyle.innerHTML = cmpTags.map(t => `${t}:not(.hydrated)`) + '{display:none}';
1594 visibilityStyle.innerHTML = cmpTags + '{visibility:hidden}.hydrated{visibility:inherit}';
1595 visibilityStyle.setAttribute('data-styles', '');
1596 head.insertBefore(visibilityStyle, y ? y.nextSibling : head.firstChild);
1597 // Process deferred connectedCallbacks now all components have been registered
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 // Fallback appLoad event
1606 endBootstrap();
1607};
1608const getElement = (ref) => getHostRef(ref).$hostElement$ ;
1609
1610export { patchEsm as a, bootstrapLazy as b, getElement as g, h, patchBrowser as p, registerInstance as r };