@lwc/engine-core 2.21.1 → 2.23.1

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.
@@ -1,7 +1,7 @@
1
1
  /* proxy-compat-disable */
2
- import { runtimeFlags } from '@lwc/features';
2
+ import { lwcRuntimeFlags } from '@lwc/features';
3
3
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
4
- import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, 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, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
4
+ import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, 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, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
5
5
 
6
6
  /*
7
7
  * Copyright (c) 2018, salesforce.com, inc.
@@ -15,7 +15,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
15
15
  window.addEventListener('test-dummy-flag', () => {
16
16
  let hasFlag = false;
17
17
 
18
- if (runtimeFlags.DUMMY_TEST_FLAG) {
18
+ if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
19
19
  hasFlag = true;
20
20
  }
21
21
 
@@ -213,11 +213,28 @@ class ReactiveObserver {
213
213
  * SPDX-License-Identifier: MIT
214
214
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
215
215
  */
216
+ const DUMMY_REACTIVE_OBSERVER = {
217
+ observe(job) {
218
+ job();
219
+ },
220
+ reset() { },
221
+ link() { },
222
+ };
216
223
  function componentValueMutated(vm, key) {
217
- valueMutated(vm.component, key);
224
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
225
+ if (process.env.IS_BROWSER) {
226
+ valueMutated(vm.component, key);
227
+ }
218
228
  }
219
229
  function componentValueObserved(vm, key) {
220
- valueObserved(vm.component, key);
230
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
231
+ if (process.env.IS_BROWSER) {
232
+ valueObserved(vm.component, key);
233
+ }
234
+ }
235
+ function createReactiveObserver(callback) {
236
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
237
+ return process.env.IS_BROWSER ? new ReactiveObserver(callback) : DUMMY_REACTIVE_OBSERVER;
221
238
  }
222
239
 
223
240
  /*
@@ -776,6 +793,14 @@ function patchLightningElementPrototypeWithRestrictions(proto) {
776
793
  defineProperties(proto, getLightningElementPrototypeRestrictionsDescriptors(proto));
777
794
  }
778
795
 
796
+ function updateComponentValue(vm, key, newValue) {
797
+ const { cmpFields } = vm;
798
+ if (newValue !== cmpFields[key]) {
799
+ cmpFields[key] = newValue;
800
+ componentValueMutated(vm, key);
801
+ }
802
+ }
803
+
779
804
  /**
780
805
  * Copyright (C) 2017 salesforce.com, inc.
781
806
  */
@@ -1339,7 +1364,24 @@ const reactiveMembrane = new ObservableMembrane({
1339
1364
  * change or being removed.
1340
1365
  */
1341
1366
  function unwrap(value) {
1342
- return reactiveMembrane.unwrapProxy(value);
1367
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1368
+ return process.env.IS_BROWSER ? reactiveMembrane.unwrapProxy(value) : value;
1369
+ }
1370
+ function getReadOnlyProxy(value) {
1371
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1372
+ // them from their parents. This applies to both the client and server.
1373
+ return reactiveMembrane.getReadOnlyProxy(value);
1374
+ }
1375
+ function getReactiveProxy(value) {
1376
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1377
+ return process.env.IS_BROWSER ? reactiveMembrane.getProxy(value) : value;
1378
+ }
1379
+ // Making the component instance a live value when using Locker to support expandos.
1380
+ function markLockerLiveObject(obj) {
1381
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1382
+ if (process.env.IS_BROWSER) {
1383
+ obj[lockerLivePropertyKey] = undefined;
1384
+ }
1343
1385
  }
1344
1386
 
1345
1387
  /*
@@ -1391,10 +1433,7 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1391
1433
  assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
1392
1434
  assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
1393
1435
  }
1394
- if (newValue !== vm.cmpProps[propName]) {
1395
- vm.cmpProps[propName] = newValue;
1396
- componentValueMutated(vm, propName);
1397
- }
1436
+ updateComponentValue(vm, propName, newValue);
1398
1437
  return set.call(vm.elm, newValue);
1399
1438
  },
1400
1439
  };
@@ -1429,8 +1468,7 @@ const LightningElement = function () {
1429
1468
  vm.setHook = setHook;
1430
1469
  vm.getHook = getHook;
1431
1470
  }
1432
- // Making the component instance a live value when using Locker to support expandos.
1433
- this[lockerLivePropertyKey] = undefined;
1471
+ markLockerLiveObject(this);
1434
1472
  // Linking elm, shadow root and component with the VM.
1435
1473
  associateVM(component, vm);
1436
1474
  associateVM(elm, vm);
@@ -1690,16 +1728,67 @@ function createObservedFieldPropertyDescriptor(key) {
1690
1728
  },
1691
1729
  set(newValue) {
1692
1730
  const vm = getAssociatedVM(this);
1693
- if (newValue !== vm.cmpFields[key]) {
1694
- vm.cmpFields[key] = newValue;
1695
- componentValueMutated(vm, key);
1696
- }
1731
+ updateComponentValue(vm, key, newValue);
1697
1732
  },
1698
1733
  enumerable: true,
1699
1734
  configurable: true,
1700
1735
  };
1701
1736
  }
1702
1737
 
1738
+ /*
1739
+ * Copyright (c) 2018, salesforce.com, inc.
1740
+ * All rights reserved.
1741
+ * SPDX-License-Identifier: MIT
1742
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
1743
+ */
1744
+ const DUMMY_ACCESSOR_REACTIVE_OBSERVER = {
1745
+ observe(job) {
1746
+ job();
1747
+ },
1748
+ reset() { },
1749
+ link() { },
1750
+ };
1751
+ class AccessorReactiveObserver extends ReactiveObserver {
1752
+ constructor(vm, set) {
1753
+ super(() => {
1754
+ if (isFalse(this.debouncing)) {
1755
+ this.debouncing = true;
1756
+ addCallbackToNextTick(() => {
1757
+ if (isTrue(this.debouncing)) {
1758
+ const { value } = this;
1759
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
1760
+ set.call(component, value);
1761
+ // de-bouncing after the call to the original setter to prevent
1762
+ // infinity loop if the setter itself is mutating things that
1763
+ // were accessed during the previous invocation.
1764
+ this.debouncing = false;
1765
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1766
+ // immediate rehydration due to a setter driven mutation, otherwise
1767
+ // the component will get rendered on the second tick, which it is not
1768
+ // desirable.
1769
+ rerenderVM(vm);
1770
+ }
1771
+ }
1772
+ });
1773
+ }
1774
+ });
1775
+ this.debouncing = false;
1776
+ }
1777
+ reset(value) {
1778
+ super.reset();
1779
+ this.debouncing = false;
1780
+ if (arguments.length > 0) {
1781
+ this.value = value;
1782
+ }
1783
+ }
1784
+ }
1785
+ function createAccessorReactiveObserver(vm, set) {
1786
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1787
+ return process.env.IS_BROWSER
1788
+ ? new AccessorReactiveObserver(vm, set)
1789
+ : DUMMY_ACCESSOR_REACTIVE_OBSERVER;
1790
+ }
1791
+
1703
1792
  /*
1704
1793
  * Copyright (c) 2018, salesforce.com, inc.
1705
1794
  * All rights reserved.
@@ -1747,50 +1836,6 @@ function createPublicPropertyDescriptor(key) {
1747
1836
  configurable: true
1748
1837
  };
1749
1838
  }
1750
- class AccessorReactiveObserver extends ReactiveObserver {
1751
- constructor(vm, set) {
1752
- super(() => {
1753
- if (isFalse(this.debouncing)) {
1754
- this.debouncing = true;
1755
- addCallbackToNextTick(() => {
1756
- if (isTrue(this.debouncing)) {
1757
- const {
1758
- value
1759
- } = this;
1760
- const {
1761
- isDirty: dirtyStateBeforeSetterCall,
1762
- component,
1763
- idx
1764
- } = vm;
1765
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
1766
- // infinity loop if the setter itself is mutating things that
1767
- // were accessed during the previous invocation.
1768
-
1769
- this.debouncing = false;
1770
-
1771
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
1772
- // immediate rehydration due to a setter driven mutation, otherwise
1773
- // the component will get rendered on the second tick, which it is not
1774
- // desirable.
1775
- rerenderVM(vm);
1776
- }
1777
- }
1778
- });
1779
- }
1780
- });
1781
- this.debouncing = false;
1782
- }
1783
-
1784
- reset(value) {
1785
- super.reset();
1786
- this.debouncing = false;
1787
-
1788
- if (arguments.length > 0) {
1789
- this.value = value;
1790
- }
1791
- }
1792
-
1793
- }
1794
1839
  function createPublicAccessorDescriptor(key, descriptor) {
1795
1840
  const {
1796
1841
  get,
@@ -1827,11 +1872,11 @@ function createPublicAccessorDescriptor(key, descriptor) {
1827
1872
  }
1828
1873
 
1829
1874
  if (set) {
1830
- if (runtimeFlags.ENABLE_REACTIVE_SETTER) {
1875
+ if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
1831
1876
  let ro = vm.oar[key];
1832
1877
 
1833
1878
  if (isUndefined$1(ro)) {
1834
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
1879
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
1835
1880
  } // every time we invoke this setter from outside (through this wrapper setter)
1836
1881
  // we should reset the value and then debounce just in case there is a pending
1837
1882
  // invocation the next tick that is not longer relevant since the value is changing
@@ -1863,7 +1908,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
1863
1908
  */
1864
1909
  function track(target) {
1865
1910
  if (arguments.length === 1) {
1866
- return reactiveMembrane.getProxy(target);
1911
+ return getReactiveProxy(target);
1867
1912
  }
1868
1913
  if (process.env.NODE_ENV !== 'production') {
1869
1914
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -1884,11 +1929,8 @@ function internalTrackDecorator(key) {
1884
1929
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
1885
1930
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
1886
1931
  }
1887
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
1888
- if (reactiveOrAnyValue !== vm.cmpFields[key]) {
1889
- vm.cmpFields[key] = reactiveOrAnyValue;
1890
- componentValueMutated(vm, key);
1891
- }
1932
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
1933
+ updateComponentValue(vm, key, reactiveOrAnyValue);
1892
1934
  },
1893
1935
  enumerable: true,
1894
1936
  configurable: true,
@@ -1927,10 +1969,7 @@ function internalWireFieldDecorator(key) {
1927
1969
  * letting the author to do the wrong thing, but it will keep our
1928
1970
  * system to be backward compatible.
1929
1971
  */
1930
- if (value !== vm.cmpFields[key]) {
1931
- vm.cmpFields[key] = value;
1932
- componentValueMutated(vm, key);
1933
- }
1972
+ updateComponentValue(vm, key, value);
1934
1973
  },
1935
1974
  enumerable: true,
1936
1975
  configurable: true,
@@ -2276,7 +2315,7 @@ function createSetter(key) {
2276
2315
  fn = cachedSetterByKey[key] = function (newValue) {
2277
2316
  const vm = getAssociatedVM(this);
2278
2317
  const { setHook } = vm;
2279
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2318
+ newValue = getReadOnlyProxy(newValue);
2280
2319
  setHook(vm.component, key, newValue);
2281
2320
  };
2282
2321
  }
@@ -2485,7 +2524,7 @@ function getTemplateOrSwappedTemplate(tpl) {
2485
2524
  throw new ReferenceError();
2486
2525
  }
2487
2526
 
2488
- if (runtimeFlags.ENABLE_HMR) {
2527
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2489
2528
  const visited = new Set();
2490
2529
 
2491
2530
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
@@ -2502,7 +2541,7 @@ function getComponentOrSwappedComponent(Ctor) {
2502
2541
  throw new ReferenceError();
2503
2542
  }
2504
2543
 
2505
- if (runtimeFlags.ENABLE_HMR) {
2544
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2506
2545
  const visited = new Set();
2507
2546
 
2508
2547
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
@@ -2519,7 +2558,7 @@ function getStyleOrSwappedStyle(style) {
2519
2558
  throw new ReferenceError();
2520
2559
  }
2521
2560
 
2522
- if (runtimeFlags.ENABLE_HMR) {
2561
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2523
2562
  const visited = new Set();
2524
2563
 
2525
2564
  while (swappedStyleMap.has(style) && !visited.has(style)) {
@@ -2536,7 +2575,7 @@ function setActiveVM(vm) {
2536
2575
  throw new ReferenceError();
2537
2576
  }
2538
2577
 
2539
- if (runtimeFlags.ENABLE_HMR) {
2578
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2540
2579
  // tracking active component
2541
2580
  const Ctor = vm.def.ctor;
2542
2581
  let componentVMs = activeComponents.get(Ctor);
@@ -2593,7 +2632,7 @@ function removeActiveVM(vm) {
2593
2632
  throw new ReferenceError();
2594
2633
  }
2595
2634
 
2596
- if (runtimeFlags.ENABLE_HMR) {
2635
+ if (lwcRuntimeFlags.ENABLE_HMR) {
2597
2636
  // tracking inactive component
2598
2637
  const Ctor = vm.def.ctor;
2599
2638
  let list = activeComponents.get(Ctor);
@@ -2640,7 +2679,7 @@ function swapTemplate(oldTpl, newTpl) {
2640
2679
  }
2641
2680
  }
2642
2681
 
2643
- if (!runtimeFlags.ENABLE_HMR) {
2682
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2644
2683
  throw new Error('HMR is not enabled');
2645
2684
  }
2646
2685
 
@@ -2656,7 +2695,7 @@ function swapComponent(oldComponent, newComponent) {
2656
2695
  }
2657
2696
  }
2658
2697
 
2659
- if (!runtimeFlags.ENABLE_HMR) {
2698
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2660
2699
  throw new Error('HMR is not enabled');
2661
2700
  }
2662
2701
 
@@ -2670,7 +2709,7 @@ function swapStyle(oldStyle, newStyle) {
2670
2709
  return rehydrateHotStyle(oldStyle);
2671
2710
  }
2672
2711
 
2673
- if (!runtimeFlags.ENABLE_HMR) {
2712
+ if (!lwcRuntimeFlags.ENABLE_HMR) {
2674
2713
  throw new Error('HMR is not enabled');
2675
2714
  }
2676
2715
 
@@ -3019,13 +3058,13 @@ function getNearestNativeShadowComponent(vm) {
3019
3058
  return owner;
3020
3059
  }
3021
3060
  function createStylesheet(vm, stylesheets) {
3022
- const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
3061
+ const { renderMode, shadowMode, renderer: { insertStylesheet }, } = vm;
3023
3062
  if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
3024
3063
  for (let i = 0; i < stylesheets.length; i++) {
3025
3064
  insertStylesheet(stylesheets[i]);
3026
3065
  }
3027
3066
  }
3028
- else if (ssr || vm.hydrated) {
3067
+ else if (!process.env.IS_BROWSER || vm.hydrated) {
3029
3068
  // Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
3030
3069
  // This works in the client, because the stylesheets are created, and cached in the VM
3031
3070
  // the first time the VM renders.
@@ -3326,7 +3365,7 @@ function patchChildren(c1, c2, parent, renderer) {
3326
3365
  updateStaticChildren(c1, c2, parent, renderer);
3327
3366
  }
3328
3367
  }
3329
- function patch(n1, n2, renderer) {
3368
+ function patch(n1, n2, parent, renderer) {
3330
3369
  var _a, _b;
3331
3370
  if (n1 === n2) {
3332
3371
  return;
@@ -3355,7 +3394,7 @@ function patch(n1, n2, renderer) {
3355
3394
  patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
3356
3395
  break;
3357
3396
  case 3 /* VNodeType.CustomElement */:
3358
- patchCustomElement(n1, n2, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3397
+ patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
3359
3398
  break;
3360
3399
  }
3361
3400
  }
@@ -3482,22 +3521,32 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3482
3521
  appendVM(vm);
3483
3522
  }
3484
3523
  }
3485
- function patchCustomElement(n1, n2, renderer) {
3486
- const elm = (n2.elm = n1.elm);
3487
- const vm = (n2.vm = n1.vm);
3488
- patchElementPropsAndAttrs$1(n1, n2, renderer);
3489
- if (!isUndefined$1(vm)) {
3490
- // in fallback mode, the allocation will always set children to
3491
- // empty and delegate the real allocation to the slot elements
3492
- allocateChildren(n2, vm);
3524
+ function patchCustomElement(n1, n2, parent, renderer) {
3525
+ if (n1.ctor !== n2.ctor) {
3526
+ // If the constructor, unmount the current component and mount a new one using the new
3527
+ // constructor.
3528
+ const anchor = renderer.nextSibling(n1.elm);
3529
+ unmount(n1, parent, renderer, true);
3530
+ mountCustomElement(n2, parent, anchor, renderer);
3493
3531
  }
3494
- // in fallback mode, the children will be always empty, so, nothing
3495
- // will happen, but in native, it does allocate the light dom
3496
- patchChildren(n1.children, n2.children, elm, renderer);
3497
- if (!isUndefined$1(vm)) {
3498
- // this will probably update the shadowRoot, but only if the vm is in a dirty state
3499
- // this is important to preserve the top to bottom synchronous rendering phase.
3500
- rerenderVM(vm);
3532
+ else {
3533
+ // Otherwise patch the existing component with new props/attrs/etc.
3534
+ const elm = (n2.elm = n1.elm);
3535
+ const vm = (n2.vm = n1.vm);
3536
+ patchElementPropsAndAttrs$1(n1, n2, renderer);
3537
+ if (!isUndefined$1(vm)) {
3538
+ // in fallback mode, the allocation will always set children to
3539
+ // empty and delegate the real allocation to the slot elements
3540
+ allocateChildren(n2, vm);
3541
+ }
3542
+ // in fallback mode, the children will be always empty, so, nothing
3543
+ // will happen, but in native, it does allocate the light dom
3544
+ patchChildren(n1.children, n2.children, elm, renderer);
3545
+ if (!isUndefined$1(vm)) {
3546
+ // this will probably update the shadowRoot, but only if the vm is in a dirty state
3547
+ // this is important to preserve the top to bottom synchronous rendering phase.
3548
+ rerenderVM(vm);
3549
+ }
3501
3550
  }
3502
3551
  }
3503
3552
  function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
@@ -3767,25 +3816,25 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3767
3816
  newEndVnode = newCh[--newEndIdx];
3768
3817
  }
3769
3818
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
3770
- patch(oldStartVnode, newStartVnode, renderer);
3819
+ patch(oldStartVnode, newStartVnode, parent, renderer);
3771
3820
  oldStartVnode = oldCh[++oldStartIdx];
3772
3821
  newStartVnode = newCh[++newStartIdx];
3773
3822
  }
3774
3823
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
3775
- patch(oldEndVnode, newEndVnode, renderer);
3824
+ patch(oldEndVnode, newEndVnode, parent, renderer);
3776
3825
  oldEndVnode = oldCh[--oldEndIdx];
3777
3826
  newEndVnode = newCh[--newEndIdx];
3778
3827
  }
3779
3828
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
3780
3829
  // Vnode moved right
3781
- patch(oldStartVnode, newEndVnode, renderer);
3830
+ patch(oldStartVnode, newEndVnode, parent, renderer);
3782
3831
  insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
3783
3832
  oldStartVnode = oldCh[++oldStartIdx];
3784
3833
  newEndVnode = newCh[--newEndIdx];
3785
3834
  }
3786
3835
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
3787
3836
  // Vnode moved left
3788
- patch(oldEndVnode, newStartVnode, renderer);
3837
+ patch(oldEndVnode, newStartVnode, parent, renderer);
3789
3838
  insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
3790
3839
  oldEndVnode = oldCh[--oldEndIdx];
3791
3840
  newStartVnode = newCh[++newStartIdx];
@@ -3808,7 +3857,7 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
3808
3857
  mount(newStartVnode, parent, renderer, oldStartVnode.elm);
3809
3858
  }
3810
3859
  else {
3811
- patch(elmToMove, newStartVnode, renderer);
3860
+ patch(elmToMove, newStartVnode, parent, renderer);
3812
3861
  // Delete the old child, but copy the array since it is read-only.
3813
3862
  // The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
3814
3863
  // so we only care about the `oldCh` object inside this function.
@@ -3868,7 +3917,7 @@ function updateStaticChildren(c1, c2, parent, renderer) {
3868
3917
  if (isVNode(n1)) {
3869
3918
  if (isVNode(n2)) {
3870
3919
  // both vnodes are equivalent, and we just need to patch them
3871
- patch(n1, n2, renderer);
3920
+ patch(n1, n2, parent, renderer);
3872
3921
  anchor = n2.elm;
3873
3922
  }
3874
3923
  else {
@@ -4202,13 +4251,6 @@ function fid(url) {
4202
4251
  }
4203
4252
  return url;
4204
4253
  }
4205
- /**
4206
- * Map to store an index value assigned to any dynamic component reference ingested
4207
- * by dc() api. This allows us to generate a unique unique per template per dynamic
4208
- * component reference to avoid diffing algo mismatches.
4209
- */
4210
- const DynamicImportedComponentMap = new Map();
4211
- let dynamicImportedComponentCounter = 0;
4212
4254
  /**
4213
4255
  * create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
4214
4256
  */
@@ -4225,18 +4267,7 @@ function dc(sel, Ctor, data, children = EmptyArray) {
4225
4267
  if (!isComponentConstructor(Ctor)) {
4226
4268
  throw new Error(`Invalid LWC Constructor ${toString$1(Ctor)} for custom element <${sel}>.`);
4227
4269
  }
4228
- let idx = DynamicImportedComponentMap.get(Ctor);
4229
- if (isUndefined$1(idx)) {
4230
- idx = dynamicImportedComponentCounter++;
4231
- DynamicImportedComponentMap.set(Ctor, idx);
4232
- }
4233
- // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
4234
- // to identify different constructors as vnodes with different keys to avoid reusing the
4235
- // element used for previous constructors.
4236
- // Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
4237
- // hoisting optimization.
4238
- const newData = Object.assign(Object.assign({}, data), { key: `dc:${idx}:${data.key}` });
4239
- return c(sel, Ctor, newData, children);
4270
+ return c(sel, Ctor, data, children);
4240
4271
  }
4241
4272
  /**
4242
4273
  * slow children collection marking mechanism. this API allows the compiler to signal
@@ -4712,7 +4743,7 @@ function getComponentRegisteredTemplate(Ctor) {
4712
4743
  return signedTemplateMap.get(Ctor);
4713
4744
  }
4714
4745
  function getTemplateReactiveObserver(vm) {
4715
- return new ReactiveObserver(() => {
4746
+ return createReactiveObserver(() => {
4716
4747
  const { isDirty } = vm;
4717
4748
  if (isFalse(isDirty)) {
4718
4749
  markComponentAsDirty(vm);
@@ -4962,7 +4993,7 @@ function createVM(elm, ctor, renderer, options) {
4962
4993
  return `[object:vm ${def.name} (${vm.idx})]`;
4963
4994
  };
4964
4995
 
4965
- if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
4996
+ if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
4966
4997
  vm.shadowMode = 0
4967
4998
  /* ShadowMode.Native */
4968
4999
  ;
@@ -5001,7 +5032,7 @@ function computeShadowMode(vm, renderer) {
5001
5032
  } else if (isNativeShadowDefined) {
5002
5033
  // Not combined with above condition because @lwc/features only supports identifiers in
5003
5034
  // the if-condition.
5004
- if (runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5035
+ if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
5005
5036
  if (def.shadowSupportMode === "any"
5006
5037
  /* ShadowSupportMode.Any */
5007
5038
  ) {
@@ -5130,13 +5161,10 @@ function runRenderedCallback(vm) {
5130
5161
  const {
5131
5162
  def: {
5132
5163
  renderedCallback
5133
- },
5134
- renderer: {
5135
- ssr
5136
5164
  }
5137
5165
  } = vm;
5138
5166
 
5139
- if (isTrue(ssr)) {
5167
+ if (!process.env.IS_BROWSER) {
5140
5168
  return;
5141
5169
  }
5142
5170
 
@@ -5389,13 +5417,7 @@ function resetComponentRoot(vm) {
5389
5417
  vm.velements = EmptyArray;
5390
5418
  }
5391
5419
  function scheduleRehydration(vm) {
5392
- const {
5393
- renderer: {
5394
- ssr
5395
- }
5396
- } = vm;
5397
-
5398
- if (isTrue(ssr) || isTrue(vm.isScheduled)) {
5420
+ if (!process.env.IS_BROWSER || isTrue(vm.isScheduled)) {
5399
5421
  return;
5400
5422
  }
5401
5423
 
@@ -5502,15 +5524,8 @@ class WireContextRegistrationEvent extends CustomEvent {
5502
5524
  }
5503
5525
 
5504
5526
  function createFieldDataCallback(vm, name) {
5505
- const {
5506
- cmpFields
5507
- } = vm;
5508
5527
  return value => {
5509
- if (value !== vm.cmpFields[name]) {
5510
- // storing the value in the underlying storage
5511
- cmpFields[name] = value;
5512
- componentValueMutated(vm, name);
5513
- }
5528
+ updateComponentValue(vm, name, value);
5514
5529
  };
5515
5530
  }
5516
5531
 
@@ -5527,7 +5542,7 @@ function createMethodDataCallback(vm, method) {
5527
5542
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
5528
5543
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
5529
5544
 
5530
- const ro = new ReactiveObserver(() => {
5545
+ const ro = createReactiveObserver(() => {
5531
5546
  if (hasPendingConfig === false) {
5532
5547
  hasPendingConfig = true; // collect new config in the micro-task
5533
5548
 
@@ -5728,7 +5743,7 @@ function installWireAdapters(vm) {
5728
5743
  ArrayPush$1.call(wiredConnecting, () => {
5729
5744
  connector.connect();
5730
5745
 
5731
- if (!runtimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5746
+ if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
5732
5747
  if (hasDynamicParams) {
5733
5748
  Promise.resolve().then(computeConfigAndUpdate);
5734
5749
  return;
@@ -5823,7 +5838,7 @@ function readonly(obj) {
5823
5838
  assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
5824
5839
  }
5825
5840
  }
5826
- return reactiveMembrane.getReadOnlyProxy(obj);
5841
+ return getReadOnlyProxy(obj);
5827
5842
  }
5828
5843
 
5829
5844
  /*
@@ -6336,4 +6351,4 @@ function getComponentConstructor(elm) {
6336
6351
  }
6337
6352
 
6338
6353
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6339
- /* version: 2.21.1 */
6354
+ /* version: 2.23.1 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.21.1",
3
+ "version": "2.23.1",
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.21.1",
29
- "@lwc/shared": "2.21.1"
28
+ "@lwc/features": "2.23.1",
29
+ "@lwc/shared": "2.23.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "observable-membrane": "2.0.0"
@@ -0,0 +1,9 @@
1
+ import { ReactiveObserver } from '../libs/mutation-tracker';
2
+ import { VM } from './vm';
3
+ export declare class AccessorReactiveObserver extends ReactiveObserver {
4
+ private value;
5
+ private debouncing;
6
+ constructor(vm: VM, set: (v: any) => void);
7
+ reset(value?: any): void;
8
+ }
9
+ export declare function createAccessorReactiveObserver(vm: VM, set: (v: any) => void): AccessorReactiveObserver;
@@ -1,4 +1,4 @@
1
- import { ReactiveObserver } from '../libs/mutation-tracker';
1
+ import { ReactiveObserver } from './mutation-tracker';
2
2
  import { VM } from './vm';
3
3
  import { LightningElementConstructor } from './base-lightning-element';
4
4
  import { Template } from './template';
@@ -1,5 +1,3 @@
1
- import { ReactiveObserver } from '../mutation-tracker';
2
- import { VM } from '../vm';
3
1
  /**
4
2
  * @api decorator to mark public fields and public methods in
5
3
  * LWC Components. This function implements the internals of this
@@ -7,10 +5,4 @@ import { VM } from '../vm';
7
5
  */
8
6
  export default function api(target: any, propertyKey: string, descriptor: PropertyDescriptor): void;
9
7
  export declare function createPublicPropertyDescriptor(key: string): PropertyDescriptor;
10
- export declare class AccessorReactiveObserver extends ReactiveObserver {
11
- private value;
12
- private debouncing;
13
- constructor(vm: VM, set: (v: any) => void);
14
- reset(value?: any): void;
15
- }
16
8
  export declare function createPublicAccessorDescriptor(key: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor;