@xmachines/play-actor 4.0.0 → 5.0.1

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The actor contract of the XMachines Play Architecture. It names no state machine library.
4
4
 
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/badge/version-4.0.0-blue)](https://www.npmjs.com/package/@xmachines/play-actor)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/badge/version-5.0.1-blue)](https://www.npmjs.com/package/@xmachines/play-actor)
6
6
 
7
7
  ## Installation
8
8
 
@@ -13,7 +13,7 @@ pnpm add @xmachines/play-actor
13
13
  **Peer dependencies.** Install them with the package:
14
14
 
15
15
  ```bash
16
- pnpm add @xmachines/play-signals
16
+ pnpm add @xmachines/play-atom
17
17
  ```
18
18
 
19
19
  ## Overview
@@ -23,7 +23,7 @@ An actor of XMachines holds exactly two things:
23
23
 
24
24
  | Member | Type | Description |
25
25
  | ------- | ------------------------- | ------------------------------------------ |
26
- | `state` | `Signal.State<TSnapshot>` | The reactive snapshot of the current state |
26
+ | `state` | `Atom<TSnapshot>` | The reactive snapshot of the current state |
27
27
  | `send` | `(event: TEvent) => void` | The typed event dispatch |
28
28
 
29
29
  **It is an interface, and no base class.** A state machine library is the concern of an
@@ -55,14 +55,15 @@ Both type parameters carry their real type through, and neither one erases it.
55
55
 
56
56
  ```ts
57
57
  import type { PlayActor } from "@xmachines/play-actor";
58
- import { Signal } from "@xmachines/play-signals";
58
+ import { createAtom } from "@xmachines/play-atom";
59
+ import type { Atom } from "@xmachines/play-atom";
59
60
 
60
61
  type Snapshot = { readonly value: string };
61
62
  type AuthEvent =
62
63
  { readonly type: "auth.login"; readonly username: string } | { readonly type: "auth.logout" };
63
64
 
64
65
  class AuthActor implements PlayActor<Snapshot, AuthEvent> {
65
- readonly state = new Signal.State<Snapshot>({ value: "guest" });
66
+ readonly state = createAtom<Snapshot>({ value: "guest" });
66
67
 
67
68
  send(event: AuthEvent): void {
68
69
  if (event.type === "auth.login") this.state.set({ value: "authenticated" });
@@ -78,7 +79,7 @@ A plain object satisfies the contract as well. Nothing here asks for a class.
78
79
 
79
80
  ```ts
80
81
  const actor: PlayActor<Snapshot, AuthEvent> = {
81
- state: new Signal.State<Snapshot>({ value: "guest" }),
82
+ state: createAtom<Snapshot>({ value: "guest" }),
82
83
  send: () => {},
83
84
  };
84
85
  ```
@@ -97,15 +98,14 @@ actor class of its own engine, and the contract stays out of the inheritance.
97
98
  ```ts
98
99
  import type { PlayActor } from "@xmachines/play-actor";
99
100
  import type { Routable } from "@xmachines/play-router";
100
- import { Signal } from "@xmachines/play-signals";
101
101
  import { Actor, type AnyActorLogic } from "xstate";
102
102
 
103
103
  class MyRoutableActor
104
104
  extends Actor<AnyActorLogic>
105
105
  implements PlayActor<unknown, { readonly type: string }>, Routable
106
106
  {
107
- readonly state = new Signal.State<unknown>({});
108
- readonly currentRoute = new Signal.Computed<string | null>(() => null);
107
+ readonly state = createAtom<unknown>({});
108
+ readonly currentRoute = createAtom<string | null>(() => null);
109
109
  readonly initialRoute = "/";
110
110
  }
111
111
  ```
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * An actor of XMachines holds exactly two things, and this file names both:
5
5
  *
6
- * - `state`: the reactive snapshot, as a TC39 Signal
6
+ * - `state`: the reactive snapshot, as an atom
7
7
  * - `send`: the typed event dispatch
8
8
  *
9
9
  * It names NO engine. A state machine library is the concern of an adapter, and
@@ -24,7 +24,7 @@
24
24
  * @packageDocumentation
25
25
  * @see [Play RFC](../../docs/rfc/play.md)
26
26
  */
27
- import type { Signal } from "@xmachines/play-signals";
27
+ import type { Atom } from "@xmachines/play-atom";
28
28
  /**
29
29
  * The minimal shape of an event that an actor receives.
30
30
  *
@@ -44,7 +44,7 @@ export interface ActorEvent {
44
44
  * of an adapter, and `@xmachines/play-xstate` is the adapter of XState v5.
45
45
  *
46
46
  * Both type parameters carry their real type through, and neither one erases it.
47
- * `AbstractActor` declares `Signal.State<unknown>`, so every consumer of a snapshot reads
47
+ * `AbstractActor` declares `Atom<unknown>`, so every consumer of a snapshot reads
48
48
  * `unknown` and asserts its way back.
49
49
  *
50
50
  * A capability is optional, and each one lives with the package that holds its shared
@@ -73,10 +73,10 @@ export interface PlayActor<TSnapshot = unknown, TEvent extends ActorEvent = Acto
73
73
  /**
74
74
  * The reactive snapshot of the current actor state.
75
75
  *
76
- * The infrastructure observes this signal, and it reacts to each state change. It
76
+ * The infrastructure observes this atom, and it reacts to each state change. It
77
77
  * therefore holds no coupling to the internal state machine of the actor.
78
78
  */
79
- readonly state: Signal.State<TSnapshot>;
79
+ readonly state: Atom<TSnapshot>;
80
80
  /**
81
81
  * Sends an event to the actor.
82
82
  *
@@ -1 +1 @@
1
- {"version":3,"file":"play-actor.d.ts","sourceRoot":"","sources":["../src/play-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,SAAS,CAAC,SAAS,GAAG,OAAO,EAAE,MAAM,SAAS,UAAU,GAAG,UAAU;IACrF;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAExC;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
1
+ {"version":3,"file":"play-actor.d.ts","sourceRoot":"","sources":["../src/play-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,SAAS,CAAC,SAAS,GAAG,OAAO,EAAE,MAAM,SAAS,UAAU,GAAG,UAAU;IACrF;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAEhC;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * An actor of XMachines holds exactly two things, and this file names both:
5
5
  *
6
- * - `state`: the reactive snapshot, as a TC39 Signal
6
+ * - `state`: the reactive snapshot, as an atom
7
7
  * - `send`: the typed event dispatch
8
8
  *
9
9
  * It names NO engine. A state machine library is the concern of an adapter, and
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@xmachines/play-actor",
3
- "version": "4.0.0",
3
+ "version": "5.0.1",
4
4
  "private": false,
5
5
  "description": "The actor contract of the Play Architecture: state and send. It names no state machine library",
6
6
  "keywords": [
7
7
  "actor",
8
+ "atoms",
8
9
  "play-architecture",
9
- "signals",
10
10
  "xmachines",
11
11
  "xstate"
12
12
  ],
@@ -50,16 +50,16 @@
50
50
  "devDependencies": {
51
51
  "@testing-library/jest-dom": "^7.0.1",
52
52
  "@types/node": "^26.6.2",
53
- "@xmachines/play": "4.0.0",
54
- "@xmachines/play-signals": "4.0.0",
55
- "oxfmt": "^0.68.0",
56
- "oxlint": "^1.83.0",
53
+ "@xmachines/play": "5.0.1",
54
+ "@xmachines/play-atom": "5.0.1",
55
+ "oxfmt": "^0.70.0",
56
+ "oxlint": "^1.85.0",
57
57
  "vite": "^8.3.0",
58
58
  "vitest": "^5.0.1",
59
59
  "xstate": "^5.33.0"
60
60
  },
61
61
  "peerDependencies": {
62
- "@xmachines/play-signals": "4.0.0"
62
+ "@xmachines/play-atom": "5.0.1"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=24.0.0"