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