Skip to content

Commit

Permalink
Merge branch 'main' into v5/routes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Sep 18, 2024
2 parents ca80978 + de6591f commit 4e3a800
Show file tree
Hide file tree
Showing 234 changed files with 65,762 additions and 71,765 deletions.
5 changes: 0 additions & 5 deletions .changeset/six-crabs-hang.md

This file was deleted.

4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# prettier formatting
71183da18ae6b0b6b2e8f0c52ea9976232e54f41
94037fe9c429839f0508ddcd287718b659276e3b
f51bf4d8907307ace083a0decb34668176c7fad3
12 changes: 8 additions & 4 deletions .github/actions/ci-checks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ runs:
using: 'composite'
steps:
- name: Build
run: yarn build
run: pnpm build
shell: bash

- name: Typecheck
run: yarn typecheck
run: pnpm typecheck
shell: bash

- name: Test
run: yarn test --silent
run: pnpm test --silent
shell: bash

- name: Svelte Check
run: yarn --cwd packages/xstate-svelte svelte-check
run: pnpm --filter @xstate/svelte svelte-check
shell: bash

- name: Knip
run: pnpm knip
shell: bash
9 changes: 7 additions & 2 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ name: 'CI setup'
runs:
using: 'composite'
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: yarn
run: pnpm install
shell: bash
14 changes: 3 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,14 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16.x
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup

- name: Build docs
working-directory: docs
run: |
yarn install
yarn docs:build
NODE_OPTIONS='--openssl-legacy-provider' pnpm docs:build
- name: Publish docs
uses: JamesIves/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup
- uses: ./.github/actions/ci-checks
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions: {}

jobs:
release:
permissions:
Expand All @@ -23,15 +24,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup
- uses: ./.github/actions/ci-checks

- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
with:
publish: yarn run release
version: yarn run version
publish: pnpm run release
version: pnpm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43 changes: 43 additions & 0 deletions .knip.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"workspaces": {
".": {
"entry": ["scripts/*.js"],
"project": ["scripts/*.js"]
},
"packages/core": {
"entry": [
"src/index.ts",
"src/actions.ts",
"src/actors/index.ts",
"src/guards.ts",
"src/dev/index.ts"
]
},
"packages/xstate-inspect": {
"entry": ["src/index.ts", "src/server.ts"]
},
"packages/xstate-store": {
"entry": ["src/index.ts", "src/react.ts", "src/solid.ts"]
},
"packages/xstate-svelte": {
"typescript": "test/tsconfig.json"
}
},
"ignore": [
// used for `#is-development` conditional import
"packages/**/{true,false}.ts",
// file acts as a type test
"packages/xstate-svelte/test/interpreterAsReadable.svelte"
],
"ignoreBinaries": ["svelte-check", "docs:build"],
"ignoreDependencies": [
"@xstate-repo/jest-utils/setup",
"synckit",
// package.json#exports aren't added as entry points, because `dist/` is .gitignored
"react",
"solid-js",
"xstate",
"@types/ws"
]
}
2 changes: 2 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "node",
"request": "launch",
"name": "Jest Current File",
"runtimeExecutable": "sh",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["${file}", "--config", "jest.config.js", "--no-cache"],
"console": "integratedTerminal",
Expand All @@ -17,6 +18,7 @@
"type": "node",
"request": "launch",
"name": "Jest Current File (no timeout)",
"runtimeExecutable": "sh",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${file}",
Expand Down
17 changes: 8 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ Please read [our code of conduct](https://github.com/statelyai/xstate/blob/main/
## Environment

- Ensure you have the latest version of Node and Yarn.
- Run `yarn` to install all needed dev dependencies.
- Run `pnpm i` to install all needed dev dependencies.

## Making changes

Pull requests are encouraged. If you want to add a feature or fix a bug:

1. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) and [clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) the [repository](https://github.com/statelyai/xstate).
2. [Create a separate branch](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/managing-branches) for your changes.
3. Make your changes, and ensure that it is formatted by [Prettier](https://prettier.io) and type-checks without errors in [TypeScript](https://www.typescriptlang.org/).
4. Write tests that validate your change and/or fix.
5. Run `yarn build` and then run tests with `yarn test` (for all packages) or `yarn test:core` (for only changes to core XState).
6. For package changes, add docs inside the `/packages/*/README.md`. These docs will be copied on build to the corresponding `/docs/packages/*/index.md` file.
7. Create a changeset by running `yarn changeset`. [More about changesets](https://github.com/atlassian/changesets).
8. Push your branch and open a PR 🚀
1. [Create a separate branch](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/managing-branches) for your changes.
1. Make your changes, and write tests that validate your change and/or fix.
1. Run `pnpm test` (for all packages) or `pnpm test:core` (for only changes to core XState).
1. Run `pnpm typecheck` to make sure that there are no type errors.
1. Create a changeset by running `pnpm changeset`. [More about changesets](https://github.com/atlassian/changesets).
1. Push your branch and open a PR 🚀

PRs are reviewed promptly and merged in within a day or two (or even within an hour) if everything looks good.

Expand Down Expand Up @@ -62,7 +61,7 @@ The [xstate.js.org](https://xstate.js.org) landing page is currently stored at `

### Building

We are using [preconstruct](https://preconstruct.tools/) to build our packages. It comes with a handy trick which allows us to always use source files of packages contained in this monorepo. It creates hook/redirecting files in place of dist files during development. This always happens after installing packages (during `postinstall` step) and you shouldn't be worried about it, but if you actually build packages you destroy those redirecting files and to run tests, typechecking etc correctly you need to bring them back by running `yarn postinstall`.
We are using [preconstruct](https://preconstruct.tools/) to build our packages. It comes with a handy trick which allows us to always use source files of packages contained in this monorepo. It creates hook/redirecting files in place of dist files during development. This always happens after installing packages (during `postinstall` step) and you shouldn't be worried about it, but if you actually build packages you destroy those redirecting files and to run tests, typechecking etc correctly you need to bring them back by running `pnpm postinstall`.

### Publishing

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ Read [📽 the slides](http://slides.com/davidkhourshid/finite-state-machines) (

## Packages

| Package | Description |
| --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| 🤖 `xstate` | Core finite state machine and statecharts library + interpreter |
| [📉 `@xstate/graph`](https://github.com/statelyai/xstate/tree/main/packages/xstate-graph) | Graph traversal and model-based testing utilities using XState |
| [⚛️ `@xstate/react`](https://github.com/statelyai/xstate/tree/main/packages/xstate-react) | React hooks and utilities for using XState in React applications |
| [💚 `@xstate/vue`](https://github.com/statelyai/xstate/tree/main/packages/xstate-vue) | Vue composition functions and utilities for using XState in Vue applications |
| [🎷 `@xstate/svelte`](https://github.com/statelyai/xstate/tree/main/packages/xstate-svelte) | Svelte utilities for using XState in Svelte applications |
| [🥏 `@xstate/solid`](https://github.com/statelyai/xstate/tree/main/packages/xstate-solid) | Solid hooks and utilities for using XState in Solid applications |
| [🔍 `@xstate/inspect`](https://github.com/statelyai/xstate/tree/main/packages/xstate-inspect) | Inspection utilities for XState |
| Package | Description |
| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| 🤖 `xstate` | Core finite state machine and statecharts library + interpreter |
| [📉 `@xstate/graph`](https://github.com/statelyai/xstate/tree/main/packages/xstate-graph) | Graph traversal and model-based testing utilities using XState |
| [⚛️ `@xstate/react`](https://github.com/statelyai/xstate/tree/main/packages/xstate-react) | React hooks and utilities for using XState in React applications |
| [💚 `@xstate/vue`](https://github.com/statelyai/xstate/tree/main/packages/xstate-vue) | Vue composition functions and utilities for using XState in Vue applications |
| [🎷 `@xstate/svelte`](https://github.com/statelyai/xstate/tree/main/packages/xstate-svelte) | Svelte utilities for using XState in Svelte applications |
| [🥏 `@xstate/solid`](https://github.com/statelyai/xstate/tree/main/packages/xstate-solid) | Solid hooks and utilities for using XState in Solid applications |
| [🔍 `@statelyai/inspect`](https://github.com/statelyai/inspect) | Inspection utilities for XState |

## Finite State Machines

Expand Down
23 changes: 2 additions & 21 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
const { NODE_ENV } = process.env;
const isTest = NODE_ENV === 'test';

const stripSymbolObservableMethodPlugin = ({ types: t }) => {
const isSymbolObservable = t.buildMatchMemberExpression('Symbol.observable');
return {
visitor: {
Class(path) {
path
.get('body.body')
.filter(
(p) => p.isClassMethod() && isSymbolObservable(p.get('key').node)
)
.forEach((p) => p.remove());
}
}
};
};

module.exports = {
assumptions: {
constantReexports: true, // only matters for tests (since only there we transpile to CJS using Babel), it makes debugging easier
Expand Down Expand Up @@ -65,12 +49,9 @@ module.exports = {
]
},
{
test: /\/xstate-solid\//,
test: /\/xstate-solid\/|solid\.test\.tsx$/,
presets: ['babel-preset-solid']
}
],
plugins: [
stripSymbolObservableMethodPlugin,
'@babel/proposal-class-properties'
]
plugins: ['@babel/proposal-class-properties']
};
2 changes: 1 addition & 1 deletion docs/fr/sandboxes/todomvc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"xstate",
"react"
],
"name": "xstate-todomvc",
"name": "xstate-todomvc-fr",
"description": "The TodoMVC app implemented with React (using hooks) and XState version 4."
}
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"author": "David Khourshid",
"license": "MIT",
"scripts": {
"docs:dev": "yarn vuepress dev .",
"docs:dev": "pnpm vuepress dev .",
"docs:readme": "cpy ../README.md .",
"docs:build": "npm run docs:readme && vuepress build .",
"docs:pdf": "npm run docs:build && vuepress export .",
"docs:publish": "npm run docs:build && gh-pages --dist .vuepress/dist --dest ./docs"
"docs:build": "pnpm run docs:readme && vuepress build .",
"docs:pdf": "pnpm run docs:build && vuepress export .",
"docs:publish": "pnpm run docs:build && gh-pages --dist .vuepress/dist --dest ./docs"
},
"dependencies": {
"@vuepress/plugin-google-analytics": "^1.8.2",
Expand Down
Loading

0 comments on commit 4e3a800

Please sign in to comment.