accelr8 3.0.2 → 3.0.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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/protocol.ts
4
- var VERSION = true ? "3.0.2" : "3.0.2";
4
+ var VERSION = true ? "3.0.3" : "3.0.2";
5
5
  var PROTO = 3;
6
6
  var PORT = 8787;
7
7
  var DEFAULT_SERVER = "wss://accelr8-canvas.patonchain.workers.dev";
@@ -7,7 +7,7 @@ import {
7
7
  VERSION,
8
8
  decode,
9
9
  encode
10
- } from "./chunk-WRSSNAIF.js";
10
+ } from "./chunk-SY2ASAWX.js";
11
11
  import {
12
12
  DEFAULT_MODEL,
13
13
  addAccount,
@@ -1181,6 +1181,7 @@ var SAMPLE_RATE = 16e3;
1181
1181
  var CHUNK_BYTES = 1280;
1182
1182
  var KILL_GRACE_MS = 300;
1183
1183
  var SPEAKER_IDLE_MS = 2e3;
1184
+ var PREBUFFER_BYTES = 4800;
1184
1185
  var DRAIN_KILL_MS = 2e3;
1185
1186
  var MAX_PLAYERS = 8;
1186
1187
  var STDERR_TAIL = 400;
@@ -1190,10 +1191,9 @@ var PLAYBACK_ARGS = [
1190
1191
  "-loglevel",
1191
1192
  "error",
1192
1193
  "-nodisp",
1193
- "-fflags",
1194
- "nobuffer",
1195
- "-flags",
1196
- "low_delay",
1194
+ "-sync",
1195
+ "audio",
1196
+ "-infbuf",
1197
1197
  "-f",
1198
1198
  "s16le",
1199
1199
  "-ar",
@@ -1355,13 +1355,31 @@ var VoicePlayback = class {
1355
1355
  if (!spawned) return;
1356
1356
  p = spawned;
1357
1357
  }
1358
- if (!this.write(p, bytes)) {
1359
- this.reap(speakerId, p);
1360
- const fresh = this.players.size < MAX_PLAYERS ? this.spawnPlayer(speakerId) : null;
1361
- if (!fresh || !this.write(fresh, bytes)) return;
1362
- p = fresh;
1358
+ if (!p.flowing) {
1359
+ p.pre.push(bytes);
1360
+ if (p.pre.reduce((n, b) => n + b.length, 0) >= PREBUFFER_BYTES) {
1361
+ const cushion = Buffer.concat(p.pre);
1362
+ p.pre = [];
1363
+ p.flowing = true;
1364
+ const np2 = this.writeOrRespawn(speakerId, p, cushion);
1365
+ if (np2) this.touch(speakerId, np2);
1366
+ } else {
1367
+ this.touch(speakerId, p);
1368
+ }
1369
+ return;
1363
1370
  }
1364
- this.touch(speakerId, p);
1371
+ const np = this.writeOrRespawn(speakerId, p, bytes);
1372
+ if (np) this.touch(speakerId, np);
1373
+ }
1374
+ /** Write to a player; on EPIPE (it died) respawn once and write there. Returns
1375
+ * the live player, or null if it couldn't be (re)spawned. */
1376
+ writeOrRespawn(speakerId, p, buf) {
1377
+ if (this.write(p, buf)) return p;
1378
+ this.reap(speakerId, p);
1379
+ const fresh = this.players.size < MAX_PLAYERS ? this.spawnPlayer(speakerId) : null;
1380
+ if (!fresh || !this.write(fresh, buf)) return null;
1381
+ fresh.flowing = true;
1382
+ return fresh;
1365
1383
  }
1366
1384
  /** Graceful close for one speaker (voiceStop): end stdin so ffplay drains
1367
1385
  * its buffered audio, then a SIGKILL backstop after 2s (we dropped -autoexit,
@@ -1408,7 +1426,7 @@ var VoicePlayback = class {
1408
1426
  } catch {
1409
1427
  return null;
1410
1428
  }
1411
- const p = { child, alive: true, idleTimer: null };
1429
+ const p = { child, alive: true, idleTimer: null, pre: [], flowing: false };
1412
1430
  child.stdin?.on("error", () => {
1413
1431
  p.alive = false;
1414
1432
  });
@@ -6,7 +6,7 @@ import {
6
6
  LIMITS,
7
7
  PORT,
8
8
  PROTO
9
- } from "./chunk-WRSSNAIF.js";
9
+ } from "./chunk-SY2ASAWX.js";
10
10
 
11
11
  // src/server.ts
12
12
  import { WebSocketServer, WebSocket } from "ws";
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DEFAULT_SERVER,
4
4
  PORT,
5
5
  VERSION
6
- } from "./chunks/chunk-WRSSNAIF.js";
6
+ } from "./chunks/chunk-SY2ASAWX.js";
7
7
 
8
8
  // src/cli.ts
9
9
  var HELP = `
@@ -52,7 +52,7 @@ async function main() {
52
52
  console.error(`invalid port: ${argVal(args, "--port")}`);
53
53
  process.exit(1);
54
54
  }
55
- const { runServer } = await import("./chunks/server-OQNHWL3Z.js");
55
+ const { runServer } = await import("./chunks/server-IVR5UHTM.js");
56
56
  runServer(port);
57
57
  return;
58
58
  }
@@ -76,7 +76,7 @@ async function main() {
76
76
  const { cachedUpdate, refreshUpdateCache } = await import("./chunks/update-UEPNGB6Y.js");
77
77
  refreshUpdateCache();
78
78
  const update = cachedUpdate(VERSION);
79
- const { runClient } = await import("./chunks/client-W4563KDL.js");
79
+ const { runClient } = await import("./chunks/client-HLMFYYAQ.js");
80
80
  runClient({
81
81
  name: argVal(args, "--name"),
82
82
  server: argVal(args, "--server"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accelr8",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Collaborative ascii canvas in your terminal. Real multiplayer, live cursors, mouse-driven TUI.",
5
5
  "type": "module",
6
6
  "license": "ISC",