fluxy-bot 0.2.23 → 0.2.25
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/cli.js +21 -3
- package/package.json +1 -1
- package/supervisor/vite-dev.ts +28 -0
- package/vite.config.ts +11 -0
- package/vite.fluxy.config.ts +14 -0
package/bin/cli.js
CHANGED
|
@@ -219,6 +219,10 @@ function bootServer() {
|
|
|
219
219
|
let resolved = false;
|
|
220
220
|
let stderrBuf = '';
|
|
221
221
|
|
|
222
|
+
// Vite warmup tracking
|
|
223
|
+
let viteWarmResolve;
|
|
224
|
+
const viteWarm = new Promise((r) => { viteWarmResolve = r; });
|
|
225
|
+
|
|
222
226
|
const doResolve = () => {
|
|
223
227
|
if (resolved) return;
|
|
224
228
|
resolved = true;
|
|
@@ -227,6 +231,7 @@ function bootServer() {
|
|
|
227
231
|
child,
|
|
228
232
|
tunnelUrl: tunnelUrl || `http://localhost:${config.port}`,
|
|
229
233
|
relayUrl: relayUrl || config.relay?.url || null,
|
|
234
|
+
viteWarm,
|
|
230
235
|
});
|
|
231
236
|
};
|
|
232
237
|
|
|
@@ -239,6 +244,10 @@ function bootServer() {
|
|
|
239
244
|
const relayMatch = text.match(/__RELAY_URL__=(\S+)/);
|
|
240
245
|
if (relayMatch) relayUrl = relayMatch[1];
|
|
241
246
|
|
|
247
|
+
if (text.includes('__VITE_WARM__')) {
|
|
248
|
+
viteWarmResolve();
|
|
249
|
+
}
|
|
250
|
+
|
|
242
251
|
if (tunnelUrl && relayUrl) {
|
|
243
252
|
doResolve();
|
|
244
253
|
return;
|
|
@@ -284,6 +293,7 @@ async function init() {
|
|
|
284
293
|
'Installing cloudflared',
|
|
285
294
|
'Starting server',
|
|
286
295
|
'Connecting tunnel',
|
|
296
|
+
'Preparing dashboard',
|
|
287
297
|
];
|
|
288
298
|
|
|
289
299
|
const stepper = new Stepper(steps);
|
|
@@ -307,7 +317,11 @@ async function init() {
|
|
|
307
317
|
console.error(` ${c.dim}${err.message}${c.reset}\n`);
|
|
308
318
|
process.exit(1);
|
|
309
319
|
}
|
|
310
|
-
const { child, tunnelUrl, relayUrl } = result;
|
|
320
|
+
const { child, tunnelUrl, relayUrl, viteWarm } = result;
|
|
321
|
+
stepper.advance();
|
|
322
|
+
|
|
323
|
+
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
324
|
+
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|
|
311
325
|
stepper.advance();
|
|
312
326
|
|
|
313
327
|
stepper.finish();
|
|
@@ -330,7 +344,7 @@ async function start() {
|
|
|
330
344
|
|
|
331
345
|
banner();
|
|
332
346
|
|
|
333
|
-
const steps = ['Loading config', 'Starting server', 'Connecting tunnel'];
|
|
347
|
+
const steps = ['Loading config', 'Starting server', 'Connecting tunnel', 'Preparing dashboard'];
|
|
334
348
|
const stepper = new Stepper(steps);
|
|
335
349
|
stepper.start();
|
|
336
350
|
|
|
@@ -346,7 +360,11 @@ async function start() {
|
|
|
346
360
|
console.error(` ${c.dim}${err.message}${c.reset}\n`);
|
|
347
361
|
process.exit(1);
|
|
348
362
|
}
|
|
349
|
-
const { child, tunnelUrl, relayUrl } = result;
|
|
363
|
+
const { child, tunnelUrl, relayUrl, viteWarm } = result;
|
|
364
|
+
stepper.advance();
|
|
365
|
+
|
|
366
|
+
// Wait for Vite to finish pre-transforming all modules (with timeout)
|
|
367
|
+
await Promise.race([viteWarm, new Promise(r => setTimeout(r, 30_000))]);
|
|
350
368
|
stepper.advance();
|
|
351
369
|
|
|
352
370
|
stepper.finish();
|
package/package.json
CHANGED
package/supervisor/vite-dev.ts
CHANGED
|
@@ -60,6 +60,34 @@ export async function startViteDevServers(supervisorPort: number): Promise<{ das
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
log.ok(`Vite HMR active — dashboard :${ports.dashboard}, fluxy :${ports.fluxy}`);
|
|
63
|
+
|
|
64
|
+
// Warm up: fetch entry pages so Vite pre-transforms all modules
|
|
65
|
+
// This runs in the background — the server is already listening
|
|
66
|
+
Promise.all([
|
|
67
|
+
fetch(`http://127.0.0.1:${ports.dashboard}/`).then(r => r.text()),
|
|
68
|
+
fetch(`http://127.0.0.1:${ports.fluxy}/fluxy/fluxy.html`).then(r => r.text()),
|
|
69
|
+
fetch(`http://127.0.0.1:${ports.fluxy}/fluxy/onboard.html`).then(r => r.text()),
|
|
70
|
+
]).then(async ([dashHtml, fluxyHtml, onboardHtml]) => {
|
|
71
|
+
// Parse script entries and fetch them to trigger full module graph transformation
|
|
72
|
+
const scriptRe = /src="([^"]+\.tsx)"/g;
|
|
73
|
+
const fetches: Promise<any>[] = [];
|
|
74
|
+
for (const [html, port, base] of [
|
|
75
|
+
[dashHtml, ports.dashboard, ''],
|
|
76
|
+
[fluxyHtml, ports.fluxy, '/fluxy'],
|
|
77
|
+
[onboardHtml, ports.fluxy, '/fluxy'],
|
|
78
|
+
] as [string, number, string][]) {
|
|
79
|
+
let m;
|
|
80
|
+
while ((m = scriptRe.exec(html)) !== null) {
|
|
81
|
+
const url = `http://127.0.0.1:${port}${base}${m[1].startsWith('/') ? '' : '/'}${m[1]}`;
|
|
82
|
+
fetches.push(fetch(url).then(r => r.text()).catch(() => {}));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
await Promise.all(fetches);
|
|
86
|
+
console.log('__VITE_WARM__');
|
|
87
|
+
}).catch(() => {
|
|
88
|
+
console.log('__VITE_WARM__');
|
|
89
|
+
});
|
|
90
|
+
|
|
63
91
|
return ports;
|
|
64
92
|
}
|
|
65
93
|
|
package/vite.config.ts
CHANGED
|
@@ -17,9 +17,20 @@ export default defineConfig({
|
|
|
17
17
|
proxy: {
|
|
18
18
|
'/api': 'http://localhost:3000',
|
|
19
19
|
},
|
|
20
|
+
warmup: {
|
|
21
|
+
clientFiles: ['./src/main.tsx'],
|
|
22
|
+
},
|
|
20
23
|
},
|
|
21
24
|
optimizeDeps: {
|
|
22
25
|
include: [
|
|
26
|
+
'react',
|
|
27
|
+
'react-dom/client',
|
|
28
|
+
'react/jsx-runtime',
|
|
29
|
+
'lucide-react',
|
|
30
|
+
'framer-motion',
|
|
31
|
+
'recharts',
|
|
32
|
+
'zustand',
|
|
33
|
+
'sonner',
|
|
23
34
|
'use-sync-external-store',
|
|
24
35
|
'use-sync-external-store/shim',
|
|
25
36
|
],
|
package/vite.fluxy.config.ts
CHANGED
|
@@ -19,8 +19,22 @@ export default defineConfig({
|
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
+
server: {
|
|
23
|
+
warmup: {
|
|
24
|
+
clientFiles: ['./fluxy-main.tsx', './onboard-main.tsx'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
22
27
|
optimizeDeps: {
|
|
23
28
|
include: [
|
|
29
|
+
'react',
|
|
30
|
+
'react-dom/client',
|
|
31
|
+
'react/jsx-runtime',
|
|
32
|
+
'lucide-react',
|
|
33
|
+
'framer-motion',
|
|
34
|
+
'react-markdown',
|
|
35
|
+
'remark-gfm',
|
|
36
|
+
'react-syntax-highlighter',
|
|
37
|
+
'react-syntax-highlighter/dist/esm/styles/prism/one-dark',
|
|
24
38
|
'use-sync-external-store',
|
|
25
39
|
'use-sync-external-store/shim',
|
|
26
40
|
],
|