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