jac-client 0.2.2__py3-none-any.whl → 0.2.6__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/examples/all-in-one/src/app.jac +841 -0
- jac_client/examples/all-in-one/{button.jac → src/button.jac} +1 -1
- jac_client/examples/all-in-one/{components → src/components}/button.jac +1 -1
- jac_client/examples/asset-serving/css-with-image/{app.jac → src/app.jac} +2 -2
- jac_client/examples/asset-serving/image-asset/{app.jac → src/app.jac} +2 -2
- jac_client/examples/asset-serving/import-alias/{app.jac → src/app.jac} +7 -7
- jac_client/examples/basic/{app.jac → src/app.jac} +2 -2
- jac_client/examples/basic-auth/src/app.jac +377 -0
- jac_client/examples/basic-auth-with-router/{app.jac → src/app.jac} +18 -18
- jac_client/examples/basic-full-stack/{app.jac → src/app.jac} +175 -130
- jac_client/examples/css-styling/js-styling/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/material-ui/{app.jac → src/app.jac} +5 -5
- jac_client/examples/css-styling/pure-css/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/sass-example/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/styled-components/{app.jac → src/app.jac} +5 -5
- jac_client/examples/css-styling/tailwind-example/{app.jac → src/app.jac} +6 -6
- jac_client/examples/full-stack-with-auth/{app.jac → src/app.jac} +37 -37
- jac_client/examples/little-x/{app.jac → src/app.jac} +27 -32
- jac_client/examples/little-x/src/submit-button.jac +16 -0
- jac_client/examples/nested-folders/nested-advance/{ButtonRoot.jac → src/ButtonRoot.jac} +1 -1
- jac_client/examples/nested-folders/nested-advance/{app.jac → src/app.jac} +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/ButtonSecondL.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/Card.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/level2/ButtonThirdL.jac +1 -1
- jac_client/examples/nested-folders/nested-basic/{app.jac → src/app.jac} +2 -2
- jac_client/examples/nested-folders/nested-basic/{button.jac → src/button.jac} +1 -1
- jac_client/examples/nested-folders/nested-basic/{components → src/components}/button.jac +1 -1
- jac_client/examples/ts-support/src/app.jac +35 -0
- jac_client/examples/with-router/{app.jac → src/app.jac} +11 -11
- jac_client/plugin/cli.jac +547 -0
- jac_client/plugin/client.jac +52 -0
- jac_client/plugin/client_runtime.cl.jac +38 -0
- jac_client/plugin/impl/client.impl.jac +134 -0
- jac_client/plugin/impl/client_runtime.impl.jac +177 -0
- jac_client/plugin/impl/vite_client_bundle.impl.jac +72 -0
- jac_client/plugin/plugin_config.jac +195 -0
- jac_client/plugin/src/__init__.jac +20 -0
- jac_client/plugin/src/asset_processor.jac +33 -0
- jac_client/plugin/src/babel_processor.jac +18 -0
- jac_client/plugin/src/compiler.jac +66 -0
- jac_client/plugin/src/config_loader.jac +32 -0
- jac_client/plugin/src/impl/asset_processor.impl.jac +127 -0
- jac_client/plugin/src/impl/babel_processor.impl.jac +84 -0
- jac_client/plugin/src/impl/compiler.impl.jac +251 -0
- jac_client/plugin/src/impl/config_loader.impl.jac +119 -0
- jac_client/plugin/src/impl/import_processor.impl.jac +33 -0
- jac_client/plugin/src/impl/jac_to_js.impl.jac +41 -0
- jac_client/plugin/src/impl/package_installer.impl.jac +105 -0
- jac_client/plugin/src/impl/vite_bundler.impl.jac +513 -0
- jac_client/plugin/src/import_processor.jac +19 -0
- jac_client/plugin/src/jac_to_js.jac +35 -0
- jac_client/plugin/src/package_installer.jac +26 -0
- jac_client/plugin/src/vite_bundler.jac +36 -0
- jac_client/plugin/vite_client_bundle.jac +31 -0
- jac_client/tests/conftest.py +281 -0
- jac_client/tests/fixtures/basic-app/app.jac +2 -2
- jac_client/tests/fixtures/cl_file/app.cl.jac +2 -2
- jac_client/tests/fixtures/client_app_with_antd/app.jac +1 -1
- jac_client/tests/fixtures/js_import/app.jac +5 -5
- jac_client/tests/fixtures/spawn_test/app.jac +7 -7
- jac_client/tests/fixtures/with-ts/app.jac +35 -0
- jac_client/tests/test_cli.py +755 -0
- jac_client/tests/test_it.py +347 -67
- {jac_client-0.2.2.dist-info → jac_client-0.2.6.dist-info}/METADATA +30 -24
- jac_client-0.2.6.dist-info/RECORD +74 -0
- {jac_client-0.2.2.dist-info → jac_client-0.2.6.dist-info}/WHEEL +2 -1
- jac_client-0.2.6.dist-info/entry_points.txt +4 -0
- jac_client-0.2.6.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/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/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/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/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/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/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/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/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/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/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/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/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/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/package.json +0 -28
- jac_client/examples/full-stack-with-auth/vite.config.js +0 -29
- 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/README.md +0 -77
- 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.js +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/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/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/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.2.dist-info/RECORD +0 -171
- jac_client-0.2.2.dist-info/entry_points.txt +0 -4
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Combined example: routing + CSS styling + asset serving + nested folder imports
|
|
3
|
-
#
|
|
4
|
-
cl import from react { useState, useEffect }
|
|
5
|
-
cl import from "@jac-client/utils" { Router, Routes, Route, Link, useLocation }
|
|
6
|
-
|
|
7
|
-
# Pure CSS + asset-in-CSS example
|
|
8
|
-
cl import ".styles.css";
|
|
9
|
-
|
|
10
|
-
# Nested folder imports (same pattern as nested-basic/)
|
|
11
|
-
cl import from .components.button {
|
|
12
|
-
CustomButton
|
|
13
|
-
}
|
|
14
|
-
cl import from .button { CustomButtonRoot }
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
# Basic backend walkers
|
|
18
|
-
#
|
|
19
|
-
node Todo {
|
|
20
|
-
has text: str;
|
|
21
|
-
has done: bool = False;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
walker create_todo {
|
|
25
|
-
has text: str;
|
|
26
|
-
|
|
27
|
-
can create with `root entry {
|
|
28
|
-
new_todo = here ++> Todo(text=self.text);
|
|
29
|
-
report new_todo ;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
walker ping_server {
|
|
34
|
-
can ping with `root entry {
|
|
35
|
-
report "pong from backend!" ;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
walker get_server_message {
|
|
40
|
-
can info with `root entry {
|
|
41
|
-
report "hello from a basic walker!" ;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
cl {
|
|
46
|
-
# Home page demonstrating CSS styling + direct asset usage + basic walkers
|
|
47
|
-
def Home() -> any {
|
|
48
|
-
let [count, setCount] = useState(0);
|
|
49
|
-
let [pingResult, setPingResult] = useState("");
|
|
50
|
-
let [serverMessage, setServerMessage] = useState("");
|
|
51
|
-
let [lastTodoMessage, setLastTodoMessage] = useState("");
|
|
52
|
-
|
|
53
|
-
useEffect(
|
|
54
|
-
lambda -> None{ console.log("Home count changed: ", count);} , [count]
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
# Call simple backend walkers
|
|
58
|
-
async def handlePing() -> None {
|
|
59
|
-
result = root spawn ping_server();
|
|
60
|
-
if result.reports and result.reports.length > 0 {
|
|
61
|
-
setPingResult(result.reports[0][0]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async def loadServerMessage() -> None {
|
|
66
|
-
result = root spawn get_server_message();
|
|
67
|
-
if result.reports and result.reports.length > 0 {
|
|
68
|
-
setServerMessage(result.reports[0][0]);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
# Create a sample Todo node in the graph with a hardcoded payload
|
|
73
|
-
async def handleCreateSampleTodo() -> None {
|
|
74
|
-
result = root spawn create_todo(text="Sample todo from all-in-one app");
|
|
75
|
-
if result.reports and result.reports.length > 0 {
|
|
76
|
-
todo = result.reports[0][0];
|
|
77
|
-
setLastTodoMessage("Created Todo: " + todo.text);
|
|
78
|
-
console.log("Created Todo node:", todo);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
useEffect(lambda -> None{ loadServerMessage();} , []);
|
|
83
|
-
|
|
84
|
-
return <div
|
|
85
|
-
style={{
|
|
86
|
-
"padding": "2rem",
|
|
87
|
-
"fontFamily": "system-ui, -apple-system, sans-serif"
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<h1>
|
|
91
|
-
🍔 Router + Styling + Assets Demo
|
|
92
|
-
</h1>
|
|
93
|
-
<p>
|
|
94
|
-
This home page combines
|
|
95
|
-
{" "}
|
|
96
|
-
<strong>
|
|
97
|
-
React Router,
|
|
98
|
-
</strong>
|
|
99
|
-
{" "}
|
|
100
|
-
<strong>
|
|
101
|
-
pure CSS styling,
|
|
102
|
-
</strong>
|
|
103
|
-
{" "}
|
|
104
|
-
<strong>
|
|
105
|
-
static assets
|
|
106
|
-
</strong>
|
|
107
|
-
{" "}
|
|
108
|
-
and
|
|
109
|
-
{" "}
|
|
110
|
-
<strong>
|
|
111
|
-
nested folder imports
|
|
112
|
-
</strong>
|
|
113
|
-
</p>
|
|
114
|
-
<div className="container">
|
|
115
|
-
<h2
|
|
116
|
-
style={{
|
|
117
|
-
"color": "white",
|
|
118
|
-
"textShadow": "2px 2px 4px rgba(0,0,0,0.6)"
|
|
119
|
-
}}
|
|
120
|
-
>
|
|
121
|
-
CSS Background Image
|
|
122
|
-
</h2>
|
|
123
|
-
<p
|
|
124
|
-
style={{
|
|
125
|
-
"color": "white",
|
|
126
|
-
"maxWidth": "480px",
|
|
127
|
-
"textShadow": "1px 1px 3px rgba(0,0,0,0.7)"
|
|
128
|
-
}}
|
|
129
|
-
>
|
|
130
|
-
This section uses the burger image as a background via CSS, just like the
|
|
131
|
-
{" "}
|
|
132
|
-
<code>
|
|
133
|
-
asset-serving/css-with-image
|
|
134
|
-
</code>
|
|
135
|
-
{" "}
|
|
136
|
-
example.
|
|
137
|
-
</p>
|
|
138
|
-
</div>
|
|
139
|
-
<div className="card">
|
|
140
|
-
<h3>
|
|
141
|
-
Direct <img> asset
|
|
142
|
-
</h3>
|
|
143
|
-
<img
|
|
144
|
-
src="/static/assets/burger.png"
|
|
145
|
-
alt="Burger asset served by Jac"
|
|
146
|
-
className="burgerImage"
|
|
147
|
-
/>
|
|
148
|
-
<p
|
|
149
|
-
style={{"marginTop": "0.75rem", "color": "#555"}}
|
|
150
|
-
>
|
|
151
|
-
This image is served from the project
|
|
152
|
-
{" "}
|
|
153
|
-
<code>
|
|
154
|
-
assets/
|
|
155
|
-
</code>
|
|
156
|
-
{" "}
|
|
157
|
-
folder using the
|
|
158
|
-
{" "}
|
|
159
|
-
<code>
|
|
160
|
-
/static/assets/
|
|
161
|
-
</code>
|
|
162
|
-
{" "}
|
|
163
|
-
path.
|
|
164
|
-
</p>
|
|
165
|
-
</div>
|
|
166
|
-
<div
|
|
167
|
-
style={{"marginTop": "2rem"}}
|
|
168
|
-
>
|
|
169
|
-
<h3>
|
|
170
|
-
Counter with pure CSS classes
|
|
171
|
-
</h3>
|
|
172
|
-
<p>
|
|
173
|
-
You've clicked the burger
|
|
174
|
-
{" "}
|
|
175
|
-
<strong>
|
|
176
|
-
{count}
|
|
177
|
-
</strong>
|
|
178
|
-
{" "}
|
|
179
|
-
times.
|
|
180
|
-
</p>
|
|
181
|
-
<button
|
|
182
|
-
onClick={lambda e: any -> None{ setCount(count + 1);} }
|
|
183
|
-
style={{
|
|
184
|
-
"padding": "0.6rem 1.4rem",
|
|
185
|
-
"fontSize": "1rem",
|
|
186
|
-
"backgroundColor": "#ff6b35",
|
|
187
|
-
"color": "white",
|
|
188
|
-
"border": "none",
|
|
189
|
-
"borderRadius": "6px",
|
|
190
|
-
"cursor": "pointer",
|
|
191
|
-
"boxShadow": "0 2px 4px rgba(0,0,0,0.2)"
|
|
192
|
-
}}
|
|
193
|
-
>
|
|
194
|
-
Click the Burger! 🍔
|
|
195
|
-
</button>
|
|
196
|
-
</div>
|
|
197
|
-
<div
|
|
198
|
-
style={{"marginTop": "2rem"}}
|
|
199
|
-
>
|
|
200
|
-
<h3>
|
|
201
|
-
Backend Walkers
|
|
202
|
-
</h3>
|
|
203
|
-
<p>
|
|
204
|
-
Basic example walkers:
|
|
205
|
-
{" "}
|
|
206
|
-
<code>
|
|
207
|
-
ping_server
|
|
208
|
-
</code>
|
|
209
|
-
{" "}
|
|
210
|
-
and
|
|
211
|
-
{" "}
|
|
212
|
-
<code>
|
|
213
|
-
get_server_message
|
|
214
|
-
</code>
|
|
215
|
-
</p>
|
|
216
|
-
<button
|
|
217
|
-
onClick={lambda e: any -> None{ handlePing();} }
|
|
218
|
-
style={{
|
|
219
|
-
"padding": "0.5rem 1.2rem",
|
|
220
|
-
"marginRight": "0.75rem",
|
|
221
|
-
"backgroundColor": "#3b82f6",
|
|
222
|
-
"color": "white",
|
|
223
|
-
"border": "none",
|
|
224
|
-
"borderRadius": "6px",
|
|
225
|
-
"cursor": "pointer"
|
|
226
|
-
}}
|
|
227
|
-
>
|
|
228
|
-
Ping Backend
|
|
229
|
-
</button>
|
|
230
|
-
<button
|
|
231
|
-
onClick={lambda e: any -> None{ handleCreateSampleTodo();} }
|
|
232
|
-
style={{
|
|
233
|
-
"padding": "0.5rem 1.2rem",
|
|
234
|
-
"backgroundColor": "#10b981",
|
|
235
|
-
"color": "white",
|
|
236
|
-
"border": "none",
|
|
237
|
-
"borderRadius": "6px",
|
|
238
|
-
"cursor": "pointer"
|
|
239
|
-
}}
|
|
240
|
-
>
|
|
241
|
-
Create Sample Todo
|
|
242
|
-
</button>
|
|
243
|
-
{pingResult
|
|
244
|
-
and (
|
|
245
|
-
<span
|
|
246
|
-
style={{"marginLeft": "0.5rem", "color": "#374151"}}
|
|
247
|
-
>
|
|
248
|
-
Result:
|
|
249
|
-
{" "}
|
|
250
|
-
<code>
|
|
251
|
-
{pingResult}
|
|
252
|
-
</code>
|
|
253
|
-
</span>
|
|
254
|
-
)}
|
|
255
|
-
{serverMessage
|
|
256
|
-
and (
|
|
257
|
-
<p
|
|
258
|
-
style={{"marginTop": "0.75rem", "color": "#374151"}}
|
|
259
|
-
>
|
|
260
|
-
Message:
|
|
261
|
-
{" "}
|
|
262
|
-
<code>
|
|
263
|
-
{serverMessage}
|
|
264
|
-
</code>
|
|
265
|
-
</p>
|
|
266
|
-
)}
|
|
267
|
-
{lastTodoMessage
|
|
268
|
-
and (
|
|
269
|
-
<p
|
|
270
|
-
style={{"marginTop": "0.5rem", "color": "#111827"}}
|
|
271
|
-
>
|
|
272
|
-
{lastTodoMessage}
|
|
273
|
-
</p>
|
|
274
|
-
)}
|
|
275
|
-
</div>
|
|
276
|
-
</div>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
# Page showing nested imports from different folders
|
|
280
|
-
def NestedImportsDemo() -> any {
|
|
281
|
-
return <div
|
|
282
|
-
style={{
|
|
283
|
-
"padding": "2rem",
|
|
284
|
-
"fontFamily": "system-ui, -apple-system, sans-serif"
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
<h1>
|
|
288
|
-
📁 Nested Folder Imports
|
|
289
|
-
</h1>
|
|
290
|
-
<p>
|
|
291
|
-
This page mirrors the
|
|
292
|
-
{" "}
|
|
293
|
-
<code>
|
|
294
|
-
nested-folders/nested-basic
|
|
295
|
-
</code>
|
|
296
|
-
{" "}
|
|
297
|
-
example by importing components from both
|
|
298
|
-
{" "}
|
|
299
|
-
<code>
|
|
300
|
-
components.button
|
|
301
|
-
</code>
|
|
302
|
-
{" "}
|
|
303
|
-
and
|
|
304
|
-
{" "}
|
|
305
|
-
<code>
|
|
306
|
-
button
|
|
307
|
-
</code>
|
|
308
|
-
</p>
|
|
309
|
-
<p
|
|
310
|
-
style={{"marginTop": "0.75rem"}}
|
|
311
|
-
>
|
|
312
|
-
Both buttons below are rendered via relative imports:
|
|
313
|
-
</p>
|
|
314
|
-
<div
|
|
315
|
-
style={{"display": "flex", "gap": "1rem", "marginTop": "1.5rem"}}
|
|
316
|
-
>
|
|
317
|
-
<CustomButton />
|
|
318
|
-
<CustomButtonRoot />
|
|
319
|
-
</div>
|
|
320
|
-
</div>;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
# Simple 404 page
|
|
324
|
-
def NotFound() -> any {
|
|
325
|
-
return <div
|
|
326
|
-
style={{
|
|
327
|
-
"padding": "2rem",
|
|
328
|
-
"textAlign": "center",
|
|
329
|
-
"fontFamily": "system-ui, -apple-system, sans-serif"
|
|
330
|
-
}}
|
|
331
|
-
>
|
|
332
|
-
<h1>
|
|
333
|
-
🔍 404 - Page Not Found
|
|
334
|
-
</h1>
|
|
335
|
-
<p>
|
|
336
|
-
The page you are looking for does not exist.
|
|
337
|
-
</p>
|
|
338
|
-
<Link to="/">
|
|
339
|
-
← Back to Home
|
|
340
|
-
</Link>
|
|
341
|
-
</div>;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
# Navigation component with active link styling (same pattern as routing docs)
|
|
345
|
-
def Navigation() -> any {
|
|
346
|
-
let location = useLocation();
|
|
347
|
-
|
|
348
|
-
def linkStyle(path: str) -> dict {
|
|
349
|
-
isActive = location.pathname == path;
|
|
350
|
-
return {
|
|
351
|
-
"padding": "0.5rem 1rem",
|
|
352
|
-
"textDecoration": "none",
|
|
353
|
-
"color": "#0066cc" if isActive else "#333",
|
|
354
|
-
"fontWeight": "bold" if isActive else "normal",
|
|
355
|
-
"backgroundColor": "#e3f2fd" if isActive else "transparent",
|
|
356
|
-
"borderRadius": "4px",
|
|
357
|
-
"display": "inline-block"
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return <nav
|
|
362
|
-
style={{
|
|
363
|
-
"padding": "1rem",
|
|
364
|
-
"backgroundColor": "#f5f5f5",
|
|
365
|
-
"marginBottom": "2rem",
|
|
366
|
-
"boxShadow": "0 2px 4px rgba(0,0,0,0.1)"
|
|
367
|
-
}}
|
|
368
|
-
>
|
|
369
|
-
<div
|
|
370
|
-
style={{
|
|
371
|
-
"maxWidth": "1200px",
|
|
372
|
-
"margin": "0 auto",
|
|
373
|
-
"display": "flex",
|
|
374
|
-
"gap": "1rem",
|
|
375
|
-
"alignItems": "center"
|
|
376
|
-
}}
|
|
377
|
-
>
|
|
378
|
-
<Link
|
|
379
|
-
to="/"
|
|
380
|
-
style={linkStyle("/")}
|
|
381
|
-
>
|
|
382
|
-
Home
|
|
383
|
-
</Link>
|
|
384
|
-
<Link
|
|
385
|
-
to="/nested"
|
|
386
|
-
style={linkStyle("/nested")}
|
|
387
|
-
>
|
|
388
|
-
Nested Imports
|
|
389
|
-
</Link>
|
|
390
|
-
</div>
|
|
391
|
-
</nav>;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
# Main app wrapped in Router (same API as with-router/ example)
|
|
395
|
-
def app() -> any {
|
|
396
|
-
return <Router>
|
|
397
|
-
<div
|
|
398
|
-
style={{"fontFamily": "system-ui, -apple-system, sans-serif"}}
|
|
399
|
-
>
|
|
400
|
-
<Navigation />
|
|
401
|
-
<div
|
|
402
|
-
style={{
|
|
403
|
-
"maxWidth": "960px",
|
|
404
|
-
"margin": "0 auto",
|
|
405
|
-
"padding": "0 1rem 3rem 1rem"
|
|
406
|
-
}}
|
|
407
|
-
>
|
|
408
|
-
<Routes>
|
|
409
|
-
<Route
|
|
410
|
-
path="/"
|
|
411
|
-
element={<Home />}
|
|
412
|
-
/>
|
|
413
|
-
<Route
|
|
414
|
-
path="/nested"
|
|
415
|
-
element={<NestedImportsDemo />}
|
|
416
|
-
/>
|
|
417
|
-
<Route
|
|
418
|
-
path="*"
|
|
419
|
-
element={<NotFound />}
|
|
420
|
-
/>
|
|
421
|
-
</Routes>
|
|
422
|
-
</div>
|
|
423
|
-
</div>
|
|
424
|
-
</Router>;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
Binary file
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "all-in-one",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npm run compile && vite build",
|
|
7
|
-
"dev": "vite dev",
|
|
8
|
-
"preview": "vite preview",
|
|
9
|
-
"compile": "babel src --out-dir build --extensions \".jsx,.js\" --out-file-extension .js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"description": "Jac application: all-in-one",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@babel/cli": "^7.28.3",
|
|
18
|
-
"@babel/core": "^7.28.5",
|
|
19
|
-
"@babel/preset-env": "^7.28.5",
|
|
20
|
-
"@babel/preset-react": "^7.28.5",
|
|
21
|
-
"vite": "^6.4.1"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"antd": "^6.0.0",
|
|
25
|
-
"react": "^19.2.0",
|
|
26
|
-
"react-dom": "^19.2.0",
|
|
27
|
-
"react-router-dom": "^6.30.1"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
background-image: url('/static/assets/burger.png');
|
|
3
|
-
background-size: cover;
|
|
4
|
-
background-position: center;
|
|
5
|
-
min-height: 300px;
|
|
6
|
-
border-radius: 10px;
|
|
7
|
-
padding: 20px;
|
|
8
|
-
margin: 20px 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.card {
|
|
12
|
-
background: white;
|
|
13
|
-
border-radius: 10px;
|
|
14
|
-
padding: 20px;
|
|
15
|
-
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
|
16
|
-
max-width: 400px;
|
|
17
|
-
margin: 20px auto;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.burgerImage {
|
|
21
|
-
width: 200px;
|
|
22
|
-
height: auto;
|
|
23
|
-
border-radius: 10px;
|
|
24
|
-
display: block;
|
|
25
|
-
margin: 0 auto;
|
|
26
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineConfig } from "vite";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
root: ".", // base folder
|
|
10
|
-
build: {
|
|
11
|
-
rollupOptions: {
|
|
12
|
-
input: "build/main.js", // your compiled entry file
|
|
13
|
-
output: {
|
|
14
|
-
entryFileNames: "client.[hash].js", // name of the final js file
|
|
15
|
-
assetFileNames: "[name].[ext]",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
outDir: "dist", // final bundled output
|
|
19
|
-
emptyOutDir: true,
|
|
20
|
-
},
|
|
21
|
-
publicDir: false,
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: {
|
|
24
|
-
"@jac-client/utils": path.resolve(__dirname, "src/client_runtime.js"),
|
|
25
|
-
"@jac-client/assets": path.resolve(__dirname, "src/assets"),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Relative Imports Example
|
|
2
|
-
|
|
3
|
-
This example demonstrates how to import static assets using relative path imports.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Imports image using relative path (`./assets/burger.png`)
|
|
8
|
-
- Component-scoped asset organization
|
|
9
|
-
- Vite processes and optimizes the asset
|
|
10
|
-
- Familiar import syntax
|
|
11
|
-
|
|
12
|
-
## Project Structure
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
relative-imports/
|
|
16
|
-
├── app.jac # Main application file
|
|
17
|
-
├── assets/ # Static assets directory
|
|
18
|
-
│ └── burger.png # Burger image
|
|
19
|
-
├── src/ # Source files (generated)
|
|
20
|
-
├── build/ # Build output (generated)
|
|
21
|
-
└── dist/ # Distribution output (generated)
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Running the Example
|
|
25
|
-
|
|
26
|
-
1. Make sure node modules are installed:
|
|
27
|
-
```bash
|
|
28
|
-
npm install
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
2. Run the Jac server:
|
|
32
|
-
```bash
|
|
33
|
-
jac serve app.jac
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
3. Open your browser and navigate to:
|
|
37
|
-
```
|
|
38
|
-
http://localhost:8000/page/app
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## How It Works
|
|
42
|
-
|
|
43
|
-
### Import Syntax
|
|
44
|
-
|
|
45
|
-
```jac
|
|
46
|
-
cl import from "./assets/burger.png" { default as burgerImage }
|
|
47
|
-
<img src={burgerImage} />
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Path Resolution
|
|
51
|
-
|
|
52
|
-
- Relative paths are resolved from the current file location
|
|
53
|
-
- `./assets/burger.png` resolves relative to `app.jac`
|
|
54
|
-
- Vite processes the import during build
|
|
55
|
-
- Assets are optimized and bundled
|
|
56
|
-
|
|
57
|
-
### Use Cases
|
|
58
|
-
|
|
59
|
-
**Component-Scoped Assets:**
|
|
60
|
-
```jac
|
|
61
|
-
# In a component file
|
|
62
|
-
cl import from "./images/icon.svg" { default as icon }
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
**Parent Directory Assets:**
|
|
66
|
-
```jac
|
|
67
|
-
# Access assets from parent directory
|
|
68
|
-
cl import from "../shared/assets/logo.png" { default as logo }
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
**Nested Assets:**
|
|
72
|
-
```jac
|
|
73
|
-
# Assets in subdirectories
|
|
74
|
-
cl import from "./assets/images/hero.jpg" { default as hero }
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Benefits
|
|
78
|
-
|
|
79
|
-
- **Familiar Syntax**: Standard relative import pattern
|
|
80
|
-
- **Component Organization**: Assets organized by component/feature
|
|
81
|
-
- **Flexibility**: Easy to reorganize without changing alias config
|
|
82
|
-
- **Modular**: Works well with component-based architecture
|
|
83
|
-
|
|
84
|
-
## Best Practices
|
|
85
|
-
|
|
86
|
-
1. Use relative imports for component-specific assets
|
|
87
|
-
2. Organize assets near the components that use them
|
|
88
|
-
3. Keep relative paths simple and clear
|
|
89
|
-
4. Use consistent naming conventions
|
|
90
|
-
|
|
91
|
-
Happy coding with Jac! 🍔
|
|
Binary file
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "relative-imports",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npm run compile && vite build",
|
|
7
|
-
"dev": "vite dev",
|
|
8
|
-
"preview": "vite preview",
|
|
9
|
-
"compile": "babel src --out-dir build --extensions \".jsx,.js\" --out-file-extension .js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"description": "Jac application: relative-imports",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"vite": "^6.4.1",
|
|
18
|
-
"@babel/cli": "^7.28.3",
|
|
19
|
-
"@babel/core": "^7.28.5",
|
|
20
|
-
"@babel/preset-env": "^7.28.5",
|
|
21
|
-
"@babel/preset-react": "^7.28.5"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"react": "^19.2.0",
|
|
25
|
-
"react-dom": "^19.2.0",
|
|
26
|
-
"react-router-dom": "^6.30.1"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
background-image: url('/static/assets/burger.png');
|
|
3
|
-
background-size: cover;
|
|
4
|
-
background-position: center;
|
|
5
|
-
min-height: 300px;
|
|
6
|
-
border-radius: 10px;
|
|
7
|
-
padding: 20px;
|
|
8
|
-
margin: 20px 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.card {
|
|
12
|
-
background: white;
|
|
13
|
-
border-radius: 10px;
|
|
14
|
-
padding: 20px;
|
|
15
|
-
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
|
16
|
-
max-width: 400px;
|
|
17
|
-
margin: 20px auto;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.burgerImage {
|
|
21
|
-
width: 200px;
|
|
22
|
-
height: auto;
|
|
23
|
-
border-radius: 10px;
|
|
24
|
-
display: block;
|
|
25
|
-
margin: 0 auto;
|
|
26
|
-
}
|