@yiin/reactive-proxy-state 1.0.29 → 1.0.30
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 +20 -0
- package/dist/index.js +20 -0
- package/dist/utils.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2461,6 +2461,22 @@ 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
|
+
const prefix = pathKey + ".";
|
|
2469
|
+
let evicted = 0;
|
|
2470
|
+
for (const key of cache.keys()) {
|
|
2471
|
+
if (key.startsWith(prefix)) {
|
|
2472
|
+
cache.delete(key);
|
|
2473
|
+
evicted++;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
if (evicted > 0) {
|
|
2477
|
+
pathCacheSize.set(root, (pathCacheSize.get(root) ?? cache.size) - evicted);
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2464
2480
|
function getPathConcat(path) {
|
|
2465
2481
|
const result = pathConcatCache.get(path);
|
|
2466
2482
|
if (result !== undefined) {
|
|
@@ -2765,6 +2781,10 @@ function updateState(root, event) {
|
|
|
2765
2781
|
return;
|
|
2766
2782
|
}
|
|
2767
2783
|
handler(targetForHandler, keyForHandler, event);
|
|
2784
|
+
if (action === "set" && event.newValue != null && typeof event.newValue === "object") {
|
|
2785
|
+
const fullPathKey = path.join(".");
|
|
2786
|
+
evictDescendantsFromPathCache(root, fullPathKey);
|
|
2787
|
+
}
|
|
2768
2788
|
}
|
|
2769
2789
|
// src/watch-effect.ts
|
|
2770
2790
|
var activeEffect = null;
|
package/dist/index.js
CHANGED
|
@@ -2401,6 +2401,22 @@ 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
|
+
const prefix = pathKey + ".";
|
|
2409
|
+
let evicted = 0;
|
|
2410
|
+
for (const key of cache.keys()) {
|
|
2411
|
+
if (key.startsWith(prefix)) {
|
|
2412
|
+
cache.delete(key);
|
|
2413
|
+
evicted++;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
if (evicted > 0) {
|
|
2417
|
+
pathCacheSize.set(root, (pathCacheSize.get(root) ?? cache.size) - evicted);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2404
2420
|
function getPathConcat(path) {
|
|
2405
2421
|
const result = pathConcatCache.get(path);
|
|
2406
2422
|
if (result !== undefined) {
|
|
@@ -2705,6 +2721,10 @@ function updateState(root, event) {
|
|
|
2705
2721
|
return;
|
|
2706
2722
|
}
|
|
2707
2723
|
handler(targetForHandler, keyForHandler, event);
|
|
2724
|
+
if (action === "set" && event.newValue != null && typeof event.newValue === "object") {
|
|
2725
|
+
const fullPathKey = path.join(".");
|
|
2726
|
+
evictDescendantsFromPathCache(root, fullPathKey);
|
|
2727
|
+
}
|
|
2708
2728
|
}
|
|
2709
2729
|
// src/watch-effect.ts
|
|
2710
2730
|
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 all cached paths that are descendants of the given path prefix.
|
|
10
|
+
* Called when a value at `pathKey` is replaced so that deeper cached references
|
|
11
|
+
* (which now point to the old, detached object) are not reused.
|
|
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
|
/**
|