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