@lwc/engine-core 2.5.9 → 2.5.10-alpha1

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.
@@ -1431,6 +1431,7 @@ const {
1431
1431
  getPrototypeOf,
1432
1432
  create: ObjectCreate,
1433
1433
  defineProperty: ObjectDefineProperty,
1434
+ defineProperties: ObjectDefineProperties,
1434
1435
  isExtensible,
1435
1436
  getOwnPropertyDescriptor,
1436
1437
  getOwnPropertyNames,
@@ -1440,7 +1441,8 @@ const {
1440
1441
  } = Object;
1441
1442
  const {
1442
1443
  push: ArrayPush,
1443
- concat: ArrayConcat
1444
+ concat: ArrayConcat,
1445
+ map: ArrayMap
1444
1446
  } = Array.prototype;
1445
1447
  const OtS = {}.toString;
1446
1448
 
@@ -1505,9 +1507,7 @@ class BaseProxyHandler {
1505
1507
  // but it will always be compatible with the previous descriptor
1506
1508
  // to preserve the object invariants, which makes these lines safe.
1507
1509
 
1508
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1509
-
1510
- /* istanbul ignore else */
1510
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1511
1511
 
1512
1512
  if (!isUndefined(originalDescriptor)) {
1513
1513
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1535,17 +1535,11 @@ class BaseProxyHandler {
1535
1535
 
1536
1536
  preventExtensions(shadowTarget);
1537
1537
  } // Shared Traps
1538
- // TODO: apply() is never called
1539
-
1540
- /* istanbul ignore next */
1541
1538
 
1542
1539
 
1543
1540
  apply(shadowTarget, thisArg, argArray) {
1544
1541
  /* No op */
1545
- } // TODO: construct() is never called
1546
-
1547
- /* istanbul ignore next */
1548
-
1542
+ }
1549
1543
 
1550
1544
  construct(shadowTarget, argArray, newTarget) {
1551
1545
  /* No op */
@@ -1658,8 +1652,8 @@ class BaseProxyHandler {
1658
1652
 
1659
1653
  }
1660
1654
 
1661
- const getterMap$1 = new WeakMap();
1662
- const setterMap$1 = new WeakMap();
1655
+ const getterMap = new WeakMap();
1656
+ const setterMap = new WeakMap();
1663
1657
  const reverseGetterMap = new WeakMap();
1664
1658
  const reverseSetterMap = new WeakMap();
1665
1659
 
@@ -1669,7 +1663,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1669
1663
  }
1670
1664
 
1671
1665
  wrapGetter(originalGet) {
1672
- const wrappedGetter = getterMap$1.get(originalGet);
1666
+ const wrappedGetter = getterMap.get(originalGet);
1673
1667
 
1674
1668
  if (!isUndefined(wrappedGetter)) {
1675
1669
  return wrappedGetter;
@@ -1682,13 +1676,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1682
1676
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1683
1677
  };
1684
1678
 
1685
- getterMap$1.set(originalGet, get);
1679
+ getterMap.set(originalGet, get);
1686
1680
  reverseGetterMap.set(get, originalGet);
1687
1681
  return get;
1688
1682
  }
1689
1683
 
1690
1684
  wrapSetter(originalSet) {
1691
- const wrappedSetter = setterMap$1.get(originalSet);
1685
+ const wrappedSetter = setterMap.get(originalSet);
1692
1686
 
1693
1687
  if (!isUndefined(wrappedSetter)) {
1694
1688
  return wrappedSetter;
@@ -1699,7 +1693,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1699
1693
  originalSet.call(unwrap$1(this), unwrap$1(v));
1700
1694
  };
1701
1695
 
1702
- setterMap$1.set(originalSet, set);
1696
+ setterMap.set(originalSet, set);
1703
1697
  reverseSetterMap.set(set, originalSet);
1704
1698
  return set;
1705
1699
  }
@@ -1740,7 +1734,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1740
1734
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1741
1735
  };
1742
1736
 
1743
- getterMap$1.set(get, redGet);
1737
+ getterMap.set(get, redGet);
1744
1738
  reverseGetterMap.set(redGet, get);
1745
1739
  return get;
1746
1740
  }
@@ -1759,7 +1753,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1759
1753
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1760
1754
  };
1761
1755
 
1762
- setterMap$1.set(set, redSet);
1756
+ setterMap.set(set, redSet);
1763
1757
  reverseSetterMap.set(redSet, set);
1764
1758
  return set;
1765
1759
  }
@@ -1800,7 +1794,6 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1800
1794
  }
1801
1795
 
1802
1796
  setPrototypeOf(shadowTarget, prototype) {
1803
- /* istanbul ignore else */
1804
1797
  if (process.env.NODE_ENV !== 'production') {
1805
1798
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
1806
1799
  }
@@ -1814,11 +1807,6 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1814
1807
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1815
1808
  // the preventExtension call, in which case we should not attempt to lock down
1816
1809
  // the shadow target.
1817
- // TODO: It should not actually be possible to reach this `if` statement.
1818
- // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1819
- // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1820
-
1821
- /* istanbul ignore if */
1822
1810
 
1823
1811
  if (isExtensible(originalTarget)) {
1824
1812
  return false;
@@ -1860,8 +1848,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1860
1848
 
1861
1849
  }
1862
1850
 
1863
- const getterMap = new WeakMap();
1864
- const setterMap = new WeakMap();
1851
+ const getterMap$1 = new WeakMap();
1852
+ const setterMap$1 = new WeakMap();
1865
1853
 
1866
1854
  class ReadOnlyHandler extends BaseProxyHandler {
1867
1855
  wrapValue(value) {
@@ -1869,7 +1857,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1869
1857
  }
1870
1858
 
1871
1859
  wrapGetter(originalGet) {
1872
- const wrappedGetter = getterMap.get(originalGet);
1860
+ const wrappedGetter = getterMap$1.get(originalGet);
1873
1861
 
1874
1862
  if (!isUndefined(wrappedGetter)) {
1875
1863
  return wrappedGetter;
@@ -1882,12 +1870,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
1882
1870
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1883
1871
  };
1884
1872
 
1885
- getterMap.set(originalGet, get);
1873
+ getterMap$1.set(originalGet, get);
1886
1874
  return get;
1887
1875
  }
1888
1876
 
1889
1877
  wrapSetter(originalSet) {
1890
- const wrappedSetter = setterMap.get(originalSet);
1878
+ const wrappedSetter = setterMap$1.get(originalSet);
1891
1879
 
1892
1880
  if (!isUndefined(wrappedSetter)) {
1893
1881
  return wrappedSetter;
@@ -1896,7 +1884,6 @@ class ReadOnlyHandler extends BaseProxyHandler {
1896
1884
  const handler = this;
1897
1885
 
1898
1886
  const set = function (v) {
1899
- /* istanbul ignore else */
1900
1887
  if (process.env.NODE_ENV !== 'production') {
1901
1888
  const {
1902
1889
  originalTarget
@@ -1905,41 +1892,33 @@ class ReadOnlyHandler extends BaseProxyHandler {
1905
1892
  }
1906
1893
  };
1907
1894
 
1908
- setterMap.set(originalSet, set);
1895
+ setterMap$1.set(originalSet, set);
1909
1896
  return set;
1910
1897
  }
1911
1898
 
1912
1899
  set(shadowTarget, key, value) {
1913
- /* istanbul ignore else */
1914
1900
  if (process.env.NODE_ENV !== 'production') {
1915
1901
  const {
1916
1902
  originalTarget
1917
1903
  } = this;
1918
- const msg = isArray(originalTarget) ? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.` : `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
1919
- throw new Error(msg);
1904
+ throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1920
1905
  }
1921
- /* istanbul ignore next */
1922
-
1923
1906
 
1924
1907
  return false;
1925
1908
  }
1926
1909
 
1927
1910
  deleteProperty(shadowTarget, key) {
1928
- /* istanbul ignore else */
1929
1911
  if (process.env.NODE_ENV !== 'production') {
1930
1912
  const {
1931
1913
  originalTarget
1932
1914
  } = this;
1933
1915
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1934
1916
  }
1935
- /* istanbul ignore next */
1936
-
1937
1917
 
1938
1918
  return false;
1939
1919
  }
1940
1920
 
1941
1921
  setPrototypeOf(shadowTarget, prototype) {
1942
- /* istanbul ignore else */
1943
1922
  if (process.env.NODE_ENV !== 'production') {
1944
1923
  const {
1945
1924
  originalTarget
@@ -1949,29 +1928,23 @@ class ReadOnlyHandler extends BaseProxyHandler {
1949
1928
  }
1950
1929
 
1951
1930
  preventExtensions(shadowTarget) {
1952
- /* istanbul ignore else */
1953
1931
  if (process.env.NODE_ENV !== 'production') {
1954
1932
  const {
1955
1933
  originalTarget
1956
1934
  } = this;
1957
1935
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
1958
1936
  }
1959
- /* istanbul ignore next */
1960
-
1961
1937
 
1962
1938
  return false;
1963
1939
  }
1964
1940
 
1965
1941
  defineProperty(shadowTarget, key, descriptor) {
1966
- /* istanbul ignore else */
1967
1942
  if (process.env.NODE_ENV !== 'production') {
1968
1943
  const {
1969
1944
  originalTarget
1970
1945
  } = this;
1971
1946
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1972
1947
  }
1973
- /* istanbul ignore next */
1974
-
1975
1948
 
1976
1949
  return false;
1977
1950
  }
@@ -2029,8 +2002,6 @@ const formatter = {
2029
2002
  }; // Inspired from paulmillr/es6-shim
2030
2003
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2031
2004
 
2032
- /* istanbul ignore next */
2033
-
2034
2005
  function getGlobal() {
2035
2006
  // the only reliable means to get the global object is `Function('return this')()`
2036
2007
  // However, this causes CSP violations in Chrome apps.
@@ -2055,7 +2026,6 @@ function getGlobal() {
2055
2026
  }
2056
2027
 
2057
2028
  function init() {
2058
- /* istanbul ignore if */
2059
2029
  if (process.env.NODE_ENV === 'production') {
2060
2030
  // this method should never leak to prod
2061
2031
  throw new ReferenceError();
@@ -2070,8 +2040,6 @@ function init() {
2070
2040
  ArrayPush.call(devtoolsFormatters, formatter);
2071
2041
  global.devtoolsFormatters = devtoolsFormatters;
2072
2042
  }
2073
- /* istanbul ignore else */
2074
-
2075
2043
 
2076
2044
  if (process.env.NODE_ENV !== 'production') {
2077
2045
  init();
@@ -2118,8 +2086,7 @@ class ReactiveMembrane {
2118
2086
  this.valueMutated = defaultValueMutated;
2119
2087
  this.valueObserved = defaultValueObserved;
2120
2088
  this.valueIsObservable = defaultValueIsObservable;
2121
- this.readOnlyObjectGraph = new WeakMap();
2122
- this.reactiveObjectGraph = new WeakMap();
2089
+ this.objectGraph = new WeakMap();
2123
2090
 
2124
2091
  if (!isUndefined(options)) {
2125
2092
  const {
@@ -2142,13 +2109,10 @@ class ReactiveMembrane {
2142
2109
  const distorted = this.valueDistortion(unwrappedValue);
2143
2110
 
2144
2111
  if (this.valueIsObservable(distorted)) {
2145
- if (this.readOnlyObjectGraph.get(distorted) === value) {
2146
- // when trying to extract the writable version of a readonly
2147
- // we return the readonly.
2148
- return value;
2149
- }
2112
+ const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2113
+ // we return the readonly.
2150
2114
 
2151
- return this.getReactiveHandler(unwrappedValue, distorted);
2115
+ return o.readOnly === value ? value : o.reactive;
2152
2116
  }
2153
2117
 
2154
2118
  return distorted;
@@ -2159,7 +2123,7 @@ class ReactiveMembrane {
2159
2123
  const distorted = this.valueDistortion(value);
2160
2124
 
2161
2125
  if (this.valueIsObservable(distorted)) {
2162
- return this.getReadOnlyHandler(value, distorted);
2126
+ return this.getReactiveState(value, distorted).readOnly;
2163
2127
  }
2164
2128
 
2165
2129
  return distorted;
@@ -2169,36 +2133,47 @@ class ReactiveMembrane {
2169
2133
  return unwrap$1(p);
2170
2134
  }
2171
2135
 
2172
- getReactiveHandler(value, distortedValue) {
2173
- let proxy = this.reactiveObjectGraph.get(distortedValue);
2136
+ getReactiveState(value, distortedValue) {
2137
+ const {
2138
+ objectGraph
2139
+ } = this;
2140
+ let reactiveState = objectGraph.get(distortedValue);
2174
2141
 
2175
- if (isUndefined(proxy)) {
2176
- // caching the proxy after the first time it is accessed
2177
- const handler = new ReactiveProxyHandler(this, distortedValue);
2178
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2179
- registerProxy(proxy, value);
2180
- this.reactiveObjectGraph.set(distortedValue, proxy);
2142
+ if (reactiveState) {
2143
+ return reactiveState;
2181
2144
  }
2182
2145
 
2183
- return proxy;
2184
- }
2146
+ const membrane = this;
2147
+ reactiveState = {
2148
+ get reactive() {
2149
+ const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2185
2150
 
2186
- getReadOnlyHandler(value, distortedValue) {
2187
- let proxy = this.readOnlyObjectGraph.get(distortedValue);
2151
+ const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2152
+ registerProxy(proxy, value);
2153
+ ObjectDefineProperty(this, 'reactive', {
2154
+ value: proxy
2155
+ });
2156
+ return proxy;
2157
+ },
2188
2158
 
2189
- if (isUndefined(proxy)) {
2190
- // caching the proxy after the first time it is accessed
2191
- const handler = new ReadOnlyHandler(this, distortedValue);
2192
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2193
- registerProxy(proxy, value);
2194
- this.readOnlyObjectGraph.set(distortedValue, proxy);
2195
- }
2159
+ get readOnly() {
2160
+ const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2161
+
2162
+ const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2163
+ registerProxy(proxy, value);
2164
+ ObjectDefineProperty(this, 'readOnly', {
2165
+ value: proxy
2166
+ });
2167
+ return proxy;
2168
+ }
2196
2169
 
2197
- return proxy;
2170
+ };
2171
+ objectGraph.set(distortedValue, reactiveState);
2172
+ return reactiveState;
2198
2173
  }
2199
2174
 
2200
2175
  }
2201
- /** version: 1.1.5 */
2176
+ /** version: 1.0.0 */
2202
2177
 
2203
2178
  /*
2204
2179
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5416,7 +5391,6 @@ function updateStylesheetToken(vm, template) {
5416
5391
 
5417
5392
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5418
5393
  const content = [];
5419
- let root;
5420
5394
 
5421
5395
  for (let i = 0; i < stylesheets.length; i++) {
5422
5396
  let stylesheet = stylesheets[i];
@@ -5429,46 +5403,23 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5429
5403
  // the component instance might be attempting to use an old version of
5430
5404
  // the stylesheet, while internally, we have a replacement for it.
5431
5405
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5432
- }
5433
-
5434
- const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5435
-
5436
- const scopeToken = isScopedCss || vm.shadowMode === 1
5437
- /* Synthetic */
5438
- && vm.renderMode === 1
5439
- /* Shadow */
5440
- ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5406
+ } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5441
5407
  // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5442
5408
 
5409
+
5410
+ const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS];
5443
5411
  const useActualHostSelector = vm.renderMode === 0
5444
5412
  /* Light */
5445
5413
  ? !isScopedCss : vm.shadowMode === 0
5446
5414
  /* Native */
5447
- ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5448
- // we use an attribute selector on the host to simulate :dir().
5449
-
5450
- let useNativeDirPseudoclass;
5415
+ ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5451
5416
 
5452
- if (vm.renderMode === 1
5417
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5418
+ /* Synthetic */
5419
+ && vm.renderMode === 1
5453
5420
  /* Shadow */
5454
- ) {
5455
- useNativeDirPseudoclass = vm.shadowMode === 0
5456
- /* Native */
5457
- ;
5458
- } else {
5459
- // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5460
- // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5461
- if (shared.isUndefined(root)) {
5462
- // Only calculate the root once as necessary
5463
- root = getNearestShadowComponent(vm);
5464
- }
5465
-
5466
- useNativeDirPseudoclass = shared.isNull(root) || root.shadowMode === 0
5467
- /* Native */
5468
- ;
5469
- }
5470
-
5471
- shared.ArrayPush.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5421
+ ? stylesheetToken : undefined;
5422
+ shared.ArrayPush.call(content, stylesheet(useActualHostSelector, scopeToken));
5472
5423
  }
5473
5424
  }
5474
5425
 
@@ -5491,12 +5442,14 @@ function getStylesheetsContent(vm, template) {
5491
5442
  // perf testing has not shown it to be a huge improvement yet:
5492
5443
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5493
5444
 
5494
- function getNearestShadowComponent(vm) {
5445
+ function getNearestNativeShadowComponent(vm) {
5495
5446
  let owner = vm;
5496
5447
 
5497
5448
  while (!shared.isNull(owner)) {
5498
5449
  if (owner.renderMode === 1
5499
5450
  /* Shadow */
5451
+ && owner.shadowMode === 0
5452
+ /* Native */
5500
5453
  ) {
5501
5454
  return owner;
5502
5455
  }
@@ -5507,20 +5460,6 @@ function getNearestShadowComponent(vm) {
5507
5460
  return owner;
5508
5461
  }
5509
5462
 
5510
- function getNearestNativeShadowComponent(vm) {
5511
- const owner = getNearestShadowComponent(vm);
5512
-
5513
- if (!shared.isNull(owner) && owner.shadowMode === 1
5514
- /* Synthetic */
5515
- ) {
5516
- // Synthetic-within-native is impossible. So if the nearest shadow component is
5517
- // synthetic, we know we won't find a native component if we go any further.
5518
- return null;
5519
- }
5520
-
5521
- return owner;
5522
- }
5523
-
5524
5463
  function createStylesheet(vm, stylesheets) {
5525
5464
  const {
5526
5465
  renderer,
@@ -7214,11 +7153,15 @@ function setHooks(hooks) {
7214
7153
 
7215
7154
  Object.defineProperty(exports, 'setFeatureFlag', {
7216
7155
  enumerable: true,
7217
- get: function () { return features.setFeatureFlag; }
7156
+ get: function () {
7157
+ return features.setFeatureFlag;
7158
+ }
7218
7159
  });
7219
7160
  Object.defineProperty(exports, 'setFeatureFlagForTest', {
7220
7161
  enumerable: true,
7221
- get: function () { return features.setFeatureFlagForTest; }
7162
+ get: function () {
7163
+ return features.setFeatureFlagForTest;
7164
+ }
7222
7165
  });
7223
7166
  exports.LightningElement = LightningElement;
7224
7167
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7246,4 +7189,4 @@ exports.swapTemplate = swapTemplate;
7246
7189
  exports.track = track;
7247
7190
  exports.unwrap = unwrap;
7248
7191
  exports.wire = wire;
7249
- /* version: 2.5.9 */
7192
+ /* version: 2.5.10-alpha1 */
@@ -1428,6 +1428,7 @@ const {
1428
1428
  getPrototypeOf,
1429
1429
  create: ObjectCreate,
1430
1430
  defineProperty: ObjectDefineProperty,
1431
+ defineProperties: ObjectDefineProperties,
1431
1432
  isExtensible,
1432
1433
  getOwnPropertyDescriptor,
1433
1434
  getOwnPropertyNames,
@@ -1437,7 +1438,8 @@ const {
1437
1438
  } = Object;
1438
1439
  const {
1439
1440
  push: ArrayPush,
1440
- concat: ArrayConcat
1441
+ concat: ArrayConcat,
1442
+ map: ArrayMap
1441
1443
  } = Array.prototype;
1442
1444
  const OtS = {}.toString;
1443
1445
 
@@ -1502,9 +1504,7 @@ class BaseProxyHandler {
1502
1504
  // but it will always be compatible with the previous descriptor
1503
1505
  // to preserve the object invariants, which makes these lines safe.
1504
1506
 
1505
- const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1506
-
1507
- /* istanbul ignore else */
1507
+ const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
1508
1508
 
1509
1509
  if (!isUndefined(originalDescriptor)) {
1510
1510
  const wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1532,17 +1532,11 @@ class BaseProxyHandler {
1532
1532
 
1533
1533
  preventExtensions(shadowTarget);
1534
1534
  } // Shared Traps
1535
- // TODO: apply() is never called
1536
-
1537
- /* istanbul ignore next */
1538
1535
 
1539
1536
 
1540
1537
  apply(shadowTarget, thisArg, argArray) {
1541
1538
  /* No op */
1542
- } // TODO: construct() is never called
1543
-
1544
- /* istanbul ignore next */
1545
-
1539
+ }
1546
1540
 
1547
1541
  construct(shadowTarget, argArray, newTarget) {
1548
1542
  /* No op */
@@ -1655,8 +1649,8 @@ class BaseProxyHandler {
1655
1649
 
1656
1650
  }
1657
1651
 
1658
- const getterMap$1 = new WeakMap();
1659
- const setterMap$1 = new WeakMap();
1652
+ const getterMap = new WeakMap();
1653
+ const setterMap = new WeakMap();
1660
1654
  const reverseGetterMap = new WeakMap();
1661
1655
  const reverseSetterMap = new WeakMap();
1662
1656
 
@@ -1666,7 +1660,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1666
1660
  }
1667
1661
 
1668
1662
  wrapGetter(originalGet) {
1669
- const wrappedGetter = getterMap$1.get(originalGet);
1663
+ const wrappedGetter = getterMap.get(originalGet);
1670
1664
 
1671
1665
  if (!isUndefined(wrappedGetter)) {
1672
1666
  return wrappedGetter;
@@ -1679,13 +1673,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1679
1673
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1680
1674
  };
1681
1675
 
1682
- getterMap$1.set(originalGet, get);
1676
+ getterMap.set(originalGet, get);
1683
1677
  reverseGetterMap.set(get, originalGet);
1684
1678
  return get;
1685
1679
  }
1686
1680
 
1687
1681
  wrapSetter(originalSet) {
1688
- const wrappedSetter = setterMap$1.get(originalSet);
1682
+ const wrappedSetter = setterMap.get(originalSet);
1689
1683
 
1690
1684
  if (!isUndefined(wrappedSetter)) {
1691
1685
  return wrappedSetter;
@@ -1696,7 +1690,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1696
1690
  originalSet.call(unwrap$1(this), unwrap$1(v));
1697
1691
  };
1698
1692
 
1699
- setterMap$1.set(originalSet, set);
1693
+ setterMap.set(originalSet, set);
1700
1694
  reverseSetterMap.set(set, originalSet);
1701
1695
  return set;
1702
1696
  }
@@ -1737,7 +1731,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1737
1731
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1738
1732
  };
1739
1733
 
1740
- getterMap$1.set(get, redGet);
1734
+ getterMap.set(get, redGet);
1741
1735
  reverseGetterMap.set(redGet, get);
1742
1736
  return get;
1743
1737
  }
@@ -1756,7 +1750,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1756
1750
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1757
1751
  };
1758
1752
 
1759
- setterMap$1.set(set, redSet);
1753
+ setterMap.set(set, redSet);
1760
1754
  reverseSetterMap.set(redSet, set);
1761
1755
  return set;
1762
1756
  }
@@ -1797,7 +1791,6 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1797
1791
  }
1798
1792
 
1799
1793
  setPrototypeOf(shadowTarget, prototype) {
1800
- /* istanbul ignore else */
1801
1794
  if (process.env.NODE_ENV !== 'production') {
1802
1795
  throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
1803
1796
  }
@@ -1811,11 +1804,6 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1811
1804
  preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1812
1805
  // the preventExtension call, in which case we should not attempt to lock down
1813
1806
  // the shadow target.
1814
- // TODO: It should not actually be possible to reach this `if` statement.
1815
- // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1816
- // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1817
-
1818
- /* istanbul ignore if */
1819
1807
 
1820
1808
  if (isExtensible(originalTarget)) {
1821
1809
  return false;
@@ -1857,8 +1845,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
1857
1845
 
1858
1846
  }
1859
1847
 
1860
- const getterMap = new WeakMap();
1861
- const setterMap = new WeakMap();
1848
+ const getterMap$1 = new WeakMap();
1849
+ const setterMap$1 = new WeakMap();
1862
1850
 
1863
1851
  class ReadOnlyHandler extends BaseProxyHandler {
1864
1852
  wrapValue(value) {
@@ -1866,7 +1854,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
1866
1854
  }
1867
1855
 
1868
1856
  wrapGetter(originalGet) {
1869
- const wrappedGetter = getterMap.get(originalGet);
1857
+ const wrappedGetter = getterMap$1.get(originalGet);
1870
1858
 
1871
1859
  if (!isUndefined(wrappedGetter)) {
1872
1860
  return wrappedGetter;
@@ -1879,12 +1867,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
1879
1867
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1880
1868
  };
1881
1869
 
1882
- getterMap.set(originalGet, get);
1870
+ getterMap$1.set(originalGet, get);
1883
1871
  return get;
1884
1872
  }
1885
1873
 
1886
1874
  wrapSetter(originalSet) {
1887
- const wrappedSetter = setterMap.get(originalSet);
1875
+ const wrappedSetter = setterMap$1.get(originalSet);
1888
1876
 
1889
1877
  if (!isUndefined(wrappedSetter)) {
1890
1878
  return wrappedSetter;
@@ -1893,7 +1881,6 @@ class ReadOnlyHandler extends BaseProxyHandler {
1893
1881
  const handler = this;
1894
1882
 
1895
1883
  const set = function (v) {
1896
- /* istanbul ignore else */
1897
1884
  if (process.env.NODE_ENV !== 'production') {
1898
1885
  const {
1899
1886
  originalTarget
@@ -1902,41 +1889,33 @@ class ReadOnlyHandler extends BaseProxyHandler {
1902
1889
  }
1903
1890
  };
1904
1891
 
1905
- setterMap.set(originalSet, set);
1892
+ setterMap$1.set(originalSet, set);
1906
1893
  return set;
1907
1894
  }
1908
1895
 
1909
1896
  set(shadowTarget, key, value) {
1910
- /* istanbul ignore else */
1911
1897
  if (process.env.NODE_ENV !== 'production') {
1912
1898
  const {
1913
1899
  originalTarget
1914
1900
  } = this;
1915
- const msg = isArray(originalTarget) ? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.` : `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
1916
- throw new Error(msg);
1901
+ throw new Error(`Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1917
1902
  }
1918
- /* istanbul ignore next */
1919
-
1920
1903
 
1921
1904
  return false;
1922
1905
  }
1923
1906
 
1924
1907
  deleteProperty(shadowTarget, key) {
1925
- /* istanbul ignore else */
1926
1908
  if (process.env.NODE_ENV !== 'production') {
1927
1909
  const {
1928
1910
  originalTarget
1929
1911
  } = this;
1930
1912
  throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1931
1913
  }
1932
- /* istanbul ignore next */
1933
-
1934
1914
 
1935
1915
  return false;
1936
1916
  }
1937
1917
 
1938
1918
  setPrototypeOf(shadowTarget, prototype) {
1939
- /* istanbul ignore else */
1940
1919
  if (process.env.NODE_ENV !== 'production') {
1941
1920
  const {
1942
1921
  originalTarget
@@ -1946,29 +1925,23 @@ class ReadOnlyHandler extends BaseProxyHandler {
1946
1925
  }
1947
1926
 
1948
1927
  preventExtensions(shadowTarget) {
1949
- /* istanbul ignore else */
1950
1928
  if (process.env.NODE_ENV !== 'production') {
1951
1929
  const {
1952
1930
  originalTarget
1953
1931
  } = this;
1954
1932
  throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
1955
1933
  }
1956
- /* istanbul ignore next */
1957
-
1958
1934
 
1959
1935
  return false;
1960
1936
  }
1961
1937
 
1962
1938
  defineProperty(shadowTarget, key, descriptor) {
1963
- /* istanbul ignore else */
1964
1939
  if (process.env.NODE_ENV !== 'production') {
1965
1940
  const {
1966
1941
  originalTarget
1967
1942
  } = this;
1968
1943
  throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
1969
1944
  }
1970
- /* istanbul ignore next */
1971
-
1972
1945
 
1973
1946
  return false;
1974
1947
  }
@@ -2026,8 +1999,6 @@ const formatter = {
2026
1999
  }; // Inspired from paulmillr/es6-shim
2027
2000
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2028
2001
 
2029
- /* istanbul ignore next */
2030
-
2031
2002
  function getGlobal() {
2032
2003
  // the only reliable means to get the global object is `Function('return this')()`
2033
2004
  // However, this causes CSP violations in Chrome apps.
@@ -2052,7 +2023,6 @@ function getGlobal() {
2052
2023
  }
2053
2024
 
2054
2025
  function init() {
2055
- /* istanbul ignore if */
2056
2026
  if (process.env.NODE_ENV === 'production') {
2057
2027
  // this method should never leak to prod
2058
2028
  throw new ReferenceError();
@@ -2067,8 +2037,6 @@ function init() {
2067
2037
  ArrayPush.call(devtoolsFormatters, formatter);
2068
2038
  global.devtoolsFormatters = devtoolsFormatters;
2069
2039
  }
2070
- /* istanbul ignore else */
2071
-
2072
2040
 
2073
2041
  if (process.env.NODE_ENV !== 'production') {
2074
2042
  init();
@@ -2115,8 +2083,7 @@ class ReactiveMembrane {
2115
2083
  this.valueMutated = defaultValueMutated;
2116
2084
  this.valueObserved = defaultValueObserved;
2117
2085
  this.valueIsObservable = defaultValueIsObservable;
2118
- this.readOnlyObjectGraph = new WeakMap();
2119
- this.reactiveObjectGraph = new WeakMap();
2086
+ this.objectGraph = new WeakMap();
2120
2087
 
2121
2088
  if (!isUndefined(options)) {
2122
2089
  const {
@@ -2139,13 +2106,10 @@ class ReactiveMembrane {
2139
2106
  const distorted = this.valueDistortion(unwrappedValue);
2140
2107
 
2141
2108
  if (this.valueIsObservable(distorted)) {
2142
- if (this.readOnlyObjectGraph.get(distorted) === value) {
2143
- // when trying to extract the writable version of a readonly
2144
- // we return the readonly.
2145
- return value;
2146
- }
2109
+ const o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2110
+ // we return the readonly.
2147
2111
 
2148
- return this.getReactiveHandler(unwrappedValue, distorted);
2112
+ return o.readOnly === value ? value : o.reactive;
2149
2113
  }
2150
2114
 
2151
2115
  return distorted;
@@ -2156,7 +2120,7 @@ class ReactiveMembrane {
2156
2120
  const distorted = this.valueDistortion(value);
2157
2121
 
2158
2122
  if (this.valueIsObservable(distorted)) {
2159
- return this.getReadOnlyHandler(value, distorted);
2123
+ return this.getReactiveState(value, distorted).readOnly;
2160
2124
  }
2161
2125
 
2162
2126
  return distorted;
@@ -2166,36 +2130,47 @@ class ReactiveMembrane {
2166
2130
  return unwrap$1(p);
2167
2131
  }
2168
2132
 
2169
- getReactiveHandler(value, distortedValue) {
2170
- let proxy = this.reactiveObjectGraph.get(distortedValue);
2133
+ getReactiveState(value, distortedValue) {
2134
+ const {
2135
+ objectGraph
2136
+ } = this;
2137
+ let reactiveState = objectGraph.get(distortedValue);
2171
2138
 
2172
- if (isUndefined(proxy)) {
2173
- // caching the proxy after the first time it is accessed
2174
- const handler = new ReactiveProxyHandler(this, distortedValue);
2175
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2176
- registerProxy(proxy, value);
2177
- this.reactiveObjectGraph.set(distortedValue, proxy);
2139
+ if (reactiveState) {
2140
+ return reactiveState;
2178
2141
  }
2179
2142
 
2180
- return proxy;
2181
- }
2143
+ const membrane = this;
2144
+ reactiveState = {
2145
+ get reactive() {
2146
+ const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2182
2147
 
2183
- getReadOnlyHandler(value, distortedValue) {
2184
- let proxy = this.readOnlyObjectGraph.get(distortedValue);
2148
+ const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2149
+ registerProxy(proxy, value);
2150
+ ObjectDefineProperty(this, 'reactive', {
2151
+ value: proxy
2152
+ });
2153
+ return proxy;
2154
+ },
2185
2155
 
2186
- if (isUndefined(proxy)) {
2187
- // caching the proxy after the first time it is accessed
2188
- const handler = new ReadOnlyHandler(this, distortedValue);
2189
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2190
- registerProxy(proxy, value);
2191
- this.readOnlyObjectGraph.set(distortedValue, proxy);
2192
- }
2156
+ get readOnly() {
2157
+ const readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2158
+
2159
+ const proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2160
+ registerProxy(proxy, value);
2161
+ ObjectDefineProperty(this, 'readOnly', {
2162
+ value: proxy
2163
+ });
2164
+ return proxy;
2165
+ }
2193
2166
 
2194
- return proxy;
2167
+ };
2168
+ objectGraph.set(distortedValue, reactiveState);
2169
+ return reactiveState;
2195
2170
  }
2196
2171
 
2197
2172
  }
2198
- /** version: 1.1.5 */
2173
+ /** version: 1.0.0 */
2199
2174
 
2200
2175
  /*
2201
2176
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5413,7 +5388,6 @@ function updateStylesheetToken(vm, template) {
5413
5388
 
5414
5389
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5415
5390
  const content = [];
5416
- let root;
5417
5391
 
5418
5392
  for (let i = 0; i < stylesheets.length; i++) {
5419
5393
  let stylesheet = stylesheets[i];
@@ -5426,46 +5400,23 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5426
5400
  // the component instance might be attempting to use an old version of
5427
5401
  // the stylesheet, while internally, we have a replacement for it.
5428
5402
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5429
- }
5430
-
5431
- const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5432
-
5433
- const scopeToken = isScopedCss || vm.shadowMode === 1
5434
- /* Synthetic */
5435
- && vm.renderMode === 1
5436
- /* Shadow */
5437
- ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5403
+ } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5438
5404
  // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5439
5405
 
5406
+
5407
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS];
5440
5408
  const useActualHostSelector = vm.renderMode === 0
5441
5409
  /* Light */
5442
5410
  ? !isScopedCss : vm.shadowMode === 0
5443
5411
  /* Native */
5444
- ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5445
- // we use an attribute selector on the host to simulate :dir().
5446
-
5447
- let useNativeDirPseudoclass;
5412
+ ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5448
5413
 
5449
- if (vm.renderMode === 1
5414
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5415
+ /* Synthetic */
5416
+ && vm.renderMode === 1
5450
5417
  /* Shadow */
5451
- ) {
5452
- useNativeDirPseudoclass = vm.shadowMode === 0
5453
- /* Native */
5454
- ;
5455
- } else {
5456
- // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5457
- // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5458
- if (isUndefined$1(root)) {
5459
- // Only calculate the root once as necessary
5460
- root = getNearestShadowComponent(vm);
5461
- }
5462
-
5463
- useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5464
- /* Native */
5465
- ;
5466
- }
5467
-
5468
- ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5418
+ ? stylesheetToken : undefined;
5419
+ ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5469
5420
  }
5470
5421
  }
5471
5422
 
@@ -5488,12 +5439,14 @@ function getStylesheetsContent(vm, template) {
5488
5439
  // perf testing has not shown it to be a huge improvement yet:
5489
5440
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5490
5441
 
5491
- function getNearestShadowComponent(vm) {
5442
+ function getNearestNativeShadowComponent(vm) {
5492
5443
  let owner = vm;
5493
5444
 
5494
5445
  while (!isNull(owner)) {
5495
5446
  if (owner.renderMode === 1
5496
5447
  /* Shadow */
5448
+ && owner.shadowMode === 0
5449
+ /* Native */
5497
5450
  ) {
5498
5451
  return owner;
5499
5452
  }
@@ -5504,20 +5457,6 @@ function getNearestShadowComponent(vm) {
5504
5457
  return owner;
5505
5458
  }
5506
5459
 
5507
- function getNearestNativeShadowComponent(vm) {
5508
- const owner = getNearestShadowComponent(vm);
5509
-
5510
- if (!isNull(owner) && owner.shadowMode === 1
5511
- /* Synthetic */
5512
- ) {
5513
- // Synthetic-within-native is impossible. So if the nearest shadow component is
5514
- // synthetic, we know we won't find a native component if we go any further.
5515
- return null;
5516
- }
5517
-
5518
- return owner;
5519
- }
5520
-
5521
5460
  function createStylesheet(vm, stylesheets) {
5522
5461
  const {
5523
5462
  renderer,
@@ -7210,4 +7149,4 @@ function setHooks(hooks) {
7210
7149
  }
7211
7150
 
7212
7151
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentInternalDef, getUpgradableConstructor, hydrateRootElement, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7213
- /* version: 2.5.9 */
7152
+ /* version: 2.5.10-alpha1 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.5.9",
3
+ "version": "2.5.10-alpha1",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.5.9",
28
- "@lwc/shared": "2.5.9"
27
+ "@lwc/features": "2.5.10-alpha1",
28
+ "@lwc/shared": "2.5.10-alpha1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "observable-membrane": "1.1.5"
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "3e50c5c599f5eb7af78bcfd6f634df10e8117145"
36
+ "gitHead": "b96b2d24f545c14a5c8984ab01081290afd5dc39"
37
37
  }
@@ -0,0 +1,10 @@
1
+ import { VM } from './vm';
2
+ export declare type MeasurementPhase = 'constructor' | 'render' | 'patch' | 'connectedCallback' | 'disconnectedCallback' | 'renderedCallback' | 'errorCallback';
3
+ export declare enum GlobalMeasurementPhase {
4
+ REHYDRATE = "lwc-rehydrate",
5
+ HYDRATE = "lwc-hydrate"
6
+ }
7
+ export declare const startMeasure: (phase: MeasurementPhase, vm: VM) => void;
8
+ export declare const endMeasure: (phase: MeasurementPhase, vm: VM) => void;
9
+ export declare const startGlobalMeasure: (phase: GlobalMeasurementPhase, vm?: VM<any, any> | undefined) => void;
10
+ export declare const endGlobalMeasure: (phase: GlobalMeasurementPhase, vm?: VM<any, any> | undefined) => void;
@@ -5,7 +5,7 @@ import { Template } from './template';
5
5
  * Function producing style based on a host and a shadow selector. This function is invoked by
6
6
  * the engine with different values depending on the mode that the component is running on.
7
7
  */
8
- export declare type StylesheetFactory = (stylesheetToken: string | undefined, useActualHostSelector: boolean, useNativeDirPseudoclass: boolean) => string;
8
+ export declare type StylesheetFactory = (useActualHostSelector: boolean, stylesheetToken: string | undefined) => string;
9
9
  /**
10
10
  * The list of stylesheets associated with a template. Each entry is either a StylesheetFactory or a
11
11
  * TemplateStylesheetFactory a given stylesheet depends on other external stylesheets (via the