@lwc/engine-core 2.12.1 → 2.13.2

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.
@@ -440,6 +440,20 @@ function logWarn(message, vm) {
440
440
  log('warn', message, vm);
441
441
  }
442
442
 
443
+ /*
444
+ * Copyright (c) 2020, salesforce.com, inc.
445
+ * All rights reserved.
446
+ * SPDX-License-Identifier: MIT
447
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
448
+ */
449
+ function resolveCircularModuleDependency(fn) {
450
+ const module = fn();
451
+ return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
452
+ }
453
+ function isCircularModuleDependency(obj) {
454
+ return shared.isFunction(obj) && shared.hasOwnProperty.call(obj, '__circular__');
455
+ }
456
+
443
457
  /*
444
458
  * Copyright (c) 2018, salesforce.com, inc.
445
459
  * All rights reserved.
@@ -1805,64 +1819,7 @@ if (process.env.NODE_ENV !== 'production') {
1805
1819
  patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
1806
1820
  }
1807
1821
 
1808
- /*
1809
- * Copyright (c) 2018, salesforce.com, inc.
1810
- * All rights reserved.
1811
- * SPDX-License-Identifier: MIT
1812
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1813
- */
1814
- /**
1815
- * @wire decorator to wire fields and methods to a wire adapter in
1816
- * LWC Components. This function implements the internals of this
1817
- * decorator.
1818
- */
1819
- function wire(_adapter, _config) {
1820
- if (process.env.NODE_ENV !== 'production') {
1821
- shared.assert.fail('@wire(adapter, config?) may only be used as a decorator.');
1822
- }
1823
- throw new Error();
1824
- }
1825
- function internalWireFieldDecorator(key) {
1826
- return {
1827
- get() {
1828
- const vm = getAssociatedVM(this);
1829
- componentValueObserved(vm, key);
1830
- return vm.cmpFields[key];
1831
- },
1832
- set(value) {
1833
- const vm = getAssociatedVM(this);
1834
- /**
1835
- * Reactivity for wired fields is provided in wiring.
1836
- * We intentionally add reactivity here since this is just
1837
- * letting the author to do the wrong thing, but it will keep our
1838
- * system to be backward compatible.
1839
- */
1840
- if (value !== vm.cmpFields[key]) {
1841
- vm.cmpFields[key] = value;
1842
- componentValueMutated(vm, key);
1843
- }
1844
- },
1845
- enumerable: true,
1846
- configurable: true,
1847
- };
1848
- }
1849
-
1850
- /*
1851
- * Copyright (c) 2018, salesforce.com, inc.
1852
- * All rights reserved.
1853
- * SPDX-License-Identifier: MIT
1854
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1855
- */
1856
- function track(target) {
1857
- if (arguments.length === 1) {
1858
- return reactiveMembrane.getProxy(target);
1859
- }
1860
- if (process.env.NODE_ENV !== 'production') {
1861
- shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
1862
- }
1863
- throw new Error();
1864
- }
1865
- function internalTrackDecorator(key) {
1822
+ function createObservedFieldPropertyDescriptor(key) {
1866
1823
  return {
1867
1824
  get() {
1868
1825
  const vm = getAssociatedVM(this);
@@ -1871,14 +1828,8 @@ function internalTrackDecorator(key) {
1871
1828
  },
1872
1829
  set(newValue) {
1873
1830
  const vm = getAssociatedVM(this);
1874
- if (process.env.NODE_ENV !== 'production') {
1875
- const vmBeingRendered = getVMBeingRendered();
1876
- shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
1877
- shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
1878
- }
1879
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
1880
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1881
- vm.cmpFields[key] = reactiveOrAnyValue;
1831
+ if (newValue !== vm.cmpFields[key]) {
1832
+ vm.cmpFields[key] = newValue;
1882
1833
  componentValueMutated(vm, key);
1883
1834
  }
1884
1835
  },
@@ -2042,7 +1993,22 @@ function createPublicAccessorDescriptor(key, descriptor) {
2042
1993
  };
2043
1994
  }
2044
1995
 
2045
- function createObservedFieldPropertyDescriptor(key) {
1996
+ /*
1997
+ * Copyright (c) 2018, salesforce.com, inc.
1998
+ * All rights reserved.
1999
+ * SPDX-License-Identifier: MIT
2000
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2001
+ */
2002
+ function track(target) {
2003
+ if (arguments.length === 1) {
2004
+ return reactiveMembrane.getProxy(target);
2005
+ }
2006
+ if (process.env.NODE_ENV !== 'production') {
2007
+ shared.assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2008
+ }
2009
+ throw new Error();
2010
+ }
2011
+ function internalTrackDecorator(key) {
2046
2012
  return {
2047
2013
  get() {
2048
2014
  const vm = getAssociatedVM(this);
@@ -2051,8 +2017,56 @@ function createObservedFieldPropertyDescriptor(key) {
2051
2017
  },
2052
2018
  set(newValue) {
2053
2019
  const vm = getAssociatedVM(this);
2054
- if (newValue !== vm.cmpFields[key]) {
2055
- vm.cmpFields[key] = newValue;
2020
+ if (process.env.NODE_ENV !== 'production') {
2021
+ const vmBeingRendered = getVMBeingRendered();
2022
+ shared.assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${shared.toString(key)}`);
2023
+ shared.assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${shared.toString(key)}`);
2024
+ }
2025
+ const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2026
+ if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2027
+ vm.cmpFields[key] = reactiveOrAnyValue;
2028
+ componentValueMutated(vm, key);
2029
+ }
2030
+ },
2031
+ enumerable: true,
2032
+ configurable: true,
2033
+ };
2034
+ }
2035
+
2036
+ /*
2037
+ * Copyright (c) 2018, salesforce.com, inc.
2038
+ * All rights reserved.
2039
+ * SPDX-License-Identifier: MIT
2040
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2041
+ */
2042
+ /**
2043
+ * @wire decorator to wire fields and methods to a wire adapter in
2044
+ * LWC Components. This function implements the internals of this
2045
+ * decorator.
2046
+ */
2047
+ function wire(_adapter, _config) {
2048
+ if (process.env.NODE_ENV !== 'production') {
2049
+ shared.assert.fail('@wire(adapter, config?) may only be used as a decorator.');
2050
+ }
2051
+ throw new Error();
2052
+ }
2053
+ function internalWireFieldDecorator(key) {
2054
+ return {
2055
+ get() {
2056
+ const vm = getAssociatedVM(this);
2057
+ componentValueObserved(vm, key);
2058
+ return vm.cmpFields[key];
2059
+ },
2060
+ set(value) {
2061
+ const vm = getAssociatedVM(this);
2062
+ /**
2063
+ * Reactivity for wired fields is provided in wiring.
2064
+ * We intentionally add reactivity here since this is just
2065
+ * letting the author to do the wrong thing, but it will keep our
2066
+ * system to be backward compatible.
2067
+ */
2068
+ if (value !== vm.cmpFields[key]) {
2069
+ vm.cmpFields[key] = value;
2056
2070
  componentValueMutated(vm, key);
2057
2071
  }
2058
2072
  },
@@ -2486,20 +2500,6 @@ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, share
2486
2500
  shared.freeze(BaseBridgeElement);
2487
2501
  shared.seal(BaseBridgeElement.prototype);
2488
2502
 
2489
- /*
2490
- * Copyright (c) 2020, salesforce.com, inc.
2491
- * All rights reserved.
2492
- * SPDX-License-Identifier: MIT
2493
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2494
- */
2495
- function resolveCircularModuleDependency(fn) {
2496
- const module = fn();
2497
- return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
2498
- }
2499
- function isCircularModuleDependency(obj) {
2500
- return shared.isFunction(obj) && shared.hasOwnProperty.call(obj, '__circular__');
2501
- }
2502
-
2503
2503
  /*
2504
2504
  * Copyright (c) 2020, salesforce.com, inc.
2505
2505
  * All rights reserved.
@@ -3589,13 +3589,6 @@ function allocateInSlot(vm, children) {
3589
3589
  slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3590
3590
  }
3591
3591
  const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
3592
- // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
3593
- // which might have similar keys. Each vnode will always have a key that
3594
- // starts with a numeric character from compiler. In this case, we add a unique
3595
- // notation for slotted vnodes keys, e.g.: `@foo:1:1`
3596
- if (!shared.isUndefined(vnode.key)) {
3597
- vnode.key = `@${slotName}:${vnode.key}`;
3598
- }
3599
3592
  shared.ArrayPush.call(vnodes, vnode);
3600
3593
  }
3601
3594
  if (shared.isFalse(vm.isDirty)) {
@@ -4899,20 +4892,9 @@ function removeVM(vm) {
4899
4892
 
4900
4893
  resetComponentStateWhenRemoved(vm);
4901
4894
  }
4902
-
4903
- function getNearestShadowAncestor(vm) {
4904
- let ancestor = vm.owner;
4905
-
4906
- while (!shared.isNull(ancestor) && ancestor.renderMode === 0
4907
- /* Light */
4908
- ) {
4909
- ancestor = ancestor.owner;
4910
- }
4911
-
4912
- return ancestor;
4913
- }
4914
-
4915
4895
  function createVM(elm, ctor, options) {
4896
+ var _a;
4897
+
4916
4898
  const {
4917
4899
  mode,
4918
4900
  owner,
@@ -4940,6 +4922,8 @@ function createVM(elm, ctor, options) {
4940
4922
  oar: shared.create(null),
4941
4923
  cmpTemplate: null,
4942
4924
  renderMode: def.renderMode,
4925
+ shadowMode: computeShadowMode(def, owner),
4926
+ nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
4943
4927
  context: {
4944
4928
  stylesheetToken: undefined,
4945
4929
  hasTokenInClass: undefined,
@@ -4952,7 +4936,6 @@ function createVM(elm, ctor, options) {
4952
4936
  },
4953
4937
  // Properties set right after VM creation.
4954
4938
  tro: null,
4955
- shadowMode: null,
4956
4939
  // Properties set by the LightningElement constructor.
4957
4940
  component: null,
4958
4941
  shadowRoot: null,
@@ -4961,7 +4944,6 @@ function createVM(elm, ctor, options) {
4961
4944
  setHook,
4962
4945
  getHook
4963
4946
  };
4964
- vm.shadowMode = computeShadowMode(vm);
4965
4947
  vm.tro = getTemplateReactiveObserver(vm);
4966
4948
 
4967
4949
  if (process.env.NODE_ENV !== 'production') {
@@ -4986,10 +4968,9 @@ function createVM(elm, ctor, options) {
4986
4968
  return vm;
4987
4969
  }
4988
4970
 
4989
- function computeShadowMode(vm) {
4990
- const {
4991
- def
4992
- } = vm;
4971
+ function computeShadowMode(def, owner) {
4972
+ var _a;
4973
+
4993
4974
  let shadowMode;
4994
4975
 
4995
4976
  if (isSyntheticShadowDefined) {
@@ -5012,23 +4993,13 @@ function computeShadowMode(vm) {
5012
4993
  /* Native */
5013
4994
  ;
5014
4995
  } else {
5015
- const shadowAncestor = getNearestShadowAncestor(vm);
5016
-
5017
- if (!shared.isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5018
- /* Native */
5019
- ) {
5020
- // Transitive support for native Shadow DOM. A component in native mode
5021
- // transitively opts all of its descendants into native.
5022
- shadowMode = 0
5023
- /* Native */
5024
- ;
5025
- } else {
5026
- // Synthetic if neither this component nor any of its ancestors are configured
5027
- // to be native.
5028
- shadowMode = 1
5029
- /* Synthetic */
5030
- ;
5031
- }
4996
+ // Transitive support for native Shadow DOM. A component in native mode
4997
+ // transitively opts all of its descendants into native.
4998
+ // Synthetic if neither this component nor any of its ancestors are configured
4999
+ // to be native.
5000
+ shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
5001
+ /* Synthetic */
5002
+ ;
5032
5003
  }
5033
5004
  } else {
5034
5005
  shadowMode = 1
@@ -6118,6 +6089,29 @@ function setHooks(hooks) {
6118
6089
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6119
6090
  }
6120
6091
 
6092
+ /*
6093
+ * Copyright (c) 2018, salesforce.com, inc.
6094
+ * All rights reserved.
6095
+ * SPDX-License-Identifier: MIT
6096
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6097
+ */
6098
+ /**
6099
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6100
+ * This API is subject to change or being removed.
6101
+ */
6102
+ function getComponentConstructor(elm) {
6103
+ let ctor = null;
6104
+ // intentionally checking for undefined due to some funky libraries patching weakmap.get
6105
+ // to throw when undefined.
6106
+ if (!shared.isUndefined(elm)) {
6107
+ const vm = getAssociatedVMIfPresent(elm);
6108
+ if (!shared.isUndefined(vm)) {
6109
+ ctor = vm.def.ctor;
6110
+ }
6111
+ }
6112
+ return ctor;
6113
+ }
6114
+
6121
6115
  Object.defineProperty(exports, 'setFeatureFlag', {
6122
6116
  enumerable: true,
6123
6117
  get: function () { return features.setFeatureFlag; }
@@ -6134,6 +6128,7 @@ exports.createContextProvider = createContextProvider;
6134
6128
  exports.createVM = createVM;
6135
6129
  exports.disconnectRootElement = disconnectRootElement;
6136
6130
  exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
6131
+ exports.getComponentConstructor = getComponentConstructor;
6137
6132
  exports.getComponentDef = getComponentDef;
6138
6133
  exports.getComponentHtmlPrototype = getComponentHtmlPrototype;
6139
6134
  exports.getUpgradableConstructor = getUpgradableConstructor;
@@ -6192,4 +6187,4 @@ exports.swapTemplate = swapTemplate;
6192
6187
  exports.track = track;
6193
6188
  exports.unwrap = unwrap;
6194
6189
  exports.wire = wire;
6195
- /* version: 2.12.1 */
6190
+ /* version: 2.13.2 */
@@ -1,5 +1,5 @@
1
1
  /* proxy-compat-disable */
2
- import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift } from '@lwc/shared';
2
+ import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift } from '@lwc/shared';
3
3
  import { runtimeFlags } from '@lwc/features';
4
4
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
5
5
 
@@ -437,6 +437,20 @@ function logWarn(message, vm) {
437
437
  log('warn', message, vm);
438
438
  }
439
439
 
440
+ /*
441
+ * Copyright (c) 2020, salesforce.com, inc.
442
+ * All rights reserved.
443
+ * SPDX-License-Identifier: MIT
444
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
445
+ */
446
+ function resolveCircularModuleDependency(fn) {
447
+ const module = fn();
448
+ return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
449
+ }
450
+ function isCircularModuleDependency(obj) {
451
+ return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
452
+ }
453
+
440
454
  /*
441
455
  * Copyright (c) 2018, salesforce.com, inc.
442
456
  * All rights reserved.
@@ -1802,64 +1816,7 @@ if (process.env.NODE_ENV !== 'production') {
1802
1816
  patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
1803
1817
  }
1804
1818
 
1805
- /*
1806
- * Copyright (c) 2018, salesforce.com, inc.
1807
- * All rights reserved.
1808
- * SPDX-License-Identifier: MIT
1809
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1810
- */
1811
- /**
1812
- * @wire decorator to wire fields and methods to a wire adapter in
1813
- * LWC Components. This function implements the internals of this
1814
- * decorator.
1815
- */
1816
- function wire(_adapter, _config) {
1817
- if (process.env.NODE_ENV !== 'production') {
1818
- assert.fail('@wire(adapter, config?) may only be used as a decorator.');
1819
- }
1820
- throw new Error();
1821
- }
1822
- function internalWireFieldDecorator(key) {
1823
- return {
1824
- get() {
1825
- const vm = getAssociatedVM(this);
1826
- componentValueObserved(vm, key);
1827
- return vm.cmpFields[key];
1828
- },
1829
- set(value) {
1830
- const vm = getAssociatedVM(this);
1831
- /**
1832
- * Reactivity for wired fields is provided in wiring.
1833
- * We intentionally add reactivity here since this is just
1834
- * letting the author to do the wrong thing, but it will keep our
1835
- * system to be backward compatible.
1836
- */
1837
- if (value !== vm.cmpFields[key]) {
1838
- vm.cmpFields[key] = value;
1839
- componentValueMutated(vm, key);
1840
- }
1841
- },
1842
- enumerable: true,
1843
- configurable: true,
1844
- };
1845
- }
1846
-
1847
- /*
1848
- * Copyright (c) 2018, salesforce.com, inc.
1849
- * All rights reserved.
1850
- * SPDX-License-Identifier: MIT
1851
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1852
- */
1853
- function track(target) {
1854
- if (arguments.length === 1) {
1855
- return reactiveMembrane.getProxy(target);
1856
- }
1857
- if (process.env.NODE_ENV !== 'production') {
1858
- assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
1859
- }
1860
- throw new Error();
1861
- }
1862
- function internalTrackDecorator(key) {
1819
+ function createObservedFieldPropertyDescriptor(key) {
1863
1820
  return {
1864
1821
  get() {
1865
1822
  const vm = getAssociatedVM(this);
@@ -1868,14 +1825,8 @@ function internalTrackDecorator(key) {
1868
1825
  },
1869
1826
  set(newValue) {
1870
1827
  const vm = getAssociatedVM(this);
1871
- if (process.env.NODE_ENV !== 'production') {
1872
- const vmBeingRendered = getVMBeingRendered();
1873
- assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
1874
- assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
1875
- }
1876
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
1877
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1878
- vm.cmpFields[key] = reactiveOrAnyValue;
1828
+ if (newValue !== vm.cmpFields[key]) {
1829
+ vm.cmpFields[key] = newValue;
1879
1830
  componentValueMutated(vm, key);
1880
1831
  }
1881
1832
  },
@@ -2039,7 +1990,22 @@ function createPublicAccessorDescriptor(key, descriptor) {
2039
1990
  };
2040
1991
  }
2041
1992
 
2042
- function createObservedFieldPropertyDescriptor(key) {
1993
+ /*
1994
+ * Copyright (c) 2018, salesforce.com, inc.
1995
+ * All rights reserved.
1996
+ * SPDX-License-Identifier: MIT
1997
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1998
+ */
1999
+ function track(target) {
2000
+ if (arguments.length === 1) {
2001
+ return reactiveMembrane.getProxy(target);
2002
+ }
2003
+ if (process.env.NODE_ENV !== 'production') {
2004
+ assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
2005
+ }
2006
+ throw new Error();
2007
+ }
2008
+ function internalTrackDecorator(key) {
2043
2009
  return {
2044
2010
  get() {
2045
2011
  const vm = getAssociatedVM(this);
@@ -2048,8 +2014,56 @@ function createObservedFieldPropertyDescriptor(key) {
2048
2014
  },
2049
2015
  set(newValue) {
2050
2016
  const vm = getAssociatedVM(this);
2051
- if (newValue !== vm.cmpFields[key]) {
2052
- vm.cmpFields[key] = newValue;
2017
+ if (process.env.NODE_ENV !== 'production') {
2018
+ const vmBeingRendered = getVMBeingRendered();
2019
+ assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2020
+ assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2021
+ }
2022
+ const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2023
+ if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2024
+ vm.cmpFields[key] = reactiveOrAnyValue;
2025
+ componentValueMutated(vm, key);
2026
+ }
2027
+ },
2028
+ enumerable: true,
2029
+ configurable: true,
2030
+ };
2031
+ }
2032
+
2033
+ /*
2034
+ * Copyright (c) 2018, salesforce.com, inc.
2035
+ * All rights reserved.
2036
+ * SPDX-License-Identifier: MIT
2037
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2038
+ */
2039
+ /**
2040
+ * @wire decorator to wire fields and methods to a wire adapter in
2041
+ * LWC Components. This function implements the internals of this
2042
+ * decorator.
2043
+ */
2044
+ function wire(_adapter, _config) {
2045
+ if (process.env.NODE_ENV !== 'production') {
2046
+ assert.fail('@wire(adapter, config?) may only be used as a decorator.');
2047
+ }
2048
+ throw new Error();
2049
+ }
2050
+ function internalWireFieldDecorator(key) {
2051
+ return {
2052
+ get() {
2053
+ const vm = getAssociatedVM(this);
2054
+ componentValueObserved(vm, key);
2055
+ return vm.cmpFields[key];
2056
+ },
2057
+ set(value) {
2058
+ const vm = getAssociatedVM(this);
2059
+ /**
2060
+ * Reactivity for wired fields is provided in wiring.
2061
+ * We intentionally add reactivity here since this is just
2062
+ * letting the author to do the wrong thing, but it will keep our
2063
+ * system to be backward compatible.
2064
+ */
2065
+ if (value !== vm.cmpFields[key]) {
2066
+ vm.cmpFields[key] = value;
2053
2067
  componentValueMutated(vm, key);
2054
2068
  }
2055
2069
  },
@@ -2483,20 +2497,6 @@ const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOw
2483
2497
  freeze(BaseBridgeElement);
2484
2498
  seal(BaseBridgeElement.prototype);
2485
2499
 
2486
- /*
2487
- * Copyright (c) 2020, salesforce.com, inc.
2488
- * All rights reserved.
2489
- * SPDX-License-Identifier: MIT
2490
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2491
- */
2492
- function resolveCircularModuleDependency(fn) {
2493
- const module = fn();
2494
- return (module === null || module === void 0 ? void 0 : module.__esModule) ? module.default : module;
2495
- }
2496
- function isCircularModuleDependency(obj) {
2497
- return isFunction$1(obj) && hasOwnProperty$1.call(obj, '__circular__');
2498
- }
2499
-
2500
2500
  /*
2501
2501
  * Copyright (c) 2020, salesforce.com, inc.
2502
2502
  * All rights reserved.
@@ -3586,13 +3586,6 @@ function allocateInSlot(vm, children) {
3586
3586
  slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
3587
3587
  }
3588
3588
  const vnodes = (cmpSlots[slotName] = cmpSlots[slotName] || []);
3589
- // re-keying the vnodes is necessary to avoid conflicts with default content for the slot
3590
- // which might have similar keys. Each vnode will always have a key that
3591
- // starts with a numeric character from compiler. In this case, we add a unique
3592
- // notation for slotted vnodes keys, e.g.: `@foo:1:1`
3593
- if (!isUndefined$1(vnode.key)) {
3594
- vnode.key = `@${slotName}:${vnode.key}`;
3595
- }
3596
3589
  ArrayPush$1.call(vnodes, vnode);
3597
3590
  }
3598
3591
  if (isFalse(vm.isDirty)) {
@@ -4896,20 +4889,9 @@ function removeVM(vm) {
4896
4889
 
4897
4890
  resetComponentStateWhenRemoved(vm);
4898
4891
  }
4899
-
4900
- function getNearestShadowAncestor(vm) {
4901
- let ancestor = vm.owner;
4902
-
4903
- while (!isNull(ancestor) && ancestor.renderMode === 0
4904
- /* Light */
4905
- ) {
4906
- ancestor = ancestor.owner;
4907
- }
4908
-
4909
- return ancestor;
4910
- }
4911
-
4912
4892
  function createVM(elm, ctor, options) {
4893
+ var _a;
4894
+
4913
4895
  const {
4914
4896
  mode,
4915
4897
  owner,
@@ -4937,6 +4919,8 @@ function createVM(elm, ctor, options) {
4937
4919
  oar: create(null),
4938
4920
  cmpTemplate: null,
4939
4921
  renderMode: def.renderMode,
4922
+ shadowMode: computeShadowMode(def, owner),
4923
+ nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
4940
4924
  context: {
4941
4925
  stylesheetToken: undefined,
4942
4926
  hasTokenInClass: undefined,
@@ -4949,7 +4933,6 @@ function createVM(elm, ctor, options) {
4949
4933
  },
4950
4934
  // Properties set right after VM creation.
4951
4935
  tro: null,
4952
- shadowMode: null,
4953
4936
  // Properties set by the LightningElement constructor.
4954
4937
  component: null,
4955
4938
  shadowRoot: null,
@@ -4958,7 +4941,6 @@ function createVM(elm, ctor, options) {
4958
4941
  setHook,
4959
4942
  getHook
4960
4943
  };
4961
- vm.shadowMode = computeShadowMode(vm);
4962
4944
  vm.tro = getTemplateReactiveObserver(vm);
4963
4945
 
4964
4946
  if (process.env.NODE_ENV !== 'production') {
@@ -4983,10 +4965,9 @@ function createVM(elm, ctor, options) {
4983
4965
  return vm;
4984
4966
  }
4985
4967
 
4986
- function computeShadowMode(vm) {
4987
- const {
4988
- def
4989
- } = vm;
4968
+ function computeShadowMode(def, owner) {
4969
+ var _a;
4970
+
4990
4971
  let shadowMode;
4991
4972
 
4992
4973
  if (isSyntheticShadowDefined) {
@@ -5009,23 +4990,13 @@ function computeShadowMode(vm) {
5009
4990
  /* Native */
5010
4991
  ;
5011
4992
  } else {
5012
- const shadowAncestor = getNearestShadowAncestor(vm);
5013
-
5014
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
5015
- /* Native */
5016
- ) {
5017
- // Transitive support for native Shadow DOM. A component in native mode
5018
- // transitively opts all of its descendants into native.
5019
- shadowMode = 0
5020
- /* Native */
5021
- ;
5022
- } else {
5023
- // Synthetic if neither this component nor any of its ancestors are configured
5024
- // to be native.
5025
- shadowMode = 1
5026
- /* Synthetic */
5027
- ;
5028
- }
4993
+ // Transitive support for native Shadow DOM. A component in native mode
4994
+ // transitively opts all of its descendants into native.
4995
+ // Synthetic if neither this component nor any of its ancestors are configured
4996
+ // to be native.
4997
+ shadowMode = (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : 1
4998
+ /* Synthetic */
4999
+ ;
5029
5000
  }
5030
5001
  } else {
5031
5002
  shadowMode = 1
@@ -6115,5 +6086,28 @@ function setHooks(hooks) {
6115
6086
  setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
6116
6087
  }
6117
6088
 
6118
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6119
- /* version: 2.12.1 */
6089
+ /*
6090
+ * Copyright (c) 2018, salesforce.com, inc.
6091
+ * All rights reserved.
6092
+ * SPDX-License-Identifier: MIT
6093
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6094
+ */
6095
+ /**
6096
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
6097
+ * This API is subject to change or being removed.
6098
+ */
6099
+ function getComponentConstructor(elm) {
6100
+ let ctor = null;
6101
+ // intentionally checking for undefined due to some funky libraries patching weakmap.get
6102
+ // to throw when undefined.
6103
+ if (!isUndefined$1(elm)) {
6104
+ const vm = getAssociatedVMIfPresent(elm);
6105
+ if (!isUndefined$1(vm)) {
6106
+ ctor = vm.def.ctor;
6107
+ }
6108
+ }
6109
+ return ctor;
6110
+ }
6111
+
6112
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6113
+ /* version: 2.13.2 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.12.1",
3
+ "version": "2.13.2",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "types/"
26
26
  ],
27
27
  "dependencies": {
28
- "@lwc/features": "2.12.1",
29
- "@lwc/shared": "2.12.1"
28
+ "@lwc/features": "2.13.2",
29
+ "@lwc/shared": "2.13.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "observable-membrane": "2.0.0"
@@ -1,5 +1,5 @@
1
- import { VM } from './vm';
2
1
  import { ReactiveObserver } from '../libs/mutation-tracker';
2
+ import { VM } from './vm';
3
3
  import { LightningElementConstructor } from './base-lightning-element';
4
4
  import { Template } from './template';
5
5
  import { VNodes } from './vnodes';
@@ -6,10 +6,10 @@
6
6
  * This structure can be used to synthetically create proxies, and understand the
7
7
  * shape of a component. It is also used internally to apply extra optimizations.
8
8
  */
9
+ import { RenderMode, ShadowSupportMode } from '../framework/vm';
9
10
  import { Template } from './template';
10
11
  import { LightningElement, LightningElementConstructor } from './base-lightning-element';
11
12
  import { PropType } from './decorators/register';
12
- import { RenderMode, ShadowSupportMode } from '../framework/vm';
13
13
  import { HTMLElementConstructor } from './base-bridge-element';
14
14
  export interface ComponentDef {
15
15
  name: string;
@@ -0,0 +1,6 @@
1
+ import { LightningElement } from './base-lightning-element';
2
+ /**
3
+ * EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
4
+ * This API is subject to change or being removed.
5
+ */
6
+ export declare function getComponentConstructor(elm: HTMLElement): typeof LightningElement | null;
@@ -19,5 +19,6 @@ export { profilerControl as __unstable__ProfilerControl } from './profiler';
19
19
  export { getUpgradableConstructor } from './upgradable-element';
20
20
  export { swapTemplate, swapComponent, swapStyle } from './hot-swaps';
21
21
  export { setHooks } from './overridable-hooks';
22
+ export { getComponentConstructor } from './get-component-constructor';
22
23
  export type { ConfigValue as WireConfigValue, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, } from './wiring';
23
24
  export { setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setInsert, setInsertGlobalStylesheet, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, setAddEventListener, } from '../renderer';
@@ -1,10 +1,10 @@
1
- import type { HostNode, HostElement } from '../renderer';
2
1
  import { Template } from './template';
3
2
  import { ComponentDef } from './def';
4
3
  import { LightningElement, LightningElementConstructor } from './base-lightning-element';
5
4
  import { ReactiveObserver } from './mutation-tracker';
6
5
  import { AccessorReactiveObserver } from './decorators/api';
7
6
  import { VNodes, VCustomElement, VNode } from './vnodes';
7
+ import type { HostNode, HostElement } from '../renderer';
8
8
  declare type ShadowRootMode = 'open' | 'closed';
9
9
  export interface TemplateCache {
10
10
  [key: string]: any;
@@ -63,8 +63,11 @@ export interface VM<N = HostNode, E = HostElement> {
63
63
  /** The owner VM or null for root elements. */
64
64
  readonly owner: VM<N, E> | null;
65
65
  /** Rendering operations associated with the VM */
66
- renderMode: RenderMode;
66
+ readonly renderMode: RenderMode;
67
67
  shadowMode: ShadowMode;
68
+ /** Transitive support for native Shadow DOM. A component in native mode
69
+ * transitively opts all of its descendants into native. */
70
+ readonly nearestShadowMode: ShadowMode | null;
68
71
  /** The component creation index. */
69
72
  idx: number;
70
73
  /** Component state, analogous to Element.isConnected */