@lwc/engine-core 2.21.1 → 2.22.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/engine-core.cjs.js +100 -57
- package/dist/engine-core.js +101 -58
- package/package.json +3 -3
- package/types/framework/accessor-reactive-observer.d.ts +9 -0
- package/types/framework/component.d.ts +1 -1
- package/types/framework/decorators/api.d.ts +0 -8
- package/types/framework/membrane.d.ts +3 -3
- package/types/framework/mutation-tracker.d.ts +2 -0
- package/types/framework/vm.d.ts +1 -1
- package/types/libs/mutation-tracker/index.d.ts +2 -3
package/dist/engine-core.cjs.js
CHANGED
|
@@ -216,11 +216,28 @@ class ReactiveObserver {
|
|
|
216
216
|
* SPDX-License-Identifier: MIT
|
|
217
217
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
218
218
|
*/
|
|
219
|
+
const DUMMY_REACTIVE_OBSERVER = {
|
|
220
|
+
observe(job) {
|
|
221
|
+
job();
|
|
222
|
+
},
|
|
223
|
+
reset() { },
|
|
224
|
+
link() { },
|
|
225
|
+
};
|
|
219
226
|
function componentValueMutated(vm, key) {
|
|
220
|
-
|
|
227
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
228
|
+
if (process.env.IS_BROWSER) {
|
|
229
|
+
valueMutated(vm.component, key);
|
|
230
|
+
}
|
|
221
231
|
}
|
|
222
232
|
function componentValueObserved(vm, key) {
|
|
223
|
-
|
|
233
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
234
|
+
if (process.env.IS_BROWSER) {
|
|
235
|
+
valueObserved(vm.component, key);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function createReactiveObserver(callback) {
|
|
239
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
240
|
+
return process.env.IS_BROWSER ? new ReactiveObserver(callback) : DUMMY_REACTIVE_OBSERVER;
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
/*
|
|
@@ -1342,7 +1359,24 @@ const reactiveMembrane = new ObservableMembrane({
|
|
|
1342
1359
|
* change or being removed.
|
|
1343
1360
|
*/
|
|
1344
1361
|
function unwrap(value) {
|
|
1345
|
-
|
|
1362
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1363
|
+
return process.env.IS_BROWSER ? reactiveMembrane.unwrapProxy(value) : value;
|
|
1364
|
+
}
|
|
1365
|
+
function getReadOnlyProxy(value) {
|
|
1366
|
+
// We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
|
|
1367
|
+
// them from their parents. This applies to both the client and server.
|
|
1368
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
|
1369
|
+
}
|
|
1370
|
+
function getReactiveProxy(value) {
|
|
1371
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1372
|
+
return process.env.IS_BROWSER ? reactiveMembrane.getProxy(value) : value;
|
|
1373
|
+
}
|
|
1374
|
+
// Making the component instance a live value when using Locker to support expandos.
|
|
1375
|
+
function markLockerLiveObject(obj) {
|
|
1376
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1377
|
+
if (process.env.IS_BROWSER) {
|
|
1378
|
+
obj[lockerLivePropertyKey] = undefined;
|
|
1379
|
+
}
|
|
1346
1380
|
}
|
|
1347
1381
|
|
|
1348
1382
|
/*
|
|
@@ -1432,8 +1466,7 @@ const LightningElement = function () {
|
|
|
1432
1466
|
vm.setHook = setHook;
|
|
1433
1467
|
vm.getHook = getHook;
|
|
1434
1468
|
}
|
|
1435
|
-
|
|
1436
|
-
this[lockerLivePropertyKey] = undefined;
|
|
1469
|
+
markLockerLiveObject(this);
|
|
1437
1470
|
// Linking elm, shadow root and component with the VM.
|
|
1438
1471
|
associateVM(component, vm);
|
|
1439
1472
|
associateVM(elm, vm);
|
|
@@ -1703,6 +1736,60 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1703
1736
|
};
|
|
1704
1737
|
}
|
|
1705
1738
|
|
|
1739
|
+
/*
|
|
1740
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1741
|
+
* All rights reserved.
|
|
1742
|
+
* SPDX-License-Identifier: MIT
|
|
1743
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1744
|
+
*/
|
|
1745
|
+
const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
|
|
1746
|
+
observe(job) {
|
|
1747
|
+
job();
|
|
1748
|
+
},
|
|
1749
|
+
reset() { },
|
|
1750
|
+
link() { },
|
|
1751
|
+
};
|
|
1752
|
+
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1753
|
+
constructor(vm, set) {
|
|
1754
|
+
super(() => {
|
|
1755
|
+
if (shared.isFalse(this.debouncing)) {
|
|
1756
|
+
this.debouncing = true;
|
|
1757
|
+
addCallbackToNextTick(() => {
|
|
1758
|
+
if (shared.isTrue(this.debouncing)) {
|
|
1759
|
+
const { value } = this;
|
|
1760
|
+
const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
|
|
1761
|
+
set.call(component, value);
|
|
1762
|
+
// de-bouncing after the call to the original setter to prevent
|
|
1763
|
+
// infinity loop if the setter itself is mutating things that
|
|
1764
|
+
// were accessed during the previous invocation.
|
|
1765
|
+
this.debouncing = false;
|
|
1766
|
+
if (shared.isTrue(vm.isDirty) && shared.isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1767
|
+
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1768
|
+
// the component will get rendered on the second tick, which it is not
|
|
1769
|
+
// desirable.
|
|
1770
|
+
rerenderVM(vm);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
});
|
|
1776
|
+
this.debouncing = false;
|
|
1777
|
+
}
|
|
1778
|
+
reset(value) {
|
|
1779
|
+
super.reset();
|
|
1780
|
+
this.debouncing = false;
|
|
1781
|
+
if (arguments.length > 0) {
|
|
1782
|
+
this.value = value;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
function createAccessorReactiveObserver(vm, set) {
|
|
1787
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1788
|
+
return process.env.IS_BROWSER
|
|
1789
|
+
? new AccessorReactiveObserver(vm, set)
|
|
1790
|
+
: DUMMY_ACCESSOR_REACTIVE_OBSERVER;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1706
1793
|
/*
|
|
1707
1794
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1708
1795
|
* All rights reserved.
|
|
@@ -1750,50 +1837,6 @@ function createPublicPropertyDescriptor(key) {
|
|
|
1750
1837
|
configurable: true
|
|
1751
1838
|
};
|
|
1752
1839
|
}
|
|
1753
|
-
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1754
|
-
constructor(vm, set) {
|
|
1755
|
-
super(() => {
|
|
1756
|
-
if (shared.isFalse(this.debouncing)) {
|
|
1757
|
-
this.debouncing = true;
|
|
1758
|
-
addCallbackToNextTick(() => {
|
|
1759
|
-
if (shared.isTrue(this.debouncing)) {
|
|
1760
|
-
const {
|
|
1761
|
-
value
|
|
1762
|
-
} = this;
|
|
1763
|
-
const {
|
|
1764
|
-
isDirty: dirtyStateBeforeSetterCall,
|
|
1765
|
-
component,
|
|
1766
|
-
idx
|
|
1767
|
-
} = vm;
|
|
1768
|
-
set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
|
1769
|
-
// infinity loop if the setter itself is mutating things that
|
|
1770
|
-
// were accessed during the previous invocation.
|
|
1771
|
-
|
|
1772
|
-
this.debouncing = false;
|
|
1773
|
-
|
|
1774
|
-
if (shared.isTrue(vm.isDirty) && shared.isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1775
|
-
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1776
|
-
// the component will get rendered on the second tick, which it is not
|
|
1777
|
-
// desirable.
|
|
1778
|
-
rerenderVM(vm);
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
});
|
|
1784
|
-
this.debouncing = false;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
reset(value) {
|
|
1788
|
-
super.reset();
|
|
1789
|
-
this.debouncing = false;
|
|
1790
|
-
|
|
1791
|
-
if (arguments.length > 0) {
|
|
1792
|
-
this.value = value;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
}
|
|
1797
1840
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
1798
1841
|
const {
|
|
1799
1842
|
get,
|
|
@@ -1834,7 +1877,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1834
1877
|
let ro = vm.oar[key];
|
|
1835
1878
|
|
|
1836
1879
|
if (shared.isUndefined(ro)) {
|
|
1837
|
-
ro = vm.oar[key] =
|
|
1880
|
+
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
1838
1881
|
} // every time we invoke this setter from outside (through this wrapper setter)
|
|
1839
1882
|
// we should reset the value and then debounce just in case there is a pending
|
|
1840
1883
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
@@ -1866,7 +1909,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1866
1909
|
*/
|
|
1867
1910
|
function track(target) {
|
|
1868
1911
|
if (arguments.length === 1) {
|
|
1869
|
-
return
|
|
1912
|
+
return getReactiveProxy(target);
|
|
1870
1913
|
}
|
|
1871
1914
|
if (process.env.NODE_ENV !== 'production') {
|
|
1872
1915
|
shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
@@ -1887,7 +1930,7 @@ function internalTrackDecorator(key) {
|
|
|
1887
1930
|
shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1888
1931
|
shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
|
|
1889
1932
|
}
|
|
1890
|
-
const reactiveOrAnyValue =
|
|
1933
|
+
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
1891
1934
|
if (reactiveOrAnyValue !== vm.cmpFields[key]) {
|
|
1892
1935
|
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
1893
1936
|
componentValueMutated(vm, key);
|
|
@@ -2279,7 +2322,7 @@ function createSetter(key) {
|
|
|
2279
2322
|
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2280
2323
|
const vm = getAssociatedVM(this);
|
|
2281
2324
|
const { setHook } = vm;
|
|
2282
|
-
newValue =
|
|
2325
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2283
2326
|
setHook(vm.component, key, newValue);
|
|
2284
2327
|
};
|
|
2285
2328
|
}
|
|
@@ -4715,7 +4758,7 @@ function getComponentRegisteredTemplate(Ctor) {
|
|
|
4715
4758
|
return signedTemplateMap.get(Ctor);
|
|
4716
4759
|
}
|
|
4717
4760
|
function getTemplateReactiveObserver(vm) {
|
|
4718
|
-
return
|
|
4761
|
+
return createReactiveObserver(() => {
|
|
4719
4762
|
const { isDirty } = vm;
|
|
4720
4763
|
if (shared.isFalse(isDirty)) {
|
|
4721
4764
|
markComponentAsDirty(vm);
|
|
@@ -5530,7 +5573,7 @@ function createMethodDataCallback(vm, method) {
|
|
|
5530
5573
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
5531
5574
|
let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
|
|
5532
5575
|
|
|
5533
|
-
const ro =
|
|
5576
|
+
const ro = createReactiveObserver(() => {
|
|
5534
5577
|
if (hasPendingConfig === false) {
|
|
5535
5578
|
hasPendingConfig = true; // collect new config in the micro-task
|
|
5536
5579
|
|
|
@@ -5826,7 +5869,7 @@ function readonly(obj) {
|
|
|
5826
5869
|
shared.assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
|
5827
5870
|
}
|
|
5828
5871
|
}
|
|
5829
|
-
return
|
|
5872
|
+
return getReadOnlyProxy(obj);
|
|
5830
5873
|
}
|
|
5831
5874
|
|
|
5832
5875
|
/*
|
|
@@ -6376,4 +6419,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6376
6419
|
exports.track = track;
|
|
6377
6420
|
exports.unwrap = unwrap;
|
|
6378
6421
|
exports.wire = wire;
|
|
6379
|
-
/* version: 2.
|
|
6422
|
+
/* version: 2.22.0 */
|
package/dist/engine-core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
2
|
import { runtimeFlags } from '@lwc/features';
|
|
3
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
|
-
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1,
|
|
4
|
+
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -213,11 +213,28 @@ class ReactiveObserver {
|
|
|
213
213
|
* SPDX-License-Identifier: MIT
|
|
214
214
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
215
215
|
*/
|
|
216
|
+
const DUMMY_REACTIVE_OBSERVER = {
|
|
217
|
+
observe(job) {
|
|
218
|
+
job();
|
|
219
|
+
},
|
|
220
|
+
reset() { },
|
|
221
|
+
link() { },
|
|
222
|
+
};
|
|
216
223
|
function componentValueMutated(vm, key) {
|
|
217
|
-
|
|
224
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
225
|
+
if (process.env.IS_BROWSER) {
|
|
226
|
+
valueMutated(vm.component, key);
|
|
227
|
+
}
|
|
218
228
|
}
|
|
219
229
|
function componentValueObserved(vm, key) {
|
|
220
|
-
|
|
230
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
231
|
+
if (process.env.IS_BROWSER) {
|
|
232
|
+
valueObserved(vm.component, key);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function createReactiveObserver(callback) {
|
|
236
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
237
|
+
return process.env.IS_BROWSER ? new ReactiveObserver(callback) : DUMMY_REACTIVE_OBSERVER;
|
|
221
238
|
}
|
|
222
239
|
|
|
223
240
|
/*
|
|
@@ -1339,7 +1356,24 @@ const reactiveMembrane = new ObservableMembrane({
|
|
|
1339
1356
|
* change or being removed.
|
|
1340
1357
|
*/
|
|
1341
1358
|
function unwrap(value) {
|
|
1342
|
-
|
|
1359
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1360
|
+
return process.env.IS_BROWSER ? reactiveMembrane.unwrapProxy(value) : value;
|
|
1361
|
+
}
|
|
1362
|
+
function getReadOnlyProxy(value) {
|
|
1363
|
+
// We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
|
|
1364
|
+
// them from their parents. This applies to both the client and server.
|
|
1365
|
+
return reactiveMembrane.getReadOnlyProxy(value);
|
|
1366
|
+
}
|
|
1367
|
+
function getReactiveProxy(value) {
|
|
1368
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1369
|
+
return process.env.IS_BROWSER ? reactiveMembrane.getProxy(value) : value;
|
|
1370
|
+
}
|
|
1371
|
+
// Making the component instance a live value when using Locker to support expandos.
|
|
1372
|
+
function markLockerLiveObject(obj) {
|
|
1373
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1374
|
+
if (process.env.IS_BROWSER) {
|
|
1375
|
+
obj[lockerLivePropertyKey] = undefined;
|
|
1376
|
+
}
|
|
1343
1377
|
}
|
|
1344
1378
|
|
|
1345
1379
|
/*
|
|
@@ -1429,8 +1463,7 @@ const LightningElement = function () {
|
|
|
1429
1463
|
vm.setHook = setHook;
|
|
1430
1464
|
vm.getHook = getHook;
|
|
1431
1465
|
}
|
|
1432
|
-
|
|
1433
|
-
this[lockerLivePropertyKey] = undefined;
|
|
1466
|
+
markLockerLiveObject(this);
|
|
1434
1467
|
// Linking elm, shadow root and component with the VM.
|
|
1435
1468
|
associateVM(component, vm);
|
|
1436
1469
|
associateVM(elm, vm);
|
|
@@ -1700,6 +1733,60 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
1700
1733
|
};
|
|
1701
1734
|
}
|
|
1702
1735
|
|
|
1736
|
+
/*
|
|
1737
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
1738
|
+
* All rights reserved.
|
|
1739
|
+
* SPDX-License-Identifier: MIT
|
|
1740
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1741
|
+
*/
|
|
1742
|
+
const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
|
|
1743
|
+
observe(job) {
|
|
1744
|
+
job();
|
|
1745
|
+
},
|
|
1746
|
+
reset() { },
|
|
1747
|
+
link() { },
|
|
1748
|
+
};
|
|
1749
|
+
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1750
|
+
constructor(vm, set) {
|
|
1751
|
+
super(() => {
|
|
1752
|
+
if (isFalse(this.debouncing)) {
|
|
1753
|
+
this.debouncing = true;
|
|
1754
|
+
addCallbackToNextTick(() => {
|
|
1755
|
+
if (isTrue(this.debouncing)) {
|
|
1756
|
+
const { value } = this;
|
|
1757
|
+
const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
|
|
1758
|
+
set.call(component, value);
|
|
1759
|
+
// de-bouncing after the call to the original setter to prevent
|
|
1760
|
+
// infinity loop if the setter itself is mutating things that
|
|
1761
|
+
// were accessed during the previous invocation.
|
|
1762
|
+
this.debouncing = false;
|
|
1763
|
+
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1764
|
+
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1765
|
+
// the component will get rendered on the second tick, which it is not
|
|
1766
|
+
// desirable.
|
|
1767
|
+
rerenderVM(vm);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
this.debouncing = false;
|
|
1774
|
+
}
|
|
1775
|
+
reset(value) {
|
|
1776
|
+
super.reset();
|
|
1777
|
+
this.debouncing = false;
|
|
1778
|
+
if (arguments.length > 0) {
|
|
1779
|
+
this.value = value;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
function createAccessorReactiveObserver(vm, set) {
|
|
1784
|
+
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
1785
|
+
return process.env.IS_BROWSER
|
|
1786
|
+
? new AccessorReactiveObserver(vm, set)
|
|
1787
|
+
: DUMMY_ACCESSOR_REACTIVE_OBSERVER;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1703
1790
|
/*
|
|
1704
1791
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1705
1792
|
* All rights reserved.
|
|
@@ -1747,50 +1834,6 @@ function createPublicPropertyDescriptor(key) {
|
|
|
1747
1834
|
configurable: true
|
|
1748
1835
|
};
|
|
1749
1836
|
}
|
|
1750
|
-
class AccessorReactiveObserver extends ReactiveObserver {
|
|
1751
|
-
constructor(vm, set) {
|
|
1752
|
-
super(() => {
|
|
1753
|
-
if (isFalse(this.debouncing)) {
|
|
1754
|
-
this.debouncing = true;
|
|
1755
|
-
addCallbackToNextTick(() => {
|
|
1756
|
-
if (isTrue(this.debouncing)) {
|
|
1757
|
-
const {
|
|
1758
|
-
value
|
|
1759
|
-
} = this;
|
|
1760
|
-
const {
|
|
1761
|
-
isDirty: dirtyStateBeforeSetterCall,
|
|
1762
|
-
component,
|
|
1763
|
-
idx
|
|
1764
|
-
} = vm;
|
|
1765
|
-
set.call(component, value); // de-bouncing after the call to the original setter to prevent
|
|
1766
|
-
// infinity loop if the setter itself is mutating things that
|
|
1767
|
-
// were accessed during the previous invocation.
|
|
1768
|
-
|
|
1769
|
-
this.debouncing = false;
|
|
1770
|
-
|
|
1771
|
-
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
1772
|
-
// immediate rehydration due to a setter driven mutation, otherwise
|
|
1773
|
-
// the component will get rendered on the second tick, which it is not
|
|
1774
|
-
// desirable.
|
|
1775
|
-
rerenderVM(vm);
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
});
|
|
1781
|
-
this.debouncing = false;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
reset(value) {
|
|
1785
|
-
super.reset();
|
|
1786
|
-
this.debouncing = false;
|
|
1787
|
-
|
|
1788
|
-
if (arguments.length > 0) {
|
|
1789
|
-
this.value = value;
|
|
1790
|
-
}
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
}
|
|
1794
1837
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
1795
1838
|
const {
|
|
1796
1839
|
get,
|
|
@@ -1831,7 +1874,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1831
1874
|
let ro = vm.oar[key];
|
|
1832
1875
|
|
|
1833
1876
|
if (isUndefined$1(ro)) {
|
|
1834
|
-
ro = vm.oar[key] =
|
|
1877
|
+
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
1835
1878
|
} // every time we invoke this setter from outside (through this wrapper setter)
|
|
1836
1879
|
// we should reset the value and then debounce just in case there is a pending
|
|
1837
1880
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
@@ -1863,7 +1906,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
1863
1906
|
*/
|
|
1864
1907
|
function track(target) {
|
|
1865
1908
|
if (arguments.length === 1) {
|
|
1866
|
-
return
|
|
1909
|
+
return getReactiveProxy(target);
|
|
1867
1910
|
}
|
|
1868
1911
|
if (process.env.NODE_ENV !== 'production') {
|
|
1869
1912
|
assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
|
|
@@ -1884,7 +1927,7 @@ function internalTrackDecorator(key) {
|
|
|
1884
1927
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1885
1928
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
1886
1929
|
}
|
|
1887
|
-
const reactiveOrAnyValue =
|
|
1930
|
+
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
|
1888
1931
|
if (reactiveOrAnyValue !== vm.cmpFields[key]) {
|
|
1889
1932
|
vm.cmpFields[key] = reactiveOrAnyValue;
|
|
1890
1933
|
componentValueMutated(vm, key);
|
|
@@ -2276,7 +2319,7 @@ function createSetter(key) {
|
|
|
2276
2319
|
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2277
2320
|
const vm = getAssociatedVM(this);
|
|
2278
2321
|
const { setHook } = vm;
|
|
2279
|
-
newValue =
|
|
2322
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2280
2323
|
setHook(vm.component, key, newValue);
|
|
2281
2324
|
};
|
|
2282
2325
|
}
|
|
@@ -4712,7 +4755,7 @@ function getComponentRegisteredTemplate(Ctor) {
|
|
|
4712
4755
|
return signedTemplateMap.get(Ctor);
|
|
4713
4756
|
}
|
|
4714
4757
|
function getTemplateReactiveObserver(vm) {
|
|
4715
|
-
return
|
|
4758
|
+
return createReactiveObserver(() => {
|
|
4716
4759
|
const { isDirty } = vm;
|
|
4717
4760
|
if (isFalse(isDirty)) {
|
|
4718
4761
|
markComponentAsDirty(vm);
|
|
@@ -5527,7 +5570,7 @@ function createMethodDataCallback(vm, method) {
|
|
|
5527
5570
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
5528
5571
|
let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
|
|
5529
5572
|
|
|
5530
|
-
const ro =
|
|
5573
|
+
const ro = createReactiveObserver(() => {
|
|
5531
5574
|
if (hasPendingConfig === false) {
|
|
5532
5575
|
hasPendingConfig = true; // collect new config in the micro-task
|
|
5533
5576
|
|
|
@@ -5823,7 +5866,7 @@ function readonly(obj) {
|
|
|
5823
5866
|
assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
|
|
5824
5867
|
}
|
|
5825
5868
|
}
|
|
5826
|
-
return
|
|
5869
|
+
return getReadOnlyProxy(obj);
|
|
5827
5870
|
}
|
|
5828
5871
|
|
|
5829
5872
|
/*
|
|
@@ -6336,4 +6379,4 @@ function getComponentConstructor(elm) {
|
|
|
6336
6379
|
}
|
|
6337
6380
|
|
|
6338
6381
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6339
|
-
/* version: 2.
|
|
6382
|
+
/* version: 2.22.0 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/engine-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Core LWC engine APIs.",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"types/"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lwc/features": "2.
|
|
29
|
-
"@lwc/shared": "2.
|
|
28
|
+
"@lwc/features": "2.22.0",
|
|
29
|
+
"@lwc/shared": "2.22.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"observable-membrane": "2.0.0"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactiveObserver } from '../libs/mutation-tracker';
|
|
2
|
+
import { VM } from './vm';
|
|
3
|
+
export declare class AccessorReactiveObserver extends ReactiveObserver {
|
|
4
|
+
private value;
|
|
5
|
+
private debouncing;
|
|
6
|
+
constructor(vm: VM, set: (v: any) => void);
|
|
7
|
+
reset(value?: any): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function createAccessorReactiveObserver(vm: VM, set: (v: any) => void): AccessorReactiveObserver;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ReactiveObserver } from '../mutation-tracker';
|
|
2
|
-
import { VM } from '../vm';
|
|
3
1
|
/**
|
|
4
2
|
* @api decorator to mark public fields and public methods in
|
|
5
3
|
* LWC Components. This function implements the internals of this
|
|
@@ -7,10 +5,4 @@ import { VM } from '../vm';
|
|
|
7
5
|
*/
|
|
8
6
|
export default function api(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
|
|
9
7
|
export declare function createPublicPropertyDescriptor(key: string): PropertyDescriptor;
|
|
10
|
-
export declare class AccessorReactiveObserver extends ReactiveObserver {
|
|
11
|
-
private value;
|
|
12
|
-
private debouncing;
|
|
13
|
-
constructor(vm: VM, set: (v: any) => void);
|
|
14
|
-
reset(value?: any): void;
|
|
15
|
-
}
|
|
16
8
|
export declare function createPublicAccessorDescriptor(key: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ObservableMembrane } from 'observable-membrane';
|
|
2
|
-
export declare const lockerLivePropertyKey: unique symbol;
|
|
3
|
-
export declare const reactiveMembrane: ObservableMembrane;
|
|
4
1
|
/**
|
|
5
2
|
* EXPERIMENTAL: This function implements an unwrap mechanism that
|
|
6
3
|
* works for observable membrane objects. This API is subject to
|
|
7
4
|
* change or being removed.
|
|
8
5
|
*/
|
|
9
6
|
export declare function unwrap(value: any): any;
|
|
7
|
+
export declare function getReadOnlyProxy(value: any): any;
|
|
8
|
+
export declare function getReactiveProxy(value: any): any;
|
|
9
|
+
export declare function markLockerLiveObject(obj: any): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { CallbackFunction, ReactiveObserver } from '../libs/mutation-tracker';
|
|
1
2
|
import { VM } from './vm';
|
|
2
3
|
export declare function componentValueMutated(vm: VM, key: PropertyKey): void;
|
|
3
4
|
export declare function componentValueObserved(vm: VM, key: PropertyKey): void;
|
|
5
|
+
export declare function createReactiveObserver(callback: CallbackFunction): ReactiveObserver;
|
|
4
6
|
export * from '../libs/mutation-tracker';
|
package/types/framework/vm.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Template } from './template';
|
|
|
3
3
|
import { ComponentDef } from './def';
|
|
4
4
|
import { LightningElement, LightningElementConstructor } from './base-lightning-element';
|
|
5
5
|
import { ReactiveObserver } from './mutation-tracker';
|
|
6
|
-
import { AccessorReactiveObserver } from './
|
|
6
|
+
import { AccessorReactiveObserver } from './accessor-reactive-observer';
|
|
7
7
|
import { VNodes, VCustomElement, VNode } from './vnodes';
|
|
8
8
|
declare type ShadowRootMode = 'open' | 'closed';
|
|
9
9
|
export interface TemplateCache {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare function valueMutated(target: object, key: PropertyKey): void;
|
|
2
2
|
export declare function valueObserved(target: object, key: PropertyKey): void;
|
|
3
|
-
declare type CallbackFunction = (rp: ReactiveObserver) => void;
|
|
4
|
-
declare type JobFunction = () => void;
|
|
3
|
+
export declare type CallbackFunction = (rp: ReactiveObserver) => void;
|
|
4
|
+
export declare type JobFunction = () => void;
|
|
5
5
|
export declare class ReactiveObserver {
|
|
6
6
|
private listeners;
|
|
7
7
|
private callback;
|
|
@@ -16,4 +16,3 @@ export declare class ReactiveObserver {
|
|
|
16
16
|
notify(): void;
|
|
17
17
|
link(reactiveObservers: ReactiveObserver[]): void;
|
|
18
18
|
}
|
|
19
|
-
export {};
|