@trippnology/mixshell 0.0.0-stage → 0.7.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.
- package/LICENSE +21 -0
- package/README.md +294 -2
- package/assets/mixshell-screenshot.png +0 -0
- package/package.json +73 -5
- package/src/alsa-pulse.conf +20 -0
- package/src/alsa-setup.js +15 -0
- package/src/components/browser.js +193 -0
- package/src/components/config.js +168 -0
- package/src/components/durations.js +151 -0
- package/src/components/library.js +679 -0
- package/src/components/mediakeys.js +222 -0
- package/src/components/mpris.js +309 -0
- package/src/components/player.js +412 -0
- package/src/components/playlist.js +335 -0
- package/src/components/session.js +96 -0
- package/src/constants.js +164 -0
- package/src/engines/ffmpeg.js +601 -0
- package/src/engines/index.js +14 -0
- package/src/engines/webaudio.js +317 -0
- package/src/index.js +188 -0
- package/src/mediakeys/macos-nowplaying.js +227 -0
- package/src/ui/app.js +56 -0
- package/src/ui/artPane.js +314 -0
- package/src/ui/confirmPrompt.js +34 -0
- package/src/ui/constants.js +133 -0
- package/src/ui/controller.js +1641 -0
- package/src/ui/dom.js +9 -0
- package/src/ui/goToPrompt.js +105 -0
- package/src/ui/index.html +78 -0
- package/src/ui/libraryPanel.js +415 -0
- package/src/ui/listView.js +209 -0
- package/src/ui/onboarding.js +353 -0
- package/src/ui/playlistPanel.js +207 -0
- package/src/ui/settingsPanel.js +473 -0
- package/src/ui/shortcuts.js +30 -0
- package/src/ui/splash.js +302 -0
- package/src/ui/style.css +532 -0
- package/src/ui/subtabs.js +31 -0
- package/src/ui/visualizer/bars.js +74 -0
- package/src/ui/visualizer/circles.js +64 -0
- package/src/ui/visualizer/color.js +61 -0
- package/src/ui/visualizer/cube.js +105 -0
- package/src/ui/visualizer/grid.js +68 -0
- package/src/ui/visualizer/index.js +65 -0
- package/src/ui/visualizer/onset.js +130 -0
- package/src/ui/visualizer/spectrum.js +34 -0
- package/src/ui/visualizer/vu.js +71 -0
- package/src/ui/visualizer/waveform.js +58 -0
- package/src/utils/audioAnalyzer.js +362 -0
- package/src/utils/audioDevices.js +222 -0
- package/src/utils/cellart.js +75 -0
- package/src/utils/debug.js +7 -0
- package/src/utils/durationProbe.js +48 -0
- package/src/utils/folderArt.js +46 -0
- package/src/utils/format.js +20 -0
- package/src/utils/id3.js +84 -0
- package/src/utils/pathInput.js +76 -0
- package/src/utils/playlistIO.js +176 -0
- package/src/utils/terminalGraphics.js +47 -0
package/src/ui/splash.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
// Idle letter-field splash (issues/049) — a terminal take on the
|
|
2
|
+
// data-slot="field" canvas on opencode.ai/font: a grid of random letters
|
|
3
|
+
// cut from the wordmark, the word itself locked across the middle row,
|
|
4
|
+
// and a mouse-driven energy field that flips letters through the cycle
|
|
5
|
+
// and climbs a faint → ink → accent → inverted colour ladder, with
|
|
6
|
+
// ripples radiating from moves and clicks. Everything renders on the
|
|
7
|
+
// cellgrid, one plain terminal character per cell (the same sanctioned
|
|
8
|
+
// animation path as the visualizer; per-rect 2d fills and the kitty
|
|
9
|
+
// pixel path are banned, see DEVELOPMENT.md §Art & visualizer).
|
|
10
|
+
|
|
11
|
+
// The field letters are the wordmark's unique characters; the centre row
|
|
12
|
+
// spells the full word (8 letters, same centre math as the original's 8).
|
|
13
|
+
export const SPLASH_LETTERS = 'mixshel';
|
|
14
|
+
export const SPLASH_WORD = 'mixshell';
|
|
15
|
+
|
|
16
|
+
// Shared field radii, in cell units: the band around an expanding ripple
|
|
17
|
+
// ring and the pointer halo's reach (both also size the per-frame boxes).
|
|
18
|
+
export const RING_BAND = 1.6;
|
|
19
|
+
export const HALO_RADIUS = 4.5;
|
|
20
|
+
|
|
21
|
+
// Per-cell base letter from the original's sin hash — deterministic per
|
|
22
|
+
// cell index, so a re-fit keeps every surviving cell's letter.
|
|
23
|
+
export function hash01(i) {
|
|
24
|
+
const v = Math.sin(i * 127.1 + 311.7) * 43758.5453;
|
|
25
|
+
return v - Math.floor(v);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Energy ladder → colour style: 0 faint (muted), 1 ink (fg), 2 accent,
|
|
29
|
+
// 3 inverted (accent tile, letter punched in bg). The centre word starts
|
|
30
|
+
// at ink instead of faint (locked cells never go below ink). Thresholds
|
|
31
|
+
// from the original: .12 / .36 / .66.
|
|
32
|
+
export function styleFor(energy, locked) {
|
|
33
|
+
if (energy > 0.66) return 3;
|
|
34
|
+
if (energy > 0.36) return 2;
|
|
35
|
+
if (energy > 0.12 || locked) return 1;
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Letter-cycle steps from energy; locked centre letters resist until the
|
|
40
|
+
// field is hot (original: `t < .35 ? 0 : ceil(t * n)` for them).
|
|
41
|
+
export function flipSteps(energy, locked) {
|
|
42
|
+
if (locked && energy < 0.35) return 0;
|
|
43
|
+
if (energy <= 0.12) return 0;
|
|
44
|
+
return Math.ceil(energy * SPLASH_LETTERS.length);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Ripple ring contribution at cell (x, y): a 1.6-cell band around the
|
|
48
|
+
// expanding radius, fading over the ripple's life; elliptical through
|
|
49
|
+
// yWeight (the terminal cell aspect) so rings read as circles in pixels.
|
|
50
|
+
export function rippleEnergy(ripple, x, y, now, yWeight) {
|
|
51
|
+
const age = now - ripple.born;
|
|
52
|
+
if (age < 0 || age > ripple.life) return 0;
|
|
53
|
+
const r = (age / 1000) * ripple.speed;
|
|
54
|
+
const d = Math.hypot(x - ripple.x, (y - ripple.y) * yWeight);
|
|
55
|
+
const ring = Math.max(0, 1 - Math.abs(d - r) / RING_BAND);
|
|
56
|
+
return ring * ripple.strength * (1 - age / ripple.life);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Persistent halo under the pointer: radius 4.5 cells, peak 0.9.
|
|
60
|
+
export function haloEnergy(px, py, x, y, yWeight) {
|
|
61
|
+
const d = Math.hypot(x - px, (y - py) * yWeight);
|
|
62
|
+
return Math.max(0, 1 - d / HALO_RADIUS) * 0.9;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function createSplash({ els, win, document }) {
|
|
66
|
+
const canvas = els.splash;
|
|
67
|
+
|
|
68
|
+
const MOVE = { strength: 0.7, life: 700, speed: 9 };
|
|
69
|
+
const CLICK = { strength: 1, life: 1800, speed: 26 };
|
|
70
|
+
const MOVE_THROTTLE_MS = 45;
|
|
71
|
+
|
|
72
|
+
let visible = false;
|
|
73
|
+
let grid = null;
|
|
74
|
+
let colors = null;
|
|
75
|
+
let ratio = 2; // terminal cell aspect, kept in sync via setCellRatio
|
|
76
|
+
let cols = 0;
|
|
77
|
+
let rows = 0;
|
|
78
|
+
let base = null; // Uint8Array: field letter per cell
|
|
79
|
+
let locked = null; // Int8Array: word letter per cell, -1 = field
|
|
80
|
+
let energy = null; // Float32Array: recomputed every frame
|
|
81
|
+
let drawnCh = null; // last emitted char per cell
|
|
82
|
+
let drawnStyle = null; // last emitted style per cell, 255 = blank
|
|
83
|
+
let paintedKey = null;
|
|
84
|
+
let ripples = [];
|
|
85
|
+
let pointer = null;
|
|
86
|
+
let raf = null;
|
|
87
|
+
let lastMoveRipple = 0;
|
|
88
|
+
|
|
89
|
+
function readColors() {
|
|
90
|
+
const style = win.getComputedStyle(document.body);
|
|
91
|
+
const read = (name) => style.getPropertyValue(name).trim();
|
|
92
|
+
return {
|
|
93
|
+
bg: read('--bg'),
|
|
94
|
+
fg: read('--fg'),
|
|
95
|
+
accent: read('--accent'),
|
|
96
|
+
muted: read('--muted'),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Grid size comes from the canvas itself: CSS gives it the panel's full
|
|
101
|
+
// inner width and every row left under the placeholder (issues/066), and
|
|
102
|
+
// fit() reads that box back after it is shown.
|
|
103
|
+
function buildGrid(w, h) {
|
|
104
|
+
cols = w;
|
|
105
|
+
rows = h;
|
|
106
|
+
const n = cols * rows;
|
|
107
|
+
base = new Uint8Array(n);
|
|
108
|
+
for (let i = 0; i < n; i++)
|
|
109
|
+
base[i] = Math.floor(hash01(i) * SPLASH_LETTERS.length);
|
|
110
|
+
locked = new Int8Array(n).fill(-1);
|
|
111
|
+
const mid = Math.floor(rows / 2);
|
|
112
|
+
const start = Math.floor(cols / 2) - 4;
|
|
113
|
+
for (let t = 0; t < SPLASH_WORD.length; t++) {
|
|
114
|
+
const x = start + t;
|
|
115
|
+
if (x >= 0 && x < cols)
|
|
116
|
+
locked[mid * cols + x] = SPLASH_LETTERS.indexOf(SPLASH_WORD[t]);
|
|
117
|
+
}
|
|
118
|
+
energy = new Float32Array(n);
|
|
119
|
+
drawnCh = new Array(n).fill(null);
|
|
120
|
+
drawnStyle = new Uint8Array(n).fill(255);
|
|
121
|
+
ripples = [];
|
|
122
|
+
pointer = null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function computeEnergies(now) {
|
|
126
|
+
energy.fill(0);
|
|
127
|
+
ripples = ripples.filter((r) => now - r.born <= r.life);
|
|
128
|
+
const yw = ratio;
|
|
129
|
+
for (const ripple of ripples) {
|
|
130
|
+
// Outer edge of the ring band, in cells; y span shrinks by the
|
|
131
|
+
// aspect so the touched box hugs the ellipse.
|
|
132
|
+
const r = ((now - ripple.born) / 1000) * ripple.speed + RING_BAND;
|
|
133
|
+
const spanY = Math.ceil(r / yw) + 1;
|
|
134
|
+
const x0 = Math.max(0, Math.floor(ripple.x - r));
|
|
135
|
+
const x1 = Math.min(cols - 1, Math.ceil(ripple.x + r));
|
|
136
|
+
const y0 = Math.max(0, Math.floor(ripple.y - spanY));
|
|
137
|
+
const y1 = Math.min(rows - 1, Math.ceil(ripple.y + spanY));
|
|
138
|
+
for (let y = y0; y <= y1; y++) {
|
|
139
|
+
for (let x = x0; x <= x1; x++) {
|
|
140
|
+
const e = rippleEnergy(ripple, x, y, now, yw);
|
|
141
|
+
const i = y * cols + x;
|
|
142
|
+
if (e > energy[i]) energy[i] = e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (pointer) {
|
|
147
|
+
const spanY = Math.ceil(HALO_RADIUS / yw) + 1;
|
|
148
|
+
const x0 = Math.max(0, Math.floor(pointer.x - HALO_RADIUS));
|
|
149
|
+
const x1 = Math.min(cols - 1, Math.ceil(pointer.x + HALO_RADIUS));
|
|
150
|
+
const y0 = Math.max(0, Math.floor(pointer.y - spanY));
|
|
151
|
+
const y1 = Math.min(rows - 1, Math.ceil(pointer.y + spanY));
|
|
152
|
+
for (let y = y0; y <= y1; y++) {
|
|
153
|
+
for (let x = x0; x <= x1; x++) {
|
|
154
|
+
const e = haloEnergy(pointer.x, pointer.y, x, y, yw);
|
|
155
|
+
const i = y * cols + x;
|
|
156
|
+
if (e > energy[i]) energy[i] = e;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function emit(x, y, c) {
|
|
163
|
+
const i = y * cols + x;
|
|
164
|
+
const isLocked = locked[i] >= 0;
|
|
165
|
+
const e = energy[i];
|
|
166
|
+
const style = styleFor(e, isLocked);
|
|
167
|
+
const steps = flipSteps(e, isLocked);
|
|
168
|
+
const b = isLocked ? locked[i] : base[i];
|
|
169
|
+
const ch = SPLASH_LETTERS[(b + steps) % SPLASH_LETTERS.length];
|
|
170
|
+
if (ch === drawnCh[i] && style === drawnStyle[i]) return;
|
|
171
|
+
drawnCh[i] = ch;
|
|
172
|
+
drawnStyle[i] = style;
|
|
173
|
+
if (style === 3) {
|
|
174
|
+
// Inverted: accent tile, letter punched out in the background
|
|
175
|
+
// colour — no clearRect needed, the fill replaces the cell bg.
|
|
176
|
+
grid.fillStyle = c.accent;
|
|
177
|
+
grid.fillRect(x, y, 1, 1);
|
|
178
|
+
grid.fillStyle = c.bg;
|
|
179
|
+
} else {
|
|
180
|
+
// Styles below invert must scrub any leftover tile bg first.
|
|
181
|
+
grid.clearRect(x, y, 1, 1);
|
|
182
|
+
grid.fillStyle = style === 0 ? c.muted : style === 1 ? c.fg : c.accent;
|
|
183
|
+
}
|
|
184
|
+
grid.fillText(ch, x, y);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function paint(now) {
|
|
188
|
+
if (!grid || grid.cols !== cols || grid.rows !== rows) return;
|
|
189
|
+
computeEnergies(now);
|
|
190
|
+
for (let y = 0; y < rows; y++)
|
|
191
|
+
for (let x = 0; x < cols; x++) emit(x, y, colors);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function tick(now) {
|
|
195
|
+
raf = null;
|
|
196
|
+
paint(now);
|
|
197
|
+
if (ripples.length || pointer) raf = win.requestAnimationFrame(tick);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function ensureLoop() {
|
|
201
|
+
if (!raf) raf = win.requestAnimationFrame(tick);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// The cellgrid re-derives cols/rows a frame or more after the box
|
|
205
|
+
// resizes — same wait as renderArt's poll (≤30 tries, then draw). The
|
|
206
|
+
// refit key is the canvas's own size, not the window's: the canvas now
|
|
207
|
+
// changes whenever the chrome does, so a footer/header change refits.
|
|
208
|
+
function fit() {
|
|
209
|
+
colors = readColors();
|
|
210
|
+
const w = Math.max(0, Math.round(canvas.getBoundingClientRect().width));
|
|
211
|
+
const h = Math.max(0, Math.round(canvas.getBoundingClientRect().height));
|
|
212
|
+
const key = `${w}x${h}x${ratio}|${colors.bg}|${colors.fg}|${colors.accent}|${colors.muted}`;
|
|
213
|
+
if (paintedKey === key) return;
|
|
214
|
+
paintedKey = key;
|
|
215
|
+
buildGrid(w, h);
|
|
216
|
+
let tries = 0;
|
|
217
|
+
const settle = () => {
|
|
218
|
+
grid ??= canvas.getContext('termdom-cellgrid');
|
|
219
|
+
if ((grid.cols !== cols || grid.rows !== rows) && ++tries < 30) {
|
|
220
|
+
win.requestAnimationFrame(settle);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
grid.clearRect(0, 0, grid.cols, grid.rows);
|
|
224
|
+
drawnCh.fill(null);
|
|
225
|
+
drawnStyle.fill(255);
|
|
226
|
+
paint(performance.now());
|
|
227
|
+
};
|
|
228
|
+
settle();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function toCell(e) {
|
|
232
|
+
const rect = canvas.getBoundingClientRect();
|
|
233
|
+
const x = Math.floor(e.clientX - rect.left);
|
|
234
|
+
const y = Math.floor(e.clientY - rect.top);
|
|
235
|
+
if (x < 0 || y < 0 || x >= cols || y >= rows) return null;
|
|
236
|
+
return { x, y };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function onMove(e) {
|
|
240
|
+
const cell = toCell(e);
|
|
241
|
+
if (!cell) return;
|
|
242
|
+
pointer = cell;
|
|
243
|
+
const now = performance.now();
|
|
244
|
+
if (now - lastMoveRipple >= MOVE_THROTTLE_MS) {
|
|
245
|
+
lastMoveRipple = now;
|
|
246
|
+
ripples.push({ x: cell.x, y: cell.y, born: now, ...MOVE });
|
|
247
|
+
}
|
|
248
|
+
ensureLoop();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function onLeave() {
|
|
252
|
+
pointer = null;
|
|
253
|
+
ensureLoop();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function onClick(e) {
|
|
257
|
+
const cell = toCell(e);
|
|
258
|
+
if (!cell) return;
|
|
259
|
+
ripples.push({ x: cell.x, y: cell.y, born: performance.now(), ...CLICK });
|
|
260
|
+
ensureLoop();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function attach() {
|
|
264
|
+
canvas.addEventListener('mousemove', onMove);
|
|
265
|
+
canvas.addEventListener('mouseleave', onLeave);
|
|
266
|
+
canvas.addEventListener('click', onClick);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function detach() {
|
|
270
|
+
canvas.removeEventListener('mousemove', onMove);
|
|
271
|
+
canvas.removeEventListener('mouseleave', onLeave);
|
|
272
|
+
canvas.removeEventListener('click', onClick);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return {
|
|
276
|
+
show() {
|
|
277
|
+
if (!visible) {
|
|
278
|
+
visible = true;
|
|
279
|
+
canvas.classList.remove('hidden');
|
|
280
|
+
attach();
|
|
281
|
+
}
|
|
282
|
+
fit();
|
|
283
|
+
paint(performance.now());
|
|
284
|
+
},
|
|
285
|
+
hide() {
|
|
286
|
+
if (!visible) return;
|
|
287
|
+
visible = false;
|
|
288
|
+
canvas.classList.add('hidden');
|
|
289
|
+
if (raf) {
|
|
290
|
+
win.cancelAnimationFrame(raf);
|
|
291
|
+
raf = null;
|
|
292
|
+
}
|
|
293
|
+
detach();
|
|
294
|
+
pointer = null;
|
|
295
|
+
ripples = [];
|
|
296
|
+
},
|
|
297
|
+
setCellRatio(r) {
|
|
298
|
+
ratio = r;
|
|
299
|
+
paintedKey = null;
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
}
|