@ionyx-apps/cli 0.1.9 → 0.2.0
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.
- package/bin/ionyx.exe +0 -0
- package/ionyx-cli/src/templates/basic/src-ionyx/Cargo.toml +3 -1
- package/ionyx-cli/src/templates/basic/src-ionyx/src/protocol.rs +87 -0
- package/ionyx-cli/src/templates/leptos/src-ionyx/Cargo.toml +3 -1
- package/ionyx-cli/src/templates/leptos/src-ionyx/src/protocol.rs +87 -0
- package/ionyx-cli/src/templates/mod.rs +5 -0
- package/ionyx-cli/src/templates/react/src-ionyx/Cargo.lock +5536 -0
- package/ionyx-cli/src/templates/react/src-ionyx/Cargo.toml +3 -1
- package/ionyx-cli/src/templates/react/src-ionyx/src/protocol.rs +87 -0
- package/ionyx-cli/src/templates/svelte/src-ionyx/Cargo.toml +3 -1
- package/ionyx-cli/src/templates/svelte/src-ionyx/src/protocol.rs +87 -0
- package/ionyx-cli/src/templates/vanilla/src-ionyx/Cargo.toml +3 -1
- package/ionyx-cli/src/templates/vanilla/src-ionyx/src/protocol.rs +87 -0
- package/ionyx-cli/src/templates/vue/src-ionyx/Cargo.toml +3 -1
- package/ionyx-cli/src/templates/vue/src-ionyx/src/protocol.rs +87 -0
- package/package.json +1 -1
package/bin/ionyx.exe
CHANGED
|
Binary file
|
|
@@ -3,12 +3,14 @@ name = "my-ionyx-app"
|
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
|
|
6
|
+
[workspace]
|
|
7
|
+
|
|
6
8
|
[[bin]]
|
|
7
9
|
name = "my-ionyx-app"
|
|
8
10
|
path = "main.rs"
|
|
9
11
|
|
|
10
12
|
[dependencies]
|
|
11
|
-
ionyx = {
|
|
13
|
+
ionyx = { path = "../../../../../../src-ionyx" }
|
|
12
14
|
anyhow = "1.0"
|
|
13
15
|
|
|
14
16
|
[profile.release]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
use std::borrow::Cow;
|
|
2
|
+
use wry::http::{Request, Response, StatusCode};
|
|
3
|
+
|
|
4
|
+
#[cfg(not(debug_assertions))]
|
|
5
|
+
use include_dir::{include_dir, Dir};
|
|
6
|
+
|
|
7
|
+
// Release modunda frontend/dist içindeki dosyaları binary'ye gömer.
|
|
8
|
+
// Path hatasını engellemek için senin yapılandırdığın "../dist" yolunu kullanıyoruz.
|
|
9
|
+
#[cfg(not(debug_assertions))]
|
|
10
|
+
static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../dist");
|
|
11
|
+
|
|
12
|
+
pub struct CustomProtocolHandler;
|
|
13
|
+
|
|
14
|
+
impl CustomProtocolHandler {
|
|
15
|
+
pub fn new() -> Self {
|
|
16
|
+
Self
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn handle_request(&self, request: Request<Vec<u8>>) -> Response<Cow<'static, [u8]>> {
|
|
20
|
+
let path = request.uri().path();
|
|
21
|
+
|
|
22
|
+
// Debug modunda (npm run dev açıkken) bu handler'ın işi yok aslında,
|
|
23
|
+
// WebView doğrudan localhost'a gitmeli. Ama bir şekilde buraya düşerse
|
|
24
|
+
// 404 yerine temiz bir hata dönüyoruz.
|
|
25
|
+
if cfg!(debug_assertions) {
|
|
26
|
+
return Response::builder()
|
|
27
|
+
.status(StatusCode::NOT_FOUND)
|
|
28
|
+
.header("Content-Type", "text/plain")
|
|
29
|
+
.body(Cow::Borrowed(&b"Debug mode: Assets are served from Vite (localhost:5173)"[..]))
|
|
30
|
+
.unwrap();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Release modunda gömülü dosyaları işle
|
|
34
|
+
#[cfg(not(debug_assertions))]
|
|
35
|
+
{
|
|
36
|
+
let clean_path = path.trim_start_matches('/');
|
|
37
|
+
let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
|
|
38
|
+
|
|
39
|
+
match EMBEDDED_ASSETS.get_file(file_path) {
|
|
40
|
+
Some(file) => {
|
|
41
|
+
let content_type = Self::get_content_type(file_path);
|
|
42
|
+
Response::builder()
|
|
43
|
+
.status(StatusCode::OK)
|
|
44
|
+
.header("Content-Type", content_type)
|
|
45
|
+
.body(Cow::Borrowed(file.contents()))
|
|
46
|
+
.unwrap()
|
|
47
|
+
}
|
|
48
|
+
None => {
|
|
49
|
+
// SPA (Single Page Application) desteği: Dosya bulunamazsa index.html'i dön
|
|
50
|
+
if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
|
|
51
|
+
Response::builder()
|
|
52
|
+
.status(StatusCode::OK)
|
|
53
|
+
.header("Content-Type", "text/html")
|
|
54
|
+
.body(Cow::Borrowed(index_file.contents()))
|
|
55
|
+
.unwrap()
|
|
56
|
+
} else {
|
|
57
|
+
Response::builder()
|
|
58
|
+
.status(StatusCode::NOT_FOUND)
|
|
59
|
+
.body(Cow::Borrowed(&b"404 Not Found"[..]))
|
|
60
|
+
.unwrap()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Burası teknik olarak unreachable ancak derleyiciyi tatmin etmek için
|
|
67
|
+
#[cfg(debug_assertions)]
|
|
68
|
+
Response::builder().status(StatusCode::NOT_FOUND).body(Cow::Borrowed(&b"Not Found"[..])).unwrap()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn get_content_type(file_path: &str) -> &'static str {
|
|
72
|
+
let path = std::path::Path::new(file_path);
|
|
73
|
+
match path.extension().and_then(|s| s.to_str()) {
|
|
74
|
+
Some("html") => "text/html",
|
|
75
|
+
Some("css") => "text/css",
|
|
76
|
+
Some("js") => "application/javascript",
|
|
77
|
+
Some("json") => "application/json",
|
|
78
|
+
Some("svg") => "image/svg+xml",
|
|
79
|
+
Some("png") => "image/png",
|
|
80
|
+
Some("jpg") | Some("jpeg") => "image/jpeg",
|
|
81
|
+
Some("gif") => "image/gif",
|
|
82
|
+
Some("woff") => "font/woff",
|
|
83
|
+
Some("woff2") => "font/woff2",
|
|
84
|
+
_ => "application/octet-stream",
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -3,12 +3,14 @@ name = "my-ionyx-app"
|
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
|
|
6
|
+
[workspace]
|
|
7
|
+
|
|
6
8
|
[[bin]]
|
|
7
9
|
name = "my-ionyx-app"
|
|
8
10
|
path = "main.rs"
|
|
9
11
|
|
|
10
12
|
[dependencies]
|
|
11
|
-
ionyx = {
|
|
13
|
+
ionyx = { path = "../../../../../../src-ionyx" }
|
|
12
14
|
anyhow = "1.0"
|
|
13
15
|
|
|
14
16
|
[profile.release]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
use std::borrow::Cow;
|
|
2
|
+
use wry::http::{Request, Response, StatusCode};
|
|
3
|
+
|
|
4
|
+
#[cfg(not(debug_assertions))]
|
|
5
|
+
use include_dir::{include_dir, Dir};
|
|
6
|
+
|
|
7
|
+
// Release modunda frontend/dist içindeki dosyaları binary'ye gömer.
|
|
8
|
+
// Path hatasını engellemek için senin yapılandırdığın "../dist" yolunu kullanıyoruz.
|
|
9
|
+
#[cfg(not(debug_assertions))]
|
|
10
|
+
static EMBEDDED_ASSETS: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/../dist");
|
|
11
|
+
|
|
12
|
+
pub struct CustomProtocolHandler;
|
|
13
|
+
|
|
14
|
+
impl CustomProtocolHandler {
|
|
15
|
+
pub fn new() -> Self {
|
|
16
|
+
Self
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub fn handle_request(&self, request: Request<Vec<u8>>) -> Response<Cow<'static, [u8]>> {
|
|
20
|
+
let path = request.uri().path();
|
|
21
|
+
|
|
22
|
+
// Debug modunda (npm run dev açıkken) bu handler'ın işi yok aslında,
|
|
23
|
+
// WebView doğrudan localhost'a gitmeli. Ama bir şekilde buraya düşerse
|
|
24
|
+
// 404 yerine temiz bir hata dönüyoruz.
|
|
25
|
+
if cfg!(debug_assertions) {
|
|
26
|
+
return Response::builder()
|
|
27
|
+
.status(StatusCode::NOT_FOUND)
|
|
28
|
+
.header("Content-Type", "text/plain")
|
|
29
|
+
.body(Cow::Borrowed(&b"Debug mode: Assets are served from Vite (localhost:5173)"[..]))
|
|
30
|
+
.unwrap();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Release modunda gömülü dosyaları işle
|
|
34
|
+
#[cfg(not(debug_assertions))]
|
|
35
|
+
{
|
|
36
|
+
let clean_path = path.trim_start_matches('/');
|
|
37
|
+
let file_path = if clean_path.is_empty() { "index.html" } else { clean_path };
|
|
38
|
+
|
|
39
|
+
match EMBEDDED_ASSETS.get_file(file_path) {
|
|
40
|
+
Some(file) => {
|
|
41
|
+
let content_type = Self::get_content_type(file_path);
|
|
42
|
+
Response::builder()
|
|
43
|
+
.status(StatusCode::OK)
|
|
44
|
+
.header("Content-Type", content_type)
|
|
45
|
+
.body(Cow::Borrowed(file.contents()))
|
|
46
|
+
.unwrap()
|
|
47
|
+
}
|
|
48
|
+
None => {
|
|
49
|
+
// SPA (Single Page Application) desteği: Dosya bulunamazsa index.html'i dön
|
|
50
|
+
if let Some(index_file) = EMBEDDED_ASSETS.get_file("index.html") {
|
|
51
|
+
Response::builder()
|
|
52
|
+
.status(StatusCode::OK)
|
|
53
|
+
.header("Content-Type", "text/html")
|
|
54
|
+
.body(Cow::Borrowed(index_file.contents()))
|
|
55
|
+
.unwrap()
|
|
56
|
+
} else {
|
|
57
|
+
Response::builder()
|
|
58
|
+
.status(StatusCode::NOT_FOUND)
|
|
59
|
+
.body(Cow::Borrowed(&b"404 Not Found"[..]))
|
|
60
|
+
.unwrap()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Burası teknik olarak unreachable ancak derleyiciyi tatmin etmek için
|
|
67
|
+
#[cfg(debug_assertions)]
|
|
68
|
+
Response::builder().status(StatusCode::NOT_FOUND).body(Cow::Borrowed(&b"Not Found"[..])).unwrap()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn get_content_type(file_path: &str) -> &'static str {
|
|
72
|
+
let path = std::path::Path::new(file_path);
|
|
73
|
+
match path.extension().and_then(|s| s.to_str()) {
|
|
74
|
+
Some("html") => "text/html",
|
|
75
|
+
Some("css") => "text/css",
|
|
76
|
+
Some("js") => "application/javascript",
|
|
77
|
+
Some("json") => "application/json",
|
|
78
|
+
Some("svg") => "image/svg+xml",
|
|
79
|
+
Some("png") => "image/png",
|
|
80
|
+
Some("jpg") | Some("jpeg") => "image/jpeg",
|
|
81
|
+
Some("gif") => "image/gif",
|
|
82
|
+
Some("woff") => "font/woff",
|
|
83
|
+
Some("woff2") => "font/woff2",
|
|
84
|
+
_ => "application/octet-stream",
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -51,6 +51,11 @@ pub async fn copy_template(project_name: &str, dest_path: &str, template: &str)
|
|
|
51
51
|
if Path::new(&backend_cargo_path).exists() {
|
|
52
52
|
let mut content = fs::read_to_string(&backend_cargo_path)?;
|
|
53
53
|
content = content.replace("my-ionyx-app", project_name);
|
|
54
|
+
// Use local path dependency to avoid Git repository path issues
|
|
55
|
+
content = content.replace(
|
|
56
|
+
"ionyx = { path = \"../../../../../../src-ionyx\" }",
|
|
57
|
+
"ionyx = { path = \"../../../src-ionyx\" }"
|
|
58
|
+
);
|
|
54
59
|
fs::write(&backend_cargo_path, content)?;
|
|
55
60
|
}
|
|
56
61
|
|