foldkit 0.13.0-canary.1 → 0.13.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -8
- package/package.json +12 -12
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
# Foldkit
|
|
2
2
|
|
|
3
|
-
> ⚠️
|
|
3
|
+
> ⚠️ Foldkit is in canary release for early adopters and experimenters. APIs are incomplete and may change rapidly.
|
|
4
4
|
|
|
5
|
-
**Foldkit** is an [Elm](https://elm-lang.org/)-inspired
|
|
5
|
+
**Foldkit** is an [Elm](https://elm-lang.org/)-inspired framework for building web applications powered by [Effect](https://effect.website/).
|
|
6
6
|
|
|
7
7
|
> Like origami: simple parts become intricate when folded together.
|
|
8
8
|
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Philosophy
|
|
12
|
+
|
|
13
|
+
Foldkit applies functional programming principles to web application development.
|
|
14
|
+
|
|
15
|
+
- **Pure updates** — State transitions are deterministic functions: `(model: Model, message: Message): Model` is the only way to change state.
|
|
16
|
+
- **Controlled side effects** — Side effects are described as `Command<Message>` values and executed by the runtime, not performed directly in update functions.
|
|
17
|
+
- **Explicit state transitions** — Every state change is modeled as a specific message type and is captured in the update function.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
9
21
|
## Installation
|
|
10
22
|
|
|
11
23
|
The best way to get started with Foldkit is to use `create-foldkit-app`. This
|
|
@@ -16,12 +28,16 @@ package manager and example template.
|
|
|
16
28
|
npx create-foldkit-app@latest --wizard
|
|
17
29
|
```
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### Simple Counter Example
|
|
34
|
+
|
|
35
|
+
See the full example at [examples/counter/src/main.ts](examples/counter/src/main.ts)
|
|
20
36
|
|
|
21
37
|
```ts
|
|
22
38
|
import { Match as M, Schema } from 'effect'
|
|
23
39
|
import { Runtime } from 'foldkit'
|
|
24
|
-
import {
|
|
40
|
+
import { Html, html } from 'foldkit/html'
|
|
25
41
|
import { ts } from 'foldkit/schema'
|
|
26
42
|
|
|
27
43
|
// MODEL
|
|
@@ -41,13 +57,13 @@ type Decrement = typeof Decrement.Type
|
|
|
41
57
|
type Increment = typeof Increment.Type
|
|
42
58
|
type Reset = typeof Reset.Type
|
|
43
59
|
|
|
44
|
-
type Message = typeof Message.Type
|
|
60
|
+
export type Message = typeof Message.Type
|
|
45
61
|
|
|
46
62
|
// UPDATE
|
|
47
63
|
|
|
48
|
-
const update = (count: Model, message: Message): [Model, Runtime.Command<Message
|
|
64
|
+
const update = (count: Model, message: Message): [Model, ReadonlyArray<Runtime.Command<Message>>] =>
|
|
49
65
|
M.value(message).pipe(
|
|
50
|
-
M.withReturnType<[Model, Runtime.Command<Message
|
|
66
|
+
M.withReturnType<[Model, ReadonlyArray<Runtime.Command<Message>>]>(),
|
|
51
67
|
M.tagsExhaustive({
|
|
52
68
|
Decrement: () => [count - 1, []],
|
|
53
69
|
Increment: () => [count + 1, []],
|
|
@@ -61,6 +77,8 @@ const init: Runtime.ElementInit<Model, Message> = () => [0, []]
|
|
|
61
77
|
|
|
62
78
|
// VIEW
|
|
63
79
|
|
|
80
|
+
const { div, button, Class, OnClick } = html<Message>()
|
|
81
|
+
|
|
64
82
|
const view = (count: Model): Html =>
|
|
65
83
|
div(
|
|
66
84
|
[Class('min-h-screen bg-white flex flex-col items-center justify-center gap-6 p-6')],
|
|
@@ -96,4 +114,40 @@ Runtime.run(element)
|
|
|
96
114
|
|
|
97
115
|
---
|
|
98
116
|
|
|
99
|
-
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
Explore the examples locally:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
git clone https://github.com/devinjameson/foldkit.git
|
|
123
|
+
cd foldkit
|
|
124
|
+
pnpm install
|
|
125
|
+
|
|
126
|
+
# In one terminal - build Foldkit in watch mode
|
|
127
|
+
pnpm dev:core
|
|
128
|
+
|
|
129
|
+
# In another terminal - run the counter example
|
|
130
|
+
pnpm dev:example:counter
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Status
|
|
136
|
+
|
|
137
|
+
We're building in the open. Feedback, issues, and contributions are welcome.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Roadmap
|
|
142
|
+
|
|
143
|
+
- [x] Core program loop with ADT-based update
|
|
144
|
+
- [x] DOM rendering
|
|
145
|
+
- [x] Optimized DOM rendering (minimal diffs, efficient updates)
|
|
146
|
+
- [x] Router integration
|
|
147
|
+
- [ ] Devtools + tracing
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit",
|
|
3
|
-
"version": "0.13.0-canary.
|
|
3
|
+
"version": "0.13.0-canary.2",
|
|
4
4
|
"description": "Elm-inspired UI framework powered by Effect",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,12 +47,18 @@
|
|
|
47
47
|
"files": [
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"clean": "rimraf dist *.tsbuildinfo",
|
|
52
|
+
"build": "pnpm run clean && tsc -b",
|
|
53
|
+
"watch": "tsc -b --watch",
|
|
54
|
+
"typecheck": "tsc -b --noEmit"
|
|
55
|
+
},
|
|
50
56
|
"peerDependencies": {
|
|
51
57
|
"effect": "^3.18.2"
|
|
52
58
|
},
|
|
53
59
|
"devDependencies": {
|
|
54
|
-
"effect": "^3.
|
|
55
|
-
"typescript": "^5.
|
|
60
|
+
"effect": "^3.19.14",
|
|
61
|
+
"typescript": "^5.9.3"
|
|
56
62
|
},
|
|
57
63
|
"keywords": [
|
|
58
64
|
"effect",
|
|
@@ -69,19 +75,13 @@
|
|
|
69
75
|
"directory": "packages/foldkit"
|
|
70
76
|
},
|
|
71
77
|
"dependencies": {
|
|
72
|
-
"@effect/platform-browser": "^0.
|
|
73
|
-
"snabbdom": "^3.6.
|
|
78
|
+
"@effect/platform-browser": "^0.74.0",
|
|
79
|
+
"snabbdom": "^3.6.3"
|
|
74
80
|
},
|
|
75
81
|
"publishConfig": {
|
|
76
82
|
"access": "public"
|
|
77
83
|
},
|
|
78
84
|
"engines": {
|
|
79
85
|
"node": ">=18.0.0"
|
|
80
|
-
},
|
|
81
|
-
"scripts": {
|
|
82
|
-
"clean": "rimraf dist *.tsbuildinfo",
|
|
83
|
-
"build": "pnpm run clean && tsc -b",
|
|
84
|
-
"watch": "tsc -b --watch",
|
|
85
|
-
"typecheck": "tsc -b --noEmit"
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Devin Jameson
|
|
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.
|