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
@@ -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.4 */
347
+ /** version: 2.5.8 */
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.4 */
519
+ /** version: 2.5.8 */
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
 
@@ -2848,15 +2893,14 @@
2848
2893
  return tpl;
2849
2894
  }
2850
2895
  /**
2851
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
2852
- * Service and other similar libraries to sanitize vulnerable attributes.
2853
- * This API is subject to change or being removed.
2896
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
2897
+ * libraries to sanitize vulnerable attributes.
2854
2898
  */
2855
2899
 
2856
2900
 
2857
2901
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
2858
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
2859
- // when ran off-core this function becomes a noop and returns the user authored value.
2902
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
2903
+ // ran off-core this function becomes a noop and returns the user authored value.
2860
2904
  return attrValue;
2861
2905
  }
2862
2906
  /*
@@ -3264,7 +3308,7 @@
3264
3308
  renderMode: 1
3265
3309
  /* Shadow */
3266
3310
  ,
3267
- shadowSupportMode: "default"
3311
+ shadowSupportMode: "reset"
3268
3312
  /* Default */
3269
3313
  ,
3270
3314
  wire: EmptyObject,
@@ -3378,6 +3422,17 @@
3378
3422
  modComputedStyle.create(vnode);
3379
3423
  }
3380
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
+
3381
3436
  function fallbackElmHook(elm, vnode) {
3382
3437
  var owner = vnode.owner;
3383
3438
  setScopeTokenClassIfNecessary(elm, owner);
@@ -3509,6 +3564,22 @@
3509
3564
  }
3510
3565
  }
3511
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
+
3512
3583
  function updateCustomElmHook(oldVnode, vnode) {
3513
3584
  // Attrs need to be applied to element before props
3514
3585
  // IE11 will wipe out value on radio inputs if value
@@ -3616,7 +3687,14 @@
3616
3687
  update: updateNodeHook,
3617
3688
  insert: insertNodeHook,
3618
3689
  move: insertNodeHook,
3619
- 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
+ }
3620
3698
  };
3621
3699
  var CommentHook = {
3622
3700
  create: function create(vnode) {
@@ -3630,7 +3708,14 @@
3630
3708
  update: updateNodeHook,
3631
3709
  insert: insertNodeHook,
3632
3710
  move: insertNodeHook,
3633
- 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
+ }
3634
3719
  }; // insert is called after update, which is used somewhere else (via a module)
3635
3720
  // to mark the vm as inserted, that means we cannot use update as the main channel
3636
3721
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3664,6 +3749,34 @@
3664
3749
  remove: function remove(vnode, parentNode) {
3665
3750
  removeNodeHook(vnode, parentNode);
3666
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
+ }
3667
3780
  }
3668
3781
  };
3669
3782
  var CustomElementHook = {
@@ -3743,6 +3856,36 @@
3743
3856
  // will take care of disconnecting any child VM attached to its shadow as well.
3744
3857
  removeVM(vm);
3745
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);
3746
3889
  }
3747
3890
  };
3748
3891
 
@@ -3870,7 +4013,7 @@
3870
4013
  next = iterator.next();
3871
4014
  last = next.done; // template factory logic based on the previous collected value
3872
4015
 
3873
- var vnode = factory(value, j, j === 0, last);
4016
+ var vnode = factory(value, j, j === 0, last === true);
3874
4017
 
3875
4018
  if (isArray$1(vnode)) {
3876
4019
  ArrayPush$1.apply(list, vnode);
@@ -4084,24 +4227,48 @@
4084
4227
  markAsDynamicChildren(vnodes);
4085
4228
  return vnodes;
4086
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
+ */
4087
4236
 
4088
- var api = /*#__PURE__*/Object.freeze({
4089
- __proto__: null,
4090
- h: h,
4091
- ti: ti,
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;
4249
+ } // [s]anitize [h]tml [c]ontent
4250
+
4251
+
4252
+ function shc(content) {
4253
+ return sanitizeHtmlContentHook(content);
4254
+ }
4255
+
4256
+ var api = freeze({
4092
4257
  s: s,
4258
+ h: h,
4093
4259
  c: c,
4094
4260
  i: i,
4095
4261
  f: f,
4096
4262
  t: t,
4097
- co: co,
4098
4263
  d: d,
4099
4264
  b: b,
4100
4265
  k: k,
4266
+ co: co,
4267
+ dc: dc,
4268
+ ti: ti,
4101
4269
  gid: gid,
4102
4270
  fid: fid,
4103
- dc: dc,
4104
- sc: sc
4271
+ shc: shc
4105
4272
  });
4106
4273
  /*
4107
4274
  * Copyright (c) 2018, salesforce.com, inc.
@@ -4115,12 +4282,12 @@
4115
4282
  }
4116
4283
 
4117
4284
  function createInlineStyleVNode(content) {
4118
- return h('style', {
4285
+ return api.h('style', {
4119
4286
  key: 'style',
4120
4287
  attrs: {
4121
4288
  type: 'text/css'
4122
4289
  }
4123
- }, [t(content)]);
4290
+ }, [api.t(content)]);
4124
4291
  }
4125
4292
 
4126
4293
  function updateStylesheetToken(vm, template) {
@@ -4181,8 +4348,8 @@
4181
4348
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
4182
4349
  var content = [];
4183
4350
 
4184
- for (var _i14 = 0; _i14 < stylesheets.length; _i14++) {
4185
- var stylesheet = stylesheets[_i14];
4351
+ for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4352
+ var stylesheet = stylesheets[_i16];
4186
4353
 
4187
4354
  if (isArray$1(stylesheet)) {
4188
4355
  ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
@@ -4252,10 +4419,13 @@
4252
4419
  && shadowMode === 1
4253
4420
  /* Synthetic */
4254
4421
  ) {
4255
- for (var _i15 = 0; _i15 < stylesheets.length; _i15++) {
4256
- renderer.insertGlobalStylesheet(stylesheets[_i15]);
4422
+ for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4423
+ renderer.insertGlobalStylesheet(stylesheets[_i17]);
4257
4424
  }
4258
- } 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.
4259
4429
  // native shadow or light DOM, SSR
4260
4430
  var combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4261
4431
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4264,12 +4434,12 @@
4264
4434
  var root = getNearestNativeShadowComponent(vm);
4265
4435
  var isGlobal = isNull(root);
4266
4436
 
4267
- for (var _i16 = 0; _i16 < stylesheets.length; _i16++) {
4437
+ for (var _i18 = 0; _i18 < stylesheets.length; _i18++) {
4268
4438
  if (isGlobal) {
4269
- renderer.insertGlobalStylesheet(stylesheets[_i16]);
4439
+ renderer.insertGlobalStylesheet(stylesheets[_i18]);
4270
4440
  } else {
4271
4441
  // local level
4272
- renderer.insertStylesheet(stylesheets[_i16], root.cmpRoot);
4442
+ renderer.insertStylesheet(stylesheets[_i18], root.cmpRoot);
4273
4443
  }
4274
4444
  }
4275
4445
  }
@@ -4454,8 +4624,8 @@
4454
4624
  var stylesheets = template.stylesheets;
4455
4625
 
4456
4626
  if (!isUndefined$1(stylesheets)) {
4457
- for (var _i17 = 0; _i17 < stylesheets.length; _i17++) {
4458
- if (isTrue(stylesheets[_i17][KEY__SCOPED_CSS])) {
4627
+ for (var _i19 = 0; _i19 < stylesheets.length; _i19++) {
4628
+ if (isTrue(stylesheets[_i19][KEY__SCOPED_CSS])) {
4459
4629
  return true;
4460
4630
  }
4461
4631
  }
@@ -4656,8 +4826,8 @@
4656
4826
 
4657
4827
  function register(service) {
4658
4828
 
4659
- for (var _i18 = 0; _i18 < hooks.length; ++_i18) {
4660
- var hookName = hooks[_i18];
4829
+ for (var _i20 = 0; _i20 < hooks.length; ++_i20) {
4830
+ var hookName = hooks[_i20];
4661
4831
 
4662
4832
  if (hookName in service) {
4663
4833
  var l = Services[hookName];
@@ -4677,8 +4847,8 @@
4677
4847
  def = vm.def,
4678
4848
  context = vm.context;
4679
4849
 
4680
- for (var _i19 = 0, _len6 = cbs.length; _i19 < _len6; ++_i19) {
4681
- 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);
4682
4852
  }
4683
4853
  }
4684
4854
  /*
@@ -4731,6 +4901,12 @@
4731
4901
  , vm);
4732
4902
  }
4733
4903
 
4904
+ function hydrateRootElement(elm) {
4905
+ var vm = getAssociatedVM(elm);
4906
+ runConnectedCallback(vm);
4907
+ hydrateVM(vm);
4908
+ }
4909
+
4734
4910
  function disconnectRootElement(elm) {
4735
4911
  var vm = getAssociatedVM(elm);
4736
4912
  resetComponentStateWhenRemoved(vm);
@@ -4738,6 +4914,10 @@
4738
4914
 
4739
4915
  function appendVM(vm) {
4740
4916
  rehydrate(vm);
4917
+ }
4918
+
4919
+ function hydrateVM(vm) {
4920
+ hydrate(vm);
4741
4921
  } // just in case the component comes back, with this we guarantee re-rendering it
4742
4922
  // while preventing any attempt to rehydration until after reinsertion.
4743
4923
 
@@ -4922,6 +5102,22 @@
4922
5102
  }
4923
5103
  }
4924
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
+
4925
5121
  function patchShadowRoot(vm, newCh) {
4926
5122
  var oldCh = vm.children; // caching the new children collection
4927
5123
 
@@ -4998,19 +5194,19 @@
4998
5194
  });
4999
5195
  rehydrateQueue = []; // reset to a new queue
5000
5196
 
5001
- for (var _i20 = 0, _len7 = vms.length; _i20 < _len7; _i20 += 1) {
5002
- var vm = vms[_i20];
5197
+ for (var _i22 = 0, _len7 = vms.length; _i22 < _len7; _i22 += 1) {
5198
+ var vm = vms[_i22];
5003
5199
 
5004
5200
  try {
5005
5201
  rehydrate(vm);
5006
5202
  } catch (error) {
5007
- if (_i20 + 1 < _len7) {
5203
+ if (_i22 + 1 < _len7) {
5008
5204
  // pieces of the queue are still pending to be rehydrated, those should have priority
5009
5205
  if (rehydrateQueue.length === 0) {
5010
5206
  addCallbackToNextTick(flushRehydrationQueue);
5011
5207
  }
5012
5208
 
5013
- ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i20 + 1));
5209
+ ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, _i22 + 1));
5014
5210
  } // we need to end the measure before throwing.
5015
5211
 
5016
5212
 
@@ -5109,8 +5305,8 @@
5109
5305
  var vCustomElementCollection = vm.velements; // Reporting disconnection for every child in inverse order since they are
5110
5306
  // inserted in reserved order.
5111
5307
 
5112
- for (var _i21 = vCustomElementCollection.length - 1; _i21 >= 0; _i21 -= 1) {
5113
- 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:
5114
5310
  // * when there is an error during the construction phase, and an error
5115
5311
  // boundary picks it, there is a possibility that the VCustomElement
5116
5312
  // is not properly initialized, and therefore is should be ignored.
@@ -5144,8 +5340,8 @@
5144
5340
 
5145
5341
 
5146
5342
  function recursivelyDisconnectChildren(vnodes) {
5147
- for (var _i22 = 0, _len8 = vnodes.length; _i22 < _len8; _i22 += 1) {
5148
- var vnode = vnodes[_i22];
5343
+ for (var _i24 = 0, _len8 = vnodes.length; _i24 < _len8; _i24 += 1) {
5344
+ var vnode = vnodes[_i24];
5149
5345
 
5150
5346
  if (!isNull(vnode) && isArray$1(vnode.children) && !isUndefined$1(vnode.elm)) {
5151
5347
  // vnode is a VElement with children
@@ -5169,8 +5365,8 @@
5169
5365
  renderer = vm.renderer;
5170
5366
  var rootNode = getRenderRoot(vm);
5171
5367
 
5172
- for (var _i23 = 0, _len9 = children.length; _i23 < _len9; _i23++) {
5173
- var child = children[_i23];
5368
+ for (var _i25 = 0, _len9 = children.length; _i25 < _len9; _i25++) {
5369
+ var child = children[_i25];
5174
5370
 
5175
5371
  if (!isNull(child) && !isUndefined$1(child.elm)) {
5176
5372
  renderer.remove(child.elm, rootNode);
@@ -5215,8 +5411,8 @@
5215
5411
  var oldSlots = vm.cmpSlots;
5216
5412
  var cmpSlots = vm.cmpSlots = create(null);
5217
5413
 
5218
- for (var _i24 = 0, _len10 = children.length; _i24 < _len10; _i24 += 1) {
5219
- var vnode = children[_i24];
5414
+ for (var _i26 = 0, _len10 = children.length; _i26 < _len10; _i26 += 1) {
5415
+ var vnode = children[_i26];
5220
5416
 
5221
5417
  if (isNull(vnode)) {
5222
5418
  continue;
@@ -5246,8 +5442,8 @@
5246
5442
  return;
5247
5443
  }
5248
5444
 
5249
- for (var _i25 = 0, _len11 = oldKeys.length; _i25 < _len11; _i25 += 1) {
5250
- var key = oldKeys[_i25];
5445
+ for (var _i27 = 0, _len11 = oldKeys.length; _i27 < _len11; _i27 += 1) {
5446
+ var key = oldKeys[_i27];
5251
5447
 
5252
5448
  if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
5253
5449
  markComponentAsDirty(vm);
@@ -5586,8 +5782,8 @@
5586
5782
  function connectWireAdapters(vm) {
5587
5783
  var wiredConnecting = vm.context.wiredConnecting;
5588
5784
 
5589
- for (var _i26 = 0, _len12 = wiredConnecting.length; _i26 < _len12; _i26 += 1) {
5590
- wiredConnecting[_i26]();
5785
+ for (var _i28 = 0, _len12 = wiredConnecting.length; _i28 < _len12; _i28 += 1) {
5786
+ wiredConnecting[_i28]();
5591
5787
  }
5592
5788
  }
5593
5789
 
@@ -5595,8 +5791,8 @@
5595
5791
  var wiredDisconnecting = vm.context.wiredDisconnecting;
5596
5792
  runWithBoundaryProtection(vm, vm, noop, function () {
5597
5793
  // job
5598
- for (var _i27 = 0, _len13 = wiredDisconnecting.length; _i27 < _len13; _i27 += 1) {
5599
- wiredDisconnecting[_i27]();
5794
+ for (var _i29 = 0, _len13 = wiredDisconnecting.length; _i29 < _len13; _i29 += 1) {
5795
+ wiredDisconnecting[_i29]();
5600
5796
  }
5601
5797
  }, noop);
5602
5798
  }
@@ -5665,7 +5861,22 @@
5665
5861
 
5666
5862
  return reactiveMembrane.getReadOnlyProxy(obj);
5667
5863
  }
5668
- /* version: 2.5.4 */
5864
+ /*
5865
+ * Copyright (c) 2018, salesforce.com, inc.
5866
+ * All rights reserved.
5867
+ * SPDX-License-Identifier: MIT
5868
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5869
+ */
5870
+
5871
+
5872
+ var hooksAreSet = false;
5873
+
5874
+ function setHooks(hooks) {
5875
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5876
+ hooksAreSet = true;
5877
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5878
+ }
5879
+ /* version: 2.5.8 */
5669
5880
 
5670
5881
  /*
5671
5882
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5677,8 +5888,11 @@
5677
5888
 
5678
5889
  var globalStylesheets = create(null);
5679
5890
 
5680
- var globalStylesheetsParentElement = document.head || document.body || document;
5681
- var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
5891
+ var globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
5892
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
5893
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
5894
+
5895
+ var supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
5682
5896
  var styleElements = create(null);
5683
5897
  var styleSheets = create(null);
5684
5898
  var nodesToStyleSheets = new WeakMap();
@@ -5807,8 +6021,19 @@
5807
6021
  HTMLElementConstructor.prototype = HTMLElement.prototype;
5808
6022
  }
5809
6023
 
6024
+ var isHydrating = false;
6025
+
6026
+ function setIsHydrating(v) {
6027
+ isHydrating = v;
6028
+ }
6029
+
5810
6030
  var renderer = {
5811
6031
  ssr: false,
6032
+
6033
+ get isHydrating() {
6034
+ return isHydrating;
6035
+ },
6036
+
5812
6037
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
5813
6038
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
5814
6039
  createElement: function createElement(tagName, namespace) {
@@ -5830,6 +6055,10 @@
5830
6055
  return node.nextSibling;
5831
6056
  },
5832
6057
  attachShadow: function attachShadow(element, options) {
6058
+ if (isHydrating) {
6059
+ return element.shadowRoot;
6060
+ }
6061
+
5833
6062
  return element.attachShadow(options);
5834
6063
  },
5835
6064
  setText: function setText(node, content) {
@@ -5934,71 +6163,6 @@
5934
6163
  getCustomElement: getCustomElement,
5935
6164
  HTMLElement: HTMLElementConstructor
5936
6165
  };
5937
- /*
5938
- * Copyright (c) 2018, salesforce.com, inc.
5939
- * All rights reserved.
5940
- * SPDX-License-Identifier: MIT
5941
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
5942
- */
5943
-
5944
- /**
5945
- * This function builds a Web Component class from a LWC constructor so it can be
5946
- * registered as a new element via customElements.define() at any given time.
5947
- *
5948
- * @deprecated since version 1.3.11
5949
- *
5950
- * @example
5951
- * ```
5952
- * import { buildCustomElementConstructor } from 'lwc';
5953
- * import Foo from 'ns/foo';
5954
- * const WC = buildCustomElementConstructor(Foo);
5955
- * customElements.define('x-foo', WC);
5956
- * const elm = document.createElement('x-foo');
5957
- * ```
5958
- */
5959
-
5960
- function deprecatedBuildCustomElementConstructor(Ctor) {
5961
-
5962
- return Ctor.CustomElementConstructor;
5963
- }
5964
-
5965
- function buildCustomElementConstructor(Ctor) {
5966
- var def = getComponentInternalDef(Ctor);
5967
- return /*#__PURE__*/function (_def$bridge) {
5968
- _inherits(_class, _def$bridge);
5969
-
5970
- var _super8 = _createSuper(_class);
5971
-
5972
- function _class() {
5973
- var _this6;
5974
-
5975
- _classCallCheck(this, _class);
5976
-
5977
- _this6 = _super8.call(this);
5978
- createVM(_assertThisInitialized(_this6), def, {
5979
- mode: 'open',
5980
- owner: null,
5981
- tagName: _this6.tagName,
5982
- renderer: renderer
5983
- });
5984
- return _this6;
5985
- }
5986
-
5987
- _createClass(_class, [{
5988
- key: "connectedCallback",
5989
- value: function connectedCallback() {
5990
- connectRootElement(this);
5991
- }
5992
- }, {
5993
- key: "disconnectedCallback",
5994
- value: function disconnectedCallback() {
5995
- disconnectRootElement(this);
5996
- }
5997
- }]);
5998
-
5999
- return _class;
6000
- }(def.bridge);
6001
- }
6002
6166
  /*
6003
6167
  * Copyright (c) 2018, salesforce.com, inc.
6004
6168
  * All rights reserved.
@@ -6008,7 +6172,6 @@
6008
6172
  // TODO [#2472]: Remove this workaround when appropriate.
6009
6173
  // eslint-disable-next-line lwc-internal/no-global-node
6010
6174
 
6011
-
6012
6175
  var _Node$1 = Node;
6013
6176
  var ConnectingSlot = new WeakMap();
6014
6177
  var DisconnectingSlot = new WeakMap();
@@ -6115,6 +6278,138 @@
6115
6278
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6116
6279
  */
6117
6280
 
6281
+
6282
+ function hydrateComponent(element, Ctor) {
6283
+ var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6284
+
6285
+ if (!isFunction$1(Ctor)) {
6286
+ throw new TypeError("\"hydrateComponent\" expects a valid component constructor as the second parameter but instead received ".concat(Ctor, "."));
6287
+ }
6288
+
6289
+ if (!isObject(props) || isNull(props)) {
6290
+ throw new TypeError("\"hydrateComponent\" expects an object as the third parameter but instead received ".concat(props, "."));
6291
+ }
6292
+
6293
+ var def = getComponentInternalDef(Ctor);
6294
+
6295
+ try {
6296
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6297
+ // and uses the same algo to create the stylesheets as in SSR.
6298
+ setIsHydrating(true);
6299
+ createVM(element, def, {
6300
+ mode: 'open',
6301
+ owner: null,
6302
+ renderer: renderer,
6303
+ tagName: element.tagName.toLowerCase()
6304
+ });
6305
+
6306
+ for (var _i31 = 0, _Object$entries2 = Object.entries(props); _i31 < _Object$entries2.length; _i31++) {
6307
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i31], 2),
6308
+ key = _Object$entries2$_i[0],
6309
+ value = _Object$entries2$_i[1];
6310
+
6311
+ element[key] = value;
6312
+ }
6313
+
6314
+ hydrateRootElement(element); // set it back since now we finished hydration.
6315
+
6316
+ setIsHydrating(false);
6317
+ } catch (e) {
6318
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6319
+ // the client generated DOM.
6320
+
6321
+ /* eslint-disable-next-line no-console */
6322
+ console.error('Recovering from error while hydrating: ', e);
6323
+ setIsHydrating(false);
6324
+ var newElem = createElement(element.tagName, {
6325
+ is: Ctor,
6326
+ mode: 'open'
6327
+ });
6328
+
6329
+ for (var _i32 = 0, _Object$entries3 = Object.entries(props); _i32 < _Object$entries3.length; _i32++) {
6330
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i32], 2),
6331
+ _key3 = _Object$entries3$_i[0],
6332
+ _value2 = _Object$entries3$_i[1];
6333
+
6334
+ newElem[_key3] = _value2;
6335
+ }
6336
+
6337
+ element.parentNode.replaceChild(newElem, element);
6338
+ }
6339
+ }
6340
+ /*
6341
+ * Copyright (c) 2018, salesforce.com, inc.
6342
+ * All rights reserved.
6343
+ * SPDX-License-Identifier: MIT
6344
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6345
+ */
6346
+
6347
+ /**
6348
+ * This function builds a Web Component class from a LWC constructor so it can be
6349
+ * registered as a new element via customElements.define() at any given time.
6350
+ *
6351
+ * @deprecated since version 1.3.11
6352
+ *
6353
+ * @example
6354
+ * ```
6355
+ * import { buildCustomElementConstructor } from 'lwc';
6356
+ * import Foo from 'ns/foo';
6357
+ * const WC = buildCustomElementConstructor(Foo);
6358
+ * customElements.define('x-foo', WC);
6359
+ * const elm = document.createElement('x-foo');
6360
+ * ```
6361
+ */
6362
+
6363
+
6364
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6365
+
6366
+ return Ctor.CustomElementConstructor;
6367
+ }
6368
+
6369
+ function buildCustomElementConstructor(Ctor) {
6370
+ var def = getComponentInternalDef(Ctor);
6371
+ return /*#__PURE__*/function (_def$bridge) {
6372
+ _inherits(_class, _def$bridge);
6373
+
6374
+ var _super8 = _createSuper(_class);
6375
+
6376
+ function _class() {
6377
+ var _this6;
6378
+
6379
+ _classCallCheck(this, _class);
6380
+
6381
+ _this6 = _super8.call(this);
6382
+ createVM(_assertThisInitialized(_this6), def, {
6383
+ mode: 'open',
6384
+ owner: null,
6385
+ tagName: _this6.tagName,
6386
+ renderer: renderer
6387
+ });
6388
+ return _this6;
6389
+ }
6390
+
6391
+ _createClass(_class, [{
6392
+ key: "connectedCallback",
6393
+ value: function connectedCallback() {
6394
+ connectRootElement(this);
6395
+ }
6396
+ }, {
6397
+ key: "disconnectedCallback",
6398
+ value: function disconnectedCallback() {
6399
+ disconnectRootElement(this);
6400
+ }
6401
+ }]);
6402
+
6403
+ return _class;
6404
+ }(def.bridge);
6405
+ }
6406
+ /*
6407
+ * Copyright (c) 2018, salesforce.com, inc.
6408
+ * All rights reserved.
6409
+ * SPDX-License-Identifier: MIT
6410
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6411
+ */
6412
+
6118
6413
  /**
6119
6414
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6120
6415
  * This API is subject to change or being removed.
@@ -6213,7 +6508,7 @@
6213
6508
  });
6214
6509
  freeze(LightningElement);
6215
6510
  seal(LightningElement.prototype);
6216
- /* version: 2.5.4 */
6511
+ /* version: 2.5.8 */
6217
6512
 
6218
6513
  exports.LightningElement = LightningElement;
6219
6514
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6223,6 +6518,7 @@
6223
6518
  exports.createElement = createElement;
6224
6519
  exports.getComponentConstructor = getComponentConstructor;
6225
6520
  exports.getComponentDef = getComponentDef;
6521
+ exports.hydrateComponent = hydrateComponent;
6226
6522
  exports.isComponentConstructor = isComponentConstructor;
6227
6523
  exports.isNodeFromTemplate = isNodeFromTemplate;
6228
6524
  exports.readonly = readonly;
@@ -6233,6 +6529,7 @@
6233
6529
  exports.sanitizeAttribute = sanitizeAttribute;
6234
6530
  exports.setFeatureFlag = setFeatureFlag;
6235
6531
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6532
+ exports.setHooks = setHooks;
6236
6533
  exports.swapComponent = swapComponent;
6237
6534
  exports.swapStyle = swapStyle;
6238
6535
  exports.swapTemplate = swapTemplate;