clavarium 0.2.251-next.1 → 0.2.253-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.
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/boxes.mjs +3 -0
- package/server/talk.mjs +1 -1
- package/web/app.js +25 -0
- package/web/style.css +2 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.253-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.253-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/boxes.mjs
CHANGED
|
@@ -714,6 +714,9 @@ export class Boxes {
|
|
|
714
714
|
const seconds = (pcm.length / 32_000).toFixed(1);
|
|
715
715
|
if (pcm.length < 16_000) { this.#log(`voice box ${box0.name}: ${seconds} s heard, too short for a sentence`); this.#tested(link, 'nothing'); link.send({ t: 'cue', name: 'done' }); return; } /* under half a second: a press, not a sentence */
|
|
716
716
|
link.send({ t: 'cue', name: 'thinking' });
|
|
717
|
+
/* Its sound, kept beside its conversation (the ten last, a week): its assistant can listen to what the box
|
|
718
|
+
really sent when the dictation goes wrong (02-11: "regarde la qualité de l'audio arrivant"). */
|
|
719
|
+
try { this.#keep?.(box0.conversation, 'phrase-boitier.wav', wavOf(pcm)); } catch { /* its chat may be off */ }
|
|
717
720
|
let text;
|
|
718
721
|
/* A sentence that goes nowhere is said so, in words, rather than with a beep nobody can read (31-10). */
|
|
719
722
|
const lost = async (words) => {
|
package/server/talk.mjs
CHANGED
|
@@ -527,7 +527,7 @@ export class Talk {
|
|
|
527
527
|
before.sort((a, b) => b.at - a.at);
|
|
528
528
|
before.forEach((x, i) => { if (i >= KEPT_TEXTS - 1 || Date.now() - x.at > KEPT_TEXT_DAYS * 86_400_000) rmSync(join(dir, FILES, x.name), { recursive: true, force: true }); });
|
|
529
529
|
mkdirSync(join(dir, FILES, id));
|
|
530
|
-
writeFileSync(join(dir, FILES, id, file), String(text ?? ''), { flag: 'wx', mode: 0o644 });
|
|
530
|
+
writeFileSync(join(dir, FILES, id, file), Buffer.isBuffer(text) ? text : String(text ?? ''), { flag: 'wx', mode: 0o644 });
|
|
531
531
|
return `${IN_MACHINE}/${FILES}/${id}/${file}`;
|
|
532
532
|
}
|
|
533
533
|
|
package/web/app.js
CHANGED
|
@@ -8073,6 +8073,12 @@
|
|
|
8073
8073
|
is offered for download, and nothing is ever run. */
|
|
8074
8074
|
const PREVIEW_MAX = 25 * 1024 * 1024;
|
|
8075
8075
|
const TEXT_MAX = 1024 * 1024;
|
|
8076
|
+
/* SOUNDS AND VIDEOS (02-11): played here, by the browser's own player. What it cannot read (an .avi, an
|
|
8077
|
+
.mkv of another codec) says so, with Download. Up to MEDIA_MAX read whole (so it can be moved through),
|
|
8078
|
+
beyond, played as it comes. */
|
|
8079
|
+
const MEDIA = { mp3: 'audio/mpeg', wav: 'audio/wav', ogg: 'audio/ogg', oga: 'audio/ogg', opus: 'audio/ogg', m4a: 'audio/mp4', aac: 'audio/aac', flac: 'audio/flac',
|
|
8080
|
+
mp4: 'video/mp4', m4v: 'video/mp4', mov: 'video/mp4', webm: 'video/webm', mkv: 'video/webm', ogv: 'video/ogg' };
|
|
8081
|
+
const MEDIA_MAX = 200 * 1024 * 1024;
|
|
8076
8082
|
const PICTURES = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp' };
|
|
8077
8083
|
/* Office files (02-11), read in the page: spreadsheets by SheetJS, Word by mammoth (loaded on first use). */
|
|
8078
8084
|
const SHEETS = ['xlsx', 'xlsm', 'xls', 'ods'];
|
|
@@ -8345,6 +8351,25 @@
|
|
|
8345
8351
|
$('preview-body').replaceChildren(box); note('');
|
|
8346
8352
|
};
|
|
8347
8353
|
const kind = name.includes('.') ? name.split('.').pop().toLowerCase() : '';
|
|
8354
|
+
if (MEDIA[kind]) {
|
|
8355
|
+
const video = MEDIA[kind].startsWith('video/');
|
|
8356
|
+
const player = document.createElement(video ? 'video' : 'audio');
|
|
8357
|
+
player.controls = true; player.preload = 'metadata'; player.className = `preview-media${video ? ' preview-video' : ''}`;
|
|
8358
|
+
player.setAttribute('playsinline', '');
|
|
8359
|
+
player.addEventListener('error', () => { if (!$('viewer').hidden && $('preview-name').textContent === name) cannot(`${size ? `${sizeOf(size)} · ` : ''}This browser cannot play this file.`); }, { once: true });
|
|
8360
|
+
if (size && size > MEDIA_MAX) { player.src = address; $('preview-body').replaceChildren(player); note(''); return; }
|
|
8361
|
+
note('Loading...');
|
|
8362
|
+
let got;
|
|
8363
|
+
try {
|
|
8364
|
+
const r = await fetch(address);
|
|
8365
|
+
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'The file could not be read.');
|
|
8366
|
+
got = await r.arrayBuffer();
|
|
8367
|
+
} catch (error) { cannot(error.message); return; }
|
|
8368
|
+
if ($('viewer').hidden || $('preview-name').textContent !== name) return;
|
|
8369
|
+
shownUrl = URL.createObjectURL(new Blob([got], { type: MEDIA[kind] }));
|
|
8370
|
+
player.src = shownUrl; $('preview-body').replaceChildren(player); note('');
|
|
8371
|
+
return;
|
|
8372
|
+
}
|
|
8348
8373
|
const known = PICTURES[kind] || kind === 'pdf' || TEXTS.includes(kind) || SHEETS.includes(kind) || kind === 'docx';
|
|
8349
8374
|
if (!known) { cannot(`${size ? `${sizeOf(size)} · ` : ''}This kind of file cannot be shown here.`); return; }
|
|
8350
8375
|
if (size > (TEXTS.includes(kind) ? TEXT_MAX : PREVIEW_MAX)) { cannot(`${sizeOf(size)} · Too large to be shown here.`); return; }
|
package/web/style.css
CHANGED
|
@@ -247,6 +247,8 @@ footer button.careful { border-style: dashed; color: var(--ink2); }
|
|
|
247
247
|
#viewer button { min-height: 40px; }
|
|
248
248
|
#viewer p { margin: 0; }
|
|
249
249
|
#preview-body { overflow: auto; flex: 1; min-height: 0; }
|
|
250
|
+
#preview-body .preview-media { display: block; width: 100%; max-width: 720px; margin: 16px auto; }
|
|
251
|
+
#preview-body .preview-video { max-height: 100%; background: #000; border-radius: 6px; }
|
|
250
252
|
#preview-body img, #preview-body canvas { display: block; max-width: 100%; height: auto; margin: 0 auto 10px; background: #fff; border-radius: 4px; }
|
|
251
253
|
#preview-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font: .8125rem/1.45 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); margin: 0; }
|
|
252
254
|
|