Skip to content

Commit da7e5b5

Browse files
authored
Merge pull request #75 from Respo/improve
add llms docs; add type hints
2 parents 986a32f + a61309d commit da7e5b5

12 files changed

Lines changed: 2099 additions & 16333 deletions

File tree

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
calcit.cirru -diff linguist-generated
33
yarn.lock -diff linguist-generated
4-
Agents.md -diff linguist-generated
4+
llms/*.md -diff linguist-generated

.github/workflows/tests.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414

15-
- uses: actions/setup-node@v4
15+
- uses: actions/setup-node@v6
1616
with:
1717
node-version: 24
18-
cache: yarn
18+
19+
- name: Enable Corepack
20+
run: |
21+
corepack enable
22+
corepack prepare yarn@4.12.0 --activate
23+
yarn --version
1924
2025
- uses: calcit-lang/setup-cr@0.0.8
2126

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ yarn-error.log
99
tmp/
1010

1111
draft/
12+
13+
.yarn/*.gz

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

Agents.md

Lines changed: 34 additions & 712 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 109 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -29,69 +29,116 @@ In `package.cirru` and run `caps`:
2929
DOM syntax
3030

3131
```cirru
32-
div
33-
{}
34-
:class-name "|demo-container"
35-
:style $ {} (:color :red)
36-
:on-click $ fn (event dispatch!)
37-
div $ {}
32+
ns app.demo $ :require
33+
respo.core :refer $ div
34+
35+
defn comp-demo (dispatch!)
36+
div
37+
{}
38+
:class-name "|demo-container"
39+
:style $ {} (:color :red)
40+
:on-click $ fn (event d!)
41+
d! :clicked
42+
div $ {}
43+
```
44+
45+
More examples adapted from `compact.cirru`:
46+
47+
```cirru
48+
ns app.demo $ :require
49+
respo.core :refer $ defcomp a <>
50+
51+
defcomp comp-link (href text)
52+
a
53+
{} $ :href href
54+
<> text
55+
```
56+
57+
```cirru
58+
ns app.demo $ :require
59+
respo.core :refer $ list-> div
60+
61+
defn comp-list ()
62+
list-> ({})
63+
[] $ [] :a
64+
div $ {}
3865
```
3966

4067
Text Node:
4168

4269
```cirru
43-
<> content
70+
ns app.demo $ :require
71+
respo.core :refer $ <>
4472
45-
; with styles
46-
<> content $ {}
47-
:color :red
48-
:font-size 14})
73+
defn comp-text (content)
74+
<> content
75+
76+
; with styles
77+
<> content $ {}
78+
:color :red
79+
:font-size 14
4980
```
5081

5182
Component definition:
5283

5384
```cirru
54-
defcomp comp-container (content)
55-
div
56-
{}
57-
:class-name |demo-container
58-
:style $ {} (:color :red)
59-
<> content
85+
ns app.demo $ :require
86+
respo.core :refer $ div <>
87+
88+
let
89+
comp-container $ fn (content)
90+
div
91+
{}
92+
:class-name |demo-container
93+
:style $ {} (:color :red)
94+
<> content
6095
```
6196

6297
App initialization:
6398

6499
```cirru
100+
ns app.demo $ :require
101+
respo.core :refer $ render!
102+
65103
; initialize store and update store
66-
defatom *store $ {} (:point 0)
67-
:states $ {}
68-
defn dispatch! (op)
69-
reset! *store (updater @*store op)
70-
71-
; TODO
72-
defn updater (store op)
73-
tag-match op
74-
(:TODO a b) TODO
75-
_ (do (eprintln "|Unknown op:" op) store)
76-
77-
; render to the DOM
78-
render! mount-point (comp-container @*store) dispatch!
104+
let
105+
*store $ atom $ {} (:point 0) (:states {})
106+
updater $ fn (store op)
107+
tag-match op
108+
(:TODO a b) store
109+
_ store
110+
dispatch! $ fn (op)
111+
reset! *store $ updater @*store op
112+
mount-point nil
113+
comp-container $ fn (state) state
114+
dispatch! $ :: :TODO 1 2
115+
116+
; render to the DOM
117+
defn render-app! ()
118+
render! mount-point (comp-container @*store) dispatch!
79119
```
80120

81121
Rerender on store changes:
82122

83123
```cirru
84-
defn render-app! ()
85-
render! mount-point (comp-container @*store) dispatch!
86-
87-
add-watch *store :changes $ fn ()
88-
render-app!
124+
let
125+
*store $ atom $ {} (:point 0)
126+
render-app! $ fn () nil
127+
add-watch *store :changes $ fn ()
128+
render-app!
89129
```
90130

91131
Reset virtual DOM caching during hot code swapping, and rerender:
92132

93133
```cirru
94-
defn reload! ()
134+
ns app.demo $ :require
135+
respo.core :refer $ clear-cache!
136+
137+
let
138+
*store $ atom $ {} (:point 0)
139+
render-app! $ fn () nil
140+
add-watch *store :changes $ fn ()
141+
render-app!
95142
remove-watch *store :changes
96143
add-watch *store :changes $ fn ()
97144
render-app!
@@ -102,29 +149,35 @@ defn reload! ()
102149
Adding effects to component:
103150

104151
```cirru
105-
defeffect effect-a (text) (action parent-element at-place?)
106-
println action
107-
; action could be :mount :update :amount
108-
109-
when (= :mount action)
110-
do nil
111-
112-
defcomp comp-a (text)
113-
[]
114-
effect-a text
115-
div {}
152+
ns app.demo $ :require
153+
respo.core :refer $ div
154+
155+
let
156+
effect-a $ fn (text)
157+
fn (action parent-element at-place?)
158+
println action
159+
; action could be :mount :update :amount
160+
when (= :mount action) nil
161+
defn comp-a (text)
162+
[]
163+
effect-a text
164+
div {}
116165
```
117166

118167
Define a hooks plugin based on Calcit Record, better use a pure function:
119168

120169
```cirru
121-
defn plugin-x (states options)
122-
%::
123-
%{} PluginX
124-
:render $ fn (self) (nth self 1)
125-
:show $ fn (self d! ? text)
126-
, :plugin-name
127-
div ({}) (<> "|Demo")
170+
ns app.demo $ :require
171+
respo.core :refer $ div <>
172+
173+
let
174+
plugin-x $ fn (states options)
175+
%::
176+
%{} :PluginX
177+
:render $ fn (self) (nth self 1)
178+
:show $ fn (self d! ? text) nil
179+
, :plugin-name
180+
div {} (<> "|Demo")
128181
```
129182

130183
### License
@@ -188,25 +241,6 @@ Core macros and functions for building applications:
188241
| `realize-ssr!` | [docs/apis/realize-ssr\_.md](docs/apis/realize-ssr_.md) | Server-side rendering |
189242
| `list->` | [docs/apis/list->.md](docs/apis/list->.md) | Create list containers |
190243

191-
### Using with Calcit CLI Tools
192-
193-
To explore the codebase using `cr` commands:
194-
195-
```bash
196-
# List all namespaces
197-
cr query ls-ns
198-
199-
# Explore core APIs
200-
cr query read-ns respo.core
201-
cr query peek-def respo.core defcomp
202-
cr query read-def respo.core render!
203-
204-
# Search for specific functionality
205-
cr query find-symbol render!
206-
cr query usages respo.core render!
207-
208-
# Check project configuration
209-
cr query configs
210-
```
244+
### Agent Workflows
211245

212-
For more CLI tool information, see [Agents.md](./Agents.md).
246+
Agent-oriented CLI workflows (query/check-md automation) are maintained in [Agents.md](./Agents.md).

0 commit comments

Comments
 (0)