jac-client 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl
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.
- jac_client/examples/all-in-one/assets/workers/worker.py +5 -0
- jac_client/tests/conftest.py +281 -0
- jac_client/tests/test_cli.py +755 -0
- jac_client/tests/test_it.py +347 -67
- {jac_client-0.2.3.dist-info → jac_client-0.2.4.dist-info}/METADATA +28 -30
- jac_client-0.2.4.dist-info/RECORD +10 -0
- {jac_client-0.2.3.dist-info → jac_client-0.2.4.dist-info}/WHEEL +2 -1
- jac_client-0.2.4.dist-info/entry_points.txt +4 -0
- jac_client-0.2.4.dist-info/top_level.txt +1 -0
- jac_client/docs/README.md +0 -689
- jac_client/docs/advanced-state.md +0 -1265
- jac_client/docs/asset-serving/intro.md +0 -209
- jac_client/docs/assets/pipe_line-v2.svg +0 -32
- jac_client/docs/assets/pipe_line.png +0 -0
- jac_client/docs/file-system/app.jac.md +0 -121
- jac_client/docs/file-system/backend-frontend.md +0 -217
- jac_client/docs/file-system/intro.md +0 -72
- jac_client/docs/file-system/nested-imports.md +0 -348
- jac_client/docs/guide-example/intro.md +0 -115
- jac_client/docs/guide-example/step-01-setup.md +0 -270
- jac_client/docs/guide-example/step-02-components.md +0 -416
- jac_client/docs/guide-example/step-03-styling.md +0 -478
- jac_client/docs/guide-example/step-04-todo-ui.md +0 -477
- jac_client/docs/guide-example/step-05-local-state.md +0 -530
- jac_client/docs/guide-example/step-06-events.md +0 -749
- jac_client/docs/guide-example/step-07-effects.md +0 -468
- jac_client/docs/guide-example/step-08-walkers.md +0 -534
- jac_client/docs/guide-example/step-09-authentication.md +0 -586
- jac_client/docs/guide-example/step-10-routing.md +0 -539
- jac_client/docs/guide-example/step-11-final.md +0 -963
- jac_client/docs/imports.md +0 -1141
- jac_client/docs/lifecycle-hooks.md +0 -773
- jac_client/docs/routing.md +0 -659
- jac_client/docs/styling/intro.md +0 -249
- jac_client/docs/styling/js-styling.md +0 -367
- jac_client/docs/styling/material-ui.md +0 -341
- jac_client/docs/styling/pure-css.md +0 -299
- jac_client/docs/styling/sass.md +0 -403
- jac_client/docs/styling/styled-components.md +0 -395
- jac_client/docs/styling/tailwind.md +0 -298
- jac_client/examples/all-in-one/.babelrc +0 -9
- jac_client/examples/all-in-one/README.md +0 -16
- jac_client/examples/all-in-one/app.jac +0 -426
- jac_client/examples/all-in-one/assets/burger.png +0 -0
- jac_client/examples/all-in-one/button.jac +0 -7
- jac_client/examples/all-in-one/components/button.jac +0 -7
- jac_client/examples/all-in-one/package.json +0 -29
- jac_client/examples/all-in-one/styles.css +0 -26
- jac_client/examples/all-in-one/vite.config.js +0 -28
- jac_client/examples/asset-serving/css-with-image/.babelrc +0 -9
- jac_client/examples/asset-serving/css-with-image/README.md +0 -91
- jac_client/examples/asset-serving/css-with-image/app.jac +0 -88
- jac_client/examples/asset-serving/css-with-image/assets/burger.png +0 -0
- jac_client/examples/asset-serving/css-with-image/package.json +0 -28
- jac_client/examples/asset-serving/css-with-image/styles.css +0 -26
- jac_client/examples/asset-serving/css-with-image/vite.config.js +0 -28
- jac_client/examples/asset-serving/image-asset/.babelrc +0 -9
- jac_client/examples/asset-serving/image-asset/README.md +0 -119
- jac_client/examples/asset-serving/image-asset/app.jac +0 -55
- jac_client/examples/asset-serving/image-asset/assets/burger.png +0 -0
- jac_client/examples/asset-serving/image-asset/package.json +0 -28
- jac_client/examples/asset-serving/image-asset/styles.css +0 -26
- jac_client/examples/asset-serving/image-asset/vite.config.js +0 -28
- jac_client/examples/asset-serving/import-alias/.babelrc +0 -9
- jac_client/examples/asset-serving/import-alias/README.md +0 -83
- jac_client/examples/asset-serving/import-alias/app.jac +0 -111
- jac_client/examples/asset-serving/import-alias/assets/burger.png +0 -0
- jac_client/examples/asset-serving/import-alias/package.json +0 -28
- jac_client/examples/asset-serving/import-alias/vite.config.js +0 -28
- jac_client/examples/basic/.babelrc +0 -9
- jac_client/examples/basic/README.md +0 -16
- jac_client/examples/basic/app.jac +0 -21
- jac_client/examples/basic/package.json +0 -27
- jac_client/examples/basic/vite.config.js +0 -27
- jac_client/examples/basic-auth/.babelrc +0 -9
- jac_client/examples/basic-auth/README.md +0 -16
- jac_client/examples/basic-auth/app.jac +0 -308
- jac_client/examples/basic-auth/package.json +0 -27
- jac_client/examples/basic-auth/vite.config.js +0 -27
- jac_client/examples/basic-auth-with-router/.babelrc +0 -9
- jac_client/examples/basic-auth-with-router/README.md +0 -60
- jac_client/examples/basic-auth-with-router/app.jac +0 -464
- jac_client/examples/basic-auth-with-router/package.json +0 -28
- jac_client/examples/basic-auth-with-router/vite.config.js +0 -27
- jac_client/examples/basic-full-stack/.babelrc +0 -9
- jac_client/examples/basic-full-stack/README.md +0 -18
- jac_client/examples/basic-full-stack/app.jac +0 -320
- jac_client/examples/basic-full-stack/package.json +0 -28
- jac_client/examples/basic-full-stack/vite.config.js +0 -27
- jac_client/examples/css-styling/js-styling/.babelrc +0 -9
- jac_client/examples/css-styling/js-styling/README.md +0 -183
- jac_client/examples/css-styling/js-styling/app.jac +0 -84
- jac_client/examples/css-styling/js-styling/package.json +0 -28
- jac_client/examples/css-styling/js-styling/styles.js +0 -100
- jac_client/examples/css-styling/js-styling/vite.config.js +0 -27
- jac_client/examples/css-styling/material-ui/.babelrc +0 -9
- jac_client/examples/css-styling/material-ui/README.md +0 -16
- jac_client/examples/css-styling/material-ui/app.jac +0 -122
- jac_client/examples/css-styling/material-ui/package.json +0 -32
- jac_client/examples/css-styling/material-ui/vite.config.js +0 -27
- jac_client/examples/css-styling/pure-css/.babelrc +0 -9
- jac_client/examples/css-styling/pure-css/README.md +0 -16
- jac_client/examples/css-styling/pure-css/app.jac +0 -64
- jac_client/examples/css-styling/pure-css/package.json +0 -28
- jac_client/examples/css-styling/pure-css/styles.css +0 -111
- jac_client/examples/css-styling/pure-css/vite.config.js +0 -27
- jac_client/examples/css-styling/sass-example/.babelrc +0 -9
- jac_client/examples/css-styling/sass-example/README.md +0 -16
- jac_client/examples/css-styling/sass-example/app.jac +0 -64
- jac_client/examples/css-styling/sass-example/package.json +0 -29
- jac_client/examples/css-styling/sass-example/styles.scss +0 -153
- jac_client/examples/css-styling/sass-example/vite.config.js +0 -27
- jac_client/examples/css-styling/styled-components/.babelrc +0 -9
- jac_client/examples/css-styling/styled-components/README.md +0 -16
- jac_client/examples/css-styling/styled-components/app.jac +0 -71
- jac_client/examples/css-styling/styled-components/package.json +0 -29
- jac_client/examples/css-styling/styled-components/styled.js +0 -90
- jac_client/examples/css-styling/styled-components/vite.config.js +0 -27
- jac_client/examples/css-styling/tailwind-example/.babelrc +0 -9
- jac_client/examples/css-styling/tailwind-example/README.md +0 -16
- jac_client/examples/css-styling/tailwind-example/app.jac +0 -63
- jac_client/examples/css-styling/tailwind-example/global.css +0 -1
- jac_client/examples/css-styling/tailwind-example/package.json +0 -30
- jac_client/examples/css-styling/tailwind-example/vite.config.js +0 -29
- jac_client/examples/full-stack-with-auth/.babelrc +0 -9
- jac_client/examples/full-stack-with-auth/README.md +0 -16
- jac_client/examples/full-stack-with-auth/app.jac +0 -722
- jac_client/examples/full-stack-with-auth/package.json +0 -28
- jac_client/examples/full-stack-with-auth/vite.config.js +0 -29
- jac_client/examples/little-x/app.jac +0 -724
- jac_client/examples/little-x/package.json +0 -23
- jac_client/examples/little-x/submit-button.jac +0 -8
- jac_client/examples/nested-folders/nested-advance/.babelrc +0 -9
- jac_client/examples/nested-folders/nested-advance/ButtonRoot.jac +0 -11
- jac_client/examples/nested-folders/nested-advance/README.md +0 -77
- jac_client/examples/nested-folders/nested-advance/app.jac +0 -35
- jac_client/examples/nested-folders/nested-advance/level1/ButtonSecondL.jac +0 -19
- jac_client/examples/nested-folders/nested-advance/level1/Card.jac +0 -43
- jac_client/examples/nested-folders/nested-advance/level1/level2/ButtonThirdL.jac +0 -25
- jac_client/examples/nested-folders/nested-advance/package.json +0 -29
- jac_client/examples/nested-folders/nested-advance/vite.config.js +0 -28
- jac_client/examples/nested-folders/nested-basic/.babelrc +0 -9
- jac_client/examples/nested-folders/nested-basic/README.md +0 -183
- jac_client/examples/nested-folders/nested-basic/app.jac +0 -13
- jac_client/examples/nested-folders/nested-basic/app.js +0 -7
- jac_client/examples/nested-folders/nested-basic/button.jac +0 -7
- jac_client/examples/nested-folders/nested-basic/components/button.jac +0 -7
- jac_client/examples/nested-folders/nested-basic/package.json +0 -28
- jac_client/examples/nested-folders/nested-basic/vite.config.js +0 -27
- jac_client/examples/with-router/.babelrc +0 -9
- jac_client/examples/with-router/README.md +0 -17
- jac_client/examples/with-router/app.jac +0 -323
- jac_client/examples/with-router/package.json +0 -28
- jac_client/examples/with-router/vite.config.js +0 -27
- jac_client/plugin/cli.py +0 -244
- jac_client/plugin/client.py +0 -152
- jac_client/plugin/client_runtime.jac +0 -234
- jac_client/plugin/vite_client_bundle.py +0 -503
- jac_client/tests/fixtures/basic-app/app.jac +0 -23
- jac_client/tests/fixtures/cl_file/app.cl.jac +0 -48
- jac_client/tests/fixtures/cl_file/app.jac +0 -15
- jac_client/tests/fixtures/client_app_with_antd/app.jac +0 -34
- jac_client/tests/fixtures/js_import/app.jac +0 -34
- jac_client/tests/fixtures/js_import/utils.js +0 -21
- jac_client/tests/fixtures/package-lock.json +0 -329
- jac_client/tests/fixtures/package.json +0 -11
- jac_client/tests/fixtures/relative_import/app.jac +0 -11
- jac_client/tests/fixtures/relative_import/button.jac +0 -7
- jac_client/tests/fixtures/spawn_test/app.jac +0 -129
- jac_client/tests/fixtures/test_fragments_spread/app.jac +0 -67
- jac_client/tests/test_asset_examples.py +0 -322
- jac_client/tests/test_cl.py +0 -530
- jac_client/tests/test_create_jac_app.py +0 -131
- jac_client/tests/test_nested_file.py +0 -374
- jac_client-0.2.3.dist-info/RECORD +0 -171
- jac_client-0.2.3.dist-info/entry_points.txt +0 -4
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
# Nested Folder Imports
|
|
2
|
-
|
|
3
|
-
Jac preserves folder structure during compilation, similar to TypeScript transpilation. This allows you to organize code in nested folders and use relative imports across multiple directory levels.
|
|
4
|
-
|
|
5
|
-
## Folder Structure Preservation
|
|
6
|
-
|
|
7
|
-
When Jac compiles your files, it preserves the folder structure in the `src/` directory:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
Source Structure: Compiled Structure:
|
|
11
|
-
my-app/ src/
|
|
12
|
-
├── app.jac → ├── app.js
|
|
13
|
-
├── ButtonRoot.jac → ├── ButtonRoot.js
|
|
14
|
-
└── level1/ └── level1/
|
|
15
|
-
├── ButtonSecondL.jac → ├── ButtonSecondL.js
|
|
16
|
-
├── Card.jac → ├── Card.js
|
|
17
|
-
└── level2/ └── level2/
|
|
18
|
-
└── ButtonThirdL.jac → └── ButtonThirdL.js
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Relative Import Syntax
|
|
22
|
-
|
|
23
|
-
Jac uses dot notation for relative imports:
|
|
24
|
-
|
|
25
|
-
- **Single dot (`.`)** - Current directory
|
|
26
|
-
- **Double dot (`..`)** - Parent directory (one level up)
|
|
27
|
-
- **Triple dot (`...`)** - Two levels up
|
|
28
|
-
- **Multiple dots** - Continue going up the directory tree
|
|
29
|
-
- **Dot notation after dots** - Go down into subdirectories (e.g., `.level2`)
|
|
30
|
-
|
|
31
|
-
## Import Patterns by Directory Level
|
|
32
|
-
|
|
33
|
-
### Root Level Imports
|
|
34
|
-
|
|
35
|
-
From the root directory, you can import from nested folders:
|
|
36
|
-
|
|
37
|
-
```jac
|
|
38
|
-
# app.jac (root level)
|
|
39
|
-
|
|
40
|
-
# Import from root
|
|
41
|
-
cl import from .ButtonRoot {
|
|
42
|
-
ButtonRoot
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# Import from level1
|
|
46
|
-
cl import from .level1.ButtonSecondL {
|
|
47
|
-
ButtonSecondL
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
# Import from level1/level2
|
|
51
|
-
cl import from .level1.level2.ButtonThirdL {
|
|
52
|
-
ButtonThirdL
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
# Import from level1
|
|
56
|
-
cl import from .level1.Card {
|
|
57
|
-
Card
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Second Level Imports
|
|
62
|
-
|
|
63
|
-
From `level1/`, you can import from root (up) or level2 (down):
|
|
64
|
-
|
|
65
|
-
```jac
|
|
66
|
-
# level1/ButtonSecondL.jac
|
|
67
|
-
|
|
68
|
-
# Import from root (go up one level with ..)
|
|
69
|
-
cl import from ..ButtonRoot {
|
|
70
|
-
ButtonRoot
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
```jac
|
|
75
|
-
# level1/Card.jac
|
|
76
|
-
|
|
77
|
-
# Import from root (go up two levels with ..)
|
|
78
|
-
cl import from ..ButtonRoot {
|
|
79
|
-
ButtonRoot
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
# Import from level2 (go down one level with .level2)
|
|
83
|
-
cl import from .level2.ButtonThirdL {
|
|
84
|
-
ButtonThirdL
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Third Level Imports
|
|
89
|
-
|
|
90
|
-
From `level1/level2/`, you can import from root or parent levels:
|
|
91
|
-
|
|
92
|
-
```jac
|
|
93
|
-
# level1/level2/ButtonThirdL.jac
|
|
94
|
-
|
|
95
|
-
# Import from root (go up three levels with ...)
|
|
96
|
-
cl import from ...ButtonRoot {
|
|
97
|
-
ButtonRoot
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
# Import from second level (go up one level with ..)
|
|
101
|
-
cl import from ..ButtonSecondL {
|
|
102
|
-
ButtonSecondL
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Complete Example
|
|
107
|
-
|
|
108
|
-
Here's a complete example demonstrating nested folder imports:
|
|
109
|
-
|
|
110
|
-
**Project Structure:**
|
|
111
|
-
```
|
|
112
|
-
nested-advance/
|
|
113
|
-
├── app.jac # Root entry point
|
|
114
|
-
├── ButtonRoot.jac # Root level button
|
|
115
|
-
└── level1/
|
|
116
|
-
├── ButtonSecondL.jac # Second level button
|
|
117
|
-
├── Card.jac # Card component (imports from root and level2)
|
|
118
|
-
└── level2/
|
|
119
|
-
└── ButtonThirdL.jac # Third level button
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**app.jac:**
|
|
123
|
-
```jac
|
|
124
|
-
cl import from .ButtonRoot {
|
|
125
|
-
ButtonRoot
|
|
126
|
-
}
|
|
127
|
-
cl import from .level1.ButtonSecondL {
|
|
128
|
-
ButtonSecondL
|
|
129
|
-
}
|
|
130
|
-
cl import from .level1.level2.ButtonThirdL {
|
|
131
|
-
ButtonThirdL
|
|
132
|
-
}
|
|
133
|
-
cl import from .level1.Card {
|
|
134
|
-
Card
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
cl def app() -> any {
|
|
138
|
-
return <div>
|
|
139
|
-
<ButtonRoot />
|
|
140
|
-
<ButtonSecondL />
|
|
141
|
-
<ButtonThirdL />
|
|
142
|
-
<Card />
|
|
143
|
-
</div>;
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**level1/ButtonSecondL.jac:**
|
|
148
|
-
```jac
|
|
149
|
-
cl import from ..ButtonRoot {
|
|
150
|
-
ButtonRoot
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
cl def ButtonSecondL() -> any {
|
|
154
|
-
return <div>
|
|
155
|
-
<Button>Second Level</Button>
|
|
156
|
-
<ButtonRoot />
|
|
157
|
-
</div>;
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**level1/Card.jac:**
|
|
162
|
-
```jac
|
|
163
|
-
# Imports from both above (root) and below (level2)
|
|
164
|
-
cl import from ..ButtonRoot {
|
|
165
|
-
ButtonRoot
|
|
166
|
-
}
|
|
167
|
-
cl import from .level2.ButtonThirdL {
|
|
168
|
-
ButtonThirdL
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
cl def Card() -> any {
|
|
172
|
-
return <div>
|
|
173
|
-
<ButtonRoot />
|
|
174
|
-
<ButtonThirdL />
|
|
175
|
-
</div>;
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
**level1/level2/ButtonThirdL.jac:**
|
|
180
|
-
```jac
|
|
181
|
-
cl import from ...ButtonRoot {
|
|
182
|
-
ButtonRoot
|
|
183
|
-
}
|
|
184
|
-
cl import from ..ButtonSecondL {
|
|
185
|
-
ButtonSecondL
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
cl def ButtonThirdL() -> any {
|
|
189
|
-
return <div>
|
|
190
|
-
<Button>Third Level</Button>
|
|
191
|
-
<ButtonRoot />
|
|
192
|
-
<ButtonSecondL />
|
|
193
|
-
</div>;
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Import Path Reference
|
|
198
|
-
|
|
199
|
-
| Your Location | Target Location | Import Path |
|
|
200
|
-
|--------------|----------------|-------------|
|
|
201
|
-
| `app.jac` (root) | `ButtonRoot.jac` (root) | `.ButtonRoot` |
|
|
202
|
-
| `app.jac` (root) | `level1/ButtonSecondL.jac` | `.level1.ButtonSecondL` |
|
|
203
|
-
| `app.jac` (root) | `level1/level2/ButtonThirdL.jac` | `.level1.level2.ButtonThirdL` |
|
|
204
|
-
| `level1/ButtonSecondL.jac` | `ButtonRoot.jac` (root) | `..ButtonRoot` |
|
|
205
|
-
| `level1/Card.jac` | `ButtonRoot.jac` (root) | `..ButtonRoot` |
|
|
206
|
-
| `level1/Card.jac` | `level2/ButtonThirdL.jac` | `.level2.ButtonThirdL` |
|
|
207
|
-
| `level1/level2/ButtonThirdL.jac` | `ButtonRoot.jac` (root) | `...ButtonRoot` |
|
|
208
|
-
| `level1/level2/ButtonThirdL.jac` | `level1/ButtonSecondL.jac` | `..ButtonSecondL` |
|
|
209
|
-
|
|
210
|
-
## Benefits of Nested Folder Structure
|
|
211
|
-
|
|
212
|
-
1. **Relative imports work correctly**: Folder structure is preserved, so imports resolve properly
|
|
213
|
-
2. **No file name conflicts**: Files with the same name in different folders don't overwrite each other
|
|
214
|
-
3. **Familiar structure**: Organize code in nested folders just like in TypeScript/JavaScript projects
|
|
215
|
-
4. **Consistent with modern tooling**: Matches the behavior of TypeScript, Babel, and other transpilers
|
|
216
|
-
5. **Scalable organization**: Organize large applications into logical folder hierarchies
|
|
217
|
-
|
|
218
|
-
## Best Practices for Nested Folders
|
|
219
|
-
|
|
220
|
-
1. **Organize by feature or component type**: Group related files together
|
|
221
|
-
```
|
|
222
|
-
components/
|
|
223
|
-
├── ui/
|
|
224
|
-
│ ├── Button.jac
|
|
225
|
-
│ └── Card.jac
|
|
226
|
-
├── layout/
|
|
227
|
-
│ ├── Header.jac
|
|
228
|
-
│ └── Footer.jac
|
|
229
|
-
└── features/
|
|
230
|
-
├── TodoList.jac
|
|
231
|
-
└── TodoItem.jac
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
2. **Use consistent naming**: Keep file names descriptive and consistent
|
|
235
|
-
3. **Limit nesting depth**: Avoid going too deep (3-4 levels is usually sufficient)
|
|
236
|
-
4. **Document import patterns**: Comment complex import relationships
|
|
237
|
-
|
|
238
|
-
## Common Patterns
|
|
239
|
-
|
|
240
|
-
### Pattern 1: Component Library Structure
|
|
241
|
-
```
|
|
242
|
-
components/
|
|
243
|
-
├── ui/
|
|
244
|
-
│ ├── Button.jac
|
|
245
|
-
│ └── Input.jac
|
|
246
|
-
├── forms/
|
|
247
|
-
│ ├── LoginForm.jac
|
|
248
|
-
│ └── SignupForm.jac
|
|
249
|
-
└── layout/
|
|
250
|
-
├── Header.jac
|
|
251
|
-
└── Sidebar.jac
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
**Usage:**
|
|
255
|
-
```jac
|
|
256
|
-
# From root
|
|
257
|
-
cl import from .components.ui.Button { Button }
|
|
258
|
-
cl import from .components.forms.LoginForm { LoginForm }
|
|
259
|
-
|
|
260
|
-
# From components/ui/Button.jac importing from forms
|
|
261
|
-
cl import from ..forms.LoginForm { LoginForm }
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### Pattern 2: Feature-Based Structure
|
|
265
|
-
```
|
|
266
|
-
features/
|
|
267
|
-
├── auth/
|
|
268
|
-
│ ├── Login.jac
|
|
269
|
-
│ └── Signup.jac
|
|
270
|
-
├── todos/
|
|
271
|
-
│ ├── TodoList.jac
|
|
272
|
-
│ └── TodoItem.jac
|
|
273
|
-
└── dashboard/
|
|
274
|
-
├── Dashboard.jac
|
|
275
|
-
└── Stats.jac
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
**Usage:**
|
|
279
|
-
```jac
|
|
280
|
-
# From root
|
|
281
|
-
cl import from .features.auth.Login { Login }
|
|
282
|
-
cl import from .features.todos.TodoList { TodoList }
|
|
283
|
-
|
|
284
|
-
# From features/auth/Login.jac importing from todos
|
|
285
|
-
cl import from ..todos.TodoList { TodoList }
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
### Pattern 3: Mixed Structure
|
|
289
|
-
```
|
|
290
|
-
app.jac # Root entry
|
|
291
|
-
components/
|
|
292
|
-
├── ui/
|
|
293
|
-
│ └── Button.jac
|
|
294
|
-
utils/
|
|
295
|
-
├── helpers/
|
|
296
|
-
│ └── format.jac
|
|
297
|
-
hooks/
|
|
298
|
-
└── useCounter.jac
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
**Usage:**
|
|
302
|
-
```jac
|
|
303
|
-
# From app.jac
|
|
304
|
-
cl import from .components.ui.Button { Button }
|
|
305
|
-
cl import from .utils.helpers.format { capitalize }
|
|
306
|
-
cl import from .hooks.useCounter { useCounter }
|
|
307
|
-
|
|
308
|
-
# From components/ui/Button.jac
|
|
309
|
-
cl import from ...utils.helpers.format { capitalize }
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
## Troubleshooting
|
|
313
|
-
|
|
314
|
-
### Import Not Found
|
|
315
|
-
- Verify the file exists at the expected path
|
|
316
|
-
- Check that the relative path matches the folder structure
|
|
317
|
-
- Ensure file extension is `.jac` (not `.cl.jac` for imports)
|
|
318
|
-
|
|
319
|
-
### Wrong Import Path
|
|
320
|
-
- Count the directory levels between source and target
|
|
321
|
-
- Use `..` for each level up, `.folder` for each level down
|
|
322
|
-
- Start with `.` for current directory imports
|
|
323
|
-
|
|
324
|
-
### File Name Conflicts
|
|
325
|
-
- Use nested folders to avoid conflicts
|
|
326
|
-
- Files with the same name in different folders won't conflict
|
|
327
|
-
- Folder structure is preserved in compiled output
|
|
328
|
-
|
|
329
|
-
## Examples
|
|
330
|
-
|
|
331
|
-
Complete working examples demonstrating nested folder imports:
|
|
332
|
-
|
|
333
|
-
- [`nested-basic/`](../../examples/nested-folders/nested-basic/) - Simple nested folder structure
|
|
334
|
-
- [`nested-advance/`](../../examples/nested-folders/nested-advance/) - Advanced multi-level nesting
|
|
335
|
-
|
|
336
|
-
Run any example:
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
cd jac-client/jac_client/examples/nested-folders/<example-name>
|
|
340
|
-
npm install
|
|
341
|
-
jac serve app.jac
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
## Related Documentation
|
|
345
|
-
|
|
346
|
-
- [Backend/Frontend Separation](backend-frontend.md)
|
|
347
|
-
- [Import System](../imports.md)
|
|
348
|
-
- [File System Organization](intro.md)
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Building a Full-Stack Todo App with Jac: Complete Walkthrough
|
|
2
|
-
|
|
3
|
-
Welcome! This guide will teach you how to build a **complete full-stack Todo application** using Jac - perfect for **complete beginners**.
|
|
4
|
-
|
|
5
|
-
## What is Full-Stack Development?
|
|
6
|
-
|
|
7
|
-
Think of building a house:
|
|
8
|
-
- **Frontend** = The interior design (what users see and interact with)
|
|
9
|
-
- **Backend** = The plumbing and electricity (where data is stored and processed)
|
|
10
|
-
- **Full-Stack** = Building both the interior AND the infrastructure
|
|
11
|
-
|
|
12
|
-
Traditionally, you'd need:
|
|
13
|
-
- **JavaScript/React** for frontend
|
|
14
|
-
- **Python/Node.js** for backend
|
|
15
|
-
- **SQL** for database
|
|
16
|
-
- **REST APIs** to connect them
|
|
17
|
-
|
|
18
|
-
With **Jac**, you write **everything in one language**, in **one file**!
|
|
19
|
-
|
|
20
|
-
## What You'll Build
|
|
21
|
-
|
|
22
|
-
By the end of this guide, you'll have a fully functional Todo app with:
|
|
23
|
-
|
|
24
|
-
- **Beautiful UI** - Modern, responsive interface
|
|
25
|
-
- **User Authentication** - Signup and login
|
|
26
|
-
- **Protected Routes** - Private pages only for logged-in users
|
|
27
|
-
- **Full CRUD** - Create, Read, Update, Delete todos
|
|
28
|
-
- **Real Backend** - Data persists even after refresh
|
|
29
|
-
- **Filtering** - View all, active, or completed todos
|
|
30
|
-
- **Multiple Pages** - Routing without page reloads
|
|
31
|
-
|
|
32
|
-
All of this in approximately **735 lines of Jac code**!
|
|
33
|
-
|
|
34
|
-
## Prerequisites
|
|
35
|
-
|
|
36
|
-
Before starting, you should have:
|
|
37
|
-
|
|
38
|
-
- **Python 3.12 or higher** installed on your system
|
|
39
|
-
- Download: [https://www.python.org/downloads/](https://www.python.org/downloads/)
|
|
40
|
-
- **Node.js 20 or higher** and npm installed (required for frontend dependencies)
|
|
41
|
-
- Download: [https://nodejs.org/](https://nodejs.org/) (npm is included with Node.js)
|
|
42
|
-
- A code editor (VS Code recommended with Jac extension)
|
|
43
|
-
- Download: [https://code.visualstudio.com/](https://code.visualstudio.com/)
|
|
44
|
-
- Basic Python knowledge
|
|
45
|
-
- Basic understanding of HTML/CSS concepts (helpful but not required)
|
|
46
|
-
|
|
47
|
-
### Quick Setup Check
|
|
48
|
-
|
|
49
|
-
Verify your environment is ready by running:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
python --version # Should show Python 3.12+
|
|
53
|
-
node --version # Should show Node 20+
|
|
54
|
-
npm --version # Should show npm
|
|
55
|
-
jac --version # Should show Jac is installed
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
If Jac is not installed, run:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
pip install jac-client
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
> **Note:** If you have previously installed `jaclang`, please uninstall it first using `pip uninstall jaclang`. The required version of `jaclang` will be installed automatically as a dependency of `jac-client`, so you do not need to install it separately.
|
|
65
|
-
|
|
66
|
-
## How This Guide Works
|
|
67
|
-
|
|
68
|
-
Each step builds on the previous one, gradually creating the complete app. Every step has **two parts**:
|
|
69
|
-
|
|
70
|
-
1. ** Part 1: Building the App** - Hands-on coding, building the actual app
|
|
71
|
-
2. ** Part 2: Understanding the Concepts** - Optional deeper knowledge
|
|
72
|
-
|
|
73
|
-
**Want to just build?** Follow only Part 1 of each step and skip all Part 2 sections. You'll still have a working app!
|
|
74
|
-
|
|
75
|
-
**Want to learn deeply?** Read both parts to understand *why* things work, not just *how*.
|
|
76
|
-
|
|
77
|
-
## Learning Path
|
|
78
|
-
|
|
79
|
-
We'll build the app in 11 progressive steps:
|
|
80
|
-
|
|
81
|
-
1. **[Step 1: Project Setup](./step-01-setup.md)** - Create your first Jac project
|
|
82
|
-
2. **[Step 2: First Component](./step-02-components.md)** - Create and organize components
|
|
83
|
-
3. **[Step 3: Styling](./step-03-styling.md)** - Make your components beautiful
|
|
84
|
-
4. **[Step 4: Todo UI](./step-04-todo-ui.md)** - Build the complete todo interface
|
|
85
|
-
5. **[Step 5: Local State](./step-05-local-state.md)** - Add interactivity with state
|
|
86
|
-
6. **[Step 6: Event Handlers](./step-06-events.md)** - Handle user clicks and input
|
|
87
|
-
7. **[Step 7: Effects](./step-07-effects.md)** - Load data when the app starts
|
|
88
|
-
8. **[Step 8: Walkers](./step-08-walkers.md)** - Create the backend with walkers
|
|
89
|
-
9. **[Step 9: Authentication](./step-09-authentication.md)** - Add user signup and login
|
|
90
|
-
10. **[Step 10: Routing](./step-10-routing.md)** - Add multiple pages
|
|
91
|
-
11. **[Step 11: Final Integration](./step-11-final.md)** - Complete working app
|
|
92
|
-
|
|
93
|
-
## Learning Tips
|
|
94
|
-
|
|
95
|
-
- **Follow in order** - Each step builds on the previous one
|
|
96
|
-
- **Type the code** - Don't just copy/paste. Typing helps you learn!
|
|
97
|
-
- **Experiment** - Try changing things to see what happens
|
|
98
|
-
- **Use the "Understanding" sections** - Read them when you want to know *why* something works
|
|
99
|
-
|
|
100
|
-
## Time to Complete
|
|
101
|
-
|
|
102
|
-
- **Just building**: 2-3 hours
|
|
103
|
-
- **Building + learning**: 4-6 hours
|
|
104
|
-
|
|
105
|
-
## Getting Help
|
|
106
|
-
|
|
107
|
-
- Each step has a **"Common Issues"** section
|
|
108
|
-
- Complete final code available in Step 11
|
|
109
|
-
- Check the [Jac Documentation](https://www.jac-lang.org) for API details
|
|
110
|
-
|
|
111
|
-
## Ready to Start?
|
|
112
|
-
|
|
113
|
-
Let's build your first full-stack app!
|
|
114
|
-
|
|
115
|
-
**[Continue to Step 1: Project Setup](./step-01-setup.md)**
|