clavarium 0.2.236-next.1 → 0.2.239-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.236-next.1",
3
+ "version": "0.2.239-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.236-next.1",
9
+ "version": "0.2.239-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.236-next.1",
3
+ "version": "0.2.239-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
@@ -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. */
@@ -8530,6 +8588,16 @@
8530
8588
  else on the machine's disk is said to be out of reach. */
8531
8589
  const PATH_ONLY = /^\/(?:work|resources\/[a-z][a-z0-9-]{0,31})(?:\/[A-Za-z0-9._@+%~-]+)+$/;
8532
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
+ }
8533
8601
  async function openPath(text) {
8534
8602
  /* A finger on the terminal also calls the on-screen keyboard: it is
8535
8603
  sent away, the file is what was asked for. */
@@ -9217,7 +9285,7 @@
9217
9285
  leavePanel();
9218
9286
  disconnect();
9219
9287
  say('going to sleep', 'connecting');
9220
- show('Going to sleep...');
9288
+ show('Going to sleep...'); mascot('asleep');
9221
9289
  try { await post(`${API}/conversations/${encodeURIComponent(name)}/sleep`); await refresh(); enter(); }
9222
9290
  catch (error) { say('awake', 'ended'); show(error.message, 'Back to the terminal', connect); }
9223
9291
  }
package/web/style.css CHANGED
@@ -2122,3 +2122,33 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
2122
2122
  .preview-cannot .hint { margin: 0; max-width: 32rem; }
2123
2123
  .preview-cannot-get { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; text-decoration: none; }
2124
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; } }