1 |
|
2 | 'use strict';
|
3 |
|
4 | Object.defineProperty(exports, '__esModule', { value: true });
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function detect() {
|
13 |
|
14 | if ('getKey' in Proxy) {
|
15 | return false;
|
16 | }
|
17 | const proxy = new Proxy([3, 4], {});
|
18 | const res = [1, 2].concat(proxy);
|
19 | return res.length !== 4;
|
20 | }
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | const { isConcatSpreadable } = Symbol;
|
29 | const { isArray } = Array;
|
30 | const { slice: ArraySlice, unshift: ArrayUnshift, shift: ArrayShift } = Array.prototype;
|
31 | function isObject(O) {
|
32 | return typeof O === 'object' ? O !== null : typeof O === 'function';
|
33 | }
|
34 |
|
35 | function isSpreadable(O) {
|
36 | if (!isObject(O)) {
|
37 | return false;
|
38 | }
|
39 | const spreadable = O[isConcatSpreadable];
|
40 | return spreadable !== undefined ? Boolean(spreadable) : isArray(O);
|
41 | }
|
42 |
|
43 | function ArrayConcatPolyfill(..._args) {
|
44 | const O = Object(this);
|
45 | const A = [];
|
46 | let N = 0;
|
47 | const items = ArraySlice.call(arguments);
|
48 | ArrayUnshift.call(items, O);
|
49 | while (items.length) {
|
50 | const E = ArrayShift.call(items);
|
51 | if (isSpreadable(E)) {
|
52 | let k = 0;
|
53 | const length = E.length;
|
54 | for (k; k < length; k += 1, N += 1) {
|
55 | if (k in E) {
|
56 | const subElement = E[k];
|
57 | A[N] = subElement;
|
58 | }
|
59 | }
|
60 | }
|
61 | else {
|
62 | A[N] = E;
|
63 | N += 1;
|
64 | }
|
65 | }
|
66 | return A;
|
67 | }
|
68 | function apply() {
|
69 |
|
70 | Array.prototype.concat = ArrayConcatPolyfill;
|
71 | }
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | if (detect()) {
|
80 | apply();
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | function invariant(value, msg) {
|
93 | if (!value) {
|
94 | throw new Error(`Invariant Violation: ${msg}`);
|
95 | }
|
96 | }
|
97 | function isTrue(value, msg) {
|
98 | if (!value) {
|
99 | throw new Error(`Assert Violation: ${msg}`);
|
100 | }
|
101 | }
|
102 | function isFalse(value, msg) {
|
103 | if (value) {
|
104 | throw new Error(`Assert Violation: ${msg}`);
|
105 | }
|
106 | }
|
107 | function fail(msg) {
|
108 | throw new Error(msg);
|
109 | }
|
110 |
|
111 | var assert = Object.freeze({
|
112 | __proto__: null,
|
113 | invariant: invariant,
|
114 | isTrue: isTrue,
|
115 | isFalse: isFalse,
|
116 | fail: fail
|
117 | });
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 | const { assign, create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor, getOwnPropertyNames, getPrototypeOf, hasOwnProperty, isFrozen, keys, seal, setPrototypeOf, } = Object;
|
126 | const { isArray: isArray$1 } = Array;
|
127 | const { filter: ArrayFilter, find: ArrayFind, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, slice: ArraySlice$1, splice: ArraySplice, unshift: ArrayUnshift$1, forEach, } = Array.prototype;
|
128 | const { charCodeAt: StringCharCodeAt, replace: StringReplace, slice: StringSlice, toLowerCase: StringToLowerCase, } = String.prototype;
|
129 | function isUndefined(obj) {
|
130 | return obj === undefined;
|
131 | }
|
132 | function isNull(obj) {
|
133 | return obj === null;
|
134 | }
|
135 | function isFalse$1(obj) {
|
136 | return obj === false;
|
137 | }
|
138 | function isFunction(obj) {
|
139 | return typeof obj === 'function';
|
140 | }
|
141 | function isObject$1(obj) {
|
142 | return typeof obj === 'object';
|
143 | }
|
144 | const OtS = {}.toString;
|
145 | function toString(obj) {
|
146 | if (obj && obj.toString) {
|
147 |
|
148 |
|
149 |
|
150 | if (isArray$1(obj)) {
|
151 | return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
152 | }
|
153 | return obj.toString();
|
154 | }
|
155 | else if (typeof obj === 'object') {
|
156 | return OtS.call(obj);
|
157 | }
|
158 | else {
|
159 | return obj + emptyString;
|
160 | }
|
161 | }
|
162 | const emptyString = '';
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 | const AriaPropertyNames = [
|
180 | 'ariaActiveDescendant',
|
181 | 'ariaAtomic',
|
182 | 'ariaAutoComplete',
|
183 | 'ariaBusy',
|
184 | 'ariaChecked',
|
185 | 'ariaColCount',
|
186 | 'ariaColIndex',
|
187 | 'ariaColSpan',
|
188 | 'ariaControls',
|
189 | 'ariaCurrent',
|
190 | 'ariaDescribedBy',
|
191 | 'ariaDetails',
|
192 | 'ariaDisabled',
|
193 | 'ariaErrorMessage',
|
194 | 'ariaExpanded',
|
195 | 'ariaFlowTo',
|
196 | 'ariaHasPopup',
|
197 | 'ariaHidden',
|
198 | 'ariaInvalid',
|
199 | 'ariaKeyShortcuts',
|
200 | 'ariaLabel',
|
201 | 'ariaLabelledBy',
|
202 | 'ariaLevel',
|
203 | 'ariaLive',
|
204 | 'ariaModal',
|
205 | 'ariaMultiLine',
|
206 | 'ariaMultiSelectable',
|
207 | 'ariaOrientation',
|
208 | 'ariaOwns',
|
209 | 'ariaPlaceholder',
|
210 | 'ariaPosInSet',
|
211 | 'ariaPressed',
|
212 | 'ariaReadOnly',
|
213 | 'ariaRelevant',
|
214 | 'ariaRequired',
|
215 | 'ariaRoleDescription',
|
216 | 'ariaRowCount',
|
217 | 'ariaRowIndex',
|
218 | 'ariaRowSpan',
|
219 | 'ariaSelected',
|
220 | 'ariaSetSize',
|
221 | 'ariaSort',
|
222 | 'ariaValueMax',
|
223 | 'ariaValueMin',
|
224 | 'ariaValueNow',
|
225 | 'ariaValueText',
|
226 | 'role',
|
227 | ];
|
228 | const AttrNameToPropNameMap = create(null);
|
229 | const PropNameToAttrNameMap = create(null);
|
230 |
|
231 | forEach.call(AriaPropertyNames, (propName) => {
|
232 |
|
233 |
|
234 |
|
235 | const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, 'aria-'));
|
236 | AttrNameToPropNameMap[attrName] = propName;
|
237 | PropNameToAttrNameMap[propName] = attrName;
|
238 | });
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 | const _globalThis = (function () {
|
248 |
|
249 | if (typeof globalThis === 'object') {
|
250 | return globalThis;
|
251 | }
|
252 | let _globalThis;
|
253 | try {
|
254 |
|
255 | Object.defineProperty(Object.prototype, '__magic__', {
|
256 | get: function () {
|
257 | return this;
|
258 | },
|
259 | configurable: true,
|
260 | });
|
261 |
|
262 |
|
263 |
|
264 | _globalThis = __magic__;
|
265 |
|
266 | delete Object.prototype.__magic__;
|
267 | }
|
268 | catch (ex) {
|
269 |
|
270 | }
|
271 | finally {
|
272 |
|
273 |
|
274 | if (typeof _globalThis === 'undefined') {
|
275 |
|
276 | _globalThis = window;
|
277 | }
|
278 | }
|
279 | return _globalThis;
|
280 | })();
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 | const hasNativeSymbolsSupport = Symbol('x').toString() === 'Symbol(x)';
|
295 | function createHiddenField(key, namespace) {
|
296 | return (hasNativeSymbolsSupport ? Symbol(key) : `$$lwc-${namespace}-${key}$$`);
|
297 | }
|
298 | const hiddenFieldsMap = new WeakMap();
|
299 | function setHiddenField(o, field, value) {
|
300 | let valuesByField = hiddenFieldsMap.get(o);
|
301 | if (isUndefined(valuesByField)) {
|
302 | valuesByField = create(null);
|
303 | hiddenFieldsMap.set(o, valuesByField);
|
304 | }
|
305 | valuesByField[field] = value;
|
306 | }
|
307 | function getHiddenField(o, field) {
|
308 | const valuesByField = hiddenFieldsMap.get(o);
|
309 | if (!isUndefined(valuesByField)) {
|
310 | return valuesByField[field];
|
311 | }
|
312 | }
|
313 | const HTML_ATTRIBUTES_TO_PROPERTY = {
|
314 | accesskey: 'accessKey',
|
315 | readonly: 'readOnly',
|
316 | tabindex: 'tabIndex',
|
317 | bgcolor: 'bgColor',
|
318 | colspan: 'colSpan',
|
319 | rowspan: 'rowSpan',
|
320 | contenteditable: 'contentEditable',
|
321 | crossorigin: 'crossOrigin',
|
322 | datetime: 'dateTime',
|
323 | formaction: 'formAction',
|
324 | ismap: 'isMap',
|
325 | maxlength: 'maxLength',
|
326 | minlength: 'minLength',
|
327 | novalidate: 'noValidate',
|
328 | usemap: 'useMap',
|
329 | for: 'htmlFor',
|
330 | };
|
331 | keys(HTML_ATTRIBUTES_TO_PROPERTY).forEach((attrName) => {
|
332 | });
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 | function detect$1(propName) {
|
342 | return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
|
343 | }
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 | const nodeToAriaPropertyValuesMap = new WeakMap();
|
352 | function getAriaPropertyMap(elm) {
|
353 | let map = nodeToAriaPropertyValuesMap.get(elm);
|
354 | if (map === undefined) {
|
355 | map = {};
|
356 | nodeToAriaPropertyValuesMap.set(elm, map);
|
357 | }
|
358 | return map;
|
359 | }
|
360 | function getNormalizedAriaPropertyValue(value) {
|
361 | return value == null ? null : String(value);
|
362 | }
|
363 | function createAriaPropertyPropertyDescriptor(propName, attrName) {
|
364 | return {
|
365 | get() {
|
366 | const map = getAriaPropertyMap(this);
|
367 | if (hasOwnProperty.call(map, propName)) {
|
368 | return map[propName];
|
369 | }
|
370 |
|
371 | return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
|
372 | },
|
373 | set(newValue) {
|
374 | const normalizedValue = getNormalizedAriaPropertyValue(newValue);
|
375 | const map = getAriaPropertyMap(this);
|
376 | map[propName] = normalizedValue;
|
377 |
|
378 | if (newValue === null) {
|
379 | this.removeAttribute(attrName);
|
380 | }
|
381 | else {
|
382 | this.setAttribute(attrName, newValue);
|
383 | }
|
384 | },
|
385 | configurable: true,
|
386 | enumerable: true,
|
387 | };
|
388 | }
|
389 | function patch(propName) {
|
390 |
|
391 |
|
392 |
|
393 | const attrName = PropNameToAttrNameMap[propName];
|
394 | const descriptor = createAriaPropertyPropertyDescriptor(propName, attrName);
|
395 | Object.defineProperty(Element.prototype, propName, descriptor);
|
396 | }
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 | const ElementPrototypeAriaPropertyNames = keys(PropNameToAttrNameMap);
|
405 | for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
|
406 | const propName = ElementPrototypeAriaPropertyNames[i];
|
407 | if (detect$1(propName)) {
|
408 | patch(propName);
|
409 | }
|
410 | }
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 | function invariant$1(value, msg) {
|
424 | if (!value) {
|
425 | throw new Error(`Invariant Violation: ${msg}`);
|
426 | }
|
427 | }
|
428 |
|
429 | function isTrue$1(value, msg) {
|
430 | if (!value) {
|
431 | throw new Error(`Assert Violation: ${msg}`);
|
432 | }
|
433 | }
|
434 |
|
435 | function isFalse$2(value, msg) {
|
436 | if (value) {
|
437 | throw new Error(`Assert Violation: ${msg}`);
|
438 | }
|
439 | }
|
440 |
|
441 | function fail$1(msg) {
|
442 | throw new Error(msg);
|
443 | }
|
444 |
|
445 | var assert$1 = Object.freeze({
|
446 | __proto__: null,
|
447 | invariant: invariant$1,
|
448 | isTrue: isTrue$1,
|
449 | isFalse: isFalse$2,
|
450 | fail: fail$1
|
451 | });
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 | const {
|
460 | assign: assign$1,
|
461 | create: create$1,
|
462 | defineProperties: defineProperties$1,
|
463 | defineProperty: defineProperty$1,
|
464 | freeze: freeze$1,
|
465 | getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
|
466 | getOwnPropertyNames: getOwnPropertyNames$1,
|
467 | getPrototypeOf: getPrototypeOf$1,
|
468 | hasOwnProperty: hasOwnProperty$1,
|
469 | isFrozen: isFrozen$1,
|
470 | keys: keys$1,
|
471 | seal: seal$1,
|
472 | setPrototypeOf: setPrototypeOf$1
|
473 | } = Object;
|
474 | const {
|
475 | isArray: isArray$2
|
476 | } = Array;
|
477 | const {
|
478 | filter: ArrayFilter$1,
|
479 | find: ArrayFind$1,
|
480 | indexOf: ArrayIndexOf$1,
|
481 | join: ArrayJoin$1,
|
482 | map: ArrayMap$1,
|
483 | push: ArrayPush$1,
|
484 | reduce: ArrayReduce$1,
|
485 | reverse: ArrayReverse$1,
|
486 | slice: ArraySlice$2,
|
487 | splice: ArraySplice$1,
|
488 | unshift: ArrayUnshift$2,
|
489 | forEach: forEach$1
|
490 | } = Array.prototype;
|
491 | const {
|
492 | charCodeAt: StringCharCodeAt$1,
|
493 | replace: StringReplace$1,
|
494 | slice: StringSlice$1,
|
495 | toLowerCase: StringToLowerCase$1
|
496 | } = String.prototype;
|
497 |
|
498 | function isUndefined$1(obj) {
|
499 | return obj === undefined;
|
500 | }
|
501 |
|
502 | function isNull$1(obj) {
|
503 | return obj === null;
|
504 | }
|
505 |
|
506 | function isTrue$1$1(obj) {
|
507 | return obj === true;
|
508 | }
|
509 |
|
510 | function isFalse$1$1(obj) {
|
511 | return obj === false;
|
512 | }
|
513 |
|
514 | function isFunction$1(obj) {
|
515 | return typeof obj === 'function';
|
516 | }
|
517 |
|
518 | function isObject$2(obj) {
|
519 | return typeof obj === 'object';
|
520 | }
|
521 |
|
522 | function isString(obj) {
|
523 | return typeof obj === 'string';
|
524 | }
|
525 |
|
526 | function isNumber(obj) {
|
527 | return typeof obj === 'number';
|
528 | }
|
529 |
|
530 | const OtS$1 = {}.toString;
|
531 |
|
532 | function toString$1(obj) {
|
533 | if (obj && obj.toString) {
|
534 |
|
535 |
|
536 |
|
537 | if (isArray$2(obj)) {
|
538 | return ArrayJoin$1.call(ArrayMap$1.call(obj, toString$1), ',');
|
539 | }
|
540 |
|
541 | return obj.toString();
|
542 | } else if (typeof obj === 'object') {
|
543 | return OtS$1.call(obj);
|
544 | } else {
|
545 | return obj + emptyString$1;
|
546 | }
|
547 | }
|
548 |
|
549 | function getPropertyDescriptor(o, p) {
|
550 | do {
|
551 | const d = getOwnPropertyDescriptor$1(o, p);
|
552 |
|
553 | if (!isUndefined$1(d)) {
|
554 | return d;
|
555 | }
|
556 |
|
557 | o = getPrototypeOf$1(o);
|
558 | } while (o !== null);
|
559 | }
|
560 |
|
561 | const emptyString$1 = '';
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 | const AriaPropertyNames$1 = ['ariaActiveDescendant', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', 'ariaChecked', 'ariaColCount', 'ariaColIndex', 'ariaColSpan', 'ariaControls', 'ariaCurrent', 'ariaDescribedBy', 'ariaDetails', 'ariaDisabled', 'ariaErrorMessage', 'ariaExpanded', 'ariaFlowTo', 'ariaHasPopup', 'ariaHidden', 'ariaInvalid', 'ariaKeyShortcuts', 'ariaLabel', 'ariaLabelledBy', 'ariaLevel', 'ariaLive', 'ariaModal', 'ariaMultiLine', 'ariaMultiSelectable', 'ariaOrientation', 'ariaOwns', 'ariaPlaceholder', 'ariaPosInSet', 'ariaPressed', 'ariaReadOnly', 'ariaRelevant', 'ariaRequired', 'ariaRoleDescription', 'ariaRowCount', 'ariaRowIndex', 'ariaRowSpan', 'ariaSelected', 'ariaSetSize', 'ariaSort', 'ariaValueMax', 'ariaValueMin', 'ariaValueNow', 'ariaValueText', 'role'];
|
580 | const AttrNameToPropNameMap$1 = create$1(null);
|
581 | const PropNameToAttrNameMap$1 = create$1(null);
|
582 |
|
583 | forEach$1.call(AriaPropertyNames$1, propName => {
|
584 |
|
585 |
|
586 |
|
587 | const attrName = StringToLowerCase$1.call(StringReplace$1.call(propName, /^aria/, 'aria-'));
|
588 | AttrNameToPropNameMap$1[attrName] = propName;
|
589 | PropNameToAttrNameMap$1[propName] = attrName;
|
590 | });
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 | const _globalThis$1 = function () {
|
601 |
|
602 | if (typeof globalThis === 'object') {
|
603 | return globalThis;
|
604 | }
|
605 |
|
606 | let _globalThis;
|
607 |
|
608 | try {
|
609 |
|
610 | Object.defineProperty(Object.prototype, '__magic__', {
|
611 | get: function () {
|
612 | return this;
|
613 | },
|
614 | configurable: true
|
615 | });
|
616 |
|
617 |
|
618 |
|
619 | _globalThis = __magic__;
|
620 |
|
621 | delete Object.prototype.__magic__;
|
622 | } catch (ex) {
|
623 | } finally {
|
624 |
|
625 |
|
626 | if (typeof _globalThis === 'undefined') {
|
627 |
|
628 | _globalThis = window;
|
629 | }
|
630 | }
|
631 |
|
632 | return _globalThis;
|
633 | }();
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 | const hasNativeSymbolsSupport$1 = Symbol('x').toString() === 'Symbol(x)';
|
650 |
|
651 | function createHiddenField$1(key, namespace) {
|
652 | return hasNativeSymbolsSupport$1 ? Symbol(key) : `$$lwc-${namespace}-${key}$$`;
|
653 | }
|
654 |
|
655 | const hiddenFieldsMap$1 = new WeakMap();
|
656 |
|
657 | function setHiddenField$1(o, field, value) {
|
658 | let valuesByField = hiddenFieldsMap$1.get(o);
|
659 |
|
660 | if (isUndefined$1(valuesByField)) {
|
661 | valuesByField = create$1(null);
|
662 | hiddenFieldsMap$1.set(o, valuesByField);
|
663 | }
|
664 |
|
665 | valuesByField[field] = value;
|
666 | }
|
667 |
|
668 | function getHiddenField$1(o, field) {
|
669 | const valuesByField = hiddenFieldsMap$1.get(o);
|
670 |
|
671 | if (!isUndefined$1(valuesByField)) {
|
672 | return valuesByField[field];
|
673 | }
|
674 | }
|
675 |
|
676 | const HTML_ATTRIBUTES_TO_PROPERTY$1 = {
|
677 | accesskey: 'accessKey',
|
678 | readonly: 'readOnly',
|
679 | tabindex: 'tabIndex',
|
680 | bgcolor: 'bgColor',
|
681 | colspan: 'colSpan',
|
682 | rowspan: 'rowSpan',
|
683 | contenteditable: 'contentEditable',
|
684 | crossorigin: 'crossOrigin',
|
685 | datetime: 'dateTime',
|
686 | formaction: 'formAction',
|
687 | ismap: 'isMap',
|
688 | maxlength: 'maxLength',
|
689 | minlength: 'minLength',
|
690 | novalidate: 'noValidate',
|
691 | usemap: 'useMap',
|
692 | for: 'htmlFor'
|
693 | };
|
694 | keys$1(HTML_ATTRIBUTES_TO_PROPERTY$1).forEach(attrName => {
|
695 | });
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 | let nextTickCallbackQueue = [];
|
705 | const SPACE_CHAR = 32;
|
706 | const EmptyObject = seal$1(create$1(null));
|
707 | const EmptyArray = seal$1([]);
|
708 |
|
709 | function flushCallbackQueue() {
|
710 | if (process.env.NODE_ENV !== 'production') {
|
711 | if (nextTickCallbackQueue.length === 0) {
|
712 | throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
|
713 | }
|
714 | }
|
715 |
|
716 | const callbacks = nextTickCallbackQueue;
|
717 | nextTickCallbackQueue = [];
|
718 |
|
719 | for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
720 | callbacks[i]();
|
721 | }
|
722 | }
|
723 |
|
724 | function addCallbackToNextTick(callback) {
|
725 | if (process.env.NODE_ENV !== 'production') {
|
726 | if (!isFunction$1(callback)) {
|
727 | throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
|
728 | }
|
729 | }
|
730 |
|
731 | if (nextTickCallbackQueue.length === 0) {
|
732 | Promise.resolve().then(flushCallbackQueue);
|
733 | }
|
734 |
|
735 | ArrayPush$1.call(nextTickCallbackQueue, callback);
|
736 | }
|
737 | function guid() {
|
738 | function s4() {
|
739 | return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
740 | }
|
741 |
|
742 | return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
743 | }
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 | const {
|
752 | create: create$1$1
|
753 | } = Object;
|
754 | const {
|
755 | splice: ArraySplice$1$1,
|
756 | indexOf: ArrayIndexOf$1$1,
|
757 | push: ArrayPush$1$1
|
758 | } = Array.prototype;
|
759 | const TargetToReactiveRecordMap = new WeakMap();
|
760 |
|
761 | function isUndefined$1$1(obj) {
|
762 | return obj === undefined;
|
763 | }
|
764 |
|
765 | function getReactiveRecord(target) {
|
766 | let reactiveRecord = TargetToReactiveRecordMap.get(target);
|
767 |
|
768 | if (isUndefined$1$1(reactiveRecord)) {
|
769 | const newRecord = create$1$1(null);
|
770 | reactiveRecord = newRecord;
|
771 | TargetToReactiveRecordMap.set(target, newRecord);
|
772 | }
|
773 |
|
774 | return reactiveRecord;
|
775 | }
|
776 |
|
777 | let currentReactiveObserver = null;
|
778 | function valueMutated(target, key) {
|
779 | const reactiveRecord = TargetToReactiveRecordMap.get(target);
|
780 |
|
781 | if (!isUndefined$1$1(reactiveRecord)) {
|
782 | const reactiveObservers = reactiveRecord[key];
|
783 |
|
784 | if (!isUndefined$1$1(reactiveObservers)) {
|
785 | for (let i = 0, len = reactiveObservers.length; i < len; i += 1) {
|
786 | const ro = reactiveObservers[i];
|
787 | ro.notify();
|
788 | }
|
789 | }
|
790 | }
|
791 | }
|
792 | function valueObserved(target, key) {
|
793 |
|
794 | if (currentReactiveObserver === null) {
|
795 | return;
|
796 | }
|
797 |
|
798 | const ro = currentReactiveObserver;
|
799 | const reactiveRecord = getReactiveRecord(target);
|
800 | let reactiveObservers = reactiveRecord[key];
|
801 |
|
802 | if (isUndefined$1$1(reactiveObservers)) {
|
803 | reactiveObservers = [];
|
804 | reactiveRecord[key] = reactiveObservers;
|
805 | } else if (reactiveObservers[0] === ro) {
|
806 | return;
|
807 | }
|
808 |
|
809 | if (ArrayIndexOf$1$1.call(reactiveObservers, ro) === -1) {
|
810 | ro.link(reactiveObservers);
|
811 | }
|
812 | }
|
813 | class ReactiveObserver {
|
814 | constructor(callback) {
|
815 | this.listeners = [];
|
816 | this.callback = callback;
|
817 | }
|
818 |
|
819 | observe(job) {
|
820 | const inceptionReactiveRecord = currentReactiveObserver;
|
821 | currentReactiveObserver = this;
|
822 | let error;
|
823 |
|
824 | try {
|
825 | job();
|
826 | } catch (e) {
|
827 | error = Object(e);
|
828 | } finally {
|
829 | currentReactiveObserver = inceptionReactiveRecord;
|
830 |
|
831 | if (error !== undefined) {
|
832 | throw error;
|
833 | }
|
834 | }
|
835 | }
|
836 | |
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 | reset() {
|
844 | const {
|
845 | listeners
|
846 | } = this;
|
847 | const len = listeners.length;
|
848 |
|
849 | if (len > 0) {
|
850 | for (let i = 0; i < len; i += 1) {
|
851 | const set = listeners[i];
|
852 | const pos = ArrayIndexOf$1$1.call(listeners[i], this);
|
853 | ArraySplice$1$1.call(set, pos, 1);
|
854 | }
|
855 |
|
856 | listeners.length = 0;
|
857 | }
|
858 | } // friend methods
|
859 |
|
860 |
|
861 | notify() {
|
862 | this.callback.call(undefined, this);
|
863 | }
|
864 |
|
865 | link(reactiveObservers) {
|
866 | ArrayPush$1$1.call(reactiveObservers, this);
|
867 |
|
868 | ArrayPush$1$1.call(this.listeners, reactiveObservers);
|
869 | }
|
870 |
|
871 | }
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 | function componentValueMutated(vm, key) {
|
880 | valueMutated(vm.component, key);
|
881 | }
|
882 | function componentValueObserved(vm, key) {
|
883 | valueObserved(vm.component, key);
|
884 | }
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 | function getComponentTag(vm) {
|
893 | return `<${StringToLowerCase$1.call(vm.tagName)}>`;
|
894 | }
|
895 |
|
896 | function getComponentStack(vm) {
|
897 | const stack = [];
|
898 | let prefix = '';
|
899 |
|
900 | while (!isNull$1(vm.owner)) {
|
901 | ArrayPush$1.call(stack, prefix + getComponentTag(vm));
|
902 | vm = vm.owner;
|
903 | prefix += '\t';
|
904 | }
|
905 |
|
906 | return ArrayJoin$1.call(stack, '\n');
|
907 | }
|
908 | function getErrorComponentStack(vm) {
|
909 | const wcStack = [];
|
910 | let currentVm = vm;
|
911 |
|
912 | while (!isNull$1(currentVm)) {
|
913 | ArrayPush$1.call(wcStack, getComponentTag(currentVm));
|
914 | currentVm = currentVm.owner;
|
915 | }
|
916 |
|
917 | return wcStack.reverse().join('\n\t');
|
918 | }
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 | function logError(message, vm) {
|
927 | let msg = `[LWC error]: ${message}`;
|
928 |
|
929 | if (!isUndefined$1(vm)) {
|
930 | msg = `${msg}\n${getComponentStack(vm)}`;
|
931 | }
|
932 |
|
933 | if (process.env.NODE_ENV === 'test') {
|
934 |
|
935 | console.error(msg);
|
936 | return;
|
937 | }
|
938 |
|
939 | try {
|
940 | throw new Error(msg);
|
941 | } catch (e) {
|
942 |
|
943 | console.error(e);
|
944 | }
|
945 | }
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 | function handleEvent(event, vnode) {
|
955 | const {
|
956 | type
|
957 | } = event;
|
958 | const {
|
959 | data: {
|
960 | on
|
961 | }
|
962 | } = vnode;
|
963 | const handler = on && on[type];
|
964 |
|
965 | if (handler) {
|
966 | handler.call(undefined, event);
|
967 | }
|
968 | }
|
969 |
|
970 | function createListener() {
|
971 | return function handler(event) {
|
972 | handleEvent(event, handler.vnode);
|
973 | };
|
974 | }
|
975 |
|
976 | function updateAllEventListeners(oldVnode, vnode) {
|
977 | if (isUndefined$1(oldVnode.listener)) {
|
978 | createAllEventListeners(vnode);
|
979 | } else {
|
980 | vnode.listener = oldVnode.listener;
|
981 | vnode.listener.vnode = vnode;
|
982 | }
|
983 | }
|
984 |
|
985 | function createAllEventListeners(vnode) {
|
986 | const {
|
987 | elm,
|
988 | data: {
|
989 | on
|
990 | },
|
991 | owner: {
|
992 | renderer
|
993 | }
|
994 | } = vnode;
|
995 |
|
996 | if (isUndefined$1(on)) {
|
997 | return;
|
998 | }
|
999 |
|
1000 | const listener = vnode.listener = createListener();
|
1001 | listener.vnode = vnode;
|
1002 | let name;
|
1003 |
|
1004 | for (name in on) {
|
1005 | renderer.addEventListener(elm, name, listener);
|
1006 | }
|
1007 | }
|
1008 |
|
1009 | var modEvents = {
|
1010 | update: updateAllEventListeners,
|
1011 | create: createAllEventListeners
|
1012 | };
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 | const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 | const HTMLPropertyNamesWithLowercasedReflectiveAttributes = ['accessKey', 'readOnly', 'tabIndex', 'bgColor', 'colSpan', 'rowSpan', 'contentEditable', 'dateTime', 'formAction', 'isMap', 'maxLength', 'useMap'];
|
1027 |
|
1028 | function offsetPropertyErrorMessage(name) {
|
1029 | return `Using the \`${name}\` property is an anti-pattern because it rounds the value to an integer. Instead, use the \`getBoundingClientRect\` method to obtain fractional values for the size of an element and its position relative to the viewport.`;
|
1030 | }
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 | const globalHTMLProperties = assign$1(create$1(null), {
|
1036 | accessKey: {
|
1037 | attribute: 'accesskey'
|
1038 | },
|
1039 | accessKeyLabel: {
|
1040 | readOnly: true
|
1041 | },
|
1042 | className: {
|
1043 | attribute: 'class',
|
1044 | error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.'
|
1045 | },
|
1046 | contentEditable: {
|
1047 | attribute: 'contenteditable'
|
1048 | },
|
1049 | dataset: {
|
1050 | readOnly: true,
|
1051 | error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead."
|
1052 | },
|
1053 | dir: {
|
1054 | attribute: 'dir'
|
1055 | },
|
1056 | draggable: {
|
1057 | attribute: 'draggable'
|
1058 | },
|
1059 | dropzone: {
|
1060 | attribute: 'dropzone',
|
1061 | readOnly: true
|
1062 | },
|
1063 | hidden: {
|
1064 | attribute: 'hidden'
|
1065 | },
|
1066 | id: {
|
1067 | attribute: 'id'
|
1068 | },
|
1069 | inputMode: {
|
1070 | attribute: 'inputmode'
|
1071 | },
|
1072 | lang: {
|
1073 | attribute: 'lang'
|
1074 | },
|
1075 | slot: {
|
1076 | attribute: 'slot',
|
1077 | error: 'Using the `slot` property is an anti-pattern.'
|
1078 | },
|
1079 | spellcheck: {
|
1080 | attribute: 'spellcheck'
|
1081 | },
|
1082 | style: {
|
1083 | attribute: 'style'
|
1084 | },
|
1085 | tabIndex: {
|
1086 | attribute: 'tabindex'
|
1087 | },
|
1088 | title: {
|
1089 | attribute: 'title'
|
1090 | },
|
1091 | translate: {
|
1092 | attribute: 'translate'
|
1093 | },
|
1094 |
|
1095 | isContentEditable: {
|
1096 | readOnly: true
|
1097 | },
|
1098 | offsetHeight: {
|
1099 | readOnly: true,
|
1100 | error: offsetPropertyErrorMessage('offsetHeight')
|
1101 | },
|
1102 | offsetLeft: {
|
1103 | readOnly: true,
|
1104 | error: offsetPropertyErrorMessage('offsetLeft')
|
1105 | },
|
1106 | offsetParent: {
|
1107 | readOnly: true
|
1108 | },
|
1109 | offsetTop: {
|
1110 | readOnly: true,
|
1111 | error: offsetPropertyErrorMessage('offsetTop')
|
1112 | },
|
1113 | offsetWidth: {
|
1114 | readOnly: true,
|
1115 | error: offsetPropertyErrorMessage('offsetWidth')
|
1116 | },
|
1117 | role: {
|
1118 | attribute: 'role'
|
1119 | }
|
1120 | });
|
1121 | const AttrNameToPropNameMap$1$1 = assign$1(create$1(null), AttrNameToPropNameMap$1);
|
1122 | const PropNameToAttrNameMap$1$1 = assign$1(create$1(null), PropNameToAttrNameMap$1);
|
1123 | forEach$1.call(defaultDefHTMLPropertyNames, propName => {
|
1124 | const attrName = StringToLowerCase$1.call(propName);
|
1125 | AttrNameToPropNameMap$1$1[attrName] = propName;
|
1126 | PropNameToAttrNameMap$1$1[propName] = attrName;
|
1127 | });
|
1128 | forEach$1.call(HTMLPropertyNamesWithLowercasedReflectiveAttributes, propName => {
|
1129 | const attrName = StringToLowerCase$1.call(propName);
|
1130 | AttrNameToPropNameMap$1$1[attrName] = propName;
|
1131 | PropNameToAttrNameMap$1$1[propName] = attrName;
|
1132 | });
|
1133 | const CAPS_REGEX = /[A-Z]/g;
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 | function getAttrNameFromPropName(propName) {
|
1140 | if (isUndefined$1(PropNameToAttrNameMap$1$1[propName])) {
|
1141 | PropNameToAttrNameMap$1$1[propName] = StringReplace$1.call(propName, CAPS_REGEX, match => '-' + match.toLowerCase());
|
1142 | }
|
1143 |
|
1144 | return PropNameToAttrNameMap$1$1[propName];
|
1145 | }
|
1146 | let controlledElement = null;
|
1147 | let controlledAttributeName;
|
1148 | function isAttributeLocked(elm, attrName) {
|
1149 | return elm !== controlledElement || attrName !== controlledAttributeName;
|
1150 | }
|
1151 | function lockAttribute(_elm, _key) {
|
1152 | controlledElement = null;
|
1153 | controlledAttributeName = undefined;
|
1154 | }
|
1155 | function unlockAttribute(elm, key) {
|
1156 | controlledElement = elm;
|
1157 | controlledAttributeName = key;
|
1158 | }
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 | const xlinkNS = 'http://www.w3.org/1999/xlink';
|
1167 | const xmlNS = 'http://www.w3.org/XML/1998/namespace';
|
1168 | const ColonCharCode = 58;
|
1169 |
|
1170 | function updateAttrs(oldVnode, vnode) {
|
1171 | const {
|
1172 | data: {
|
1173 | attrs
|
1174 | },
|
1175 | owner: {
|
1176 | renderer
|
1177 | }
|
1178 | } = vnode;
|
1179 |
|
1180 | if (isUndefined$1(attrs)) {
|
1181 | return;
|
1182 | }
|
1183 |
|
1184 | let {
|
1185 | data: {
|
1186 | attrs: oldAttrs
|
1187 | }
|
1188 | } = oldVnode;
|
1189 |
|
1190 | if (oldAttrs === attrs) {
|
1191 | return;
|
1192 | }
|
1193 |
|
1194 | if (process.env.NODE_ENV !== 'production') {
|
1195 | assert$1.invariant(isUndefined$1(oldAttrs) || keys$1(oldAttrs).join(',') === keys$1(attrs).join(','), `vnode.data.attrs cannot change shape.`);
|
1196 | }
|
1197 |
|
1198 | const elm = vnode.elm;
|
1199 | const {
|
1200 | setAttribute,
|
1201 | removeAttribute
|
1202 | } = renderer;
|
1203 | let key;
|
1204 | oldAttrs = isUndefined$1(oldAttrs) ? EmptyObject : oldAttrs;
|
1205 |
|
1206 |
|
1207 |
|
1208 | for (key in attrs) {
|
1209 | const cur = attrs[key];
|
1210 | const old = oldAttrs[key];
|
1211 |
|
1212 | if (old !== cur) {
|
1213 | unlockAttribute(elm, key);
|
1214 |
|
1215 | if (StringCharCodeAt$1.call(key, 3) === ColonCharCode) {
|
1216 |
|
1217 | setAttribute(elm, key, cur, xmlNS);
|
1218 | } else if (StringCharCodeAt$1.call(key, 5) === ColonCharCode) {
|
1219 |
|
1220 | setAttribute(elm, key, cur, xlinkNS);
|
1221 | } else if (isNull$1(cur)) {
|
1222 | removeAttribute(elm, key);
|
1223 | } else {
|
1224 | setAttribute(elm, key, cur);
|
1225 | }
|
1226 |
|
1227 | lockAttribute();
|
1228 | }
|
1229 | }
|
1230 | }
|
1231 |
|
1232 | const emptyVNode = {
|
1233 | data: {}
|
1234 | };
|
1235 | var modAttrs = {
|
1236 | create: vnode => updateAttrs(emptyVNode, vnode),
|
1237 | update: updateAttrs
|
1238 | };
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 | function isLiveBindingProp(sel, key) {
|
1248 |
|
1249 |
|
1250 | return sel === 'input' && (key === 'value' || key === 'checked');
|
1251 | }
|
1252 |
|
1253 | function update(oldVnode, vnode) {
|
1254 | const props = vnode.data.props;
|
1255 |
|
1256 | if (isUndefined$1(props)) {
|
1257 | return;
|
1258 | }
|
1259 |
|
1260 | const oldProps = oldVnode.data.props;
|
1261 |
|
1262 | if (oldProps === props) {
|
1263 | return;
|
1264 | }
|
1265 |
|
1266 | if (process.env.NODE_ENV !== 'production') {
|
1267 | assert$1.invariant(isUndefined$1(oldProps) || keys$1(oldProps).join(',') === keys$1(props).join(','), 'vnode.data.props cannot change shape.');
|
1268 | }
|
1269 |
|
1270 | const isFirstPatch = isUndefined$1(oldProps);
|
1271 | const {
|
1272 | elm,
|
1273 | sel,
|
1274 | owner: {
|
1275 | renderer
|
1276 | }
|
1277 | } = vnode;
|
1278 |
|
1279 | for (const key in props) {
|
1280 | const cur = props[key];
|
1281 |
|
1282 | if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? renderer.getProperty(elm, key) : oldProps[key])) {
|
1283 | renderer.setProperty(elm, key, cur);
|
1284 | }
|
1285 | }
|
1286 | }
|
1287 |
|
1288 | const emptyVNode$1 = {
|
1289 | data: {}
|
1290 | };
|
1291 | var modProps = {
|
1292 | create: vnode => update(emptyVNode$1, vnode),
|
1293 | update
|
1294 | };
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 | const classNameToClassMap = create$1(null);
|
1303 |
|
1304 | function getMapFromClassName(className) {
|
1305 |
|
1306 | if (className == null) {
|
1307 | return EmptyObject;
|
1308 | }
|
1309 |
|
1310 |
|
1311 | className = isString(className) ? className : className + '';
|
1312 | let map = classNameToClassMap[className];
|
1313 |
|
1314 | if (map) {
|
1315 | return map;
|
1316 | }
|
1317 |
|
1318 | map = create$1(null);
|
1319 | let start = 0;
|
1320 | let o;
|
1321 | const len = className.length;
|
1322 |
|
1323 | for (o = 0; o < len; o++) {
|
1324 | if (StringCharCodeAt$1.call(className, o) === SPACE_CHAR) {
|
1325 | if (o > start) {
|
1326 | map[StringSlice$1.call(className, start, o)] = true;
|
1327 | }
|
1328 |
|
1329 | start = o + 1;
|
1330 | }
|
1331 | }
|
1332 |
|
1333 | if (o > start) {
|
1334 | map[StringSlice$1.call(className, start, o)] = true;
|
1335 | }
|
1336 |
|
1337 | classNameToClassMap[className] = map;
|
1338 |
|
1339 | if (process.env.NODE_ENV !== 'production') {
|
1340 |
|
1341 | freeze$1(map);
|
1342 | }
|
1343 |
|
1344 | return map;
|
1345 | }
|
1346 |
|
1347 | function updateClassAttribute(oldVnode, vnode) {
|
1348 | const {
|
1349 | elm,
|
1350 | data: {
|
1351 | className: newClass
|
1352 | },
|
1353 | owner: {
|
1354 | renderer
|
1355 | }
|
1356 | } = vnode;
|
1357 | const {
|
1358 | data: {
|
1359 | className: oldClass
|
1360 | }
|
1361 | } = oldVnode;
|
1362 |
|
1363 | if (oldClass === newClass) {
|
1364 | return;
|
1365 | }
|
1366 |
|
1367 | const classList = renderer.getClassList(elm);
|
1368 | const newClassMap = getMapFromClassName(newClass);
|
1369 | const oldClassMap = getMapFromClassName(oldClass);
|
1370 | let name;
|
1371 |
|
1372 | for (name in oldClassMap) {
|
1373 |
|
1374 | if (isUndefined$1(newClassMap[name])) {
|
1375 | classList.remove(name);
|
1376 | }
|
1377 | }
|
1378 |
|
1379 | for (name in newClassMap) {
|
1380 | if (isUndefined$1(oldClassMap[name])) {
|
1381 | classList.add(name);
|
1382 | }
|
1383 | }
|
1384 | }
|
1385 |
|
1386 | const emptyVNode$2 = {
|
1387 | data: {}
|
1388 | };
|
1389 | var modComputedClassName = {
|
1390 | create: vnode => updateClassAttribute(emptyVNode$2, vnode),
|
1391 | update: updateClassAttribute
|
1392 | };
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 | function updateStyleAttribute(oldVnode, vnode) {
|
1402 | const {
|
1403 | elm,
|
1404 | data: {
|
1405 | style: newStyle
|
1406 | },
|
1407 | owner: {
|
1408 | renderer
|
1409 | }
|
1410 | } = vnode;
|
1411 | const {
|
1412 | getStyleDeclaration,
|
1413 | removeAttribute
|
1414 | } = renderer;
|
1415 |
|
1416 | if (oldVnode.data.style === newStyle) {
|
1417 | return;
|
1418 | }
|
1419 |
|
1420 | const style = getStyleDeclaration(elm);
|
1421 |
|
1422 | if (!isString(newStyle) || newStyle === '') {
|
1423 | removeAttribute(elm, 'style');
|
1424 | } else {
|
1425 | style.cssText = newStyle;
|
1426 | }
|
1427 | }
|
1428 |
|
1429 | const emptyVNode$3 = {
|
1430 | data: {}
|
1431 | };
|
1432 | var modComputedStyle = {
|
1433 | create: vnode => updateStyleAttribute(emptyVNode$3, vnode),
|
1434 | update: updateStyleAttribute
|
1435 | };
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 | function createClassAttribute(vnode) {
|
1447 | const {
|
1448 | elm,
|
1449 | data: {
|
1450 | classMap
|
1451 | },
|
1452 | owner: {
|
1453 | renderer
|
1454 | }
|
1455 | } = vnode;
|
1456 |
|
1457 | if (isUndefined$1(classMap)) {
|
1458 | return;
|
1459 | }
|
1460 |
|
1461 | const classList = renderer.getClassList(elm);
|
1462 |
|
1463 | for (const name in classMap) {
|
1464 | classList.add(name);
|
1465 | }
|
1466 | }
|
1467 |
|
1468 | var modStaticClassName = {
|
1469 | create: createClassAttribute
|
1470 | };
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 | function createStyleAttribute(vnode) {
|
1482 | const {
|
1483 | elm,
|
1484 | data: {
|
1485 | styleMap
|
1486 | },
|
1487 | owner: {
|
1488 | renderer
|
1489 | }
|
1490 | } = vnode;
|
1491 |
|
1492 | if (isUndefined$1(styleMap)) {
|
1493 | return;
|
1494 | }
|
1495 |
|
1496 | const style = renderer.getStyleDeclaration(elm);
|
1497 |
|
1498 | for (const name in styleMap) {
|
1499 | style[name] = styleMap[name];
|
1500 | }
|
1501 | }
|
1502 |
|
1503 | var modStaticStyle = {
|
1504 | create: createStyleAttribute
|
1505 | };
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 | function isUndef(s) {
|
1523 | return s === undefined;
|
1524 | }
|
1525 |
|
1526 | function sameVnode(vnode1, vnode2) {
|
1527 | return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
1528 | }
|
1529 |
|
1530 | function isVNode(vnode) {
|
1531 | return vnode != null;
|
1532 | }
|
1533 |
|
1534 | function createKeyToOldIdx(children, beginIdx, endIdx) {
|
1535 | const map = {};
|
1536 | let j, key, ch;
|
1537 |
|
1538 | for (j = beginIdx; j <= endIdx; ++j) {
|
1539 | ch = children[j];
|
1540 |
|
1541 | if (isVNode(ch)) {
|
1542 | key = ch.key;
|
1543 |
|
1544 | if (key !== undefined) {
|
1545 | map[key] = j;
|
1546 | }
|
1547 | }
|
1548 | }
|
1549 |
|
1550 | return map;
|
1551 | }
|
1552 |
|
1553 | function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
|
1554 | for (; startIdx <= endIdx; ++startIdx) {
|
1555 | const ch = vnodes[startIdx];
|
1556 |
|
1557 | if (isVNode(ch)) {
|
1558 | ch.hook.create(ch);
|
1559 | ch.hook.insert(ch, parentElm, before);
|
1560 | }
|
1561 | }
|
1562 | }
|
1563 |
|
1564 | function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
1565 | for (; startIdx <= endIdx; ++startIdx) {
|
1566 | const ch = vnodes[startIdx];
|
1567 |
|
1568 | if (isVNode(ch)) {
|
1569 | ch.hook.remove(ch, parentElm);
|
1570 | }
|
1571 | }
|
1572 | }
|
1573 |
|
1574 | function updateDynamicChildren(parentElm, oldCh, newCh) {
|
1575 | let oldStartIdx = 0;
|
1576 | let newStartIdx = 0;
|
1577 | let oldEndIdx = oldCh.length - 1;
|
1578 | let oldStartVnode = oldCh[0];
|
1579 | let oldEndVnode = oldCh[oldEndIdx];
|
1580 | let newEndIdx = newCh.length - 1;
|
1581 | let newStartVnode = newCh[0];
|
1582 | let newEndVnode = newCh[newEndIdx];
|
1583 | let oldKeyToIdx;
|
1584 | let idxInOld;
|
1585 | let elmToMove;
|
1586 | let before;
|
1587 |
|
1588 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
1589 | if (!isVNode(oldStartVnode)) {
|
1590 | oldStartVnode = oldCh[++oldStartIdx];
|
1591 | } else if (!isVNode(oldEndVnode)) {
|
1592 | oldEndVnode = oldCh[--oldEndIdx];
|
1593 | } else if (!isVNode(newStartVnode)) {
|
1594 | newStartVnode = newCh[++newStartIdx];
|
1595 | } else if (!isVNode(newEndVnode)) {
|
1596 | newEndVnode = newCh[--newEndIdx];
|
1597 | } else if (sameVnode(oldStartVnode, newStartVnode)) {
|
1598 | patchVnode(oldStartVnode, newStartVnode);
|
1599 | oldStartVnode = oldCh[++oldStartIdx];
|
1600 | newStartVnode = newCh[++newStartIdx];
|
1601 | } else if (sameVnode(oldEndVnode, newEndVnode)) {
|
1602 | patchVnode(oldEndVnode, newEndVnode);
|
1603 | oldEndVnode = oldCh[--oldEndIdx];
|
1604 | newEndVnode = newCh[--newEndIdx];
|
1605 | } else if (sameVnode(oldStartVnode, newEndVnode)) {
|
1606 |
|
1607 | patchVnode(oldStartVnode, newEndVnode);
|
1608 | newEndVnode.hook.move(oldStartVnode, parentElm, oldEndVnode.owner.renderer.nextSibling(oldEndVnode.elm));
|
1609 | oldStartVnode = oldCh[++oldStartIdx];
|
1610 | newEndVnode = newCh[--newEndIdx];
|
1611 | } else if (sameVnode(oldEndVnode, newStartVnode)) {
|
1612 |
|
1613 | patchVnode(oldEndVnode, newStartVnode);
|
1614 | newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
|
1615 | oldEndVnode = oldCh[--oldEndIdx];
|
1616 | newStartVnode = newCh[++newStartIdx];
|
1617 | } else {
|
1618 | if (oldKeyToIdx === undefined) {
|
1619 | oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
1620 | }
|
1621 |
|
1622 | idxInOld = oldKeyToIdx[newStartVnode.key];
|
1623 |
|
1624 | if (isUndef(idxInOld)) {
|
1625 |
|
1626 | newStartVnode.hook.create(newStartVnode);
|
1627 | newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
1628 | newStartVnode = newCh[++newStartIdx];
|
1629 | } else {
|
1630 | elmToMove = oldCh[idxInOld];
|
1631 |
|
1632 | if (isVNode(elmToMove)) {
|
1633 | if (elmToMove.sel !== newStartVnode.sel) {
|
1634 |
|
1635 | newStartVnode.hook.create(newStartVnode);
|
1636 | newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
1637 | } else {
|
1638 | patchVnode(elmToMove, newStartVnode);
|
1639 | oldCh[idxInOld] = undefined;
|
1640 | newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
|
1641 | }
|
1642 | }
|
1643 |
|
1644 | newStartVnode = newCh[++newStartIdx];
|
1645 | }
|
1646 | }
|
1647 | }
|
1648 |
|
1649 | if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
1650 | if (oldStartIdx > oldEndIdx) {
|
1651 | const n = newCh[newEndIdx + 1];
|
1652 | before = isVNode(n) ? n.elm : null;
|
1653 | addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
|
1654 | } else {
|
1655 | removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
|
1656 | }
|
1657 | }
|
1658 | }
|
1659 | function updateStaticChildren(parentElm, oldCh, newCh) {
|
1660 | const {
|
1661 | length
|
1662 | } = newCh;
|
1663 |
|
1664 | if (oldCh.length === 0) {
|
1665 |
|
1666 | addVnodes(parentElm, null, newCh, 0, length);
|
1667 | return;
|
1668 | }
|
1669 |
|
1670 |
|
1671 |
|
1672 | let referenceElm = null;
|
1673 |
|
1674 | for (let i = length - 1; i >= 0; i -= 1) {
|
1675 | const vnode = newCh[i];
|
1676 | const oldVNode = oldCh[i];
|
1677 |
|
1678 | if (vnode !== oldVNode) {
|
1679 | if (isVNode(oldVNode)) {
|
1680 | if (isVNode(vnode)) {
|
1681 |
|
1682 | patchVnode(oldVNode, vnode);
|
1683 | referenceElm = vnode.elm;
|
1684 | } else {
|
1685 |
|
1686 | oldVNode.hook.remove(oldVNode, parentElm);
|
1687 | }
|
1688 | } else if (isVNode(vnode)) {
|
1689 |
|
1690 | vnode.hook.create(vnode);
|
1691 |
|
1692 | vnode.hook.insert(vnode, parentElm, referenceElm);
|
1693 | referenceElm = vnode.elm;
|
1694 | }
|
1695 | }
|
1696 | }
|
1697 | }
|
1698 |
|
1699 | function patchVnode(oldVnode, vnode) {
|
1700 | if (oldVnode !== vnode) {
|
1701 | vnode.elm = oldVnode.elm;
|
1702 | vnode.hook.update(oldVnode, vnode);
|
1703 | }
|
1704 | }
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 | function generateDataDescriptor(options) {
|
1714 | return assign$1({
|
1715 | configurable: true,
|
1716 | enumerable: true,
|
1717 | writable: true
|
1718 | }, options);
|
1719 | }
|
1720 |
|
1721 | function generateAccessorDescriptor(options) {
|
1722 | return assign$1({
|
1723 | configurable: true,
|
1724 | enumerable: true
|
1725 | }, options);
|
1726 | }
|
1727 |
|
1728 | let isDomMutationAllowed = false;
|
1729 | function unlockDomMutation() {
|
1730 | if (process.env.NODE_ENV === 'production') {
|
1731 |
|
1732 | throw new ReferenceError();
|
1733 | }
|
1734 |
|
1735 | isDomMutationAllowed = true;
|
1736 | }
|
1737 | function lockDomMutation() {
|
1738 | if (process.env.NODE_ENV === 'production') {
|
1739 |
|
1740 | throw new ReferenceError();
|
1741 | }
|
1742 |
|
1743 | isDomMutationAllowed = false;
|
1744 | }
|
1745 |
|
1746 | function logMissingPortalError(name, type) {
|
1747 | return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
|
1748 | }
|
1749 |
|
1750 | function patchElementWithRestrictions(elm, options) {
|
1751 | if (process.env.NODE_ENV === 'production') {
|
1752 |
|
1753 | throw new ReferenceError();
|
1754 | }
|
1755 |
|
1756 | const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
1757 | const descriptors = {
|
1758 | outerHTML: generateAccessorDescriptor({
|
1759 | get() {
|
1760 | return originalOuterHTMLDescriptor.get.call(this);
|
1761 | },
|
1762 |
|
1763 | set(_value) {
|
1764 | throw new TypeError(`Invalid attempt to set outerHTML on Element.`);
|
1765 | }
|
1766 |
|
1767 | })
|
1768 | };
|
1769 |
|
1770 | if (isFalse$1$1(options.isPortal)) {
|
1771 | const {
|
1772 | appendChild,
|
1773 | insertBefore,
|
1774 | removeChild,
|
1775 | replaceChild
|
1776 | } = elm;
|
1777 | const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
|
1778 | const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
1779 | const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
1780 | assign$1(descriptors, {
|
1781 | appendChild: generateDataDescriptor({
|
1782 | value(aChild) {
|
1783 | logMissingPortalError('appendChild', 'method');
|
1784 | return appendChild.call(this, aChild);
|
1785 | }
|
1786 |
|
1787 | }),
|
1788 | insertBefore: generateDataDescriptor({
|
1789 | value(newNode, referenceNode) {
|
1790 | if (!isDomMutationAllowed) {
|
1791 | logMissingPortalError('insertBefore', 'method');
|
1792 | }
|
1793 |
|
1794 | return insertBefore.call(this, newNode, referenceNode);
|
1795 | }
|
1796 |
|
1797 | }),
|
1798 | removeChild: generateDataDescriptor({
|
1799 | value(aChild) {
|
1800 | if (!isDomMutationAllowed) {
|
1801 | logMissingPortalError('removeChild', 'method');
|
1802 | }
|
1803 |
|
1804 | return removeChild.call(this, aChild);
|
1805 | }
|
1806 |
|
1807 | }),
|
1808 | replaceChild: generateDataDescriptor({
|
1809 | value(newChild, oldChild) {
|
1810 | logMissingPortalError('replaceChild', 'method');
|
1811 | return replaceChild.call(this, newChild, oldChild);
|
1812 | }
|
1813 |
|
1814 | }),
|
1815 | nodeValue: generateAccessorDescriptor({
|
1816 | get() {
|
1817 | return originalNodeValueDescriptor.get.call(this);
|
1818 | },
|
1819 |
|
1820 | set(value) {
|
1821 | if (!isDomMutationAllowed) {
|
1822 | logMissingPortalError('nodeValue', 'property');
|
1823 | }
|
1824 |
|
1825 | originalNodeValueDescriptor.set.call(this, value);
|
1826 | }
|
1827 |
|
1828 | }),
|
1829 | textContent: generateAccessorDescriptor({
|
1830 | get() {
|
1831 | return originalTextContentDescriptor.get.call(this);
|
1832 | },
|
1833 |
|
1834 | set(value) {
|
1835 | logMissingPortalError('textContent', 'property');
|
1836 | originalTextContentDescriptor.set.call(this, value);
|
1837 | }
|
1838 |
|
1839 | }),
|
1840 | innerHTML: generateAccessorDescriptor({
|
1841 | get() {
|
1842 | return originalInnerHTMLDescriptor.get.call(this);
|
1843 | },
|
1844 |
|
1845 | set(value) {
|
1846 | logMissingPortalError('innerHTML', 'property');
|
1847 | return originalInnerHTMLDescriptor.set.call(this, value);
|
1848 | }
|
1849 |
|
1850 | })
|
1851 | });
|
1852 | }
|
1853 |
|
1854 | defineProperties$1(elm, descriptors);
|
1855 | }
|
1856 | const BLOCKED_SHADOW_ROOT_METHODS = ['cloneNode', 'getElementById', 'getSelection', 'elementsFromPoint', 'dispatchEvent'];
|
1857 |
|
1858 | function getShadowRootRestrictionsDescriptors(sr) {
|
1859 | if (process.env.NODE_ENV === 'production') {
|
1860 |
|
1861 | throw new ReferenceError();
|
1862 | }
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 | const originalAddEventListener = sr.addEventListener;
|
1868 | const originalInnerHTMLDescriptor = getPropertyDescriptor(sr, 'innerHTML');
|
1869 | const originalTextContentDescriptor = getPropertyDescriptor(sr, 'textContent');
|
1870 | const descriptors = {
|
1871 | innerHTML: generateAccessorDescriptor({
|
1872 | get() {
|
1873 | return originalInnerHTMLDescriptor.get.call(this);
|
1874 | },
|
1875 |
|
1876 | set(_value) {
|
1877 | throw new TypeError(`Invalid attempt to set innerHTML on ShadowRoot.`);
|
1878 | }
|
1879 |
|
1880 | }),
|
1881 | textContent: generateAccessorDescriptor({
|
1882 | get() {
|
1883 | return originalTextContentDescriptor.get.call(this);
|
1884 | },
|
1885 |
|
1886 | set(_value) {
|
1887 | throw new TypeError(`Invalid attempt to set textContent on ShadowRoot.`);
|
1888 | }
|
1889 |
|
1890 | }),
|
1891 | addEventListener: generateDataDescriptor({
|
1892 | value(type, listener, options) {
|
1893 |
|
1894 |
|
1895 | if (!isUndefined$1(options)) {
|
1896 | logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
1897 | }
|
1898 |
|
1899 |
|
1900 |
|
1901 | return originalAddEventListener.apply(this, arguments);
|
1902 | }
|
1903 |
|
1904 | })
|
1905 | };
|
1906 | forEach$1.call(BLOCKED_SHADOW_ROOT_METHODS, methodName => {
|
1907 | descriptors[methodName] = generateAccessorDescriptor({
|
1908 | get() {
|
1909 | throw new Error(`Disallowed method "${methodName}" in ShadowRoot.`);
|
1910 | }
|
1911 |
|
1912 | });
|
1913 | });
|
1914 | return descriptors;
|
1915 | }
|
1916 |
|
1917 |
|
1918 |
|
1919 | function getCustomElementRestrictionsDescriptors(elm) {
|
1920 | if (process.env.NODE_ENV === 'production') {
|
1921 |
|
1922 | throw new ReferenceError();
|
1923 | }
|
1924 |
|
1925 | const originalAddEventListener = elm.addEventListener;
|
1926 | const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
1927 | const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
|
1928 | const originalTextContentDescriptor = getPropertyDescriptor(elm, 'textContent');
|
1929 | return {
|
1930 | innerHTML: generateAccessorDescriptor({
|
1931 | get() {
|
1932 | return originalInnerHTMLDescriptor.get.call(this);
|
1933 | },
|
1934 |
|
1935 | set(_value) {
|
1936 | throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
|
1937 | }
|
1938 |
|
1939 | }),
|
1940 | outerHTML: generateAccessorDescriptor({
|
1941 | get() {
|
1942 | return originalOuterHTMLDescriptor.get.call(this);
|
1943 | },
|
1944 |
|
1945 | set(_value) {
|
1946 | throw new TypeError(`Invalid attempt to set outerHTML on HTMLElement.`);
|
1947 | }
|
1948 |
|
1949 | }),
|
1950 | textContent: generateAccessorDescriptor({
|
1951 | get() {
|
1952 | return originalTextContentDescriptor.get.call(this);
|
1953 | },
|
1954 |
|
1955 | set(_value) {
|
1956 | throw new TypeError(`Invalid attempt to set textContent on HTMLElement.`);
|
1957 | }
|
1958 |
|
1959 | }),
|
1960 | addEventListener: generateDataDescriptor({
|
1961 | value(type, listener, options) {
|
1962 |
|
1963 |
|
1964 | if (!isUndefined$1(options)) {
|
1965 | logError('The `addEventListener` method in `LightningElement` does not support any options.', getAssociatedVMIfPresent(this));
|
1966 | }
|
1967 |
|
1968 |
|
1969 |
|
1970 | return originalAddEventListener.apply(this, arguments);
|
1971 | }
|
1972 |
|
1973 | })
|
1974 | };
|
1975 | }
|
1976 |
|
1977 | function getComponentRestrictionsDescriptors() {
|
1978 | if (process.env.NODE_ENV === 'production') {
|
1979 |
|
1980 | throw new ReferenceError();
|
1981 | }
|
1982 |
|
1983 | return {
|
1984 | tagName: generateAccessorDescriptor({
|
1985 | get() {
|
1986 | throw new Error(`Usage of property \`tagName\` is disallowed because the component itself does` + ` not know which tagName will be used to create the element, therefore writing` + ` code that check for that value is error prone.`);
|
1987 | },
|
1988 |
|
1989 | configurable: true,
|
1990 | enumerable: false
|
1991 | })
|
1992 | };
|
1993 | }
|
1994 |
|
1995 | function getLightningElementPrototypeRestrictionsDescriptors(proto) {
|
1996 | if (process.env.NODE_ENV === 'production') {
|
1997 |
|
1998 | throw new ReferenceError();
|
1999 | }
|
2000 |
|
2001 | const originalDispatchEvent = proto.dispatchEvent;
|
2002 | const descriptors = {
|
2003 | dispatchEvent: generateDataDescriptor({
|
2004 | value(event) {
|
2005 | const vm = getAssociatedVM(this);
|
2006 |
|
2007 | if (!isNull$1(event) && isObject$2(event)) {
|
2008 | const {
|
2009 | type
|
2010 | } = event;
|
2011 |
|
2012 | if (!/^[a-z][a-z0-9_]*$/.test(type)) {
|
2013 | logError(`Invalid event type "${type}" dispatched in element ${getComponentTag(vm)}.` + ` Event name must start with a lowercase letter and followed only lowercase` + ` letters, numbers, and underscores`, vm);
|
2014 | }
|
2015 | }
|
2016 |
|
2017 |
|
2018 |
|
2019 | return originalDispatchEvent.apply(this, arguments);
|
2020 | }
|
2021 |
|
2022 | })
|
2023 | };
|
2024 | forEach$1.call(getOwnPropertyNames$1(globalHTMLProperties), propName => {
|
2025 | if (propName in proto) {
|
2026 | return;
|
2027 | }
|
2028 |
|
2029 | descriptors[propName] = generateAccessorDescriptor({
|
2030 | get() {
|
2031 | const {
|
2032 | error,
|
2033 | attribute
|
2034 | } = globalHTMLProperties[propName];
|
2035 | const msg = [];
|
2036 | msg.push(`Accessing the global HTML property "${propName}" is disabled.`);
|
2037 |
|
2038 | if (error) {
|
2039 | msg.push(error);
|
2040 | } else if (attribute) {
|
2041 | msg.push(`Instead access it via \`this.getAttribute("${attribute}")\`.`);
|
2042 | }
|
2043 |
|
2044 | logError(msg.join('\n'), getAssociatedVM(this));
|
2045 | },
|
2046 |
|
2047 | set() {
|
2048 | const {
|
2049 | readOnly
|
2050 | } = globalHTMLProperties[propName];
|
2051 |
|
2052 | if (readOnly) {
|
2053 | logError(`The global HTML property \`${propName}\` is read-only.`, getAssociatedVM(this));
|
2054 | }
|
2055 | }
|
2056 |
|
2057 | });
|
2058 | });
|
2059 | return descriptors;
|
2060 | }
|
2061 |
|
2062 |
|
2063 |
|
2064 | function patchShadowRootWithRestrictions(sr) {
|
2065 | defineProperties$1(sr, getShadowRootRestrictionsDescriptors(sr));
|
2066 | }
|
2067 | function patchCustomElementWithRestrictions(elm) {
|
2068 | const restrictionsDescriptors = getCustomElementRestrictionsDescriptors(elm);
|
2069 | const elmProto = getPrototypeOf$1(elm);
|
2070 | setPrototypeOf$1(elm, create$1(elmProto, restrictionsDescriptors));
|
2071 | }
|
2072 | function patchComponentWithRestrictions(cmp) {
|
2073 | defineProperties$1(cmp, getComponentRestrictionsDescriptors());
|
2074 | }
|
2075 | function patchLightningElementPrototypeWithRestrictions(proto) {
|
2076 | defineProperties$1(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
|
2077 | }
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 |
|
2087 | const HTMLElementConstructor = typeof HTMLElement !== 'undefined' ? HTMLElement : function () {};
|
2088 | const HTMLElementPrototype = HTMLElementConstructor.prototype;
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 | const HTMLElementOriginalDescriptors = create$1(null);
|
2104 | forEach$1.call(keys$1(PropNameToAttrNameMap$1), propName => {
|
2105 |
|
2106 |
|
2107 | const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
2108 |
|
2109 | if (!isUndefined$1(descriptor)) {
|
2110 | HTMLElementOriginalDescriptors[propName] = descriptor;
|
2111 | }
|
2112 | });
|
2113 | forEach$1.call(defaultDefHTMLPropertyNames, propName => {
|
2114 |
|
2115 |
|
2116 |
|
2117 | const descriptor = getPropertyDescriptor(HTMLElementPrototype, propName);
|
2118 |
|
2119 | if (!isUndefined$1(descriptor)) {
|
2120 | HTMLElementOriginalDescriptors[propName] = descriptor;
|
2121 | }
|
2122 | });
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 | const {
|
2128 | isArray: isArray$1$1
|
2129 | } = Array;
|
2130 | const {
|
2131 | getPrototypeOf: getPrototypeOf$1$1,
|
2132 | create: ObjectCreate,
|
2133 | defineProperty: ObjectDefineProperty,
|
2134 | defineProperties: ObjectDefineProperties,
|
2135 | isExtensible,
|
2136 | getOwnPropertyDescriptor: getOwnPropertyDescriptor$1$1,
|
2137 | getOwnPropertyNames: getOwnPropertyNames$1$1,
|
2138 | getOwnPropertySymbols,
|
2139 | preventExtensions,
|
2140 | hasOwnProperty: hasOwnProperty$1$1
|
2141 | } = Object;
|
2142 | const {
|
2143 | push: ArrayPush$2,
|
2144 | concat: ArrayConcat,
|
2145 | map: ArrayMap$1$1
|
2146 | } = Array.prototype;
|
2147 | const OtS$1$1 = {}.toString;
|
2148 |
|
2149 | function toString$1$1(obj) {
|
2150 | if (obj && obj.toString) {
|
2151 | return obj.toString();
|
2152 | } else if (typeof obj === 'object') {
|
2153 | return OtS$1$1.call(obj);
|
2154 | } else {
|
2155 | return obj + '';
|
2156 | }
|
2157 | }
|
2158 |
|
2159 | function isUndefined$2(obj) {
|
2160 | return obj === undefined;
|
2161 | }
|
2162 |
|
2163 | function isFunction$1$1(obj) {
|
2164 | return typeof obj === 'function';
|
2165 | }
|
2166 |
|
2167 | const proxyToValueMap = new WeakMap();
|
2168 |
|
2169 | function registerProxy(proxy, value) {
|
2170 | proxyToValueMap.set(proxy, value);
|
2171 | }
|
2172 |
|
2173 | const unwrap = replicaOrAny => proxyToValueMap.get(replicaOrAny) || replicaOrAny;
|
2174 |
|
2175 | class BaseProxyHandler {
|
2176 | constructor(membrane, value) {
|
2177 | this.originalTarget = value;
|
2178 | this.membrane = membrane;
|
2179 | }
|
2180 |
|
2181 |
|
2182 | wrapDescriptor(descriptor) {
|
2183 | if (hasOwnProperty$1$1.call(descriptor, 'value')) {
|
2184 | descriptor.value = this.wrapValue(descriptor.value);
|
2185 | } else {
|
2186 | const {
|
2187 | set: originalSet,
|
2188 | get: originalGet
|
2189 | } = descriptor;
|
2190 |
|
2191 | if (!isUndefined$2(originalGet)) {
|
2192 | descriptor.get = this.wrapGetter(originalGet);
|
2193 | }
|
2194 |
|
2195 | if (!isUndefined$2(originalSet)) {
|
2196 | descriptor.set = this.wrapSetter(originalSet);
|
2197 | }
|
2198 | }
|
2199 |
|
2200 | return descriptor;
|
2201 | }
|
2202 |
|
2203 | copyDescriptorIntoShadowTarget(shadowTarget, key) {
|
2204 | const {
|
2205 | originalTarget
|
2206 | } = this;
|
2207 |
|
2208 |
|
2209 |
|
2210 | const originalDescriptor = getOwnPropertyDescriptor$1$1(originalTarget, key);
|
2211 |
|
2212 | if (!isUndefined$2(originalDescriptor)) {
|
2213 | const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
2214 | ObjectDefineProperty(shadowTarget, key, wrappedDesc);
|
2215 | }
|
2216 | }
|
2217 |
|
2218 | lockShadowTarget(shadowTarget) {
|
2219 | const {
|
2220 | originalTarget
|
2221 | } = this;
|
2222 | const targetKeys = ArrayConcat.call(getOwnPropertyNames$1$1(originalTarget), getOwnPropertySymbols(originalTarget));
|
2223 | targetKeys.forEach(key => {
|
2224 | this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
2225 | });
|
2226 | const {
|
2227 | membrane: {
|
2228 | tagPropertyKey
|
2229 | }
|
2230 | } = this;
|
2231 |
|
2232 | if (!isUndefined$2(tagPropertyKey) && !hasOwnProperty$1$1.call(shadowTarget, tagPropertyKey)) {
|
2233 | ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
|
2234 | }
|
2235 |
|
2236 | preventExtensions(shadowTarget);
|
2237 | }
|
2238 |
|
2239 |
|
2240 | apply(shadowTarget, thisArg, argArray) {
|
2241 |
|
2242 | }
|
2243 |
|
2244 | construct(shadowTarget, argArray, newTarget) {
|
2245 |
|
2246 | }
|
2247 |
|
2248 | get(shadowTarget, key) {
|
2249 | const {
|
2250 | originalTarget,
|
2251 | membrane: {
|
2252 | valueObserved
|
2253 | }
|
2254 | } = this;
|
2255 | const value = originalTarget[key];
|
2256 | valueObserved(originalTarget, key);
|
2257 | return this.wrapValue(value);
|
2258 | }
|
2259 |
|
2260 | has(shadowTarget, key) {
|
2261 | const {
|
2262 | originalTarget,
|
2263 | membrane: {
|
2264 | tagPropertyKey,
|
2265 | valueObserved
|
2266 | }
|
2267 | } = this;
|
2268 | valueObserved(originalTarget, key);
|
2269 |
|
2270 |
|
2271 | return key in originalTarget || key === tagPropertyKey;
|
2272 | }
|
2273 |
|
2274 | ownKeys(shadowTarget) {
|
2275 | const {
|
2276 | originalTarget,
|
2277 | membrane: {
|
2278 | tagPropertyKey
|
2279 | }
|
2280 | } = this;
|
2281 |
|
2282 | const keys = isUndefined$2(tagPropertyKey) || hasOwnProperty$1$1.call(originalTarget, tagPropertyKey) ? [] : [tagPropertyKey];
|
2283 |
|
2284 | ArrayPush$2.apply(keys, getOwnPropertyNames$1$1(originalTarget));
|
2285 | ArrayPush$2.apply(keys, getOwnPropertySymbols(originalTarget));
|
2286 | return keys;
|
2287 | }
|
2288 |
|
2289 | isExtensible(shadowTarget) {
|
2290 | const {
|
2291 | originalTarget
|
2292 | } = this;
|
2293 |
|
2294 | if (!isExtensible(shadowTarget)) {
|
2295 | return false;
|
2296 | }
|
2297 |
|
2298 | if (!isExtensible(originalTarget)) {
|
2299 | this.lockShadowTarget(shadowTarget);
|
2300 | return false;
|
2301 | }
|
2302 |
|
2303 | return true;
|
2304 | }
|
2305 |
|
2306 | getPrototypeOf(shadowTarget) {
|
2307 | const {
|
2308 | originalTarget
|
2309 | } = this;
|
2310 | return getPrototypeOf$1$1(originalTarget);
|
2311 | }
|
2312 |
|
2313 | getOwnPropertyDescriptor(shadowTarget, key) {
|
2314 | const {
|
2315 | originalTarget,
|
2316 | membrane: {
|
2317 | valueObserved,
|
2318 | tagPropertyKey
|
2319 | }
|
2320 | } = this;
|
2321 |
|
2322 | valueObserved(originalTarget, key);
|
2323 | let desc = getOwnPropertyDescriptor$1$1(originalTarget, key);
|
2324 |
|
2325 | if (isUndefined$2(desc)) {
|
2326 | if (key !== tagPropertyKey) {
|
2327 | return undefined;
|
2328 | }
|
2329 |
|
2330 |
|
2331 |
|
2332 | desc = {
|
2333 | value: undefined,
|
2334 | writable: false,
|
2335 | configurable: false,
|
2336 | enumerable: false
|
2337 | };
|
2338 | ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
|
2339 | return desc;
|
2340 | }
|
2341 |
|
2342 | if (desc.configurable === false) {
|
2343 |
|
2344 | this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
2345 | }
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 | return this.wrapDescriptor(desc);
|
2351 | }
|
2352 |
|
2353 | }
|
2354 |
|
2355 | const getterMap = new WeakMap();
|
2356 | const setterMap = new WeakMap();
|
2357 | const reverseGetterMap = new WeakMap();
|
2358 | const reverseSetterMap = new WeakMap();
|
2359 |
|
2360 | class ReactiveProxyHandler extends BaseProxyHandler {
|
2361 | wrapValue(value) {
|
2362 | return this.membrane.getProxy(value);
|
2363 | }
|
2364 |
|
2365 | wrapGetter(originalGet) {
|
2366 | const wrappedGetter = getterMap.get(originalGet);
|
2367 |
|
2368 | if (!isUndefined$2(wrappedGetter)) {
|
2369 | return wrappedGetter;
|
2370 | }
|
2371 |
|
2372 | const handler = this;
|
2373 |
|
2374 | const get = function () {
|
2375 |
|
2376 | return handler.wrapValue(originalGet.call(unwrap(this)));
|
2377 | };
|
2378 |
|
2379 | getterMap.set(originalGet, get);
|
2380 | reverseGetterMap.set(get, originalGet);
|
2381 | return get;
|
2382 | }
|
2383 |
|
2384 | wrapSetter(originalSet) {
|
2385 | const wrappedSetter = setterMap.get(originalSet);
|
2386 |
|
2387 | if (!isUndefined$2(wrappedSetter)) {
|
2388 | return wrappedSetter;
|
2389 | }
|
2390 |
|
2391 | const set = function (v) {
|
2392 |
|
2393 | originalSet.call(unwrap(this), unwrap(v));
|
2394 | };
|
2395 |
|
2396 | setterMap.set(originalSet, set);
|
2397 | reverseSetterMap.set(set, originalSet);
|
2398 | return set;
|
2399 | }
|
2400 |
|
2401 | unwrapDescriptor(descriptor) {
|
2402 | if (hasOwnProperty$1$1.call(descriptor, 'value')) {
|
2403 |
|
2404 | descriptor.value = unwrap(descriptor.value);
|
2405 | } else {
|
2406 | const {
|
2407 | set,
|
2408 | get
|
2409 | } = descriptor;
|
2410 |
|
2411 | if (!isUndefined$2(get)) {
|
2412 | descriptor.get = this.unwrapGetter(get);
|
2413 | }
|
2414 |
|
2415 | if (!isUndefined$2(set)) {
|
2416 | descriptor.set = this.unwrapSetter(set);
|
2417 | }
|
2418 | }
|
2419 |
|
2420 | return descriptor;
|
2421 | }
|
2422 |
|
2423 | unwrapGetter(redGet) {
|
2424 | const reverseGetter = reverseGetterMap.get(redGet);
|
2425 |
|
2426 | if (!isUndefined$2(reverseGetter)) {
|
2427 | return reverseGetter;
|
2428 | }
|
2429 |
|
2430 | const handler = this;
|
2431 |
|
2432 | const get = function () {
|
2433 |
|
2434 | return unwrap(redGet.call(handler.wrapValue(this)));
|
2435 | };
|
2436 |
|
2437 | getterMap.set(get, redGet);
|
2438 | reverseGetterMap.set(redGet, get);
|
2439 | return get;
|
2440 | }
|
2441 |
|
2442 | unwrapSetter(redSet) {
|
2443 | const reverseSetter = reverseSetterMap.get(redSet);
|
2444 |
|
2445 | if (!isUndefined$2(reverseSetter)) {
|
2446 | return reverseSetter;
|
2447 | }
|
2448 |
|
2449 | const handler = this;
|
2450 |
|
2451 | const set = function (v) {
|
2452 |
|
2453 | redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
2454 | };
|
2455 |
|
2456 | setterMap.set(set, redSet);
|
2457 | reverseSetterMap.set(redSet, set);
|
2458 | return set;
|
2459 | }
|
2460 |
|
2461 | set(shadowTarget, key, value) {
|
2462 | const {
|
2463 | originalTarget,
|
2464 | membrane: {
|
2465 | valueMutated
|
2466 | }
|
2467 | } = this;
|
2468 | const oldValue = originalTarget[key];
|
2469 |
|
2470 | if (oldValue !== value) {
|
2471 | originalTarget[key] = value;
|
2472 | valueMutated(originalTarget, key);
|
2473 | } else if (key === 'length' && isArray$1$1(originalTarget)) {
|
2474 |
|
2475 |
|
2476 |
|
2477 |
|
2478 | valueMutated(originalTarget, key);
|
2479 | }
|
2480 |
|
2481 | return true;
|
2482 | }
|
2483 |
|
2484 | deleteProperty(shadowTarget, key) {
|
2485 | const {
|
2486 | originalTarget,
|
2487 | membrane: {
|
2488 | valueMutated
|
2489 | }
|
2490 | } = this;
|
2491 | delete originalTarget[key];
|
2492 | valueMutated(originalTarget, key);
|
2493 | return true;
|
2494 | }
|
2495 |
|
2496 | setPrototypeOf(shadowTarget, prototype) {
|
2497 | if (process.env.NODE_ENV !== 'production') {
|
2498 | throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString$1$1(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
2499 | }
|
2500 | }
|
2501 |
|
2502 | preventExtensions(shadowTarget) {
|
2503 | if (isExtensible(shadowTarget)) {
|
2504 | const {
|
2505 | originalTarget
|
2506 | } = this;
|
2507 | preventExtensions(originalTarget);
|
2508 |
|
2509 |
|
2510 |
|
2511 | if (isExtensible(originalTarget)) {
|
2512 | return false;
|
2513 | }
|
2514 |
|
2515 | this.lockShadowTarget(shadowTarget);
|
2516 | }
|
2517 |
|
2518 | return true;
|
2519 | }
|
2520 |
|
2521 | defineProperty(shadowTarget, key, descriptor) {
|
2522 | const {
|
2523 | originalTarget,
|
2524 | membrane: {
|
2525 | valueMutated,
|
2526 | tagPropertyKey
|
2527 | }
|
2528 | } = this;
|
2529 |
|
2530 | if (key === tagPropertyKey && !hasOwnProperty$1$1.call(originalTarget, key)) {
|
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 | return true;
|
2537 | }
|
2538 |
|
2539 | ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor));
|
2540 |
|
2541 | if (descriptor.configurable === false) {
|
2542 | this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
2543 | }
|
2544 |
|
2545 | valueMutated(originalTarget, key);
|
2546 | return true;
|
2547 | }
|
2548 |
|
2549 | }
|
2550 |
|
2551 | const getterMap$1 = new WeakMap();
|
2552 | const setterMap$1 = new WeakMap();
|
2553 |
|
2554 | class ReadOnlyHandler extends BaseProxyHandler {
|
2555 | wrapValue(value) {
|
2556 | return this.membrane.getReadOnlyProxy(value);
|
2557 | }
|
2558 |
|
2559 | wrapGetter(originalGet) {
|
2560 | const wrappedGetter = getterMap$1.get(originalGet);
|
2561 |
|
2562 | if (!isUndefined$2(wrappedGetter)) {
|
2563 | return wrappedGetter;
|
2564 | }
|
2565 |
|
2566 | const handler = this;
|
2567 |
|
2568 | const get = function () {
|
2569 |
|
2570 | return handler.wrapValue(originalGet.call(unwrap(this)));
|
2571 | };
|
2572 |
|
2573 | getterMap$1.set(originalGet, get);
|
2574 | return get;
|
2575 | }
|
2576 |
|
2577 | wrapSetter(originalSet) {
|
2578 | const wrappedSetter = setterMap$1.get(originalSet);
|
2579 |
|
2580 | if (!isUndefined$2(wrappedSetter)) {
|
2581 | return wrappedSetter;
|
2582 | }
|
2583 |
|
2584 | const handler = this;
|
2585 |
|
2586 | const set = function (v) {
|
2587 | if (process.env.NODE_ENV !== 'production') {
|
2588 | const {
|
2589 | originalTarget
|
2590 | } = handler;
|
2591 | throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
2592 | }
|
2593 | };
|
2594 |
|
2595 | setterMap$1.set(originalSet, set);
|
2596 | return set;
|
2597 | }
|
2598 |
|
2599 | set(shadowTarget, key, value) {
|
2600 | if (process.env.NODE_ENV !== 'production') {
|
2601 | const {
|
2602 | originalTarget
|
2603 | } = this;
|
2604 | throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
2605 | }
|
2606 |
|
2607 | return false;
|
2608 | }
|
2609 |
|
2610 | deleteProperty(shadowTarget, key) {
|
2611 | if (process.env.NODE_ENV !== 'production') {
|
2612 | const {
|
2613 | originalTarget
|
2614 | } = this;
|
2615 | throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
2616 | }
|
2617 |
|
2618 | return false;
|
2619 | }
|
2620 |
|
2621 | setPrototypeOf(shadowTarget, prototype) {
|
2622 | if (process.env.NODE_ENV !== 'production') {
|
2623 | const {
|
2624 | originalTarget
|
2625 | } = this;
|
2626 | throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
2627 | }
|
2628 | }
|
2629 |
|
2630 | preventExtensions(shadowTarget) {
|
2631 | if (process.env.NODE_ENV !== 'production') {
|
2632 | const {
|
2633 | originalTarget
|
2634 | } = this;
|
2635 | throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
2636 | }
|
2637 |
|
2638 | return false;
|
2639 | }
|
2640 |
|
2641 | defineProperty(shadowTarget, key, descriptor) {
|
2642 | if (process.env.NODE_ENV !== 'production') {
|
2643 | const {
|
2644 | originalTarget
|
2645 | } = this;
|
2646 | throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
2647 | }
|
2648 |
|
2649 | return false;
|
2650 | }
|
2651 |
|
2652 | }
|
2653 |
|
2654 | function extract(objectOrArray) {
|
2655 | if (isArray$1$1(objectOrArray)) {
|
2656 | return objectOrArray.map(item => {
|
2657 | const original = unwrap(item);
|
2658 |
|
2659 | if (original !== item) {
|
2660 | return extract(original);
|
2661 | }
|
2662 |
|
2663 | return item;
|
2664 | });
|
2665 | }
|
2666 |
|
2667 | const obj = ObjectCreate(getPrototypeOf$1$1(objectOrArray));
|
2668 | const names = getOwnPropertyNames$1$1(objectOrArray);
|
2669 | return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
2670 | const item = objectOrArray[key];
|
2671 | const original = unwrap(item);
|
2672 |
|
2673 | if (original !== item) {
|
2674 | seed[key] = extract(original);
|
2675 | } else {
|
2676 | seed[key] = item;
|
2677 | }
|
2678 |
|
2679 | return seed;
|
2680 | }, obj);
|
2681 | }
|
2682 |
|
2683 | const formatter = {
|
2684 | header: plainOrProxy => {
|
2685 | const originalTarget = unwrap(plainOrProxy);
|
2686 |
|
2687 | if (!originalTarget || originalTarget === plainOrProxy) {
|
2688 | return null;
|
2689 | }
|
2690 |
|
2691 | const obj = extract(plainOrProxy);
|
2692 | return ['object', {
|
2693 | object: obj
|
2694 | }];
|
2695 | },
|
2696 | hasBody: () => {
|
2697 | return false;
|
2698 | },
|
2699 | body: () => {
|
2700 | return null;
|
2701 | }
|
2702 | };
|
2703 |
|
2704 |
|
2705 | function getGlobal() {
|
2706 |
|
2707 |
|
2708 | if (typeof globalThis !== 'undefined') {
|
2709 | return globalThis;
|
2710 | }
|
2711 |
|
2712 | if (typeof self !== 'undefined') {
|
2713 | return self;
|
2714 | }
|
2715 |
|
2716 | if (typeof window !== 'undefined') {
|
2717 | return window;
|
2718 | }
|
2719 |
|
2720 | if (typeof global !== 'undefined') {
|
2721 | return global;
|
2722 | }
|
2723 |
|
2724 |
|
2725 | return {};
|
2726 | }
|
2727 |
|
2728 | function init() {
|
2729 | if (process.env.NODE_ENV === 'production') {
|
2730 |
|
2731 | throw new ReferenceError();
|
2732 | }
|
2733 |
|
2734 | const global = getGlobal();
|
2735 |
|
2736 |
|
2737 |
|
2738 |
|
2739 | const devtoolsFormatters = global.devtoolsFormatters || [];
|
2740 | ArrayPush$2.call(devtoolsFormatters, formatter);
|
2741 | global.devtoolsFormatters = devtoolsFormatters;
|
2742 | }
|
2743 |
|
2744 | if (process.env.NODE_ENV !== 'production') {
|
2745 | init();
|
2746 | }
|
2747 |
|
2748 | const ObjectDotPrototype = Object.prototype;
|
2749 |
|
2750 | function defaultValueIsObservable(value) {
|
2751 |
|
2752 | if (value === null) {
|
2753 | return false;
|
2754 | }
|
2755 |
|
2756 |
|
2757 | if (typeof value !== 'object') {
|
2758 | return false;
|
2759 | }
|
2760 |
|
2761 | if (isArray$1$1(value)) {
|
2762 | return true;
|
2763 | }
|
2764 |
|
2765 | const proto = getPrototypeOf$1$1(value);
|
2766 | return proto === ObjectDotPrototype || proto === null || getPrototypeOf$1$1(proto) === null;
|
2767 | }
|
2768 |
|
2769 | const defaultValueObserved = (obj, key) => {
|
2770 |
|
2771 | };
|
2772 |
|
2773 | const defaultValueMutated = (obj, key) => {
|
2774 |
|
2775 | };
|
2776 |
|
2777 | const defaultValueDistortion = value => value;
|
2778 |
|
2779 | function createShadowTarget(value) {
|
2780 | return isArray$1$1(value) ? [] : {};
|
2781 | }
|
2782 |
|
2783 | class ReactiveMembrane {
|
2784 | constructor(options) {
|
2785 | this.valueDistortion = defaultValueDistortion;
|
2786 | this.valueMutated = defaultValueMutated;
|
2787 | this.valueObserved = defaultValueObserved;
|
2788 | this.valueIsObservable = defaultValueIsObservable;
|
2789 | this.objectGraph = new WeakMap();
|
2790 |
|
2791 | if (!isUndefined$2(options)) {
|
2792 | const {
|
2793 | valueDistortion,
|
2794 | valueMutated,
|
2795 | valueObserved,
|
2796 | valueIsObservable,
|
2797 | tagPropertyKey
|
2798 | } = options;
|
2799 | this.valueDistortion = isFunction$1$1(valueDistortion) ? valueDistortion : defaultValueDistortion;
|
2800 | this.valueMutated = isFunction$1$1(valueMutated) ? valueMutated : defaultValueMutated;
|
2801 | this.valueObserved = isFunction$1$1(valueObserved) ? valueObserved : defaultValueObserved;
|
2802 | this.valueIsObservable = isFunction$1$1(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
|
2803 | this.tagPropertyKey = tagPropertyKey;
|
2804 | }
|
2805 | }
|
2806 |
|
2807 | getProxy(value) {
|
2808 | const unwrappedValue = unwrap(value);
|
2809 | const distorted = this.valueDistortion(unwrappedValue);
|
2810 |
|
2811 | if (this.valueIsObservable(distorted)) {
|
2812 | const o = this.getReactiveState(unwrappedValue, distorted);
|
2813 |
|
2814 |
|
2815 | return o.readOnly === value ? value : o.reactive;
|
2816 | }
|
2817 |
|
2818 | return distorted;
|
2819 | }
|
2820 |
|
2821 | getReadOnlyProxy(value) {
|
2822 | value = unwrap(value);
|
2823 | const distorted = this.valueDistortion(value);
|
2824 |
|
2825 | if (this.valueIsObservable(distorted)) {
|
2826 | return this.getReactiveState(value, distorted).readOnly;
|
2827 | }
|
2828 |
|
2829 | return distorted;
|
2830 | }
|
2831 |
|
2832 | unwrapProxy(p) {
|
2833 | return unwrap(p);
|
2834 | }
|
2835 |
|
2836 | getReactiveState(value, distortedValue) {
|
2837 | const {
|
2838 | objectGraph
|
2839 | } = this;
|
2840 | let reactiveState = objectGraph.get(distortedValue);
|
2841 |
|
2842 | if (reactiveState) {
|
2843 | return reactiveState;
|
2844 | }
|
2845 |
|
2846 | const membrane = this;
|
2847 | reactiveState = {
|
2848 | get reactive() {
|
2849 | const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue);
|
2850 |
|
2851 | const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
|
2852 | registerProxy(proxy, value);
|
2853 | ObjectDefineProperty(this, 'reactive', {
|
2854 | value: proxy
|
2855 | });
|
2856 | return proxy;
|
2857 | },
|
2858 |
|
2859 | get readOnly() {
|
2860 | const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue);
|
2861 |
|
2862 | const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
|
2863 | registerProxy(proxy, value);
|
2864 | ObjectDefineProperty(this, 'readOnly', {
|
2865 | value: proxy
|
2866 | });
|
2867 | return proxy;
|
2868 | }
|
2869 |
|
2870 | };
|
2871 | objectGraph.set(distortedValue, reactiveState);
|
2872 | return reactiveState;
|
2873 | }
|
2874 |
|
2875 | }
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 |
|
2883 |
|
2884 | const lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
|
2885 |
|
2886 | function valueDistortion(value) {
|
2887 | return value;
|
2888 | }
|
2889 |
|
2890 | const reactiveMembrane = new ReactiveMembrane({
|
2891 | valueObserved,
|
2892 | valueMutated,
|
2893 | valueDistortion,
|
2894 | tagPropertyKey: lockerLivePropertyKey
|
2895 | });
|
2896 |
|
2897 |
|
2898 |
|
2899 |
|
2900 |
|
2901 |
|
2902 | const unwrap$1 = function (value) {
|
2903 | const unwrapped = reactiveMembrane.unwrapProxy(value);
|
2904 |
|
2905 | if (unwrapped !== value) {
|
2906 |
|
2907 | return valueDistortion(unwrapped);
|
2908 | }
|
2909 |
|
2910 | return value;
|
2911 | };
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 | function createBridgeToElementDescriptor(propName, descriptor) {
|
2927 | const {
|
2928 | get,
|
2929 | set,
|
2930 | enumerable,
|
2931 | configurable
|
2932 | } = descriptor;
|
2933 |
|
2934 | if (!isFunction$1(get)) {
|
2935 | if (process.env.NODE_ENV !== 'production') {
|
2936 | assert$1.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
2937 | }
|
2938 |
|
2939 | throw new TypeError();
|
2940 | }
|
2941 |
|
2942 | if (!isFunction$1(set)) {
|
2943 | if (process.env.NODE_ENV !== 'production') {
|
2944 | assert$1.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
2945 | }
|
2946 |
|
2947 | throw new TypeError();
|
2948 | }
|
2949 |
|
2950 | return {
|
2951 | enumerable,
|
2952 | configurable,
|
2953 |
|
2954 | get() {
|
2955 | const vm = getAssociatedVM(this);
|
2956 |
|
2957 | if (isBeingConstructed(vm)) {
|
2958 | if (process.env.NODE_ENV !== 'production') {
|
2959 | logError(`The value of property \`${propName}\` can't be read from the constructor because the owner component hasn't set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
2960 | }
|
2961 |
|
2962 | return;
|
2963 | }
|
2964 |
|
2965 | componentValueObserved(vm, propName);
|
2966 | return get.call(vm.elm);
|
2967 | },
|
2968 |
|
2969 | set(newValue) {
|
2970 | const vm = getAssociatedVM(this);
|
2971 |
|
2972 | if (process.env.NODE_ENV !== 'production') {
|
2973 | const vmBeingRendered = getVMBeingRendered();
|
2974 | assert$1.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
2975 | assert$1.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
|
2976 | assert$1.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
2977 | assert$1.invariant(!isObject$2(newValue) || isNull$1(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
2978 | }
|
2979 |
|
2980 | if (newValue !== vm.cmpProps[propName]) {
|
2981 | vm.cmpProps[propName] = newValue;
|
2982 | componentValueMutated(vm, propName);
|
2983 | }
|
2984 |
|
2985 | return set.call(vm.elm, newValue);
|
2986 | }
|
2987 |
|
2988 | };
|
2989 | }
|
2990 | /**
|
2991 | * This class is the base class for any LWC element.
|
2992 | * Some elements directly extends this class, others implement it via inheritance.
|
2993 | **/
|
2994 |
|
2995 |
|
2996 | function BaseLightningElementConstructor() {
|
2997 | var _a;
|
2998 |
|
2999 |
|
3000 | if (isNull$1(vmBeingConstructed)) {
|
3001 | throw new ReferenceError('Illegal constructor');
|
3002 | }
|
3003 |
|
3004 | const vm = vmBeingConstructed;
|
3005 | const {
|
3006 | elm,
|
3007 | mode,
|
3008 | renderer,
|
3009 | def: {
|
3010 | ctor
|
3011 | }
|
3012 | } = vm;
|
3013 |
|
3014 | if (process.env.NODE_ENV !== 'production') {
|
3015 | (_a = renderer.assertInstanceOfHTMLElement) === null || _a === void 0 ? void 0 : _a.call(renderer, vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
3016 | }
|
3017 |
|
3018 | const component = this;
|
3019 | const cmpRoot = renderer.attachShadow(elm, {
|
3020 | mode,
|
3021 | delegatesFocus: !!ctor.delegatesFocus,
|
3022 | '$$lwc-synthetic-mode$$': true
|
3023 | });
|
3024 | vm.component = this;
|
3025 | vm.cmpRoot = cmpRoot;
|
3026 |
|
3027 |
|
3028 |
|
3029 |
|
3030 | if (arguments.length === 1) {
|
3031 | const {
|
3032 | callHook,
|
3033 | setHook,
|
3034 | getHook
|
3035 | } = arguments[0];
|
3036 | vm.callHook = callHook;
|
3037 | vm.setHook = setHook;
|
3038 | vm.getHook = getHook;
|
3039 | }
|
3040 |
|
3041 |
|
3042 | defineProperty$1(component, lockerLivePropertyKey, EmptyObject);
|
3043 |
|
3044 | associateVM(component, vm);
|
3045 | associateVM(cmpRoot, vm);
|
3046 | associateVM(elm, vm);
|
3047 |
|
3048 | if (process.env.NODE_ENV !== 'production') {
|
3049 | patchCustomElementWithRestrictions(elm);
|
3050 | patchComponentWithRestrictions(component);
|
3051 | patchShadowRootWithRestrictions(cmpRoot);
|
3052 | }
|
3053 |
|
3054 | return this;
|
3055 | }
|
3056 |
|
3057 | BaseLightningElementConstructor.prototype = {
|
3058 | constructor: BaseLightningElementConstructor,
|
3059 |
|
3060 | dispatchEvent(event) {
|
3061 | const {
|
3062 | elm,
|
3063 | renderer: {
|
3064 | dispatchEvent
|
3065 | }
|
3066 | } = getAssociatedVM(this);
|
3067 | return dispatchEvent(elm, event);
|
3068 | },
|
3069 |
|
3070 | addEventListener(type, listener, options) {
|
3071 | const vm = getAssociatedVM(this);
|
3072 | const {
|
3073 | elm,
|
3074 | renderer: {
|
3075 | addEventListener
|
3076 | }
|
3077 | } = vm;
|
3078 |
|
3079 | if (process.env.NODE_ENV !== 'production') {
|
3080 | const vmBeingRendered = getVMBeingRendered();
|
3081 | assert$1.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
3082 | assert$1.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
3083 | assert$1.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
3084 | }
|
3085 |
|
3086 | const wrappedListener = getWrappedComponentsListener(vm, listener);
|
3087 | addEventListener(elm, type, wrappedListener, options);
|
3088 | },
|
3089 |
|
3090 | removeEventListener(type, listener, options) {
|
3091 | const vm = getAssociatedVM(this);
|
3092 | const {
|
3093 | elm,
|
3094 | renderer: {
|
3095 | removeEventListener
|
3096 | }
|
3097 | } = vm;
|
3098 | const wrappedListener = getWrappedComponentsListener(vm, listener);
|
3099 | removeEventListener(elm, type, wrappedListener, options);
|
3100 | },
|
3101 |
|
3102 | hasAttribute(name) {
|
3103 | const {
|
3104 | elm,
|
3105 | renderer: {
|
3106 | getAttribute
|
3107 | }
|
3108 | } = getAssociatedVM(this);
|
3109 | return !isNull$1(getAttribute(elm, name));
|
3110 | },
|
3111 |
|
3112 | hasAttributeNS(namespace, name) {
|
3113 | const {
|
3114 | elm,
|
3115 | renderer: {
|
3116 | getAttribute
|
3117 | }
|
3118 | } = getAssociatedVM(this);
|
3119 | return !isNull$1(getAttribute(elm, name, namespace));
|
3120 | },
|
3121 |
|
3122 | removeAttribute(name) {
|
3123 | const {
|
3124 | elm,
|
3125 | renderer: {
|
3126 | removeAttribute
|
3127 | }
|
3128 | } = getAssociatedVM(this);
|
3129 | unlockAttribute(elm, name);
|
3130 | removeAttribute(elm, name);
|
3131 | lockAttribute();
|
3132 | },
|
3133 |
|
3134 | removeAttributeNS(namespace, name) {
|
3135 | const {
|
3136 | elm,
|
3137 | renderer: {
|
3138 | removeAttribute
|
3139 | }
|
3140 | } = getAssociatedVM(this);
|
3141 | unlockAttribute(elm, name);
|
3142 | removeAttribute(elm, name, namespace);
|
3143 | lockAttribute();
|
3144 | },
|
3145 |
|
3146 | getAttribute(name) {
|
3147 | const {
|
3148 | elm,
|
3149 | renderer: {
|
3150 | getAttribute
|
3151 | }
|
3152 | } = getAssociatedVM(this);
|
3153 | return getAttribute(elm, name);
|
3154 | },
|
3155 |
|
3156 | getAttributeNS(namespace, name) {
|
3157 | const {
|
3158 | elm,
|
3159 | renderer: {
|
3160 | getAttribute
|
3161 | }
|
3162 | } = getAssociatedVM(this);
|
3163 | return getAttribute(elm, name, namespace);
|
3164 | },
|
3165 |
|
3166 | setAttribute(name, value) {
|
3167 | const vm = getAssociatedVM(this);
|
3168 | const {
|
3169 | elm,
|
3170 | renderer: {
|
3171 | setAttribute
|
3172 | }
|
3173 | } = vm;
|
3174 |
|
3175 | if (process.env.NODE_ENV !== 'production') {
|
3176 | assert$1.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
3177 | }
|
3178 |
|
3179 | unlockAttribute(elm, name);
|
3180 | setAttribute(elm, name, value);
|
3181 | lockAttribute();
|
3182 | },
|
3183 |
|
3184 | setAttributeNS(namespace, name, value) {
|
3185 | const vm = getAssociatedVM(this);
|
3186 | const {
|
3187 | elm,
|
3188 | renderer: {
|
3189 | setAttribute
|
3190 | }
|
3191 | } = vm;
|
3192 |
|
3193 | if (process.env.NODE_ENV !== 'production') {
|
3194 | assert$1.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
3195 | }
|
3196 |
|
3197 | unlockAttribute(elm, name);
|
3198 | setAttribute(elm, name, value, namespace);
|
3199 | lockAttribute();
|
3200 | },
|
3201 |
|
3202 | getBoundingClientRect() {
|
3203 | const vm = getAssociatedVM(this);
|
3204 | const {
|
3205 | elm,
|
3206 | renderer: {
|
3207 | getBoundingClientRect
|
3208 | }
|
3209 | } = vm;
|
3210 |
|
3211 | if (process.env.NODE_ENV !== 'production') {
|
3212 | assert$1.isFalse(isBeingConstructed(vm), `this.getBoundingClientRect() should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM, instead, you can use it in one of the available life-cycle hooks.`);
|
3213 | }
|
3214 |
|
3215 | return getBoundingClientRect(elm);
|
3216 | },
|
3217 |
|
3218 | querySelector(selectors) {
|
3219 | const vm = getAssociatedVM(this);
|
3220 | const {
|
3221 | elm,
|
3222 | renderer: {
|
3223 | querySelector
|
3224 | }
|
3225 | } = vm;
|
3226 |
|
3227 | if (process.env.NODE_ENV !== 'production') {
|
3228 | assert$1.isFalse(isBeingConstructed(vm), `this.querySelector() cannot be called during the construction of the custom element for ${getComponentTag(vm)} because no children has been added to this element yet.`);
|
3229 | }
|
3230 |
|
3231 | return querySelector(elm, selectors);
|
3232 | },
|
3233 |
|
3234 | querySelectorAll(selectors) {
|
3235 | const vm = getAssociatedVM(this);
|
3236 | const {
|
3237 | elm,
|
3238 | renderer: {
|
3239 | querySelectorAll
|
3240 | }
|
3241 | } = vm;
|
3242 |
|
3243 | if (process.env.NODE_ENV !== 'production') {
|
3244 | assert$1.isFalse(isBeingConstructed(vm), `this.querySelectorAll() cannot be called during the construction of the custom element for ${getComponentTag(vm)} because no children has been added to this element yet.`);
|
3245 | }
|
3246 |
|
3247 | return querySelectorAll(elm, selectors);
|
3248 | },
|
3249 |
|
3250 | getElementsByTagName(tagNameOrWildCard) {
|
3251 | const vm = getAssociatedVM(this);
|
3252 | const {
|
3253 | elm,
|
3254 | renderer: {
|
3255 | getElementsByTagName
|
3256 | }
|
3257 | } = vm;
|
3258 |
|
3259 | if (process.env.NODE_ENV !== 'production') {
|
3260 | assert$1.isFalse(isBeingConstructed(vm), `this.getElementsByTagName() cannot be called during the construction of the custom element for ${getComponentTag(vm)} because no children has been added to this element yet.`);
|
3261 | }
|
3262 |
|
3263 | return getElementsByTagName(elm, tagNameOrWildCard);
|
3264 | },
|
3265 |
|
3266 | getElementsByClassName(names) {
|
3267 | const vm = getAssociatedVM(this);
|
3268 | const {
|
3269 | elm,
|
3270 | renderer: {
|
3271 | getElementsByClassName
|
3272 | }
|
3273 | } = vm;
|
3274 |
|
3275 | if (process.env.NODE_ENV !== 'production') {
|
3276 | assert$1.isFalse(isBeingConstructed(vm), `this.getElementsByClassName() cannot be called during the construction of the custom element for ${getComponentTag(vm)} because no children has been added to this element yet.`);
|
3277 | }
|
3278 |
|
3279 | return getElementsByClassName(elm, names);
|
3280 | },
|
3281 |
|
3282 | get isConnected() {
|
3283 | const {
|
3284 | elm,
|
3285 | renderer: {
|
3286 | isConnected
|
3287 | }
|
3288 | } = getAssociatedVM(this);
|
3289 | return isConnected(elm);
|
3290 | },
|
3291 |
|
3292 | get classList() {
|
3293 | const vm = getAssociatedVM(this);
|
3294 | const {
|
3295 | elm,
|
3296 | renderer: {
|
3297 | getClassList
|
3298 | }
|
3299 | } = vm;
|
3300 |
|
3301 | if (process.env.NODE_ENV !== 'production') {
|
3302 |
|
3303 |
|
3304 | assert$1.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
|
3305 | }
|
3306 |
|
3307 | return getClassList(elm);
|
3308 | },
|
3309 |
|
3310 | get template() {
|
3311 | const vm = getAssociatedVM(this);
|
3312 | return vm.cmpRoot;
|
3313 | },
|
3314 |
|
3315 | get shadowRoot() {
|
3316 |
|
3317 |
|
3318 | return null;
|
3319 | },
|
3320 |
|
3321 | render() {
|
3322 | const vm = getAssociatedVM(this);
|
3323 | return vm.def.template;
|
3324 | },
|
3325 |
|
3326 | toString() {
|
3327 | const vm = getAssociatedVM(this);
|
3328 | return `[object ${vm.def.name}]`;
|
3329 | }
|
3330 |
|
3331 | };
|
3332 | const lightningBasedDescriptors = create$1(null);
|
3333 |
|
3334 | for (const propName in HTMLElementOriginalDescriptors) {
|
3335 | lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
3336 | }
|
3337 |
|
3338 | defineProperties$1(BaseLightningElementConstructor.prototype, lightningBasedDescriptors);
|
3339 | defineProperty$1(BaseLightningElementConstructor, 'CustomElementConstructor', {
|
3340 | get() {
|
3341 |
|
3342 | throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
3343 | },
|
3344 |
|
3345 | configurable: true
|
3346 | });
|
3347 |
|
3348 | if (process.env.NODE_ENV !== 'production') {
|
3349 | patchLightningElementPrototypeWithRestrictions(BaseLightningElementConstructor.prototype);
|
3350 | }
|
3351 |
|
3352 |
|
3353 | const BaseLightningElement = BaseLightningElementConstructor;
|
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 |
|
3361 |
|
3362 |
|
3363 |
|
3364 |
|
3365 |
|
3366 |
|
3367 | function wire(_adapter, _config) {
|
3368 | if (process.env.NODE_ENV !== 'production') {
|
3369 | assert$1.fail('@wire(adapter, config?) may only be used as a decorator.');
|
3370 | }
|
3371 |
|
3372 | throw new Error();
|
3373 | }
|
3374 | function internalWireFieldDecorator(key) {
|
3375 | return {
|
3376 | get() {
|
3377 | const vm = getAssociatedVM(this);
|
3378 | componentValueObserved(vm, key);
|
3379 | return vm.cmpFields[key];
|
3380 | },
|
3381 |
|
3382 | set(value) {
|
3383 | const vm = getAssociatedVM(this);
|
3384 | |
3385 |
|
3386 |
|
3387 |
|
3388 |
|
3389 |
|
3390 |
|
3391 | if (value !== vm.cmpFields[key]) {
|
3392 | vm.cmpFields[key] = value;
|
3393 | componentValueMutated(vm, key);
|
3394 | }
|
3395 | },
|
3396 |
|
3397 | enumerable: true,
|
3398 | configurable: true
|
3399 | };
|
3400 | }
|
3401 |
|
3402 |
|
3403 |
|
3404 |
|
3405 |
|
3406 |
|
3407 |
|
3408 | function track(target) {
|
3409 | if (arguments.length === 1) {
|
3410 | return reactiveMembrane.getProxy(target);
|
3411 | }
|
3412 |
|
3413 | if (process.env.NODE_ENV !== 'production') {
|
3414 | assert$1.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
3415 | }
|
3416 |
|
3417 | throw new Error();
|
3418 | }
|
3419 | function internalTrackDecorator(key) {
|
3420 | return {
|
3421 | get() {
|
3422 | const vm = getAssociatedVM(this);
|
3423 | componentValueObserved(vm, key);
|
3424 | return vm.cmpFields[key];
|
3425 | },
|
3426 |
|
3427 | set(newValue) {
|
3428 | const vm = getAssociatedVM(this);
|
3429 |
|
3430 | if (process.env.NODE_ENV !== 'production') {
|
3431 | const vmBeingRendered = getVMBeingRendered();
|
3432 | assert$1.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
3433 | assert$1.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
3434 | }
|
3435 |
|
3436 | const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
|
3437 |
|
3438 | if (reactiveOrAnyValue !== vm.cmpFields[key]) {
|
3439 | vm.cmpFields[key] = reactiveOrAnyValue;
|
3440 | componentValueMutated(vm, key);
|
3441 | }
|
3442 | },
|
3443 |
|
3444 | enumerable: true,
|
3445 | configurable: true
|
3446 | };
|
3447 | }
|
3448 |
|
3449 |
|
3450 |
|
3451 |
|
3452 |
|
3453 |
|
3454 |
|
3455 |
|
3456 |
|
3457 |
|
3458 |
|
3459 |
|
3460 |
|
3461 |
|
3462 |
|
3463 | const {
|
3464 | assign: assign$1$1,
|
3465 | create: create$2,
|
3466 | defineProperties: defineProperties$1$1,
|
3467 | defineProperty: defineProperty$1$1,
|
3468 | freeze: freeze$1$1,
|
3469 | getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
|
3470 | getOwnPropertyNames: getOwnPropertyNames$2,
|
3471 | getPrototypeOf: getPrototypeOf$2,
|
3472 | hasOwnProperty: hasOwnProperty$2,
|
3473 | isFrozen: isFrozen$1$1,
|
3474 | keys: keys$1$1,
|
3475 | seal: seal$1$1,
|
3476 | setPrototypeOf: setPrototypeOf$1$1
|
3477 | } = Object;
|
3478 | const {
|
3479 | filter: ArrayFilter$1$1,
|
3480 | find: ArrayFind$1$1,
|
3481 | indexOf: ArrayIndexOf$2,
|
3482 | join: ArrayJoin$1$1,
|
3483 | map: ArrayMap$2,
|
3484 | push: ArrayPush$3,
|
3485 | reduce: ArrayReduce$1$1,
|
3486 | reverse: ArrayReverse$1$1,
|
3487 | slice: ArraySlice$1$1,
|
3488 | splice: ArraySplice$2,
|
3489 | unshift: ArrayUnshift$1$1,
|
3490 | forEach: forEach$1$1
|
3491 | } = Array.prototype;
|
3492 | const {
|
3493 | charCodeAt: StringCharCodeAt$1$1,
|
3494 | replace: StringReplace$1$1,
|
3495 | slice: StringSlice$1$1,
|
3496 | toLowerCase: StringToLowerCase$1$1
|
3497 | } = String.prototype;
|
3498 |
|
3499 | function isUndefined$3(obj) {
|
3500 | return obj === undefined;
|
3501 | }
|
3502 |
|
3503 | function isTrue$1$1$1(obj) {
|
3504 | return obj === true;
|
3505 | }
|
3506 |
|
3507 | function isFalse$1$1$1(obj) {
|
3508 | return obj === false;
|
3509 | }
|
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 |
|
3515 |
|
3516 |
|
3517 |
|
3518 |
|
3519 |
|
3520 |
|
3521 |
|
3522 |
|
3523 |
|
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 | const AriaPropertyNames$1$1 = ['ariaActiveDescendant', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', 'ariaChecked', 'ariaColCount', 'ariaColIndex', 'ariaColSpan', 'ariaControls', 'ariaCurrent', 'ariaDescribedBy', 'ariaDetails', 'ariaDisabled', 'ariaErrorMessage', 'ariaExpanded', 'ariaFlowTo', 'ariaHasPopup', 'ariaHidden', 'ariaInvalid', 'ariaKeyShortcuts', 'ariaLabel', 'ariaLabelledBy', 'ariaLevel', 'ariaLive', 'ariaModal', 'ariaMultiLine', 'ariaMultiSelectable', 'ariaOrientation', 'ariaOwns', 'ariaPlaceholder', 'ariaPosInSet', 'ariaPressed', 'ariaReadOnly', 'ariaRelevant', 'ariaRequired', 'ariaRoleDescription', 'ariaRowCount', 'ariaRowIndex', 'ariaRowSpan', 'ariaSelected', 'ariaSetSize', 'ariaSort', 'ariaValueMax', 'ariaValueMin', 'ariaValueNow', 'ariaValueText', 'role'];
|
3529 | const AttrNameToPropNameMap$2 = create$2(null);
|
3530 | const PropNameToAttrNameMap$2 = create$2(null);
|
3531 |
|
3532 | forEach$1$1.call(AriaPropertyNames$1$1, propName => {
|
3533 |
|
3534 |
|
3535 |
|
3536 | const attrName = StringToLowerCase$1$1.call(StringReplace$1$1.call(propName, /^aria/, 'aria-'));
|
3537 | AttrNameToPropNameMap$2[attrName] = propName;
|
3538 | PropNameToAttrNameMap$2[propName] = attrName;
|
3539 | });
|
3540 |
|
3541 |
|
3542 |
|
3543 |
|
3544 |
|
3545 |
|
3546 |
|
3547 |
|
3548 | const _globalThis$1$1 = function () {
|
3549 |
|
3550 | if (typeof globalThis === 'object') {
|
3551 | return globalThis;
|
3552 | }
|
3553 |
|
3554 | let _globalThis;
|
3555 |
|
3556 | try {
|
3557 |
|
3558 | Object.defineProperty(Object.prototype, '__magic__', {
|
3559 | get: function () {
|
3560 | return this;
|
3561 | },
|
3562 | configurable: true
|
3563 | });
|
3564 |
|
3565 |
|
3566 |
|
3567 | _globalThis = __magic__;
|
3568 |
|
3569 | delete Object.prototype.__magic__;
|
3570 | } catch (ex) {
|
3571 | } finally {
|
3572 |
|
3573 |
|
3574 | if (typeof _globalThis === 'undefined') {
|
3575 |
|
3576 | _globalThis = window;
|
3577 | }
|
3578 | }
|
3579 |
|
3580 | return _globalThis;
|
3581 | }();
|
3582 |
|
3583 |
|
3584 |
|
3585 |
|
3586 |
|
3587 |
|
3588 |
|
3589 |
|
3590 |
|
3591 |
|
3592 |
|
3593 |
|
3594 |
|
3595 |
|
3596 |
|
3597 | const hasNativeSymbolsSupport$1$1 = Symbol('x').toString() === 'Symbol(x)';
|
3598 | const HTML_ATTRIBUTES_TO_PROPERTY$1$1 = {
|
3599 | accesskey: 'accessKey',
|
3600 | readonly: 'readOnly',
|
3601 | tabindex: 'tabIndex',
|
3602 | bgcolor: 'bgColor',
|
3603 | colspan: 'colSpan',
|
3604 | rowspan: 'rowSpan',
|
3605 | contenteditable: 'contentEditable',
|
3606 | crossorigin: 'crossOrigin',
|
3607 | datetime: 'dateTime',
|
3608 | formaction: 'formAction',
|
3609 | ismap: 'isMap',
|
3610 | maxlength: 'maxLength',
|
3611 | minlength: 'minLength',
|
3612 | novalidate: 'noValidate',
|
3613 | usemap: 'useMap',
|
3614 | for: 'htmlFor'
|
3615 | };
|
3616 | keys$1$1(HTML_ATTRIBUTES_TO_PROPERTY$1$1).forEach(attrName => {});
|
3617 |
|
3618 |
|
3619 |
|
3620 |
|
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 |
|
3626 | if (!_globalThis$1$1.lwcRuntimeFlags) {
|
3627 | Object.defineProperty(_globalThis$1$1, 'lwcRuntimeFlags', {
|
3628 | value: create$2(null)
|
3629 | });
|
3630 | }
|
3631 |
|
3632 | const runtimeFlags = _globalThis$1$1.lwcRuntimeFlags;
|
3633 |
|
3634 |
|
3635 | function setFeatureFlag(name, value) {
|
3636 | const isBoolean = isTrue$1$1$1(value) || isFalse$1$1$1(value);
|
3637 |
|
3638 | if (!isBoolean) {
|
3639 | const message = `Failed to set the value "${value}" for the runtime feature flag "${name}". Runtime feature flags can only be set to a boolean value.`;
|
3640 |
|
3641 | if (process.env.NODE_ENV !== 'production') {
|
3642 | throw new TypeError(message);
|
3643 | } else {
|
3644 |
|
3645 | console.error(message);
|
3646 | return;
|
3647 | }
|
3648 | }
|
3649 |
|
3650 | if (isUndefined$3(featureFlagLookup[name])) {
|
3651 |
|
3652 | console.warn(`Failed to set the value "${value}" for the runtime feature flag "${name}" because it is undefined. Possible reasons are that 1) it was misspelled or 2) it was removed from the @lwc/features package.`);
|
3653 | return;
|
3654 | }
|
3655 |
|
3656 | if (process.env.NODE_ENV !== 'production') {
|
3657 |
|
3658 | runtimeFlags[name] = value;
|
3659 | } else {
|
3660 |
|
3661 | const runtimeValue = runtimeFlags[name];
|
3662 |
|
3663 | if (!isUndefined$3(runtimeValue)) {
|
3664 |
|
3665 | console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
|
3666 | return;
|
3667 | }
|
3668 |
|
3669 | Object.defineProperty(runtimeFlags, name, {
|
3670 | value
|
3671 | });
|
3672 | }
|
3673 | }
|
3674 |
|
3675 |
|
3676 |
|
3677 | function setFeatureFlagForTest(name, value) {
|
3678 | if (process.env.NODE_ENV !== 'production') {
|
3679 | return setFeatureFlag(name, value);
|
3680 | }
|
3681 | }
|
3682 |
|
3683 | const featureFlagLookup = {
|
3684 | ENABLE_REACTIVE_SETTER: null,
|
3685 |
|
3686 | ENABLE_ELEMENT_PATCH: null,
|
3687 | ENABLE_NODE_LIST_PATCH: null,
|
3688 | ENABLE_HTML_COLLECTIONS_PATCH: null,
|
3689 | ENABLE_NODE_PATCH: null
|
3690 | };
|
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 |
|
3696 |
|
3697 |
|
3698 |
|
3699 | function api() {
|
3700 | if (process.env.NODE_ENV !== 'production') {
|
3701 | assert$1.fail(`@api decorator can only be used as a decorator function.`);
|
3702 | }
|
3703 |
|
3704 | throw new Error();
|
3705 | }
|
3706 | function createPublicPropertyDescriptor(key) {
|
3707 | return {
|
3708 | get() {
|
3709 | const vm = getAssociatedVM(this);
|
3710 |
|
3711 | if (isBeingConstructed(vm)) {
|
3712 | if (process.env.NODE_ENV !== 'production') {
|
3713 | logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
3714 | }
|
3715 |
|
3716 | return;
|
3717 | }
|
3718 |
|
3719 | componentValueObserved(vm, key);
|
3720 | return vm.cmpProps[key];
|
3721 | },
|
3722 |
|
3723 | set(newValue) {
|
3724 | const vm = getAssociatedVM(this);
|
3725 |
|
3726 | if (process.env.NODE_ENV !== 'production') {
|
3727 | const vmBeingRendered = getVMBeingRendered();
|
3728 | assert$1.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
3729 | assert$1.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
3730 | }
|
3731 |
|
3732 | vm.cmpProps[key] = newValue;
|
3733 | componentValueMutated(vm, key);
|
3734 | },
|
3735 |
|
3736 | enumerable: true,
|
3737 | configurable: true
|
3738 | };
|
3739 | }
|
3740 | class AccessorReactiveObserver extends ReactiveObserver {
|
3741 | constructor(vm, set) {
|
3742 | super(() => {
|
3743 | if (isFalse$1$1(this.debouncing)) {
|
3744 | this.debouncing = true;
|
3745 | addCallbackToNextTick(() => {
|
3746 | if (isTrue$1$1(this.debouncing)) {
|
3747 | const {
|
3748 | value
|
3749 | } = this;
|
3750 | const {
|
3751 | isDirty: dirtyStateBeforeSetterCall,
|
3752 | component,
|
3753 | idx
|
3754 | } = vm;
|
3755 | set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
3756 | // infinity loop if the setter itself is mutating things that
|
3757 | // were accessed during the previous invocation.
|
3758 |
|
3759 | this.debouncing = false;
|
3760 |
|
3761 | if (isTrue$1$1(vm.isDirty) && isFalse$1$1(dirtyStateBeforeSetterCall) && idx > 0) {
|
3762 |
|
3763 |
|
3764 |
|
3765 | rerenderVM(vm);
|
3766 | }
|
3767 | }
|
3768 | });
|
3769 | }
|
3770 | });
|
3771 | this.debouncing = false;
|
3772 | }
|
3773 |
|
3774 | reset(value) {
|
3775 | super.reset();
|
3776 | this.debouncing = false;
|
3777 |
|
3778 | if (arguments.length > 0) {
|
3779 | this.value = value;
|
3780 | }
|
3781 | }
|
3782 |
|
3783 | }
|
3784 | function createPublicAccessorDescriptor(key, descriptor) {
|
3785 | const {
|
3786 | get,
|
3787 | set,
|
3788 | enumerable,
|
3789 | configurable
|
3790 | } = descriptor;
|
3791 |
|
3792 | if (!isFunction$1(get)) {
|
3793 | if (process.env.NODE_ENV !== 'production') {
|
3794 | assert$1.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
3795 | }
|
3796 |
|
3797 | throw new Error();
|
3798 | }
|
3799 |
|
3800 | return {
|
3801 | get() {
|
3802 | if (process.env.NODE_ENV !== 'production') {
|
3803 | // Assert that the this value is an actual Component with an associated VM.
|
3804 | getAssociatedVM(this);
|
3805 | }
|
3806 |
|
3807 | return get.call(this);
|
3808 | },
|
3809 |
|
3810 | set(newValue) {
|
3811 | const vm = getAssociatedVM(this);
|
3812 |
|
3813 | if (process.env.NODE_ENV !== 'production') {
|
3814 | const vmBeingRendered = getVMBeingRendered();
|
3815 | assert$1.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
3816 | assert$1.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
3817 | }
|
3818 |
|
3819 | if (set) {
|
3820 | if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
|
3821 | let ro = vm.oar[key];
|
3822 |
|
3823 | if (isUndefined$1(ro)) {
|
3824 | ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
|
3825 | } // every time we invoke this setter from outside (through this wrapper setter)
|
3826 | // we should reset the value and then debounce just in case there is a pending
|
3827 | // invocation the next tick that is not longer relevant since the value is changing
|
3828 | // from outside.
|
3829 |
|
3830 |
|
3831 | ro.reset(newValue);
|
3832 | ro.observe(() => {
|
3833 | set.call(this, newValue);
|
3834 | });
|
3835 | } else {
|
3836 | set.call(this, newValue);
|
3837 | }
|
3838 | } else if (process.env.NODE_ENV !== 'production') {
|
3839 | assert$1.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
3840 | }
|
3841 | },
|
3842 |
|
3843 | enumerable,
|
3844 | configurable
|
3845 | };
|
3846 | }
|
3847 |
|
3848 | function createObservedFieldPropertyDescriptor(key) {
|
3849 | return {
|
3850 | get() {
|
3851 | const vm = getAssociatedVM(this);
|
3852 | componentValueObserved(vm, key);
|
3853 | return vm.cmpFields[key];
|
3854 | },
|
3855 |
|
3856 | set(newValue) {
|
3857 | const vm = getAssociatedVM(this);
|
3858 |
|
3859 | if (newValue !== vm.cmpFields[key]) {
|
3860 | vm.cmpFields[key] = newValue;
|
3861 | componentValueMutated(vm, key);
|
3862 | }
|
3863 | },
|
3864 |
|
3865 | enumerable: true,
|
3866 | configurable: true
|
3867 | };
|
3868 | }
|
3869 |
|
3870 | /*
|
3871 | * Copyright (c) 2018, salesforce.com, inc.
|
3872 | * All rights reserved.
|
3873 | * SPDX-License-Identifier: MIT
|
3874 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3875 | */
|
3876 | var PropType;
|
3877 |
|
3878 | (function (PropType) {
|
3879 | PropType[PropType["Field"] = 0] = "Field";
|
3880 | PropType[PropType["Set"] = 1] = "Set";
|
3881 | PropType[PropType["Get"] = 2] = "Get";
|
3882 | PropType[PropType["GetSet"] = 3] = "GetSet";
|
3883 | })(PropType || (PropType = {}));
|
3884 |
|
3885 | function validateObservedField(Ctor, fieldName, descriptor) {
|
3886 | if (process.env.NODE_ENV !== 'production') {
|
3887 | if (!isUndefined$1(descriptor)) {
|
3888 | assert$1.fail(`Compiler Error: Invalid field ${fieldName} declaration.`);
|
3889 | }
|
3890 | }
|
3891 | }
|
3892 |
|
3893 | function validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor) {
|
3894 | if (process.env.NODE_ENV !== 'production') {
|
3895 | if (!isUndefined$1(descriptor)) {
|
3896 | assert$1.fail(`Compiler Error: Invalid @track ${fieldName} declaration.`);
|
3897 | }
|
3898 | }
|
3899 | }
|
3900 |
|
3901 | function validateFieldDecoratedWithWire(Ctor, fieldName, descriptor) {
|
3902 | if (process.env.NODE_ENV !== 'production') {
|
3903 | if (!isUndefined$1(descriptor)) {
|
3904 | assert$1.fail(`Compiler Error: Invalid @wire(...) ${fieldName} field declaration.`);
|
3905 | }
|
3906 | }
|
3907 | }
|
3908 |
|
3909 | function validateMethodDecoratedWithWire(Ctor, methodName, descriptor) {
|
3910 | if (process.env.NODE_ENV !== 'production') {
|
3911 | if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse$1$1(descriptor.writable)) {
|
3912 | assert$1.fail(`Compiler Error: Invalid @wire(...) ${methodName} method declaration.`);
|
3913 | }
|
3914 | }
|
3915 | }
|
3916 |
|
3917 | function validateFieldDecoratedWithApi(Ctor, fieldName, descriptor) {
|
3918 | if (process.env.NODE_ENV !== 'production') {
|
3919 | if (!isUndefined$1(descriptor)) {
|
3920 | assert$1.fail(`Compiler Error: Invalid @api ${fieldName} field declaration.`);
|
3921 | }
|
3922 | }
|
3923 | }
|
3924 |
|
3925 | function validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor) {
|
3926 | if (process.env.NODE_ENV !== 'production') {
|
3927 | if (isUndefined$1(descriptor)) {
|
3928 | assert$1.fail(`Compiler Error: Invalid @api get ${fieldName} accessor declaration.`);
|
3929 | } else if (isFunction$1(descriptor.set)) {
|
3930 | assert$1.isTrue(isFunction$1(descriptor.get), `Compiler Error: Missing getter for property ${toString$1(fieldName)} decorated with @api in ${Ctor}. You cannot have a setter without the corresponding getter.`);
|
3931 | } else if (!isFunction$1(descriptor.get)) {
|
3932 | assert$1.fail(`Compiler Error: Missing @api get ${fieldName} accessor declaration.`);
|
3933 | }
|
3934 | }
|
3935 | }
|
3936 |
|
3937 | function validateMethodDecoratedWithApi(Ctor, methodName, descriptor) {
|
3938 | if (process.env.NODE_ENV !== 'production') {
|
3939 | if (isUndefined$1(descriptor) || !isFunction$1(descriptor.value) || isFalse$1$1(descriptor.writable)) {
|
3940 | assert$1.fail(`Compiler Error: Invalid @api ${methodName} method declaration.`);
|
3941 | }
|
3942 | }
|
3943 | }
|
3944 | /**
|
3945 | * INTERNAL: This function can only be invoked by compiled code. The compiler
|
3946 | * will prevent this function from being imported by user-land code.
|
3947 | */
|
3948 |
|
3949 |
|
3950 | function registerDecorators(Ctor, meta) {
|
3951 | const proto = Ctor.prototype;
|
3952 | const {
|
3953 | publicProps,
|
3954 | publicMethods,
|
3955 | wire,
|
3956 | track,
|
3957 | fields
|
3958 | } = meta;
|
3959 | const apiMethods = create$1(null);
|
3960 | const apiFields = create$1(null);
|
3961 | const wiredMethods = create$1(null);
|
3962 | const wiredFields = create$1(null);
|
3963 | const observedFields = create$1(null);
|
3964 | const apiFieldsConfig = create$1(null);
|
3965 | let descriptor;
|
3966 |
|
3967 | if (!isUndefined$1(publicProps)) {
|
3968 | for (const fieldName in publicProps) {
|
3969 | const propConfig = publicProps[fieldName];
|
3970 | apiFieldsConfig[fieldName] = propConfig.config;
|
3971 | descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
3972 |
|
3973 | if (propConfig.config > 0) {
|
3974 | // accessor declaration
|
3975 | if (process.env.NODE_ENV !== 'production') {
|
3976 | validateAccessorDecoratedWithApi(Ctor, fieldName, descriptor);
|
3977 | }
|
3978 |
|
3979 | if (isUndefined$1(descriptor)) {
|
3980 | throw new Error();
|
3981 | }
|
3982 |
|
3983 | descriptor = createPublicAccessorDescriptor(fieldName, descriptor);
|
3984 | } else {
|
3985 | // field declaration
|
3986 | if (process.env.NODE_ENV !== 'production') {
|
3987 | validateFieldDecoratedWithApi(Ctor, fieldName, descriptor);
|
3988 | }
|
3989 |
|
3990 | descriptor = createPublicPropertyDescriptor(fieldName);
|
3991 | }
|
3992 |
|
3993 | apiFields[fieldName] = descriptor;
|
3994 | defineProperty$1(proto, fieldName, descriptor);
|
3995 | }
|
3996 | }
|
3997 |
|
3998 | if (!isUndefined$1(publicMethods)) {
|
3999 | forEach$1.call(publicMethods, methodName => {
|
4000 | descriptor = getOwnPropertyDescriptor$1(proto, methodName);
|
4001 |
|
4002 | if (process.env.NODE_ENV !== 'production') {
|
4003 | validateMethodDecoratedWithApi(Ctor, methodName, descriptor);
|
4004 | }
|
4005 |
|
4006 | if (isUndefined$1(descriptor)) {
|
4007 | throw new Error();
|
4008 | }
|
4009 |
|
4010 | apiMethods[methodName] = descriptor;
|
4011 | });
|
4012 | }
|
4013 |
|
4014 | if (!isUndefined$1(wire)) {
|
4015 | for (const fieldOrMethodName in wire) {
|
4016 | const {
|
4017 | adapter,
|
4018 | method,
|
4019 | config: configCallback,
|
4020 | dynamic = []
|
4021 | } = wire[fieldOrMethodName];
|
4022 | descriptor = getOwnPropertyDescriptor$1(proto, fieldOrMethodName);
|
4023 |
|
4024 | if (method === 1) {
|
4025 | if (process.env.NODE_ENV !== 'production') {
|
4026 | assert$1.isTrue(adapter, `@wire on method "${fieldOrMethodName}": adapter id must be truthy.`);
|
4027 | validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
4028 | }
|
4029 |
|
4030 | if (isUndefined$1(descriptor)) {
|
4031 | throw new Error();
|
4032 | }
|
4033 |
|
4034 | wiredMethods[fieldOrMethodName] = descriptor;
|
4035 | storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
|
4036 | } else {
|
4037 | if (process.env.NODE_ENV !== 'production') {
|
4038 | assert$1.isTrue(adapter, `@wire on field "${fieldOrMethodName}": adapter id must be truthy.`);
|
4039 | validateFieldDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
|
4040 | }
|
4041 |
|
4042 | descriptor = internalWireFieldDecorator(fieldOrMethodName);
|
4043 | wiredFields[fieldOrMethodName] = descriptor;
|
4044 | storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic);
|
4045 | defineProperty$1(proto, fieldOrMethodName, descriptor);
|
4046 | }
|
4047 | }
|
4048 | }
|
4049 |
|
4050 | if (!isUndefined$1(track)) {
|
4051 | for (const fieldName in track) {
|
4052 | descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
4053 |
|
4054 | if (process.env.NODE_ENV !== 'production') {
|
4055 | validateFieldDecoratedWithTrack(Ctor, fieldName, descriptor);
|
4056 | }
|
4057 |
|
4058 | descriptor = internalTrackDecorator(fieldName);
|
4059 | defineProperty$1(proto, fieldName, descriptor);
|
4060 | }
|
4061 | }
|
4062 |
|
4063 | if (!isUndefined$1(fields)) {
|
4064 | for (let i = 0, n = fields.length; i < n; i++) {
|
4065 | const fieldName = fields[i];
|
4066 | descriptor = getOwnPropertyDescriptor$1(proto, fieldName);
|
4067 |
|
4068 | if (process.env.NODE_ENV !== 'production') {
|
4069 | validateObservedField(Ctor, fieldName, descriptor);
|
4070 | }
|
4071 |
|
4072 | observedFields[fieldName] = createObservedFieldPropertyDescriptor(fieldName);
|
4073 | }
|
4074 | }
|
4075 |
|
4076 | setDecoratorsMeta(Ctor, {
|
4077 | apiMethods,
|
4078 | apiFields,
|
4079 | apiFieldsConfig,
|
4080 | wiredMethods,
|
4081 | wiredFields,
|
4082 | observedFields
|
4083 | });
|
4084 | return Ctor;
|
4085 | }
|
4086 | const signedDecoratorToMetaMap = new Map();
|
4087 |
|
4088 | function setDecoratorsMeta(Ctor, meta) {
|
4089 | signedDecoratorToMetaMap.set(Ctor, meta);
|
4090 | }
|
4091 |
|
4092 | const defaultMeta = {
|
4093 | apiMethods: EmptyObject,
|
4094 | apiFields: EmptyObject,
|
4095 | apiFieldsConfig: EmptyObject,
|
4096 | wiredMethods: EmptyObject,
|
4097 | wiredFields: EmptyObject,
|
4098 | observedFields: EmptyObject
|
4099 | };
|
4100 | function getDecoratorsMeta(Ctor) {
|
4101 | const meta = signedDecoratorToMetaMap.get(Ctor);
|
4102 | return isUndefined$1(meta) ? defaultMeta : meta;
|
4103 | }
|
4104 |
|
4105 | const signedTemplateSet = new Set();
|
4106 | function defaultEmptyTemplate() {
|
4107 | return [];
|
4108 | }
|
4109 | signedTemplateSet.add(defaultEmptyTemplate);
|
4110 | function isTemplateRegistered(tpl) {
|
4111 | return signedTemplateSet.has(tpl);
|
4112 | }
|
4113 | /**
|
4114 | * INTERNAL: This function can only be invoked by compiled code. The compiler
|
4115 | * will prevent this function from being imported by userland code.
|
4116 | */
|
4117 |
|
4118 | function registerTemplate(tpl) {
|
4119 | signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
|
4120 | // assignment of templates easily, without too much transformation
|
4121 |
|
4122 | return tpl;
|
4123 | }
|
4124 | /**
|
4125 | * EXPERIMENTAL: This function acts like a hook for Lightning Locker
|
4126 | * Service and other similar libraries to sanitize vulnerable attributes.
|
4127 | * This API is subject to change or being removed.
|
4128 | */
|
4129 |
|
4130 | function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
4131 | // locker-service patches this function during runtime to sanitize vulnerable attributes.
|
4132 | // when ran off-core this function becomes a noop and returns the user authored value.
|
4133 | return attrValue;
|
4134 | }
|
4135 |
|
4136 | /*
|
4137 | * Copyright (c) 2018, salesforce.com, inc.
|
4138 | * All rights reserved.
|
4139 | * SPDX-License-Identifier: MIT
|
4140 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4141 | */
|
4142 | // from the element instance, and get the value or set a new value on the component.
|
4143 | // This means that across different elements, similar names can get the exact same
|
4144 | // descriptor, so we can cache them:
|
4145 |
|
4146 | const cachedGetterByKey = create$1(null);
|
4147 | const cachedSetterByKey = create$1(null);
|
4148 |
|
4149 | function createGetter(key) {
|
4150 | let fn = cachedGetterByKey[key];
|
4151 |
|
4152 | if (isUndefined$1(fn)) {
|
4153 | fn = cachedGetterByKey[key] = function () {
|
4154 | const vm = getAssociatedVM(this);
|
4155 | const {
|
4156 | getHook
|
4157 | } = vm;
|
4158 | return getHook(vm.component, key);
|
4159 | };
|
4160 | }
|
4161 |
|
4162 | return fn;
|
4163 | }
|
4164 |
|
4165 | function createSetter(key) {
|
4166 | let fn = cachedSetterByKey[key];
|
4167 |
|
4168 | if (isUndefined$1(fn)) {
|
4169 | fn = cachedSetterByKey[key] = function (newValue) {
|
4170 | const vm = getAssociatedVM(this);
|
4171 | const {
|
4172 | setHook
|
4173 | } = vm;
|
4174 | newValue = reactiveMembrane.getReadOnlyProxy(newValue);
|
4175 | setHook(vm.component, key, newValue);
|
4176 | };
|
4177 | }
|
4178 |
|
4179 | return fn;
|
4180 | }
|
4181 |
|
4182 | function createMethodCaller(methodName) {
|
4183 | return function () {
|
4184 | const vm = getAssociatedVM(this);
|
4185 | const {
|
4186 | callHook,
|
4187 | component
|
4188 | } = vm;
|
4189 | const fn = component[methodName];
|
4190 | return callHook(vm.component, fn, ArraySlice$2.call(arguments));
|
4191 | };
|
4192 | }
|
4193 |
|
4194 | function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
4195 | let HTMLBridgeElement;
|
4196 | /**
|
4197 | * Modern browsers will have all Native Constructors as regular Classes
|
4198 | * and must be instantiated with the new keyword. In older browsers,
|
4199 | * specifically IE11, those are objects with a prototype property defined,
|
4200 | * since they are not supposed to be extended or instantiated with the
|
4201 | * new keyword. This forking logic supports both cases, specifically because
|
4202 | * wc.ts relies on the construction path of the bridges to create new
|
4203 | * fully qualifying web components.
|
4204 | */
|
4205 |
|
4206 | if (isFunction$1(SuperClass)) {
|
4207 | HTMLBridgeElement = class extends SuperClass {};
|
4208 | } else {
|
4209 | HTMLBridgeElement = function () {
|
4210 | // Bridge classes are not supposed to be instantiated directly in
|
4211 | // browsers that do not support web components.
|
4212 | throw new TypeError('Illegal constructor');
|
4213 | }; // prototype inheritance dance
|
4214 |
|
4215 |
|
4216 | setPrototypeOf$1(HTMLBridgeElement, SuperClass);
|
4217 | setPrototypeOf$1(HTMLBridgeElement.prototype, SuperClass.prototype);
|
4218 | defineProperty$1(HTMLBridgeElement.prototype, 'constructor', {
|
4219 | writable: true,
|
4220 | configurable: true,
|
4221 | value: HTMLBridgeElement
|
4222 | });
|
4223 | }
|
4224 |
|
4225 | const descriptors = create$1(null); // expose getters and setters for each public props on the new Element Bridge
|
4226 |
|
4227 | for (let i = 0, len = props.length; i < len; i += 1) {
|
4228 | const propName = props[i];
|
4229 | descriptors[propName] = {
|
4230 | get: createGetter(propName),
|
4231 | set: createSetter(propName),
|
4232 | enumerable: true,
|
4233 | configurable: true
|
4234 | };
|
4235 | } // expose public methods as props on the new Element Bridge
|
4236 |
|
4237 |
|
4238 | for (let i = 0, len = methods.length; i < len; i += 1) {
|
4239 | const methodName = methods[i];
|
4240 | descriptors[methodName] = {
|
4241 | value: createMethodCaller(methodName),
|
4242 | writable: true,
|
4243 | configurable: true
|
4244 | };
|
4245 | }
|
4246 |
|
4247 | defineProperties$1(HTMLBridgeElement.prototype, descriptors);
|
4248 | return HTMLBridgeElement;
|
4249 | }
|
4250 | const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
4251 | freeze$1(BaseBridgeElement);
|
4252 | seal$1(BaseBridgeElement.prototype);
|
4253 |
|
4254 | /*
|
4255 | * Copyright (c) 2020, salesforce.com, inc.
|
4256 | * All rights reserved.
|
4257 | * SPDX-License-Identifier: MIT
|
4258 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4259 | */
|
4260 | function resolveCircularModuleDependency(fn) {
|
4261 | return fn();
|
4262 | }
|
4263 | function isCircularModuleDependency(obj) {
|
4264 | return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
|
4265 | }
|
4266 |
|
4267 | /*
|
4268 | * Copyright (c) 2018, salesforce.com, inc.
|
4269 | * All rights reserved.
|
4270 | * SPDX-License-Identifier: MIT
|
4271 | * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4272 | */
|
4273 | const CtorToDefMap = new WeakMap();
|
4274 |
|
4275 | function getCtorProto(Ctor) {
|
4276 | let proto = getPrototypeOf$1(Ctor);
|
4277 |
|
4278 | if (isNull$1(proto)) {
|
4279 | throw new ReferenceError(`Invalid prototype chain for ${Ctor.name}, you must extend LightningElement.`);
|
4280 | } // covering the cases where the ref is circular in AMD
|
4281 |
|
4282 |
|
4283 | if (isCircularModuleDependency(proto)) {
|
4284 | const p = resolveCircularModuleDependency(proto);
|
4285 |
|
4286 | if (process.env.NODE_ENV !== 'production') {
|
4287 | if (isNull$1(p)) {
|
4288 | throw new ReferenceError(`Circular module dependency for ${Ctor.name}, must resolve to a constructor that extends LightningElement.`);
|
4289 | }
|
4290 | } // escape hatch for Locker and other abstractions to provide their own base class instead
|
4291 | // of our Base class without having to leak it to user-land. If the circular function returns
|
4292 | // itself, that's the signal that we have hit the end of the proto chain, which must always
|
4293 | // be base.
|
4294 |
|
4295 |
|
4296 | proto = p === proto ? BaseLightningElement : p;
|
4297 | }
|
4298 |
|
4299 | return proto;
|
4300 | }
|
4301 |
|
4302 | function createComponentDef(Ctor) {
|
4303 | if (process.env.NODE_ENV !== 'production') {
|
4304 | const ctorName = Ctor.name;
|
4305 |
|
4306 |
|
4307 | assert$1.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
|
4308 | }
|
4309 |
|
4310 | const decoratorsMeta = getDecoratorsMeta(Ctor);
|
4311 | const {
|
4312 | apiFields,
|
4313 | apiFieldsConfig,
|
4314 | apiMethods,
|
4315 | wiredFields,
|
4316 | wiredMethods,
|
4317 | observedFields
|
4318 | } = decoratorsMeta;
|
4319 | const proto = Ctor.prototype;
|
4320 | let {
|
4321 | connectedCallback,
|
4322 | disconnectedCallback,
|
4323 | renderedCallback,
|
4324 | errorCallback,
|
4325 | render
|
4326 | } = proto;
|
4327 | const superProto = getCtorProto(Ctor);
|
4328 | const superDef = superProto !== BaseLightningElement ? getComponentInternalDef(superProto) : lightingElementDef;
|
4329 | const bridge = HTMLBridgeElementFactory(superDef.bridge, keys$1(apiFields), keys$1(apiMethods));
|
4330 | const props = assign$1(create$1(null), superDef.props, apiFields);
|
4331 | const propsConfig = assign$1(create$1(null), superDef.propsConfig, apiFieldsConfig);
|
4332 | const methods = assign$1(create$1(null), superDef.methods, apiMethods);
|
4333 | const wire = assign$1(create$1(null), superDef.wire, wiredFields, wiredMethods);
|
4334 | connectedCallback = connectedCallback || superDef.connectedCallback;
|
4335 | disconnectedCallback = disconnectedCallback || superDef.disconnectedCallback;
|
4336 | renderedCallback = renderedCallback || superDef.renderedCallback;
|
4337 | errorCallback = errorCallback || superDef.errorCallback;
|
4338 | render = render || superDef.render;
|
4339 | const template = getComponentRegisteredTemplate(Ctor) || superDef.template;
|
4340 | const name = Ctor.name || superDef.name;
|
4341 |
|
4342 | defineProperties$1(proto, observedFields);
|
4343 | const def = {
|
4344 | ctor: Ctor,
|
4345 | name,
|
4346 | wire,
|
4347 | props,
|
4348 | propsConfig,
|
4349 | methods,
|
4350 | bridge,
|
4351 | template,
|
4352 | connectedCallback,
|
4353 | disconnectedCallback,
|
4354 | renderedCallback,
|
4355 | errorCallback,
|
4356 | render
|
4357 | };
|
4358 |
|
4359 | if (process.env.NODE_ENV !== 'production') {
|
4360 | freeze$1(Ctor.prototype);
|
4361 | }
|
4362 |
|
4363 | return def;
|
4364 | }
|
4365 |
|
4366 |
|
4367 |
|
4368 |
|
4369 |
|
4370 |
|
4371 | function isComponentConstructor(ctor) {
|
4372 | if (!isFunction$1(ctor)) {
|
4373 | return false;
|
4374 | }
|
4375 |
|
4376 |
|
4377 | if (ctor.prototype instanceof BaseLightningElement) {
|
4378 | return true;
|
4379 | }
|
4380 |
|
4381 |
|
4382 |
|
4383 |
|
4384 | let current = ctor;
|
4385 |
|
4386 | do {
|
4387 | if (isCircularModuleDependency(current)) {
|
4388 | const circularResolved = resolveCircularModuleDependency(current);
|
4389 |
|
4390 |
|
4391 | if (circularResolved === current) {
|
4392 | return true;
|
4393 | }
|
4394 |
|
4395 | current = circularResolved;
|
4396 | }
|
4397 |
|
4398 | if (current === BaseLightningElement) {
|
4399 | return true;
|
4400 | }
|
4401 | } while (!isNull$1(current) && (current = getPrototypeOf$1(current)));
|
4402 |
|
4403 |
|
4404 | return false;
|
4405 | }
|
4406 | function getComponentInternalDef(Ctor) {
|
4407 | let def = CtorToDefMap.get(Ctor);
|
4408 |
|
4409 | if (isUndefined$1(def)) {
|
4410 | if (isCircularModuleDependency(Ctor)) {
|
4411 | const resolvedCtor = resolveCircularModuleDependency(Ctor);
|
4412 | def = getComponentInternalDef(resolvedCtor);
|
4413 |
|
4414 |
|
4415 | CtorToDefMap.set(Ctor, def);
|
4416 | return def;
|
4417 | }
|
4418 |
|
4419 | if (!isComponentConstructor(Ctor)) {
|
4420 | throw new TypeError(`${Ctor} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.`);
|
4421 | }
|
4422 |
|
4423 | def = createComponentDef(Ctor);
|
4424 | CtorToDefMap.set(Ctor, def);
|
4425 | }
|
4426 |
|
4427 | return def;
|
4428 | }
|
4429 |
|
4430 |
|
4431 | function setElementProto(elm, def) {
|
4432 | setPrototypeOf$1(elm, def.bridge.prototype);
|
4433 | }
|
4434 | const lightingElementDef = {
|
4435 | ctor: BaseLightningElement,
|
4436 | name: BaseLightningElement.name,
|
4437 | props: lightningBasedDescriptors,
|
4438 | propsConfig: EmptyObject,
|
4439 | methods: EmptyObject,
|
4440 | wire: EmptyObject,
|
4441 | bridge: BaseBridgeElement,
|
4442 | template: defaultEmptyTemplate,
|
4443 | render: BaseLightningElement.prototype.render
|
4444 | };
|
4445 | var PropDefType;
|
4446 |
|
4447 | (function (PropDefType) {
|
4448 | PropDefType["any"] = "any";
|
4449 | })(PropDefType || (PropDefType = {}));
|
4450 |
|
4451 |
|
4452 |
|
4453 |
|
4454 |
|
4455 |
|
4456 | function getComponentDef(Ctor) {
|
4457 | const def = getComponentInternalDef(Ctor);
|
4458 |
|
4459 |
|
4460 |
|
4461 |
|
4462 | const {
|
4463 | ctor,
|
4464 | name,
|
4465 | props,
|
4466 | propsConfig,
|
4467 | methods
|
4468 | } = def;
|
4469 | const publicProps = {};
|
4470 |
|
4471 | for (const key in props) {
|
4472 |
|
4473 | publicProps[key] = {
|
4474 | config: propsConfig[key] || 0,
|
4475 | type: PropDefType.any,
|
4476 | attr: getAttrNameFromPropName(key)
|
4477 | };
|
4478 | }
|
4479 |
|
4480 | const publicMethods = {};
|
4481 |
|
4482 | for (const key in methods) {
|
4483 |
|
4484 | publicMethods[key] = methods[key].value;
|
4485 | }
|
4486 |
|
4487 | return {
|
4488 | ctor,
|
4489 | name,
|
4490 | props: publicProps,
|
4491 | methods: publicMethods
|
4492 | };
|
4493 | }
|
4494 |
|
4495 |
|
4496 |
|
4497 |
|
4498 |
|
4499 |
|
4500 |
|
4501 |
|
4502 | const noop = () => void 0;
|
4503 |
|
4504 | function observeElementChildNodes(elm) {
|
4505 | elm.$domManual$ = true;
|
4506 | }
|
4507 |
|
4508 | function setElementShadowToken(elm, token) {
|
4509 | elm.$shadowToken$ = token;
|
4510 | }
|
4511 |
|
4512 | function updateNodeHook(oldVnode, vnode) {
|
4513 | const {
|
4514 | elm,
|
4515 | text,
|
4516 | owner: {
|
4517 | renderer
|
4518 | }
|
4519 | } = vnode;
|
4520 |
|
4521 | if (oldVnode.text !== text) {
|
4522 | if (process.env.NODE_ENV !== 'production') {
|
4523 | unlockDomMutation();
|
4524 | }
|
4525 |
|
4526 | renderer.setText(elm, text);
|
4527 |
|
4528 | if (process.env.NODE_ENV !== 'production') {
|
4529 | lockDomMutation();
|
4530 | }
|
4531 | }
|
4532 | }
|
4533 | function insertNodeHook(vnode, parentNode, referenceNode) {
|
4534 | const {
|
4535 | renderer
|
4536 | } = vnode.owner;
|
4537 |
|
4538 | if (process.env.NODE_ENV !== 'production') {
|
4539 | unlockDomMutation();
|
4540 | }
|
4541 |
|
4542 | renderer.insert(vnode.elm, parentNode, referenceNode);
|
4543 |
|
4544 | if (process.env.NODE_ENV !== 'production') {
|
4545 | lockDomMutation();
|
4546 | }
|
4547 | }
|
4548 | function removeNodeHook(vnode, parentNode) {
|
4549 | const {
|
4550 | renderer
|
4551 | } = vnode.owner;
|
4552 |
|
4553 | if (process.env.NODE_ENV !== 'production') {
|
4554 | unlockDomMutation();
|
4555 | }
|
4556 |
|
4557 | renderer.remove(vnode.elm, parentNode);
|
4558 |
|
4559 | if (process.env.NODE_ENV !== 'production') {
|
4560 | lockDomMutation();
|
4561 | }
|
4562 | }
|
4563 | function createElmHook(vnode) {
|
4564 | modEvents.create(vnode);
|
4565 |
|
4566 |
|
4567 |
|
4568 | modAttrs.create(vnode);
|
4569 | modProps.create(vnode);
|
4570 | modStaticClassName.create(vnode);
|
4571 | modStaticStyle.create(vnode);
|
4572 | modComputedClassName.create(vnode);
|
4573 | modComputedStyle.create(vnode);
|
4574 | }
|
4575 | var LWCDOMMode;
|
4576 |
|
4577 | (function (LWCDOMMode) {
|
4578 | LWCDOMMode["manual"] = "manual";
|
4579 | })(LWCDOMMode || (LWCDOMMode = {}));
|
4580 |
|
4581 | function fallbackElmHook(elm, vnode) {
|
4582 | const {
|
4583 | owner
|
4584 | } = vnode;
|
4585 |
|
4586 | if (isTrue$1$1(owner.renderer.syntheticShadow)) {
|
4587 | const {
|
4588 | data: {
|
4589 | context
|
4590 | }
|
4591 | } = vnode;
|
4592 | const {
|
4593 | shadowAttribute
|
4594 | } = owner.context;
|
4595 |
|
4596 | if (!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === LWCDOMMode.manual) {
|
4597 |
|
4598 | observeElementChildNodes(elm);
|
4599 | }
|
4600 |
|
4601 |
|
4602 |
|
4603 | setElementShadowToken(elm, shadowAttribute);
|
4604 | }
|
4605 |
|
4606 | if (process.env.NODE_ENV !== 'production') {
|
4607 | const {
|
4608 | data: {
|
4609 | context
|
4610 | }
|
4611 | } = vnode;
|
4612 | const isPortal = !isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === LWCDOMMode.manual;
|
4613 | patchElementWithRestrictions(elm, {
|
4614 | isPortal
|
4615 | });
|
4616 | }
|
4617 | }
|
4618 | function updateElmHook(oldVnode, vnode) {
|
4619 |
|
4620 |
|
4621 |
|
4622 | modAttrs.update(oldVnode, vnode);
|
4623 | modProps.update(oldVnode, vnode);
|
4624 | modComputedClassName.update(oldVnode, vnode);
|
4625 | modComputedStyle.update(oldVnode, vnode);
|
4626 | }
|
4627 | function updateChildrenHook(oldVnode, vnode) {
|
4628 | const {
|
4629 | children,
|
4630 | owner
|
4631 | } = vnode;
|
4632 | const fn = hasDynamicChildren(children) ? updateDynamicChildren : updateStaticChildren;
|
4633 | runWithBoundaryProtection(owner, owner.owner, noop, () => {
|
4634 | fn(vnode.elm, oldVnode.children, children);
|
4635 | }, noop);
|
4636 | }
|
4637 | function allocateChildrenHook(vnode, vm) {
|
4638 |
|
4639 |
|
4640 |
|
4641 |
|
4642 |
|
4643 |
|
4644 |
|
4645 |
|
4646 |
|
4647 |
|
4648 | const children = vnode.aChildren || vnode.children;
|
4649 | vm.aChildren = children;
|
4650 |
|
4651 | if (isTrue$1$1(vm.renderer.syntheticShadow)) {
|
4652 |
|
4653 | allocateInSlot(vm, children);
|
4654 |
|
4655 | vnode.aChildren = children;
|
4656 |
|
4657 | vnode.children = EmptyArray;
|
4658 | }
|
4659 | }
|
4660 | function createViewModelHook(elm, vnode) {
|
4661 | if (!isUndefined$1(getAssociatedVMIfPresent(elm))) {
|
4662 |
|
4663 |
|
4664 |
|
4665 | return;
|
4666 | }
|
4667 |
|
4668 | const {
|
4669 | sel,
|
4670 | mode,
|
4671 | ctor,
|
4672 | owner
|
4673 | } = vnode;
|
4674 | const def = getComponentInternalDef(ctor);
|
4675 | setElementProto(elm, def);
|
4676 |
|
4677 | if (isTrue$1$1(owner.renderer.syntheticShadow)) {
|
4678 | const {
|
4679 | shadowAttribute
|
4680 | } = owner.context;
|
4681 |
|
4682 |
|
4683 | setElementShadowToken(elm, shadowAttribute);
|
4684 | }
|
4685 |
|
4686 | createVM(elm, def, {
|
4687 | mode,
|
4688 | owner,
|
4689 | tagName: sel,
|
4690 | renderer: owner.renderer
|
4691 | });
|
4692 |
|
4693 | if (process.env.NODE_ENV !== 'production') {
|
4694 | assert$1.isTrue(isArray$2(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
4695 | }
|
4696 | }
|
4697 | function createCustomElmHook(vnode) {
|
4698 | modEvents.create(vnode);
|
4699 |
|
4700 |
|
4701 |
|
4702 | modAttrs.create(vnode);
|
4703 | modProps.create(vnode);
|
4704 | modStaticClassName.create(vnode);
|
4705 | modStaticStyle.create(vnode);
|
4706 | modComputedClassName.create(vnode);
|
4707 | modComputedStyle.create(vnode);
|
4708 | }
|
4709 | function createChildrenHook(vnode) {
|
4710 | const {
|
4711 | elm,
|
4712 | children
|
4713 | } = vnode;
|
4714 |
|
4715 | for (let j = 0; j < children.length; ++j) {
|
4716 | const ch = children[j];
|
4717 |
|
4718 | if (ch != null) {
|
4719 | ch.hook.create(ch);
|
4720 | ch.hook.insert(ch, elm, null);
|
4721 | }
|
4722 | }
|
4723 | }
|
4724 | function updateCustomElmHook(oldVnode, vnode) {
|
4725 |
|
4726 |
|
4727 |
|
4728 | modAttrs.update(oldVnode, vnode);
|
4729 | modProps.update(oldVnode, vnode);
|
4730 | modComputedClassName.update(oldVnode, vnode);
|
4731 | modComputedStyle.update(oldVnode, vnode);
|
4732 | }
|
4733 | function removeElmHook(vnode) {
|
4734 |
|
4735 |
|
4736 |
|
4737 | const {
|
4738 | children,
|
4739 | elm
|
4740 | } = vnode;
|
4741 |
|
4742 | for (let j = 0, len = children.length; j < len; ++j) {
|
4743 | const ch = children[j];
|
4744 |
|
4745 | if (!isNull$1(ch)) {
|
4746 | ch.hook.remove(ch, elm);
|
4747 | }
|
4748 | }
|
4749 | }
|
4750 |
|
4751 | const FromIteration = new WeakMap();
|
4752 |
|
4753 |
|
4754 | function markAsDynamicChildren(children) {
|
4755 | FromIteration.set(children, 1);
|
4756 | }
|
4757 | function hasDynamicChildren(children) {
|
4758 | return FromIteration.has(children);
|
4759 | }
|
4760 |
|
4761 |
|
4762 |
|
4763 |
|
4764 |
|
4765 |
|
4766 |
|
4767 | function getUpgradableConstructor(tagName, renderer) {
|
4768 |
|
4769 |
|
4770 |
|
4771 | tagName = tagName.toLowerCase();
|
4772 | let CE = renderer.getCustomElement(tagName);
|
4773 |
|
4774 | if (!isUndefined$1(CE)) {
|
4775 | return CE;
|
4776 | }
|
4777 | |
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 |
|
4783 | CE = class LWCUpgradableElement extends renderer.HTMLElement {
|
4784 | constructor() {
|
4785 | super();
|
4786 | const constructor = this.constructor;
|
4787 | const {
|
4788 | upgradeCallback
|
4789 | } = constructor;
|
4790 | constructor.upgradeCallback = undefined; // resetting it
|
4791 |
|
4792 | if (isFunction$1(upgradeCallback)) {
|
4793 | upgradeCallback(this);
|
4794 | }
|
4795 | }
|
4796 |
|
4797 | static set upgrade(callbackOnce) {
|
4798 | this.upgradeCallback = callbackOnce;
|
4799 | }
|
4800 |
|
4801 | };
|
4802 | renderer.defineCustomElement(tagName, CE);
|
4803 | return CE;
|
4804 | }
|
4805 |
|
4806 |
|
4807 |
|
4808 |
|
4809 |
|
4810 |
|
4811 |
|
4812 | const CHAR_S = 115;
|
4813 | const CHAR_V = 118;
|
4814 | const CHAR_G = 103;
|
4815 | const NamespaceAttributeForSVG = 'http://www.w3.org/2000/svg';
|
4816 | const SymbolIterator = Symbol.iterator;
|
4817 | const TextHook = {
|
4818 | create: vnode => {
|
4819 | const {
|
4820 | renderer
|
4821 | } = vnode.owner;
|
4822 | const elm = renderer.createText(vnode.text);
|
4823 | linkNodeToShadow(elm, vnode);
|
4824 | vnode.elm = elm;
|
4825 | },
|
4826 | update: updateNodeHook,
|
4827 | insert: insertNodeHook,
|
4828 | move: insertNodeHook,
|
4829 | remove: removeNodeHook
|
4830 | };
|
4831 |
|
4832 |
|
4833 |
|
4834 |
|
4835 |
|
4836 | const ElementHook = {
|
4837 | create: vnode => {
|
4838 | const {
|
4839 | sel,
|
4840 | data: {
|
4841 | ns
|
4842 | },
|
4843 | owner: {
|
4844 | renderer
|
4845 | }
|
4846 | } = vnode;
|
4847 | const elm = renderer.createElement(sel, ns);
|
4848 | linkNodeToShadow(elm, vnode);
|
4849 | fallbackElmHook(elm, vnode);
|
4850 | vnode.elm = elm;
|
4851 | createElmHook(vnode);
|
4852 | },
|
4853 | update: (oldVnode, vnode) => {
|
4854 | updateElmHook(oldVnode, vnode);
|
4855 | updateChildrenHook(oldVnode, vnode);
|
4856 | },
|
4857 | insert: (vnode, parentNode, referenceNode) => {
|
4858 | insertNodeHook(vnode, parentNode, referenceNode);
|
4859 | createChildrenHook(vnode);
|
4860 | },
|
4861 | move: (vnode, parentNode, referenceNode) => {
|
4862 | insertNodeHook(vnode, parentNode, referenceNode);
|
4863 | },
|
4864 | remove: (vnode, parentNode) => {
|
4865 | removeNodeHook(vnode, parentNode);
|
4866 | removeElmHook(vnode);
|
4867 | }
|
4868 | };
|
4869 |
|
4870 | function isUpgradableComponent(ctor) {
|
4871 | return 'upgrade' in ctor;
|
4872 | }
|
4873 |
|
4874 | const CustomElementHook = {
|
4875 | create: vnode => {
|
4876 | const {
|
4877 | sel,
|
4878 | owner: {
|
4879 | renderer
|
4880 | }
|
4881 | } = vnode;
|
4882 | const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
4883 |
|
4884 | if (isUpgradableComponent(UpgradableConstructor)) {
|
4885 |
|
4886 | UpgradableConstructor.upgrade = elm => {
|
4887 | createViewModelHook(elm, vnode);
|
4888 | };
|
4889 | }
|
4890 |
|
4891 | const elm = new UpgradableConstructor();
|
4892 | vnode.elm = elm;
|
4893 | linkNodeToShadow(elm, vnode);
|
4894 | const vm = getAssociatedVMIfPresent(elm);
|
4895 |
|
4896 | if (vm) {
|
4897 | allocateChildrenHook(vnode, vm);
|
4898 | } else if (vnode.ctor !== UpgradableConstructor) {
|
4899 | throw new TypeError(`Incorrect Component Constructor`);
|
4900 | }
|
4901 |
|
4902 | createCustomElmHook(vnode);
|
4903 | },
|
4904 | update: (oldVnode, vnode) => {
|
4905 | updateCustomElmHook(oldVnode, vnode);
|
4906 | const vm = getAssociatedVMIfPresent(vnode.elm);
|
4907 |
|
4908 | if (vm) {
|
4909 |
|
4910 |
|
4911 | allocateChildrenHook(vnode, vm);
|
4912 | }
|
4913 |
|
4914 |
|
4915 |
|
4916 | updateChildrenHook(oldVnode, vnode);
|
4917 |
|
4918 | if (vm) {
|
4919 | if (process.env.NODE_ENV !== 'production') {
|
4920 | assert$1.isTrue(isArray$2(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
4921 | }
|
4922 |
|
4923 |
|
4924 |
|
4925 | rerenderVM(vm);
|
4926 | }
|
4927 | },
|
4928 | insert: (vnode, parentNode, referenceNode) => {
|
4929 | insertNodeHook(vnode, parentNode, referenceNode);
|
4930 | const vm = getAssociatedVMIfPresent(vnode.elm);
|
4931 |
|
4932 | if (vm) {
|
4933 | if (process.env.NODE_ENV !== 'production') {
|
4934 | assert$1.isTrue(vm.state === VMState.created, `${vm} cannot be recycled.`);
|
4935 | }
|
4936 |
|
4937 | runConnectedCallback(vm);
|
4938 | }
|
4939 |
|
4940 | createChildrenHook(vnode);
|
4941 |
|
4942 | if (vm) {
|
4943 | appendVM(vm);
|
4944 | }
|
4945 | },
|
4946 | move: (vnode, parentNode, referenceNode) => {
|
4947 | insertNodeHook(vnode, parentNode, referenceNode);
|
4948 | },
|
4949 | remove: (vnode, parentNode) => {
|
4950 | removeNodeHook(vnode, parentNode);
|
4951 | const vm = getAssociatedVMIfPresent(vnode.elm);
|
4952 |
|
4953 | if (vm) {
|
4954 |
|
4955 |
|
4956 | removeVM(vm);
|
4957 | }
|
4958 | }
|
4959 | };
|
4960 |
|
4961 | function linkNodeToShadow(elm, vnode) {
|
4962 |
|
4963 | elm.$shadowResolver$ = vnode.owner.cmpRoot.$shadowResolver$;
|
4964 | }
|
4965 |
|
4966 |
|
4967 | function addNS(vnode) {
|
4968 | const {
|
4969 | data,
|
4970 | children,
|
4971 | sel
|
4972 | } = vnode;
|
4973 | data.ns = NamespaceAttributeForSVG;
|
4974 |
|
4975 | if (isArray$2(children) && sel !== 'foreignObject') {
|
4976 | for (let j = 0, n = children.length; j < n; ++j) {
|
4977 | const childNode = children[j];
|
4978 |
|
4979 | if (childNode != null && childNode.hook === ElementHook) {
|
4980 | addNS(childNode);
|
4981 | }
|
4982 | }
|
4983 | }
|
4984 | }
|
4985 |
|
4986 | function addVNodeToChildLWC(vnode) {
|
4987 | ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
4988 | }
|
4989 |
|
4990 |
|
4991 | function h(sel, data, children) {
|
4992 | const vmBeingRendered = getVMBeingRendered();
|
4993 |
|
4994 | if (process.env.NODE_ENV !== 'production') {
|
4995 | assert$1.isTrue(isString(sel), `h() 1st argument sel must be a string.`);
|
4996 | assert$1.isTrue(isObject$2(data), `h() 2nd argument data must be an object.`);
|
4997 | assert$1.isTrue(isArray$2(children), `h() 3rd argument children must be an array.`);
|
4998 | assert$1.isTrue('key' in data, ` <${sel}> "key" attribute is invalid or missing for ${vmBeingRendered}. Key inside iterator is either undefined or null.`);
|
4999 |
|
5000 | assert$1.isFalse(data.className && data.classMap, `vnode.data.className and vnode.data.classMap ambiguous declaration.`);
|
5001 | assert$1.isFalse(data.styleMap && data.style, `vnode.data.styleMap and vnode.data.style ambiguous declaration.`);
|
5002 |
|
5003 | if (data.style && !isString(data.style)) {
|
5004 | logError(`Invalid 'style' attribute passed to <${sel}> is ignored. This attribute must be a string value.`, vmBeingRendered);
|
5005 | }
|
5006 |
|
5007 | forEach$1.call(children, childVnode => {
|
5008 | if (childVnode != null) {
|
5009 | assert$1.isTrue(childVnode && 'sel' in childVnode && 'data' in childVnode && 'children' in childVnode && 'text' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
5010 | }
|
5011 | });
|
5012 | }
|
5013 |
|
5014 | const {
|
5015 | key
|
5016 | } = data;
|
5017 | let text, elm;
|
5018 | const vnode = {
|
5019 | sel,
|
5020 | data,
|
5021 | children,
|
5022 | text,
|
5023 | elm,
|
5024 | key,
|
5025 | hook: ElementHook,
|
5026 | owner: vmBeingRendered
|
5027 | };
|
5028 |
|
5029 | if (sel.length === 3 && StringCharCodeAt$1.call(sel, 0) === CHAR_S && StringCharCodeAt$1.call(sel, 1) === CHAR_V && StringCharCodeAt$1.call(sel, 2) === CHAR_G) {
|
5030 | addNS(vnode);
|
5031 | }
|
5032 |
|
5033 | return vnode;
|
5034 | }
|
5035 |
|
5036 | function ti(value) {
|
5037 |
|
5038 |
|
5039 |
|
5040 | const shouldNormalize = value > 0 && !(isTrue$1$1(value) || isFalse$1$1(value));
|
5041 |
|
5042 | if (process.env.NODE_ENV !== 'production') {
|
5043 | const vmBeingRendered = getVMBeingRendered();
|
5044 |
|
5045 | if (shouldNormalize) {
|
5046 | logError(`Invalid tabindex value \`${toString$1(value)}\` in template for ${vmBeingRendered}. This attribute must be set to 0 or -1.`, vmBeingRendered);
|
5047 | }
|
5048 | }
|
5049 |
|
5050 | return shouldNormalize ? 0 : value;
|
5051 | }
|
5052 |
|
5053 | function s(slotName, data, children, slotset) {
|
5054 | if (process.env.NODE_ENV !== 'production') {
|
5055 | assert$1.isTrue(isString(slotName), `s() 1st argument slotName must be a string.`);
|
5056 | assert$1.isTrue(isObject$2(data), `s() 2nd argument data must be an object.`);
|
5057 | assert$1.isTrue(isArray$2(children), `h() 3rd argument children must be an array.`);
|
5058 | }
|
5059 |
|
5060 | if (!isUndefined$1(slotset) && !isUndefined$1(slotset[slotName]) && slotset[slotName].length !== 0) {
|
5061 | children = slotset[slotName];
|
5062 | }
|
5063 |
|
5064 | const vnode = h('slot', data, children);
|
5065 |
|
5066 | if (vnode.owner.renderer.syntheticShadow) {
|
5067 |
|
5068 | sc(children);
|
5069 | }
|
5070 |
|
5071 | return vnode;
|
5072 | }
|
5073 |
|
5074 | function c(sel, Ctor, data, children = EmptyArray) {
|
5075 | const vmBeingRendered = getVMBeingRendered();
|
5076 |
|
5077 | if (process.env.NODE_ENV !== 'production') {
|
5078 | assert$1.isTrue(isString(sel), `c() 1st argument sel must be a string.`);
|
5079 | assert$1.isTrue(isFunction$1(Ctor), `c() 2nd argument Ctor must be a function.`);
|
5080 | assert$1.isTrue(isObject$2(data), `c() 3nd argument data must be an object.`);
|
5081 | assert$1.isTrue(arguments.length === 3 || isArray$2(children), `c() 4nd argument data must be an array.`);
|
5082 |
|
5083 | assert$1.isFalse(data.className && data.classMap, `vnode.data.className and vnode.data.classMap ambiguous declaration.`);
|
5084 | assert$1.isFalse(data.styleMap && data.style, `vnode.data.styleMap and vnode.data.style ambiguous declaration.`);
|
5085 |
|
5086 | if (data.style && !isString(data.style)) {
|
5087 | logError(`Invalid 'style' attribute passed to <${sel}> is ignored. This attribute must be a string value.`, vmBeingRendered);
|
5088 | }
|
5089 |
|
5090 | if (arguments.length === 4) {
|
5091 | forEach$1.call(children, childVnode => {
|
5092 | if (childVnode != null) {
|
5093 | assert$1.isTrue(childVnode && 'sel' in childVnode && 'data' in childVnode && 'children' in childVnode && 'text' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
5094 | }
|
5095 | });
|
5096 | }
|
5097 | }
|
5098 |
|
5099 | const {
|
5100 | key
|
5101 | } = data;
|
5102 | let text, elm;
|
5103 | const vnode = {
|
5104 | sel,
|
5105 | data,
|
5106 | children,
|
5107 | text,
|
5108 | elm,
|
5109 | key,
|
5110 | hook: CustomElementHook,
|
5111 | ctor: Ctor,
|
5112 | owner: vmBeingRendered,
|
5113 | mode: 'open'
|
5114 | };
|
5115 | addVNodeToChildLWC(vnode);
|
5116 | return vnode;
|
5117 | }
|
5118 |
|
5119 | function i(iterable, factory) {
|
5120 | const list = [];
|
5121 |
|
5122 | sc(list);
|
5123 | const vmBeingRendered = getVMBeingRendered();
|
5124 |
|
5125 | if (isUndefined$1(iterable) || iterable === null) {
|
5126 | if (process.env.NODE_ENV !== 'production') {
|
5127 | logError(`Invalid template iteration for value "${toString$1(iterable)}" in ${vmBeingRendered}. It must be an Array or an iterable Object.`, vmBeingRendered);
|
5128 | }
|
5129 |
|
5130 | return list;
|
5131 | }
|
5132 |
|
5133 | if (process.env.NODE_ENV !== 'production') {
|
5134 | assert$1.isFalse(isUndefined$1(iterable[SymbolIterator]), `Invalid template iteration for value \`${toString$1(iterable)}\` in ${vmBeingRendered}. It must be an array-like object and not \`null\` nor \`undefined\`.`);
|
5135 | }
|
5136 |
|
5137 | const iterator = iterable[SymbolIterator]();
|
5138 |
|
5139 | if (process.env.NODE_ENV !== 'production') {
|
5140 | assert$1.isTrue(iterator && isFunction$1(iterator.next), `Invalid iterator function for "${toString$1(iterable)}" in ${vmBeingRendered}.`);
|
5141 | }
|
5142 |
|
5143 | let next = iterator.next();
|
5144 | let j = 0;
|
5145 | let {
|
5146 | value,
|
5147 | done: last
|
5148 | } = next;
|
5149 | let keyMap;
|
5150 | let iterationError;
|
5151 |
|
5152 | if (process.env.NODE_ENV !== 'production') {
|
5153 | keyMap = create$1(null);
|
5154 | }
|
5155 |
|
5156 | while (last === false) {
|
5157 |
|
5158 | next = iterator.next();
|
5159 | last = next.done;
|
5160 |
|
5161 | const vnode = factory(value, j, j === 0, last);
|
5162 |
|
5163 | if (isArray$2(vnode)) {
|
5164 | ArrayPush$1.apply(list, vnode);
|
5165 | } else {
|
5166 | ArrayPush$1.call(list, vnode);
|
5167 | }
|
5168 |
|
5169 | if (process.env.NODE_ENV !== 'production') {
|
5170 | const vnodes = isArray$2(vnode) ? vnode : [vnode];
|
5171 | forEach$1.call(vnodes, childVnode => {
|
5172 | if (!isNull$1(childVnode) && isObject$2(childVnode) && !isUndefined$1(childVnode.sel)) {
|
5173 | const {
|
5174 | key
|
5175 | } = childVnode;
|
5176 |
|
5177 | if (isString(key) || isNumber(key)) {
|
5178 | if (keyMap[key] === 1 && isUndefined$1(iterationError)) {
|
5179 | iterationError = `Duplicated "key" attribute value for "<${childVnode.sel}>" in ${vmBeingRendered} for item number ${j}. A key with value "${childVnode.key}" appears more than once in the iteration. Key values must be unique numbers or strings.`;
|
5180 | }
|
5181 |
|
5182 | keyMap[key] = 1;
|
5183 | } else if (isUndefined$1(iterationError)) {
|
5184 | iterationError = `Invalid "key" attribute value in "<${childVnode.sel}>" in ${vmBeingRendered} for item number ${j}. Set a unique "key" value on all iterated child elements.`;
|
5185 | }
|
5186 | }
|
5187 | });
|
5188 | }
|
5189 |
|
5190 |
|
5191 | j += 1;
|
5192 | value = next.value;
|
5193 | }
|
5194 |
|
5195 | if (process.env.NODE_ENV !== 'production') {
|
5196 | if (!isUndefined$1(iterationError)) {
|
5197 | logError(iterationError, vmBeingRendered);
|
5198 | }
|
5199 | }
|
5200 |
|
5201 | return list;
|
5202 | }
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 | function f(items) {
|
5208 | if (process.env.NODE_ENV !== 'production') {
|
5209 | assert$1.isTrue(isArray$2(items), 'flattening api can only work with arrays.');
|
5210 | }
|
5211 |
|
5212 | const len = items.length;
|
5213 | const flattened = [];
|
5214 |
|
5215 | sc(flattened);
|
5216 |
|
5217 | for (let j = 0; j < len; j += 1) {
|
5218 | const item = items[j];
|
5219 |
|
5220 | if (isArray$2(item)) {
|
5221 | ArrayPush$1.apply(flattened, item);
|
5222 | } else {
|
5223 | ArrayPush$1.call(flattened, item);
|
5224 | }
|
5225 | }
|
5226 |
|
5227 | return flattened;
|
5228 | }
|
5229 |
|
5230 | function t(text) {
|
5231 | const data = EmptyObject;
|
5232 | let sel, children, key, elm;
|
5233 | return {
|
5234 | sel,
|
5235 | data,
|
5236 | children,
|
5237 | text,
|
5238 | elm,
|
5239 | key,
|
5240 | hook: TextHook,
|
5241 | owner: getVMBeingRendered()
|
5242 | };
|
5243 | }
|
5244 |
|
5245 | function d(value) {
|
5246 | if (value == null) {
|
5247 | return null;
|
5248 | }
|
5249 |
|
5250 | return t(value);
|
5251 | }
|
5252 |
|
5253 | function b(fn) {
|
5254 | const vmBeingRendered = getVMBeingRendered();
|
5255 |
|
5256 | if (isNull$1(vmBeingRendered)) {
|
5257 | throw new Error();
|
5258 | }
|
5259 |
|
5260 | const vm = vmBeingRendered;
|
5261 | return function (event) {
|
5262 | invokeEventListener(vm, fn, vm.component, event);
|
5263 | };
|
5264 | }
|
5265 |
|
5266 | function k(compilerKey, obj) {
|
5267 | switch (typeof obj) {
|
5268 | case 'number':
|
5269 | case 'string':
|
5270 | return compilerKey + ':' + obj;
|
5271 |
|
5272 | case 'object':
|
5273 | if (process.env.NODE_ENV !== 'production') {
|
5274 | assert$1.fail(`Invalid key value "${obj}" in ${getVMBeingRendered()}. Key must be a string or number.`);
|
5275 | }
|
5276 |
|
5277 | }
|
5278 | }
|
5279 |
|
5280 | function gid(id) {
|
5281 | const vmBeingRendered = getVMBeingRendered();
|
5282 |
|
5283 | if (isUndefined$1(id) || id === '') {
|
5284 | if (process.env.NODE_ENV !== 'production') {
|
5285 | logError(`Invalid id value "${id}". The id attribute must contain a non-empty string.`, vmBeingRendered);
|
5286 | }
|
5287 |
|
5288 | return id;
|
5289 | }
|
5290 |
|
5291 |
|
5292 | if (isNull$1(id)) {
|
5293 | return null;
|
5294 | }
|
5295 |
|
5296 | return `${id}-${vmBeingRendered.idx}`;
|
5297 | }
|
5298 |
|
5299 | function fid(url) {
|
5300 | const vmBeingRendered = getVMBeingRendered();
|
5301 |
|
5302 | if (isUndefined$1(url) || url === '') {
|
5303 | if (process.env.NODE_ENV !== 'production') {
|
5304 | if (isUndefined$1(url)) {
|
5305 | logError(`Undefined url value for "href" or "xlink:href" attribute. Expected a non-empty string.`, vmBeingRendered);
|
5306 | }
|
5307 | }
|
5308 |
|
5309 | return url;
|
5310 | }
|
5311 |
|
5312 |
|
5313 | if (isNull$1(url)) {
|
5314 | return null;
|
5315 | }
|
5316 |
|
5317 |
|
5318 | if (/^#/.test(url)) {
|
5319 | return `${url}-${vmBeingRendered.idx}`;
|
5320 | }
|
5321 |
|
5322 | return url;
|
5323 | }
|
5324 |
|
5325 |
|
5326 |
|
5327 |
|
5328 |
|
5329 |
|
5330 | const DynamicImportedComponentMap = new Map();
|
5331 | let dynamicImportedComponentCounter = 0;
|
5332 |
|
5333 |
|
5334 |
|
5335 |
|
5336 | function dc(sel, Ctor, data, children) {
|
5337 | if (process.env.NODE_ENV !== 'production') {
|
5338 | assert$1.isTrue(isString(sel), `dc() 1st argument sel must be a string.`);
|
5339 | assert$1.isTrue(isObject$2(data), `dc() 3nd argument data must be an object.`);
|
5340 | assert$1.isTrue(arguments.length === 3 || isArray$2(children), `dc() 4nd argument data must be an array.`);
|
5341 | }
|
5342 |
|
5343 |
|
5344 | if (Ctor == null) {
|
5345 | return null;
|
5346 | }
|
5347 |
|
5348 | if (!isComponentConstructor(Ctor)) {
|
5349 | throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
|
5350 | }
|
5351 |
|
5352 | let idx = DynamicImportedComponentMap.get(Ctor);
|
5353 |
|
5354 | if (isUndefined$1(idx)) {
|
5355 | idx = dynamicImportedComponentCounter++;
|
5356 | DynamicImportedComponentMap.set(Ctor, idx);
|
5357 | }
|
5358 |
|
5359 |
|
5360 |
|
5361 |
|
5362 | data.key = `dc:${idx}:${data.key}`;
|
5363 | return c(sel, Ctor, data, children);
|
5364 | }
|
5365 |
|
5366 |
|
5367 |
|
5368 |
|
5369 |
|
5370 |
|
5371 |
|
5372 |
|
5373 |
|
5374 |
|
5375 |
|
5376 |
|
5377 |
|
5378 |
|
5379 | function sc(vnodes) {
|
5380 | if (process.env.NODE_ENV !== 'production') {
|
5381 | assert$1.isTrue(isArray$2(vnodes), 'sc() api can only work with arrays.');
|
5382 | }
|
5383 |
|
5384 |
|
5385 |
|
5386 |
|
5387 | markAsDynamicChildren(vnodes);
|
5388 | return vnodes;
|
5389 | }
|
5390 |
|
5391 | var api$1 = Object.freeze({
|
5392 | __proto__: null,
|
5393 | h: h,
|
5394 | ti: ti,
|
5395 | s: s,
|
5396 | c: c,
|
5397 | i: i,
|
5398 | f: f,
|
5399 | t: t,
|
5400 | d: d,
|
5401 | b: b,
|
5402 | k: k,
|
5403 | gid: gid,
|
5404 | fid: fid,
|
5405 | dc: dc,
|
5406 | sc: sc
|
5407 | });
|
5408 |
|
5409 |
|
5410 |
|
5411 |
|
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 | function createShadowStyleVNode(content) {
|
5417 | return h('style', {
|
5418 | key: 'style',
|
5419 | attrs: {
|
5420 | type: 'text/css'
|
5421 | }
|
5422 | }, [t(content)]);
|
5423 | }
|
5424 |
|
5425 | function updateSyntheticShadowAttributes(vm, template) {
|
5426 | const {
|
5427 | elm,
|
5428 | context,
|
5429 | renderer
|
5430 | } = vm;
|
5431 | const {
|
5432 | stylesheets: newStylesheets,
|
5433 | stylesheetTokens: newStylesheetTokens
|
5434 | } = template;
|
5435 | let newHostAttribute;
|
5436 | let newShadowAttribute;
|
5437 |
|
5438 | const oldHostAttribute = context.hostAttribute;
|
5439 |
|
5440 | if (!isUndefined$1(oldHostAttribute)) {
|
5441 | renderer.removeAttribute(elm, oldHostAttribute);
|
5442 | }
|
5443 |
|
5444 |
|
5445 |
|
5446 | if (!isUndefined$1(newStylesheetTokens) && !isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
5447 | newHostAttribute = newStylesheetTokens.hostAttribute;
|
5448 | newShadowAttribute = newStylesheetTokens.shadowAttribute;
|
5449 | renderer.setAttribute(elm, newHostAttribute, '');
|
5450 | }
|
5451 |
|
5452 |
|
5453 | context.hostAttribute = newHostAttribute;
|
5454 | context.shadowAttribute = newShadowAttribute;
|
5455 | }
|
5456 |
|
5457 | function evaluateStylesheetsContent(stylesheets, hostSelector, shadowSelector, nativeShadow) {
|
5458 | const content = [];
|
5459 |
|
5460 | for (let i = 0; i < stylesheets.length; i++) {
|
5461 | const stylesheet = stylesheets[i];
|
5462 |
|
5463 | if (isArray$2(stylesheet)) {
|
5464 | ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, hostSelector, shadowSelector, nativeShadow));
|
5465 | } else {
|
5466 | ArrayPush$1.call(content, stylesheet(hostSelector, shadowSelector, nativeShadow));
|
5467 | }
|
5468 | }
|
5469 |
|
5470 | return content;
|
5471 | }
|
5472 |
|
5473 | function getStylesheetsContent(vm, template) {
|
5474 | const {
|
5475 | stylesheets,
|
5476 | stylesheetTokens: tokens
|
5477 | } = template;
|
5478 | const {
|
5479 | syntheticShadow
|
5480 | } = vm.renderer;
|
5481 | let content = [];
|
5482 |
|
5483 | if (!isUndefined$1(stylesheets) && !isUndefined$1(tokens)) {
|
5484 | const hostSelector = syntheticShadow ? `[${tokens.hostAttribute}]` : '';
|
5485 | const shadowSelector = syntheticShadow ? `[${tokens.shadowAttribute}]` : '';
|
5486 | content = evaluateStylesheetsContent(stylesheets, hostSelector, shadowSelector, !syntheticShadow);
|
5487 | }
|
5488 |
|
5489 | return content;
|
5490 | }
|
5491 | function createStylesheet(vm, stylesheets) {
|
5492 | const {
|
5493 | renderer
|
5494 | } = vm;
|
5495 |
|
5496 | if (renderer.syntheticShadow) {
|
5497 | for (let i = 0; i < stylesheets.length; i++) {
|
5498 | renderer.insertGlobalStylesheet(stylesheets[i]);
|
5499 | }
|
5500 |
|
5501 | return null;
|
5502 | } else {
|
5503 | const shadowStyleSheetContent = ArrayJoin$1.call(stylesheets, '\n');
|
5504 | return createShadowStyleVNode(shadowStyleSheetContent);
|
5505 | }
|
5506 | }
|
5507 |
|
5508 |
|
5509 |
|
5510 |
|
5511 |
|
5512 |
|
5513 |
|
5514 | var GlobalMeasurementPhase;
|
5515 |
|
5516 | (function (GlobalMeasurementPhase) {
|
5517 | GlobalMeasurementPhase["REHYDRATE"] = "lwc-rehydrate";
|
5518 | GlobalMeasurementPhase["HYDRATE"] = "lwc-hydrate";
|
5519 | })(GlobalMeasurementPhase || (GlobalMeasurementPhase = {}));
|
5520 |
|
5521 |
|
5522 |
|
5523 | const isUserTimingSupported = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
|
5524 |
|
5525 | function getMarkName(phase, vm) {
|
5526 |
|
5527 |
|
5528 | return `${getComponentTag(vm)} - ${phase} - ${vm.idx}`;
|
5529 | }
|
5530 |
|
5531 | function getMeasureName(phase, vm) {
|
5532 | return `${getComponentTag(vm)} - ${phase}`;
|
5533 | }
|
5534 |
|
5535 | function start(markName) {
|
5536 | performance.mark(markName);
|
5537 | }
|
5538 |
|
5539 | function end(measureName, markName) {
|
5540 | performance.measure(measureName, markName);
|
5541 |
|
5542 |
|
5543 | performance.clearMarks(markName);
|
5544 | performance.clearMarks(measureName);
|
5545 | }
|
5546 |
|
5547 | function noop$1() {
|
5548 |
|
5549 | }
|
5550 |
|
5551 | const startMeasure = !isUserTimingSupported ? noop$1 : function (phase, vm) {
|
5552 | const markName = getMarkName(phase, vm);
|
5553 | start(markName);
|
5554 | };
|
5555 | const endMeasure = !isUserTimingSupported ? noop$1 : function (phase, vm) {
|
5556 | const markName = getMarkName(phase, vm);
|
5557 | const measureName = getMeasureName(phase, vm);
|
5558 | end(measureName, markName);
|
5559 | };
|
5560 | const startGlobalMeasure = !isUserTimingSupported ? noop$1 : function (phase, vm) {
|
5561 | const markName = isUndefined$1(vm) ? phase : getMarkName(phase, vm);
|
5562 | start(markName);
|
5563 | };
|
5564 | const endGlobalMeasure = !isUserTimingSupported ? noop$1 : function (phase, vm) {
|
5565 | const markName = isUndefined$1(vm) ? phase : getMarkName(phase, vm);
|
5566 | end(phase, markName);
|
5567 | };
|
5568 |
|
5569 |
|
5570 |
|
5571 |
|
5572 |
|
5573 |
|
5574 |
|
5575 |
|
5576 | function noop$2(_opId, _phase, _cmpName, _vm_idx) {}
|
5577 |
|
5578 | let logOperation = noop$2;
|
5579 | var OperationId;
|
5580 |
|
5581 | (function (OperationId) {
|
5582 | OperationId[OperationId["constructor"] = 0] = "constructor";
|
5583 | OperationId[OperationId["render"] = 1] = "render";
|
5584 | OperationId[OperationId["patch"] = 2] = "patch";
|
5585 | OperationId[OperationId["connectedCallback"] = 3] = "connectedCallback";
|
5586 | OperationId[OperationId["renderedCallback"] = 4] = "renderedCallback";
|
5587 | OperationId[OperationId["disconnectedCallback"] = 5] = "disconnectedCallback";
|
5588 | OperationId[OperationId["errorCallback"] = 6] = "errorCallback";
|
5589 | })(OperationId || (OperationId = {}));
|
5590 |
|
5591 | var Phase;
|
5592 |
|
5593 | (function (Phase) {
|
5594 | Phase[Phase["Start"] = 0] = "Start";
|
5595 | Phase[Phase["Stop"] = 1] = "Stop";
|
5596 | })(Phase || (Phase = {}));
|
5597 |
|
5598 | const opIdToMeasurementPhaseMappingArray = ['constructor', 'render', 'patch', 'connectedCallback', 'renderedCallback', 'disconnectedCallback', 'errorCallback'];
|
5599 | let profilerEnabled = false;
|
5600 | let logMarks = false;
|
5601 | let bufferLogging = false;
|
5602 |
|
5603 | if (process.env.NODE_ENV !== 'production') {
|
5604 | profilerEnabled = true;
|
5605 | logMarks = true;
|
5606 | bufferLogging = false;
|
5607 | }
|
5608 |
|
5609 | const profilerStateCallbacks = [];
|
5610 |
|
5611 | function trackProfilerState(callback) {
|
5612 | callback(profilerEnabled);
|
5613 | profilerStateCallbacks.push(callback);
|
5614 | }
|
5615 |
|
5616 | function logOperationStart(opId, vm) {
|
5617 | if (logMarks) {
|
5618 | startMeasure(opIdToMeasurementPhaseMappingArray[opId], vm);
|
5619 | }
|
5620 |
|
5621 | if (bufferLogging) {
|
5622 | logOperation(opId, Phase.Start, vm.tagName, vm.idx);
|
5623 | }
|
5624 | }
|
5625 |
|
5626 | function logOperationEnd(opId, vm) {
|
5627 | if (logMarks) {
|
5628 | endMeasure(opIdToMeasurementPhaseMappingArray[opId], vm);
|
5629 | }
|
5630 |
|
5631 | if (bufferLogging) {
|
5632 | logOperation(opId, Phase.Stop, vm.tagName, vm.idx);
|
5633 | }
|
5634 | }
|
5635 |
|
5636 | function enableProfiler() {
|
5637 | profilerEnabled = true;
|
5638 | bufferLogging = true;
|
5639 | notifyProfilerStateChange();
|
5640 | }
|
5641 |
|
5642 | function disableProfiler() {
|
5643 | if (process.env.NODE_ENV !== 'production') {
|
5644 |
|
5645 | profilerEnabled = true;
|
5646 | logMarks = true;
|
5647 | bufferLogging = false;
|
5648 | } else {
|
5649 | profilerEnabled = false;
|
5650 | bufferLogging = false;
|
5651 | logMarks = false;
|
5652 | }
|
5653 |
|
5654 | notifyProfilerStateChange();
|
5655 | }
|
5656 |
|
5657 | function notifyProfilerStateChange() {
|
5658 | for (let i = 0; i < profilerStateCallbacks.length; i++) {
|
5659 | profilerStateCallbacks[i](profilerEnabled);
|
5660 | }
|
5661 | }
|
5662 |
|
5663 | function attachDispatcher(dispatcher) {
|
5664 | logOperation = dispatcher;
|
5665 | bufferLogging = true;
|
5666 | }
|
5667 |
|
5668 | function detachDispatcher() {
|
5669 | const currentLogOperation = logOperation;
|
5670 | logOperation = noop$2;
|
5671 | bufferLogging = false;
|
5672 | return currentLogOperation;
|
5673 | }
|
5674 |
|
5675 | const profilerControl = {
|
5676 | enableProfiler,
|
5677 | disableProfiler,
|
5678 | attachDispatcher,
|
5679 | detachDispatcher
|
5680 | };
|
5681 |
|
5682 |
|
5683 |
|
5684 |
|
5685 |
|
5686 |
|
5687 |
|
5688 | let isUpdatingTemplate = false;
|
5689 | let vmBeingRendered = null;
|
5690 | function getVMBeingRendered() {
|
5691 | return vmBeingRendered;
|
5692 | }
|
5693 | function setVMBeingRendered(vm) {
|
5694 | vmBeingRendered = vm;
|
5695 | }
|
5696 | let profilerEnabled$1 = false;
|
5697 | trackProfilerState(t => profilerEnabled$1 = t);
|
5698 |
|
5699 | function validateSlots(vm, html) {
|
5700 | if (process.env.NODE_ENV === 'production') {
|
5701 |
|
5702 | throw new ReferenceError();
|
5703 | }
|
5704 |
|
5705 | const {
|
5706 | cmpSlots
|
5707 | } = vm;
|
5708 | const {
|
5709 | slots = EmptyArray
|
5710 | } = html;
|
5711 |
|
5712 | for (const slotName in cmpSlots) {
|
5713 |
|
5714 | assert$1.isTrue(isArray$2(cmpSlots[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots[slotName])} for slot "${slotName}" in ${vm}.`);
|
5715 |
|
5716 | if (slotName !== '' && ArrayIndexOf$1.call(slots, slotName) === -1) {
|
5717 |
|
5718 |
|
5719 | logError(`Ignoring unknown provided slot name "${slotName}" in ${vm}. Check for a typo on the slot attribute.`, vm);
|
5720 | }
|
5721 | }
|
5722 | }
|
5723 |
|
5724 | function evaluateTemplate(vm, html) {
|
5725 | if (process.env.NODE_ENV !== 'production') {
|
5726 | assert$1.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
|
5727 | }
|
5728 |
|
5729 | const isUpdatingTemplateInception = isUpdatingTemplate;
|
5730 | const vmOfTemplateBeingUpdatedInception = vmBeingRendered;
|
5731 | let vnodes = [];
|
5732 | runWithBoundaryProtection(vm, vm.owner, () => {
|
5733 |
|
5734 | vmBeingRendered = vm;
|
5735 |
|
5736 | if (profilerEnabled$1) {
|
5737 | logOperationStart(OperationId.render, vm);
|
5738 | }
|
5739 | }, () => {
|
5740 |
|
5741 | const {
|
5742 | component,
|
5743 | context,
|
5744 | cmpSlots,
|
5745 | cmpTemplate,
|
5746 | tro,
|
5747 | renderer
|
5748 | } = vm;
|
5749 | tro.observe(() => {
|
5750 |
|
5751 | if (html !== cmpTemplate) {
|
5752 |
|
5753 |
|
5754 | if (!isNull$1(cmpTemplate)) {
|
5755 |
|
5756 |
|
5757 |
|
5758 | resetShadowRoot(vm);
|
5759 | }
|
5760 |
|
5761 |
|
5762 | if (!isTemplateRegistered(html)) {
|
5763 | throw new TypeError(`Invalid template returned by the render() method on ${vm}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
|
5764 | }
|
5765 |
|
5766 | vm.cmpTemplate = html;
|
5767 |
|
5768 | context.tplCache = create$1(null);
|
5769 |
|
5770 | if (renderer.syntheticShadow) {
|
5771 | updateSyntheticShadowAttributes(vm, html);
|
5772 | }
|
5773 |
|
5774 |
|
5775 |
|
5776 | const stylesheetsContent = getStylesheetsContent(vm, html);
|
5777 | context.styleVNode = stylesheetsContent.length === 0 ? null : createStylesheet(vm, stylesheetsContent);
|
5778 | }
|
5779 |
|
5780 | if (process.env.NODE_ENV !== 'production') {
|
5781 |
|
5782 | validateSlots(vm, html);
|
5783 | }
|
5784 |
|
5785 |
|
5786 |
|
5787 | vm.velements = [];
|
5788 |
|
5789 | isUpdatingTemplate = true;
|
5790 | vnodes = html.call(undefined, api$1, component, cmpSlots, context.tplCache);
|
5791 | const {
|
5792 | styleVNode
|
5793 | } = context;
|
5794 |
|
5795 | if (!isNull$1(styleVNode)) {
|
5796 | ArrayUnshift$2.call(vnodes, styleVNode);
|
5797 | }
|
5798 | });
|
5799 | }, () => {
|
5800 |
|
5801 | isUpdatingTemplate = isUpdatingTemplateInception;
|
5802 | vmBeingRendered = vmOfTemplateBeingUpdatedInception;
|
5803 |
|
5804 | if (profilerEnabled$1) {
|
5805 | logOperationEnd(OperationId.render, vm);
|
5806 | }
|
5807 | });
|
5808 |
|
5809 | if (process.env.NODE_ENV !== 'production') {
|
5810 | assert$1.invariant(isArray$2(vnodes), `Compiler should produce html functions that always return an array.`);
|
5811 | }
|
5812 |
|
5813 | return vnodes;
|
5814 | }
|
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 | function addErrorComponentStack(vm, error) {
|
5823 | if (!isFrozen$1(error) && isUndefined$1(error.wcStack)) {
|
5824 | const wcStack = getErrorComponentStack(vm);
|
5825 | defineProperty$1(error, 'wcStack', {
|
5826 | get() {
|
5827 | return wcStack;
|
5828 | }
|
5829 |
|
5830 | });
|
5831 | }
|
5832 | }
|
5833 |
|
5834 |
|
5835 |
|
5836 |
|
5837 |
|
5838 |
|
5839 |
|
5840 | let isInvokingRender = false;
|
5841 | let vmBeingConstructed = null;
|
5842 | function isBeingConstructed(vm) {
|
5843 | return vmBeingConstructed === vm;
|
5844 | }
|
5845 | let profilerEnabled$2 = false;
|
5846 | trackProfilerState(t => profilerEnabled$2 = t);
|
5847 |
|
5848 | const noop$3 = () => void 0;
|
5849 |
|
5850 | function invokeComponentCallback(vm, fn, args) {
|
5851 | const {
|
5852 | component,
|
5853 | callHook,
|
5854 | owner
|
5855 | } = vm;
|
5856 | let result;
|
5857 | runWithBoundaryProtection(vm, owner, noop$3, () => {
|
5858 |
|
5859 | result = callHook(component, fn, args);
|
5860 | }, noop$3);
|
5861 | return result;
|
5862 | }
|
5863 | function invokeComponentConstructor(vm, Ctor) {
|
5864 | const vmBeingConstructedInception = vmBeingConstructed;
|
5865 | let error;
|
5866 |
|
5867 | if (profilerEnabled$2) {
|
5868 | logOperationStart(OperationId.constructor, vm);
|
5869 | }
|
5870 |
|
5871 | vmBeingConstructed = vm;
|
5872 | |
5873 |
|
5874 |
|
5875 |
|
5876 |
|
5877 |
|
5878 | try {
|
5879 |
|
5880 | const result = new Ctor();
|
5881 |
|
5882 |
|
5883 |
|
5884 |
|
5885 | if (vmBeingConstructed.component !== result) {
|
5886 | throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
|
5887 | }
|
5888 | } catch (e) {
|
5889 | error = Object(e);
|
5890 | } finally {
|
5891 | if (profilerEnabled$2) {
|
5892 | logOperationEnd(OperationId.constructor, vm);
|
5893 | }
|
5894 |
|
5895 | vmBeingConstructed = vmBeingConstructedInception;
|
5896 |
|
5897 | if (!isUndefined$1(error)) {
|
5898 | addErrorComponentStack(vm, error);
|
5899 |
|
5900 | throw error;
|
5901 | }
|
5902 | }
|
5903 | }
|
5904 | function invokeComponentRenderMethod(vm) {
|
5905 | const {
|
5906 | def: {
|
5907 | render
|
5908 | },
|
5909 | callHook,
|
5910 | component,
|
5911 | owner
|
5912 | } = vm;
|
5913 | const isRenderBeingInvokedInception = isInvokingRender;
|
5914 | const vmBeingRenderedInception = getVMBeingRendered();
|
5915 | let html;
|
5916 | let renderInvocationSuccessful = false;
|
5917 | runWithBoundaryProtection(vm, owner, () => {
|
5918 |
|
5919 | isInvokingRender = true;
|
5920 | setVMBeingRendered(vm);
|
5921 | }, () => {
|
5922 |
|
5923 | vm.tro.observe(() => {
|
5924 | html = callHook(component, render);
|
5925 | renderInvocationSuccessful = true;
|
5926 | });
|
5927 | }, () => {
|
5928 |
|
5929 | isInvokingRender = isRenderBeingInvokedInception;
|
5930 | setVMBeingRendered(vmBeingRenderedInception);
|
5931 | });
|
5932 |
|
5933 | return renderInvocationSuccessful ? evaluateTemplate(vm, html) : [];
|
5934 | }
|
5935 | function invokeComponentRenderedCallback(vm) {
|
5936 | const {
|
5937 | def: {
|
5938 | renderedCallback
|
5939 | },
|
5940 | component,
|
5941 | callHook,
|
5942 | owner
|
5943 | } = vm;
|
5944 |
|
5945 | if (!isUndefined$1(renderedCallback)) {
|
5946 | runWithBoundaryProtection(vm, owner, () => {
|
5947 |
|
5948 | if (profilerEnabled$2) {
|
5949 | logOperationStart(OperationId.renderedCallback, vm);
|
5950 | }
|
5951 | }, () => {
|
5952 |
|
5953 | callHook(component, renderedCallback);
|
5954 | }, () => {
|
5955 |
|
5956 | if (profilerEnabled$2) {
|
5957 | logOperationEnd(OperationId.renderedCallback, vm);
|
5958 | }
|
5959 | });
|
5960 | }
|
5961 | }
|
5962 | function invokeEventListener(vm, fn, thisValue, event) {
|
5963 | const {
|
5964 | callHook,
|
5965 | owner
|
5966 | } = vm;
|
5967 | runWithBoundaryProtection(vm, owner, noop$3, () => {
|
5968 |
|
5969 | if (process.env.NODE_ENV !== 'production') {
|
5970 | assert$1.isTrue(isFunction$1(fn), `Invalid event handler for event '${event.type}' on ${vm}.`);
|
5971 | }
|
5972 |
|
5973 | callHook(thisValue, fn, [event]);
|
5974 | }, noop$3);
|
5975 | }
|
5976 |
|
5977 |
|
5978 |
|
5979 |
|
5980 |
|
5981 |
|
5982 |
|
5983 | const signedTemplateMap = new Map();
|
5984 |
|
5985 |
|
5986 |
|
5987 |
|
5988 |
|
5989 | function registerComponent(Ctor, {
|
5990 | tmpl
|
5991 | }) {
|
5992 | signedTemplateMap.set(Ctor, tmpl);
|
5993 |
|
5994 |
|
5995 | return Ctor;
|
5996 | }
|
5997 | function getComponentRegisteredTemplate(Ctor) {
|
5998 | return signedTemplateMap.get(Ctor);
|
5999 | }
|
6000 | function createComponent(vm, Ctor) {
|
6001 |
|
6002 | invokeComponentConstructor(vm, Ctor);
|
6003 |
|
6004 | if (isUndefined$1(vm.component)) {
|
6005 | throw new ReferenceError(`Invalid construction for ${Ctor}, you must extend LightningElement.`);
|
6006 | }
|
6007 | }
|
6008 | function getTemplateReactiveObserver(vm) {
|
6009 | return new ReactiveObserver(() => {
|
6010 | const {
|
6011 | isDirty
|
6012 | } = vm;
|
6013 |
|
6014 | if (isFalse$1$1(isDirty)) {
|
6015 | markComponentAsDirty(vm);
|
6016 | scheduleRehydration(vm);
|
6017 | }
|
6018 | });
|
6019 | }
|
6020 | function renderComponent(vm) {
|
6021 | if (process.env.NODE_ENV !== 'production') {
|
6022 | assert$1.invariant(vm.isDirty, `${vm} is not dirty.`);
|
6023 | }
|
6024 |
|
6025 | vm.tro.reset();
|
6026 | const vnodes = invokeComponentRenderMethod(vm);
|
6027 | vm.isDirty = false;
|
6028 | vm.isScheduled = false;
|
6029 |
|
6030 | if (process.env.NODE_ENV !== 'production') {
|
6031 | assert$1.invariant(isArray$2(vnodes), `${vm}.render() should always return an array of vnodes instead of ${vnodes}`);
|
6032 | }
|
6033 |
|
6034 | return vnodes;
|
6035 | }
|
6036 | function markComponentAsDirty(vm) {
|
6037 | if (process.env.NODE_ENV !== 'production') {
|
6038 | const vmBeingRendered = getVMBeingRendered();
|
6039 | assert$1.isFalse(vm.isDirty, `markComponentAsDirty() for ${vm} should not be called when the component is already dirty.`);
|
6040 | assert$1.isFalse(isInvokingRender, `markComponentAsDirty() for ${vm} cannot be called during rendering of ${vmBeingRendered}.`);
|
6041 | assert$1.isFalse(isUpdatingTemplate, `markComponentAsDirty() for ${vm} cannot be called while updating template of ${vmBeingRendered}.`);
|
6042 | }
|
6043 |
|
6044 | vm.isDirty = true;
|
6045 | }
|
6046 | const cmpEventListenerMap = new WeakMap();
|
6047 | function getWrappedComponentsListener(vm, listener) {
|
6048 | if (!isFunction$1(listener)) {
|
6049 | throw new TypeError();
|
6050 | }
|
6051 |
|
6052 | let wrappedListener = cmpEventListenerMap.get(listener);
|
6053 |
|
6054 | if (isUndefined$1(wrappedListener)) {
|
6055 | wrappedListener = function (event) {
|
6056 | invokeEventListener(vm, listener, undefined, event);
|
6057 | };
|
6058 |
|
6059 | cmpEventListenerMap.set(listener, wrappedListener);
|
6060 | }
|
6061 |
|
6062 | return wrappedListener;
|
6063 | }
|
6064 |
|
6065 |
|
6066 |
|
6067 |
|
6068 |
|
6069 |
|
6070 |
|
6071 | const Services = create$1(null);
|
6072 | const hooks = ['rendered', 'connected', 'disconnected'];
|
6073 |
|
6074 |
|
6075 |
|
6076 |
|
6077 |
|
6078 |
|
6079 | function register(service) {
|
6080 | if (process.env.NODE_ENV !== 'production') {
|
6081 | assert$1.isTrue(isObject$2(service), `Invalid service declaration, ${service}: service must be an object`);
|
6082 | }
|
6083 |
|
6084 | for (let i = 0; i < hooks.length; ++i) {
|
6085 | const hookName = hooks[i];
|
6086 |
|
6087 | if (hookName in service) {
|
6088 | let l = Services[hookName];
|
6089 |
|
6090 | if (isUndefined$1(l)) {
|
6091 | Services[hookName] = l = [];
|
6092 | }
|
6093 |
|
6094 | ArrayPush$1.call(l, service[hookName]);
|
6095 | }
|
6096 | }
|
6097 | }
|
6098 | function invokeServiceHook(vm, cbs) {
|
6099 | if (process.env.NODE_ENV !== 'production') {
|
6100 | assert$1.isTrue(isArray$2(cbs) && cbs.length > 0, `Optimize invokeServiceHook() to be invoked only when needed`);
|
6101 | }
|
6102 |
|
6103 | const {
|
6104 | component,
|
6105 | def,
|
6106 | context
|
6107 | } = vm;
|
6108 |
|
6109 | for (let i = 0, len = cbs.length; i < len; ++i) {
|
6110 | cbs[i].call(undefined, component, {}, def, context);
|
6111 | }
|
6112 | }
|
6113 |
|
6114 |
|
6115 |
|
6116 |
|
6117 |
|
6118 |
|
6119 |
|
6120 | var VMState;
|
6121 |
|
6122 | (function (VMState) {
|
6123 | VMState[VMState["created"] = 0] = "created";
|
6124 | VMState[VMState["connected"] = 1] = "connected";
|
6125 | VMState[VMState["disconnected"] = 2] = "disconnected";
|
6126 | })(VMState || (VMState = {}));
|
6127 |
|
6128 | let profilerEnabled$3 = false;
|
6129 | trackProfilerState(t => profilerEnabled$3 = t);
|
6130 | let idx = 0;
|
6131 |
|
6132 |
|
6133 | const ViewModelReflection = createHiddenField$1('ViewModel', 'engine');
|
6134 |
|
6135 | function callHook(cmp, fn, args = []) {
|
6136 | return fn.apply(cmp, args);
|
6137 | }
|
6138 |
|
6139 | function setHook(cmp, prop, newValue) {
|
6140 | cmp[prop] = newValue;
|
6141 | }
|
6142 |
|
6143 | function getHook(cmp, prop) {
|
6144 | return cmp[prop];
|
6145 | }
|
6146 |
|
6147 | function rerenderVM(vm) {
|
6148 | rehydrate(vm);
|
6149 | }
|
6150 | function connectRootElement(elm) {
|
6151 | const vm = getAssociatedVM(elm);
|
6152 | startGlobalMeasure(GlobalMeasurementPhase.HYDRATE, vm);
|
6153 |
|
6154 |
|
6155 | if (vm.state === VMState.connected) {
|
6156 | disconnectRootElement(elm);
|
6157 | }
|
6158 |
|
6159 | runConnectedCallback(vm);
|
6160 | rehydrate(vm);
|
6161 | endGlobalMeasure(GlobalMeasurementPhase.HYDRATE, vm);
|
6162 | }
|
6163 | function disconnectRootElement(elm) {
|
6164 | const vm = getAssociatedVM(elm);
|
6165 | resetComponentStateWhenRemoved(vm);
|
6166 | }
|
6167 | function appendVM(vm) {
|
6168 | rehydrate(vm);
|
6169 | }
|
6170 |
|
6171 |
|
6172 | function resetComponentStateWhenRemoved(vm) {
|
6173 | const {
|
6174 | state
|
6175 | } = vm;
|
6176 |
|
6177 | if (state !== VMState.disconnected) {
|
6178 | const {
|
6179 | oar,
|
6180 | tro
|
6181 | } = vm;
|
6182 |
|
6183 | tro.reset();
|
6184 |
|
6185 | for (const key in oar) {
|
6186 | oar[key].reset();
|
6187 | }
|
6188 |
|
6189 | runDisconnectedCallback(vm);
|
6190 |
|
6191 | runShadowChildNodesDisconnectedCallback(vm);
|
6192 | runLightChildNodesDisconnectedCallback(vm);
|
6193 | }
|
6194 | }
|
6195 |
|
6196 |
|
6197 |
|
6198 | function removeVM(vm) {
|
6199 | if (process.env.NODE_ENV !== 'production') {
|
6200 | assert$1.isTrue(vm.state === VMState.connected || vm.state === VMState.disconnected, `${vm} must have been connected.`);
|
6201 | }
|
6202 |
|
6203 | resetComponentStateWhenRemoved(vm);
|
6204 | }
|
6205 | function createVM(elm, def, options) {
|
6206 | const {
|
6207 | mode,
|
6208 | owner,
|
6209 | renderer,
|
6210 | tagName
|
6211 | } = options;
|
6212 | const vm = {
|
6213 | elm,
|
6214 | def,
|
6215 | idx: idx++,
|
6216 | state: VMState.created,
|
6217 | isScheduled: false,
|
6218 | isDirty: true,
|
6219 | tagName,
|
6220 | mode,
|
6221 | owner,
|
6222 | renderer,
|
6223 | children: EmptyArray,
|
6224 | aChildren: EmptyArray,
|
6225 | velements: EmptyArray,
|
6226 | cmpProps: create$1(null),
|
6227 | cmpFields: create$1(null),
|
6228 | cmpSlots: create$1(null),
|
6229 | oar: create$1(null),
|
6230 | cmpTemplate: null,
|
6231 | context: {
|
6232 | hostAttribute: undefined,
|
6233 | shadowAttribute: undefined,
|
6234 | styleVNode: null,
|
6235 | tplCache: EmptyObject,
|
6236 | wiredConnecting: EmptyArray,
|
6237 | wiredDisconnecting: EmptyArray
|
6238 | },
|
6239 | tro: null,
|
6240 | component: null,
|
6241 | cmpRoot: null,
|
6242 | callHook,
|
6243 | setHook,
|
6244 | getHook
|
6245 | };
|
6246 | vm.tro = getTemplateReactiveObserver(vm);
|
6247 |
|
6248 | if (process.env.NODE_ENV !== 'production') {
|
6249 | vm.toString = () => {
|
6250 | return `[object:vm ${def.name} (${vm.idx})]`;
|
6251 | };
|
6252 | }
|
6253 |
|
6254 |
|
6255 | createComponent(vm, def.ctor);
|
6256 |
|
6257 | if (isFalse$1$1(renderer.ssr) && hasWireAdapters(vm)) {
|
6258 | installWireAdapters(vm);
|
6259 | }
|
6260 |
|
6261 | return vm;
|
6262 | }
|
6263 |
|
6264 | function assertIsVM(obj) {
|
6265 | if (isNull$1(obj) || !isObject$2(obj) || !('cmpRoot' in obj)) {
|
6266 | throw new TypeError(`${obj} is not a VM.`);
|
6267 | }
|
6268 | }
|
6269 |
|
6270 | function associateVM(obj, vm) {
|
6271 | setHiddenField$1(obj, ViewModelReflection, vm);
|
6272 | }
|
6273 | function getAssociatedVM(obj) {
|
6274 | const vm = getHiddenField$1(obj, ViewModelReflection);
|
6275 |
|
6276 | if (process.env.NODE_ENV !== 'production') {
|
6277 | assertIsVM(vm);
|
6278 | }
|
6279 |
|
6280 | return vm;
|
6281 | }
|
6282 | function getAssociatedVMIfPresent(obj) {
|
6283 | const maybeVm = getHiddenField$1(obj, ViewModelReflection);
|
6284 |
|
6285 | if (process.env.NODE_ENV !== 'production') {
|
6286 | if (!isUndefined$1(maybeVm)) {
|
6287 | assertIsVM(maybeVm);
|
6288 | }
|
6289 | }
|
6290 |
|
6291 | return maybeVm;
|
6292 | }
|
6293 |
|
6294 | function rehydrate(vm) {
|
6295 | if (isTrue$1$1(vm.isDirty)) {
|
6296 | const children = renderComponent(vm);
|
6297 | patchShadowRoot(vm, children);
|
6298 | }
|
6299 | }
|
6300 |
|
6301 | function patchShadowRoot(vm, newCh) {
|
6302 | const {
|
6303 | cmpRoot,
|
6304 | children: oldCh
|
6305 | } = vm;
|
6306 |
|
6307 | vm.children = newCh;
|
6308 |
|
6309 | if (newCh.length > 0 || oldCh.length > 0) {
|
6310 |
|
6311 |
|
6312 | if (oldCh !== newCh) {
|
6313 | const fn = hasDynamicChildren(newCh) ? updateDynamicChildren : updateStaticChildren;
|
6314 | runWithBoundaryProtection(vm, vm, () => {
|
6315 |
|
6316 | if (profilerEnabled$3) {
|
6317 | logOperationStart(OperationId.patch, vm);
|
6318 | }
|
6319 | }, () => {
|
6320 |
|
6321 | fn(cmpRoot, oldCh, newCh);
|
6322 | }, () => {
|
6323 |
|
6324 | if (profilerEnabled$3) {
|
6325 | logOperationEnd(OperationId.patch, vm);
|
6326 | }
|
6327 | });
|
6328 | }
|
6329 | }
|
6330 |
|
6331 | if (vm.state === VMState.connected) {
|
6332 |
|
6333 |
|
6334 |
|
6335 |
|
6336 | runRenderedCallback(vm);
|
6337 | }
|
6338 | }
|
6339 |
|
6340 | function runRenderedCallback(vm) {
|
6341 | if (isTrue$1$1(vm.renderer.ssr)) {
|
6342 | return;
|
6343 | }
|
6344 |
|
6345 | const {
|
6346 | rendered
|
6347 | } = Services;
|
6348 |
|
6349 | if (rendered) {
|
6350 | invokeServiceHook(vm, rendered);
|
6351 | }
|
6352 |
|
6353 | invokeComponentRenderedCallback(vm);
|
6354 | }
|
6355 |
|
6356 | let rehydrateQueue = [];
|
6357 |
|
6358 | function flushRehydrationQueue() {
|
6359 | startGlobalMeasure(GlobalMeasurementPhase.REHYDRATE);
|
6360 |
|
6361 | if (process.env.NODE_ENV !== 'production') {
|
6362 | assert$1.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
|
6363 | }
|
6364 |
|
6365 | const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
|
6366 | rehydrateQueue = [];
|
6367 |
|
6368 | for (let i = 0, len = vms.length; i < len; i += 1) {
|
6369 | const vm = vms[i];
|
6370 |
|
6371 | try {
|
6372 | rehydrate(vm);
|
6373 | } catch (error) {
|
6374 | if (i + 1 < len) {
|
6375 |
|
6376 | if (rehydrateQueue.length === 0) {
|
6377 | addCallbackToNextTick(flushRehydrationQueue);
|
6378 | }
|
6379 |
|
6380 | ArrayUnshift$2.apply(rehydrateQueue, ArraySlice$2.call(vms, i + 1));
|
6381 | }
|
6382 |
|
6383 |
|
6384 | endGlobalMeasure(GlobalMeasurementPhase.REHYDRATE);
|
6385 |
|
6386 |
|
6387 | throw error;
|
6388 | }
|
6389 | }
|
6390 |
|
6391 | endGlobalMeasure(GlobalMeasurementPhase.REHYDRATE);
|
6392 | }
|
6393 |
|
6394 | function runConnectedCallback(vm) {
|
6395 | const {
|
6396 | state
|
6397 | } = vm;
|
6398 |
|
6399 | if (state === VMState.connected) {
|
6400 | return;
|
6401 | }
|
6402 |
|
6403 | vm.state = VMState.connected;
|
6404 |
|
6405 | const {
|
6406 | connected
|
6407 | } = Services;
|
6408 |
|
6409 | if (connected) {
|
6410 | invokeServiceHook(vm, connected);
|
6411 | }
|
6412 |
|
6413 | if (hasWireAdapters(vm)) {
|
6414 | connectWireAdapters(vm);
|
6415 | }
|
6416 |
|
6417 | const {
|
6418 | connectedCallback
|
6419 | } = vm.def;
|
6420 |
|
6421 | if (!isUndefined$1(connectedCallback)) {
|
6422 | if (profilerEnabled$3) {
|
6423 | logOperationStart(OperationId.connectedCallback, vm);
|
6424 | }
|
6425 |
|
6426 | invokeComponentCallback(vm, connectedCallback);
|
6427 |
|
6428 | if (profilerEnabled$3) {
|
6429 | logOperationEnd(OperationId.connectedCallback, vm);
|
6430 | }
|
6431 | }
|
6432 | }
|
6433 |
|
6434 | function hasWireAdapters(vm) {
|
6435 | return getOwnPropertyNames$1(vm.def.wire).length > 0;
|
6436 | }
|
6437 |
|
6438 | function runDisconnectedCallback(vm) {
|
6439 | if (process.env.NODE_ENV !== 'production') {
|
6440 | assert$1.isTrue(vm.state !== VMState.disconnected, `${vm} must be inserted.`);
|
6441 | }
|
6442 |
|
6443 | if (isFalse$1$1(vm.isDirty)) {
|
6444 |
|
6445 |
|
6446 |
|
6447 |
|
6448 | vm.isDirty = true;
|
6449 | }
|
6450 |
|
6451 | vm.state = VMState.disconnected;
|
6452 |
|
6453 | const {
|
6454 | disconnected
|
6455 | } = Services;
|
6456 |
|
6457 | if (disconnected) {
|
6458 | invokeServiceHook(vm, disconnected);
|
6459 | }
|
6460 |
|
6461 | if (hasWireAdapters(vm)) {
|
6462 | disconnectWireAdapters(vm);
|
6463 | }
|
6464 |
|
6465 | const {
|
6466 | disconnectedCallback
|
6467 | } = vm.def;
|
6468 |
|
6469 | if (!isUndefined$1(disconnectedCallback)) {
|
6470 | if (profilerEnabled$3) {
|
6471 | logOperationStart(OperationId.disconnectedCallback, vm);
|
6472 | }
|
6473 |
|
6474 | invokeComponentCallback(vm, disconnectedCallback);
|
6475 |
|
6476 | if (profilerEnabled$3) {
|
6477 | logOperationEnd(OperationId.disconnectedCallback, vm);
|
6478 | }
|
6479 | }
|
6480 | }
|
6481 |
|
6482 | function runShadowChildNodesDisconnectedCallback(vm) {
|
6483 | const {
|
6484 | velements: vCustomElementCollection
|
6485 | } = vm;
|
6486 |
|
6487 |
|
6488 | for (let i = vCustomElementCollection.length - 1; i >= 0; i -= 1) {
|
6489 | const {
|
6490 | elm
|
6491 | } = vCustomElementCollection[i];
|
6492 |
|
6493 |
|
6494 |
|
6495 |
|
6496 |
|
6497 |
|
6498 |
|
6499 | if (!isUndefined$1(elm)) {
|
6500 | const childVM = getAssociatedVMIfPresent(elm);
|
6501 |
|
6502 |
|
6503 |
|
6504 | if (!isUndefined$1(childVM)) {
|
6505 | resetComponentStateWhenRemoved(childVM);
|
6506 | }
|
6507 | }
|
6508 | }
|
6509 | }
|
6510 |
|
6511 | function runLightChildNodesDisconnectedCallback(vm) {
|
6512 | const {
|
6513 | aChildren: adoptedChildren
|
6514 | } = vm;
|
6515 | recursivelyDisconnectChildren(adoptedChildren);
|
6516 | }
|
6517 |
|
6518 |
|
6519 |
|
6520 |
|
6521 |
|
6522 |
|
6523 |
|
6524 |
|
6525 |
|
6526 | function recursivelyDisconnectChildren(vnodes) {
|
6527 | for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
6528 | const vnode = vnodes[i];
|
6529 |
|
6530 | if (!isNull$1(vnode) && isArray$2(vnode.children) && !isUndefined$1(vnode.elm)) {
|
6531 |
|
6532 | if (isUndefined$1(vnode.ctor)) {
|
6533 |
|
6534 | recursivelyDisconnectChildren(vnode.children);
|
6535 | } else {
|
6536 |
|
6537 | resetComponentStateWhenRemoved(getAssociatedVM(vnode.elm));
|
6538 | }
|
6539 | }
|
6540 | }
|
6541 | }
|
6542 |
|
6543 |
|
6544 |
|
6545 |
|
6546 | function resetShadowRoot(vm) {
|
6547 | const {
|
6548 | children,
|
6549 | cmpRoot,
|
6550 | renderer
|
6551 | } = vm;
|
6552 |
|
6553 | for (let i = 0, len = children.length; i < len; i++) {
|
6554 | const child = children[i];
|
6555 |
|
6556 | if (!isNull$1(child) && !isUndefined$1(child.elm)) {
|
6557 | renderer.remove(child.elm, cmpRoot);
|
6558 | }
|
6559 | }
|
6560 |
|
6561 | vm.children = EmptyArray;
|
6562 | runShadowChildNodesDisconnectedCallback(vm);
|
6563 | vm.velements = EmptyArray;
|
6564 | }
|
6565 | function scheduleRehydration(vm) {
|
6566 | if (isTrue$1$1(vm.renderer.ssr) || isTrue$1$1(vm.isScheduled)) {
|
6567 | return;
|
6568 | }
|
6569 |
|
6570 | vm.isScheduled = true;
|
6571 |
|
6572 | if (rehydrateQueue.length === 0) {
|
6573 | addCallbackToNextTick(flushRehydrationQueue);
|
6574 | }
|
6575 |
|
6576 | ArrayPush$1.call(rehydrateQueue, vm);
|
6577 | }
|
6578 |
|
6579 | function getErrorBoundaryVM(vm) {
|
6580 | let currentVm = vm;
|
6581 |
|
6582 | while (!isNull$1(currentVm)) {
|
6583 | if (!isUndefined$1(currentVm.def.errorCallback)) {
|
6584 | return currentVm;
|
6585 | }
|
6586 |
|
6587 | currentVm = currentVm.owner;
|
6588 | }
|
6589 | }
|
6590 |
|
6591 |
|
6592 |
|
6593 |
|
6594 | function allocateInSlot(vm, children) {
|
6595 | if (process.env.NODE_ENV !== 'production') {
|
6596 | assert$1.invariant(isObject$2(vm.cmpSlots), `When doing manual allocation, there must be a cmpSlots object available.`);
|
6597 | }
|
6598 |
|
6599 | const {
|
6600 | cmpSlots: oldSlots
|
6601 | } = vm;
|
6602 | const cmpSlots = vm.cmpSlots = create$1(null);
|
6603 |
|
6604 | for (let i = 0, len = children.length; i < len; i += 1) {
|
6605 | const vnode = children[i];
|
6606 |
|
6607 | if (isNull$1(vnode)) {
|
6608 | continue;
|
6609 | }
|
6610 |
|
6611 | const {
|
6612 | data
|
6613 | } = vnode;
|
6614 | const slotName = data.attrs && data.attrs.slot || '';
|
6615 | const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
6616 |
|
6617 |
|
6618 |
|
6619 |
|
6620 | if (!isUndefined$1(vnode.key)) {
|
6621 | vnode.key = `@${slotName}:${vnode.key}`;
|
6622 | }
|
6623 |
|
6624 | ArrayPush$1.call(vnodes, vnode);
|
6625 | }
|
6626 |
|
6627 | if (isFalse$1$1(vm.isDirty)) {
|
6628 |
|
6629 |
|
6630 | const oldKeys = keys$1(oldSlots);
|
6631 |
|
6632 | if (oldKeys.length !== keys$1(cmpSlots).length) {
|
6633 | markComponentAsDirty(vm);
|
6634 | return;
|
6635 | }
|
6636 |
|
6637 | for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
6638 | const key = oldKeys[i];
|
6639 |
|
6640 | if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
6641 | markComponentAsDirty(vm);
|
6642 | return;
|
6643 | }
|
6644 |
|
6645 | const oldVNodes = oldSlots[key];
|
6646 | const vnodes = cmpSlots[key];
|
6647 |
|
6648 | for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
6649 | if (oldVNodes[j] !== vnodes[j]) {
|
6650 | markComponentAsDirty(vm);
|
6651 | return;
|
6652 | }
|
6653 | }
|
6654 | }
|
6655 | }
|
6656 | }
|
6657 | function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
6658 | let error;
|
6659 | pre();
|
6660 |
|
6661 | try {
|
6662 | job();
|
6663 | } catch (e) {
|
6664 | error = Object(e);
|
6665 | } finally {
|
6666 | post();
|
6667 |
|
6668 | if (!isUndefined$1(error)) {
|
6669 | addErrorComponentStack(vm, error);
|
6670 | const errorBoundaryVm = isNull$1(owner) ? undefined : getErrorBoundaryVM(owner);
|
6671 |
|
6672 | if (isUndefined$1(errorBoundaryVm)) {
|
6673 | throw error;
|
6674 | }
|
6675 |
|
6676 | resetShadowRoot(vm);
|
6677 |
|
6678 | if (profilerEnabled$3) {
|
6679 | logOperationStart(OperationId.errorCallback, vm);
|
6680 | }
|
6681 |
|
6682 |
|
6683 | const errorCallback = errorBoundaryVm.def.errorCallback;
|
6684 | invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
6685 |
|
6686 | if (profilerEnabled$3) {
|
6687 | logOperationEnd(OperationId.errorCallback, vm);
|
6688 | }
|
6689 | }
|
6690 | }
|
6691 | }
|
6692 |
|
6693 |
|
6694 |
|
6695 |
|
6696 |
|
6697 |
|
6698 |
|
6699 | const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
6700 | const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
6701 | const WireMetaMap = new Map();
|
6702 |
|
6703 | function noop$4() {}
|
6704 |
|
6705 | class WireContextRegistrationEvent extends CustomEvent {
|
6706 | constructor(adapterToken, {
|
6707 | setNewContext,
|
6708 | setDisconnectedCallback
|
6709 | }) {
|
6710 | super(adapterToken, {
|
6711 | bubbles: true,
|
6712 | composed: true
|
6713 | });
|
6714 | defineProperties$1(this, {
|
6715 | setNewContext: {
|
6716 | value: setNewContext
|
6717 | },
|
6718 | setDisconnectedCallback: {
|
6719 | value: setDisconnectedCallback
|
6720 | }
|
6721 | });
|
6722 | }
|
6723 |
|
6724 | }
|
6725 |
|
6726 | function createFieldDataCallback(vm, name) {
|
6727 | const {
|
6728 | cmpFields
|
6729 | } = vm;
|
6730 | return value => {
|
6731 | if (value !== vm.cmpFields[name]) {
|
6732 |
|
6733 | cmpFields[name] = value;
|
6734 | componentValueMutated(vm, name);
|
6735 | }
|
6736 | };
|
6737 | }
|
6738 |
|
6739 | function createMethodDataCallback(vm, method) {
|
6740 | return value => {
|
6741 |
|
6742 | runWithBoundaryProtection(vm, vm.owner, noop$4, () => {
|
6743 |
|
6744 | method.call(vm.component, value);
|
6745 | }, noop$4);
|
6746 | };
|
6747 | }
|
6748 |
|
6749 | function createConfigWatcher(vm, wireDef, callbackWhenConfigIsReady) {
|
6750 | const {
|
6751 | component
|
6752 | } = vm;
|
6753 | const {
|
6754 | configCallback
|
6755 | } = wireDef;
|
6756 | let hasPendingConfig = false;
|
6757 |
|
6758 | const ro = new ReactiveObserver(() => {
|
6759 | if (hasPendingConfig === false) {
|
6760 | hasPendingConfig = true;
|
6761 |
|
6762 | Promise.resolve().then(() => {
|
6763 | hasPendingConfig = false;
|
6764 |
|
6765 | ro.reset();
|
6766 |
|
6767 | callback();
|
6768 | });
|
6769 | }
|
6770 | });
|
6771 |
|
6772 | const callback = () => {
|
6773 | let config;
|
6774 | ro.observe(() => config = configCallback(component));
|
6775 |
|
6776 |
|
6777 |
|
6778 | callbackWhenConfigIsReady(config);
|
6779 | };
|
6780 |
|
6781 | return callback;
|
6782 | }
|
6783 |
|
6784 | function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
6785 | const {
|
6786 | adapter
|
6787 | } = wireDef;
|
6788 | const adapterContextToken = getAdapterToken(adapter);
|
6789 |
|
6790 | if (isUndefined$1(adapterContextToken)) {
|
6791 | return;
|
6792 | }
|
6793 |
|
6794 | const {
|
6795 | elm,
|
6796 | renderer,
|
6797 | context: {
|
6798 | wiredConnecting,
|
6799 | wiredDisconnecting
|
6800 | }
|
6801 | } = vm;
|
6802 |
|
6803 | ArrayPush$1.call(wiredConnecting, () => {
|
6804 |
|
6805 |
|
6806 |
|
6807 |
|
6808 |
|
6809 | const contextRegistrationEvent = new WireContextRegistrationEvent(adapterContextToken, {
|
6810 | setNewContext(newContext) {
|
6811 |
|
6812 |
|
6813 | callbackWhenContextIsReady(newContext);
|
6814 | },
|
6815 |
|
6816 | setDisconnectedCallback(disconnectCallback) {
|
6817 |
|
6818 |
|
6819 | ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
6820 | }
|
6821 |
|
6822 | });
|
6823 | renderer.dispatchEvent(elm, contextRegistrationEvent);
|
6824 | });
|
6825 | }
|
6826 |
|
6827 | function createConnector(vm, name, wireDef) {
|
6828 | const {
|
6829 | method,
|
6830 | adapter,
|
6831 | configCallback,
|
6832 | dynamic
|
6833 | } = wireDef;
|
6834 | const hasDynamicParams = dynamic.length > 0;
|
6835 | const {
|
6836 | component
|
6837 | } = vm;
|
6838 | const dataCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
6839 | let context;
|
6840 | let connector;
|
6841 |
|
6842 | defineProperty$1(dataCallback, DeprecatedWiredElementHost, {
|
6843 | value: vm.elm
|
6844 | });
|
6845 | defineProperty$1(dataCallback, DeprecatedWiredParamsMeta, {
|
6846 | value: dynamic
|
6847 | });
|
6848 | runWithBoundaryProtection(vm, vm, noop$4, () => {
|
6849 |
|
6850 | connector = new adapter(dataCallback);
|
6851 | }, noop$4);
|
6852 |
|
6853 | const updateConnectorConfig = config => {
|
6854 |
|
6855 |
|
6856 | runWithBoundaryProtection(vm, vm, noop$4, () => {
|
6857 |
|
6858 | connector.update(config, context);
|
6859 | }, noop$4);
|
6860 | };
|
6861 |
|
6862 |
|
6863 |
|
6864 |
|
6865 | let computeConfigAndUpdate = () => {
|
6866 | updateConnectorConfig(configCallback(component));
|
6867 | };
|
6868 |
|
6869 | if (hasDynamicParams) {
|
6870 |
|
6871 |
|
6872 | Promise.resolve().then(() => {
|
6873 | computeConfigAndUpdate = createConfigWatcher(vm, wireDef, updateConnectorConfig);
|
6874 | computeConfigAndUpdate();
|
6875 | });
|
6876 | } else {
|
6877 | computeConfigAndUpdate();
|
6878 | }
|
6879 |
|
6880 |
|
6881 | if (!isUndefined$1(adapter.contextSchema)) {
|
6882 | createContextWatcher(vm, wireDef, newContext => {
|
6883 |
|
6884 |
|
6885 | if (context !== newContext) {
|
6886 | context = newContext;
|
6887 |
|
6888 |
|
6889 |
|
6890 | computeConfigAndUpdate();
|
6891 | }
|
6892 | });
|
6893 | }
|
6894 |
|
6895 |
|
6896 | return connector;
|
6897 | }
|
6898 |
|
6899 | const AdapterToTokenMap = new Map();
|
6900 | function getAdapterToken(adapter) {
|
6901 | return AdapterToTokenMap.get(adapter);
|
6902 | }
|
6903 | function setAdapterToken(adapter, token) {
|
6904 | AdapterToTokenMap.set(adapter, token);
|
6905 | }
|
6906 | function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
6907 |
|
6908 | if (adapter.adapter) {
|
6909 | adapter = adapter.adapter;
|
6910 | }
|
6911 |
|
6912 | const method = descriptor.value;
|
6913 | const def = {
|
6914 | adapter,
|
6915 | method,
|
6916 | configCallback,
|
6917 | dynamic
|
6918 | };
|
6919 | WireMetaMap.set(descriptor, def);
|
6920 | }
|
6921 | function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
6922 |
|
6923 | if (adapter.adapter) {
|
6924 | adapter = adapter.adapter;
|
6925 | }
|
6926 |
|
6927 | const def = {
|
6928 | adapter,
|
6929 | configCallback,
|
6930 | dynamic
|
6931 | };
|
6932 | WireMetaMap.set(descriptor, def);
|
6933 | }
|
6934 | function installWireAdapters(vm) {
|
6935 | const {
|
6936 | context,
|
6937 | def: {
|
6938 | wire
|
6939 | }
|
6940 | } = vm;
|
6941 | const wiredConnecting = context.wiredConnecting = [];
|
6942 | const wiredDisconnecting = context.wiredDisconnecting = [];
|
6943 |
|
6944 | for (const fieldNameOrMethod in wire) {
|
6945 | const descriptor = wire[fieldNameOrMethod];
|
6946 | const wireDef = WireMetaMap.get(descriptor);
|
6947 |
|
6948 | if (process.env.NODE_ENV !== 'production') {
|
6949 | assert$1.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
6950 | }
|
6951 |
|
6952 | if (!isUndefined$1(wireDef)) {
|
6953 | const adapterInstance = createConnector(vm, fieldNameOrMethod, wireDef);
|
6954 | ArrayPush$1.call(wiredConnecting, () => adapterInstance.connect());
|
6955 | ArrayPush$1.call(wiredDisconnecting, () => adapterInstance.disconnect());
|
6956 | }
|
6957 | }
|
6958 | }
|
6959 | function connectWireAdapters(vm) {
|
6960 | const {
|
6961 | wiredConnecting
|
6962 | } = vm.context;
|
6963 |
|
6964 | for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
6965 | wiredConnecting[i]();
|
6966 | }
|
6967 | }
|
6968 | function disconnectWireAdapters(vm) {
|
6969 | const {
|
6970 | wiredDisconnecting
|
6971 | } = vm.context;
|
6972 | runWithBoundaryProtection(vm, vm, noop$4, () => {
|
6973 |
|
6974 | for (let i = 0, len = wiredDisconnecting.length; i < len; i += 1) {
|
6975 | wiredDisconnecting[i]();
|
6976 | }
|
6977 | }, noop$4);
|
6978 | }
|
6979 |
|
6980 |
|
6981 |
|
6982 |
|
6983 |
|
6984 |
|
6985 |
|
6986 |
|
6987 | function createContextProvider(adapter) {
|
6988 | let adapterContextToken = getAdapterToken(adapter);
|
6989 |
|
6990 | if (!isUndefined$1(adapterContextToken)) {
|
6991 | throw new Error(`Adapter already has a context provider.`);
|
6992 | }
|
6993 |
|
6994 | adapterContextToken = guid();
|
6995 | setAdapterToken(adapter, adapterContextToken);
|
6996 | const providers = new WeakSet();
|
6997 | return (elm, options) => {
|
6998 | if (providers.has(elm)) {
|
6999 | throw new Error(`Adapter was already installed on ${elm}.`);
|
7000 | }
|
7001 |
|
7002 | providers.add(elm);
|
7003 | const {
|
7004 | consumerConnectedCallback,
|
7005 | consumerDisconnectedCallback
|
7006 | } = options;
|
7007 | elm.addEventListener(adapterContextToken, evt => {
|
7008 | const {
|
7009 | setNewContext,
|
7010 | setDisconnectedCallback
|
7011 | } = evt;
|
7012 | const consumer = {
|
7013 | provide(newContext) {
|
7014 | setNewContext(newContext);
|
7015 | }
|
7016 |
|
7017 | };
|
7018 |
|
7019 | const disconnectCallback = () => {
|
7020 | if (!isUndefined$1(consumerDisconnectedCallback)) {
|
7021 | consumerDisconnectedCallback(consumer);
|
7022 | }
|
7023 | };
|
7024 |
|
7025 | setDisconnectedCallback(disconnectCallback);
|
7026 | consumerConnectedCallback(consumer);
|
7027 | evt.stopImmediatePropagation();
|
7028 | });
|
7029 | };
|
7030 | }
|
7031 |
|
7032 |
|
7033 |
|
7034 |
|
7035 |
|
7036 |
|
7037 |
|
7038 |
|
7039 |
|
7040 |
|
7041 |
|
7042 |
|
7043 |
|
7044 | function readonly(obj) {
|
7045 | if (process.env.NODE_ENV !== 'production') {
|
7046 |
|
7047 | if (arguments.length !== 1) {
|
7048 | assert$1.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
7049 | }
|
7050 | }
|
7051 |
|
7052 | return reactiveMembrane.getReadOnlyProxy(obj);
|
7053 | }
|
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 |
|
7059 |
|
7060 |
|
7061 |
|
7062 | const globalStylesheets = create(null);
|
7063 | const globalStylesheetsParentElement = document.head || document.body || document;
|
7064 | let getCustomElement, defineCustomElement, HTMLElementConstructor$1;
|
7065 | function isCustomElementRegistryAvailable() {
|
7066 | if (typeof customElements === 'undefined') {
|
7067 | return false;
|
7068 | }
|
7069 | try {
|
7070 |
|
7071 |
|
7072 |
|
7073 |
|
7074 | const HTMLElementAlias = HTMLElement;
|
7075 |
|
7076 |
|
7077 |
|
7078 | class clazz extends HTMLElementAlias {
|
7079 | }
|
7080 | customElements.define('lwc-test-' + Math.floor(Math.random() * 1000000), clazz);
|
7081 | new clazz();
|
7082 | return true;
|
7083 | }
|
7084 | catch (_a) {
|
7085 | return false;
|
7086 | }
|
7087 | }
|
7088 | if (isCustomElementRegistryAvailable()) {
|
7089 | getCustomElement = customElements.get.bind(customElements);
|
7090 | defineCustomElement = customElements.define.bind(customElements);
|
7091 | HTMLElementConstructor$1 = HTMLElement;
|
7092 | }
|
7093 | else {
|
7094 | const registry = create(null);
|
7095 | const reverseRegistry = new WeakMap();
|
7096 | defineCustomElement = function define(name, ctor) {
|
7097 | if (name !== StringToLowerCase.call(name) || registry[name]) {
|
7098 | throw new TypeError(`Invalid Registration`);
|
7099 | }
|
7100 | registry[name] = ctor;
|
7101 | reverseRegistry.set(ctor, name);
|
7102 | };
|
7103 | getCustomElement = function get(name) {
|
7104 | return registry[name];
|
7105 | };
|
7106 | HTMLElementConstructor$1 = function HTMLElement() {
|
7107 | if (!(this instanceof HTMLElement)) {
|
7108 | throw new TypeError(`Invalid Invocation`);
|
7109 | }
|
7110 | const { constructor } = this;
|
7111 | const name = reverseRegistry.get(constructor);
|
7112 | if (!name) {
|
7113 | throw new TypeError(`Invalid Construction`);
|
7114 | }
|
7115 | const elm = document.createElement(name);
|
7116 | setPrototypeOf(elm, constructor.prototype);
|
7117 | return elm;
|
7118 | };
|
7119 | HTMLElementConstructor$1.prototype = HTMLElement.prototype;
|
7120 | }
|
7121 | // TODO [#0]: Evaluate how we can extract the `$shadowToken$` property name in a shared package
|
7122 | // to avoid having to synchronize it between the different modules.
|
7123 | const useSyntheticShadow = hasOwnProperty.call(Element.prototype, '$shadowToken$');
|
7124 | const renderer = {
|
7125 | ssr: false,
|
7126 | syntheticShadow: useSyntheticShadow,
|
7127 | createElement(tagName, namespace) {
|
7128 | return isUndefined(namespace)
|
7129 | ? document.createElement(tagName)
|
7130 | : document.createElementNS(namespace, tagName);
|
7131 | },
|
7132 | createText(content) {
|
7133 | return document.createTextNode(content);
|
7134 | },
|
7135 | insert(node, parent, anchor) {
|
7136 | parent.insertBefore(node, anchor);
|
7137 | },
|
7138 | remove(node, parent) {
|
7139 | parent.removeChild(node);
|
7140 | },
|
7141 | nextSibling(node) {
|
7142 | return node.nextSibling;
|
7143 | },
|
7144 | attachShadow(element, options) {
|
7145 | return element.attachShadow(options);
|
7146 | },
|
7147 | setText(node, content) {
|
7148 | node.nodeValue = content;
|
7149 | },
|
7150 | getProperty(node, key) {
|
7151 | return node[key];
|
7152 | },
|
7153 | setProperty(node, key, value) {
|
7154 | if (process.env.NODE_ENV !== 'production') {
|
7155 | if (node instanceof Element && !(key in node)) {
|
7156 |
|
7157 | assert.fail(`Unknown public property "${key}" of element <${node.tagName}>. This is likely a typo on the corresponding attribute "${getAttrNameFromPropName(key)}".`);
|
7158 | }
|
7159 | }
|
7160 | node[key] = value;
|
7161 | },
|
7162 | getAttribute(element, name, namespace) {
|
7163 | return isUndefined(namespace)
|
7164 | ? element.getAttribute(name)
|
7165 | : element.getAttributeNS(namespace, name);
|
7166 | },
|
7167 | setAttribute(element, name, value, namespace) {
|
7168 | return isUndefined(namespace)
|
7169 | ? element.setAttribute(name, value)
|
7170 | : element.setAttributeNS(namespace, name, value);
|
7171 | },
|
7172 | removeAttribute(element, name, namespace) {
|
7173 | if (isUndefined(namespace)) {
|
7174 | element.removeAttribute(name);
|
7175 | }
|
7176 | else {
|
7177 | element.removeAttributeNS(namespace, name);
|
7178 | }
|
7179 | },
|
7180 | addEventListener(target, type, callback, options) {
|
7181 | target.addEventListener(type, callback, options);
|
7182 | },
|
7183 | removeEventListener(target, type, callback, options) {
|
7184 | target.removeEventListener(type, callback, options);
|
7185 | },
|
7186 | dispatchEvent(target, event) {
|
7187 | return target.dispatchEvent(event);
|
7188 | },
|
7189 | getClassList(element) {
|
7190 | return element.classList;
|
7191 | },
|
7192 | getStyleDeclaration(element) {
|
7193 |
|
7194 |
|
7195 | return element.style;
|
7196 | },
|
7197 | getBoundingClientRect(element) {
|
7198 | return element.getBoundingClientRect();
|
7199 | },
|
7200 | querySelector(element, selectors) {
|
7201 | return element.querySelector(selectors);
|
7202 | },
|
7203 | querySelectorAll(element, selectors) {
|
7204 | return element.querySelectorAll(selectors);
|
7205 | },
|
7206 | getElementsByTagName(element, tagNameOrWildCard) {
|
7207 | return element.getElementsByTagName(tagNameOrWildCard);
|
7208 | },
|
7209 | getElementsByClassName(element, names) {
|
7210 | return element.getElementsByClassName(names);
|
7211 | },
|
7212 | isConnected(node) {
|
7213 | return node.isConnected;
|
7214 | },
|
7215 | insertGlobalStylesheet(content) {
|
7216 | if (!isUndefined(globalStylesheets[content])) {
|
7217 | return;
|
7218 | }
|
7219 | globalStylesheets[content] = true;
|
7220 | const elm = document.createElement('style');
|
7221 | elm.type = 'text/css';
|
7222 | elm.textContent = content;
|
7223 | globalStylesheetsParentElement.appendChild(elm);
|
7224 | },
|
7225 | assertInstanceOfHTMLElement(elm, msg) {
|
7226 | assert.invariant(elm instanceof HTMLElement, msg);
|
7227 | },
|
7228 | defineCustomElement,
|
7229 | getCustomElement,
|
7230 | HTMLElement: HTMLElementConstructor$1,
|
7231 | };
|
7232 |
|
7233 |
|
7234 |
|
7235 |
|
7236 |
|
7237 |
|
7238 |
|
7239 |
|
7240 |
|
7241 |
|
7242 |
|
7243 |
|
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 |
|
7249 |
|
7250 |
|
7251 |
|
7252 |
|
7253 |
|
7254 | function deprecatedBuildCustomElementConstructor(Ctor) {
|
7255 | if (process.env.NODE_ENV !== 'production') {
|
7256 |
|
7257 | console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' +
|
7258 | `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
7259 | }
|
7260 | return Ctor.CustomElementConstructor;
|
7261 | }
|
7262 | function buildCustomElementConstructor(Ctor) {
|
7263 | var _a;
|
7264 | const def = getComponentInternalDef(Ctor);
|
7265 |
|
7266 |
|
7267 | const attributeToPropMap = create(null);
|
7268 | for (const propName in def.props) {
|
7269 | attributeToPropMap[getAttrNameFromPropName(propName)] = propName;
|
7270 | }
|
7271 | return _a = class extends def.bridge {
|
7272 | constructor() {
|
7273 | super();
|
7274 | createVM(this, def, {
|
7275 | mode: 'open',
|
7276 | owner: null,
|
7277 | tagName: this.tagName,
|
7278 | renderer,
|
7279 | });
|
7280 | }
|
7281 | connectedCallback() {
|
7282 | connectRootElement(this);
|
7283 | }
|
7284 | disconnectedCallback() {
|
7285 | disconnectRootElement(this);
|
7286 | }
|
7287 | attributeChangedCallback(attrName, oldValue, newValue) {
|
7288 | if (oldValue === newValue) {
|
7289 |
|
7290 | return;
|
7291 | }
|
7292 | const propName = attributeToPropMap[attrName];
|
7293 | if (isUndefined(propName)) {
|
7294 |
|
7295 | return;
|
7296 | }
|
7297 | if (!isAttributeLocked(this, attrName)) {
|
7298 |
|
7299 |
|
7300 |
|
7301 |
|
7302 |
|
7303 | return;
|
7304 | }
|
7305 |
|
7306 | this[propName] = newValue;
|
7307 | }
|
7308 | },
|
7309 |
|
7310 |
|
7311 | _a.observedAttributes = keys(attributeToPropMap),
|
7312 | _a;
|
7313 | }
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 |
|
7319 |
|
7320 |
|
7321 | const ConnectingSlot = createHiddenField('connecting', 'engine');
|
7322 | const DisconnectingSlot = createHiddenField('disconnecting', 'engine');
|
7323 | function callNodeSlot(node, slot) {
|
7324 | if (process.env.NODE_ENV !== 'production') {
|
7325 | assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
|
7326 | }
|
7327 | const fn = getHiddenField(node, slot);
|
7328 | if (!isUndefined(fn)) {
|
7329 | fn(node);
|
7330 | }
|
7331 | return node;
|
7332 | }
|
7333 |
|
7334 |
|
7335 | const { appendChild, insertBefore, removeChild, replaceChild } = Node.prototype;
|
7336 | assign(Node.prototype, {
|
7337 | appendChild(newChild) {
|
7338 | const appendedNode = appendChild.call(this, newChild);
|
7339 | return callNodeSlot(appendedNode, ConnectingSlot);
|
7340 | },
|
7341 | insertBefore(newChild, referenceNode) {
|
7342 | const insertedNode = insertBefore.call(this, newChild, referenceNode);
|
7343 | return callNodeSlot(insertedNode, ConnectingSlot);
|
7344 | },
|
7345 | removeChild(oldChild) {
|
7346 | const removedNode = removeChild.call(this, oldChild);
|
7347 | return callNodeSlot(removedNode, DisconnectingSlot);
|
7348 | },
|
7349 | replaceChild(newChild, oldChild) {
|
7350 | const replacedNode = replaceChild.call(this, newChild, oldChild);
|
7351 | callNodeSlot(replacedNode, DisconnectingSlot);
|
7352 | callNodeSlot(newChild, ConnectingSlot);
|
7353 | return replacedNode;
|
7354 | },
|
7355 | });
|
7356 |
|
7357 |
|
7358 |
|
7359 |
|
7360 |
|
7361 |
|
7362 |
|
7363 |
|
7364 |
|
7365 |
|
7366 |
|
7367 | function createElement(sel, options) {
|
7368 | if (!isObject$1(options) || isNull(options)) {
|
7369 | throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString(options)}".`);
|
7370 | }
|
7371 | const Ctor = options.is;
|
7372 | if (!isFunction(Ctor)) {
|
7373 | throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
7374 | }
|
7375 | const element = document.createElement(sel);
|
7376 |
|
7377 |
|
7378 | if (!isUndefined(getAssociatedVMIfPresent(element))) {
|
7379 | return element;
|
7380 | }
|
7381 | const def = getComponentInternalDef(Ctor);
|
7382 | setElementProto(element, def);
|
7383 | createVM(element, def, {
|
7384 | tagName: sel,
|
7385 | mode: options.mode !== 'closed' ? 'open' : 'closed',
|
7386 | owner: null,
|
7387 | renderer,
|
7388 | });
|
7389 | setHiddenField(element, ConnectingSlot, connectRootElement);
|
7390 | setHiddenField(element, DisconnectingSlot, disconnectRootElement);
|
7391 | return element;
|
7392 | }
|
7393 |
|
7394 |
|
7395 |
|
7396 |
|
7397 |
|
7398 |
|
7399 |
|
7400 |
|
7401 |
|
7402 |
|
7403 |
|
7404 | function getComponentConstructor(elm) {
|
7405 | let ctor = null;
|
7406 | if (elm instanceof HTMLElement) {
|
7407 | const vm = getAssociatedVMIfPresent(elm);
|
7408 | if (!isUndefined(vm)) {
|
7409 | ctor = vm.def.ctor;
|
7410 | }
|
7411 | }
|
7412 | return ctor;
|
7413 | }
|
7414 |
|
7415 |
|
7416 |
|
7417 |
|
7418 |
|
7419 |
|
7420 |
|
7421 |
|
7422 |
|
7423 |
|
7424 |
|
7425 | function isNodeFromTemplate(node) {
|
7426 | if (isFalse$1(node instanceof Node)) {
|
7427 | return false;
|
7428 | }
|
7429 |
|
7430 |
|
7431 | if (node instanceof ShadowRoot) {
|
7432 | return false;
|
7433 | }
|
7434 | if (useSyntheticShadow) {
|
7435 |
|
7436 |
|
7437 |
|
7438 | if (isUndefined(node.$shadowResolver$)) {
|
7439 | return false;
|
7440 | }
|
7441 | }
|
7442 | const root = node.getRootNode();
|
7443 | return root instanceof ShadowRoot;
|
7444 | }
|
7445 |
|
7446 |
|
7447 |
|
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 | const ComponentConstructorToCustomElementConstructorMap = new Map();
|
7453 | function getCustomElementConstructor(Ctor) {
|
7454 | if (Ctor === BaseLightningElement) {
|
7455 | throw new TypeError(`Invalid Constructor. LightningElement base class can't be claimed as a custom element.`);
|
7456 | }
|
7457 | let ce = ComponentConstructorToCustomElementConstructorMap.get(Ctor);
|
7458 | if (isUndefined(ce)) {
|
7459 | ce = buildCustomElementConstructor(Ctor);
|
7460 | ComponentConstructorToCustomElementConstructorMap.set(Ctor, ce);
|
7461 | }
|
7462 | return ce;
|
7463 | }
|
7464 |
|
7465 |
|
7466 |
|
7467 |
|
7468 |
|
7469 |
|
7470 |
|
7471 |
|
7472 |
|
7473 | defineProperty(BaseLightningElement, 'CustomElementConstructor', {
|
7474 | get() {
|
7475 | return getCustomElementConstructor(this);
|
7476 | },
|
7477 | });
|
7478 | freeze(BaseLightningElement);
|
7479 | seal(BaseLightningElement.prototype);
|
7480 |
|
7481 | exports.LightningElement = BaseLightningElement;
|
7482 | exports.__unstable__ProfilerControl = profilerControl;
|
7483 | exports.api = api;
|
7484 | exports.buildCustomElementConstructor = deprecatedBuildCustomElementConstructor;
|
7485 | exports.createContextProvider = createContextProvider;
|
7486 | exports.createElement = createElement;
|
7487 | exports.getComponentConstructor = getComponentConstructor;
|
7488 | exports.getComponentDef = getComponentDef;
|
7489 | exports.isComponentConstructor = isComponentConstructor;
|
7490 | exports.isNodeFromTemplate = isNodeFromTemplate;
|
7491 | exports.readonly = readonly;
|
7492 | exports.register = register;
|
7493 | exports.registerComponent = registerComponent;
|
7494 | exports.registerDecorators = registerDecorators;
|
7495 | exports.registerTemplate = registerTemplate;
|
7496 | exports.sanitizeAttribute = sanitizeAttribute;
|
7497 | exports.setFeatureFlag = setFeatureFlag;
|
7498 | exports.setFeatureFlagForTest = setFeatureFlagForTest;
|
7499 | exports.track = track;
|
7500 | exports.unwrap = unwrap$1;
|
7501 | exports.wire = wire;
|
7502 |
|