@ionyx-apps/cli 0.4.7 → 0.4.9
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/angular/src-ionyx/Cargo.toml +30 -0
- package/ionyx-cli/src/templates/angular/src-ionyx/build.rs +5 -0
- package/ionyx-cli/src/templates/angular/src-ionyx/main.rs +48 -0
- package/ionyx-cli/src/templates/angular/src-ionyx/src/lib.rs +267 -0
- package/ionyx-cli/src/templates/basic/index.html +3 -2
- package/ionyx-cli/src/templates/basic/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/basic/ionyx.config.json +3 -0
- package/ionyx-cli/src/templates/basic/package.json +6 -1
- package/ionyx-cli/src/templates/basic/src/App.tsx +14 -0
- package/ionyx-cli/src/templates/basic/src-ionyx/Cargo.toml +14 -12
- package/ionyx-cli/src/templates/basic/src-ionyx/main.rs +46 -3
- package/ionyx-cli/src/templates/leptos/index.html +2 -1
- package/ionyx-cli/src/templates/leptos/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/leptos/package.json +6 -1
- package/ionyx-cli/src/templates/leptos/src-ionyx/Cargo.toml +14 -8
- package/ionyx-cli/src/templates/leptos/src-ionyx/main.rs +46 -3
- package/ionyx-cli/src/templates/mod.rs +1 -5
- package/ionyx-cli/src/templates/react/index.html +1 -0
- package/ionyx-cli/src/templates/react/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/react/ionyx.config.json +4 -1
- package/ionyx-cli/src/templates/react/package.json +6 -1
- package/ionyx-cli/src/templates/react/src-ionyx/Cargo.toml +14 -12
- package/ionyx-cli/src/templates/react/src-ionyx/main.rs +46 -3
- package/ionyx-cli/src/templates/src-ionyx/Cargo.toml +15 -5
- package/ionyx-cli/src/templates/src-ionyx/bridge.rs +380 -0
- package/ionyx-cli/src/templates/src-ionyx/fusion.rs +47 -0
- package/ionyx-cli/src/templates/src-ionyx/ionyx.js +100 -0
- package/ionyx-cli/src/templates/src-ionyx/ipc_bridge.rs +206 -0
- package/ionyx-cli/src/templates/src-ionyx/lib.rs +204 -114
- package/ionyx-cli/src/templates/src-ionyx/main.rs +268 -3
- package/ionyx-cli/src/templates/src-ionyx/protocol.rs +98 -0
- package/ionyx-cli/src/templates/src-ionyx/window.rs +13 -0
- package/ionyx-cli/src/templates/svelte/index.html +1 -0
- package/ionyx-cli/src/templates/svelte/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/svelte/package.json +6 -1
- package/ionyx-cli/src/templates/svelte/src-ionyx/Cargo.toml +14 -12
- package/ionyx-cli/src/templates/svelte/src-ionyx/main.rs +46 -3
- package/ionyx-cli/src/templates/vanilla/index.html +1 -0
- package/ionyx-cli/src/templates/vanilla/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/vanilla/ionyx.config.json +3 -0
- package/ionyx-cli/src/templates/vanilla/package.json +6 -1
- package/ionyx-cli/src/templates/vanilla/src-ionyx/Cargo.toml +14 -12
- package/ionyx-cli/src/templates/vanilla/src-ionyx/main.rs +46 -3
- package/ionyx-cli/src/templates/vue/index.html +1 -0
- package/ionyx-cli/src/templates/vue/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/vue/ionyx.config.json +4 -1
- package/ionyx-cli/src/templates/vue/package.json +6 -1
- package/ionyx-cli/src/templates/vue/src-ionyx/Cargo.toml +14 -12
- package/ionyx-cli/src/templates/vue/src-ionyx/main.rs +46 -3
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Ionyx IPC Bridge JavaScript
|
|
2
|
+
(function() {
|
|
3
|
+
const _promises = {};
|
|
4
|
+
let _fusion_data = {};
|
|
5
|
+
|
|
6
|
+
window.ionyx = {
|
|
7
|
+
_promises,
|
|
8
|
+
_fusion_sync: (data) => {
|
|
9
|
+
console.log("🧬 Fusion Sync:", data);
|
|
10
|
+
_fusion_data = data;
|
|
11
|
+
},
|
|
12
|
+
resolveResponse: (responseId, response) => {
|
|
13
|
+
const promiseHandlers = _promises[responseId];
|
|
14
|
+
if (promiseHandlers) {
|
|
15
|
+
console.log("📥 Received IPC response:", response);
|
|
16
|
+
clearTimeout(promiseHandlers.timeoutId);
|
|
17
|
+
if (response.success) {
|
|
18
|
+
promiseHandlers.resolve(response.data);
|
|
19
|
+
} else {
|
|
20
|
+
promiseHandlers.reject(new Error(response.error));
|
|
21
|
+
}
|
|
22
|
+
delete _promises[responseId];
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
invoke: (command, payload = {}) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const id = `${Date.now()}_${Math.random().toString(36).substr(2, 9)}_${command}`;
|
|
28
|
+
const request = {
|
|
29
|
+
id,
|
|
30
|
+
command,
|
|
31
|
+
payload: payload || {}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
console.log("🚀 Sending IPC request:", request);
|
|
35
|
+
|
|
36
|
+
const timeoutId = setTimeout(() => {
|
|
37
|
+
console.error("❌ IPC request timeout for:", command);
|
|
38
|
+
reject(new Error("IPC request timeout"));
|
|
39
|
+
delete _promises[id];
|
|
40
|
+
}, 15000);
|
|
41
|
+
|
|
42
|
+
_promises[id] = { resolve, reject, timeoutId };
|
|
43
|
+
|
|
44
|
+
if (window.ipc && typeof window.ipc.postMessage === 'function') {
|
|
45
|
+
console.log("📤 Sending via window.ipc.postMessage");
|
|
46
|
+
window.ipc.postMessage(JSON.stringify(request));
|
|
47
|
+
} else {
|
|
48
|
+
console.error("❌ window.ipc not available");
|
|
49
|
+
clearTimeout(timeoutId);
|
|
50
|
+
reject(new Error("IPC not available natively through window.ipc"));
|
|
51
|
+
delete _promises[id];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Add Tauri-like namespaces
|
|
58
|
+
const invoke = window.ionyx.invoke;
|
|
59
|
+
|
|
60
|
+
window.ionyx.fs = {
|
|
61
|
+
readFile: (path) => invoke("fs.readFile", { path }),
|
|
62
|
+
writeFile: (path, content) => invoke("fs.writeFile", { path, content }),
|
|
63
|
+
exists: (path) => invoke("fs.exists", { path }),
|
|
64
|
+
readDir: (path) => invoke("fs.readdir", { path })
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
window.ionyx.os = {
|
|
68
|
+
info: () => invoke("os.info")
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
window.ionyx.dialog = {
|
|
72
|
+
openFile: () => invoke("dialog.openFile", {}),
|
|
73
|
+
saveFile: () => invoke("dialog.saveFile", {})
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
window.ionyx.app = {
|
|
77
|
+
getVersion: () => invoke("app.getVersion"),
|
|
78
|
+
getConfig: () => invoke("app.getConfig")
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
window.ionyx.network = {
|
|
82
|
+
request: (url, method = "GET", body = null) => invoke("network.request", { url, method, body })
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Inspired by NW.js Unified Context:
|
|
86
|
+
// Native Fusion allows direct access to shared state.
|
|
87
|
+
window.fusion = new Proxy({}, {
|
|
88
|
+
get: (target, prop) => {
|
|
89
|
+
return _fusion_data[prop];
|
|
90
|
+
},
|
|
91
|
+
set: (target, prop, value) => {
|
|
92
|
+
_fusion_data[prop] = value;
|
|
93
|
+
invoke("fusion.update", { key: prop, value });
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
})();
|
|
99
|
+
|
|
100
|
+
console.log("🔧 Ionyx IPC Bridge injected successfully.");
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
"build": "vite build",
|
|
9
9
|
"preview": "vite preview",
|
|
10
10
|
"ionyx:dev": "cd src-ionyx && cargo run --bin my-ionyx-app",
|
|
11
|
-
"ionyx:build": "cd src-ionyx && cargo build --release",
|
|
11
|
+
"ionyx:build": "cd src-ionyx && cargo build --release && npm run bundle:create",
|
|
12
|
+
"bundle:create": "node -e \"const fs=require('fs');const path=require('path');const dist=path.join(__dirname,'dist');if(!fs.existsSync(dist))fs.mkdirSync(dist);const target=path.join(__dirname,'src-ionyx','target','release','my-ionyx-app.exe');if(fs.existsSync(target)){const bundle=path.join(dist,'my-ionyx-app-v1.0.0.exe');fs.copyFileSync(target,bundle);console.log('✅ Bundle created:',bundle);}else{console.log('❌ Executable not found');}\"",
|
|
13
|
+
"bundle": "npm run bundle:create",
|
|
14
|
+
"bundle:windows": "npm run bundle:create",
|
|
15
|
+
"bundle:macos": "npm run bundle:create",
|
|
16
|
+
"bundle:linux": "npm run bundle:create",
|
|
12
17
|
"ionyx": "npx ionyx",
|
|
13
18
|
"ionyx:dev2": "npx ionyx dev",
|
|
14
19
|
"ionyx:build2": "npx ionyx build",
|
|
@@ -4,22 +4,24 @@ name = "my-ionyx-app"
|
|
|
4
4
|
version = "0.4.2"
|
|
5
5
|
edition = "2021"
|
|
6
6
|
|
|
7
|
-
[workspace]
|
|
8
|
-
|
|
9
|
-
[lib]
|
|
10
|
-
name = "my_ionyx_app"
|
|
11
|
-
path = "src/lib.rs"
|
|
12
|
-
|
|
13
|
-
[[bin]]
|
|
14
|
-
name = "my-ionyx-app"
|
|
15
|
-
path = "main.rs"
|
|
16
|
-
|
|
17
7
|
[dependencies]
|
|
18
8
|
include_dir = "0.7"
|
|
19
|
-
|
|
20
|
-
anyhow = "1.0"
|
|
9
|
+
# Web framework dependencies
|
|
21
10
|
wry = "0.54"
|
|
22
11
|
tao = "0.34"
|
|
12
|
+
tokio = { version = "1.50", features = ["full"] }
|
|
13
|
+
serde = { version = "1.0", features = ["derive"] }
|
|
14
|
+
serde_json = "1.0"
|
|
15
|
+
anyhow = "1.0"
|
|
16
|
+
toml = "0.8"
|
|
17
|
+
tracing = "0.1"
|
|
18
|
+
tracing-subscriber = "0.3"
|
|
19
|
+
os_info = "3"
|
|
20
|
+
gethostname = "0.4"
|
|
21
|
+
|
|
22
|
+
[[bin]]
|
|
23
|
+
name = "my-ionyx-app"
|
|
24
|
+
path = "main.rs"
|
|
23
25
|
|
|
24
26
|
[profile.release]
|
|
25
27
|
opt-level = 3
|
|
@@ -1,5 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
use ionyx::{config, security, protocol};
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
#[tokio::main]
|
|
4
|
+
async fn main() {
|
|
5
|
+
println!("🚀 Ionyx Application starting...");
|
|
6
|
+
|
|
7
|
+
// Load application configuration
|
|
8
|
+
let app_config = match config::Config::load().await {
|
|
9
|
+
Ok(config) => {
|
|
10
|
+
println!("✅ Configuration loaded successfully");
|
|
11
|
+
config
|
|
12
|
+
}
|
|
13
|
+
Err(e) => {
|
|
14
|
+
eprintln!("⚠️ Failed to load config, using defaults: {}", e);
|
|
15
|
+
config::Config::default()
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Initialize security manager for demonstration
|
|
20
|
+
let security_manager: crate::security::SecurityManager = security::SecurityManager::new(app_config.clone());
|
|
21
|
+
|
|
22
|
+
// Demonstrate comprehensive security manager functionality
|
|
23
|
+
let test_paths = ["./app-data", "/system", "../outside"];
|
|
24
|
+
for &test_path in &test_paths {
|
|
25
|
+
let is_secure = security_manager.is_path_allowed(test_path);
|
|
26
|
+
println!("🔒 Security check: '{}' -> {}",
|
|
27
|
+
test_path,
|
|
28
|
+
if is_secure { "ALLOWED" } else { "DENIED" });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Demonstrate security validation
|
|
32
|
+
if let Ok(()) = security_manager.validate_path_operation("./app-data", "read") {
|
|
33
|
+
println!("🔒 Security validation: Path operation approved");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Initialize protocol handler for demonstration
|
|
37
|
+
let _protocol_handler = protocol::CustomProtocolHandler::new();
|
|
38
|
+
println!("🌐 Protocol handler initialized");
|
|
39
|
+
|
|
40
|
+
// Create and run the Ionyx application with automatic Vite server startup
|
|
41
|
+
println!("🚀 Launching Ionyx application...");
|
|
42
|
+
let builder = ionyx::Builder::new().config(app_config);
|
|
43
|
+
|
|
44
|
+
if let Err(e) = builder.run() {
|
|
45
|
+
eprintln!("❌ Application failed to start: {}", e);
|
|
46
|
+
std::process::exit(1);
|
|
47
|
+
}
|
|
5
48
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Ionyx IPC Bridge JavaScript
|
|
2
|
+
(function() {
|
|
3
|
+
const _promises = {};
|
|
4
|
+
let _fusion_data = {};
|
|
5
|
+
|
|
6
|
+
window.ionyx = {
|
|
7
|
+
_promises,
|
|
8
|
+
_fusion_sync: (data) => {
|
|
9
|
+
console.log("🧬 Fusion Sync:", data);
|
|
10
|
+
_fusion_data = data;
|
|
11
|
+
},
|
|
12
|
+
resolveResponse: (responseId, response) => {
|
|
13
|
+
const promiseHandlers = _promises[responseId];
|
|
14
|
+
if (promiseHandlers) {
|
|
15
|
+
console.log("📥 Received IPC response:", response);
|
|
16
|
+
clearTimeout(promiseHandlers.timeoutId);
|
|
17
|
+
if (response.success) {
|
|
18
|
+
promiseHandlers.resolve(response.data);
|
|
19
|
+
} else {
|
|
20
|
+
promiseHandlers.reject(new Error(response.error));
|
|
21
|
+
}
|
|
22
|
+
delete _promises[responseId];
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
invoke: (command, payload = {}) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const id = `${Date.now()}_${Math.random().toString(36).substr(2, 9)}_${command}`;
|
|
28
|
+
const request = {
|
|
29
|
+
id,
|
|
30
|
+
command,
|
|
31
|
+
payload: payload || {}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
console.log("🚀 Sending IPC request:", request);
|
|
35
|
+
|
|
36
|
+
const timeoutId = setTimeout(() => {
|
|
37
|
+
console.error("❌ IPC request timeout for:", command);
|
|
38
|
+
reject(new Error("IPC request timeout"));
|
|
39
|
+
delete _promises[id];
|
|
40
|
+
}, 15000);
|
|
41
|
+
|
|
42
|
+
_promises[id] = { resolve, reject, timeoutId };
|
|
43
|
+
|
|
44
|
+
if (window.ipc && typeof window.ipc.postMessage === 'function') {
|
|
45
|
+
console.log("📤 Sending via window.ipc.postMessage");
|
|
46
|
+
window.ipc.postMessage(JSON.stringify(request));
|
|
47
|
+
} else {
|
|
48
|
+
console.error("❌ window.ipc not available");
|
|
49
|
+
clearTimeout(timeoutId);
|
|
50
|
+
reject(new Error("IPC not available natively through window.ipc"));
|
|
51
|
+
delete _promises[id];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Add Tauri-like namespaces
|
|
58
|
+
const invoke = window.ionyx.invoke;
|
|
59
|
+
|
|
60
|
+
window.ionyx.fs = {
|
|
61
|
+
readFile: (path) => invoke("fs.readFile", { path }),
|
|
62
|
+
writeFile: (path, content) => invoke("fs.writeFile", { path, content }),
|
|
63
|
+
exists: (path) => invoke("fs.exists", { path }),
|
|
64
|
+
readDir: (path) => invoke("fs.readdir", { path })
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
window.ionyx.os = {
|
|
68
|
+
info: () => invoke("os.info")
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
window.ionyx.dialog = {
|
|
72
|
+
openFile: () => invoke("dialog.openFile", {}),
|
|
73
|
+
saveFile: () => invoke("dialog.saveFile", {})
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
window.ionyx.app = {
|
|
77
|
+
getVersion: () => invoke("app.getVersion"),
|
|
78
|
+
getConfig: () => invoke("app.getConfig")
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
window.ionyx.network = {
|
|
82
|
+
request: (url, method = "GET", body = null) => invoke("network.request", { url, method, body })
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Inspired by NW.js Unified Context:
|
|
86
|
+
// Native Fusion allows direct access to shared state.
|
|
87
|
+
window.fusion = new Proxy({}, {
|
|
88
|
+
get: (target, prop) => {
|
|
89
|
+
return _fusion_data[prop];
|
|
90
|
+
},
|
|
91
|
+
set: (target, prop, value) => {
|
|
92
|
+
_fusion_data[prop] = value;
|
|
93
|
+
invoke("fusion.update", { key: prop, value });
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
})();
|
|
99
|
+
|
|
100
|
+
console.log("🔧 Ionyx IPC Bridge injected successfully.");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "{{PROJECT_NAME}}",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"description": "Ionyx Framework
|
|
4
|
+
"description": "Vue + TypeScript + Vite application with Ionyx Framework",
|
|
5
5
|
"type": "app",
|
|
6
6
|
"src": "src",
|
|
7
7
|
"dist": "dist",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dev": {
|
|
15
15
|
"port": 5173,
|
|
16
|
+
"host": "127.0.0.1",
|
|
17
|
+
"beforeDevCommand": "npm run dev",
|
|
18
|
+
"devUrl": "http://127.0.0.1:5173",
|
|
16
19
|
"hot": true
|
|
17
20
|
},
|
|
18
21
|
"build": {
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
"build": "vite build",
|
|
9
9
|
"preview": "vite preview",
|
|
10
10
|
"ionyx:dev": "cd src-ionyx && cargo run --bin my-ionyx-app",
|
|
11
|
-
"ionyx:build": "cd src-ionyx && cargo build --release",
|
|
11
|
+
"ionyx:build": "cd src-ionyx && cargo build --release && npm run bundle:create",
|
|
12
|
+
"bundle:create": "node -e \"const fs=require('fs');const path=require('path');const dist=path.join(__dirname,'dist');if(!fs.existsSync(dist))fs.mkdirSync(dist);const target=path.join(__dirname,'src-ionyx','target','release','my-ionyx-app.exe');if(fs.existsSync(target)){const bundle=path.join(dist,'my-ionyx-app-v1.0.0.exe');fs.copyFileSync(target,bundle);console.log('✅ Bundle created:',bundle);}else{console.log('❌ Executable not found');}\"",
|
|
13
|
+
"bundle": "npm run bundle:create",
|
|
14
|
+
"bundle:windows": "npm run bundle:create",
|
|
15
|
+
"bundle:macos": "npm run bundle:create",
|
|
16
|
+
"bundle:linux": "npm run bundle:create",
|
|
12
17
|
"ionyx": "npx ionyx",
|
|
13
18
|
"ionyx:dev2": "npx ionyx dev",
|
|
14
19
|
"ionyx:build2": "npx ionyx build",
|
|
@@ -4,22 +4,24 @@ name = "my-ionyx-app"
|
|
|
4
4
|
version = "0.4.2"
|
|
5
5
|
edition = "2021"
|
|
6
6
|
|
|
7
|
-
[workspace]
|
|
8
|
-
|
|
9
|
-
[lib]
|
|
10
|
-
name = "my_ionyx_app"
|
|
11
|
-
path = "src/lib.rs"
|
|
12
|
-
|
|
13
|
-
[[bin]]
|
|
14
|
-
name = "my-ionyx-app"
|
|
15
|
-
path = "main.rs"
|
|
16
|
-
|
|
17
7
|
[dependencies]
|
|
18
8
|
include_dir = "0.7"
|
|
19
|
-
|
|
20
|
-
anyhow = "1.0"
|
|
9
|
+
# Web framework dependencies
|
|
21
10
|
wry = "0.54"
|
|
22
11
|
tao = "0.34"
|
|
12
|
+
tokio = { version = "1.50", features = ["full"] }
|
|
13
|
+
serde = { version = "1.0", features = ["derive"] }
|
|
14
|
+
serde_json = "1.0"
|
|
15
|
+
anyhow = "1.0"
|
|
16
|
+
toml = "0.8"
|
|
17
|
+
tracing = "0.1"
|
|
18
|
+
tracing-subscriber = "0.3"
|
|
19
|
+
os_info = "3"
|
|
20
|
+
gethostname = "0.4"
|
|
21
|
+
|
|
22
|
+
[[bin]]
|
|
23
|
+
name = "my-ionyx-app"
|
|
24
|
+
path = "main.rs"
|
|
23
25
|
|
|
24
26
|
[profile.release]
|
|
25
27
|
opt-level = 3
|
|
@@ -1,5 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
use ionyx::{config, security, protocol};
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
#[tokio::main]
|
|
4
|
+
async fn main() {
|
|
5
|
+
println!("🚀 Ionyx Application starting...");
|
|
6
|
+
|
|
7
|
+
// Load application configuration
|
|
8
|
+
let app_config = match config::Config::load().await {
|
|
9
|
+
Ok(config) => {
|
|
10
|
+
println!("✅ Configuration loaded successfully");
|
|
11
|
+
config
|
|
12
|
+
}
|
|
13
|
+
Err(e) => {
|
|
14
|
+
eprintln!("⚠️ Failed to load config, using defaults: {}", e);
|
|
15
|
+
config::Config::default()
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Initialize security manager for demonstration
|
|
20
|
+
let security_manager: crate::security::SecurityManager = security::SecurityManager::new(app_config.clone());
|
|
21
|
+
|
|
22
|
+
// Demonstrate comprehensive security manager functionality
|
|
23
|
+
let test_paths = ["./app-data", "/system", "../outside"];
|
|
24
|
+
for &test_path in &test_paths {
|
|
25
|
+
let is_secure = security_manager.is_path_allowed(test_path);
|
|
26
|
+
println!("🔒 Security check: '{}' -> {}",
|
|
27
|
+
test_path,
|
|
28
|
+
if is_secure { "ALLOWED" } else { "DENIED" });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Demonstrate security validation
|
|
32
|
+
if let Ok(()) = security_manager.validate_path_operation("./app-data", "read") {
|
|
33
|
+
println!("🔒 Security validation: Path operation approved");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Initialize protocol handler for demonstration
|
|
37
|
+
let _protocol_handler = protocol::CustomProtocolHandler::new();
|
|
38
|
+
println!("🌐 Protocol handler initialized");
|
|
39
|
+
|
|
40
|
+
// Create and run the Ionyx application with automatic Vite server startup
|
|
41
|
+
println!("🚀 Launching Ionyx application...");
|
|
42
|
+
let builder = ionyx::Builder::new().config(app_config);
|
|
43
|
+
|
|
44
|
+
if let Err(e) = builder.run() {
|
|
45
|
+
eprintln!("❌ Application failed to start: {}", e);
|
|
46
|
+
std::process::exit(1);
|
|
47
|
+
}
|
|
5
48
|
}
|