nstantpage-agent 0.3.1 → 0.3.3
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/commands/start.js +20 -4
- package/dist/devServer.js +1 -1
- package/dist/tunnel.d.ts +7 -0
- package/dist/tunnel.js +19 -1
- package/package.json +1 -1
package/dist/commands/start.js
CHANGED
|
@@ -226,15 +226,31 @@ export async function startCommand(directory, options) {
|
|
|
226
226
|
else {
|
|
227
227
|
console.log(chalk.gray(' Dev server skipped (--no-dev)'));
|
|
228
228
|
}
|
|
229
|
-
// Connect tunnel to gateway
|
|
229
|
+
// Connect tunnel to gateway (non-fatal — dev server keeps running even if tunnel fails)
|
|
230
230
|
console.log(chalk.gray(' Connecting to gateway...'));
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
let tunnelConnected = false;
|
|
232
|
+
try {
|
|
233
|
+
await tunnel.connect();
|
|
234
|
+
tunnelConnected = true;
|
|
235
|
+
console.log(chalk.green(` ✓ Tunnel connected\n`));
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
console.log(chalk.yellow(` ⚠ Tunnel connection failed: ${err.message || 'connection refused'}`));
|
|
239
|
+
console.log(chalk.gray(' Local dev server is still running. Tunnel will retry in background.'));
|
|
240
|
+
console.log(chalk.gray(` Is the gateway running at ${options.gateway}?\n`));
|
|
241
|
+
// Start background reconnection
|
|
242
|
+
tunnel.startBackgroundReconnect();
|
|
243
|
+
}
|
|
233
244
|
// Display status
|
|
234
245
|
console.log(chalk.blue.bold(` ┌──────────────────────────────────────────────┐`));
|
|
235
246
|
console.log(chalk.blue.bold(` │ Your project is live! │`));
|
|
236
247
|
console.log(chalk.blue.bold(` ├──────────────────────────────────────────────┤`));
|
|
237
|
-
|
|
248
|
+
if (tunnelConnected) {
|
|
249
|
+
console.log(chalk.white(` │ Cloud: https://${projectId}.webprev.live`));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
console.log(chalk.yellow(` │ Cloud: ⏳ waiting for tunnel...`));
|
|
253
|
+
}
|
|
238
254
|
console.log(chalk.white(` │ Local: http://localhost:${devPort}`));
|
|
239
255
|
console.log(chalk.white(` │ Files: ${projectDir}`));
|
|
240
256
|
console.log(chalk.blue.bold(` └──────────────────────────────────────────────┘\n`));
|
package/dist/devServer.js
CHANGED
|
@@ -54,7 +54,7 @@ export class DevServer {
|
|
|
54
54
|
this.startedAt = Date.now();
|
|
55
55
|
// Start backend if present
|
|
56
56
|
if (hasBackend) {
|
|
57
|
-
const backendPort = port +
|
|
57
|
+
const backendPort = port + 1001; // 3000 → 4001 (avoids gateway port 4000)
|
|
58
58
|
const backendEntry = fs.existsSync(path.join(projectDir, 'server', 'index.ts'))
|
|
59
59
|
? 'server/index.ts'
|
|
60
60
|
: 'server/index.js';
|
package/dist/tunnel.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ export declare class TunnelClient {
|
|
|
42
42
|
uptime: number;
|
|
43
43
|
};
|
|
44
44
|
connect(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Start reconnecting in the background (non-blocking).
|
|
47
|
+
* Used when initial connect() fails so the dev server can keep running.
|
|
48
|
+
* The close handler from the failed connect() already schedules a reconnect,
|
|
49
|
+
* so we just ensure shouldReconnect is true and don't duplicate.
|
|
50
|
+
*/
|
|
51
|
+
startBackgroundReconnect(): void;
|
|
45
52
|
disconnect(): void;
|
|
46
53
|
/**
|
|
47
54
|
* Push an error update to the gateway (for WebSocket error notifications).
|
package/dist/tunnel.js
CHANGED
|
@@ -58,7 +58,7 @@ export class TunnelClient {
|
|
|
58
58
|
// Send enhanced agent info with capabilities
|
|
59
59
|
this.send({
|
|
60
60
|
type: 'agent-info',
|
|
61
|
-
version: '0.2
|
|
61
|
+
version: '0.3.2',
|
|
62
62
|
hostname: os.hostname(),
|
|
63
63
|
platform: `${os.platform()} ${os.arch()}`,
|
|
64
64
|
capabilities: [
|
|
@@ -103,6 +103,21 @@ export class TunnelClient {
|
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Start reconnecting in the background (non-blocking).
|
|
108
|
+
* Used when initial connect() fails so the dev server can keep running.
|
|
109
|
+
* The close handler from the failed connect() already schedules a reconnect,
|
|
110
|
+
* so we just ensure shouldReconnect is true and don't duplicate.
|
|
111
|
+
*/
|
|
112
|
+
startBackgroundReconnect() {
|
|
113
|
+
this.shouldReconnect = true;
|
|
114
|
+
// Only kick off a reconnect if there isn't one already pending
|
|
115
|
+
// (the close handler from the failed connect() already scheduled one)
|
|
116
|
+
if (!this.reconnectTimer) {
|
|
117
|
+
this.reconnectAttempts = 0;
|
|
118
|
+
this.scheduleReconnect();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
106
121
|
disconnect() {
|
|
107
122
|
this.shouldReconnect = false;
|
|
108
123
|
this.cleanup();
|
|
@@ -226,6 +241,8 @@ export class TunnelClient {
|
|
|
226
241
|
scheduleReconnect() {
|
|
227
242
|
if (!this.shouldReconnect)
|
|
228
243
|
return;
|
|
244
|
+
if (this.reconnectTimer)
|
|
245
|
+
return; // Already have a pending reconnect
|
|
229
246
|
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
230
247
|
console.error(' [Tunnel] Max reconnect attempts reached. Giving up.');
|
|
231
248
|
return;
|
|
@@ -234,6 +251,7 @@ export class TunnelClient {
|
|
|
234
251
|
this.reconnectAttempts++;
|
|
235
252
|
console.log(` [Tunnel] Reconnecting in ${delay / 1000}s (attempt ${this.reconnectAttempts})...`);
|
|
236
253
|
this.reconnectTimer = setTimeout(async () => {
|
|
254
|
+
this.reconnectTimer = null; // Clear so next scheduleReconnect can fire
|
|
237
255
|
try {
|
|
238
256
|
await this.connect();
|
|
239
257
|
console.log(' [Tunnel] Reconnected!');
|
package/package.json
CHANGED