clavarium 0.2.252-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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.252-next.1",
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.252-next.1",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.252-next.1",
3
+ "version": "0.2.253-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.",
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