@zap-js/client 0.1.4 → 0.1.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.
- package/dist/cli/commands/serve.js +36 -0
- package/package.json +4 -4
|
@@ -76,6 +76,22 @@ export async function serveCommand(options) {
|
|
|
76
76
|
process.exit(1);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Wait for Rust server to create RPC socket file
|
|
81
|
+
*/
|
|
82
|
+
async function waitForRpcSocket(socketPath) {
|
|
83
|
+
const rpcSocketPath = socketPath + '.rpc';
|
|
84
|
+
const maxWait = 10000; // 10 seconds
|
|
85
|
+
const checkInterval = 100; // 100ms
|
|
86
|
+
const startTime = Date.now();
|
|
87
|
+
while (Date.now() - startTime < maxWait) {
|
|
88
|
+
if (existsSync(rpcSocketPath)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await new Promise(resolve => setTimeout(resolve, checkInterval));
|
|
92
|
+
}
|
|
93
|
+
throw new Error(`RPC socket not ready within ${maxWait}ms`);
|
|
94
|
+
}
|
|
79
95
|
async function runProductionServer(binPath, options, workDir, prodConfig) {
|
|
80
96
|
const port = parseInt(options.port || prodConfig?.server?.port?.toString() || '3000');
|
|
81
97
|
const host = options.host || prodConfig?.server?.host || '0.0.0.0';
|
|
@@ -143,6 +159,26 @@ async function runProductionServer(binPath, options, workDir, prodConfig) {
|
|
|
143
159
|
ZAP_ENV: 'production',
|
|
144
160
|
},
|
|
145
161
|
});
|
|
162
|
+
// Wait for Rust server to create RPC socket, then initialize RPC client
|
|
163
|
+
cliLogger.spinner('rpc', 'Waiting for RPC server...');
|
|
164
|
+
try {
|
|
165
|
+
await waitForRpcSocket(socketPath);
|
|
166
|
+
// Initialize RPC client for bidirectional IPC communication
|
|
167
|
+
// This allows TypeScript route handlers to call Rust functions via rpc.call()
|
|
168
|
+
const { initRpcClient } = await import('../../runtime/rpc-client.js');
|
|
169
|
+
await initRpcClient(socketPath + '.rpc');
|
|
170
|
+
cliLogger.succeedSpinner('rpc', 'RPC client connected');
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
cliLogger.failSpinner('rpc', 'Failed to connect RPC client');
|
|
174
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
175
|
+
cliLogger.error(message);
|
|
176
|
+
cleanup(ipcServer, tempConfigPath);
|
|
177
|
+
if (!rustProcess.killed) {
|
|
178
|
+
rustProcess.kill();
|
|
179
|
+
}
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
146
182
|
let started = false;
|
|
147
183
|
rustProcess.stdout?.on('data', (data) => {
|
|
148
184
|
const output = data.toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zap-js/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "High-performance fullstack React framework - Client package",
|
|
5
5
|
"homepage": "https://github.com/saint0x/zapjs",
|
|
6
6
|
"repository": {
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"ws": "^8.16.0"
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
|
-
"@zap-js/darwin-arm64": "0.1.
|
|
78
|
-
"@zap-js/darwin-x64": "0.1.
|
|
79
|
-
"@zap-js/linux-x64": "0.1.
|
|
77
|
+
"@zap-js/darwin-arm64": "0.1.6",
|
|
78
|
+
"@zap-js/darwin-x64": "0.1.6",
|
|
79
|
+
"@zap-js/linux-x64": "0.1.6"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"react": "^18.0.0",
|