UNPKG

66.5 kBJavaScriptView Raw
1'use strict';
2
3function _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
22const 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};
23const NAMESPACE = 'anjuna-docs';
24
25let queueCongestion = 0;
26let queuePending = false;
27let scopeId;
28let contentRef;
29let hostTagName;
30let useNativeShadowDom = false;
31let checkSlotFallbackVisibility = false;
32let checkSlotRelocate = false;
33let isSvgMode = false;
34const win = window;
35const doc = document;
36const 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};
44const supportsShadowDom = false;
45const supportsListenerOptions = /*@__PURE__*/ (() => {
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})();
55const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
56 try {
57 new CSSStyleSheet();
58 return true;
59 }
60 catch (e) { }
61 return false;
62})() ;
63const hostRefs = new WeakMap();
64const getHostRef = (ref) => hostRefs.get(ref);
65const registerInstance = (lazyInstance, hostRef) => hostRefs.set(hostRef.$lazyInstance$ = lazyInstance, hostRef);
66const 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};
79const isMemberInElement = (elm, memberName) => memberName in elm;
80const consoleError = (e) => console.error(e);
81const moduleCache = /*@__PURE__*/ new Map();
82const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
83 // loadModuleImport
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 /* webpackInclude: /\.entry\.js$/ */
92 /* webpackExclude: /\.system\.entry\.js$/ */
93 /* webpackMode: "lazy" */
94 `./${bundleId}.entry.js${ ''}`))); }).then(importedModule => {
95 {
96 moduleCache.set(bundleId, importedModule);
97 }
98 return importedModule[exportName];
99 }, consoleError);
100};
101const styles = new Map();
102const queueDomReads = [];
103const queueDomWrites = [];
104const queueDomWritesLow = [];
105const queueTask = (queue, write) => (cb) => {
106 queue.push(cb);
107 if (!queuePending) {
108 queuePending = true;
109 if (write && plt.$flags$ & 4 /* queueSync */) {
110 nextTick(flush);
111 }
112 else {
113 plt.raf(flush);
114 }
115 }
116};
117const 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};
128const 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};
146const flush = () => {
147 queueCongestion++;
148 // always force a bunch of medium callbacks to run, but still have
149 // a throttle on how many can run in a certain time
150 // DOM READS!!!
151 consume(queueDomReads);
152 const timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */
153 ? performance.now() + (10 * Math.ceil(queueCongestion * (1.0 / 22.0)))
154 : Infinity;
155 // DOM WRITES!!!
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 // still more to do yet, but we've run out of time
164 // let's let this thing cool off and try again in the next tick
165 plt.raf(flush);
166 }
167 else {
168 queueCongestion = 0;
169 }
170};
171const nextTick = /*@__PURE__*/ (cb) => Promise.resolve().then(cb);
172const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
173/**
174 * Default style mode id
175 */
176/**
177 * Reusable empty obj/array
178 * Don't add values to these!!
179 */
180const EMPTY_OBJ = {};
181/**
182 * Namespaces
183 */
184const SVG_NS = 'http://www.w3.org/2000/svg';
185const HTML_NS = 'http://www.w3.org/1999/xhtml';
186const isDef = (v) => v != null;
187const isComplexType = (o) => {
188 // https://jsperf.com/typeof-fn-object/5
189 o = typeof o;
190 return o === 'object' || o === 'function';
191};
192const getDynamicImportFunction = (namespace) => {
193 return `__sc_import_${namespace.replace(/\s|-/g, '_')}`;
194};
195const patchEsm = () => {
196 // @ts-ignore
197 if ( !(win.CSS && win.CSS.supports && win.CSS.supports('color', 'var(--c)'))) {
198 // @ts-ignore
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};
208const patchBrowser = async () => {
209 {
210 plt.$cssShim$ = win.__stencil_cssshim;
211 }
212 // @ts-ignore
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 // @ts-ignore
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};
231const patchDynamicImport = (base) => {
232 const importFunctionName = getDynamicImportFunction(NAMESPACE);
233 try {
234 // There is a caching issue in V8, that breaks using import() in Function
235 // By generating a random string, we can workaround it
236 // Check https://bugs.chromium.org/p/v8/issues/detail?id=9558 for more info
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};
261const parsePropertyValue = (propValue, propType) => {
262 // ensure this value is of the correct prop type
263 if (propValue != null && !isComplexType(propValue)) {
264 if ( propType & 4 /* Boolean */) {
265 // per the HTML spec, any string value means it is a boolean true value
266 // but we'll cheat here and say that the string "false" is the boolean false
267 return (propValue === 'false' ? false : propValue === '' || !!propValue);
268 }
269 if ( propType & 1 /* String */) {
270 // could have been passed as a number or boolean
271 // but we still want it as a string
272 return String(propValue);
273 }
274 // redundant return here for better minification
275 return propValue;
276 }
277 // not sure exactly what type we want
278 // so no need to change to a different type
279 return propValue;
280};
281const HYDRATED_CLASS = 'hydrated';
282const createTime = (fnName, tagName = '') => {
283 {
284 return () => { return; };
285 }
286};
287const uniqueTime = (key, measureText) => {
288 {
289 return () => { return; };
290 }
291};
292const rootAppliedStyles = new WeakMap();
293const 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};
304const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
305 let scopeId = getScopeId(cmpMeta.$tagName$);
306 let style = styles.get(scopeId);
307 // if an element is NOT connected then getRootNode() will return the wrong root node
308 // so the fallback is to always use the document for the root node in those cases
309 styleContainerNode = (styleContainerNode.nodeType === 11 /* DocumentFragment */ ? 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 /* needsScopedEncapsulation */));
322 const newScopeId = styleElm['s-sc'];
323 if (newScopeId) {
324 scopeId = newScopeId;
325 // we don't want to add this styleID to the appliedStyles Set
326 // since the cssVarShim might need to apply several different
327 // stylesheets for the same component
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};
351const 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 /* needsScopedEncapsulation */) {
355 // only required when we're NOT using native shadow dom (slot)
356 // or this browser doesn't support native shadow dom
357 // and this host element was NOT created with SSR
358 // let's pick out the inner content for slot projection
359 // create a node to represent where the original
360 // content was first placed, which is useful later on
361 // DOM WRITE!!
362 elm['s-sc'] = scopeId;
363 elm.classList.add(scopeId + '-h');
364 if ( cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
365 elm.classList.add(scopeId + '-s');
366 }
367 }
368 endAttachStyles();
369};
370const getScopeId = (tagName, mode) => 'sc-' + ( tagName);
371/**
372 * Production h() function based on Preact by
373 * Jason Miller (@developit)
374 * Licensed under the MIT License
375 * https://github.com/developit/preact/blob/master/LICENSE
376 *
377 * Modified for Stencil's compiler and vdom
378 */
379// const stack: any[] = [];
380// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
381// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
382const 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 // If the previous child was simple (string), we merge both
400 vNodeChildren[vNodeChildren.length - 1].$text$ += child;
401 }
402 else {
403 // Append a new vNode, if it's text, we create a text vNode
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};
436const 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};
452const Host = {};
453const isHost = (node) => node && node.$tag$ === Host;
454/**
455 * Production setAccessor() function based on Preact by
456 * Jason Miller (@developit)
457 * Licensed under the MIT License
458 * https://github.com/developit/preact/blob/master/LICENSE
459 *
460 * Modified for Stencil's compiler and vdom
461 */
462const 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 // update style attribute, css properties and values
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 // Event Handlers
502 // so if the member name starts with "on" and the 3rd characters is
503 // a capital letter, and it's not already a member on the element,
504 // then we're assuming it's an event listener
505 if (memberName[2] === '-') {
506 // on- prefixed events
507 // allows to be explicit about the dom event to listen without any magic
508 // under the hood:
509 // <my-cmp on-click> // listens for "click"
510 // <my-cmp on-Click> // listens for "Click"
511 // <my-cmp on-ionChange> // listens for "ionChange"
512 // <my-cmp on-EVENTS> // listens for "EVENTS"
513 memberName = memberName.slice(3);
514 }
515 else if (isMemberInElement(win, ln)) {
516 // standard event
517 // the JSX attribute could have been "onMouseOver" and the
518 // member name "onmouseover" is on the window's prototype
519 // so let's add the listener "mouseover", which is all lowercased
520 memberName = ln.slice(2);
521 }
522 else {
523 // custom event
524 // the JSX attribute could have been "onMyCustomEvent"
525 // so let's trim off the "on" prefix and lowercase the first character
526 // and add the listener "myCustomEvent"
527 // except for the first character, we keep the event name case
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 // Set property if it exists and it's not a SVG
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 // Workaround for Safari, moving the <input> caret when re-assigning the same valued
545 if (memberName === 'list') {
546 isProp = false;
547 // tslint:disable-next-line: triple-equals
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 /* isHost */) || isSvg) && !isComplex) {
565 newValue = newValue === true ? '' : newValue;
566 {
567 elm.setAttribute(memberName, newValue);
568 }
569 }
570 }
571};
572const parseClassListRegex = /\s/;
573const parseClassList = (value) => (!value) ? [] : value.split(parseClassListRegex);
574const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
575 // if the element passed in is a shadow root, which is a document fragment
576 // then we want to be adding attrs/props to the shadow root's "host" element
577 // if it's not a shadow root, then we add attrs/props to the same element
578 const elm = (newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && 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 // remove attributes no longer present on the vnode by setting them to undefined
583 for (memberName in oldVnodeAttrs) {
584 if (!(memberName in newVnodeAttrs)) {
585 setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
586 }
587 }
588 }
589 // add new & update changed attributes
590 for (memberName in newVnodeAttrs) {
591 setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
592 }
593};
594const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
595 // tslint:disable-next-line: prefer-const
596 let newVNode = newParentVNode.$children$[childIndex];
597 let i = 0;
598 let elm;
599 let childNode;
600 let oldVNode;
601 if ( !useNativeShadowDom) {
602 // remember for later we need to check to relocate nodes
603 checkSlotRelocate = true;
604 if (newVNode.$tag$ === 'slot') {
605 if (scopeId) {
606 // scoped css needs to add its scoped id to the parent element
607 parentElm.classList.add(scopeId + '-s');
608 }
609 newVNode.$flags$ |= (newVNode.$children$)
610 // slot element has fallback content
611 // still create an element that "mocks" the slot element
612 ? 2 /* isSlotFallback */
613 // slot element does not have fallback content
614 // create an html comment we'll use to always reference
615 // where actual slot content should sit next to
616 : 1 /* isSlotReference */;
617 }
618 }
619 if ( newVNode.$text$ !== null) {
620 // create text node
621 elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
622 }
623 else if ( newVNode.$flags$ & 1 /* isSlotReference */) {
624 // create a slot reference node
625 elm = newVNode.$elm$ = doc.createTextNode('');
626 }
627 else {
628 if ( !isSvgMode) {
629 isSvgMode = newVNode.$tag$ === 'svg';
630 }
631 // create element
632 elm = newVNode.$elm$ = ( doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, ( newVNode.$flags$ & 2 /* isSlotFallback */) ? 'slot-fb' : newVNode.$tag$)
633 );
634 if ( isSvgMode && newVNode.$tag$ === 'foreignObject') {
635 isSvgMode = false;
636 }
637 // add css classes, attrs, props, listeners, etc.
638 {
639 updateElement(null, newVNode, isSvgMode);
640 }
641 if ( isDef(scopeId) && elm['s-si'] !== scopeId) {
642 // if there is a scopeId and this is the initial render
643 // then let's add the scopeId as a css class
644 elm.classList.add((elm['s-si'] = scopeId));
645 }
646 if (newVNode.$children$) {
647 for (i = 0; i < newVNode.$children$.length; ++i) {
648 // create the node
649 childNode = createElm(oldParentVNode, newVNode, i, elm);
650 // return node could have been null
651 if (childNode) {
652 // append our new node
653 elm.appendChild(childNode);
654 }
655 }
656 }
657 {
658 if (newVNode.$tag$ === 'svg') {
659 // Only reset the SVG context when we're exiting <svg> element
660 isSvgMode = false;
661 }
662 else if (elm.tagName === 'foreignObject') {
663 // Reenter SVG context when we're exiting <foreignObject> element
664 isSvgMode = true;
665 }
666 }
667 }
668 {
669 elm['s-hn'] = hostTagName;
670 if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
671 // remember the content reference comment
672 elm['s-sr'] = true;
673 // remember the content reference comment
674 elm['s-cr'] = contentRef;
675 // remember the slot name, or empty string for default slot
676 elm['s-sn'] = newVNode.$name$ || '';
677 // check if we've got an old vnode for this slot
678 oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
679 if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
680 // we've got an old slot vnode and the wrapper is being replaced
681 // so let's move the old slot content back to it's original location
682 putBackInOriginalLocation(oldParentVNode.$elm$, false);
683 }
684 }
685 }
686 return elm;
687};
688const putBackInOriginalLocation = (parentElm, recursive) => {
689 plt.$flags$ |= 1 /* isTmpDisconnected */;
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 // // this child node in the old element is from another component
695 // // remove this node from the old slot's parent
696 // childNode.remove();
697 // and relocate it back to it's original location
698 parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
699 // remove the old original location comment entirely
700 // later on the patch function will know what to do
701 // and move this to the correct spot in need be
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 /* isTmpDisconnected */;
711};
712const 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};
725const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
726 for (; startIdx <= endIdx; ++startIdx) {
727 if (vnode = vnodes[startIdx]) {
728 elm = vnode.$elm$;
729 {
730 // we're removing this element
731 // so it's possible we need to show slot fallback content now
732 checkSlotFallbackVisibility = true;
733 if (elm['s-ol']) {
734 // remove the original location comment
735 elm['s-ol'].remove();
736 }
737 else {
738 // it's possible that child nodes of the node
739 // that's being removed are slot nodes
740 putBackInOriginalLocation(elm, true);
741 }
742 }
743 // remove the vnode's element from the dom
744 elm.remove();
745 }
746 }
747};
748const 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 // Vnode might have been moved left
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 // Vnode moved right
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 // Vnode moved left
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 // new element
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};
822const isSameVnode = (vnode1, vnode2) => {
823 // compare if two vnode to see if they're "technically" the same
824 // need to have the same element tag, and same key to be the same
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};
833const referenceNode = (node) => {
834 // this node was relocated to a new location in the dom
835 // because of some other component's slot
836 // but we still have an html comment in place of where
837 // it's original location was according to it's original vdom
838 return (node && node['s-ol']) || node;
839};
840const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
841const 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 // test if we're rendering an svg element, or still rendering nodes inside of one
848 // only add this to the when the compiler sees we're using an svg somewhere
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 // element node
855 {
856 if ( newVNode.$tag$ === 'slot')
857 ;
858 else {
859 // either this is the first render of an element OR it's an update
860 // AND we already know it's possible it could have changed
861 // this updates the element's css classes, attrs, props, listeners, etc.
862 updateElement(oldVNode, newVNode, isSvgMode);
863 }
864 }
865 if ( oldChildren !== null && newChildren !== null) {
866 // looks like there's child vnodes for both the old and new vnodes
867 updateChildren(elm, oldChildren, newVNode, newChildren);
868 }
869 else if (newChildren !== null) {
870 // no old child vnodes, but there are new child vnodes to add
871 if ( oldVNode.$text$ !== null) {
872 // the old vnode was text, so be sure to clear it out
873 elm.textContent = '';
874 }
875 // add the new vnode children
876 addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
877 }
878 else if ( oldChildren !== null) {
879 // no new child vnodes, but there are old child vnodes to remove
880 removeVnodes(oldChildren, 0, oldChildren.length - 1);
881 }
882 }
883 else if ( (defaultHolder = elm['s-cr'])) {
884 // this element has slotted content
885 defaultHolder.parentNode.textContent = newVNode.$text$;
886 }
887 else if ( oldVNode.$text$ !== newVNode.$text$) {
888 // update the text content for the text only vnode
889 // and also only if the text is different than before
890 elm.data = newVNode.$text$;
891 }
892 if ( isSvgMode && newVNode.$tag$ === 'svg') {
893 isSvgMode = false;
894 }
895};
896const updateFallbackSlotVisibility = (elm) => {
897 // tslint:disable-next-line: prefer-const
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 /* ElementNode */) {
908 if (childNode['s-sr']) {
909 // this is a slot fallback node
910 // get the slot name for this slot reference node
911 slotNameAttr = childNode['s-sn'];
912 // by default always show a fallback slot node
913 // then hide it if there are other slots in the light dom
914 childNode.hidden = false;
915 for (j = 0; j < ilen; j++) {
916 if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
917 // this sibling node is from a different component
918 nodeType = childNodes[j].nodeType;
919 if (slotNameAttr !== '') {
920 // this is a named fallback slot node
921 if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
922 childNode.hidden = true;
923 break;
924 }
925 }
926 else {
927 // this is a default fallback slot node
928 // any element or text node (with content)
929 // should hide the default fallback slot node
930 if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
931 childNode.hidden = true;
932 break;
933 }
934 }
935 }
936 }
937 }
938 // keep drilling down
939 updateFallbackSlotVisibility(childNode);
940 }
941 }
942};
943const relocateNodes = [];
944const relocateSlotContent = (elm) => {
945 // tslint:disable-next-line: prefer-const
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 // first got the content reference comment node
959 // then we got it's parent, which is where all the host content is in now
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 // let's do some relocating to its new home
966 // but never relocate a content reference node
967 // that is suppose to always represent the original content location
968 nodeType = node.nodeType;
969 if (((nodeType === 3 /* TextNode */ || nodeType === 8 /* CommentNode */) && slotNameAttr === '') ||
970 (nodeType === 1 /* ElementNode */ && node.getAttribute('slot') === null && slotNameAttr === '') ||
971 (nodeType === 1 /* ElementNode */ && node.getAttribute('slot') === slotNameAttr)) {
972 // it's possible we've already decided to relocate this node
973 if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
974 // made some changes to slots
975 // let's make sure we also double check
976 // fallbacks are correctly hidden or shown
977 checkSlotFallbackVisibility = true;
978 node['s-sn'] = slotNameAttr;
979 // add to our list of nodes to relocate
980 relocateNodes.push({
981 $slotRefNode$: childNode,
982 $nodeToRelocate$: node
983 });
984 }
985 }
986 }
987 }
988 }
989 if (childNode.nodeType === 1 /* ElementNode */) {
990 relocateSlotContent(childNode);
991 }
992 }
993};
994const 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 /* isHost */;
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 // always reset
1015 checkSlotFallbackVisibility = false;
1016 }
1017 // synchronous patch
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 // add a reference node marking this node's original location
1026 // keep a reference to this node for later lookups
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 // while we're moving nodes around existing nodes, temporarily disable
1033 // the disconnectCallback from working
1034 plt.$flags$ |= 1 /* isTmpDisconnected */;
1035 for (let i = 0; i < relocateNodes.length; i++) {
1036 const relocateNode = relocateNodes[i];
1037 // by default we're just going to insert it directly
1038 // after the slot reference node
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 // we've checked that it's worth while to relocate
1057 // since that the node to relocate
1058 // has a different next sibling or parent relocated
1059 if (relocateNode.$nodeToRelocate$ !== insertBeforeNode) {
1060 // add it back to the dom but in its new home
1061 parentNodeRef.insertBefore(relocateNode.$nodeToRelocate$, insertBeforeNode);
1062 }
1063 }
1064 }
1065 // done moving nodes around
1066 // allow the disconnect callback to work again
1067 plt.$flags$ &= ~1 /* isTmpDisconnected */;
1068 }
1069 if (checkSlotFallbackVisibility) {
1070 updateFallbackSlotVisibility(rootVnode.$elm$);
1071 }
1072 // always reset
1073 relocateNodes.length = 0;
1074 }
1075};
1076const attachToAncestor = (hostRef, ancestorComponent) => {
1077 if ( ancestorComponent && !hostRef.$onRenderResolve$) {
1078 ancestorComponent['s-p'].push(new Promise(r => hostRef.$onRenderResolve$ = r));
1079 }
1080};
1081const scheduleUpdate = (elm, hostRef, cmpMeta, isInitialLoad) => {
1082 {
1083 hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1084 }
1085 if ( hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1086 hostRef.$flags$ |= 512 /* needsRerender */;
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 /* isListenReady */;
1098 if (hostRef.$queuedListeners$) {
1099 hostRef.$queuedListeners$.forEach(([methodName, event]) => safeCall(instance, methodName, event));
1100 hostRef.$queuedListeners$ = null;
1101 }
1102 }
1103 }
1104 endSchedule();
1105 // there is no ancestorc omponent or the ancestor component
1106 // has already fired off its lifecycle update then
1107 // fire off the initial update
1108 return then(promise, () => writeTask(update)
1109 );
1110};
1111const updateComponent = (elm, hostRef, cmpMeta, instance, isInitialLoad) => {
1112 // updateComponent
1113 const endUpdate = createTime('update', cmpMeta.$tagName$);
1114 const rc = elm['s-rc'];
1115 if ( isInitialLoad) {
1116 // DOM WRITE!
1117 attachStyles(elm, cmpMeta, hostRef.$modeName$);
1118 }
1119 const endRender = createTime('render', cmpMeta.$tagName$);
1120 {
1121 {
1122 try {
1123 // looks like we've got child nodes to render into this host element
1124 // or we need to update the css class/attrs on the host element
1125 // DOM WRITE!
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 /* isQueuedForUpdate */;
1138 }
1139 {
1140 hostRef.$flags$ |= 2 /* hasRendered */;
1141 }
1142 if ( rc) {
1143 // ok, so turns out there are some child host elements
1144 // waiting on this parent element to load
1145 // let's fire off all update callbacks waiting
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 /* isWaitingForChildren */;
1160 childrenPromises.length = 0;
1161 }
1162 }
1163};
1164const 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 /* hasLoadedComponent */)) {
1172 hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1173 {
1174 // DOM WRITE!
1175 // add the css class that this element has officially hydrated
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 // load events fire from bottom to top
1190 // the deepest elements load first then bubbles up
1191 {
1192 if (hostRef.$onRenderResolve$) {
1193 hostRef.$onRenderResolve$();
1194 hostRef.$onRenderResolve$ = undefined;
1195 }
1196 if (hostRef.$flags$ & 512 /* needsRerender */) {
1197 nextTick(() => scheduleUpdate(elm, hostRef, cmpMeta, false));
1198 }
1199 hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1200 }
1201 // ( •_•)
1202 // ( •_•)>⌐■-■
1203 // (⌐■_■)
1204};
1205const forceUpdate = (elm, cmpMeta) => {
1206 {
1207 const hostRef = getHostRef(elm);
1208 if ((hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1209 scheduleUpdate(elm, hostRef, cmpMeta, false);
1210 }
1211 }
1212};
1213const appDidLoad = (who) => {
1214 // on appload
1215 // we have finish the first big initial render
1216 {
1217 doc.documentElement.classList.add(HYDRATED_CLASS);
1218 }
1219 {
1220 plt.$flags$ |= 2 /* appLoaded */;
1221 }
1222};
1223const 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};
1234const then = (promise, thenFn) => {
1235 return promise && promise.then ? promise.then(thenFn) : thenFn();
1236};
1237const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1238const setValue = (ref, propName, newVal, cmpMeta) => {
1239 // check our new property value against our internal value
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 // gadzooks! the property's value has changed!!
1248 // set our new value!
1249 hostRef.$instanceValues$.set(propName, newVal);
1250 if ( instance) {
1251 // get an array of method names of watch functions to call
1252 if ( cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1253 const watchMethods = cmpMeta.$watchers$[propName];
1254 if (watchMethods) {
1255 // this instance is watching for when this property changed
1256 watchMethods.forEach(watchMethodName => {
1257 try {
1258 // fire off each of the watch methods that are watching this property
1259 instance[watchMethodName](newVal, oldVal, propName);
1260 }
1261 catch (e) {
1262 consoleError(e);
1263 }
1264 });
1265 }
1266 }
1267 if ( (flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1268 // looks like this value actually changed, so we've got work to do!
1269 // but only if we've already rendered, otherwise just chill out
1270 // queue that we need to do an update, but don't worry about queuing
1271 // up millions cuz this function ensures it only runs once
1272 scheduleUpdate(elm, hostRef, cmpMeta, false);
1273 }
1274 }
1275 }
1276};
1277const proxyComponent = (Cstr, cmpMeta, flags) => {
1278 if ( cmpMeta.$members$) {
1279 if ( Cstr.watchers) {
1280 cmpMeta.$watchers$ = Cstr.watchers;
1281 }
1282 // It's better to have a const than two Object.entries()
1283 const members = Object.entries(cmpMeta.$members$);
1284 const prototype = Cstr.prototype;
1285 members.forEach(([memberName, [memberFlags]]) => {
1286 if ( ((memberFlags & 31 /* Prop */) ||
1287 (( flags & 2 /* proxyState */) &&
1288 (memberFlags & 32 /* State */)))) {
1289 // proxyComponent - prop
1290 Object.defineProperty(prototype, memberName, {
1291 get() {
1292 // proxyComponent, get value
1293 return getValue(this, memberName);
1294 },
1295 set(newValue) {
1296 // proxyComponent, set value
1297 setValue(this, memberName, newValue, cmpMeta);
1298 },
1299 configurable: true,
1300 enumerable: true
1301 });
1302 }
1303 });
1304 if ( ( flags & 1 /* isElementConstructor */)) {
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 // create an array of attributes to observe
1315 // and also create a map of html attribute name to js property name
1316 Cstr.observedAttributes = members
1317 .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1318 .map(([propName, m]) => {
1319 const attrName = m[1] || propName;
1320 attrNameToPropName.set(attrName, propName);
1321 if ( m[0] & 512 /* ReflectAttr */) {
1322 cmpMeta.$attrsToReflect$.push([propName, attrName]);
1323 }
1324 return attrName;
1325 });
1326 }
1327 }
1328 return Cstr;
1329};
1330const 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};
1341const hostListenerProxy = (hostRef, methodName) => {
1342 return (ev) => {
1343 {
1344 if (hostRef.$flags$ & 256 /* isListenReady */) {
1345 // instance is ready, let's call it's member method for this event
1346 hostRef.$lazyInstance$[methodName](ev);
1347 }
1348 else {
1349 hostRef.$queuedListeners$.push([methodName, ev]);
1350 }
1351 }
1352 };
1353};
1354const getHostListenerTarget = (elm, flags) => {
1355 if ( flags & 8 /* TargetWindow */)
1356 return win;
1357 return elm;
1358};
1359const hostListenerOpts = (flags) => supportsListenerOptions ?
1360 {
1361 'passive': (flags & 1 /* Passive */) !== 0,
1362 'capture': (flags & 2 /* Capture */) !== 0,
1363 }
1364 : (flags & 2 /* Capture */) !== 0;
1365const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1366 // initializeComponent
1367 if ( (hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1368 // we haven't initialized this element yet
1369 hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1370 {
1371 // lazy loaded components
1372 // request the component's implementation to be
1373 // wired up with the host element
1374 Cstr = loadModule(cmpMeta);
1375 if (Cstr.then) {
1376 // Await creates a micro-task avoid if possible
1377 const endLoad = uniqueTime();
1378 Cstr = await Cstr;
1379 endLoad();
1380 }
1381 if ( !Cstr.isProxied) {
1382 // we'eve never proxied this Constructor before
1383 // let's add the getters/setters to its prototype before
1384 // the first time we create an instance of the implementation
1385 {
1386 cmpMeta.$watchers$ = Cstr.watchers;
1387 }
1388 proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1389 Cstr.isProxied = true;
1390 }
1391 const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1392 // ok, time to construct the instance
1393 // but let's keep track of when we start and stop
1394 // so that the getters/setters don't incorrectly step on data
1395 {
1396 hostRef.$flags$ |= 8 /* isConstructingInstance */;
1397 }
1398 // construct the lazy-loaded component implementation
1399 // passing the hostRef is very important during
1400 // construction in order to directly wire together the
1401 // host element and the lazy-loaded instance
1402 try {
1403 new Cstr(hostRef);
1404 }
1405 catch (e) {
1406 consoleError(e);
1407 }
1408 {
1409 hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1410 }
1411 {
1412 hostRef.$flags$ |= 128 /* isWatchReady */;
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 // this component has styles but we haven't registered them yet
1421 let style = Cstr.style;
1422 registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1423 endRegisterStyles();
1424 }
1425 }
1426 // we've successfully created a lazy instance
1427 const ancestorComponent = hostRef.$ancestorComponent$;
1428 const schedule = () => scheduleUpdate(elm, hostRef, cmpMeta, true);
1429 if ( ancestorComponent && ancestorComponent['s-rc']) {
1430 // this is the intial load and this component it has an ancestor component
1431 // but the ancestor component has NOT fired its will update lifecycle yet
1432 // so let's just cool our jets and wait for the ancestor to continue first
1433 // this will get fired off when the ancestor component
1434 // finally gets around to rendering its lazy self
1435 // fire off the initial update
1436 ancestorComponent['s-rc'].push(schedule);
1437 }
1438 else {
1439 schedule();
1440 }
1441};
1442const fireConnectedCallback = (instance) => {
1443 {
1444 safeCall(instance, 'connectedCallback');
1445 }
1446};
1447const connectedCallback = (elm, cmpMeta) => {
1448 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1449 const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1450 // connectedCallback
1451 const hostRef = getHostRef(elm);
1452 if ( cmpMeta.$listeners$) {
1453 // initialize our event listeners on the host element
1454 // we do this now so that we can listening to events that may
1455 // have fired even before the instance is ready
1456 hostRef.$rmListeners$ = addEventListeners(elm, hostRef, cmpMeta.$listeners$);
1457 }
1458 if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1459 // first time this component has connected
1460 hostRef.$flags$ |= 1 /* hasConnected */;
1461 let hostId;
1462 if ( !hostId) {
1463 // initUpdate
1464 // if the slot polyfill is required we'll need to put some nodes
1465 // in here to act as original content anchors as we move nodes around
1466 // host element has been connected to the DOM
1467 if (
1468 ( cmpMeta.$flags$ & 4 /* hasSlotRelocation */) ||
1469 (BUILD.shadowDom /* needsShadowDomShim */)) {
1470 setContentReference(elm);
1471 }
1472 }
1473 {
1474 // find the first ancestor component (if there is one) and register
1475 // this component as one of the actively loading child components for its ancestor
1476 let ancestorComponent = elm;
1477 while ((ancestorComponent = (ancestorComponent.parentNode || ancestorComponent.host))) {
1478 // climb up the ancestors looking for the first
1479 // component that hasn't finished its lifecycle update yet
1480 if (
1481 (ancestorComponent['s-p'])) {
1482 // we found this components first ancestor component
1483 // keep a reference to this component's ancestor component
1484 attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1485 break;
1486 }
1487 }
1488 }
1489 // Lazy properties
1490 // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1491 if ( cmpMeta.$members$) {
1492 Object.entries(cmpMeta.$members$).forEach(([memberName, [memberFlags]]) => {
1493 if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1494 const value = elm[memberName];
1495 delete elm[memberName];
1496 elm[memberName] = value;
1497 }
1498 });
1499 }
1500 {
1501 // connectedCallback, taskQueue, initialLoad
1502 // angular sets attribute AFTER connectCallback
1503 // https://github.com/angular/angular/issues/18909
1504 // https://github.com/angular/angular/issues/19940
1505 nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
1506 }
1507 }
1508 fireConnectedCallback(hostRef.$lazyInstance$);
1509 endConnected();
1510 }
1511};
1512const setContentReference = (elm) => {
1513 // only required when we're NOT using native shadow dom (slot)
1514 // or this browser doesn't support native shadow dom
1515 // and this host element was NOT created with SSR
1516 // let's pick out the inner content for slot projection
1517 // create a node to represent where the original
1518 // content was first placed, which is useful later on
1519 const crName = '';
1520 const contentRefElm = elm['s-cr'] = doc.createComment(crName);
1521 contentRefElm['s-cn'] = true;
1522 elm.insertBefore(contentRefElm, elm.firstChild);
1523};
1524const disconnectedCallback = (elm) => {
1525 if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1526 const hostRef = getHostRef(elm);
1527 {
1528 if (hostRef.$rmListeners$) {
1529 hostRef.$rmListeners$();
1530 hostRef.$rmListeners$ = undefined;
1531 }
1532 }
1533 // clear CSS var-shim tracking
1534 if ( plt.$cssShim$) {
1535 plt.$cssShim$.removeHost(elm);
1536 }
1537 }
1538};
1539const 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 = /*@__PURE__*/ head.querySelector('meta[charset]');
1546 const visibilityStyle = /*@__PURE__*/ 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 /* queueSync */;
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 // StencilLazyHost
1577 constructor(self) {
1578 // @ts-ignore
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 // connectedCallback will be processed once all components have been registered
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 /* isElementConstructor */));
1612 }
1613 }));
1614 // visibilityStyle.innerHTML = cmpTags.map(t => `${t}:not(.hydrated)`) + '{display:none}';
1615 visibilityStyle.innerHTML = cmpTags + '{visibility:hidden}.hydrated{visibility:inherit}';
1616 visibilityStyle.setAttribute('data-styles', '');
1617 head.insertBefore(visibilityStyle, y ? y.nextSibling : head.firstChild);
1618 // Process deferred connectedCallbacks now all components have been registered
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 // Fallback appLoad event
1627 endBootstrap();
1628};
1629const getElement = (ref) => getHostRef(ref).$hostElement$ ;
1630
1631exports.bootstrapLazy = bootstrapLazy;
1632exports.getElement = getElement;
1633exports.h = h;
1634exports.patchBrowser = patchBrowser;
1635exports.patchEsm = patchEsm;
1636exports.registerInstance = registerInstance;