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
  /* proxy-compat-disable */
8
8
 
@@ -301,7 +301,7 @@
301
301
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
302
302
  return attributeName;
303
303
  }
304
- /** version: 2.5.6 */
304
+ /** version: 2.5.10-alpha1 */
305
305
 
306
306
  /*
307
307
  * Copyright (c) 2018, salesforce.com, inc.
@@ -473,7 +473,7 @@
473
473
 
474
474
  function setFeatureFlagForTest(name, value) {
475
475
  }
476
- /** version: 2.5.6 */
476
+ /** version: 2.5.10-alpha1 */
477
477
 
478
478
  /* proxy-compat-disable */
479
479
 
@@ -515,7 +515,7 @@
515
515
  }
516
516
 
517
517
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
518
- }
518
+ } // Borrowed from Vue template compiler.
519
519
  /*
520
520
  * Copyright (c) 2019, salesforce.com, inc.
521
521
  * All rights reserved.
@@ -663,6 +663,20 @@
663
663
  return `<${StringToLowerCase.call(vm.tagName)}>`;
664
664
  } // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
665
665
 
666
+
667
+ function getComponentStack(vm) {
668
+ const stack = [];
669
+ let prefix = '';
670
+
671
+ while (!isNull(vm.owner)) {
672
+ ArrayPush$1.call(stack, prefix + getComponentTag(vm));
673
+ vm = vm.owner;
674
+ prefix += '\t';
675
+ }
676
+
677
+ return ArrayJoin.call(stack, '\n');
678
+ }
679
+
666
680
  function getErrorComponentStack(vm) {
667
681
  const wcStack = [];
668
682
  let currentVm = vm;
@@ -682,6 +696,32 @@
682
696
  */
683
697
 
684
698
 
699
+ function log(method, message, vm) {
700
+ let msg = `[LWC ${method}]: ${message}`;
701
+
702
+ if (!isUndefined$1(vm)) {
703
+ msg = `${msg}\n${getComponentStack(vm)}`;
704
+ }
705
+
706
+ try {
707
+ throw new Error(msg);
708
+ } catch (e) {
709
+ /* eslint-disable-next-line no-console */
710
+ console[method](e);
711
+ }
712
+ }
713
+
714
+ function logWarn(message, vm) {
715
+ log('warn', message, vm);
716
+ }
717
+ /*
718
+ * Copyright (c) 2018, salesforce.com, inc.
719
+ * All rights reserved.
720
+ * SPDX-License-Identifier: MIT
721
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
722
+ */
723
+
724
+
685
725
  function handleEvent(event, vnode) {
686
726
  const {
687
727
  type
@@ -2434,8 +2474,10 @@
2434
2474
  } = vm;
2435
2475
 
2436
2476
  return renderer[rendererMethod](elm);
2437
- }
2477
+ },
2438
2478
 
2479
+ configurable: true,
2480
+ enumerable: true
2439
2481
  };
2440
2482
  }
2441
2483
 
@@ -2451,8 +2493,11 @@
2451
2493
  } = vm;
2452
2494
 
2453
2495
  return renderer[queryMethod](elm, arg);
2454
- }
2496
+ },
2455
2497
 
2498
+ configurable: true,
2499
+ enumerable: true,
2500
+ writable: true
2456
2501
  };
2457
2502
  }
2458
2503
 
@@ -3303,7 +3348,7 @@
3303
3348
  renderMode: 1
3304
3349
  /* Shadow */
3305
3350
  ,
3306
- shadowSupportMode: "default"
3351
+ shadowSupportMode: "reset"
3307
3352
  /* Default */
3308
3353
  ,
3309
3354
  wire: EmptyObject,
@@ -3429,6 +3474,17 @@
3429
3474
  modComputedStyle.create(vnode);
3430
3475
  }
3431
3476
 
3477
+ function hydrateElmHook(vnode) {
3478
+ modEvents.create(vnode); // Attrs are already on the element.
3479
+ // modAttrs.create(vnode);
3480
+
3481
+ modProps.create(vnode); // Already set.
3482
+ // modStaticClassName.create(vnode);
3483
+ // modStaticStyle.create(vnode);
3484
+ // modComputedClassName.create(vnode);
3485
+ // modComputedStyle.create(vnode);
3486
+ }
3487
+
3432
3488
  function fallbackElmHook(elm, vnode) {
3433
3489
  const {
3434
3490
  owner
@@ -3578,6 +3634,22 @@
3578
3634
  }
3579
3635
  }
3580
3636
 
3637
+ function hydrateChildrenHook(elmChildren, children, vm) {
3638
+
3639
+ let elmCurrentChildIdx = 0;
3640
+
3641
+ for (let j = 0, n = children.length; j < n; j++) {
3642
+ const ch = children[j];
3643
+
3644
+ if (ch != null) {
3645
+ const childNode = elmChildren[elmCurrentChildIdx];
3646
+
3647
+ ch.hook.hydrate(ch, childNode);
3648
+ elmCurrentChildIdx++;
3649
+ }
3650
+ }
3651
+ }
3652
+
3581
3653
  function updateCustomElmHook(oldVnode, vnode) {
3582
3654
  // Attrs need to be applied to element before props
3583
3655
  // IE11 will wipe out value on radio inputs if value
@@ -3661,38 +3733,6 @@
3661
3733
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3662
3734
  */
3663
3735
 
3664
- /**
3665
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3666
- * libraries to sanitize HTML content. This hook process the content passed via the template to
3667
- * lwc:inner-html directive.
3668
- * It is meant to be overridden with setSanitizeHtmlContentHook
3669
- */
3670
-
3671
-
3672
- let sanitizeHtmlContentHook = () => {
3673
- // locker-service patches this function during runtime to sanitize HTML content.
3674
- throw new Error('sanitizeHtmlContent hook must be implemented.');
3675
- };
3676
- /**
3677
- * Sets the sanitizeHtmlContentHook.
3678
- *
3679
- * @param newHookImpl
3680
- * @returns oldHookImplementation.
3681
- */
3682
-
3683
-
3684
- function setSanitizeHtmlContentHook(newHookImpl) {
3685
- const currentHook = sanitizeHtmlContentHook;
3686
- sanitizeHtmlContentHook = newHookImpl;
3687
- return currentHook;
3688
- }
3689
- /*
3690
- * Copyright (c) 2018, salesforce.com, inc.
3691
- * All rights reserved.
3692
- * SPDX-License-Identifier: MIT
3693
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3694
- */
3695
-
3696
3736
 
3697
3737
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
3698
3738
  const SymbolIterator = Symbol.iterator;
@@ -3711,7 +3751,14 @@
3711
3751
  update: updateNodeHook,
3712
3752
  insert: insertNodeHook,
3713
3753
  move: insertNodeHook,
3714
- remove: removeNodeHook
3754
+ remove: removeNodeHook,
3755
+ hydrate: (vNode, node) => {
3756
+ var _a;
3757
+
3758
+
3759
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3760
+ vNode.elm = node;
3761
+ }
3715
3762
  };
3716
3763
  const CommentHook = {
3717
3764
  create: vnode => {
@@ -3729,7 +3776,14 @@
3729
3776
  update: updateNodeHook,
3730
3777
  insert: insertNodeHook,
3731
3778
  move: insertNodeHook,
3732
- remove: removeNodeHook
3779
+ remove: removeNodeHook,
3780
+ hydrate: (vNode, node) => {
3781
+ var _a;
3782
+
3783
+
3784
+ node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
3785
+ vNode.elm = node;
3786
+ }
3733
3787
  }; // insert is called after update, which is used somewhere else (via a module)
3734
3788
  // to mark the vm as inserted, that means we cannot use update as the main channel
3735
3789
  // to rehydrate when dirty, because sometimes the element is not inserted just yet,
@@ -3769,6 +3823,38 @@
3769
3823
  remove: (vnode, parentNode) => {
3770
3824
  removeNodeHook(vnode, parentNode);
3771
3825
  removeElmHook(vnode);
3826
+ },
3827
+ hydrate: (vnode, node) => {
3828
+ const elm = node;
3829
+ vnode.elm = elm;
3830
+ const {
3831
+ context
3832
+ } = vnode.data;
3833
+ const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
3834
+ /* manual */
3835
+ );
3836
+
3837
+ if (isDomManual) {
3838
+ // it may be that this element has lwc:inner-html, we need to diff and in case are the same,
3839
+ // remove the innerHTML from props so it reuses the existing dom elements.
3840
+ const {
3841
+ props
3842
+ } = vnode.data;
3843
+
3844
+ if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
3845
+ if (elm.innerHTML === props.innerHTML) {
3846
+ delete props.innerHTML;
3847
+ } else {
3848
+ logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
3849
+ }
3850
+ }
3851
+ }
3852
+
3853
+ hydrateElmHook(vnode);
3854
+
3855
+ if (!isDomManual) {
3856
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
3857
+ }
3772
3858
  }
3773
3859
  };
3774
3860
  const CustomElementHook = {
@@ -3852,6 +3938,38 @@
3852
3938
  // will take care of disconnecting any child VM attached to its shadow as well.
3853
3939
  removeVM(vm);
3854
3940
  }
3941
+ },
3942
+ hydrate: (vnode, elm) => {
3943
+ // the element is created, but the vm is not
3944
+ const {
3945
+ sel,
3946
+ mode,
3947
+ ctor,
3948
+ owner
3949
+ } = vnode;
3950
+ const def = getComponentInternalDef(ctor);
3951
+ createVM(elm, def, {
3952
+ mode,
3953
+ owner,
3954
+ tagName: sel,
3955
+ renderer: owner.renderer
3956
+ });
3957
+ vnode.elm = elm;
3958
+ const vm = getAssociatedVM(elm);
3959
+ allocateChildrenHook(vnode, vm);
3960
+ hydrateElmHook(vnode); // Insert hook section:
3961
+
3962
+ runConnectedCallback(vm);
3963
+
3964
+ if (vm.renderMode !== 0
3965
+ /* Light */
3966
+ ) {
3967
+ // VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
3968
+ // Note: for Light DOM, this is handled while hydrating the VM
3969
+ hydrateChildrenHook(vnode.elm.childNodes, vnode.children);
3970
+ }
3971
+
3972
+ hydrateVM(vm);
3855
3973
  }
3856
3974
  };
3857
3975
 
@@ -4061,7 +4179,7 @@
4061
4179
 
4062
4180
 
4063
4181
  function d(value) {
4064
- return value == null ? '' : value;
4182
+ return value == null ? '' : String(value);
4065
4183
  } // [b]ind function
4066
4184
 
4067
4185
 
@@ -4202,6 +4320,26 @@
4202
4320
 
4203
4321
  markAsDynamicChildren(vnodes);
4204
4322
  return vnodes;
4323
+ }
4324
+ /**
4325
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4326
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4327
+ * lwc:inner-html directive.
4328
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
4329
+ */
4330
+
4331
+
4332
+ let sanitizeHtmlContentHook = () => {
4333
+ // locker-service patches this function during runtime to sanitize HTML content.
4334
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4335
+ };
4336
+ /**
4337
+ * Sets the sanitizeHtmlContentHook.
4338
+ */
4339
+
4340
+
4341
+ function setSanitizeHtmlContentHook(newHookImpl) {
4342
+ sanitizeHtmlContentHook = newHookImpl;
4205
4343
  } // [s]anitize [h]tml [c]ontent
4206
4344
 
4207
4345
 
@@ -4390,7 +4528,10 @@
4390
4528
  for (let i = 0; i < stylesheets.length; i++) {
4391
4529
  renderer.insertGlobalStylesheet(stylesheets[i]);
4392
4530
  }
4393
- } else if (renderer.ssr) {
4531
+ } else if (renderer.ssr || renderer.isHydrating()) {
4532
+ // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
4533
+ // This works in the client, because the stylesheets are created, and cached in the VM
4534
+ // the first time the VM renders.
4394
4535
  // native shadow or light DOM, SSR
4395
4536
  const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
4396
4537
  return createInlineStyleVNode(combinedStylesheetContent);
@@ -4889,6 +5030,12 @@
4889
5030
  , vm);
4890
5031
  }
4891
5032
 
5033
+ function hydrateRootElement(elm) {
5034
+ const vm = getAssociatedVM(elm);
5035
+ runConnectedCallback(vm);
5036
+ hydrateVM(vm);
5037
+ }
5038
+
4892
5039
  function disconnectRootElement(elm) {
4893
5040
  const vm = getAssociatedVM(elm);
4894
5041
  resetComponentStateWhenRemoved(vm);
@@ -4896,6 +5043,10 @@
4896
5043
 
4897
5044
  function appendVM(vm) {
4898
5045
  rehydrate(vm);
5046
+ }
5047
+
5048
+ function hydrateVM(vm) {
5049
+ hydrate(vm);
4899
5050
  } // just in case the component comes back, with this we guarantee re-rendering it
4900
5051
  // while preventing any attempt to rehydration until after reinsertion.
4901
5052
 
@@ -5090,6 +5241,22 @@
5090
5241
  }
5091
5242
  }
5092
5243
 
5244
+ function hydrate(vm) {
5245
+ if (isTrue(vm.isDirty)) {
5246
+ // manually diffing/patching here.
5247
+ // This routine is:
5248
+ // patchShadowRoot(vm, children);
5249
+ // -> addVnodes.
5250
+ const children = renderComponent(vm);
5251
+ vm.children = children;
5252
+ const vmChildren = vm.renderMode === 0
5253
+ /* Light */
5254
+ ? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
5255
+ hydrateChildrenHook(vmChildren, children);
5256
+ runRenderedCallback(vm);
5257
+ }
5258
+ }
5259
+
5093
5260
  function patchShadowRoot(vm, newCh) {
5094
5261
  const {
5095
5262
  children: oldCh
@@ -5879,25 +6046,12 @@
5879
6046
 
5880
6047
  let hooksAreSet = false;
5881
6048
 
5882
- function overrideHooks(hooks) {
5883
- const oldHooks = {};
5884
-
5885
- if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
5886
- oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5887
- }
5888
-
5889
- return oldHooks;
5890
- }
5891
-
5892
6049
  function setHooks(hooks) {
5893
6050
  assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
5894
- overrideHooks(hooks);
5895
6051
  hooksAreSet = true;
6052
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
5896
6053
  }
5897
-
5898
- function setHooksForTest(hooks) {
5899
- }
5900
- /* version: 2.5.6 */
6054
+ /* version: 2.5.10-alpha1 */
5901
6055
 
5902
6056
  /*
5903
6057
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6032,8 +6186,19 @@
6032
6186
  HTMLElementConstructor.prototype = HTMLElement.prototype;
6033
6187
  }
6034
6188
 
6189
+ let isHydrating = false;
6190
+
6191
+ function setIsHydrating(v) {
6192
+ isHydrating = v;
6193
+ }
6194
+
6035
6195
  const renderer = {
6036
6196
  ssr: false,
6197
+
6198
+ isHydrating() {
6199
+ return isHydrating;
6200
+ },
6201
+
6037
6202
  isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
6038
6203
  isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
6039
6204
 
@@ -6062,6 +6227,10 @@
6062
6227
  },
6063
6228
 
6064
6229
  attachShadow(element, options) {
6230
+ if (isHydrating) {
6231
+ return element.shadowRoot;
6232
+ }
6233
+
6065
6234
  return element.attachShadow(options);
6066
6235
  },
6067
6236
 
@@ -6193,57 +6362,6 @@
6193
6362
  getCustomElement,
6194
6363
  HTMLElement: HTMLElementConstructor
6195
6364
  };
6196
- /*
6197
- * Copyright (c) 2018, salesforce.com, inc.
6198
- * All rights reserved.
6199
- * SPDX-License-Identifier: MIT
6200
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6201
- */
6202
-
6203
- /**
6204
- * This function builds a Web Component class from a LWC constructor so it can be
6205
- * registered as a new element via customElements.define() at any given time.
6206
- *
6207
- * @deprecated since version 1.3.11
6208
- *
6209
- * @example
6210
- * ```
6211
- * import { buildCustomElementConstructor } from 'lwc';
6212
- * import Foo from 'ns/foo';
6213
- * const WC = buildCustomElementConstructor(Foo);
6214
- * customElements.define('x-foo', WC);
6215
- * const elm = document.createElement('x-foo');
6216
- * ```
6217
- */
6218
-
6219
- function deprecatedBuildCustomElementConstructor(Ctor) {
6220
-
6221
- return Ctor.CustomElementConstructor;
6222
- }
6223
-
6224
- function buildCustomElementConstructor(Ctor) {
6225
- const def = getComponentInternalDef(Ctor);
6226
- return class extends def.bridge {
6227
- constructor() {
6228
- super();
6229
- createVM(this, def, {
6230
- mode: 'open',
6231
- owner: null,
6232
- tagName: this.tagName,
6233
- renderer
6234
- });
6235
- }
6236
-
6237
- connectedCallback() {
6238
- connectRootElement(this);
6239
- }
6240
-
6241
- disconnectedCallback() {
6242
- disconnectRootElement(this);
6243
- }
6244
-
6245
- };
6246
- }
6247
6365
  /*
6248
6366
  * Copyright (c) 2018, salesforce.com, inc.
6249
6367
  * All rights reserved.
@@ -6253,7 +6371,6 @@
6253
6371
  // TODO [#2472]: Remove this workaround when appropriate.
6254
6372
  // eslint-disable-next-line lwc-internal/no-global-node
6255
6373
 
6256
-
6257
6374
  const _Node$1 = Node;
6258
6375
  const ConnectingSlot = new WeakMap();
6259
6376
  const DisconnectingSlot = new WeakMap();
@@ -6361,6 +6478,114 @@
6361
6478
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6362
6479
  */
6363
6480
 
6481
+
6482
+ function hydrateComponent(element, Ctor, props = {}) {
6483
+ if (!isFunction$1(Ctor)) {
6484
+ throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
6485
+ }
6486
+
6487
+ if (!isObject(props) || isNull(props)) {
6488
+ throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
6489
+ }
6490
+
6491
+ const def = getComponentInternalDef(Ctor);
6492
+
6493
+ try {
6494
+ // Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
6495
+ // and uses the same algo to create the stylesheets as in SSR.
6496
+ setIsHydrating(true);
6497
+ createVM(element, def, {
6498
+ mode: 'open',
6499
+ owner: null,
6500
+ renderer,
6501
+ tagName: element.tagName.toLowerCase()
6502
+ });
6503
+
6504
+ for (const [key, value] of Object.entries(props)) {
6505
+ element[key] = value;
6506
+ }
6507
+
6508
+ hydrateRootElement(element); // set it back since now we finished hydration.
6509
+
6510
+ setIsHydrating(false);
6511
+ } catch (e) {
6512
+ // Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
6513
+ // the client generated DOM.
6514
+
6515
+ /* eslint-disable-next-line no-console */
6516
+ console.error('Recovering from error while hydrating: ', e);
6517
+ setIsHydrating(false);
6518
+ const newElem = createElement(element.tagName, {
6519
+ is: Ctor,
6520
+ mode: 'open'
6521
+ });
6522
+
6523
+ for (const [key, value] of Object.entries(props)) {
6524
+ newElem[key] = value;
6525
+ }
6526
+
6527
+ element.parentNode.replaceChild(newElem, element);
6528
+ }
6529
+ }
6530
+ /*
6531
+ * Copyright (c) 2018, salesforce.com, inc.
6532
+ * All rights reserved.
6533
+ * SPDX-License-Identifier: MIT
6534
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6535
+ */
6536
+
6537
+ /**
6538
+ * This function builds a Web Component class from a LWC constructor so it can be
6539
+ * registered as a new element via customElements.define() at any given time.
6540
+ *
6541
+ * @deprecated since version 1.3.11
6542
+ *
6543
+ * @example
6544
+ * ```
6545
+ * import { buildCustomElementConstructor } from 'lwc';
6546
+ * import Foo from 'ns/foo';
6547
+ * const WC = buildCustomElementConstructor(Foo);
6548
+ * customElements.define('x-foo', WC);
6549
+ * const elm = document.createElement('x-foo');
6550
+ * ```
6551
+ */
6552
+
6553
+
6554
+ function deprecatedBuildCustomElementConstructor(Ctor) {
6555
+
6556
+ return Ctor.CustomElementConstructor;
6557
+ }
6558
+
6559
+ function buildCustomElementConstructor(Ctor) {
6560
+ const def = getComponentInternalDef(Ctor);
6561
+ return class extends def.bridge {
6562
+ constructor() {
6563
+ super();
6564
+ createVM(this, def, {
6565
+ mode: 'open',
6566
+ owner: null,
6567
+ tagName: this.tagName,
6568
+ renderer
6569
+ });
6570
+ }
6571
+
6572
+ connectedCallback() {
6573
+ connectRootElement(this);
6574
+ }
6575
+
6576
+ disconnectedCallback() {
6577
+ disconnectRootElement(this);
6578
+ }
6579
+
6580
+ };
6581
+ }
6582
+ /*
6583
+ * Copyright (c) 2018, salesforce.com, inc.
6584
+ * All rights reserved.
6585
+ * SPDX-License-Identifier: MIT
6586
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6587
+ */
6588
+
6364
6589
  /**
6365
6590
  * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6366
6591
  * This API is subject to change or being removed.
@@ -6460,7 +6685,7 @@
6460
6685
  });
6461
6686
  freeze(LightningElement);
6462
6687
  seal(LightningElement.prototype);
6463
- /* version: 2.5.6 */
6688
+ /* version: 2.5.10-alpha1 */
6464
6689
 
6465
6690
  exports.LightningElement = LightningElement;
6466
6691
  exports.__unstable__ProfilerControl = profilerControl;
@@ -6470,6 +6695,7 @@
6470
6695
  exports.createElement = createElement;
6471
6696
  exports.getComponentConstructor = getComponentConstructor;
6472
6697
  exports.getComponentDef = getComponentDef;
6698
+ exports.hydrateComponent = hydrateComponent;
6473
6699
  exports.isComponentConstructor = isComponentConstructor;
6474
6700
  exports.isNodeFromTemplate = isNodeFromTemplate;
6475
6701
  exports.readonly = readonly;
@@ -6481,7 +6707,6 @@
6481
6707
  exports.setFeatureFlag = setFeatureFlag;
6482
6708
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
6483
6709
  exports.setHooks = setHooks;
6484
- exports.setHooksForTest = setHooksForTest;
6485
6710
  exports.swapComponent = swapComponent;
6486
6711
  exports.swapStyle = swapStyle;
6487
6712
  exports.swapTemplate = swapTemplate;
@@ -6491,4 +6716,4 @@
6491
6716
 
6492
6717
  Object.defineProperty(exports, '__esModule', { value: true });
6493
6718
 
6494
- }));
6719
+ })));