diff --git a/.changeset/slow-swans-punch.md b/.changeset/slow-swans-punch.md deleted file mode 100644 index 3dd5610a4f..0000000000 --- a/.changeset/slow-swans-punch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'xstate': patch ---- - -Ensure that `InteropObservable` and `InteropSubscribable` are present in the type definition file. diff --git a/.changeset/stale-snails-drive.md b/.changeset/stale-snails-drive.md deleted file mode 100644 index 60243618c2..0000000000 --- a/.changeset/stale-snails-drive.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'xstate': patch ---- - -Add `UnknownMachineConfig` type diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index edf05f5b83..b5c262e251 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,32 @@ # xstate +## 5.6.2 + +### Patch Changes + +- [#4731](https://github.com/statelyai/xstate/pull/4731) [`960cdcbcb`](https://github.com/statelyai/xstate/commit/960cdcbcb88eb565bba2f03f3eeceff6001576d9) Thanks [@davidkpiano](https://github.com/davidkpiano)! - You can now import `getInitialSnapshot(…)` from `xstate` directly, which is useful for getting a mock of the initial snapshot when interacting with machines (or other actor logic) without `createActor(…)`: + + ```ts + import { getInitialSnapshot } from 'xstate'; + import { someMachine } from './someMachine'; + + // Returns the initial snapshot (state) of the machine + const initialSnapshot = getInitialSnapshot( + someMachine, + { name: 'Mateusz' } // optional input + ); + ``` + +## 5.6.1 + +### Patch Changes + +- [#4728](https://github.com/statelyai/xstate/pull/4728) [`659efd5c1`](https://github.com/statelyai/xstate/commit/659efd5c14b69038b0c234255494c2fe5418fdea) Thanks [@Andarist](https://github.com/Andarist)! - Fixed compatibility issue of the internal type definitions with TypeScript 5.0 + +- [#4712](https://github.com/statelyai/xstate/pull/4712) [`2f1d36a9d`](https://github.com/statelyai/xstate/commit/2f1d36a9d949119bb93295362523de59acc039a0) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Ensure that `InteropObservable` and `InteropSubscribable` are present in the type definition file. + +- [#4694](https://github.com/statelyai/xstate/pull/4694) [`0b6dff210`](https://github.com/statelyai/xstate/commit/0b6dff21069bb168b46c943653e445ff3daa5d63) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Add `UnknownMachineConfig` type + ## 5.6.0 ### Minor Changes diff --git a/packages/core/package.json b/packages/core/package.json index cff4411a1d..ad980b4f70 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "xstate", - "version": "5.6.0", + "version": "5.6.2", "description": "Finite State Machines and Statecharts for the Modern Web.", "main": "dist/xstate.cjs.js", "module": "dist/xstate.esm.js", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index b0177584bb..da7666949b 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -9,7 +9,7 @@ export * from './typegenTypes.ts'; export * from './types.ts'; export { waitFor } from './waitFor.ts'; import { createMachine } from './createMachine.ts'; -export { getNextSnapshot } from './getNextSnapshot.ts'; +export { getNextSnapshot, getInitialSnapshot } from './getNextSnapshot.ts'; import { Actor, createActor, interpret, Interpreter } from './createActor.ts'; import { StateNode } from './StateNode.ts'; // TODO: decide from where those should be exported diff --git a/packages/core/src/setup.ts b/packages/core/src/setup.ts index 65d280fc0e..d9986f9094 100644 --- a/packages/core/src/setup.ts +++ b/packages/core/src/setup.ts @@ -61,7 +61,7 @@ type ToProvidedActor< id: IsNever extends true ? string | undefined : K extends keyof Invert - ? Invert[K] + ? Invert[K] & string : string | undefined; }; }>; diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index b9ec69caed..4c37ca68a0 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -2352,19 +2352,21 @@ export type ToChildren = // or maybe even `TActor["logic"]` since it's possible to configure `{ src: string; logic: SomeConcreteLogic }` // TODO: consider adding `| undefined` here Record - : ToConcreteChildren & - { - include: { - [id: string]: TActor extends any - ? ActorRefFrom | undefined - : never; - }; - exclude: {}; - }[undefined extends TActor['id'] // if not all actors have literal string IDs then we need to create an index signature containing all possible actor types - ? 'include' - : string extends TActor['id'] + : Compute< + ToConcreteChildren & + { + include: { + [id: string]: TActor extends any + ? ActorRefFrom | undefined + : never; + }; + exclude: {}; + }[undefined extends TActor['id'] // if not all actors have literal string IDs then we need to create an index signature containing all possible actor types ? 'include' - : 'exclude']; + : string extends TActor['id'] + ? 'include' + : 'exclude'] + >; export type StateSchema = { states?: Record; diff --git a/packages/core/test/deterministic.test.ts b/packages/core/test/deterministic.test.ts index 753bb7482e..bdaafbaaa6 100644 --- a/packages/core/test/deterministic.test.ts +++ b/packages/core/test/deterministic.test.ts @@ -1,6 +1,10 @@ -import { fromCallback, createActor, getNextSnapshot } from '../src/index.ts'; -import { createMachine } from '../src/createMachine.ts'; -import { getInitialSnapshot } from '../src/getNextSnapshot.ts'; +import { + fromCallback, + createActor, + getNextSnapshot, + createMachine, + getInitialSnapshot +} from '../src/index.ts'; describe('deterministic machine', () => { const lightMachine = createMachine({ diff --git a/packages/core/test/getNextSnapshot.test.ts b/packages/core/test/getNextSnapshot.test.ts index b5b37309ef..76759391d2 100644 --- a/packages/core/test/getNextSnapshot.test.ts +++ b/packages/core/test/getNextSnapshot.test.ts @@ -1,10 +1,9 @@ import { - createActor, createMachine, fromTransition, - getNextSnapshot + getNextSnapshot, + getInitialSnapshot } from '../src'; -import { getInitialSnapshot } from '../src/getNextSnapshot'; describe('getNextSnapshot', () => { it('should calculate the next snapshot for transition logic', () => { diff --git a/packages/core/test/id.test.ts b/packages/core/test/id.test.ts index 86373a70af..ba624ff889 100644 --- a/packages/core/test/id.test.ts +++ b/packages/core/test/id.test.ts @@ -1,6 +1,10 @@ import { testAll } from './utils'; -import { createMachine, createActor } from '../src/index.ts'; -import { getInitialSnapshot, getNextSnapshot } from '../src/getNextSnapshot.ts'; +import { + createMachine, + createActor, + getNextSnapshot, + getInitialSnapshot +} from '../src/index.ts'; const idMachine = createMachine({ initial: 'A', diff --git a/packages/xstate-graph/package.json b/packages/xstate-graph/package.json index 089b73c9ee..9081ae6e64 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.6.0" + "xstate": "^5.6.2" }, "devDependencies": { - "xstate": "5.6.0" + "xstate": "5.6.2" }, "dependencies": {} } diff --git a/packages/xstate-immer/package.json b/packages/xstate-immer/package.json index 5f087f0b05..a15b050c04 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.6.0" + "xstate": "^5.6.2" }, "devDependencies": { "immer": "^10.0.2", - "xstate": "5.6.0" + "xstate": "5.6.2" } } diff --git a/packages/xstate-inspect/package.json b/packages/xstate-inspect/package.json index fa663ed554..cf31040ff8 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.6.0" + "xstate": "5.6.2" }, "peerDependencies": { "@types/ws": "^8.0.0", "ws": "^8.0.0", - "xstate": "^5.6.0" + "xstate": "^5.6.2" }, "peerDependenciesMeta": { "@types/ws": { diff --git a/packages/xstate-react/package.json b/packages/xstate-react/package.json index f70b65b42d..3e4bcaa7ac 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.6.0" + "xstate": "^5.6.2" }, "peerDependenciesMeta": { "xstate": { @@ -76,6 +76,6 @@ "jsdom-global": "^3.0.2", "react": "^18.0.0", "react-dom": "^18.0.0", - "xstate": "5.6.0" + "xstate": "5.6.2" } } diff --git a/packages/xstate-solid/package.json b/packages/xstate-solid/package.json index 1aed715d5d..6b5e98123b 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.6.0" + "xstate": "^5.6.2" }, "peerDependenciesMeta": { "xstate": { @@ -53,6 +53,6 @@ "devDependencies": { "solid-js": "^1.7.6", "solid-testing-library": "^0.3.0", - "xstate": "5.6.0" + "xstate": "5.6.2" } } diff --git a/packages/xstate-svelte/package.json b/packages/xstate-svelte/package.json index caf58663d9..aed90b715b 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.6.0" + "xstate": "^5.6.2" }, "peerDependenciesMeta": { "xstate": { @@ -60,6 +60,6 @@ "svelte-check": "^3.2.0", "svelte-jester": "^2.3.2", "svelte-preprocess": "^5.0.0", - "xstate": "5.6.0" + "xstate": "5.6.2" } } diff --git a/packages/xstate-test/package.json b/packages/xstate-test/package.json index 438859379f..01da7816c1 100644 --- a/packages/xstate-test/package.json +++ b/packages/xstate-test/package.json @@ -46,11 +46,11 @@ "url": "https://github.com/statelyai/xstate/issues" }, "peerDependencies": { - "xstate": "^5.6.0" + "xstate": "^5.6.2" }, "devDependencies": { "strip-ansi": "^5.2.0", - "xstate": "5.6.0" + "xstate": "5.6.2" }, "dependencies": { "@xstate/graph": "2.0.0-beta.6" diff --git a/packages/xstate-vue/package.json b/packages/xstate-vue/package.json index e436bdaa06..79e960a232 100644 --- a/packages/xstate-vue/package.json +++ b/packages/xstate-vue/package.json @@ -54,7 +54,7 @@ }, "peerDependencies": { "vue": "^3.0.0", - "xstate": "^5.6.0" + "xstate": "^5.6.2" }, "peerDependenciesMeta": { "xstate": { @@ -66,6 +66,6 @@ "@testing-library/vue": "^6.6.1", "@vue/compiler-sfc": "^3.0.11", "vue": "^3.0.11", - "xstate": "5.6.0" + "xstate": "5.6.2" } }