@lwc/engine-core 6.0.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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Copyright (C) 2023 salesforce.com, inc.
2
+ * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
- import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, globalThis as globalThis$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, isObject, KEY__SYNTHETIC_MODE, isString, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, isFalse, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, ArrayShift, ArrayUnshift, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse } from '@lwc/shared';
4
+ import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArraySplice, create, seal, isAPIFeatureEnabled, isArray as isArray$1, isFunction as isFunction$1, keys, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, isObject, KEY__SYNTHETIC_MODE, isString, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, isFalse, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, StringSlice, ArrayShift, ArrayUnshift, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, ArrayPop, isNumber, StringReplace, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse } from '@lwc/shared';
5
5
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
6
6
 
7
7
  /*
@@ -409,6 +409,25 @@ function assertNotProd() {
409
409
  throw new ReferenceError();
410
410
  }
411
411
  }
412
+ // Temporary fix for when the LWC v5 compiler is used in conjunction with a v6+ engine
413
+ // The old compiler format used the "slot" attribute in the `data` bag, whereas the new
414
+ // format uses the special `slotAssignment` key.
415
+ // This should be removed when the LWC v5 compiler is not used anywhere where it could be mismatched
416
+ // with another LWC engine version.
417
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
418
+ function applyTemporaryCompilerV5SlotFix(data) {
419
+ if (lwcRuntimeFlags.DISABLE_TEMPORARY_V5_COMPILER_SUPPORT) {
420
+ return data;
421
+ }
422
+ const { attrs } = data;
423
+ if (!isUndefined$1(attrs)) {
424
+ const { slot } = attrs;
425
+ if (!isUndefined$1(slot) && !isNull(slot)) {
426
+ return Object.assign(Object.assign({}, data), { attrs: cloneAndOmitKey(attrs, 'slot'), slotAssignment: String(slot) });
427
+ }
428
+ }
429
+ return data;
430
+ }
412
431
 
413
432
  /*
414
433
  * Copyright (c) 2020, salesforce.com, inc.
@@ -425,8 +444,8 @@ function isCircularModuleDependency(obj) {
425
444
  }
426
445
 
427
446
  var _a, _b;
428
- const instrumentDef = (_a = globalThis$1.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : noop;
429
- const instrumentInstance = (_b = globalThis$1.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
447
+ const instrumentDef = (_a = globalThis.__lwc_instrument_cmp_def) !== null && _a !== void 0 ? _a : noop;
448
+ const instrumentInstance = (_b = globalThis.__lwc_instrument_cmp_instance) !== null && _b !== void 0 ? _b : noop;
430
449
 
431
450
  /*
432
451
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3148,6 +3167,10 @@ function createComponentDef(Ctor) {
3148
3167
  ctorShadowSupportMode !== "native" /* ShadowSupportMode.Native */) {
3149
3168
  logError(`Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
3150
3169
  }
3170
+ // TODO [#3971]: Completely remove shadowSupportMode "any"
3171
+ if (ctorShadowSupportMode === "any" /* ShadowSupportMode.Any */) {
3172
+ logWarn(`Invalid value 'any' for static property shadowSupportMode. 'any' is deprecated and will be removed in a future release--use 'native' instead.`);
3173
+ }
3151
3174
  if (!isUndefined$1(ctorRenderMode) &&
3152
3175
  ctorRenderMode !== 'light' &&
3153
3176
  ctorRenderMode !== 'shadow') {
@@ -4816,6 +4839,8 @@ function h(sel, data, children = EmptyArray) {
4816
4839
  }
4817
4840
  });
4818
4841
  }
4842
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
4843
+ data = applyTemporaryCompilerV5SlotFix(data);
4819
4844
  const { key, slotAssignment } = data;
4820
4845
  const vnode = {
4821
4846
  type: 2 /* VNodeType.Element */,
@@ -4852,6 +4877,8 @@ function s(slotName, data, children, slotset) {
4852
4877
  }
4853
4878
  const vmBeingRendered = getVMBeingRendered();
4854
4879
  const { renderMode, apiVersion } = vmBeingRendered;
4880
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
4881
+ data = applyTemporaryCompilerV5SlotFix(data);
4855
4882
  if (!isUndefined$1(slotset) &&
4856
4883
  !isUndefined$1(slotset.slotAssignments) &&
4857
4884
  !isUndefined$1(slotset.slotAssignments[slotName]) &&
@@ -4955,6 +4982,8 @@ function c(sel, Ctor, data, children = EmptyArray) {
4955
4982
  });
4956
4983
  }
4957
4984
  }
4985
+ // TODO [#3974]: remove temporary logic to support v5 compiler + v6+ engine
4986
+ data = applyTemporaryCompilerV5SlotFix(data);
4958
4987
  const { key, slotAssignment } = data;
4959
4988
  let elm, aChildren, vm;
4960
4989
  const vnode = {
@@ -5479,7 +5508,6 @@ const parseSVGFragment = buildParseFragmentFn((html, renderer) => {
5479
5508
  });
5480
5509
  function evaluateTemplate(vm, html) {
5481
5510
  if (process.env.NODE_ENV !== 'production') {
5482
- assert.isTrue(isFunction$1(html), `evaluateTemplate() second argument must be an imported template instead of ${toString$1(html)}`);
5483
5511
  // in dev-mode, we support hot swapping of templates, which means that
5484
5512
  // the component instance might be attempting to use an old version of
5485
5513
  // the template, while internally, we have a replacement for it.
@@ -5498,6 +5526,10 @@ function evaluateTemplate(vm, html) {
5498
5526
  tro.observe(() => {
5499
5527
  // Reset the cache memoizer for template when needed.
5500
5528
  if (html !== cmpTemplate) {
5529
+ // Check that the template was built by the compiler.
5530
+ if (!isTemplateRegistered(html)) {
5531
+ throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
5532
+ }
5501
5533
  if (process.env.NODE_ENV !== 'production') {
5502
5534
  validateLightDomTemplate(html, vm);
5503
5535
  }
@@ -5509,10 +5541,6 @@ function evaluateTemplate(vm, html) {
5509
5541
  // and snabbdom just rely on the IDs.
5510
5542
  resetComponentRoot(vm);
5511
5543
  }
5512
- // Check that the template was built by the compiler.
5513
- if (!isTemplateRegistered(html)) {
5514
- throw new TypeError(`Invalid template returned by the render() method on ${vm}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
5515
- }
5516
5544
  vm.cmpTemplate = html;
5517
5545
  // Create a brand new template cache for the swapped templated.
5518
5546
  context.tplCache = create(null);
@@ -5887,7 +5915,7 @@ function createVM(elm, ctor, renderer, options) {
5887
5915
  vm.debugInfo = create(null);
5888
5916
  }
5889
5917
  vm.stylesheets = computeStylesheets(vm, def.ctor);
5890
- const computedShadowMode = computeShadowMode(def, vm.owner, renderer);
5918
+ const computedShadowMode = computeShadowMode(def, vm.owner, renderer, hydrated);
5891
5919
  if (lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
5892
5920
  vm.shadowMode = 0 /* ShadowMode.Native */;
5893
5921
  vm.shadowMigrateMode = computedShadowMode === 1 /* ShadowMode.Synthetic */;
@@ -5974,48 +6002,45 @@ function computeShadowAndRenderMode(Ctor, renderer) {
5974
6002
  const def = getComponentInternalDef(Ctor);
5975
6003
  const { renderMode } = def;
5976
6004
  // Assume null `owner` - this is what happens in hydration cases anyway
5977
- const shadowMode = computeShadowMode(def, /* owner */ null, renderer);
6005
+ // Also assume we are not in hydration mode for this exported API
6006
+ const shadowMode = computeShadowMode(def, /* owner */ null, renderer, false);
5978
6007
  return { renderMode, shadowMode };
5979
6008
  }
5980
- function computeShadowMode(def, owner, renderer) {
6009
+ function computeShadowMode(def, owner, renderer, hydrated) {
5981
6010
  // Force the shadow mode to always be native. Used for running tests with synthetic shadow patches
5982
6011
  // on, but components running in actual native shadow mode
5983
6012
  if (process.env.NODE_ENV !== 'production' &&
5984
6013
  lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
5985
6014
  return 0 /* ShadowMode.Native */;
5986
6015
  }
6016
+ if (isTrue(hydrated)) {
6017
+ // hydration only supports native shadow
6018
+ return 0 /* ShadowMode.Native */;
6019
+ }
5987
6020
  const { isSyntheticShadowDefined } = renderer;
5988
6021
  let shadowMode;
5989
- // If ENABLE_FORCE_SHADOW_MIGRATE_MODE is true, then ShadowMode.Synthetic here will mean "force-migrate" mode.
5990
6022
  if (isSyntheticShadowDefined || lwcRuntimeFlags.ENABLE_FORCE_SHADOW_MIGRATE_MODE) {
5991
6023
  if (def.renderMode === 0 /* RenderMode.Light */) {
5992
6024
  // ShadowMode.Native implies "not synthetic shadow" which is consistent with how
5993
6025
  // everything defaults to native when the synthetic shadow polyfill is unavailable.
5994
6026
  shadowMode = 0 /* ShadowMode.Native */;
5995
6027
  }
5996
- else if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE ||
5997
- def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
5998
- if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */ ||
5999
- def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6028
+ else if (def.shadowSupportMode === "native" /* ShadowSupportMode.Native */) {
6029
+ shadowMode = 0 /* ShadowMode.Native */;
6030
+ }
6031
+ else {
6032
+ const shadowAncestor = getNearestShadowAncestor(owner);
6033
+ if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
6034
+ // Transitive support for native Shadow DOM. A component in native mode
6035
+ // transitively opts all of its descendants into native.
6000
6036
  shadowMode = 0 /* ShadowMode.Native */;
6001
6037
  }
6002
6038
  else {
6003
- const shadowAncestor = getNearestShadowAncestor(owner);
6004
- if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
6005
- // Transitive support for native Shadow DOM. A component in native mode
6006
- // transitively opts all of its descendants into native.
6007
- shadowMode = 0 /* ShadowMode.Native */;
6008
- }
6009
- else {
6010
- // Synthetic if neither this component nor any of its ancestors are configured
6011
- // to be native.
6012
- shadowMode = 1 /* ShadowMode.Synthetic */;
6013
- }
6039
+ // Synthetic if neither this component nor any of its ancestors are configured
6040
+ // to be native.
6041
+ shadowMode = 1 /* ShadowMode.Synthetic */;
6014
6042
  }
6015
6043
  }
6016
- else {
6017
- shadowMode = 1 /* ShadowMode.Synthetic */;
6018
- }
6019
6044
  }
6020
6045
  else {
6021
6046
  // Native if the synthetic shadow polyfill is unavailable.
@@ -6390,12 +6415,12 @@ function resetRefVNodes(vm) {
6390
6415
  // See: https://sfdc.co/synthetic-aria
6391
6416
  //
6392
6417
  // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
6393
- const getElementById = globalThis$1[KEY__NATIVE_GET_ELEMENT_BY_ID];
6394
- const querySelectorAll = globalThis$1[KEY__NATIVE_QUERY_SELECTOR_ALL];
6418
+ const getElementById = globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
6419
+ const querySelectorAll = globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
6395
6420
  // This is a "handoff" from synthetic-shadow to engine-core – we want to clean up after ourselves
6396
6421
  // so nobody else can misuse these global APIs.
6397
- delete globalThis$1[KEY__NATIVE_GET_ELEMENT_BY_ID];
6398
- delete globalThis$1[KEY__NATIVE_QUERY_SELECTOR_ALL];
6422
+ delete globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
6423
+ delete globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
6399
6424
  function isSyntheticShadowRootInstance(rootNode) {
6400
6425
  return rootNode !== document && isTrue(rootNode.synthetic);
6401
6426
  }
@@ -7404,5 +7429,5 @@ function readonly(obj) {
7404
7429
  }
7405
7430
 
7406
7431
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7407
- /** version: 6.0.0 */
7432
+ /** version: 6.1.1 */
7408
7433
  //# sourceMappingURL=index.js.map