@praxisjs/core 0.3.0 → 0.4.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @praxisjs/core
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f52354d: Add `@Computed()` decorator to `@praxisjs/decorators` for declaring read-only reactive getters backed by a cached `computed()` signal. The getter recomputes automatically when any `@State` or `@Prop` dependency changes, and the result is cached until a dependency is invalidated — unlike a plain getter which recalculates on every read.
|
|
8
|
+
|
|
9
|
+
`@Debug()` in `@praxisjs/devtools` now supports `@Computed()` getters (`ClassGetterDecoratorContext`) in addition to fields and methods, allowing computed values to be tracked and historized in the devtools panel.
|
|
10
|
+
|
|
11
|
+
Also fixes a bug in the `computed()` primitive where an erroneous `track(recompute)` call caused premature dependency tracking on signal creation.
|
|
12
|
+
|
|
3
13
|
## 0.3.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CA0C3D"}
|
package/dist/signal/computed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { activeEffect, runEffect } from "./effect";
|
|
2
2
|
export function computed(computeFn) {
|
|
3
3
|
let cachedValue;
|
|
4
4
|
let dirty = true;
|
|
@@ -30,7 +30,6 @@ export function computed(computeFn) {
|
|
|
30
30
|
wrappedEffect();
|
|
31
31
|
return () => subscribers.delete(wrappedEffect);
|
|
32
32
|
}
|
|
33
|
-
track(recompute);
|
|
34
33
|
const computedSignal = read;
|
|
35
34
|
computedSignal.subscribe = subscribe;
|
|
36
35
|
computedSignal.__isComputed = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAe,MAAM,UAAU,CAAC;AAEhE,MAAM,UAAU,QAAQ,CAAI,SAAkB;IAC5C,IAAI,WAAc,CAAC;IACnB,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,KAAK,GAAG,IAAI,CAAC;QACb,CAAC,GAAG,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,GAAG,EAAE,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,SAAS,IAAI;QACX,IAAI,YAAY,EAAE,CAAC;YACjB,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,UAAU,GAAG,YAAY,CAAC;YAChC,SAAS,CAAC,SAAS,CAAC,CAAC;YACrB,WAAW,GAAG,SAAS,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC;YACd,SAAS,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,SAAS,SAAS,CAAC,EAAsB;QACvC,MAAM,aAAa,GAAG,GAAG,EAAE;YACzB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACb,CAAC,CAAC;QACF,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC/B,aAAa,EAAE,CAAC;QAChB,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,cAAc,GAAG,IAAmB,CAAC;IAC3C,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC;IACrC,cAAc,CAAC,YAAY,GAAG,IAAI,CAAC;IAEnC,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
package/src/signal/computed.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Computed } from "@praxisjs/shared";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { activeEffect, runEffect, type Effect } from "./effect";
|
|
4
4
|
|
|
5
5
|
export function computed<T>(computeFn: () => T): Computed<T> {
|
|
6
6
|
let cachedValue: T;
|
|
@@ -39,8 +39,6 @@ export function computed<T>(computeFn: () => T): Computed<T> {
|
|
|
39
39
|
return () => subscribers.delete(wrappedEffect);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
track(recompute);
|
|
43
|
-
|
|
44
42
|
const computedSignal = read as Computed<T>;
|
|
45
43
|
computedSignal.subscribe = subscribe;
|
|
46
44
|
computedSignal.__isComputed = true;
|