jac-client 0.2.8__py3-none-any.whl → 0.2.11__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.
Files changed (119) hide show
  1. jac_client/examples/all-in-one/button.jac +4 -3
  2. jac_client/examples/all-in-one/components/CategoryFilter.jac +36 -24
  3. jac_client/examples/all-in-one/components/Header.jac +12 -8
  4. jac_client/examples/all-in-one/components/ProfitOverview.jac +49 -35
  5. jac_client/examples/all-in-one/components/Summary.jac +59 -36
  6. jac_client/examples/all-in-one/components/TransactionForm.jac +142 -112
  7. jac_client/examples/all-in-one/components/TransactionItem.jac +37 -30
  8. jac_client/examples/all-in-one/components/TransactionList.jac +33 -26
  9. jac_client/examples/all-in-one/components/button.jac +4 -3
  10. jac_client/examples/all-in-one/components/navigation.jac +111 -117
  11. jac_client/examples/all-in-one/constants/categories.jac +23 -24
  12. jac_client/examples/all-in-one/constants/clients.jac +7 -8
  13. jac_client/examples/all-in-one/context/BudgetContext.jac +9 -6
  14. jac_client/examples/all-in-one/hooks/useBudget.jac +18 -12
  15. jac_client/examples/all-in-one/hooks/useLocalStorage.jac +14 -13
  16. jac_client/examples/all-in-one/main.jac +542 -0
  17. jac_client/examples/all-in-one/pages/BudgetPlanner.jac +26 -12
  18. jac_client/examples/all-in-one/pages/FeaturesTest.jac +43 -12
  19. jac_client/examples/all-in-one/pages/LandingPage.jac +113 -90
  20. jac_client/examples/all-in-one/pages/budget_planner_ui.cl.jac +65 -0
  21. jac_client/examples/all-in-one/pages/features_test_ui.cl.jac +675 -0
  22. jac_client/examples/all-in-one/pages/loginPage.jac +114 -119
  23. jac_client/examples/all-in-one/pages/nestedDemo.jac +44 -51
  24. jac_client/examples/all-in-one/pages/notFound.jac +15 -21
  25. jac_client/examples/all-in-one/pages/signupPage.jac +113 -119
  26. jac_client/examples/all-in-one/utils/formatters.jac +5 -8
  27. jac_client/examples/asset-serving/css-with-image/main.jac +92 -0
  28. jac_client/examples/asset-serving/image-asset/main.jac +56 -0
  29. jac_client/examples/asset-serving/import-alias/main.jac +109 -0
  30. jac_client/examples/basic/main.jac +23 -0
  31. jac_client/examples/basic-auth/main.jac +363 -0
  32. jac_client/examples/basic-auth-with-router/main.jac +451 -0
  33. jac_client/examples/basic-full-stack/main.jac +362 -0
  34. jac_client/examples/css-styling/js-styling/main.jac +63 -0
  35. jac_client/examples/css-styling/material-ui/main.jac +122 -0
  36. jac_client/examples/css-styling/pure-css/main.jac +55 -0
  37. jac_client/examples/css-styling/sass-example/main.jac +55 -0
  38. jac_client/examples/css-styling/styled-components/main.jac +62 -0
  39. jac_client/examples/css-styling/tailwind-example/main.jac +74 -0
  40. jac_client/examples/full-stack-with-auth/main.jac +696 -0
  41. jac_client/examples/little-x/main.jac +681 -0
  42. jac_client/examples/little-x/src/submit-button.jac +15 -14
  43. jac_client/examples/nested-folders/nested-advance/main.jac +26 -0
  44. jac_client/examples/nested-folders/nested-advance/src/ButtonRoot.jac +4 -6
  45. jac_client/examples/nested-folders/nested-advance/src/level1/ButtonSecondL.jac +9 -13
  46. jac_client/examples/nested-folders/nested-advance/src/level1/Card.jac +29 -32
  47. jac_client/examples/nested-folders/nested-advance/src/level1/level2/ButtonThirdL.jac +12 -18
  48. jac_client/examples/nested-folders/nested-basic/{src/app.jac → main.jac} +7 -5
  49. jac_client/examples/nested-folders/nested-basic/src/button.jac +4 -3
  50. jac_client/examples/nested-folders/nested-basic/src/components/button.jac +4 -3
  51. jac_client/examples/ts-support/main.jac +35 -0
  52. jac_client/examples/with-router/main.jac +286 -0
  53. jac_client/plugin/cli.jac +491 -411
  54. jac_client/plugin/client.jac +25 -0
  55. jac_client/plugin/client_runtime.cl.jac +10 -4
  56. jac_client/plugin/impl/client.impl.jac +96 -55
  57. jac_client/plugin/impl/client_runtime.impl.jac +155 -1
  58. jac_client/plugin/plugin_config.jac +211 -29
  59. jac_client/plugin/src/__init__.jac +0 -2
  60. jac_client/plugin/src/compiler.jac +0 -1
  61. jac_client/plugin/src/config_loader.jac +1 -0
  62. jac_client/plugin/src/desktop_config.jac +31 -0
  63. jac_client/plugin/src/impl/compiler.impl.jac +49 -17
  64. jac_client/plugin/src/impl/config_loader.impl.jac +8 -0
  65. jac_client/plugin/src/impl/desktop_config.impl.jac +191 -0
  66. jac_client/plugin/src/impl/jac_to_js.impl.jac +5 -1
  67. jac_client/plugin/src/impl/package_installer.impl.jac +20 -20
  68. jac_client/plugin/src/impl/vite_bundler.impl.jac +191 -64
  69. jac_client/plugin/src/targets/desktop/sidecar/main.py +144 -0
  70. jac_client/plugin/src/targets/desktop_target.jac +37 -0
  71. jac_client/plugin/src/targets/impl/desktop_target.impl.jac +2347 -0
  72. jac_client/plugin/src/targets/impl/registry.impl.jac +64 -0
  73. jac_client/plugin/src/targets/impl/web_target.impl.jac +157 -0
  74. jac_client/plugin/src/targets/register.jac +21 -0
  75. jac_client/plugin/src/targets/registry.jac +87 -0
  76. jac_client/plugin/src/targets/web_target.jac +35 -0
  77. jac_client/plugin/src/vite_bundler.jac +6 -0
  78. jac_client/plugin/utils/__init__.jac +3 -0
  79. jac_client/plugin/utils/bun_installer.jac +16 -0
  80. jac_client/plugin/utils/impl/bun_installer.impl.jac +99 -0
  81. jac_client/templates/client.jacpack +72 -0
  82. jac_client/templates/fullstack.jacpack +61 -0
  83. jac_client/tests/conftest.py +103 -47
  84. jac_client/tests/fixtures/spawn_test/app.jac +49 -52
  85. jac_client/tests/fixtures/with-ts/app.jac +27 -27
  86. jac_client/tests/test_cli.py +182 -71
  87. jac_client/tests/test_e2e.py +232 -0
  88. jac_client/tests/test_helpers.py +58 -0
  89. jac_client/tests/test_it.py +91 -135
  90. jac_client/tests/test_it_desktop.py +891 -0
  91. {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/METADATA +6 -6
  92. jac_client-0.2.11.dist-info/RECORD +113 -0
  93. {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/WHEEL +1 -1
  94. jac_client/examples/all-in-one/app.jac +0 -573
  95. jac_client/examples/all-in-one/pages/BudgetPlanner.cl.jac +0 -70
  96. jac_client/examples/all-in-one/pages/FeaturesTest.cl.jac +0 -552
  97. jac_client/examples/asset-serving/css-with-image/src/app.jac +0 -88
  98. jac_client/examples/asset-serving/image-asset/src/app.jac +0 -55
  99. jac_client/examples/asset-serving/import-alias/src/app.jac +0 -111
  100. jac_client/examples/basic/src/app.jac +0 -21
  101. jac_client/examples/basic-auth/src/app.jac +0 -371
  102. jac_client/examples/basic-auth-with-router/src/app.jac +0 -464
  103. jac_client/examples/basic-full-stack/src/app.jac +0 -359
  104. jac_client/examples/css-styling/js-styling/src/app.jac +0 -84
  105. jac_client/examples/css-styling/material-ui/src/app.jac +0 -122
  106. jac_client/examples/css-styling/pure-css/src/app.jac +0 -64
  107. jac_client/examples/css-styling/sass-example/src/app.jac +0 -64
  108. jac_client/examples/css-styling/styled-components/src/app.jac +0 -71
  109. jac_client/examples/css-styling/tailwind-example/src/app.jac +0 -63
  110. jac_client/examples/full-stack-with-auth/src/app.jac +0 -722
  111. jac_client/examples/little-x/src/app.jac +0 -719
  112. jac_client/examples/nested-folders/nested-advance/src/app.jac +0 -35
  113. jac_client/examples/ts-support/src/app.jac +0 -35
  114. jac_client/examples/with-router/src/app.jac +0 -323
  115. jac_client/plugin/src/babel_processor.jac +0 -18
  116. jac_client/plugin/src/impl/babel_processor.impl.jac +0 -89
  117. jac_client-0.2.8.dist-info/RECORD +0 -97
  118. {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/entry_points.txt +0 -0
  119. {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/top_level.txt +0 -0
@@ -18,6 +18,31 @@ glob JsonValue: TypeAlias = None | str | int | float | bool | list['JsonValue']
18
18
  ],
19
19
  StatusCode: TypeAlias = Literal[(200, 201, 400, 401, 404, 503)];
20
20
 
21
+ """Builds HTML head content from meta data."""
22
+ obj HeaderBuilder {
23
+ has meta_data: dict,
24
+ function_name: str,
25
+ DEFAULTS: dict = {
26
+ "charset": "UTF-8",
27
+ "viewport": "width=device-width,initial-scale=1"
28
+ },
29
+ standard_tags: list = [
30
+ "description",
31
+ "keywords",
32
+ "author",
33
+ "robots",
34
+ "theme_color"
35
+ ];
36
+
37
+ def build_head -> str;
38
+ def _get_value(key: str) -> str;
39
+ def _build_special_tags -> list[str];
40
+ def _build_meta_tags -> list[str];
41
+ def _build_og_tags -> list[str];
42
+ def _build_link_tags -> list[str];
43
+ def _build_generic_meta_tags -> list[str];
44
+ }
45
+
21
46
  """Jac Client."""
22
47
  class JacClient {
23
48
  @hookimpl
@@ -1,7 +1,7 @@
1
1
  """Client-side runtime for Jac JSX and walker interactions."""
2
2
 
3
3
  import from 'react' { * as React }
4
- import from 'react' { useState as reactUseState }
4
+ import from 'react' { useState as reactUseState, useEffect as reactUseEffect }
5
5
  import from 'react-dom/client' { * as ReactDOM }
6
6
  import from 'react-router-dom' {
7
7
  HashRouter as ReactRouterHashRouter,
@@ -13,11 +13,14 @@ import from 'react-router-dom' {
13
13
  useLocation as reactRouterUseLocation,
14
14
  useParams as reactRouterUseParams
15
15
  }
16
+ import from 'react-error-boundary' { ErrorBoundary }
16
17
 
17
18
  def:pub __jacJsx(tag: any, props: dict = {}, children: any = []) -> any;
18
19
 
19
- # React hooks re-exported for auto-injection by `has` variables
20
- glob:pub useState = reactUseState,
20
+ # React hooks re-exported for auto-injection by `has` variables and `can with entry/exit` effects
21
+ glob:
22
+ pub useState = reactUseState,
23
+ useEffect = reactUseEffect,
21
24
  Router = ReactRouterHashRouter,
22
25
  Routes = ReactRouterRoutes,
23
26
  Route = ReactRouterRoute,
@@ -25,7 +28,8 @@ glob:pub useState = reactUseState,
25
28
  Navigate = ReactRouterNavigate,
26
29
  useNavigate = reactRouterUseNavigate,
27
30
  useLocation = reactRouterUseLocation,
28
- useParams = reactRouterUseParams;
31
+ useParams = reactRouterUseParams,
32
+ JacClientErrorBoundary = ErrorBoundary;
29
33
 
30
34
  def:pub useRouter -> dict;
31
35
  def:pub navigate(path: str) -> None;
@@ -39,4 +43,6 @@ def:pub jacIsLoggedIn -> bool;
39
43
  def:pub __getLocalStorage(key: str) -> str;
40
44
  def:pub __setLocalStorage(key: str, value: str) -> None;
41
45
  def:pub __removeLocalStorage(key: str) -> None;
46
+ def:pub ErrorFallback(error: str, resetErrorBoundary: any) -> any;
47
+ def:pub errorOverlay(filePath: str, errors: str) -> any;
42
48
  # React Router components
@@ -126,61 +126,8 @@ impl JacClient.render_page(
126
126
  # Get meta data from config
127
127
  client_cfg = config.get_plugin_config("client") if config else None;
128
128
  meta_data = client_cfg.get("app_meta_data", {}) if client_cfg else {};
129
- charset = meta_data.get("charset", "UTF-8");
130
- title = meta_data.get("title", function_name);
131
- viewport = meta_data.get("viewport", "width=device-width, initial-scale=1");
132
- description = meta_data.get("description", None);
133
- robots = meta_data.get("robots", "index, follow");
134
- canonical = meta_data.get("canonical", None);
135
- og_type = meta_data.get("og_type", "website");
136
- og_title = meta_data.get("og_title", title);
137
- og_description = meta_data.get("og_description", None);
138
- og_url = meta_data.get("og_url", None);
139
- og_image = meta_data.get("og_image", None);
140
- theme_color = meta_data.get("theme_color", "#ffffff");
141
- icon = meta_data.get("icon", None);
142
- # Build head content from TOML metadata
143
- head_content = f'<meta charset="{html.escape(charset)}"/>\n <meta name="viewport" content="{html.escape(
144
- viewport
145
- )}"/>\n <title>{html.escape(title)}</title>';
146
- head_content += f'\n <meta name="robots" content="{html.escape(robots)}"/>';
147
- head_content += f'\n <meta name="theme-color" content="{html.escape(
148
- theme_color
149
- )}"/>';
150
- head_content += f'\n <meta property="og:type" content="{html.escape(
151
- og_type
152
- )}"/>';
153
- head_content += f'\n <meta property="og:title" content="{html.escape(
154
- og_title
155
- )}"/>';
156
- if description {
157
- head_content += f'\n <meta name="description" content="{html.escape(
158
- description
159
- )}"/>';
160
- }
161
- if canonical {
162
- head_content += f'\n <link rel="canonical" href="{html.escape(
163
- canonical
164
- )}"/>';
165
- }
166
- if icon {
167
- head_content += f'\n <link rel="icon" href="{html.escape(icon)}"/>';
168
- }
169
- if og_url {
170
- head_content += f'\n <meta property="og:url" content="{html.escape(
171
- og_url
172
- )}"/>';
173
- }
174
- if og_image {
175
- head_content += f'\n <meta property="og:image" content="{html.escape(
176
- og_image
177
- )}"/>';
178
- }
179
- if og_description {
180
- head_content += f'\n <meta property="og:description" content="{html.escape(
181
- og_description
182
- )}"/>';
183
- }
129
+ head_builder = HeaderBuilder(meta_data, function_name);
130
+ head_content = head_builder.build_head();
184
131
  if css_link {
185
132
  head_content += f"\n {css_link}";
186
133
  }
@@ -191,3 +138,97 @@ impl JacClient.render_page(
191
138
  'bundle_code': introspector._bundle.code
192
139
  };
193
140
  }
141
+
142
+ """Build complete HTML head."""
143
+ impl HeaderBuilder.build_head -> str {
144
+ lines: list = [];
145
+ lines.extend(self._build_special_tags()); # charset, viewport, title
146
+ lines.extend(self._build_meta_tags()); # description, robots, etc
147
+ lines.extend(self._build_og_tags()); # Open Graph
148
+ lines.extend(self._build_link_tags()); # canonical, icon, etc
149
+ lines.extend(self._build_generic_meta_tags()); # custom meta_* tags
150
+ return "\n ".join(lines);
151
+ }
152
+
153
+ """Build generic meta tags (meta_* prefix for any custom metadata)."""
154
+ impl HeaderBuilder._build_generic_meta_tags -> list[str] {
155
+ lines: list = [];
156
+ for (key, val) in self.meta_data.items() {
157
+ if key.startswith("meta_") and val {
158
+ # meta_custom_field → name="custom-field"
159
+ name = key[5:].replace("_", "-");
160
+ lines.append(f'<meta name={name} content={html.escape(str(val))} />');
161
+ }
162
+ }
163
+ return lines;
164
+ }
165
+
166
+ """Build link tags (link_* prefix or special cases)."""
167
+ impl HeaderBuilder._build_link_tags -> list[str] {
168
+ lines: list = [];
169
+ special_links = {
170
+ "canonical": "canonical",
171
+ "icon": "icon",
172
+ "apple_touch_icon": "apple-touch-icon",
173
+ "manifest": "manifest"
174
+ };
175
+ for (key, rel) in special_links.items() {
176
+ if val := self._get_value(key) {
177
+ lines.append(f'<link rel={rel} href={html.escape(str(val))} />');
178
+ }
179
+ }
180
+ for (key, val) in self.meta_data.items() {
181
+ if key.startswith("link_") and val {
182
+ # link_preconnect_google → rel="preconnect"
183
+ rel = key[5:].replace("_", "-");
184
+ lines.append(f'<link rel={rel} href={html.escape(str(val))} />');
185
+ }
186
+ }
187
+ return lines;
188
+ }
189
+
190
+ """Build Open Graph tags (og_* prefix)."""
191
+ impl HeaderBuilder._build_og_tags -> list[str] {
192
+ lines: list = [];
193
+ for (key, val) in self.meta_data.items() {
194
+ if key.startswith("og_") and val {
195
+ property_name = key[3:].replace("_", ":");
196
+ lines.append(
197
+ f'<meta property=og:{property_name} content={html.escape(str(val))} />'
198
+ );
199
+ }
200
+ }
201
+ return lines;
202
+ }
203
+
204
+ """Build standard meta tags (description, robots, keywords, author, etc)."""
205
+ impl HeaderBuilder._build_meta_tags -> list[str] {
206
+ lines: list = [];
207
+ for key in self.standard_tags {
208
+ if val := self._get_value(key) {
209
+ # Convert underscore to dash (theme_color → theme-color)
210
+ name = key.replace("_", "-");
211
+ lines.append(f'<meta name={name} content={html.escape(val)} />');
212
+ }
213
+ }
214
+ return lines;
215
+ }
216
+
217
+ """Build special tags (charset, viewport, title)."""
218
+ impl HeaderBuilder._build_special_tags -> list[str] {
219
+ lines: list = [];
220
+ if charset := self._get_value("charset") {
221
+ lines.append(f'<meta charset={html.escape(charset)} />');
222
+ }
223
+ if viewport := self._get_value("viewport") {
224
+ lines.append(f'<meta name="viewport" content={html.escape(viewport)} />');
225
+ }
226
+ title = self._get_value("title") or self.function_name;
227
+ lines.append(f'<title>{html.escape(title)}</title>');
228
+ return lines;
229
+ }
230
+
231
+ """Get value with fallback to defaults."""
232
+ impl HeaderBuilder._get_value(key: str) -> str {
233
+ return self.meta_data.get(key) or self.DEFAULTS.get(key);
234
+ }
@@ -86,7 +86,7 @@ impl __jacCallFunction(function_name: str, args: dict = {}) -> any {
86
86
  "Content-Type": "application/json",
87
87
  "Authorization": f"Bearer {token}" if token else ""
88
88
  },
89
- "body": JSON.stringify({"args": args})
89
+ "body": JSON.stringify(args)
90
90
  }
91
91
  );
92
92
  payload = await response.json();
@@ -193,3 +193,157 @@ impl __removeLocalStorage(key: str) -> None {
193
193
  storage.removeItem(key);
194
194
  }
195
195
  }
196
+
197
+ impl ErrorFallback(error: str, resetErrorBoundary: any) -> any {
198
+ return
199
+ <div
200
+ role="alert"
201
+ style={{
202
+ minHeight: "100vh",
203
+ display: "flex",
204
+ justifyContent: "center",
205
+ alignItems: "center",
206
+ backgroundColor: "#f9fafb",
207
+ fontFamily: "system-ui, sans-serif",
208
+
209
+ }}
210
+ >
211
+ <div
212
+ role="alert"
213
+ style={{
214
+ minHeight: "100vh",
215
+ display: "flex",
216
+ flexDirection: "column",
217
+ justifyContent: "center",
218
+ alignItems: "center",
219
+ backgroundColor: "#f9fafb",
220
+ fontFamily: "system-ui, sans-serif",
221
+
222
+ }}
223
+ >
224
+ <h2 style={{color: "#dc2626", marginBottom: "12px"}}>
225
+ 🚨 Something went wrong
226
+ </h2>
227
+ <p style={{color: "#374151", marginBottom: "16px"}}>
228
+ An unexpected error occurred. Please try again.
229
+ </p>
230
+ <pre
231
+ style={{
232
+ color: "#991b1b",
233
+ background: "#fee2e2",
234
+ padding: "12px",
235
+ borderRadius: "8px",
236
+ fontSize: "14px",
237
+ overflowX: "auto",
238
+ marginBottom: "16px",
239
+
240
+ }}
241
+ >
242
+ {error.error.message}
243
+ </pre>
244
+ <button
245
+ onClick={lambda -> None { error.resetErrorBoundary();}}
246
+ style={{
247
+ backgroundColor: "#2563eb",
248
+ color: "#fff",
249
+ padding: "10px 16px",
250
+ borderRadius: "8px",
251
+ border: "none",
252
+ cursor: "pointer",
253
+ fontSize: "14px",
254
+
255
+ }}
256
+ >
257
+ 🔄 Try again
258
+ </button>
259
+ </div>
260
+ </div>;
261
+ }
262
+
263
+ impl errorOverlay(filePath: str, errors: str) -> any {
264
+ return (
265
+ <div
266
+ style={{
267
+ position: "fixed",
268
+ top: 0,
269
+ left: 0,
270
+ width: "100%",
271
+ height: "100%",
272
+ background: "rgba(0, 0, 0, 0.85)",
273
+ color: "#fff",
274
+ fontFamily: "'Monaco', 'Menlo', 'Ubuntu Mono', monospace",
275
+ fontSize: 14,
276
+ zIndex: 999999,
277
+ overflow: "auto",
278
+ padding: 20,
279
+ boxSizing: "border-box",
280
+
281
+ }}
282
+ >
283
+ <div style={{maxWidth: 1200, margin: "0 auto"}}>
284
+ <div
285
+ style={{
286
+ background: "#d32f2f",
287
+ color: "white",
288
+ padding: "16px 24px",
289
+ borderRadius: "8px 8px 0 0",
290
+ fontSize: 18,
291
+ fontWeight: "bold",
292
+
293
+ }}
294
+ >
295
+ ⚠️ Compilation Error
296
+ </div>
297
+ <div
298
+ style={{
299
+ background: "#1e1e1e",
300
+ padding: 24,
301
+ borderRadius: "0 0 8px 8px",
302
+
303
+ }}
304
+ >
305
+ <div style={{marginBottom: 16}}>
306
+ <div style={{color: "#888", marginBottom: 8}}>
307
+ File:
308
+ </div>
309
+ <div style={{color: "#64b5f6", fontWeight: "bold"}}>
310
+ {filePath}
311
+ </div>
312
+ </div>
313
+ <div>
314
+ <div style={{color: "#888", marginBottom: 8}}>
315
+ Error:
316
+ </div>
317
+ <pre
318
+ style={{
319
+ background: "#2d2d2d",
320
+ padding: 16,
321
+ borderRadius: 4,
322
+ overflowX: "auto",
323
+ margin: 0,
324
+ borderLeft: "4px solid #d32f2f",
325
+ lineHeight: 1.6,
326
+ color: "#ff6b6b",
327
+
328
+ }}
329
+ >
330
+ {errors}
331
+ </pre>
332
+ </div>
333
+ <div
334
+ style={{
335
+ marginTop: 24,
336
+ paddingTop: 16,
337
+ borderTop: "1px solid #444",
338
+ color: "#888",
339
+ fontSize: 13,
340
+
341
+ }}
342
+ >
343
+ 💡 Fix the error and save the file to continue development.
344
+ </div>
345
+ </div>
346
+ </div>
347
+ </div>
348
+ );
349
+ }