lwc 2.5.6 → 2.5.10-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/engine/esm/es2017/engine.js +7981 -0
  2. package/dist/engine/iife/es2017/engine.js +8013 -0
  3. package/dist/engine/iife/es2017/engine.min.js +9 -0
  4. package/dist/engine/iife/es2017/engine_debug.js +6541 -0
  5. package/dist/engine/iife/es5/engine.js +6060 -0
  6. package/dist/engine/iife/es5/engine.min.js +23 -0
  7. package/dist/engine/iife/es5/engine_debug.js +4856 -0
  8. package/dist/engine/umd/es2017/engine.js +8014 -0
  9. package/dist/engine/umd/es2017/engine.min.js +9 -0
  10. package/dist/engine/umd/es2017/engine_debug.js +6542 -0
  11. package/dist/engine/umd/es5/engine.js +6061 -0
  12. package/dist/engine/umd/es5/engine.min.js +23 -0
  13. package/dist/engine/umd/es5/engine_debug.js +4857 -0
  14. package/dist/engine-dom/esm/es2017/engine-dom.js +521 -122
  15. package/dist/engine-dom/iife/es2017/engine-dom.js +522 -123
  16. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  17. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +337 -112
  18. package/dist/engine-dom/iife/es5/engine-dom.js +596 -185
  19. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  20. package/dist/engine-dom/iife/es5/engine-dom_debug.js +392 -165
  21. package/dist/engine-dom/umd/es2017/engine-dom.js +523 -124
  22. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  23. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +338 -113
  24. package/dist/engine-dom/umd/es5/engine-dom.js +597 -186
  25. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  26. package/dist/engine-dom/umd/es5/engine-dom_debug.js +393 -166
  27. package/dist/engine-server/commonjs/es2017/engine-server.js +400 -74
  28. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  29. package/dist/engine-server/esm/es2017/engine-server.js +401 -74
  30. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  31. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +4 -4
  32. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  33. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +4 -4
  34. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +4 -4
  35. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  36. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +4 -4
  37. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +5 -5
  38. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  39. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +5 -5
  40. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +5 -5
  41. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  42. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +5 -5
  43. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  44. package/dist/wire-service/iife/es2017/wire-service.js +3 -3
  45. package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
  46. package/dist/wire-service/iife/es5/wire-service.js +3 -3
  47. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  48. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  49. package/dist/wire-service/umd/es2017/wire-service.js +4 -4
  50. package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
  51. package/dist/wire-service/umd/es5/wire-service.js +4 -4
  52. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  53. package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
  54. package/package.json +8 -8
@@ -35,23 +35,23 @@ var LWC = (function (exports) {
35
35
 
36
36
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
37
37
 
38
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
38
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
39
39
 
40
- 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."); }
40
+ 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); } }
41
41
 
42
- 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); }
42
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
43
43
 
44
- 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; }
44
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
45
+
46
+ 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."); }
45
47
 
46
48
  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; }
47
49
 
48
50
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
49
51
 
50
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
51
-
52
- 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); } }
52
+ 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); }
53
53
 
54
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
54
+ 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; }
55
55
 
56
56
  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); }
57
57
 
@@ -341,7 +341,7 @@ var LWC = (function (exports) {
341
341
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
342
342
  return attributeName;
343
343
  }
344
- /** version: 2.5.6 */
344
+ /** version: 2.5.10-alpha1 */
345
345
 
346
346
  /*
347
347
  * Copyright (c) 2018, salesforce.com, inc.
@@ -513,7 +513,7 @@ var LWC = (function (exports) {
513
513
 
514
514
  function setFeatureFlagForTest(name, value) {
515
515
  }
516
- /** version: 2.5.6 */
516
+ /** version: 2.5.10-alpha1 */
517
517
 
518
518
  /* proxy-compat-disable */
519
519
 
@@ -555,7 +555,7 @@ var LWC = (function (exports) {
555
555
  }
556
556
 
557
557
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
558
- }
558
+ } // Borrowed from Vue template compiler.
559
559
  /*
560
560
  * Copyright (c) 2019, salesforce.com, inc.
561
561
  * All rights reserved.
@@ -710,6 +710,20 @@ var LWC = (function (exports) {
710
710
  return "<".concat(StringToLowerCase.call(vm.tagName), ">");
711
711
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
712
712
 
713
+
714
+ function getComponentStack(vm) {
715
+ var stack = [];
716
+ var prefix = '';
717
+
718
+ while (!isNull(vm.owner)) {
719
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
720
+ vm = vm.owner;
721
+ prefix += '\t';
722
+ }
723
+
724
+ return ArrayJoin.call(stack, '\n');
725
+ }
726
+
713
727
  function getErrorComponentStack(vm) {
714
728
  var wcStack = [];
715
729
  var currentVm = vm;
@@ -729,6 +743,32 @@ var LWC = (function (exports) {
729
743
  */
730
744
 
731
745
 
746
+ function log(method, message, vm) {
747
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
748
+
749
+ if (!isUndefined$1(vm)) {
750
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
751
+ }
752
+
753
+ try {
754
+ throw new Error(msg);
755
+ } catch (e) {
756
+ /* eslint-disable-next-line no-console */
757
+ console[method](e);
758
+ }
759
+ }
760
+
761
+ function logWarn(message, vm) {
762
+ log('warn', message, vm);
763
+ }
764
+ /*
765
+ * Copyright (c) 2018, salesforce.com, inc.
766
+ * All rights reserved.
767
+ * SPDX-License-Identifier: MIT
768
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
769
+ */
770
+
771
+
732
772
  function handleEvent(event, vnode) {
733
773
  var type = event.type;
734
774
  var on = vnode.data.on;
@@ -2391,7 +2431,9 @@ var LWC = (function (exports) {
2391
2431
  renderer = vm.renderer;
2392
2432
 
2393
2433
  return renderer[rendererMethod](elm);
2394
- }
2434
+ },
2435
+ configurable: true,
2436
+ enumerable: true
2395
2437
  };
2396
2438
  };
2397
2439
 
@@ -2410,7 +2452,10 @@ var LWC = (function (exports) {
2410
2452
  renderer = vm.renderer;
2411
2453
 
2412
2454
  return renderer[queryMethod](elm, arg);
2413
- }
2455
+ },
2456
+ configurable: true,
2457
+ enumerable: true,
2458
+ writable: true
2414
2459
  };
2415
2460
  };
2416
2461
 
@@ -3260,7 +3305,7 @@ var LWC = (function (exports) {
3260
3305
  renderMode: 1
3261
3306
  /* Shadow */
3262
3307
  ,
3263
- shadowSupportMode: "default"
3308
+ shadowSupportMode: "reset"
3264
3309
  /* Default */
3265
3310
  ,
3266
3311
  wire: EmptyObject,
@@ -3374,6 +3419,17 @@ var LWC = (function (exports) {
3374
3419
  modComputedStyle.create(vnode);
3375
3420
  }
3376
3421
 
3422
+ function hydrateElmHook(vnode) {
3423
+ modEvents.create(vnode); // Attrs are already on the element.
3424
+ // modAttrs.create(vnode);
3425
+
3426
+ modProps.create(vnode); // Already set.
3427
+ // modStaticClassName.create(vnode);
3428
+ // modStaticStyle.create(vnode);
3429
+ // modComputedClassName.create(vnode);
3430
+ // modComputedStyle.create(vnode);
3431
+ }
3432
+
3377
3433
  function fallbackElmHook(elm, vnode) {
3378
3434
  var owner = vnode.owner;
3379
3435
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3505,6 +3561,22 @@ var LWC = (function (exports) {
3505
3561
  }
3506
3562
  }
3507
3563
 
3564
+ function hydrateChildrenHook(elmChildren, children, vm) {
3565
+
3566
+ var elmCurrentChildIdx = 0;
3567
+
3568
+ for (var j = 0, n = children.length; j < n; j++) {
3569
+ var ch = children[j];
3570
+
3571
+ if (ch != null) {
3572
+ var childNode = elmChildren[elmCurrentChildIdx];
3573
+
3574
+ ch.hook.hydrate(ch, childNode);
3575
+ elmCurrentChildIdx++;
3576
+ }
3577
+ }
3578
+ }
3579
+
3508
3580
  function updateCustomElmHook(oldVnode, vnode) {
3509
3581
  // Attrs need to be applied to element before props
3510
3582
  // IE11 will wipe out value on radio inputs if value
@@ -3598,38 +3670,6 @@ var LWC = (function (exports) {
3598
3670
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3599
3671
  */
3600
3672
 
3601
- /**
3602
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3603
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3604
- * lwc:inner-html directive.
3605
- * It is meant to be overridden with setSanitizeHtmlContentHook
3606
- */
3607
-
3608
-
3609
- var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
3610
- // locker-service patches this function during runtime to sanitize HTML content.
3611
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3612
- };
3613
- /**
3614
- * Sets the sanitizeHtmlContentHook.
3615
- *
3616
- * @param newHookImpl
3617
- * @returns oldHookImplementation.
3618
- */
3619
-
3620
-
3621
- function setSanitizeHtmlContentHook(newHookImpl) {
3622
- var currentHook = sanitizeHtmlContentHook;
3623
- sanitizeHtmlContentHook = newHookImpl;
3624
- return currentHook;
3625
- }
3626
- /*
3627
- * Copyright (c) 2018, salesforce.com, inc.
3628
- * All rights reserved.
3629
- * SPDX-License-Identifier: MIT
3630
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3631
- */
3632
-
3633
3673
 
3634
3674
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3635
3675
  var SymbolIterator = Symbol.iterator;
@@ -3644,7 +3684,14 @@ var LWC = (function (exports) {
3644
3684
  update: updateNodeHook,
3645
3685
  insert: insertNodeHook,
3646
3686
  move: insertNodeHook,
3647
- remove: removeNodeHook
3687
+ remove: removeNodeHook,
3688
+ hydrate: function hydrate(vNode, node) {
3689
+ var _a;
3690
+
3691
+
3692
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3693
+ vNode.elm = node;
3694
+ }
3648
3695
  };
3649
3696
  var CommentHook = {
3650
3697
  create: function create(vnode) {
@@ -3658,7 +3705,14 @@ var LWC = (function (exports) {
3658
3705
  update: updateNodeHook,
3659
3706
  insert: insertNodeHook,
3660
3707
  move: insertNodeHook,
3661
- 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
+ }
3662
3716
  }; // insert is called after update, which is used somewhere else (via a module)
3663
3717
  // to mark the vm as inserted, that means we cannot use update as the main channel
3664
3718
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3692,6 +3746,34 @@ var LWC = (function (exports) {
3692
3746
  remove: function remove(vnode, parentNode) {
3693
3747
  removeNodeHook(vnode, parentNode);
3694
3748
  removeElmHook(vnode);
3749
+ },
3750
+ hydrate: function hydrate(vnode, node) {
3751
+ var elm = node;
3752
+ vnode.elm = elm;
3753
+ var context = vnode.data.context;
3754
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3755
+ /* manual */
3756
+ );
3757
+
3758
+ if (isDomManual) {
3759
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3760
+ // remove the innerHTML from props so it reuses the existing dom elements.
3761
+ var props = vnode.data.props;
3762
+
3763
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3764
+ if (elm.innerHTML === props.innerHTML) {
3765
+ delete props.innerHTML;
3766
+ } else {
3767
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3768
+ }
3769
+ }
3770
+ }
3771
+
3772
+ hydrateElmHook(vnode);
3773
+
3774
+ if (!isDomManual) {
3775
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3776
+ }
3695
3777
  }
3696
3778
  };
3697
3779
  var CustomElementHook = {
@@ -3771,6 +3853,36 @@ var LWC = (function (exports) {
3771
3853
  // will take care of disconnecting any child VM attached to its shadow as well.
3772
3854
  removeVM(vm);
3773
3855
  }
3856
+ },
3857
+ hydrate: function hydrate(vnode, elm) {
3858
+ // the element is created, but the vm is not
3859
+ var sel = vnode.sel,
3860
+ mode = vnode.mode,
3861
+ ctor = vnode.ctor,
3862
+ owner = vnode.owner;
3863
+ var def = getComponentInternalDef(ctor);
3864
+ createVM(elm, def, {
3865
+ mode: mode,
3866
+ owner: owner,
3867
+ tagName: sel,
3868
+ renderer: owner.renderer
3869
+ });
3870
+ vnode.elm = elm;
3871
+ var vm = getAssociatedVM(elm);
3872
+ allocateChildrenHook(vnode, vm);
3873
+ hydrateElmHook(vnode); // Insert hook section:
3874
+
3875
+ runConnectedCallback(vm);
3876
+
3877
+ if (vm.renderMode !== 0
3878
+ /* Light */
3879
+ ) {
3880
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3881
+ // Note: for Light DOM, this is handled while hydrating the VM
3882
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3883
+ }
3884
+
3885
+ hydrateVM(vm);
3774
3886
  }
3775
3887
  };
3776
3888
 
@@ -3972,7 +4084,7 @@ var LWC = (function (exports) {
3972
4084
 
3973
4085
 
3974
4086
  function d(value) {
3975
- return value == null ? '' : value;
4087
+ return value == null ? '' : String(value);
3976
4088
  } // [b]ind function
3977
4089
 
3978
4090
 
@@ -4111,6 +4223,26 @@ var LWC = (function (exports) {
4111
4223
 
4112
4224
  markAsDynamicChildren(vnodes);
4113
4225
  return vnodes;
4226
+ }
4227
+ /**
4228
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4229
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4230
+ * lwc:inner-html directive.
4231
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4232
+ */
4233
+
4234
+
4235
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
4236
+ // locker-service patches this function during runtime to sanitize HTML content.
4237
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4238
+ };
4239
+ /**
4240
+ * Sets the sanitizeHtmlContentHook.
4241
+ */
4242
+
4243
+
4244
+ function setSanitizeHtmlContentHook(newHookImpl) {
4245
+ sanitizeHtmlContentHook = newHookImpl;
4114
4246
  } // [s]anitize [h]tml [c]ontent
4115
4247
 
4116
4248
 
@@ -4213,8 +4345,8 @@ var LWC = (function (exports) {
4213
4345
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4214
4346
  var content = [];
4215
4347
 
4216
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4217
- var stylesheet = stylesheets[_i14];
4348
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4349
+ var stylesheet = stylesheets[_i16];
4218
4350
 
4219
4351
  if (isArray$1(stylesheet)) {
4220
4352
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4284,10 +4416,13 @@ var LWC = (function (exports) {
4284
4416
  && shadowMode === 1
4285
4417
  /* Synthetic */
4286
4418
  ) {
4287
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4288
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4419
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4420
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4289
4421
  }
4290
- } else if (renderer.ssr) {
4422
+ } else if (renderer.ssr || renderer.isHydrating()) {
4423
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4424
+ // This works in the client, because the stylesheets are created, and cached in the VM
4425
+ // the first time the VM renders.
4291
4426
  // native shadow or light DOM, SSR
4292
4427
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4293
4428
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4296,12 +4431,12 @@ var LWC = (function (exports) {
4296
4431
  var root = getNearestNativeShadowComponent(vm);
4297
4432
  var isGlobal = isNull(root);
4298
4433
 
4299
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4434
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4300
4435
  if (isGlobal) {
4301
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4436
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4302
4437
  } else {
4303
4438
  // local level
4304
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4439
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4305
4440
  }
4306
4441
  }
4307
4442
  }
@@ -4486,8 +4621,8 @@ var LWC = (function (exports) {
4486
4621
  var stylesheets = template.stylesheets;
4487
4622
 
4488
4623
  if (!isUndefined$1(stylesheets)) {
4489
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4490
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4624
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4625
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4491
4626
  return true;
4492
4627
  }
4493
4628
  }
@@ -4688,8 +4823,8 @@ var LWC = (function (exports) {
4688
4823
 
4689
4824
  function register(service) {
4690
4825
 
4691
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4692
- var hookName = hooks[_i18];
4826
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4827
+ var hookName = hooks[_i20];
4693
4828
 
4694
4829
  if (hookName in service) {
4695
4830
  var l = Services[hookName];
@@ -4709,8 +4844,8 @@ var LWC = (function (exports) {
4709
4844
  def = vm.def,
4710
4845
  context = vm.context;
4711
4846
 
4712
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4713
- cbs[_i19].call(undefined, component, {}, def, context);
4847
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
4848
+ cbs[_i21].call(undefined, component, {}, def, context);
4714
4849
  }
4715
4850
  }
4716
4851
  /*
@@ -4763,6 +4898,12 @@ var LWC = (function (exports) {
4763
4898
  , vm);
4764
4899
  }
4765
4900
 
4901
+ function hydrateRootElement(elm) {
4902
+ var vm = getAssociatedVM(elm);
4903
+ runConnectedCallback(vm);
4904
+ hydrateVM(vm);
4905
+ }
4906
+
4766
4907
  function disconnectRootElement(elm) {
4767
4908
  var vm = getAssociatedVM(elm);
4768
4909
  resetComponentStateWhenRemoved(vm);
@@ -4770,6 +4911,10 @@ var LWC = (function (exports) {
4770
4911
 
4771
4912
  function appendVM(vm) {
4772
4913
  rehydrate(vm);
4914
+ }
4915
+
4916
+ function hydrateVM(vm) {
4917
+ hydrate(vm);
4773
4918
  } // just in case the component comes back, with this we guarantee re-rendering it
4774
4919
  // while preventing any attempt to rehydration until after reinsertion.
4775
4920
 
@@ -4954,6 +5099,22 @@ var LWC = (function (exports) {
4954
5099
  }
4955
5100
  }
4956
5101
 
5102
+ function hydrate(vm) {
5103
+ if (isTrue(vm.isDirty)) {
5104
+ // manually diffing/patching here.
5105
+ // This routine is:
5106
+ // patchShadowRoot(vm, children);
5107
+ // -> addVnodes.
5108
+ var children = renderComponent(vm);
5109
+ vm.children = children;
5110
+ var vmChildren = vm.renderMode === 0
5111
+ /* Light */
5112
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5113
+ hydrateChildrenHook(vmChildren, children);
5114
+ runRenderedCallback(vm);
5115
+ }
5116
+ }
5117
+
4957
5118
  function patchShadowRoot(vm, newCh) {
4958
5119
  var oldCh = vm.children; // caching the new children collection
4959
5120
 
@@ -5030,19 +5191,19 @@ var LWC = (function (exports) {
5030
5191
  });
5031
5192
  rehydrateQueue = []; // reset to a new queue
5032
5193
 
5033
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5034
- var vm = vms[_i20];
5194
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5195
+ var vm = vms[_i22];
5035
5196
 
5036
5197
  try {
5037
5198
  rehydrate(vm);
5038
5199
  } catch (error) {
5039
- if (_i20 + 1 < _len7) {
5200
+ if (_i22 + 1 < _len7) {
5040
5201
  // pieces of the queue are still pending to be rehydrated, those should have priority
5041
5202
  if (rehydrateQueue.length === 0) {
5042
5203
  addCallbackToNextTick(flushRehydrationQueue);
5043
5204
  }
5044
5205
 
5045
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5206
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5046
5207
  } // we need to end the measure before throwing.
5047
5208
 
5048
5209
 
@@ -5141,8 +5302,8 @@ var LWC = (function (exports) {
5141
5302
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5142
5303
  // inserted in reserved order.
5143
5304
 
5144
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5145
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
5305
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5306
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5146
5307
  // * when there is an error during the construction phase, and an error
5147
5308
  // boundary picks it, there is a possibility that the VCustomElement
5148
5309
  // is not properly initialized, and therefore is should be ignored.
@@ -5176,8 +5337,8 @@ var LWC = (function (exports) {
5176
5337
 
5177
5338
 
5178
5339
  function recursivelyDisconnectChildren(vnodes) {
5179
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5180
- var vnode = vnodes[_i22];
5340
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5341
+ var vnode = vnodes[_i24];
5181
5342
 
5182
5343
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5183
5344
  // vnode is a VElement with children
@@ -5201,8 +5362,8 @@ var LWC = (function (exports) {
5201
5362
  renderer = vm.renderer;
5202
5363
  var rootNode = getRenderRoot(vm);
5203
5364
 
5204
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5205
- var child = children[_i23];
5365
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5366
+ var child = children[_i25];
5206
5367
 
5207
5368
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5208
5369
  renderer.remove(child.elm, rootNode);
@@ -5247,8 +5408,8 @@ var LWC = (function (exports) {
5247
5408
  var oldSlots = vm.cmpSlots;
5248
5409
  var cmpSlots = vm.cmpSlots = create(null);
5249
5410
 
5250
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5251
- var vnode = children[_i24];
5411
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5412
+ var vnode = children[_i26];
5252
5413
 
5253
5414
  if (isNull(vnode)) {
5254
5415
  continue;
@@ -5278,8 +5439,8 @@ var LWC = (function (exports) {
5278
5439
  return;
5279
5440
  }
5280
5441
 
5281
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5282
- var key = oldKeys[_i25];
5442
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5443
+ var key = oldKeys[_i27];
5283
5444
 
5284
5445
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5285
5446
  markComponentAsDirty(vm);
@@ -5618,8 +5779,8 @@ var LWC = (function (exports) {
5618
5779
  function connectWireAdapters(vm) {
5619
5780
  var wiredConnecting = vm.context.wiredConnecting;
5620
5781
 
5621
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5622
- wiredConnecting[_i26]();
5782
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5783
+ wiredConnecting[_i28]();
5623
5784
  }
5624
5785
  }
5625
5786
 
@@ -5627,8 +5788,8 @@ var LWC = (function (exports) {
5627
5788
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5628
5789
  runWithBoundaryProtection(vm, vm, noop, function () {
5629
5790
  // job
5630
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5631
- wiredDisconnecting[_i27]();
5791
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5792
+ wiredDisconnecting[_i29]();
5632
5793
  }
5633
5794
  }, noop);
5634
5795
  }
@@ -5707,25 +5868,12 @@ var LWC = (function (exports) {
5707
5868
 
5708
5869
  var hooksAreSet = false;
5709
5870
 
5710
- function overrideHooks(hooks) {
5711
- var oldHooks = {};
5712
-
5713
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5714
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5715
- }
5716
-
5717
- return oldHooks;
5718
- }
5719
-
5720
5871
  function setHooks(hooks) {
5721
5872
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5722
- overrideHooks(hooks);
5723
5873
  hooksAreSet = true;
5874
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5724
5875
  }
5725
-
5726
- function setHooksForTest(hooks) {
5727
- }
5728
- /* version: 2.5.6 */
5876
+ /* version: 2.5.10-alpha1 */
5729
5877
 
5730
5878
  /*
5731
5879
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5870,8 +6018,17 @@ var LWC = (function (exports) {
5870
6018
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5871
6019
  }
5872
6020
 
6021
+ var _isHydrating = false;
6022
+
6023
+ function setIsHydrating(v) {
6024
+ _isHydrating = v;
6025
+ }
6026
+
5873
6027
  var renderer = {
5874
6028
  ssr: false,
6029
+ isHydrating: function isHydrating() {
6030
+ return _isHydrating;
6031
+ },
5875
6032
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5876
6033
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5877
6034
  createElement: function createElement(tagName, namespace) {
@@ -5893,6 +6050,10 @@ var LWC = (function (exports) {
5893
6050
  return node.nextSibling;
5894
6051
  },
5895
6052
  attachShadow: function attachShadow(element, options) {
6053
+ if (_isHydrating) {
6054
+ return element.shadowRoot;
6055
+ }
6056
+
5896
6057
  return element.attachShadow(options);
5897
6058
  },
5898
6059
  setText: function setText(node, content) {
@@ -5997,71 +6158,6 @@ var LWC = (function (exports) {
5997
6158
  getCustomElement: getCustomElement,
5998
6159
  HTMLElement: HTMLElementConstructor
5999
6160
  };
6000
- /*
6001
- * Copyright (c) 2018, salesforce.com, inc.
6002
- * All rights reserved.
6003
- * SPDX-License-Identifier: MIT
6004
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6005
- */
6006
-
6007
- /**
6008
- * This function builds a Web Component class from a LWC constructor so it can be
6009
- * registered as a new element via customElements.define() at any given time.
6010
- *
6011
- * @deprecated since version 1.3.11
6012
- *
6013
- * @example
6014
- * ```
6015
- * import { buildCustomElementConstructor } from 'lwc';
6016
- * import Foo from 'ns/foo';
6017
- * const WC = buildCustomElementConstructor(Foo);
6018
- * customElements.define('x-foo', WC);
6019
- * const elm = document.createElement('x-foo');
6020
- * ```
6021
- */
6022
-
6023
- function deprecatedBuildCustomElementConstructor(Ctor) {
6024
-
6025
- return Ctor.CustomElementConstructor;
6026
- }
6027
-
6028
- function buildCustomElementConstructor(Ctor) {
6029
- var def = getComponentInternalDef(Ctor);
6030
- return /*#__PURE__*/function (_def$bridge) {
6031
- _inherits(_class, _def$bridge);
6032
-
6033
- var _super8 = _createSuper(_class);
6034
-
6035
- function _class() {
6036
- var _this6;
6037
-
6038
- _classCallCheck(this, _class);
6039
-
6040
- _this6 = _super8.call(this);
6041
- createVM(_assertThisInitialized(_this6), def, {
6042
- mode: 'open',
6043
- owner: null,
6044
- tagName: _this6.tagName,
6045
- renderer: renderer
6046
- });
6047
- return _this6;
6048
- }
6049
-
6050
- _createClass(_class, [{
6051
- key: "connectedCallback",
6052
- value: function connectedCallback() {
6053
- connectRootElement(this);
6054
- }
6055
- }, {
6056
- key: "disconnectedCallback",
6057
- value: function disconnectedCallback() {
6058
- disconnectRootElement(this);
6059
- }
6060
- }]);
6061
-
6062
- return _class;
6063
- }(def.bridge);
6064
- }
6065
6161
  /*
6066
6162
  * Copyright (c) 2018, salesforce.com, inc.
6067
6163
  * All rights reserved.
@@ -6071,7 +6167,6 @@ var LWC = (function (exports) {
6071
6167
  // TODO [#2472]: Remove this workaround when appropriate.
6072
6168
  // eslint-disable-next-line lwc-internal/no-global-node
6073
6169
 
6074
-
6075
6170
  var _Node$1 = Node;
6076
6171
  var ConnectingSlot = new WeakMap();
6077
6172
  var DisconnectingSlot = new WeakMap();
@@ -6178,6 +6273,138 @@ var LWC = (function (exports) {
6178
6273
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6179
6274
  */
6180
6275
 
6276
+
6277
+ function hydrateComponent(element, Ctor) {
6278
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6279
+
6280
+ if (!isFunction$1(Ctor)) {
6281
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6282
+ }
6283
+
6284
+ if (!isObject(props) || isNull(props)) {
6285
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6286
+ }
6287
+
6288
+ var def = getComponentInternalDef(Ctor);
6289
+
6290
+ try {
6291
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6292
+ // and uses the same algo to create the stylesheets as in SSR.
6293
+ setIsHydrating(true);
6294
+ createVM(element, def, {
6295
+ mode: 'open',
6296
+ owner: null,
6297
+ renderer: renderer,
6298
+ tagName: element.tagName.toLowerCase()
6299
+ });
6300
+
6301
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6302
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6303
+ key = _Object$entries2$_i[0],
6304
+ value = _Object$entries2$_i[1];
6305
+
6306
+ element[key] = value;
6307
+ }
6308
+
6309
+ hydrateRootElement(element); // set it back since now we finished hydration.
6310
+
6311
+ setIsHydrating(false);
6312
+ } catch (e) {
6313
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6314
+ // the client generated DOM.
6315
+
6316
+ /* eslint-disable-next-line no-console */
6317
+ console.error('Recovering from error while hydrating: ', e);
6318
+ setIsHydrating(false);
6319
+ var newElem = createElement(element.tagName, {
6320
+ is: Ctor,
6321
+ mode: 'open'
6322
+ });
6323
+
6324
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6325
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6326
+ _key3 = _Object$entries3$_i[0],
6327
+ _value2 = _Object$entries3$_i[1];
6328
+
6329
+ newElem[_key3] = _value2;
6330
+ }
6331
+
6332
+ element.parentNode.replaceChild(newElem, element);
6333
+ }
6334
+ }
6335
+ /*
6336
+ * Copyright (c) 2018, salesforce.com, inc.
6337
+ * All rights reserved.
6338
+ * SPDX-License-Identifier: MIT
6339
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6340
+ */
6341
+
6342
+ /**
6343
+ * This function builds a Web Component class from a LWC constructor so it can be
6344
+ * registered as a new element via customElements.define() at any given time.
6345
+ *
6346
+ * @deprecated since version 1.3.11
6347
+ *
6348
+ * @example
6349
+ * ```
6350
+ * import { buildCustomElementConstructor } from 'lwc';
6351
+ * import Foo from 'ns/foo';
6352
+ * const WC = buildCustomElementConstructor(Foo);
6353
+ * customElements.define('x-foo', WC);
6354
+ * const elm = document.createElement('x-foo');
6355
+ * ```
6356
+ */
6357
+
6358
+
6359
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6360
+
6361
+ return Ctor.CustomElementConstructor;
6362
+ }
6363
+
6364
+ function buildCustomElementConstructor(Ctor) {
6365
+ var def = getComponentInternalDef(Ctor);
6366
+ return /*#__PURE__*/function (_def$bridge) {
6367
+ _inherits(_class, _def$bridge);
6368
+
6369
+ var _super8 = _createSuper(_class);
6370
+
6371
+ function _class() {
6372
+ var _this6;
6373
+
6374
+ _classCallCheck(this, _class);
6375
+
6376
+ _this6 = _super8.call(this);
6377
+ createVM(_assertThisInitialized(_this6), def, {
6378
+ mode: 'open',
6379
+ owner: null,
6380
+ tagName: _this6.tagName,
6381
+ renderer: renderer
6382
+ });
6383
+ return _this6;
6384
+ }
6385
+
6386
+ _createClass(_class, [{
6387
+ key: "connectedCallback",
6388
+ value: function connectedCallback() {
6389
+ connectRootElement(this);
6390
+ }
6391
+ }, {
6392
+ key: "disconnectedCallback",
6393
+ value: function disconnectedCallback() {
6394
+ disconnectRootElement(this);
6395
+ }
6396
+ }]);
6397
+
6398
+ return _class;
6399
+ }(def.bridge);
6400
+ }
6401
+ /*
6402
+ * Copyright (c) 2018, salesforce.com, inc.
6403
+ * All rights reserved.
6404
+ * SPDX-License-Identifier: MIT
6405
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6406
+ */
6407
+
6181
6408
  /**
6182
6409
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6183
6410
  * This API is subject to change or being removed.
@@ -6276,7 +6503,7 @@ var LWC = (function (exports) {
6276
6503
  });
6277
6504
  freeze(LightningElement);
6278
6505
  seal(LightningElement.prototype);
6279
- /* version: 2.5.6 */
6506
+ /* version: 2.5.10-alpha1 */
6280
6507
 
6281
6508
  exports.LightningElement = LightningElement;
6282
6509
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6286,6 +6513,7 @@ var LWC = (function (exports) {
6286
6513
  exports.createElement = createElement;
6287
6514
  exports.getComponentConstructor = getComponentConstructor;
6288
6515
  exports.getComponentDef = getComponentDef;
6516
+ exports.hydrateComponent = hydrateComponent;
6289
6517
  exports.isComponentConstructor = isComponentConstructor;
6290
6518
  exports.isNodeFromTemplate = isNodeFromTemplate;
6291
6519
  exports.readonly = readonly;
@@ -6297,7 +6525,6 @@ var LWC = (function (exports) {
6297
6525
  exports.setFeatureFlag = setFeatureFlag;
6298
6526
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6299
6527
  exports.setHooks = setHooks;
6300
- exports.setHooksForTest = setHooksForTest;
6301
6528
  exports.swapComponent = swapComponent;
6302
6529
  exports.swapStyle = swapStyle;
6303
6530
  exports.swapTemplate = swapTemplate;
@@ -6309,4 +6536,4 @@ var LWC = (function (exports) {
6309
6536
 
6310
6537
  return exports;
6311
6538
 
6312
- })({});
6539
+ }({}));