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