clavarium 0.2.130-beta.1 → 0.2.131-beta.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.130-beta.1",
3
+ "version": "0.2.131-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.130-beta.1",
9
+ "version": "0.2.131-beta.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.130-beta.1",
3
+ "version": "0.2.131-beta.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
@@ -99,6 +99,62 @@
99
99
  };
100
100
 
101
101
  const say = (label, kind) => { state.textContent = label; state.dataset.state = kind; };
102
+ /* THE MASCOT (02-11): a small animal drawn above the words while a conversation goes to sleep, sleeps,
103
+ or wakes. All of it is HERE -- the drawing -- and in style.css under .mascot -- its poses: another
104
+ animal, or other movements, is changed in one place. Poses: 'asleep' (lies, eyes shut, breathes, z's),
105
+ 'waking' (rises in one movement, an ear flick, a blink), '' (standing). A device asking for less
106
+ motion sees still pictures. */
107
+ const scallops = (cx, cy, rx, ry, n, depth) => {
108
+ let d = '';
109
+ for (let i = 0; i <= n; i++) {
110
+ const a = (i / n) * Math.PI * 2; const x = cx + rx * Math.cos(a); const y = cy + ry * Math.sin(a);
111
+ if (i === 0) { d += `M${x.toFixed(1)} ${y.toFixed(1)}`; continue; }
112
+ const m = ((i - 0.5) / n) * Math.PI * 2;
113
+ d += ` Q${(cx + (rx + depth) * Math.cos(m)).toFixed(1)} ${(cy + (ry + depth) * Math.sin(m)).toFixed(1)} ${x.toFixed(1)} ${y.toFixed(1)}`;
114
+ }
115
+ return `${d} Z`;
116
+ };
117
+ const MASCOTS = {
118
+ sheep: () => `<svg viewBox="0 0 150 112" aria-hidden="true">
119
+ <g class="m-legs"><path class="m-line m-leg" d="M46 82 l-1 16 h4"/><path class="m-line m-leg" d="M60 85 l0 14 h4"/><path class="m-line m-leg" d="M84 85 l0 14 h4"/><path class="m-line m-leg" d="M97 82 l1 16 h4"/></g>
120
+ <g class="m-body">
121
+ <path class="m-line m-fill" d="${scallops(72, 62, 42, 27, 14, 9)}"/>
122
+ <path class="m-soft" d="M52 56 q4 -6 8 0"/><path class="m-soft" d="M70 48 q4 -6 8 0"/><path class="m-soft" d="M60 70 q4 -6 8 0"/><path class="m-soft" d="M80 66 q4 -6 8 0"/>
123
+ <g class="m-head">
124
+ <path class="m-line m-fill m-ear" d="M110 47 c-4 -6 -12 -8 -17 -5 c4 5 11 7 17 5 z"/>
125
+ <path class="m-line m-fill" d="M106 44 c8 -6 20 -2 24 10 c3 9 2 18 -4 22 c-5 3 -12 1 -16 -4 c-5 -6 -8 -14 -6 -22 z"/>
126
+ <path class="m-line m-fill" d="${scallops(114, 43, 9, 4.5, 6, 3.5)}"/>
127
+ <ellipse class="m-eye" cx="120" cy="53" rx="2.1" ry="2.7"/>
128
+ <path class="m-shut" d="M117 54 q3 2.4 6 0"/>
129
+ <ellipse class="m-blush" cx="117" cy="62" rx="3.4" ry="2.1"/>
130
+ <path class="m-line m-thin" d="M126 70 q-2 2 -4 1"/>
131
+ </g>
132
+ </g>
133
+ </svg>`,
134
+ };
135
+ const MASCOT = 'sheep';
136
+ const mascot = (pose) => {
137
+ let m = document.getElementById('notice-mascot'); /* not $(): it gives a stand-in when there is none */
138
+ if (pose === null) { if (m) m.hidden = true; return; }
139
+ if (!m) {
140
+ m = document.createElement('div'); m.id = 'notice-mascot'; m.className = 'mascot';
141
+ m.innerHTML = `${MASCOTS[MASCOT]()}<span class="m-z">z</span><span class="m-z">z</span><span class="m-z">z</span>`;
142
+ $('notice-text').before(m);
143
+ }
144
+ m.hidden = false;
145
+ const was = m.dataset.pose ?? '';
146
+ if (pose === 'waking') {
147
+ if (was === 'waking') return;
148
+ /* From lying, in one movement: the breathing stops first, then it rises. */
149
+ m.classList.add('asleep', 'stirring'); m.dataset.pose = 'waking';
150
+ requestAnimationFrame(() => requestAnimationFrame(() => { m.classList.remove('asleep'); m.classList.add('waking'); }));
151
+ return;
152
+ }
153
+ m.classList.remove('waking', 'stirring');
154
+ m.classList.toggle('asleep', pose === 'asleep');
155
+ m.dataset.pose = pose;
156
+ };
157
+
102
158
  const show = (text, action, run, cancel) => {
103
159
  $('notice-text').textContent = text;
104
160
  $('notice-action').textContent = action ?? '';
@@ -110,6 +166,7 @@
110
166
  notice.hidden = false;
111
167
  $('notice-spin').hidden = true; $('notice-steps').hidden = true;
112
168
  $('notice-head').hidden = true; delete notice.dataset.progress; delete notice.dataset.loading;
169
+ mascot(null);
113
170
  };
114
171
  /* A terminal on its way: a neutral word and the wheel, nothing that sounds like a fault. It
115
172
  covers only when the terminal is what is on screen -- not the chat already there, which a tab
@@ -200,6 +257,7 @@
200
257
  }
201
258
  const s = Math.max(0, Math.floor((Date.now() - (Date.parse(p.since ?? '') || Date.now())) / 1000));
202
259
  $('notice-title').textContent = PROGRESS_TITLES[p.kind] ?? 'Starting';
260
+ mascot(p.kind === 'wake' ? 'waking' : null);
203
261
  $('notice-count').textContent = `Step ${at + 1} of ${p.steps.length} \u00b7 ${clockOf(s)}`;
204
262
  $('notice-text').textContent = usualFor(p.kind, s);
205
263
  return true;
@@ -914,7 +972,7 @@
914
972
  /* Given its chat and not its terminal: the chat is the whole page, and no terminal is ever opened. */
915
973
  if (noTerminal()) { chatAlone(); return; }
916
974
  /* Asleep because somebody asked: it stays asleep until somebody asks. */
917
- if (c && c.asleep === true && !socket) { say('asleep', 'waiting'); show(`Asleep. The tool is frozen as it was.${c.sizeAtWake ? ` When it wakes, its machine is restarted with its new size (${laterWords(c.sizeAtWake)}), and the tool takes up its session.` : ''}`, 'Wake it', connect); return; }
975
+ if (c && c.asleep === true && !socket) { say('asleep', 'waiting'); show(`Asleep. The tool is frozen as it was.${c.sizeAtWake ? ` When it wakes, its machine is restarted with its new size (${laterWords(c.sizeAtWake)}), and the tool takes up its session.` : ''}`, 'Wake it', connect); mascot('asleep'); return; }
918
976
  if (!socket) { terminal.reset(); connect(); }
919
977
  void watchSignIn();
920
978
  }
@@ -2661,7 +2719,7 @@
2661
2719
  math: { url: new URL('vendor/katex/katex.mjs', new URL(DEVICE ? '/c/' : '/', location.href)).href },
2662
2720
  refs: {
2663
2721
  label: (ref) => (/^file:\/(work|resources)\//.test(ref) ? 'Open' : null),
2664
- open: (ref) => { const m = /^file:\/(work|resources\/[^/]+)\/(.+)$/.exec(ref); if (!m) return; const tab = m[1] === 'work' ? 'work' : m[1].slice('resources/'.length); void preview(tab, m[2], m[2].split('/').pop(), 0); },
2722
+ open: (ref) => { const m = /^file:\/(work|resources\/[^/]+)\/(.+)$/.exec(ref); if (!m) return; const tab = m[1] === 'work' ? 'work' : m[1].slice('resources/'.length); void openFromChat(tab, m[2]); },
2665
2723
  },
2666
2724
  /* A reaction to one of its messages: wherever the chat may be written in. */
2667
2725
  ...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
@@ -2675,7 +2733,7 @@
2675
2733
  ...(!DEVICE || deviceParts.chat === 'write' ? { attach: { upload: (file) => attachToChat(name, file) } } : {}),
2676
2734
  /* Its terminal, when this device was given it. */
2677
2735
  /* A file the tool showed opens in the window when it is in its work folder or an attached folder ("work:report.html"). */
2678
- open: (file) => { if (!file.open) return; const at = file.open.indexOf(':'); const tab = file.open.slice(0, at); const inner = file.open.slice(at + 1); void preview(tab, inner, inner.split('/').pop(), 0); },
2736
+ open: (file) => { if (!file.open) return; const at = file.open.indexOf(':'); const tab = file.open.slice(0, at); const inner = file.open.slice(at + 1); void openFromChat(tab, inner); },
2679
2737
  ...(noTerminal() ? {} : { terminal: () => seeTerminal() }),
2680
2738
  /* What the tool writes is rendered (Parley builds it element by element), and named by its tool. */
2681
2739
  /* Named as its owner chose, else by the neutral word of the dictionary; its tool, small, in the detailed view. */
@@ -8229,17 +8287,28 @@
8229
8287
  /* A file read from the machine's disk says so, whatever else is said. */
8230
8288
  const origin = from ? 'Read from the disk of the machine: this file is not kept here, and goes with the machine.' : '';
8231
8289
  const note = (text) => { const all = [text, text === 'Loading...' ? '' : origin].filter(Boolean).join(' '); $('preview-note').textContent = all; $('preview-note').hidden = !all; };
8290
+ /* NOTHING TO SHOW (02-11): not an empty frame, but a file, why, and a Download button that is seen. */
8291
+ const cannot = (why) => {
8292
+ const box = el('div', 'preview-cannot');
8293
+ const icon = el('div', 'preview-cannot-icon'); icon.setAttribute('aria-hidden', 'true');
8294
+ icon.innerHTML = '<svg class="ic" viewBox="0 0 24 24"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/></svg>';
8295
+ const get = el('a', 'button primary preview-cannot-get'); get.href = address; get.setAttribute('download', name);
8296
+ get.innerHTML = '<svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4v11"/><path d="m7 11 5 5 5-5"/><path d="M5 20h14"/></svg>';
8297
+ get.append(document.createTextNode(' Download'));
8298
+ box.append(icon, el('b', 'preview-cannot-name', name), el('p', 'hint', why), get);
8299
+ $('preview-body').replaceChildren(box); note('');
8300
+ };
8232
8301
  const kind = name.includes('.') ? name.split('.').pop().toLowerCase() : '';
8233
8302
  const known = PICTURES[kind] || kind === 'pdf' || TEXTS.includes(kind);
8234
- if (!known) { note('This kind of file is not shown here. Download it to open it.'); return; }
8235
- if (size > (TEXTS.includes(kind) ? TEXT_MAX : PREVIEW_MAX)) { note(`This file is too large to be shown here (${sizeOf(size)}). Download it to open it.`); return; }
8303
+ if (!known) { cannot(`${size ? `${sizeOf(size)} · ` : ''}This kind of file cannot be shown here.`); return; }
8304
+ if (size > (TEXTS.includes(kind) ? TEXT_MAX : PREVIEW_MAX)) { cannot(`${sizeOf(size)} · Too large to be shown here.`); return; }
8236
8305
  note('Loading...');
8237
8306
  let bytes;
8238
8307
  try {
8239
8308
  const r = await fetch(address);
8240
8309
  if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'The file could not be read.');
8241
8310
  bytes = await r.arrayBuffer();
8242
- } catch (error) { note(error.message); return; }
8311
+ } catch (error) { cannot(error.message); return; }
8243
8312
  if ($('viewer').hidden || $('preview-name').textContent !== name) return; /* closed meanwhile */
8244
8313
  const body = $('preview-body');
8245
8314
  if (PICTURES[kind]) {
@@ -8269,7 +8338,7 @@
8269
8338
  if ($('viewer').hidden) return;
8270
8339
  }
8271
8340
  note(doc.numPages > pages ? `The first ${pages} pages of ${doc.numPages}. Download the file to read the rest.` : `${doc.numPages} page${doc.numPages > 1 ? 's' : ''}.`);
8272
- } catch { body.replaceChildren(); note('This PDF could not be shown here. Download it to open it.'); }
8341
+ } catch { cannot('This PDF could not be shown here.'); }
8273
8342
  } else {
8274
8343
  const text = new TextDecoder('utf-8', { fatal: false }).decode(bytes);
8275
8344
  const source = () => { const pre = document.createElement('pre'); pre.className = 'source'; pre.textContent = text; return pre; };
@@ -8519,6 +8588,16 @@
8519
8588
  else on the machine's disk is said to be out of reach. */
8520
8589
  const PATH_ONLY = /^\/(?:work|resources\/[a-z][a-z0-9-]{0,31})(?:\/[A-Za-z0-9._@+%~-]+)+$/;
8521
8590
  const PATH = /\/(?:work|resources\/[a-z][a-z0-9-]{0,31})(?:\/[A-Za-z0-9._@+%~-]+)+/g;
8591
+ /* FROM THE CHAT (02-11): a folder named in a message is listed, as in Assets -- not an empty preview. */
8592
+ async function openFromChat(tab, inner) {
8593
+ const clean = String(inner).replace(/\/+$/, '');
8594
+ const asFolder = await fetch(`${API}/files?${new URLSearchParams({ c: current, r: tab, p: clean })}`).catch(() => null);
8595
+ if (asFolder?.ok) {
8596
+ if (!DEVICE) { showInAssets(tab, clean); return; }
8597
+ filesOf = tab; filesAt = clean; await paintFiles(); showFiles(); return;
8598
+ }
8599
+ await preview(tab, clean, clean.split('/').pop(), 0);
8600
+ }
8522
8601
  async function openPath(text) {
8523
8602
  /* A finger on the terminal also calls the on-screen keyboard: it is
8524
8603
  sent away, the file is what was asked for. */
@@ -9206,7 +9285,7 @@
9206
9285
  leavePanel();
9207
9286
  disconnect();
9208
9287
  say('going to sleep', 'connecting');
9209
- show('Going to sleep...');
9288
+ show('Going to sleep...'); mascot('asleep');
9210
9289
  try { await post(`${API}/conversations/${encodeURIComponent(name)}/sleep`); await refresh(); enter(); }
9211
9290
  catch (error) { say('awake', 'ended'); show(error.message, 'Back to the terminal', connect); }
9212
9291
  }
package/web/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  <link rel="stylesheet" href="/vendor/diff2html.css">
15
15
  <div id="app" data-place="conversations">
16
16
  <aside id="list" hidden>
17
- <div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="primary">+ New</button></span></div>
17
+ <div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="icon-btn new-btn" aria-label="New conversation" title="New conversation"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg></button></span></div>
18
18
  <!-- SEARCH, discreet: opened by the magnifier, "/" or Ctrl+K; filters as it is typed. -->
19
19
  <div id="search" role="search" hidden><input id="search-field" type="search" placeholder="Search" aria-label="Search conversations: name, folder, identifier, tool" autocomplete="off" spellcheck="false" maxlength="60" aria-controls="items"></div>
20
20
  <!-- Needs you and Recent: copies of rows of the list below, by when they were last used (app.js, paint). -->
package/web/style.css CHANGED
@@ -2110,3 +2110,47 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
2110
2110
  .as-live-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-width: 28rem; }
2111
2111
  .as-live-form > button { justify-self: start; margin-top: 4px; }
2112
2112
 
2113
+
2114
+ /* New conversation: a + like its neighbours, in the brass of an action (02-11: the words were loud). */
2115
+ #new.new-btn { color: var(--brass); }
2116
+ #new.new-btn:hover { border-color: var(--brass); }
2117
+
2118
+ /* A file that cannot be shown: its icon, its name, why, and Download, in the middle of the viewer. */
2119
+ .preview-cannot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 40vh; padding: 24px 16px; text-align: center; }
2120
+ .preview-cannot-icon .ic { width: 56px; height: 56px; stroke-width: 1.2; color: var(--ink2); }
2121
+ .preview-cannot-name { overflow-wrap: anywhere; max-width: 32rem; }
2122
+ .preview-cannot .hint { margin: 0; max-width: 32rem; }
2123
+ .preview-cannot-get { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; text-decoration: none; }
2124
+ .preview-cannot-get .ic { width: 18px; height: 18px; }
2125
+
2126
+ /* THE MASCOT: a line drawing in the colour of the text, on nothing (02-11). Its poses -- every animal drawn
2127
+ in app.js (MASCOTS) uses these class names: m-body, m-head, m-legs, m-ear, m-eye, m-shut, m-z. */
2128
+ .mascot { position: relative; width: 132px; height: 99px; margin: 0 auto 6px; color: var(--ink, currentColor); }
2129
+ .mascot svg { width: 100%; height: 100%; overflow: visible; }
2130
+ .mascot .m-line { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
2131
+ .mascot .m-fill { fill: var(--bg); }
2132
+ .mascot .m-thin { stroke-width: 1.8; }
2133
+ .mascot .m-soft { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; opacity: .55; }
2134
+ .mascot .m-eye { fill: currentColor; }
2135
+ .mascot .m-shut { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; opacity: 0; }
2136
+ .mascot .m-blush { fill: #e8a3a3; opacity: .55; }
2137
+ .mascot .m-body, .mascot .m-head, .mascot .m-legs, .mascot .m-ear, .mascot .m-eye, .mascot .m-shut { transition: transform 1.2s cubic-bezier(.45,.05,.35,1), opacity .6s ease; }
2138
+ .mascot .m-head { transform-origin: 108px 56px; } .mascot .m-ear { transform-origin: 110px 47px; } .mascot .m-body { transform-origin: 75px 90px; }
2139
+ .mascot.asleep .m-legs { opacity: 0; transform: translateY(-10px); }
2140
+ .mascot.asleep .m-body { transform: translateY(12px) scale(1.02, .96); animation: m-breathe 3.2s ease-in-out 1.2s infinite; }
2141
+ .mascot.asleep .m-head { transform: rotate(14deg) translateY(3px); }
2142
+ .mascot.asleep .m-ear { transform: rotate(10deg); }
2143
+ .mascot.asleep .m-eye { opacity: 0; } .mascot.asleep .m-shut { opacity: 1; }
2144
+ .mascot.stirring .m-body { animation: none; }
2145
+ .mascot.waking .m-legs { transition-delay: .25s; }
2146
+ .mascot.waking .m-ear { animation: m-flick .5s ease .7s 2; }
2147
+ @keyframes m-breathe { 0%, 100% { transform: translateY(12px) scale(1.02, .96); } 50% { transform: translateY(11px) scale(1.03, .99); } }
2148
+ @keyframes m-flick { 50% { transform: rotate(-16deg); } }
2149
+ .mascot .m-z { position: absolute; left: 82%; top: -6%; font: 600 15px var(--sans, system-ui); color: var(--ink2); opacity: 0; pointer-events: none; }
2150
+ .mascot.asleep .m-z { animation: m-zz 2.8s ease-in infinite; }
2151
+ .mascot.asleep .m-z:nth-of-type(2) { animation-delay: .95s; font-size: 12px; }
2152
+ .mascot.asleep .m-z:nth-of-type(3) { animation-delay: 1.9s; font-size: 10px; }
2153
+ @keyframes m-zz { 0% { opacity: 0; transform: translate(0, 0); } 20% { opacity: .9; } 100% { opacity: 0; transform: translate(18px, -42px); } }
2154
+ @media (prefers-reduced-motion: reduce) { .mascot *, .mascot { animation: none !important; transition: none !important; } }
2155
+ .preview-cannot .ic { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
2156
+ .preview-cannot-get .ic { stroke-width: 2.2; }