@lwc/engine-core 8.28.1 → 8.28.3-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.
@@ -3,21 +3,11 @@
3
3
  * The goal is to avoid leaking the values, which is what would happen with a WeakMap<K, Set<V>>.
4
4
  *
5
5
  * Note that this is currently only intended to be used in dev/PRODDEBUG environments.
6
- * It leaks in legacy browsers, which may be undesired.
6
+ *
7
+ * This implementation relies on WeakRefs and FinalizationRegistry.
8
+ * For some background, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef
7
9
  */
8
- export interface WeakMultiMap<T extends object, V extends object> {
9
- get(key: T): ReadonlySet<V>;
10
- add(key: T, vm: V): void;
11
- delete(key: T): void;
12
- }
13
- declare class LegacyWeakMultiMap<K extends object, V extends object> implements WeakMultiMap<K, V> {
14
- private _map;
15
- private _getValues;
16
- get(key: K): ReadonlySet<V>;
17
- add(key: K, vm: V): void;
18
- delete(key: K): void;
19
- }
20
- declare class ModernWeakMultiMap<K extends object, V extends object> implements WeakMultiMap<K, V> {
10
+ export declare class WeakMultiMap<K extends object, V extends object> {
21
11
  private _map;
22
12
  private _registry;
23
13
  private _getWeakRefs;
@@ -25,6 +15,4 @@ declare class ModernWeakMultiMap<K extends object, V extends object> implements
25
15
  add(key: K, value: V): void;
26
16
  delete(key: K): void;
27
17
  }
28
- export declare const WeakMultiMap: typeof LegacyWeakMultiMap | typeof ModernWeakMultiMap;
29
- export {};
30
18
  //# sourceMappingURL=weak-multimap.d.ts.map
package/dist/index.cjs.js CHANGED
@@ -3326,6 +3326,9 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3326
3326
  function getStylesheetsContent(vm, template) {
3327
3327
  const { stylesheets, stylesheetToken } = template;
3328
3328
  const { stylesheets: vmStylesheets } = vm;
3329
+ if (!shared.isUndefined(stylesheetToken) && !isValidScopeToken(stylesheetToken)) {
3330
+ throw new Error('stylesheet token must be a valid string');
3331
+ }
3329
3332
  const hasTemplateStyles = hasStyles(stylesheets);
3330
3333
  const hasVmStyles = hasStyles(vmStylesheets);
3331
3334
  if (hasTemplateStyles) {
@@ -3439,34 +3442,16 @@ function isValidScopeToken(token) {
3439
3442
  * SPDX-License-Identifier: MIT
3440
3443
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3441
3444
  */
3442
- const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
3443
- // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
3444
- class LegacyWeakMultiMap {
3445
- constructor() {
3446
- this._map = new WeakMap();
3447
- }
3448
- _getValues(key) {
3449
- let values = this._map.get(key);
3450
- if (shared.isUndefined(values)) {
3451
- values = new Set();
3452
- this._map.set(key, values);
3453
- }
3454
- return values;
3455
- }
3456
- get(key) {
3457
- return this._getValues(key);
3458
- }
3459
- add(key, vm) {
3460
- const set = this._getValues(key);
3461
- set.add(vm);
3462
- }
3463
- delete(key) {
3464
- this._map.delete(key);
3465
- }
3466
- }
3467
- // This implementation relies on the WeakRef/FinalizationRegistry proposal.
3468
- // For some background, see: https://github.com/tc39/proposal-weakrefs
3469
- class ModernWeakMultiMap {
3445
+ /**
3446
+ * A map where the keys are weakly held and the values are a Set that are also each weakly held.
3447
+ * The goal is to avoid leaking the values, which is what would happen with a WeakMap<K, Set<V>>.
3448
+ *
3449
+ * Note that this is currently only intended to be used in dev/PRODDEBUG environments.
3450
+ *
3451
+ * This implementation relies on WeakRefs and FinalizationRegistry.
3452
+ * For some background, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef
3453
+ */
3454
+ class WeakMultiMap {
3470
3455
  constructor() {
3471
3456
  this._map = new WeakMap();
3472
3457
  this._registry = new FinalizationRegistry((weakRefs) => {
@@ -3502,8 +3487,12 @@ class ModernWeakMultiMap {
3502
3487
  }
3503
3488
  add(key, value) {
3504
3489
  const weakRefs = this._getWeakRefs(key);
3505
- // We could check for duplicate values here, but it doesn't seem worth it.
3506
- // We transform the output into a Set anyway
3490
+ // Skip adding if already present
3491
+ for (const weakRef of weakRefs) {
3492
+ if (weakRef.deref() === value) {
3493
+ return;
3494
+ }
3495
+ }
3507
3496
  shared.ArrayPush.call(weakRefs, new WeakRef(value));
3508
3497
  // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
3509
3498
  // effectively creates a strong reference between the first argument (the "target") and the held value. When
@@ -3518,7 +3507,6 @@ class ModernWeakMultiMap {
3518
3507
  this._map.delete(key);
3519
3508
  }
3520
3509
  }
3521
- const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
3522
3510
 
3523
3511
  /*
3524
3512
  * Copyright (c) 2020, salesforce.com, inc.
@@ -8840,5 +8828,5 @@ exports.swapTemplate = swapTemplate;
8840
8828
  exports.track = track;
8841
8829
  exports.unwrap = unwrap;
8842
8830
  exports.wire = wire;
8843
- /** version: 8.28.1 */
8831
+ /** version: 8.28.3-0 */
8844
8832
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.js CHANGED
@@ -3323,6 +3323,9 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
3323
3323
  function getStylesheetsContent(vm, template) {
3324
3324
  const { stylesheets, stylesheetToken } = template;
3325
3325
  const { stylesheets: vmStylesheets } = vm;
3326
+ if (!isUndefined$1(stylesheetToken) && !isValidScopeToken(stylesheetToken)) {
3327
+ throw new Error('stylesheet token must be a valid string');
3328
+ }
3326
3329
  const hasTemplateStyles = hasStyles(stylesheets);
3327
3330
  const hasVmStyles = hasStyles(vmStylesheets);
3328
3331
  if (hasTemplateStyles) {
@@ -3436,34 +3439,16 @@ function isValidScopeToken(token) {
3436
3439
  * SPDX-License-Identifier: MIT
3437
3440
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3438
3441
  */
3439
- const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
3440
- // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
3441
- class LegacyWeakMultiMap {
3442
- constructor() {
3443
- this._map = new WeakMap();
3444
- }
3445
- _getValues(key) {
3446
- let values = this._map.get(key);
3447
- if (isUndefined$1(values)) {
3448
- values = new Set();
3449
- this._map.set(key, values);
3450
- }
3451
- return values;
3452
- }
3453
- get(key) {
3454
- return this._getValues(key);
3455
- }
3456
- add(key, vm) {
3457
- const set = this._getValues(key);
3458
- set.add(vm);
3459
- }
3460
- delete(key) {
3461
- this._map.delete(key);
3462
- }
3463
- }
3464
- // This implementation relies on the WeakRef/FinalizationRegistry proposal.
3465
- // For some background, see: https://github.com/tc39/proposal-weakrefs
3466
- class ModernWeakMultiMap {
3442
+ /**
3443
+ * A map where the keys are weakly held and the values are a Set that are also each weakly held.
3444
+ * The goal is to avoid leaking the values, which is what would happen with a WeakMap<K, Set<V>>.
3445
+ *
3446
+ * Note that this is currently only intended to be used in dev/PRODDEBUG environments.
3447
+ *
3448
+ * This implementation relies on WeakRefs and FinalizationRegistry.
3449
+ * For some background, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef
3450
+ */
3451
+ class WeakMultiMap {
3467
3452
  constructor() {
3468
3453
  this._map = new WeakMap();
3469
3454
  this._registry = new FinalizationRegistry((weakRefs) => {
@@ -3499,8 +3484,12 @@ class ModernWeakMultiMap {
3499
3484
  }
3500
3485
  add(key, value) {
3501
3486
  const weakRefs = this._getWeakRefs(key);
3502
- // We could check for duplicate values here, but it doesn't seem worth it.
3503
- // We transform the output into a Set anyway
3487
+ // Skip adding if already present
3488
+ for (const weakRef of weakRefs) {
3489
+ if (weakRef.deref() === value) {
3490
+ return;
3491
+ }
3492
+ }
3504
3493
  ArrayPush$1.call(weakRefs, new WeakRef(value));
3505
3494
  // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
3506
3495
  // effectively creates a strong reference between the first argument (the "target") and the held value. When
@@ -3515,7 +3504,6 @@ class ModernWeakMultiMap {
3515
3504
  this._map.delete(key);
3516
3505
  }
3517
3506
  }
3518
- const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
3519
3507
 
3520
3508
  /*
3521
3509
  * Copyright (c) 2020, salesforce.com, inc.
@@ -8766,5 +8754,5 @@ function readonly(obj) {
8766
8754
  }
8767
8755
 
8768
8756
  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 };
8769
- /** version: 8.28.1 */
8757
+ /** version: 8.28.3-0 */
8770
8758
  //# 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.28.1",
7
+ "version": "8.28.3-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.28.1",
50
- "@lwc/shared": "8.28.1",
51
- "@lwc/signals": "8.28.1"
49
+ "@lwc/features": "8.28.3-0",
50
+ "@lwc/shared": "8.28.3-0",
51
+ "@lwc/signals": "8.28.3-0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "observable-membrane": "2.0.0"