Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V5 (WIP) #898

Merged
merged 1,192 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
1192 commits
Select commit Hold shift + click to select a range
b13bfcb
Drop support for array-based transition configs (#4123)
Andarist Jul 7, 2023
d860f8e
Remove `machineToJSON` experiment (#4126)
Andarist Jul 7, 2023
cdaddc2
Refactor how builtin actions are structured and how all actions are s…
Andarist Jul 10, 2023
1afd949
Version Packages (beta) (#4125)
github-actions[bot] Jul 10, 2023
461e398
Fixed missing `.mjs` proxy files for condition-based builds (#4138)
Andarist Jul 11, 2023
5b56864
Version Packages (beta) (#4139)
github-actions[bot] Jul 11, 2023
2f36232
Merge remote-tracking branch 'origin/main' into next
Andarist Jul 12, 2023
afc6900
[v5] Require `context` if specified (#4049)
davidkpiano Jul 15, 2023
c7c3cb4
[v5] `self` for all actor logic (#4117)
davidkpiano Jul 25, 2023
4df5744
Version Packages (beta) (#4149)
github-actions[bot] Jul 25, 2023
e2440f0
Reworked how actor types are provided to machines (#4036)
davidkpiano Jul 27, 2023
31eb5f8
Move all callback actor parameters into a single object (#4157)
Valkendorm Jul 28, 2023
f0694cb
Version Packages (beta) (#4164)
github-actions[bot] Jul 28, 2023
ead1e43
Rewrite `ComputeConcreteChildren` to be faster (#4165)
Andarist Jul 28, 2023
a247111
Input types for machines (#4054)
davidkpiano Aug 1, 2023
231a6f3
Make sure that `useSelector` doesn’t create stale values in `@xstate/…
enyo Aug 2, 2023
5cc9025
Reworked parts of internal error handling (#4145)
davidkpiano Aug 4, 2023
0c3bf27
Version Packages (beta) (#4170)
github-actions[bot] Aug 4, 2023
2e176b0
[v5] Rename `interpret` to `createActor` (#4176)
davidkpiano Aug 7, 2023
8401035
Add persisted state example (#4090)
davidkpiano Aug 10, 2023
6feac8b
Version Packages (beta) (#4178)
github-actions[bot] Aug 15, 2023
2b75485
Add `TOutput` to machines (#4179)
davidkpiano Aug 17, 2023
21b9a0c
Update README.md
davidkpiano Aug 19, 2023
495684b
Update README.md
davidkpiano Aug 19, 2023
d3d72b1
Remove the script that was rewriting the computed property name in a …
Andarist Aug 19, 2023
ada1799
Remove `@xstate/scxml` package (#4201)
Andarist Aug 21, 2023
ead0ba0
Remove leftover references of `@xstate/scxml`
Andarist Aug 21, 2023
1005cea
Change `State['nextEvents']` return type to `string[]` (#4203)
Andarist Aug 22, 2023
6b1646b
Introduce `TAction` that allows to type actions that can be used with…
davidkpiano Aug 22, 2023
8163d19
Version Packages (beta) (#4194)
github-actions[bot] Aug 22, 2023
47069a7
Update README.md
davidkpiano Aug 24, 2023
e7b5949
Refactor composite guards (#4206)
Andarist Aug 24, 2023
70bd8d0
Introduce `TGuard` that allows to type guards that can be used within…
davidkpiano Aug 25, 2023
5d19c5a
Allow the types to flow from `pure` to `raise` (#4210)
Andarist Aug 26, 2023
6abc2a6
Version Packages (beta) (#4207)
github-actions[bot] Aug 26, 2023
e658a37
Add `TGuard` to actions so `choose` can benefit from it (#4209)
Andarist Aug 29, 2023
d34f8b1
Introduce `TDelay` that allows to type delays that can be used within…
davidkpiano Aug 30, 2023
243d36f
Introduce `TTag` that allows to type tags that can be used within a m…
Andarist Aug 30, 2023
26d566a
Version Packages (beta) (#4215)
github-actions[bot] Aug 30, 2023
c67a3d3
[v5] Strongly-typed partial event descriptors (#4220)
davidkpiano Aug 31, 2023
d04cf6f
Version Packages (beta) (#4223)
github-actions[bot] Aug 31, 2023
189fa24
Snake example (#4230)
davidkpiano Sep 4, 2023
3d96d0f
Remove `getMachineShortestPaths` and `getMachineSimplePaths` (#4233)
davidkpiano Sep 5, 2023
322b42c
Start including `@xstate/graph` and `@xstate/test` in v5 releases (#4…
Andarist Sep 5, 2023
7d5d447
Version Packages (beta) (#4236)
github-actions[bot] Sep 5, 2023
953cf65
Add a type-level test related to states composition (#4242)
Andarist Sep 6, 2023
f4082c7
Remove `StateNode['target']` getter (#4245)
Andarist Sep 6, 2023
9db5079
Remove leftovers of `invoke.meta` (#4243)
Andarist Sep 6, 2023
59c1db7
Cleanup/deduplicate `xstate.init`/`xstate.stop` event types (#4244)
Andarist Sep 6, 2023
723e3ff
Removed `StateNode['stateIds']` getter (#4246)
Andarist Sep 6, 2023
b4f12a5
[v5] Improve paths in `@xstate/graph` (#4238)
davidkpiano Sep 6, 2023
ab1485d
Version Packages (beta) (#4247)
github-actions[bot] Sep 6, 2023
d02226c
Remove the ability to pass a string directly as `invoke`'s value (#4…
Andarist Sep 6, 2023
7b843b7
Bump the TS version used by the repository (#4251)
Andarist Sep 6, 2023
3dd95a2
Refactor all test cases to use `.types` and not explicit generic type…
Andarist Sep 6, 2023
d2977b0
Add type exports for all builtin action types (#4252)
Andarist Sep 6, 2023
824bee8
Allow action and guard params to be dynamic (#4228)
Andarist Sep 7, 2023
e91eff0
Version Packages (beta) (#4249)
github-actions[bot] Sep 7, 2023
b750e63
Move event utils to a separate file (#4255)
Andarist Sep 8, 2023
dbbd3c2
Bump `@tsconfig/svelte` (#4260)
Andarist Sep 8, 2023
41822f0
Utilize `TActor` to type `spawn` (#4222)
Andarist Sep 11, 2023
2c916b8
[v5] Export actor logic types (#4269)
davidkpiano Sep 12, 2023
c8de2ce
Put all special events under `xstate.*` namespace (#4270)
Andarist Sep 12, 2023
1153b3f
[v5] Remove FSM-related code (#4265)
davidkpiano Sep 12, 2023
b8118bf
Improved type safety of `spawn`ed inline actors when the actor types …
Andarist Sep 12, 2023
d42050e
Version Packages (beta) (#4266)
github-actions[bot] Sep 13, 2023
e4d300e
docs(vue): migrate examples to script setup (#4272)
wobsoriano Sep 13, 2023
a2e9a89
Rewrite one of the `invoke.onError` tests (#4273)
Andarist Sep 13, 2023
6ff9fc2
Drop support for handling promises returned by `fromCallback` (#3282)
Andarist Sep 13, 2023
f983fb8
Add extra test cases for `fromObservable` (#3566)
with-heart Sep 14, 2023
c8e4ff7
Fixed a typo in internal `toSerializableAction` util (#4279)
Andarist Sep 14, 2023
f2d5ac0
Improve types for `self` (#4278)
Andarist Sep 14, 2023
52b26fd
Remove `deferEvents` option (#4281)
Andarist Sep 15, 2023
4f1e416
Remove redundant `toActorRef` and `isActorRef` helpers (#4283)
Andarist Sep 15, 2023
896c605
Version Packages (beta) (#4275)
github-actions[bot] Sep 15, 2023
409552c
[v5] Alias `useMachine` in `@xstate/react` (#4240)
davidkpiano Sep 16, 2023
2a84922
Version Packages (beta) (#4289)
github-actions[bot] Sep 17, 2023
4ede0f9
Update templates (#4287)
davidkpiano Sep 17, 2023
da8bbb7
Update the Transloadit's sponsorship link and logo (#4291)
nqst Sep 18, 2023
8028d78
Move tests related to restarting actors within a macrotask (#4274)
Andarist Sep 19, 2023
6236980
Remove CodeSee action
Andarist Sep 19, 2023
b17b627
Update README.md
davidkpiano Sep 19, 2023
d30b348
Change Babel's target to node 18 (#4298)
Andarist Sep 21, 2023
bd9a1a5
Normalize snapshot shapes (#4299)
Andarist Sep 22, 2023
17e036e
Fix types in tests
Andarist Sep 22, 2023
7375350
Version Packages (beta) (#4303)
github-actions[bot] Sep 22, 2023
5fd8f26
Tweak types in a few actor-related tests (#4304)
Andarist Sep 23, 2023
af032db
[@xstate/graph] Mock `actorContext` (#4308)
davidkpiano Sep 24, 2023
612dd3a
Version Packages (beta) (#4309)
github-actions[bot] Sep 24, 2023
23402e3
Give unique names to `resolve` in `execute` helpers used by builtin a…
Andarist Sep 25, 2023
6ec18f1
add example with persistence saving to mongodb (#4314)
gavination Sep 25, 2023
0c7b3aa
Persist callback input (#4307)
davidkpiano Sep 26, 2023
30e3cb2
Move machine's `output` to top level (#4306)
Andarist Sep 26, 2023
d913858
add readme (#4317)
gavination Sep 26, 2023
04b7b9e
Update README.md
davidkpiano Sep 26, 2023
3b24561
docs(vue): Fix example conditions typos and migration and script setu…
wobsoriano Sep 27, 2023
aeef5e2
[v5] `onSnapshot` for all actors (#4172)
davidkpiano Sep 27, 2023
9e45969
Version Packages (beta) (#4316)
github-actions[bot] Sep 27, 2023
44aa0a4
update application request workflow. remove invalid always transition…
gavination Sep 29, 2023
9f69d46
Fix a parent reference on rehydrated children (#4330)
Andarist Oct 1, 2023
ba111c3
Bind `this` to actor logic methods on state machines (#4335)
davidkpiano Oct 2, 2023
ddafb83
Version Packages (beta) (#4333)
github-actions[bot] Oct 2, 2023
13480c3
[v5] Inspect API (#4082)
davidkpiano Oct 3, 2023
17da186
Do not rehydrate missing invoked children (#4336)
Andarist Oct 3, 2023
2b0d5fc
Version Packages (beta) (#4337)
github-actions[bot] Oct 4, 2023
8e1586b
Fix typos (#4340)
szepeviktor Oct 6, 2023
986b726
Fix a few broken links to the new docs (#4346)
mellson Oct 9, 2023
f9b17f1
Export inspection event types (#4344)
davidkpiano Oct 9, 2023
6f18183
Make updated context available to invokes (#4351)
Andarist Oct 13, 2023
a867cc0
Version Packages (beta) (#4349)
github-actions[bot] Oct 14, 2023
0ca1b86
[v5] Persist & restore spawned actors (#3921)
davidkpiano Oct 16, 2023
04cad53
Remove the ability to define delayed transitions using an array (#4216)
Andarist Oct 16, 2023
81b6eda
Fixed an issue with actions of initial transitions being called too m…
Andarist Oct 16, 2023
84c46c1
Fixed an issue with not all actions of initial transitions being exec…
Andarist Oct 16, 2023
03ac5c0
Generate `xstate.done.state.*` events recursively for nested parallel…
Andarist Oct 17, 2023
1a00b5a
Fixed a runtime crash related to machines with their root state's typ…
Andarist Oct 17, 2023
f7f3c2d
Cleanup implementation related to entering final state of a machine (…
Andarist Oct 17, 2023
3513280
Remove support for deep and multiple initial states (#4363)
Andarist Oct 17, 2023
5348142
Change wording when mentioning the SCXML spec (#4366)
Andarist Oct 17, 2023
d239a1e
Call root's `output` with the done state event of the outermost compl…
Andarist Oct 18, 2023
98f9f91
Avoid completing a single state node more than once (#4367)
Andarist Oct 18, 2023
e0733b4
Version Packages (beta) (#4355)
github-actions[bot] Oct 19, 2023
c19e6fb
Remove `State['_internalQueue']` (#4372)
Andarist Oct 19, 2023
e890094
Remove further redundant state instances (#4375)
Andarist Oct 20, 2023
078eaad
Fixed an issue with exit actions being called twice when machine reac…
Andarist Oct 20, 2023
14cb2ed
Stop calling exit actions on stop (#4377)
Andarist Oct 20, 2023
8b3f664
Avoid selecting always transitions when the preceeding transition doe…
Andarist Oct 20, 2023
26542fc
Version Packages (beta) (#4373)
github-actions[bot] Oct 20, 2023
e0bbe33
Fixed an issue that caused parallel states with direct final children…
Andarist Oct 23, 2023
731799a
Do not resolve `output` of final states directly nested in parallel s…
Andarist Oct 23, 2023
0be0ef0
Added support to `stateIn` guard for checking a combination of an ID …
Andarist Oct 23, 2023
d040385
Avoid mutating `implementations.actors` with inline actors (#4250)
Andarist Oct 23, 2023
57814f4
Always avoid source reentrancy with `reenter: false` (the default) (#…
Andarist Oct 23, 2023
7a916da
Merge remote-tracking branch 'origin/main' into next
Andarist Oct 24, 2023
e4a4838
Add extra test cases for final outgoing events (#4389)
Andarist Oct 24, 2023
6d50df4
Switch from JSDoc to TSDoc (#4393)
audionerd Oct 25, 2023
d66200e
Add helpful code comments to `defer` calls in `sendTo` and `stop` (#4…
Andarist Oct 25, 2023
74a713e
Remove unused `Mailbox#prepend` (#4395)
Andarist Oct 25, 2023
ea0ce0d
Version Packages (beta) (#4385)
github-actions[bot] Oct 25, 2023
d4c3653
Added table in README.md (#4354)
HimajPatil Oct 26, 2023
eea74c5
Update machine snapshots with the stopped status when the actor gets …
Andarist Oct 26, 2023
bd22b14
Remove `TPersisted` generic (#4390)
Andarist Oct 26, 2023
a01169e
Unregister `systemId`s eagerly (#4405)
Andarist Oct 26, 2023
3f84bba
Fixed an issue with rehydrated actors not registering themselves in t…
Andarist Oct 27, 2023
41f5a7d
[v5] Add `spawn()` action (#4329)
davidkpiano Oct 27, 2023
e676dff
Fixes to support Generating API Documentation (#4391)
audionerd Oct 27, 2023
531a634
Call actions and guards with simplified `params` parameter (#4257)
Andarist Oct 27, 2023
12cfae0
Version Packages (beta) (#4402)
github-actions[bot] Oct 27, 2023
c46a800
[v5] ActorContext -> ActorScope (#4407)
davidkpiano Oct 27, 2023
a4a429e
API Docs: fromCallback (#4406)
audionerd Oct 30, 2023
21c98f6
API Docs: Actor#subscribe (#4418)
audionerd Oct 31, 2023
5393e82
Fixed an issue with parallel transition sources not being reentered c…
Andarist Nov 2, 2023
b28abfb
Add a test case related to invokes and history states (#4370)
Andarist Nov 2, 2023
a91fdea
Fixed an issue that caused non-active children to be rehydrated (#4404)
Andarist Nov 2, 2023
f4ca83a
API Docs: Actor (#4420)
audionerd Nov 2, 2023
9adb1cd
Version Packages (beta) (#4408)
github-actions[bot] Nov 2, 2023
36cb3ae
fromCallback does work with onError (#4426)
audionerd Nov 3, 2023
74baddc
Fixed an issue with persisting children that got rehydrated (#4425)
Andarist Nov 3, 2023
b07b5ea
Add deprecation notice in Provider (#4413)
davidkpiano Nov 3, 2023
26fbc6c
[v5] Consistent `actorRef` property for inspection events (#4414)
davidkpiano Nov 3, 2023
a79f2e4
Version Packages (beta) (#4427)
github-actions[bot] Nov 4, 2023
bdee70b
Simple workflow engine example (#4350)
davidkpiano Nov 5, 2023
8fb9844
Removed `Interpreter['status']` from publicly available properties (#…
Andarist Nov 6, 2023
2685a33
Remove the unsupported machine implementation types from `useActorRef…
Andarist Nov 7, 2023
37d8793
[v5] Remove `waitFor` timeout (#4435)
davidkpiano Nov 7, 2023
74179ee
Add an extra test case for correct action execution when it is provid…
Andarist Nov 7, 2023
51c20bc
Remove a mention of the removed `execute` option from the types
Andarist Nov 7, 2023
340aee6
Improved Fast Refresh support (#4436)
Andarist Nov 8, 2023
b4503a5
Version Packages (beta) (#4431)
github-actions[bot] Nov 8, 2023
e1c34b5
Run all tests in `assign.test.ts`
Andarist Nov 9, 2023
3eeb502
API Docs: ActorOptions (#4419)
audionerd Nov 9, 2023
7bbf41d
Removed `State#toStrings` method (#4438)
Andarist Nov 10, 2023
10d9539
Deduplicate `State` creation methods (#4440)
Andarist Nov 10, 2023
15c786b
Remove the internal `getInitialConfiguration` (#4441)
Andarist Nov 10, 2023
18862e5
Declassify `State` (#4443)
Andarist Nov 10, 2023
d6e41a9
Remove `mapState` util (#4444)
Andarist Nov 10, 2023
689190c
Version Packages (beta) (#4446)
github-actions[bot] Nov 10, 2023
b840b76
API Docs: fromPromise (#4452)
audionerd Nov 10, 2023
1fa4eb4
Update examples (#4437)
davidkpiano Nov 10, 2023
cfdf754
Update `@xstate/vue` hooks (#4288)
davidkpiano Nov 12, 2023
c50b4ea
Add `ActorLogic` interface docs (#4445)
audionerd Nov 13, 2023
7d5dcb1
Version Packages (beta) (#4458)
github-actions[bot] Nov 13, 2023
eea011c
Reuse methods across machine snapshot instances (#4447)
Andarist Nov 14, 2023
73079ed
Add extra test cases for targetless transitions combined with paralle…
Andarist Nov 14, 2023
21f18b5
Drop support for `implementations.actors.{src,input}` (#4451)
Andarist Nov 14, 2023
2e0c3e7
Add test (#4454)
davidkpiano Nov 14, 2023
0bbae03
Version Packages (beta) (#4461)
github-actions[bot] Nov 15, 2023
178dead
Require required inputs for invoked and spawned actors (#4463)
Andarist Nov 15, 2023
9c43530
Replace `isState`/`isStateConfig` with `isMachineSnapshot` (#4448)
Andarist Nov 15, 2023
5278a98
Fixed registered `systemId`s availability in initial actions (#4464)
Andarist Nov 15, 2023
06e4de0
Version Packages (beta) (#4465)
github-actions[bot] Nov 15, 2023
5457c34
API Docs: fromTransition (#4471)
audionerd Nov 16, 2023
b6e9387
API Docs: fromObservable (#4475)
audionerd Nov 20, 2023
6777c32
Fixed an issue with `onSnapshot` not working after rehydration (#4476)
Andarist Nov 21, 2023
a3a11c8
Introduce `setup()` API (#4353)
davidkpiano Nov 21, 2023
3c71e53
Replace getters on `MachineSnapshot` with methods (#4467)
Andarist Nov 21, 2023
d70c3f3
Version Packages (beta) (#4477)
github-actions[bot] Nov 21, 2023
d2a3bf6
Remove most of the phantom types from the `StateMachine` (#4479)
Andarist Nov 21, 2023
55174ee
API Docs: fromEventObservable (#4481)
audionerd Nov 21, 2023
3e610a1
Replace `TActor` with `TChildren` in `MachineSnapshot` (#4480)
Andarist Nov 22, 2023
f51bf4d
Update Prettier (#4295)
Andarist Nov 22, 2023
b7a5164
Upgrade Babel-related dependencies (#4484)
Andarist Nov 22, 2023
87521af
Introduce `const TConfig` to the `setup` API (#4483)
Andarist Nov 22, 2023
d90a595
setup function may lead to unexpected behavior (#4332)
sachin-nanayakkara Nov 22, 2023
0cbd722
Update Jest and a few of related dependencies (#4489)
Andarist Nov 23, 2023
1008cee
Patch `jest-snapshot` to benefit from the unreleased Prettier v3 supp…
Andarist Nov 23, 2023
c0025c3
Fixed an issue with actors deep in the tree failing to rehydrate (#4491)
Andarist Nov 23, 2023
384f0ff
Remove `getNextEvents` method from the `MachineSnapshot` (#4478)
Andarist Nov 24, 2023
145cbf2
Version Packages (beta) (#4482)
github-actions[bot] Nov 24, 2023
9ca3c3d
[v5] Rename `spawn(...)` action creator to `spawnChild(...)` (#4488)
davidkpiano Nov 24, 2023
4b1c854
Version Packages (beta) (#4494)
github-actions[bot] Nov 24, 2023
ac3ba5e
Remove some duplicated test cases (#4493)
Andarist Nov 24, 2023
f0dd7c0
API Docs: createActor (#4416)
audionerd Nov 25, 2023
ba4e8b3
Update README.md (#4495)
bartoszgolebiowski Nov 25, 2023
c9908b7
Fixed `ToProvidedActor` helper type (#4499)
davidkpiano Nov 27, 2023
2640437
Add missing CHANGELOG entry for `[email protected]`
Andarist Nov 27, 2023
17ca80a
Version Packages (beta) (#4501)
github-actions[bot] Nov 27, 2023
5da17f2
Do not select always transitions when no regular transition gets sele…
Andarist Nov 27, 2023
a9c8ecc
Revert "Do not select always transitions when no regular transition g…
Andarist Nov 27, 2023
ef4db67
Cleanup `@xstate/vue` tests (#4506)
Andarist Nov 27, 2023
bf4ae01
Merge `createActor` overloads into one (#4510)
Andarist Nov 28, 2023
a533ecc
Use `.flat`/`.flatMap` instead of the custom `flatten` util (#4515)
Andarist Nov 29, 2023
d648de0
Add extra test cases related to error reporting (#4517)
Andarist Nov 29, 2023
daf532b
Export all TS snapshot types (#4516)
Andarist Nov 29, 2023
02e14f6
Strongly-typed `state.value` and `state.matches` (#4498)
davidkpiano Nov 29, 2023
5604152
Refactor callback logic to not send self-event (#4509)
davidkpiano Nov 29, 2023
f25a60f
Add a changeset for the `TStateValue` work (#4518)
Andarist Nov 29, 2023
15634c2
Version Packages (beta) (#4502)
github-actions[bot] Nov 29, 2023
7916400
Update templates (#4519)
davidkpiano Nov 29, 2023
63d9238
Further errors-related adjustments (#4492)
Andarist Nov 29, 2023
e21e3f9
Fixed an issue with contextual parameters in input factories of input…
Andarist Nov 30, 2023
ec75859
Version Packages (beta) (#4520)
github-actions[bot] Nov 30, 2023
9ea542c
Update `@xstate/svelte` (#4507)
Andarist Nov 30, 2023
a91a728
Remove unused codepaths related to the removed array after transition…
Andarist Nov 30, 2023
76024f6
Remove unused utils (#4526)
Andarist Nov 30, 2023
7bcc62c
`enqueueActions()` (replaces `pure()` and `choose()`) (#4429)
davidkpiano Nov 30, 2023
cf6fded
Version Packages (beta) (#4528)
github-actions[bot] Nov 30, 2023
355e896
Edit after events (#4521)
davidkpiano Nov 30, 2023
5dc9777
Fixed type of `.events` and `.ownEvents` properties (#4530)
Andarist Nov 30, 2023
43843ea
Remove `pure` and `choose` (#4529)
Andarist Nov 30, 2023
83bc200
Remove xstate-analytics (#4522)
davidkpiano Nov 30, 2023
a5b1983
Fixed order of type parameters in `ActorRef` (#4531)
Andarist Nov 30, 2023
0012138
Version Packages (beta) (#4532)
github-actions[bot] Nov 30, 2023
2495aa2
Rename snapshot-related methods on the `ActorLogic` (#4533)
Andarist Nov 30, 2023
e85ee76
Version Packages (beta) (#4534)
github-actions[bot] Nov 30, 2023
6a9fa1f
Remove `escalate` (#4535)
Andarist Nov 30, 2023
a2a377f
[v5] `event.data` -> `event.error` for error events (#4539)
davidkpiano Dec 1, 2023
63b185a
Version Packages (beta) (#4536)
github-actions[bot] Dec 1, 2023
b434c1b
Merge remote-tracking branch 'origin/main' into next
Andarist Dec 1, 2023
d3d6149
Group changesets and remove irrelevant ones
Andarist Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/Machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export function createMachine<
>(
config: MachineConfig<TContext, TEvent, any>,
options?: Partial<MachineOptions<TContext, TEvent>>
): MachineNode<TContext, TEvent, TTypestate> {
): MachineNode<TContext, TEvent, any, TTypestate> {
return new MachineNode<TContext, TEvent, TTypestate>(config, options);
}
14 changes: 14 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,20 @@ export interface InterpreterOptions {

export type AnyInterpreter = Interpreter<any, any, any>;

/**
* Represents the `Interpreter` type of a given `MachineNode`.
*
* @typeParam TM - the machine to infer the interpreter's types from
*/
export type InterpreterOf<TM extends MachineNode> = TM extends MachineNode<
davidkpiano marked this conversation as resolved.
Show resolved Hide resolved
infer TContext,
infer TEvent,
infer TStateSchema,
infer TTypestate
>
? Interpreter<TContext, TEvent, TStateSchema, TTypestate>
: never;

export declare namespace SCXML {
// tslint:disable-next-line:no-shadowed-variable
export interface Event<TEvent extends EventObject> {
Expand Down
7 changes: 4 additions & 3 deletions packages/xstate-react/src/useMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
Typestate,
ActionObject,
ActionFunction,
ActionMeta
ActionMeta,
InterpreterOf
} from 'xstate';
import useConstant from './useConstant';
import { partition } from './utils';
Expand Down Expand Up @@ -109,8 +110,8 @@ export function useMachine<
Partial<MachineOptions<TContext, TEvent>> = {}
): [
State<TContext, TEvent, any, TTypestate>,
Interpreter<TContext, TEvent, TTypestate>['send'],
Interpreter<TContext, TEvent, TTypestate>
InterpreterOf<typeof machine>['send'],
InterpreterOf<typeof machine>
] {
if (process.env.NODE_ENV !== 'production') {
const [initialMachine] = useState(machine);
Expand Down
9 changes: 5 additions & 4 deletions packages/xstate-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
InterpreterOptions,
MachineOptions,
StateConfig,
Typestate
Typestate,
InterpreterOf
} from 'xstate';

interface UseMachineOptions<TContext, TEvent extends EventObject> {
Expand All @@ -40,9 +41,9 @@ export function useMachine<
Partial<UseMachineOptions<TContext, TEvent>> &
Partial<MachineOptions<TContext, TEvent>> = {}
): {
state: Ref<State<TContext, TEvent>, any, TTypestate>;
send: Interpreter<TContext, TEvent, any, TTypestate>['send'];
service: Interpreter<TContext, TEvent, any, TTypestate>;
state: Ref<State<TContext, TEvent, any, TTypestate>>;
send: InterpreterOf<typeof machine>['send'];
service: InterpreterOf<typeof machine>;
} {
const {
context,
Expand Down