accelr8 3.7.1 → 3.8.0

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.
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-HY6ULYGH.js";
7
7
  import {
8
8
  DEFAULT_SERVER
9
- } from "./chunk-P3CEHEKI.js";
9
+ } from "./chunk-YUZORFN4.js";
10
10
 
11
11
  // src/radio/app.ts
12
12
  import tk from "terminal-kit";
@@ -5561,6 +5561,14 @@ function applyStation(m) {
5561
5561
  const broadcast = m.broadcast || null;
5562
5562
  state = { ...state, schedule: sched, listeners, broadcast, connected: true };
5563
5563
  if (audio) audio.setSchedule(sched);
5564
+ if (m.skip) {
5565
+ skipVotes = m.skip.votes ?? 0;
5566
+ skipNeeded = m.skip.needed ?? 1;
5567
+ if (m.skip.trackId && m.skip.trackId !== skipTrackId) {
5568
+ skipTrackId = m.skip.trackId;
5569
+ youVoted = false;
5570
+ }
5571
+ }
5564
5572
  }
5565
5573
  function startBackground(opts) {
5566
5574
  const tools = detectVoiceTools();
@@ -5594,42 +5602,44 @@ function makeScreen() {
5594
5602
  screen = new ScreenBuffer({ dst: term, width: W(), height: H() });
5595
5603
  video?.resize(W(), H());
5596
5604
  }
5597
- var volMsg = "";
5598
- var volMsgUntil = 0;
5599
- function flashVol() {
5600
- if (!audio) return;
5601
- const v = audio.volume, bars = 12, on = Math.round(v / 100 * bars);
5602
- volMsg = audio.isMuted ? "\u266B muted (m to unmute)" : `\u266B ${"\u2588".repeat(on)}${"\u2591".repeat(bars - on)} ${v}%`;
5603
- volMsgUntil = Date.now() + 1800;
5604
- }
5605
5605
  function volUp() {
5606
5606
  if (audio) {
5607
5607
  if (audio.isMuted) audio.toggleMute();
5608
5608
  audio.setVolume(audio.volume + 10);
5609
- flashVol();
5610
5609
  }
5611
5610
  }
5612
5611
  function volDown() {
5613
5612
  if (audio) {
5614
5613
  if (audio.isMuted) audio.toggleMute();
5615
5614
  audio.setVolume(audio.volume - 10);
5616
- flashVol();
5617
5615
  }
5618
5616
  }
5619
5617
  function muteToggle() {
5620
- if (audio) {
5621
- audio.toggleMute();
5622
- flashVol();
5623
- }
5624
- }
5625
- function drawVolToast() {
5626
- if (Date.now() >= volMsgUntil || !volMsg) return;
5627
- const y = Math.max(1, Math.floor(screen.height / 3));
5628
- const s = ` ${volMsg} `;
5629
- const x = Math.max(0, Math.floor((screen.width - s.length) / 2));
5630
- for (let i = 0; i < s.length && x + i < screen.width; i++)
5631
- screen.put({ x: x + i, y, attr: { color: 231, bgColor: 16, bold: true }, dx: 1, dy: 0, wrap: false }, s[i]);
5632
- }
5618
+ if (audio) audio.toggleMute();
5619
+ }
5620
+ var skipVotes = 0;
5621
+ var skipNeeded = 1;
5622
+ var youVoted = false;
5623
+ var skipTrackId = "";
5624
+ function toggleSkip() {
5625
+ youVoted = !youVoted;
5626
+ if (stationWs && stationWs.readyState === 1) stationWs.send(JSON.stringify({ t: youVoted ? "voteSkip" : "unvoteSkip" }));
5627
+ }
5628
+ function drawControls() {
5629
+ const w = screen.width, y = 1;
5630
+ if (screen.height < 3) return;
5631
+ for (let x = 0; x < w; x++) screen.put({ x, y, attr: { color: 231, bgColor: 234 }, dx: 1, dy: 0, wrap: false }, " ");
5632
+ const put2 = (x, s, color = 231, bold = false) => {
5633
+ for (let i = 0; i < s.length && x + i < w; i++) if (x + i >= 0) screen.put({ x: x + i, y, attr: { color, bgColor: 234, bold }, dx: 1, dy: 0, wrap: false }, s[i]);
5634
+ };
5635
+ const vol = audio ? audio.isMuted ? "MUTED" : `vol ${audio.volume}%` : "no audio";
5636
+ put2(1, `\u266A ${vol} [m] mute [+/-] volume [q] quit`);
5637
+ const met = skipVotes >= skipNeeded && skipVotes > 0;
5638
+ const label = youVoted ? "[s] voted \u2713" : "[s] vote skip";
5639
+ const right = `${label} skip ${skipVotes}/${skipNeeded} `;
5640
+ put2(w - right.length, right, met ? C_GOOD : 231, youVoted);
5641
+ }
5642
+ var C_GOOD = 46;
5633
5643
  var BG = 16;
5634
5644
  function blitVideo() {
5635
5645
  const w = screen.width, h = screen.height;
@@ -5669,7 +5679,7 @@ function renderFrame() {
5669
5679
  blitVideo();
5670
5680
  const cells = renderOverlay({ w: screen.width, h: screen.height, tMs, state });
5671
5681
  blitOverlay(cells);
5672
- drawVolToast();
5682
+ drawControls();
5673
5683
  if (screen.dst) screen.draw({ delta: true });
5674
5684
  }
5675
5685
  function teardown() {
@@ -5725,13 +5735,13 @@ function runRadio(opts) {
5725
5735
  term.on("key", (name) => {
5726
5736
  if (name === "CTRL_C" || name === "q" || name === "ESCAPE") return quit();
5727
5737
  if (name === "m") return muteToggle();
5738
+ if (name === "s") return toggleSkip();
5728
5739
  if (name === "+" || name === "=" || name === "UP") return volUp();
5729
5740
  if (name === "-" || name === "_" || name === "DOWN") return volDown();
5730
5741
  });
5731
5742
  term.on("resize", () => makeScreen());
5732
5743
  process.on("SIGINT", quit);
5733
5744
  process.on("SIGTERM", quit);
5734
- flashVol();
5735
5745
  renderTimer = setInterval(renderFrame, Math.round(1e3 / RENDER_FPS));
5736
5746
  renderFrame();
5737
5747
  }
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/protocol.ts
4
- var VERSION = true ? "3.7.1" : "3.7.1";
4
+ var VERSION = true ? "3.8.0" : "3.8.0";
5
5
  var PROTO = 3;
6
6
  var PORT = 8787;
7
7
  var DEFAULT_SERVER = "wss://accelr8-canvas.patonchain.workers.dev";
@@ -32,7 +32,7 @@ import {
32
32
  VERSION,
33
33
  decode,
34
34
  encode
35
- } from "./chunk-P3CEHEKI.js";
35
+ } from "./chunk-YUZORFN4.js";
36
36
 
37
37
  // src/client.ts
38
38
  import tk from "terminal-kit";
@@ -6,7 +6,7 @@ import {
6
6
  LIMITS,
7
7
  PORT,
8
8
  PROTO
9
- } from "./chunk-P3CEHEKI.js";
9
+ } from "./chunk-YUZORFN4.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-P3CEHEKI.js";
6
+ } from "./chunks/chunk-YUZORFN4.js";
7
7
 
8
8
  // src/cli.ts
9
9
  var HELP = `
@@ -53,7 +53,7 @@ async function main() {
53
53
  console.error(`invalid port: ${argVal(args, "--port")}`);
54
54
  process.exit(1);
55
55
  }
56
- const { runServer } = await import("./chunks/server-NZ5JUOCF.js");
56
+ const { runServer } = await import("./chunks/server-6VK3AAAJ.js");
57
57
  runServer(port);
58
58
  return;
59
59
  }
@@ -67,7 +67,7 @@ async function main() {
67
67
  console.error("accelr8 radio needs an interactive terminal (TTY).");
68
68
  process.exit(1);
69
69
  }
70
- const { runRadio } = await import("./chunks/app-EOVXVIEE.js");
70
+ const { runRadio } = await import("./chunks/app-DCVVDS5A.js");
71
71
  runRadio({
72
72
  name: argVal(args, "--name"),
73
73
  server: argVal(args, "--server"),
@@ -90,7 +90,7 @@ async function main() {
90
90
  const { cachedUpdate, refreshUpdateCache } = await import("./chunks/update-UEPNGB6Y.js");
91
91
  refreshUpdateCache();
92
92
  const update = cachedUpdate(VERSION);
93
- const { runClient } = await import("./chunks/client-OIVTEENE.js");
93
+ const { runClient } = await import("./chunks/client-Y2PNGYRP.js");
94
94
  runClient({
95
95
  name: argVal(args, "--name"),
96
96
  server: argVal(args, "--server"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accelr8",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "description": "Collaborative ascii canvas in your terminal. Real multiplayer, live cursors, mouse-driven TUI.",
5
5
  "type": "module",
6
6
  "license": "ISC",