@lwc/ssr-runtime 8.10.1 → 8.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1090 -991
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1089 -992
- package/dist/index.js.map +1 -1
- package/dist/render-text-content.d.ts +5 -0
- package/dist/render.d.ts +6 -6
- package/dist/styles.d.ts +4 -2
- package/package.json +6 -3
package/dist/index.cjs.js
CHANGED
@@ -262,24 +262,44 @@ defineProperties,
|
|
262
262
|
defineProperty,
|
263
263
|
/** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
|
264
264
|
entries,
|
265
|
+
/** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
|
266
|
+
freeze,
|
267
|
+
/** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
|
268
|
+
fromEntries,
|
269
|
+
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
|
270
|
+
getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
|
271
|
+
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
|
272
|
+
getOwnPropertyDescriptors,
|
265
273
|
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
|
266
274
|
getOwnPropertyNames: getOwnPropertyNames$1,
|
275
|
+
/** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
|
276
|
+
getOwnPropertySymbols: getOwnPropertySymbols$1,
|
277
|
+
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
|
278
|
+
getPrototypeOf: getPrototypeOf$1,
|
267
279
|
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
|
268
280
|
hasOwnProperty: hasOwnProperty$1,
|
281
|
+
/** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
|
282
|
+
isFrozen,
|
269
283
|
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
|
270
|
-
keys
|
284
|
+
keys,
|
285
|
+
/** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
|
286
|
+
seal,
|
287
|
+
/** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
|
288
|
+
setPrototypeOf, } = Object;
|
271
289
|
const {
|
272
290
|
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
273
|
-
isArray: isArray$1
|
291
|
+
isArray: isArray$1,
|
292
|
+
/** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
|
293
|
+
from: ArrayFrom, } = Array;
|
274
294
|
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
|
275
295
|
// though it works fine for one, e.g. isArray), so comments for these are added to the export
|
276
296
|
// statement, rather than this declaration.
|
277
|
-
const { join: ArrayJoin, map: ArrayMap, forEach, // Weird anomaly!
|
297
|
+
const { concat: ArrayConcat$1, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush$1, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
|
278
298
|
} = Array.prototype;
|
279
299
|
/** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
|
280
300
|
const { fromCharCode: StringFromCharCode } = String;
|
281
301
|
// No JSDocs here - see comment for Array.prototype
|
282
|
-
const { charCodeAt: StringCharCodeAt, replace: StringReplace, toLowerCase: StringToLowerCase} = String.prototype;
|
302
|
+
const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
|
283
303
|
/**
|
284
304
|
* Determines whether the argument is `undefined`.
|
285
305
|
* @param obj Value to test
|
@@ -296,6 +316,14 @@ function isUndefined$1(obj) {
|
|
296
316
|
function isNull(obj) {
|
297
317
|
return obj === null;
|
298
318
|
}
|
319
|
+
/**
|
320
|
+
* Determines whether the argument is an object or null.
|
321
|
+
* @param obj Value to test
|
322
|
+
* @returns `true` if the value is an object or null.
|
323
|
+
*/
|
324
|
+
function isObject(obj) {
|
325
|
+
return typeof obj === 'object';
|
326
|
+
}
|
299
327
|
/**
|
300
328
|
* Determines whether the argument is a string.
|
301
329
|
* @param obj Value to test
|
@@ -549,6 +577,52 @@ function htmlEscape(str, attrMode = false) {
|
|
549
577
|
return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
|
550
578
|
}
|
551
579
|
|
580
|
+
/*
|
581
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
582
|
+
* All rights reserved.
|
583
|
+
* SPDX-License-Identifier: MIT
|
584
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
585
|
+
*/
|
586
|
+
/**
|
587
|
+
* [ncls] - Normalize class name attribute.
|
588
|
+
*
|
589
|
+
* Transforms the provided class property value from an object/string into a string the diffing algo
|
590
|
+
* can operate on.
|
591
|
+
*
|
592
|
+
* This implementation is borrowed from Vue:
|
593
|
+
* https://github.com/vuejs/core/blob/e790e1bdd7df7be39e14780529db86e4da47a3db/packages/shared/src/normalizeProp.ts#L63-L82
|
594
|
+
*/
|
595
|
+
function normalizeClass(value) {
|
596
|
+
if (isUndefined$1(value) || isNull(value)) {
|
597
|
+
// Returning undefined here improves initial render cost, because the old vnode's class will be considered
|
598
|
+
// undefined in the `patchClassAttribute` routine, so `oldClass === newClass` will be true so we return early
|
599
|
+
return undefined;
|
600
|
+
}
|
601
|
+
let res = '';
|
602
|
+
if (isString(value)) {
|
603
|
+
res = value;
|
604
|
+
}
|
605
|
+
else if (isArray$1(value)) {
|
606
|
+
for (let i = 0; i < value.length; i++) {
|
607
|
+
const normalized = normalizeClass(value[i]);
|
608
|
+
if (normalized) {
|
609
|
+
res += normalized + ' ';
|
610
|
+
}
|
611
|
+
}
|
612
|
+
}
|
613
|
+
else if (isObject(value) && !isNull(value)) {
|
614
|
+
// Iterate own enumerable keys of the object
|
615
|
+
const _keys = keys(value);
|
616
|
+
for (let i = 0; i < _keys.length; i += 1) {
|
617
|
+
const key = _keys[i];
|
618
|
+
if (value[key]) {
|
619
|
+
res += key + ' ';
|
620
|
+
}
|
621
|
+
}
|
622
|
+
}
|
623
|
+
return StringTrim.call(res);
|
624
|
+
}
|
625
|
+
|
552
626
|
/*
|
553
627
|
* Copyright (c) 2024, Salesforce, Inc.
|
554
628
|
* All rights reserved.
|
@@ -571,18 +645,6 @@ function setHooks(hooks) {
|
|
571
645
|
hooksAreSet = true;
|
572
646
|
exports.sanitizeHtmlContent = hooks.sanitizeHtmlContent;
|
573
647
|
}
|
574
|
-
function flattenStylesheets(stylesheets) {
|
575
|
-
const list = [];
|
576
|
-
for (const stylesheet of stylesheets) {
|
577
|
-
if (!isArray$1(stylesheet)) {
|
578
|
-
list.push(stylesheet);
|
579
|
-
}
|
580
|
-
else {
|
581
|
-
list.push(...flattenStylesheets(stylesheet));
|
582
|
-
}
|
583
|
-
}
|
584
|
-
return list;
|
585
|
-
}
|
586
648
|
|
587
649
|
/*
|
588
650
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -591,7 +653,7 @@ function flattenStylesheets(stylesheets) {
|
|
591
653
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
592
654
|
*/
|
593
655
|
const DEFAULT_SSR_MODE = 'sync';
|
594
|
-
/** version: 8.
|
656
|
+
/** version: 8.12.0 */
|
595
657
|
|
596
658
|
/*
|
597
659
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -669,493 +731,550 @@ class ClassList {
|
|
669
731
|
}
|
670
732
|
}
|
671
733
|
|
672
|
-
|
673
|
-
Copyright (
|
674
|
-
|
675
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
676
|
-
purpose with or without fee is hereby granted.
|
677
|
-
|
678
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
679
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
680
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
681
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
682
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
683
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
684
|
-
PERFORMANCE OF THIS SOFTWARE.
|
685
|
-
***************************************************************************** */
|
686
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
687
|
-
|
688
|
-
|
689
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
690
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
691
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
692
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
693
|
-
}
|
694
|
-
|
695
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
696
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
697
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
698
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
699
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
700
|
-
}
|
701
|
-
|
702
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
703
|
-
var e = new Error(message);
|
704
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
705
|
-
};
|
706
|
-
|
707
|
-
/*
|
708
|
-
* Copyright (c) 2024, Salesforce, Inc.
|
709
|
-
* All rights reserved.
|
710
|
-
* SPDX-License-Identifier: MIT
|
711
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
734
|
+
/**
|
735
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
712
736
|
*/
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
737
|
+
const { isArray } = Array;
|
738
|
+
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
739
|
+
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
740
|
+
const OtS = {}.toString;
|
741
|
+
function toString(obj) {
|
742
|
+
if (obj && obj.toString) {
|
743
|
+
return obj.toString();
|
718
744
|
}
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
745
|
+
else if (typeof obj === 'object') {
|
746
|
+
return OtS.call(obj);
|
747
|
+
}
|
748
|
+
else {
|
749
|
+
return obj + '';
|
750
|
+
}
|
751
|
+
}
|
752
|
+
function isUndefined(obj) {
|
753
|
+
return obj === undefined;
|
754
|
+
}
|
755
|
+
function isFunction(obj) {
|
756
|
+
return typeof obj === 'function';
|
757
|
+
}
|
758
|
+
const proxyToValueMap = new WeakMap();
|
759
|
+
function registerProxy(proxy, value) {
|
760
|
+
proxyToValueMap.set(proxy, value);
|
761
|
+
}
|
762
|
+
const unwrap = (replicaOrAny) => proxyToValueMap.get(replicaOrAny) || replicaOrAny;
|
763
|
+
|
764
|
+
class BaseProxyHandler {
|
765
|
+
constructor(membrane, value) {
|
766
|
+
this.originalTarget = value;
|
767
|
+
this.membrane = membrane;
|
768
|
+
}
|
769
|
+
// Shared utility methods
|
770
|
+
wrapDescriptor(descriptor) {
|
771
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
772
|
+
descriptor.value = this.wrapValue(descriptor.value);
|
773
|
+
}
|
774
|
+
else {
|
775
|
+
const { set: originalSet, get: originalGet } = descriptor;
|
776
|
+
if (!isUndefined(originalGet)) {
|
777
|
+
descriptor.get = this.wrapGetter(originalGet);
|
778
|
+
}
|
779
|
+
if (!isUndefined(originalSet)) {
|
780
|
+
descriptor.set = this.wrapSetter(originalSet);
|
725
781
|
}
|
726
|
-
mutatedAttrs.add(attrName.toLowerCase());
|
727
782
|
}
|
783
|
+
return descriptor;
|
728
784
|
}
|
729
|
-
|
730
|
-
|
785
|
+
copyDescriptorIntoShadowTarget(shadowTarget, key) {
|
786
|
+
const { originalTarget } = this;
|
787
|
+
// Note: a property might get defined multiple times in the shadowTarget
|
788
|
+
// but it will always be compatible with the previous descriptor
|
789
|
+
// to preserve the object invariants, which makes these lines safe.
|
790
|
+
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
|
791
|
+
// TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
|
792
|
+
/* istanbul ignore else */
|
793
|
+
if (!isUndefined(originalDescriptor)) {
|
794
|
+
const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
795
|
+
ObjectDefineProperty(shadowTarget, key, wrappedDesc);
|
796
|
+
}
|
731
797
|
}
|
732
|
-
|
733
|
-
|
798
|
+
lockShadowTarget(shadowTarget) {
|
799
|
+
const { originalTarget } = this;
|
800
|
+
const targetKeys = ArrayConcat.call(getOwnPropertyNames(originalTarget), getOwnPropertySymbols(originalTarget));
|
801
|
+
targetKeys.forEach((key) => {
|
802
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
803
|
+
});
|
804
|
+
const { membrane: { tagPropertyKey }, } = this;
|
805
|
+
if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
|
806
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
|
807
|
+
}
|
808
|
+
preventExtensions(shadowTarget);
|
734
809
|
}
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
810
|
+
// Shared Traps
|
811
|
+
// TODO: apply() is never called
|
812
|
+
/* istanbul ignore next */
|
813
|
+
apply(shadowTarget, thisArg, argArray) {
|
814
|
+
/* No op */
|
815
|
+
}
|
816
|
+
// TODO: construct() is never called
|
817
|
+
/* istanbul ignore next */
|
818
|
+
construct(shadowTarget, argArray, newTarget) {
|
819
|
+
/* No op */
|
820
|
+
}
|
821
|
+
get(shadowTarget, key) {
|
822
|
+
const { originalTarget, membrane: { valueObserved }, } = this;
|
823
|
+
const value = originalTarget[key];
|
824
|
+
valueObserved(originalTarget, key);
|
825
|
+
return this.wrapValue(value);
|
826
|
+
}
|
827
|
+
has(shadowTarget, key) {
|
828
|
+
const { originalTarget, membrane: { tagPropertyKey, valueObserved }, } = this;
|
829
|
+
valueObserved(originalTarget, key);
|
830
|
+
// since key is never going to be undefined, and tagPropertyKey might be undefined
|
831
|
+
// we can simply compare them as the second part of the condition.
|
832
|
+
return key in originalTarget || key === tagPropertyKey;
|
833
|
+
}
|
834
|
+
ownKeys(shadowTarget) {
|
835
|
+
const { originalTarget, membrane: { tagPropertyKey }, } = this;
|
836
|
+
// if the membrane tag key exists and it is not in the original target, we add it to the keys.
|
837
|
+
const keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey)
|
838
|
+
? []
|
839
|
+
: [tagPropertyKey];
|
840
|
+
// small perf optimization using push instead of concat to avoid creating an extra array
|
841
|
+
ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
|
842
|
+
ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
|
843
|
+
return keys;
|
844
|
+
}
|
845
|
+
isExtensible(shadowTarget) {
|
846
|
+
const { originalTarget } = this;
|
847
|
+
// optimization to avoid attempting to lock down the shadowTarget multiple times
|
848
|
+
if (!isExtensible(shadowTarget)) {
|
849
|
+
return false; // was already locked down
|
739
850
|
}
|
740
|
-
|
741
|
-
|
851
|
+
if (!isExtensible(originalTarget)) {
|
852
|
+
this.lockShadowTarget(shadowTarget);
|
853
|
+
return false;
|
854
|
+
}
|
855
|
+
return true;
|
856
|
+
}
|
857
|
+
getPrototypeOf(shadowTarget) {
|
858
|
+
const { originalTarget } = this;
|
859
|
+
return getPrototypeOf(originalTarget);
|
860
|
+
}
|
861
|
+
getOwnPropertyDescriptor(shadowTarget, key) {
|
862
|
+
const { originalTarget, membrane: { valueObserved, tagPropertyKey }, } = this;
|
863
|
+
// keys looked up via getOwnPropertyDescriptor need to be reactive
|
864
|
+
valueObserved(originalTarget, key);
|
865
|
+
let desc = getOwnPropertyDescriptor(originalTarget, key);
|
866
|
+
if (isUndefined(desc)) {
|
867
|
+
if (key !== tagPropertyKey) {
|
868
|
+
return undefined;
|
869
|
+
}
|
870
|
+
// if the key is the membrane tag key, and is not in the original target,
|
871
|
+
// we produce a synthetic descriptor and install it on the shadow target
|
872
|
+
desc = { value: undefined, writable: false, configurable: false, enumerable: false };
|
873
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
|
874
|
+
return desc;
|
875
|
+
}
|
876
|
+
if (desc.configurable === false) {
|
877
|
+
// updating the descriptor to non-configurable on the shadow
|
878
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
742
879
|
}
|
880
|
+
// Note: by accessing the descriptor, the key is marked as observed
|
881
|
+
// but access to the value, setter or getter (if available) cannot observe
|
882
|
+
// mutations, just like regular methods, in which case we just do nothing.
|
883
|
+
return this.wrapDescriptor(desc);
|
743
884
|
}
|
744
885
|
}
|
745
|
-
_MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
|
746
|
-
const mutationTracker = new MutationTracker();
|
747
886
|
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
function filterProperties(props, publicFields, privateFields) {
|
761
|
-
const propsToAssign = create(null);
|
762
|
-
const publicFieldSet = new Set(publicFields);
|
763
|
-
const privateFieldSet = new Set(privateFields);
|
764
|
-
keys(props).forEach((propName) => {
|
765
|
-
const attrName = htmlPropertyToAttribute(propName);
|
766
|
-
if (publicFieldSet.has(propName) ||
|
767
|
-
((isGlobalHtmlAttribute(attrName) || isAriaAttribute(attrName)) &&
|
768
|
-
!privateFieldSet.has(propName))) {
|
769
|
-
propsToAssign[propName] = props[propName];
|
770
|
-
}
|
771
|
-
});
|
772
|
-
return propsToAssign;
|
773
|
-
}
|
774
|
-
/**
|
775
|
-
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
776
|
-
*/
|
777
|
-
const stringDescriptor = (attrName) => ({
|
778
|
-
configurable: true,
|
779
|
-
enumerable: true,
|
780
|
-
get() {
|
781
|
-
return this.getAttribute(attrName);
|
782
|
-
},
|
783
|
-
set(newValue) {
|
784
|
-
const currentValue = this.getAttribute(attrName);
|
785
|
-
const normalizedValue = String(newValue);
|
786
|
-
if (normalizedValue !== currentValue) {
|
787
|
-
this.setAttribute(attrName, normalizedValue);
|
887
|
+
const getterMap$1 = new WeakMap();
|
888
|
+
const setterMap$1 = new WeakMap();
|
889
|
+
const reverseGetterMap = new WeakMap();
|
890
|
+
const reverseSetterMap = new WeakMap();
|
891
|
+
class ReactiveProxyHandler extends BaseProxyHandler {
|
892
|
+
wrapValue(value) {
|
893
|
+
return this.membrane.getProxy(value);
|
894
|
+
}
|
895
|
+
wrapGetter(originalGet) {
|
896
|
+
const wrappedGetter = getterMap$1.get(originalGet);
|
897
|
+
if (!isUndefined(wrappedGetter)) {
|
898
|
+
return wrappedGetter;
|
788
899
|
}
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
},
|
803
|
-
set(newValue) {
|
804
|
-
const currentValue = this.getAttribute(attrName);
|
805
|
-
const normalizedValue = String(Boolean(newValue));
|
806
|
-
if (normalizedValue !== currentValue) {
|
807
|
-
this.setAttribute(attrName, normalizedValue);
|
900
|
+
const handler = this;
|
901
|
+
const get = function () {
|
902
|
+
// invoking the original getter with the original target
|
903
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
904
|
+
};
|
905
|
+
getterMap$1.set(originalGet, get);
|
906
|
+
reverseGetterMap.set(get, originalGet);
|
907
|
+
return get;
|
908
|
+
}
|
909
|
+
wrapSetter(originalSet) {
|
910
|
+
const wrappedSetter = setterMap$1.get(originalSet);
|
911
|
+
if (!isUndefined(wrappedSetter)) {
|
912
|
+
return wrappedSetter;
|
808
913
|
}
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
const hasAttribute = this.hasAttribute(attrName);
|
822
|
-
if (newValue) {
|
823
|
-
if (!hasAttribute) {
|
824
|
-
this.setAttribute(attrName, '');
|
825
|
-
}
|
914
|
+
const set = function (v) {
|
915
|
+
// invoking the original setter with the original target
|
916
|
+
originalSet.call(unwrap(this), unwrap(v));
|
917
|
+
};
|
918
|
+
setterMap$1.set(originalSet, set);
|
919
|
+
reverseSetterMap.set(set, originalSet);
|
920
|
+
return set;
|
921
|
+
}
|
922
|
+
unwrapDescriptor(descriptor) {
|
923
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
924
|
+
// dealing with a data descriptor
|
925
|
+
descriptor.value = unwrap(descriptor.value);
|
826
926
|
}
|
827
927
|
else {
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
}
|
832
|
-
},
|
833
|
-
});
|
834
|
-
/**
|
835
|
-
* Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
|
836
|
-
*/
|
837
|
-
const ariaDescriptor = (attrName) => ({
|
838
|
-
configurable: true,
|
839
|
-
enumerable: true,
|
840
|
-
get() {
|
841
|
-
return this.getAttribute(attrName);
|
842
|
-
},
|
843
|
-
set(newValue) {
|
844
|
-
const currentValue = this.getAttribute(attrName);
|
845
|
-
if (newValue !== currentValue) {
|
846
|
-
// TODO [#3284]: According to the spec, IDL nullable type values
|
847
|
-
// (null and undefined) should remove the attribute; however, we
|
848
|
-
// only do so in the case of null for historical reasons.
|
849
|
-
if (isNull(newValue)) {
|
850
|
-
this.removeAttribute(attrName);
|
928
|
+
const { set, get } = descriptor;
|
929
|
+
if (!isUndefined(get)) {
|
930
|
+
descriptor.get = this.unwrapGetter(get);
|
851
931
|
}
|
852
|
-
|
853
|
-
this.
|
932
|
+
if (!isUndefined(set)) {
|
933
|
+
descriptor.set = this.unwrapSetter(set);
|
854
934
|
}
|
855
935
|
}
|
856
|
-
|
857
|
-
});
|
858
|
-
const tabIndexDescriptor = () => ({
|
859
|
-
configurable: true,
|
860
|
-
enumerable: true,
|
861
|
-
get() {
|
862
|
-
const str = this.getAttribute('tabindex');
|
863
|
-
const num = Number(str);
|
864
|
-
return isFinite(num) ? Math.trunc(num) : -1;
|
865
|
-
},
|
866
|
-
set(newValue) {
|
867
|
-
const currentValue = this.getAttribute('tabindex');
|
868
|
-
const num = Number(newValue);
|
869
|
-
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
870
|
-
if (normalizedValue !== currentValue) {
|
871
|
-
this.setAttribute('tabindex', toString$1(newValue));
|
872
|
-
}
|
873
|
-
},
|
874
|
-
});
|
875
|
-
const descriptors = {
|
876
|
-
accessKey: stringDescriptor('accesskey'),
|
877
|
-
dir: stringDescriptor('dir'),
|
878
|
-
draggable: explicitBooleanDescriptor('draggable', true),
|
879
|
-
hidden: booleanAttributeDescriptor('hidden'),
|
880
|
-
id: stringDescriptor('id'),
|
881
|
-
lang: stringDescriptor('lang'),
|
882
|
-
spellcheck: explicitBooleanDescriptor('spellcheck', false),
|
883
|
-
tabIndex: tabIndexDescriptor(),
|
884
|
-
title: stringDescriptor('title'),
|
885
|
-
};
|
886
|
-
// Add descriptors for ARIA attributes
|
887
|
-
for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
|
888
|
-
descriptors[propName] = ariaDescriptor(attrName);
|
889
|
-
}
|
890
|
-
|
891
|
-
/*
|
892
|
-
* Copyright (c) 2024, salesforce.com, inc.
|
893
|
-
* All rights reserved.
|
894
|
-
* SPDX-License-Identifier: MIT
|
895
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
896
|
-
*/
|
897
|
-
var _LightningElement_attrs, _LightningElement_classList;
|
898
|
-
const SYMBOL__SET_INTERNALS = Symbol('set-internals');
|
899
|
-
const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
|
900
|
-
const SYMBOL__DEFAULT_TEMPLATE = Symbol('default-template');
|
901
|
-
class LightningElement {
|
902
|
-
constructor(propsAvailableAtConstruction) {
|
903
|
-
this.isConnected = false;
|
904
|
-
this.className = '';
|
905
|
-
_LightningElement_attrs.set(this, void 0);
|
906
|
-
_LightningElement_classList.set(this, null);
|
907
|
-
assign(this, propsAvailableAtConstruction);
|
908
|
-
}
|
909
|
-
[(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
|
910
|
-
__classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
|
911
|
-
assign(this, props);
|
912
|
-
defineProperty(this, 'className', {
|
913
|
-
get() {
|
914
|
-
return props.class ?? '';
|
915
|
-
},
|
916
|
-
set(newVal) {
|
917
|
-
props.class = newVal;
|
918
|
-
attrs.class = newVal;
|
919
|
-
mutationTracker.add(this, 'class');
|
920
|
-
},
|
921
|
-
});
|
936
|
+
return descriptor;
|
922
937
|
}
|
923
|
-
|
924
|
-
|
925
|
-
|
938
|
+
unwrapGetter(redGet) {
|
939
|
+
const reverseGetter = reverseGetterMap.get(redGet);
|
940
|
+
if (!isUndefined(reverseGetter)) {
|
941
|
+
return reverseGetter;
|
926
942
|
}
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
943
|
+
const handler = this;
|
944
|
+
const get = function () {
|
945
|
+
// invoking the red getter with the proxy of this
|
946
|
+
return unwrap(redGet.call(handler.wrapValue(this)));
|
947
|
+
};
|
948
|
+
getterMap$1.set(get, redGet);
|
949
|
+
reverseGetterMap.set(redGet, get);
|
950
|
+
return get;
|
934
951
|
}
|
935
|
-
|
936
|
-
const
|
937
|
-
if (
|
938
|
-
return
|
952
|
+
unwrapSetter(redSet) {
|
953
|
+
const reverseSetter = reverseSetterMap.get(redSet);
|
954
|
+
if (!isUndefined(reverseSetter)) {
|
955
|
+
return reverseSetter;
|
939
956
|
}
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
949
|
-
// Track mutations for removal of non-existing attributes
|
950
|
-
mutationTracker.add(this, normalizedName);
|
951
|
-
}
|
952
|
-
addEventListener(_type, _listener, _options) {
|
953
|
-
// noop
|
954
|
-
}
|
955
|
-
removeEventListener(_type, _listener, _options) {
|
956
|
-
// noop
|
957
|
-
}
|
958
|
-
// ----------------------------------------------------------- //
|
959
|
-
// Props/methods explicitly not available in this environment //
|
960
|
-
// Getters are named "get*" for parity with @lwc/engine-server //
|
961
|
-
// ----------------------------------------------------------- //
|
962
|
-
get children() {
|
963
|
-
throw new TypeError('"getChildren" is not supported in this environment');
|
964
|
-
}
|
965
|
-
get childNodes() {
|
966
|
-
throw new TypeError('"getChildNodes" is not supported in this environment');
|
967
|
-
}
|
968
|
-
get firstChild() {
|
969
|
-
throw new TypeError('"getFirstChild" is not supported in this environment');
|
970
|
-
}
|
971
|
-
get firstElementChild() {
|
972
|
-
throw new TypeError('"getFirstElementChild" is not supported in this environment');
|
973
|
-
}
|
974
|
-
get hostElement() {
|
975
|
-
// Intentionally different to match @lwc/engine-*core*
|
976
|
-
throw new TypeError('this.hostElement is not supported in this environment');
|
977
|
-
}
|
978
|
-
get lastChild() {
|
979
|
-
throw new TypeError('"getLastChild" is not supported in this environment');
|
980
|
-
}
|
981
|
-
get lastElementChild() {
|
982
|
-
throw new TypeError('"getLastElementChild" is not supported in this environment');
|
957
|
+
const handler = this;
|
958
|
+
const set = function (v) {
|
959
|
+
// invoking the red setter with the proxy of this
|
960
|
+
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
961
|
+
};
|
962
|
+
setterMap$1.set(set, redSet);
|
963
|
+
reverseSetterMap.set(redSet, set);
|
964
|
+
return set;
|
983
965
|
}
|
984
|
-
|
985
|
-
|
986
|
-
|
966
|
+
set(shadowTarget, key, value) {
|
967
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
968
|
+
const oldValue = originalTarget[key];
|
969
|
+
if (oldValue !== value) {
|
970
|
+
originalTarget[key] = value;
|
971
|
+
valueMutated(originalTarget, key);
|
972
|
+
}
|
973
|
+
else if (key === 'length' && isArray(originalTarget)) {
|
974
|
+
// fix for issue #236: push will add the new index, and by the time length
|
975
|
+
// is updated, the internal length is already equal to the new length value
|
976
|
+
// therefore, the oldValue is equal to the value. This is the forking logic
|
977
|
+
// to support this use case.
|
978
|
+
valueMutated(originalTarget, key);
|
979
|
+
}
|
980
|
+
return true;
|
987
981
|
}
|
988
|
-
|
989
|
-
|
990
|
-
|
982
|
+
deleteProperty(shadowTarget, key) {
|
983
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
984
|
+
delete originalTarget[key];
|
985
|
+
valueMutated(originalTarget, key);
|
986
|
+
return true;
|
991
987
|
}
|
992
|
-
|
993
|
-
|
988
|
+
setPrototypeOf(shadowTarget, prototype) {
|
989
|
+
/* istanbul ignore else */
|
990
|
+
if (process.env.NODE_ENV !== 'production') {
|
991
|
+
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
992
|
+
}
|
994
993
|
}
|
995
|
-
|
996
|
-
|
994
|
+
preventExtensions(shadowTarget) {
|
995
|
+
if (isExtensible(shadowTarget)) {
|
996
|
+
const { originalTarget } = this;
|
997
|
+
preventExtensions(originalTarget);
|
998
|
+
// if the originalTarget is a proxy itself, it might reject
|
999
|
+
// the preventExtension call, in which case we should not attempt to lock down
|
1000
|
+
// the shadow target.
|
1001
|
+
// TODO: It should not actually be possible to reach this `if` statement.
|
1002
|
+
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
1003
|
+
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
1004
|
+
/* istanbul ignore if */
|
1005
|
+
if (isExtensible(originalTarget)) {
|
1006
|
+
return false;
|
1007
|
+
}
|
1008
|
+
this.lockShadowTarget(shadowTarget);
|
1009
|
+
}
|
1010
|
+
return true;
|
997
1011
|
}
|
998
|
-
|
999
|
-
|
1012
|
+
defineProperty(shadowTarget, key, descriptor) {
|
1013
|
+
const { originalTarget, membrane: { valueMutated, tagPropertyKey }, } = this;
|
1014
|
+
if (key === tagPropertyKey && !hasOwnProperty.call(originalTarget, key)) {
|
1015
|
+
// To avoid leaking the membrane tag property into the original target, we must
|
1016
|
+
// be sure that the original target doesn't have yet.
|
1017
|
+
// NOTE: we do not return false here because Object.freeze and equivalent operations
|
1018
|
+
// will attempt to set the descriptor to the same value, and expect no to throw. This
|
1019
|
+
// is an small compromise for the sake of not having to diff the descriptors.
|
1020
|
+
return true;
|
1021
|
+
}
|
1022
|
+
ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor));
|
1023
|
+
// intentionally testing if false since it could be undefined as well
|
1024
|
+
if (descriptor.configurable === false) {
|
1025
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
1026
|
+
}
|
1027
|
+
valueMutated(originalTarget, key);
|
1028
|
+
return true;
|
1000
1029
|
}
|
1001
|
-
|
1002
|
-
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
const getterMap = new WeakMap();
|
1033
|
+
const setterMap = new WeakMap();
|
1034
|
+
class ReadOnlyHandler extends BaseProxyHandler {
|
1035
|
+
wrapValue(value) {
|
1036
|
+
return this.membrane.getReadOnlyProxy(value);
|
1003
1037
|
}
|
1004
|
-
|
1005
|
-
|
1038
|
+
wrapGetter(originalGet) {
|
1039
|
+
const wrappedGetter = getterMap.get(originalGet);
|
1040
|
+
if (!isUndefined(wrappedGetter)) {
|
1041
|
+
return wrappedGetter;
|
1042
|
+
}
|
1043
|
+
const handler = this;
|
1044
|
+
const get = function () {
|
1045
|
+
// invoking the original getter with the original target
|
1046
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
1047
|
+
};
|
1048
|
+
getterMap.set(originalGet, get);
|
1049
|
+
return get;
|
1006
1050
|
}
|
1007
|
-
|
1008
|
-
|
1051
|
+
wrapSetter(originalSet) {
|
1052
|
+
const wrappedSetter = setterMap.get(originalSet);
|
1053
|
+
if (!isUndefined(wrappedSetter)) {
|
1054
|
+
return wrappedSetter;
|
1055
|
+
}
|
1056
|
+
const handler = this;
|
1057
|
+
const set = function (v) {
|
1058
|
+
/* istanbul ignore else */
|
1059
|
+
if (process.env.NODE_ENV !== 'production') {
|
1060
|
+
const { originalTarget } = handler;
|
1061
|
+
throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1062
|
+
}
|
1063
|
+
};
|
1064
|
+
setterMap.set(originalSet, set);
|
1065
|
+
return set;
|
1009
1066
|
}
|
1010
|
-
|
1011
|
-
|
1067
|
+
set(shadowTarget, key, value) {
|
1068
|
+
/* istanbul ignore else */
|
1069
|
+
if (process.env.NODE_ENV !== 'production') {
|
1070
|
+
const { originalTarget } = this;
|
1071
|
+
const msg = isArray(originalTarget)
|
1072
|
+
? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.`
|
1073
|
+
: `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
1074
|
+
throw new Error(msg);
|
1075
|
+
}
|
1076
|
+
/* istanbul ignore next */
|
1077
|
+
return false;
|
1012
1078
|
}
|
1013
|
-
|
1014
|
-
|
1079
|
+
deleteProperty(shadowTarget, key) {
|
1080
|
+
/* istanbul ignore else */
|
1081
|
+
if (process.env.NODE_ENV !== 'production') {
|
1082
|
+
const { originalTarget } = this;
|
1083
|
+
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1084
|
+
}
|
1085
|
+
/* istanbul ignore next */
|
1086
|
+
return false;
|
1015
1087
|
}
|
1016
|
-
|
1017
|
-
|
1088
|
+
setPrototypeOf(shadowTarget, prototype) {
|
1089
|
+
/* istanbul ignore else */
|
1090
|
+
if (process.env.NODE_ENV !== 'production') {
|
1091
|
+
const { originalTarget } = this;
|
1092
|
+
throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
1093
|
+
}
|
1018
1094
|
}
|
1019
|
-
|
1020
|
-
|
1095
|
+
preventExtensions(shadowTarget) {
|
1096
|
+
/* istanbul ignore else */
|
1097
|
+
if (process.env.NODE_ENV !== 'production') {
|
1098
|
+
const { originalTarget } = this;
|
1099
|
+
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
1100
|
+
}
|
1101
|
+
/* istanbul ignore next */
|
1102
|
+
return false;
|
1021
1103
|
}
|
1022
|
-
|
1023
|
-
|
1104
|
+
defineProperty(shadowTarget, key, descriptor) {
|
1105
|
+
/* istanbul ignore else */
|
1106
|
+
if (process.env.NODE_ENV !== 'production') {
|
1107
|
+
const { originalTarget } = this;
|
1108
|
+
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1109
|
+
}
|
1110
|
+
/* istanbul ignore next */
|
1111
|
+
return false;
|
1024
1112
|
}
|
1025
1113
|
}
|
1026
|
-
defineProperties(LightningElement.prototype, descriptors);
|
1027
1114
|
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
const
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
let attrValue = attrs[attrName];
|
1046
|
-
if (isNull(attrValue) || isUndefined$1(attrValue)) {
|
1047
|
-
attrValue = '';
|
1115
|
+
function extract(objectOrArray) {
|
1116
|
+
if (isArray(objectOrArray)) {
|
1117
|
+
return objectOrArray.map((item) => {
|
1118
|
+
const original = unwrap(item);
|
1119
|
+
if (original !== item) {
|
1120
|
+
return extract(original);
|
1121
|
+
}
|
1122
|
+
return item;
|
1123
|
+
});
|
1124
|
+
}
|
1125
|
+
const obj = ObjectCreate(getPrototypeOf(objectOrArray));
|
1126
|
+
const names = getOwnPropertyNames(objectOrArray);
|
1127
|
+
return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
1128
|
+
const item = objectOrArray[key];
|
1129
|
+
const original = unwrap(item);
|
1130
|
+
if (original !== item) {
|
1131
|
+
seed[key] = extract(original);
|
1048
1132
|
}
|
1049
|
-
else
|
1050
|
-
|
1133
|
+
else {
|
1134
|
+
seed[key] = item;
|
1051
1135
|
}
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1136
|
+
return seed;
|
1137
|
+
}, obj);
|
1138
|
+
}
|
1139
|
+
const formatter = {
|
1140
|
+
header: (plainOrProxy) => {
|
1141
|
+
const originalTarget = unwrap(plainOrProxy);
|
1142
|
+
// if originalTarget is falsy or not unwrappable, exit
|
1143
|
+
if (!originalTarget || originalTarget === plainOrProxy) {
|
1144
|
+
return null;
|
1055
1145
|
}
|
1056
|
-
|
1146
|
+
const obj = extract(plainOrProxy);
|
1147
|
+
return ['object', { object: obj }];
|
1148
|
+
},
|
1149
|
+
hasBody: () => {
|
1150
|
+
return false;
|
1151
|
+
},
|
1152
|
+
body: () => {
|
1153
|
+
return null;
|
1154
|
+
},
|
1155
|
+
};
|
1156
|
+
// Inspired from paulmillr/es6-shim
|
1157
|
+
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
1158
|
+
/* istanbul ignore next */
|
1159
|
+
function getGlobal() {
|
1160
|
+
// the only reliable means to get the global object is `Function('return this')()`
|
1161
|
+
// However, this causes CSP violations in Chrome apps.
|
1162
|
+
if (typeof globalThis !== 'undefined') {
|
1163
|
+
return globalThis;
|
1057
1164
|
}
|
1058
|
-
|
1059
|
-
|
1060
|
-
result += ` class="${combinedScopeToken}"`;
|
1165
|
+
if (typeof self !== 'undefined') {
|
1166
|
+
return self;
|
1061
1167
|
}
|
1062
|
-
|
1063
|
-
|
1064
|
-
result += ` data-lwc-host-scope-token="${hostScopeToken}"`;
|
1168
|
+
if (typeof window !== 'undefined') {
|
1169
|
+
return window;
|
1065
1170
|
}
|
1066
|
-
|
1067
|
-
|
1171
|
+
if (typeof global !== 'undefined') {
|
1172
|
+
return global;
|
1173
|
+
}
|
1174
|
+
// Gracefully degrade if not able to locate the global object
|
1175
|
+
return {};
|
1068
1176
|
}
|
1069
|
-
function
|
1070
|
-
|
1177
|
+
function init() {
|
1178
|
+
/* istanbul ignore if */
|
1179
|
+
if (process.env.NODE_ENV === 'production') {
|
1180
|
+
// this method should never leak to prod
|
1181
|
+
throw new ReferenceError();
|
1182
|
+
}
|
1183
|
+
const global = getGlobal();
|
1184
|
+
// Custom Formatter for Dev Tools. To enable this, open Chrome Dev Tools
|
1185
|
+
// - Go to Settings,
|
1186
|
+
// - Under console, select "Enable custom formatters"
|
1187
|
+
// For more information, https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview
|
1188
|
+
const devtoolsFormatters = global.devtoolsFormatters || [];
|
1189
|
+
ArrayPush.call(devtoolsFormatters, formatter);
|
1190
|
+
global.devtoolsFormatters = devtoolsFormatters;
|
1071
1191
|
}
|
1072
|
-
|
1073
|
-
|
1192
|
+
|
1193
|
+
/* istanbul ignore else */
|
1194
|
+
if (process.env.NODE_ENV !== 'production') {
|
1195
|
+
init();
|
1074
1196
|
}
|
1075
|
-
function
|
1076
|
-
|
1077
|
-
|
1197
|
+
function defaultValueIsObservable(value) {
|
1198
|
+
// intentionally checking for null
|
1199
|
+
if (value === null) {
|
1200
|
+
return false;
|
1078
1201
|
}
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1202
|
+
// treat all non-object types, including undefined, as non-observable values
|
1203
|
+
if (typeof value !== 'object') {
|
1204
|
+
return false;
|
1205
|
+
}
|
1206
|
+
if (isArray(value)) {
|
1207
|
+
return true;
|
1083
1208
|
}
|
1209
|
+
const proto = getPrototypeOf(value);
|
1210
|
+
return proto === ObjectDotPrototype || proto === null || getPrototypeOf(proto) === null;
|
1084
1211
|
}
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1212
|
+
const defaultValueObserved = (obj, key) => {
|
1213
|
+
/* do nothing */
|
1214
|
+
};
|
1215
|
+
const defaultValueMutated = (obj, key) => {
|
1216
|
+
/* do nothing */
|
1217
|
+
};
|
1218
|
+
function createShadowTarget(value) {
|
1219
|
+
return isArray(value) ? [] : {};
|
1220
|
+
}
|
1221
|
+
class ObservableMembrane {
|
1222
|
+
constructor(options = {}) {
|
1223
|
+
this.readOnlyObjectGraph = new WeakMap();
|
1224
|
+
this.reactiveObjectGraph = new WeakMap();
|
1225
|
+
const { valueMutated, valueObserved, valueIsObservable, tagPropertyKey } = options;
|
1226
|
+
this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
|
1227
|
+
this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
|
1228
|
+
this.valueIsObservable = isFunction(valueIsObservable)
|
1229
|
+
? valueIsObservable
|
1230
|
+
: defaultValueIsObservable;
|
1231
|
+
this.tagPropertyKey = tagPropertyKey;
|
1088
1232
|
}
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
markup += segment;
|
1233
|
+
getProxy(value) {
|
1234
|
+
const unwrappedValue = unwrap(value);
|
1235
|
+
if (this.valueIsObservable(unwrappedValue)) {
|
1236
|
+
// When trying to extract the writable version of a readonly we return the readonly.
|
1237
|
+
if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
|
1238
|
+
return value;
|
1239
|
+
}
|
1240
|
+
return this.getReactiveHandler(unwrappedValue);
|
1098
1241
|
}
|
1242
|
+
return unwrappedValue;
|
1099
1243
|
}
|
1100
|
-
|
1101
|
-
|
1244
|
+
getReadOnlyProxy(value) {
|
1245
|
+
value = unwrap(value);
|
1246
|
+
if (this.valueIsObservable(value)) {
|
1247
|
+
return this.getReadOnlyHandler(value);
|
1248
|
+
}
|
1249
|
+
return value;
|
1102
1250
|
}
|
1103
|
-
|
1104
|
-
|
1251
|
+
unwrapProxy(p) {
|
1252
|
+
return unwrap(p);
|
1105
1253
|
}
|
1106
|
-
|
1107
|
-
|
1254
|
+
getReactiveHandler(value) {
|
1255
|
+
let proxy = this.reactiveObjectGraph.get(value);
|
1256
|
+
if (isUndefined(proxy)) {
|
1257
|
+
// caching the proxy after the first time it is accessed
|
1258
|
+
const handler = new ReactiveProxyHandler(this, value);
|
1259
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
1260
|
+
registerProxy(proxy, value);
|
1261
|
+
this.reactiveObjectGraph.set(value, proxy);
|
1262
|
+
}
|
1263
|
+
return proxy;
|
1108
1264
|
}
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
* Per the HTML spec on restrictions for "raw text elements" like `<style>`:
|
1120
|
-
*
|
1121
|
-
* > The text in raw text and escapable raw text elements must not contain any occurrences of the string
|
1122
|
-
* > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
|
1123
|
-
* > the element followed by one of:
|
1124
|
-
* > - U+0009 CHARACTER TABULATION (tab)
|
1125
|
-
* > - U+000A LINE FEED (LF)
|
1126
|
-
* > - U+000C FORM FEED (FF)
|
1127
|
-
* > - U+000D CARRIAGE RETURN (CR)
|
1128
|
-
* > - U+0020 SPACE
|
1129
|
-
* > - U+003E GREATER-THAN SIGN (>), or
|
1130
|
-
* > - U+002F SOLIDUS (/)
|
1131
|
-
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
1132
|
-
*/
|
1133
|
-
const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
|
1134
|
-
/**
|
1135
|
-
* The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
|
1136
|
-
* are disallowed inside of HTML templates.
|
1137
|
-
*
|
1138
|
-
* The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
|
1139
|
-
* which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
|
1140
|
-
* attacks like `</style><script>alert("pwned")</script>`.
|
1141
|
-
*
|
1142
|
-
* This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `<`,
|
1143
|
-
* `>`, etc., because these are treated as-is by the HTML parser.
|
1144
|
-
*
|
1145
|
-
*
|
1146
|
-
* @param contents CSS source to validate
|
1147
|
-
* @throws Throws if the contents provided are not valid.
|
1148
|
-
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
1149
|
-
* @see https://github.com/salesforce/lwc/issues/3439
|
1150
|
-
* @example
|
1151
|
-
* validateStyleTextContents('div { color: red }') // Ok
|
1152
|
-
* validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
|
1153
|
-
*/
|
1154
|
-
function validateStyleTextContents(contents) {
|
1155
|
-
if (INVALID_STYLE_CONTENT.test(contents)) {
|
1156
|
-
throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
|
1265
|
+
getReadOnlyHandler(value) {
|
1266
|
+
let proxy = this.readOnlyObjectGraph.get(value);
|
1267
|
+
if (isUndefined(proxy)) {
|
1268
|
+
// caching the proxy after the first time it is accessed
|
1269
|
+
const handler = new ReadOnlyHandler(this, value);
|
1270
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
1271
|
+
registerProxy(proxy, value);
|
1272
|
+
this.readOnlyObjectGraph.set(value, proxy);
|
1273
|
+
}
|
1274
|
+
return proxy;
|
1157
1275
|
}
|
1158
1276
|
}
|
1277
|
+
/** version: 2.0.0 */
|
1159
1278
|
|
1160
1279
|
/*
|
1161
1280
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -1163,611 +1282,522 @@ function validateStyleTextContents(contents) {
|
|
1163
1282
|
* SPDX-License-Identifier: MIT
|
1164
1283
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1165
1284
|
*/
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
return
|
1172
|
-
}
|
1173
|
-
function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplateStyles) {
|
1174
|
-
const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
|
1175
|
-
let result = '';
|
1176
|
-
const truthyStylesheets = stylesheets.filter(Boolean);
|
1177
|
-
for (const stylesheet of flattenStylesheets(truthyStylesheets)) {
|
1178
|
-
// TODO [#2869]: `<style>`s should not have scope token classes
|
1179
|
-
result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">`;
|
1180
|
-
const token = stylesheet.$scoped$ ? scopeToken : undefined;
|
1181
|
-
const useActualHostSelector = !stylesheet.$scoped$ || Component.renderMode !== 'light';
|
1182
|
-
const useNativeDirPseudoclass = true;
|
1183
|
-
const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
|
1184
|
-
validateStyleTextContents(styleContents);
|
1185
|
-
result += styleContents + '</style>';
|
1186
|
-
}
|
1187
|
-
return result;
|
1285
|
+
const reactiveMembrane = new ObservableMembrane();
|
1286
|
+
// Modeled after `getReadOnlyProxy` in `membrane.ts` in `engine-core`
|
1287
|
+
// Return a proxy over the given object so that access is immutable
|
1288
|
+
// https://github.com/salesforce/lwc/blob/e9db491/packages/%40lwc/engine-core/src/framework/membrane.ts#L29-L33
|
1289
|
+
function getReadOnlyProxy(value) {
|
1290
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
1188
1291
|
}
|
1189
1292
|
|
1293
|
+
/******************************************************************************
|
1294
|
+
Copyright (c) Microsoft Corporation.
|
1295
|
+
|
1296
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
1297
|
+
purpose with or without fee is hereby granted.
|
1298
|
+
|
1299
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
1300
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
1301
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
1302
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
1303
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
1304
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
1305
|
+
PERFORMANCE OF THIS SOFTWARE.
|
1306
|
+
***************************************************************************** */
|
1307
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
1308
|
+
|
1309
|
+
|
1310
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
1311
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
1312
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
1313
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
1317
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
1318
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
1319
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
1320
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
1324
|
+
var e = new Error(message);
|
1325
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
1326
|
+
};
|
1327
|
+
|
1190
1328
|
/*
|
1191
|
-
* Copyright (c) 2024,
|
1329
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1192
1330
|
* All rights reserved.
|
1193
1331
|
* SPDX-License-Identifier: MIT
|
1194
1332
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1195
1333
|
*/
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
if (iterable === undefined || iterable === null)
|
1202
|
-
return;
|
1203
|
-
if (!iterable[Symbol.iterator]) {
|
1204
|
-
throw new Error(
|
1205
|
-
// Mimic error message from "[i]terable node" in engine-core's api.ts
|
1206
|
-
`Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
|
1334
|
+
var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
|
1335
|
+
class MutationTracker {
|
1336
|
+
constructor() {
|
1337
|
+
_MutationTracker_enabledSet.set(this, new WeakSet());
|
1338
|
+
_MutationTracker_mutationMap.set(this, new WeakMap());
|
1207
1339
|
}
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
value,
|
1218
|
-
index,
|
1219
|
-
first: index === 0,
|
1220
|
-
last,
|
1221
|
-
};
|
1222
|
-
index += 1;
|
1223
|
-
value = next.value;
|
1340
|
+
add(instance, attrName) {
|
1341
|
+
if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
|
1342
|
+
let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
1343
|
+
if (!mutatedAttrs) {
|
1344
|
+
mutatedAttrs = new Set();
|
1345
|
+
__classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
|
1346
|
+
}
|
1347
|
+
mutatedAttrs.add(attrName.toLowerCase());
|
1348
|
+
}
|
1224
1349
|
}
|
1225
|
-
|
1226
|
-
|
1227
|
-
/**
|
1228
|
-
* Copyright (C) 2017 salesforce.com, inc.
|
1229
|
-
*/
|
1230
|
-
const { isArray } = Array;
|
1231
|
-
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
1232
|
-
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
1233
|
-
const OtS = {}.toString;
|
1234
|
-
function toString(obj) {
|
1235
|
-
if (obj && obj.toString) {
|
1236
|
-
return obj.toString();
|
1350
|
+
enable(instance) {
|
1351
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
|
1237
1352
|
}
|
1238
|
-
|
1239
|
-
|
1353
|
+
disable(instance) {
|
1354
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
|
1240
1355
|
}
|
1241
|
-
|
1242
|
-
|
1356
|
+
renderMutatedAttrs(instance) {
|
1357
|
+
const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
1358
|
+
if (mutatedAttrs) {
|
1359
|
+
return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
|
1360
|
+
}
|
1361
|
+
else {
|
1362
|
+
return '';
|
1363
|
+
}
|
1243
1364
|
}
|
1244
1365
|
}
|
1245
|
-
|
1246
|
-
|
1247
|
-
}
|
1248
|
-
function isFunction(obj) {
|
1249
|
-
return typeof obj === 'function';
|
1250
|
-
}
|
1251
|
-
const proxyToValueMap = new WeakMap();
|
1252
|
-
function registerProxy(proxy, value) {
|
1253
|
-
proxyToValueMap.set(proxy, value);
|
1254
|
-
}
|
1255
|
-
const unwrap = (replicaOrAny) => proxyToValueMap.get(replicaOrAny) || replicaOrAny;
|
1366
|
+
_MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
|
1367
|
+
const mutationTracker = new MutationTracker();
|
1256
1368
|
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1369
|
+
/*
|
1370
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1371
|
+
* All rights reserved.
|
1372
|
+
* SPDX-License-Identifier: MIT
|
1373
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1374
|
+
*/
|
1375
|
+
/**
|
1376
|
+
* Filters out the following types of properties that should not be set.
|
1377
|
+
* - Properties that are not public.
|
1378
|
+
* - Properties that are not global.
|
1379
|
+
* - Properties that are global but are internally overridden.
|
1380
|
+
*/
|
1381
|
+
function filterProperties(props, publicFields, privateFields) {
|
1382
|
+
const propsToAssign = create(null);
|
1383
|
+
const publicFieldSet = new Set(publicFields);
|
1384
|
+
const privateFieldSet = new Set(privateFields);
|
1385
|
+
keys(props).forEach((propName) => {
|
1386
|
+
const attrName = htmlPropertyToAttribute(propName);
|
1387
|
+
if (publicFieldSet.has(propName) ||
|
1388
|
+
((isGlobalHtmlAttribute(attrName) || isAriaAttribute(attrName)) &&
|
1389
|
+
!privateFieldSet.has(propName))) {
|
1390
|
+
propsToAssign[propName] = props[propName];
|
1391
|
+
}
|
1392
|
+
});
|
1393
|
+
return propsToAssign;
|
1394
|
+
}
|
1395
|
+
/**
|
1396
|
+
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
1397
|
+
*/
|
1398
|
+
const stringDescriptor = (attrName) => ({
|
1399
|
+
configurable: true,
|
1400
|
+
enumerable: true,
|
1401
|
+
get() {
|
1402
|
+
return this.getAttribute(attrName);
|
1403
|
+
},
|
1404
|
+
set(newValue) {
|
1405
|
+
const currentValue = this.getAttribute(attrName);
|
1406
|
+
const normalizedValue = String(newValue);
|
1407
|
+
if (normalizedValue !== currentValue) {
|
1408
|
+
this.setAttribute(attrName, normalizedValue);
|
1409
|
+
}
|
1410
|
+
},
|
1411
|
+
});
|
1412
|
+
/** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
|
1413
|
+
const explicitBooleanDescriptor = (attrName, defaultValue) => ({
|
1414
|
+
configurable: true,
|
1415
|
+
enumerable: true,
|
1416
|
+
get() {
|
1417
|
+
const value = this.getAttribute(attrName);
|
1418
|
+
if (value === null)
|
1419
|
+
return defaultValue;
|
1420
|
+
// spellcheck=false => false, everything else => true
|
1421
|
+
// draggable=true => true, everything else => false
|
1422
|
+
return value.toLowerCase() === String(defaultValue) ? defaultValue : !defaultValue;
|
1423
|
+
},
|
1424
|
+
set(newValue) {
|
1425
|
+
const currentValue = this.getAttribute(attrName);
|
1426
|
+
const normalizedValue = String(Boolean(newValue));
|
1427
|
+
if (normalizedValue !== currentValue) {
|
1428
|
+
this.setAttribute(attrName, normalizedValue);
|
1429
|
+
}
|
1430
|
+
},
|
1431
|
+
});
|
1432
|
+
/**
|
1433
|
+
* Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
|
1434
|
+
*/
|
1435
|
+
const booleanAttributeDescriptor = (attrName) => ({
|
1436
|
+
configurable: true,
|
1437
|
+
enumerable: true,
|
1438
|
+
get() {
|
1439
|
+
return this.hasAttribute(attrName);
|
1440
|
+
},
|
1441
|
+
set(newValue) {
|
1442
|
+
const hasAttribute = this.hasAttribute(attrName);
|
1443
|
+
if (newValue) {
|
1444
|
+
if (!hasAttribute) {
|
1445
|
+
this.setAttribute(attrName, '');
|
1446
|
+
}
|
1266
1447
|
}
|
1267
1448
|
else {
|
1268
|
-
|
1269
|
-
|
1270
|
-
descriptor.get = this.wrapGetter(originalGet);
|
1449
|
+
if (hasAttribute) {
|
1450
|
+
this.removeAttribute(attrName);
|
1271
1451
|
}
|
1272
|
-
|
1273
|
-
|
1452
|
+
}
|
1453
|
+
},
|
1454
|
+
});
|
1455
|
+
/**
|
1456
|
+
* Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
|
1457
|
+
*/
|
1458
|
+
const ariaDescriptor = (attrName) => ({
|
1459
|
+
configurable: true,
|
1460
|
+
enumerable: true,
|
1461
|
+
get() {
|
1462
|
+
return this.getAttribute(attrName);
|
1463
|
+
},
|
1464
|
+
set(newValue) {
|
1465
|
+
const currentValue = this.getAttribute(attrName);
|
1466
|
+
if (newValue !== currentValue) {
|
1467
|
+
// TODO [#3284]: According to the spec, IDL nullable type values
|
1468
|
+
// (null and undefined) should remove the attribute; however, we
|
1469
|
+
// only do so in the case of null for historical reasons.
|
1470
|
+
if (isNull(newValue)) {
|
1471
|
+
this.removeAttribute(attrName);
|
1472
|
+
}
|
1473
|
+
else {
|
1474
|
+
this.setAttribute(attrName, toString$1(newValue));
|
1274
1475
|
}
|
1275
1476
|
}
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
const
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1477
|
+
},
|
1478
|
+
});
|
1479
|
+
const tabIndexDescriptor = () => ({
|
1480
|
+
configurable: true,
|
1481
|
+
enumerable: true,
|
1482
|
+
get() {
|
1483
|
+
const str = this.getAttribute('tabindex');
|
1484
|
+
const num = Number(str);
|
1485
|
+
return isFinite(num) ? Math.trunc(num) : -1;
|
1486
|
+
},
|
1487
|
+
set(newValue) {
|
1488
|
+
const currentValue = this.getAttribute('tabindex');
|
1489
|
+
const num = Number(newValue);
|
1490
|
+
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
1491
|
+
if (normalizedValue !== currentValue) {
|
1492
|
+
this.setAttribute('tabindex', toString$1(newValue));
|
1289
1493
|
}
|
1494
|
+
},
|
1495
|
+
});
|
1496
|
+
const descriptors = {
|
1497
|
+
accessKey: stringDescriptor('accesskey'),
|
1498
|
+
dir: stringDescriptor('dir'),
|
1499
|
+
draggable: explicitBooleanDescriptor('draggable', true),
|
1500
|
+
hidden: booleanAttributeDescriptor('hidden'),
|
1501
|
+
id: stringDescriptor('id'),
|
1502
|
+
lang: stringDescriptor('lang'),
|
1503
|
+
spellcheck: explicitBooleanDescriptor('spellcheck', false),
|
1504
|
+
tabIndex: tabIndexDescriptor(),
|
1505
|
+
title: stringDescriptor('title'),
|
1506
|
+
};
|
1507
|
+
// Add descriptors for ARIA attributes
|
1508
|
+
for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
|
1509
|
+
descriptors[propName] = ariaDescriptor(attrName);
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
/*
|
1513
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
1514
|
+
* All rights reserved.
|
1515
|
+
* SPDX-License-Identifier: MIT
|
1516
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1517
|
+
*/
|
1518
|
+
var _LightningElement_attrs, _LightningElement_classList;
|
1519
|
+
const SYMBOL__SET_INTERNALS = Symbol('set-internals');
|
1520
|
+
const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
|
1521
|
+
const SYMBOL__DEFAULT_TEMPLATE = Symbol('default-template');
|
1522
|
+
class LightningElement {
|
1523
|
+
constructor(propsAvailableAtConstruction) {
|
1524
|
+
this.isConnected = false;
|
1525
|
+
this.className = '';
|
1526
|
+
_LightningElement_attrs.set(this, void 0);
|
1527
|
+
_LightningElement_classList.set(this, null);
|
1528
|
+
assign(this, propsAvailableAtConstruction);
|
1290
1529
|
}
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1530
|
+
[(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
|
1531
|
+
__classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
|
1532
|
+
assign(this, props);
|
1533
|
+
defineProperty(this, 'className', {
|
1534
|
+
get() {
|
1535
|
+
return props.class ?? '';
|
1536
|
+
},
|
1537
|
+
set(newVal) {
|
1538
|
+
props.class = newVal;
|
1539
|
+
attrs.class = newVal;
|
1540
|
+
mutationTracker.add(this, 'class');
|
1541
|
+
},
|
1296
1542
|
});
|
1297
|
-
const { membrane: { tagPropertyKey }, } = this;
|
1298
|
-
if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
|
1299
|
-
ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
|
1300
|
-
}
|
1301
|
-
preventExtensions(shadowTarget);
|
1302
|
-
}
|
1303
|
-
// Shared Traps
|
1304
|
-
// TODO: apply() is never called
|
1305
|
-
/* istanbul ignore next */
|
1306
|
-
apply(shadowTarget, thisArg, argArray) {
|
1307
|
-
/* No op */
|
1308
|
-
}
|
1309
|
-
// TODO: construct() is never called
|
1310
|
-
/* istanbul ignore next */
|
1311
|
-
construct(shadowTarget, argArray, newTarget) {
|
1312
|
-
/* No op */
|
1313
|
-
}
|
1314
|
-
get(shadowTarget, key) {
|
1315
|
-
const { originalTarget, membrane: { valueObserved }, } = this;
|
1316
|
-
const value = originalTarget[key];
|
1317
|
-
valueObserved(originalTarget, key);
|
1318
|
-
return this.wrapValue(value);
|
1319
|
-
}
|
1320
|
-
has(shadowTarget, key) {
|
1321
|
-
const { originalTarget, membrane: { tagPropertyKey, valueObserved }, } = this;
|
1322
|
-
valueObserved(originalTarget, key);
|
1323
|
-
// since key is never going to be undefined, and tagPropertyKey might be undefined
|
1324
|
-
// we can simply compare them as the second part of the condition.
|
1325
|
-
return key in originalTarget || key === tagPropertyKey;
|
1326
|
-
}
|
1327
|
-
ownKeys(shadowTarget) {
|
1328
|
-
const { originalTarget, membrane: { tagPropertyKey }, } = this;
|
1329
|
-
// if the membrane tag key exists and it is not in the original target, we add it to the keys.
|
1330
|
-
const keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey)
|
1331
|
-
? []
|
1332
|
-
: [tagPropertyKey];
|
1333
|
-
// small perf optimization using push instead of concat to avoid creating an extra array
|
1334
|
-
ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
|
1335
|
-
ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
|
1336
|
-
return keys;
|
1337
1543
|
}
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
if (!isExtensible(shadowTarget)) {
|
1342
|
-
return false; // was already locked down
|
1343
|
-
}
|
1344
|
-
if (!isExtensible(originalTarget)) {
|
1345
|
-
this.lockShadowTarget(shadowTarget);
|
1346
|
-
return false;
|
1544
|
+
get classList() {
|
1545
|
+
if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
|
1546
|
+
return __classPrivateFieldGet(this, _LightningElement_classList, "f");
|
1347
1547
|
}
|
1348
|
-
return
|
1548
|
+
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
1349
1549
|
}
|
1350
|
-
|
1351
|
-
const
|
1352
|
-
|
1550
|
+
setAttribute(attrName, attrValue) {
|
1551
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
1552
|
+
const normalizedValue = String(attrValue);
|
1553
|
+
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
1554
|
+
mutationTracker.add(this, normalizedName);
|
1353
1555
|
}
|
1354
|
-
|
1355
|
-
const
|
1356
|
-
|
1357
|
-
|
1358
|
-
let desc = getOwnPropertyDescriptor(originalTarget, key);
|
1359
|
-
if (isUndefined(desc)) {
|
1360
|
-
if (key !== tagPropertyKey) {
|
1361
|
-
return undefined;
|
1362
|
-
}
|
1363
|
-
// if the key is the membrane tag key, and is not in the original target,
|
1364
|
-
// we produce a synthetic descriptor and install it on the shadow target
|
1365
|
-
desc = { value: undefined, writable: false, configurable: false, enumerable: false };
|
1366
|
-
ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
|
1367
|
-
return desc;
|
1368
|
-
}
|
1369
|
-
if (desc.configurable === false) {
|
1370
|
-
// updating the descriptor to non-configurable on the shadow
|
1371
|
-
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
1556
|
+
getAttribute(attrName) {
|
1557
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
1558
|
+
if (hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
1559
|
+
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
1372
1560
|
}
|
1373
|
-
|
1374
|
-
// but access to the value, setter or getter (if available) cannot observe
|
1375
|
-
// mutations, just like regular methods, in which case we just do nothing.
|
1376
|
-
return this.wrapDescriptor(desc);
|
1561
|
+
return null;
|
1377
1562
|
}
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
const setterMap$1 = new WeakMap();
|
1382
|
-
const reverseGetterMap = new WeakMap();
|
1383
|
-
const reverseSetterMap = new WeakMap();
|
1384
|
-
class ReactiveProxyHandler extends BaseProxyHandler {
|
1385
|
-
wrapValue(value) {
|
1386
|
-
return this.membrane.getProxy(value);
|
1563
|
+
hasAttribute(attrName) {
|
1564
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
1565
|
+
return hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
1387
1566
|
}
|
1388
|
-
|
1389
|
-
const
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
const handler = this;
|
1394
|
-
const get = function () {
|
1395
|
-
// invoking the original getter with the original target
|
1396
|
-
return handler.wrapValue(originalGet.call(unwrap(this)));
|
1397
|
-
};
|
1398
|
-
getterMap$1.set(originalGet, get);
|
1399
|
-
reverseGetterMap.set(get, originalGet);
|
1400
|
-
return get;
|
1567
|
+
removeAttribute(attrName) {
|
1568
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
1569
|
+
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
1570
|
+
// Track mutations for removal of non-existing attributes
|
1571
|
+
mutationTracker.add(this, normalizedName);
|
1401
1572
|
}
|
1402
|
-
|
1403
|
-
|
1404
|
-
if (!isUndefined(wrappedSetter)) {
|
1405
|
-
return wrappedSetter;
|
1406
|
-
}
|
1407
|
-
const set = function (v) {
|
1408
|
-
// invoking the original setter with the original target
|
1409
|
-
originalSet.call(unwrap(this), unwrap(v));
|
1410
|
-
};
|
1411
|
-
setterMap$1.set(originalSet, set);
|
1412
|
-
reverseSetterMap.set(set, originalSet);
|
1413
|
-
return set;
|
1573
|
+
addEventListener(_type, _listener, _options) {
|
1574
|
+
// noop
|
1414
1575
|
}
|
1415
|
-
|
1416
|
-
|
1417
|
-
// dealing with a data descriptor
|
1418
|
-
descriptor.value = unwrap(descriptor.value);
|
1419
|
-
}
|
1420
|
-
else {
|
1421
|
-
const { set, get } = descriptor;
|
1422
|
-
if (!isUndefined(get)) {
|
1423
|
-
descriptor.get = this.unwrapGetter(get);
|
1424
|
-
}
|
1425
|
-
if (!isUndefined(set)) {
|
1426
|
-
descriptor.set = this.unwrapSetter(set);
|
1427
|
-
}
|
1428
|
-
}
|
1429
|
-
return descriptor;
|
1576
|
+
removeEventListener(_type, _listener, _options) {
|
1577
|
+
// noop
|
1430
1578
|
}
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
};
|
1441
|
-
getterMap$1.set(get, redGet);
|
1442
|
-
reverseGetterMap.set(redGet, get);
|
1443
|
-
return get;
|
1579
|
+
// ----------------------------------------------------------- //
|
1580
|
+
// Props/methods explicitly not available in this environment //
|
1581
|
+
// Getters are named "get*" for parity with @lwc/engine-server //
|
1582
|
+
// ----------------------------------------------------------- //
|
1583
|
+
get children() {
|
1584
|
+
throw new TypeError('"getChildren" is not supported in this environment');
|
1585
|
+
}
|
1586
|
+
get childNodes() {
|
1587
|
+
throw new TypeError('"getChildNodes" is not supported in this environment');
|
1444
1588
|
}
|
1445
|
-
|
1446
|
-
|
1447
|
-
if (!isUndefined(reverseSetter)) {
|
1448
|
-
return reverseSetter;
|
1449
|
-
}
|
1450
|
-
const handler = this;
|
1451
|
-
const set = function (v) {
|
1452
|
-
// invoking the red setter with the proxy of this
|
1453
|
-
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
1454
|
-
};
|
1455
|
-
setterMap$1.set(set, redSet);
|
1456
|
-
reverseSetterMap.set(redSet, set);
|
1457
|
-
return set;
|
1589
|
+
get firstChild() {
|
1590
|
+
throw new TypeError('"getFirstChild" is not supported in this environment');
|
1458
1591
|
}
|
1459
|
-
|
1460
|
-
|
1461
|
-
const oldValue = originalTarget[key];
|
1462
|
-
if (oldValue !== value) {
|
1463
|
-
originalTarget[key] = value;
|
1464
|
-
valueMutated(originalTarget, key);
|
1465
|
-
}
|
1466
|
-
else if (key === 'length' && isArray(originalTarget)) {
|
1467
|
-
// fix for issue #236: push will add the new index, and by the time length
|
1468
|
-
// is updated, the internal length is already equal to the new length value
|
1469
|
-
// therefore, the oldValue is equal to the value. This is the forking logic
|
1470
|
-
// to support this use case.
|
1471
|
-
valueMutated(originalTarget, key);
|
1472
|
-
}
|
1473
|
-
return true;
|
1592
|
+
get firstElementChild() {
|
1593
|
+
throw new TypeError('"getFirstElementChild" is not supported in this environment');
|
1474
1594
|
}
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
valueMutated(originalTarget, key);
|
1479
|
-
return true;
|
1595
|
+
get hostElement() {
|
1596
|
+
// Intentionally different to match @lwc/engine-*core*
|
1597
|
+
throw new TypeError('this.hostElement is not supported in this environment');
|
1480
1598
|
}
|
1481
|
-
|
1482
|
-
|
1483
|
-
if (process.env.NODE_ENV !== 'production') {
|
1484
|
-
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
1485
|
-
}
|
1599
|
+
get lastChild() {
|
1600
|
+
throw new TypeError('"getLastChild" is not supported in this environment');
|
1486
1601
|
}
|
1487
|
-
|
1488
|
-
|
1489
|
-
const { originalTarget } = this;
|
1490
|
-
preventExtensions(originalTarget);
|
1491
|
-
// if the originalTarget is a proxy itself, it might reject
|
1492
|
-
// the preventExtension call, in which case we should not attempt to lock down
|
1493
|
-
// the shadow target.
|
1494
|
-
// TODO: It should not actually be possible to reach this `if` statement.
|
1495
|
-
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
1496
|
-
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
1497
|
-
/* istanbul ignore if */
|
1498
|
-
if (isExtensible(originalTarget)) {
|
1499
|
-
return false;
|
1500
|
-
}
|
1501
|
-
this.lockShadowTarget(shadowTarget);
|
1502
|
-
}
|
1503
|
-
return true;
|
1602
|
+
get lastElementChild() {
|
1603
|
+
throw new TypeError('"getLastElementChild" is not supported in this environment');
|
1504
1604
|
}
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
// To avoid leaking the membrane tag property into the original target, we must
|
1509
|
-
// be sure that the original target doesn't have yet.
|
1510
|
-
// NOTE: we do not return false here because Object.freeze and equivalent operations
|
1511
|
-
// will attempt to set the descriptor to the same value, and expect no to throw. This
|
1512
|
-
// is an small compromise for the sake of not having to diff the descriptors.
|
1513
|
-
return true;
|
1514
|
-
}
|
1515
|
-
ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor));
|
1516
|
-
// intentionally testing if false since it could be undefined as well
|
1517
|
-
if (descriptor.configurable === false) {
|
1518
|
-
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
1519
|
-
}
|
1520
|
-
valueMutated(originalTarget, key);
|
1521
|
-
return true;
|
1605
|
+
get ownerDocument() {
|
1606
|
+
// Intentionally not "get*" to match @lwc/engine-server
|
1607
|
+
throw new TypeError('"ownerDocument" is not supported in this environment');
|
1522
1608
|
}
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
const setterMap = new WeakMap();
|
1527
|
-
class ReadOnlyHandler extends BaseProxyHandler {
|
1528
|
-
wrapValue(value) {
|
1529
|
-
return this.membrane.getReadOnlyProxy(value);
|
1609
|
+
get style() {
|
1610
|
+
// Intentionally not "get*" to match @lwc/engine-server
|
1611
|
+
throw new TypeError('"style" is not supported in this environment');
|
1530
1612
|
}
|
1531
|
-
|
1532
|
-
|
1533
|
-
if (!isUndefined(wrappedGetter)) {
|
1534
|
-
return wrappedGetter;
|
1535
|
-
}
|
1536
|
-
const handler = this;
|
1537
|
-
const get = function () {
|
1538
|
-
// invoking the original getter with the original target
|
1539
|
-
return handler.wrapValue(originalGet.call(unwrap(this)));
|
1540
|
-
};
|
1541
|
-
getterMap.set(originalGet, get);
|
1542
|
-
return get;
|
1613
|
+
attachInternals() {
|
1614
|
+
throw new TypeError('"attachInternals" is not supported in this environment');
|
1543
1615
|
}
|
1544
|
-
|
1545
|
-
|
1546
|
-
if (!isUndefined(wrappedSetter)) {
|
1547
|
-
return wrappedSetter;
|
1548
|
-
}
|
1549
|
-
const handler = this;
|
1550
|
-
const set = function (v) {
|
1551
|
-
/* istanbul ignore else */
|
1552
|
-
if (process.env.NODE_ENV !== 'production') {
|
1553
|
-
const { originalTarget } = handler;
|
1554
|
-
throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1555
|
-
}
|
1556
|
-
};
|
1557
|
-
setterMap.set(originalSet, set);
|
1558
|
-
return set;
|
1616
|
+
dispatchEvent(_event) {
|
1617
|
+
throw new TypeError('"dispatchEvent" is not supported in this environment');
|
1559
1618
|
}
|
1560
|
-
|
1561
|
-
|
1562
|
-
if (process.env.NODE_ENV !== 'production') {
|
1563
|
-
const { originalTarget } = this;
|
1564
|
-
const msg = isArray(originalTarget)
|
1565
|
-
? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.`
|
1566
|
-
: `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
1567
|
-
throw new Error(msg);
|
1568
|
-
}
|
1569
|
-
/* istanbul ignore next */
|
1570
|
-
return false;
|
1619
|
+
getBoundingClientRect() {
|
1620
|
+
throw new TypeError('"getBoundingClientRect" is not supported in this environment');
|
1571
1621
|
}
|
1572
|
-
|
1573
|
-
|
1574
|
-
if (process.env.NODE_ENV !== 'production') {
|
1575
|
-
const { originalTarget } = this;
|
1576
|
-
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1577
|
-
}
|
1578
|
-
/* istanbul ignore next */
|
1579
|
-
return false;
|
1622
|
+
getElementsByClassName(_classNames) {
|
1623
|
+
throw new TypeError('"getElementsByClassName" is not supported in this environment');
|
1580
1624
|
}
|
1581
|
-
|
1582
|
-
|
1583
|
-
if (process.env.NODE_ENV !== 'production') {
|
1584
|
-
const { originalTarget } = this;
|
1585
|
-
throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
1586
|
-
}
|
1625
|
+
getElementsByTagName(_qualifiedName) {
|
1626
|
+
throw new TypeError('"getElementsByTagName" is not supported in this environment');
|
1587
1627
|
}
|
1588
|
-
|
1589
|
-
|
1590
|
-
if (process.env.NODE_ENV !== 'production') {
|
1591
|
-
const { originalTarget } = this;
|
1592
|
-
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
1593
|
-
}
|
1594
|
-
/* istanbul ignore next */
|
1595
|
-
return false;
|
1628
|
+
querySelector(_selectors) {
|
1629
|
+
throw new TypeError('"querySelector" is not supported in this environment');
|
1596
1630
|
}
|
1597
|
-
|
1598
|
-
|
1599
|
-
if (process.env.NODE_ENV !== 'production') {
|
1600
|
-
const { originalTarget } = this;
|
1601
|
-
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1602
|
-
}
|
1603
|
-
/* istanbul ignore next */
|
1604
|
-
return false;
|
1631
|
+
querySelectorAll(_selectors) {
|
1632
|
+
throw new TypeError('"querySelectorAll" is not supported in this environment');
|
1605
1633
|
}
|
1606
|
-
|
1607
|
-
|
1608
|
-
function extract(objectOrArray) {
|
1609
|
-
if (isArray(objectOrArray)) {
|
1610
|
-
return objectOrArray.map((item) => {
|
1611
|
-
const original = unwrap(item);
|
1612
|
-
if (original !== item) {
|
1613
|
-
return extract(original);
|
1614
|
-
}
|
1615
|
-
return item;
|
1616
|
-
});
|
1634
|
+
getAttributeNS(_namespace, _localName) {
|
1635
|
+
throw new Error('Method "getAttributeNS" not implemented.');
|
1617
1636
|
}
|
1618
|
-
|
1619
|
-
|
1620
|
-
return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
1621
|
-
const item = objectOrArray[key];
|
1622
|
-
const original = unwrap(item);
|
1623
|
-
if (original !== item) {
|
1624
|
-
seed[key] = extract(original);
|
1625
|
-
}
|
1626
|
-
else {
|
1627
|
-
seed[key] = item;
|
1628
|
-
}
|
1629
|
-
return seed;
|
1630
|
-
}, obj);
|
1631
|
-
}
|
1632
|
-
const formatter = {
|
1633
|
-
header: (plainOrProxy) => {
|
1634
|
-
const originalTarget = unwrap(plainOrProxy);
|
1635
|
-
// if originalTarget is falsy or not unwrappable, exit
|
1636
|
-
if (!originalTarget || originalTarget === plainOrProxy) {
|
1637
|
-
return null;
|
1638
|
-
}
|
1639
|
-
const obj = extract(plainOrProxy);
|
1640
|
-
return ['object', { object: obj }];
|
1641
|
-
},
|
1642
|
-
hasBody: () => {
|
1643
|
-
return false;
|
1644
|
-
},
|
1645
|
-
body: () => {
|
1646
|
-
return null;
|
1647
|
-
},
|
1648
|
-
};
|
1649
|
-
// Inspired from paulmillr/es6-shim
|
1650
|
-
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
1651
|
-
/* istanbul ignore next */
|
1652
|
-
function getGlobal() {
|
1653
|
-
// the only reliable means to get the global object is `Function('return this')()`
|
1654
|
-
// However, this causes CSP violations in Chrome apps.
|
1655
|
-
if (typeof globalThis !== 'undefined') {
|
1656
|
-
return globalThis;
|
1637
|
+
hasAttributeNS(_namespace, _localName) {
|
1638
|
+
throw new Error('Method "hasAttributeNS" not implemented.');
|
1657
1639
|
}
|
1658
|
-
|
1659
|
-
|
1640
|
+
removeAttributeNS(_namespace, _localName) {
|
1641
|
+
throw new Error('Method "removeAttributeNS" not implemented.');
|
1642
|
+
}
|
1643
|
+
setAttributeNS(_namespace, _qualifiedName, _value) {
|
1644
|
+
throw new Error('Method "setAttributeNS" not implemented.');
|
1645
|
+
}
|
1646
|
+
}
|
1647
|
+
defineProperties(LightningElement.prototype, descriptors);
|
1648
|
+
|
1649
|
+
/*
|
1650
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
1651
|
+
* All rights reserved.
|
1652
|
+
* SPDX-License-Identifier: MIT
|
1653
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1654
|
+
*/
|
1655
|
+
const escapeAttrVal = (attrValue) => attrValue.replaceAll('&', '&').replaceAll('"', '"');
|
1656
|
+
function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
|
1657
|
+
// The scopeToken is e.g. `lwc-xyz123` which is the token our parent gives us.
|
1658
|
+
// The hostScopeToken is e.g. `lwc-abc456-host` which is the token for our own component.
|
1659
|
+
// It's possible to have both, one, the other, or neither.
|
1660
|
+
const combinedScopeToken = scopeToken && hostScopeToken
|
1661
|
+
? `${scopeToken} ${hostScopeToken}`
|
1662
|
+
: scopeToken || hostScopeToken || '';
|
1663
|
+
let result = '';
|
1664
|
+
let hasClassAttribute = false;
|
1665
|
+
for (const attrName of getOwnPropertyNames$1(attrs)) {
|
1666
|
+
let attrValue = attrs[attrName];
|
1667
|
+
if (isNull(attrValue) || isUndefined$1(attrValue)) {
|
1668
|
+
attrValue = '';
|
1669
|
+
}
|
1670
|
+
else if (!isString(attrValue)) {
|
1671
|
+
attrValue = String(attrValue);
|
1672
|
+
}
|
1673
|
+
if (attrName === 'class') {
|
1674
|
+
if (attrValue === '') {
|
1675
|
+
// If the class attribute is empty, we don't render it.
|
1676
|
+
continue;
|
1677
|
+
}
|
1678
|
+
if (combinedScopeToken) {
|
1679
|
+
attrValue += ' ' + combinedScopeToken;
|
1680
|
+
hasClassAttribute = true;
|
1681
|
+
}
|
1682
|
+
}
|
1683
|
+
result += attrValue === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrValue)}"`;
|
1660
1684
|
}
|
1661
|
-
|
1662
|
-
|
1685
|
+
// If we didn't render any `class` attribute, render one for the scope token(s)
|
1686
|
+
if (!hasClassAttribute && combinedScopeToken) {
|
1687
|
+
result += ` class="${combinedScopeToken}"`;
|
1663
1688
|
}
|
1664
|
-
|
1665
|
-
|
1689
|
+
// For the host scope token only, we encode a special attribute for hydration
|
1690
|
+
if (hostScopeToken) {
|
1691
|
+
result += ` data-lwc-host-scope-token="${hostScopeToken}"`;
|
1666
1692
|
}
|
1667
|
-
|
1668
|
-
return
|
1693
|
+
result += mutationTracker.renderMutatedAttrs(instance);
|
1694
|
+
return result;
|
1669
1695
|
}
|
1670
|
-
function
|
1671
|
-
|
1672
|
-
if (process.env.NODE_ENV === 'production') {
|
1673
|
-
// this method should never leak to prod
|
1674
|
-
throw new ReferenceError();
|
1675
|
-
}
|
1676
|
-
const global = getGlobal();
|
1677
|
-
// Custom Formatter for Dev Tools. To enable this, open Chrome Dev Tools
|
1678
|
-
// - Go to Settings,
|
1679
|
-
// - Under console, select "Enable custom formatters"
|
1680
|
-
// For more information, https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview
|
1681
|
-
const devtoolsFormatters = global.devtoolsFormatters || [];
|
1682
|
-
ArrayPush.call(devtoolsFormatters, formatter);
|
1683
|
-
global.devtoolsFormatters = devtoolsFormatters;
|
1696
|
+
function* renderAttrs(instance, attrs, hostScopeToken, scopeToken) {
|
1697
|
+
yield renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken);
|
1684
1698
|
}
|
1685
|
-
|
1686
|
-
|
1687
|
-
if (process.env.NODE_ENV !== 'production') {
|
1688
|
-
init();
|
1699
|
+
function renderAttrsNoYield(emit, instance, attrs, hostScopeToken, scopeToken) {
|
1700
|
+
emit(renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken));
|
1689
1701
|
}
|
1690
|
-
function
|
1691
|
-
|
1692
|
-
|
1693
|
-
return false;
|
1694
|
-
}
|
1695
|
-
// treat all non-object types, including undefined, as non-observable values
|
1696
|
-
if (typeof value !== 'object') {
|
1697
|
-
return false;
|
1698
|
-
}
|
1699
|
-
if (isArray(value)) {
|
1700
|
-
return true;
|
1702
|
+
function* fallbackTmpl(_props, _attrs, _shadowSlottedContent, _lightSlottedContent, Cmp, _instance) {
|
1703
|
+
if (Cmp.renderMode !== 'light') {
|
1704
|
+
yield '<template shadowrootmode="open"></template>';
|
1701
1705
|
}
|
1702
|
-
const proto = getPrototypeOf(value);
|
1703
|
-
return proto === ObjectDotPrototype || proto === null || getPrototypeOf(proto) === null;
|
1704
1706
|
}
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
/* do nothing */
|
1710
|
-
};
|
1711
|
-
function createShadowTarget(value) {
|
1712
|
-
return isArray(value) ? [] : {};
|
1707
|
+
function fallbackTmplNoYield(emit, _props, _attrs, _shadowSlottedContent, _lightSlottedContent, Cmp, _instance) {
|
1708
|
+
if (Cmp.renderMode !== 'light') {
|
1709
|
+
emit('<template shadowrootmode="open"></template>');
|
1710
|
+
}
|
1713
1711
|
}
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
this.reactiveObjectGraph = new WeakMap();
|
1718
|
-
const { valueMutated, valueObserved, valueIsObservable, tagPropertyKey } = options;
|
1719
|
-
this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
|
1720
|
-
this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
|
1721
|
-
this.valueIsObservable = isFunction(valueIsObservable)
|
1722
|
-
? valueIsObservable
|
1723
|
-
: defaultValueIsObservable;
|
1724
|
-
this.tagPropertyKey = tagPropertyKey;
|
1712
|
+
async function serverSideRenderComponent(tagName, Component, props = {}, mode = DEFAULT_SSR_MODE) {
|
1713
|
+
if (typeof tagName !== 'string') {
|
1714
|
+
throw new Error(`tagName must be a string, found: ${tagName}`);
|
1725
1715
|
}
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1716
|
+
const generateMarkup = Component[SYMBOL__GENERATE_MARKUP];
|
1717
|
+
let markup = '';
|
1718
|
+
const emit = (segment) => {
|
1719
|
+
markup += segment;
|
1720
|
+
};
|
1721
|
+
if (mode === 'asyncYield') {
|
1722
|
+
for await (const segment of generateMarkup(tagName, props, null, null, null, null, null, null)) {
|
1723
|
+
markup += segment;
|
1734
1724
|
}
|
1735
|
-
return unwrappedValue;
|
1736
1725
|
}
|
1737
|
-
|
1738
|
-
|
1739
|
-
if (this.valueIsObservable(value)) {
|
1740
|
-
return this.getReadOnlyHandler(value);
|
1741
|
-
}
|
1742
|
-
return value;
|
1726
|
+
else if (mode === 'async') {
|
1727
|
+
await generateMarkup(emit, tagName, props, null, null, null, null, null, null);
|
1743
1728
|
}
|
1744
|
-
|
1745
|
-
|
1729
|
+
else if (mode === 'sync') {
|
1730
|
+
generateMarkup(emit, tagName, props, null, null, null, null, null, null);
|
1746
1731
|
}
|
1747
|
-
|
1748
|
-
|
1749
|
-
if (isUndefined(proxy)) {
|
1750
|
-
// caching the proxy after the first time it is accessed
|
1751
|
-
const handler = new ReactiveProxyHandler(this, value);
|
1752
|
-
proxy = new Proxy(createShadowTarget(value), handler);
|
1753
|
-
registerProxy(proxy, value);
|
1754
|
-
this.reactiveObjectGraph.set(value, proxy);
|
1755
|
-
}
|
1756
|
-
return proxy;
|
1732
|
+
else {
|
1733
|
+
throw new Error(`Invalid mode: ${mode}`);
|
1757
1734
|
}
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1735
|
+
return markup;
|
1736
|
+
}
|
1737
|
+
|
1738
|
+
/*
|
1739
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1740
|
+
* All rights reserved.
|
1741
|
+
* SPDX-License-Identifier: MIT
|
1742
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1743
|
+
*/
|
1744
|
+
/**
|
1745
|
+
* Given an object, render it for use as a text content node.
|
1746
|
+
* @param value
|
1747
|
+
*/
|
1748
|
+
function massageTextContent(value) {
|
1749
|
+
// Using non strict equality to align with original implementation (ex. undefined == null)
|
1750
|
+
// See: https://github.com/salesforce/lwc/blob/348130f/packages/%40lwc/engine-core/src/framework/api.ts#L548
|
1751
|
+
return value == null ? '' : String(value);
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
/*
|
1755
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1756
|
+
* All rights reserved.
|
1757
|
+
* SPDX-License-Identifier: MIT
|
1758
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1759
|
+
*/
|
1760
|
+
/**
|
1761
|
+
* Per the HTML spec on restrictions for "raw text elements" like `<style>`:
|
1762
|
+
*
|
1763
|
+
* > The text in raw text and escapable raw text elements must not contain any occurrences of the string
|
1764
|
+
* > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
|
1765
|
+
* > the element followed by one of:
|
1766
|
+
* > - U+0009 CHARACTER TABULATION (tab)
|
1767
|
+
* > - U+000A LINE FEED (LF)
|
1768
|
+
* > - U+000C FORM FEED (FF)
|
1769
|
+
* > - U+000D CARRIAGE RETURN (CR)
|
1770
|
+
* > - U+0020 SPACE
|
1771
|
+
* > - U+003E GREATER-THAN SIGN (>), or
|
1772
|
+
* > - U+002F SOLIDUS (/)
|
1773
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
|
1774
|
+
*/
|
1775
|
+
const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
|
1776
|
+
/**
|
1777
|
+
* The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
|
1778
|
+
* are disallowed inside of HTML templates.
|
1779
|
+
*
|
1780
|
+
* The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
|
1781
|
+
* which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
|
1782
|
+
* attacks like `</style><script>alert("pwned")</script>`.
|
1783
|
+
*
|
1784
|
+
* This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `<`,
|
1785
|
+
* `>`, etc., because these are treated as-is by the HTML parser.
|
1786
|
+
*
|
1787
|
+
*
|
1788
|
+
* @param contents CSS source to validate
|
1789
|
+
* @throws Throws if the contents provided are not valid.
|
1790
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
|
1791
|
+
* @see https://github.com/salesforce/lwc/issues/3439
|
1792
|
+
* @example
|
1793
|
+
* validateStyleTextContents('div { color: red }') // Ok
|
1794
|
+
* validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
|
1795
|
+
*/
|
1796
|
+
function validateStyleTextContents(contents) {
|
1797
|
+
if (INVALID_STYLE_CONTENT.test(contents)) {
|
1798
|
+
throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
|
1768
1799
|
}
|
1769
1800
|
}
|
1770
|
-
/** version: 2.0.0 */
|
1771
1801
|
|
1772
1802
|
/*
|
1773
1803
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -1775,12 +1805,79 @@ class ObservableMembrane {
|
|
1775
1805
|
* SPDX-License-Identifier: MIT
|
1776
1806
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1777
1807
|
*/
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1808
|
+
// Traverse in the same order as `flattenStylesheets` but without creating unnecessary additional arrays
|
1809
|
+
function traverseStylesheets(stylesheets, callback) {
|
1810
|
+
if (isArray$1(stylesheets)) {
|
1811
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
1812
|
+
traverseStylesheets(stylesheets[i], callback);
|
1813
|
+
}
|
1814
|
+
}
|
1815
|
+
else if (stylesheets) {
|
1816
|
+
callback(stylesheets);
|
1817
|
+
}
|
1818
|
+
}
|
1819
|
+
function hasScopedStaticStylesheets(Component) {
|
1820
|
+
let scoped = false;
|
1821
|
+
traverseStylesheets(Component.stylesheets, (stylesheet) => {
|
1822
|
+
scoped ||= !!stylesheet.$scoped$;
|
1823
|
+
});
|
1824
|
+
return scoped;
|
1825
|
+
}
|
1826
|
+
function renderStylesheets(defaultStylesheets, defaultScopedStylesheets, staticStylesheets, scopeToken, Component, hasScopedTemplateStyles) {
|
1827
|
+
const hasAnyScopedStyles = hasScopedTemplateStyles || hasScopedStaticStylesheets(Component);
|
1828
|
+
const { renderMode } = Component;
|
1829
|
+
let result = '';
|
1830
|
+
const renderStylesheet = (stylesheet) => {
|
1831
|
+
const { $scoped$: scoped } = stylesheet;
|
1832
|
+
const token = scoped ? scopeToken : undefined;
|
1833
|
+
const useActualHostSelector = !scoped || renderMode !== 'light';
|
1834
|
+
const useNativeDirPseudoclass = true;
|
1835
|
+
const styleContents = stylesheet(token, useActualHostSelector, useNativeDirPseudoclass);
|
1836
|
+
validateStyleTextContents(styleContents);
|
1837
|
+
// TODO [#2869]: `<style>`s should not have scope token classes
|
1838
|
+
result += `<style${hasAnyScopedStyles ? ` class="${scopeToken}"` : ''} type="text/css">${styleContents}</style>`;
|
1839
|
+
};
|
1840
|
+
traverseStylesheets(defaultStylesheets, renderStylesheet);
|
1841
|
+
traverseStylesheets(defaultScopedStylesheets, renderStylesheet);
|
1842
|
+
traverseStylesheets(staticStylesheets, renderStylesheet);
|
1843
|
+
return result;
|
1844
|
+
}
|
1845
|
+
|
1846
|
+
/*
|
1847
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
1848
|
+
* All rights reserved.
|
1849
|
+
* SPDX-License-Identifier: MIT
|
1850
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1851
|
+
*/
|
1852
|
+
/**
|
1853
|
+
* Converts an iterable into one that emits the object used by the [`iterator` directive](
|
1854
|
+
* https://lwc.dev/guide/html_templates#iterator).
|
1855
|
+
*/
|
1856
|
+
function* toIteratorDirective(iterable) {
|
1857
|
+
if (iterable === undefined || iterable === null)
|
1858
|
+
return;
|
1859
|
+
if (!iterable[Symbol.iterator]) {
|
1860
|
+
throw new Error(
|
1861
|
+
// Mimic error message from "[i]terable node" in engine-core's api.ts
|
1862
|
+
`Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
|
1863
|
+
}
|
1864
|
+
const iterator = iterable[Symbol.iterator]();
|
1865
|
+
let next = iterator.next();
|
1866
|
+
let index = 0;
|
1867
|
+
let { value, done: last = false } = next;
|
1868
|
+
while (last === false) {
|
1869
|
+
// using a look-back approach because we need to know if the element is the last
|
1870
|
+
next = iterator.next();
|
1871
|
+
last = next.done ?? false;
|
1872
|
+
yield {
|
1873
|
+
value,
|
1874
|
+
index,
|
1875
|
+
first: index === 0,
|
1876
|
+
last,
|
1877
|
+
};
|
1878
|
+
index += 1;
|
1879
|
+
value = next.value;
|
1880
|
+
}
|
1784
1881
|
}
|
1785
1882
|
|
1786
1883
|
/*
|
@@ -1860,7 +1957,9 @@ exports.hasScopedStaticStylesheets = hasScopedStaticStylesheets;
|
|
1860
1957
|
exports.hot = hot;
|
1861
1958
|
exports.htmlEscape = htmlEscape;
|
1862
1959
|
exports.isComponentConstructor = isComponentConstructor;
|
1960
|
+
exports.massageTextContent = massageTextContent;
|
1863
1961
|
exports.mutationTracker = mutationTracker;
|
1962
|
+
exports.normalizeClass = normalizeClass;
|
1864
1963
|
exports.parseFragment = parseFragment;
|
1865
1964
|
exports.parseSVGFragment = parseSVGFragment;
|
1866
1965
|
exports.readonly = readonly;
|
@@ -1885,5 +1984,5 @@ exports.track = track;
|
|
1885
1984
|
exports.unwrap = unwrap$1;
|
1886
1985
|
exports.validateStyleTextContents = validateStyleTextContents;
|
1887
1986
|
exports.wire = wire;
|
1888
|
-
/** version: 8.
|
1987
|
+
/** version: 8.12.0 */
|
1889
1988
|
//# sourceMappingURL=index.cjs.js.map
|