Skip to content

Commit 64381d7

Browse files
committed
feat: switch to monorepo and add vue package
1 parent d6dc8f0 commit 64381d7

27 files changed

+5531
-1552
lines changed

.editorconfig

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ jobs:
8484
run: nr build
8585

8686
- name: Test
87-
run: nr test
87+
run: nr test:unit

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

eslint.config.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import deviltea from '@deviltea/eslint-config'
2+
3+
export default deviltea()

lerna.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3+
"version": "0.0.1",
4+
"packages": [
5+
"packages/*"
6+
],
7+
"npmClient": "pnpm"
8+
}

package.json

Lines changed: 31 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"name": "@deviltea/tiny-state-machine",
2+
"name": "@deviltea/tiny-state-machine-mono",
33
"type": "module",
44
"version": "0.0.1",
5+
"private": true,
56
"packageManager": "[email protected]",
67
"description": "A simple state machine with tiny size and type safe.",
78
"author": "DevilTea <[email protected]>",
@@ -13,74 +14,38 @@
1314
},
1415
"bugs": "https://github.com/DevilTea/tiny-state-machine/issues",
1516
"keywords": [],
16-
"sideEffects": false,
17-
"exports": {
18-
".": {
19-
"types": {
20-
"import": "./dist/index.d.mts",
21-
"require": "./dist/index.d.cts",
22-
"default": "./dist/index.d.ts"
23-
},
24-
"import": "./dist/index.mjs",
25-
"require": "./dist/index.cjs"
26-
}
27-
},
28-
"main": "./dist/index.mjs",
29-
"module": "./dist/index.mjs",
30-
"types": "./dist/index.d.ts",
31-
"typesVersions": {
32-
"*": {
33-
"*": [
34-
"./dist/*",
35-
"./dist/index.d.ts"
36-
]
37-
}
38-
},
39-
"files": [
40-
"dist"
41-
],
4217
"scripts": {
43-
"build": "unbuild && pnpm calcsize",
44-
"dev": "unbuild --stub",
45-
"lint": "eslint .",
46-
"lint:fix": "eslint . --fix",
47-
"prepublishOnly": "nr build",
48-
"release": "bumpp && npm publish",
49-
"start": "tsx src/index.ts",
50-
"test": "vitest",
18+
"build": "pnpm -r --filter=./packages/* run build",
19+
"stub": "pnpm -r --filter=./packages/* run stub",
20+
"prepare:local": "pnpm build && tsx ./scripts/prepareLocalInstall.ts",
21+
"release": "pnpm exec bumpp -r && pnpm run build && pnpm -r --filter=./packages/* publish",
5122
"calcsize": "tsx ./scripts/calcsize.ts",
52-
"typecheck": "tsc --noEmit --project tsconfig.test.json",
53-
"prepare": "simple-git-hooks"
23+
"lint": "eslint --fix .",
24+
"lint:packages": "eslint --fix ./packages/**/src/*",
25+
"lint:scripts": "eslint --fix ./scripts/*",
26+
"lint:configs": "eslint --fix ./vitest.config.ts",
27+
"typecheck": "tsc --noEmit --project ./tsconfig.json",
28+
"publint": "pnpm -r --filter=./packages/* exec publint",
29+
"test:unit": "vitest",
30+
"test:coverage": "vitest run --coverage"
5431
},
5532
"devDependencies": {
56-
"@antfu/ni": "0.23.0",
57-
"@deviltea/eslint-config": "3.4.1",
58-
"@deviltea/tsconfig": "0.0.6",
59-
"@types/node": "^20.10.1",
60-
"@vitest/coverage-v8": "2.1.3",
61-
"brotli-size": "4.0.0",
62-
"bumpp": "9.7.1",
63-
"eslint": "9.13.0",
64-
"fast-glob": "3.3.2",
65-
"gzip-size": "7.0.0",
66-
"lint-staged": "15.2.0",
67-
"pnpm": "9.12.2",
68-
"rimraf": "6.0.1",
69-
"simple-git-hooks": "2.11.1",
70-
"terser": "5.36.0",
71-
"tsx": "4.16.2",
72-
"typescript": "5.6.3",
73-
"unbuild": "^2.0.0",
74-
"vite": "5.4.10",
75-
"vitest": "2.1.3"
76-
},
77-
"simple-git-hooks": {
78-
"pre-commit": "pnpm lint-staged"
79-
},
80-
"lint-staged": {
81-
"*": "eslint --fix"
82-
},
83-
"publishConfig": {
84-
"access": "public"
33+
"@deviltea/eslint-config": "catalog:",
34+
"@deviltea/tsconfig": "catalog:",
35+
"@types/node": "catalog:",
36+
"@vitest/coverage-v8": "catalog:",
37+
"bumpp": "catalog:",
38+
"eslint": "catalog:",
39+
"happy-dom": "catalog:",
40+
"lerna": "^8.1.9",
41+
"pkg-size": "catalog:",
42+
"publint": "catalog:",
43+
"rimraf": "catalog:",
44+
"terser": "catalog:",
45+
"tsx": "catalog:",
46+
"typescript": "catalog:",
47+
"unbuild": "catalog:",
48+
"vitest": "catalog:",
49+
"zx": "catalog:"
8550
}
8651
}

build.config.ts renamed to packages/core/build.config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { defineBuildConfig } from 'unbuild'
22

33
export default defineBuildConfig({
4-
entries: [
5-
'src/index',
6-
],
4+
entries: ['src/index.ts'],
75
declaration: true,
8-
clean: true,
96
rollup: {
107
emitCJS: true,
118
},

packages/core/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@deviltea/tiny-state-machine",
3+
"type": "module",
4+
"publishConfig": {
5+
"access": "public"
6+
},
7+
"version": "0.0.1",
8+
"author": "DevilTea <[email protected]>",
9+
"license": "MIT",
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/DevilTea/tiny-state-machine.git",
13+
"directory": "packages/core"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/DevilTea/tiny-state-machine/issues"
17+
},
18+
"keywords": [],
19+
"exports": {
20+
".": {
21+
"import": {
22+
"types": "./dist/index.d.mts",
23+
"default": "./dist/index.mjs"
24+
},
25+
"require": {
26+
"types": "./dist/index.d.cts",
27+
"default": "./dist/index.cjs"
28+
}
29+
}
30+
},
31+
"main": "dist/index.cjs",
32+
"module": "dist/index.mjs",
33+
"types": "dist/index.d.ts",
34+
"files": [
35+
"dist"
36+
],
37+
"scripts": {
38+
"build": "unbuild && pkg-size",
39+
"stub": "unbuild --stub"
40+
}
41+
}

src/index.ts renamed to packages/core/src/index.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
type Prettify<T> = { [Key in keyof T]: T[Key] } & {}
22

3-
interface GeneralStateShape<StatesKeys extends string> {
4-
on: {
5-
[Event in string]: StatesKeys
3+
interface MachineState<StateKey extends string> {
4+
on?: {
5+
[Event in string]: StateKey
66
}
77
}
8-
interface FinalStateShape {
9-
type: 'final'
10-
}
11-
type StateShape<StatesKeys extends string> = GeneralStateShape<StatesKeys> | FinalStateShape
128

13-
interface MachineConfig<StatesKeys extends string = string> {
9+
export interface MachineConfig<StateKey extends string = string> {
1410
id?: string
15-
initial: StatesKeys
11+
initial: StateKey
1612
states: {
17-
[EachState in StatesKeys & string]: StateShape<StatesKeys>
13+
[EachState in StateKey]: MachineState<StateKey>
1814
}
1915
}
2016

21-
type MachineContext = Record<any, any> | null
17+
export type MachineContext = Record<any, any> | null
2218

23-
type StateKeyOf<Config extends MachineConfig> = keyof Config['states']
19+
export type StateKeyOf<Config extends MachineConfig> = keyof Config['states']
2420
type SourceState<Config extends MachineConfig> = Config extends { states: infer StatesConfig }
2521
? { [Key in keyof StatesConfig as StatesConfig[Key] extends { on: any } ? Key : never]: StatesConfig[Key] }
2622
: never

0 commit comments

Comments
 (0)