@lwc/ssr-runtime 8.6.0 → 8.8.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/get-read-only-proxy.d.ts +1 -0
- package/dist/index.cjs.js +816 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +812 -80
- package/dist/index.js.map +1 -1
- package/dist/reflection.d.ts +7 -2
- package/dist/render.d.ts +2 -2
- package/dist/stubs.d.ts +0 -1
- package/dist/wire.d.ts +8 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
@@ -11,9 +11,6 @@
|
|
11
11
|
function api(..._) {
|
12
12
|
throw new Error('@api cannot be used in SSR context.');
|
13
13
|
}
|
14
|
-
function createContextProvider(..._) {
|
15
|
-
throw new Error('createContextProvider cannot be used in SSR context.');
|
16
|
-
}
|
17
14
|
function createElement(..._) {
|
18
15
|
throw new Error('createElement cannot be used in SSR context.');
|
19
16
|
}
|
@@ -65,7 +62,7 @@ function swapTemplate(..._) {
|
|
65
62
|
function track(..._) {
|
66
63
|
throw new Error('@track cannot be used in SSR context.');
|
67
64
|
}
|
68
|
-
function unwrap(..._) {
|
65
|
+
function unwrap$1(..._) {
|
69
66
|
throw new Error('unwrap cannot be used in SSR context.');
|
70
67
|
}
|
71
68
|
function wire(..._) {
|
@@ -266,17 +263,17 @@ freeze,
|
|
266
263
|
/** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
|
267
264
|
fromEntries,
|
268
265
|
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
|
269
|
-
getOwnPropertyDescriptor,
|
266
|
+
getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
|
270
267
|
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
|
271
268
|
getOwnPropertyDescriptors,
|
272
269
|
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
|
273
|
-
getOwnPropertyNames,
|
270
|
+
getOwnPropertyNames: getOwnPropertyNames$1,
|
274
271
|
/** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
|
275
|
-
getOwnPropertySymbols,
|
272
|
+
getOwnPropertySymbols: getOwnPropertySymbols$1,
|
276
273
|
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
|
277
|
-
getPrototypeOf,
|
274
|
+
getPrototypeOf: getPrototypeOf$1,
|
278
275
|
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
|
279
|
-
hasOwnProperty,
|
276
|
+
hasOwnProperty: hasOwnProperty$1,
|
280
277
|
/** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
|
281
278
|
isFrozen,
|
282
279
|
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
|
@@ -287,16 +284,26 @@ seal,
|
|
287
284
|
setPrototypeOf, } = Object;
|
288
285
|
const {
|
289
286
|
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
290
|
-
isArray,
|
287
|
+
isArray: isArray$1,
|
291
288
|
/** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
|
292
289
|
from: ArrayFrom, } = Array;
|
293
290
|
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
|
294
291
|
// though it works fine for one, e.g. isArray), so comments for these are added to the export
|
295
292
|
// statement, rather than this declaration.
|
296
|
-
const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
|
293
|
+
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!
|
297
294
|
} = Array.prototype;
|
295
|
+
/** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
|
296
|
+
const { fromCharCode: StringFromCharCode } = String;
|
298
297
|
// No JSDocs here - see comment for Array.prototype
|
299
298
|
const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
|
299
|
+
/**
|
300
|
+
* Determines whether the argument is `undefined`.
|
301
|
+
* @param obj Value to test
|
302
|
+
* @returns `true` if the value is `undefined`.
|
303
|
+
*/
|
304
|
+
function isUndefined$1(obj) {
|
305
|
+
return obj === undefined;
|
306
|
+
}
|
300
307
|
/**
|
301
308
|
* Determines whether the argument is `null`.
|
302
309
|
* @param obj Value to test
|
@@ -305,19 +312,27 @@ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringRepla
|
|
305
312
|
function isNull(obj) {
|
306
313
|
return obj === null;
|
307
314
|
}
|
308
|
-
|
315
|
+
/**
|
316
|
+
* Determines whether the argument is a string.
|
317
|
+
* @param obj Value to test
|
318
|
+
* @returns `true` if the value is a string.
|
319
|
+
*/
|
320
|
+
function isString(obj) {
|
321
|
+
return typeof obj === 'string';
|
322
|
+
}
|
323
|
+
const OtS$1 = {}.toString;
|
309
324
|
/**
|
310
325
|
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
311
326
|
* Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
|
312
327
|
* @param obj Value to convert to a string.
|
313
328
|
* @returns String representation of the value.
|
314
329
|
*/
|
315
|
-
function toString(obj) {
|
330
|
+
function toString$1(obj) {
|
316
331
|
if (obj?.toString) {
|
317
332
|
// Arrays might hold objects with "null" prototype So using
|
318
333
|
// Array.prototype.toString directly will cause an error Iterate through
|
319
334
|
// all the items and handle individually.
|
320
|
-
if (isArray(obj)) {
|
335
|
+
if (isArray$1(obj)) {
|
321
336
|
// This behavior is slightly different from Array#toString:
|
322
337
|
// 1. Array#toString calls `this.join`, rather than Array#join
|
323
338
|
// Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
|
@@ -328,13 +343,13 @@ function toString(obj) {
|
|
328
343
|
// 4. Array#toString converts recursive references to arrays to ''
|
329
344
|
// Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
|
330
345
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
|
331
|
-
return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
346
|
+
return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
|
332
347
|
}
|
333
348
|
return obj.toString();
|
334
349
|
}
|
335
350
|
else if (typeof obj === 'object') {
|
336
351
|
// This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
|
337
|
-
return OtS.call(obj);
|
352
|
+
return OtS$1.call(obj);
|
338
353
|
}
|
339
354
|
else {
|
340
355
|
return String(obj);
|
@@ -419,11 +434,114 @@ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (
|
|
419
434
|
// Synthetic creation of all AOM property descriptors for Custom Elements
|
420
435
|
forEach.call(AriaPropertyNames, (propName) => {
|
421
436
|
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
|
437
|
+
// These type assertions are because the map types are a 1:1 mapping of ariaX to aria-x.
|
438
|
+
// TypeScript knows we have one of ariaX | ariaY and one of aria-x | aria-y, and tries to
|
439
|
+
// prevent us from doing ariaX: aria-y, but we that it's safe.
|
422
440
|
AriaAttrNameToPropNameMap[attrName] = propName;
|
423
441
|
AriaPropNameToAttrNameMap[propName] = attrName;
|
424
442
|
});
|
425
443
|
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
|
426
444
|
})();
|
445
|
+
/**
|
446
|
+
*
|
447
|
+
* @param attrName
|
448
|
+
*/
|
449
|
+
function isAriaAttribute(attrName) {
|
450
|
+
return attrName in AriaAttrNameToPropNameMap;
|
451
|
+
}
|
452
|
+
// This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
453
|
+
const GLOBAL_ATTRIBUTE = /*@__PURE__*/ new Set([
|
454
|
+
'accesskey',
|
455
|
+
'autocapitalize',
|
456
|
+
'autofocus',
|
457
|
+
'class',
|
458
|
+
'contenteditable',
|
459
|
+
'contextmenu',
|
460
|
+
'dir',
|
461
|
+
'draggable',
|
462
|
+
'enterkeyhint',
|
463
|
+
'exportparts',
|
464
|
+
'hidden',
|
465
|
+
'id',
|
466
|
+
'inputmode',
|
467
|
+
'is',
|
468
|
+
'itemid',
|
469
|
+
'itemprop',
|
470
|
+
'itemref',
|
471
|
+
'itemscope',
|
472
|
+
'itemtype',
|
473
|
+
'lang',
|
474
|
+
'nonce',
|
475
|
+
'part',
|
476
|
+
'slot',
|
477
|
+
'spellcheck',
|
478
|
+
'style',
|
479
|
+
'tabindex',
|
480
|
+
'title',
|
481
|
+
'translate',
|
482
|
+
]);
|
483
|
+
/**
|
484
|
+
*
|
485
|
+
* @param attrName
|
486
|
+
*/
|
487
|
+
function isGlobalHtmlAttribute(attrName) {
|
488
|
+
return GLOBAL_ATTRIBUTE.has(attrName);
|
489
|
+
}
|
490
|
+
// These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
|
491
|
+
const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
|
492
|
+
['accessKey', 'accesskey'],
|
493
|
+
['readOnly', 'readonly'],
|
494
|
+
['tabIndex', 'tabindex'],
|
495
|
+
['bgColor', 'bgcolor'],
|
496
|
+
['colSpan', 'colspan'],
|
497
|
+
['rowSpan', 'rowspan'],
|
498
|
+
['contentEditable', 'contenteditable'],
|
499
|
+
['crossOrigin', 'crossorigin'],
|
500
|
+
['dateTime', 'datetime'],
|
501
|
+
['formAction', 'formaction'],
|
502
|
+
['isMap', 'ismap'],
|
503
|
+
['maxLength', 'maxlength'],
|
504
|
+
['minLength', 'minlength'],
|
505
|
+
['noValidate', 'novalidate'],
|
506
|
+
['useMap', 'usemap'],
|
507
|
+
['htmlFor', 'for'],
|
508
|
+
]);
|
509
|
+
/**
|
510
|
+
* Map associating previously transformed HTML property into HTML attribute.
|
511
|
+
*/
|
512
|
+
const CACHED_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map();
|
513
|
+
/**
|
514
|
+
*
|
515
|
+
* @param propName
|
516
|
+
*/
|
517
|
+
function htmlPropertyToAttribute(propName) {
|
518
|
+
const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
|
519
|
+
if (!isUndefined$1(ariaAttributeName)) {
|
520
|
+
return ariaAttributeName;
|
521
|
+
}
|
522
|
+
const specialAttributeName = SPECIAL_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
523
|
+
if (!isUndefined$1(specialAttributeName)) {
|
524
|
+
return specialAttributeName;
|
525
|
+
}
|
526
|
+
const cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
527
|
+
if (!isUndefined$1(cachedAttributeName)) {
|
528
|
+
return cachedAttributeName;
|
529
|
+
}
|
530
|
+
let attributeName = '';
|
531
|
+
for (let i = 0, len = propName.length; i < len; i++) {
|
532
|
+
const code = StringCharCodeAt.call(propName, i);
|
533
|
+
if (code >= 65 && // "A"
|
534
|
+
code <= 90 // "Z"
|
535
|
+
) {
|
536
|
+
attributeName += '-' + StringFromCharCode(code + 32);
|
537
|
+
}
|
538
|
+
else {
|
539
|
+
attributeName += StringFromCharCode(code);
|
540
|
+
}
|
541
|
+
}
|
542
|
+
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
543
|
+
return attributeName;
|
544
|
+
}
|
427
545
|
|
428
546
|
/*
|
429
547
|
* Copyright (c) 2020, salesforce.com, inc.
|
@@ -473,7 +591,7 @@ function setHooks(hooks) {
|
|
473
591
|
function flattenStylesheets(stylesheets) {
|
474
592
|
const list = [];
|
475
593
|
for (const stylesheet of stylesheets) {
|
476
|
-
if (!isArray(stylesheet)) {
|
594
|
+
if (!isArray$1(stylesheet)) {
|
477
595
|
list.push(stylesheet);
|
478
596
|
}
|
479
597
|
else {
|
@@ -482,7 +600,7 @@ function flattenStylesheets(stylesheets) {
|
|
482
600
|
}
|
483
601
|
return list;
|
484
602
|
}
|
485
|
-
/** version: 8.
|
603
|
+
/** version: 8.8.0 */
|
486
604
|
|
487
605
|
/*
|
488
606
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -643,21 +761,25 @@ const mutationTracker = new MutationTracker();
|
|
643
761
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
644
762
|
*/
|
645
763
|
/**
|
646
|
-
*
|
647
|
-
*
|
764
|
+
* Filters out the following types of properties that should not be set.
|
765
|
+
* - Properties that are not public.
|
766
|
+
* - Properties that are not global.
|
767
|
+
* - Properties that are global but are internally overridden.
|
648
768
|
*/
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
});
|
769
|
+
function filterProperties(props, publicFields, privateFields) {
|
770
|
+
const propsToAssign = create(null);
|
771
|
+
const publicFieldSet = new Set(publicFields);
|
772
|
+
const privateFieldSet = new Set(privateFields);
|
773
|
+
keys(props).forEach((propName) => {
|
774
|
+
const attrName = htmlPropertyToAttribute(propName);
|
775
|
+
if (publicFieldSet.has(propName) ||
|
776
|
+
((isGlobalHtmlAttribute(attrName) || isAriaAttribute(attrName)) &&
|
777
|
+
!privateFieldSet.has(propName))) {
|
778
|
+
propsToAssign[propName] = props[propName];
|
779
|
+
}
|
780
|
+
});
|
781
|
+
return propsToAssign;
|
782
|
+
}
|
661
783
|
/**
|
662
784
|
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
663
785
|
*/
|
@@ -733,21 +855,11 @@ const ariaDescriptor = (attrName) => ({
|
|
733
855
|
this.removeAttribute(attrName);
|
734
856
|
}
|
735
857
|
else {
|
736
|
-
this.setAttribute(attrName, toString(newValue));
|
858
|
+
this.setAttribute(attrName, toString$1(newValue));
|
737
859
|
}
|
738
860
|
}
|
739
861
|
},
|
740
862
|
});
|
741
|
-
function reflectAttrToProp(instance, attrName, attrValue) {
|
742
|
-
const reflectedPropName = attrsToProps[attrName];
|
743
|
-
// If it is a reflected property and it was not overridden by the instance
|
744
|
-
if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
|
745
|
-
const currentValue = instance[reflectedPropName];
|
746
|
-
if (currentValue !== attrValue) {
|
747
|
-
instance[reflectedPropName] = attrValue;
|
748
|
-
}
|
749
|
-
}
|
750
|
-
}
|
751
863
|
const descriptors = {
|
752
864
|
accessKey: stringDescriptor('accesskey'),
|
753
865
|
dir: stringDescriptor('dir'),
|
@@ -767,7 +879,7 @@ const descriptors = {
|
|
767
879
|
const num = Number(newValue);
|
768
880
|
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
769
881
|
if (normalizedValue !== currentValue) {
|
770
|
-
this.setAttribute('tabindex', toString(newValue));
|
882
|
+
this.setAttribute('tabindex', toString$1(newValue));
|
771
883
|
}
|
772
884
|
},
|
773
885
|
},
|
@@ -816,27 +928,25 @@ class LightningElement {
|
|
816
928
|
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
817
929
|
}
|
818
930
|
setAttribute(attrName, attrValue) {
|
819
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
931
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
820
932
|
const normalizedValue = String(attrValue);
|
821
933
|
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
822
|
-
reflectAttrToProp(this, normalizedName, normalizedValue);
|
823
934
|
mutationTracker.add(this, normalizedName);
|
824
935
|
}
|
825
936
|
getAttribute(attrName) {
|
826
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
827
|
-
if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
937
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
938
|
+
if (hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
828
939
|
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
829
940
|
}
|
830
941
|
return null;
|
831
942
|
}
|
832
943
|
hasAttribute(attrName) {
|
833
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
834
|
-
return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
944
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
945
|
+
return hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
835
946
|
}
|
836
947
|
removeAttribute(attrName) {
|
837
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
948
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
838
949
|
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
839
|
-
reflectAttrToProp(this, normalizedName, null);
|
840
950
|
// Track mutations for removal of non-existing attributes
|
841
951
|
mutationTracker.add(this, normalizedName);
|
842
952
|
}
|
@@ -922,36 +1032,42 @@ defineProperties(LightningElement.prototype, descriptors);
|
|
922
1032
|
* SPDX-License-Identifier: MIT
|
923
1033
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
924
1034
|
*/
|
925
|
-
const escapeAttrVal = (
|
926
|
-
function
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
1035
|
+
const escapeAttrVal = (attrValue) => attrValue.replaceAll('&', '&').replaceAll('"', '"');
|
1036
|
+
function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
|
1037
|
+
// The scopeToken is e.g. `lwc-xyz123` which is the token our parent gives us.
|
1038
|
+
// The hostScopeToken is e.g. `lwc-abc456-host` which is the token for our own component.
|
1039
|
+
// It's possible to have both, one, the other, or neither.
|
1040
|
+
const combinedScopeToken = scopeToken && hostScopeToken
|
1041
|
+
? `${scopeToken} ${hostScopeToken}`
|
1042
|
+
: scopeToken || hostScopeToken || '';
|
1043
|
+
let result = '';
|
1044
|
+
let hasClassAttribute = false;
|
1045
|
+
for (const attrName of getOwnPropertyNames$1(attrs)) {
|
1046
|
+
let attrValue = attrs[attrName];
|
1047
|
+
if (isNull(attrValue) || isUndefined$1(attrValue)) {
|
1048
|
+
attrValue = '';
|
934
1049
|
}
|
935
|
-
else if (
|
936
|
-
|
1050
|
+
else if (!isString(attrValue)) {
|
1051
|
+
attrValue = String(attrValue);
|
937
1052
|
}
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
function renderAttrsNoYield(emit, instance, attrs) {
|
942
|
-
if (!attrs) {
|
943
|
-
return;
|
944
|
-
}
|
945
|
-
for (const attrName of Object.getOwnPropertyNames(attrs)) {
|
946
|
-
const attrVal = attrs[attrName];
|
947
|
-
if (typeof attrVal === 'string') {
|
948
|
-
emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
|
949
|
-
}
|
950
|
-
else if (attrVal === null) {
|
951
|
-
emit('');
|
1053
|
+
if (combinedScopeToken && attrName === 'class') {
|
1054
|
+
attrValue += ' ' + combinedScopeToken;
|
1055
|
+
hasClassAttribute = true;
|
952
1056
|
}
|
1057
|
+
result += attrValue === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrValue)}"`;
|
1058
|
+
}
|
1059
|
+
// If we didn't render any `class` attribute, render one for the scope token(s)
|
1060
|
+
if (!hasClassAttribute && combinedScopeToken) {
|
1061
|
+
result += ` class="${combinedScopeToken}"`;
|
953
1062
|
}
|
954
|
-
|
1063
|
+
result += mutationTracker.renderMutatedAttrs(instance);
|
1064
|
+
return result;
|
1065
|
+
}
|
1066
|
+
function* renderAttrs(instance, attrs, hostScopeToken, scopeToken) {
|
1067
|
+
yield renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken);
|
1068
|
+
}
|
1069
|
+
function renderAttrsNoYield(emit, instance, attrs, hostScopeToken, scopeToken) {
|
1070
|
+
emit(renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken));
|
955
1071
|
}
|
956
1072
|
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
957
1073
|
if (Cmp.renderMode !== 'light') {
|
@@ -1105,6 +1221,622 @@ function* toIteratorDirective(iterable) {
|
|
1105
1221
|
}
|
1106
1222
|
}
|
1107
1223
|
|
1108
|
-
|
1109
|
-
|
1224
|
+
/**
|
1225
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
1226
|
+
*/
|
1227
|
+
const { isArray } = Array;
|
1228
|
+
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
1229
|
+
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
1230
|
+
const OtS = {}.toString;
|
1231
|
+
function toString(obj) {
|
1232
|
+
if (obj && obj.toString) {
|
1233
|
+
return obj.toString();
|
1234
|
+
}
|
1235
|
+
else if (typeof obj === 'object') {
|
1236
|
+
return OtS.call(obj);
|
1237
|
+
}
|
1238
|
+
else {
|
1239
|
+
return obj + '';
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
function isUndefined(obj) {
|
1243
|
+
return obj === undefined;
|
1244
|
+
}
|
1245
|
+
function isFunction(obj) {
|
1246
|
+
return typeof obj === 'function';
|
1247
|
+
}
|
1248
|
+
const proxyToValueMap = new WeakMap();
|
1249
|
+
function registerProxy(proxy, value) {
|
1250
|
+
proxyToValueMap.set(proxy, value);
|
1251
|
+
}
|
1252
|
+
const unwrap = (replicaOrAny) => proxyToValueMap.get(replicaOrAny) || replicaOrAny;
|
1253
|
+
|
1254
|
+
class BaseProxyHandler {
|
1255
|
+
constructor(membrane, value) {
|
1256
|
+
this.originalTarget = value;
|
1257
|
+
this.membrane = membrane;
|
1258
|
+
}
|
1259
|
+
// Shared utility methods
|
1260
|
+
wrapDescriptor(descriptor) {
|
1261
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
1262
|
+
descriptor.value = this.wrapValue(descriptor.value);
|
1263
|
+
}
|
1264
|
+
else {
|
1265
|
+
const { set: originalSet, get: originalGet } = descriptor;
|
1266
|
+
if (!isUndefined(originalGet)) {
|
1267
|
+
descriptor.get = this.wrapGetter(originalGet);
|
1268
|
+
}
|
1269
|
+
if (!isUndefined(originalSet)) {
|
1270
|
+
descriptor.set = this.wrapSetter(originalSet);
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
return descriptor;
|
1274
|
+
}
|
1275
|
+
copyDescriptorIntoShadowTarget(shadowTarget, key) {
|
1276
|
+
const { originalTarget } = this;
|
1277
|
+
// Note: a property might get defined multiple times in the shadowTarget
|
1278
|
+
// but it will always be compatible with the previous descriptor
|
1279
|
+
// to preserve the object invariants, which makes these lines safe.
|
1280
|
+
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
|
1281
|
+
// TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
|
1282
|
+
/* istanbul ignore else */
|
1283
|
+
if (!isUndefined(originalDescriptor)) {
|
1284
|
+
const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
1285
|
+
ObjectDefineProperty(shadowTarget, key, wrappedDesc);
|
1286
|
+
}
|
1287
|
+
}
|
1288
|
+
lockShadowTarget(shadowTarget) {
|
1289
|
+
const { originalTarget } = this;
|
1290
|
+
const targetKeys = ArrayConcat.call(getOwnPropertyNames(originalTarget), getOwnPropertySymbols(originalTarget));
|
1291
|
+
targetKeys.forEach((key) => {
|
1292
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
1293
|
+
});
|
1294
|
+
const { membrane: { tagPropertyKey }, } = this;
|
1295
|
+
if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
|
1296
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
|
1297
|
+
}
|
1298
|
+
preventExtensions(shadowTarget);
|
1299
|
+
}
|
1300
|
+
// Shared Traps
|
1301
|
+
// TODO: apply() is never called
|
1302
|
+
/* istanbul ignore next */
|
1303
|
+
apply(shadowTarget, thisArg, argArray) {
|
1304
|
+
/* No op */
|
1305
|
+
}
|
1306
|
+
// TODO: construct() is never called
|
1307
|
+
/* istanbul ignore next */
|
1308
|
+
construct(shadowTarget, argArray, newTarget) {
|
1309
|
+
/* No op */
|
1310
|
+
}
|
1311
|
+
get(shadowTarget, key) {
|
1312
|
+
const { originalTarget, membrane: { valueObserved }, } = this;
|
1313
|
+
const value = originalTarget[key];
|
1314
|
+
valueObserved(originalTarget, key);
|
1315
|
+
return this.wrapValue(value);
|
1316
|
+
}
|
1317
|
+
has(shadowTarget, key) {
|
1318
|
+
const { originalTarget, membrane: { tagPropertyKey, valueObserved }, } = this;
|
1319
|
+
valueObserved(originalTarget, key);
|
1320
|
+
// since key is never going to be undefined, and tagPropertyKey might be undefined
|
1321
|
+
// we can simply compare them as the second part of the condition.
|
1322
|
+
return key in originalTarget || key === tagPropertyKey;
|
1323
|
+
}
|
1324
|
+
ownKeys(shadowTarget) {
|
1325
|
+
const { originalTarget, membrane: { tagPropertyKey }, } = this;
|
1326
|
+
// if the membrane tag key exists and it is not in the original target, we add it to the keys.
|
1327
|
+
const keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey)
|
1328
|
+
? []
|
1329
|
+
: [tagPropertyKey];
|
1330
|
+
// small perf optimization using push instead of concat to avoid creating an extra array
|
1331
|
+
ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
|
1332
|
+
ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
|
1333
|
+
return keys;
|
1334
|
+
}
|
1335
|
+
isExtensible(shadowTarget) {
|
1336
|
+
const { originalTarget } = this;
|
1337
|
+
// optimization to avoid attempting to lock down the shadowTarget multiple times
|
1338
|
+
if (!isExtensible(shadowTarget)) {
|
1339
|
+
return false; // was already locked down
|
1340
|
+
}
|
1341
|
+
if (!isExtensible(originalTarget)) {
|
1342
|
+
this.lockShadowTarget(shadowTarget);
|
1343
|
+
return false;
|
1344
|
+
}
|
1345
|
+
return true;
|
1346
|
+
}
|
1347
|
+
getPrototypeOf(shadowTarget) {
|
1348
|
+
const { originalTarget } = this;
|
1349
|
+
return getPrototypeOf(originalTarget);
|
1350
|
+
}
|
1351
|
+
getOwnPropertyDescriptor(shadowTarget, key) {
|
1352
|
+
const { originalTarget, membrane: { valueObserved, tagPropertyKey }, } = this;
|
1353
|
+
// keys looked up via getOwnPropertyDescriptor need to be reactive
|
1354
|
+
valueObserved(originalTarget, key);
|
1355
|
+
let desc = getOwnPropertyDescriptor(originalTarget, key);
|
1356
|
+
if (isUndefined(desc)) {
|
1357
|
+
if (key !== tagPropertyKey) {
|
1358
|
+
return undefined;
|
1359
|
+
}
|
1360
|
+
// if the key is the membrane tag key, and is not in the original target,
|
1361
|
+
// we produce a synthetic descriptor and install it on the shadow target
|
1362
|
+
desc = { value: undefined, writable: false, configurable: false, enumerable: false };
|
1363
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
|
1364
|
+
return desc;
|
1365
|
+
}
|
1366
|
+
if (desc.configurable === false) {
|
1367
|
+
// updating the descriptor to non-configurable on the shadow
|
1368
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
1369
|
+
}
|
1370
|
+
// Note: by accessing the descriptor, the key is marked as observed
|
1371
|
+
// but access to the value, setter or getter (if available) cannot observe
|
1372
|
+
// mutations, just like regular methods, in which case we just do nothing.
|
1373
|
+
return this.wrapDescriptor(desc);
|
1374
|
+
}
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
const getterMap$1 = new WeakMap();
|
1378
|
+
const setterMap$1 = new WeakMap();
|
1379
|
+
const reverseGetterMap = new WeakMap();
|
1380
|
+
const reverseSetterMap = new WeakMap();
|
1381
|
+
class ReactiveProxyHandler extends BaseProxyHandler {
|
1382
|
+
wrapValue(value) {
|
1383
|
+
return this.membrane.getProxy(value);
|
1384
|
+
}
|
1385
|
+
wrapGetter(originalGet) {
|
1386
|
+
const wrappedGetter = getterMap$1.get(originalGet);
|
1387
|
+
if (!isUndefined(wrappedGetter)) {
|
1388
|
+
return wrappedGetter;
|
1389
|
+
}
|
1390
|
+
const handler = this;
|
1391
|
+
const get = function () {
|
1392
|
+
// invoking the original getter with the original target
|
1393
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
1394
|
+
};
|
1395
|
+
getterMap$1.set(originalGet, get);
|
1396
|
+
reverseGetterMap.set(get, originalGet);
|
1397
|
+
return get;
|
1398
|
+
}
|
1399
|
+
wrapSetter(originalSet) {
|
1400
|
+
const wrappedSetter = setterMap$1.get(originalSet);
|
1401
|
+
if (!isUndefined(wrappedSetter)) {
|
1402
|
+
return wrappedSetter;
|
1403
|
+
}
|
1404
|
+
const set = function (v) {
|
1405
|
+
// invoking the original setter with the original target
|
1406
|
+
originalSet.call(unwrap(this), unwrap(v));
|
1407
|
+
};
|
1408
|
+
setterMap$1.set(originalSet, set);
|
1409
|
+
reverseSetterMap.set(set, originalSet);
|
1410
|
+
return set;
|
1411
|
+
}
|
1412
|
+
unwrapDescriptor(descriptor) {
|
1413
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
1414
|
+
// dealing with a data descriptor
|
1415
|
+
descriptor.value = unwrap(descriptor.value);
|
1416
|
+
}
|
1417
|
+
else {
|
1418
|
+
const { set, get } = descriptor;
|
1419
|
+
if (!isUndefined(get)) {
|
1420
|
+
descriptor.get = this.unwrapGetter(get);
|
1421
|
+
}
|
1422
|
+
if (!isUndefined(set)) {
|
1423
|
+
descriptor.set = this.unwrapSetter(set);
|
1424
|
+
}
|
1425
|
+
}
|
1426
|
+
return descriptor;
|
1427
|
+
}
|
1428
|
+
unwrapGetter(redGet) {
|
1429
|
+
const reverseGetter = reverseGetterMap.get(redGet);
|
1430
|
+
if (!isUndefined(reverseGetter)) {
|
1431
|
+
return reverseGetter;
|
1432
|
+
}
|
1433
|
+
const handler = this;
|
1434
|
+
const get = function () {
|
1435
|
+
// invoking the red getter with the proxy of this
|
1436
|
+
return unwrap(redGet.call(handler.wrapValue(this)));
|
1437
|
+
};
|
1438
|
+
getterMap$1.set(get, redGet);
|
1439
|
+
reverseGetterMap.set(redGet, get);
|
1440
|
+
return get;
|
1441
|
+
}
|
1442
|
+
unwrapSetter(redSet) {
|
1443
|
+
const reverseSetter = reverseSetterMap.get(redSet);
|
1444
|
+
if (!isUndefined(reverseSetter)) {
|
1445
|
+
return reverseSetter;
|
1446
|
+
}
|
1447
|
+
const handler = this;
|
1448
|
+
const set = function (v) {
|
1449
|
+
// invoking the red setter with the proxy of this
|
1450
|
+
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
1451
|
+
};
|
1452
|
+
setterMap$1.set(set, redSet);
|
1453
|
+
reverseSetterMap.set(redSet, set);
|
1454
|
+
return set;
|
1455
|
+
}
|
1456
|
+
set(shadowTarget, key, value) {
|
1457
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
1458
|
+
const oldValue = originalTarget[key];
|
1459
|
+
if (oldValue !== value) {
|
1460
|
+
originalTarget[key] = value;
|
1461
|
+
valueMutated(originalTarget, key);
|
1462
|
+
}
|
1463
|
+
else if (key === 'length' && isArray(originalTarget)) {
|
1464
|
+
// fix for issue #236: push will add the new index, and by the time length
|
1465
|
+
// is updated, the internal length is already equal to the new length value
|
1466
|
+
// therefore, the oldValue is equal to the value. This is the forking logic
|
1467
|
+
// to support this use case.
|
1468
|
+
valueMutated(originalTarget, key);
|
1469
|
+
}
|
1470
|
+
return true;
|
1471
|
+
}
|
1472
|
+
deleteProperty(shadowTarget, key) {
|
1473
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
1474
|
+
delete originalTarget[key];
|
1475
|
+
valueMutated(originalTarget, key);
|
1476
|
+
return true;
|
1477
|
+
}
|
1478
|
+
setPrototypeOf(shadowTarget, prototype) {
|
1479
|
+
/* istanbul ignore else */
|
1480
|
+
if (process.env.NODE_ENV !== 'production') {
|
1481
|
+
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
1482
|
+
}
|
1483
|
+
}
|
1484
|
+
preventExtensions(shadowTarget) {
|
1485
|
+
if (isExtensible(shadowTarget)) {
|
1486
|
+
const { originalTarget } = this;
|
1487
|
+
preventExtensions(originalTarget);
|
1488
|
+
// if the originalTarget is a proxy itself, it might reject
|
1489
|
+
// the preventExtension call, in which case we should not attempt to lock down
|
1490
|
+
// the shadow target.
|
1491
|
+
// TODO: It should not actually be possible to reach this `if` statement.
|
1492
|
+
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
1493
|
+
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
1494
|
+
/* istanbul ignore if */
|
1495
|
+
if (isExtensible(originalTarget)) {
|
1496
|
+
return false;
|
1497
|
+
}
|
1498
|
+
this.lockShadowTarget(shadowTarget);
|
1499
|
+
}
|
1500
|
+
return true;
|
1501
|
+
}
|
1502
|
+
defineProperty(shadowTarget, key, descriptor) {
|
1503
|
+
const { originalTarget, membrane: { valueMutated, tagPropertyKey }, } = this;
|
1504
|
+
if (key === tagPropertyKey && !hasOwnProperty.call(originalTarget, key)) {
|
1505
|
+
// To avoid leaking the membrane tag property into the original target, we must
|
1506
|
+
// be sure that the original target doesn't have yet.
|
1507
|
+
// NOTE: we do not return false here because Object.freeze and equivalent operations
|
1508
|
+
// will attempt to set the descriptor to the same value, and expect no to throw. This
|
1509
|
+
// is an small compromise for the sake of not having to diff the descriptors.
|
1510
|
+
return true;
|
1511
|
+
}
|
1512
|
+
ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor));
|
1513
|
+
// intentionally testing if false since it could be undefined as well
|
1514
|
+
if (descriptor.configurable === false) {
|
1515
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
1516
|
+
}
|
1517
|
+
valueMutated(originalTarget, key);
|
1518
|
+
return true;
|
1519
|
+
}
|
1520
|
+
}
|
1521
|
+
|
1522
|
+
const getterMap = new WeakMap();
|
1523
|
+
const setterMap = new WeakMap();
|
1524
|
+
class ReadOnlyHandler extends BaseProxyHandler {
|
1525
|
+
wrapValue(value) {
|
1526
|
+
return this.membrane.getReadOnlyProxy(value);
|
1527
|
+
}
|
1528
|
+
wrapGetter(originalGet) {
|
1529
|
+
const wrappedGetter = getterMap.get(originalGet);
|
1530
|
+
if (!isUndefined(wrappedGetter)) {
|
1531
|
+
return wrappedGetter;
|
1532
|
+
}
|
1533
|
+
const handler = this;
|
1534
|
+
const get = function () {
|
1535
|
+
// invoking the original getter with the original target
|
1536
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
1537
|
+
};
|
1538
|
+
getterMap.set(originalGet, get);
|
1539
|
+
return get;
|
1540
|
+
}
|
1541
|
+
wrapSetter(originalSet) {
|
1542
|
+
const wrappedSetter = setterMap.get(originalSet);
|
1543
|
+
if (!isUndefined(wrappedSetter)) {
|
1544
|
+
return wrappedSetter;
|
1545
|
+
}
|
1546
|
+
const handler = this;
|
1547
|
+
const set = function (v) {
|
1548
|
+
/* istanbul ignore else */
|
1549
|
+
if (process.env.NODE_ENV !== 'production') {
|
1550
|
+
const { originalTarget } = handler;
|
1551
|
+
throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1552
|
+
}
|
1553
|
+
};
|
1554
|
+
setterMap.set(originalSet, set);
|
1555
|
+
return set;
|
1556
|
+
}
|
1557
|
+
set(shadowTarget, key, value) {
|
1558
|
+
/* istanbul ignore else */
|
1559
|
+
if (process.env.NODE_ENV !== 'production') {
|
1560
|
+
const { originalTarget } = this;
|
1561
|
+
const msg = isArray(originalTarget)
|
1562
|
+
? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.`
|
1563
|
+
: `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
1564
|
+
throw new Error(msg);
|
1565
|
+
}
|
1566
|
+
/* istanbul ignore next */
|
1567
|
+
return false;
|
1568
|
+
}
|
1569
|
+
deleteProperty(shadowTarget, key) {
|
1570
|
+
/* istanbul ignore else */
|
1571
|
+
if (process.env.NODE_ENV !== 'production') {
|
1572
|
+
const { originalTarget } = this;
|
1573
|
+
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1574
|
+
}
|
1575
|
+
/* istanbul ignore next */
|
1576
|
+
return false;
|
1577
|
+
}
|
1578
|
+
setPrototypeOf(shadowTarget, prototype) {
|
1579
|
+
/* istanbul ignore else */
|
1580
|
+
if (process.env.NODE_ENV !== 'production') {
|
1581
|
+
const { originalTarget } = this;
|
1582
|
+
throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
1583
|
+
}
|
1584
|
+
}
|
1585
|
+
preventExtensions(shadowTarget) {
|
1586
|
+
/* istanbul ignore else */
|
1587
|
+
if (process.env.NODE_ENV !== 'production') {
|
1588
|
+
const { originalTarget } = this;
|
1589
|
+
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
1590
|
+
}
|
1591
|
+
/* istanbul ignore next */
|
1592
|
+
return false;
|
1593
|
+
}
|
1594
|
+
defineProperty(shadowTarget, key, descriptor) {
|
1595
|
+
/* istanbul ignore else */
|
1596
|
+
if (process.env.NODE_ENV !== 'production') {
|
1597
|
+
const { originalTarget } = this;
|
1598
|
+
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1599
|
+
}
|
1600
|
+
/* istanbul ignore next */
|
1601
|
+
return false;
|
1602
|
+
}
|
1603
|
+
}
|
1604
|
+
|
1605
|
+
function extract(objectOrArray) {
|
1606
|
+
if (isArray(objectOrArray)) {
|
1607
|
+
return objectOrArray.map((item) => {
|
1608
|
+
const original = unwrap(item);
|
1609
|
+
if (original !== item) {
|
1610
|
+
return extract(original);
|
1611
|
+
}
|
1612
|
+
return item;
|
1613
|
+
});
|
1614
|
+
}
|
1615
|
+
const obj = ObjectCreate(getPrototypeOf(objectOrArray));
|
1616
|
+
const names = getOwnPropertyNames(objectOrArray);
|
1617
|
+
return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
1618
|
+
const item = objectOrArray[key];
|
1619
|
+
const original = unwrap(item);
|
1620
|
+
if (original !== item) {
|
1621
|
+
seed[key] = extract(original);
|
1622
|
+
}
|
1623
|
+
else {
|
1624
|
+
seed[key] = item;
|
1625
|
+
}
|
1626
|
+
return seed;
|
1627
|
+
}, obj);
|
1628
|
+
}
|
1629
|
+
const formatter = {
|
1630
|
+
header: (plainOrProxy) => {
|
1631
|
+
const originalTarget = unwrap(plainOrProxy);
|
1632
|
+
// if originalTarget is falsy or not unwrappable, exit
|
1633
|
+
if (!originalTarget || originalTarget === plainOrProxy) {
|
1634
|
+
return null;
|
1635
|
+
}
|
1636
|
+
const obj = extract(plainOrProxy);
|
1637
|
+
return ['object', { object: obj }];
|
1638
|
+
},
|
1639
|
+
hasBody: () => {
|
1640
|
+
return false;
|
1641
|
+
},
|
1642
|
+
body: () => {
|
1643
|
+
return null;
|
1644
|
+
},
|
1645
|
+
};
|
1646
|
+
// Inspired from paulmillr/es6-shim
|
1647
|
+
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
1648
|
+
/* istanbul ignore next */
|
1649
|
+
function getGlobal() {
|
1650
|
+
// the only reliable means to get the global object is `Function('return this')()`
|
1651
|
+
// However, this causes CSP violations in Chrome apps.
|
1652
|
+
if (typeof globalThis !== 'undefined') {
|
1653
|
+
return globalThis;
|
1654
|
+
}
|
1655
|
+
if (typeof self !== 'undefined') {
|
1656
|
+
return self;
|
1657
|
+
}
|
1658
|
+
if (typeof window !== 'undefined') {
|
1659
|
+
return window;
|
1660
|
+
}
|
1661
|
+
if (typeof global !== 'undefined') {
|
1662
|
+
return global;
|
1663
|
+
}
|
1664
|
+
// Gracefully degrade if not able to locate the global object
|
1665
|
+
return {};
|
1666
|
+
}
|
1667
|
+
function init() {
|
1668
|
+
/* istanbul ignore if */
|
1669
|
+
if (process.env.NODE_ENV === 'production') {
|
1670
|
+
// this method should never leak to prod
|
1671
|
+
throw new ReferenceError();
|
1672
|
+
}
|
1673
|
+
const global = getGlobal();
|
1674
|
+
// Custom Formatter for Dev Tools. To enable this, open Chrome Dev Tools
|
1675
|
+
// - Go to Settings,
|
1676
|
+
// - Under console, select "Enable custom formatters"
|
1677
|
+
// For more information, https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview
|
1678
|
+
const devtoolsFormatters = global.devtoolsFormatters || [];
|
1679
|
+
ArrayPush.call(devtoolsFormatters, formatter);
|
1680
|
+
global.devtoolsFormatters = devtoolsFormatters;
|
1681
|
+
}
|
1682
|
+
|
1683
|
+
/* istanbul ignore else */
|
1684
|
+
if (process.env.NODE_ENV !== 'production') {
|
1685
|
+
init();
|
1686
|
+
}
|
1687
|
+
function defaultValueIsObservable(value) {
|
1688
|
+
// intentionally checking for null
|
1689
|
+
if (value === null) {
|
1690
|
+
return false;
|
1691
|
+
}
|
1692
|
+
// treat all non-object types, including undefined, as non-observable values
|
1693
|
+
if (typeof value !== 'object') {
|
1694
|
+
return false;
|
1695
|
+
}
|
1696
|
+
if (isArray(value)) {
|
1697
|
+
return true;
|
1698
|
+
}
|
1699
|
+
const proto = getPrototypeOf(value);
|
1700
|
+
return proto === ObjectDotPrototype || proto === null || getPrototypeOf(proto) === null;
|
1701
|
+
}
|
1702
|
+
const defaultValueObserved = (obj, key) => {
|
1703
|
+
/* do nothing */
|
1704
|
+
};
|
1705
|
+
const defaultValueMutated = (obj, key) => {
|
1706
|
+
/* do nothing */
|
1707
|
+
};
|
1708
|
+
function createShadowTarget(value) {
|
1709
|
+
return isArray(value) ? [] : {};
|
1710
|
+
}
|
1711
|
+
class ObservableMembrane {
|
1712
|
+
constructor(options = {}) {
|
1713
|
+
this.readOnlyObjectGraph = new WeakMap();
|
1714
|
+
this.reactiveObjectGraph = new WeakMap();
|
1715
|
+
const { valueMutated, valueObserved, valueIsObservable, tagPropertyKey } = options;
|
1716
|
+
this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
|
1717
|
+
this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
|
1718
|
+
this.valueIsObservable = isFunction(valueIsObservable)
|
1719
|
+
? valueIsObservable
|
1720
|
+
: defaultValueIsObservable;
|
1721
|
+
this.tagPropertyKey = tagPropertyKey;
|
1722
|
+
}
|
1723
|
+
getProxy(value) {
|
1724
|
+
const unwrappedValue = unwrap(value);
|
1725
|
+
if (this.valueIsObservable(unwrappedValue)) {
|
1726
|
+
// When trying to extract the writable version of a readonly we return the readonly.
|
1727
|
+
if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
|
1728
|
+
return value;
|
1729
|
+
}
|
1730
|
+
return this.getReactiveHandler(unwrappedValue);
|
1731
|
+
}
|
1732
|
+
return unwrappedValue;
|
1733
|
+
}
|
1734
|
+
getReadOnlyProxy(value) {
|
1735
|
+
value = unwrap(value);
|
1736
|
+
if (this.valueIsObservable(value)) {
|
1737
|
+
return this.getReadOnlyHandler(value);
|
1738
|
+
}
|
1739
|
+
return value;
|
1740
|
+
}
|
1741
|
+
unwrapProxy(p) {
|
1742
|
+
return unwrap(p);
|
1743
|
+
}
|
1744
|
+
getReactiveHandler(value) {
|
1745
|
+
let proxy = this.reactiveObjectGraph.get(value);
|
1746
|
+
if (isUndefined(proxy)) {
|
1747
|
+
// caching the proxy after the first time it is accessed
|
1748
|
+
const handler = new ReactiveProxyHandler(this, value);
|
1749
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
1750
|
+
registerProxy(proxy, value);
|
1751
|
+
this.reactiveObjectGraph.set(value, proxy);
|
1752
|
+
}
|
1753
|
+
return proxy;
|
1754
|
+
}
|
1755
|
+
getReadOnlyHandler(value) {
|
1756
|
+
let proxy = this.readOnlyObjectGraph.get(value);
|
1757
|
+
if (isUndefined(proxy)) {
|
1758
|
+
// caching the proxy after the first time it is accessed
|
1759
|
+
const handler = new ReadOnlyHandler(this, value);
|
1760
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
1761
|
+
registerProxy(proxy, value);
|
1762
|
+
this.readOnlyObjectGraph.set(value, proxy);
|
1763
|
+
}
|
1764
|
+
return proxy;
|
1765
|
+
}
|
1766
|
+
}
|
1767
|
+
/** version: 2.0.0 */
|
1768
|
+
|
1769
|
+
/*
|
1770
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1771
|
+
* All rights reserved.
|
1772
|
+
* SPDX-License-Identifier: MIT
|
1773
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1774
|
+
*/
|
1775
|
+
const reactiveMembrane = new ObservableMembrane();
|
1776
|
+
// Modeled after `getReadOnlyProxy` in `membrane.ts` in `engine-core`
|
1777
|
+
// Return a proxy over the given object so that access is immutable
|
1778
|
+
// https://github.com/salesforce/lwc/blob/e9db491/packages/%40lwc/engine-core/src/framework/membrane.ts#L29-L33
|
1779
|
+
function getReadOnlyProxy(value) {
|
1780
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
1781
|
+
}
|
1782
|
+
|
1783
|
+
/*
|
1784
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
1785
|
+
* All rights reserved.
|
1786
|
+
* SPDX-License-Identifier: MIT
|
1787
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1788
|
+
*/
|
1789
|
+
const contextfulRelationships = new WeakMap();
|
1790
|
+
function establishContextfulRelationship(parentLe, childLe) {
|
1791
|
+
contextfulRelationships.set(childLe, parentLe);
|
1792
|
+
}
|
1793
|
+
function getContextfulStack(le) {
|
1794
|
+
const contextfulParent = contextfulRelationships.get(le);
|
1795
|
+
if (!contextfulParent) {
|
1796
|
+
return [];
|
1797
|
+
}
|
1798
|
+
return [contextfulParent, ...getContextfulStack(contextfulParent)];
|
1799
|
+
}
|
1800
|
+
const contextProviders = new WeakMap();
|
1801
|
+
function registerContextProvider(adapter, attachedLe, consumerCallback) {
|
1802
|
+
let elementMap = contextProviders.get(adapter);
|
1803
|
+
if (!elementMap) {
|
1804
|
+
elementMap = new WeakMap();
|
1805
|
+
contextProviders.set(adapter, elementMap);
|
1806
|
+
}
|
1807
|
+
elementMap.set(attachedLe, consumerCallback);
|
1808
|
+
}
|
1809
|
+
function connectContext(adapter, contextConsumer, onNewValue) {
|
1810
|
+
const elementMap = contextProviders.get(adapter);
|
1811
|
+
if (!elementMap) {
|
1812
|
+
return;
|
1813
|
+
}
|
1814
|
+
const contextfulStack = getContextfulStack(contextConsumer);
|
1815
|
+
for (const ancestor of contextfulStack) {
|
1816
|
+
const onConsumerConnected = elementMap.get(ancestor);
|
1817
|
+
if (onConsumerConnected) {
|
1818
|
+
onConsumerConnected({
|
1819
|
+
provide(newContextValue) {
|
1820
|
+
onNewValue(newContextValue);
|
1821
|
+
},
|
1822
|
+
});
|
1823
|
+
return;
|
1824
|
+
}
|
1825
|
+
}
|
1826
|
+
}
|
1827
|
+
function createContextProvider(adapter) {
|
1828
|
+
return (le, options) => {
|
1829
|
+
if (!(le instanceof LightningElement)) {
|
1830
|
+
throw new Error('Unable to register context provider on provided `elm`.');
|
1831
|
+
}
|
1832
|
+
if (!le.isConnected || !options?.consumerConnectedCallback) {
|
1833
|
+
return;
|
1834
|
+
}
|
1835
|
+
const { consumerConnectedCallback } = options;
|
1836
|
+
registerContextProvider(adapter, le, (consumer) => consumerConnectedCallback(consumer));
|
1837
|
+
};
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
export { ClassList, LightningElement, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api, connectContext, createContextProvider, createElement, establishContextfulRelationship, fallbackTmpl, fallbackTmplNoYield, filterProperties, freezeTemplate, getComponentDef, getReadOnlyProxy, hasScopedStaticStylesheets, hot, htmlEscape, isComponentConstructor, mutationTracker, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, renderAttrs, renderAttrsNoYield, serverSideRenderComponent as renderComponent, renderStylesheets, renderer, sanitizeAttribute, sanitizeHtmlContent, serverSideRenderComponent, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, toIteratorDirective, track, unwrap$1 as unwrap, validateStyleTextContents, wire };
|
1841
|
+
/** version: 8.8.0 */
|
1110
1842
|
//# sourceMappingURL=index.js.map
|