lwc 2.5.4 → 2.5.8

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 (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +567 -99
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +568 -98
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +383 -90
  5. package/dist/engine-dom/iife/es5/engine-dom.js +634 -150
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +430 -133
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +568 -98
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +383 -90
  11. package/dist/engine-dom/umd/es5/engine-dom.js +634 -150
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +430 -133
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +457 -49
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +457 -50
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -39
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +9 -39
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +9 -39
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +9 -39
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +9 -39
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +9 -39
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +9 -39
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +9 -39
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +9 -39
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. 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.4 */
344
+ /** version: 2.5.8 */
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.4 */
516
+ /** version: 2.5.8 */
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
 
@@ -2845,15 +2890,14 @@ var LWC = (function (exports) {
2845
2890
  return tpl;
2846
2891
  }
2847
2892
  /**
2848
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
2849
- * Service and other similar libraries to sanitize vulnerable attributes.
2850
- * This API is subject to change or being removed.
2893
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
2894
+ * libraries to sanitize vulnerable attributes.
2851
2895
  */
2852
2896
 
2853
2897
 
2854
2898
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
2855
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
2856
- // when ran off-core this function becomes a noop and returns the user authored value.
2899
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
2900
+ // ran off-core this function becomes a noop and returns the user authored value.
2857
2901
  return attrValue;
2858
2902
  }
2859
2903
  /*
@@ -3261,7 +3305,7 @@ var LWC = (function (exports) {
3261
3305
  renderMode: 1
3262
3306
  /* Shadow */
3263
3307
  ,
3264
- shadowSupportMode: "default"
3308
+ shadowSupportMode: "reset"
3265
3309
  /* Default */
3266
3310
  ,
3267
3311
  wire: EmptyObject,
@@ -3375,6 +3419,17 @@ var LWC = (function (exports) {
3375
3419
  modComputedStyle.create(vnode);
3376
3420
  }
3377
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
+
3378
3433
  function fallbackElmHook(elm, vnode) {
3379
3434
  var owner = vnode.owner;
3380
3435
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3506,6 +3561,22 @@ var LWC = (function (exports) {
3506
3561
  }
3507
3562
  }
3508
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
+
3509
3580
  function updateCustomElmHook(oldVnode, vnode) {
3510
3581
  // Attrs need to be applied to element before props
3511
3582
  // IE11 will wipe out value on radio inputs if value
@@ -3613,7 +3684,14 @@ var LWC = (function (exports) {
3613
3684
  update: updateNodeHook,
3614
3685
  insert: insertNodeHook,
3615
3686
  move: insertNodeHook,
3616
- 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
+ }
3617
3695
  };
3618
3696
  var CommentHook = {
3619
3697
  create: function create(vnode) {
@@ -3627,7 +3705,14 @@ var LWC = (function (exports) {
3627
3705
  update: updateNodeHook,
3628
3706
  insert: insertNodeHook,
3629
3707
  move: insertNodeHook,
3630
- 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
+ }
3631
3716
  }; // insert is called after update, which is used somewhere else (via a module)
3632
3717
  // to mark the vm as inserted, that means we cannot use update as the main channel
3633
3718
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3661,6 +3746,34 @@ var LWC = (function (exports) {
3661
3746
  remove: function remove(vnode, parentNode) {
3662
3747
  removeNodeHook(vnode, parentNode);
3663
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
+ }
3664
3777
  }
3665
3778
  };
3666
3779
  var CustomElementHook = {
@@ -3740,6 +3853,36 @@ var LWC = (function (exports) {
3740
3853
  // will take care of disconnecting any child VM attached to its shadow as well.
3741
3854
  removeVM(vm);
3742
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);
3743
3886
  }
3744
3887
  };
3745
3888
 
@@ -3867,7 +4010,7 @@ var LWC = (function (exports) {
3867
4010
  next = iterator.next();
3868
4011
  last = next.done; // template factory logic based on the previous collected value
3869
4012
 
3870
- var vnode = factory(value, j, j === 0, last);
4013
+ var vnode = factory(value, j, j === 0, last === true);
3871
4014
 
3872
4015
  if (isArray$1(vnode)) {
3873
4016
  ArrayPush$1.apply(list, vnode);
@@ -4081,24 +4224,48 @@ var LWC = (function (exports) {
4081
4224
  markAsDynamicChildren(vnodes);
4082
4225
  return vnodes;
4083
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
+ */
4084
4233
 
4085
- var api = /*#__PURE__*/Object.freeze({
4086
- __proto__: null,
4087
- h: h,
4088
- ti: ti,
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;
4246
+ } // [s]anitize [h]tml [c]ontent
4247
+
4248
+
4249
+ function shc(content) {
4250
+ return sanitizeHtmlContentHook(content);
4251
+ }
4252
+
4253
+ var api = freeze({
4089
4254
  s: s,
4255
+ h: h,
4090
4256
  c: c,
4091
4257
  i: i,
4092
4258
  f: f,
4093
4259
  t: t,
4094
- co: co,
4095
4260
  d: d,
4096
4261
  b: b,
4097
4262
  k: k,
4263
+ co: co,
4264
+ dc: dc,
4265
+ ti: ti,
4098
4266
  gid: gid,
4099
4267
  fid: fid,
4100
- dc: dc,
4101
- sc: sc
4268
+ shc: shc
4102
4269
  });
4103
4270
  /*
4104
4271
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4112,12 +4279,12 @@ var LWC = (function (exports) {
4112
4279
  }
4113
4280
 
4114
4281
  function createInlineStyleVNode(content) {
4115
- return h('style', {
4282
+ return api.h('style', {
4116
4283
  key: 'style',
4117
4284
  attrs: {
4118
4285
  type: 'text/css'
4119
4286
  }
4120
- }, [t(content)]);
4287
+ }, [api.t(content)]);
4121
4288
  }
4122
4289
 
4123
4290
  function updateStylesheetToken(vm, template) {
@@ -4178,8 +4345,8 @@ var LWC = (function (exports) {
4178
4345
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4179
4346
  var content = [];
4180
4347
 
4181
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4182
- var stylesheet = stylesheets[_i14];
4348
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4349
+ var stylesheet = stylesheets[_i16];
4183
4350
 
4184
4351
  if (isArray$1(stylesheet)) {
4185
4352
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4249,10 +4416,13 @@ var LWC = (function (exports) {
4249
4416
  && shadowMode === 1
4250
4417
  /* Synthetic */
4251
4418
  ) {
4252
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4253
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4419
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4420
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4254
4421
  }
4255
- } 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.
4256
4426
  // native shadow or light DOM, SSR
4257
4427
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4258
4428
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4261,12 +4431,12 @@ var LWC = (function (exports) {
4261
4431
  var root = getNearestNativeShadowComponent(vm);
4262
4432
  var isGlobal = isNull(root);
4263
4433
 
4264
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4434
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4265
4435
  if (isGlobal) {
4266
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4436
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4267
4437
  } else {
4268
4438
  // local level
4269
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4439
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4270
4440
  }
4271
4441
  }
4272
4442
  }
@@ -4451,8 +4621,8 @@ var LWC = (function (exports) {
4451
4621
  var stylesheets = template.stylesheets;
4452
4622
 
4453
4623
  if (!isUndefined$1(stylesheets)) {
4454
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4455
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4624
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4625
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4456
4626
  return true;
4457
4627
  }
4458
4628
  }
@@ -4653,8 +4823,8 @@ var LWC = (function (exports) {
4653
4823
 
4654
4824
  function register(service) {
4655
4825
 
4656
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4657
- var hookName = hooks[_i18];
4826
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4827
+ var hookName = hooks[_i20];
4658
4828
 
4659
4829
  if (hookName in service) {
4660
4830
  var l = Services[hookName];
@@ -4674,8 +4844,8 @@ var LWC = (function (exports) {
4674
4844
  def = vm.def,
4675
4845
  context = vm.context;
4676
4846
 
4677
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4678
- 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);
4679
4849
  }
4680
4850
  }
4681
4851
  /*
@@ -4728,6 +4898,12 @@ var LWC = (function (exports) {
4728
4898
  , vm);
4729
4899
  }
4730
4900
 
4901
+ function hydrateRootElement(elm) {
4902
+ var vm = getAssociatedVM(elm);
4903
+ runConnectedCallback(vm);
4904
+ hydrateVM(vm);
4905
+ }
4906
+
4731
4907
  function disconnectRootElement(elm) {
4732
4908
  var vm = getAssociatedVM(elm);
4733
4909
  resetComponentStateWhenRemoved(vm);
@@ -4735,6 +4911,10 @@ var LWC = (function (exports) {
4735
4911
 
4736
4912
  function appendVM(vm) {
4737
4913
  rehydrate(vm);
4914
+ }
4915
+
4916
+ function hydrateVM(vm) {
4917
+ hydrate(vm);
4738
4918
  } // just in case the component comes back, with this we guarantee re-rendering it
4739
4919
  // while preventing any attempt to rehydration until after reinsertion.
4740
4920
 
@@ -4919,6 +5099,22 @@ var LWC = (function (exports) {
4919
5099
  }
4920
5100
  }
4921
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
+
4922
5118
  function patchShadowRoot(vm, newCh) {
4923
5119
  var oldCh = vm.children; // caching the new children collection
4924
5120
 
@@ -4995,19 +5191,19 @@ var LWC = (function (exports) {
4995
5191
  });
4996
5192
  rehydrateQueue = []; // reset to a new queue
4997
5193
 
4998
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
4999
- var vm = vms[_i20];
5194
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5195
+ var vm = vms[_i22];
5000
5196
 
5001
5197
  try {
5002
5198
  rehydrate(vm);
5003
5199
  } catch (error) {
5004
- if (_i20 + 1 < _len7) {
5200
+ if (_i22 + 1 < _len7) {
5005
5201
  // pieces of the queue are still pending to be rehydrated, those should have priority
5006
5202
  if (rehydrateQueue.length === 0) {
5007
5203
  addCallbackToNextTick(flushRehydrationQueue);
5008
5204
  }
5009
5205
 
5010
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5206
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5011
5207
  } // we need to end the measure before throwing.
5012
5208
 
5013
5209
 
@@ -5106,8 +5302,8 @@ var LWC = (function (exports) {
5106
5302
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5107
5303
  // inserted in reserved order.
5108
5304
 
5109
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5110
- 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:
5111
5307
  // * when there is an error during the construction phase, and an error
5112
5308
  // boundary picks it, there is a possibility that the VCustomElement
5113
5309
  // is not properly initialized, and therefore is should be ignored.
@@ -5141,8 +5337,8 @@ var LWC = (function (exports) {
5141
5337
 
5142
5338
 
5143
5339
  function recursivelyDisconnectChildren(vnodes) {
5144
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5145
- var vnode = vnodes[_i22];
5340
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5341
+ var vnode = vnodes[_i24];
5146
5342
 
5147
5343
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5148
5344
  // vnode is a VElement with children
@@ -5166,8 +5362,8 @@ var LWC = (function (exports) {
5166
5362
  renderer = vm.renderer;
5167
5363
  var rootNode = getRenderRoot(vm);
5168
5364
 
5169
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5170
- var child = children[_i23];
5365
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5366
+ var child = children[_i25];
5171
5367
 
5172
5368
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5173
5369
  renderer.remove(child.elm, rootNode);
@@ -5212,8 +5408,8 @@ var LWC = (function (exports) {
5212
5408
  var oldSlots = vm.cmpSlots;
5213
5409
  var cmpSlots = vm.cmpSlots = create(null);
5214
5410
 
5215
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5216
- var vnode = children[_i24];
5411
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5412
+ var vnode = children[_i26];
5217
5413
 
5218
5414
  if (isNull(vnode)) {
5219
5415
  continue;
@@ -5243,8 +5439,8 @@ var LWC = (function (exports) {
5243
5439
  return;
5244
5440
  }
5245
5441
 
5246
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5247
- var key = oldKeys[_i25];
5442
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5443
+ var key = oldKeys[_i27];
5248
5444
 
5249
5445
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5250
5446
  markComponentAsDirty(vm);
@@ -5583,8 +5779,8 @@ var LWC = (function (exports) {
5583
5779
  function connectWireAdapters(vm) {
5584
5780
  var wiredConnecting = vm.context.wiredConnecting;
5585
5781
 
5586
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5587
- wiredConnecting[_i26]();
5782
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5783
+ wiredConnecting[_i28]();
5588
5784
  }
5589
5785
  }
5590
5786
 
@@ -5592,8 +5788,8 @@ var LWC = (function (exports) {
5592
5788
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5593
5789
  runWithBoundaryProtection(vm, vm, noop, function () {
5594
5790
  // job
5595
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5596
- wiredDisconnecting[_i27]();
5791
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5792
+ wiredDisconnecting[_i29]();
5597
5793
  }
5598
5794
  }, noop);
5599
5795
  }
@@ -5662,7 +5858,22 @@ var LWC = (function (exports) {
5662
5858
 
5663
5859
  return reactiveMembrane.getReadOnlyProxy(obj);
5664
5860
  }
5665
- /* version: 2.5.4 */
5861
+ /*
5862
+ * Copyright (c) 2018, salesforce.com, inc.
5863
+ * All rights reserved.
5864
+ * SPDX-License-Identifier: MIT
5865
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5866
+ */
5867
+
5868
+
5869
+ var hooksAreSet = false;
5870
+
5871
+ function setHooks(hooks) {
5872
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5873
+ hooksAreSet = true;
5874
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5875
+ }
5876
+ /* version: 2.5.8 */
5666
5877
 
5667
5878
  /*
5668
5879
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5674,8 +5885,11 @@ var LWC = (function (exports) {
5674
5885
 
5675
5886
  var globalStylesheets = create(null);
5676
5887
 
5677
- var globalStylesheetsParentElement = document.head || document.body || document;
5678
- var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
5888
+ var globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
5889
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
5890
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
5891
+
5892
+ var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
5679
5893
  var styleElements = create(null);
5680
5894
  var styleSheets = create(null);
5681
5895
  var nodesToStyleSheets = new WeakMap();
@@ -5804,8 +6018,19 @@ var LWC = (function (exports) {
5804
6018
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5805
6019
  }
5806
6020
 
6021
+ var isHydrating = false;
6022
+
6023
+ function setIsHydrating(v) {
6024
+ isHydrating = v;
6025
+ }
6026
+
5807
6027
  var renderer = {
5808
6028
  ssr: false,
6029
+
6030
+ get isHydrating() {
6031
+ return isHydrating;
6032
+ },
6033
+
5809
6034
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5810
6035
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5811
6036
  createElement: function createElement(tagName, namespace) {
@@ -5827,6 +6052,10 @@ var LWC = (function (exports) {
5827
6052
  return node.nextSibling;
5828
6053
  },
5829
6054
  attachShadow: function attachShadow(element, options) {
6055
+ if (isHydrating) {
6056
+ return element.shadowRoot;
6057
+ }
6058
+
5830
6059
  return element.attachShadow(options);
5831
6060
  },
5832
6061
  setText: function setText(node, content) {
@@ -5931,71 +6160,6 @@ var LWC = (function (exports) {
5931
6160
  getCustomElement: getCustomElement,
5932
6161
  HTMLElement: HTMLElementConstructor
5933
6162
  };
5934
- /*
5935
- * Copyright (c) 2018, salesforce.com, inc.
5936
- * All rights reserved.
5937
- * SPDX-License-Identifier: MIT
5938
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5939
- */
5940
-
5941
- /**
5942
- * This function builds a Web Component class from a LWC constructor so it can be
5943
- * registered as a new element via customElements.define() at any given time.
5944
- *
5945
- * @deprecated since version 1.3.11
5946
- *
5947
- * @example
5948
- * ```
5949
- * import { buildCustomElementConstructor } from 'lwc';
5950
- * import Foo from 'ns/foo';
5951
- * const WC = buildCustomElementConstructor(Foo);
5952
- * customElements.define('x-foo', WC);
5953
- * const elm = document.createElement('x-foo');
5954
- * ```
5955
- */
5956
-
5957
- function deprecatedBuildCustomElementConstructor(Ctor) {
5958
-
5959
- return Ctor.CustomElementConstructor;
5960
- }
5961
-
5962
- function buildCustomElementConstructor(Ctor) {
5963
- var def = getComponentInternalDef(Ctor);
5964
- return /*#__PURE__*/function (_def$bridge) {
5965
- _inherits(_class, _def$bridge);
5966
-
5967
- var _super8 = _createSuper(_class);
5968
-
5969
- function _class() {
5970
- var _this6;
5971
-
5972
- _classCallCheck(this, _class);
5973
-
5974
- _this6 = _super8.call(this);
5975
- createVM(_assertThisInitialized(_this6), def, {
5976
- mode: 'open',
5977
- owner: null,
5978
- tagName: _this6.tagName,
5979
- renderer: renderer
5980
- });
5981
- return _this6;
5982
- }
5983
-
5984
- _createClass(_class, [{
5985
- key: "connectedCallback",
5986
- value: function connectedCallback() {
5987
- connectRootElement(this);
5988
- }
5989
- }, {
5990
- key: "disconnectedCallback",
5991
- value: function disconnectedCallback() {
5992
- disconnectRootElement(this);
5993
- }
5994
- }]);
5995
-
5996
- return _class;
5997
- }(def.bridge);
5998
- }
5999
6163
  /*
6000
6164
  * Copyright (c) 2018, salesforce.com, inc.
6001
6165
  * All rights reserved.
@@ -6005,7 +6169,6 @@ var LWC = (function (exports) {
6005
6169
  // TODO [#2472]: Remove this workaround when appropriate.
6006
6170
  // eslint-disable-next-line lwc-internal/no-global-node
6007
6171
 
6008
-
6009
6172
  var _Node$1 = Node;
6010
6173
  var ConnectingSlot = new WeakMap();
6011
6174
  var DisconnectingSlot = new WeakMap();
@@ -6112,6 +6275,138 @@ var LWC = (function (exports) {
6112
6275
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6113
6276
  */
6114
6277
 
6278
+
6279
+ function hydrateComponent(element, Ctor) {
6280
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6281
+
6282
+ if (!isFunction$1(Ctor)) {
6283
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6284
+ }
6285
+
6286
+ if (!isObject(props) || isNull(props)) {
6287
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6288
+ }
6289
+
6290
+ var def = getComponentInternalDef(Ctor);
6291
+
6292
+ try {
6293
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6294
+ // and uses the same algo to create the stylesheets as in SSR.
6295
+ setIsHydrating(true);
6296
+ createVM(element, def, {
6297
+ mode: 'open',
6298
+ owner: null,
6299
+ renderer: renderer,
6300
+ tagName: element.tagName.toLowerCase()
6301
+ });
6302
+
6303
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6304
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6305
+ key = _Object$entries2$_i[0],
6306
+ value = _Object$entries2$_i[1];
6307
+
6308
+ element[key] = value;
6309
+ }
6310
+
6311
+ hydrateRootElement(element); // set it back since now we finished hydration.
6312
+
6313
+ setIsHydrating(false);
6314
+ } catch (e) {
6315
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6316
+ // the client generated DOM.
6317
+
6318
+ /* eslint-disable-next-line no-console */
6319
+ console.error('Recovering from error while hydrating: ', e);
6320
+ setIsHydrating(false);
6321
+ var newElem = createElement(element.tagName, {
6322
+ is: Ctor,
6323
+ mode: 'open'
6324
+ });
6325
+
6326
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6327
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6328
+ _key3 = _Object$entries3$_i[0],
6329
+ _value2 = _Object$entries3$_i[1];
6330
+
6331
+ newElem[_key3] = _value2;
6332
+ }
6333
+
6334
+ element.parentNode.replaceChild(newElem, element);
6335
+ }
6336
+ }
6337
+ /*
6338
+ * Copyright (c) 2018, salesforce.com, inc.
6339
+ * All rights reserved.
6340
+ * SPDX-License-Identifier: MIT
6341
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6342
+ */
6343
+
6344
+ /**
6345
+ * This function builds a Web Component class from a LWC constructor so it can be
6346
+ * registered as a new element via customElements.define() at any given time.
6347
+ *
6348
+ * @deprecated since version 1.3.11
6349
+ *
6350
+ * @example
6351
+ * ```
6352
+ * import { buildCustomElementConstructor } from 'lwc';
6353
+ * import Foo from 'ns/foo';
6354
+ * const WC = buildCustomElementConstructor(Foo);
6355
+ * customElements.define('x-foo', WC);
6356
+ * const elm = document.createElement('x-foo');
6357
+ * ```
6358
+ */
6359
+
6360
+
6361
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6362
+
6363
+ return Ctor.CustomElementConstructor;
6364
+ }
6365
+
6366
+ function buildCustomElementConstructor(Ctor) {
6367
+ var def = getComponentInternalDef(Ctor);
6368
+ return /*#__PURE__*/function (_def$bridge) {
6369
+ _inherits(_class, _def$bridge);
6370
+
6371
+ var _super8 = _createSuper(_class);
6372
+
6373
+ function _class() {
6374
+ var _this6;
6375
+
6376
+ _classCallCheck(this, _class);
6377
+
6378
+ _this6 = _super8.call(this);
6379
+ createVM(_assertThisInitialized(_this6), def, {
6380
+ mode: 'open',
6381
+ owner: null,
6382
+ tagName: _this6.tagName,
6383
+ renderer: renderer
6384
+ });
6385
+ return _this6;
6386
+ }
6387
+
6388
+ _createClass(_class, [{
6389
+ key: "connectedCallback",
6390
+ value: function connectedCallback() {
6391
+ connectRootElement(this);
6392
+ }
6393
+ }, {
6394
+ key: "disconnectedCallback",
6395
+ value: function disconnectedCallback() {
6396
+ disconnectRootElement(this);
6397
+ }
6398
+ }]);
6399
+
6400
+ return _class;
6401
+ }(def.bridge);
6402
+ }
6403
+ /*
6404
+ * Copyright (c) 2018, salesforce.com, inc.
6405
+ * All rights reserved.
6406
+ * SPDX-License-Identifier: MIT
6407
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6408
+ */
6409
+
6115
6410
  /**
6116
6411
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6117
6412
  * This API is subject to change or being removed.
@@ -6210,7 +6505,7 @@ var LWC = (function (exports) {
6210
6505
  });
6211
6506
  freeze(LightningElement);
6212
6507
  seal(LightningElement.prototype);
6213
- /* version: 2.5.4 */
6508
+ /* version: 2.5.8 */
6214
6509
 
6215
6510
  exports.LightningElement = LightningElement;
6216
6511
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6220,6 +6515,7 @@ var LWC = (function (exports) {
6220
6515
  exports.createElement = createElement;
6221
6516
  exports.getComponentConstructor = getComponentConstructor;
6222
6517
  exports.getComponentDef = getComponentDef;
6518
+ exports.hydrateComponent = hydrateComponent;
6223
6519
  exports.isComponentConstructor = isComponentConstructor;
6224
6520
  exports.isNodeFromTemplate = isNodeFromTemplate;
6225
6521
  exports.readonly = readonly;
@@ -6230,6 +6526,7 @@ var LWC = (function (exports) {
6230
6526
  exports.sanitizeAttribute = sanitizeAttribute;
6231
6527
  exports.setFeatureFlag = setFeatureFlag;
6232
6528
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6529
+ exports.setHooks = setHooks;
6233
6530
  exports.swapComponent = swapComponent;
6234
6531
  exports.swapStyle = swapStyle;
6235
6532
  exports.swapTemplate = swapTemplate;