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