@lwc/engine-core 6.1.0 → 6.1.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,5 +1,6 @@
1
1
  import { StylesheetFactory, TemplateStylesheetFactories } from './stylesheet';
2
2
  import { LightningElementConstructor } from './base-lightning-element';
3
+ import { VElementData } from './vnodes';
3
4
  type Callback = () => void;
4
5
  export declare const SPACE_CHAR = 32;
5
6
  export declare const EmptyObject: any;
@@ -17,4 +18,23 @@ export declare function cloneAndOmitKey(object: {
17
18
  };
18
19
  export declare function flattenStylesheets(stylesheets: TemplateStylesheetFactories): StylesheetFactory[];
19
20
  export declare function assertNotProd(): void;
21
+ export declare function applyTemporaryCompilerV5SlotFix(data: VElementData): VElementData | {
22
+ attrs: {
23
+ [key: string]: any;
24
+ };
25
+ slotAssignment: string;
26
+ key: import("./vnodes").Key;
27
+ external?: boolean | undefined;
28
+ ref?: string | undefined;
29
+ slotData?: any;
30
+ props?: Readonly<Record<string, any>> | undefined;
31
+ className?: string | undefined;
32
+ style?: string | undefined;
33
+ classMap?: Readonly<Record<string, boolean>> | undefined;
34
+ styleDecls?: readonly [string, string, boolean][] | undefined;
35
+ context?: Readonly<Record<string, Readonly<Record<string, any>>>> | undefined;
36
+ on?: Readonly<Record<string, (event: Event) => any>> | undefined;
37
+ svg?: boolean | undefined;
38
+ renderer?: import("./renderer").RendererAPI | undefined;
39
+ };
20
40
  export {};
@@ -30,6 +30,7 @@ export declare const enum ShadowMode {
30
30
  Synthetic = 1
31
31
  }
32
32
  export declare const enum ShadowSupportMode {
33
+ Any = "any",
33
34
  Default = "reset",
34
35
  Native = "native"
35
36
  }
package/dist/index.cjs.js CHANGED
@@ -413,6 +413,25 @@ function assertNotProd() {
413
413
  throw new ReferenceError();
414
414
  }
415
415
  }
416
+ // Temporary fix for when the LWC v5 compiler is used in conjunction with a v6+ engine
417
+ // The old compiler format used the "slot" attribute in the `data` bag, whereas the new
418
+ // format uses the special `slotAssignment` key.
419
+ // This should be removed when the LWC v5 compiler is not used anywhere where it could be mismatched
420
+ // with another LWC engine version.
421
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
422
+ function applyTemporaryCompilerV5SlotFix(data) {
423
+ if (lwcRuntimeFlags.DISABLE_TEMPORARY_V5_COMPILER_SUPPORT) {
424
+ return data;
425
+ }
426
+ const { attrs } = data;
427
+ if (!shared.isUndefined(attrs)) {
428
+ const { slot } = attrs;
429
+ if (!shared.isUndefined(slot) && !shared.isNull(slot)) {
430
+ return Object.assign(Object.assign({}, data), { attrs: cloneAndOmitKey(attrs, 'slot'), slotAssignment: String(slot) });
431
+ }
432
+ }
433
+ return data;
434
+ }
416
435
 
417
436
  /*
418
437
  * Copyright (c) 2020, salesforce.com, inc.
@@ -3147,10 +3166,15 @@ function createComponentDef(Ctor) {
3147
3166
  logError(`Missing ${ctorName}.constructor, ${ctorName} should have a "constructor" property.`);
3148
3167
  }
3149
3168
  if (!shared.isUndefined(ctorShadowSupportMode) &&
3169
+ ctorShadowSupportMode !== "any" /* ShadowSupportMode.Any */ &&
3150
3170
  ctorShadowSupportMode !== "reset" /* ShadowSupportMode.Default */ &&
3151
3171
  ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
3152
3172
  logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3153
3173
  }
3174
+ // TODO [#3971]: Completely remove shadowSupportMode "any"
3175
+ if (ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */) {
3176
+ logWarn(`Invalid value 'any' for static property shadowSupportMode. 'any' is deprecated and will be removed in a future release--use 'native' instead.`);
3177
+ }
3154
3178
  if (!shared.isUndefined(ctorRenderMode) &&
3155
3179
  ctorRenderMode !== 'light' &&
3156
3180
  ctorRenderMode !== 'shadow') {
@@ -4819,6 +4843,8 @@ function h(sel, data, children = EmptyArray) {
4819
4843
  }
4820
4844
  });
4821
4845
  }
4846
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
4847
+ data = applyTemporaryCompilerV5SlotFix(data);
4822
4848
  const { key, slotAssignment } = data;
4823
4849
  const vnode = {
4824
4850
  type: 2 /* VNodeType.Element */,
@@ -4855,6 +4881,8 @@ function s(slotName, data, children, slotset) {
4855
4881
  }
4856
4882
  const vmBeingRendered = getVMBeingRendered();
4857
4883
  const { renderMode, apiVersion } = vmBeingRendered;
4884
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
4885
+ data = applyTemporaryCompilerV5SlotFix(data);
4858
4886
  if (!shared.isUndefined(slotset) &&
4859
4887
  !shared.isUndefined(slotset.slotAssignments) &&
4860
4888
  !shared.isUndefined(slotset.slotAssignments[slotName]) &&
@@ -4958,6 +4986,8 @@ function c(sel, Ctor, data, children = EmptyArray) {
4958
4986
  });
4959
4987
  }
4960
4988
  }
4989
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
4990
+ data = applyTemporaryCompilerV5SlotFix(data);
4961
4991
  const { key, slotAssignment } = data;
4962
4992
  let elm, aChildren, vm;
4963
4993
  const vnode = {
@@ -5889,7 +5919,7 @@ function createVM(elm, ctor, renderer, options) {
5889
5919
  vm.debugInfo = shared.create(null);
5890
5920
  }
5891
5921
  vm.stylesheets = computeStylesheets(vm, def.ctor);
5892
- const computedShadowMode = computeShadowMode(def, vm.owner, renderer);
5922
+ const computedShadowMode = computeShadowMode(def, vm.owner, renderer, hydrated);
5893
5923
  if (lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
5894
5924
  vm.shadowMode = 0 /* ShadowMode.Native */;
5895
5925
  vm.shadowMigrateMode = computedShadowMode === 1 /* ShadowMode.Synthetic */;
@@ -5976,16 +6006,21 @@ function computeShadowAndRenderMode(Ctor, renderer) {
5976
6006
  const def = getComponentInternalDef(Ctor);
5977
6007
  const { renderMode } = def;
5978
6008
  // Assume null `owner` - this is what happens in hydration cases anyway
5979
- const shadowMode = computeShadowMode(def, /* owner */ null, renderer);
6009
+ // Also assume we are not in hydration mode for this exported API
6010
+ const shadowMode = computeShadowMode(def, /* owner */ null, renderer, false);
5980
6011
  return { renderMode, shadowMode };
5981
6012
  }
5982
- function computeShadowMode(def, owner, renderer) {
6013
+ function computeShadowMode(def, owner, renderer, hydrated) {
5983
6014
  // Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
5984
6015
  // on, but components running in actual native shadow mode
5985
6016
  if (process.env.NODE_ENV !== 'production' &&
5986
6017
  lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5987
6018
  return 0 /* ShadowMode.Native */;
5988
6019
  }
6020
+ if (shared.isTrue(hydrated)) {
6021
+ // hydration only supports native shadow
6022
+ return 0 /* ShadowMode.Native */;
6023
+ }
5989
6024
  const { isSyntheticShadowDefined } = renderer;
5990
6025
  let shadowMode;
5991
6026
  if (isSyntheticShadowDefined || lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
@@ -7440,5 +7475,5 @@ exports.swapTemplate = swapTemplate;
7440
7475
  exports.track = track;
7441
7476
  exports.unwrap = unwrap;
7442
7477
  exports.wire = wire;
7443
- /** version: 6.1.0 */
7478
+ /** version: 6.1.1 */
7444
7479
  //# sourceMappingURL=index.cjs.js.map