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
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LWC = {}));
5
- })(this, (function (exports) { 'use strict';
5
+ }(this, (function (exports) { 'use strict';
6
6
 
7
7
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf2(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
8
8
 
@@ -38,23 +38,23 @@
38
38
 
39
39
  function _getPrototypeOf2(o) { _getPrototypeOf2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf2(o); }
40
40
 
41
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
42
42
 
43
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
44
44
 
45
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
46
46
 
47
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
48
+
49
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
48
50
 
49
51
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
52
 
51
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
54
 
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
-
55
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
55
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
56
56
 
57
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
57
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
58
58
 
59
59
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
60
60
 
@@ -344,7 +344,7 @@
344
344
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
345
345
  return attributeName;
346
346
  }
347
- /** version: 2.5.6 */
347
+ /** version: 2.5.10-alpha1 */
348
348
 
349
349
  /*
350
350
  * Copyright (c) 2018, salesforce.com, inc.
@@ -516,7 +516,7 @@
516
516
 
517
517
  function setFeatureFlagForTest(name, value) {
518
518
  }
519
- /** version: 2.5.6 */
519
+ /** version: 2.5.10-alpha1 */
520
520
 
521
521
  /* proxy-compat-disable */
522
522
 
@@ -558,7 +558,7 @@
558
558
  }
559
559
 
560
560
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
561
- }
561
+ } // Borrowed from Vue template compiler.
562
562
  /*
563
563
  * Copyright (c) 2019, salesforce.com, inc.
564
564
  * All rights reserved.
@@ -713,6 +713,20 @@
713
713
  return "<".concat(StringToLowerCase.call(vm.tagName), ">");
714
714
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
715
715
 
716
+
717
+ function getComponentStack(vm) {
718
+ var stack = [];
719
+ var prefix = '';
720
+
721
+ while (!isNull(vm.owner)) {
722
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
723
+ vm = vm.owner;
724
+ prefix += '\t';
725
+ }
726
+
727
+ return ArrayJoin.call(stack, '\n');
728
+ }
729
+
716
730
  function getErrorComponentStack(vm) {
717
731
  var wcStack = [];
718
732
  var currentVm = vm;
@@ -732,6 +746,32 @@
732
746
  */
733
747
 
734
748
 
749
+ function log(method, message, vm) {
750
+ var msg = "[LWC ".concat(method, "]: ").concat(message);
751
+
752
+ if (!isUndefined$1(vm)) {
753
+ msg = "".concat(msg, "\n").concat(getComponentStack(vm));
754
+ }
755
+
756
+ try {
757
+ throw new Error(msg);
758
+ } catch (e) {
759
+ /* eslint-disable-next-line no-console */
760
+ console[method](e);
761
+ }
762
+ }
763
+
764
+ function logWarn(message, vm) {
765
+ log('warn', message, vm);
766
+ }
767
+ /*
768
+ * Copyright (c) 2018, salesforce.com, inc.
769
+ * All rights reserved.
770
+ * SPDX-License-Identifier: MIT
771
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
772
+ */
773
+
774
+
735
775
  function handleEvent(event, vnode) {
736
776
  var type = event.type;
737
777
  var on = vnode.data.on;
@@ -2394,7 +2434,9 @@
2394
2434
  renderer = vm.renderer;
2395
2435
 
2396
2436
  return renderer[rendererMethod](elm);
2397
- }
2437
+ },
2438
+ configurable: true,
2439
+ enumerable: true
2398
2440
  };
2399
2441
  };
2400
2442
 
@@ -2413,7 +2455,10 @@
2413
2455
  renderer = vm.renderer;
2414
2456
 
2415
2457
  return renderer[queryMethod](elm, arg);
2416
- }
2458
+ },
2459
+ configurable: true,
2460
+ enumerable: true,
2461
+ writable: true
2417
2462
  };
2418
2463
  };
2419
2464
 
@@ -3263,7 +3308,7 @@
3263
3308
  renderMode: 1
3264
3309
  /* Shadow */
3265
3310
  ,
3266
- shadowSupportMode: "default"
3311
+ shadowSupportMode: "reset"
3267
3312
  /* Default */
3268
3313
  ,
3269
3314
  wire: EmptyObject,
@@ -3377,6 +3422,17 @@
3377
3422
  modComputedStyle.create(vnode);
3378
3423
  }
3379
3424
 
3425
+ function hydrateElmHook(vnode) {
3426
+ modEvents.create(vnode); // Attrs are already on the element.
3427
+ // modAttrs.create(vnode);
3428
+
3429
+ modProps.create(vnode); // Already set.
3430
+ // modStaticClassName.create(vnode);
3431
+ // modStaticStyle.create(vnode);
3432
+ // modComputedClassName.create(vnode);
3433
+ // modComputedStyle.create(vnode);
3434
+ }
3435
+
3380
3436
  function fallbackElmHook(elm, vnode) {
3381
3437
  var owner = vnode.owner;
3382
3438
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3508,6 +3564,22 @@
3508
3564
  }
3509
3565
  }
3510
3566
 
3567
+ function hydrateChildrenHook(elmChildren, children, vm) {
3568
+
3569
+ var elmCurrentChildIdx = 0;
3570
+
3571
+ for (var j = 0, n = children.length; j < n; j++) {
3572
+ var ch = children[j];
3573
+
3574
+ if (ch != null) {
3575
+ var childNode = elmChildren[elmCurrentChildIdx];
3576
+
3577
+ ch.hook.hydrate(ch, childNode);
3578
+ elmCurrentChildIdx++;
3579
+ }
3580
+ }
3581
+ }
3582
+
3511
3583
  function updateCustomElmHook(oldVnode, vnode) {
3512
3584
  // Attrs need to be applied to element before props
3513
3585
  // IE11 will wipe out value on radio inputs if value
@@ -3601,38 +3673,6 @@
3601
3673
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3602
3674
  */
3603
3675
 
3604
- /**
3605
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3606
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3607
- * lwc:inner-html directive.
3608
- * It is meant to be overridden with setSanitizeHtmlContentHook
3609
- */
3610
-
3611
-
3612
- var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
3613
- // locker-service patches this function during runtime to sanitize HTML content.
3614
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3615
- };
3616
- /**
3617
- * Sets the sanitizeHtmlContentHook.
3618
- *
3619
- * @param newHookImpl
3620
- * @returns oldHookImplementation.
3621
- */
3622
-
3623
-
3624
- function setSanitizeHtmlContentHook(newHookImpl) {
3625
- var currentHook = sanitizeHtmlContentHook;
3626
- sanitizeHtmlContentHook = newHookImpl;
3627
- return currentHook;
3628
- }
3629
- /*
3630
- * Copyright (c) 2018, salesforce.com, inc.
3631
- * All rights reserved.
3632
- * SPDX-License-Identifier: MIT
3633
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3634
- */
3635
-
3636
3676
 
3637
3677
  var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3638
3678
  var SymbolIterator = Symbol.iterator;
@@ -3647,7 +3687,14 @@
3647
3687
  update: updateNodeHook,
3648
3688
  insert: insertNodeHook,
3649
3689
  move: insertNodeHook,
3650
- remove: removeNodeHook
3690
+ remove: removeNodeHook,
3691
+ hydrate: function hydrate(vNode, node) {
3692
+ var _a;
3693
+
3694
+
3695
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3696
+ vNode.elm = node;
3697
+ }
3651
3698
  };
3652
3699
  var CommentHook = {
3653
3700
  create: function create(vnode) {
@@ -3661,7 +3708,14 @@
3661
3708
  update: updateNodeHook,
3662
3709
  insert: insertNodeHook,
3663
3710
  move: insertNodeHook,
3664
- remove: removeNodeHook
3711
+ remove: removeNodeHook,
3712
+ hydrate: function hydrate(vNode, node) {
3713
+ var _a;
3714
+
3715
+
3716
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3717
+ vNode.elm = node;
3718
+ }
3665
3719
  }; // insert is called after update, which is used somewhere else (via a module)
3666
3720
  // to mark the vm as inserted, that means we cannot use update as the main channel
3667
3721
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3695,6 +3749,34 @@
3695
3749
  remove: function remove(vnode, parentNode) {
3696
3750
  removeNodeHook(vnode, parentNode);
3697
3751
  removeElmHook(vnode);
3752
+ },
3753
+ hydrate: function hydrate(vnode, node) {
3754
+ var elm = node;
3755
+ vnode.elm = elm;
3756
+ var context = vnode.data.context;
3757
+ var isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3758
+ /* manual */
3759
+ );
3760
+
3761
+ if (isDomManual) {
3762
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3763
+ // remove the innerHTML from props so it reuses the existing dom elements.
3764
+ var props = vnode.data.props;
3765
+
3766
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3767
+ if (elm.innerHTML === props.innerHTML) {
3768
+ delete props.innerHTML;
3769
+ } else {
3770
+ logWarn("Mismatch hydrating element <".concat(elm.tagName.toLowerCase(), ">: innerHTML values do not match for element, will recover from the difference"), vnode.owner);
3771
+ }
3772
+ }
3773
+ }
3774
+
3775
+ hydrateElmHook(vnode);
3776
+
3777
+ if (!isDomManual) {
3778
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3779
+ }
3698
3780
  }
3699
3781
  };
3700
3782
  var CustomElementHook = {
@@ -3774,6 +3856,36 @@
3774
3856
  // will take care of disconnecting any child VM attached to its shadow as well.
3775
3857
  removeVM(vm);
3776
3858
  }
3859
+ },
3860
+ hydrate: function hydrate(vnode, elm) {
3861
+ // the element is created, but the vm is not
3862
+ var sel = vnode.sel,
3863
+ mode = vnode.mode,
3864
+ ctor = vnode.ctor,
3865
+ owner = vnode.owner;
3866
+ var def = getComponentInternalDef(ctor);
3867
+ createVM(elm, def, {
3868
+ mode: mode,
3869
+ owner: owner,
3870
+ tagName: sel,
3871
+ renderer: owner.renderer
3872
+ });
3873
+ vnode.elm = elm;
3874
+ var vm = getAssociatedVM(elm);
3875
+ allocateChildrenHook(vnode, vm);
3876
+ hydrateElmHook(vnode); // Insert hook section:
3877
+
3878
+ runConnectedCallback(vm);
3879
+
3880
+ if (vm.renderMode !== 0
3881
+ /* Light */
3882
+ ) {
3883
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3884
+ // Note: for Light DOM, this is handled while hydrating the VM
3885
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3886
+ }
3887
+
3888
+ hydrateVM(vm);
3777
3889
  }
3778
3890
  };
3779
3891
 
@@ -3975,7 +4087,7 @@
3975
4087
 
3976
4088
 
3977
4089
  function d(value) {
3978
- return value == null ? '' : value;
4090
+ return value == null ? '' : String(value);
3979
4091
  } // [b]ind function
3980
4092
 
3981
4093
 
@@ -4114,6 +4226,26 @@
4114
4226
 
4115
4227
  markAsDynamicChildren(vnodes);
4116
4228
  return vnodes;
4229
+ }
4230
+ /**
4231
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4232
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4233
+ * lwc:inner-html directive.
4234
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4235
+ */
4236
+
4237
+
4238
+ var sanitizeHtmlContentHook = function sanitizeHtmlContentHook() {
4239
+ // locker-service patches this function during runtime to sanitize HTML content.
4240
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4241
+ };
4242
+ /**
4243
+ * Sets the sanitizeHtmlContentHook.
4244
+ */
4245
+
4246
+
4247
+ function setSanitizeHtmlContentHook(newHookImpl) {
4248
+ sanitizeHtmlContentHook = newHookImpl;
4117
4249
  } // [s]anitize [h]tml [c]ontent
4118
4250
 
4119
4251
 
@@ -4216,8 +4348,8 @@
4216
4348
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4217
4349
  var content = [];
4218
4350
 
4219
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4220
- var stylesheet = stylesheets[_i14];
4351
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4352
+ var stylesheet = stylesheets[_i16];
4221
4353
 
4222
4354
  if (isArray$1(stylesheet)) {
4223
4355
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4287,10 +4419,13 @@
4287
4419
  && shadowMode === 1
4288
4420
  /* Synthetic */
4289
4421
  ) {
4290
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4291
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4422
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4423
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4292
4424
  }
4293
- } else if (renderer.ssr) {
4425
+ } else if (renderer.ssr || renderer.isHydrating()) {
4426
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4427
+ // This works in the client, because the stylesheets are created, and cached in the VM
4428
+ // the first time the VM renders.
4294
4429
  // native shadow or light DOM, SSR
4295
4430
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4296
4431
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4299,12 +4434,12 @@
4299
4434
  var root = getNearestNativeShadowComponent(vm);
4300
4435
  var isGlobal = isNull(root);
4301
4436
 
4302
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4437
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4303
4438
  if (isGlobal) {
4304
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4439
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4305
4440
  } else {
4306
4441
  // local level
4307
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4442
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4308
4443
  }
4309
4444
  }
4310
4445
  }
@@ -4489,8 +4624,8 @@
4489
4624
  var stylesheets = template.stylesheets;
4490
4625
 
4491
4626
  if (!isUndefined$1(stylesheets)) {
4492
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4493
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4627
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4628
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4494
4629
  return true;
4495
4630
  }
4496
4631
  }
@@ -4691,8 +4826,8 @@
4691
4826
 
4692
4827
  function register(service) {
4693
4828
 
4694
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4695
- var hookName = hooks[_i18];
4829
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4830
+ var hookName = hooks[_i20];
4696
4831
 
4697
4832
  if (hookName in service) {
4698
4833
  var l = Services[hookName];
@@ -4712,8 +4847,8 @@
4712
4847
  def = vm.def,
4713
4848
  context = vm.context;
4714
4849
 
4715
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4716
- cbs[_i19].call(undefined, component, {}, def, context);
4850
+ for (var _i21 = 0, _len6 = cbs.length; _i21 < _len6; ++_i21) {
4851
+ cbs[_i21].call(undefined, component, {}, def, context);
4717
4852
  }
4718
4853
  }
4719
4854
  /*
@@ -4766,6 +4901,12 @@
4766
4901
  , vm);
4767
4902
  }
4768
4903
 
4904
+ function hydrateRootElement(elm) {
4905
+ var vm = getAssociatedVM(elm);
4906
+ runConnectedCallback(vm);
4907
+ hydrateVM(vm);
4908
+ }
4909
+
4769
4910
  function disconnectRootElement(elm) {
4770
4911
  var vm = getAssociatedVM(elm);
4771
4912
  resetComponentStateWhenRemoved(vm);
@@ -4773,6 +4914,10 @@
4773
4914
 
4774
4915
  function appendVM(vm) {
4775
4916
  rehydrate(vm);
4917
+ }
4918
+
4919
+ function hydrateVM(vm) {
4920
+ hydrate(vm);
4776
4921
  } // just in case the component comes back, with this we guarantee re-rendering it
4777
4922
  // while preventing any attempt to rehydration until after reinsertion.
4778
4923
 
@@ -4957,6 +5102,22 @@
4957
5102
  }
4958
5103
  }
4959
5104
 
5105
+ function hydrate(vm) {
5106
+ if (isTrue(vm.isDirty)) {
5107
+ // manually diffing/patching here.
5108
+ // This routine is:
5109
+ // patchShadowRoot(vm, children);
5110
+ // -> addVnodes.
5111
+ var children = renderComponent(vm);
5112
+ vm.children = children;
5113
+ var vmChildren = vm.renderMode === 0
5114
+ /* Light */
5115
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5116
+ hydrateChildrenHook(vmChildren, children);
5117
+ runRenderedCallback(vm);
5118
+ }
5119
+ }
5120
+
4960
5121
  function patchShadowRoot(vm, newCh) {
4961
5122
  var oldCh = vm.children; // caching the new children collection
4962
5123
 
@@ -5033,19 +5194,19 @@
5033
5194
  });
5034
5195
  rehydrateQueue = []; // reset to a new queue
5035
5196
 
5036
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5037
- var vm = vms[_i20];
5197
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5198
+ var vm = vms[_i22];
5038
5199
 
5039
5200
  try {
5040
5201
  rehydrate(vm);
5041
5202
  } catch (error) {
5042
- if (_i20 + 1 < _len7) {
5203
+ if (_i22 + 1 < _len7) {
5043
5204
  // pieces of the queue are still pending to be rehydrated, those should have priority
5044
5205
  if (rehydrateQueue.length === 0) {
5045
5206
  addCallbackToNextTick(flushRehydrationQueue);
5046
5207
  }
5047
5208
 
5048
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5209
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5049
5210
  } // we need to end the measure before throwing.
5050
5211
 
5051
5212
 
@@ -5144,8 +5305,8 @@
5144
5305
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5145
5306
  // inserted in reserved order.
5146
5307
 
5147
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5148
- var elm = vCustomElementCollection[_i21].elm; // There are two cases where the element could be undefined:
5308
+ for (var _i23 = vCustomElementCollection.length - 1; _i23 >= 0; _i23 -= 1) {
5309
+ var elm = vCustomElementCollection[_i23].elm; // There are two cases where the element could be undefined:
5149
5310
  // * when there is an error during the construction phase, and an error
5150
5311
  // boundary picks it, there is a possibility that the VCustomElement
5151
5312
  // is not properly initialized, and therefore is should be ignored.
@@ -5179,8 +5340,8 @@
5179
5340
 
5180
5341
 
5181
5342
  function recursivelyDisconnectChildren(vnodes) {
5182
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5183
- var vnode = vnodes[_i22];
5343
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5344
+ var vnode = vnodes[_i24];
5184
5345
 
5185
5346
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5186
5347
  // vnode is a VElement with children
@@ -5204,8 +5365,8 @@
5204
5365
  renderer = vm.renderer;
5205
5366
  var rootNode = getRenderRoot(vm);
5206
5367
 
5207
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5208
- var child = children[_i23];
5368
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5369
+ var child = children[_i25];
5209
5370
 
5210
5371
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5211
5372
  renderer.remove(child.elm, rootNode);
@@ -5250,8 +5411,8 @@
5250
5411
  var oldSlots = vm.cmpSlots;
5251
5412
  var cmpSlots = vm.cmpSlots = create(null);
5252
5413
 
5253
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5254
- var vnode = children[_i24];
5414
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5415
+ var vnode = children[_i26];
5255
5416
 
5256
5417
  if (isNull(vnode)) {
5257
5418
  continue;
@@ -5281,8 +5442,8 @@
5281
5442
  return;
5282
5443
  }
5283
5444
 
5284
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5285
- var key = oldKeys[_i25];
5445
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5446
+ var key = oldKeys[_i27];
5286
5447
 
5287
5448
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5288
5449
  markComponentAsDirty(vm);
@@ -5621,8 +5782,8 @@
5621
5782
  function connectWireAdapters(vm) {
5622
5783
  var wiredConnecting = vm.context.wiredConnecting;
5623
5784
 
5624
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5625
- wiredConnecting[_i26]();
5785
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5786
+ wiredConnecting[_i28]();
5626
5787
  }
5627
5788
  }
5628
5789
 
@@ -5630,8 +5791,8 @@
5630
5791
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5631
5792
  runWithBoundaryProtection(vm, vm, noop, function () {
5632
5793
  // job
5633
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5634
- wiredDisconnecting[_i27]();
5794
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5795
+ wiredDisconnecting[_i29]();
5635
5796
  }
5636
5797
  }, noop);
5637
5798
  }
@@ -5710,25 +5871,12 @@
5710
5871
 
5711
5872
  var hooksAreSet = false;
5712
5873
 
5713
- function overrideHooks(hooks) {
5714
- var oldHooks = {};
5715
-
5716
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5717
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5718
- }
5719
-
5720
- return oldHooks;
5721
- }
5722
-
5723
5874
  function setHooks(hooks) {
5724
5875
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5725
- overrideHooks(hooks);
5726
5876
  hooksAreSet = true;
5877
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5727
5878
  }
5728
-
5729
- function setHooksForTest(hooks) {
5730
- }
5731
- /* version: 2.5.6 */
5879
+ /* version: 2.5.10-alpha1 */
5732
5880
 
5733
5881
  /*
5734
5882
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5873,8 +6021,17 @@
5873
6021
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5874
6022
  }
5875
6023
 
6024
+ var _isHydrating = false;
6025
+
6026
+ function setIsHydrating(v) {
6027
+ _isHydrating = v;
6028
+ }
6029
+
5876
6030
  var renderer = {
5877
6031
  ssr: false,
6032
+ isHydrating: function isHydrating() {
6033
+ return _isHydrating;
6034
+ },
5878
6035
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5879
6036
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5880
6037
  createElement: function createElement(tagName, namespace) {
@@ -5896,6 +6053,10 @@
5896
6053
  return node.nextSibling;
5897
6054
  },
5898
6055
  attachShadow: function attachShadow(element, options) {
6056
+ if (_isHydrating) {
6057
+ return element.shadowRoot;
6058
+ }
6059
+
5899
6060
  return element.attachShadow(options);
5900
6061
  },
5901
6062
  setText: function setText(node, content) {
@@ -6000,71 +6161,6 @@
6000
6161
  getCustomElement: getCustomElement,
6001
6162
  HTMLElement: HTMLElementConstructor
6002
6163
  };
6003
- /*
6004
- * Copyright (c) 2018, salesforce.com, inc.
6005
- * All rights reserved.
6006
- * SPDX-License-Identifier: MIT
6007
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6008
- */
6009
-
6010
- /**
6011
- * This function builds a Web Component class from a LWC constructor so it can be
6012
- * registered as a new element via customElements.define() at any given time.
6013
- *
6014
- * @deprecated since version 1.3.11
6015
- *
6016
- * @example
6017
- * ```
6018
- * import { buildCustomElementConstructor } from 'lwc';
6019
- * import Foo from 'ns/foo';
6020
- * const WC = buildCustomElementConstructor(Foo);
6021
- * customElements.define('x-foo', WC);
6022
- * const elm = document.createElement('x-foo');
6023
- * ```
6024
- */
6025
-
6026
- function deprecatedBuildCustomElementConstructor(Ctor) {
6027
-
6028
- return Ctor.CustomElementConstructor;
6029
- }
6030
-
6031
- function buildCustomElementConstructor(Ctor) {
6032
- var def = getComponentInternalDef(Ctor);
6033
- return /*#__PURE__*/function (_def$bridge) {
6034
- _inherits(_class, _def$bridge);
6035
-
6036
- var _super8 = _createSuper(_class);
6037
-
6038
- function _class() {
6039
- var _this6;
6040
-
6041
- _classCallCheck(this, _class);
6042
-
6043
- _this6 = _super8.call(this);
6044
- createVM(_assertThisInitialized(_this6), def, {
6045
- mode: 'open',
6046
- owner: null,
6047
- tagName: _this6.tagName,
6048
- renderer: renderer
6049
- });
6050
- return _this6;
6051
- }
6052
-
6053
- _createClass(_class, [{
6054
- key: "connectedCallback",
6055
- value: function connectedCallback() {
6056
- connectRootElement(this);
6057
- }
6058
- }, {
6059
- key: "disconnectedCallback",
6060
- value: function disconnectedCallback() {
6061
- disconnectRootElement(this);
6062
- }
6063
- }]);
6064
-
6065
- return _class;
6066
- }(def.bridge);
6067
- }
6068
6164
  /*
6069
6165
  * Copyright (c) 2018, salesforce.com, inc.
6070
6166
  * All rights reserved.
@@ -6074,7 +6170,6 @@
6074
6170
  // TODO [#2472]: Remove this workaround when appropriate.
6075
6171
  // eslint-disable-next-line lwc-internal/no-global-node
6076
6172
 
6077
-
6078
6173
  var _Node$1 = Node;
6079
6174
  var ConnectingSlot = new WeakMap();
6080
6175
  var DisconnectingSlot = new WeakMap();
@@ -6181,6 +6276,138 @@
6181
6276
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6182
6277
  */
6183
6278
 
6279
+
6280
+ function hydrateComponent(element, Ctor) {
6281
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6282
+
6283
+ if (!isFunction$1(Ctor)) {
6284
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6285
+ }
6286
+
6287
+ if (!isObject(props) || isNull(props)) {
6288
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6289
+ }
6290
+
6291
+ var def = getComponentInternalDef(Ctor);
6292
+
6293
+ try {
6294
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6295
+ // and uses the same algo to create the stylesheets as in SSR.
6296
+ setIsHydrating(true);
6297
+ createVM(element, def, {
6298
+ mode: 'open',
6299
+ owner: null,
6300
+ renderer: renderer,
6301
+ tagName: element.tagName.toLowerCase()
6302
+ });
6303
+
6304
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6305
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6306
+ key = _Object$entries2$_i[0],
6307
+ value = _Object$entries2$_i[1];
6308
+
6309
+ element[key] = value;
6310
+ }
6311
+
6312
+ hydrateRootElement(element); // set it back since now we finished hydration.
6313
+
6314
+ setIsHydrating(false);
6315
+ } catch (e) {
6316
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6317
+ // the client generated DOM.
6318
+
6319
+ /* eslint-disable-next-line no-console */
6320
+ console.error('Recovering from error while hydrating: ', e);
6321
+ setIsHydrating(false);
6322
+ var newElem = createElement(element.tagName, {
6323
+ is: Ctor,
6324
+ mode: 'open'
6325
+ });
6326
+
6327
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6328
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6329
+ _key3 = _Object$entries3$_i[0],
6330
+ _value2 = _Object$entries3$_i[1];
6331
+
6332
+ newElem[_key3] = _value2;
6333
+ }
6334
+
6335
+ element.parentNode.replaceChild(newElem, element);
6336
+ }
6337
+ }
6338
+ /*
6339
+ * Copyright (c) 2018, salesforce.com, inc.
6340
+ * All rights reserved.
6341
+ * SPDX-License-Identifier: MIT
6342
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6343
+ */
6344
+
6345
+ /**
6346
+ * This function builds a Web Component class from a LWC constructor so it can be
6347
+ * registered as a new element via customElements.define() at any given time.
6348
+ *
6349
+ * @deprecated since version 1.3.11
6350
+ *
6351
+ * @example
6352
+ * ```
6353
+ * import { buildCustomElementConstructor } from 'lwc';
6354
+ * import Foo from 'ns/foo';
6355
+ * const WC = buildCustomElementConstructor(Foo);
6356
+ * customElements.define('x-foo', WC);
6357
+ * const elm = document.createElement('x-foo');
6358
+ * ```
6359
+ */
6360
+
6361
+
6362
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6363
+
6364
+ return Ctor.CustomElementConstructor;
6365
+ }
6366
+
6367
+ function buildCustomElementConstructor(Ctor) {
6368
+ var def = getComponentInternalDef(Ctor);
6369
+ return /*#__PURE__*/function (_def$bridge) {
6370
+ _inherits(_class, _def$bridge);
6371
+
6372
+ var _super8 = _createSuper(_class);
6373
+
6374
+ function _class() {
6375
+ var _this6;
6376
+
6377
+ _classCallCheck(this, _class);
6378
+
6379
+ _this6 = _super8.call(this);
6380
+ createVM(_assertThisInitialized(_this6), def, {
6381
+ mode: 'open',
6382
+ owner: null,
6383
+ tagName: _this6.tagName,
6384
+ renderer: renderer
6385
+ });
6386
+ return _this6;
6387
+ }
6388
+
6389
+ _createClass(_class, [{
6390
+ key: "connectedCallback",
6391
+ value: function connectedCallback() {
6392
+ connectRootElement(this);
6393
+ }
6394
+ }, {
6395
+ key: "disconnectedCallback",
6396
+ value: function disconnectedCallback() {
6397
+ disconnectRootElement(this);
6398
+ }
6399
+ }]);
6400
+
6401
+ return _class;
6402
+ }(def.bridge);
6403
+ }
6404
+ /*
6405
+ * Copyright (c) 2018, salesforce.com, inc.
6406
+ * All rights reserved.
6407
+ * SPDX-License-Identifier: MIT
6408
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6409
+ */
6410
+
6184
6411
  /**
6185
6412
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6186
6413
  * This API is subject to change or being removed.
@@ -6279,7 +6506,7 @@
6279
6506
  });
6280
6507
  freeze(LightningElement);
6281
6508
  seal(LightningElement.prototype);
6282
- /* version: 2.5.6 */
6509
+ /* version: 2.5.10-alpha1 */
6283
6510
 
6284
6511
  exports.LightningElement = LightningElement;
6285
6512
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6289,6 +6516,7 @@
6289
6516
  exports.createElement = createElement;
6290
6517
  exports.getComponentConstructor = getComponentConstructor;
6291
6518
  exports.getComponentDef = getComponentDef;
6519
+ exports.hydrateComponent = hydrateComponent;
6292
6520
  exports.isComponentConstructor = isComponentConstructor;
6293
6521
  exports.isNodeFromTemplate = isNodeFromTemplate;
6294
6522
  exports.readonly = readonly;
@@ -6300,7 +6528,6 @@
6300
6528
  exports.setFeatureFlag = setFeatureFlag;
6301
6529
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6302
6530
  exports.setHooks = setHooks;
6303
- exports.setHooksForTest = setHooksForTest;
6304
6531
  exports.swapComponent = swapComponent;
6305
6532
  exports.swapStyle = swapStyle;
6306
6533
  exports.swapTemplate = swapTemplate;
@@ -6310,4 +6537,4 @@
6310
6537
 
6311
6538
  Object.defineProperty(exports, '__esModule', { value: true });
6312
6539
 
6313
- }));
6540
+ })));