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