@cplieger/actions 2.0.0 → 2.0.2
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 +3 -2
- package/jsr.json +1 -1
- package/package.json +9 -9
- package/src/registry.ts +30 -0
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# actions
|
|
2
2
|
|
|
3
|
-
[](https://github.com/cplieger/actions/actions/workflows/ci.yaml)
|
|
4
3
|
[](https://www.npmjs.com/package/@cplieger/actions)
|
|
5
4
|
[](https://jsr.io/@cplieger/actions)
|
|
6
|
-
[](https://github.com/cplieger/actions/actions/workflows/coverage.yml)
|
|
6
|
+
[](https://www.bestpractices.dev/projects/13197)
|
|
7
|
+
[](https://scorecard.dev/viewer/?uri=github.com/cplieger/actions)
|
|
7
8
|
|
|
8
9
|
> Declarative UI-actions framework with lifecycle management, retry, debounce, and polling.
|
|
9
10
|
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cplieger/actions",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"test": "vitest --run"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@cplieger/reactive": "1.
|
|
16
|
+
"@cplieger/reactive": "1.2.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@eslint/js": "10.0.1",
|
|
20
|
-
"@types/node": "24.13.
|
|
21
|
-
"@vitest/coverage-v8": "4.1.
|
|
22
|
-
"eslint": "10.
|
|
20
|
+
"@types/node": "24.13.2",
|
|
21
|
+
"@vitest/coverage-v8": "4.1.9",
|
|
22
|
+
"eslint": "10.5.0",
|
|
23
23
|
"fast-check": "4.8.0",
|
|
24
|
-
"happy-dom": "20.10.
|
|
25
|
-
"prettier": "3.8.
|
|
26
|
-
"typescript-eslint": "8.
|
|
27
|
-
"vitest": "4.1.
|
|
24
|
+
"happy-dom": "20.10.3",
|
|
25
|
+
"prettier": "3.8.4",
|
|
26
|
+
"typescript-eslint": "8.61.1",
|
|
27
|
+
"vitest": "4.1.9"
|
|
28
28
|
},
|
|
29
29
|
"description": "Declarative async UI-action framework for TypeScript",
|
|
30
30
|
"license": "GPL-3.0-or-later",
|
package/src/registry.ts
CHANGED
|
@@ -33,6 +33,13 @@ let _pendingTotal = 0;
|
|
|
33
33
|
let _liveCount = 0;
|
|
34
34
|
let _head = 0;
|
|
35
35
|
|
|
36
|
+
// Test-only: when true, a detected _pendingTotal underflow throws instead of
|
|
37
|
+
// the production warn + clamp, so an add/removePending pairing bug surfaces in
|
|
38
|
+
// tests rather than being silently masked. Production default is false.
|
|
39
|
+
// Toggled via _setThrowOnInvariantViolationForTest (same _*ForTest convention
|
|
40
|
+
// as _resetForTest); reset to false by _resetForTest.
|
|
41
|
+
let _throwOnInvariantViolation = false;
|
|
42
|
+
|
|
36
43
|
// Reactive mirrors of the pending state. pendingByName remains the source of
|
|
37
44
|
// truth; these signals expose the derived counts so isPending/pendingCount can
|
|
38
45
|
// be read reactively (e.g. by bindLoadingState's effect).
|
|
@@ -153,6 +160,9 @@ export function record(instance: ActionInstance): void {
|
|
|
153
160
|
compact();
|
|
154
161
|
}
|
|
155
162
|
if (_pendingTotal < 0) {
|
|
163
|
+
if (_throwOnInvariantViolation) {
|
|
164
|
+
throw new Error("[actions] _pendingTotal went negative — invariant violation");
|
|
165
|
+
}
|
|
156
166
|
console.warn("[actions] _pendingTotal went negative — invariant violation; clamping to 0");
|
|
157
167
|
_pendingTotal = 0;
|
|
158
168
|
pendingTotalSig.value = 0;
|
|
@@ -243,6 +253,26 @@ export function _resetForTest(): void {
|
|
|
243
253
|
listeners.clear();
|
|
244
254
|
namedListeners.clear();
|
|
245
255
|
_pendingTotal = 0;
|
|
256
|
+
_throwOnInvariantViolation = false;
|
|
246
257
|
pendingSigs.clearAll();
|
|
247
258
|
pendingTotalSig.value = 0;
|
|
248
259
|
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @internal Test-only: toggle whether a detected `_pendingTotal` underflow
|
|
263
|
+
* throws (true) instead of the production warn + clamp (false). Lets tests
|
|
264
|
+
* assert that an add/removePending pairing bug surfaces loudly. Reset to false
|
|
265
|
+
* by `_resetForTest`.
|
|
266
|
+
*/
|
|
267
|
+
export function _setThrowOnInvariantViolationForTest(enabled: boolean): void {
|
|
268
|
+
_throwOnInvariantViolation = enabled;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @internal Test-only: simulate an unpaired `removePending` (an add/remove
|
|
273
|
+
* mismatch) by decrementing the pending total without a matching add, driving
|
|
274
|
+
* the invariant negative. The next `record()` then hits the clamp branch.
|
|
275
|
+
*/
|
|
276
|
+
export function _forcePendingUnderflowForTest(): void {
|
|
277
|
+
_pendingTotal--;
|
|
278
|
+
}
|