vibelet 0.1.33 → 0.1.35
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/vibelet.cjs +12 -0
- package/bin/vibelet.mjs +32 -16
- package/dist/index.cjs +45 -43
- package/package.json +3 -3
- package/bin/vibelet +0 -4
package/bin/vibelet.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { realpathSync } = require('node:fs');
|
|
4
|
+
const { dirname, join } = require('node:path');
|
|
5
|
+
const { pathToFileURL } = require('node:url');
|
|
6
|
+
|
|
7
|
+
const entryPath = join(dirname(realpathSync(__filename)), 'vibelet.mjs');
|
|
8
|
+
|
|
9
|
+
import(pathToFileURL(entryPath).href).catch((error) => {
|
|
10
|
+
console.error(error);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
package/bin/vibelet.mjs
CHANGED
|
@@ -18,6 +18,7 @@ const daemonDistDir = resolve(rootDir, 'dist');
|
|
|
18
18
|
const daemonEntryPath = resolve(daemonDistDir, 'index.cjs');
|
|
19
19
|
const port = Number(process.env.VIBE_PORT) || 9876;
|
|
20
20
|
const vibeletDir = join(homedir(), '.vibelet');
|
|
21
|
+
const pairingQrPngPath = join(vibeletDir, 'pairing-qr.png');
|
|
21
22
|
const logDir = join(vibeletDir, 'logs');
|
|
22
23
|
const runtimeDir = join(vibeletDir, 'runtime');
|
|
23
24
|
const runtimeCurrentDir = join(runtimeDir, 'current');
|
|
@@ -584,20 +585,7 @@ async function stopRunningDaemon(backend) {
|
|
|
584
585
|
}
|
|
585
586
|
}
|
|
586
587
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
async function printPairingSummary(existingHealth = null) {
|
|
590
|
-
const health = existingHealth ?? await waitForHealth();
|
|
591
|
-
const pairingPayload = await postJson('/pair/open');
|
|
592
|
-
|
|
593
|
-
process.stdout.write(`Vibelet daemon is ready.\n\n`);
|
|
594
|
-
process.stdout.write(`Device: ${health.displayName}\n`);
|
|
595
|
-
process.stdout.write(`Daemon ID: ${health.daemonId}\n`);
|
|
596
|
-
process.stdout.write(`Host: ${pairingPayload.canonicalHost}\n`);
|
|
597
|
-
process.stdout.write(`Port: ${pairingPayload.port}\n`);
|
|
598
|
-
process.stdout.write(`Paired devices: ${health.pairedDevices}\n`);
|
|
599
|
-
|
|
600
|
-
// Use compact keys to keep QR code small
|
|
588
|
+
function createCompactPairingPayload(pairingPayload) {
|
|
601
589
|
const compactPayload = {
|
|
602
590
|
t: 'vp',
|
|
603
591
|
d: pairingPayload.daemonId,
|
|
@@ -608,12 +596,40 @@ async function printPairingSummary(existingHealth = null) {
|
|
|
608
596
|
e: pairingPayload.expiresAt,
|
|
609
597
|
};
|
|
610
598
|
if (pairingPayload.fallbackHosts) compactPayload.f = pairingPayload.fallbackHosts;
|
|
611
|
-
|
|
599
|
+
return compactPayload;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async function printPairingQr(pairingPayload) {
|
|
603
|
+
const payload = JSON.stringify(createCompactPairingPayload(pairingPayload));
|
|
604
|
+
mkdirSync(vibeletDir, { recursive: true });
|
|
605
|
+
await QRCode.toFile(pairingQrPngPath, payload, {
|
|
606
|
+
type: 'png',
|
|
607
|
+
errorCorrectionLevel: 'M',
|
|
608
|
+
margin: 1,
|
|
609
|
+
scale: 8,
|
|
610
|
+
});
|
|
611
|
+
const qr = await QRCode.toString(payload, {
|
|
612
612
|
type: 'terminal',
|
|
613
613
|
small: true,
|
|
614
|
-
errorCorrectionLevel: '
|
|
614
|
+
errorCorrectionLevel: 'M',
|
|
615
615
|
});
|
|
616
616
|
process.stdout.write(`\nScan this QR code with the Vibelet app:\n\n${qr}\n`);
|
|
617
|
+
process.stdout.write(`If Vibelet app can't scan the terminal QR, open this PNG instead:\n${pairingQrPngPath}\n`);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// ─── Commands ───────────────────────────────────────────────────────────────────
|
|
621
|
+
|
|
622
|
+
async function printPairingSummary(existingHealth = null) {
|
|
623
|
+
const health = existingHealth ?? await waitForHealth();
|
|
624
|
+
const pairingPayload = await postJson('/pair/open');
|
|
625
|
+
|
|
626
|
+
process.stdout.write(`Vibelet daemon is ready.\n\n`);
|
|
627
|
+
process.stdout.write(`Device: ${health.displayName}\n`);
|
|
628
|
+
process.stdout.write(`Daemon ID: ${health.daemonId}\n`);
|
|
629
|
+
process.stdout.write(`Host: ${pairingPayload.canonicalHost}\n`);
|
|
630
|
+
process.stdout.write(`Port: ${pairingPayload.port}\n`);
|
|
631
|
+
process.stdout.write(`Paired devices: ${health.pairedDevices}\n`);
|
|
632
|
+
await printPairingQr(pairingPayload);
|
|
617
633
|
}
|
|
618
634
|
|
|
619
635
|
function printHelp() {
|