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