@ionyx-apps/cli 0.4.7 → 0.4.8
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/index.html +3 -2
- package/ionyx-cli/src/templates/basic/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/basic/src/App.tsx +14 -0
- 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/react/index.html +1 -0
- package/ionyx-cli/src/templates/react/ionyx-bridge.js +100 -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/vanilla/index.html +1 -0
- package/ionyx-cli/src/templates/vanilla/ionyx-bridge.js +100 -0
- package/ionyx-cli/src/templates/vue/index.html +1 -0
- package/ionyx-cli/src/templates/vue/ionyx-bridge.js +100 -0
- package/package.json +1 -1
package/bin/ionyx.exe
CHANGED
|
Binary file
|
|
@@ -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.");
|
|
@@ -52,7 +52,21 @@ function App() {
|
|
|
52
52
|
setWebGpuSupported(false)
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
// Test IPC communication
|
|
57
|
+
const testIPC = async () => {
|
|
58
|
+
try {
|
|
59
|
+
const info = await window.ionyx.invoke("app.getVersion")
|
|
60
|
+
setMessage("Hello from Ionyx Framework! 🚀")
|
|
61
|
+
console.log("IPC Response:", info)
|
|
62
|
+
} catch (error) {
|
|
63
|
+
setMessage("Error connecting to backend")
|
|
64
|
+
console.error("IPC Error:", error)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
checkWebGPU()
|
|
69
|
+
testIPC()
|
|
56
70
|
}, [])
|
|
57
71
|
|
|
58
72
|
return (
|
|
@@ -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.");
|
|
@@ -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.");
|
|
@@ -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.");
|
|
@@ -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.");
|
|
@@ -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.");
|