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