From 10a6e382ea237c48254d5b78740e462156b24c09 Mon Sep 17 00:00:00 2001 From: Vladislav Maraev Date: Thu, 22 Aug 2024 10:12:10 +0200 Subject: [PATCH] Start with documentation Additionally, update @statelyai/inspect and make typescript checks for pull requests. --- .github/workflows/check-typescript.js.yml | 21 +++++++++++++++++++++ package.json | 2 +- src/dme.ts | 11 +++++++++-- yarn.lock | 10 +++++----- 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/check-typescript.js.yml diff --git a/.github/workflows/check-typescript.js.yml b/.github/workflows/check-typescript.js.yml new file mode 100644 index 0000000..c633d22 --- /dev/null +++ b/.github/workflows/check-typescript.js.yml @@ -0,0 +1,21 @@ +name: Typechecker + +on: + pull_request: + branches: [ "main" ] +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Enable Corepack + run: corepack enable + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + - run: yarn exec tsc --noemit diff --git a/package.json b/package.json index f9011e8..814a20f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "vitest": "^2.0.5" }, "dependencies": { - "@statelyai/inspect": "^0.2.5", + "@statelyai/inspect": "^0.4.0", "speechstate": "^2.4.0" }, "packageManager": "yarn@3.6.4+sha256.7f7d51b38db0d94adf25c512e3f3d3b47d23c97922eecc540f7440f116bdb99a" diff --git a/src/dme.ts b/src/dme.ts index 4e67024..3abf4cf 100644 --- a/src/dme.ts +++ b/src/dme.ts @@ -2,15 +2,22 @@ import { setup, assign, sendTo, AnyTransitionConfig } from "xstate"; import { rules } from "./rules"; import { SaysMoveEvent, DMEEvent, DMEContext } from "./types"; +/** + * Creates a transition with a guarded ISU. + * + * @param nextState Target state. + * @param ruleName Name of ISU rule. + * @param sendBackNextMove If `true`, communicate next move to the parent machine. + */ function isuTransition( nextState: string, ruleName: string, - nextMove: boolean, + sendBackNextMove: boolean, ): AnyTransitionConfig { return { target: nextState, guard: { type: "isu", params: { name: ruleName } }, - actions: nextMove + actions: sendBackNextMove ? [ { type: "isu", params: { name: ruleName } }, { type: "sendBackNextMove" }, diff --git a/yarn.lock b/yarn.lock index 14c1f04..30b2626 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2038,9 +2038,9 @@ __metadata: languageName: node linkType: hard -"@statelyai/inspect@npm:^0.2.5": - version: 0.2.5 - resolution: "@statelyai/inspect@npm:0.2.5" +"@statelyai/inspect@npm:^0.4.0": + version: 0.4.0 + resolution: "@statelyai/inspect@npm:0.4.0" dependencies: fast-safe-stringify: ^2.1.1 isomorphic-ws: ^5.0.0 @@ -2050,7 +2050,7 @@ __metadata: uuid: ^9.0.1 peerDependencies: xstate: ^5.5.1 - checksum: a39ac4690dad15ecb6bf0dd898890d8351c075c6a6f5acee522f3119b8ffdf710ad9351e10b77f1f371c1e295a03c71520d8f8131acc9a9fc3221ae4c218b4b8 + checksum: 3e0c88e19f950138d623d60729c2fa56edf82cb7ac74e16b00390ee6f4aa9304fa5103c60137993505c9f1edf5c8af92602fafd2eb4d38e04e6b626357cc8274 languageName: node linkType: hard @@ -4466,7 +4466,7 @@ __metadata: version: 0.0.0-use.local resolution: "sisu@workspace:." dependencies: - "@statelyai/inspect": ^0.2.5 + "@statelyai/inspect": ^0.4.0 speechstate: ^2.4.0 typescript: ^5.2.2 vite: ^5.2.0