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