lwc 2.5.5-canary1 → 2.5.9

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.
Files changed (41) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +672 -214
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +673 -215
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +473 -202
  5. package/dist/engine-dom/iife/es5/engine-dom.js +741 -265
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +522 -243
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +674 -216
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +474 -203
  11. package/dist/engine-dom/umd/es5/engine-dom.js +742 -266
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +523 -244
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +551 -166
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +552 -166
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +10 -40
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +10 -40
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +10 -40
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +10 -40
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +11 -41
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +11 -41
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +11 -41
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +11 -41
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +3 -3
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
  33. package/dist/wire-service/iife/es5/wire-service.js +3 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +4 -4
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
  38. package/dist/wire-service/umd/es5/wire-service.js +4 -4
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
  41. package/package.json +8 -8
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LWC = {}));
5
- }(this, (function (exports) { 'use strict';
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf2(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
8
8
 
@@ -38,23 +38,23 @@
38
38
 
39
39
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
40
40
 
41
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42
42
 
43
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
44
44
 
45
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
46
46
 
47
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
48
+
49
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
48
50
 
49
51
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
52
 
51
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
54
 
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
-
55
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
55
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
56
56
 
57
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
57
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
58
58
 
59
59
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
60
60
 
@@ -123,7 +123,7 @@
123
123
  var _Array$prototype = Array.prototype,
124
124
  ArrayIndexOf = _Array$prototype.indexOf,
125
125
  ArrayJoin = _Array$prototype.join,
126
- ArrayMap$1 = _Array$prototype.map,
126
+ ArrayMap = _Array$prototype.map,
127
127
  ArrayPush$1 = _Array$prototype.push,
128
128
  ArraySlice = _Array$prototype.slice,
129
129
  ArraySplice = _Array$prototype.splice,
@@ -180,7 +180,7 @@
180
180
  // Array.prototype.toString directly will cause an error Iterate through
181
181
  // all the items and handle individually.
182
182
  if (isArray$1(obj)) {
183
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
183
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
184
184
  }
185
185
 
186
186
  return obj.toString();
@@ -344,7 +344,7 @@
344
344
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
345
345
  return attributeName;
346
346
  }
347
- /** version: 2.5.5-canary1 */
347
+ /** version: 2.5.9 */
348
348
 
349
349
  /*
350
350
  * Copyright (c) 2018, salesforce.com, inc.
@@ -516,7 +516,7 @@
516
516
 
517
517
  function setFeatureFlagForTest(name, value) {
518
518
  }
519
- /** version: 2.5.5-canary1 */
519
+ /** version: 2.5.9 */
520
520
 
521
521
  /* proxy-compat-disable */
522
522
 
@@ -558,7 +558,7 @@
558
558
  }
559
559
 
560
560
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
561
- }
561
+ } // Borrowed from Vue template compiler.
562
562
  /*
563
563
  * Copyright (c) 2019, salesforce.com, inc.
564
564
  * All rights reserved.
@@ -713,6 +713,20 @@
713
713
  return "<".concat(StringToLowerCase.call(vm.tagName), ">");
714
714
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
715
715
 
716
+
717
+ function getComponentStack(vm) {
718
+ var stack = [];
719
+ var prefix = '';
720
+
721
+ while (!isNull(vm.owner)) {
722
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
723
+ vm = vm.owner;
724
+ prefix += '\t';
725
+ }
726
+
727
+ return ArrayJoin.call(stack, '\n');
728
+ }
729
+
716
730
  function getErrorComponentStack(vm) {
717
731
  var wcStack = [];
718
732
  var currentVm = vm;
@@ -732,6 +746,32 @@
732
746
  */
733
747
 
734
748
 
749
+ function log(method, message, vm) {
750
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
751
+
752
+ if (!isUndefined$1(vm)) {
753
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
754
+ }
755
+
756
+ try {
757
+ throw new Error(msg);
758
+ } catch (e) {
759
+ /* eslint-disable-next-line no-console */
760
+ console[method](e);
761
+ }
762
+ }
763
+
764
+ function logWarn(message, vm) {
765
+ log('warn', message, vm);
766
+ }
767
+ /*
768
+ * Copyright (c) 2018, salesforce.com, inc.
769
+ * All rights reserved.
770
+ * SPDX-License-Identifier: MIT
771
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
772
+ */
773
+
774
+
735
775
  function handleEvent(event, vnode) {
736
776
  var type = event.type;
737
777
  var on = vnode.data.on;
@@ -1524,7 +1564,10 @@
1524
1564
  // but it will always be compatible with the previous descriptor
1525
1565
  // to preserve the object invariants, which makes these lines safe.
1526
1566
 
1527
- var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key);
1567
+ var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1568
+
1569
+ /* istanbul ignore else */
1570
+
1528
1571
 
1529
1572
  if (!isUndefined(originalDescriptor)) {
1530
1573
  var wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1549,12 +1592,18 @@
1549
1592
 
1550
1593
  _preventExtensions(shadowTarget);
1551
1594
  } // Shared Traps
1595
+ // TODO: apply() is never called
1596
+
1597
+ /* istanbul ignore next */
1552
1598
 
1553
1599
  }, {
1554
1600
  key: "apply",
1555
1601
  value: function apply(shadowTarget, thisArg, argArray) {
1556
1602
  /* No op */
1557
- }
1603
+ } // TODO: construct() is never called
1604
+
1605
+ /* istanbul ignore next */
1606
+
1558
1607
  }, {
1559
1608
  key: "construct",
1560
1609
  value: function construct(shadowTarget, argArray, newTarget) {
@@ -1659,8 +1708,8 @@
1659
1708
  return BaseProxyHandler;
1660
1709
  }();
1661
1710
 
1662
- var getterMap = new WeakMap();
1663
- var setterMap = new WeakMap();
1711
+ var getterMap$1 = new WeakMap();
1712
+ var setterMap$1 = new WeakMap();
1664
1713
  var reverseGetterMap = new WeakMap();
1665
1714
  var reverseSetterMap = new WeakMap();
1666
1715
 
@@ -1683,7 +1732,7 @@
1683
1732
  }, {
1684
1733
  key: "wrapGetter",
1685
1734
  value: function wrapGetter(originalGet) {
1686
- var wrappedGetter = getterMap.get(originalGet);
1735
+ var wrappedGetter = getterMap$1.get(originalGet);
1687
1736
 
1688
1737
  if (!isUndefined(wrappedGetter)) {
1689
1738
  return wrappedGetter;
@@ -1696,14 +1745,14 @@
1696
1745
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1697
1746
  };
1698
1747
 
1699
- getterMap.set(originalGet, get);
1748
+ getterMap$1.set(originalGet, get);
1700
1749
  reverseGetterMap.set(get, originalGet);
1701
1750
  return get;
1702
1751
  }
1703
1752
  }, {
1704
1753
  key: "wrapSetter",
1705
1754
  value: function wrapSetter(originalSet) {
1706
- var wrappedSetter = setterMap.get(originalSet);
1755
+ var wrappedSetter = setterMap$1.get(originalSet);
1707
1756
 
1708
1757
  if (!isUndefined(wrappedSetter)) {
1709
1758
  return wrappedSetter;
@@ -1714,7 +1763,7 @@
1714
1763
  originalSet.call(unwrap$1(this), unwrap$1(v));
1715
1764
  };
1716
1765
 
1717
- setterMap.set(originalSet, set);
1766
+ setterMap$1.set(originalSet, set);
1718
1767
  reverseSetterMap.set(set, originalSet);
1719
1768
  return set;
1720
1769
  }
@@ -1755,7 +1804,7 @@
1755
1804
  return unwrap$1(redGet.call(handler.wrapValue(this)));
1756
1805
  };
1757
1806
 
1758
- getterMap.set(get, redGet);
1807
+ getterMap$1.set(get, redGet);
1759
1808
  reverseGetterMap.set(redGet, get);
1760
1809
  return get;
1761
1810
  }
@@ -1775,7 +1824,7 @@
1775
1824
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
1776
1825
  };
1777
1826
 
1778
- setterMap.set(set, redSet);
1827
+ setterMap$1.set(set, redSet);
1779
1828
  reverseSetterMap.set(redSet, set);
1780
1829
  return set;
1781
1830
  }
@@ -1821,6 +1870,11 @@
1821
1870
  _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
1822
1871
  // the preventExtension call, in which case we should not attempt to lock down
1823
1872
  // the shadow target.
1873
+ // TODO: It should not actually be possible to reach this `if` statement.
1874
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
1875
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
1876
+
1877
+ /* istanbul ignore if */
1824
1878
 
1825
1879
 
1826
1880
  if (_isExtensible(originalTarget)) {
@@ -1863,8 +1917,8 @@
1863
1917
  return ReactiveProxyHandler;
1864
1918
  }(BaseProxyHandler);
1865
1919
 
1866
- var getterMap$1 = new WeakMap();
1867
- var setterMap$1 = new WeakMap();
1920
+ var getterMap = new WeakMap();
1921
+ var setterMap = new WeakMap();
1868
1922
 
1869
1923
  var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
1870
1924
  _inherits(ReadOnlyHandler, _BaseProxyHandler2);
@@ -1885,7 +1939,7 @@
1885
1939
  }, {
1886
1940
  key: "wrapGetter",
1887
1941
  value: function wrapGetter(originalGet) {
1888
- var wrappedGetter = getterMap$1.get(originalGet);
1942
+ var wrappedGetter = getterMap.get(originalGet);
1889
1943
 
1890
1944
  if (!isUndefined(wrappedGetter)) {
1891
1945
  return wrappedGetter;
@@ -1898,13 +1952,13 @@
1898
1952
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
1899
1953
  };
1900
1954
 
1901
- getterMap$1.set(originalGet, get);
1955
+ getterMap.set(originalGet, get);
1902
1956
  return get;
1903
1957
  }
1904
1958
  }, {
1905
1959
  key: "wrapSetter",
1906
1960
  value: function wrapSetter(originalSet) {
1907
- var wrappedSetter = setterMap$1.get(originalSet);
1961
+ var wrappedSetter = setterMap.get(originalSet);
1908
1962
 
1909
1963
  if (!isUndefined(wrappedSetter)) {
1910
1964
  return wrappedSetter;
@@ -1913,18 +1967,22 @@
1913
1967
  var set = function set(v) {
1914
1968
  };
1915
1969
 
1916
- setterMap$1.set(originalSet, set);
1970
+ setterMap.set(originalSet, set);
1917
1971
  return set;
1918
1972
  }
1919
1973
  }, {
1920
1974
  key: "set",
1921
1975
  value: function set(shadowTarget, key, value) {
1976
+ /* istanbul ignore next */
1977
+
1922
1978
 
1923
1979
  return false;
1924
1980
  }
1925
1981
  }, {
1926
1982
  key: "deleteProperty",
1927
1983
  value: function deleteProperty(shadowTarget, key) {
1984
+ /* istanbul ignore next */
1985
+
1928
1986
 
1929
1987
  return false;
1930
1988
  }
@@ -1935,12 +1993,16 @@
1935
1993
  }, {
1936
1994
  key: "preventExtensions",
1937
1995
  value: function preventExtensions(shadowTarget) {
1996
+ /* istanbul ignore next */
1997
+
1938
1998
 
1939
1999
  return false;
1940
2000
  }
1941
2001
  }, {
1942
2002
  key: "defineProperty",
1943
2003
  value: function defineProperty(shadowTarget, key, descriptor) {
2004
+ /* istanbul ignore next */
2005
+
1944
2006
 
1945
2007
  return false;
1946
2008
  }
@@ -1995,7 +2057,8 @@
1995
2057
  this.valueMutated = defaultValueMutated;
1996
2058
  this.valueObserved = defaultValueObserved;
1997
2059
  this.valueIsObservable = defaultValueIsObservable;
1998
- this.objectGraph = new WeakMap();
2060
+ this.readOnlyObjectGraph = new WeakMap();
2061
+ this.reactiveObjectGraph = new WeakMap();
1999
2062
 
2000
2063
  if (!isUndefined(options)) {
2001
2064
  var _valueDistortion = options.valueDistortion,
@@ -2018,10 +2081,13 @@
2018
2081
  var distorted = this.valueDistortion(unwrappedValue);
2019
2082
 
2020
2083
  if (this.valueIsObservable(distorted)) {
2021
- var o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2022
- // we return the readonly.
2084
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2085
+ // when trying to extract the writable version of a readonly
2086
+ // we return the readonly.
2087
+ return value;
2088
+ }
2023
2089
 
2024
- return o.readOnly === value ? value : o.reactive;
2090
+ return this.getReactiveHandler(unwrappedValue, distorted);
2025
2091
  }
2026
2092
 
2027
2093
  return distorted;
@@ -2033,7 +2099,7 @@
2033
2099
  var distorted = this.valueDistortion(value);
2034
2100
 
2035
2101
  if (this.valueIsObservable(distorted)) {
2036
- return this.getReactiveState(value, distorted).readOnly;
2102
+ return this.getReadOnlyHandler(value, distorted);
2037
2103
  }
2038
2104
 
2039
2105
  return distorted;
@@ -2044,48 +2110,40 @@
2044
2110
  return unwrap$1(p);
2045
2111
  }
2046
2112
  }, {
2047
- key: "getReactiveState",
2048
- value: function getReactiveState(value, distortedValue) {
2049
- var objectGraph = this.objectGraph;
2050
- var reactiveState = objectGraph.get(distortedValue);
2051
-
2052
- if (reactiveState) {
2053
- return reactiveState;
2113
+ key: "getReactiveHandler",
2114
+ value: function getReactiveHandler(value, distortedValue) {
2115
+ var proxy = this.reactiveObjectGraph.get(distortedValue);
2116
+
2117
+ if (isUndefined(proxy)) {
2118
+ // caching the proxy after the first time it is accessed
2119
+ var handler = new ReactiveProxyHandler(this, distortedValue);
2120
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2121
+ registerProxy(proxy, value);
2122
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2054
2123
  }
2055
2124
 
2056
- var membrane = this;
2057
- reactiveState = {
2058
- get reactive() {
2059
- var reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2060
-
2061
- var proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2062
- registerProxy(proxy, value);
2063
- ObjectDefineProperty(this, 'reactive', {
2064
- value: proxy
2065
- });
2066
- return proxy;
2067
- },
2068
-
2069
- get readOnly() {
2070
- var readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2071
-
2072
- var proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2073
- registerProxy(proxy, value);
2074
- ObjectDefineProperty(this, 'readOnly', {
2075
- value: proxy
2076
- });
2077
- return proxy;
2078
- }
2125
+ return proxy;
2126
+ }
2127
+ }, {
2128
+ key: "getReadOnlyHandler",
2129
+ value: function getReadOnlyHandler(value, distortedValue) {
2130
+ var proxy = this.readOnlyObjectGraph.get(distortedValue);
2131
+
2132
+ if (isUndefined(proxy)) {
2133
+ // caching the proxy after the first time it is accessed
2134
+ var handler = new ReadOnlyHandler(this, distortedValue);
2135
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2136
+ registerProxy(proxy, value);
2137
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2138
+ }
2079
2139
 
2080
- };
2081
- objectGraph.set(distortedValue, reactiveState);
2082
- return reactiveState;
2140
+ return proxy;
2083
2141
  }
2084
2142
  }]);
2085
2143
 
2086
2144
  return ReactiveMembrane;
2087
2145
  }();
2088
- /** version: 1.0.0 */
2146
+ /** version: 1.1.5 */
2089
2147
 
2090
2148
  /*
2091
2149
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2394,7 +2452,9 @@
2394
2452
  renderer = vm.renderer;
2395
2453
 
2396
2454
  return renderer[rendererMethod](elm);
2397
- }
2455
+ },
2456
+ configurable: true,
2457
+ enumerable: true
2398
2458
  };
2399
2459
  };
2400
2460
 
@@ -2413,7 +2473,10 @@
2413
2473
  renderer = vm.renderer;
2414
2474
 
2415
2475
  return renderer[queryMethod](elm, arg);
2416
- }
2476
+ },
2477
+ configurable: true,
2478
+ enumerable: true,
2479
+ writable: true
2417
2480
  };
2418
2481
  };
2419
2482
 
@@ -3263,7 +3326,7 @@
3263
3326
  renderMode: 1
3264
3327
  /* Shadow */
3265
3328
  ,
3266
- shadowSupportMode: "default"
3329
+ shadowSupportMode: "reset"
3267
3330
  /* Default */
3268
3331
  ,
3269
3332
  wire: EmptyObject,
@@ -3377,6 +3440,17 @@
3377
3440
  modComputedStyle.create(vnode);
3378
3441
  }
3379
3442
 
3443
+ function hydrateElmHook(vnode) {
3444
+ modEvents.create(vnode); // Attrs are already on the element.
3445
+ // modAttrs.create(vnode);
3446
+
3447
+ modProps.create(vnode); // Already set.
3448
+ // modStaticClassName.create(vnode);
3449
+ // modStaticStyle.create(vnode);
3450
+ // modComputedClassName.create(vnode);
3451
+ // modComputedStyle.create(vnode);
3452
+ }
3453
+
3380
3454
  function fallbackElmHook(elm, vnode) {
3381
3455
  var owner = vnode.owner;
3382
3456
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3508,6 +3582,22 @@
3508
3582
  }
3509
3583
  }
3510
3584
 
3585
+ function hydrateChildrenHook(elmChildren, children, vm) {
3586
+
3587
+ var elmCurrentChildIdx = 0;
3588
+
3589
+ for (var j = 0, n = children.length; j < n; j++) {
3590
+ var ch = children[j];
3591
+
3592
+ if (ch != null) {
3593
+ var childNode = elmChildren[elmCurrentChildIdx];
3594
+
3595
+ ch.hook.hydrate(ch, childNode);
3596
+ elmCurrentChildIdx++;
3597
+ }
3598
+ }
3599
+ }
3600
+
3511
3601
  function updateCustomElmHook(oldVnode, vnode) {
3512
3602
  // Attrs need to be applied to element before props
3513
3603
  // IE11 will wipe out value on radio inputs if value
@@ -3601,38 +3691,6 @@
3601
3691
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3602
3692
  */
3603
3693
 
3604
- /**
3605
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3606
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3607
- * lwc:inner-html directive.
3608
- * It is meant to be overridden with setSanitizeHtmlContentHook
3609
- */
3610
-
3611
-
3612
- var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
3613
- // locker-service patches this function during runtime to sanitize HTML content.
3614
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3615
- };
3616
- /**
3617
- * Sets the sanitizeHtmlContentHook.
3618
- *
3619
- * @param newHookImpl
3620
- * @returns oldHookImplementation.
3621
- */
3622
-
3623
-
3624
- function setSanitizeHtmlContentHook(newHookImpl) {
3625
- var currentHook = sanitizeHtmlContentHook;
3626
- sanitizeHtmlContentHook = newHookImpl;
3627
- return currentHook;
3628
- }
3629
- /*
3630
- * Copyright (c) 2018, salesforce.com, inc.
3631
- * All rights reserved.
3632
- * SPDX-License-Identifier: MIT
3633
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3634
- */
3635
-
3636
3694
 
3637
3695
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3638
3696
  var SymbolIterator = Symbol.iterator;
@@ -3647,7 +3705,14 @@
3647
3705
  update: updateNodeHook,
3648
3706
  insert: insertNodeHook,
3649
3707
  move: insertNodeHook,
3650
- remove: removeNodeHook
3708
+ remove: removeNodeHook,
3709
+ hydrate: function hydrate(vNode, node) {
3710
+ var _a;
3711
+
3712
+
3713
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3714
+ vNode.elm = node;
3715
+ }
3651
3716
  };
3652
3717
  var CommentHook = {
3653
3718
  create: function create(vnode) {
@@ -3661,7 +3726,14 @@
3661
3726
  update: updateNodeHook,
3662
3727
  insert: insertNodeHook,
3663
3728
  move: insertNodeHook,
3664
- remove: removeNodeHook
3729
+ remove: removeNodeHook,
3730
+ hydrate: function hydrate(vNode, node) {
3731
+ var _a;
3732
+
3733
+
3734
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3735
+ vNode.elm = node;
3736
+ }
3665
3737
  }; // insert is called after update, which is used somewhere else (via a module)
3666
3738
  // to mark the vm as inserted, that means we cannot use update as the main channel
3667
3739
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3695,6 +3767,34 @@
3695
3767
  remove: function remove(vnode, parentNode) {
3696
3768
  removeNodeHook(vnode, parentNode);
3697
3769
  removeElmHook(vnode);
3770
+ },
3771
+ hydrate: function hydrate(vnode, node) {
3772
+ var elm = node;
3773
+ vnode.elm = elm;
3774
+ var context = vnode.data.context;
3775
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3776
+ /* manual */
3777
+ );
3778
+
3779
+ if (isDomManual) {
3780
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3781
+ // remove the innerHTML from props so it reuses the existing dom elements.
3782
+ var props = vnode.data.props;
3783
+
3784
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3785
+ if (elm.innerHTML === props.innerHTML) {
3786
+ delete props.innerHTML;
3787
+ } else {
3788
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3789
+ }
3790
+ }
3791
+ }
3792
+
3793
+ hydrateElmHook(vnode);
3794
+
3795
+ if (!isDomManual) {
3796
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3797
+ }
3698
3798
  }
3699
3799
  };
3700
3800
  var CustomElementHook = {
@@ -3774,6 +3874,36 @@
3774
3874
  // will take care of disconnecting any child VM attached to its shadow as well.
3775
3875
  removeVM(vm);
3776
3876
  }
3877
+ },
3878
+ hydrate: function hydrate(vnode, elm) {
3879
+ // the element is created, but the vm is not
3880
+ var sel = vnode.sel,
3881
+ mode = vnode.mode,
3882
+ ctor = vnode.ctor,
3883
+ owner = vnode.owner;
3884
+ var def = getComponentInternalDef(ctor);
3885
+ createVM(elm, def, {
3886
+ mode: mode,
3887
+ owner: owner,
3888
+ tagName: sel,
3889
+ renderer: owner.renderer
3890
+ });
3891
+ vnode.elm = elm;
3892
+ var vm = getAssociatedVM(elm);
3893
+ allocateChildrenHook(vnode, vm);
3894
+ hydrateElmHook(vnode); // Insert hook section:
3895
+
3896
+ runConnectedCallback(vm);
3897
+
3898
+ if (vm.renderMode !== 0
3899
+ /* Light */
3900
+ ) {
3901
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3902
+ // Note: for Light DOM, this is handled while hydrating the VM
3903
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3904
+ }
3905
+
3906
+ hydrateVM(vm);
3777
3907
  }
3778
3908
  };
3779
3909
 
@@ -3901,7 +4031,7 @@
3901
4031
  next = iterator.next();
3902
4032
  last = next.done; // template factory logic based on the previous collected value
3903
4033
 
3904
- var vnode = factory(value, j, j === 0, last);
4034
+ var vnode = factory(value, j, j === 0, last === true);
3905
4035
 
3906
4036
  if (isArray$1(vnode)) {
3907
4037
  ArrayPush$1.apply(list, vnode);
@@ -3975,7 +4105,7 @@
3975
4105
 
3976
4106
 
3977
4107
  function d(value) {
3978
- return value == null ? '' : value;
4108
+ return value == null ? '' : String(value);
3979
4109
  } // [b]ind function
3980
4110
 
3981
4111
 
@@ -4114,6 +4244,26 @@
4114
4244
 
4115
4245
  markAsDynamicChildren(vnodes);
4116
4246
  return vnodes;
4247
+ }
4248
+ /**
4249
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4250
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4251
+ * lwc:inner-html directive.
4252
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4253
+ */
4254
+
4255
+
4256
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
4257
+ // locker-service patches this function during runtime to sanitize HTML content.
4258
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4259
+ };
4260
+ /**
4261
+ * Sets the sanitizeHtmlContentHook.
4262
+ */
4263
+
4264
+
4265
+ function setSanitizeHtmlContentHook(newHookImpl) {
4266
+ sanitizeHtmlContentHook = newHookImpl;
4117
4267
  } // [s]anitize [h]tml [c]ontent
4118
4268
 
4119
4269
 
@@ -4121,23 +4271,21 @@
4121
4271
  return sanitizeHtmlContentHook(content);
4122
4272
  }
4123
4273
 
4124
- var api = /*#__PURE__*/Object.freeze({
4125
- __proto__: null,
4126
- h: h,
4127
- ti: ti,
4274
+ var api = freeze({
4128
4275
  s: s,
4276
+ h: h,
4129
4277
  c: c,
4130
4278
  i: i,
4131
4279
  f: f,
4132
4280
  t: t,
4133
- co: co,
4134
4281
  d: d,
4135
4282
  b: b,
4136
4283
  k: k,
4284
+ co: co,
4285
+ dc: dc,
4286
+ ti: ti,
4137
4287
  gid: gid,
4138
4288
  fid: fid,
4139
- dc: dc,
4140
- sc: sc,
4141
4289
  shc: shc
4142
4290
  });
4143
4291
  /*
@@ -4152,12 +4300,12 @@
4152
4300
  }
4153
4301
 
4154
4302
  function createInlineStyleVNode(content) {
4155
- return h('style', {
4303
+ return api.h('style', {
4156
4304
  key: 'style',
4157
4305
  attrs: {
4158
4306
  type: 'text/css'
4159
4307
  }
4160
- }, [t(content)]);
4308
+ }, [api.t(content)]);
4161
4309
  }
4162
4310
 
4163
4311
  function updateStylesheetToken(vm, template) {
@@ -4217,29 +4365,53 @@
4217
4365
 
4218
4366
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4219
4367
  var content = [];
4368
+ var root;
4220
4369
 
4221
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4222
- var stylesheet = stylesheets[_i14];
4370
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4371
+ var stylesheet = stylesheets[_i16];
4223
4372
 
4224
4373
  if (isArray$1(stylesheet)) {
4225
4374
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
4226
4375
  } else {
4227
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
4228
4376
 
4377
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
4378
+
4379
+ var scopeToken = isScopedCss || vm.shadowMode === 1
4380
+ /* Synthetic */
4381
+ && vm.renderMode === 1
4382
+ /* Shadow */
4383
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
4384
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
4229
4385
 
4230
- var isScopedCss = stylesheet[KEY__SCOPED_CSS];
4231
4386
  var useActualHostSelector = vm.renderMode === 0
4232
4387
  /* Light */
4233
4388
  ? !isScopedCss : vm.shadowMode === 0
4234
4389
  /* Native */
4235
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
4390
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
4391
+ // we use an attribute selector on the host to simulate :dir().
4236
4392
 
4237
- var scopeToken = isScopedCss || vm.shadowMode === 1
4238
- /* Synthetic */
4239
- && vm.renderMode === 1
4393
+ var useNativeDirPseudoclass = void 0;
4394
+
4395
+ if (vm.renderMode === 1
4240
4396
  /* Shadow */
4241
- ? stylesheetToken : undefined;
4242
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
4397
+ ) {
4398
+ useNativeDirPseudoclass = vm.shadowMode === 0
4399
+ /* Native */
4400
+ ;
4401
+ } else {
4402
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
4403
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
4404
+ if (isUndefined$1(root)) {
4405
+ // Only calculate the root once as necessary
4406
+ root = getNearestShadowComponent(vm);
4407
+ }
4408
+
4409
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
4410
+ /* Native */
4411
+ ;
4412
+ }
4413
+
4414
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
4243
4415
  }
4244
4416
  }
4245
4417
 
@@ -4261,14 +4433,12 @@
4261
4433
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
4262
4434
 
4263
4435
 
4264
- function getNearestNativeShadowComponent(vm) {
4436
+ function getNearestShadowComponent(vm) {
4265
4437
  var owner = vm;
4266
4438
 
4267
4439
  while (!isNull(owner)) {
4268
4440
  if (owner.renderMode === 1
4269
4441
  /* Shadow */
4270
- && owner.shadowMode === 0
4271
- /* Native */
4272
4442
  ) {
4273
4443
  return owner;
4274
4444
  }
@@ -4279,6 +4449,20 @@
4279
4449
  return owner;
4280
4450
  }
4281
4451
 
4452
+ function getNearestNativeShadowComponent(vm) {
4453
+ var owner = getNearestShadowComponent(vm);
4454
+
4455
+ if (!isNull(owner) && owner.shadowMode === 1
4456
+ /* Synthetic */
4457
+ ) {
4458
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
4459
+ // synthetic, we know we won't find a native component if we go any further.
4460
+ return null;
4461
+ }
4462
+
4463
+ return owner;
4464
+ }
4465
+
4282
4466
  function createStylesheet(vm, stylesheets) {
4283
4467
  var renderer = vm.renderer,
4284
4468
  renderMode = vm.renderMode,
@@ -4289,10 +4473,13 @@
4289
4473
  && shadowMode === 1
4290
4474
  /* Synthetic */
4291
4475
  ) {
4292
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4293
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4476
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4477
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4294
4478
  }
4295
- } else if (renderer.ssr) {
4479
+ } else if (renderer.ssr || renderer.isHydrating()) {
4480
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4481
+ // This works in the client, because the stylesheets are created, and cached in the VM
4482
+ // the first time the VM renders.
4296
4483
  // native shadow or light DOM, SSR
4297
4484
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4298
4485
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4301,12 +4488,12 @@
4301
4488
  var root = getNearestNativeShadowComponent(vm);
4302
4489
  var isGlobal = isNull(root);
4303
4490
 
4304
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4491
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4305
4492
  if (isGlobal) {
4306
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4493
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4307
4494
  } else {
4308
4495
  // local level
4309
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4496
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4310
4497
  }
4311
4498
  }
4312
4499
  }
@@ -4491,8 +4678,8 @@
4491
4678
  var stylesheets = template.stylesheets;
4492
4679
 
4493
4680
  if (!isUndefined$1(stylesheets)) {
4494
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4495
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4681
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4682
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4496
4683
  return true;
4497
4684
  }
4498
4685
  }
@@ -4693,8 +4880,8 @@
4693
4880
 
4694
4881
  function register(service) {
4695
4882
 
4696
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4697
- var hookName = hooks[_i18];
4883
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4884
+ var hookName = hooks[_i20];
4698
4885
 
4699
4886
  if (hookName in service) {
4700
4887
  var l = Services[hookName];
@@ -4714,8 +4901,8 @@
4714
4901
  def = vm.def,
4715
4902
  context = vm.context;
4716
4903
 
4717
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4718
- cbs[_i19].call(undefined, component, {}, def, context);
4904
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
4905
+ cbs[_i21].call(undefined, component, {}, def, context);
4719
4906
  }
4720
4907
  }
4721
4908
  /*
@@ -4768,6 +4955,12 @@
4768
4955
  , vm);
4769
4956
  }
4770
4957
 
4958
+ function hydrateRootElement(elm) {
4959
+ var vm = getAssociatedVM(elm);
4960
+ runConnectedCallback(vm);
4961
+ hydrateVM(vm);
4962
+ }
4963
+
4771
4964
  function disconnectRootElement(elm) {
4772
4965
  var vm = getAssociatedVM(elm);
4773
4966
  resetComponentStateWhenRemoved(vm);
@@ -4775,6 +4968,10 @@
4775
4968
 
4776
4969
  function appendVM(vm) {
4777
4970
  rehydrate(vm);
4971
+ }
4972
+
4973
+ function hydrateVM(vm) {
4974
+ hydrate(vm);
4778
4975
  } // just in case the component comes back, with this we guarantee re-rendering it
4779
4976
  // while preventing any attempt to rehydration until after reinsertion.
4780
4977
 
@@ -4959,6 +5156,22 @@
4959
5156
  }
4960
5157
  }
4961
5158
 
5159
+ function hydrate(vm) {
5160
+ if (isTrue(vm.isDirty)) {
5161
+ // manually diffing/patching here.
5162
+ // This routine is:
5163
+ // patchShadowRoot(vm, children);
5164
+ // -> addVnodes.
5165
+ var children = renderComponent(vm);
5166
+ vm.children = children;
5167
+ var vmChildren = vm.renderMode === 0
5168
+ /* Light */
5169
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5170
+ hydrateChildrenHook(vmChildren, children);
5171
+ runRenderedCallback(vm);
5172
+ }
5173
+ }
5174
+
4962
5175
  function patchShadowRoot(vm, newCh) {
4963
5176
  var oldCh = vm.children; // caching the new children collection
4964
5177
 
@@ -5035,19 +5248,19 @@
5035
5248
  });
5036
5249
  rehydrateQueue = []; // reset to a new queue
5037
5250
 
5038
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5039
- var vm = vms[_i20];
5251
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5252
+ var vm = vms[_i22];
5040
5253
 
5041
5254
  try {
5042
5255
  rehydrate(vm);
5043
5256
  } catch (error) {
5044
- if (_i20 + 1 < _len7) {
5257
+ if (_i22 + 1 < _len7) {
5045
5258
  // pieces of the queue are still pending to be rehydrated, those should have priority
5046
5259
  if (rehydrateQueue.length === 0) {
5047
5260
  addCallbackToNextTick(flushRehydrationQueue);
5048
5261
  }
5049
5262
 
5050
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5263
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5051
5264
  } // we need to end the measure before throwing.
5052
5265
 
5053
5266
 
@@ -5146,8 +5359,8 @@
5146
5359
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5147
5360
  // inserted in reserved order.
5148
5361
 
5149
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5150
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
5362
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5363
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5151
5364
  // * when there is an error during the construction phase, and an error
5152
5365
  // boundary picks it, there is a possibility that the VCustomElement
5153
5366
  // is not properly initialized, and therefore is should be ignored.
@@ -5181,8 +5394,8 @@
5181
5394
 
5182
5395
 
5183
5396
  function recursivelyDisconnectChildren(vnodes) {
5184
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5185
- var vnode = vnodes[_i22];
5397
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5398
+ var vnode = vnodes[_i24];
5186
5399
 
5187
5400
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5188
5401
  // vnode is a VElement with children
@@ -5206,8 +5419,8 @@
5206
5419
  renderer = vm.renderer;
5207
5420
  var rootNode = getRenderRoot(vm);
5208
5421
 
5209
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5210
- var child = children[_i23];
5422
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5423
+ var child = children[_i25];
5211
5424
 
5212
5425
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5213
5426
  renderer.remove(child.elm, rootNode);
@@ -5252,8 +5465,8 @@
5252
5465
  var oldSlots = vm.cmpSlots;
5253
5466
  var cmpSlots = vm.cmpSlots = create(null);
5254
5467
 
5255
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5256
- var vnode = children[_i24];
5468
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5469
+ var vnode = children[_i26];
5257
5470
 
5258
5471
  if (isNull(vnode)) {
5259
5472
  continue;
@@ -5283,8 +5496,8 @@
5283
5496
  return;
5284
5497
  }
5285
5498
 
5286
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5287
- var key = oldKeys[_i25];
5499
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5500
+ var key = oldKeys[_i27];
5288
5501
 
5289
5502
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5290
5503
  markComponentAsDirty(vm);
@@ -5623,8 +5836,8 @@
5623
5836
  function connectWireAdapters(vm) {
5624
5837
  var wiredConnecting = vm.context.wiredConnecting;
5625
5838
 
5626
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5627
- wiredConnecting[_i26]();
5839
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5840
+ wiredConnecting[_i28]();
5628
5841
  }
5629
5842
  }
5630
5843
 
@@ -5632,8 +5845,8 @@
5632
5845
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5633
5846
  runWithBoundaryProtection(vm, vm, noop, function () {
5634
5847
  // job
5635
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5636
- wiredDisconnecting[_i27]();
5848
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5849
+ wiredDisconnecting[_i29]();
5637
5850
  }
5638
5851
  }, noop);
5639
5852
  }
@@ -5712,25 +5925,12 @@
5712
5925
 
5713
5926
  var hooksAreSet = false;
5714
5927
 
5715
- function overrideHooks(hooks) {
5716
- var oldHooks = {};
5717
-
5718
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5719
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5720
- }
5721
-
5722
- return oldHooks;
5723
- }
5724
-
5725
5928
  function setHooks(hooks) {
5726
5929
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5727
- overrideHooks(hooks);
5728
5930
  hooksAreSet = true;
5931
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5729
5932
  }
5730
-
5731
- function setHooksForTest(hooks) {
5732
- }
5733
- /* version: 2.5.5-canary1 */
5933
+ /* version: 2.5.9 */
5734
5934
 
5735
5935
  /*
5736
5936
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5875,8 +6075,17 @@
5875
6075
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5876
6076
  }
5877
6077
 
6078
+ var _isHydrating = false;
6079
+
6080
+ function setIsHydrating(v) {
6081
+ _isHydrating = v;
6082
+ }
6083
+
5878
6084
  var renderer = {
5879
6085
  ssr: false,
6086
+ isHydrating: function isHydrating() {
6087
+ return _isHydrating;
6088
+ },
5880
6089
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5881
6090
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5882
6091
  createElement: function createElement(tagName, namespace) {
@@ -5898,6 +6107,10 @@
5898
6107
  return node.nextSibling;
5899
6108
  },
5900
6109
  attachShadow: function attachShadow(element, options) {
6110
+ if (_isHydrating) {
6111
+ return element.shadowRoot;
6112
+ }
6113
+
5901
6114
  return element.attachShadow(options);
5902
6115
  },
5903
6116
  setText: function setText(node, content) {
@@ -6002,71 +6215,6 @@
6002
6215
  getCustomElement: getCustomElement,
6003
6216
  HTMLElement: HTMLElementConstructor
6004
6217
  };
6005
- /*
6006
- * Copyright (c) 2018, salesforce.com, inc.
6007
- * All rights reserved.
6008
- * SPDX-License-Identifier: MIT
6009
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6010
- */
6011
-
6012
- /**
6013
- * This function builds a Web Component class from a LWC constructor so it can be
6014
- * registered as a new element via customElements.define() at any given time.
6015
- *
6016
- * @deprecated since version 1.3.11
6017
- *
6018
- * @example
6019
- * ```
6020
- * import { buildCustomElementConstructor } from 'lwc';
6021
- * import Foo from 'ns/foo';
6022
- * const WC = buildCustomElementConstructor(Foo);
6023
- * customElements.define('x-foo', WC);
6024
- * const elm = document.createElement('x-foo');
6025
- * ```
6026
- */
6027
-
6028
- function deprecatedBuildCustomElementConstructor(Ctor) {
6029
-
6030
- return Ctor.CustomElementConstructor;
6031
- }
6032
-
6033
- function buildCustomElementConstructor(Ctor) {
6034
- var def = getComponentInternalDef(Ctor);
6035
- return /*#__PURE__*/function (_def$bridge) {
6036
- _inherits(_class, _def$bridge);
6037
-
6038
- var _super8 = _createSuper(_class);
6039
-
6040
- function _class() {
6041
- var _this6;
6042
-
6043
- _classCallCheck(this, _class);
6044
-
6045
- _this6 = _super8.call(this);
6046
- createVM(_assertThisInitialized(_this6), def, {
6047
- mode: 'open',
6048
- owner: null,
6049
- tagName: _this6.tagName,
6050
- renderer: renderer
6051
- });
6052
- return _this6;
6053
- }
6054
-
6055
- _createClass(_class, [{
6056
- key: "connectedCallback",
6057
- value: function connectedCallback() {
6058
- connectRootElement(this);
6059
- }
6060
- }, {
6061
- key: "disconnectedCallback",
6062
- value: function disconnectedCallback() {
6063
- disconnectRootElement(this);
6064
- }
6065
- }]);
6066
-
6067
- return _class;
6068
- }(def.bridge);
6069
- }
6070
6218
  /*
6071
6219
  * Copyright (c) 2018, salesforce.com, inc.
6072
6220
  * All rights reserved.
@@ -6076,7 +6224,6 @@
6076
6224
  // TODO [#2472]: Remove this workaround when appropriate.
6077
6225
  // eslint-disable-next-line lwc-internal/no-global-node
6078
6226
 
6079
-
6080
6227
  var _Node$1 = Node;
6081
6228
  var ConnectingSlot = new WeakMap();
6082
6229
  var DisconnectingSlot = new WeakMap();
@@ -6183,6 +6330,138 @@
6183
6330
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6184
6331
  */
6185
6332
 
6333
+
6334
+ function hydrateComponent(element, Ctor) {
6335
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6336
+
6337
+ if (!isFunction$1(Ctor)) {
6338
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6339
+ }
6340
+
6341
+ if (!isObject(props) || isNull(props)) {
6342
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6343
+ }
6344
+
6345
+ var def = getComponentInternalDef(Ctor);
6346
+
6347
+ try {
6348
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6349
+ // and uses the same algo to create the stylesheets as in SSR.
6350
+ setIsHydrating(true);
6351
+ createVM(element, def, {
6352
+ mode: 'open',
6353
+ owner: null,
6354
+ renderer: renderer,
6355
+ tagName: element.tagName.toLowerCase()
6356
+ });
6357
+
6358
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6359
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6360
+ key = _Object$entries2$_i[0],
6361
+ value = _Object$entries2$_i[1];
6362
+
6363
+ element[key] = value;
6364
+ }
6365
+
6366
+ hydrateRootElement(element); // set it back since now we finished hydration.
6367
+
6368
+ setIsHydrating(false);
6369
+ } catch (e) {
6370
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6371
+ // the client generated DOM.
6372
+
6373
+ /* eslint-disable-next-line no-console */
6374
+ console.error('Recovering from error while hydrating: ', e);
6375
+ setIsHydrating(false);
6376
+ var newElem = createElement(element.tagName, {
6377
+ is: Ctor,
6378
+ mode: 'open'
6379
+ });
6380
+
6381
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6382
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6383
+ _key3 = _Object$entries3$_i[0],
6384
+ _value2 = _Object$entries3$_i[1];
6385
+
6386
+ newElem[_key3] = _value2;
6387
+ }
6388
+
6389
+ element.parentNode.replaceChild(newElem, element);
6390
+ }
6391
+ }
6392
+ /*
6393
+ * Copyright (c) 2018, salesforce.com, inc.
6394
+ * All rights reserved.
6395
+ * SPDX-License-Identifier: MIT
6396
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6397
+ */
6398
+
6399
+ /**
6400
+ * This function builds a Web Component class from a LWC constructor so it can be
6401
+ * registered as a new element via customElements.define() at any given time.
6402
+ *
6403
+ * @deprecated since version 1.3.11
6404
+ *
6405
+ * @example
6406
+ * ```
6407
+ * import { buildCustomElementConstructor } from 'lwc';
6408
+ * import Foo from 'ns/foo';
6409
+ * const WC = buildCustomElementConstructor(Foo);
6410
+ * customElements.define('x-foo', WC);
6411
+ * const elm = document.createElement('x-foo');
6412
+ * ```
6413
+ */
6414
+
6415
+
6416
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6417
+
6418
+ return Ctor.CustomElementConstructor;
6419
+ }
6420
+
6421
+ function buildCustomElementConstructor(Ctor) {
6422
+ var def = getComponentInternalDef(Ctor);
6423
+ return /*#__PURE__*/function (_def$bridge) {
6424
+ _inherits(_class, _def$bridge);
6425
+
6426
+ var _super8 = _createSuper(_class);
6427
+
6428
+ function _class() {
6429
+ var _this6;
6430
+
6431
+ _classCallCheck(this, _class);
6432
+
6433
+ _this6 = _super8.call(this);
6434
+ createVM(_assertThisInitialized(_this6), def, {
6435
+ mode: 'open',
6436
+ owner: null,
6437
+ tagName: _this6.tagName,
6438
+ renderer: renderer
6439
+ });
6440
+ return _this6;
6441
+ }
6442
+
6443
+ _createClass(_class, [{
6444
+ key: "connectedCallback",
6445
+ value: function connectedCallback() {
6446
+ connectRootElement(this);
6447
+ }
6448
+ }, {
6449
+ key: "disconnectedCallback",
6450
+ value: function disconnectedCallback() {
6451
+ disconnectRootElement(this);
6452
+ }
6453
+ }]);
6454
+
6455
+ return _class;
6456
+ }(def.bridge);
6457
+ }
6458
+ /*
6459
+ * Copyright (c) 2018, salesforce.com, inc.
6460
+ * All rights reserved.
6461
+ * SPDX-License-Identifier: MIT
6462
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6463
+ */
6464
+
6186
6465
  /**
6187
6466
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6188
6467
  * This API is subject to change or being removed.
@@ -6281,7 +6560,7 @@
6281
6560
  });
6282
6561
  freeze(LightningElement);
6283
6562
  seal(LightningElement.prototype);
6284
- /* version: 2.5.5-canary1 */
6563
+ /* version: 2.5.9 */
6285
6564
 
6286
6565
  exports.LightningElement = LightningElement;
6287
6566
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6291,6 +6570,7 @@
6291
6570
  exports.createElement = createElement;
6292
6571
  exports.getComponentConstructor = getComponentConstructor;
6293
6572
  exports.getComponentDef = getComponentDef;
6573
+ exports.hydrateComponent = hydrateComponent;
6294
6574
  exports.isComponentConstructor = isComponentConstructor;
6295
6575
  exports.isNodeFromTemplate = isNodeFromTemplate;
6296
6576
  exports.readonly = readonly;
@@ -6302,7 +6582,6 @@
6302
6582
  exports.setFeatureFlag = setFeatureFlag;
6303
6583
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6304
6584
  exports.setHooks = setHooks;
6305
- exports.setHooksForTest = setHooksForTest;
6306
6585
  exports.swapComponent = swapComponent;
6307
6586
  exports.swapStyle = swapStyle;
6308
6587
  exports.swapTemplate = swapTemplate;
@@ -6312,4 +6591,4 @@
6312
6591
 
6313
6592
  Object.defineProperty(exports, '__esModule', { value: true });
6314
6593
 
6315
- })));
6594
+ }));