Skip to content

Commit 65d6488

Browse files
publish effect machine 0.1.0
0 parents  commit 65d6488

38 files changed

Lines changed: 22561 additions & 0 deletions

.changeset/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changesets
2+
3+
Run `pnpm changeset` for every user-facing change.

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": false,
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: pnpm/action-setup@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 24
20+
cache: pnpm
21+
- run: pnpm install --frozen-lockfile
22+
- run: pnpm check

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
id-token: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
environment: npm
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: pnpm/action-setup@v4
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 24
22+
cache: pnpm
23+
registry-url: https://registry.npmjs.org
24+
- run: pnpm install --frozen-lockfile
25+
- run: pnpm check
26+
- uses: changesets/action@v1
27+
with:
28+
publish: pnpm release
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
*.tgz
4+
.DS_Store

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist
2+
node_modules
3+
pnpm-lock.yaml
4+
*.tgz
5+
src
6+
test
7+
typetest

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"printWidth": 120,
4+
"trailingComma": "none"
5+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Sandro Maglione
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NOTICE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This package incubates the Machine work proposed in Effect PR #6429.
2+
3+
Portions are adapted from the Effect project, which is distributed under the
4+
MIT License. See https://github.com/Effect-TS/effect and the source history for
5+
authorship and provenance.

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# @typeonce/effect-machine
2+
3+
External home for the schema-first Machine API proposed in
4+
[Effect PR #6429](https://github.com/Effect-TS/effect/pull/6429). During
5+
incubation this repository is the canonical implementation; the synchronization
6+
tool keeps the Effect PR mechanically aligned without a second logic
7+
implementation.
8+
9+
> Early-release software: APIs may change, and releases are coupled to an exact
10+
> Effect beta.
11+
12+
## Installation
13+
14+
```sh
15+
pnpm add @typeonce/effect-machine effect@4.0.0-beta.102
16+
```
17+
18+
`effect` is an exact peer dependency, not a bundled runtime dependency. Consumers
19+
must install `effect@4.0.0-beta.102`. Upgrading this package may require upgrading
20+
Effect in lockstep; do not override the peer to another beta.
21+
22+
## Entrypoints
23+
24+
```ts
25+
import { Machine } from "@typeonce/effect-machine"
26+
import { AtomMachine } from "@typeonce/effect-machine/reactivity"
27+
import { ClusterMachine } from "@typeonce/effect-machine/cluster"
28+
```
29+
30+
Each ESM entrypoint is independent and tree-shakeable. Importing the root does
31+
not load the reactivity or cluster adapters.
32+
33+
## Basic machine
34+
35+
```ts
36+
import { Effect, Schema } from "effect"
37+
import { Machine } from "@typeonce/effect-machine"
38+
39+
class Idle extends Schema.TaggedClass<Idle>("Idle")("Idle", {}) {}
40+
class Running extends Schema.TaggedClass<Running>("Running")("Running", {}) {}
41+
class Start extends Schema.TaggedClass<Start>("Start")("Start", {}) {}
42+
43+
const states = Machine.defineStates({ Idle, Running })
44+
45+
const Counter = Machine.make({
46+
id: "Counter",
47+
states: states.states,
48+
events: [Start],
49+
initial: states.initial.Idle(new Idle())
50+
}).handle({
51+
Idle: {
52+
on: {
53+
Start: ({ target }) => Effect.succeed(target.full.Running(new Running()))
54+
}
55+
}
56+
})
57+
```
58+
59+
The exported namespaces preserve the API, type identifiers, service keys,
60+
semantics, and documentation of the Effect proposal.
61+
62+
## Development and validation
63+
64+
Use pnpm 10 and Node.js 20 or newer:
65+
66+
```sh
67+
pnpm install --frozen-lockfile
68+
pnpm check
69+
```
70+
71+
Individual commands are available for `build`, `test`, `test:types`,
72+
`typecheck`, `format:check`, `test:consumer`, `test:sync`, `sync:check`, and
73+
`pack:check`. Runtime tests use `@effect/vitest`; type tests use TSTyche and
74+
TypeScript 6.0.3.
75+
76+
## Synchronizing Effect PR #6429
77+
78+
Make logic changes here first and run `pnpm check`. Then generate the mapped
79+
production files, runtime tests, and type tests into a writable Effect checkout:
80+
81+
```sh
82+
pnpm sync:effect -- /path/to/effect
83+
```
84+
85+
The explicit mapping covers only the eight production files and six test files.
86+
It rewrites package imports to Effect repository-relative `.ts` imports and
87+
restores Effect's private `PipeInspectableProto` boundary. It never copies
88+
package metadata, documentation, release files, or changesets.
89+
90+
Check an existing checkout without writing:
91+
92+
```sh
93+
pnpm sync:effect -- --check /path/to/effect
94+
```
95+
96+
Check mode exits non-zero on any drift. `pnpm test:sync` exercises generation,
97+
a clean check, and drift detection in a disposable temporary directory. Never
98+
generate into a checkout with work you have not reviewed. After generation,
99+
inspect the Effect diff and run its targeted machine, reactivity, cluster, and
100+
type-test validations followed by `pnpm check`.
101+
102+
The current source reference is branch `sandro/state-charts` in the Effect
103+
repository. Exact dependency pins and the sync check are the proof boundary;
104+
vendoring the rest of Effect is intentionally unnecessary.
105+
106+
## Releases
107+
108+
Add a changeset with `pnpm changeset`. CI validates frozen installation and the
109+
complete check suite. The release workflow opens version PRs and publishes with
110+
npm provenance through GitHub Actions.
111+
112+
Before the first release, create the `typeonce-dev/effect-machine` GitHub
113+
repository and configure npm trusted publishing for the repository and
114+
`.github/workflows/release.yml` environment. No npm token is intended.
115+
116+
When equivalent Machine modules ship in Effect, this package is intended to
117+
become a thin compatibility re-export package before eventual retirement.

0 commit comments

Comments
 (0)