@lwc/engine-core 2.5.10 → 2.7.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.
@@ -1428,6 +1428,7 @@ const {
1428
1428
  isArray
1429
1429
  } = Array;
1430
1430
  const {
1431
+ prototype: ObjectDotPrototype,
1431
1432
  getPrototypeOf,
1432
1433
  create: ObjectCreate,
1433
1434
  defineProperty: ObjectDefineProperty,
@@ -2077,8 +2078,6 @@ if (process.env.NODE_ENV !== 'production') {
2077
2078
  init();
2078
2079
  }
2079
2080
 
2080
- const ObjectDotPrototype = Object.prototype;
2081
-
2082
2081
  function defaultValueIsObservable(value) {
2083
2082
  // intentionally checking for null
2084
2083
  if (value === null) {
@@ -2106,99 +2105,85 @@ const defaultValueMutated = (obj, key) => {
2106
2105
  /* do nothing */
2107
2106
  };
2108
2107
 
2109
- const defaultValueDistortion = value => value;
2110
-
2111
2108
  function createShadowTarget(value) {
2112
2109
  return isArray(value) ? [] : {};
2113
2110
  }
2114
2111
 
2115
- class ReactiveMembrane {
2116
- constructor(options) {
2117
- this.valueDistortion = defaultValueDistortion;
2118
- this.valueMutated = defaultValueMutated;
2119
- this.valueObserved = defaultValueObserved;
2120
- this.valueIsObservable = defaultValueIsObservable;
2112
+ class ObservableMembrane {
2113
+ constructor(options = {}) {
2121
2114
  this.readOnlyObjectGraph = new WeakMap();
2122
2115
  this.reactiveObjectGraph = new WeakMap();
2123
-
2124
- if (!isUndefined(options)) {
2125
- const {
2126
- valueDistortion,
2127
- valueMutated,
2128
- valueObserved,
2129
- valueIsObservable,
2130
- tagPropertyKey
2131
- } = options;
2132
- this.valueDistortion = isFunction(valueDistortion) ? valueDistortion : defaultValueDistortion;
2133
- this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2134
- this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2135
- this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2136
- this.tagPropertyKey = tagPropertyKey;
2137
- }
2116
+ const {
2117
+ valueMutated,
2118
+ valueObserved,
2119
+ valueIsObservable,
2120
+ tagPropertyKey
2121
+ } = options;
2122
+ this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2123
+ this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2124
+ this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2125
+ this.tagPropertyKey = tagPropertyKey;
2138
2126
  }
2139
2127
 
2140
2128
  getProxy(value) {
2141
2129
  const unwrappedValue = unwrap$1(value);
2142
- const distorted = this.valueDistortion(unwrappedValue);
2143
2130
 
2144
- if (this.valueIsObservable(distorted)) {
2145
- if (this.readOnlyObjectGraph.get(distorted) === value) {
2146
- // when trying to extract the writable version of a readonly
2147
- // we return the readonly.
2131
+ if (this.valueIsObservable(unwrappedValue)) {
2132
+ // When trying to extract the writable version of a readonly we return the readonly.
2133
+ if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
2148
2134
  return value;
2149
2135
  }
2150
2136
 
2151
- return this.getReactiveHandler(unwrappedValue, distorted);
2137
+ return this.getReactiveHandler(unwrappedValue);
2152
2138
  }
2153
2139
 
2154
- return distorted;
2140
+ return unwrappedValue;
2155
2141
  }
2156
2142
 
2157
2143
  getReadOnlyProxy(value) {
2158
2144
  value = unwrap$1(value);
2159
- const distorted = this.valueDistortion(value);
2160
2145
 
2161
- if (this.valueIsObservable(distorted)) {
2162
- return this.getReadOnlyHandler(value, distorted);
2146
+ if (this.valueIsObservable(value)) {
2147
+ return this.getReadOnlyHandler(value);
2163
2148
  }
2164
2149
 
2165
- return distorted;
2150
+ return value;
2166
2151
  }
2167
2152
 
2168
2153
  unwrapProxy(p) {
2169
2154
  return unwrap$1(p);
2170
2155
  }
2171
2156
 
2172
- getReactiveHandler(value, distortedValue) {
2173
- let proxy = this.reactiveObjectGraph.get(distortedValue);
2157
+ getReactiveHandler(value) {
2158
+ let proxy = this.reactiveObjectGraph.get(value);
2174
2159
 
2175
2160
  if (isUndefined(proxy)) {
2176
2161
  // caching the proxy after the first time it is accessed
2177
- const handler = new ReactiveProxyHandler(this, distortedValue);
2178
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2162
+ const handler = new ReactiveProxyHandler(this, value);
2163
+ proxy = new Proxy(createShadowTarget(value), handler);
2179
2164
  registerProxy(proxy, value);
2180
- this.reactiveObjectGraph.set(distortedValue, proxy);
2165
+ this.reactiveObjectGraph.set(value, proxy);
2181
2166
  }
2182
2167
 
2183
2168
  return proxy;
2184
2169
  }
2185
2170
 
2186
- getReadOnlyHandler(value, distortedValue) {
2187
- let proxy = this.readOnlyObjectGraph.get(distortedValue);
2171
+ getReadOnlyHandler(value) {
2172
+ let proxy = this.readOnlyObjectGraph.get(value);
2188
2173
 
2189
2174
  if (isUndefined(proxy)) {
2190
2175
  // caching the proxy after the first time it is accessed
2191
- const handler = new ReadOnlyHandler(this, distortedValue);
2192
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2176
+ const handler = new ReadOnlyHandler(this, value);
2177
+ proxy = new Proxy(createShadowTarget(value), handler);
2193
2178
  registerProxy(proxy, value);
2194
- this.readOnlyObjectGraph.set(distortedValue, proxy);
2179
+ this.readOnlyObjectGraph.set(value, proxy);
2195
2180
  }
2196
2181
 
2197
2182
  return proxy;
2198
2183
  }
2199
2184
 
2200
2185
  }
2201
- /** version: 1.1.5 */
2186
+ /** version: 2.0.0 */
2202
2187
 
2203
2188
  /*
2204
2189
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2207,15 +2192,9 @@ class ReactiveMembrane {
2207
2192
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2208
2193
  */
2209
2194
  const lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
2210
-
2211
- function valueDistortion(value) {
2212
- return value;
2213
- }
2214
-
2215
- const reactiveMembrane = new ReactiveMembrane({
2195
+ const reactiveMembrane = new ObservableMembrane({
2216
2196
  valueObserved,
2217
2197
  valueMutated,
2218
- valueDistortion,
2219
2198
  tagPropertyKey: lockerLivePropertyKey
2220
2199
  });
2221
2200
  /**
@@ -2224,16 +2203,9 @@ const reactiveMembrane = new ReactiveMembrane({
2224
2203
  * change or being removed.
2225
2204
  */
2226
2205
 
2227
- const unwrap = function (value) {
2228
- const unwrapped = reactiveMembrane.unwrapProxy(value);
2229
-
2230
- if (unwrapped !== value) {
2231
- // if value is a proxy, unwrap to access original value and apply distortion
2232
- return valueDistortion(unwrapped);
2233
- }
2234
-
2235
- return value;
2236
- };
2206
+ function unwrap(value) {
2207
+ return reactiveMembrane.unwrapProxy(value);
2208
+ }
2237
2209
 
2238
2210
  /*
2239
2211
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3801,10 +3773,6 @@ function createComponentDef(Ctor) {
3801
3773
 
3802
3774
  shared.assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3803
3775
 
3804
- if (!features.runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
3805
- shared.assert.isFalse('shadowSupportMode' in Ctor, `${ctorName || 'Anonymous class'} is an invalid LWC component. The shadowSupportMode static property is not available in this environment.`);
3806
- }
3807
-
3808
3776
  if (!shared.isUndefined(ctorShadowSupportMode)) {
3809
3777
  shared.assert.invariant(ctorShadowSupportMode === "any"
3810
3778
  /* Any */
@@ -4182,13 +4150,15 @@ function updateElmHook(oldVnode, vnode) {
4182
4150
  }
4183
4151
  function updateChildrenHook(oldVnode, vnode) {
4184
4152
  const {
4185
- children,
4186
- owner
4153
+ elm,
4154
+ children
4187
4155
  } = vnode;
4188
- const fn = hasDynamicChildren(children) ? updateDynamicChildren : updateStaticChildren;
4189
- runWithBoundaryProtection(owner, owner.owner, shared.noop, () => {
4190
- fn(vnode.elm, oldVnode.children, children);
4191
- }, shared.noop);
4156
+
4157
+ if (hasDynamicChildren(children)) {
4158
+ updateDynamicChildren(elm, oldVnode.children, children);
4159
+ } else {
4160
+ updateStaticChildren(elm, oldVnode.children, children);
4161
+ }
4192
4162
  }
4193
4163
  function allocateChildrenHook(vnode, vm) {
4194
4164
  // A component with slots will re-render because:
@@ -5416,6 +5386,7 @@ function updateStylesheetToken(vm, template) {
5416
5386
 
5417
5387
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5418
5388
  const content = [];
5389
+ let root;
5419
5390
 
5420
5391
  for (let i = 0; i < stylesheets.length; i++) {
5421
5392
  let stylesheet = stylesheets[i];
@@ -5428,23 +5399,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5428
5399
  // the component instance might be attempting to use an old version of
5429
5400
  // the stylesheet, while internally, we have a replacement for it.
5430
5401
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5431
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5432
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5402
+ }
5433
5403
 
5404
+ const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5405
+
5406
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5407
+ /* Synthetic */
5408
+ && vm.renderMode === 1
5409
+ /* Shadow */
5410
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5411
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5434
5412
 
5435
- const isScopedCss = stylesheet[shared.KEY__SCOPED_CSS];
5436
5413
  const useActualHostSelector = vm.renderMode === 0
5437
5414
  /* Light */
5438
5415
  ? !isScopedCss : vm.shadowMode === 0
5439
5416
  /* Native */
5440
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5417
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5418
+ // we use an attribute selector on the host to simulate :dir().
5441
5419
 
5442
- const scopeToken = isScopedCss || vm.shadowMode === 1
5443
- /* Synthetic */
5444
- && vm.renderMode === 1
5420
+ let useNativeDirPseudoclass;
5421
+
5422
+ if (vm.renderMode === 1
5445
5423
  /* Shadow */
5446
- ? stylesheetToken : undefined;
5447
- shared.ArrayPush.call(content, stylesheet(useActualHostSelector, scopeToken));
5424
+ ) {
5425
+ useNativeDirPseudoclass = vm.shadowMode === 0
5426
+ /* Native */
5427
+ ;
5428
+ } else {
5429
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5430
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5431
+ if (shared.isUndefined(root)) {
5432
+ // Only calculate the root once as necessary
5433
+ root = getNearestShadowComponent(vm);
5434
+ }
5435
+
5436
+ useNativeDirPseudoclass = shared.isNull(root) || root.shadowMode === 0
5437
+ /* Native */
5438
+ ;
5439
+ }
5440
+
5441
+ shared.ArrayPush.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5448
5442
  }
5449
5443
  }
5450
5444
 
@@ -5467,14 +5461,12 @@ function getStylesheetsContent(vm, template) {
5467
5461
  // perf testing has not shown it to be a huge improvement yet:
5468
5462
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5469
5463
 
5470
- function getNearestNativeShadowComponent(vm) {
5464
+ function getNearestShadowComponent(vm) {
5471
5465
  let owner = vm;
5472
5466
 
5473
5467
  while (!shared.isNull(owner)) {
5474
5468
  if (owner.renderMode === 1
5475
5469
  /* Shadow */
5476
- && owner.shadowMode === 0
5477
- /* Native */
5478
5470
  ) {
5479
5471
  return owner;
5480
5472
  }
@@ -5485,6 +5477,20 @@ function getNearestNativeShadowComponent(vm) {
5485
5477
  return owner;
5486
5478
  }
5487
5479
 
5480
+ function getNearestNativeShadowComponent(vm) {
5481
+ const owner = getNearestShadowComponent(vm);
5482
+
5483
+ if (!shared.isNull(owner) && owner.shadowMode === 1
5484
+ /* Synthetic */
5485
+ ) {
5486
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5487
+ // synthetic, we know we won't find a native component if we go any further.
5488
+ return null;
5489
+ }
5490
+
5491
+ return owner;
5492
+ }
5493
+
5488
5494
  function createStylesheet(vm, stylesheets) {
5489
5495
  const {
5490
5496
  renderer,
@@ -5600,7 +5606,7 @@ function logOperationStart(opId, vm) {
5600
5606
  if (isProfilerEnabled) {
5601
5607
  currentDispatcher(opId, 0
5602
5608
  /* Start */
5603
- , vm.tagName, vm.idx);
5609
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5604
5610
  }
5605
5611
  }
5606
5612
  function logOperationEnd(opId, vm) {
@@ -5613,7 +5619,7 @@ function logOperationEnd(opId, vm) {
5613
5619
  if (isProfilerEnabled) {
5614
5620
  currentDispatcher(opId, 1
5615
5621
  /* Stop */
5616
- , vm.tagName, vm.idx);
5622
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5617
5623
  }
5618
5624
  }
5619
5625
  function logGlobalOperationStart(opId, vm) {
@@ -5626,7 +5632,7 @@ function logGlobalOperationStart(opId, vm) {
5626
5632
  if (isProfilerEnabled) {
5627
5633
  currentDispatcher(opId, 0
5628
5634
  /* Start */
5629
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5635
+ , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
5630
5636
  }
5631
5637
  }
5632
5638
  function logGlobalOperationEnd(opId, vm) {
@@ -5639,7 +5645,7 @@ function logGlobalOperationEnd(opId, vm) {
5639
5645
  if (isProfilerEnabled) {
5640
5646
  currentDispatcher(opId, 1
5641
5647
  /* Stop */
5642
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5648
+ , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
5643
5649
  }
5644
5650
  }
5645
5651
 
@@ -5792,6 +5798,7 @@ function evaluateTemplate(vm, html) {
5792
5798
 
5793
5799
  return vnodes;
5794
5800
  }
5801
+
5795
5802
  function computeHasScopedStyles(template) {
5796
5803
  const {
5797
5804
  stylesheets
@@ -7210,4 +7217,4 @@ exports.swapTemplate = swapTemplate;
7210
7217
  exports.track = track;
7211
7218
  exports.unwrap = unwrap;
7212
7219
  exports.wire = wire;
7213
- /* version: 2.5.10 */
7220
+ /* version: 2.7.1 */
@@ -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, assign, assert, keys, StringCharCodeAt, isString, StringSlice, freeze, defineProperties, forEach, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, getPropertyDescriptor, isObject, AriaPropNameToAttrNameMap, defineProperty, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, ArrayFilter, noop, isArray as isArray$1, isNumber, StringReplace, KEY__SHADOW_RESOLVER, KEY__SCOPED_CSS, ArrayUnshift, isFrozen } from '@lwc/shared';
2
+ import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, assign, assert, keys, StringCharCodeAt, isString, StringSlice, freeze, defineProperties, forEach, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, getPropertyDescriptor, isObject, AriaPropNameToAttrNameMap, defineProperty, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, htmlPropertyToAttribute, ArraySlice, hasOwnProperty as hasOwnProperty$1, ArrayFilter, isArray as isArray$1, isNumber, StringReplace, KEY__SHADOW_RESOLVER, KEY__SCOPED_CSS, noop, ArrayUnshift, isFrozen } from '@lwc/shared';
3
3
  import { runtimeFlags } from '@lwc/features';
4
4
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
5
5
 
@@ -1425,6 +1425,7 @@ const {
1425
1425
  isArray
1426
1426
  } = Array;
1427
1427
  const {
1428
+ prototype: ObjectDotPrototype,
1428
1429
  getPrototypeOf,
1429
1430
  create: ObjectCreate,
1430
1431
  defineProperty: ObjectDefineProperty,
@@ -2074,8 +2075,6 @@ if (process.env.NODE_ENV !== 'production') {
2074
2075
  init();
2075
2076
  }
2076
2077
 
2077
- const ObjectDotPrototype = Object.prototype;
2078
-
2079
2078
  function defaultValueIsObservable(value) {
2080
2079
  // intentionally checking for null
2081
2080
  if (value === null) {
@@ -2103,99 +2102,85 @@ const defaultValueMutated = (obj, key) => {
2103
2102
  /* do nothing */
2104
2103
  };
2105
2104
 
2106
- const defaultValueDistortion = value => value;
2107
-
2108
2105
  function createShadowTarget(value) {
2109
2106
  return isArray(value) ? [] : {};
2110
2107
  }
2111
2108
 
2112
- class ReactiveMembrane {
2113
- constructor(options) {
2114
- this.valueDistortion = defaultValueDistortion;
2115
- this.valueMutated = defaultValueMutated;
2116
- this.valueObserved = defaultValueObserved;
2117
- this.valueIsObservable = defaultValueIsObservable;
2109
+ class ObservableMembrane {
2110
+ constructor(options = {}) {
2118
2111
  this.readOnlyObjectGraph = new WeakMap();
2119
2112
  this.reactiveObjectGraph = new WeakMap();
2120
-
2121
- if (!isUndefined(options)) {
2122
- const {
2123
- valueDistortion,
2124
- valueMutated,
2125
- valueObserved,
2126
- valueIsObservable,
2127
- tagPropertyKey
2128
- } = options;
2129
- this.valueDistortion = isFunction(valueDistortion) ? valueDistortion : defaultValueDistortion;
2130
- this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2131
- this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2132
- this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2133
- this.tagPropertyKey = tagPropertyKey;
2134
- }
2113
+ const {
2114
+ valueMutated,
2115
+ valueObserved,
2116
+ valueIsObservable,
2117
+ tagPropertyKey
2118
+ } = options;
2119
+ this.valueMutated = isFunction(valueMutated) ? valueMutated : defaultValueMutated;
2120
+ this.valueObserved = isFunction(valueObserved) ? valueObserved : defaultValueObserved;
2121
+ this.valueIsObservable = isFunction(valueIsObservable) ? valueIsObservable : defaultValueIsObservable;
2122
+ this.tagPropertyKey = tagPropertyKey;
2135
2123
  }
2136
2124
 
2137
2125
  getProxy(value) {
2138
2126
  const unwrappedValue = unwrap$1(value);
2139
- const distorted = this.valueDistortion(unwrappedValue);
2140
2127
 
2141
- if (this.valueIsObservable(distorted)) {
2142
- if (this.readOnlyObjectGraph.get(distorted) === value) {
2143
- // when trying to extract the writable version of a readonly
2144
- // we return the readonly.
2128
+ if (this.valueIsObservable(unwrappedValue)) {
2129
+ // When trying to extract the writable version of a readonly we return the readonly.
2130
+ if (this.readOnlyObjectGraph.get(unwrappedValue) === value) {
2145
2131
  return value;
2146
2132
  }
2147
2133
 
2148
- return this.getReactiveHandler(unwrappedValue, distorted);
2134
+ return this.getReactiveHandler(unwrappedValue);
2149
2135
  }
2150
2136
 
2151
- return distorted;
2137
+ return unwrappedValue;
2152
2138
  }
2153
2139
 
2154
2140
  getReadOnlyProxy(value) {
2155
2141
  value = unwrap$1(value);
2156
- const distorted = this.valueDistortion(value);
2157
2142
 
2158
- if (this.valueIsObservable(distorted)) {
2159
- return this.getReadOnlyHandler(value, distorted);
2143
+ if (this.valueIsObservable(value)) {
2144
+ return this.getReadOnlyHandler(value);
2160
2145
  }
2161
2146
 
2162
- return distorted;
2147
+ return value;
2163
2148
  }
2164
2149
 
2165
2150
  unwrapProxy(p) {
2166
2151
  return unwrap$1(p);
2167
2152
  }
2168
2153
 
2169
- getReactiveHandler(value, distortedValue) {
2170
- let proxy = this.reactiveObjectGraph.get(distortedValue);
2154
+ getReactiveHandler(value) {
2155
+ let proxy = this.reactiveObjectGraph.get(value);
2171
2156
 
2172
2157
  if (isUndefined(proxy)) {
2173
2158
  // caching the proxy after the first time it is accessed
2174
- const handler = new ReactiveProxyHandler(this, distortedValue);
2175
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2159
+ const handler = new ReactiveProxyHandler(this, value);
2160
+ proxy = new Proxy(createShadowTarget(value), handler);
2176
2161
  registerProxy(proxy, value);
2177
- this.reactiveObjectGraph.set(distortedValue, proxy);
2162
+ this.reactiveObjectGraph.set(value, proxy);
2178
2163
  }
2179
2164
 
2180
2165
  return proxy;
2181
2166
  }
2182
2167
 
2183
- getReadOnlyHandler(value, distortedValue) {
2184
- let proxy = this.readOnlyObjectGraph.get(distortedValue);
2168
+ getReadOnlyHandler(value) {
2169
+ let proxy = this.readOnlyObjectGraph.get(value);
2185
2170
 
2186
2171
  if (isUndefined(proxy)) {
2187
2172
  // caching the proxy after the first time it is accessed
2188
- const handler = new ReadOnlyHandler(this, distortedValue);
2189
- proxy = new Proxy(createShadowTarget(distortedValue), handler);
2173
+ const handler = new ReadOnlyHandler(this, value);
2174
+ proxy = new Proxy(createShadowTarget(value), handler);
2190
2175
  registerProxy(proxy, value);
2191
- this.readOnlyObjectGraph.set(distortedValue, proxy);
2176
+ this.readOnlyObjectGraph.set(value, proxy);
2192
2177
  }
2193
2178
 
2194
2179
  return proxy;
2195
2180
  }
2196
2181
 
2197
2182
  }
2198
- /** version: 1.1.5 */
2183
+ /** version: 2.0.0 */
2199
2184
 
2200
2185
  /*
2201
2186
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2204,15 +2189,9 @@ class ReactiveMembrane {
2204
2189
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
2205
2190
  */
2206
2191
  const lockerLivePropertyKey = Symbol.for('@@lockerLiveValue');
2207
-
2208
- function valueDistortion(value) {
2209
- return value;
2210
- }
2211
-
2212
- const reactiveMembrane = new ReactiveMembrane({
2192
+ const reactiveMembrane = new ObservableMembrane({
2213
2193
  valueObserved,
2214
2194
  valueMutated,
2215
- valueDistortion,
2216
2195
  tagPropertyKey: lockerLivePropertyKey
2217
2196
  });
2218
2197
  /**
@@ -2221,16 +2200,9 @@ const reactiveMembrane = new ReactiveMembrane({
2221
2200
  * change or being removed.
2222
2201
  */
2223
2202
 
2224
- const unwrap = function (value) {
2225
- const unwrapped = reactiveMembrane.unwrapProxy(value);
2226
-
2227
- if (unwrapped !== value) {
2228
- // if value is a proxy, unwrap to access original value and apply distortion
2229
- return valueDistortion(unwrapped);
2230
- }
2231
-
2232
- return value;
2233
- };
2203
+ function unwrap(value) {
2204
+ return reactiveMembrane.unwrapProxy(value);
2205
+ }
2234
2206
 
2235
2207
  /*
2236
2208
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3798,10 +3770,6 @@ function createComponentDef(Ctor) {
3798
3770
 
3799
3771
  assert.isTrue(Ctor.constructor, `Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3800
3772
 
3801
- if (!runtimeFlags.ENABLE_MIXED_SHADOW_MODE) {
3802
- assert.isFalse('shadowSupportMode' in Ctor, `${ctorName || 'Anonymous class'} is an invalid LWC component. The shadowSupportMode static property is not available in this environment.`);
3803
- }
3804
-
3805
3773
  if (!isUndefined$1(ctorShadowSupportMode)) {
3806
3774
  assert.invariant(ctorShadowSupportMode === "any"
3807
3775
  /* Any */
@@ -4179,13 +4147,15 @@ function updateElmHook(oldVnode, vnode) {
4179
4147
  }
4180
4148
  function updateChildrenHook(oldVnode, vnode) {
4181
4149
  const {
4182
- children,
4183
- owner
4150
+ elm,
4151
+ children
4184
4152
  } = vnode;
4185
- const fn = hasDynamicChildren(children) ? updateDynamicChildren : updateStaticChildren;
4186
- runWithBoundaryProtection(owner, owner.owner, noop, () => {
4187
- fn(vnode.elm, oldVnode.children, children);
4188
- }, noop);
4153
+
4154
+ if (hasDynamicChildren(children)) {
4155
+ updateDynamicChildren(elm, oldVnode.children, children);
4156
+ } else {
4157
+ updateStaticChildren(elm, oldVnode.children, children);
4158
+ }
4189
4159
  }
4190
4160
  function allocateChildrenHook(vnode, vm) {
4191
4161
  // A component with slots will re-render because:
@@ -5413,6 +5383,7 @@ function updateStylesheetToken(vm, template) {
5413
5383
 
5414
5384
  function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5415
5385
  const content = [];
5386
+ let root;
5416
5387
 
5417
5388
  for (let i = 0; i < stylesheets.length; i++) {
5418
5389
  let stylesheet = stylesheets[i];
@@ -5425,23 +5396,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
5425
5396
  // the component instance might be attempting to use an old version of
5426
5397
  // the stylesheet, while internally, we have a replacement for it.
5427
5398
  stylesheet = getStyleOrSwappedStyle(stylesheet);
5428
- } // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5429
- // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5399
+ }
5430
5400
 
5401
+ const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5402
+
5403
+ const scopeToken = isScopedCss || vm.shadowMode === 1
5404
+ /* Synthetic */
5405
+ && vm.renderMode === 1
5406
+ /* Shadow */
5407
+ ? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
5408
+ // native shadow DOM. Synthetic shadow DOM never uses `:host`.
5431
5409
 
5432
- const isScopedCss = stylesheet[KEY__SCOPED_CSS];
5433
5410
  const useActualHostSelector = vm.renderMode === 0
5434
5411
  /* Light */
5435
5412
  ? !isScopedCss : vm.shadowMode === 0
5436
5413
  /* Native */
5437
- ; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
5414
+ ; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
5415
+ // we use an attribute selector on the host to simulate :dir().
5438
5416
 
5439
- const scopeToken = isScopedCss || vm.shadowMode === 1
5440
- /* Synthetic */
5441
- && vm.renderMode === 1
5417
+ let useNativeDirPseudoclass;
5418
+
5419
+ if (vm.renderMode === 1
5442
5420
  /* Shadow */
5443
- ? stylesheetToken : undefined;
5444
- ArrayPush$1.call(content, stylesheet(useActualHostSelector, scopeToken));
5421
+ ) {
5422
+ useNativeDirPseudoclass = vm.shadowMode === 0
5423
+ /* Native */
5424
+ ;
5425
+ } else {
5426
+ // Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
5427
+ // At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
5428
+ if (isUndefined$1(root)) {
5429
+ // Only calculate the root once as necessary
5430
+ root = getNearestShadowComponent(vm);
5431
+ }
5432
+
5433
+ useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
5434
+ /* Native */
5435
+ ;
5436
+ }
5437
+
5438
+ ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
5445
5439
  }
5446
5440
  }
5447
5441
 
@@ -5464,14 +5458,12 @@ function getStylesheetsContent(vm, template) {
5464
5458
  // perf testing has not shown it to be a huge improvement yet:
5465
5459
  // https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
5466
5460
 
5467
- function getNearestNativeShadowComponent(vm) {
5461
+ function getNearestShadowComponent(vm) {
5468
5462
  let owner = vm;
5469
5463
 
5470
5464
  while (!isNull(owner)) {
5471
5465
  if (owner.renderMode === 1
5472
5466
  /* Shadow */
5473
- && owner.shadowMode === 0
5474
- /* Native */
5475
5467
  ) {
5476
5468
  return owner;
5477
5469
  }
@@ -5482,6 +5474,20 @@ function getNearestNativeShadowComponent(vm) {
5482
5474
  return owner;
5483
5475
  }
5484
5476
 
5477
+ function getNearestNativeShadowComponent(vm) {
5478
+ const owner = getNearestShadowComponent(vm);
5479
+
5480
+ if (!isNull(owner) && owner.shadowMode === 1
5481
+ /* Synthetic */
5482
+ ) {
5483
+ // Synthetic-within-native is impossible. So if the nearest shadow component is
5484
+ // synthetic, we know we won't find a native component if we go any further.
5485
+ return null;
5486
+ }
5487
+
5488
+ return owner;
5489
+ }
5490
+
5485
5491
  function createStylesheet(vm, stylesheets) {
5486
5492
  const {
5487
5493
  renderer,
@@ -5597,7 +5603,7 @@ function logOperationStart(opId, vm) {
5597
5603
  if (isProfilerEnabled) {
5598
5604
  currentDispatcher(opId, 0
5599
5605
  /* Start */
5600
- , vm.tagName, vm.idx);
5606
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5601
5607
  }
5602
5608
  }
5603
5609
  function logOperationEnd(opId, vm) {
@@ -5610,7 +5616,7 @@ function logOperationEnd(opId, vm) {
5610
5616
  if (isProfilerEnabled) {
5611
5617
  currentDispatcher(opId, 1
5612
5618
  /* Stop */
5613
- , vm.tagName, vm.idx);
5619
+ , vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
5614
5620
  }
5615
5621
  }
5616
5622
  function logGlobalOperationStart(opId, vm) {
@@ -5623,7 +5629,7 @@ function logGlobalOperationStart(opId, vm) {
5623
5629
  if (isProfilerEnabled) {
5624
5630
  currentDispatcher(opId, 0
5625
5631
  /* Start */
5626
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5632
+ , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
5627
5633
  }
5628
5634
  }
5629
5635
  function logGlobalOperationEnd(opId, vm) {
@@ -5636,7 +5642,7 @@ function logGlobalOperationEnd(opId, vm) {
5636
5642
  if (isProfilerEnabled) {
5637
5643
  currentDispatcher(opId, 1
5638
5644
  /* Stop */
5639
- , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx);
5645
+ , vm === null || vm === void 0 ? void 0 : vm.tagName, vm === null || vm === void 0 ? void 0 : vm.idx, vm === null || vm === void 0 ? void 0 : vm.renderMode, vm === null || vm === void 0 ? void 0 : vm.shadowMode);
5640
5646
  }
5641
5647
  }
5642
5648
 
@@ -5789,6 +5795,7 @@ function evaluateTemplate(vm, html) {
5789
5795
 
5790
5796
  return vnodes;
5791
5797
  }
5798
+
5792
5799
  function computeHasScopedStyles(template) {
5793
5800
  const {
5794
5801
  stylesheets
@@ -7174,4 +7181,4 @@ function setHooks(hooks) {
7174
7181
  }
7175
7182
 
7176
7183
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentDef, getComponentInternalDef, getUpgradableConstructor, hydrateRootElement, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7177
- /* version: 2.5.10 */
7184
+ /* version: 2.7.1 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.5.10",
3
+ "version": "2.7.1",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,14 +24,14 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.5.10",
28
- "@lwc/shared": "2.5.10"
27
+ "@lwc/features": "2.7.1",
28
+ "@lwc/shared": "2.7.1"
29
29
  },
30
30
  "devDependencies": {
31
- "observable-membrane": "1.1.5"
31
+ "observable-membrane": "2.0.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "44a0ea56fa42bf411aa91514e958f386e3a1d191"
36
+ "gitHead": "1b2e246e03c6bfbc80bea3def43b7d0281a1de21"
37
37
  }
@@ -7,13 +7,6 @@
7
7
  https://github.com/snabbdom/snabbdom/
8
8
  */
9
9
  import { VM } from '../../framework/vm';
10
- export declare type VNodeStyleDecls = Array<[string, string, boolean]>;
11
- export interface On {
12
- [event: string]: EventListener;
13
- }
14
- export declare type Attrs = Record<string, string | number | boolean>;
15
- export declare type Classes = Record<string, boolean>;
16
- export declare type Props = Record<string, any>;
17
10
  export declare type Key = string | number;
18
11
  export declare type VNodes = Array<VNode | null>;
19
12
  export interface VNode {
@@ -53,16 +46,15 @@ export interface VComment extends VNode {
53
46
  text: string;
54
47
  key: undefined;
55
48
  }
56
- export declare type CustomElementContext = Record<string, Record<string, any>>;
57
49
  export interface VNodeData {
58
- props?: Props;
59
- attrs?: Attrs;
60
- className?: any;
61
- style?: any;
62
- classMap?: Classes;
63
- styleDecls?: VNodeStyleDecls;
64
- context?: CustomElementContext;
65
- on?: On;
50
+ props?: Record<string, any>;
51
+ attrs?: Record<string, string | number | boolean>;
52
+ className?: string;
53
+ style?: string;
54
+ classMap?: Record<string, boolean>;
55
+ styleDecls?: Array<[string, string, boolean]>;
56
+ context?: Record<string, Record<string, any>>;
57
+ on?: Record<string, Function>;
66
58
  svg?: boolean;
67
59
  }
68
60
  export interface VElementData extends VNodeData {
@@ -76,7 +68,3 @@ export interface Hooks<N extends VNode> {
76
68
  remove: (vNode: N, parentNode: Node) => void;
77
69
  hydrate: (vNode: N, node: Node) => void;
78
70
  }
79
- export interface Module<N extends VNode> {
80
- create?: (vNode: N) => void;
81
- update?: (oldVNode: N, vNode: N) => void;
82
- }
@@ -1,4 +1,4 @@
1
- import ObservableMembrane from 'observable-membrane';
1
+ import { ObservableMembrane } from 'observable-membrane';
2
2
  export declare const lockerLivePropertyKey: unique symbol;
3
3
  export declare const reactiveMembrane: ObservableMembrane;
4
4
  /**
@@ -6,4 +6,4 @@ export declare const reactiveMembrane: ObservableMembrane;
6
6
  * works for observable membrane objects. This API is subject to
7
7
  * change or being removed.
8
8
  */
9
- export declare const unwrap: (value: any) => any;
9
+ export declare function unwrap(value: any): any;
@@ -1,4 +1,4 @@
1
- import { VM } from './vm';
1
+ import { RenderMode, ShadowMode, VM } from './vm';
2
2
  export declare const enum OperationId {
3
3
  Constructor = 0,
4
4
  Render = 1,
@@ -15,7 +15,7 @@ declare const enum Phase {
15
15
  Start = 0,
16
16
  Stop = 1
17
17
  }
18
- declare type LogDispatcher = (opId: OperationId, phase: Phase, cmpName?: string, vmIndex?: number) => void;
18
+ declare type LogDispatcher = (opId: OperationId, phase: Phase, cmpName?: string, vmIndex?: number, renderMode?: RenderMode, shadowMode?: ShadowMode) => void;
19
19
  export declare const profilerControl: {
20
20
  enableProfiler(): void;
21
21
  disableProfiler(): void;
@@ -5,7 +5,7 @@ import { Template } from './template';
5
5
  * Function producing style based on a host and a shadow selector. This function is invoked by
6
6
  * the engine with different values depending on the mode that the component is running on.
7
7
  */
8
- export declare type StylesheetFactory = (useActualHostSelector: boolean, stylesheetToken: string | undefined) => string;
8
+ export declare type StylesheetFactory = (stylesheetToken: string | undefined, useActualHostSelector: boolean, useNativeDirPseudoclass: boolean) => string;
9
9
  /**
10
10
  * The list of stylesheets associated with a template. Each entry is either a StylesheetFactory or a
11
11
  * TemplateStylesheetFactory a given stylesheet depends on other external stylesheets (via the
@@ -17,4 +17,3 @@ export declare let isUpdatingTemplate: boolean;
17
17
  export declare function getVMBeingRendered(): VM | null;
18
18
  export declare function setVMBeingRendered(vm: VM | null): void;
19
19
  export declare function evaluateTemplate(vm: VM, html: Template): Array<VNode | null>;
20
- export declare function computeHasScopedStyles(template: Template): boolean;