jac-client 0.2.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 +31 -1
- jac_client/docs/asset-serving/intro.md +209 -0
- jac_client/docs/assets/pipe_line-v2.svg +32 -0
- jac_client/docs/file-system/intro.md +90 -0
- 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/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/with-router/app.jac +1 -1
- jac_client/plugin/cli.py +5 -0
- jac_client/plugin/client.py +64 -3
- jac_client/plugin/vite_client_bundle.py +96 -1
- jac_client/tests/__init__.py +0 -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/js_import/app.jac +1 -1
- jac_client/tests/fixtures/relative_import/button.jac +2 -2
- jac_client/tests/fixtures/test_fragments_spread/app.jac +2 -2
- jac_client/tests/test_asset_examples.py +339 -0
- jac_client/tests/test_cl.py +165 -87
- jac_client/tests/test_create_jac_app.py +40 -44
- {jac_client-0.2.0.dist-info → jac_client-0.2.1.dist-info}/METADATA +2 -2
- jac_client-0.2.1.dist-info/RECORD +140 -0
- jac_client-0.2.0.dist-info/RECORD +0 -72
- {jac_client-0.2.0.dist-info → jac_client-0.2.1.dist-info}/WHEEL +0 -0
- {jac_client-0.2.0.dist-info → jac_client-0.2.1.dist-info}/entry_points.txt +0 -0
jac_client/docs/README.md
CHANGED
|
@@ -6,9 +6,39 @@ Welcome to the Todo App example! This guide will walk you through building a ful
|
|
|
6
6
|
|
|
7
7
|
## 📦 1. Creating the Application
|
|
8
8
|
|
|
9
|
+
### Prerequisites
|
|
10
|
+
|
|
11
|
+
Before installing Jac client, you need to have **Node.js** installed on your system.
|
|
12
|
+
|
|
13
|
+
#### Installing Node.js
|
|
14
|
+
|
|
15
|
+
**For Linux users:**
|
|
16
|
+
|
|
17
|
+
Visit [https://nodejs.org/en/download](https://nodejs.org/en/download) and follow the instructions to install Node.js using **nvm** (Node Version Manager) with **npm**.
|
|
18
|
+
|
|
19
|
+
Select:
|
|
20
|
+
- **Platform**: Linux
|
|
21
|
+
- **Package Manager**: nvm
|
|
22
|
+
- **Package**: npm
|
|
23
|
+
|
|
24
|
+
Then follow the installation commands provided on that page.
|
|
25
|
+
|
|
26
|
+
**For macOS users:**
|
|
27
|
+
|
|
28
|
+
Download and install Node.js from [https://nodejs.org/en/download](https://nodejs.org/en/download) by selecting your operating system.
|
|
29
|
+
|
|
30
|
+
**Verify Installation:**
|
|
31
|
+
|
|
32
|
+
After installation, verify Node.js and npm are installed correctly:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
node -v
|
|
36
|
+
npm -v
|
|
37
|
+
```
|
|
38
|
+
|
|
9
39
|
### Installation
|
|
10
40
|
|
|
11
|
-
|
|
41
|
+
Once Node.js is installed, install the Jac client package:
|
|
12
42
|
|
|
13
43
|
```bash
|
|
14
44
|
pip install jac-client
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Asset Serving in Jac
|
|
2
|
+
|
|
3
|
+
Static assets such as images, fonts, videos, and stylesheets are essential for web applications. Jac provides multiple approaches for serving these assets, each suited for different use cases.
|
|
4
|
+
|
|
5
|
+
!!! tip "Important"
|
|
6
|
+
All local assets must be placed in the `assets/` folder at the root of your project. The server serves these files from the `/static/` path.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Jac supports two primary approaches for asset serving:
|
|
11
|
+
|
|
12
|
+
- **Remote Assets**: External URLs from CDNs or remote servers
|
|
13
|
+
- **Local Assets**: Files stored in your project, served by the Jac server
|
|
14
|
+
|
|
15
|
+
Local assets can be referenced using either **Static Path** (direct `/static/` URLs) or **Import Alias** (Vite-processed imports with optimization).
|
|
16
|
+
|
|
17
|
+
## Remote Assets
|
|
18
|
+
|
|
19
|
+
Use external URLs for assets hosted on CDNs or remote servers.
|
|
20
|
+
|
|
21
|
+
### Usage
|
|
22
|
+
|
|
23
|
+
```jac
|
|
24
|
+
<img src="https://picsum.photos/400/300" alt="Image" />
|
|
25
|
+
<img src="https://via.placeholder.com/400x300" alt="Placeholder" />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### When to Use
|
|
29
|
+
|
|
30
|
+
- CDN-hosted production assets
|
|
31
|
+
- Placeholder images during development
|
|
32
|
+
- External resources managed outside your project
|
|
33
|
+
- Dynamic or user-generated content
|
|
34
|
+
|
|
35
|
+
## Local Assets
|
|
36
|
+
|
|
37
|
+
> **Important**: All local assets must be placed in the `assets/` folder at the root of your project. .
|
|
38
|
+
|
|
39
|
+
Local assets are stored in your project and served by the Jac server. Two methods are available:
|
|
40
|
+
|
|
41
|
+
### Static Path
|
|
42
|
+
|
|
43
|
+
Reference assets directly using the `/static/` path prefix.
|
|
44
|
+
|
|
45
|
+
#### Usage
|
|
46
|
+
|
|
47
|
+
```jac
|
|
48
|
+
<img src="/static/assets/burger.png" alt="Burger" />
|
|
49
|
+
<link rel="stylesheet" href="/static/styles.css" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
#### How It Works
|
|
53
|
+
|
|
54
|
+
- Assets in the `assets/` folder are served at `/static/assets/` path
|
|
55
|
+
- Assets in `dist/` are also accessible via `/static/`
|
|
56
|
+
- Server automatically detects file type and sets correct MIME type
|
|
57
|
+
- No build configuration required
|
|
58
|
+
|
|
59
|
+
#### When to Use
|
|
60
|
+
|
|
61
|
+
- Quick prototypes and simple applications
|
|
62
|
+
- Assets that don't require optimization
|
|
63
|
+
- Immediate results without build step
|
|
64
|
+
|
|
65
|
+
### Import Alias
|
|
66
|
+
|
|
67
|
+
Import assets using the `@jac-client/assets` alias for Vite-processed assets.
|
|
68
|
+
|
|
69
|
+
#### Usage
|
|
70
|
+
|
|
71
|
+
```jac
|
|
72
|
+
cl import from "@jac-client/assets/burger.png" { default as burgerImage }
|
|
73
|
+
|
|
74
|
+
<img src={burgerImage} alt="Burger" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### How It Works
|
|
78
|
+
|
|
79
|
+
- Alias configured in `vite.config.js` points to `src/assets/`
|
|
80
|
+
- Assets from root `assets/` folder are copied to `src/assets/` during build
|
|
81
|
+
- Vite processes imports and generates optimized asset URLs
|
|
82
|
+
- Automatic hash generation for cache busting
|
|
83
|
+
|
|
84
|
+
#### When to Use
|
|
85
|
+
|
|
86
|
+
- Production applications
|
|
87
|
+
- Assets that benefit from optimization
|
|
88
|
+
- Type-safe asset references
|
|
89
|
+
- Automatic cache busting
|
|
90
|
+
|
|
91
|
+
## Using Assets in CSS
|
|
92
|
+
|
|
93
|
+
Assets can be referenced in CSS files using static paths.
|
|
94
|
+
|
|
95
|
+
### Usage
|
|
96
|
+
|
|
97
|
+
**CSS File (`styles.css`):**
|
|
98
|
+
```css
|
|
99
|
+
.container {
|
|
100
|
+
background-image: url('/static/assets/burger.png');
|
|
101
|
+
background-size: cover;
|
|
102
|
+
background-position: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.burgerImage {
|
|
106
|
+
width: 200px;
|
|
107
|
+
height: auto;
|
|
108
|
+
border-radius: 10px;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Jac File:**
|
|
113
|
+
```jac
|
|
114
|
+
cl import "./styles.css";
|
|
115
|
+
|
|
116
|
+
<div className="container">
|
|
117
|
+
<img src="/static/assets/burger.png" className="burgerImage" alt="Burger" />
|
|
118
|
+
</div>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Notes
|
|
122
|
+
|
|
123
|
+
- CSS files reference assets using `/static/` paths
|
|
124
|
+
- Assets are resolved at runtime by the server
|
|
125
|
+
- Works with both background images and regular image elements
|
|
126
|
+
|
|
127
|
+
## Supported Asset Types
|
|
128
|
+
|
|
129
|
+
Jac automatically serves and detects MIME types for:
|
|
130
|
+
|
|
131
|
+
- **Images**: `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.svg`, `.ico`, `.avif`
|
|
132
|
+
- **Fonts**: `.woff`, `.woff2`, `.ttf`, `.otf`, `.eot`
|
|
133
|
+
- **Media**: `.mp4`, `.webm`, `.ogg`, `.mov`, `.mp3`, `.wav`, `.m4a`
|
|
134
|
+
- **Documents**: `.pdf`
|
|
135
|
+
- **Stylesheets**: `.css`, `.scss`, `.sass`, `.less`
|
|
136
|
+
|
|
137
|
+
## Project Structure
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
project/
|
|
141
|
+
├── assets/ # Static assets (served via /static/)
|
|
142
|
+
│ ├── images/
|
|
143
|
+
│ ├── fonts/
|
|
144
|
+
│ └── videos/
|
|
145
|
+
├── src/
|
|
146
|
+
│ └── assets/ # Assets for import alias (@jac-client/assets)
|
|
147
|
+
└── dist/ # Vite output (auto-generated)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Examples
|
|
151
|
+
|
|
152
|
+
Complete working examples are available:
|
|
153
|
+
|
|
154
|
+
- [`image-asset/`](../../examples/asset-serving/image-asset/) - Static path serving
|
|
155
|
+
- [`import-alias/`](../../examples/asset-serving/import-alias/) - Import alias pattern
|
|
156
|
+
- [`css-with-image/`](../../examples/asset-serving/css-with-image/) - Assets in CSS
|
|
157
|
+
|
|
158
|
+
Run any example:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
cd jac-client/jac_client/examples/asset-serving/<example-name>
|
|
162
|
+
npm install
|
|
163
|
+
jac serve app.jac
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Quick Reference
|
|
167
|
+
|
|
168
|
+
### Remote URLs
|
|
169
|
+
```jac
|
|
170
|
+
<img src="https://example.com/image.jpg" alt="Image" />
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Static Path
|
|
174
|
+
```jac
|
|
175
|
+
<img src="/static/assets/logo.png" alt="Logo" />
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Import Alias
|
|
179
|
+
```jac
|
|
180
|
+
cl import from "@jac-client/assets/logo.png" { default as logo }
|
|
181
|
+
<img src={logo} />
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### CSS Assets
|
|
185
|
+
```css
|
|
186
|
+
.hero {
|
|
187
|
+
background-image: url('/static/assets/hero.jpg');
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Troubleshooting
|
|
192
|
+
|
|
193
|
+
**Asset not found (404)**
|
|
194
|
+
- Verify file exists in `assets/` or `dist/` directory
|
|
195
|
+
- Check path matches file location exactly
|
|
196
|
+
|
|
197
|
+
**Import not resolving**
|
|
198
|
+
- Ensure `vite.config.js` has `@jac-client/assets` alias configured
|
|
199
|
+
- Verify assets are copied to `src/assets/` during build
|
|
200
|
+
|
|
201
|
+
**CSS background image not showing**
|
|
202
|
+
- Use `/static/` prefix in CSS `url()` paths
|
|
203
|
+
- Verify asset file exists in `assets/` directory
|
|
204
|
+
|
|
205
|
+
## Related Documentation
|
|
206
|
+
|
|
207
|
+
- [Import System](../imports.md)
|
|
208
|
+
- [Styling](../styling/intro.md)
|
|
209
|
+
- [Routing](../routing.md)
|