jac-client 0.1.0__py3-none-any.whl → 0.2.1__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/docs/README.md +232 -172
- jac_client/docs/advanced-state.md +1012 -452
- jac_client/docs/asset-serving/intro.md +209 -0
- jac_client/docs/assets/pipe_line-v2.svg +32 -0
- jac_client/docs/assets/pipe_line.png +0 -0
- jac_client/docs/file-system/intro.md +90 -0
- jac_client/docs/guide-example/intro.md +117 -0
- jac_client/docs/guide-example/step-01-setup.md +260 -0
- jac_client/docs/guide-example/step-02-components.md +416 -0
- jac_client/docs/guide-example/step-03-styling.md +478 -0
- jac_client/docs/guide-example/step-04-todo-ui.md +477 -0
- jac_client/docs/guide-example/step-05-local-state.md +530 -0
- jac_client/docs/guide-example/step-06-events.md +750 -0
- jac_client/docs/guide-example/step-07-effects.md +469 -0
- jac_client/docs/guide-example/step-08-walkers.md +534 -0
- jac_client/docs/guide-example/step-09-authentication.md +586 -0
- jac_client/docs/guide-example/step-10-routing.md +540 -0
- jac_client/docs/guide-example/step-11-final.md +964 -0
- jac_client/docs/imports.md +538 -46
- jac_client/docs/lifecycle-hooks.md +517 -297
- jac_client/docs/routing.md +487 -357
- jac_client/docs/styling/intro.md +250 -0
- jac_client/docs/styling/js-styling.md +373 -0
- jac_client/docs/styling/material-ui.md +346 -0
- jac_client/docs/styling/pure-css.md +305 -0
- jac_client/docs/styling/sass.md +409 -0
- jac_client/docs/styling/styled-components.md +401 -0
- jac_client/docs/styling/tailwind.md +303 -0
- jac_client/examples/asset-serving/css-with-image/.babelrc +9 -0
- jac_client/examples/asset-serving/css-with-image/README.md +91 -0
- jac_client/examples/asset-serving/css-with-image/app.jac +67 -0
- jac_client/examples/asset-serving/css-with-image/assets/burger.png +0 -0
- jac_client/examples/asset-serving/css-with-image/package.json +28 -0
- jac_client/examples/asset-serving/css-with-image/styles.css +27 -0
- jac_client/examples/asset-serving/css-with-image/vite.config.js +29 -0
- jac_client/examples/asset-serving/image-asset/.babelrc +9 -0
- jac_client/examples/asset-serving/image-asset/README.md +119 -0
- jac_client/examples/asset-serving/image-asset/app.jac +43 -0
- jac_client/examples/asset-serving/image-asset/assets/burger.png +0 -0
- jac_client/examples/asset-serving/image-asset/package.json +28 -0
- jac_client/examples/asset-serving/image-asset/styles.css +27 -0
- jac_client/examples/asset-serving/image-asset/vite.config.js +29 -0
- jac_client/examples/asset-serving/import-alias/.babelrc +9 -0
- jac_client/examples/asset-serving/import-alias/README.md +83 -0
- jac_client/examples/asset-serving/import-alias/app.jac +57 -0
- jac_client/examples/asset-serving/import-alias/assets/burger.png +0 -0
- jac_client/examples/asset-serving/import-alias/package.json +28 -0
- jac_client/examples/asset-serving/import-alias/vite.config.js +29 -0
- jac_client/examples/basic/.babelrc +9 -0
- jac_client/examples/basic/README.md +16 -0
- jac_client/examples/basic/app.jac +16 -0
- jac_client/examples/basic/package.json +27 -0
- jac_client/examples/basic/vite.config.js +28 -0
- jac_client/examples/basic-auth/.babelrc +9 -0
- jac_client/examples/basic-auth/README.md +16 -0
- jac_client/examples/basic-auth/app.jac +308 -0
- jac_client/examples/basic-auth/package.json +27 -0
- jac_client/examples/basic-auth/vite.config.js +28 -0
- jac_client/examples/basic-auth-with-router/.babelrc +9 -0
- jac_client/examples/basic-auth-with-router/README.md +60 -0
- jac_client/examples/basic-auth-with-router/app.jac +464 -0
- jac_client/examples/basic-auth-with-router/package.json +28 -0
- jac_client/examples/basic-auth-with-router/vite.config.js +28 -0
- jac_client/examples/basic-full-stack/.babelrc +9 -0
- jac_client/examples/basic-full-stack/README.md +18 -0
- jac_client/examples/basic-full-stack/app.jac +320 -0
- jac_client/examples/basic-full-stack/package.json +28 -0
- jac_client/examples/basic-full-stack/vite.config.js +28 -0
- jac_client/examples/css-styling/js-styling/.babelrc +9 -0
- jac_client/examples/css-styling/js-styling/README.md +183 -0
- jac_client/examples/css-styling/js-styling/app.jac +63 -0
- jac_client/examples/css-styling/js-styling/package.json +28 -0
- jac_client/examples/css-styling/js-styling/styles.js +100 -0
- jac_client/examples/css-styling/js-styling/vite.config.js +28 -0
- jac_client/examples/css-styling/material-ui/.babelrc +9 -0
- jac_client/examples/css-styling/material-ui/README.md +16 -0
- jac_client/examples/css-styling/material-ui/app.jac +82 -0
- jac_client/examples/css-styling/material-ui/package.json +32 -0
- jac_client/examples/css-styling/material-ui/vite.config.js +28 -0
- jac_client/examples/css-styling/pure-css/.babelrc +9 -0
- jac_client/examples/css-styling/pure-css/README.md +16 -0
- jac_client/examples/css-styling/pure-css/app.jac +63 -0
- jac_client/examples/css-styling/pure-css/package.json +28 -0
- jac_client/examples/css-styling/pure-css/styles.css +112 -0
- jac_client/examples/css-styling/pure-css/vite.config.js +28 -0
- jac_client/examples/css-styling/sass-example/.babelrc +9 -0
- jac_client/examples/css-styling/sass-example/README.md +16 -0
- jac_client/examples/css-styling/sass-example/app.jac +63 -0
- jac_client/examples/css-styling/sass-example/package.json +29 -0
- jac_client/examples/css-styling/sass-example/styles.scss +158 -0
- jac_client/examples/css-styling/sass-example/vite.config.js +28 -0
- jac_client/examples/css-styling/styled-components/.babelrc +9 -0
- jac_client/examples/css-styling/styled-components/README.md +16 -0
- jac_client/examples/css-styling/styled-components/app.jac +66 -0
- jac_client/examples/css-styling/styled-components/package.json +29 -0
- jac_client/examples/css-styling/styled-components/styled.js +91 -0
- jac_client/examples/css-styling/styled-components/vite.config.js +28 -0
- jac_client/examples/css-styling/tailwind-example/.babelrc +9 -0
- jac_client/examples/css-styling/tailwind-example/README.md +16 -0
- jac_client/examples/css-styling/tailwind-example/app.jac +64 -0
- jac_client/examples/css-styling/tailwind-example/global.css +1 -0
- jac_client/examples/css-styling/tailwind-example/package.json +30 -0
- jac_client/examples/css-styling/tailwind-example/vite.config.js +30 -0
- jac_client/examples/full-stack-with-auth/.babelrc +9 -0
- jac_client/examples/full-stack-with-auth/README.md +16 -0
- jac_client/examples/full-stack-with-auth/app.jac +735 -0
- jac_client/examples/full-stack-with-auth/package.json +28 -0
- jac_client/examples/full-stack-with-auth/vite.config.js +30 -0
- jac_client/examples/with-router/.babelrc +9 -0
- jac_client/examples/with-router/README.md +17 -0
- jac_client/examples/with-router/app.jac +323 -0
- jac_client/examples/with-router/package.json +28 -0
- jac_client/examples/with-router/vite.config.js +28 -0
- jac_client/plugin/cli.py +95 -179
- jac_client/plugin/client.py +111 -2
- jac_client/plugin/client_runtime.jac +183 -890
- jac_client/plugin/vite_client_bundle.py +185 -205
- jac_client/tests/__init__.py +0 -1
- jac_client/tests/fixtures/{client_app.jac → basic-app/app.jac} +1 -1
- jac_client/tests/fixtures/cl_file/app.cl.jac +38 -0
- jac_client/tests/fixtures/cl_file/app.jac +15 -0
- jac_client/tests/fixtures/{client_app_with_antd.jac → client_app_with_antd/app.jac} +7 -0
- jac_client/tests/fixtures/{js_import.jac → js_import/app.jac} +2 -2
- jac_client/tests/fixtures/{relative_import.jac → relative_import/app.jac} +1 -1
- jac_client/tests/fixtures/{button.jac → relative_import/button.jac} +2 -2
- jac_client/tests/fixtures/spawn_test/app.jac +133 -0
- jac_client/tests/fixtures/{test_fragments_spread.jac → test_fragments_spread/app.jac} +11 -2
- jac_client/tests/test_asset_examples.py +339 -0
- jac_client/tests/test_cl.py +345 -151
- jac_client/tests/test_create_jac_app.py +41 -45
- {jac_client-0.1.0.dist-info → jac_client-0.2.1.dist-info}/METADATA +72 -16
- jac_client-0.2.1.dist-info/RECORD +140 -0
- jac_client/examples/little-x/package-lock.json +0 -2840
- jac_client/examples/todo-app/README.md +0 -82
- jac_client/examples/todo-app/app.jac +0 -683
- jac_client/examples/todo-app/package-lock.json +0 -999
- jac_client/examples/todo-app/package.json +0 -22
- jac_client-0.1.0.dist-info/RECORD +0 -33
- /jac_client/tests/fixtures/{utils.js → js_import/utils.js} +0 -0
- {jac_client-0.1.0.dist-info → jac_client-0.2.1.dist-info}/WHEEL +0 -0
- {jac_client-0.1.0.dist-info → jac_client-0.2.1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
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)**
|
|
116
|
+
|
|
117
|
+
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Step 1: Project Setup
|
|
2
|
+
|
|
3
|
+
> **💡 Quick Tip:** Each step has two parts. **Part 1** shows you what to build. **Part 2** explains why it works. Want to just build? Skip all Part 2 sections!
|
|
4
|
+
|
|
5
|
+
In this first step, you'll create your Jac project and understand the basic file structure.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🏗️ Part 1: Building the App
|
|
10
|
+
|
|
11
|
+
### Step 1.1: Create Your Project
|
|
12
|
+
|
|
13
|
+
Open your terminal and run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
jac create_jac_app todo-app
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This creates a new directory called `todo-app` with everything you need.
|
|
20
|
+
|
|
21
|
+
### Step 1.2: Navigate to Your Project
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd todo-app
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Step 1.3: Understand the Structure
|
|
28
|
+
|
|
29
|
+
Your project now has these files:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
todo-app/
|
|
33
|
+
├── app.jac # Your main application file (we'll work here!)
|
|
34
|
+
├── package.json # Node.js dependencies (auto-managed)
|
|
35
|
+
├── vite.config.js # Build configuration (you can ignore this)
|
|
36
|
+
└── README.md # Basic instructions
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Important**: We'll write ALL our code in `app.jac` - that's it!
|
|
40
|
+
|
|
41
|
+
### Step 1.4: Create Your First App
|
|
42
|
+
|
|
43
|
+
Open `app.jac` in your code editor and replace everything with this:
|
|
44
|
+
|
|
45
|
+
```jac
|
|
46
|
+
cl {
|
|
47
|
+
def app() -> any {
|
|
48
|
+
return <div>
|
|
49
|
+
<h1>Hello, Jac!</h1>
|
|
50
|
+
<p>My first full-stack app</p>
|
|
51
|
+
</div>;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 1.5: Run Your App
|
|
57
|
+
|
|
58
|
+
In your terminal, run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
jac serve app.jac
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You'll see output like:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
INFO: Started server process [12345]
|
|
68
|
+
INFO: Waiting for application startup.
|
|
69
|
+
INFO: Application startup complete.
|
|
70
|
+
INFO: Uvicorn running on http://127.0.0.1:8000
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 1.6: View in Browser
|
|
74
|
+
|
|
75
|
+
Open your browser and go to:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
http://localhost:8000/page/app
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You should see "Hello, Jac!" and "My first full-stack app" 🎉
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
**⏭️ Want to skip the theory?** Jump to [Step 2: First Component](./step-02-components.md)
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 💡 Part 2: Understanding the Concepts
|
|
90
|
+
|
|
91
|
+
### What is `cl { ... }`?
|
|
92
|
+
|
|
93
|
+
`cl` stands for "client" - it means this code runs in the **browser** (frontend).
|
|
94
|
+
|
|
95
|
+
```jac
|
|
96
|
+
cl {
|
|
97
|
+
# Everything here runs on the client-side (browser)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Think of it like this:
|
|
102
|
+
- Code **inside** `cl { }` → Runs in the browser (frontend)
|
|
103
|
+
- Code **outside** `cl { }` → Runs on the server (backend)
|
|
104
|
+
|
|
105
|
+
### What is `def app() -> any`?
|
|
106
|
+
|
|
107
|
+
This is your **main entry point** - the function that Jac calls first.
|
|
108
|
+
|
|
109
|
+
```jac
|
|
110
|
+
def app() -> any {
|
|
111
|
+
return <div>...</div>;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Requirements:**
|
|
116
|
+
- Must be named `app` (by convention)
|
|
117
|
+
- Must return JSX (HTML-like syntax)
|
|
118
|
+
- Located inside `cl { }` block
|
|
119
|
+
|
|
120
|
+
**Python analogy:**
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
# Python
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
run_app()
|
|
126
|
+
|
|
127
|
+
# Jac
|
|
128
|
+
def app() -> any {
|
|
129
|
+
# Start here
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### What is JSX?
|
|
134
|
+
|
|
135
|
+
JSX lets you write HTML directly in your Jac code:
|
|
136
|
+
|
|
137
|
+
```jac
|
|
138
|
+
return <div>
|
|
139
|
+
<h1>This is HTML!</h1>
|
|
140
|
+
<p>But written in Jac code</p>
|
|
141
|
+
</div>;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Key rules:**
|
|
145
|
+
1. Must have **one root element**
|
|
146
|
+
```jac
|
|
147
|
+
# ✅ Correct
|
|
148
|
+
return <div><h1>Title</h1><p>Text</p></div>;
|
|
149
|
+
|
|
150
|
+
# ❌ Wrong (two root elements)
|
|
151
|
+
return <h1>Title</h1><p>Text</p>;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
2. Self-closing tags need `/`
|
|
155
|
+
```jac
|
|
156
|
+
<img src="photo.jpg" /> # ✅ Correct
|
|
157
|
+
<img src="photo.jpg"> # ❌ Wrong
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
3. Use `{}` to insert Jac code
|
|
161
|
+
```jac
|
|
162
|
+
let name = "Alice";
|
|
163
|
+
return <h1>Hello, {name}!</h1>; # Shows: Hello, Alice!
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### How `jac serve` Works
|
|
167
|
+
|
|
168
|
+
When you run `jac serve app.jac`:
|
|
169
|
+
|
|
170
|
+
1. **Jac compiler** reads your `.jac` file
|
|
171
|
+
2. **Frontend code** (inside `cl`) → Compiled to JavaScript
|
|
172
|
+
3. **Backend code** (outside `cl`) → Stays as Python-like backend code
|
|
173
|
+
4. **Single server** serves both on port 8000
|
|
174
|
+
5. **Auto-reload** watches for file changes (coming soon...)
|
|
175
|
+
|
|
176
|
+
It's like running a Flask/FastAPI server, but it ALSO compiles and serves your React frontend - all in one command!
|
|
177
|
+
|
|
178
|
+
### File Organization
|
|
179
|
+
|
|
180
|
+
For now, everything goes in `app.jac`. As your app grows, you can split into multiple files:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
todo-app/
|
|
184
|
+
├── app.jac # Main app
|
|
185
|
+
├── components.jac # Reusable components
|
|
186
|
+
└── walkers.jac # Backend logic
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
But for this tutorial, we'll keep everything in one file for simplicity.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## ✅ What You've Learned
|
|
194
|
+
|
|
195
|
+
- ✅ How to create a Jac project
|
|
196
|
+
- ✅ Project structure basics
|
|
197
|
+
- ✅ What `cl { }` means (client-side code)
|
|
198
|
+
- ✅ The `def app()` entry point
|
|
199
|
+
- ✅ JSX basics (HTML in code)
|
|
200
|
+
- ✅ Running your app with `jac serve`
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 🐛 Common Issues
|
|
205
|
+
|
|
206
|
+
### Issue: `jac: command not found`
|
|
207
|
+
|
|
208
|
+
**Solution**: Install jac-client:
|
|
209
|
+
```bash
|
|
210
|
+
pip install jac-client
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Issue: Port 8000 already in use
|
|
214
|
+
|
|
215
|
+
**Solution**: Use a different port:
|
|
216
|
+
```bash
|
|
217
|
+
jac serve app.jac --port 8080
|
|
218
|
+
```
|
|
219
|
+
Then visit `http://localhost:8080/page/app`
|
|
220
|
+
|
|
221
|
+
### Issue: Blank page in browser
|
|
222
|
+
|
|
223
|
+
**Check:**
|
|
224
|
+
- Did you visit `/page/app` (not just `/`)?
|
|
225
|
+
- Check terminal for errors
|
|
226
|
+
- Make sure `app()` has a `return` statement
|
|
227
|
+
|
|
228
|
+
### Issue: Changes not showing
|
|
229
|
+
|
|
230
|
+
**Solution**:
|
|
231
|
+
- Stop the server (Ctrl+C)
|
|
232
|
+
- Restart: `jac serve app.jac`
|
|
233
|
+
- Refresh browser
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 🎯 Quick Exercise
|
|
238
|
+
|
|
239
|
+
Before moving on, try changing the text:
|
|
240
|
+
|
|
241
|
+
```jac
|
|
242
|
+
cl {
|
|
243
|
+
def app() -> any {
|
|
244
|
+
return <div>
|
|
245
|
+
<h1>My Todo App</h1>
|
|
246
|
+
<p>Built with Jac</p>
|
|
247
|
+
</div>;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Save, refresh your browser, and see the changes!
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## ➡️ Next Step
|
|
257
|
+
|
|
258
|
+
Great! You have a running Jac app. Now let's learn about **components** - the building blocks of any UI.
|
|
259
|
+
|
|
260
|
+
👉 **[Continue to Step 2: First Component](./step-02-components.md)**
|