@but212/atom-effect 0.1.2 → 0.1.4
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/README.md +7 -7
- package/dist/core/atom/atom.d.ts.map +1 -1
- package/dist/core/computed/index.d.ts.map +1 -1
- package/dist/core/effect/effect.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +387 -472
- package/dist/index.mjs.map +1 -1
- package/dist/scheduler/scheduler.d.ts +4 -0
- package/dist/scheduler/scheduler.d.ts.map +1 -1
- package/dist/tracking/dependency-manager.d.ts +17 -13
- package/dist/tracking/dependency-manager.d.ts.map +1 -1
- package/package.json +2 -3
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
*/
|
|
26
26
|
declare class Scheduler {
|
|
27
27
|
/** Queue of callbacks waiting for microtask execution */
|
|
28
|
+
/** Queue buffers for double buffering optimization */
|
|
29
|
+
private queueA;
|
|
30
|
+
private queueB;
|
|
31
|
+
/** Currently active queue receiving new tasks */
|
|
28
32
|
private queue;
|
|
29
33
|
/** Whether the scheduler is currently processing the queue */
|
|
30
34
|
private isProcessing;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/scheduler/scheduler.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,cAAM,SAAS;IACb,yDAAyD;IACzD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/scheduler/scheduler.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,cAAM,SAAS;IACb,yDAAyD;IACzD,sDAAsD;IACtD,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,MAAM,CAA8B;IAE5C,iDAAiD;IACjD,OAAO,CAAC,KAAK,CAAgC;IAE7C,8DAA8D;IAC9D,OAAO,CAAC,YAAY,CAAkB;IAEtC,2CAA2C;IACpC,UAAU,EAAE,OAAO,CAAS;IAEnC,gDAAgD;IAChD,OAAO,CAAC,UAAU,CAAa;IAE/B,gDAAgD;IAChD,OAAO,CAAC,UAAU,CAAyB;IAE3C,wDAAwD;IACxD,OAAO,CAAC,cAAc,CAAK;IAE3B,+CAA+C;IAC/C,OAAO,CAAC,cAAc,CAAkB;IAExC,wEAAwE;IACxE,OAAO,CAAC,kBAAkB,CAAgB;IAE1C;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAepC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK;IAgCb;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,SAAS;IAuDjB;;;;;;;;;;;;;;;OAeG;IACH,UAAU,IAAI,IAAI;IAKlB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,IAAI,IAAI;IAShB;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAMzC;AAED,qDAAqD;AACrD,eAAO,MAAM,SAAS,WAAkB,CAAC"}
|
|
@@ -35,15 +35,17 @@ import { Dependency } from '../types';
|
|
|
35
35
|
*/
|
|
36
36
|
export declare class DependencyManager {
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Array of tracked dependencies.
|
|
39
|
+
* Managed as a simple array for maximum performance (no WeakRef overhead).
|
|
40
40
|
*/
|
|
41
|
-
private
|
|
41
|
+
private readonly depRefs;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* Map of dependencies to their unsubscribe functions.
|
|
44
|
+
* WeakMap ensures automatic cleanup when dependency is garbage collected.
|
|
45
45
|
*/
|
|
46
|
-
private
|
|
46
|
+
private readonly depMap;
|
|
47
|
+
/** Current number of active dependencies */
|
|
48
|
+
private count;
|
|
47
49
|
/**
|
|
48
50
|
* Number of additions before triggering automatic cleanup.
|
|
49
51
|
* @defaultValue 100
|
|
@@ -53,6 +55,7 @@ export declare class DependencyManager {
|
|
|
53
55
|
* Counter tracking additions since last cleanup.
|
|
54
56
|
*/
|
|
55
57
|
private addCount;
|
|
58
|
+
constructor();
|
|
56
59
|
/**
|
|
57
60
|
* Adds a dependency with its associated unsubscribe callback.
|
|
58
61
|
*
|
|
@@ -60,7 +63,7 @@ export declare class DependencyManager {
|
|
|
60
63
|
* immediately called to prevent duplicate subscriptions.
|
|
61
64
|
*
|
|
62
65
|
* @param dep - The dependency to track (atom, computed, etc.)
|
|
63
|
-
* @param
|
|
66
|
+
* @param cleanup - Callback to invoke when removing the dependency
|
|
64
67
|
*
|
|
65
68
|
* @remarks
|
|
66
69
|
* - Duplicate dependencies are rejected with immediate unsubscribe
|
|
@@ -73,7 +76,7 @@ export declare class DependencyManager {
|
|
|
73
76
|
* manager.addDependency(atom, unsubscribe);
|
|
74
77
|
* ```
|
|
75
78
|
*/
|
|
76
|
-
addDependency(dep: Dependency,
|
|
79
|
+
addDependency(dep: Dependency, cleanup: () => void): void;
|
|
77
80
|
/**
|
|
78
81
|
* Removes a dependency and calls its unsubscribe callback.
|
|
79
82
|
*
|
|
@@ -130,15 +133,16 @@ export declare class DependencyManager {
|
|
|
130
133
|
*/
|
|
131
134
|
unsubscribeAll(): void;
|
|
132
135
|
/**
|
|
133
|
-
* Removes stale
|
|
136
|
+
* Removes stale references from the internal array.
|
|
134
137
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
138
|
+
* This method iterates through the `depRefs` array and removes any dependencies
|
|
139
|
+
* that are no longer present in the `depMap` (meaning their unsubscribe
|
|
140
|
+
* callback has been garbage collected or explicitly deleted).
|
|
137
141
|
*
|
|
138
142
|
* @remarks
|
|
139
143
|
* - Called automatically every `cleanupThreshold` additions
|
|
140
144
|
* - Can be called manually for immediate cleanup
|
|
141
|
-
* - Time complexity: O(n) where n is the number of
|
|
145
|
+
* - Time complexity: O(n) where n is the number of dependencies
|
|
142
146
|
*
|
|
143
147
|
* @example
|
|
144
148
|
* ```typescript
|
|
@@ -161,7 +165,7 @@ export declare class DependencyManager {
|
|
|
161
165
|
* console.log(`Tracking ${manager.count} dependencies`);
|
|
162
166
|
* ```
|
|
163
167
|
*/
|
|
164
|
-
get
|
|
168
|
+
get liveCount(): number;
|
|
165
169
|
/**
|
|
166
170
|
* Gets an array of all live dependencies.
|
|
167
171
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-manager.d.ts","sourceRoot":"","sources":["../../src/tracking/dependency-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,iBAAiB;IAC5B;;;OAGG;IACH,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"dependency-manager.d.ts","sourceRoot":"","sources":["../../src/tracking/dependency-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,iBAAiB;IAC5B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IAEzD,4CAA4C;IAC5C,OAAO,CAAC,KAAK,CAAS;IAEtB;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAO;IAE/B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAK;;IAQrB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAoBzD;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO;IAwC1C;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO;IAKvC;;;;;;;;;;;;;;;;OAgBG;IACH,cAAc,IAAI,IAAI;IAqBtB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,IAAI,IAAI;IA8Bf;;;;;;;;;;;;;OAaG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;;;;;;;;;;;OAeG;IACH,eAAe,IAAI,UAAU,EAAE;IAW/B;;;;;;;;;;;;;;;OAeG;IACH,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC;IAI5C;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAG7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@but212/atom-effect",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A reactive state management library that combines the power of `atom`, `computed`, and `effect` for seamless management of reactive state.",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
"bench:atom": "vitest bench __benchmarks__/micro/atom.bench",
|
|
68
68
|
"bench:computed": "vitest bench __benchmarks__/micro/computed.bench",
|
|
69
69
|
"bench:effect": "vitest bench __benchmarks__/micro/effect.bench",
|
|
70
|
-
"bench:
|
|
71
|
-
"bench:regression": "tsx scripts/check-regression.ts"
|
|
70
|
+
"bench:realistic": "vitest bench __benchmarks__/realistic"
|
|
72
71
|
}
|
|
73
72
|
}
|