@lwc/engine-core 8.28.2 → 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
@@ -3442,34 +3442,16 @@ function isValidScopeToken(token) {
3442
3442
  * SPDX-License-Identifier: MIT
3443
3443
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3444
3444
  */
3445
- const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
3446
- // In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
3447
- class LegacyWeakMultiMap {
3448
- constructor() {
3449
- this._map = new WeakMap();
3450
- }
3451
- _getValues(key) {
3452
- let values = this._map.get(key);
3453
- if (shared.isUndefined(values)) {
3454
- values = new Set();
3455
- this._map.set(key, values);
3456
- }
3457
- return values;
3458
- }
3459
- get(key) {
3460
- return this._getValues(key);
3461
- }
3462
- add(key, vm) {
3463
- const set = this._getValues(key);
3464
- set.add(vm);
3465
- }
3466
- delete(key) {
3467
- this._map.delete(key);
3468
- }
3469
- }
3470
- // This implementation relies on the WeakRef/FinalizationRegistry proposal.
3471
- // For some background, see: https://github.com/tc39/proposal-weakrefs
3472
- 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 {
3473
3455
  constructor() {
3474
3456
  this._map = new WeakMap();
3475
3457
  this._registry = new FinalizationRegistry((weakRefs) => {
@@ -3505,8 +3487,12 @@ class ModernWeakMultiMap {
3505
3487
  }
3506
3488
  add(key, value) {
3507
3489
  const weakRefs = this._getWeakRefs(key);
3508
- // We could check for duplicate values here, but it doesn't seem worth it.
3509
- // 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
+ }
3510
3496
  shared.ArrayPush.call(weakRefs, new WeakRef(value));
3511
3497
  // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
3512
3498
  // effectively creates a strong reference between the first argument (the "target") and the held value. When
@@ -3521,7 +3507,6 @@ class ModernWeakMultiMap {
3521
3507
  this._map.delete(key);
3522
3508
  }
3523
3509
  }
3524
- const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
3525
3510
 
3526
3511
  /*
3527
3512
  * Copyright (c) 2020, salesforce.com, inc.
@@ -8843,5 +8828,5 @@ exports.swapTemplate = swapTemplate;
8843
8828
  exports.track = track;
8844
8829
  exports.unwrap = unwrap;
8845
8830
  exports.wire = wire;
8846
- /** version: 8.28.2 */
8831
+ /** version: 8.28.3-0 */
8847
8832
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.js CHANGED
@@ -3439,34 +3439,16 @@ function isValidScopeToken(token) {
3439
3439
  * SPDX-License-Identifier: MIT
3440
3440
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3441
3441
  */
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 (isUndefined$1(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 {
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 {
3470
3452
  constructor() {
3471
3453
  this._map = new WeakMap();
3472
3454
  this._registry = new FinalizationRegistry((weakRefs) => {
@@ -3502,8 +3484,12 @@ class ModernWeakMultiMap {
3502
3484
  }
3503
3485
  add(key, value) {
3504
3486
  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
3487
+ // Skip adding if already present
3488
+ for (const weakRef of weakRefs) {
3489
+ if (weakRef.deref() === value) {
3490
+ return;
3491
+ }
3492
+ }
3507
3493
  ArrayPush$1.call(weakRefs, new WeakRef(value));
3508
3494
  // It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
3509
3495
  // effectively creates a strong reference between the first argument (the "target") and the held value. When
@@ -3518,7 +3504,6 @@ class ModernWeakMultiMap {
3518
3504
  this._map.delete(key);
3519
3505
  }
3520
3506
  }
3521
- const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
3522
3507
 
3523
3508
  /*
3524
3509
  * Copyright (c) 2020, salesforce.com, inc.
@@ -8769,5 +8754,5 @@ function readonly(obj) {
8769
8754
  }
8770
8755
 
8771
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 };
8772
- /** version: 8.28.2 */
8757
+ /** version: 8.28.3-0 */
8773
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.2",
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.2",
50
- "@lwc/shared": "8.28.2",
51
- "@lwc/signals": "8.28.2"
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"