@yiin/reactive-proxy-state 1.0.29 → 1.0.31
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.cjs +24 -0
- package/dist/index.js +24 -0
- package/dist/utils.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2461,6 +2461,26 @@ function setInPathCache(root, pathKey, value) {
|
|
|
2461
2461
|
cache.set(pathKey, value);
|
|
2462
2462
|
cleanupPathCache(root);
|
|
2463
2463
|
}
|
|
2464
|
+
function evictDescendantsFromPathCache(root, pathKey) {
|
|
2465
|
+
const cache = pathCache.get(root);
|
|
2466
|
+
if (!cache)
|
|
2467
|
+
return;
|
|
2468
|
+
let evicted = 0;
|
|
2469
|
+
if (cache.has(pathKey)) {
|
|
2470
|
+
cache.delete(pathKey);
|
|
2471
|
+
evicted++;
|
|
2472
|
+
}
|
|
2473
|
+
const prefix = pathKey + ".";
|
|
2474
|
+
for (const key of cache.keys()) {
|
|
2475
|
+
if (key.startsWith(prefix)) {
|
|
2476
|
+
cache.delete(key);
|
|
2477
|
+
evicted++;
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
if (evicted > 0) {
|
|
2481
|
+
pathCacheSize.set(root, (pathCacheSize.get(root) ?? cache.size) - evicted);
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2464
2484
|
function getPathConcat(path) {
|
|
2465
2485
|
const result = pathConcatCache.get(path);
|
|
2466
2486
|
if (result !== undefined) {
|
|
@@ -2765,6 +2785,10 @@ function updateState(root, event) {
|
|
|
2765
2785
|
return;
|
|
2766
2786
|
}
|
|
2767
2787
|
handler(targetForHandler, keyForHandler, event);
|
|
2788
|
+
if (action === "set" && event.newValue != null && typeof event.newValue === "object") {
|
|
2789
|
+
const fullPathKey = path.join(".");
|
|
2790
|
+
evictDescendantsFromPathCache(root, fullPathKey);
|
|
2791
|
+
}
|
|
2768
2792
|
}
|
|
2769
2793
|
// src/watch-effect.ts
|
|
2770
2794
|
var activeEffect = null;
|
package/dist/index.js
CHANGED
|
@@ -2401,6 +2401,26 @@ function setInPathCache(root, pathKey, value) {
|
|
|
2401
2401
|
cache.set(pathKey, value);
|
|
2402
2402
|
cleanupPathCache(root);
|
|
2403
2403
|
}
|
|
2404
|
+
function evictDescendantsFromPathCache(root, pathKey) {
|
|
2405
|
+
const cache = pathCache.get(root);
|
|
2406
|
+
if (!cache)
|
|
2407
|
+
return;
|
|
2408
|
+
let evicted = 0;
|
|
2409
|
+
if (cache.has(pathKey)) {
|
|
2410
|
+
cache.delete(pathKey);
|
|
2411
|
+
evicted++;
|
|
2412
|
+
}
|
|
2413
|
+
const prefix = pathKey + ".";
|
|
2414
|
+
for (const key of cache.keys()) {
|
|
2415
|
+
if (key.startsWith(prefix)) {
|
|
2416
|
+
cache.delete(key);
|
|
2417
|
+
evicted++;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
if (evicted > 0) {
|
|
2421
|
+
pathCacheSize.set(root, (pathCacheSize.get(root) ?? cache.size) - evicted);
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2404
2424
|
function getPathConcat(path) {
|
|
2405
2425
|
const result = pathConcatCache.get(path);
|
|
2406
2426
|
if (result !== undefined) {
|
|
@@ -2705,6 +2725,10 @@ function updateState(root, event) {
|
|
|
2705
2725
|
return;
|
|
2706
2726
|
}
|
|
2707
2727
|
handler(targetForHandler, keyForHandler, event);
|
|
2728
|
+
if (action === "set" && event.newValue != null && typeof event.newValue === "object") {
|
|
2729
|
+
const fullPathKey = path.join(".");
|
|
2730
|
+
evictDescendantsFromPathCache(root, fullPathKey);
|
|
2731
|
+
}
|
|
2708
2732
|
}
|
|
2709
2733
|
// src/watch-effect.ts
|
|
2710
2734
|
var activeEffect = null;
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export declare const wrapperCache: WeakMap<object, object>;
|
|
|
5
5
|
export declare function deepEqual(a: any, b: any, seen?: WeakMap<any, any>): boolean;
|
|
6
6
|
export declare function getFromPathCache(root: object, pathKey: string): any | undefined;
|
|
7
7
|
export declare function setInPathCache(root: object, pathKey: string, value: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Evict the cached path entry at `pathKey` AND all its descendants.
|
|
10
|
+
* Called when a value at `pathKey` is replaced so that the stale cached reference
|
|
11
|
+
* (and any deeper ones) are not reused on subsequent mutations.
|
|
12
|
+
*/
|
|
13
|
+
export declare function evictDescendantsFromPathCache(root: object, pathKey: string): void;
|
|
8
14
|
export declare function getPathConcat(path: string): any[] | undefined;
|
|
9
15
|
export declare function setPathConcat(path: string, value: any[]): void;
|
|
10
16
|
/**
|