Skip to content

Commit

Permalink
Version Packages (#4967)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Jul 13, 2024
1 parent 452bce7 commit 9841fab
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 153 deletions.
133 changes: 0 additions & 133 deletions .changeset/mighty-guests-hunt.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/six-crabs-hang.md

This file was deleted.

136 changes: 136 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,141 @@
# xstate

## 5.15.0

### Minor Changes

- [#4976](https://github.com/statelyai/xstate/pull/4976) [`452bce71e`](https://github.com/statelyai/xstate/commit/452bce71e56fb28bfd85294b44138cf1bd5a9608) Thanks [@with-heart](https://github.com/with-heart)! - Added exports for actor logic-specific `ActorRef` types: `CallbackActorRef`, `ObservableActorRef`, `PromiseActorRef`, and `TransitionActorRef`.

Each type represents `ActorRef` narrowed to the corresponding type of logic (the type of `self` within the actor's logic):

- `CallbackActorRef`: actor created by [`fromCallback`](https://stately.ai/docs/actors#fromcallback)

```ts
import { fromCallback, createActor } from 'xstate';

/** The events the actor receives. */
type Event = { type: 'someEvent' };
/** The actor's input. */
type Input = { name: string };

/** Actor logic that logs whenever it receives an event of type `someEvent`. */
const logic = fromCallback<Event, Input>(({ self, input, receive }) => {
self;
// ^? CallbackActorRef<Event, Input>

receive((event) => {
if (event.type === 'someEvent') {
console.log(`${input.name}: received "someEvent" event`);
// logs 'myActor: received "someEvent" event'
}
});
});

const actor = createActor(logic, { input: { name: 'myActor' } });
// ^? CallbackActorRef<Event, Input>
```

- `ObservableActorRef`: actor created by [`fromObservable`](https://stately.ai/docs/actors#fromobservable) and [`fromEventObservable`](https://stately.ai/docs/actors#fromeventobservable)

```ts
import { fromObservable, createActor } from 'xstate';
import { interval } from 'rxjs';
/** The type of the value observed by the actor's logic. */
type Context = number;
/** The actor's input. */
type Input = { period?: number };
/**
* Actor logic that observes a number incremented every `input.period`
* milliseconds (default: 1_000).
*/
const logic = fromObservable<Context, Input>(({ input, self }) => {
self;
// ^? ObservableActorRef<Event, Input>
return interval(input.period ?? 1_000);
});
const actor = createActor(logic, { input: { period: 2_000 } });
// ^? ObservableActorRef<Event, Input>
```

- `PromiseActorRef`: actor created by [`fromPromise`](https://stately.ai/docs/actors#actors-as-promises)

```ts
import { fromPromise, createActor } from 'xstate';
/** The actor's resolved output. */
type Output = string;
/** The actor's input. */
type Input = { message: string };
/** Actor logic that fetches the url of an image of a cat saying `input.message`. */
const logic = fromPromise<Output, Input>(async ({ input, self }) => {
self;
// ^? PromiseActorRef<Output, Input>
const data = await fetch(`https://cataas.com/cat/says/${input.message}`);
const url = await data.json();
return url;
});

const actor = createActor(logic, { input: { message: 'hello world' } });
// ^? PromiseActorRef<Output, Input>
```
- `TransitionActorRef`: actor created by [`fromTransition`](https://stately.ai/docs/actors#fromtransition)
```ts
import { fromTransition, createActor, type AnyActorSystem } from 'xstate';

/** The actor's stored context. */
type Context = {
/** The current count. */
count: number;
/** The amount to increase `count` by. */
step: number;
};
/** The events the actor receives. */
type Event = { type: 'increment' };
/** The actor's input. */
type Input = { step?: number };

/**
* Actor logic that increments `count` by `step` when it receives an event of
* type `increment`.
*/
const logic = fromTransition<Context, Event, AnyActorSystem, Input>(
(state, event, actorScope) => {
actorScope.self;
// ^? TransitionActorRef<Context, Event>

if (event.type === 'increment') {
return {
...state,
count: state.count + state.step
};
}
return state;
},
({ input, self }) => {
self;
// ^? TransitionActorRef<Context, Event>

return {
count: 0,
step: input.step ?? 1
};
}
);

const actor = createActor(logic, { input: { step: 10 } });
// ^? TransitionActorRef<Context, Event>
```
- [#4949](https://github.com/statelyai/xstate/pull/4949) [`8aa4c2b90`](https://github.com/statelyai/xstate/commit/8aa4c2b90c6a07a4678202181420b5ddd33edacf) Thanks [@davidkpiano](https://github.com/davidkpiano)! - The TypeGen-related types have been removed from XState, simplifying the internal types without affecting normal XState usage.
## 5.14.0
### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xstate",
"version": "5.14.0",
"version": "5.15.0",
"description": "Finite State Machines and Statecharts for the Modern Web.",
"main": "dist/xstate.cjs.js",
"module": "dist/xstate.esm.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/xstate-graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"url": "https://github.com/statelyai/xstate/issues"
},
"peerDependencies": {
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"devDependencies": {
"xstate": "5.14.0"
"xstate": "5.15.0"
},
"dependencies": {}
}
4 changes: 2 additions & 2 deletions packages/xstate-immer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"dependencies": {},
"peerDependencies": {
"immer": "^9.0.6 || ^10",
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"devDependencies": {
"immer": "^10.0.2",
"xstate": "5.14.0"
"xstate": "5.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/xstate-inspect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
"devDependencies": {
"@types/ws": "^8.2.2",
"ws": "^8.4.0",
"xstate": "5.14.0"
"xstate": "5.15.0"
},
"peerDependencies": {
"@types/ws": "^8.0.0",
"ws": "^8.0.0",
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"peerDependenciesMeta": {
"@types/ws": {
Expand Down
4 changes: 2 additions & 2 deletions packages/xstate-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"peerDependenciesMeta": {
"xstate": {
Expand All @@ -76,6 +76,6 @@
"jsdom-global": "^3.0.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"xstate": "5.14.0"
"xstate": "5.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/xstate-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"peerDependencies": {
"solid-js": "^1.6.0",
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"peerDependenciesMeta": {
"xstate": {
Expand All @@ -53,6 +53,6 @@
"devDependencies": {
"solid-js": "^1.7.6",
"solid-testing-library": "^0.3.0",
"xstate": "5.14.0"
"xstate": "5.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/xstate-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"peerDependencies": {
"svelte": "^3.24.1 || ^4",
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"peerDependenciesMeta": {
"xstate": {
Expand All @@ -60,6 +60,6 @@
"svelte-check": "^3.2.0",
"svelte-jester": "^2.3.2",
"svelte-preprocess": "^5.0.0",
"xstate": "5.14.0"
"xstate": "5.15.0"
}
}
4 changes: 2 additions & 2 deletions packages/xstate-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"peerDependencies": {
"vue": "^3.0.0",
"xstate": "^5.14.0"
"xstate": "^5.15.0"
},
"peerDependenciesMeta": {
"xstate": {
Expand All @@ -66,6 +66,6 @@
"@testing-library/vue": "^6.6.1",
"@vue/compiler-sfc": "^3.0.11",
"vue": "^3.0.11",
"xstate": "5.14.0"
"xstate": "5.15.0"
}
}

0 comments on commit 9841fab

Please sign in to comment.