diff --git a/.changeset/cold-planes-clap.md b/.changeset/cold-planes-clap.md deleted file mode 100644 index 27ff74d03a..0000000000 --- a/.changeset/cold-planes-clap.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -'xstate': minor ---- - -Inspecting an actor system via `actor.system.inspect(ev => …)` now accepts a function or observer, and returns a subscription: - -```ts -const actor = createActor(someMachine); - -const sub = actor.system.inspect((inspectionEvent) => { - console.log(inspectionEvent); -}); - -// Inspection events will be logged -actor.start(); -actor.send({ type: 'anEvent' }); - -// ... - -sub.unsubscribe(); - -// Will no longer log inspection events -actor.send({ type: 'someEvent' }); -``` diff --git a/.changeset/giant-bananas-drive.md b/.changeset/giant-bananas-drive.md deleted file mode 100644 index 18207a46f5..0000000000 --- a/.changeset/giant-bananas-drive.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'xstate': minor ---- - -`DoneActorEvent` and `ErrorActorEvent` now contain property `actorId`, which refers to the ID of the actor the event refers to. diff --git a/.changeset/smooth-crabs-dress.md b/.changeset/smooth-crabs-dress.md deleted file mode 100644 index 84d937ae26..0000000000 --- a/.changeset/smooth-crabs-dress.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -'xstate': minor ---- - -All actor logic creators now support [emitting events](https://stately.ai/docs/event-emitter): - -**Promise actors** - -```ts -const logic = fromPromise(async ({ emit }) => { - // ... - emit({ - type: 'emitted', - msg: 'hello' - }); - // ... -}); -``` - -**Transition actors** - -```ts -const logic = fromTransition((state, event, { emit }) => { - // ... - emit({ - type: 'emitted', - msg: 'hello' - }); - // ... - return state; -}, {}); -``` - -**Observable actors** - -```ts -const logic = fromObservable(({ emit }) => { - // ... - - emit({ - type: 'emitted', - msg: 'hello' - }); - - // ... -}); -``` - -**Callback actors** - -```ts -const logic = fromCallback(({ emit }) => { - // ... - emit({ - type: 'emitted', - msg: 'hello' - }); - // ... -}); -``` diff --git a/.changeset/strange-fireants-tap.md b/.changeset/strange-fireants-tap.md deleted file mode 100644 index 4e344125ea..0000000000 --- a/.changeset/strange-fireants-tap.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'xstate': patch ---- - -Expose type `UnknownActorRef` for use when calling `getSnapshot()` on an unknown `ActorRef`. diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index d6fa2d72b3..580a16bc68 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,93 @@ # xstate +## 5.14.0 + +### Minor Changes + +- [#4936](https://github.com/statelyai/xstate/pull/4936) [`c58b36dc3`](https://github.com/statelyai/xstate/commit/c58b36dc35991e20ba5d3c6e212e075f9b27f37d) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Inspecting an actor system via `actor.system.inspect(ev => …)` now accepts a function or observer, and returns a subscription: + + ```ts + const actor = createActor(someMachine); + + const sub = actor.system.inspect((inspectionEvent) => { + console.log(inspectionEvent); + }); + + // Inspection events will be logged + actor.start(); + actor.send({ type: 'anEvent' }); + + // ... + + sub.unsubscribe(); + + // Will no longer log inspection events + actor.send({ type: 'someEvent' }); + ``` + +- [#4942](https://github.com/statelyai/xstate/pull/4942) [`9caaa1f70`](https://github.com/statelyai/xstate/commit/9caaa1f7039f2f50096afd3885560dd40f6f17c0) Thanks [@boneskull](https://github.com/boneskull)! - `DoneActorEvent` and `ErrorActorEvent` now contain property `actorId`, which refers to the ID of the actor the event refers to. + +- [#4935](https://github.com/statelyai/xstate/pull/4935) [`2ac08b700`](https://github.com/statelyai/xstate/commit/2ac08b70054e8c6699051b7fafa450af95f7e483) Thanks [@davidkpiano](https://github.com/davidkpiano)! - All actor logic creators now support [emitting events](https://stately.ai/docs/event-emitter): + + **Promise actors** + + ```ts + const logic = fromPromise(async ({ emit }) => { + // ... + emit({ + type: 'emitted', + msg: 'hello' + }); + // ... + }); + ``` + + **Transition actors** + + ```ts + const logic = fromTransition((state, event, { emit }) => { + // ... + emit({ + type: 'emitted', + msg: 'hello' + }); + // ... + return state; + }, {}); + ``` + + **Observable actors** + + ```ts + const logic = fromObservable(({ emit }) => { + // ... + + emit({ + type: 'emitted', + msg: 'hello' + }); + + // ... + }); + ``` + + **Callback actors** + + ```ts + const logic = fromCallback(({ emit }) => { + // ... + emit({ + type: 'emitted', + msg: 'hello' + }); + // ... + }); + ``` + +### Patch Changes + +- [#4929](https://github.com/statelyai/xstate/pull/4929) [`417f35a11`](https://github.com/statelyai/xstate/commit/417f35a119d2d5a579927af4a971a41857836b4a) Thanks [@boneskull](https://github.com/boneskull)! - Expose type `UnknownActorRef` for use when calling `getSnapshot()` on an unknown `ActorRef`. + ## 5.13.2 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index eaae4f4144..474f8f2fae 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "xstate", - "version": "5.13.2", + "version": "5.14.0", "description": "Finite State Machines and Statecharts for the Modern Web.", "main": "dist/xstate.cjs.js", "module": "dist/xstate.esm.js", diff --git a/packages/xstate-graph/package.json b/packages/xstate-graph/package.json index 3d4a066eb8..15b1566d7c 100644 --- a/packages/xstate-graph/package.json +++ b/packages/xstate-graph/package.json @@ -40,10 +40,10 @@ "url": "https://github.com/statelyai/xstate/issues" }, "peerDependencies": { - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "devDependencies": { - "xstate": "5.13.2" + "xstate": "5.14.0" }, "dependencies": {} } diff --git a/packages/xstate-immer/package.json b/packages/xstate-immer/package.json index e8d46c0342..48dd15de5f 100644 --- a/packages/xstate-immer/package.json +++ b/packages/xstate-immer/package.json @@ -41,10 +41,10 @@ "dependencies": {}, "peerDependencies": { "immer": "^9.0.6 || ^10", - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "devDependencies": { "immer": "^10.0.2", - "xstate": "5.13.2" + "xstate": "5.14.0" } } diff --git a/packages/xstate-inspect/package.json b/packages/xstate-inspect/package.json index 8d4b060c57..ef8e98d815 100644 --- a/packages/xstate-inspect/package.json +++ b/packages/xstate-inspect/package.json @@ -53,12 +53,12 @@ "devDependencies": { "@types/ws": "^8.2.2", "ws": "^8.4.0", - "xstate": "5.13.2" + "xstate": "5.14.0" }, "peerDependencies": { "@types/ws": "^8.0.0", "ws": "^8.0.0", - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "peerDependenciesMeta": { "@types/ws": { diff --git a/packages/xstate-react/package.json b/packages/xstate-react/package.json index 5c0b823031..57dfd93ebe 100644 --- a/packages/xstate-react/package.json +++ b/packages/xstate-react/package.json @@ -55,7 +55,7 @@ }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "peerDependenciesMeta": { "xstate": { @@ -76,6 +76,6 @@ "jsdom-global": "^3.0.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "xstate": "5.13.2" + "xstate": "5.14.0" } } diff --git a/packages/xstate-solid/package.json b/packages/xstate-solid/package.json index ebd38ad6c8..1e842f9d52 100644 --- a/packages/xstate-solid/package.json +++ b/packages/xstate-solid/package.json @@ -43,7 +43,7 @@ }, "peerDependencies": { "solid-js": "^1.6.0", - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "peerDependenciesMeta": { "xstate": { @@ -53,6 +53,6 @@ "devDependencies": { "solid-js": "^1.7.6", "solid-testing-library": "^0.3.0", - "xstate": "5.13.2" + "xstate": "5.14.0" } } diff --git a/packages/xstate-svelte/package.json b/packages/xstate-svelte/package.json index 27c99c14ae..e3ef9fcb8a 100644 --- a/packages/xstate-svelte/package.json +++ b/packages/xstate-svelte/package.json @@ -45,7 +45,7 @@ }, "peerDependencies": { "svelte": "^3.24.1 || ^4", - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "peerDependenciesMeta": { "xstate": { @@ -60,6 +60,6 @@ "svelte-check": "^3.2.0", "svelte-jester": "^2.3.2", "svelte-preprocess": "^5.0.0", - "xstate": "5.13.2" + "xstate": "5.14.0" } } diff --git a/packages/xstate-vue/package.json b/packages/xstate-vue/package.json index cfa05eb589..bb0b029cb9 100644 --- a/packages/xstate-vue/package.json +++ b/packages/xstate-vue/package.json @@ -54,7 +54,7 @@ }, "peerDependencies": { "vue": "^3.0.0", - "xstate": "^5.13.2" + "xstate": "^5.14.0" }, "peerDependenciesMeta": { "xstate": { @@ -66,6 +66,6 @@ "@testing-library/vue": "^6.6.1", "@vue/compiler-sfc": "^3.0.11", "vue": "^3.0.11", - "xstate": "5.13.2" + "xstate": "5.14.0" } }