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