1 | 'use strict';
|
2 |
|
3 | function _interopNamespace(e) {
|
4 | if (e && e.__esModule) { return e; } else {
|
5 | var n = {};
|
6 | if (e) {
|
7 | Object.keys(e).forEach(function (k) {
|
8 | var d = Object.getOwnPropertyDescriptor(e, k);
|
9 | Object.defineProperty(n, k, d.get ? d : {
|
10 | enumerable: true,
|
11 | get: function () {
|
12 | return e[k];
|
13 | }
|
14 | });
|
15 | });
|
16 | }
|
17 | n['default'] = e;
|
18 | return n;
|
19 | }
|
20 | }
|
21 |
|
22 | const NAMESPACE = 'bulmil';
|
23 | const BUILD = { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: true, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, cssVarShim: true, devTools: false, disconnectedCallback: false, dynamicImportShim: true, element: false, event: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: true, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: true, isDebug: false, isDev: true, isTesting: true, lazyLoad: true, lifecycle: false, lifecycleDOMEvents: true, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: true, scoped: false, scriptDataOpts: true, shadowDelegatesFocus: false, shadowDom: false, shadowDomShim: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: false, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: false, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
|
24 |
|
25 | let scopeId;
|
26 | let contentRef;
|
27 | let hostTagName;
|
28 | let i = 0;
|
29 | let useNativeShadowDom = false;
|
30 | let checkSlotFallbackVisibility = false;
|
31 | let checkSlotRelocate = false;
|
32 | let isSvgMode = false;
|
33 | let renderingRef = null;
|
34 | let queueCongestion = 0;
|
35 | let queuePending = false;
|
36 | const win = typeof window !== 'undefined' ? window : {};
|
37 | const CSS = BUILD.cssVarShim ? win.CSS : null;
|
38 | const doc = win.document || { head: {} };
|
39 | const H = (win.HTMLElement || class {
|
40 | });
|
41 | const plt = {
|
42 | $flags$: 0,
|
43 | $resourcesUrl$: '',
|
44 | jmp: h => h(),
|
45 | raf: h => requestAnimationFrame(h),
|
46 | ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
47 | rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
48 | };
|
49 | const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom ? (() => (doc.head.attachShadow + '').indexOf('[native') > -1)() : true;
|
50 | const supportsListenerOptions = (() => {
|
51 | let supportsListenerOptions = false;
|
52 | try {
|
53 | doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
|
54 | get() {
|
55 | supportsListenerOptions = true;
|
56 | },
|
57 | }));
|
58 | }
|
59 | catch (e) { }
|
60 | return supportsListenerOptions;
|
61 | })();
|
62 | const promiseResolve = (v) => Promise.resolve(v);
|
63 | const supportsConstructibleStylesheets = BUILD.constructableCSS
|
64 | ? (() => {
|
65 | try {
|
66 | new CSSStyleSheet();
|
67 | return true;
|
68 | }
|
69 | catch (e) { }
|
70 | return false;
|
71 | })()
|
72 | : false;
|
73 | const Context = {};
|
74 | const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
75 | if (BUILD.hostListener && listeners) {
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | if (BUILD.hostListenerTargetParent) {
|
81 |
|
82 | if (attachParentListeners) {
|
83 |
|
84 |
|
85 |
|
86 | listeners = listeners.filter(([flags]) => flags & 16 );
|
87 | }
|
88 | else {
|
89 |
|
90 |
|
91 |
|
92 | listeners = listeners.filter(([flags]) => !(flags & 16 ));
|
93 | }
|
94 | }
|
95 | listeners.map(([flags, name, method]) => {
|
96 | const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
|
97 | const handler = hostListenerProxy(hostRef, method);
|
98 | const opts = hostListenerOpts(flags);
|
99 | plt.ael(target, name, handler, opts);
|
100 | (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
101 | });
|
102 | }
|
103 | };
|
104 | const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
105 | if (BUILD.lazyLoad) {
|
106 | if (hostRef.$flags$ & 256 ) {
|
107 |
|
108 | hostRef.$lazyInstance$[methodName](ev);
|
109 | }
|
110 | else {
|
111 | (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
112 | }
|
113 | }
|
114 | else {
|
115 | hostRef.$hostElement$[methodName](ev);
|
116 | }
|
117 | };
|
118 | const getHostListenerTarget = (elm, flags) => {
|
119 | if (BUILD.hostListenerTargetDocument && flags & 4 )
|
120 | return doc;
|
121 | if (BUILD.hostListenerTargetWindow && flags & 8 )
|
122 | return win;
|
123 | if (BUILD.hostListenerTargetBody && flags & 32 )
|
124 | return doc.body;
|
125 | if (BUILD.hostListenerTargetParent && flags & 16 )
|
126 | return elm.parentElement;
|
127 | return elm;
|
128 | };
|
129 |
|
130 | const hostListenerOpts = (flags) => supportsListenerOptions
|
131 | ? ({
|
132 | passive: (flags & 1 ) !== 0,
|
133 | capture: (flags & 2 ) !== 0,
|
134 | })
|
135 | : (flags & 2 ) !== 0;
|
136 | const CONTENT_REF_ID = 'r';
|
137 | const ORG_LOCATION_ID = 'o';
|
138 | const SLOT_NODE_ID = 's';
|
139 | const TEXT_NODE_ID = 't';
|
140 | const HYDRATE_ID = 's-id';
|
141 | const HYDRATED_STYLE_ID = 'sty-id';
|
142 | const HYDRATE_CHILD_ID = 'c-id';
|
143 | const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
144 | const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
145 | const createTime = (fnName, tagName = '') => {
|
146 | if (BUILD.profile && performance.mark) {
|
147 | const key = `st:${fnName}:${tagName}:${i++}`;
|
148 |
|
149 | performance.mark(key);
|
150 |
|
151 | return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
|
152 | }
|
153 | else {
|
154 | return () => {
|
155 | return;
|
156 | };
|
157 | }
|
158 | };
|
159 | const uniqueTime = (key, measureText) => {
|
160 | if (BUILD.profile && performance.mark) {
|
161 | if (performance.getEntriesByName(key).length === 0) {
|
162 | performance.mark(key);
|
163 | }
|
164 | return () => {
|
165 | if (performance.getEntriesByName(measureText).length === 0) {
|
166 | performance.measure(measureText, key);
|
167 | }
|
168 | };
|
169 | }
|
170 | else {
|
171 | return () => {
|
172 | return;
|
173 | };
|
174 | }
|
175 | };
|
176 | const inspect = (ref) => {
|
177 | const hostRef = getHostRef(ref);
|
178 | if (!hostRef) {
|
179 | return undefined;
|
180 | }
|
181 | const flags = hostRef.$flags$;
|
182 | const hostElement = hostRef.$hostElement$;
|
183 | return {
|
184 | renderCount: hostRef.$renderCount$,
|
185 | flags: {
|
186 | hasRendered: !!(flags & 2 ),
|
187 | hasConnected: !!(flags & 1 ),
|
188 | isWaitingForChildren: !!(flags & 4 ),
|
189 | isConstructingInstance: !!(flags & 8 ),
|
190 | isQueuedForUpdate: !!(flags & 16 ),
|
191 | hasInitializedComponent: !!(flags & 32 ),
|
192 | hasLoadedComponent: !!(flags & 64 ),
|
193 | isWatchReady: !!(flags & 128 ),
|
194 | isListenReady: !!(flags & 256 ),
|
195 | needsRerender: !!(flags & 512 ),
|
196 | },
|
197 | instanceValues: hostRef.$instanceValues$,
|
198 | ancestorComponent: hostRef.$ancestorComponent$,
|
199 | hostElement,
|
200 | lazyInstance: hostRef.$lazyInstance$,
|
201 | vnode: hostRef.$vnode$,
|
202 | modeName: hostRef.$modeName$,
|
203 | onReadyPromise: hostRef.$onReadyPromise$,
|
204 | onReadyResolve: hostRef.$onReadyResolve$,
|
205 | onInstancePromise: hostRef.$onInstancePromise$,
|
206 | onInstanceResolve: hostRef.$onInstanceResolve$,
|
207 | onRenderResolve: hostRef.$onRenderResolve$,
|
208 | queuedListeners: hostRef.$queuedListeners$,
|
209 | rmListeners: hostRef.$rmListeners$,
|
210 | ['s-id']: hostElement['s-id'],
|
211 | ['s-cr']: hostElement['s-cr'],
|
212 | ['s-lr']: hostElement['s-lr'],
|
213 | ['s-p']: hostElement['s-p'],
|
214 | ['s-rc']: hostElement['s-rc'],
|
215 | ['s-sc']: hostElement['s-sc'],
|
216 | };
|
217 | };
|
218 | const installDevTools = () => {
|
219 | if (BUILD.devTools) {
|
220 | const stencil = (win.stencil = win.stencil || {});
|
221 | const originalInspect = stencil.inspect;
|
222 | stencil.inspect = (ref) => {
|
223 | let result = inspect(ref);
|
224 | if (!result && typeof originalInspect === 'function') {
|
225 | result = originalInspect(ref);
|
226 | }
|
227 | return result;
|
228 | };
|
229 | }
|
230 | };
|
231 | const rootAppliedStyles = new WeakMap();
|
232 | const registerStyle = (scopeId, cssText, allowCS) => {
|
233 | let style = styles.get(scopeId);
|
234 | if (supportsConstructibleStylesheets && allowCS) {
|
235 | style = (style || new CSSStyleSheet());
|
236 | style.replace(cssText);
|
237 | }
|
238 | else {
|
239 | style = cssText;
|
240 | }
|
241 | styles.set(scopeId, style);
|
242 | };
|
243 | const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
244 | let scopeId = getScopeId(cmpMeta, mode);
|
245 | let style = styles.get(scopeId);
|
246 | if (!BUILD.attachStyles) {
|
247 | return scopeId;
|
248 | }
|
249 |
|
250 |
|
251 | styleContainerNode = styleContainerNode.nodeType === 11 ? styleContainerNode : doc;
|
252 | if (style) {
|
253 | if (typeof style === 'string') {
|
254 | styleContainerNode = styleContainerNode.head || styleContainerNode;
|
255 | let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
256 | let styleElm;
|
257 | if (!appliedStyles) {
|
258 | rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
259 | }
|
260 | if (!appliedStyles.has(scopeId)) {
|
261 | if (BUILD.hydrateClientSide && styleContainerNode.host && (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
262 |
|
263 | styleElm.innerHTML = style;
|
264 | }
|
265 | else {
|
266 | if (BUILD.cssVarShim && plt.$cssShim$) {
|
267 | styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 ));
|
268 | const newScopeId = styleElm['s-sc'];
|
269 | if (newScopeId) {
|
270 | scopeId = newScopeId;
|
271 |
|
272 |
|
273 |
|
274 | appliedStyles = null;
|
275 | }
|
276 | }
|
277 | else {
|
278 | styleElm = doc.createElement('style');
|
279 | styleElm.innerHTML = style;
|
280 | }
|
281 | if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
|
282 | styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
|
283 | }
|
284 | styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
285 | }
|
286 | if (appliedStyles) {
|
287 | appliedStyles.add(scopeId);
|
288 | }
|
289 | }
|
290 | }
|
291 | else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
|
292 | styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
293 | }
|
294 | }
|
295 | return scopeId;
|
296 | };
|
297 | const attachStyles = (hostRef) => {
|
298 | const cmpMeta = hostRef.$cmpMeta$;
|
299 | const elm = hostRef.$hostElement$;
|
300 | const flags = cmpMeta.$flags$;
|
301 | const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
302 | const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
303 | if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 ) {
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 | elm['s-sc'] = scopeId;
|
312 | elm.classList.add(scopeId + '-h');
|
313 | if (BUILD.scoped && flags & 2 ) {
|
314 | elm.classList.add(scopeId + '-s');
|
315 | }
|
316 | }
|
317 | endAttachStyles();
|
318 | };
|
319 | const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
|
320 | const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
321 |
|
322 | const computeMode = (elm) => modeResolutionChain.map(h => h(elm)).find(m => !!m);
|
323 |
|
324 | const setMode = (handler) => modeResolutionChain.push(handler);
|
325 | const getMode = (ref) => getHostRef(ref).$modeName$;
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 | const EMPTY_OBJ = {};
|
334 |
|
335 |
|
336 |
|
337 | const SVG_NS = 'http://www.w3.org/2000/svg';
|
338 | const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
339 | const isDef = (v) => v != null;
|
340 | const isComplexType = (o) => {
|
341 |
|
342 | o = typeof o;
|
343 | return o === 'object' || o === 'function';
|
344 | };
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 | const h = (nodeName, vnodeData, ...children) => {
|
357 | let child = null;
|
358 | let key = null;
|
359 | let slotName = null;
|
360 | let simple = false;
|
361 | let lastSimple = false;
|
362 | let vNodeChildren = [];
|
363 | const walk = (c) => {
|
364 | for (let i = 0; i < c.length; i++) {
|
365 | child = c[i];
|
366 | if (Array.isArray(child)) {
|
367 | walk(child);
|
368 | }
|
369 | else if (child != null && typeof child !== 'boolean') {
|
370 | if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
|
371 | child = String(child);
|
372 | }
|
373 | else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
|
374 | consoleDevError(`vNode passed as children has unexpected type.
|
375 | Make sure it's using the correct h() function.
|
376 | Empty objects can also be the cause, look for JSX comments that became objects.`);
|
377 | }
|
378 | if (simple && lastSimple) {
|
379 |
|
380 | vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
381 | }
|
382 | else {
|
383 |
|
384 | vNodeChildren.push(simple ? newVNode(null, child) : child);
|
385 | }
|
386 | lastSimple = simple;
|
387 | }
|
388 | }
|
389 | };
|
390 | walk(children);
|
391 | if (vnodeData) {
|
392 | if (BUILD.isDev && nodeName === 'input') {
|
393 | validateInputProperties(vnodeData);
|
394 | }
|
395 |
|
396 | if (BUILD.vdomKey && vnodeData.key) {
|
397 | key = vnodeData.key;
|
398 | }
|
399 | if (BUILD.slotRelocation && vnodeData.name) {
|
400 | slotName = vnodeData.name;
|
401 | }
|
402 | if (BUILD.vdomClass) {
|
403 | const classData = vnodeData.className || vnodeData.class;
|
404 | if (classData) {
|
405 | vnodeData.class =
|
406 | typeof classData !== 'object'
|
407 | ? classData
|
408 | : Object.keys(classData)
|
409 | .filter(k => classData[k])
|
410 | .join(' ');
|
411 | }
|
412 | }
|
413 | }
|
414 | if (BUILD.isDev && vNodeChildren.some(isHost)) {
|
415 | consoleDevError(`The <Host> must be the single root component. Make sure:
|
416 | - You are NOT using hostData() and <Host> in the same component.
|
417 | - <Host> is used once, and it's the single root component of the render() function.`);
|
418 | }
|
419 | if (BUILD.vdomFunctional && typeof nodeName === 'function') {
|
420 |
|
421 | return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
422 | }
|
423 | const vnode = newVNode(nodeName, null);
|
424 | vnode.$attrs$ = vnodeData;
|
425 | if (vNodeChildren.length > 0) {
|
426 | vnode.$children$ = vNodeChildren;
|
427 | }
|
428 | if (BUILD.vdomKey) {
|
429 | vnode.$key$ = key;
|
430 | }
|
431 | if (BUILD.slotRelocation) {
|
432 | vnode.$name$ = slotName;
|
433 | }
|
434 | return vnode;
|
435 | };
|
436 | const newVNode = (tag, text) => {
|
437 | const vnode = {
|
438 | $flags$: 0,
|
439 | $tag$: tag,
|
440 | $text$: text,
|
441 | $elm$: null,
|
442 | $children$: null,
|
443 | };
|
444 | if (BUILD.vdomAttribute) {
|
445 | vnode.$attrs$ = null;
|
446 | }
|
447 | if (BUILD.vdomKey) {
|
448 | vnode.$key$ = null;
|
449 | }
|
450 | if (BUILD.slotRelocation) {
|
451 | vnode.$name$ = null;
|
452 | }
|
453 | return vnode;
|
454 | };
|
455 | const Host = {};
|
456 | const isHost = (node) => node && node.$tag$ === Host;
|
457 | const vdomFnUtils = {
|
458 | forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
459 | map: (children, cb) => children
|
460 | .map(convertToPublic)
|
461 | .map(cb)
|
462 | .map(convertToPrivate),
|
463 | };
|
464 | const convertToPublic = (node) => ({
|
465 | vattrs: node.$attrs$,
|
466 | vchildren: node.$children$,
|
467 | vkey: node.$key$,
|
468 | vname: node.$name$,
|
469 | vtag: node.$tag$,
|
470 | vtext: node.$text$,
|
471 | });
|
472 | const convertToPrivate = (node) => {
|
473 | const vnode = newVNode(node.vtag, node.vtext);
|
474 | vnode.$attrs$ = node.vattrs;
|
475 | vnode.$children$ = node.vchildren;
|
476 | vnode.$key$ = node.vkey;
|
477 | vnode.$name$ = node.vname;
|
478 | return vnode;
|
479 | };
|
480 | const validateInputProperties = (vnodeData) => {
|
481 | const props = Object.keys(vnodeData);
|
482 | const typeIndex = props.indexOf('type');
|
483 | const minIndex = props.indexOf('min');
|
484 | const maxIndex = props.indexOf('max');
|
485 | const stepIndex = props.indexOf('min');
|
486 | const value = props.indexOf('value');
|
487 | if (value === -1) {
|
488 | return;
|
489 | }
|
490 | if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
|
491 | consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
|
492 | }
|
493 | };
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 | const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
503 | if (oldValue !== newValue) {
|
504 | let isProp = isMemberInElement(elm, memberName);
|
505 | let ln = memberName.toLowerCase();
|
506 | if (BUILD.vdomClass && memberName === 'class') {
|
507 | const classList = elm.classList;
|
508 | const oldClasses = parseClassList(oldValue);
|
509 | const newClasses = parseClassList(newValue);
|
510 | classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
|
511 | classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
|
512 | }
|
513 | else if (BUILD.vdomStyle && memberName === 'style') {
|
514 |
|
515 | if (BUILD.updatable) {
|
516 | for (const prop in oldValue) {
|
517 | if (!newValue || newValue[prop] == null) {
|
518 | if (!BUILD.hydrateServerSide && prop.includes('-')) {
|
519 | elm.style.removeProperty(prop);
|
520 | }
|
521 | else {
|
522 | elm.style[prop] = '';
|
523 | }
|
524 | }
|
525 | }
|
526 | }
|
527 | for (const prop in newValue) {
|
528 | if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
529 | if (!BUILD.hydrateServerSide && prop.includes('-')) {
|
530 | elm.style.setProperty(prop, newValue[prop]);
|
531 | }
|
532 | else {
|
533 | elm.style[prop] = newValue[prop];
|
534 | }
|
535 | }
|
536 | }
|
537 | }
|
538 | else if (BUILD.vdomKey && memberName === 'key')
|
539 | ;
|
540 | else if (BUILD.vdomRef && memberName === 'ref') {
|
541 |
|
542 | if (newValue) {
|
543 | newValue(elm);
|
544 | }
|
545 | }
|
546 | else if (BUILD.vdomListener && (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === 'o' && memberName[1] === 'n') {
|
547 |
|
548 |
|
549 |
|
550 |
|
551 | if (memberName[2] === '-') {
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 | memberName = memberName.slice(3);
|
560 | }
|
561 | else if (isMemberInElement(win, ln)) {
|
562 |
|
563 |
|
564 |
|
565 |
|
566 | memberName = ln.slice(2);
|
567 | }
|
568 | else {
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | memberName = ln[2] + memberName.slice(3);
|
575 | }
|
576 | if (oldValue) {
|
577 | plt.rel(elm, memberName, oldValue, false);
|
578 | }
|
579 | if (newValue) {
|
580 | plt.ael(elm, memberName, newValue, false);
|
581 | }
|
582 | }
|
583 | else if (BUILD.vdomPropOrAttr) {
|
584 |
|
585 | const isComplex = isComplexType(newValue);
|
586 | if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
587 | try {
|
588 | if (!elm.tagName.includes('-')) {
|
589 | let n = newValue == null ? '' : newValue;
|
590 |
|
591 | if (memberName === 'list') {
|
592 | isProp = false;
|
593 |
|
594 | }
|
595 | else if (oldValue == null || elm[memberName] != n) {
|
596 | elm[memberName] = n;
|
597 | }
|
598 | }
|
599 | else {
|
600 | elm[memberName] = newValue;
|
601 | }
|
602 | }
|
603 | catch (e) { }
|
604 | }
|
605 | |
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 | let xlink = false;
|
613 | if (BUILD.vdomXlink) {
|
614 | if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
615 | memberName = ln;
|
616 | xlink = true;
|
617 | }
|
618 | }
|
619 | if (newValue == null || newValue === false) {
|
620 | if (newValue !== false || elm.getAttribute(memberName) === '') {
|
621 | if (BUILD.vdomXlink && xlink) {
|
622 | elm.removeAttributeNS(XLINK_NS, memberName);
|
623 | }
|
624 | else {
|
625 | elm.removeAttribute(memberName);
|
626 | }
|
627 | }
|
628 | }
|
629 | else if ((!isProp || flags & 4 || isSvg) && !isComplex) {
|
630 | newValue = newValue === true ? '' : newValue;
|
631 | if (BUILD.vdomXlink && xlink) {
|
632 | elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
633 | }
|
634 | else {
|
635 | elm.setAttribute(memberName, newValue);
|
636 | }
|
637 | }
|
638 | }
|
639 | }
|
640 | };
|
641 | const parseClassListRegex = /\s/;
|
642 | const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
643 | const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
644 |
|
645 |
|
646 |
|
647 | const elm = newVnode.$elm$.nodeType === 11 && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
|
648 | const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
649 | const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
650 | if (BUILD.updatable) {
|
651 |
|
652 | for (memberName in oldVnodeAttrs) {
|
653 | if (!(memberName in newVnodeAttrs)) {
|
654 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
655 | }
|
656 | }
|
657 | }
|
658 |
|
659 | for (memberName in newVnodeAttrs) {
|
660 | setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
661 | }
|
662 | };
|
663 | const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
664 |
|
665 | let newVNode = newParentVNode.$children$[childIndex];
|
666 | let i = 0;
|
667 | let elm;
|
668 | let childNode;
|
669 | let oldVNode;
|
670 | if (BUILD.slotRelocation && !useNativeShadowDom) {
|
671 |
|
672 | checkSlotRelocate = true;
|
673 | if (newVNode.$tag$ === 'slot') {
|
674 | if (scopeId) {
|
675 |
|
676 | parentElm.classList.add(scopeId + '-s');
|
677 | }
|
678 | newVNode.$flags$ |= newVNode.$children$
|
679 | ?
|
680 | 2
|
681 | :
|
682 | 1 ;
|
683 | }
|
684 | }
|
685 | if (BUILD.isDev && newVNode.$elm$) {
|
686 | consoleError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
|
687 | }
|
688 | if (BUILD.vdomText && newVNode.$text$ !== null) {
|
689 |
|
690 | elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
691 | }
|
692 | else if (BUILD.slotRelocation && newVNode.$flags$ & 1 ) {
|
693 |
|
694 | elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
|
695 | }
|
696 | else {
|
697 | if (BUILD.svg && !isSvgMode) {
|
698 | isSvgMode = newVNode.$tag$ === 'svg';
|
699 | }
|
700 |
|
701 | elm = newVNode.$elm$ = (BUILD.svg
|
702 | ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 ? 'slot-fb' : newVNode.$tag$)
|
703 | : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 ? 'slot-fb' : newVNode.$tag$));
|
704 | if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
705 | isSvgMode = false;
|
706 | }
|
707 |
|
708 | if (BUILD.vdomAttribute) {
|
709 | updateElement(null, newVNode, isSvgMode);
|
710 | }
|
711 | if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
|
712 |
|
713 |
|
714 | elm.classList.add((elm['s-si'] = scopeId));
|
715 | }
|
716 | if (newVNode.$children$) {
|
717 | for (i = 0; i < newVNode.$children$.length; ++i) {
|
718 |
|
719 | childNode = createElm(oldParentVNode, newVNode, i, elm);
|
720 |
|
721 | if (childNode) {
|
722 |
|
723 | elm.appendChild(childNode);
|
724 | }
|
725 | }
|
726 | }
|
727 | if (BUILD.svg) {
|
728 | if (newVNode.$tag$ === 'svg') {
|
729 |
|
730 | isSvgMode = false;
|
731 | }
|
732 | else if (elm.tagName === 'foreignObject') {
|
733 |
|
734 | isSvgMode = true;
|
735 | }
|
736 | }
|
737 | }
|
738 | if (BUILD.slotRelocation) {
|
739 | elm['s-hn'] = hostTagName;
|
740 | if (newVNode.$flags$ & (2 | 1 )) {
|
741 |
|
742 | elm['s-sr'] = true;
|
743 |
|
744 | elm['s-cr'] = contentRef;
|
745 |
|
746 | elm['s-sn'] = newVNode.$name$ || '';
|
747 |
|
748 | oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
749 | if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
750 |
|
751 |
|
752 | putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
753 | }
|
754 | }
|
755 | }
|
756 | return elm;
|
757 | };
|
758 | const putBackInOriginalLocation = (parentElm, recursive) => {
|
759 | plt.$flags$ |= 1 ;
|
760 | const oldSlotChildNodes = parentElm.childNodes;
|
761 | for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
762 | const childNode = oldSlotChildNodes[i];
|
763 | if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
764 |
|
765 |
|
766 |
|
767 |
|
768 | parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
769 |
|
770 |
|
771 |
|
772 | childNode['s-ol'].remove();
|
773 | childNode['s-ol'] = undefined;
|
774 | checkSlotRelocate = true;
|
775 | }
|
776 | if (recursive) {
|
777 | putBackInOriginalLocation(childNode, recursive);
|
778 | }
|
779 | }
|
780 | plt.$flags$ &= ~1 ;
|
781 | };
|
782 | const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
783 | let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
784 | let childNode;
|
785 | if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
786 | containerElm = containerElm.shadowRoot;
|
787 | }
|
788 | for (; startIdx <= endIdx; ++startIdx) {
|
789 | if (vnodes[startIdx]) {
|
790 | childNode = createElm(null, parentVNode, startIdx, parentElm);
|
791 | if (childNode) {
|
792 | vnodes[startIdx].$elm$ = childNode;
|
793 | containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
|
794 | }
|
795 | }
|
796 | }
|
797 | };
|
798 | const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
799 | for (; startIdx <= endIdx; ++startIdx) {
|
800 | if ((vnode = vnodes[startIdx])) {
|
801 | elm = vnode.$elm$;
|
802 | callNodeRefs(vnode);
|
803 | if (BUILD.slotRelocation) {
|
804 |
|
805 |
|
806 | checkSlotFallbackVisibility = true;
|
807 | if (elm['s-ol']) {
|
808 |
|
809 | elm['s-ol'].remove();
|
810 | }
|
811 | else {
|
812 |
|
813 |
|
814 | putBackInOriginalLocation(elm, true);
|
815 | }
|
816 | }
|
817 |
|
818 | elm.remove();
|
819 | }
|
820 | }
|
821 | };
|
822 | const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
823 | let oldStartIdx = 0;
|
824 | let newStartIdx = 0;
|
825 | let idxInOld = 0;
|
826 | let i = 0;
|
827 | let oldEndIdx = oldCh.length - 1;
|
828 | let oldStartVnode = oldCh[0];
|
829 | let oldEndVnode = oldCh[oldEndIdx];
|
830 | let newEndIdx = newCh.length - 1;
|
831 | let newStartVnode = newCh[0];
|
832 | let newEndVnode = newCh[newEndIdx];
|
833 | let node;
|
834 | let elmToMove;
|
835 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
836 | if (oldStartVnode == null) {
|
837 |
|
838 | oldStartVnode = oldCh[++oldStartIdx];
|
839 | }
|
840 | else if (oldEndVnode == null) {
|
841 | oldEndVnode = oldCh[--oldEndIdx];
|
842 | }
|
843 | else if (newStartVnode == null) {
|
844 | newStartVnode = newCh[++newStartIdx];
|
845 | }
|
846 | else if (newEndVnode == null) {
|
847 | newEndVnode = newCh[--newEndIdx];
|
848 | }
|
849 | else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
850 | patch(oldStartVnode, newStartVnode);
|
851 | oldStartVnode = oldCh[++oldStartIdx];
|
852 | newStartVnode = newCh[++newStartIdx];
|
853 | }
|
854 | else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
855 | patch(oldEndVnode, newEndVnode);
|
856 | oldEndVnode = oldCh[--oldEndIdx];
|
857 | newEndVnode = newCh[--newEndIdx];
|
858 | }
|
859 | else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
860 |
|
861 | if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
862 | putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
863 | }
|
864 | patch(oldStartVnode, newEndVnode);
|
865 | parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
866 | oldStartVnode = oldCh[++oldStartIdx];
|
867 | newEndVnode = newCh[--newEndIdx];
|
868 | }
|
869 | else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
870 |
|
871 | if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
872 | putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
873 | }
|
874 | patch(oldEndVnode, newStartVnode);
|
875 | parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
876 | oldEndVnode = oldCh[--oldEndIdx];
|
877 | newStartVnode = newCh[++newStartIdx];
|
878 | }
|
879 | else {
|
880 |
|
881 | idxInOld = -1;
|
882 | if (BUILD.vdomKey) {
|
883 | for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
884 | if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
885 | idxInOld = i;
|
886 | break;
|
887 | }
|
888 | }
|
889 | }
|
890 | if (BUILD.vdomKey && idxInOld >= 0) {
|
891 | elmToMove = oldCh[idxInOld];
|
892 | if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
893 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
894 | }
|
895 | else {
|
896 | patch(elmToMove, newStartVnode);
|
897 | oldCh[idxInOld] = undefined;
|
898 | node = elmToMove.$elm$;
|
899 | }
|
900 | newStartVnode = newCh[++newStartIdx];
|
901 | }
|
902 | else {
|
903 |
|
904 | node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
905 | newStartVnode = newCh[++newStartIdx];
|
906 | }
|
907 | if (node) {
|
908 | if (BUILD.slotRelocation) {
|
909 | parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
910 | }
|
911 | else {
|
912 | oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
913 | }
|
914 | }
|
915 | }
|
916 | }
|
917 | if (oldStartIdx > oldEndIdx) {
|
918 | addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
919 | }
|
920 | else if (BUILD.updatable && newStartIdx > newEndIdx) {
|
921 | removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
922 | }
|
923 | };
|
924 | const isSameVnode = (vnode1, vnode2) => {
|
925 |
|
926 |
|
927 | if (vnode1.$tag$ === vnode2.$tag$) {
|
928 | if (BUILD.slotRelocation && vnode1.$tag$ === 'slot') {
|
929 | return vnode1.$name$ === vnode2.$name$;
|
930 | }
|
931 | if (BUILD.vdomKey) {
|
932 | return vnode1.$key$ === vnode2.$key$;
|
933 | }
|
934 | return true;
|
935 | }
|
936 | return false;
|
937 | };
|
938 | const referenceNode = (node) => {
|
939 |
|
940 |
|
941 |
|
942 |
|
943 | return (node && node['s-ol']) || node;
|
944 | };
|
945 | const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
946 | const patch = (oldVNode, newVNode) => {
|
947 | const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
948 | const oldChildren = oldVNode.$children$;
|
949 | const newChildren = newVNode.$children$;
|
950 | const tag = newVNode.$tag$;
|
951 | const text = newVNode.$text$;
|
952 | let defaultHolder;
|
953 | if (!BUILD.vdomText || text === null) {
|
954 | if (BUILD.svg) {
|
955 |
|
956 |
|
957 | isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
958 | }
|
959 |
|
960 | if (BUILD.vdomAttribute || BUILD.reflect) {
|
961 | if (BUILD.slot && tag === 'slot')
|
962 | ;
|
963 | else {
|
964 |
|
965 |
|
966 |
|
967 | updateElement(oldVNode, newVNode, isSvgMode);
|
968 | }
|
969 | }
|
970 | if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
|
971 |
|
972 | updateChildren(elm, oldChildren, newVNode, newChildren);
|
973 | }
|
974 | else if (newChildren !== null) {
|
975 |
|
976 | if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
|
977 |
|
978 | elm.textContent = '';
|
979 | }
|
980 |
|
981 | addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
982 | }
|
983 | else if (BUILD.updatable && oldChildren !== null) {
|
984 |
|
985 | removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
986 | }
|
987 | if (BUILD.svg && isSvgMode && tag === 'svg') {
|
988 | isSvgMode = false;
|
989 | }
|
990 | }
|
991 | else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
|
992 |
|
993 | defaultHolder.parentNode.textContent = text;
|
994 | }
|
995 | else if (BUILD.vdomText && oldVNode.$text$ !== text) {
|
996 |
|
997 |
|
998 | elm.data = text;
|
999 | }
|
1000 | };
|
1001 | const updateFallbackSlotVisibility = (elm) => {
|
1002 |
|
1003 | let childNodes = elm.childNodes;
|
1004 | let childNode;
|
1005 | let i;
|
1006 | let ilen;
|
1007 | let j;
|
1008 | let slotNameAttr;
|
1009 | let nodeType;
|
1010 | for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
1011 | childNode = childNodes[i];
|
1012 | if (childNode.nodeType === 1 ) {
|
1013 | if (childNode['s-sr']) {
|
1014 |
|
1015 |
|
1016 | slotNameAttr = childNode['s-sn'];
|
1017 |
|
1018 |
|
1019 | childNode.hidden = false;
|
1020 | for (j = 0; j < ilen; j++) {
|
1021 | if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
|
1022 |
|
1023 | nodeType = childNodes[j].nodeType;
|
1024 | if (slotNameAttr !== '') {
|
1025 |
|
1026 | if (nodeType === 1 && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
1027 | childNode.hidden = true;
|
1028 | break;
|
1029 | }
|
1030 | }
|
1031 | else {
|
1032 |
|
1033 |
|
1034 |
|
1035 | if (nodeType === 1 || (nodeType === 3 && childNodes[j].textContent.trim() !== '')) {
|
1036 | childNode.hidden = true;
|
1037 | break;
|
1038 | }
|
1039 | }
|
1040 | }
|
1041 | }
|
1042 | }
|
1043 |
|
1044 | updateFallbackSlotVisibility(childNode);
|
1045 | }
|
1046 | }
|
1047 | };
|
1048 | const relocateNodes = [];
|
1049 | const relocateSlotContent = (elm) => {
|
1050 |
|
1051 | let childNode;
|
1052 | let node;
|
1053 | let hostContentNodes;
|
1054 | let slotNameAttr;
|
1055 | let relocateNodeData;
|
1056 | let j;
|
1057 | let i = 0;
|
1058 | let childNodes = elm.childNodes;
|
1059 | let ilen = childNodes.length;
|
1060 | for (; i < ilen; i++) {
|
1061 | childNode = childNodes[i];
|
1062 | if (childNode['s-sr'] && (node = childNode['s-cr'])) {
|
1063 |
|
1064 |
|
1065 | hostContentNodes = node.parentNode.childNodes;
|
1066 | slotNameAttr = childNode['s-sn'];
|
1067 | for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
1068 | node = hostContentNodes[j];
|
1069 | if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
1070 |
|
1071 |
|
1072 |
|
1073 | if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
1074 |
|
1075 | relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
|
1076 |
|
1077 |
|
1078 |
|
1079 | checkSlotFallbackVisibility = true;
|
1080 | node['s-sn'] = node['s-sn'] || slotNameAttr;
|
1081 | if (relocateNodeData) {
|
1082 |
|
1083 |
|
1084 | relocateNodeData.$slotRefNode$ = childNode;
|
1085 | }
|
1086 | else {
|
1087 |
|
1088 | relocateNodes.push({
|
1089 | $slotRefNode$: childNode,
|
1090 | $nodeToRelocate$: node,
|
1091 | });
|
1092 | }
|
1093 | if (node['s-sr']) {
|
1094 | relocateNodes.map(relocateNode => {
|
1095 | if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
1096 | relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
|
1097 | if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
1098 | relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
1099 | }
|
1100 | }
|
1101 | });
|
1102 | }
|
1103 | }
|
1104 | else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
|
1105 |
|
1106 |
|
1107 | relocateNodes.push({
|
1108 | $nodeToRelocate$: node,
|
1109 | });
|
1110 | }
|
1111 | }
|
1112 | }
|
1113 | }
|
1114 | if (childNode.nodeType === 1 ) {
|
1115 | relocateSlotContent(childNode);
|
1116 | }
|
1117 | }
|
1118 | };
|
1119 | const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
1120 | if (nodeToRelocate.nodeType === 1 ) {
|
1121 | if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
1122 | return true;
|
1123 | }
|
1124 | if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
1125 | return true;
|
1126 | }
|
1127 | return false;
|
1128 | }
|
1129 | if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
1130 | return true;
|
1131 | }
|
1132 | return slotNameAttr === '';
|
1133 | };
|
1134 | const callNodeRefs = (vNode) => {
|
1135 | if (BUILD.vdomRef) {
|
1136 | vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
1137 | vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
1138 | }
|
1139 | };
|
1140 | const renderVdom = (hostRef, renderFnResults) => {
|
1141 | const hostElm = hostRef.$hostElement$;
|
1142 | const cmpMeta = hostRef.$cmpMeta$;
|
1143 | const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
1144 | const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
1145 | hostTagName = hostElm.tagName;
|
1146 |
|
1147 | if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
|
1148 | throw new Error(`The <Host> must be the single root component.
|
1149 | Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
1150 |
|
1151 | The render() function should look like this instead:
|
1152 |
|
1153 | render() {
|
1154 | // Do not return an array
|
1155 | return (
|
1156 | <Host>{content}</Host>
|
1157 | );
|
1158 | }
|
1159 | `);
|
1160 | }
|
1161 | if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
|
1162 | rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
1163 | cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
1164 | }
|
1165 | rootVnode.$tag$ = null;
|
1166 | rootVnode.$flags$ |= 4 ;
|
1167 | hostRef.$vnode$ = rootVnode;
|
1168 | rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
|
1169 | if (BUILD.scoped || BUILD.shadowDom) {
|
1170 | scopeId = hostElm['s-sc'];
|
1171 | }
|
1172 | if (BUILD.slotRelocation) {
|
1173 | contentRef = hostElm['s-cr'];
|
1174 | useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 ) !== 0;
|
1175 |
|
1176 | checkSlotFallbackVisibility = false;
|
1177 | }
|
1178 |
|
1179 | patch(oldVNode, rootVnode);
|
1180 | if (BUILD.slotRelocation) {
|
1181 |
|
1182 |
|
1183 | plt.$flags$ |= 1 ;
|
1184 | if (checkSlotRelocate) {
|
1185 | relocateSlotContent(rootVnode.$elm$);
|
1186 | let relocateData;
|
1187 | let nodeToRelocate;
|
1188 | let orgLocationNode;
|
1189 | let parentNodeRef;
|
1190 | let insertBeforeNode;
|
1191 | let refNode;
|
1192 | let i = 0;
|
1193 | for (; i < relocateNodes.length; i++) {
|
1194 | relocateData = relocateNodes[i];
|
1195 | nodeToRelocate = relocateData.$nodeToRelocate$;
|
1196 | if (!nodeToRelocate['s-ol']) {
|
1197 |
|
1198 |
|
1199 | orgLocationNode = BUILD.isDebug || BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode('');
|
1200 | orgLocationNode['s-nr'] = nodeToRelocate;
|
1201 | nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
1202 | }
|
1203 | }
|
1204 | for (i = 0; i < relocateNodes.length; i++) {
|
1205 | relocateData = relocateNodes[i];
|
1206 | nodeToRelocate = relocateData.$nodeToRelocate$;
|
1207 | if (relocateData.$slotRefNode$) {
|
1208 |
|
1209 |
|
1210 | parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
1211 | insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
1212 | orgLocationNode = nodeToRelocate['s-ol'];
|
1213 | while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
1214 | refNode = orgLocationNode['s-nr'];
|
1215 | if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
1216 | refNode = refNode.nextSibling;
|
1217 | if (!refNode || !refNode['s-nr']) {
|
1218 | insertBeforeNode = refNode;
|
1219 | break;
|
1220 | }
|
1221 | }
|
1222 | }
|
1223 | if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
|
1224 |
|
1225 |
|
1226 |
|
1227 | if (nodeToRelocate !== insertBeforeNode) {
|
1228 | if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
1229 |
|
1230 | nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
1231 | }
|
1232 |
|
1233 | parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
1234 | }
|
1235 | }
|
1236 | }
|
1237 | else {
|
1238 |
|
1239 | if (nodeToRelocate.nodeType === 1 ) {
|
1240 | nodeToRelocate.hidden = true;
|
1241 | }
|
1242 | }
|
1243 | }
|
1244 | }
|
1245 | if (checkSlotFallbackVisibility) {
|
1246 | updateFallbackSlotVisibility(rootVnode.$elm$);
|
1247 | }
|
1248 |
|
1249 |
|
1250 | plt.$flags$ &= ~1 ;
|
1251 |
|
1252 | relocateNodes.length = 0;
|
1253 | }
|
1254 | };
|
1255 |
|
1256 |
|
1257 | const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
|
1258 | const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})` : `[${nodeToRelocate.textContent}]`));
|
1259 | const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
|
1260 | const createEvent = (ref, name, flags) => {
|
1261 | const elm = getElement(ref);
|
1262 | return {
|
1263 | emit: (detail) => {
|
1264 | if (BUILD.isDev && !elm.isConnected) {
|
1265 | consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
|
1266 | }
|
1267 | return emitEvent(elm, name, {
|
1268 | bubbles: !!(flags & 4 ),
|
1269 | composed: !!(flags & 2 ),
|
1270 | cancelable: !!(flags & 1 ),
|
1271 | detail,
|
1272 | });
|
1273 | },
|
1274 | };
|
1275 | };
|
1276 | const emitEvent = (elm, name, opts) => {
|
1277 | const ev = new (BUILD.hydrateServerSide ? win.CustomEvent : CustomEvent)(name, opts);
|
1278 | elm.dispatchEvent(ev);
|
1279 | return ev;
|
1280 | };
|
1281 | const attachToAncestor = (hostRef, ancestorComponent) => {
|
1282 | if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
1283 | ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
|
1284 | }
|
1285 | };
|
1286 | const scheduleUpdate = (hostRef, isInitialLoad) => {
|
1287 | if (BUILD.taskQueue && BUILD.updatable) {
|
1288 | hostRef.$flags$ |= 16 ;
|
1289 | }
|
1290 | if (BUILD.asyncLoading && hostRef.$flags$ & 4 ) {
|
1291 | hostRef.$flags$ |= 512 ;
|
1292 | return;
|
1293 | }
|
1294 | attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
1295 |
|
1296 |
|
1297 |
|
1298 | const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
1299 | return BUILD.taskQueue ? writeTask(dispatch) : dispatch;
|
1300 | };
|
1301 | const dispatchHooks = (hostRef, isInitialLoad) => {
|
1302 | const elm = hostRef.$hostElement$;
|
1303 | const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
1304 | const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
1305 | let promise;
|
1306 | if (isInitialLoad) {
|
1307 | if (BUILD.lazyLoad && BUILD.hostListener) {
|
1308 | hostRef.$flags$ |= 256 ;
|
1309 | if (hostRef.$queuedListeners$) {
|
1310 | hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
1311 | hostRef.$queuedListeners$ = null;
|
1312 | }
|
1313 | }
|
1314 | emitLifecycleEvent(elm, 'componentWillLoad');
|
1315 | if (BUILD.cmpWillLoad) {
|
1316 | promise = safeCall(instance, 'componentWillLoad');
|
1317 | }
|
1318 | }
|
1319 | else {
|
1320 | emitLifecycleEvent(elm, 'componentWillUpdate');
|
1321 | if (BUILD.cmpWillUpdate) {
|
1322 | promise = safeCall(instance, 'componentWillUpdate');
|
1323 | }
|
1324 | }
|
1325 | emitLifecycleEvent(elm, 'componentWillRender');
|
1326 | if (BUILD.cmpWillRender) {
|
1327 | promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
1328 | }
|
1329 | endSchedule();
|
1330 | return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
1331 | };
|
1332 | const updateComponent = (hostRef, instance, isInitialLoad) => {
|
1333 |
|
1334 | const elm = hostRef.$hostElement$;
|
1335 | const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
1336 | const rc = elm['s-rc'];
|
1337 | if (BUILD.style && isInitialLoad) {
|
1338 |
|
1339 | attachStyles(hostRef);
|
1340 | }
|
1341 | const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
1342 | if (BUILD.isDev) {
|
1343 | hostRef.$flags$ |= 1024 ;
|
1344 | }
|
1345 | if (BUILD.hasRenderFn || BUILD.reflect) {
|
1346 | if (BUILD.vdomRender || BUILD.reflect) {
|
1347 |
|
1348 |
|
1349 |
|
1350 | renderVdom(hostRef, callRender(hostRef, instance));
|
1351 | }
|
1352 | else {
|
1353 | elm.textContent = callRender(hostRef, instance);
|
1354 | }
|
1355 | }
|
1356 | if (BUILD.cssVarShim && plt.$cssShim$) {
|
1357 | plt.$cssShim$.updateHost(elm);
|
1358 | }
|
1359 | if (BUILD.isDev) {
|
1360 | hostRef.$renderCount$++;
|
1361 | hostRef.$flags$ &= ~1024 ;
|
1362 | }
|
1363 | if (BUILD.hydrateServerSide) {
|
1364 | try {
|
1365 |
|
1366 | serverSideConnected(elm);
|
1367 | if (isInitialLoad) {
|
1368 |
|
1369 | if (hostRef.$cmpMeta$.$flags$ & 1 ) {
|
1370 | elm['s-en'] = '';
|
1371 | }
|
1372 | else if (hostRef.$cmpMeta$.$flags$ & 2 ) {
|
1373 | elm['s-en'] = 'c';
|
1374 | }
|
1375 | }
|
1376 | }
|
1377 | catch (e) {
|
1378 | consoleError(e);
|
1379 | }
|
1380 | }
|
1381 | if (BUILD.asyncLoading && rc) {
|
1382 |
|
1383 |
|
1384 |
|
1385 | rc.map(cb => cb());
|
1386 | elm['s-rc'] = undefined;
|
1387 | }
|
1388 | endRender();
|
1389 | endUpdate();
|
1390 | if (BUILD.asyncLoading) {
|
1391 | const childrenPromises = elm['s-p'];
|
1392 | const postUpdate = () => postUpdateComponent(hostRef);
|
1393 | if (childrenPromises.length === 0) {
|
1394 | postUpdate();
|
1395 | }
|
1396 | else {
|
1397 | Promise.all(childrenPromises).then(postUpdate);
|
1398 | hostRef.$flags$ |= 4 ;
|
1399 | childrenPromises.length = 0;
|
1400 | }
|
1401 | }
|
1402 | else {
|
1403 | postUpdateComponent(hostRef);
|
1404 | }
|
1405 | };
|
1406 | const callRender = (hostRef, instance) => {
|
1407 | try {
|
1408 | renderingRef = instance;
|
1409 | instance = BUILD.allRenderFn ? instance.render() : instance.render && instance.render();
|
1410 | if (BUILD.updatable && BUILD.taskQueue) {
|
1411 | hostRef.$flags$ &= ~16 ;
|
1412 | }
|
1413 | if (BUILD.updatable || BUILD.lazyLoad) {
|
1414 | hostRef.$flags$ |= 2 ;
|
1415 | }
|
1416 | }
|
1417 | catch (e) {
|
1418 | consoleError(e);
|
1419 | }
|
1420 | renderingRef = null;
|
1421 | return instance;
|
1422 | };
|
1423 | const getRenderingRef = () => renderingRef;
|
1424 | const postUpdateComponent = (hostRef) => {
|
1425 | const tagName = hostRef.$cmpMeta$.$tagName$;
|
1426 | const elm = hostRef.$hostElement$;
|
1427 | const endPostUpdate = createTime('postUpdate', tagName);
|
1428 | const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
1429 | const ancestorComponent = hostRef.$ancestorComponent$;
|
1430 | if (BUILD.cmpDidRender) {
|
1431 | if (BUILD.isDev) {
|
1432 | hostRef.$flags$ |= 1024 ;
|
1433 | }
|
1434 | safeCall(instance, 'componentDidRender');
|
1435 | if (BUILD.isDev) {
|
1436 | hostRef.$flags$ &= ~1024 ;
|
1437 | }
|
1438 | }
|
1439 | emitLifecycleEvent(elm, 'componentDidRender');
|
1440 | if (!(hostRef.$flags$ & 64 )) {
|
1441 | hostRef.$flags$ |= 64 ;
|
1442 | if (BUILD.asyncLoading && BUILD.cssAnnotations) {
|
1443 |
|
1444 | addHydratedFlag(elm);
|
1445 | }
|
1446 | if (BUILD.cmpDidLoad) {
|
1447 | if (BUILD.isDev) {
|
1448 | hostRef.$flags$ |= 2048 ;
|
1449 | }
|
1450 | safeCall(instance, 'componentDidLoad');
|
1451 | if (BUILD.isDev) {
|
1452 | hostRef.$flags$ &= ~2048 ;
|
1453 | }
|
1454 | }
|
1455 | emitLifecycleEvent(elm, 'componentDidLoad');
|
1456 | endPostUpdate();
|
1457 | if (BUILD.asyncLoading) {
|
1458 | hostRef.$onReadyResolve$(elm);
|
1459 | if (!ancestorComponent) {
|
1460 | appDidLoad(tagName);
|
1461 | }
|
1462 | }
|
1463 | }
|
1464 | else {
|
1465 | if (BUILD.cmpDidUpdate) {
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 | if (BUILD.isDev) {
|
1471 | hostRef.$flags$ |= 1024 ;
|
1472 | }
|
1473 | safeCall(instance, 'componentDidUpdate');
|
1474 | if (BUILD.isDev) {
|
1475 | hostRef.$flags$ &= ~1024 ;
|
1476 | }
|
1477 | }
|
1478 | emitLifecycleEvent(elm, 'componentDidUpdate');
|
1479 | endPostUpdate();
|
1480 | }
|
1481 | if (BUILD.hotModuleReplacement) {
|
1482 | elm['s-hmr-load'] && elm['s-hmr-load']();
|
1483 | }
|
1484 | if (BUILD.method && BUILD.lazyLoad) {
|
1485 | hostRef.$onInstanceResolve$(elm);
|
1486 | }
|
1487 |
|
1488 |
|
1489 | if (BUILD.asyncLoading) {
|
1490 | if (hostRef.$onRenderResolve$) {
|
1491 | hostRef.$onRenderResolve$();
|
1492 | hostRef.$onRenderResolve$ = undefined;
|
1493 | }
|
1494 | if (hostRef.$flags$ & 512 ) {
|
1495 | nextTick(() => scheduleUpdate(hostRef, false));
|
1496 | }
|
1497 | hostRef.$flags$ &= ~(4 | 512 );
|
1498 | }
|
1499 |
|
1500 |
|
1501 |
|
1502 | };
|
1503 | const forceUpdate = (ref) => {
|
1504 | if (BUILD.updatable) {
|
1505 | const hostRef = getHostRef(ref);
|
1506 | const isConnected = hostRef.$hostElement$.isConnected;
|
1507 | if (isConnected && (hostRef.$flags$ & (2 | 16 )) === 2 ) {
|
1508 | scheduleUpdate(hostRef, false);
|
1509 | }
|
1510 |
|
1511 | return isConnected;
|
1512 | }
|
1513 | return false;
|
1514 | };
|
1515 | const appDidLoad = (who) => {
|
1516 |
|
1517 |
|
1518 | if (BUILD.cssAnnotations) {
|
1519 | addHydratedFlag(doc.documentElement);
|
1520 | }
|
1521 | if (BUILD.asyncQueue) {
|
1522 | plt.$flags$ |= 2 ;
|
1523 | }
|
1524 | nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
1525 | if (BUILD.profile && performance.measure) {
|
1526 | performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
|
1527 | }
|
1528 | };
|
1529 | const safeCall = (instance, method, arg) => {
|
1530 | if (instance && instance[method]) {
|
1531 | try {
|
1532 | return instance[method](arg);
|
1533 | }
|
1534 | catch (e) {
|
1535 | consoleError(e);
|
1536 | }
|
1537 | }
|
1538 | return undefined;
|
1539 | };
|
1540 | const then = (promise, thenFn) => {
|
1541 | return promise && promise.then ? promise.then(thenFn) : thenFn();
|
1542 | };
|
1543 | const emitLifecycleEvent = (elm, lifecycleName) => {
|
1544 | if (BUILD.lifecycleDOMEvents) {
|
1545 | emitEvent(elm, 'stencil_' + lifecycleName, {
|
1546 | bubbles: true,
|
1547 | composed: true,
|
1548 | detail: {
|
1549 | namespace: NAMESPACE,
|
1550 | },
|
1551 | });
|
1552 | }
|
1553 | };
|
1554 | const addHydratedFlag = (elm) => (BUILD.hydratedClass ? elm.classList.add('hydrated') : BUILD.hydratedAttribute ? elm.setAttribute('hydrated', '') : undefined);
|
1555 | const serverSideConnected = (elm) => {
|
1556 | const children = elm.children;
|
1557 | if (children != null) {
|
1558 | for (let i = 0, ii = children.length; i < ii; i++) {
|
1559 | const childElm = children[i];
|
1560 | if (typeof childElm.connectedCallback === 'function') {
|
1561 | childElm.connectedCallback();
|
1562 | }
|
1563 | serverSideConnected(childElm);
|
1564 | }
|
1565 | }
|
1566 | };
|
1567 | const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
1568 | const endHydrate = createTime('hydrateClient', tagName);
|
1569 | const shadowRoot = hostElm.shadowRoot;
|
1570 | const childRenderNodes = [];
|
1571 | const slotNodes = [];
|
1572 | const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
|
1573 | const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
1574 | if (!plt.$orgLocNodes$) {
|
1575 | initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
1576 | }
|
1577 | hostElm[HYDRATE_ID] = hostId;
|
1578 | hostElm.removeAttribute(HYDRATE_ID);
|
1579 | clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
1580 | childRenderNodes.map(c => {
|
1581 | const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
1582 | const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
1583 | const node = c.$elm$;
|
1584 | if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
1585 | orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
1586 | }
|
1587 | if (!shadowRoot) {
|
1588 | node['s-hn'] = tagName;
|
1589 | if (orgLocationNode) {
|
1590 | node['s-ol'] = orgLocationNode;
|
1591 | node['s-ol']['s-nr'] = node;
|
1592 | }
|
1593 | }
|
1594 | plt.$orgLocNodes$.delete(orgLocationId);
|
1595 | });
|
1596 | if (BUILD.shadowDom && shadowRoot) {
|
1597 | shadowRootNodes.map(shadowRootNode => {
|
1598 | if (shadowRootNode) {
|
1599 | shadowRoot.appendChild(shadowRootNode);
|
1600 | }
|
1601 | });
|
1602 | }
|
1603 | endHydrate();
|
1604 | };
|
1605 | const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
1606 | let childNodeType;
|
1607 | let childIdSplt;
|
1608 | let childVNode;
|
1609 | let i;
|
1610 | if (node.nodeType === 1 ) {
|
1611 | childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
1612 | if (childNodeType) {
|
1613 |
|
1614 |
|
1615 | childIdSplt = childNodeType.split('.');
|
1616 | if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
1617 | childVNode = {
|
1618 | $flags$: 0,
|
1619 | $hostId$: childIdSplt[0],
|
1620 | $nodeId$: childIdSplt[1],
|
1621 | $depth$: childIdSplt[2],
|
1622 | $index$: childIdSplt[3],
|
1623 | $tag$: node.tagName.toLowerCase(),
|
1624 | $elm$: node,
|
1625 | $attrs$: null,
|
1626 | $children$: null,
|
1627 | $key$: null,
|
1628 | $name$: null,
|
1629 | $text$: null,
|
1630 | };
|
1631 | childRenderNodes.push(childVNode);
|
1632 | node.removeAttribute(HYDRATE_CHILD_ID);
|
1633 |
|
1634 |
|
1635 | if (!parentVNode.$children$) {
|
1636 | parentVNode.$children$ = [];
|
1637 | }
|
1638 |
|
1639 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1640 |
|
1641 | parentVNode = childVNode;
|
1642 | if (shadowRootNodes && childVNode.$depth$ === '0') {
|
1643 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1644 | }
|
1645 | }
|
1646 | }
|
1647 |
|
1648 | for (i = node.childNodes.length - 1; i >= 0; i--) {
|
1649 | clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
1650 | }
|
1651 | if (node.shadowRoot) {
|
1652 |
|
1653 | for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
1654 | clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
1655 | }
|
1656 | }
|
1657 | }
|
1658 | else if (node.nodeType === 8 ) {
|
1659 |
|
1660 | childIdSplt = node.nodeValue.split('.');
|
1661 | if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
1662 |
|
1663 | childNodeType = childIdSplt[0];
|
1664 | childVNode = {
|
1665 | $flags$: 0,
|
1666 | $hostId$: childIdSplt[1],
|
1667 | $nodeId$: childIdSplt[2],
|
1668 | $depth$: childIdSplt[3],
|
1669 | $index$: childIdSplt[4],
|
1670 | $elm$: node,
|
1671 | $attrs$: null,
|
1672 | $children$: null,
|
1673 | $key$: null,
|
1674 | $name$: null,
|
1675 | $tag$: null,
|
1676 | $text$: null,
|
1677 | };
|
1678 | if (childNodeType === TEXT_NODE_ID) {
|
1679 | childVNode.$elm$ = node.nextSibling;
|
1680 | if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 ) {
|
1681 | childVNode.$text$ = childVNode.$elm$.textContent;
|
1682 | childRenderNodes.push(childVNode);
|
1683 |
|
1684 | node.remove();
|
1685 | if (!parentVNode.$children$) {
|
1686 | parentVNode.$children$ = [];
|
1687 | }
|
1688 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1689 | if (shadowRootNodes && childVNode.$depth$ === '0') {
|
1690 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1691 | }
|
1692 | }
|
1693 | }
|
1694 | else if (childVNode.$hostId$ === hostId) {
|
1695 |
|
1696 | if (childNodeType === SLOT_NODE_ID) {
|
1697 |
|
1698 | childVNode.$tag$ = 'slot';
|
1699 | if (childIdSplt[5]) {
|
1700 | node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
1701 | }
|
1702 | else {
|
1703 | node['s-sn'] = '';
|
1704 | }
|
1705 | node['s-sr'] = true;
|
1706 | if (BUILD.shadowDom && shadowRootNodes) {
|
1707 |
|
1708 |
|
1709 | childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
1710 | if (childVNode.$name$) {
|
1711 |
|
1712 | childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
1713 | }
|
1714 |
|
1715 | node.parentNode.insertBefore(childVNode.$elm$, node);
|
1716 |
|
1717 | node.remove();
|
1718 | if (childVNode.$depth$ === '0') {
|
1719 | shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
1720 | }
|
1721 | }
|
1722 | slotNodes.push(childVNode);
|
1723 | if (!parentVNode.$children$) {
|
1724 | parentVNode.$children$ = [];
|
1725 | }
|
1726 | parentVNode.$children$[childVNode.$index$] = childVNode;
|
1727 | }
|
1728 | else if (childNodeType === CONTENT_REF_ID) {
|
1729 |
|
1730 | if (BUILD.shadowDom && shadowRootNodes) {
|
1731 |
|
1732 | node.remove();
|
1733 | }
|
1734 | else if (BUILD.slotRelocation) {
|
1735 | hostElm['s-cr'] = node;
|
1736 | node['s-cn'] = true;
|
1737 | }
|
1738 | }
|
1739 | }
|
1740 | }
|
1741 | }
|
1742 | else if (parentVNode && parentVNode.$tag$ === 'style') {
|
1743 | const vnode = newVNode(null, node.textContent);
|
1744 | vnode.$elm$ = node;
|
1745 | vnode.$index$ = '0';
|
1746 | parentVNode.$children$ = [vnode];
|
1747 | }
|
1748 | };
|
1749 | const initializeDocumentHydrate = (node, orgLocNodes) => {
|
1750 | if (node.nodeType === 1 ) {
|
1751 | let i = 0;
|
1752 | for (; i < node.childNodes.length; i++) {
|
1753 | initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
1754 | }
|
1755 | if (node.shadowRoot) {
|
1756 | for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
1757 | initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
1758 | }
|
1759 | }
|
1760 | }
|
1761 | else if (node.nodeType === 8 ) {
|
1762 | const childIdSplt = node.nodeValue.split('.');
|
1763 | if (childIdSplt[0] === ORG_LOCATION_ID) {
|
1764 | orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
1765 | node.nodeValue = '';
|
1766 |
|
1767 |
|
1768 | node['s-en'] = childIdSplt[3];
|
1769 | }
|
1770 | }
|
1771 | };
|
1772 | const parsePropertyValue = (propValue, propType) => {
|
1773 |
|
1774 | if (propValue != null && !isComplexType(propValue)) {
|
1775 | if (BUILD.propBoolean && propType & 4 ) {
|
1776 |
|
1777 |
|
1778 | return propValue === 'false' ? false : propValue === '' || !!propValue;
|
1779 | }
|
1780 | if (BUILD.propNumber && propType & 2 ) {
|
1781 |
|
1782 | return parseFloat(propValue);
|
1783 | }
|
1784 | if (BUILD.propString && propType & 1 ) {
|
1785 |
|
1786 |
|
1787 | return String(propValue);
|
1788 | }
|
1789 |
|
1790 | return propValue;
|
1791 | }
|
1792 |
|
1793 |
|
1794 | return propValue;
|
1795 | };
|
1796 | const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
1797 | const setValue = (ref, propName, newVal, cmpMeta) => {
|
1798 |
|
1799 | const hostRef = getHostRef(ref);
|
1800 | const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
1801 | const oldVal = hostRef.$instanceValues$.get(propName);
|
1802 | const flags = hostRef.$flags$;
|
1803 | const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
1804 | newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
1805 | if ((!BUILD.lazyLoad || !(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
|
1806 |
|
1807 |
|
1808 | hostRef.$instanceValues$.set(propName, newVal);
|
1809 | if (BUILD.isDev) {
|
1810 | if (hostRef.$flags$ & 1024 ) {
|
1811 | consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
|
1812 | }
|
1813 | else if (hostRef.$flags$ & 2048 ) {
|
1814 | consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
|
1815 | }
|
1816 | }
|
1817 | if (!BUILD.lazyLoad || instance) {
|
1818 |
|
1819 | if (BUILD.watchCallback && cmpMeta.$watchers$) {
|
1820 | if (!BUILD.lazyLoad || flags & 128 ) {
|
1821 | const watchMethods = cmpMeta.$watchers$[propName];
|
1822 | if (watchMethods) {
|
1823 |
|
1824 | watchMethods.map(watchMethodName => {
|
1825 | try {
|
1826 |
|
1827 | instance[watchMethodName](newVal, oldVal, propName);
|
1828 | }
|
1829 | catch (e) {
|
1830 | consoleError(e);
|
1831 | }
|
1832 | });
|
1833 | }
|
1834 | }
|
1835 | }
|
1836 | if (BUILD.updatable && (flags & (2 | 16 )) === 2 ) {
|
1837 | if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
|
1838 | if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
1839 | return;
|
1840 | }
|
1841 | }
|
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 | scheduleUpdate(hostRef, false);
|
1847 | }
|
1848 | }
|
1849 | }
|
1850 | };
|
1851 | const proxyComponent = (Cstr, cmpMeta, flags) => {
|
1852 | if (BUILD.member && cmpMeta.$members$) {
|
1853 | if (BUILD.watchCallback && Cstr.watchers) {
|
1854 | cmpMeta.$watchers$ = Cstr.watchers;
|
1855 | }
|
1856 |
|
1857 | const members = Object.entries(cmpMeta.$members$);
|
1858 | const prototype = Cstr.prototype;
|
1859 | members.map(([memberName, [memberFlags]]) => {
|
1860 | if ((BUILD.prop || BUILD.state) && (memberFlags & 31 || ((!BUILD.lazyLoad || flags & 2 ) && memberFlags & 32 ))) {
|
1861 |
|
1862 | Object.defineProperty(prototype, memberName, {
|
1863 | get() {
|
1864 |
|
1865 | return getValue(this, memberName);
|
1866 | },
|
1867 | set(newValue) {
|
1868 | if (
|
1869 |
|
1870 | BUILD.isDev &&
|
1871 |
|
1872 | (flags & 1 ) === 0 &&
|
1873 |
|
1874 | (memberFlags & (31 | 1024 )) === 31 ) {
|
1875 | consoleDevWarn(`@Prop() "${memberName}" on "${cmpMeta.$tagName$}" cannot be modified.\nFurther information: https://stenciljs.com/docs/properties#prop-mutability`);
|
1876 | }
|
1877 |
|
1878 | setValue(this, memberName, newValue, cmpMeta);
|
1879 | },
|
1880 | configurable: true,
|
1881 | enumerable: true,
|
1882 | });
|
1883 | }
|
1884 | else if (BUILD.lazyLoad && BUILD.method && flags & 1 && memberFlags & 64 ) {
|
1885 |
|
1886 | Object.defineProperty(prototype, memberName, {
|
1887 | value(...args) {
|
1888 | const ref = getHostRef(this);
|
1889 | return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
|
1890 | },
|
1891 | });
|
1892 | }
|
1893 | });
|
1894 | if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 )) {
|
1895 | const attrNameToPropName = new Map();
|
1896 | prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
1897 | plt.jmp(() => {
|
1898 | const propName = attrNameToPropName.get(attrName);
|
1899 | this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
1900 | });
|
1901 | };
|
1902 |
|
1903 |
|
1904 | Cstr.observedAttributes = members
|
1905 | .filter(([_, m]) => m[0] & 15 )
|
1906 | .map(([propName, m]) => {
|
1907 | const attrName = m[1] || propName;
|
1908 | attrNameToPropName.set(attrName, propName);
|
1909 | if (BUILD.reflect && m[0] & 512 ) {
|
1910 | cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
1911 | }
|
1912 | return attrName;
|
1913 | });
|
1914 | }
|
1915 | }
|
1916 | return Cstr;
|
1917 | };
|
1918 | const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
1919 |
|
1920 | if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) && (hostRef.$flags$ & 32 ) === 0) {
|
1921 |
|
1922 | hostRef.$flags$ |= 32 ;
|
1923 | if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
|
1924 |
|
1925 |
|
1926 |
|
1927 | Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
|
1928 | if (Cstr.then) {
|
1929 |
|
1930 | const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
|
1931 | Cstr = await Cstr;
|
1932 | endLoad();
|
1933 | }
|
1934 | if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
|
1935 | throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
1936 | }
|
1937 | if (BUILD.member && !Cstr.isProxied) {
|
1938 |
|
1939 |
|
1940 |
|
1941 | if (BUILD.watchCallback) {
|
1942 | cmpMeta.$watchers$ = Cstr.watchers;
|
1943 | }
|
1944 | proxyComponent(Cstr, cmpMeta, 2 );
|
1945 | Cstr.isProxied = true;
|
1946 | }
|
1947 | const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
1948 |
|
1949 |
|
1950 |
|
1951 | if (BUILD.member) {
|
1952 | hostRef.$flags$ |= 8 ;
|
1953 | }
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 | try {
|
1959 | new Cstr(hostRef);
|
1960 | }
|
1961 | catch (e) {
|
1962 | consoleError(e);
|
1963 | }
|
1964 | if (BUILD.member) {
|
1965 | hostRef.$flags$ &= ~8 ;
|
1966 | }
|
1967 | if (BUILD.watchCallback) {
|
1968 | hostRef.$flags$ |= 128 ;
|
1969 | }
|
1970 | endNewInstance();
|
1971 | fireConnectedCallback(hostRef.$lazyInstance$);
|
1972 | }
|
1973 | else {
|
1974 | Cstr = elm.constructor;
|
1975 | }
|
1976 | if (BUILD.style && Cstr.style) {
|
1977 |
|
1978 | let style = Cstr.style;
|
1979 | if (BUILD.mode && typeof style !== 'string') {
|
1980 | style = style[(hostRef.$modeName$ = computeMode(elm))];
|
1981 | if (BUILD.hydrateServerSide && hostRef.$modeName$) {
|
1982 | elm.setAttribute('s-mode', hostRef.$modeName$);
|
1983 | }
|
1984 | }
|
1985 | const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
|
1986 | if (!styles.has(scopeId)) {
|
1987 | const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
1988 | if (!BUILD.hydrateServerSide && BUILD.shadowDom && BUILD.shadowDomShim && cmpMeta.$flags$ & 8 ) {
|
1989 | style = await Promise.resolve().then(function () { return require('./shadow-css-d4b529be.js'); }).then(m => m.scopeCss(style, scopeId, false));
|
1990 | }
|
1991 | registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 ));
|
1992 | endRegisterStyles();
|
1993 | }
|
1994 | }
|
1995 | }
|
1996 |
|
1997 | const ancestorComponent = hostRef.$ancestorComponent$;
|
1998 | const schedule = () => scheduleUpdate(hostRef, true);
|
1999 | if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 | ancestorComponent['s-rc'].push(schedule);
|
2007 | }
|
2008 | else {
|
2009 | schedule();
|
2010 | }
|
2011 | };
|
2012 | const fireConnectedCallback = (instance) => {
|
2013 | if (BUILD.lazyLoad && BUILD.connectedCallback) {
|
2014 | safeCall(instance, 'connectedCallback');
|
2015 | }
|
2016 | };
|
2017 | const connectedCallback = (elm) => {
|
2018 | if ((plt.$flags$ & 1 ) === 0) {
|
2019 | const hostRef = getHostRef(elm);
|
2020 | const cmpMeta = hostRef.$cmpMeta$;
|
2021 | const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
2022 | if (BUILD.hostListenerTargetParent) {
|
2023 |
|
2024 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
|
2025 | }
|
2026 | if (!(hostRef.$flags$ & 1 )) {
|
2027 |
|
2028 | hostRef.$flags$ |= 1 ;
|
2029 | let hostId;
|
2030 | if (BUILD.hydrateClientSide) {
|
2031 | hostId = elm.getAttribute(HYDRATE_ID);
|
2032 | if (hostId) {
|
2033 | if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 ) {
|
2034 | const scopeId = BUILD.mode ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode')) : addStyle(elm.shadowRoot, cmpMeta);
|
2035 | elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
2036 | }
|
2037 | initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
2038 | }
|
2039 | }
|
2040 | if (BUILD.slotRelocation && !hostId) {
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 | if (BUILD.hydrateServerSide || ((BUILD.slot || BUILD.shadowDom) && cmpMeta.$flags$ & (4 | 8 ))) {
|
2046 | setContentReference(elm);
|
2047 | }
|
2048 | }
|
2049 | if (BUILD.asyncLoading) {
|
2050 |
|
2051 |
|
2052 | let ancestorComponent = elm;
|
2053 | while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
2054 |
|
2055 |
|
2056 | if ((BUILD.hydrateClientSide && ancestorComponent.nodeType === 1 && ancestorComponent.hasAttribute('s-id') && ancestorComponent['s-p']) ||
|
2057 | ancestorComponent['s-p']) {
|
2058 |
|
2059 |
|
2060 | attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
2061 | break;
|
2062 | }
|
2063 | }
|
2064 | }
|
2065 |
|
2066 |
|
2067 | if (BUILD.prop && BUILD.lazyLoad && !BUILD.hydrateServerSide && cmpMeta.$members$) {
|
2068 | Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
2069 | if (memberFlags & 31 && elm.hasOwnProperty(memberName)) {
|
2070 | const value = elm[memberName];
|
2071 | delete elm[memberName];
|
2072 | elm[memberName] = value;
|
2073 | }
|
2074 | });
|
2075 | }
|
2076 | if (BUILD.initializeNextTick) {
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 | nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
|
2082 | }
|
2083 | else {
|
2084 | initializeComponent(elm, hostRef, cmpMeta);
|
2085 | }
|
2086 | }
|
2087 | else {
|
2088 |
|
2089 |
|
2090 |
|
2091 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
|
2092 |
|
2093 | fireConnectedCallback(hostRef.$lazyInstance$);
|
2094 | }
|
2095 | endConnected();
|
2096 | }
|
2097 | };
|
2098 | const setContentReference = (elm) => {
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 |
|
2104 |
|
2105 | const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
|
2106 | contentRefElm['s-cn'] = true;
|
2107 | elm.insertBefore(contentRefElm, elm.firstChild);
|
2108 | };
|
2109 | const disconnectedCallback = (elm) => {
|
2110 | if ((plt.$flags$ & 1 ) === 0) {
|
2111 | const hostRef = getHostRef(elm);
|
2112 | const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
2113 | if (BUILD.hostListener) {
|
2114 | if (hostRef.$rmListeners$) {
|
2115 | hostRef.$rmListeners$.map(rmListener => rmListener());
|
2116 | hostRef.$rmListeners$ = undefined;
|
2117 | }
|
2118 | }
|
2119 |
|
2120 | if (BUILD.cssVarShim && plt.$cssShim$) {
|
2121 | plt.$cssShim$.removeHost(elm);
|
2122 | }
|
2123 | if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
|
2124 | safeCall(instance, 'disconnectedCallback');
|
2125 | }
|
2126 | if (BUILD.cmpDidUnload) {
|
2127 | safeCall(instance, 'componentDidUnload');
|
2128 | }
|
2129 | }
|
2130 | };
|
2131 | const defineCustomElement = (Cstr, compactMeta) => {
|
2132 | customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
|
2133 | };
|
2134 | const proxyCustomElement = (Cstr, compactMeta) => {
|
2135 | const cmpMeta = {
|
2136 | $flags$: compactMeta[0],
|
2137 | $tagName$: compactMeta[1],
|
2138 | };
|
2139 | if (BUILD.member) {
|
2140 | cmpMeta.$members$ = compactMeta[2];
|
2141 | }
|
2142 | if (BUILD.hostListener) {
|
2143 | cmpMeta.$listeners$ = compactMeta[3];
|
2144 | }
|
2145 | if (BUILD.watchCallback) {
|
2146 | cmpMeta.$watchers$ = Cstr.$watchers$;
|
2147 | }
|
2148 | if (BUILD.reflect) {
|
2149 | cmpMeta.$attrsToReflect$ = [];
|
2150 | }
|
2151 | if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 ) {
|
2152 | cmpMeta.$flags$ |= 8 ;
|
2153 | }
|
2154 | const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
2155 | const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
|
2156 | Object.assign(Cstr.prototype, {
|
2157 | __registerHost() {
|
2158 | registerHost(this, cmpMeta);
|
2159 | },
|
2160 | connectedCallback() {
|
2161 | connectedCallback(this);
|
2162 | if (BUILD.connectedCallback && originalConnectedCallback) {
|
2163 | originalConnectedCallback.call(this);
|
2164 | }
|
2165 | },
|
2166 | disconnectedCallback() {
|
2167 | disconnectedCallback(this);
|
2168 | if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
|
2169 | originalDisconnectedCallback.call(this);
|
2170 | }
|
2171 | },
|
2172 | });
|
2173 | Cstr.is = cmpMeta.$tagName$;
|
2174 | return proxyComponent(Cstr, cmpMeta, 1 | 2 );
|
2175 | };
|
2176 | const forceModeUpdate = (elm) => {
|
2177 | if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
|
2178 | const mode = computeMode(elm);
|
2179 | const hostRef = getHostRef(elm);
|
2180 | if (hostRef.$modeName$ !== mode) {
|
2181 | const cmpMeta = hostRef.$cmpMeta$;
|
2182 | const oldScopeId = elm['s-sc'];
|
2183 | const scopeId = getScopeId(cmpMeta, mode);
|
2184 | const style = elm.constructor.style[mode];
|
2185 | const flags = cmpMeta.$flags$;
|
2186 | if (style) {
|
2187 | if (!styles.has(scopeId)) {
|
2188 | registerStyle(scopeId, style, !!(flags & 1 ));
|
2189 | }
|
2190 | hostRef.$modeName$ = mode;
|
2191 | elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
|
2192 | attachStyles(hostRef);
|
2193 | forceUpdate(elm);
|
2194 | }
|
2195 | }
|
2196 | }
|
2197 | };
|
2198 | const attachShadow = (el) => {
|
2199 | if (supportsShadow) {
|
2200 | el.attachShadow({ mode: 'open' });
|
2201 | }
|
2202 | else {
|
2203 | el.shadowRoot = el;
|
2204 | }
|
2205 | };
|
2206 | const hmrStart = (elm, cmpMeta, hmrVersionId) => {
|
2207 |
|
2208 | const hostRef = getHostRef(elm);
|
2209 |
|
2210 | hostRef.$flags$ = 1 ;
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 | elm['s-hmr-load'] = () => {
|
2217 |
|
2218 | delete elm['s-hmr-load'];
|
2219 | };
|
2220 |
|
2221 | initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
|
2222 | };
|
2223 | const patchCloneNode = (HostElementPrototype) => {
|
2224 | const orgCloneNode = HostElementPrototype.cloneNode;
|
2225 | HostElementPrototype.cloneNode = function (deep) {
|
2226 | const srcNode = this;
|
2227 | const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
|
2228 | const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
|
2229 | if (BUILD.slot && !isShadowDom && deep) {
|
2230 | let i = 0;
|
2231 | let slotted;
|
2232 | for (; i < srcNode.childNodes.length; i++) {
|
2233 | slotted = srcNode.childNodes[i]['s-nr'];
|
2234 | if (slotted) {
|
2235 | if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
|
2236 | clonedNode.__appendChild(slotted.cloneNode(true));
|
2237 | }
|
2238 | else {
|
2239 | clonedNode.appendChild(slotted.cloneNode(true));
|
2240 | }
|
2241 | }
|
2242 | }
|
2243 | }
|
2244 | return clonedNode;
|
2245 | };
|
2246 | };
|
2247 | const patchSlotAppendChild = (HostElementPrototype) => {
|
2248 | HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
|
2249 | HostElementPrototype.appendChild = function (newChild) {
|
2250 | const slotName = (newChild['s-sn'] = getSlotName(newChild));
|
2251 | const slotNode = getHostSlotNode(this.childNodes, slotName);
|
2252 | if (slotNode) {
|
2253 | const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
|
2254 | const appendAfter = slotChildNodes[slotChildNodes.length - 1];
|
2255 | return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
|
2256 | }
|
2257 | return this.__appendChild(newChild);
|
2258 | };
|
2259 | };
|
2260 | const patchChildSlotNodes = (elm, cmpMeta) => {
|
2261 | class FakeNodeList extends Array {
|
2262 | item(n) {
|
2263 | return this[n];
|
2264 | }
|
2265 | }
|
2266 | if (cmpMeta.$flags$ & 8 ) {
|
2267 | const childNodesFn = elm.__lookupGetter__('childNodes');
|
2268 | Object.defineProperty(elm, 'children', {
|
2269 | get() {
|
2270 | return this.childNodes.map((n) => n.nodeType === 1);
|
2271 | },
|
2272 | });
|
2273 | Object.defineProperty(elm, 'childElementCount', {
|
2274 | get() {
|
2275 | return elm.children.length;
|
2276 | },
|
2277 | });
|
2278 | Object.defineProperty(elm, 'childNodes', {
|
2279 | get() {
|
2280 | const childNodes = childNodesFn.call(this);
|
2281 | if ((plt.$flags$ & 1 ) === 0 && getHostRef(this).$flags$ & 2 ) {
|
2282 | const result = new FakeNodeList();
|
2283 | for (let i = 0; i < childNodes.length; i++) {
|
2284 | const slot = childNodes[i]['s-nr'];
|
2285 | if (slot) {
|
2286 | result.push(slot);
|
2287 | }
|
2288 | }
|
2289 | return result;
|
2290 | }
|
2291 | return FakeNodeList.from(childNodes);
|
2292 | },
|
2293 | });
|
2294 | }
|
2295 | };
|
2296 | const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
|
2297 | const getHostSlotNode = (childNodes, slotName) => {
|
2298 | let i = 0;
|
2299 | let childNode;
|
2300 | for (; i < childNodes.length; i++) {
|
2301 | childNode = childNodes[i];
|
2302 | if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
|
2303 | return childNode;
|
2304 | }
|
2305 | childNode = getHostSlotNode(childNode.childNodes, slotName);
|
2306 | if (childNode) {
|
2307 | return childNode;
|
2308 | }
|
2309 | }
|
2310 | return null;
|
2311 | };
|
2312 | const getHostSlotChildNodes = (n, slotName) => {
|
2313 | const childNodes = [n];
|
2314 | while ((n = n.nextSibling) && n['s-sn'] === slotName) {
|
2315 | childNodes.push(n);
|
2316 | }
|
2317 | return childNodes;
|
2318 | };
|
2319 | const bootstrapLazy = (lazyBundles, options = {}) => {
|
2320 | if (BUILD.profile && performance.mark) {
|
2321 | performance.mark('st:app:start');
|
2322 | }
|
2323 | installDevTools();
|
2324 | const endBootstrap = createTime('bootstrapLazy');
|
2325 | const cmpTags = [];
|
2326 | const exclude = options.exclude || [];
|
2327 | const customElements = win.customElements;
|
2328 | const head = doc.head;
|
2329 | const metaCharset = head.querySelector('meta[charset]');
|
2330 | const visibilityStyle = doc.createElement('style');
|
2331 | const deferredConnectedCallbacks = [];
|
2332 | const styles = doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
2333 | let appLoadFallback;
|
2334 | let isBootstrapping = true;
|
2335 | let i = 0;
|
2336 | Object.assign(plt, options);
|
2337 | plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
2338 | if (BUILD.asyncQueue) {
|
2339 | if (options.syncQueue) {
|
2340 | plt.$flags$ |= 4 ;
|
2341 | }
|
2342 | }
|
2343 | if (BUILD.hydrateClientSide) {
|
2344 |
|
2345 |
|
2346 | plt.$flags$ |= 2 ;
|
2347 | }
|
2348 | if (BUILD.hydrateClientSide && BUILD.shadowDom) {
|
2349 | for (; i < styles.length; i++) {
|
2350 | registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
2351 | }
|
2352 | }
|
2353 | lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
|
2354 | const cmpMeta = {
|
2355 | $flags$: compactMeta[0],
|
2356 | $tagName$: compactMeta[1],
|
2357 | $members$: compactMeta[2],
|
2358 | $listeners$: compactMeta[3],
|
2359 | };
|
2360 | if (BUILD.member) {
|
2361 | cmpMeta.$members$ = compactMeta[2];
|
2362 | }
|
2363 | if (BUILD.hostListener) {
|
2364 | cmpMeta.$listeners$ = compactMeta[3];
|
2365 | }
|
2366 | if (BUILD.reflect) {
|
2367 | cmpMeta.$attrsToReflect$ = [];
|
2368 | }
|
2369 | if (BUILD.watchCallback) {
|
2370 | cmpMeta.$watchers$ = {};
|
2371 | }
|
2372 | if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 ) {
|
2373 | cmpMeta.$flags$ |= 8 ;
|
2374 | }
|
2375 | const tagName = BUILD.transformTagName && options.transformTagName ? options.transformTagName(cmpMeta.$tagName$) : cmpMeta.$tagName$;
|
2376 | const HostElement = class extends HTMLElement {
|
2377 |
|
2378 | constructor(self) {
|
2379 |
|
2380 | super(self);
|
2381 | self = this;
|
2382 | registerHost(self, cmpMeta);
|
2383 | if (BUILD.shadowDom && cmpMeta.$flags$ & 1 ) {
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 | if (supportsShadow) {
|
2389 | if (BUILD.shadowDelegatesFocus) {
|
2390 | self.attachShadow({
|
2391 | mode: 'open',
|
2392 | delegatesFocus: !!(cmpMeta.$flags$ & 16 ),
|
2393 | });
|
2394 | }
|
2395 | else {
|
2396 | self.attachShadow({ mode: 'open' });
|
2397 | }
|
2398 | }
|
2399 | else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
|
2400 | self.shadowRoot = self;
|
2401 | }
|
2402 | }
|
2403 | if (BUILD.slotChildNodesFix) {
|
2404 | patchChildSlotNodes(self, cmpMeta);
|
2405 | }
|
2406 | }
|
2407 | connectedCallback() {
|
2408 | if (appLoadFallback) {
|
2409 | clearTimeout(appLoadFallback);
|
2410 | appLoadFallback = null;
|
2411 | }
|
2412 | if (isBootstrapping) {
|
2413 |
|
2414 | deferredConnectedCallbacks.push(this);
|
2415 | }
|
2416 | else {
|
2417 | plt.jmp(() => connectedCallback(this));
|
2418 | }
|
2419 | }
|
2420 | disconnectedCallback() {
|
2421 | plt.jmp(() => disconnectedCallback(this));
|
2422 | }
|
2423 | forceUpdate() {
|
2424 | if (BUILD.isDev) {
|
2425 | consoleDevWarn(`element.forceUpdate() is deprecated, use the "forceUpdate" function from "@stencil/core" instead:
|
2426 |
|
2427 | import { forceUpdate } from ‘@stencil/core’;
|
2428 |
|
2429 | forceUpdate(this);
|
2430 | forceUpdate(element);`);
|
2431 | }
|
2432 | forceUpdate(this);
|
2433 | }
|
2434 | componentOnReady() {
|
2435 | return getHostRef(this).$onReadyPromise$;
|
2436 | }
|
2437 | };
|
2438 | if (BUILD.cloneNodeFix) {
|
2439 | patchCloneNode(HostElement.prototype);
|
2440 | }
|
2441 | if (BUILD.appendChildSlotFix) {
|
2442 | patchSlotAppendChild(HostElement.prototype);
|
2443 | }
|
2444 | if (BUILD.hotModuleReplacement) {
|
2445 | HostElement.prototype['s-hmr'] = function (hmrVersionId) {
|
2446 | hmrStart(this, cmpMeta, hmrVersionId);
|
2447 | };
|
2448 | }
|
2449 | cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
2450 | if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
2451 | cmpTags.push(tagName);
|
2452 | customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 ));
|
2453 | }
|
2454 | }));
|
2455 | if (BUILD.hydratedClass || BUILD.hydratedAttribute) {
|
2456 | visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
2457 | visibilityStyle.setAttribute('data-styles', '');
|
2458 | head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
2459 | }
|
2460 |
|
2461 | isBootstrapping = false;
|
2462 | if (deferredConnectedCallbacks.length) {
|
2463 | deferredConnectedCallbacks.map(host => host.connectedCallback());
|
2464 | }
|
2465 | else {
|
2466 | if (BUILD.profile) {
|
2467 | plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
|
2468 | }
|
2469 | else {
|
2470 | plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
|
2471 | }
|
2472 | }
|
2473 |
|
2474 | endBootstrap();
|
2475 | };
|
2476 | const getAssetPath = (path) => {
|
2477 | const assetUrl = new URL(path, plt.$resourcesUrl$);
|
2478 | return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
2479 | };
|
2480 | const getConnect = (_ref, tagName) => {
|
2481 | const componentOnReady = () => {
|
2482 | let elm = doc.querySelector(tagName);
|
2483 | if (!elm) {
|
2484 | elm = doc.createElement(tagName);
|
2485 | doc.body.appendChild(elm);
|
2486 | }
|
2487 | return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
|
2488 | };
|
2489 | const create = (...args) => {
|
2490 | return componentOnReady().then(el => el.create(...args));
|
2491 | };
|
2492 | return {
|
2493 | create,
|
2494 | componentOnReady,
|
2495 | };
|
2496 | };
|
2497 | const getContext = (_elm, context) => {
|
2498 | if (context in Context) {
|
2499 | return Context[context];
|
2500 | }
|
2501 | else if (context === 'window') {
|
2502 | return win;
|
2503 | }
|
2504 | else if (context === 'document') {
|
2505 | return doc;
|
2506 | }
|
2507 | else if (context === 'isServer' || context === 'isPrerender') {
|
2508 | return BUILD.hydrateServerSide ? true : false;
|
2509 | }
|
2510 | else if (context === 'isClient') {
|
2511 | return BUILD.hydrateServerSide ? false : true;
|
2512 | }
|
2513 | else if (context === 'resourcesUrl' || context === 'publicPath') {
|
2514 | return getAssetPath('.');
|
2515 | }
|
2516 | else if (context === 'queue') {
|
2517 | return {
|
2518 | write: writeTask,
|
2519 | read: readTask,
|
2520 | tick: {
|
2521 | then(cb) {
|
2522 | return nextTick(cb);
|
2523 | },
|
2524 | },
|
2525 | };
|
2526 | }
|
2527 | return undefined;
|
2528 | };
|
2529 | const insertVdomAnnotations = (doc, staticComponents) => {
|
2530 | if (doc != null) {
|
2531 | const docData = {
|
2532 | hostIds: 0,
|
2533 | rootLevelIds: 0,
|
2534 | staticComponents: new Set(staticComponents),
|
2535 | };
|
2536 | const orgLocationNodes = [];
|
2537 | parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
|
2538 | orgLocationNodes.forEach(orgLocationNode => {
|
2539 | if (orgLocationNode != null) {
|
2540 | const nodeRef = orgLocationNode['s-nr'];
|
2541 | let hostId = nodeRef['s-host-id'];
|
2542 | let nodeId = nodeRef['s-node-id'];
|
2543 | let childId = `${hostId}.${nodeId}`;
|
2544 | if (hostId == null) {
|
2545 | hostId = 0;
|
2546 | docData.rootLevelIds++;
|
2547 | nodeId = docData.rootLevelIds;
|
2548 | childId = `${hostId}.${nodeId}`;
|
2549 | if (nodeRef.nodeType === 1 ) {
|
2550 | nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
|
2551 | }
|
2552 | else if (nodeRef.nodeType === 3 ) {
|
2553 | if (hostId === 0) {
|
2554 | const textContent = nodeRef.nodeValue.trim();
|
2555 | if (textContent === '') {
|
2556 |
|
2557 | orgLocationNode.remove();
|
2558 | return;
|
2559 | }
|
2560 | }
|
2561 | const commentBeforeTextNode = doc.createComment(childId);
|
2562 | commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
|
2563 | nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
|
2564 | }
|
2565 | }
|
2566 | let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
|
2567 | const orgLocationParentNode = orgLocationNode.parentElement;
|
2568 | if (orgLocationParentNode) {
|
2569 | if (orgLocationParentNode['s-en'] === '') {
|
2570 |
|
2571 |
|
2572 |
|
2573 | orgLocationNodeId += `.`;
|
2574 | }
|
2575 | else if (orgLocationParentNode['s-en'] === 'c') {
|
2576 |
|
2577 |
|
2578 |
|
2579 | orgLocationNodeId += `.c`;
|
2580 | }
|
2581 | }
|
2582 | orgLocationNode.nodeValue = orgLocationNodeId;
|
2583 | }
|
2584 | });
|
2585 | }
|
2586 | };
|
2587 | const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
|
2588 | if (node == null) {
|
2589 | return;
|
2590 | }
|
2591 | if (node['s-nr'] != null) {
|
2592 | orgLocationNodes.push(node);
|
2593 | }
|
2594 | if (node.nodeType === 1 ) {
|
2595 | node.childNodes.forEach(childNode => {
|
2596 | const hostRef = getHostRef(childNode);
|
2597 | if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
|
2598 | const cmpData = {
|
2599 | nodeIds: 0,
|
2600 | };
|
2601 | insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
|
2602 | }
|
2603 | parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
|
2604 | });
|
2605 | }
|
2606 | };
|
2607 | const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
|
2608 | if (vnode != null) {
|
2609 | const hostId = ++docData.hostIds;
|
2610 | hostElm.setAttribute(HYDRATE_ID, hostId);
|
2611 | if (hostElm['s-cr'] != null) {
|
2612 | hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
|
2613 | }
|
2614 | if (vnode.$children$ != null) {
|
2615 | const depth = 0;
|
2616 | vnode.$children$.forEach((vnodeChild, index) => {
|
2617 | insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
|
2618 | });
|
2619 | }
|
2620 | if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
|
2621 | const parent = hostElm.parentElement;
|
2622 | if (parent && parent.childNodes) {
|
2623 | const parentChildNodes = Array.from(parent.childNodes);
|
2624 | const comment = parentChildNodes.find(node => node.nodeType === 8 && node['s-sr']);
|
2625 | if (comment) {
|
2626 | const index = parentChildNodes.indexOf(hostElm) - 1;
|
2627 | vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
|
2628 | }
|
2629 | }
|
2630 | }
|
2631 | }
|
2632 | };
|
2633 | const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
|
2634 | const childElm = vnodeChild.$elm$;
|
2635 | if (childElm == null) {
|
2636 | return;
|
2637 | }
|
2638 | const nodeId = cmpData.nodeIds++;
|
2639 | const childId = `${hostId}.${nodeId}.${depth}.${index}`;
|
2640 | childElm['s-host-id'] = hostId;
|
2641 | childElm['s-node-id'] = nodeId;
|
2642 | if (childElm.nodeType === 1 ) {
|
2643 | childElm.setAttribute(HYDRATE_CHILD_ID, childId);
|
2644 | }
|
2645 | else if (childElm.nodeType === 3 ) {
|
2646 | const parentNode = childElm.parentNode;
|
2647 | if (parentNode.nodeName !== 'STYLE') {
|
2648 | const textNodeId = `${TEXT_NODE_ID}.${childId}`;
|
2649 | const commentBeforeTextNode = doc.createComment(textNodeId);
|
2650 | parentNode.insertBefore(commentBeforeTextNode, childElm);
|
2651 | }
|
2652 | }
|
2653 | else if (childElm.nodeType === 8 ) {
|
2654 | if (childElm['s-sr']) {
|
2655 | const slotName = childElm['s-sn'] || '';
|
2656 | const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
|
2657 | childElm.nodeValue = slotNodeId;
|
2658 | }
|
2659 | }
|
2660 | if (vnodeChild.$children$ != null) {
|
2661 | const childDepth = depth + 1;
|
2662 | vnodeChild.$children$.forEach((vnode, index) => {
|
2663 | insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
|
2664 | });
|
2665 | }
|
2666 | };
|
2667 | const hostRefs = new WeakMap();
|
2668 | const getHostRef = (ref) => hostRefs.get(ref);
|
2669 | const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
2670 | const registerHost = (elm, cmpMeta) => {
|
2671 | const hostRef = {
|
2672 | $flags$: 0,
|
2673 | $hostElement$: elm,
|
2674 | $cmpMeta$: cmpMeta,
|
2675 | $instanceValues$: new Map(),
|
2676 | };
|
2677 | if (BUILD.isDev) {
|
2678 | hostRef.$renderCount$ = 0;
|
2679 | }
|
2680 | if (BUILD.method && BUILD.lazyLoad) {
|
2681 | hostRef.$onInstancePromise$ = new Promise(r => (hostRef.$onInstanceResolve$ = r));
|
2682 | }
|
2683 | if (BUILD.asyncLoading) {
|
2684 | hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
|
2685 | elm['s-p'] = [];
|
2686 | elm['s-rc'] = [];
|
2687 | }
|
2688 | addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
|
2689 | return hostRefs.set(elm, hostRef);
|
2690 | };
|
2691 | const isMemberInElement = (elm, memberName) => memberName in elm;
|
2692 | const STENCIL_DEV_MODE = BUILD.isTesting
|
2693 | ? ['STENCIL:']
|
2694 | : ['%cstencil', 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px'];
|
2695 | const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
|
2696 | const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
|
2697 | const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
|
2698 | const consoleError = (e) => console.error(e);
|
2699 | const cmpModules = new Map();
|
2700 | const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
2701 |
|
2702 | const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
2703 | const bundleId = cmpMeta.$lazyBundleId$;
|
2704 | if (BUILD.isDev && typeof bundleId !== 'string') {
|
2705 | consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
|
2706 | return undefined;
|
2707 | }
|
2708 | const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
|
2709 | if (module) {
|
2710 | return module[exportName];
|
2711 | }
|
2712 | return Promise.resolve().then(function () { return _interopNamespace(require(
|
2713 |
|
2714 |
|
2715 |
|
2716 | `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then(importedModule => {
|
2717 | if (!BUILD.hotModuleReplacement) {
|
2718 | cmpModules.set(bundleId, importedModule);
|
2719 | }
|
2720 | return importedModule[exportName];
|
2721 | }, consoleError);
|
2722 | };
|
2723 | const styles = new Map();
|
2724 | const modeResolutionChain = [];
|
2725 | const queueDomReads = [];
|
2726 | const queueDomWrites = [];
|
2727 | const queueDomWritesLow = [];
|
2728 | const queueTask = (queue, write) => (cb) => {
|
2729 | queue.push(cb);
|
2730 | if (!queuePending) {
|
2731 | queuePending = true;
|
2732 | if (write && plt.$flags$ & 4 ) {
|
2733 | nextTick(flush);
|
2734 | }
|
2735 | else {
|
2736 | plt.raf(flush);
|
2737 | }
|
2738 | }
|
2739 | };
|
2740 | const consume = (queue) => {
|
2741 | for (let i = 0; i < queue.length; i++) {
|
2742 | try {
|
2743 | queue[i](performance.now());
|
2744 | }
|
2745 | catch (e) {
|
2746 | consoleError(e);
|
2747 | }
|
2748 | }
|
2749 | queue.length = 0;
|
2750 | };
|
2751 | const consumeTimeout = (queue, timeout) => {
|
2752 | let i = 0;
|
2753 | let ts = 0;
|
2754 | while (i < queue.length && (ts = performance.now()) < timeout) {
|
2755 | try {
|
2756 | queue[i++](ts);
|
2757 | }
|
2758 | catch (e) {
|
2759 | consoleError(e);
|
2760 | }
|
2761 | }
|
2762 | if (i === queue.length) {
|
2763 | queue.length = 0;
|
2764 | }
|
2765 | else if (i !== 0) {
|
2766 | queue.splice(0, i);
|
2767 | }
|
2768 | };
|
2769 | const flush = () => {
|
2770 | if (BUILD.asyncQueue) {
|
2771 | queueCongestion++;
|
2772 | }
|
2773 |
|
2774 |
|
2775 |
|
2776 | consume(queueDomReads);
|
2777 |
|
2778 | if (BUILD.asyncQueue) {
|
2779 | const timeout = (plt.$flags$ & 6 ) === 2 ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0)) : Infinity;
|
2780 | consumeTimeout(queueDomWrites, timeout);
|
2781 | consumeTimeout(queueDomWritesLow, timeout);
|
2782 | if (queueDomWrites.length > 0) {
|
2783 | queueDomWritesLow.push(...queueDomWrites);
|
2784 | queueDomWrites.length = 0;
|
2785 | }
|
2786 | if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
|
2787 |
|
2788 |
|
2789 | plt.raf(flush);
|
2790 | }
|
2791 | else {
|
2792 | queueCongestion = 0;
|
2793 | }
|
2794 | }
|
2795 | else {
|
2796 | consume(queueDomWrites);
|
2797 | if ((queuePending = queueDomReads.length > 0)) {
|
2798 |
|
2799 |
|
2800 | plt.raf(flush);
|
2801 | }
|
2802 | }
|
2803 | };
|
2804 | const nextTick = (cb) => promiseResolve().then(cb);
|
2805 | const readTask = queueTask(queueDomReads, false);
|
2806 | const writeTask = queueTask(queueDomWrites, true);
|
2807 | const Build = {
|
2808 | isDev: BUILD.isDev ? true : false,
|
2809 | isBrowser: true,
|
2810 | isServer: false,
|
2811 | isTesting: BUILD.isTesting ? true : false,
|
2812 | };
|
2813 |
|
2814 | exports.BUILD = BUILD;
|
2815 | exports.CSS = CSS;
|
2816 | exports.H = H;
|
2817 | exports.Host = Host;
|
2818 | exports.NAMESPACE = NAMESPACE;
|
2819 | exports.bootstrapLazy = bootstrapLazy;
|
2820 | exports.consoleDevInfo = consoleDevInfo;
|
2821 | exports.doc = doc;
|
2822 | exports.h = h;
|
2823 | exports.plt = plt;
|
2824 | exports.promiseResolve = promiseResolve;
|
2825 | exports.registerInstance = registerInstance;
|
2826 | exports.win = win;
|