@pyreon/state-tree 0.9.0 → 0.11.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/lib/devtools.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/devtools.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +11 -6
- package/src/devtools.ts +2 -4
- package/src/index.ts +6 -6
- package/src/instance.ts +11 -17
- package/src/middleware.ts +4 -8
- package/src/model.ts +8 -18
- package/src/patch.ts +22 -39
- package/src/registry.ts +2 -6
- package/src/snapshot.ts +7 -11
- package/src/tests/devtools.test.ts +43 -43
- package/src/tests/edge-cases.test.ts +715 -0
- package/src/tests/model.test.ts +161 -167
- package/src/types.ts +5 -9
package/src/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Computed, Signal } from
|
|
1
|
+
import type { Computed, Signal } from "@pyreon/reactivity"
|
|
2
2
|
|
|
3
3
|
// ─── Model brand ──────────────────────────────────────────────────────────────
|
|
4
4
|
|
|
5
5
|
/** Property key stamped on every ModelDefinition to distinguish it from plain objects. */
|
|
6
|
-
export const MODEL_BRAND =
|
|
6
|
+
export const MODEL_BRAND = "__pyreonMod" as const
|
|
7
7
|
|
|
8
8
|
// ─── State type helpers ───────────────────────────────────────────────────────
|
|
9
9
|
|
|
@@ -31,8 +31,7 @@ export type StateSignals<TState extends StateShape> = {
|
|
|
31
31
|
* strongly typed for state signals, `any` for actions and views so that
|
|
32
32
|
* actions can call each other without circular type issues.
|
|
33
33
|
*/
|
|
34
|
-
export type ModelSelf<TState extends StateShape> = StateSignals<TState> &
|
|
35
|
-
Record<string, any>
|
|
34
|
+
export type ModelSelf<TState extends StateShape> = StateSignals<TState> & Record<string, any>
|
|
36
35
|
|
|
37
36
|
/** The public instance type returned by `.create()` and hooks. */
|
|
38
37
|
export type ModelInstance<
|
|
@@ -65,7 +64,7 @@ export type Snapshot<TState extends StateShape> = {
|
|
|
65
64
|
// ─── Patch ────────────────────────────────────────────────────────────────────
|
|
66
65
|
|
|
67
66
|
export interface Patch {
|
|
68
|
-
op:
|
|
67
|
+
op: "replace"
|
|
69
68
|
path: string
|
|
70
69
|
value: unknown
|
|
71
70
|
}
|
|
@@ -83,10 +82,7 @@ export interface ActionCall {
|
|
|
83
82
|
path: string
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export type MiddlewareFn = (
|
|
87
|
-
call: ActionCall,
|
|
88
|
-
next: (nextCall: ActionCall) => unknown,
|
|
89
|
-
) => unknown
|
|
85
|
+
export type MiddlewareFn = (call: ActionCall, next: (nextCall: ActionCall) => unknown) => unknown
|
|
90
86
|
|
|
91
87
|
// ─── Instance metadata ────────────────────────────────────────────────────────
|
|
92
88
|
|