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
 
@@ -10,8 +10,6 @@
10
10
 
11
11
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
12
12
 
13
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
14
-
15
13
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
16
14
 
17
15
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -40,23 +38,25 @@
40
38
 
41
39
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
42
40
 
43
- 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"); } }
44
42
 
45
- 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); } }
46
44
 
47
- 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; }
48
46
 
49
- 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."); }
50
50
 
51
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; }
52
52
 
53
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
54
54
 
55
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
56
56
 
57
- 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); } }
57
+ 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); }
58
58
 
59
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
59
+ 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; }
60
60
 
61
61
  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); }
62
62
 
@@ -123,9 +123,10 @@
123
123
  setPrototypeOf = Object.setPrototypeOf;
124
124
  var isArray$1 = Array.isArray;
125
125
  var _Array$prototype = Array.prototype,
126
+ ArrayFilter = _Array$prototype.filter,
126
127
  ArrayIndexOf = _Array$prototype.indexOf,
127
128
  ArrayJoin = _Array$prototype.join,
128
- ArrayMap$1 = _Array$prototype.map,
129
+ ArrayMap = _Array$prototype.map,
129
130
  ArrayPush$1 = _Array$prototype.push,
130
131
  ArraySlice = _Array$prototype.slice,
131
132
  ArraySplice = _Array$prototype.splice,
@@ -186,7 +187,7 @@
186
187
  // Array.prototype.toString directly will cause an error Iterate through
187
188
  // all the items and handle individually.
188
189
  if (isArray$1(obj)) {
189
- return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
190
+ return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
190
191
  }
191
192
 
192
193
  return obj.toString();
@@ -350,7 +351,7 @@
350
351
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
351
352
  return attributeName;
352
353
  }
353
- /** version: 2.5.5-canary1 */
354
+ /** version: 2.5.9 */
354
355
 
355
356
  /*
356
357
  * Copyright (c) 2018, salesforce.com, inc.
@@ -530,7 +531,7 @@
530
531
  setFeatureFlag(name, value);
531
532
  }
532
533
  }
533
- /** version: 2.5.5-canary1 */
534
+ /** version: 2.5.9 */
534
535
 
535
536
  /* proxy-compat-disable */
536
537
 
@@ -582,6 +583,42 @@
582
583
  }
583
584
 
584
585
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
586
+ } // Borrowed from Vue template compiler.
587
+ // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
588
+
589
+
590
+ var DECLARATION_DELIMITER = /;(?![^(]*\))/g;
591
+ var PROPERTY_DELIMITER = /:(.+)/;
592
+
593
+ function parseStyleText(cssText) {
594
+ var styleMap = {};
595
+ var declarations = cssText.split(DECLARATION_DELIMITER);
596
+
597
+ var _iterator = _createForOfIteratorHelper(declarations),
598
+ _step;
599
+
600
+ try {
601
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
602
+ var declaration = _step.value;
603
+
604
+ if (declaration) {
605
+ var _declaration$split = declaration.split(PROPERTY_DELIMITER),
606
+ _declaration$split2 = _slicedToArray(_declaration$split, 2),
607
+ prop = _declaration$split2[0],
608
+ value = _declaration$split2[1];
609
+
610
+ if (prop !== undefined && value !== undefined) {
611
+ styleMap[prop.trim()] = value.trim();
612
+ }
613
+ }
614
+ }
615
+ } catch (err) {
616
+ _iterator.e(err);
617
+ } finally {
618
+ _iterator.f();
619
+ }
620
+
621
+ return styleMap;
585
622
  }
586
623
  /*
587
624
  * Copyright (c) 2019, salesforce.com, inc.
@@ -770,8 +807,8 @@
770
807
  */
771
808
 
772
809
 
773
- function logError(message, vm) {
774
- var msg = "[LWC error]: ".concat(message);
810
+ function log(method, message, vm) {
811
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
775
812
 
776
813
  if (!isUndefined$1(vm)) {
777
814
  msg = "".concat(msg, "\n").concat(getComponentStack(vm));
@@ -779,7 +816,7 @@
779
816
 
780
817
  if (process.env.NODE_ENV === 'test') {
781
818
  /* eslint-disable-next-line no-console */
782
- console.error(msg);
819
+ console[method](msg);
783
820
  return;
784
821
  }
785
822
 
@@ -787,9 +824,17 @@
787
824
  throw new Error(msg);
788
825
  } catch (e) {
789
826
  /* eslint-disable-next-line no-console */
790
- console.error(e);
827
+ console[method](e);
791
828
  }
792
829
  }
830
+
831
+ function logError(message, vm) {
832
+ log('error', message, vm);
833
+ }
834
+
835
+ function logWarn(message, vm) {
836
+ log('warn', message, vm);
837
+ }
793
838
  /*
794
839
  * Copyright (c) 2018, salesforce.com, inc.
795
840
  * All rights reserved.
@@ -1948,7 +1993,10 @@
1948
1993
  // but it will always be compatible with the previous descriptor
1949
1994
  // to preserve the object invariants, which makes these lines safe.
1950
1995
 
1951
- var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key);
1996
+ var originalDescriptor = _getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
1997
+
1998
+ /* istanbul ignore else */
1999
+
1952
2000
 
1953
2001
  if (!isUndefined(originalDescriptor)) {
1954
2002
  var wrappedDesc = this.wrapDescriptor(originalDescriptor);
@@ -1973,12 +2021,18 @@
1973
2021
 
1974
2022
  _preventExtensions(shadowTarget);
1975
2023
  } // Shared Traps
2024
+ // TODO: apply() is never called
2025
+
2026
+ /* istanbul ignore next */
1976
2027
 
1977
2028
  }, {
1978
2029
  key: "apply",
1979
2030
  value: function apply(shadowTarget, thisArg, argArray) {
1980
2031
  /* No op */
1981
- }
2032
+ } // TODO: construct() is never called
2033
+
2034
+ /* istanbul ignore next */
2035
+
1982
2036
  }, {
1983
2037
  key: "construct",
1984
2038
  value: function construct(shadowTarget, argArray, newTarget) {
@@ -2083,8 +2137,8 @@
2083
2137
  return BaseProxyHandler;
2084
2138
  }();
2085
2139
 
2086
- var getterMap = new WeakMap();
2087
- var setterMap = new WeakMap();
2140
+ var getterMap$1 = new WeakMap();
2141
+ var setterMap$1 = new WeakMap();
2088
2142
  var reverseGetterMap = new WeakMap();
2089
2143
  var reverseSetterMap = new WeakMap();
2090
2144
 
@@ -2107,7 +2161,7 @@
2107
2161
  }, {
2108
2162
  key: "wrapGetter",
2109
2163
  value: function wrapGetter(originalGet) {
2110
- var wrappedGetter = getterMap.get(originalGet);
2164
+ var wrappedGetter = getterMap$1.get(originalGet);
2111
2165
 
2112
2166
  if (!isUndefined(wrappedGetter)) {
2113
2167
  return wrappedGetter;
@@ -2120,14 +2174,14 @@
2120
2174
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2121
2175
  };
2122
2176
 
2123
- getterMap.set(originalGet, get);
2177
+ getterMap$1.set(originalGet, get);
2124
2178
  reverseGetterMap.set(get, originalGet);
2125
2179
  return get;
2126
2180
  }
2127
2181
  }, {
2128
2182
  key: "wrapSetter",
2129
2183
  value: function wrapSetter(originalSet) {
2130
- var wrappedSetter = setterMap.get(originalSet);
2184
+ var wrappedSetter = setterMap$1.get(originalSet);
2131
2185
 
2132
2186
  if (!isUndefined(wrappedSetter)) {
2133
2187
  return wrappedSetter;
@@ -2138,7 +2192,7 @@
2138
2192
  originalSet.call(unwrap$1(this), unwrap$1(v));
2139
2193
  };
2140
2194
 
2141
- setterMap.set(originalSet, set);
2195
+ setterMap$1.set(originalSet, set);
2142
2196
  reverseSetterMap.set(set, originalSet);
2143
2197
  return set;
2144
2198
  }
@@ -2179,7 +2233,7 @@
2179
2233
  return unwrap$1(redGet.call(handler.wrapValue(this)));
2180
2234
  };
2181
2235
 
2182
- getterMap.set(get, redGet);
2236
+ getterMap$1.set(get, redGet);
2183
2237
  reverseGetterMap.set(redGet, get);
2184
2238
  return get;
2185
2239
  }
@@ -2199,7 +2253,7 @@
2199
2253
  redSet.call(handler.wrapValue(this), handler.wrapValue(v));
2200
2254
  };
2201
2255
 
2202
- setterMap.set(set, redSet);
2256
+ setterMap$1.set(set, redSet);
2203
2257
  reverseSetterMap.set(redSet, set);
2204
2258
  return set;
2205
2259
  }
@@ -2235,6 +2289,7 @@
2235
2289
  }, {
2236
2290
  key: "setPrototypeOf",
2237
2291
  value: function setPrototypeOf(shadowTarget, prototype) {
2292
+ /* istanbul ignore else */
2238
2293
  if (process.env.NODE_ENV !== 'production') {
2239
2294
  throw new Error("Invalid setPrototypeOf invocation for reactive proxy ".concat(toString(this.originalTarget), ". Prototype of reactive objects cannot be changed."));
2240
2295
  }
@@ -2248,6 +2303,11 @@
2248
2303
  _preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
2249
2304
  // the preventExtension call, in which case we should not attempt to lock down
2250
2305
  // the shadow target.
2306
+ // TODO: It should not actually be possible to reach this `if` statement.
2307
+ // If a proxy rejects extensions, then calling preventExtensions will throw an error:
2308
+ // https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
2309
+
2310
+ /* istanbul ignore if */
2251
2311
 
2252
2312
 
2253
2313
  if (_isExtensible(originalTarget)) {
@@ -2290,8 +2350,8 @@
2290
2350
  return ReactiveProxyHandler;
2291
2351
  }(BaseProxyHandler);
2292
2352
 
2293
- var getterMap$1 = new WeakMap();
2294
- var setterMap$1 = new WeakMap();
2353
+ var getterMap = new WeakMap();
2354
+ var setterMap = new WeakMap();
2295
2355
 
2296
2356
  var ReadOnlyHandler = /*#__PURE__*/function (_BaseProxyHandler2) {
2297
2357
  _inherits(ReadOnlyHandler, _BaseProxyHandler2);
@@ -2312,7 +2372,7 @@
2312
2372
  }, {
2313
2373
  key: "wrapGetter",
2314
2374
  value: function wrapGetter(originalGet) {
2315
- var wrappedGetter = getterMap$1.get(originalGet);
2375
+ var wrappedGetter = getterMap.get(originalGet);
2316
2376
 
2317
2377
  if (!isUndefined(wrappedGetter)) {
2318
2378
  return wrappedGetter;
@@ -2325,13 +2385,13 @@
2325
2385
  return handler.wrapValue(originalGet.call(unwrap$1(this)));
2326
2386
  };
2327
2387
 
2328
- getterMap$1.set(originalGet, get);
2388
+ getterMap.set(originalGet, get);
2329
2389
  return get;
2330
2390
  }
2331
2391
  }, {
2332
2392
  key: "wrapSetter",
2333
2393
  value: function wrapSetter(originalSet) {
2334
- var wrappedSetter = setterMap$1.get(originalSet);
2394
+ var wrappedSetter = setterMap.get(originalSet);
2335
2395
 
2336
2396
  if (!isUndefined(wrappedSetter)) {
2337
2397
  return wrappedSetter;
@@ -2340,38 +2400,47 @@
2340
2400
  var handler = this;
2341
2401
 
2342
2402
  var set = function set(v) {
2403
+ /* istanbul ignore else */
2343
2404
  if (process.env.NODE_ENV !== 'production') {
2344
2405
  var originalTarget = handler.originalTarget;
2345
2406
  throw new Error("Invalid mutation: Cannot invoke a setter on \"".concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2346
2407
  }
2347
2408
  };
2348
2409
 
2349
- setterMap$1.set(originalSet, set);
2410
+ setterMap.set(originalSet, set);
2350
2411
  return set;
2351
2412
  }
2352
2413
  }, {
2353
2414
  key: "set",
2354
2415
  value: function set(shadowTarget, key, value) {
2416
+ /* istanbul ignore else */
2355
2417
  if (process.env.NODE_ENV !== 'production') {
2356
2418
  var originalTarget = this.originalTarget;
2357
- throw new Error("Invalid mutation: Cannot set \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2419
+ var msg = isArray(originalTarget) ? "Invalid mutation: Cannot mutate array at index ".concat(key.toString(), ". Array is read-only.") : "Invalid mutation: Cannot set \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only.");
2420
+ throw new Error(msg);
2358
2421
  }
2422
+ /* istanbul ignore next */
2423
+
2359
2424
 
2360
2425
  return false;
2361
2426
  }
2362
2427
  }, {
2363
2428
  key: "deleteProperty",
2364
2429
  value: function deleteProperty(shadowTarget, key) {
2430
+ /* istanbul ignore else */
2365
2431
  if (process.env.NODE_ENV !== 'production') {
2366
2432
  var originalTarget = this.originalTarget;
2367
2433
  throw new Error("Invalid mutation: Cannot delete \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2368
2434
  }
2435
+ /* istanbul ignore next */
2436
+
2369
2437
 
2370
2438
  return false;
2371
2439
  }
2372
2440
  }, {
2373
2441
  key: "setPrototypeOf",
2374
2442
  value: function setPrototypeOf(shadowTarget, prototype) {
2443
+ /* istanbul ignore else */
2375
2444
  if (process.env.NODE_ENV !== 'production') {
2376
2445
  var originalTarget = this.originalTarget;
2377
2446
  throw new Error("Invalid prototype mutation: Cannot set prototype on \"".concat(originalTarget, "\". \"").concat(originalTarget, "\" prototype is read-only."));
@@ -2380,20 +2449,26 @@
2380
2449
  }, {
2381
2450
  key: "preventExtensions",
2382
2451
  value: function preventExtensions(shadowTarget) {
2452
+ /* istanbul ignore else */
2383
2453
  if (process.env.NODE_ENV !== 'production') {
2384
2454
  var originalTarget = this.originalTarget;
2385
2455
  throw new Error("Invalid mutation: Cannot preventExtensions on ".concat(originalTarget, "\". \"").concat(originalTarget, " is read-only."));
2386
2456
  }
2457
+ /* istanbul ignore next */
2458
+
2387
2459
 
2388
2460
  return false;
2389
2461
  }
2390
2462
  }, {
2391
2463
  key: "defineProperty",
2392
2464
  value: function defineProperty(shadowTarget, key, descriptor) {
2465
+ /* istanbul ignore else */
2393
2466
  if (process.env.NODE_ENV !== 'production') {
2394
2467
  var originalTarget = this.originalTarget;
2395
2468
  throw new Error("Invalid mutation: Cannot defineProperty \"".concat(key.toString(), "\" on \"").concat(originalTarget, "\". \"").concat(originalTarget, "\" is read-only."));
2396
2469
  }
2470
+ /* istanbul ignore next */
2471
+
2397
2472
 
2398
2473
  return false;
2399
2474
  }
@@ -2453,6 +2528,8 @@
2453
2528
  }; // Inspired from paulmillr/es6-shim
2454
2529
  // https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
2455
2530
 
2531
+ /* istanbul ignore next */
2532
+
2456
2533
  function getGlobal() {
2457
2534
  // the only reliable means to get the global object is `Function('return this')()`
2458
2535
  // However, this causes CSP violations in Chrome apps.
@@ -2477,6 +2554,7 @@
2477
2554
  }
2478
2555
 
2479
2556
  function init() {
2557
+ /* istanbul ignore if */
2480
2558
  if (process.env.NODE_ENV === 'production') {
2481
2559
  // this method should never leak to prod
2482
2560
  throw new ReferenceError();
@@ -2491,6 +2569,8 @@
2491
2569
  ArrayPush.call(devtoolsFormatters, formatter);
2492
2570
  global.devtoolsFormatters = devtoolsFormatters;
2493
2571
  }
2572
+ /* istanbul ignore else */
2573
+
2494
2574
 
2495
2575
  if (process.env.NODE_ENV !== 'production') {
2496
2576
  init();
@@ -2542,7 +2622,8 @@
2542
2622
  this.valueMutated = defaultValueMutated;
2543
2623
  this.valueObserved = defaultValueObserved;
2544
2624
  this.valueIsObservable = defaultValueIsObservable;
2545
- this.objectGraph = new WeakMap();
2625
+ this.readOnlyObjectGraph = new WeakMap();
2626
+ this.reactiveObjectGraph = new WeakMap();
2546
2627
 
2547
2628
  if (!isUndefined(options)) {
2548
2629
  var _valueDistortion = options.valueDistortion,
@@ -2565,10 +2646,13 @@
2565
2646
  var distorted = this.valueDistortion(unwrappedValue);
2566
2647
 
2567
2648
  if (this.valueIsObservable(distorted)) {
2568
- var o = this.getReactiveState(unwrappedValue, distorted); // when trying to extract the writable version of a readonly
2569
- // we return the readonly.
2649
+ if (this.readOnlyObjectGraph.get(distorted) === value) {
2650
+ // when trying to extract the writable version of a readonly
2651
+ // we return the readonly.
2652
+ return value;
2653
+ }
2570
2654
 
2571
- return o.readOnly === value ? value : o.reactive;
2655
+ return this.getReactiveHandler(unwrappedValue, distorted);
2572
2656
  }
2573
2657
 
2574
2658
  return distorted;
@@ -2580,7 +2664,7 @@
2580
2664
  var distorted = this.valueDistortion(value);
2581
2665
 
2582
2666
  if (this.valueIsObservable(distorted)) {
2583
- return this.getReactiveState(value, distorted).readOnly;
2667
+ return this.getReadOnlyHandler(value, distorted);
2584
2668
  }
2585
2669
 
2586
2670
  return distorted;
@@ -2591,48 +2675,40 @@
2591
2675
  return unwrap$1(p);
2592
2676
  }
2593
2677
  }, {
2594
- key: "getReactiveState",
2595
- value: function getReactiveState(value, distortedValue) {
2596
- var objectGraph = this.objectGraph;
2597
- var reactiveState = objectGraph.get(distortedValue);
2598
-
2599
- if (reactiveState) {
2600
- return reactiveState;
2678
+ key: "getReactiveHandler",
2679
+ value: function getReactiveHandler(value, distortedValue) {
2680
+ var proxy = this.reactiveObjectGraph.get(distortedValue);
2681
+
2682
+ if (isUndefined(proxy)) {
2683
+ // caching the proxy after the first time it is accessed
2684
+ var handler = new ReactiveProxyHandler(this, distortedValue);
2685
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2686
+ registerProxy(proxy, value);
2687
+ this.reactiveObjectGraph.set(distortedValue, proxy);
2601
2688
  }
2602
2689
 
2603
- var membrane = this;
2604
- reactiveState = {
2605
- get reactive() {
2606
- var reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
2607
-
2608
- var proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
2609
- registerProxy(proxy, value);
2610
- ObjectDefineProperty(this, 'reactive', {
2611
- value: proxy
2612
- });
2613
- return proxy;
2614
- },
2615
-
2616
- get readOnly() {
2617
- var readOnlyHandler = new ReadOnlyHandler(membrane, distortedValue); // caching the readOnly proxy after the first time it is accessed
2618
-
2619
- var proxy = new Proxy(createShadowTarget(distortedValue), readOnlyHandler);
2620
- registerProxy(proxy, value);
2621
- ObjectDefineProperty(this, 'readOnly', {
2622
- value: proxy
2623
- });
2624
- return proxy;
2625
- }
2690
+ return proxy;
2691
+ }
2692
+ }, {
2693
+ key: "getReadOnlyHandler",
2694
+ value: function getReadOnlyHandler(value, distortedValue) {
2695
+ var proxy = this.readOnlyObjectGraph.get(distortedValue);
2696
+
2697
+ if (isUndefined(proxy)) {
2698
+ // caching the proxy after the first time it is accessed
2699
+ var handler = new ReadOnlyHandler(this, distortedValue);
2700
+ proxy = new Proxy(createShadowTarget(distortedValue), handler);
2701
+ registerProxy(proxy, value);
2702
+ this.readOnlyObjectGraph.set(distortedValue, proxy);
2703
+ }
2626
2704
 
2627
- };
2628
- objectGraph.set(distortedValue, reactiveState);
2629
- return reactiveState;
2705
+ return proxy;
2630
2706
  }
2631
2707
  }]);
2632
2708
 
2633
2709
  return ReactiveMembrane;
2634
2710
  }();
2635
- /** version: 1.0.0 */
2711
+ /** version: 1.1.5 */
2636
2712
 
2637
2713
  /*
2638
2714
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3018,7 +3094,9 @@
3018
3094
  }
3019
3095
 
3020
3096
  return renderer[rendererMethod](elm);
3021
- }
3097
+ },
3098
+ configurable: true,
3099
+ enumerable: true
3022
3100
  };
3023
3101
  };
3024
3102
 
@@ -3041,7 +3119,10 @@
3041
3119
  }
3042
3120
 
3043
3121
  return renderer[queryMethod](elm, arg);
3044
- }
3122
+ },
3123
+ configurable: true,
3124
+ enumerable: true,
3125
+ writable: true
3045
3126
  };
3046
3127
  };
3047
3128
 
@@ -3934,12 +4015,12 @@
3934
4015
  function flattenStylesheets(stylesheets) {
3935
4016
  var list = [];
3936
4017
 
3937
- var _iterator = _createForOfIteratorHelper(stylesheets),
3938
- _step;
4018
+ var _iterator2 = _createForOfIteratorHelper(stylesheets),
4019
+ _step2;
3939
4020
 
3940
4021
  try {
3941
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3942
- var stylesheet = _step.value;
4022
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4023
+ var stylesheet = _step2.value;
3943
4024
 
3944
4025
  if (!Array.isArray(stylesheet)) {
3945
4026
  list.push(stylesheet);
@@ -3948,9 +4029,9 @@
3948
4029
  }
3949
4030
  }
3950
4031
  } catch (err) {
3951
- _iterator.e(err);
4032
+ _iterator2.e(err);
3952
4033
  } finally {
3953
- _iterator.f();
4034
+ _iterator2.f();
3954
4035
  }
3955
4036
 
3956
4037
  return list;
@@ -4214,7 +4295,7 @@
4214
4295
  if (!isUndefined$1(ctorShadowSupportMode)) {
4215
4296
  assert.invariant(ctorShadowSupportMode === "any"
4216
4297
  /* Any */
4217
- || ctorShadowSupportMode === "default"
4298
+ || ctorShadowSupportMode === "reset"
4218
4299
  /* Default */
4219
4300
  , "Invalid value for static property shadowSupportMode: '".concat(ctorShadowSupportMode, "'"));
4220
4301
  }
@@ -4372,7 +4453,7 @@
4372
4453
  renderMode: 1
4373
4454
  /* Shadow */
4374
4455
  ,
4375
- shadowSupportMode: "default"
4456
+ shadowSupportMode: "reset"
4376
4457
  /* Default */
4377
4458
  ,
4378
4459
  wire: EmptyObject,
@@ -4509,6 +4590,17 @@
4509
4590
  modComputedStyle.create(vnode);
4510
4591
  }
4511
4592
 
4593
+ function hydrateElmHook(vnode) {
4594
+ modEvents.create(vnode); // Attrs are already on the element.
4595
+ // modAttrs.create(vnode);
4596
+
4597
+ modProps.create(vnode); // Already set.
4598
+ // modStaticClassName.create(vnode);
4599
+ // modStaticStyle.create(vnode);
4600
+ // modComputedClassName.create(vnode);
4601
+ // modComputedStyle.create(vnode);
4602
+ }
4603
+
4512
4604
  function fallbackElmHook(elm, vnode) {
4513
4605
  var owner = vnode.owner;
4514
4606
  setScopeTokenClassIfNecessary(elm, owner);
@@ -4658,6 +4750,174 @@
4658
4750
  }
4659
4751
  }
4660
4752
 
4753
+ function isElementNode(node) {
4754
+ // eslint-disable-next-line lwc-internal/no-global-node
4755
+ return node.nodeType === Node.ELEMENT_NODE;
4756
+ }
4757
+
4758
+ function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
4759
+ var _vnode$data$attrs = vnode.data.attrs,
4760
+ attrs = _vnode$data$attrs === void 0 ? {} : _vnode$data$attrs,
4761
+ renderer = vnode.owner.renderer;
4762
+ var nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
4763
+ // Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
4764
+
4765
+ for (var _i14 = 0, _Object$entries = Object.entries(attrs); _i14 < _Object$entries.length; _i14++) {
4766
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i14], 2),
4767
+ attrName = _Object$entries$_i[0],
4768
+ attrValue = _Object$entries$_i[1];
4769
+
4770
+ var elmAttrValue = renderer.getAttribute(elm, attrName);
4771
+
4772
+ if (String(attrValue) !== elmAttrValue) {
4773
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"").concat(attrName, "\" has different values, expected \"").concat(attrValue, "\" but found \"").concat(elmAttrValue, "\""), vnode.owner);
4774
+ nodesAreCompatible = false;
4775
+ }
4776
+ }
4777
+
4778
+ return nodesAreCompatible;
4779
+ }
4780
+
4781
+ function vnodesAndElementHaveCompatibleClass(vnode, elm) {
4782
+ var _vnode$data = vnode.data,
4783
+ className = _vnode$data.className,
4784
+ classMap = _vnode$data.classMap,
4785
+ renderer = vnode.owner.renderer;
4786
+ var nodesAreCompatible = true;
4787
+ var vnodeClassName;
4788
+
4789
+ if (!isUndefined$1(className) && String(className) !== elm.className) {
4790
+ // className is used when class is bound to an expr.
4791
+ nodesAreCompatible = false;
4792
+ vnodeClassName = className;
4793
+ } else if (!isUndefined$1(classMap)) {
4794
+ // classMap is used when class is set to static value.
4795
+ var classList = renderer.getClassList(elm);
4796
+ var computedClassName = ''; // all classes from the vnode should be in the element.classList
4797
+
4798
+ for (var name in classMap) {
4799
+ computedClassName += ' ' + name;
4800
+
4801
+ if (!classList.contains(name)) {
4802
+ nodesAreCompatible = false;
4803
+ }
4804
+ }
4805
+
4806
+ vnodeClassName = computedClassName.trim();
4807
+
4808
+ if (classList.length > keys(classMap).length) {
4809
+ nodesAreCompatible = false;
4810
+ }
4811
+ }
4812
+
4813
+ if (!nodesAreCompatible) {
4814
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"class\" has different values, expected \"").concat(vnodeClassName, "\" but found \"").concat(elm.className, "\""), vnode.owner);
4815
+ }
4816
+
4817
+ return nodesAreCompatible;
4818
+ }
4819
+
4820
+ function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
4821
+ var _vnode$data2 = vnode.data,
4822
+ style = _vnode$data2.style,
4823
+ styleDecls = _vnode$data2.styleDecls,
4824
+ renderer = vnode.owner.renderer;
4825
+ var elmStyle = renderer.getAttribute(elm, 'style') || '';
4826
+ var vnodeStyle;
4827
+ var nodesAreCompatible = true;
4828
+
4829
+ if (!isUndefined$1(style) && style !== elmStyle) {
4830
+ nodesAreCompatible = false;
4831
+ vnodeStyle = style;
4832
+ } else if (!isUndefined$1(styleDecls)) {
4833
+ var parsedVnodeStyle = parseStyleText(elmStyle);
4834
+ var expectedStyle = []; // styleMap is used when style is set to static value.
4835
+
4836
+ for (var _i15 = 0, n = styleDecls.length; _i15 < n; _i15++) {
4837
+ var _styleDecls$_i2 = _slicedToArray(styleDecls[_i15], 3),
4838
+ prop = _styleDecls$_i2[0],
4839
+ value = _styleDecls$_i2[1],
4840
+ important = _styleDecls$_i2[2];
4841
+
4842
+ expectedStyle.push("".concat(prop, ": ").concat(value + (important ? ' important!' : '')));
4843
+ var parsedPropValue = parsedVnodeStyle[prop];
4844
+
4845
+ if (isUndefined$1(parsedPropValue)) {
4846
+ nodesAreCompatible = false;
4847
+ } else if (!parsedPropValue.startsWith(value)) {
4848
+ nodesAreCompatible = false;
4849
+ } else if (important && !parsedPropValue.endsWith('!important')) {
4850
+ nodesAreCompatible = false;
4851
+ }
4852
+ }
4853
+
4854
+ if (keys(parsedVnodeStyle).length > styleDecls.length) {
4855
+ nodesAreCompatible = false;
4856
+ }
4857
+
4858
+ vnodeStyle = ArrayJoin.call(expectedStyle, ';');
4859
+ }
4860
+
4861
+ if (!nodesAreCompatible) {
4862
+ // style is used when class is bound to an expr.
4863
+ logError("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: attribute \"style\" has different values, expected \"").concat(vnodeStyle, "\" but found \"").concat(elmStyle, "\"."), vnode.owner);
4864
+ }
4865
+
4866
+ return nodesAreCompatible;
4867
+ }
4868
+
4869
+ function throwHydrationError() {
4870
+ assert.fail('Server rendered elements do not match client side generated elements');
4871
+ }
4872
+
4873
+ function hydrateChildrenHook(elmChildren, children, vm) {
4874
+ var _a, _b;
4875
+
4876
+ if (process.env.NODE_ENV !== 'production') {
4877
+ var filteredVNodes = ArrayFilter.call(children, function (vnode) {
4878
+ return !!vnode;
4879
+ });
4880
+
4881
+ if (elmChildren.length !== filteredVNodes.length) {
4882
+ logError("Hydration mismatch: incorrect number of rendered nodes, expected ".concat(filteredVNodes.length, " but found ").concat(elmChildren.length, "."), vm);
4883
+ throwHydrationError();
4884
+ }
4885
+ }
4886
+
4887
+ var elmCurrentChildIdx = 0;
4888
+
4889
+ for (var j = 0, n = children.length; j < n; j++) {
4890
+ var ch = children[j];
4891
+
4892
+ if (ch != null) {
4893
+ var childNode = elmChildren[elmCurrentChildIdx];
4894
+
4895
+ if (process.env.NODE_ENV !== 'production') {
4896
+ // VComments and VTexts validation is handled in their hooks
4897
+ if (isElementNode(childNode)) {
4898
+ if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
4899
+ logError("Hydration mismatch: expecting element with tag \"".concat((_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase(), "\" but found \"").concat(childNode.tagName.toLowerCase(), "\"."), vm);
4900
+ throwHydrationError();
4901
+ } // Note: props are not yet set
4902
+
4903
+
4904
+ var hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
4905
+ var hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
4906
+ var hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
4907
+ var isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
4908
+
4909
+ if (!isVNodeAndElementCompatible) {
4910
+ throwHydrationError();
4911
+ }
4912
+ }
4913
+ }
4914
+
4915
+ ch.hook.hydrate(ch, childNode);
4916
+ elmCurrentChildIdx++;
4917
+ }
4918
+ }
4919
+ }
4920
+
4661
4921
  function updateCustomElmHook(oldVnode, vnode) {
4662
4922
  // Attrs need to be applied to element before props
4663
4923
  // IE11 will wipe out value on radio inputs if value
@@ -4751,38 +5011,6 @@
4751
5011
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4752
5012
  */
4753
5013
 
4754
- /**
4755
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4756
- * libraries to sanitize HTML content. This hook process the content passed via the template to
4757
- * lwc:inner-html directive.
4758
- * It is meant to be overridden with setSanitizeHtmlContentHook
4759
- */
4760
-
4761
-
4762
- var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
4763
- // locker-service patches this function during runtime to sanitize HTML content.
4764
- throw new Error('sanitizeHtmlContent hook must be implemented.');
4765
- };
4766
- /**
4767
- * Sets the sanitizeHtmlContentHook.
4768
- *
4769
- * @param newHookImpl
4770
- * @returns oldHookImplementation.
4771
- */
4772
-
4773
-
4774
- function setSanitizeHtmlContentHook(newHookImpl) {
4775
- var currentHook = sanitizeHtmlContentHook;
4776
- sanitizeHtmlContentHook = newHookImpl;
4777
- return currentHook;
4778
- }
4779
- /*
4780
- * Copyright (c) 2018, salesforce.com, inc.
4781
- * All rights reserved.
4782
- * SPDX-License-Identifier: MIT
4783
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4784
- */
4785
-
4786
5014
 
4787
5015
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4788
5016
  var SymbolIterator = Symbol.iterator;
@@ -4797,7 +5025,26 @@
4797
5025
  update: updateNodeHook,
4798
5026
  insert: insertNodeHook,
4799
5027
  move: insertNodeHook,
4800
- remove: removeNodeHook
5028
+ remove: removeNodeHook,
5029
+ hydrate: function hydrate(vNode, node) {
5030
+ var _a;
5031
+
5032
+ if (process.env.NODE_ENV !== 'production') {
5033
+ // eslint-disable-next-line lwc-internal/no-global-node
5034
+ if (node.nodeType !== Node.TEXT_NODE) {
5035
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5036
+ assert.fail('Hydration mismatch: incorrect node type received.');
5037
+ }
5038
+
5039
+ if (node.nodeValue !== vNode.text) {
5040
+ logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
5041
+ }
5042
+ } // always set the text value to the one from the vnode.
5043
+
5044
+
5045
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5046
+ vNode.elm = node;
5047
+ }
4801
5048
  };
4802
5049
  var CommentHook = {
4803
5050
  create: function create(vnode) {
@@ -4811,7 +5058,26 @@
4811
5058
  update: updateNodeHook,
4812
5059
  insert: insertNodeHook,
4813
5060
  move: insertNodeHook,
4814
- remove: removeNodeHook
5061
+ remove: removeNodeHook,
5062
+ hydrate: function hydrate(vNode, node) {
5063
+ var _a;
5064
+
5065
+ if (process.env.NODE_ENV !== 'production') {
5066
+ // eslint-disable-next-line lwc-internal/no-global-node
5067
+ if (node.nodeType !== Node.COMMENT_NODE) {
5068
+ logError('Hydration mismatch: incorrect node type received', vNode.owner);
5069
+ assert.fail('Hydration mismatch: incorrect node type received.');
5070
+ }
5071
+
5072
+ if (node.nodeValue !== vNode.text) {
5073
+ logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
5074
+ }
5075
+ } // always set the text value to the one from the vnode.
5076
+
5077
+
5078
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
5079
+ vNode.elm = node;
5080
+ }
4815
5081
  }; // insert is called after update, which is used somewhere else (via a module)
4816
5082
  // to mark the vm as inserted, that means we cannot use update as the main channel
4817
5083
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -4845,6 +5111,34 @@
4845
5111
  remove: function remove(vnode, parentNode) {
4846
5112
  removeNodeHook(vnode, parentNode);
4847
5113
  removeElmHook(vnode);
5114
+ },
5115
+ hydrate: function hydrate(vnode, node) {
5116
+ var elm = node;
5117
+ vnode.elm = elm;
5118
+ var context = vnode.data.context;
5119
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
5120
+ /* manual */
5121
+ );
5122
+
5123
+ if (isDomManual) {
5124
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
5125
+ // remove the innerHTML from props so it reuses the existing dom elements.
5126
+ var props = vnode.data.props;
5127
+
5128
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
5129
+ if (elm.innerHTML === props.innerHTML) {
5130
+ delete props.innerHTML;
5131
+ } else {
5132
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
5133
+ }
5134
+ }
5135
+ }
5136
+
5137
+ hydrateElmHook(vnode);
5138
+
5139
+ if (!isDomManual) {
5140
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
5141
+ }
4848
5142
  }
4849
5143
  };
4850
5144
  var CustomElementHook = {
@@ -4932,6 +5226,42 @@
4932
5226
  // will take care of disconnecting any child VM attached to its shadow as well.
4933
5227
  removeVM(vm);
4934
5228
  }
5229
+ },
5230
+ hydrate: function hydrate(vnode, elm) {
5231
+ // the element is created, but the vm is not
5232
+ var sel = vnode.sel,
5233
+ mode = vnode.mode,
5234
+ ctor = vnode.ctor,
5235
+ owner = vnode.owner;
5236
+ var def = getComponentInternalDef(ctor);
5237
+ createVM(elm, def, {
5238
+ mode: mode,
5239
+ owner: owner,
5240
+ tagName: sel,
5241
+ renderer: owner.renderer
5242
+ });
5243
+ vnode.elm = elm;
5244
+ var vm = getAssociatedVM(elm);
5245
+ allocateChildrenHook(vnode, vm);
5246
+ hydrateElmHook(vnode); // Insert hook section:
5247
+
5248
+ if (process.env.NODE_ENV !== 'production') {
5249
+ assert.isTrue(vm.state === 0
5250
+ /* created */
5251
+ , "".concat(vm, " cannot be recycled."));
5252
+ }
5253
+
5254
+ runConnectedCallback(vm);
5255
+
5256
+ if (vm.renderMode !== 0
5257
+ /* Light */
5258
+ ) {
5259
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
5260
+ // Note: for Light DOM, this is handled while hydrating the VM
5261
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
5262
+ }
5263
+
5264
+ hydrateVM(vm);
4935
5265
  }
4936
5266
  };
4937
5267
 
@@ -5132,7 +5462,7 @@
5132
5462
  next = iterator.next();
5133
5463
  last = next.done; // template factory logic based on the previous collected value
5134
5464
 
5135
- var vnode = factory(value, j, j === 0, last);
5465
+ var vnode = factory(value, j, j === 0, last === true);
5136
5466
 
5137
5467
  if (isArray$1(vnode)) {
5138
5468
  ArrayPush$1.apply(list, vnode);
@@ -5234,7 +5564,7 @@
5234
5564
 
5235
5565
 
5236
5566
  function d(value) {
5237
- return value == null ? '' : value;
5567
+ return value == null ? '' : String(value);
5238
5568
  } // [b]ind function
5239
5569
 
5240
5570
 
@@ -5394,6 +5724,26 @@
5394
5724
 
5395
5725
  markAsDynamicChildren(vnodes);
5396
5726
  return vnodes;
5727
+ }
5728
+ /**
5729
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5730
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5731
+ * lwc:inner-html directive.
5732
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5733
+ */
5734
+
5735
+
5736
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
5737
+ // locker-service patches this function during runtime to sanitize HTML content.
5738
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5739
+ };
5740
+ /**
5741
+ * Sets the sanitizeHtmlContentHook.
5742
+ */
5743
+
5744
+
5745
+ function setSanitizeHtmlContentHook(newHookImpl) {
5746
+ sanitizeHtmlContentHook = newHookImpl;
5397
5747
  } // [s]anitize [h]tml [c]ontent
5398
5748
 
5399
5749
 
@@ -5401,23 +5751,21 @@
5401
5751
  return sanitizeHtmlContentHook(content);
5402
5752
  }
5403
5753
 
5404
- var api = /*#__PURE__*/Object.freeze({
5405
- __proto__: null,
5406
- h: h,
5407
- ti: ti,
5754
+ var api = freeze({
5408
5755
  s: s,
5756
+ h: h,
5409
5757
  c: c,
5410
5758
  i: i,
5411
5759
  f: f,
5412
5760
  t: t,
5413
- co: co,
5414
5761
  d: d,
5415
5762
  b: b,
5416
5763
  k: k,
5764
+ co: co,
5765
+ dc: dc,
5766
+ ti: ti,
5417
5767
  gid: gid,
5418
5768
  fid: fid,
5419
- dc: dc,
5420
- sc: sc,
5421
5769
  shc: shc
5422
5770
  });
5423
5771
  /*
@@ -5432,12 +5780,12 @@
5432
5780
  }
5433
5781
 
5434
5782
  function createInlineStyleVNode(content) {
5435
- return h('style', {
5783
+ return api.h('style', {
5436
5784
  key: 'style',
5437
5785
  attrs: {
5438
5786
  type: 'text/css'
5439
5787
  }
5440
- }, [t(content)]);
5788
+ }, [api.t(content)]);
5441
5789
  }
5442
5790
 
5443
5791
  function updateStylesheetToken(vm, template) {
@@ -5497,9 +5845,10 @@
5497
5845
 
5498
5846
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5499
5847
  var content = [];
5848
+ var root;
5500
5849
 
5501
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
5502
- var stylesheet = stylesheets[_i14];
5850
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5851
+ var stylesheet = stylesheets[_i16];
5503
5852
 
5504
5853
  if (isArray$1(stylesheet)) {
5505
5854
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -5509,23 +5858,46 @@
5509
5858
  // the component instance might be attempting to use an old version of
5510
5859
  // the stylesheet, while internally, we have a replacement for it.
5511
5860
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5512
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5513
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5861
+ }
5514
5862
 
5863
+ var isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5864
+
5865
+ var scopeToken = isScopedCss || vm.shadowMode === 1
5866
+ /* Synthetic */
5867
+ && vm.renderMode === 1
5868
+ /* Shadow */
5869
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5870
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5515
5871
 
5516
- var isScopedCss = stylesheet[KEY__SCOPED_CSS];
5517
5872
  var useActualHostSelector = vm.renderMode === 0
5518
5873
  /* Light */
5519
5874
  ? !isScopedCss : vm.shadowMode === 0
5520
5875
  /* Native */
5521
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5876
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5877
+ // we use an attribute selector on the host to simulate :dir().
5522
5878
 
5523
- var scopeToken = isScopedCss || vm.shadowMode === 1
5524
- /* Synthetic */
5525
- && vm.renderMode === 1
5879
+ var useNativeDirPseudoclass = void 0;
5880
+
5881
+ if (vm.renderMode === 1
5526
5882
  /* Shadow */
5527
- ? stylesheetToken : undefined;
5528
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5883
+ ) {
5884
+ useNativeDirPseudoclass = vm.shadowMode === 0
5885
+ /* Native */
5886
+ ;
5887
+ } else {
5888
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5889
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5890
+ if (isUndefined$1(root)) {
5891
+ // Only calculate the root once as necessary
5892
+ root = getNearestShadowComponent(vm);
5893
+ }
5894
+
5895
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5896
+ /* Native */
5897
+ ;
5898
+ }
5899
+
5900
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5529
5901
  }
5530
5902
  }
5531
5903
 
@@ -5547,14 +5919,12 @@
5547
5919
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5548
5920
 
5549
5921
 
5550
- function getNearestNativeShadowComponent(vm) {
5922
+ function getNearestShadowComponent(vm) {
5551
5923
  var owner = vm;
5552
5924
 
5553
5925
  while (!isNull(owner)) {
5554
5926
  if (owner.renderMode === 1
5555
5927
  /* Shadow */
5556
- && owner.shadowMode === 0
5557
- /* Native */
5558
5928
  ) {
5559
5929
  return owner;
5560
5930
  }
@@ -5565,6 +5935,20 @@
5565
5935
  return owner;
5566
5936
  }
5567
5937
 
5938
+ function getNearestNativeShadowComponent(vm) {
5939
+ var owner = getNearestShadowComponent(vm);
5940
+
5941
+ if (!isNull(owner) && owner.shadowMode === 1
5942
+ /* Synthetic */
5943
+ ) {
5944
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5945
+ // synthetic, we know we won't find a native component if we go any further.
5946
+ return null;
5947
+ }
5948
+
5949
+ return owner;
5950
+ }
5951
+
5568
5952
  function createStylesheet(vm, stylesheets) {
5569
5953
  var renderer = vm.renderer,
5570
5954
  renderMode = vm.renderMode,
@@ -5575,10 +5959,13 @@
5575
5959
  && shadowMode === 1
5576
5960
  /* Synthetic */
5577
5961
  ) {
5578
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
5579
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
5962
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5963
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
5580
5964
  }
5581
- } else if (renderer.ssr) {
5965
+ } else if (renderer.ssr || renderer.isHydrating()) {
5966
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
5967
+ // This works in the client, because the stylesheets are created, and cached in the VM
5968
+ // the first time the VM renders.
5582
5969
  // native shadow or light DOM, SSR
5583
5970
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
5584
5971
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -5587,12 +5974,12 @@
5587
5974
  var root = getNearestNativeShadowComponent(vm);
5588
5975
  var isGlobal = isNull(root);
5589
5976
 
5590
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
5977
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
5591
5978
  if (isGlobal) {
5592
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
5979
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
5593
5980
  } else {
5594
5981
  // local level
5595
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
5982
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
5596
5983
  }
5597
5984
  }
5598
5985
  }
@@ -5869,8 +6256,8 @@
5869
6256
  var stylesheets = template.stylesheets;
5870
6257
 
5871
6258
  if (!isUndefined$1(stylesheets)) {
5872
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
5873
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
6259
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
6260
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
5874
6261
  return true;
5875
6262
  }
5876
6263
  }
@@ -6100,8 +6487,8 @@
6100
6487
  assert.isTrue(isObject(service), "Invalid service declaration, ".concat(service, ": service must be an object"));
6101
6488
  }
6102
6489
 
6103
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
6104
- var hookName = hooks[_i18];
6490
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
6491
+ var hookName = hooks[_i20];
6105
6492
 
6106
6493
  if (hookName in service) {
6107
6494
  var l = Services[hookName];
@@ -6124,8 +6511,8 @@
6124
6511
  def = vm.def,
6125
6512
  context = vm.context;
6126
6513
 
6127
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
6128
- cbs[_i19].call(undefined, component, {}, def, context);
6514
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
6515
+ cbs[_i21].call(undefined, component, {}, def, context);
6129
6516
  }
6130
6517
  }
6131
6518
  /*
@@ -6178,6 +6565,12 @@
6178
6565
  , vm);
6179
6566
  }
6180
6567
 
6568
+ function hydrateRootElement(elm) {
6569
+ var vm = getAssociatedVM(elm);
6570
+ runConnectedCallback(vm);
6571
+ hydrateVM(vm);
6572
+ }
6573
+
6181
6574
  function disconnectRootElement(elm) {
6182
6575
  var vm = getAssociatedVM(elm);
6183
6576
  resetComponentStateWhenRemoved(vm);
@@ -6185,6 +6578,10 @@
6185
6578
 
6186
6579
  function appendVM(vm) {
6187
6580
  rehydrate(vm);
6581
+ }
6582
+
6583
+ function hydrateVM(vm) {
6584
+ hydrate(vm);
6188
6585
  } // just in case the component comes back, with this we guarantee re-rendering it
6189
6586
  // while preventing any attempt to rehydration until after reinsertion.
6190
6587
 
@@ -6408,6 +6805,22 @@
6408
6805
  }
6409
6806
  }
6410
6807
 
6808
+ function hydrate(vm) {
6809
+ if (isTrue(vm.isDirty)) {
6810
+ // manually diffing/patching here.
6811
+ // This routine is:
6812
+ // patchShadowRoot(vm, children);
6813
+ // -> addVnodes.
6814
+ var children = renderComponent(vm);
6815
+ vm.children = children;
6816
+ var vmChildren = vm.renderMode === 0
6817
+ /* Light */
6818
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
6819
+ hydrateChildrenHook(vmChildren, children, vm);
6820
+ runRenderedCallback(vm);
6821
+ }
6822
+ }
6823
+
6411
6824
  function patchShadowRoot(vm, newCh) {
6412
6825
  var oldCh = vm.children; // caching the new children collection
6413
6826
 
@@ -6488,19 +6901,19 @@
6488
6901
  });
6489
6902
  rehydrateQueue = []; // reset to a new queue
6490
6903
 
6491
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
6492
- var vm = vms[_i20];
6904
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
6905
+ var vm = vms[_i22];
6493
6906
 
6494
6907
  try {
6495
6908
  rehydrate(vm);
6496
6909
  } catch (error) {
6497
- if (_i20 + 1 < _len7) {
6910
+ if (_i22 + 1 < _len7) {
6498
6911
  // pieces of the queue are still pending to be rehydrated, those should have priority
6499
6912
  if (rehydrateQueue.length === 0) {
6500
6913
  addCallbackToNextTick(flushRehydrationQueue);
6501
6914
  }
6502
6915
 
6503
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
6916
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
6504
6917
  } // we need to end the measure before throwing.
6505
6918
 
6506
6919
 
@@ -6604,8 +7017,8 @@
6604
7017
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
6605
7018
  // inserted in reserved order.
6606
7019
 
6607
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
6608
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
7020
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
7021
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
6609
7022
  // * when there is an error during the construction phase, and an error
6610
7023
  // boundary picks it, there is a possibility that the VCustomElement
6611
7024
  // is not properly initialized, and therefore is should be ignored.
@@ -6639,8 +7052,8 @@
6639
7052
 
6640
7053
 
6641
7054
  function recursivelyDisconnectChildren(vnodes) {
6642
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
6643
- var vnode = vnodes[_i22];
7055
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
7056
+ var vnode = vnodes[_i24];
6644
7057
 
6645
7058
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
6646
7059
  // vnode is a VElement with children
@@ -6664,8 +7077,8 @@
6664
7077
  renderer = vm.renderer;
6665
7078
  var rootNode = getRenderRoot(vm);
6666
7079
 
6667
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
6668
- var child = children[_i23];
7080
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
7081
+ var child = children[_i25];
6669
7082
 
6670
7083
  if (!isNull(child) && !isUndefined$1(child.elm)) {
6671
7084
  renderer.remove(child.elm, rootNode);
@@ -6710,8 +7123,8 @@
6710
7123
  var oldSlots = vm.cmpSlots;
6711
7124
  var cmpSlots = vm.cmpSlots = create(null);
6712
7125
 
6713
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
6714
- var vnode = children[_i24];
7126
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
7127
+ var vnode = children[_i26];
6715
7128
 
6716
7129
  if (isNull(vnode)) {
6717
7130
  continue;
@@ -6741,8 +7154,8 @@
6741
7154
  return;
6742
7155
  }
6743
7156
 
6744
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
6745
- var key = oldKeys[_i25];
7157
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
7158
+ var key = oldKeys[_i27];
6746
7159
 
6747
7160
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
6748
7161
  markComponentAsDirty(vm);
@@ -7105,8 +7518,8 @@
7105
7518
  function connectWireAdapters(vm) {
7106
7519
  var wiredConnecting = vm.context.wiredConnecting;
7107
7520
 
7108
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
7109
- wiredConnecting[_i26]();
7521
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
7522
+ wiredConnecting[_i28]();
7110
7523
  }
7111
7524
  }
7112
7525
 
@@ -7114,8 +7527,8 @@
7114
7527
  var wiredDisconnecting = vm.context.wiredDisconnecting;
7115
7528
  runWithBoundaryProtection(vm, vm, noop, function () {
7116
7529
  // job
7117
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
7118
- wiredDisconnecting[_i27]();
7530
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
7531
+ wiredDisconnecting[_i29]();
7119
7532
  }
7120
7533
  }, noop);
7121
7534
  }
@@ -7200,28 +7613,12 @@
7200
7613
 
7201
7614
  var hooksAreSet = false;
7202
7615
 
7203
- function overrideHooks(hooks) {
7204
- var oldHooks = {};
7205
-
7206
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7207
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7208
- }
7209
-
7210
- return oldHooks;
7211
- }
7212
-
7213
7616
  function setHooks(hooks) {
7214
7617
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7215
- overrideHooks(hooks);
7216
7618
  hooksAreSet = true;
7619
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7217
7620
  }
7218
-
7219
- function setHooksForTest(hooks) {
7220
- if (process.env.NODE_ENV !== 'production') {
7221
- return overrideHooks(hooks);
7222
- }
7223
- }
7224
- /* version: 2.5.5-canary1 */
7621
+ /* version: 2.5.9 */
7225
7622
 
7226
7623
  /*
7227
7624
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7236,8 +7633,8 @@
7236
7633
  if (process.env.NODE_ENV === 'development') {
7237
7634
  // @ts-ignore
7238
7635
  window.__lwcResetGlobalStylesheets = function () {
7239
- for (var _i28 = 0, _Object$keys = Object.keys(globalStylesheets); _i28 < _Object$keys.length; _i28++) {
7240
- var key = _Object$keys[_i28];
7636
+ for (var _i30 = 0, _Object$keys = Object.keys(globalStylesheets); _i30 < _Object$keys.length; _i30++) {
7637
+ var key = _Object$keys[_i30];
7241
7638
  delete globalStylesheets[key];
7242
7639
  }
7243
7640
  };
@@ -7376,8 +7773,17 @@
7376
7773
  HTMLElementConstructor.prototype = HTMLElement.prototype;
7377
7774
  }
7378
7775
 
7776
+ var _isHydrating = false;
7777
+
7778
+ function setIsHydrating(v) {
7779
+ _isHydrating = v;
7780
+ }
7781
+
7379
7782
  var renderer = {
7380
7783
  ssr: false,
7784
+ isHydrating: function isHydrating() {
7785
+ return _isHydrating;
7786
+ },
7381
7787
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
7382
7788
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
7383
7789
  createElement: function createElement(tagName, namespace) {
@@ -7399,6 +7805,10 @@
7399
7805
  return node.nextSibling;
7400
7806
  },
7401
7807
  attachShadow: function attachShadow(element, options) {
7808
+ if (_isHydrating) {
7809
+ return element.shadowRoot;
7810
+ }
7811
+
7402
7812
  return element.attachShadow(options);
7403
7813
  },
7404
7814
  setText: function setText(node, content) {
@@ -7509,75 +7919,6 @@
7509
7919
  getCustomElement: getCustomElement,
7510
7920
  HTMLElement: HTMLElementConstructor
7511
7921
  };
7512
- /*
7513
- * Copyright (c) 2018, salesforce.com, inc.
7514
- * All rights reserved.
7515
- * SPDX-License-Identifier: MIT
7516
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7517
- */
7518
-
7519
- /**
7520
- * This function builds a Web Component class from a LWC constructor so it can be
7521
- * registered as a new element via customElements.define() at any given time.
7522
- *
7523
- * @deprecated since version 1.3.11
7524
- *
7525
- * @example
7526
- * ```
7527
- * import { buildCustomElementConstructor } from 'lwc';
7528
- * import Foo from 'ns/foo';
7529
- * const WC = buildCustomElementConstructor(Foo);
7530
- * customElements.define('x-foo', WC);
7531
- * const elm = document.createElement('x-foo');
7532
- * ```
7533
- */
7534
-
7535
- function deprecatedBuildCustomElementConstructor(Ctor) {
7536
- if (process.env.NODE_ENV !== 'production') {
7537
- /* eslint-disable-next-line no-console */
7538
- console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + "Use \"".concat(Ctor.name, ".CustomElementConstructor\" static property of the component constructor to access the corresponding custom element constructor instead."));
7539
- }
7540
-
7541
- return Ctor.CustomElementConstructor;
7542
- }
7543
-
7544
- function buildCustomElementConstructor(Ctor) {
7545
- var def = getComponentInternalDef(Ctor);
7546
- return /*#__PURE__*/function (_def$bridge) {
7547
- _inherits(_class, _def$bridge);
7548
-
7549
- var _super8 = _createSuper(_class);
7550
-
7551
- function _class() {
7552
- var _this6;
7553
-
7554
- _classCallCheck(this, _class);
7555
-
7556
- _this6 = _super8.call(this);
7557
- createVM(_assertThisInitialized(_this6), def, {
7558
- mode: 'open',
7559
- owner: null,
7560
- tagName: _this6.tagName,
7561
- renderer: renderer
7562
- });
7563
- return _this6;
7564
- }
7565
-
7566
- _createClass(_class, [{
7567
- key: "connectedCallback",
7568
- value: function connectedCallback() {
7569
- connectRootElement(this);
7570
- }
7571
- }, {
7572
- key: "disconnectedCallback",
7573
- value: function disconnectedCallback() {
7574
- disconnectRootElement(this);
7575
- }
7576
- }]);
7577
-
7578
- return _class;
7579
- }(def.bridge);
7580
- }
7581
7922
  /*
7582
7923
  * Copyright (c) 2018, salesforce.com, inc.
7583
7924
  * All rights reserved.
@@ -7587,7 +7928,6 @@
7587
7928
  // TODO [#2472]: Remove this workaround when appropriate.
7588
7929
  // eslint-disable-next-line lwc-internal/no-global-node
7589
7930
 
7590
-
7591
7931
  var _Node$1 = Node;
7592
7932
  var ConnectingSlot = new WeakMap();
7593
7933
  var DisconnectingSlot = new WeakMap();
@@ -7697,6 +8037,142 @@
7697
8037
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7698
8038
  */
7699
8039
 
8040
+
8041
+ function hydrateComponent(element, Ctor) {
8042
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
8043
+
8044
+ if (!isFunction$1(Ctor)) {
8045
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
8046
+ }
8047
+
8048
+ if (!isObject(props) || isNull(props)) {
8049
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
8050
+ }
8051
+
8052
+ var def = getComponentInternalDef(Ctor);
8053
+
8054
+ try {
8055
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
8056
+ // and uses the same algo to create the stylesheets as in SSR.
8057
+ setIsHydrating(true);
8058
+ createVM(element, def, {
8059
+ mode: 'open',
8060
+ owner: null,
8061
+ renderer: renderer,
8062
+ tagName: element.tagName.toLowerCase()
8063
+ });
8064
+
8065
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
8066
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
8067
+ key = _Object$entries2$_i[0],
8068
+ value = _Object$entries2$_i[1];
8069
+
8070
+ element[key] = value;
8071
+ }
8072
+
8073
+ hydrateRootElement(element); // set it back since now we finished hydration.
8074
+
8075
+ setIsHydrating(false);
8076
+ } catch (e) {
8077
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
8078
+ // the client generated DOM.
8079
+
8080
+ /* eslint-disable-next-line no-console */
8081
+ console.error('Recovering from error while hydrating: ', e);
8082
+ setIsHydrating(false);
8083
+ var newElem = createElement(element.tagName, {
8084
+ is: Ctor,
8085
+ mode: 'open'
8086
+ });
8087
+
8088
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
8089
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
8090
+ _key3 = _Object$entries3$_i[0],
8091
+ _value2 = _Object$entries3$_i[1];
8092
+
8093
+ newElem[_key3] = _value2;
8094
+ }
8095
+
8096
+ element.parentNode.replaceChild(newElem, element);
8097
+ }
8098
+ }
8099
+ /*
8100
+ * Copyright (c) 2018, salesforce.com, inc.
8101
+ * All rights reserved.
8102
+ * SPDX-License-Identifier: MIT
8103
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8104
+ */
8105
+
8106
+ /**
8107
+ * This function builds a Web Component class from a LWC constructor so it can be
8108
+ * registered as a new element via customElements.define() at any given time.
8109
+ *
8110
+ * @deprecated since version 1.3.11
8111
+ *
8112
+ * @example
8113
+ * ```
8114
+ * import { buildCustomElementConstructor } from 'lwc';
8115
+ * import Foo from 'ns/foo';
8116
+ * const WC = buildCustomElementConstructor(Foo);
8117
+ * customElements.define('x-foo', WC);
8118
+ * const elm = document.createElement('x-foo');
8119
+ * ```
8120
+ */
8121
+
8122
+
8123
+ function deprecatedBuildCustomElementConstructor(Ctor) {
8124
+ if (process.env.NODE_ENV !== 'production') {
8125
+ /* eslint-disable-next-line no-console */
8126
+ console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + "Use \"".concat(Ctor.name, ".CustomElementConstructor\" static property of the component constructor to access the corresponding custom element constructor instead."));
8127
+ }
8128
+
8129
+ return Ctor.CustomElementConstructor;
8130
+ }
8131
+
8132
+ function buildCustomElementConstructor(Ctor) {
8133
+ var def = getComponentInternalDef(Ctor);
8134
+ return /*#__PURE__*/function (_def$bridge) {
8135
+ _inherits(_class, _def$bridge);
8136
+
8137
+ var _super8 = _createSuper(_class);
8138
+
8139
+ function _class() {
8140
+ var _this6;
8141
+
8142
+ _classCallCheck(this, _class);
8143
+
8144
+ _this6 = _super8.call(this);
8145
+ createVM(_assertThisInitialized(_this6), def, {
8146
+ mode: 'open',
8147
+ owner: null,
8148
+ tagName: _this6.tagName,
8149
+ renderer: renderer
8150
+ });
8151
+ return _this6;
8152
+ }
8153
+
8154
+ _createClass(_class, [{
8155
+ key: "connectedCallback",
8156
+ value: function connectedCallback() {
8157
+ connectRootElement(this);
8158
+ }
8159
+ }, {
8160
+ key: "disconnectedCallback",
8161
+ value: function disconnectedCallback() {
8162
+ disconnectRootElement(this);
8163
+ }
8164
+ }]);
8165
+
8166
+ return _class;
8167
+ }(def.bridge);
8168
+ }
8169
+ /*
8170
+ * Copyright (c) 2018, salesforce.com, inc.
8171
+ * All rights reserved.
8172
+ * SPDX-License-Identifier: MIT
8173
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8174
+ */
8175
+
7700
8176
  /**
7701
8177
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
7702
8178
  * This API is subject to change or being removed.
@@ -7795,7 +8271,7 @@
7795
8271
  });
7796
8272
  freeze(LightningElement);
7797
8273
  seal(LightningElement.prototype);
7798
- /* version: 2.5.5-canary1 */
8274
+ /* version: 2.5.9 */
7799
8275
 
7800
8276
  exports.LightningElement = LightningElement;
7801
8277
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7805,6 +8281,7 @@
7805
8281
  exports.createElement = createElement;
7806
8282
  exports.getComponentConstructor = getComponentConstructor;
7807
8283
  exports.getComponentDef = getComponentDef;
8284
+ exports.hydrateComponent = hydrateComponent;
7808
8285
  exports.isComponentConstructor = isComponentConstructor;
7809
8286
  exports.isNodeFromTemplate = isNodeFromTemplate;
7810
8287
  exports.readonly = readonly;
@@ -7816,7 +8293,6 @@
7816
8293
  exports.setFeatureFlag = setFeatureFlag;
7817
8294
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
7818
8295
  exports.setHooks = setHooks;
7819
- exports.setHooksForTest = setHooksForTest;
7820
8296
  exports.swapComponent = swapComponent;
7821
8297
  exports.swapStyle = swapStyle;
7822
8298
  exports.swapTemplate = swapTemplate;
@@ -7826,4 +8302,4 @@
7826
8302
 
7827
8303
  Object.defineProperty(exports, '__esModule', { value: true });
7828
8304
 
7829
- })));
8305
+ }));