@lwc/ssr-runtime 8.7.0 → 8.9.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 +706 -120
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +703 -119
- package/dist/index.js.map +1 -1
- 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/clone-and-deep-freeze.d.ts +0 -1
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(..._) {
|
|
@@ -261,50 +258,30 @@ defineProperties,
|
|
|
261
258
|
defineProperty,
|
|
262
259
|
/** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */
|
|
263
260
|
entries,
|
|
264
|
-
/** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */
|
|
265
|
-
freeze,
|
|
266
|
-
/** Detached {@linkcode Object.fromEntries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries MDN Reference}. */
|
|
267
|
-
fromEntries,
|
|
268
|
-
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */
|
|
269
|
-
getOwnPropertyDescriptor,
|
|
270
|
-
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */
|
|
271
|
-
getOwnPropertyDescriptors,
|
|
272
261
|
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
|
|
273
|
-
getOwnPropertyNames,
|
|
274
|
-
/** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
|
|
275
|
-
getOwnPropertySymbols,
|
|
276
|
-
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
|
|
277
|
-
getPrototypeOf,
|
|
262
|
+
getOwnPropertyNames: getOwnPropertyNames$1,
|
|
278
263
|
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
|
|
279
|
-
hasOwnProperty,
|
|
280
|
-
/** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */
|
|
281
|
-
isFrozen,
|
|
264
|
+
hasOwnProperty: hasOwnProperty$1,
|
|
282
265
|
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */
|
|
283
|
-
keys
|
|
284
|
-
/** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */
|
|
285
|
-
seal,
|
|
286
|
-
/** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
|
|
287
|
-
setPrototypeOf, } = Object;
|
|
266
|
+
keys} = Object;
|
|
288
267
|
const {
|
|
289
268
|
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
|
290
|
-
isArray
|
|
291
|
-
/** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
|
|
292
|
-
from: ArrayFrom, } = Array;
|
|
269
|
+
isArray: isArray$1} = Array;
|
|
293
270
|
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
|
|
294
271
|
// though it works fine for one, e.g. isArray), so comments for these are added to the export
|
|
295
272
|
// statement, rather than this declaration.
|
|
296
|
-
const {
|
|
273
|
+
const { join: ArrayJoin, map: ArrayMap, forEach, // Weird anomaly!
|
|
297
274
|
} = Array.prototype;
|
|
298
275
|
/** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
|
|
299
276
|
const { fromCharCode: StringFromCharCode } = String;
|
|
300
277
|
// No JSDocs here - see comment for Array.prototype
|
|
301
|
-
const {
|
|
278
|
+
const { charCodeAt: StringCharCodeAt, replace: StringReplace, toLowerCase: StringToLowerCase} = String.prototype;
|
|
302
279
|
/**
|
|
303
280
|
* Determines whether the argument is `undefined`.
|
|
304
281
|
* @param obj Value to test
|
|
305
282
|
* @returns `true` if the value is `undefined`.
|
|
306
283
|
*/
|
|
307
|
-
function isUndefined(obj) {
|
|
284
|
+
function isUndefined$1(obj) {
|
|
308
285
|
return obj === undefined;
|
|
309
286
|
}
|
|
310
287
|
/**
|
|
@@ -316,26 +293,26 @@ function isNull(obj) {
|
|
|
316
293
|
return obj === null;
|
|
317
294
|
}
|
|
318
295
|
/**
|
|
319
|
-
* Determines whether the argument is
|
|
296
|
+
* Determines whether the argument is a string.
|
|
320
297
|
* @param obj Value to test
|
|
321
|
-
* @returns `true` if the value is
|
|
298
|
+
* @returns `true` if the value is a string.
|
|
322
299
|
*/
|
|
323
|
-
function
|
|
324
|
-
return typeof obj === '
|
|
300
|
+
function isString(obj) {
|
|
301
|
+
return typeof obj === 'string';
|
|
325
302
|
}
|
|
326
|
-
const OtS = {}.toString;
|
|
303
|
+
const OtS$1 = {}.toString;
|
|
327
304
|
/**
|
|
328
305
|
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
|
329
306
|
* Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
|
|
330
307
|
* @param obj Value to convert to a string.
|
|
331
308
|
* @returns String representation of the value.
|
|
332
309
|
*/
|
|
333
|
-
function toString(obj) {
|
|
310
|
+
function toString$1(obj) {
|
|
334
311
|
if (obj?.toString) {
|
|
335
312
|
// Arrays might hold objects with "null" prototype So using
|
|
336
313
|
// Array.prototype.toString directly will cause an error Iterate through
|
|
337
314
|
// all the items and handle individually.
|
|
338
|
-
if (isArray(obj)) {
|
|
315
|
+
if (isArray$1(obj)) {
|
|
339
316
|
// This behavior is slightly different from Array#toString:
|
|
340
317
|
// 1. Array#toString calls `this.join`, rather than Array#join
|
|
341
318
|
// Ex: arr = []; arr.join = () => 1; arr.toString() === 1; toString(arr) === ''
|
|
@@ -346,13 +323,13 @@ function toString(obj) {
|
|
|
346
323
|
// 4. Array#toString converts recursive references to arrays to ''
|
|
347
324
|
// Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
|
|
348
325
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
|
|
349
|
-
return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
|
326
|
+
return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
|
|
350
327
|
}
|
|
351
328
|
return obj.toString();
|
|
352
329
|
}
|
|
353
330
|
else if (typeof obj === 'object') {
|
|
354
331
|
// This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
|
|
355
|
-
return OtS.call(obj);
|
|
332
|
+
return OtS$1.call(obj);
|
|
356
333
|
}
|
|
357
334
|
else {
|
|
358
335
|
return String(obj);
|
|
@@ -459,7 +436,6 @@ const GLOBAL_ATTRIBUTE = /*@__PURE__*/ new Set([
|
|
|
459
436
|
'autofocus',
|
|
460
437
|
'class',
|
|
461
438
|
'contenteditable',
|
|
462
|
-
'contextmenu',
|
|
463
439
|
'dir',
|
|
464
440
|
'draggable',
|
|
465
441
|
'enterkeyhint',
|
|
@@ -519,15 +495,15 @@ const CACHED_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map();
|
|
|
519
495
|
*/
|
|
520
496
|
function htmlPropertyToAttribute(propName) {
|
|
521
497
|
const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
|
|
522
|
-
if (!isUndefined(ariaAttributeName)) {
|
|
498
|
+
if (!isUndefined$1(ariaAttributeName)) {
|
|
523
499
|
return ariaAttributeName;
|
|
524
500
|
}
|
|
525
501
|
const specialAttributeName = SPECIAL_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
|
526
|
-
if (!isUndefined(specialAttributeName)) {
|
|
502
|
+
if (!isUndefined$1(specialAttributeName)) {
|
|
527
503
|
return specialAttributeName;
|
|
528
504
|
}
|
|
529
505
|
const cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
|
530
|
-
if (!isUndefined(cachedAttributeName)) {
|
|
506
|
+
if (!isUndefined$1(cachedAttributeName)) {
|
|
531
507
|
return cachedAttributeName;
|
|
532
508
|
}
|
|
533
509
|
let attributeName = '';
|
|
@@ -594,7 +570,7 @@ function setHooks(hooks) {
|
|
|
594
570
|
function flattenStylesheets(stylesheets) {
|
|
595
571
|
const list = [];
|
|
596
572
|
for (const stylesheet of stylesheets) {
|
|
597
|
-
if (!isArray(stylesheet)) {
|
|
573
|
+
if (!isArray$1(stylesheet)) {
|
|
598
574
|
list.push(stylesheet);
|
|
599
575
|
}
|
|
600
576
|
else {
|
|
@@ -603,7 +579,15 @@ function flattenStylesheets(stylesheets) {
|
|
|
603
579
|
}
|
|
604
580
|
return list;
|
|
605
581
|
}
|
|
606
|
-
|
|
582
|
+
|
|
583
|
+
/*
|
|
584
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
585
|
+
* All rights reserved.
|
|
586
|
+
* SPDX-License-Identifier: MIT
|
|
587
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
588
|
+
*/
|
|
589
|
+
const DEFAULT_SSR_MODE = 'sync';
|
|
590
|
+
/** version: 8.9.0 */
|
|
607
591
|
|
|
608
592
|
/*
|
|
609
593
|
* Copyright (c) 2024, Salesforce, Inc.
|
|
@@ -806,7 +790,11 @@ const explicitBooleanDescriptor = (attrName, defaultValue) => ({
|
|
|
806
790
|
enumerable: true,
|
|
807
791
|
get() {
|
|
808
792
|
const value = this.getAttribute(attrName);
|
|
809
|
-
|
|
793
|
+
if (value === null)
|
|
794
|
+
return defaultValue;
|
|
795
|
+
// spellcheck=false => false, everything else => true
|
|
796
|
+
// draggable=true => true, everything else => false
|
|
797
|
+
return value.toLowerCase() === String(defaultValue) ? defaultValue : !defaultValue;
|
|
810
798
|
},
|
|
811
799
|
set(newValue) {
|
|
812
800
|
const currentValue = this.getAttribute(attrName);
|
|
@@ -858,11 +846,28 @@ const ariaDescriptor = (attrName) => ({
|
|
|
858
846
|
this.removeAttribute(attrName);
|
|
859
847
|
}
|
|
860
848
|
else {
|
|
861
|
-
this.setAttribute(attrName, toString(newValue));
|
|
849
|
+
this.setAttribute(attrName, toString$1(newValue));
|
|
862
850
|
}
|
|
863
851
|
}
|
|
864
852
|
},
|
|
865
853
|
});
|
|
854
|
+
const tabIndexDescriptor = () => ({
|
|
855
|
+
configurable: true,
|
|
856
|
+
enumerable: true,
|
|
857
|
+
get() {
|
|
858
|
+
const str = this.getAttribute('tabindex');
|
|
859
|
+
const num = Number(str);
|
|
860
|
+
return isFinite(num) ? Math.trunc(num) : -1;
|
|
861
|
+
},
|
|
862
|
+
set(newValue) {
|
|
863
|
+
const currentValue = this.getAttribute('tabindex');
|
|
864
|
+
const num = Number(newValue);
|
|
865
|
+
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
|
866
|
+
if (normalizedValue !== currentValue) {
|
|
867
|
+
this.setAttribute('tabindex', toString$1(newValue));
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
});
|
|
866
871
|
const descriptors = {
|
|
867
872
|
accessKey: stringDescriptor('accesskey'),
|
|
868
873
|
dir: stringDescriptor('dir'),
|
|
@@ -871,21 +876,7 @@ const descriptors = {
|
|
|
871
876
|
id: stringDescriptor('id'),
|
|
872
877
|
lang: stringDescriptor('lang'),
|
|
873
878
|
spellcheck: explicitBooleanDescriptor('spellcheck', false),
|
|
874
|
-
tabIndex:
|
|
875
|
-
get() {
|
|
876
|
-
const str = this.getAttribute('tabindex');
|
|
877
|
-
const num = Number(str);
|
|
878
|
-
return isFinite(num) ? Math.trunc(num) : -1;
|
|
879
|
-
},
|
|
880
|
-
set(newValue) {
|
|
881
|
-
const currentValue = this.getAttribute('tabindex');
|
|
882
|
-
const num = Number(newValue);
|
|
883
|
-
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
|
884
|
-
if (normalizedValue !== currentValue) {
|
|
885
|
-
this.setAttribute('tabindex', toString(newValue));
|
|
886
|
-
}
|
|
887
|
-
},
|
|
888
|
-
},
|
|
879
|
+
tabIndex: tabIndexDescriptor(),
|
|
889
880
|
title: stringDescriptor('title'),
|
|
890
881
|
};
|
|
891
882
|
// Add descriptors for ARIA attributes
|
|
@@ -931,24 +922,24 @@ class LightningElement {
|
|
|
931
922
|
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
|
932
923
|
}
|
|
933
924
|
setAttribute(attrName, attrValue) {
|
|
934
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
925
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
|
935
926
|
const normalizedValue = String(attrValue);
|
|
936
927
|
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
|
937
928
|
mutationTracker.add(this, normalizedName);
|
|
938
929
|
}
|
|
939
930
|
getAttribute(attrName) {
|
|
940
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
941
|
-
if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
|
931
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
|
932
|
+
if (hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
|
942
933
|
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
|
943
934
|
}
|
|
944
935
|
return null;
|
|
945
936
|
}
|
|
946
937
|
hasAttribute(attrName) {
|
|
947
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
948
|
-
return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
|
938
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
|
939
|
+
return hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
|
949
940
|
}
|
|
950
941
|
removeAttribute(attrName) {
|
|
951
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
|
942
|
+
const normalizedName = StringToLowerCase.call(toString$1(attrName));
|
|
952
943
|
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
|
953
944
|
// Track mutations for removal of non-existing attributes
|
|
954
945
|
mutationTracker.add(this, normalizedName);
|
|
@@ -1035,36 +1026,46 @@ defineProperties(LightningElement.prototype, descriptors);
|
|
|
1035
1026
|
* SPDX-License-Identifier: MIT
|
|
1036
1027
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1037
1028
|
*/
|
|
1038
|
-
const escapeAttrVal = (
|
|
1039
|
-
function
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1029
|
+
const escapeAttrVal = (attrValue) => attrValue.replaceAll('&', '&').replaceAll('"', '"');
|
|
1030
|
+
function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
|
|
1031
|
+
// The scopeToken is e.g. `lwc-xyz123` which is the token our parent gives us.
|
|
1032
|
+
// The hostScopeToken is e.g. `lwc-abc456-host` which is the token for our own component.
|
|
1033
|
+
// It's possible to have both, one, the other, or neither.
|
|
1034
|
+
const combinedScopeToken = scopeToken && hostScopeToken
|
|
1035
|
+
? `${scopeToken} ${hostScopeToken}`
|
|
1036
|
+
: scopeToken || hostScopeToken || '';
|
|
1037
|
+
let result = '';
|
|
1038
|
+
let hasClassAttribute = false;
|
|
1039
|
+
for (const attrName of getOwnPropertyNames$1(attrs)) {
|
|
1040
|
+
let attrValue = attrs[attrName];
|
|
1041
|
+
if (isNull(attrValue) || isUndefined$1(attrValue)) {
|
|
1042
|
+
attrValue = '';
|
|
1047
1043
|
}
|
|
1048
|
-
else if (
|
|
1049
|
-
|
|
1044
|
+
else if (!isString(attrValue)) {
|
|
1045
|
+
attrValue = String(attrValue);
|
|
1050
1046
|
}
|
|
1047
|
+
if (combinedScopeToken && attrName === 'class') {
|
|
1048
|
+
attrValue += ' ' + combinedScopeToken;
|
|
1049
|
+
hasClassAttribute = true;
|
|
1050
|
+
}
|
|
1051
|
+
result += attrValue === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrValue)}"`;
|
|
1051
1052
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
if (!attrs) {
|
|
1056
|
-
return;
|
|
1053
|
+
// If we didn't render any `class` attribute, render one for the scope token(s)
|
|
1054
|
+
if (!hasClassAttribute && combinedScopeToken) {
|
|
1055
|
+
result += ` class="${combinedScopeToken}"`;
|
|
1057
1056
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
|
|
1062
|
-
}
|
|
1063
|
-
else if (attrVal === null) {
|
|
1064
|
-
emit('');
|
|
1065
|
-
}
|
|
1057
|
+
// For the host scope token only, we encode a special attribute for hydration
|
|
1058
|
+
if (hostScopeToken) {
|
|
1059
|
+
result += ` data-lwc-host-scope-token="${hostScopeToken}"`;
|
|
1066
1060
|
}
|
|
1067
|
-
|
|
1061
|
+
result += mutationTracker.renderMutatedAttrs(instance);
|
|
1062
|
+
return result;
|
|
1063
|
+
}
|
|
1064
|
+
function* renderAttrs(instance, attrs, hostScopeToken, scopeToken) {
|
|
1065
|
+
yield renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken);
|
|
1066
|
+
}
|
|
1067
|
+
function renderAttrsNoYield(emit, instance, attrs, hostScopeToken, scopeToken) {
|
|
1068
|
+
emit(renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken));
|
|
1068
1069
|
}
|
|
1069
1070
|
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
|
1070
1071
|
if (Cmp.renderMode !== 'light') {
|
|
@@ -1076,7 +1077,7 @@ function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
|
|
|
1076
1077
|
emit('<template shadowrootmode="open"></template>');
|
|
1077
1078
|
}
|
|
1078
1079
|
}
|
|
1079
|
-
async function serverSideRenderComponent(tagName, Component, props = {}, mode =
|
|
1080
|
+
async function serverSideRenderComponent(tagName, Component, props = {}, mode = DEFAULT_SSR_MODE) {
|
|
1080
1081
|
if (typeof tagName !== 'string') {
|
|
1081
1082
|
throw new Error(`tagName must be a string, found: ${tagName}`);
|
|
1082
1083
|
}
|
|
@@ -1218,39 +1219,622 @@ function* toIteratorDirective(iterable) {
|
|
|
1218
1219
|
}
|
|
1219
1220
|
}
|
|
1220
1221
|
|
|
1222
|
+
/**
|
|
1223
|
+
* Copyright (C) 2017 salesforce.com, inc.
|
|
1224
|
+
*/
|
|
1225
|
+
const { isArray } = Array;
|
|
1226
|
+
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
|
1227
|
+
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
|
1228
|
+
const OtS = {}.toString;
|
|
1229
|
+
function toString(obj) {
|
|
1230
|
+
if (obj && obj.toString) {
|
|
1231
|
+
return obj.toString();
|
|
1232
|
+
}
|
|
1233
|
+
else if (typeof obj === 'object') {
|
|
1234
|
+
return OtS.call(obj);
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
return obj + '';
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
function isUndefined(obj) {
|
|
1241
|
+
return obj === undefined;
|
|
1242
|
+
}
|
|
1243
|
+
function isFunction(obj) {
|
|
1244
|
+
return typeof obj === 'function';
|
|
1245
|
+
}
|
|
1246
|
+
const proxyToValueMap = new WeakMap();
|
|
1247
|
+
function registerProxy(proxy, value) {
|
|
1248
|
+
proxyToValueMap.set(proxy, value);
|
|
1249
|
+
}
|
|
1250
|
+
const unwrap = (replicaOrAny) => proxyToValueMap.get(replicaOrAny) || replicaOrAny;
|
|
1251
|
+
|
|
1252
|
+
class BaseProxyHandler {
|
|
1253
|
+
constructor(membrane, value) {
|
|
1254
|
+
this.originalTarget = value;
|
|
1255
|
+
this.membrane = membrane;
|
|
1256
|
+
}
|
|
1257
|
+
// Shared utility methods
|
|
1258
|
+
wrapDescriptor(descriptor) {
|
|
1259
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
|
1260
|
+
descriptor.value = this.wrapValue(descriptor.value);
|
|
1261
|
+
}
|
|
1262
|
+
else {
|
|
1263
|
+
const { set: originalSet, get: originalGet } = descriptor;
|
|
1264
|
+
if (!isUndefined(originalGet)) {
|
|
1265
|
+
descriptor.get = this.wrapGetter(originalGet);
|
|
1266
|
+
}
|
|
1267
|
+
if (!isUndefined(originalSet)) {
|
|
1268
|
+
descriptor.set = this.wrapSetter(originalSet);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
return descriptor;
|
|
1272
|
+
}
|
|
1273
|
+
copyDescriptorIntoShadowTarget(shadowTarget, key) {
|
|
1274
|
+
const { originalTarget } = this;
|
|
1275
|
+
// Note: a property might get defined multiple times in the shadowTarget
|
|
1276
|
+
// but it will always be compatible with the previous descriptor
|
|
1277
|
+
// to preserve the object invariants, which makes these lines safe.
|
|
1278
|
+
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
|
|
1279
|
+
// TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
|
|
1280
|
+
/* istanbul ignore else */
|
|
1281
|
+
if (!isUndefined(originalDescriptor)) {
|
|
1282
|
+
const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
|
1283
|
+
ObjectDefineProperty(shadowTarget, key, wrappedDesc);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
lockShadowTarget(shadowTarget) {
|
|
1287
|
+
const { originalTarget } = this;
|
|
1288
|
+
const targetKeys = ArrayConcat.call(getOwnPropertyNames(originalTarget), getOwnPropertySymbols(originalTarget));
|
|
1289
|
+
targetKeys.forEach((key) => {
|
|
1290
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
|
1291
|
+
});
|
|
1292
|
+
const { membrane: { tagPropertyKey }, } = this;
|
|
1293
|
+
if (!isUndefined(tagPropertyKey) && !hasOwnProperty.call(shadowTarget, tagPropertyKey)) {
|
|
1294
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, ObjectCreate(null));
|
|
1295
|
+
}
|
|
1296
|
+
preventExtensions(shadowTarget);
|
|
1297
|
+
}
|
|
1298
|
+
// Shared Traps
|
|
1299
|
+
// TODO: apply() is never called
|
|
1300
|
+
/* istanbul ignore next */
|
|
1301
|
+
apply(shadowTarget, thisArg, argArray) {
|
|
1302
|
+
/* No op */
|
|
1303
|
+
}
|
|
1304
|
+
// TODO: construct() is never called
|
|
1305
|
+
/* istanbul ignore next */
|
|
1306
|
+
construct(shadowTarget, argArray, newTarget) {
|
|
1307
|
+
/* No op */
|
|
1308
|
+
}
|
|
1309
|
+
get(shadowTarget, key) {
|
|
1310
|
+
const { originalTarget, membrane: { valueObserved }, } = this;
|
|
1311
|
+
const value = originalTarget[key];
|
|
1312
|
+
valueObserved(originalTarget, key);
|
|
1313
|
+
return this.wrapValue(value);
|
|
1314
|
+
}
|
|
1315
|
+
has(shadowTarget, key) {
|
|
1316
|
+
const { originalTarget, membrane: { tagPropertyKey, valueObserved }, } = this;
|
|
1317
|
+
valueObserved(originalTarget, key);
|
|
1318
|
+
// since key is never going to be undefined, and tagPropertyKey might be undefined
|
|
1319
|
+
// we can simply compare them as the second part of the condition.
|
|
1320
|
+
return key in originalTarget || key === tagPropertyKey;
|
|
1321
|
+
}
|
|
1322
|
+
ownKeys(shadowTarget) {
|
|
1323
|
+
const { originalTarget, membrane: { tagPropertyKey }, } = this;
|
|
1324
|
+
// if the membrane tag key exists and it is not in the original target, we add it to the keys.
|
|
1325
|
+
const keys = isUndefined(tagPropertyKey) || hasOwnProperty.call(originalTarget, tagPropertyKey)
|
|
1326
|
+
? []
|
|
1327
|
+
: [tagPropertyKey];
|
|
1328
|
+
// small perf optimization using push instead of concat to avoid creating an extra array
|
|
1329
|
+
ArrayPush.apply(keys, getOwnPropertyNames(originalTarget));
|
|
1330
|
+
ArrayPush.apply(keys, getOwnPropertySymbols(originalTarget));
|
|
1331
|
+
return keys;
|
|
1332
|
+
}
|
|
1333
|
+
isExtensible(shadowTarget) {
|
|
1334
|
+
const { originalTarget } = this;
|
|
1335
|
+
// optimization to avoid attempting to lock down the shadowTarget multiple times
|
|
1336
|
+
if (!isExtensible(shadowTarget)) {
|
|
1337
|
+
return false; // was already locked down
|
|
1338
|
+
}
|
|
1339
|
+
if (!isExtensible(originalTarget)) {
|
|
1340
|
+
this.lockShadowTarget(shadowTarget);
|
|
1341
|
+
return false;
|
|
1342
|
+
}
|
|
1343
|
+
return true;
|
|
1344
|
+
}
|
|
1345
|
+
getPrototypeOf(shadowTarget) {
|
|
1346
|
+
const { originalTarget } = this;
|
|
1347
|
+
return getPrototypeOf(originalTarget);
|
|
1348
|
+
}
|
|
1349
|
+
getOwnPropertyDescriptor(shadowTarget, key) {
|
|
1350
|
+
const { originalTarget, membrane: { valueObserved, tagPropertyKey }, } = this;
|
|
1351
|
+
// keys looked up via getOwnPropertyDescriptor need to be reactive
|
|
1352
|
+
valueObserved(originalTarget, key);
|
|
1353
|
+
let desc = getOwnPropertyDescriptor(originalTarget, key);
|
|
1354
|
+
if (isUndefined(desc)) {
|
|
1355
|
+
if (key !== tagPropertyKey) {
|
|
1356
|
+
return undefined;
|
|
1357
|
+
}
|
|
1358
|
+
// if the key is the membrane tag key, and is not in the original target,
|
|
1359
|
+
// we produce a synthetic descriptor and install it on the shadow target
|
|
1360
|
+
desc = { value: undefined, writable: false, configurable: false, enumerable: false };
|
|
1361
|
+
ObjectDefineProperty(shadowTarget, tagPropertyKey, desc);
|
|
1362
|
+
return desc;
|
|
1363
|
+
}
|
|
1364
|
+
if (desc.configurable === false) {
|
|
1365
|
+
// updating the descriptor to non-configurable on the shadow
|
|
1366
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
|
1367
|
+
}
|
|
1368
|
+
// Note: by accessing the descriptor, the key is marked as observed
|
|
1369
|
+
// but access to the value, setter or getter (if available) cannot observe
|
|
1370
|
+
// mutations, just like regular methods, in which case we just do nothing.
|
|
1371
|
+
return this.wrapDescriptor(desc);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
const getterMap$1 = new WeakMap();
|
|
1376
|
+
const setterMap$1 = new WeakMap();
|
|
1377
|
+
const reverseGetterMap = new WeakMap();
|
|
1378
|
+
const reverseSetterMap = new WeakMap();
|
|
1379
|
+
class ReactiveProxyHandler extends BaseProxyHandler {
|
|
1380
|
+
wrapValue(value) {
|
|
1381
|
+
return this.membrane.getProxy(value);
|
|
1382
|
+
}
|
|
1383
|
+
wrapGetter(originalGet) {
|
|
1384
|
+
const wrappedGetter = getterMap$1.get(originalGet);
|
|
1385
|
+
if (!isUndefined(wrappedGetter)) {
|
|
1386
|
+
return wrappedGetter;
|
|
1387
|
+
}
|
|
1388
|
+
const handler = this;
|
|
1389
|
+
const get = function () {
|
|
1390
|
+
// invoking the original getter with the original target
|
|
1391
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
|
1392
|
+
};
|
|
1393
|
+
getterMap$1.set(originalGet, get);
|
|
1394
|
+
reverseGetterMap.set(get, originalGet);
|
|
1395
|
+
return get;
|
|
1396
|
+
}
|
|
1397
|
+
wrapSetter(originalSet) {
|
|
1398
|
+
const wrappedSetter = setterMap$1.get(originalSet);
|
|
1399
|
+
if (!isUndefined(wrappedSetter)) {
|
|
1400
|
+
return wrappedSetter;
|
|
1401
|
+
}
|
|
1402
|
+
const set = function (v) {
|
|
1403
|
+
// invoking the original setter with the original target
|
|
1404
|
+
originalSet.call(unwrap(this), unwrap(v));
|
|
1405
|
+
};
|
|
1406
|
+
setterMap$1.set(originalSet, set);
|
|
1407
|
+
reverseSetterMap.set(set, originalSet);
|
|
1408
|
+
return set;
|
|
1409
|
+
}
|
|
1410
|
+
unwrapDescriptor(descriptor) {
|
|
1411
|
+
if (hasOwnProperty.call(descriptor, 'value')) {
|
|
1412
|
+
// dealing with a data descriptor
|
|
1413
|
+
descriptor.value = unwrap(descriptor.value);
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
const { set, get } = descriptor;
|
|
1417
|
+
if (!isUndefined(get)) {
|
|
1418
|
+
descriptor.get = this.unwrapGetter(get);
|
|
1419
|
+
}
|
|
1420
|
+
if (!isUndefined(set)) {
|
|
1421
|
+
descriptor.set = this.unwrapSetter(set);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return descriptor;
|
|
1425
|
+
}
|
|
1426
|
+
unwrapGetter(redGet) {
|
|
1427
|
+
const reverseGetter = reverseGetterMap.get(redGet);
|
|
1428
|
+
if (!isUndefined(reverseGetter)) {
|
|
1429
|
+
return reverseGetter;
|
|
1430
|
+
}
|
|
1431
|
+
const handler = this;
|
|
1432
|
+
const get = function () {
|
|
1433
|
+
// invoking the red getter with the proxy of this
|
|
1434
|
+
return unwrap(redGet.call(handler.wrapValue(this)));
|
|
1435
|
+
};
|
|
1436
|
+
getterMap$1.set(get, redGet);
|
|
1437
|
+
reverseGetterMap.set(redGet, get);
|
|
1438
|
+
return get;
|
|
1439
|
+
}
|
|
1440
|
+
unwrapSetter(redSet) {
|
|
1441
|
+
const reverseSetter = reverseSetterMap.get(redSet);
|
|
1442
|
+
if (!isUndefined(reverseSetter)) {
|
|
1443
|
+
return reverseSetter;
|
|
1444
|
+
}
|
|
1445
|
+
const handler = this;
|
|
1446
|
+
const set = function (v) {
|
|
1447
|
+
// invoking the red setter with the proxy of this
|
|
1448
|
+
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
|
1449
|
+
};
|
|
1450
|
+
setterMap$1.set(set, redSet);
|
|
1451
|
+
reverseSetterMap.set(redSet, set);
|
|
1452
|
+
return set;
|
|
1453
|
+
}
|
|
1454
|
+
set(shadowTarget, key, value) {
|
|
1455
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
|
1456
|
+
const oldValue = originalTarget[key];
|
|
1457
|
+
if (oldValue !== value) {
|
|
1458
|
+
originalTarget[key] = value;
|
|
1459
|
+
valueMutated(originalTarget, key);
|
|
1460
|
+
}
|
|
1461
|
+
else if (key === 'length' && isArray(originalTarget)) {
|
|
1462
|
+
// fix for issue #236: push will add the new index, and by the time length
|
|
1463
|
+
// is updated, the internal length is already equal to the new length value
|
|
1464
|
+
// therefore, the oldValue is equal to the value. This is the forking logic
|
|
1465
|
+
// to support this use case.
|
|
1466
|
+
valueMutated(originalTarget, key);
|
|
1467
|
+
}
|
|
1468
|
+
return true;
|
|
1469
|
+
}
|
|
1470
|
+
deleteProperty(shadowTarget, key) {
|
|
1471
|
+
const { originalTarget, membrane: { valueMutated }, } = this;
|
|
1472
|
+
delete originalTarget[key];
|
|
1473
|
+
valueMutated(originalTarget, key);
|
|
1474
|
+
return true;
|
|
1475
|
+
}
|
|
1476
|
+
setPrototypeOf(shadowTarget, prototype) {
|
|
1477
|
+
/* istanbul ignore else */
|
|
1478
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1479
|
+
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
preventExtensions(shadowTarget) {
|
|
1483
|
+
if (isExtensible(shadowTarget)) {
|
|
1484
|
+
const { originalTarget } = this;
|
|
1485
|
+
preventExtensions(originalTarget);
|
|
1486
|
+
// if the originalTarget is a proxy itself, it might reject
|
|
1487
|
+
// the preventExtension call, in which case we should not attempt to lock down
|
|
1488
|
+
// the shadow target.
|
|
1489
|
+
// TODO: It should not actually be possible to reach this `if` statement.
|
|
1490
|
+
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
|
1491
|
+
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
|
1492
|
+
/* istanbul ignore if */
|
|
1493
|
+
if (isExtensible(originalTarget)) {
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
this.lockShadowTarget(shadowTarget);
|
|
1497
|
+
}
|
|
1498
|
+
return true;
|
|
1499
|
+
}
|
|
1500
|
+
defineProperty(shadowTarget, key, descriptor) {
|
|
1501
|
+
const { originalTarget, membrane: { valueMutated, tagPropertyKey }, } = this;
|
|
1502
|
+
if (key === tagPropertyKey && !hasOwnProperty.call(originalTarget, key)) {
|
|
1503
|
+
// To avoid leaking the membrane tag property into the original target, we must
|
|
1504
|
+
// be sure that the original target doesn't have yet.
|
|
1505
|
+
// NOTE: we do not return false here because Object.freeze and equivalent operations
|
|
1506
|
+
// will attempt to set the descriptor to the same value, and expect no to throw. This
|
|
1507
|
+
// is an small compromise for the sake of not having to diff the descriptors.
|
|
1508
|
+
return true;
|
|
1509
|
+
}
|
|
1510
|
+
ObjectDefineProperty(originalTarget, key, this.unwrapDescriptor(descriptor));
|
|
1511
|
+
// intentionally testing if false since it could be undefined as well
|
|
1512
|
+
if (descriptor.configurable === false) {
|
|
1513
|
+
this.copyDescriptorIntoShadowTarget(shadowTarget, key);
|
|
1514
|
+
}
|
|
1515
|
+
valueMutated(originalTarget, key);
|
|
1516
|
+
return true;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
const getterMap = new WeakMap();
|
|
1521
|
+
const setterMap = new WeakMap();
|
|
1522
|
+
class ReadOnlyHandler extends BaseProxyHandler {
|
|
1523
|
+
wrapValue(value) {
|
|
1524
|
+
return this.membrane.getReadOnlyProxy(value);
|
|
1525
|
+
}
|
|
1526
|
+
wrapGetter(originalGet) {
|
|
1527
|
+
const wrappedGetter = getterMap.get(originalGet);
|
|
1528
|
+
if (!isUndefined(wrappedGetter)) {
|
|
1529
|
+
return wrappedGetter;
|
|
1530
|
+
}
|
|
1531
|
+
const handler = this;
|
|
1532
|
+
const get = function () {
|
|
1533
|
+
// invoking the original getter with the original target
|
|
1534
|
+
return handler.wrapValue(originalGet.call(unwrap(this)));
|
|
1535
|
+
};
|
|
1536
|
+
getterMap.set(originalGet, get);
|
|
1537
|
+
return get;
|
|
1538
|
+
}
|
|
1539
|
+
wrapSetter(originalSet) {
|
|
1540
|
+
const wrappedSetter = setterMap.get(originalSet);
|
|
1541
|
+
if (!isUndefined(wrappedSetter)) {
|
|
1542
|
+
return wrappedSetter;
|
|
1543
|
+
}
|
|
1544
|
+
const handler = this;
|
|
1545
|
+
const set = function (v) {
|
|
1546
|
+
/* istanbul ignore else */
|
|
1547
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1548
|
+
const { originalTarget } = handler;
|
|
1549
|
+
throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
setterMap.set(originalSet, set);
|
|
1553
|
+
return set;
|
|
1554
|
+
}
|
|
1555
|
+
set(shadowTarget, key, value) {
|
|
1556
|
+
/* istanbul ignore else */
|
|
1557
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1558
|
+
const { originalTarget } = this;
|
|
1559
|
+
const msg = isArray(originalTarget)
|
|
1560
|
+
? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.`
|
|
1561
|
+
: `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
|
1562
|
+
throw new Error(msg);
|
|
1563
|
+
}
|
|
1564
|
+
/* istanbul ignore next */
|
|
1565
|
+
return false;
|
|
1566
|
+
}
|
|
1567
|
+
deleteProperty(shadowTarget, key) {
|
|
1568
|
+
/* istanbul ignore else */
|
|
1569
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1570
|
+
const { originalTarget } = this;
|
|
1571
|
+
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
1572
|
+
}
|
|
1573
|
+
/* istanbul ignore next */
|
|
1574
|
+
return false;
|
|
1575
|
+
}
|
|
1576
|
+
setPrototypeOf(shadowTarget, prototype) {
|
|
1577
|
+
/* istanbul ignore else */
|
|
1578
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1579
|
+
const { originalTarget } = this;
|
|
1580
|
+
throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
preventExtensions(shadowTarget) {
|
|
1584
|
+
/* istanbul ignore else */
|
|
1585
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1586
|
+
const { originalTarget } = this;
|
|
1587
|
+
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
|
1588
|
+
}
|
|
1589
|
+
/* istanbul ignore next */
|
|
1590
|
+
return false;
|
|
1591
|
+
}
|
|
1592
|
+
defineProperty(shadowTarget, key, descriptor) {
|
|
1593
|
+
/* istanbul ignore else */
|
|
1594
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1595
|
+
const { originalTarget } = this;
|
|
1596
|
+
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
1597
|
+
}
|
|
1598
|
+
/* istanbul ignore next */
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
function extract(objectOrArray) {
|
|
1604
|
+
if (isArray(objectOrArray)) {
|
|
1605
|
+
return objectOrArray.map((item) => {
|
|
1606
|
+
const original = unwrap(item);
|
|
1607
|
+
if (original !== item) {
|
|
1608
|
+
return extract(original);
|
|
1609
|
+
}
|
|
1610
|
+
return item;
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
const obj = ObjectCreate(getPrototypeOf(objectOrArray));
|
|
1614
|
+
const names = getOwnPropertyNames(objectOrArray);
|
|
1615
|
+
return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
|
1616
|
+
const item = objectOrArray[key];
|
|
1617
|
+
const original = unwrap(item);
|
|
1618
|
+
if (original !== item) {
|
|
1619
|
+
seed[key] = extract(original);
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
seed[key] = item;
|
|
1623
|
+
}
|
|
1624
|
+
return seed;
|
|
1625
|
+
}, obj);
|
|
1626
|
+
}
|
|
1627
|
+
const formatter = {
|
|
1628
|
+
header: (plainOrProxy) => {
|
|
1629
|
+
const originalTarget = unwrap(plainOrProxy);
|
|
1630
|
+
// if originalTarget is falsy or not unwrappable, exit
|
|
1631
|
+
if (!originalTarget || originalTarget === plainOrProxy) {
|
|
1632
|
+
return null;
|
|
1633
|
+
}
|
|
1634
|
+
const obj = extract(plainOrProxy);
|
|
1635
|
+
return ['object', { object: obj }];
|
|
1636
|
+
},
|
|
1637
|
+
hasBody: () => {
|
|
1638
|
+
return false;
|
|
1639
|
+
},
|
|
1640
|
+
body: () => {
|
|
1641
|
+
return null;
|
|
1642
|
+
},
|
|
1643
|
+
};
|
|
1644
|
+
// Inspired from paulmillr/es6-shim
|
|
1645
|
+
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
|
1646
|
+
/* istanbul ignore next */
|
|
1647
|
+
function getGlobal() {
|
|
1648
|
+
// the only reliable means to get the global object is `Function('return this')()`
|
|
1649
|
+
// However, this causes CSP violations in Chrome apps.
|
|
1650
|
+
if (typeof globalThis !== 'undefined') {
|
|
1651
|
+
return globalThis;
|
|
1652
|
+
}
|
|
1653
|
+
if (typeof self !== 'undefined') {
|
|
1654
|
+
return self;
|
|
1655
|
+
}
|
|
1656
|
+
if (typeof window !== 'undefined') {
|
|
1657
|
+
return window;
|
|
1658
|
+
}
|
|
1659
|
+
if (typeof global !== 'undefined') {
|
|
1660
|
+
return global;
|
|
1661
|
+
}
|
|
1662
|
+
// Gracefully degrade if not able to locate the global object
|
|
1663
|
+
return {};
|
|
1664
|
+
}
|
|
1665
|
+
function init() {
|
|
1666
|
+
/* istanbul ignore if */
|
|
1667
|
+
if (process.env.NODE_ENV === 'production') {
|
|
1668
|
+
// this method should never leak to prod
|
|
1669
|
+
throw new ReferenceError();
|
|
1670
|
+
}
|
|
1671
|
+
const global = getGlobal();
|
|
1672
|
+
// Custom Formatter for Dev Tools. To enable this, open Chrome Dev Tools
|
|
1673
|
+
// - Go to Settings,
|
|
1674
|
+
// - Under console, select "Enable custom formatters"
|
|
1675
|
+
// For more information, https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview
|
|
1676
|
+
const devtoolsFormatters = global.devtoolsFormatters || [];
|
|
1677
|
+
ArrayPush.call(devtoolsFormatters, formatter);
|
|
1678
|
+
global.devtoolsFormatters = devtoolsFormatters;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
/* istanbul ignore else */
|
|
1682
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1683
|
+
init();
|
|
1684
|
+
}
|
|
1685
|
+
function defaultValueIsObservable(value) {
|
|
1686
|
+
// intentionally checking for null
|
|
1687
|
+
if (value === null) {
|
|
1688
|
+
return false;
|
|
1689
|
+
}
|
|
1690
|
+
// treat all non-object types, including undefined, as non-observable values
|
|
1691
|
+
if (typeof value !== 'object') {
|
|
1692
|
+
return false;
|
|
1693
|
+
}
|
|
1694
|
+
if (isArray(value)) {
|
|
1695
|
+
return true;
|
|
1696
|
+
}
|
|
1697
|
+
const proto = getPrototypeOf(value);
|
|
1698
|
+
return proto === ObjectDotPrototype || proto === null || getPrototypeOf(proto) === null;
|
|
1699
|
+
}
|
|
1700
|
+
const defaultValueObserved = (obj, key) => {
|
|
1701
|
+
/* do nothing */
|
|
1702
|
+
};
|
|
1703
|
+
const defaultValueMutated = (obj, key) => {
|
|
1704
|
+
/* do nothing */
|
|
1705
|
+
};
|
|
1706
|
+
function createShadowTarget(value) {
|
|
1707
|
+
return isArray(value) ? [] : {};
|
|
1708
|
+
}
|
|
1709
|
+
class ObservableMembrane {
|
|
1710
|
+
constructor(options = {}) {
|
|
1711
|
+
this.readOnlyObjectGraph = new WeakMap();
|
|
1712
|
+
this.reactiveObjectGraph = new WeakMap();
|
|
1713
|
+
const { valueMutated, valueObserved, valueIsObservable, tagPropertyKey } = options;
|
|
1714
|
+
this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
|
|
1715
|
+
this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
|
|
1716
|
+
this.valueIsObservable = isFunction(valueIsObservable)
|
|
1717
|
+
? valueIsObservable
|
|
1718
|
+
: defaultValueIsObservable;
|
|
1719
|
+
this.tagPropertyKey = tagPropertyKey;
|
|
1720
|
+
}
|
|
1721
|
+
getProxy(value) {
|
|
1722
|
+
const unwrappedValue = unwrap(value);
|
|
1723
|
+
if (this.valueIsObservable(unwrappedValue)) {
|
|
1724
|
+
// When trying to extract the writable version of a readonly we return the readonly.
|
|
1725
|
+
if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
|
|
1726
|
+
return value;
|
|
1727
|
+
}
|
|
1728
|
+
return this.getReactiveHandler(unwrappedValue);
|
|
1729
|
+
}
|
|
1730
|
+
return unwrappedValue;
|
|
1731
|
+
}
|
|
1732
|
+
getReadOnlyProxy(value) {
|
|
1733
|
+
value = unwrap(value);
|
|
1734
|
+
if (this.valueIsObservable(value)) {
|
|
1735
|
+
return this.getReadOnlyHandler(value);
|
|
1736
|
+
}
|
|
1737
|
+
return value;
|
|
1738
|
+
}
|
|
1739
|
+
unwrapProxy(p) {
|
|
1740
|
+
return unwrap(p);
|
|
1741
|
+
}
|
|
1742
|
+
getReactiveHandler(value) {
|
|
1743
|
+
let proxy = this.reactiveObjectGraph.get(value);
|
|
1744
|
+
if (isUndefined(proxy)) {
|
|
1745
|
+
// caching the proxy after the first time it is accessed
|
|
1746
|
+
const handler = new ReactiveProxyHandler(this, value);
|
|
1747
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
|
1748
|
+
registerProxy(proxy, value);
|
|
1749
|
+
this.reactiveObjectGraph.set(value, proxy);
|
|
1750
|
+
}
|
|
1751
|
+
return proxy;
|
|
1752
|
+
}
|
|
1753
|
+
getReadOnlyHandler(value) {
|
|
1754
|
+
let proxy = this.readOnlyObjectGraph.get(value);
|
|
1755
|
+
if (isUndefined(proxy)) {
|
|
1756
|
+
// caching the proxy after the first time it is accessed
|
|
1757
|
+
const handler = new ReadOnlyHandler(this, value);
|
|
1758
|
+
proxy = new Proxy(createShadowTarget(value), handler);
|
|
1759
|
+
registerProxy(proxy, value);
|
|
1760
|
+
this.readOnlyObjectGraph.set(value, proxy);
|
|
1761
|
+
}
|
|
1762
|
+
return proxy;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
/** version: 2.0.0 */
|
|
1766
|
+
|
|
1221
1767
|
/*
|
|
1222
1768
|
* Copyright (c) 2024, Salesforce, Inc.
|
|
1223
1769
|
* All rights reserved.
|
|
1224
1770
|
* SPDX-License-Identifier: MIT
|
|
1225
1771
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1226
1772
|
*/
|
|
1227
|
-
|
|
1228
|
-
//
|
|
1229
|
-
//
|
|
1230
|
-
//
|
|
1231
|
-
function
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1773
|
+
const reactiveMembrane = new ObservableMembrane();
|
|
1774
|
+
// Modeled after `getReadOnlyProxy` in `membrane.ts` in `engine-core`
|
|
1775
|
+
// Return a proxy over the given object so that access is immutable
|
|
1776
|
+
// https://github.com/salesforce/lwc/blob/e9db491/packages/%40lwc/engine-core/src/framework/membrane.ts#L29-L33
|
|
1777
|
+
function getReadOnlyProxy(value) {
|
|
1778
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
/*
|
|
1782
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
1783
|
+
* All rights reserved.
|
|
1784
|
+
* SPDX-License-Identifier: MIT
|
|
1785
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1786
|
+
*/
|
|
1787
|
+
const contextfulRelationships = new WeakMap();
|
|
1788
|
+
function establishContextfulRelationship(parentLe, childLe) {
|
|
1789
|
+
contextfulRelationships.set(childLe, parentLe);
|
|
1790
|
+
}
|
|
1791
|
+
function getContextfulStack(le) {
|
|
1792
|
+
const contextfulParent = contextfulRelationships.get(le);
|
|
1793
|
+
if (!contextfulParent) {
|
|
1794
|
+
return [];
|
|
1239
1795
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1796
|
+
return [contextfulParent, ...getContextfulStack(contextfulParent)];
|
|
1797
|
+
}
|
|
1798
|
+
const contextProviders = new WeakMap();
|
|
1799
|
+
function registerContextProvider(adapter, attachedLe, consumerCallback) {
|
|
1800
|
+
let elementMap = contextProviders.get(adapter);
|
|
1801
|
+
if (!elementMap) {
|
|
1802
|
+
elementMap = new WeakMap();
|
|
1803
|
+
contextProviders.set(adapter, elementMap);
|
|
1804
|
+
}
|
|
1805
|
+
elementMap.set(attachedLe, consumerCallback);
|
|
1806
|
+
}
|
|
1807
|
+
function connectContext(adapter, contextConsumer, onNewValue) {
|
|
1808
|
+
const elementMap = contextProviders.get(adapter);
|
|
1809
|
+
if (!elementMap) {
|
|
1810
|
+
return;
|
|
1247
1811
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1812
|
+
const contextfulStack = getContextfulStack(contextConsumer);
|
|
1813
|
+
for (const ancestor of contextfulStack) {
|
|
1814
|
+
const onConsumerConnected = elementMap.get(ancestor);
|
|
1815
|
+
if (onConsumerConnected) {
|
|
1816
|
+
onConsumerConnected({
|
|
1817
|
+
provide(newContextValue) {
|
|
1818
|
+
onNewValue(newContextValue);
|
|
1819
|
+
},
|
|
1820
|
+
});
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1251
1823
|
}
|
|
1252
1824
|
}
|
|
1825
|
+
function createContextProvider(adapter) {
|
|
1826
|
+
return (le, options) => {
|
|
1827
|
+
if (!(le instanceof LightningElement)) {
|
|
1828
|
+
throw new Error('Unable to register context provider on provided `elm`.');
|
|
1829
|
+
}
|
|
1830
|
+
if (!le.isConnected || !options?.consumerConnectedCallback) {
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
const { consumerConnectedCallback } = options;
|
|
1834
|
+
registerContextProvider(adapter, le, (consumer) => consumerConnectedCallback(consumer));
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1253
1837
|
|
|
1254
|
-
export { ClassList, LightningElement, SYMBOL__GENERATE_MARKUP, SYMBOL__SET_INTERNALS, api,
|
|
1255
|
-
/** version: 8.
|
|
1838
|
+
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 };
|
|
1839
|
+
/** version: 8.9.0 */
|
|
1256
1840
|
//# sourceMappingURL=index.js.map
|