@lwc/engine-core 8.13.3 → 8.15.0

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,4 +1,4 @@
1
- import { LightningElement } from './base-lightning-element';
1
+ import type { LightningElement } from './base-lightning-element';
2
2
  import type { VM } from './vm';
3
3
  import type { LightningElementConstructor } from './base-lightning-element';
4
4
  import type { VNodes } from './vnodes';
@@ -22,4 +22,5 @@ export declare function getScopeTokenClass(owner: VM, legacy: boolean): string |
22
22
  export declare function getStylesheetTokenHost(vnode: VCustomElement): string | null;
23
23
  export declare function createStylesheet(vm: VM, stylesheets: ReadonlyArray<string>): VNode[] | null;
24
24
  export declare function unrenderStylesheet(stylesheet: Stylesheet): void;
25
+ export declare function isValidScopeToken(token: unknown): boolean;
25
26
  //# sourceMappingURL=stylesheet.d.ts.map
package/dist/index.cjs.js CHANGED
@@ -2825,6 +2825,10 @@ if (process.env.NODE_ENV === 'test-karma-lwc') {
2825
2825
  function checkVersionMismatch(func, type) {
2826
2826
  const versionMatcher = func.toString().match(shared.LWC_VERSION_COMMENT_REGEX);
2827
2827
  if (!shared.isNull(versionMatcher) && !warned) {
2828
+ if (process.env.SKIP_LWC_VERSION_MISMATCH_CHECK === 'true') {
2829
+ warned = true; // skip printing out version mismatch errors when env var is set
2830
+ return;
2831
+ }
2828
2832
  const version = versionMatcher[1];
2829
2833
  if (version !== shared.LWC_VERSION) {
2830
2834
  warned = true; // only warn once to avoid flooding the console
@@ -3085,6 +3089,7 @@ shared.seal(BaseBridgeElement.prototype);
3085
3089
  * SPDX-License-Identifier: MIT
3086
3090
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3087
3091
  */
3092
+ const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_]+$/;
3088
3093
  // These are only used for HMR in dev mode
3089
3094
  // The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
3090
3095
  let stylesheetsToCssContent = /*@__PURE__@*/ new WeakMap();
@@ -3377,6 +3382,13 @@ function unrenderStylesheet(stylesheet) {
3377
3382
  cssContentToAbortControllers.delete(cssContent);
3378
3383
  }
3379
3384
  }
3385
+ function isValidScopeToken(token) {
3386
+ if (!shared.isString(token)) {
3387
+ return false;
3388
+ }
3389
+ // See W-16614556
3390
+ return lwcRuntimeFlags.DISABLE_SCOPE_TOKEN_VALIDATION || VALID_SCOPE_TOKEN_REGEX.test(token);
3391
+ }
3380
3392
 
3381
3393
  /*
3382
3394
  * Copyright (c) 2023, salesforce.com, inc.
@@ -4892,6 +4904,10 @@ function applyStyleScoping(elm, owner, renderer) {
4892
4904
  // Set the class name for `*.scoped.css` style scoping.
4893
4905
  const scopeToken = getScopeTokenClass(owner, /* legacy */ false);
4894
4906
  if (!shared.isNull(scopeToken)) {
4907
+ if (!isValidScopeToken(scopeToken)) {
4908
+ // See W-16614556
4909
+ throw new Error('stylesheet token must be a valid string');
4910
+ }
4895
4911
  // TODO [#2762]: this dot notation with add is probably problematic
4896
4912
  // probably we should have a renderer api for just the add operation
4897
4913
  getClassList(elm).add(scopeToken);
@@ -4900,6 +4916,10 @@ function applyStyleScoping(elm, owner, renderer) {
4900
4916
  if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
4901
4917
  const legacyScopeToken = getScopeTokenClass(owner, /* legacy */ true);
4902
4918
  if (!shared.isNull(legacyScopeToken)) {
4919
+ if (!isValidScopeToken(legacyScopeToken)) {
4920
+ // See W-16614556
4921
+ throw new Error('stylesheet token must be a valid string');
4922
+ }
4903
4923
  // TODO [#2762]: this dot notation with add is probably problematic
4904
4924
  // probably we should have a renderer api for just the add operation
4905
4925
  getClassList(elm).add(legacyScopeToken);
@@ -6126,12 +6146,6 @@ function getVMBeingRendered() {
6126
6146
  function setVMBeingRendered(vm) {
6127
6147
  vmBeingRendered = vm;
6128
6148
  }
6129
- const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_]+$/;
6130
- // See W-16614556
6131
- // TODO [#2826]: freeze the template object
6132
- function isValidScopeToken(token) {
6133
- return shared.isString(token) && VALID_SCOPE_TOKEN_REGEX.test(token);
6134
- }
6135
6149
  function validateSlots(vm) {
6136
6150
  assertNotProd(); // this method should never leak to prod
6137
6151
  const { cmpSlots } = vm;
@@ -6295,6 +6309,7 @@ function buildParseFragmentFn(createFragmentFn) {
6295
6309
  }
6296
6310
  }
6297
6311
  // See W-16614556
6312
+ // TODO [#2826]: freeze the template object
6298
6313
  if ((hasStyleToken && !isValidScopeToken(stylesheetToken)) ||
6299
6314
  (hasLegacyToken && !isValidScopeToken(legacyStylesheetToken))) {
6300
6315
  throw new Error('stylesheet token must be a valid string');
@@ -6494,9 +6509,11 @@ function invokeComponentConstructor(vm, Ctor) {
6494
6509
  // the "instanceof" operator would not work here since Locker Service provides its own
6495
6510
  // implementation of LightningElement, so we indirectly check if the base constructor is
6496
6511
  // invoked by accessing the component on the vm.
6497
- const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6498
- ? vmBeingConstructed.component !== result
6499
- : !(result instanceof LightningElement);
6512
+ // TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled
6513
+ // const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6514
+ // ? vmBeingConstructed.component !== result
6515
+ // : !(result instanceof LightningElement);
6516
+ const isInvalidConstructor = vmBeingConstructed.component !== result;
6500
6517
  if (isInvalidConstructor) {
6501
6518
  throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
6502
6519
  }
@@ -8500,5 +8517,5 @@ exports.swapTemplate = swapTemplate;
8500
8517
  exports.track = track;
8501
8518
  exports.unwrap = unwrap;
8502
8519
  exports.wire = wire;
8503
- /** version: 8.13.3 */
8520
+ /** version: 8.15.0 */
8504
8521
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.js CHANGED
@@ -2822,6 +2822,10 @@ if (process.env.NODE_ENV === 'test-karma-lwc') {
2822
2822
  function checkVersionMismatch(func, type) {
2823
2823
  const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
2824
2824
  if (!isNull(versionMatcher) && !warned) {
2825
+ if (process.env.SKIP_LWC_VERSION_MISMATCH_CHECK === 'true') {
2826
+ warned = true; // skip printing out version mismatch errors when env var is set
2827
+ return;
2828
+ }
2825
2829
  const version = versionMatcher[1];
2826
2830
  if (version !== LWC_VERSION) {
2827
2831
  warned = true; // only warn once to avoid flooding the console
@@ -3082,6 +3086,7 @@ seal(BaseBridgeElement.prototype);
3082
3086
  * SPDX-License-Identifier: MIT
3083
3087
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3084
3088
  */
3089
+ const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_]+$/;
3085
3090
  // These are only used for HMR in dev mode
3086
3091
  // The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
3087
3092
  let stylesheetsToCssContent = /*@__PURE__@*/ new WeakMap();
@@ -3374,6 +3379,13 @@ function unrenderStylesheet(stylesheet) {
3374
3379
  cssContentToAbortControllers.delete(cssContent);
3375
3380
  }
3376
3381
  }
3382
+ function isValidScopeToken(token) {
3383
+ if (!isString(token)) {
3384
+ return false;
3385
+ }
3386
+ // See W-16614556
3387
+ return lwcRuntimeFlags.DISABLE_SCOPE_TOKEN_VALIDATION || VALID_SCOPE_TOKEN_REGEX.test(token);
3388
+ }
3377
3389
 
3378
3390
  /*
3379
3391
  * Copyright (c) 2023, salesforce.com, inc.
@@ -4889,6 +4901,10 @@ function applyStyleScoping(elm, owner, renderer) {
4889
4901
  // Set the class name for `*.scoped.css` style scoping.
4890
4902
  const scopeToken = getScopeTokenClass(owner, /* legacy */ false);
4891
4903
  if (!isNull(scopeToken)) {
4904
+ if (!isValidScopeToken(scopeToken)) {
4905
+ // See W-16614556
4906
+ throw new Error('stylesheet token must be a valid string');
4907
+ }
4892
4908
  // TODO [#2762]: this dot notation with add is probably problematic
4893
4909
  // probably we should have a renderer api for just the add operation
4894
4910
  getClassList(elm).add(scopeToken);
@@ -4897,6 +4913,10 @@ function applyStyleScoping(elm, owner, renderer) {
4897
4913
  if (lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS) {
4898
4914
  const legacyScopeToken = getScopeTokenClass(owner, /* legacy */ true);
4899
4915
  if (!isNull(legacyScopeToken)) {
4916
+ if (!isValidScopeToken(legacyScopeToken)) {
4917
+ // See W-16614556
4918
+ throw new Error('stylesheet token must be a valid string');
4919
+ }
4900
4920
  // TODO [#2762]: this dot notation with add is probably problematic
4901
4921
  // probably we should have a renderer api for just the add operation
4902
4922
  getClassList(elm).add(legacyScopeToken);
@@ -6123,12 +6143,6 @@ function getVMBeingRendered() {
6123
6143
  function setVMBeingRendered(vm) {
6124
6144
  vmBeingRendered = vm;
6125
6145
  }
6126
- const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_]+$/;
6127
- // See W-16614556
6128
- // TODO [#2826]: freeze the template object
6129
- function isValidScopeToken(token) {
6130
- return isString(token) && VALID_SCOPE_TOKEN_REGEX.test(token);
6131
- }
6132
6146
  function validateSlots(vm) {
6133
6147
  assertNotProd(); // this method should never leak to prod
6134
6148
  const { cmpSlots } = vm;
@@ -6292,6 +6306,7 @@ function buildParseFragmentFn(createFragmentFn) {
6292
6306
  }
6293
6307
  }
6294
6308
  // See W-16614556
6309
+ // TODO [#2826]: freeze the template object
6295
6310
  if ((hasStyleToken && !isValidScopeToken(stylesheetToken)) ||
6296
6311
  (hasLegacyToken && !isValidScopeToken(legacyStylesheetToken))) {
6297
6312
  throw new Error('stylesheet token must be a valid string');
@@ -6491,9 +6506,11 @@ function invokeComponentConstructor(vm, Ctor) {
6491
6506
  // the "instanceof" operator would not work here since Locker Service provides its own
6492
6507
  // implementation of LightningElement, so we indirectly check if the base constructor is
6493
6508
  // invoked by accessing the component on the vm.
6494
- const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6495
- ? vmBeingConstructed.component !== result
6496
- : !(result instanceof LightningElement);
6509
+ // TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled
6510
+ // const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6511
+ // ? vmBeingConstructed.component !== result
6512
+ // : !(result instanceof LightningElement);
6513
+ const isInvalidConstructor = vmBeingConstructed.component !== result;
6497
6514
  if (isInvalidConstructor) {
6498
6515
  throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
6499
6516
  }
@@ -8446,5 +8463,5 @@ function readonly(obj) {
8446
8463
  }
8447
8464
 
8448
8465
  export { BaseBridgeElement, 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, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8449
- /** version: 8.13.3 */
8466
+ /** version: 8.15.0 */
8450
8467
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/engine-core",
7
- "version": "8.13.3",
7
+ "version": "8.15.0",
8
8
  "description": "Core LWC engine APIs.",
9
9
  "keywords": [
10
10
  "lwc"
@@ -46,9 +46,9 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@lwc/features": "8.13.3",
50
- "@lwc/shared": "8.13.3",
51
- "@lwc/signals": "8.13.3"
49
+ "@lwc/features": "8.15.0",
50
+ "@lwc/shared": "8.15.0",
51
+ "@lwc/signals": "8.15.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "observable-membrane": "2.0.0"