clavarium 0.2.312-next.1 → 0.2.314-next.1

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,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.312-next.1",
3
+ "version": "0.2.314-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.312-next.1",
9
+ "version": "0.2.314-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
14
  "clavarium-binder": "0.1.60-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
- "clavarium-parley": "0.17.64-next.1",
16
+ "clavarium-parley": "0.17.65-next.1",
17
17
  "clavarium-tether": "0.1.0-next.49",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
@@ -787,9 +787,9 @@
787
787
  }
788
788
  },
789
789
  "node_modules/clavarium-parley": {
790
- "version": "0.17.64-next.1",
791
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.64-next.1.tgz",
792
- "integrity": "sha512-xODV5QxOSFMjZAchfK7z3ZSvvSTeI57TYKifvDFjBrkK4Z3bAzc/0cnAq/OYid7nX4viMjZGV4OlJnRVowYg7Q==",
790
+ "version": "0.17.65-next.1",
791
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.65-next.1.tgz",
792
+ "integrity": "sha512-EZVq6df0eRWdrOC4yoFstBIahevIdFFOXpXa5PQBM8yol//V1sOgerr2Zk2INYKxY8T4bIBqsU5wCbloRtyjfQ==",
793
793
  "license": "MIT",
794
794
  "bin": {
795
795
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.312-next.1",
3
+ "version": "0.2.314-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -46,7 +46,7 @@
46
46
  "@xterm/xterm": "^6.0.0",
47
47
  "clavarium-binder": "0.1.60-next.1",
48
48
  "clavarium-docket": "0.1.2-next.2",
49
- "clavarium-parley": "0.17.64-next.1",
49
+ "clavarium-parley": "0.17.65-next.1",
50
50
  "clavarium-tether": "0.1.0-next.49",
51
51
  "mammoth": "1.13.0",
52
52
  "mermaid": "11.17.2",
package/web/app.js CHANGED
@@ -424,6 +424,39 @@
424
424
  return bar;
425
425
  }
426
426
  for (const top of [...document.querySelectorAll('#places .sheet > .panel-top')]) topBar(top, top.parentElement.id === 'salon' ? { state: 'salon-state' } : {});
427
+ /* A SEARCH ATOP A SETTINGS PAGE (05-11): one field in its top bar; what is typed keeps only the chapters (or
428
+ blocks) whose title or rows say it, opened; the headings left with nothing are hidden. Emptied, all comes back
429
+ as it was. The server's Settings, a conversation's, and any sheet given the same shape. */
430
+ const settingsSearch = (sheet) => {
431
+ const bar = sheet?.querySelector(':scope > header.topbar .bar-right') ?? sheet?.querySelector(':scope > header.topbar') ?? sheet?.querySelector(':scope > .panel-top');
432
+ if (!bar || sheet.querySelector('.settings-search')) return;
433
+ const field = document.createElement('input'); field.type = 'search'; field.className = 'settings-search';
434
+ field.placeholder = 'Search'; field.setAttribute('aria-label', 'Search these settings'); field.autocomplete = 'off';
435
+ bar.prepend(field);
436
+ const items = () => {
437
+ const chapters = [...sheet.querySelectorAll('details.chapter')];
438
+ return chapters.length ? chapters : [...sheet.querySelectorAll(':scope > :not(header.topbar):not(.panel-top)')].filter((e) => e.querySelector(':scope > .panel-top'));
439
+ };
440
+ const wasOpen = new Map();
441
+ const norm = (t) => String(t).toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '');
442
+ field.addEventListener('input', () => {
443
+ const q = norm(field.value.trim());
444
+ sheet.dataset.searching = q ? 'on' : '';
445
+ for (const it of items()) {
446
+ if (!q) { it.hidden = false; for (const row of it.querySelectorAll('.search-out')) row.classList.remove('search-out'); if (it.tagName === 'DETAILS' && wasOpen.has(it)) { it.open = wasOpen.get(it); wasOpen.delete(it); } continue; }
447
+ const hit = norm(it.textContent).includes(q);
448
+ it.hidden = !hit;
449
+ /* Within a chapter whose title does not say it: only its rows that do. */
450
+ const head = it.querySelector(':scope > summary, :scope > .panel-top');
451
+ const whole = !head || norm(head.textContent).includes(q);
452
+ for (const row of it.querySelectorAll('.set-row')) row.classList.toggle('search-out', hit && !whole && !norm(row.textContent).includes(q));
453
+ if (hit && it.tagName === 'DETAILS') { if (!wasOpen.has(it)) wasOpen.set(it, it.open); it.open = true; }
454
+ }
455
+ for (const group of sheet.querySelectorAll('.settings-group')) group.hidden = Boolean(q) && ![...group.querySelectorAll('details.chapter')].some((d) => !d.hidden);
456
+ });
457
+ field.addEventListener('keydown', (e) => { if (e.key === 'Escape' && field.value) { e.stopPropagation(); field.value = ''; field.dispatchEvent(new Event('input')); } });
458
+ };
459
+ for (const id of ['settings', 'panel']) settingsSearch($(id));
427
460
  /* A room's title: its name, and under it who speaks now (salonLive). */
428
461
  /* The device page (/c/) has no rooms sheet (05-11: it stopped app.js there, the page stuck on connecting). */
429
462
  if ($('salon')) { const t = $('salon-title'); const name = document.createElement('span'); name.id = 'salon-name'; name.textContent = t.textContent; const live = document.createElement('small'); live.id = 'salon-live'; live.className = 'salon-live'; live.hidden = true; t.replaceChildren(name, live); }
@@ -6172,7 +6205,24 @@
6172
6205
  });
6173
6206
  /* "Try it", per engine: a few seconds from this microphone, sent to the engine in its card (nothing saved). */
6174
6207
  let stopTrying = null;
6175
- const endTry = () => { stopTrying?.(); stopTrying = null; for (const slot of ['main', 'backup']) dq(slot, 'try').textContent = 'Try it'; };
6208
+ /* How loud the microphone is, in five thin bars beside what it says (voice.js: on.level): drawn once a
6209
+ frame; it rises at once and falls slowly. Decorative: the words say the state. */
6210
+ let tryLevels = []; let tryFrame = null;
6211
+ const tryLevel = (slot, n) => {
6212
+ if (!stopTrying || !window.clavariumVoice?.levelBars) return;
6213
+ tryLevels = [Math.max(n, (tryLevels[0] ?? 0) * 0.8), ...tryLevels].slice(0, 3);
6214
+ dq(slot, 'level').hidden = false;
6215
+ tryFrame ??= requestAnimationFrame(() => {
6216
+ tryFrame = null;
6217
+ if (!stopTrying) return;
6218
+ const bars = dq(slot, 'level').children;
6219
+ window.clavariumVoice.levelBars(tryLevels).forEach((h, i) => { if (bars[i]) bars[i].style.transform = `scaleY(${h})`; });
6220
+ });
6221
+ };
6222
+ const endTry = () => {
6223
+ stopTrying?.(); stopTrying = null; tryLevels = [];
6224
+ for (const slot of ['main', 'backup']) { dq(slot, 'try').textContent = 'Try it'; dq(slot, 'level').hidden = true; for (const bar of dq(slot, 'level').children) bar.style.transform = ''; }
6225
+ };
6176
6226
  for (const slot of ['main', 'backup']) dq(slot, 'try').addEventListener('click', async () => {
6177
6227
  if (stopTrying) { endTry(); return; }
6178
6228
  dictationSay(null);
@@ -6187,6 +6237,7 @@
6187
6237
  let spoke = began;
6188
6238
  const stop = await window.clavariumVoice.listen({
6189
6239
  state: (w) => { if (w === 'transcribing') spoke = Date.now(); if (stopTrying) heard.textContent = words[w] ?? w; },
6240
+ level: (n) => tryLevel(slot, n),
6190
6241
  phrase: (text) => { endTry(); heard.textContent = `Heard: ${text}`; heard.title = `${((Date.now() - spoke) / 1000).toFixed(1)} s`; },
6191
6242
  error: (message) => { endTry(); heard.hidden = true; dictationSay(message); },
6192
6243
  }, { to });
package/web/index.html CHANGED
@@ -924,7 +924,7 @@
924
924
  <div class="set-row" id="dictation-secret-row"><div class="set-what"><label for="dictation-secret">Key</label><small>One of your secrets. Never shown</small></div><div class="set-control"><select id="dictation-secret"><option value="">No key</option></select></div></div>
925
925
  <div class="set-row" id="dictation-newkey" hidden><div class="set-what"><label for="dictation-newkey-value">New key</label><small id="dictation-newkey-name"></small></div><div class="set-control"><input id="dictation-newkey-value" type="password" autocomplete="off" spellcheck="false" placeholder="Paste the key"><button type="button" class="primary" id="dictation-newkey-keep">Keep in secrets</button></div></div>
926
926
  <p class="hint" id="dictation-other-hint" hidden>Any engine with the same interface (<code>/v1/audio/transcriptions</code>); it alone may be on this server's own network.</p>
927
- <div class="action-row"><span class="hint" id="dictation-heard" role="status" hidden></span><button type="button" id="dictation-try" data-slot="main">Try it</button></div>
927
+ <div class="action-row"><span class="voice-level" id="dictation-level" aria-hidden="true" hidden><i></i><i></i><i></i><i></i><i></i></span><span class="hint" id="dictation-heard" role="status" hidden></span><button type="button" id="dictation-try" data-slot="main">Try it</button></div>
928
928
  </div>
929
929
  <div class="set-rows set-card dict-engine" id="dictation-backup-card" data-slot="backup">
930
930
  <div class="dict-head"><span class="dict-dot" id="dictation-backup-dot"></span><b>Backup</b><small>if the main one is down</small></div>
@@ -934,7 +934,7 @@
934
934
  <div class="set-row" id="dictation-backup-secret-row"><div class="set-what"><label for="dictation-backup-secret">Key</label><small>One of your secrets. Never shown</small></div><div class="set-control"><select id="dictation-backup-secret"><option value="">No key</option></select></div></div>
935
935
  <div class="set-row" id="dictation-backup-newkey" hidden><div class="set-what"><label for="dictation-backup-newkey-value">New key</label><small id="dictation-backup-newkey-name"></small></div><div class="set-control"><input id="dictation-backup-newkey-value" type="password" autocomplete="off" spellcheck="false" placeholder="Paste the key"><button type="button" class="primary" id="dictation-backup-newkey-keep">Keep in secrets</button></div></div>
936
936
  <p class="hint" id="dictation-backup-other-hint" hidden>Any engine with the same interface (<code>/v1/audio/transcriptions</code>); it alone may be on this server's own network.</p>
937
- <div class="action-row"><span class="hint" id="dictation-backup-heard" role="status" hidden></span><button type="button" id="dictation-backup-try" data-slot="backup">Try it</button></div>
937
+ <div class="action-row"><span class="voice-level" id="dictation-backup-level" aria-hidden="true" hidden><i></i><i></i><i></i><i></i><i></i></span><span class="hint" id="dictation-backup-heard" role="status" hidden></span><button type="button" id="dictation-backup-try" data-slot="backup">Try it</button></div>
938
938
  </div>
939
939
  <div class="set-rows set-card">
940
940
  <div class="set-row"><div class="set-what"><label for="dictation-language">Language</label></div><div class="set-control"><select id="dictation-language"><option value="">Each device's</option><option value="auto">Automatic</option><option value="en">English (en)</option><option value="fr">French (fr)</option><option value="de">German (de)</option><option value="es">Spanish (es)</option><option value="it">Italian (it)</option><option value="nl">Dutch (nl)</option><option value="pt">Portuguese (pt)</option><option value="other">Another code...</option></select><input id="dictation-language-code" maxlength="8" spellcheck="false" placeholder="code, such as pl" aria-label="Language code" hidden></div></div>
package/web/style.css CHANGED
@@ -1735,6 +1735,10 @@ button.inline.more-recent { text-decoration: none; }
1735
1735
  @media (max-width: 560px) { .set-row { grid-template-columns: minmax(0, 1fr); } .set-row > .set-control { justify-content: flex-start; } .set-row > .set-control > :is(input, select) { width: 100%; } }
1736
1736
  .action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
1737
1737
  .action-row > [role=status] { margin-right: auto; }
1738
+ /* Dictation's "Try it": five thin bars that follow how loud the microphone is (app.js, tryLevel). */
1739
+ .voice-level { display: inline-flex; align-items: center; gap: 2px; height: 14px; color: var(--ok); }
1740
+ .voice-level i { display: block; width: 3px; height: 100%; border-radius: 2px; background: currentColor; transform: scaleY(.2); transition: transform 90ms linear; }
1741
+ @media (prefers-reduced-motion: reduce) { .voice-level i { transform: scaleY(.2) !important; transition: none; } }
1738
1742
  /* Settings > Dictation: two engines, main and backup, each its card. */
1739
1743
  .dict-form { display: flex; flex-direction: column; gap: 12px; }
1740
1744
  .dict-form > .set-rows { display: flex; flex-direction: column; }
@@ -2583,3 +2587,8 @@ header.topbar .views .icon-btn { width: auto; height: auto; }
2583
2587
  .ft *, .ft *::before, .ft *::after, .ft-toast { animation: none !important; transition: none !important; }
2584
2588
  .ft-house .ft-wire.lit, .ft-house .ft-link.lit { stroke-dashoffset: 0 !important; }
2585
2589
  }
2590
+
2591
+ /* The search atop a settings page (05-11). */
2592
+ :is(header.topbar, .panel-top) .settings-search { margin-left: auto; width: min(240px, 42vw); min-height: 32px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: .875rem; }
2593
+ .sheet[data-searching="on"] .settings-nav { opacity: .5; }
2594
+ .set-row.search-out { display: none; }
package/web/voice-core.js CHANGED
@@ -32,6 +32,31 @@ export function loudness(samples) {
32
32
  return Number.isFinite(rms) ? rms : 0;
33
33
  }
34
34
 
35
+ /* HOW LOUD, TO DRAW: the loudness of a block as a level from 0 to 1 that an eye reads as a voice reads to
36
+ an ear, in decibels: a quiet room (-60 dB and below) is 0, a near shout (-12 dB) is 1. */
37
+ export const LEVEL_QUIET_DB = -60;
38
+ export const LEVEL_LOUD_DB = -12;
39
+ export function levelOf(rms) {
40
+ if (typeof rms !== 'number' || !Number.isFinite(rms) || rms <= 0) return 0;
41
+ const db = 20 * Math.log10(rms);
42
+ return Math.round(Math.min(1, Math.max(0, (db - LEVEL_QUIET_DB) / (LEVEL_LOUD_DB - LEVEL_QUIET_DB))) * 100) / 100;
43
+ }
44
+
45
+ /* The same level as the heights of a few thin bars (a share of their full height), as Parley draws it: the
46
+ newest level in the middle, the ones before towards the sides, lower there; a dot when quiet. */
47
+ export const LEVEL_BARS = 5;
48
+ export const LEVEL_DOT = 0.2;
49
+ export function levelBars(recent, n = LEVEL_BARS) {
50
+ const levels = (Array.isArray(recent) ? recent : [recent]).map((v) => (Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : 0));
51
+ const middle = (n - 1) / 2;
52
+ return Array.from({ length: n }, (_, i) => {
53
+ const away = Math.abs(i - middle);
54
+ const level = levels[Math.round(away)] ?? levels.at(-1) ?? 0;
55
+ const shape = middle > 0 ? 1 - 0.4 * (away / middle) : 1;
56
+ return Math.round((LEVEL_DOT + (1 - LEVEL_DOT) * level * shape) * 100) / 100;
57
+ });
58
+ }
59
+
35
60
  /* THE THRESHOLD FOLLOWS THE ROOM. An absolute threshold measures the world;
36
61
  what matters is what rises above the noise HERE. The floor is a low
37
62
  quantile of the last thirty seconds; speech is three times the floor. */
package/web/voice.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* DICTATION IN THE PAGE: the microphone stays open, each spoken phrase is
2
2
  transcribed and handed to whoever listens. The page types it into the
3
3
  terminal. See voice-core.js for how a phrase is found. */
4
- import { RATE, BLOCK, BLOCK_MS, Detector, Segmenter, loudness, toWav } from './voice-core.js';
4
+ import { RATE, BLOCK, BLOCK_MS, Detector, Segmenter, loudness, levelOf, levelBars, toWav } from './voice-core.js';
5
5
 
6
6
  /* The operator's pages ask /api; a paired device asks /c/api/<its pairing>,
7
7
  known once it has signed in (the page writes it on the document). */
@@ -16,7 +16,9 @@ const withLanguage = (to) => {
16
16
 
17
17
  /* Opens the microphone; resolves with a function that closes it.
18
18
  `on.phrase(text)`, `on.state(word)`: calibrating, listening, hearing,
19
- transcribing; `on.error(message)`. `to`: where phrases go, if not the
19
+ transcribing; `on.error(message)`; `on.level(n)`, if given: how loud the
20
+ microphone is, 0 to 1, each block (about 30 times a second), measured on
21
+ the same stream (no second microphone) for a few bars to follow. `to`: where phrases go, if not the
20
22
  usual engine (Settings' "Try it" sends them to the one in its form). */
21
23
  async function listen(on, { to } = {}) {
22
24
  const stream = await navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true, noiseSuppression: false, autoGainControl: false } });
@@ -44,7 +46,9 @@ async function listen(on, { to } = {}) {
44
46
  node.onaudioprocess = (event) => {
45
47
  const samples = Float32Array.from(event.inputBuffer.getChannelData(0));
46
48
  const was = segmenter.speaking;
47
- segmenter.feed(detector.hear(loudness(samples)), count++ * BLOCK_MS, samples);
49
+ const rms = loudness(samples);
50
+ segmenter.feed(detector.hear(rms), count++ * BLOCK_MS, samples);
51
+ if (!closed) { try { on.level?.(levelOf(rms)); } catch { /* a drawing never stops the dictation */ } }
48
52
  if (was !== segmenter.speaking || count === 33) tell();
49
53
  };
50
54
  source.connect(node); node.connect(context.destination);
@@ -60,5 +64,7 @@ async function listen(on, { to } = {}) {
60
64
  window.clavariumVoice = {
61
65
  available: async () => { try { const r = await fetch(`${api()}/voice`); return r.ok && (await r.json()).available === true; } catch { return false; } },
62
66
  listen,
67
+ /* The heights of the bars that show how loud it is (Settings' "Try it" draws them). */
68
+ levelBars,
63
69
  };
64
70
  window.dispatchEvent(new Event('clavarium-voice-ready'));