@ionyx-apps/cli 0.4.4 → 0.4.6

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 (30) hide show
  1. package/bin/ionyx.exe +0 -0
  2. package/ionyx-cli/Cargo.toml +3 -0
  3. package/ionyx-cli/src/templates/basic/src-ionyx/Cargo.toml +3 -0
  4. package/ionyx-cli/src/templates/basic/src-ionyx/build.rs +11 -0
  5. package/ionyx-cli/src/templates/basic/src-ionyx/ionyx.config.toml +2 -1
  6. package/ionyx-cli/src/templates/basic/src-ionyx/src/protocol.rs +26 -32
  7. package/ionyx-cli/src/templates/leptos/Cargo.toml +3 -0
  8. package/ionyx-cli/src/templates/leptos/src-ionyx/Cargo.toml +3 -0
  9. package/ionyx-cli/src/templates/leptos/src-ionyx/build.rs +11 -0
  10. package/ionyx-cli/src/templates/leptos/src-ionyx/ionyx.config.toml +2 -1
  11. package/ionyx-cli/src/templates/leptos/src-ionyx/src/protocol.rs +26 -32
  12. package/ionyx-cli/src/templates/react/src-ionyx/Cargo.toml +3 -0
  13. package/ionyx-cli/src/templates/react/src-ionyx/build.rs +11 -0
  14. package/ionyx-cli/src/templates/react/src-ionyx/ionyx.config.toml +2 -1
  15. package/ionyx-cli/src/templates/react/src-ionyx/src/protocol.rs +26 -32
  16. package/ionyx-cli/src/templates/src-ionyx/Cargo.toml +3 -0
  17. package/ionyx-cli/src/templates/src-ionyx/build.rs +11 -0
  18. package/ionyx-cli/src/templates/svelte/src-ionyx/Cargo.toml +3 -0
  19. package/ionyx-cli/src/templates/svelte/src-ionyx/build.rs +11 -0
  20. package/ionyx-cli/src/templates/svelte/src-ionyx/ionyx.config.toml +2 -1
  21. package/ionyx-cli/src/templates/svelte/src-ionyx/src/protocol.rs +26 -32
  22. package/ionyx-cli/src/templates/vanilla/src-ionyx/Cargo.toml +3 -0
  23. package/ionyx-cli/src/templates/vanilla/src-ionyx/build.rs +11 -0
  24. package/ionyx-cli/src/templates/vanilla/src-ionyx/ionyx.config.toml +2 -1
  25. package/ionyx-cli/src/templates/vanilla/src-ionyx/src/protocol.rs +26 -32
  26. package/ionyx-cli/src/templates/vue/src-ionyx/Cargo.toml +3 -0
  27. package/ionyx-cli/src/templates/vue/src-ionyx/build.rs +11 -0
  28. package/ionyx-cli/src/templates/vue/src-ionyx/ionyx.config.toml +2 -1
  29. package/ionyx-cli/src/templates/vue/src-ionyx/src/protocol.rs +26 -32
  30. package/package.json +1 -1
package/bin/ionyx.exe CHANGED
Binary file
@@ -39,3 +39,6 @@ exclude = [
39
39
  "src/templates/vanilla/src-ionyx",
40
40
  "src/templates/vue/src-ionyx"
41
41
  ]
42
+
43
+
44
+
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -14,6 +15,7 @@ name = "my-ionyx-app"
14
15
  path = "main.rs"
15
16
 
16
17
  [dependencies]
18
+ include_dir = "0.7"
17
19
  ionyx = { path = "../../../../../../src-ionyx" }
18
20
  anyhow = "1.0"
19
21
  wry = "0.54"
@@ -24,3 +26,4 @@ opt-level = 3
24
26
  lto = true
25
27
  codegen-units = 1
26
28
  panic = "abort"
29
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -22,6 +22,7 @@ open_devtools = false
22
22
 
23
23
  [build]
24
24
  before_dev_command = "npm run dev"
25
- dev_url = "http://127.0.0.1:5173"
25
+ dev_url = "http://localhost:5173"
26
26
  frontend_dist = "../frontend/dist"
27
27
 
28
+
@@ -1,7 +1,9 @@
1
1
  use std::borrow::Cow;
2
2
  use wry::http::{Request, Response, StatusCode};
3
3
  use std::path::{PathBuf};
4
- use std::fs;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
5
7
 
6
8
  // Configuration'dan frontendDist path'ini oku
7
9
  fn get_frontend_dist_path() -> PathBuf {
@@ -17,19 +19,12 @@ fn get_frontend_dist_path() -> PathBuf {
17
19
  }
18
20
  }
19
21
 
20
- // Varsayılan path: exe yanındaki dist klasörü
21
- if let Ok(exe_path) = std::env::current_exe() {
22
- if let Some(exe_dir) = exe_path.parent() {
23
- let dist = exe_dir.join("dist");
24
- if dist.exists() {
25
- return dist;
26
- }
27
- }
28
- }
29
-
30
- PathBuf::from("dist")
22
+ PathBuf::from("../frontend/dist")
31
23
  }
32
24
 
25
+ #[cfg(not(debug_assertions))]
26
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../frontend/dist");
27
+
33
28
  pub struct CustomProtocolHandler;
34
29
 
35
30
  impl CustomProtocolHandler {
@@ -43,7 +38,6 @@ impl CustomProtocolHandler {
43
38
  #[cfg(debug_assertions)]
44
39
  {
45
40
  let _uri_path = uri_path;
46
- let _dist_path = get_frontend_dist_path();
47
41
  let _unused_ct = Self::get_content_type("index.html");
48
42
  return Response::builder()
49
43
  .status(StatusCode::NOT_FOUND)
@@ -54,32 +48,32 @@ impl CustomProtocolHandler {
54
48
 
55
49
  #[cfg(not(debug_assertions))]
56
50
  {
57
- let dist_dir = get_frontend_dist_path();
58
51
  let clean_path = uri_path.trim_start_matches('/');
59
52
  let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
60
- let full_path = dist_dir.join(file_path);
61
53
 
62
- if let Ok(contents) = fs::read(&full_path) {
63
- let content_type = Self::get_content_type(file_path);
64
- Response::builder()
65
- .status(StatusCode::OK)
66
- .header("Content-Type", content_type)
67
- .body(Cow::Owned(contents))
68
- .unwrap()
69
- } else {
70
- let index_path = dist_dir.join("index.html");
71
- if let Ok(index_contents) = fs::read(&index_path) {
54
+ match EMBEDDED_ASSETS.get_file(file_path) {
55
+ Some(file) => {
56
+ let content_type = Self::get_content_type(file_path);
72
57
  Response::builder()
73
58
  .status(StatusCode::OK)
74
- .header("Content-Type", "text/html")
75
- .body(Cow::Owned(index_contents))
76
- .unwrap()
77
- } else {
78
- Response::builder()
79
- .status(StatusCode::NOT_FOUND)
80
- .body(Cow::Borrowed(&b"404 Not Found"[..]))
59
+ .header("Content-Type", content_type)
60
+ .body(Cow::Borrowed(file.contents()))
81
61
  .unwrap()
82
62
  }
63
+ None => {
64
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
65
+ Response::builder()
66
+ .status(StatusCode::OK)
67
+ .header("Content-Type", "text/html")
68
+ .body(Cow::Borrowed(index_file.contents()))
69
+ .unwrap()
70
+ } else {
71
+ Response::builder()
72
+ .status(StatusCode::NOT_FOUND)
73
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
74
+ .unwrap()
75
+ }
76
+ }
83
77
  }
84
78
  }
85
79
  }
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -7,8 +8,10 @@ edition = "2021"
7
8
  crate-type = ["cdylib"]
8
9
 
9
10
  [dependencies]
11
+ include_dir = "0.7"
10
12
  leptos = { version = "0.6", features = ["csr"] }
11
13
  wasm-bindgen = "0.2"
12
14
  console_log = "1.0"
13
15
  log = "0.4"
14
16
  console_error_panic_hook = "0.1"
17
+
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -10,6 +11,7 @@ name = "my-ionyx-app"
10
11
  path = "main.rs"
11
12
 
12
13
  [dependencies]
14
+ include_dir = "0.7"
13
15
  ionyx = { path = "../../../../../../src-ionyx" }
14
16
  anyhow = "1.0"
15
17
  wry = "0.54"
@@ -20,3 +22,4 @@ opt-level = 3
20
22
  lto = true
21
23
  codegen-units = 1
22
24
  panic = "abort"
25
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -22,6 +22,7 @@ open_devtools = false
22
22
 
23
23
  [build]
24
24
  before_dev_command = "npm run dev"
25
- dev_url = "http://127.0.0.1:5173"
25
+ dev_url = "http://localhost:5173"
26
26
  frontend_dist = "../frontend/dist"
27
27
 
28
+
@@ -1,7 +1,9 @@
1
1
  use std::borrow::Cow;
2
2
  use wry::http::{Request, Response, StatusCode};
3
3
  use std::path::{PathBuf};
4
- use std::fs;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
5
7
 
6
8
  // Configuration'dan frontendDist path'ini oku
7
9
  fn get_frontend_dist_path() -> PathBuf {
@@ -17,19 +19,12 @@ fn get_frontend_dist_path() -> PathBuf {
17
19
  }
18
20
  }
19
21
 
20
- // Varsayılan path: exe yanındaki dist klasörü
21
- if let Ok(exe_path) = std::env::current_exe() {
22
- if let Some(exe_dir) = exe_path.parent() {
23
- let dist = exe_dir.join("dist");
24
- if dist.exists() {
25
- return dist;
26
- }
27
- }
28
- }
29
-
30
- PathBuf::from("dist")
22
+ PathBuf::from("../frontend/dist")
31
23
  }
32
24
 
25
+ #[cfg(not(debug_assertions))]
26
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../frontend/dist");
27
+
33
28
  pub struct CustomProtocolHandler;
34
29
 
35
30
  impl CustomProtocolHandler {
@@ -43,7 +38,6 @@ impl CustomProtocolHandler {
43
38
  #[cfg(debug_assertions)]
44
39
  {
45
40
  let _uri_path = uri_path;
46
- let _dist_path = get_frontend_dist_path();
47
41
  let _unused_ct = Self::get_content_type("index.html");
48
42
  return Response::builder()
49
43
  .status(StatusCode::NOT_FOUND)
@@ -54,32 +48,32 @@ impl CustomProtocolHandler {
54
48
 
55
49
  #[cfg(not(debug_assertions))]
56
50
  {
57
- let dist_dir = get_frontend_dist_path();
58
51
  let clean_path = uri_path.trim_start_matches('/');
59
52
  let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
60
- let full_path = dist_dir.join(file_path);
61
53
 
62
- if let Ok(contents) = fs::read(&full_path) {
63
- let content_type = Self::get_content_type(file_path);
64
- Response::builder()
65
- .status(StatusCode::OK)
66
- .header("Content-Type", content_type)
67
- .body(Cow::Owned(contents))
68
- .unwrap()
69
- } else {
70
- let index_path = dist_dir.join("index.html");
71
- if let Ok(index_contents) = fs::read(&index_path) {
54
+ match EMBEDDED_ASSETS.get_file(file_path) {
55
+ Some(file) => {
56
+ let content_type = Self::get_content_type(file_path);
72
57
  Response::builder()
73
58
  .status(StatusCode::OK)
74
- .header("Content-Type", "text/html")
75
- .body(Cow::Owned(index_contents))
76
- .unwrap()
77
- } else {
78
- Response::builder()
79
- .status(StatusCode::NOT_FOUND)
80
- .body(Cow::Borrowed(&b"404 Not Found"[..]))
59
+ .header("Content-Type", content_type)
60
+ .body(Cow::Borrowed(file.contents()))
81
61
  .unwrap()
82
62
  }
63
+ None => {
64
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
65
+ Response::builder()
66
+ .status(StatusCode::OK)
67
+ .header("Content-Type", "text/html")
68
+ .body(Cow::Borrowed(index_file.contents()))
69
+ .unwrap()
70
+ } else {
71
+ Response::builder()
72
+ .status(StatusCode::NOT_FOUND)
73
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
74
+ .unwrap()
75
+ }
76
+ }
83
77
  }
84
78
  }
85
79
  }
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -14,6 +15,7 @@ name = "my-ionyx-app"
14
15
  path = "main.rs"
15
16
 
16
17
  [dependencies]
18
+ include_dir = "0.7"
17
19
  ionyx = { path = "../../../../../../src-ionyx" }
18
20
  anyhow = "1.0"
19
21
  wry = "0.54"
@@ -24,3 +26,4 @@ opt-level = 3
24
26
  lto = true
25
27
  codegen-units = 1
26
28
  panic = "abort"
29
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -22,6 +22,7 @@ open_devtools = false
22
22
 
23
23
  [build]
24
24
  before_dev_command = "npm run dev"
25
- dev_url = "http://127.0.0.1:5173"
25
+ dev_url = "http://localhost:5173"
26
26
  frontend_dist = "../frontend/dist"
27
27
 
28
+
@@ -1,7 +1,9 @@
1
1
  use std::borrow::Cow;
2
2
  use wry::http::{Request, Response, StatusCode};
3
3
  use std::path::{PathBuf};
4
- use std::fs;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
5
7
 
6
8
  // Configuration'dan frontendDist path'ini oku
7
9
  fn get_frontend_dist_path() -> PathBuf {
@@ -17,19 +19,12 @@ fn get_frontend_dist_path() -> PathBuf {
17
19
  }
18
20
  }
19
21
 
20
- // Varsayılan path: exe yanındaki dist klasörü
21
- if let Ok(exe_path) = std::env::current_exe() {
22
- if let Some(exe_dir) = exe_path.parent() {
23
- let dist = exe_dir.join("dist");
24
- if dist.exists() {
25
- return dist;
26
- }
27
- }
28
- }
29
-
30
- PathBuf::from("dist")
22
+ PathBuf::from("../frontend/dist")
31
23
  }
32
24
 
25
+ #[cfg(not(debug_assertions))]
26
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../frontend/dist");
27
+
33
28
  pub struct CustomProtocolHandler;
34
29
 
35
30
  impl CustomProtocolHandler {
@@ -43,7 +38,6 @@ impl CustomProtocolHandler {
43
38
  #[cfg(debug_assertions)]
44
39
  {
45
40
  let _uri_path = uri_path;
46
- let _dist_path = get_frontend_dist_path();
47
41
  let _unused_ct = Self::get_content_type("index.html");
48
42
  return Response::builder()
49
43
  .status(StatusCode::NOT_FOUND)
@@ -54,32 +48,32 @@ impl CustomProtocolHandler {
54
48
 
55
49
  #[cfg(not(debug_assertions))]
56
50
  {
57
- let dist_dir = get_frontend_dist_path();
58
51
  let clean_path = uri_path.trim_start_matches('/');
59
52
  let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
60
- let full_path = dist_dir.join(file_path);
61
53
 
62
- if let Ok(contents) = fs::read(&full_path) {
63
- let content_type = Self::get_content_type(file_path);
64
- Response::builder()
65
- .status(StatusCode::OK)
66
- .header("Content-Type", content_type)
67
- .body(Cow::Owned(contents))
68
- .unwrap()
69
- } else {
70
- let index_path = dist_dir.join("index.html");
71
- if let Ok(index_contents) = fs::read(&index_path) {
54
+ match EMBEDDED_ASSETS.get_file(file_path) {
55
+ Some(file) => {
56
+ let content_type = Self::get_content_type(file_path);
72
57
  Response::builder()
73
58
  .status(StatusCode::OK)
74
- .header("Content-Type", "text/html")
75
- .body(Cow::Owned(index_contents))
76
- .unwrap()
77
- } else {
78
- Response::builder()
79
- .status(StatusCode::NOT_FOUND)
80
- .body(Cow::Borrowed(&b"404 Not Found"[..]))
59
+ .header("Content-Type", content_type)
60
+ .body(Cow::Borrowed(file.contents()))
81
61
  .unwrap()
82
62
  }
63
+ None => {
64
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
65
+ Response::builder()
66
+ .status(StatusCode::OK)
67
+ .header("Content-Type", "text/html")
68
+ .body(Cow::Borrowed(index_file.contents()))
69
+ .unwrap()
70
+ } else {
71
+ Response::builder()
72
+ .status(StatusCode::NOT_FOUND)
73
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
74
+ .unwrap()
75
+ }
76
+ }
83
77
  }
84
78
  }
85
79
  }
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -8,6 +9,7 @@ name = "my-ionyx-app"
8
9
  path = "main.rs"
9
10
 
10
11
  [dependencies]
12
+ include_dir = "0.7"
11
13
  ionyx = "1.0.0"
12
14
  anyhow = "1.0"
13
15
 
@@ -16,3 +18,4 @@ opt-level = 3
16
18
  lto = true
17
19
  codegen-units = 1
18
20
  panic = "abort"
21
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -14,6 +15,7 @@ name = "my-ionyx-app"
14
15
  path = "main.rs"
15
16
 
16
17
  [dependencies]
18
+ include_dir = "0.7"
17
19
  ionyx = { path = "../../../../../../src-ionyx" }
18
20
  anyhow = "1.0"
19
21
  wry = "0.54"
@@ -24,3 +26,4 @@ opt-level = 3
24
26
  lto = true
25
27
  codegen-units = 1
26
28
  panic = "abort"
29
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -22,6 +22,7 @@ open_devtools = false
22
22
 
23
23
  [build]
24
24
  before_dev_command = "npm run dev"
25
- dev_url = "http://127.0.0.1:5173"
25
+ dev_url = "http://localhost:5173"
26
26
  frontend_dist = "../frontend/dist"
27
27
 
28
+
@@ -1,7 +1,9 @@
1
1
  use std::borrow::Cow;
2
2
  use wry::http::{Request, Response, StatusCode};
3
3
  use std::path::{PathBuf};
4
- use std::fs;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
5
7
 
6
8
  // Configuration'dan frontendDist path'ini oku
7
9
  fn get_frontend_dist_path() -> PathBuf {
@@ -17,19 +19,12 @@ fn get_frontend_dist_path() -> PathBuf {
17
19
  }
18
20
  }
19
21
 
20
- // Varsayılan path: exe yanındaki dist klasörü
21
- if let Ok(exe_path) = std::env::current_exe() {
22
- if let Some(exe_dir) = exe_path.parent() {
23
- let dist = exe_dir.join("dist");
24
- if dist.exists() {
25
- return dist;
26
- }
27
- }
28
- }
29
-
30
- PathBuf::from("dist")
22
+ PathBuf::from("../frontend/dist")
31
23
  }
32
24
 
25
+ #[cfg(not(debug_assertions))]
26
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../frontend/dist");
27
+
33
28
  pub struct CustomProtocolHandler;
34
29
 
35
30
  impl CustomProtocolHandler {
@@ -43,7 +38,6 @@ impl CustomProtocolHandler {
43
38
  #[cfg(debug_assertions)]
44
39
  {
45
40
  let _uri_path = uri_path;
46
- let _dist_path = get_frontend_dist_path();
47
41
  let _unused_ct = Self::get_content_type("index.html");
48
42
  return Response::builder()
49
43
  .status(StatusCode::NOT_FOUND)
@@ -54,32 +48,32 @@ impl CustomProtocolHandler {
54
48
 
55
49
  #[cfg(not(debug_assertions))]
56
50
  {
57
- let dist_dir = get_frontend_dist_path();
58
51
  let clean_path = uri_path.trim_start_matches('/');
59
52
  let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
60
- let full_path = dist_dir.join(file_path);
61
53
 
62
- if let Ok(contents) = fs::read(&full_path) {
63
- let content_type = Self::get_content_type(file_path);
64
- Response::builder()
65
- .status(StatusCode::OK)
66
- .header("Content-Type", content_type)
67
- .body(Cow::Owned(contents))
68
- .unwrap()
69
- } else {
70
- let index_path = dist_dir.join("index.html");
71
- if let Ok(index_contents) = fs::read(&index_path) {
54
+ match EMBEDDED_ASSETS.get_file(file_path) {
55
+ Some(file) => {
56
+ let content_type = Self::get_content_type(file_path);
72
57
  Response::builder()
73
58
  .status(StatusCode::OK)
74
- .header("Content-Type", "text/html")
75
- .body(Cow::Owned(index_contents))
76
- .unwrap()
77
- } else {
78
- Response::builder()
79
- .status(StatusCode::NOT_FOUND)
80
- .body(Cow::Borrowed(&b"404 Not Found"[..]))
59
+ .header("Content-Type", content_type)
60
+ .body(Cow::Borrowed(file.contents()))
81
61
  .unwrap()
82
62
  }
63
+ None => {
64
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
65
+ Response::builder()
66
+ .status(StatusCode::OK)
67
+ .header("Content-Type", "text/html")
68
+ .body(Cow::Borrowed(index_file.contents()))
69
+ .unwrap()
70
+ } else {
71
+ Response::builder()
72
+ .status(StatusCode::NOT_FOUND)
73
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
74
+ .unwrap()
75
+ }
76
+ }
83
77
  }
84
78
  }
85
79
  }
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -14,6 +15,7 @@ name = "my-ionyx-app"
14
15
  path = "main.rs"
15
16
 
16
17
  [dependencies]
18
+ include_dir = "0.7"
17
19
  ionyx = { path = "../../../../../../src-ionyx" }
18
20
  anyhow = "1.0"
19
21
  wry = "0.54"
@@ -24,3 +26,4 @@ opt-level = 3
24
26
  lto = true
25
27
  codegen-units = 1
26
28
  panic = "abort"
29
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -22,6 +22,7 @@ open_devtools = false
22
22
 
23
23
  [build]
24
24
  before_dev_command = "npm run dev"
25
- dev_url = "http://127.0.0.1:5173"
25
+ dev_url = "http://localhost:5173"
26
26
  frontend_dist = "../frontend/dist"
27
27
 
28
+
@@ -1,7 +1,9 @@
1
1
  use std::borrow::Cow;
2
2
  use wry::http::{Request, Response, StatusCode};
3
3
  use std::path::{PathBuf};
4
- use std::fs;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
5
7
 
6
8
  // Configuration'dan frontendDist path'ini oku
7
9
  fn get_frontend_dist_path() -> PathBuf {
@@ -17,19 +19,12 @@ fn get_frontend_dist_path() -> PathBuf {
17
19
  }
18
20
  }
19
21
 
20
- // Varsayılan path: exe yanındaki dist klasörü
21
- if let Ok(exe_path) = std::env::current_exe() {
22
- if let Some(exe_dir) = exe_path.parent() {
23
- let dist = exe_dir.join("dist");
24
- if dist.exists() {
25
- return dist;
26
- }
27
- }
28
- }
29
-
30
- PathBuf::from("dist")
22
+ PathBuf::from("../frontend/dist")
31
23
  }
32
24
 
25
+ #[cfg(not(debug_assertions))]
26
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../frontend/dist");
27
+
33
28
  pub struct CustomProtocolHandler;
34
29
 
35
30
  impl CustomProtocolHandler {
@@ -43,7 +38,6 @@ impl CustomProtocolHandler {
43
38
  #[cfg(debug_assertions)]
44
39
  {
45
40
  let _uri_path = uri_path;
46
- let _dist_path = get_frontend_dist_path();
47
41
  let _unused_ct = Self::get_content_type("index.html");
48
42
  return Response::builder()
49
43
  .status(StatusCode::NOT_FOUND)
@@ -54,32 +48,32 @@ impl CustomProtocolHandler {
54
48
 
55
49
  #[cfg(not(debug_assertions))]
56
50
  {
57
- let dist_dir = get_frontend_dist_path();
58
51
  let clean_path = uri_path.trim_start_matches('/');
59
52
  let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
60
- let full_path = dist_dir.join(file_path);
61
53
 
62
- if let Ok(contents) = fs::read(&full_path) {
63
- let content_type = Self::get_content_type(file_path);
64
- Response::builder()
65
- .status(StatusCode::OK)
66
- .header("Content-Type", content_type)
67
- .body(Cow::Owned(contents))
68
- .unwrap()
69
- } else {
70
- let index_path = dist_dir.join("index.html");
71
- if let Ok(index_contents) = fs::read(&index_path) {
54
+ match EMBEDDED_ASSETS.get_file(file_path) {
55
+ Some(file) => {
56
+ let content_type = Self::get_content_type(file_path);
72
57
  Response::builder()
73
58
  .status(StatusCode::OK)
74
- .header("Content-Type", "text/html")
75
- .body(Cow::Owned(index_contents))
76
- .unwrap()
77
- } else {
78
- Response::builder()
79
- .status(StatusCode::NOT_FOUND)
80
- .body(Cow::Borrowed(&b"404 Not Found"[..]))
59
+ .header("Content-Type", content_type)
60
+ .body(Cow::Borrowed(file.contents()))
81
61
  .unwrap()
82
62
  }
63
+ None => {
64
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
65
+ Response::builder()
66
+ .status(StatusCode::OK)
67
+ .header("Content-Type", "text/html")
68
+ .body(Cow::Borrowed(index_file.contents()))
69
+ .unwrap()
70
+ } else {
71
+ Response::builder()
72
+ .status(StatusCode::NOT_FOUND)
73
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
74
+ .unwrap()
75
+ }
76
+ }
83
77
  }
84
78
  }
85
79
  }
@@ -1,4 +1,5 @@
1
1
  [package]
2
+ build = "build.rs"
2
3
  name = "my-ionyx-app"
3
4
  version = "0.4.2"
4
5
  edition = "2021"
@@ -14,6 +15,7 @@ name = "my-ionyx-app"
14
15
  path = "main.rs"
15
16
 
16
17
  [dependencies]
18
+ include_dir = "0.7"
17
19
  ionyx = { path = "../../../../../../src-ionyx" }
18
20
  anyhow = "1.0"
19
21
  wry = "0.54"
@@ -24,3 +26,4 @@ opt-level = 3
24
26
  lto = true
25
27
  codegen-units = 1
26
28
  panic = "abort"
29
+
@@ -0,0 +1,11 @@
1
+ use std::fs;
2
+ use std::path::Path;
3
+
4
+ fn main() {
5
+ let dist_path = Path::new("../frontend/dist");
6
+ if !dist_path.exists() {
7
+ fs::create_dir_all(dist_path).expect("Failed to create frontend/dist directory");
8
+ fs::write(dist_path.join("index.html"), "<html><body><h1>Ionyx App Loading...</h1></body></html>").expect("Failed to write placeholder index.html");
9
+ }
10
+ println!("cargo:rerun-if-changed=../frontend/dist");
11
+ }
@@ -22,6 +22,7 @@ open_devtools = false
22
22
 
23
23
  [build]
24
24
  before_dev_command = "npm run dev"
25
- dev_url = "http://127.0.0.1:5173"
25
+ dev_url = "http://localhost:5173"
26
26
  frontend_dist = "../frontend/dist"
27
27
 
28
+
@@ -1,7 +1,9 @@
1
1
  use std::borrow::Cow;
2
2
  use wry::http::{Request, Response, StatusCode};
3
3
  use std::path::{PathBuf};
4
- use std::fs;
4
+
5
+ #[cfg(not(debug_assertions))]
6
+ use include_dir::{include_dir, Dir};
5
7
 
6
8
  // Configuration'dan frontendDist path'ini oku
7
9
  fn get_frontend_dist_path() -> PathBuf {
@@ -17,19 +19,12 @@ fn get_frontend_dist_path() -> PathBuf {
17
19
  }
18
20
  }
19
21
 
20
- // Varsayılan path: exe yanındaki dist klasörü
21
- if let Ok(exe_path) = std::env::current_exe() {
22
- if let Some(exe_dir) = exe_path.parent() {
23
- let dist = exe_dir.join("dist");
24
- if dist.exists() {
25
- return dist;
26
- }
27
- }
28
- }
29
-
30
- PathBuf::from("dist")
22
+ PathBuf::from("../frontend/dist")
31
23
  }
32
24
 
25
+ #[cfg(not(debug_assertions))]
26
+ static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../frontend/dist");
27
+
33
28
  pub struct CustomProtocolHandler;
34
29
 
35
30
  impl CustomProtocolHandler {
@@ -43,7 +38,6 @@ impl CustomProtocolHandler {
43
38
  #[cfg(debug_assertions)]
44
39
  {
45
40
  let _uri_path = uri_path;
46
- let _dist_path = get_frontend_dist_path();
47
41
  let _unused_ct = Self::get_content_type("index.html");
48
42
  return Response::builder()
49
43
  .status(StatusCode::NOT_FOUND)
@@ -54,32 +48,32 @@ impl CustomProtocolHandler {
54
48
 
55
49
  #[cfg(not(debug_assertions))]
56
50
  {
57
- let dist_dir = get_frontend_dist_path();
58
51
  let clean_path = uri_path.trim_start_matches('/');
59
52
  let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
60
- let full_path = dist_dir.join(file_path);
61
53
 
62
- if let Ok(contents) = fs::read(&full_path) {
63
- let content_type = Self::get_content_type(file_path);
64
- Response::builder()
65
- .status(StatusCode::OK)
66
- .header("Content-Type", content_type)
67
- .body(Cow::Owned(contents))
68
- .unwrap()
69
- } else {
70
- let index_path = dist_dir.join("index.html");
71
- if let Ok(index_contents) = fs::read(&index_path) {
54
+ match EMBEDDED_ASSETS.get_file(file_path) {
55
+ Some(file) => {
56
+ let content_type = Self::get_content_type(file_path);
72
57
  Response::builder()
73
58
  .status(StatusCode::OK)
74
- .header("Content-Type", "text/html")
75
- .body(Cow::Owned(index_contents))
76
- .unwrap()
77
- } else {
78
- Response::builder()
79
- .status(StatusCode::NOT_FOUND)
80
- .body(Cow::Borrowed(&b"404 Not Found"[..]))
59
+ .header("Content-Type", content_type)
60
+ .body(Cow::Borrowed(file.contents()))
81
61
  .unwrap()
82
62
  }
63
+ None => {
64
+ if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
65
+ Response::builder()
66
+ .status(StatusCode::OK)
67
+ .header("Content-Type", "text/html")
68
+ .body(Cow::Borrowed(index_file.contents()))
69
+ .unwrap()
70
+ } else {
71
+ Response::builder()
72
+ .status(StatusCode::NOT_FOUND)
73
+ .body(Cow::Borrowed(&b"404 Not Found"[..]))
74
+ .unwrap()
75
+ }
76
+ }
83
77
  }
84
78
  }
85
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionyx-apps/cli",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Ionyx Framework CLI - High-performance desktop apps with Rust and WebGPU",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",