clavarium 0.2.24-next.1 → 0.2.24-next.2
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 +6 -6
- package/package.json +2 -2
- package/server/api.mjs +7 -2
- package/server/events.mjs +2 -0
- package/server/guide.mjs +1 -1
- package/server/main.mjs +15 -2
- package/server/secrets.mjs +86 -16
- package/server/talk.mjs +2 -2
- package/web/app.js +113 -14
- package/web/index.html +1 -0
- package/web/links.js +164 -114
- package/web/style.css +34 -33
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.24-next.
|
|
3
|
+
"version": "0.2.24-next.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.24-next.
|
|
9
|
+
"version": "0.2.24-next.2",
|
|
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-docket": "0.1.0",
|
|
15
|
-
"clavarium-parley": "0.15.0-next.
|
|
15
|
+
"clavarium-parley": "0.15.0-next.2",
|
|
16
16
|
"mermaid": "11.17.2",
|
|
17
17
|
"node-pty": "^1.1.0",
|
|
18
18
|
"pdfjs-dist": "6.4.299",
|
|
@@ -700,9 +700,9 @@
|
|
|
700
700
|
}
|
|
701
701
|
},
|
|
702
702
|
"node_modules/clavarium-parley": {
|
|
703
|
-
"version": "0.15.0-next.
|
|
704
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.15.0-next.
|
|
705
|
-
"integrity": "sha512-
|
|
703
|
+
"version": "0.15.0-next.2",
|
|
704
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.15.0-next.2.tgz",
|
|
705
|
+
"integrity": "sha512-rOH6fyC52iE6XLZI+EqSbJxQdzZIyvdHHAl3224JV/x/6xr6+S0tPuKy3Y/bUZM8M6+pnZ+5hyPacCH9pykoVA==",
|
|
706
706
|
"license": "MIT",
|
|
707
707
|
"bin": {
|
|
708
708
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.24-next.
|
|
3
|
+
"version": "0.2.24-next.2",
|
|
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.",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
47
|
"clavarium-docket": "0.1.0",
|
|
48
|
-
"clavarium-parley": "0.15.0-next.
|
|
48
|
+
"clavarium-parley": "0.15.0-next.2",
|
|
49
49
|
"mermaid": "11.17.2",
|
|
50
50
|
"node-pty": "^1.1.0",
|
|
51
51
|
"pdfjs-dist": "6.4.299",
|
package/server/api.mjs
CHANGED
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
* GET /api/conversations/<name>/signin {available, configured, host, user, items}
|
|
67
67
|
* POST /api/conversations/<name>/signin {host, port?, user, password}; empty host removes
|
|
68
68
|
* GET /api/secrets names only: a value never comes back
|
|
69
|
-
* POST /api/secrets {name, value} create or replace
|
|
69
|
+
* POST /api/secrets {name, value, expires?} create or replace; expires YYYY-MM-DD
|
|
70
|
+
* POST /api/secrets/<NAME>/replace {value?, expires?}: in place, its name and grants kept; '' removes the expiry
|
|
70
71
|
* POST /api/secrets/<NAME>/remove
|
|
71
72
|
* POST /api/secrets/<NAME>/rename {name}: its value and where it is handed go with it
|
|
72
73
|
* GET /api/conversations/<name>/health-react POST the same {on?, message?, command?}: what it does when its machine is short
|
|
@@ -415,6 +416,9 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
415
416
|
}
|
|
416
417
|
const renaming = /^\/api\/secrets\/([A-Z][A-Z0-9_]{0,39})\/rename$/.exec(pathname);
|
|
417
418
|
if (renaming && secrets) return send(200, secrets.rename(renaming[1], String(body.name ?? '').trim())), true;
|
|
419
|
+
/* A new value (never sent back) and/or a new expiry, in place. */
|
|
420
|
+
const replacing = /^\/api\/secrets\/([A-Z][A-Z0-9_]{0,39})\/replace$/.exec(pathname);
|
|
421
|
+
if (replacing && secrets) return send(200, secrets.replace(replacing[1], { value: body.value, expires: body.expires })), true;
|
|
418
422
|
const dropped = /^\/api\/secrets\/([A-Z][A-Z0-9_]{0,39})\/remove$/.exec(pathname);
|
|
419
423
|
if (dropped && secrets) { secrets.remove(dropped[1]); return send(200, { ok: true }), true; }
|
|
420
424
|
if (pathname === '/api/alerts' && alerts) return send(201, alerts.add(body.subscription, body.label)), true;
|
|
@@ -437,7 +441,8 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
437
441
|
if (talking[2] === '/remind') return send(200, await talk.remind(conversation)), true;
|
|
438
442
|
if (talking[2] === '/react') return send(200, await talk.react(conversation, body.to, body.reaction ?? null)), true;
|
|
439
443
|
if (typeof body.on === 'boolean') { const now = await talk.set(conversation, body.on); retell(conversation); return send(200, now), true; }
|
|
440
|
-
|
|
444
|
+
/* What the chat may add to an answer: the choices ticked, the answers of a group, the zone of a picture it is about (Parley checks each). */
|
|
445
|
+
return send(201, await talk.say(conversation, body.text, body.answers, body.files, body.via, { picked: body.picked, replies: body.replies, about: body.about })), true;
|
|
441
446
|
}
|
|
442
447
|
const docketed = /^\/api\/conversations\/([^/]+)\/docket(\/cancel)?$/.exec(pathname);
|
|
443
448
|
if (docketed && wakeups) {
|
package/server/events.mjs
CHANGED
|
@@ -42,6 +42,8 @@ const SAID = [
|
|
|
42
42
|
[/^\/api\/resources\/([^/]+)\/remove$/, 'asset', (m) => `${clip(decodeURIComponent(m[1]), 40)} removed (its content put aside)`],
|
|
43
43
|
[/^\/api\/secrets$/, 'asset', (m, b) => `Secret ${clip(b.name, 40)} set`],
|
|
44
44
|
[/^\/api\/secrets\/([^/]+)\/remove$/, 'asset', (m) => `Secret ${clip(m[1], 40)} removed`],
|
|
45
|
+
/* Never the value: only that it was replaced, and the expiry. */
|
|
46
|
+
[/^\/api\/secrets\/([^/]+)\/replace$/, 'asset', (m, b) => `Secret ${clip(m[1], 40)}: ${[...(b.value ? ['value replaced'] : []), ...(b.expires === undefined ? [] : [b.expires ? `expires ${clip(b.expires, 10)}` : 'no expiry'])].join(', ') || 'unchanged'}`],
|
|
45
47
|
[/^\/api\/secrets\/([^/]+)\/rename$/, 'asset', (m, b) => `Secret ${clip(m[1], 40)} renamed ${clip(b.name, 40)}`],
|
|
46
48
|
[/^\/api\/git\/([^/]+)\/push$/, 'asset', (m, b) => `${clip(decodeURIComponent(m[1]), 40)}: a commit sent${b.target ? ` to ${clip(b.target, 40)}` : ''}`],
|
|
47
49
|
[/^\/api\/mailboxes$/, 'asset', (m, b) => `Mailbox ${clip(b.name, 40)} added`],
|
package/server/guide.mjs
CHANGED
|
@@ -207,7 +207,7 @@ export class Guide {
|
|
|
207
207
|
const type = this.#resources.get(r.name)?.type ?? 'folder';
|
|
208
208
|
return { name: r.name, access: r.access, type, origin: type === 'git' && this.#resources.hasOrigin?.(r.name) ? originFolder(r.name) : undefined };
|
|
209
209
|
});
|
|
210
|
-
return ownText({ name, tool: this.#tool(c)?.label ?? c.tool, workKept: c.work === 'kept', resources, chat: Boolean(this.#chat(name)), online: c.offline !== true, secrets: this.#secrets?.of(name) ?? [], lines: this.lines(name) });
|
|
210
|
+
return ownText({ name, tool: this.#tool(c)?.label ?? c.tool, workKept: c.work === 'kept', resources, chat: Boolean(this.#chat(name)), online: c.offline !== true, secrets: (this.#secrets?.given ?? this.#secrets?.of)?.call(this.#secrets, name) ?? [], lines: this.lines(name) });
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
/* What the page shows: the exact texts, where each is, and the line in the tool's own file. */
|
package/server/main.mjs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* node server/main.mjs --command "your-tool" --cwd /path/to/work
|
|
13
13
|
* no VM: one tool on this machine, at /?c=<name>. For development.
|
|
14
14
|
*/
|
|
15
|
-
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
16
16
|
import { createHash } from 'node:crypto';
|
|
17
17
|
import { createServer } from 'node:http';
|
|
18
18
|
import { readFile } from 'node:fs/promises';
|
|
@@ -107,6 +107,14 @@ export const FILES = {
|
|
|
107
107
|
'/vendor/prism.js': [['web/prism-manual.js', ...['core', 'clike', 'markup', 'css', 'javascript', 'typescript', 'json', 'python', 'bash', 'markup-templating', 'php', 'sql', 'yaml', 'diff', 'markdown', 'ini', 'apacheconf']
|
|
108
108
|
.map((l) => packageFile('prismjs', `components/prism-${l}.min.js`))], 'text/javascript; charset=utf-8'],
|
|
109
109
|
};
|
|
110
|
+
/* Formulas in the chat are drawn by Parley with its own copy of KaTeX, loaded on the first formula
|
|
111
|
+
(the page tells it where: /vendor/katex/katex.mjs): served as Parley ships it, fonts included. */
|
|
112
|
+
try {
|
|
113
|
+
const katex = packageFile(PARLEY, 'ui/vendor/katex');
|
|
114
|
+
FILES['/vendor/katex/katex.mjs'] = [`${katex}/katex.mjs`, 'text/javascript; charset=utf-8'];
|
|
115
|
+
FILES['/vendor/katex/katex.min.css'] = [`${katex}/katex.min.css`, 'text/css; charset=utf-8'];
|
|
116
|
+
for (const font of readdirSync(`${katex}/fonts`)) if (/^[\w.-]+\.woff2$/.test(font)) FILES[`/vendor/katex/fonts/${font}`] = [`${katex}/fonts/${font}`, 'font/woff2'];
|
|
117
|
+
} catch { /* a Parley without it: formulas shown as their text */ }
|
|
110
118
|
/* The device door serves the same files under /c/: that prefix is the only
|
|
111
119
|
one the edge lets through without sign-on. Its page differs; nothing else. */
|
|
112
120
|
const DEVICE_FILES = Object.fromEntries(Object.entries(FILES).filter(([path]) => path !== '/').map(([path, file]) => [`/c${path}`, file]));
|
|
@@ -292,6 +300,10 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
292
300
|
const secrets = new Secrets({ store: new Store(`${dataDir}/secrets.json`), vault, vms, grants });
|
|
293
301
|
/* A secret renamed: what names it follows (the key of dictation). `voice` is made below. */
|
|
294
302
|
secrets.renamed = (from, to) => voice.secretRenamed(from, to);
|
|
303
|
+
/* Expired: kept, no longer delivered; said once in What happened. */
|
|
304
|
+
secrets.expired = (name, users) => { events.add({ kind: 'asset', text: `Secret ${name} expired: no longer given${users.length ? ` to ${users.join(', ')}` : ''}` }); };
|
|
305
|
+
secrets.check();
|
|
306
|
+
const expiryTimer = setInterval(() => secrets.check(), 10 * 60_000); expiryTimer.unref();
|
|
295
307
|
const signin = new SignInMailboxes({ store: new Store(`${dataDir}/signin.json`), vault, rules: (name) => all.signinRules(name) });
|
|
296
308
|
/* Each opening: the runner and the attached secrets are put in the VM,
|
|
297
309
|
and the tool is started through the runner. */
|
|
@@ -316,6 +328,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
316
328
|
const parleySaid = new Map();
|
|
317
329
|
all.prepare = async (name, woke) => {
|
|
318
330
|
await hostReady;
|
|
331
|
+
secrets.check();
|
|
319
332
|
const wanted = secrets.signature(name);
|
|
320
333
|
const rules = network.apply();
|
|
321
334
|
if (woke || delivered.get(name) !== wanted) {
|
|
@@ -467,7 +480,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
467
480
|
const watching = setInterval(() => { void team.watch().catch(() => {}); }, 60_000); watching.unref?.();
|
|
468
481
|
}
|
|
469
482
|
const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
|
|
470
|
-
server.on('close', () => { closing = true; clearInterval(historyTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
483
|
+
server.on('close', () => { closing = true; clearInterval(historyTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
471
484
|
let closing = false;
|
|
472
485
|
bridge = attachBridge(server, {
|
|
473
486
|
onRejoin: (name) => all.rejoin(name),
|
package/server/secrets.mjs
CHANGED
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* never in a log, never back to a browser: once saved, a value cannot be
|
|
13
13
|
* read again from the page, only replaced.
|
|
14
14
|
*
|
|
15
|
+
* EXPIRY (optional, a day, like a token's): from that day on the secret is
|
|
16
|
+
* kept -- never deleted by itself -- but no longer delivered; WARN_DAYS
|
|
17
|
+
* before, the page says it is near. Days are those of this server's clock.
|
|
18
|
+
*
|
|
15
19
|
* WHAT IT IS NOT: protected from the tool. The agent is root in its VM and
|
|
16
20
|
* can read and send anywhere whatever is delivered there. A secret the host
|
|
17
21
|
* should use on the agent's behalf (a push key, a mailbox password) does not
|
|
@@ -25,6 +29,9 @@ import { VM_USER } from './vm.mjs';
|
|
|
25
29
|
export const SECRETS_DIR = '/run/secrets';
|
|
26
30
|
export const RUNNER = '/usr/local/bin/clv-run';
|
|
27
31
|
export const VALUE_MAX = 8 * 1024;
|
|
32
|
+
export const WARN_DAYS = 7;
|
|
33
|
+
const DAY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
34
|
+
const DAY_MS = 86_400_000;
|
|
28
35
|
const NAME = /^[A-Z][A-Z0-9_]{0,39}$/;
|
|
29
36
|
/* Names the tool's own start depends on must not be replaced by a secret. */
|
|
30
37
|
const RESERVED = new Set(['PATH', 'HOME', 'USER', 'SHELL', 'TERM', 'LANG', 'PWD', 'IFS', 'LD_PRELOAD', 'LD_LIBRARY_PATH']);
|
|
@@ -45,15 +52,29 @@ done
|
|
|
45
52
|
exec "$@"
|
|
46
53
|
`;
|
|
47
54
|
|
|
55
|
+
/* A day as YYYY-MM-DD, or '' / null for none; anything else is refused. */
|
|
56
|
+
export function expiryOf(value) {
|
|
57
|
+
if (value === undefined || value === null || value === '') return null;
|
|
58
|
+
const m = DAY.exec(String(value));
|
|
59
|
+
const d = m && new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
60
|
+
if (!d || d.toISOString().slice(0, 10) !== value || Number(m[1]) < 2000) throw new Refusal(400, 'An expiry is a day, as YYYY-MM-DD.');
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
/* Whole days from today (this server's local day) to that day: 0 or less, expired. */
|
|
64
|
+
export function daysTo(day, now = new Date()) {
|
|
65
|
+
const m = DAY.exec(day);
|
|
66
|
+
return Math.round((Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])) - Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())) / DAY_MS);
|
|
67
|
+
}
|
|
68
|
+
|
|
48
69
|
const firstLine = (text) => String(text ?? '').trim().split('\n').filter(Boolean).pop()?.slice(0, 200) ?? '';
|
|
49
70
|
|
|
50
71
|
export class Secrets {
|
|
51
|
-
#store; #vault; #vms; #grants;
|
|
72
|
+
#store; #vault; #vms; #grants; #now;
|
|
52
73
|
|
|
53
74
|
/* `grants`: the one table of rights. "Handed to a conversation" is a
|
|
54
75
|
line of it: the conversation may USE the secret. */
|
|
55
|
-
constructor({ store, vault, vms, grants = new Grants() }) {
|
|
56
|
-
this.#store = store; this.#vault = vault; this.#vms = vms; this.#grants = grants;
|
|
76
|
+
constructor({ store, vault, vms, grants = new Grants(), now = () => new Date() }) {
|
|
77
|
+
this.#store = store; this.#vault = vault; this.#vms = vms; this.#grants = grants; this.#now = now;
|
|
57
78
|
for (const s of store.all()) {
|
|
58
79
|
if (s.attachments === undefined) continue;
|
|
59
80
|
for (const conversation of Object.keys(s.attachments)) this.#grants.give(conversationSubject(conversation), `secret:${s.name}`, 'x');
|
|
@@ -61,25 +82,74 @@ export class Secrets {
|
|
|
61
82
|
}
|
|
62
83
|
}
|
|
63
84
|
#handed(conversation, name) { return this.#grants.can(conversationSubject(conversation), `secret:${name}`, 'x'); }
|
|
85
|
+
#expired(s) { return Boolean(s.expires) && daysTo(s.expires, this.#now()) <= 0; }
|
|
86
|
+
#users(name) { return this.#grants.on(`secret:${name}`).map((g) => g.subject.slice('conversation:'.length)); }
|
|
87
|
+
/* What is delivered to this conversation: handed, and not expired. */
|
|
88
|
+
#given(conversation) { return this.#store.all().filter((s) => this.#handed(conversation, s.name) && !this.#expired(s)); }
|
|
64
89
|
|
|
65
|
-
/* Names
|
|
66
|
-
|
|
90
|
+
/* Names, where they are attached, the expiry. Never a value. `days`: whole
|
|
91
|
+
days left (null without an expiry); `expired`: no longer delivered. */
|
|
92
|
+
list() {
|
|
93
|
+
return this.#store.all().map((s) => ({ name: s.name, conversations: this.#users(s.name), createdAt: s.createdAt,
|
|
94
|
+
expires: s.expires ?? null, days: s.expires ? daysTo(s.expires, this.#now()) : null, expired: this.#expired(s) }));
|
|
95
|
+
}
|
|
96
|
+
/* Handed to it, expired or not (its Assets show both). */
|
|
67
97
|
of(conversation) { return this.#store.all().filter((s) => this.#handed(conversation, s.name)).map((s) => s.name); }
|
|
98
|
+
/* Delivered to it at its next start. */
|
|
99
|
+
given(conversation) { return this.#given(conversation).map((s) => s.name); }
|
|
68
100
|
|
|
69
101
|
/* The value, for this server's own use only (the key of the dictation
|
|
70
102
|
engine, put in a request's header): never returned by any route. */
|
|
71
103
|
reveal(name) { const s = this.#store.get(name); return s ? this.#vault.open(s.sealed) : undefined; }
|
|
72
104
|
|
|
73
|
-
/* Creates, or replaces the value of, a secret.
|
|
74
|
-
|
|
105
|
+
/* Creates, or replaces the value of, a secret. `expires`: a day, '' for
|
|
106
|
+
none, left out to keep the one it had. */
|
|
107
|
+
set({ name, value, expires }) {
|
|
75
108
|
if (!isSecretName(name)) throw new Refusal(400, 'A secret is named like a variable: capitals, digits and underscores, starting with a letter.');
|
|
76
|
-
|
|
77
|
-
|
|
109
|
+
const sealed = this.#seal(value);
|
|
110
|
+
const day = expires === undefined ? undefined : expiryOf(expires);
|
|
78
111
|
const before = this.#store.get(name);
|
|
79
|
-
this.#
|
|
112
|
+
this.#write({ ...before, name, sealed, createdAt: before?.createdAt ?? new Date().toISOString() }, day);
|
|
80
113
|
return { name };
|
|
81
114
|
}
|
|
82
115
|
|
|
116
|
+
/* REPLACED in place, without being seen: a new value (empty keeps the
|
|
117
|
+
one it has) and/or a new expiry ('' removes it). Its name and the
|
|
118
|
+
conversations it is handed to stay; they get it at their next start. */
|
|
119
|
+
replace(name, { value, expires } = {}) {
|
|
120
|
+
const before = this.#store.get(name);
|
|
121
|
+
if (!before) throw new Refusal(404, 'No such secret.');
|
|
122
|
+
const keep = value === undefined || value === null || value === '';
|
|
123
|
+
const day = expires === undefined ? undefined : expiryOf(expires);
|
|
124
|
+
if (keep && day === undefined) throw new Refusal(400, 'Nothing to change: a new value or an expiry.');
|
|
125
|
+
this.#write({ ...before, sealed: keep ? before.sealed : this.#seal(value) }, day);
|
|
126
|
+
return { name, expires: this.#store.get(name).expires ?? null };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#seal(value) {
|
|
130
|
+
if (typeof value !== 'string' || value === '' || Buffer.byteLength(value) > VALUE_MAX) throw new Refusal(400, `A value is between 1 byte and ${VALUE_MAX / 1024} KB.`);
|
|
131
|
+
if (value.includes('\0')) throw new Refusal(400, 'A value cannot contain a null byte.');
|
|
132
|
+
return this.#vault.seal(value);
|
|
133
|
+
}
|
|
134
|
+
/* `day`: undefined keeps the expiry, null removes it. */
|
|
135
|
+
#write(record, day) {
|
|
136
|
+
const next = { ...record };
|
|
137
|
+
if (day !== undefined) { if (day) next.expires = day; else delete next.expires; }
|
|
138
|
+
this.#store.put(next);
|
|
139
|
+
this.check();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* Said once, when it expires (`expired(name, conversations)`): remembered
|
|
143
|
+
with the day said, so a new expiry is said again when it comes. */
|
|
144
|
+
check() {
|
|
145
|
+
for (const s of this.#store.all()) {
|
|
146
|
+
if (!this.#expired(s) || s.expiredSaid === s.expires) continue;
|
|
147
|
+
this.#store.patch(s.name, { expiredSaid: s.expires });
|
|
148
|
+
try { this.expired(s.name, this.#users(s.name)); } catch { /* said nowhere: never a reason to fail */ }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
expired = () => {};
|
|
152
|
+
|
|
83
153
|
/* RENAMED: its value (still sealed, never opened) and the conversations it is handed to go with
|
|
84
154
|
it; `renamed(from, to)` tells what else names it (dictation's key). Delivered under its new
|
|
85
155
|
name at each conversation's next start. */
|
|
@@ -118,12 +188,13 @@ export class Secrets {
|
|
|
118
188
|
/* What a delivery to this conversation would contain, as one string that
|
|
119
189
|
changes whenever a delivery would differ: names and sealed values. */
|
|
120
190
|
signature(conversation) {
|
|
121
|
-
return this.#
|
|
191
|
+
return this.#given(conversation).map((s) => `${s.name}=${s.sealed}`).sort().join('|');
|
|
122
192
|
}
|
|
123
193
|
|
|
124
|
-
/* Puts in the VM exactly the secrets attached NOW, and the
|
|
125
|
-
each time the conversation is opened: a detached
|
|
126
|
-
the VM, a new one appears, and a
|
|
194
|
+
/* Puts in the VM exactly the secrets attached NOW and not expired, and the
|
|
195
|
+
runner. Called each time the conversation is opened: a detached or
|
|
196
|
+
expired secret disappears from the VM, a new one appears, and a
|
|
197
|
+
restarted VM gets them back. */
|
|
127
198
|
async deliver(conversation) {
|
|
128
199
|
const run = async (argv, input) => {
|
|
129
200
|
const r = await this.#vms.exec(conversation, argv, { input });
|
|
@@ -132,8 +203,7 @@ export class Secrets {
|
|
|
132
203
|
await run(['sudo', '-n', 'install', '-m', '0755', '/dev/stdin', RUNNER], RUNNER_SCRIPT);
|
|
133
204
|
await run(['sudo', '-n', 'install', '-d', '-m', '0755', SECRETS_DIR]);
|
|
134
205
|
await run(['sudo', '-n', 'find', SECRETS_DIR, '-mindepth', '1', '-delete']);
|
|
135
|
-
for (const secret of this.#
|
|
136
|
-
if (!this.#handed(conversation, secret.name)) continue;
|
|
206
|
+
for (const secret of this.#given(conversation)) {
|
|
137
207
|
await run(['sudo', '-n', 'install', '-m', '0600', '-o', VM_USER, '-g', VM_USER, '/dev/stdin', `${SECRETS_DIR}/${secret.name}`], this.#vault.open(secret.sealed));
|
|
138
208
|
}
|
|
139
209
|
}
|
package/server/talk.mjs
CHANGED
|
@@ -371,7 +371,7 @@ export class Talk {
|
|
|
371
371
|
return { ...this.of(name), invited: text };
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
async say(name, text, answers, files, via) {
|
|
374
|
+
async say(name, text, answers, files, via, extra) {
|
|
375
375
|
if (!this.of(name).on) throw new Refusal(409, 'Talking through the app is not turned on for this conversation.');
|
|
376
376
|
const given = files === undefined || files === null ? [] : files;
|
|
377
377
|
if (!Array.isArray(given) || given.length > FILES_MAX) throw new Refusal(400, `A message has ${FILES_MAX} files at most.`);
|
|
@@ -386,7 +386,7 @@ export class Talk {
|
|
|
386
386
|
const note = item && typeof item === 'object' && typeof item.note === 'string' ? item.note : '';
|
|
387
387
|
return { path, name: m[2], size: info.size, ...(note ? { note } : {}) };
|
|
388
388
|
});
|
|
389
|
-
try { this.#parley(name).say(text ?? '', answers, attached, { via: via === 'voice' ? 'voice' : undefined }); } catch (error) { if (error instanceof RangeError) throw new Refusal(400, error.message); throw error; }
|
|
389
|
+
try { this.#parley(name).say(text ?? '', answers, attached, { via: via === 'voice' ? 'voice' : undefined, ...(extra && typeof extra === 'object' ? { picked: extra.picked, replies: extra.replies, about: extra.about } : {}) }); } catch (error) { if (error instanceof RangeError) throw new Refusal(400, error.message); throw error; }
|
|
390
390
|
const told = await this.#wake(name);
|
|
391
391
|
return { ...this.of(name), told };
|
|
392
392
|
}
|
package/web/app.js
CHANGED
|
@@ -767,8 +767,9 @@
|
|
|
767
767
|
stepText(way);
|
|
768
768
|
}, true);
|
|
769
769
|
let wheelAt = 0;
|
|
770
|
-
/* A picture large in the chat's viewer zooms itself, with a pinch or the wheel: the text is not grown under it.
|
|
771
|
-
|
|
770
|
+
/* A picture large in the chat's viewer zooms itself, with a pinch or the wheel: the text is not grown under it.
|
|
771
|
+
So does the map of Access (links.js). */
|
|
772
|
+
const inViewer = (event) => event.target instanceof Element && Boolean(event.target.closest('.parley-zoom, .lk-scroller'));
|
|
772
773
|
addEventListener('wheel', (event) => {
|
|
773
774
|
if (!event.ctrlKey || inViewer(event)) return;
|
|
774
775
|
event.preventDefault(); event.stopPropagation();
|
|
@@ -1612,12 +1613,24 @@
|
|
|
1612
1613
|
/* THE BAR (G): Chat | Terminal | Assets N, then its settings. What was
|
|
1613
1614
|
given to it is counted on "Assets", and shown there. */
|
|
1614
1615
|
let assetsShown = false; let roomPick = '';
|
|
1616
|
+
/* A secret near or past its expiry (secrets.mjs, WARN_DAYS): a dot on Assets, and on the
|
|
1617
|
+
Assets of a conversation that has it. Read with the list, at most once a minute. */
|
|
1618
|
+
let secretsKnown = []; let secretsReadAt = 0;
|
|
1619
|
+
const secretDue = (s) => s.expired === true || (typeof s.days === 'number' && s.days <= 7);
|
|
1620
|
+
function markSecrets(list) {
|
|
1621
|
+
secretsKnown = Array.isArray(list) ? list : []; secretsReadAt = Date.now();
|
|
1622
|
+
$('nav-assets').toggleAttribute('data-attention', secretsKnown.some(secretDue));
|
|
1623
|
+
$('view-assets').toggleAttribute('data-attention', secretsKnown.some((s) => secretDue(s) && s.conversations.includes(current)));
|
|
1624
|
+
}
|
|
1625
|
+
async function readSecretsNow() { if (!DEVICE) markSecrets(await (await fetch(`${API}/secrets`)).json().catch(() => [])); }
|
|
1615
1626
|
function paintChips() {
|
|
1616
1627
|
if (DEVICE) return;
|
|
1617
1628
|
const c = conversations.find((x) => x.name === current);
|
|
1618
1629
|
$('views').hidden = !c;
|
|
1619
1630
|
const n = (c?.resources?.length ?? 0) + (c?.secrets?.length ?? 0) + (c?.work === 'kept' ? 1 : 0);
|
|
1620
1631
|
$('assets-count').textContent = n ? String(n) : '';
|
|
1632
|
+
$('view-assets').toggleAttribute('data-attention', secretsKnown.some((s) => secretDue(s) && s.conversations.includes(current)));
|
|
1633
|
+
if (Date.now() - secretsReadAt > 60_000) { secretsReadAt = Date.now(); void readSecretsNow().catch(() => {}); }
|
|
1621
1634
|
/* Its title names each of them, with what it may do. */
|
|
1622
1635
|
$('view-assets').title = c ? [...(c.offline === true ? ['offline'] : []), ...(c.resources ?? []).map((r) => `${r.name} - ${r.access}`), ...(c.secrets ?? [])].join(', ') || 'Nothing given yet' : '';
|
|
1623
1636
|
paintViews();
|
|
@@ -2405,7 +2418,15 @@
|
|
|
2405
2418
|
onView: (v) => { chatView = v; try { localStorage.setItem('clavarium-chat-view', v); } catch { /* as above */ } },
|
|
2406
2419
|
load: () => fetch(talkPath(name)).then((r) => r.json()).then(machineLines).then((data) => withMachine(data, name)),
|
|
2407
2420
|
/* `via: 'voice'`: part of it was dictated, said to the tool. */
|
|
2408
|
-
send: (text, answers, files, extra) => post(talkPath(name), { text, answers, ...(files ? { files: files.map((f) => (f.note ? { path: f.path, note: f.note } : f.path)) } : {}), ...(extra?.via === 'voice' ? { via: 'voice' } : {})
|
|
2421
|
+
send: (text, answers, files, extra) => post(talkPath(name), { text, answers, ...(files ? { files: files.map((f) => (f.note ? { path: f.path, note: f.note } : f.path)) } : {}), ...(extra?.via === 'voice' ? { via: 'voice' } : {}),
|
|
2422
|
+
/* The choices ticked, the answers of a group, the zone of a picture the answer is about. */
|
|
2423
|
+
...(extra?.picked ? { picked: extra.picked } : {}), ...(extra?.replies ? { replies: extra.replies } : {}), ...(extra?.about ? { about: extra.about } : {}) }),
|
|
2424
|
+
/* Formulas: Parley's own KaTeX, served here. Zones and people may point to a file of a shared folder (file:/work/...). */
|
|
2425
|
+
math: { url: new URL('vendor/katex/katex.mjs', new URL(DEVICE ? '/c/' : '/', location.href)).href },
|
|
2426
|
+
refs: {
|
|
2427
|
+
label: (ref) => (/^file:\/(work|resources)\//.test(ref) ? 'Open' : null),
|
|
2428
|
+
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); },
|
|
2429
|
+
},
|
|
2409
2430
|
/* A reaction to one of its messages: wherever the chat may be written in. */
|
|
2410
2431
|
...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
|
|
2411
2432
|
/* The buttons of a line of the machine: what this screen may do. */
|
|
@@ -2964,6 +2985,7 @@
|
|
|
2964
2985
|
const name = el('b', '', item.name);
|
|
2965
2986
|
if (item.badge) { const badge = el('span', `as-badge${item.badgeTone ? ` ${item.badgeTone}` : ''}`, item.badge); if (item.badgeTitle) badge.title = item.badgeTitle; name.append(badge); }
|
|
2966
2987
|
const sub = el('small', item.tone ? `as-sub ${item.tone}` : 'as-sub', item.sub ?? '');
|
|
2988
|
+
if (item.dot) { sub.classList.add('status-line'); sub.dataset.tone = item.dot; }
|
|
2967
2989
|
const words = el('span', 'as-words'); words.append(name, sub);
|
|
2968
2990
|
row.append(kindIcon(kind), words);
|
|
2969
2991
|
row.addEventListener('click', () => choose(item.key));
|
|
@@ -2985,6 +3007,21 @@
|
|
|
2985
3007
|
const chapter = (title, ...extra) => { const head = el('div', 'as-chapter'); head.append(el('h3', '', title), ...extra); return head; };
|
|
2986
3008
|
const boxSub = (box) => (!box ? 'mailbox' : box.failure ? box.failure : `${box.messages} message${box.messages === 1 ? '' : 's'}`);
|
|
2987
3009
|
const gitSub = (r) => (r.from ? `from ${hostOf(r.from)}` : 'repository');
|
|
3010
|
+
/* A secret's expiry, as said: `due` when it asks for the person (near, or past). */
|
|
3011
|
+
const secretState = (s) => {
|
|
3012
|
+
if (s.expired) return { text: 'Expired', tone: 'bad', due: true };
|
|
3013
|
+
if (s.days === null || s.days === undefined) return { text: 'No expiry', tone: '', due: false };
|
|
3014
|
+
if (secretDue(s)) return { text: s.days === 1 ? 'Expires tomorrow' : `Expires in ${s.days} days`, tone: 'warn', due: true };
|
|
3015
|
+
return { text: `Expires ${s.expires}`, tone: 'ok', due: false };
|
|
3016
|
+
};
|
|
3017
|
+
const secretItem = (s, sub) => { const st = secretState(s); return st.due ? { sub: st.text, dot: st.tone, tone: st.tone === 'bad' ? 'bad' : '' } : { sub }; };
|
|
3018
|
+
/* Its line on a sheet: the state and the day. */
|
|
3019
|
+
const secretLine = (s, expiredWords) => {
|
|
3020
|
+
const st = secretState(s);
|
|
3021
|
+
const line = el('p', 'status-line secret-expiry-state', st.tone === 'bad' ? `Expired · ${expiredWords}` : st.due ? `${st.text} · ${s.expires}` : st.text);
|
|
3022
|
+
if (st.tone) line.dataset.tone = st.tone;
|
|
3023
|
+
return line;
|
|
3024
|
+
};
|
|
2988
3025
|
|
|
2989
3026
|
/* A repository, on the right: its branch, what would go, the diagram. */
|
|
2990
3027
|
async function gitDetail(holder, name, { place = false, others = false } = {}) {
|
|
@@ -3081,7 +3118,7 @@
|
|
|
3081
3118
|
bar.append(why, together, go);
|
|
3082
3119
|
const said = el('p', 'ts-said'); said.hidden = true; said.setAttribute('role', 'status');
|
|
3083
3120
|
const review = el('div', 'ts-review'); review.hidden = true;
|
|
3084
|
-
holder.append(progress, meter, filters, list, bar,
|
|
3121
|
+
holder.append(progress, meter, said, filters, list, bar, review);
|
|
3085
3122
|
const rows = [];
|
|
3086
3123
|
let filter = 'update';
|
|
3087
3124
|
let sending = false; let checking = false;
|
|
@@ -3153,7 +3190,9 @@
|
|
|
3153
3190
|
together.textContent = p.length > 1 ? `Review the ${p.length} together` : 'Review';
|
|
3154
3191
|
go.disabled = sending || checking || p.length === 0 || running.length > 0 || (!unchecked.length && held.length > 0);
|
|
3155
3192
|
why.textContent = p.length === 0 ? 'Nothing ticked.' : running.length ? 'Checking...' : unchecked.length ? '' : held.length ? `Passing checks are required: ${held.map(label).join(', ')}.` : failed.length ? `Checks did not pass: ${failed.map(label).join(', ')}.` : '';
|
|
3156
|
-
|
|
3193
|
+
/* Once something went and nothing is left ticked, no button that would seem to say nothing went. */
|
|
3194
|
+
go.hidden = !sending && p.length === 0 && rows.some((r) => r.sent?.ok);
|
|
3195
|
+
if (sending) { go.textContent = 'Sending…'; return; }
|
|
3157
3196
|
/* First the checks of what is ticked; then Send. */
|
|
3158
3197
|
if (unchecked.length || running.length) { go.dataset.step = 'check'; go.textContent = `Check ${word}`; return; }
|
|
3159
3198
|
go.dataset.step = 'send';
|
|
@@ -3194,7 +3233,8 @@
|
|
|
3194
3233
|
size.append(el('span', '', what), el('br'), el('span', 'plus', `+${files.reduce((n, f) => n + f.added, 0)}`), ' ', el('span', 'minus', `−${files.reduce((n, f) => n + f.removed, 0)}`));
|
|
3195
3234
|
} else size.append(el('span', 'hint', out.state === 'up-to-date' ? 'nothing' : '-'));
|
|
3196
3235
|
const state = el('div', 'ts-state');
|
|
3197
|
-
if (r.
|
|
3236
|
+
if (r.sending) { const s2 = el('span', 'ts-running'); s2.append(el('span', 'warn', 'Sending…')); state.append(s2); }
|
|
3237
|
+
else if (r.sent) state.append(el('b', r.sent.ok ? 'ok' : 'bad', r.sent.ok ? r.sent.text : '✗ Not sent'));
|
|
3198
3238
|
else if (!out) state.append('');
|
|
3199
3239
|
else if (!ahead) state.append(el('span', out.state === 'diverged' || out.state === 'unreachable' || out.state === 'error' ? 'bad' : 'hint', STATE_SAID[out.state] ?? out.message ?? out.state));
|
|
3200
3240
|
else if (!r.check) state.append(el('span', 'hint', r.picked ? 'to check' : ''));
|
|
@@ -3346,11 +3386,12 @@
|
|
|
3346
3386
|
for (const r of rows) r.sent = null;
|
|
3347
3387
|
paint();
|
|
3348
3388
|
for (const r of p) {
|
|
3389
|
+
r.sending = true; paint();
|
|
3349
3390
|
try {
|
|
3350
3391
|
const sent = await post(`${API}/git/${r.name}/push`, { head: r.out.head, target: r.out.target, ...(r.out.guards?.confirm ? { sure: true } : {}) });
|
|
3351
3392
|
r.sent = { ok: true, text: sent.already ? `✓ Already in ${sent.branch}` : sent.commits > 0 ? `✓ Sent to ${sent.branch}` : `✓ Made ${sent.branch}` };
|
|
3352
3393
|
} catch (error) { r.sent = { ok: false, text: /^Not sent/.test(error.message) ? error.message : `Not sent: ${error.message}` }; }
|
|
3353
|
-
paint();
|
|
3394
|
+
r.sending = false; paint();
|
|
3354
3395
|
}
|
|
3355
3396
|
sending = false; paint();
|
|
3356
3397
|
const ok = p.filter((r) => r.sent?.ok).length;
|
|
@@ -3360,8 +3401,10 @@
|
|
|
3360
3401
|
/* What is left to send, read again; what became of each stays said. */
|
|
3361
3402
|
const kept = new Map(rows.map((r) => [r, r.sent]));
|
|
3362
3403
|
await Promise.all(rows.map((r) => look(r)));
|
|
3363
|
-
|
|
3404
|
+
/* What went is unticked: nothing is offered again for what is done. */
|
|
3405
|
+
for (const r of rows) { r.sent = kept.get(r); if (r.sent?.ok) r.picked = false; }
|
|
3364
3406
|
paint();
|
|
3407
|
+
said.scrollIntoView({ block: 'nearest' });
|
|
3365
3408
|
});
|
|
3366
3409
|
paint();
|
|
3367
3410
|
/* Each repository's branch that moved last, then up to BRANCHES_MORE others of its agent: each row shown as soon as it is read. */
|
|
@@ -3420,7 +3463,8 @@
|
|
|
3420
3463
|
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, badge: access, badgeTone: access, badgeLong: access === 'write' ? 'read and write' : 'read only',
|
|
3421
3464
|
sub: kind === 'git' ? gitSub(r) : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
3422
3465
|
}
|
|
3423
|
-
|
|
3466
|
+
markSecrets(secrets);
|
|
3467
|
+
for (const s2 of secrets.filter((x) => x.conversations.includes(current))) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, ...secretItem(s2, 'name only · used by its agent') });
|
|
3424
3468
|
/* TO SEND, above them all, once it has a repository: every one of them on one screen. */
|
|
3425
3469
|
const gits = items.filter((i) => i.kind === 'git').map((i) => i.name);
|
|
3426
3470
|
const outbox = gits.length ? { key: 'send:all', kind: 'send', name: 'To send', sub: 'every repository, reviewed and sent at once' } : null;
|
|
@@ -3453,6 +3497,7 @@
|
|
|
3453
3497
|
} else if (chosen.kind === 'send') await sendDetail(detail, gits);
|
|
3454
3498
|
else if (chosen.kind === 'git') await gitDetail(detail, chosen.name, { others: gits.length > 1 });
|
|
3455
3499
|
else {
|
|
3500
|
+
if (chosen.secret.expires) detail.append(secretLine(chosen.secret, 'not given to its tool'));
|
|
3456
3501
|
detail.append(el('p', 'hint', 'Handed to its tool as a variable and a file, the next time it starts. Its value is never shown.'), chapter('Used by'));
|
|
3457
3502
|
const list = el('div', 'as-chips');
|
|
3458
3503
|
for (const who of chosen.secret.conversations) list.append(el('span', 'as-chip', shownName(conversations.find((x) => x.name === who)) || who));
|
|
@@ -3488,12 +3533,63 @@
|
|
|
3488
3533
|
if ($('cassets').contains($('gitview'))) shutGit();
|
|
3489
3534
|
}
|
|
3490
3535
|
|
|
3536
|
+
/* REPLACE THE VALUE, without seeing it: a new one typed (never shown, the old one
|
|
3537
|
+
never sent here) and/or its expiry; its name and who has it stay. */
|
|
3538
|
+
let secretReplacing = ''; let secretSaid = null;
|
|
3539
|
+
function secretReplace(chosen) {
|
|
3540
|
+
const said = el(secretReplacing === chosen.name ? 'span' : 'p', 'hint secret-replace-said', secretSaid?.name === chosen.name ? secretSaid.text : ''); said.setAttribute('role', 'status');
|
|
3541
|
+
if (secretReplacing !== chosen.name) {
|
|
3542
|
+
const open = el('button', '', 'Replace the value...'); open.type = 'button'; open.id = 'secret-replace-open';
|
|
3543
|
+
open.addEventListener('click', () => { secretReplacing = chosen.name; secretSaid = null; void paintAssets(); });
|
|
3544
|
+
const what = el('div', 'set-what'); what.append(el('span', '', 'Value'), el('small', '', 'Never shown'));
|
|
3545
|
+
const control = el('div', 'set-control'); control.append(open);
|
|
3546
|
+
const row = el('div', 'set-row'); row.append(what, control);
|
|
3547
|
+
return { rows: said.textContent ? [row, said] : [row], card: [] };
|
|
3548
|
+
}
|
|
3549
|
+
const form = el('form', 'set-rows as-block secret-replace'); form.id = 'secret-replace'; form.autocomplete = 'off';
|
|
3550
|
+
const value = el('input'); value.id = 'secret-replace-value'; value.type = 'password'; value.autocomplete = 'new-password'; value.setAttribute('aria-label', 'New value');
|
|
3551
|
+
const lines = el('textarea', 'secret-lines'); lines.id = 'secret-replace-lines'; lines.rows = 5; lines.spellcheck = false; lines.hidden = true; lines.setAttribute('aria-label', 'New value, several lines');
|
|
3552
|
+
/* A key pasted: its lines kept, in a box of several lines, masked too. */
|
|
3553
|
+
value.addEventListener('paste', (event) => {
|
|
3554
|
+
const text = event.clipboardData?.getData('text') ?? '';
|
|
3555
|
+
if (!/[\r\n]/.test(text.replace(/[\r\n]+$/, ''))) return;
|
|
3556
|
+
event.preventDefault();
|
|
3557
|
+
lines.value = text.replace(/\r\n?/g, '\n'); lines.hidden = false; value.hidden = true; value.value = ''; lines.focus();
|
|
3558
|
+
});
|
|
3559
|
+
const day = el('input'); day.id = 'secret-replace-expires'; day.type = 'date'; day.value = chosen.secret.expires ?? ''; day.setAttribute('aria-label', 'Expires');
|
|
3560
|
+
const field = (label, small, ...control) => {
|
|
3561
|
+
const what = el('div', 'set-what'); what.append(el('span', '', label), el('small', '', small));
|
|
3562
|
+
const c = el('div', 'set-control'); c.append(...control);
|
|
3563
|
+
const row = el('div', 'set-row'); row.append(what, c); return row;
|
|
3564
|
+
};
|
|
3565
|
+
const cancel = el('button', '', 'Cancel'); cancel.type = 'button';
|
|
3566
|
+
cancel.addEventListener('click', () => { secretReplacing = ''; void paintAssets(); });
|
|
3567
|
+
const go = el('button', 'primary', 'Replace'); go.type = 'submit';
|
|
3568
|
+
const actions = el('div', 'action-row'); actions.append(said, cancel, go);
|
|
3569
|
+
form.append(field('New value', 'Never shown · empty keeps it', value, lines), field('Expires', 'Optional', day), actions);
|
|
3570
|
+
form.addEventListener('submit', async (event) => {
|
|
3571
|
+
event.preventDefault();
|
|
3572
|
+
$('assets-error').hidden = true;
|
|
3573
|
+
const typed = lines.hidden ? value.value : lines.value.replace(/\r\n?/g, '\n');
|
|
3574
|
+
const body = { expires: day.value };
|
|
3575
|
+
if (typed) body.value = typed;
|
|
3576
|
+
/* Not kept in the page a moment longer. */
|
|
3577
|
+
value.value = ''; lines.value = '';
|
|
3578
|
+
try { await post(`${API}/secrets/${chosen.name}/replace`, body); secretReplacing = ''; secretSaid = { name: chosen.name, text: 'Machines get it at their next start' }; }
|
|
3579
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3580
|
+
await paintAssets();
|
|
3581
|
+
});
|
|
3582
|
+
setTimeout(() => value.focus(), 0);
|
|
3583
|
+
return { rows: [], card: [form] };
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3491
3586
|
/* ---- the server's ---- */
|
|
3492
3587
|
let assetOpen = ''; let assetsAdding = ''; let assetsQuery = ''; let remoteShown = ''; let remoteEditing = false;
|
|
3493
3588
|
async function paintAssets() {
|
|
3494
3589
|
if (place !== 'assets' || DEVICE) return;
|
|
3495
3590
|
const [all, boxes, secrets, keys] = await Promise.all([getJson('/resources', []), getJson('/mailboxes', []), getJson('/secrets', []), getJson('/git-keys', []), readDevices()]);
|
|
3496
3591
|
paintKeys(keys);
|
|
3592
|
+
markSecrets(secrets);
|
|
3497
3593
|
const items = [];
|
|
3498
3594
|
for (const r of all) {
|
|
3499
3595
|
const kind = kindOf(r); const users = Object.keys(r.attachments ?? {}).length;
|
|
@@ -3501,7 +3597,7 @@
|
|
|
3501
3597
|
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, badge: String(users), badgeTitle: `Used by ${users} conversation${users === 1 ? '' : 's'}`, badgeTone: 'count',
|
|
3502
3598
|
sub: kind === 'git' ? `${gitSub(r)}${viaText(r.via)}` : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
3503
3599
|
}
|
|
3504
|
-
for (const s2 of secrets) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, badge: String(s2.conversations.length), badgeTitle: `Used by ${s2.conversations.length} conversation${s2.conversations.length === 1 ? '' : 's'}`, badgeTone: 'count',
|
|
3600
|
+
for (const s2 of secrets) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, badge: String(s2.conversations.length), badgeTitle: `Used by ${s2.conversations.length} conversation${s2.conversations.length === 1 ? '' : 's'}`, badgeTone: 'count', ...secretItem(s2, 'name only') });
|
|
3505
3601
|
const shown = assetsQuery ? items.filter((i) => i.name.includes(assetsQuery.toLowerCase()) || i.name.toLowerCase().includes(assetsQuery.toLowerCase())) : items;
|
|
3506
3602
|
const chosen = assetsAdding ? null : items.find((i) => i.key === assetOpen) ?? null;
|
|
3507
3603
|
$('assets-as').dataset.open = chosen || assetsAdding ? 'detail' : 'list';
|
|
@@ -3551,7 +3647,7 @@
|
|
|
3551
3647
|
const form = el('form', 'set-row secret-rename'); form.autocomplete = 'off';
|
|
3552
3648
|
const name = el('input'); name.id = 'secret-rename-name'; name.value = chosen.name; name.maxLength = 40; name.pattern = '[A-Z][A-Z0-9_]*'; name.spellcheck = false; name.autocapitalize = 'characters'; name.setAttribute('aria-label', 'New name');
|
|
3553
3649
|
const go = el('button', '', 'Rename'); go.type = 'submit';
|
|
3554
|
-
const what = el('div', 'set-what'); what.append(el('span', '', 'Name'), el('small', '', '
|
|
3650
|
+
const what = el('div', 'set-what'); what.append(el('span', '', 'Name'), el('small', '', 'Applies at next start'));
|
|
3555
3651
|
const control = el('div', 'set-control'); control.append(name, go);
|
|
3556
3652
|
form.append(what, control);
|
|
3557
3653
|
form.addEventListener('submit', async (event) => {
|
|
@@ -3561,8 +3657,10 @@
|
|
|
3561
3657
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3562
3658
|
await paintAssets();
|
|
3563
3659
|
});
|
|
3564
|
-
|
|
3565
|
-
|
|
3660
|
+
detail.append(secretLine(chosen.secret, 'not given to machines'));
|
|
3661
|
+
const replace = secretReplace(chosen);
|
|
3662
|
+
const box = el('div', 'set-rows as-block'); box.append(form, ...replace.rows);
|
|
3663
|
+
detail.append(box, ...replace.card);
|
|
3566
3664
|
}
|
|
3567
3665
|
/* Used by: each conversation that has it, what it may do; "+" offers the others. */
|
|
3568
3666
|
const options = chosen.kind === 'secret' ? [['off', 'Off'], ['use', 'Use']] : chosen.kind === 'mailbox' ? [['none', 'Off'], ['read', 'Read']] : [['none', 'Off'], ['read', 'Read'], ['write', 'Write']];
|
|
@@ -3790,7 +3888,8 @@
|
|
|
3790
3888
|
const lines = !$('secret-lines').hidden;
|
|
3791
3889
|
/* A key's last line ends with a line break: kept as it was pasted. */
|
|
3792
3890
|
const value = lines ? $('secret-lines').value.replace(/\r\n?/g, '\n') : $('secret-value').value;
|
|
3793
|
-
|
|
3891
|
+
const expires = $('secret-expires').value;
|
|
3892
|
+
try { await post(`${API}/secrets`, { name: $('secret-name').value.trim(), value, ...(expires ? { expires } : {}) }); assetOpen = `secret:${$('secret-name').value.trim()}`; assetsAdding = ''; $('secret-name').value = ''; $('secret-expires').value = ''; secretLines(false, ''); }
|
|
3794
3893
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3795
3894
|
await paintAssets();
|
|
3796
3895
|
});
|
package/web/index.html
CHANGED
|
@@ -519,6 +519,7 @@
|
|
|
519
519
|
<div class="row"><input id="secret-name" maxlength="40" pattern="[A-Z][A-Z0-9_]*" title="Capitals, digits and underscores, starting with a letter. Example: MODEL_KEY" placeholder="MODEL_KEY" spellcheck="false" autocapitalize="characters" required>
|
|
520
520
|
<input id="secret-value" type="password" placeholder="value (never shown again)" autocomplete="new-password" required>
|
|
521
521
|
<button type="submit" class="primary">Save</button></div>
|
|
522
|
+
<div class="row secret-expiry"><label for="secret-expires">Expires</label><input id="secret-expires" type="date"><small class="hint">Optional</small></div>
|
|
522
523
|
<!-- A key or a certificate is several lines: pasted into the line above, they come here by themselves. -->
|
|
523
524
|
<textarea id="secret-lines" class="secret-lines" rows="7" spellcheck="false" autocomplete="off" autocapitalize="off" placeholder="-----BEGIN ...----- ... -----END ...-----" aria-label="Value, several lines (never shown again)" hidden></textarea>
|
|
524
525
|
<button type="button" id="secret-lines-switch" class="as-link">Several lines (a key, a certificate)</button>
|
package/web/links.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* THE MAP (once "Who gets what"), AND FLOWS: the first tab of Access, with
|
|
2
2
|
* its Map / Flows switch (app.js opens, closes and filters Access).
|
|
3
3
|
*
|
|
4
|
-
* Map devices, conversations and assets in columns
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Map devices, conversations and assets in columns, laid out
|
|
5
|
+
* whole and fitted to the screen, with a zoom of its own
|
|
6
|
+
* (pinch, ctrl + wheel, the buttons; moved by a drag once
|
|
7
|
+
* zoomed in); a link is a right, coloured by what it gives. At rest no line, a count on each box; a box
|
|
7
8
|
* touched shows its links, greys the rest, and says them in
|
|
8
9
|
* words. A link is made by dragging from a dot (or a box
|
|
9
10
|
* touched, then another), changed by the knob on it, taken
|
|
@@ -27,8 +28,6 @@
|
|
|
27
28
|
/* An icon of that set, or, until it is there, nothing in its place. */
|
|
28
29
|
const ic = (name, cls = 'lk-svg') => window.clavariumIcons?.icon(name, cls) ?? null;
|
|
29
30
|
const kindIcon = (kind) => h('span', { class: 'lk-ic', 'aria-hidden': 'true' }, ic(KIND_ICON[kind]));
|
|
30
|
-
/* A pill that points up or down: its arrow drawn, then its words. */
|
|
31
|
-
const arrowed = (pill, dir, text) => { pill.replaceChildren(...[ic(dir === 'up' ? 'arrow-up' : 'arrow-down', 'lk-arrow')].filter(Boolean), text); return pill; };
|
|
32
31
|
const KIND_WORD = { device: 'device', conversation: 'conversation', folder: 'folder', git: 'repository', mailbox: 'mailbox', secret: 'secret' };
|
|
33
32
|
const COLUMN = { device: 'device', conversation: 'conversation', folder: 'asset', git: 'asset', mailbox: 'asset', secret: 'asset' };
|
|
34
33
|
const TITLES = { device: 'Devices', conversation: 'Conversations', asset: 'Assets' };
|
|
@@ -189,7 +188,7 @@
|
|
|
189
188
|
legend();
|
|
190
189
|
const bd = board();
|
|
191
190
|
bd.className = `lk-board ${VIEWS[view].cols.length === 3 ? 'three' : 'two'}`;
|
|
192
|
-
bd.querySelectorAll('.lk-col, .lk-knob
|
|
191
|
+
bd.querySelectorAll('.lk-col, .lk-knob').forEach((e) => e.remove()); closePop();
|
|
193
192
|
const lists = layout();
|
|
194
193
|
VIEWS[view].cols.forEach((cols, ci) => {
|
|
195
194
|
const col = h('div', { class: 'lk-col' });
|
|
@@ -200,10 +199,9 @@
|
|
|
200
199
|
for (const n of list) col.append(nodeEl(n));
|
|
201
200
|
if (!list.length) col.append(empty(k));
|
|
202
201
|
});
|
|
203
|
-
col.addEventListener('scroll', () => { place(); draw(); }, { passive: true });
|
|
204
202
|
bd.append(col);
|
|
205
203
|
});
|
|
206
|
-
draw(); hint(); paintPhone();
|
|
204
|
+
fit(); draw(); hint(); paintPhone();
|
|
207
205
|
}
|
|
208
206
|
/* How each kind is made: a device paired, a conversation created, an asset added. The same,
|
|
209
207
|
from the small round "+" by each column's title (always there, however many it holds)
|
|
@@ -220,9 +218,12 @@
|
|
|
220
218
|
}
|
|
221
219
|
function nodeEl(n) {
|
|
222
220
|
const cnt = graph.links.filter((l) => (l.from === n.id || l.to === n.id) && shown(l)).length;
|
|
223
|
-
|
|
221
|
+
/* One line: the icon says the kind; its words in the title. A conversation says by a dot its chat on, or that it is not ready. */
|
|
222
|
+
const state = n.kind !== 'conversation' ? null : n.phase && n.phase !== 'ready' ? 'off' : n.chat ? 'chat' : null;
|
|
223
|
+
const e = h('div', { class: `lk-node lk-c-${COLUMN[n.kind]}${n.pending ? ' pending' : ''}`, 'data-id': n.id, 'data-kind': n.kind, tabindex: 0, role: 'button', title: `${n.name} · ${n.sub}`, 'aria-label': `${n.name}, ${n.sub}, ${cnt} link${cnt === 1 ? '' : 's'}` },
|
|
224
224
|
kindIcon(n.kind),
|
|
225
|
-
h('span', { class: 'lk-tx' }, h('span', { class: 'lk-nm', text: n.name })
|
|
225
|
+
h('span', { class: 'lk-tx' }, h('span', { class: 'lk-nm', text: n.name })),
|
|
226
|
+
state && h('span', { class: 'lk-st', 'data-state': state, 'aria-hidden': 'true' }),
|
|
226
227
|
h('span', { class: 'lk-cnt', text: String(cnt), title: `${cnt} link${cnt === 1 ? '' : 's'}` }));
|
|
227
228
|
if (VIEWS[view].sources.includes(n.kind) && !n.pending) {
|
|
228
229
|
const dot = h('span', { class: 'lk-handle', title: 'Drag to what it gets', 'aria-hidden': 'true' });
|
|
@@ -236,14 +237,15 @@
|
|
|
236
237
|
return e;
|
|
237
238
|
}
|
|
238
239
|
const el = (id) => board().querySelector(`.lk-node[data-id="${CSS.escape(id)}"]`);
|
|
239
|
-
/*
|
|
240
|
+
/* A box's place on the board, in the board's own terms (before its zoom). */
|
|
241
|
+
function local(e) {
|
|
242
|
+
const r = e.getBoundingClientRect(); const b = board().getBoundingClientRect(); const k = zoom.k;
|
|
243
|
+
return { left: (r.left - b.left) / k, right: (r.right - b.left) / k, top: (r.top - b.top) / k, bottom: (r.bottom - b.top) / k };
|
|
244
|
+
}
|
|
245
|
+
/* Where a link meets a box. */
|
|
240
246
|
function anchor(id, side) {
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
const top = c.top + 34; const bottom = c.bottom - 2;
|
|
244
|
-
let y = r.top + r.height / 2; let away = 0;
|
|
245
|
-
if (y < top) { y = top; away = -1; } else if (y > bottom) { y = bottom; away = 1; }
|
|
246
|
-
return { x: (side === 'out' ? r.right : r.left) - b.left, y: y - b.top, away, col };
|
|
247
|
+
const r = local(el(id));
|
|
248
|
+
return { x: side === 'out' ? r.right : r.left, y: (r.top + r.bottom) / 2 };
|
|
247
249
|
}
|
|
248
250
|
/* Everything a box reaches or is reached by, in this view. */
|
|
249
251
|
function related(id) {
|
|
@@ -282,16 +284,14 @@
|
|
|
282
284
|
return { d: `M${a.x},${a.y} L${t},${a.y} C${t + g * 0.35},${a.y} ${z.x - g * 0.3},${z.y} ${z.x},${z.y}` };
|
|
283
285
|
}
|
|
284
286
|
/* The free gaps of the middle column, top to bottom, in the board's terms. */
|
|
285
|
-
function gaps(col
|
|
286
|
-
const c = col
|
|
287
|
-
let at = c.top + 34
|
|
288
|
-
for (const n of [...col.querySelectorAll('.lk-node')].map(
|
|
289
|
-
if (n.
|
|
290
|
-
|
|
291
|
-
at = Math.max(at, n.bottom - b.top);
|
|
292
|
-
if (at > c.bottom - b.top) break;
|
|
287
|
+
function gaps(col) {
|
|
288
|
+
const c = local(col); const out = [];
|
|
289
|
+
let at = c.top + 34;
|
|
290
|
+
for (const n of [...col.querySelectorAll('.lk-node')].map(local).sort((x, y) => x.top - y.top)) {
|
|
291
|
+
if (n.top > at + 2) out.push([at, n.top]);
|
|
292
|
+
at = Math.max(at, n.bottom);
|
|
293
293
|
}
|
|
294
|
-
if (at < c.bottom -
|
|
294
|
+
if (at < c.bottom - 2) out.push([at, c.bottom]);
|
|
295
295
|
return out;
|
|
296
296
|
}
|
|
297
297
|
function draw() {
|
|
@@ -302,14 +302,13 @@
|
|
|
302
302
|
const many = allLines && !drag && ls.length > MANY;
|
|
303
303
|
bd.classList.toggle('simple', !allLines && !drag);
|
|
304
304
|
bd.classList.toggle('many', many);
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
svg.setAttribute('viewBox', `0 0 ${b.width} ${b.height}`);
|
|
305
|
+
const colEls = [...bd.querySelectorAll('.lk-col')]; const cols = colEls.map(local);
|
|
306
|
+
const middle = cols.length === 3 ? { left: cols[1].left, right: cols[1].right, free: gaps(colEls[1]) } : null;
|
|
307
|
+
svg.setAttribute('viewBox', `0 0 ${bd.offsetWidth} ${bd.offsetHeight}`);
|
|
309
308
|
/* No arrowheads: the colour of a line says the right. */
|
|
310
309
|
svg.replaceChildren();
|
|
311
|
-
bd.querySelectorAll('.lk-knob
|
|
312
|
-
const
|
|
310
|
+
bd.querySelectorAll('.lk-knob').forEach((c) => c.remove());
|
|
311
|
+
const knobs = []; const wanted = [];
|
|
313
312
|
/* The pale ones first: the links in colour are drawn over them. */
|
|
314
313
|
const layers = [s('g', { class: 'lk-pale' }), s('g')];
|
|
315
314
|
svg.append(...layers);
|
|
@@ -318,26 +317,13 @@
|
|
|
318
317
|
const off = rel && !(rel.has(l.from) && rel.has(l.to));
|
|
319
318
|
const on = rel && !off;
|
|
320
319
|
const pale = many && !on;
|
|
321
|
-
const away = a.away || z.away;
|
|
322
|
-
for (const [p, end] of [[a, l.from], [z, l.to]]) if (p.away && !off) { const e = edges.get(p.col) ?? { up: [], down: [] }; (p.away < 0 ? e.up : e.down).push(end); edges.set(p.col, e); }
|
|
323
|
-
/* Gathered, a link to a box out of sight is a short hook at the end in sight, bent the way the
|
|
324
|
-
other end is; the pill at the column's edge says how many. */
|
|
325
|
-
if (pale && away) {
|
|
326
|
-
/* Its other end hidden on the left: counted by the pill of that column only. */
|
|
327
|
-
if (a.away || off) continue;
|
|
328
|
-
const out = Boolean(z.away); const dir = a.away || z.away; const at = out ? a : z;
|
|
329
|
-
const key = `${out ? l.from : l.to}|${dir}`;
|
|
330
|
-
const g = hooks.get(key) ?? { box: out ? l.from : l.to, out, dir, x: at.x, y: at.y, room: z.x - a.x, k, ids: [] };
|
|
331
|
-
g.ids.push(out ? l.to : l.from); hooks.set(key, g);
|
|
332
|
-
continue;
|
|
333
|
-
}
|
|
334
320
|
const dash = node(l.from).kind === 'device' && COLUMN[node(l.to).kind] === 'asset';
|
|
335
|
-
const over = dash && middle
|
|
321
|
+
const over = dash && middle ? middle : null;
|
|
336
322
|
const r = route(a, z, over, many);
|
|
337
|
-
const p = s('path', { d: r.d, class: [dash ? 'dash' : '',
|
|
323
|
+
const p = s('path', { d: r.d, class: [dash ? 'dash' : '', off ? 'dim' : '', on ? 'on' : '', pale ? 'pale' : '', l.pending ? 'later' : ''].join(' '), 'data-from': l.from, 'data-to': l.to, 'data-kind': k });
|
|
338
324
|
p.style.stroke = css(k);
|
|
339
325
|
layers[pale ? 0 : 1].append(p);
|
|
340
|
-
if (
|
|
326
|
+
if (pale || off) continue;
|
|
341
327
|
const hit = s('path', { d: r.d, class: 'hit' }); hit.addEventListener('click', () => openPop(l)); layers[1].append(hit);
|
|
342
328
|
const spots = (r.knob ? [0.5, 0.3, 0.7, 0.2, 0.82].map(r.knob) : [0.68, 0.55, 0.8, 0.45, 0.88, 0.38].map((f) => p.getPointAtLength(p.getTotalLength() * f)));
|
|
343
329
|
wanted.push({ l, k, off, on, spots, late: Boolean(r.knob) });
|
|
@@ -353,45 +339,6 @@
|
|
|
353
339
|
kb.addEventListener('click', () => openPop(l));
|
|
354
340
|
bd.append(kb);
|
|
355
341
|
}
|
|
356
|
-
/* A box whose links go to boxes out of sight: a short hook bent the way they are, and a small
|
|
357
|
-
pill naming them; touched, it brings the first into sight. */
|
|
358
|
-
const taken = [];
|
|
359
|
-
for (const g of hooks.values()) {
|
|
360
|
-
const len = Math.min(40, g.room * 0.3); const names = [...new Set(g.ids)].map((id) => node(id).name);
|
|
361
|
-
const d = g.out ? `M${g.x},${g.y} L${g.x + len * 0.5},${g.y} Q${g.x + len},${g.y} ${g.x + len},${g.y + g.dir * 12}` : `M${g.x - len},${g.y + g.dir * 12} Q${g.x - len},${g.y} ${g.x - len * 0.5},${g.y} L${g.x},${g.y}`;
|
|
362
|
-
const hook = s('path', { d, class: 'pale hook' }); hook.style.stroke = css(g.k); layers[0].append(hook);
|
|
363
|
-
const pill = h('button', { type: 'button', class: `lk-hook ${g.out ? 'out' : 'in'}`, title: `${g.dir < 0 ? 'Above' : 'Below'}: ${names.join(', ')}`,
|
|
364
|
-
style: `${g.out ? `left:${g.x + 4}px` : `left:${g.x - 4}px`};top:${g.y + g.dir * 22}px;max-width:${Math.max(48, Math.min(170, g.room - 24))}px` });
|
|
365
|
-
arrowed(pill, g.dir < 0 ? 'up' : 'down', `${names[0]}${names.length > 1 ? ` +${names.length - 1}` : ''}`);
|
|
366
|
-
pill.addEventListener('click', () => { el([...g.ids].find((id) => el(id)))?.scrollIntoView({ block: 'center', behavior: 'smooth' }); });
|
|
367
|
-
bd.append(pill);
|
|
368
|
-
/* A name cut short says nothing: where it does not fit, the count, the names in its title. */
|
|
369
|
-
if (pill.scrollWidth > pill.clientWidth + 1) {
|
|
370
|
-
/* No room in the gap: inside its box, at the end of its second line, where there is. */
|
|
371
|
-
const r = el(g.box)?.getBoundingClientRect();
|
|
372
|
-
if (r) { pill.classList.add('inbox'); pill.style.left = `${r.right - b.left - 20}px`; pill.style.top = `${r.bottom - b.top - 13}px`; pill.style.maxWidth = `${Math.max(48, r.width - 100)}px`; }
|
|
373
|
-
if (pill.scrollWidth > pill.clientWidth + 1) arrowed(pill, g.dir < 0 ? 'up' : 'down', String(names.length));
|
|
374
|
-
}
|
|
375
|
-
/* Never over another pill or a knob: moved further the same way, or left out (the hook stays). */
|
|
376
|
-
const clear = () => { const r = pill.getBoundingClientRect(); return [...taken, ...knobs.map((q) => ({ left: q.x + b.left - 11, right: q.x + b.left + 11, top: q.y + b.top - 11, bottom: q.y + b.top + 11 }))].every((o) => r.right < o.left || r.left > o.right || r.bottom < o.top || r.top > o.bottom); };
|
|
377
|
-
let tries = 0;
|
|
378
|
-
while (!clear() && tries < 2) { tries += 1; pill.style.top = `${g.y + g.dir * (22 + tries * 20)}px`; }
|
|
379
|
-
if (clear()) taken.push(pill.getBoundingClientRect()); else pill.remove();
|
|
380
|
-
}
|
|
381
|
-
/* Links to boxes scrolled away: a pill says how many, and brings the first into sight.
|
|
382
|
-
Above: in the column's title band; below: in the strip under the column. Never over a name. */
|
|
383
|
-
for (const [col, e] of edges) {
|
|
384
|
-
const c = col.getBoundingClientRect();
|
|
385
|
-
for (const [dir, ids] of [['up', e.up], ['down', e.down]]) {
|
|
386
|
-
if (!ids.length) continue;
|
|
387
|
-
const n = new Set(ids).size;
|
|
388
|
-
const pill = h('button', { type: 'button', class: `lk-edge ${dir}`, title: `${n} linked box${n === 1 ? '' : 'es'} ${dir === 'up' ? 'above' : 'below'}: bring into sight`,
|
|
389
|
-
style: dir === 'up' ? `left:${c.right - b.left - 14}px;top:${c.top - b.top + 8}px` : `left:${c.left - b.left + c.width / 2}px;top:${c.bottom - b.top + 4}px` });
|
|
390
|
-
arrowed(pill, dir, `${n} more linked`);
|
|
391
|
-
pill.addEventListener('click', () => { el(ids[0])?.scrollIntoView({ block: 'center', behavior: 'smooth' }); });
|
|
392
|
-
bd.append(pill);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
342
|
if (drag?.at) svg.append(s('path', { d: curve(anchor(drag.from.id, 'out'), drag.at), class: 'temp' }));
|
|
396
343
|
const src = picked || drag?.from;
|
|
397
344
|
bd.querySelectorAll('.lk-node').forEach((e) => {
|
|
@@ -410,29 +357,127 @@
|
|
|
410
357
|
const again = pinned === n.id;
|
|
411
358
|
pinned = again ? null : n.id;
|
|
412
359
|
picked = !again && VIEWS[view].sources.includes(n.kind) && !n.pending ? n : null;
|
|
413
|
-
closePop(); hint();
|
|
360
|
+
closePop(); hint(); draw(); reveal();
|
|
414
361
|
}
|
|
415
|
-
/* A box touched: what it is linked to
|
|
362
|
+
/* A box touched: it and what it is linked to are brought into the map's window (its card above takes room). */
|
|
416
363
|
function reveal() {
|
|
417
364
|
if (!pinned || phone() || !el(pinned)) return;
|
|
418
|
-
const rel = related(pinned); const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
365
|
+
const rel = related(pinned); const sc = scroller(); const H = sc.clientHeight - BAR_H; const W = sc.clientWidth;
|
|
366
|
+
const rs = [...board().querySelectorAll('.lk-node')].filter((e) => rel.has(e.dataset.id)).map(local);
|
|
367
|
+
const me = local(el(pinned));
|
|
368
|
+
const top = Math.min(...rs.map((r) => r.top)) * zoom.k; const bottom = Math.max(...rs.map((r) => r.bottom)) * zoom.k;
|
|
369
|
+
const left = Math.min(...rs.map((r) => r.left)) * zoom.k; const right = Math.max(...rs.map((r) => r.right)) * zoom.k;
|
|
370
|
+
const inY = (y) => top + y >= 0 && bottom + y <= H; const inX = (x) => left + x >= 0 && right + x <= W;
|
|
371
|
+
if (!inY(zoom.y)) zoom.y = bottom - top <= H ? 8 - top + (H - 16 - (bottom - top)) / 2 : 24 - me.top * zoom.k;
|
|
372
|
+
if (!inX(zoom.x)) zoom.x = right - left <= W ? (W - (right - left)) / 2 - left : 24 - me.left * zoom.k;
|
|
373
|
+
apply();
|
|
374
|
+
}
|
|
375
|
+
/* ---------- the map's own zoom: a transform of the board alone, never the page's text size ---------- */
|
|
376
|
+
/* `fit`: the whole board in sight, as at first; zoomed or moved by hand, it stays as it was put. */
|
|
377
|
+
const zoom = { k: 1, x: 0, y: 0, fit: true, min: 1 };
|
|
378
|
+
const MAX_ZOOM = 2.5;
|
|
379
|
+
const scroller = () => $('links-scroller');
|
|
380
|
+
/* Natural width: columns of their own width; wider when the screen has the room. */
|
|
381
|
+
const COL_W = 236; const COL_GAP = 96;
|
|
382
|
+
/* Room kept under the board for the zoom's buttons, fitted. */
|
|
383
|
+
const BAR_H = 46;
|
|
384
|
+
/* Moved or zoomed, kept inside its window: smaller than it, at its top, centred across. */
|
|
385
|
+
function apply() {
|
|
386
|
+
const sc = scroller(); const bd = board(); const W = sc.clientWidth; const H = sc.clientHeight;
|
|
387
|
+
zoom.k = Math.min(MAX_ZOOM, Math.max(zoom.min, zoom.k));
|
|
388
|
+
const w = bd.offsetWidth * zoom.k; const hh = bd.offsetHeight * zoom.k;
|
|
389
|
+
zoom.x = w <= W ? (W - w) / 2 : Math.min(0, Math.max(W - w, zoom.x));
|
|
390
|
+
zoom.y = hh <= H ? 0 : Math.min(0, Math.max(H - hh, zoom.y));
|
|
391
|
+
bd.style.transform = `translate(${zoom.x}px, ${zoom.y}px) scale(${zoom.k})`;
|
|
392
|
+
/* The dots to drag from and the knobs keep their size on the screen, zoomed out. */
|
|
393
|
+
bd.style.setProperty('--lk-inv', String(Math.min(2, Math.max(1, 1 / zoom.k))));
|
|
394
|
+
sc.classList.toggle('zoomed', w > W + 1 || hh > H + 1);
|
|
395
|
+
const bar = sc.querySelector('.lk-zoom');
|
|
396
|
+
if (bar) {
|
|
397
|
+
bar.querySelector('[data-zoom="out"]').disabled = zoom.k <= zoom.min + 0.001;
|
|
398
|
+
bar.querySelector('[data-zoom="in"]').disabled = zoom.k >= MAX_ZOOM - 0.001;
|
|
399
|
+
bar.querySelector('[data-zoom="fit"]').disabled = zoom.fit;
|
|
427
400
|
}
|
|
401
|
+
place();
|
|
428
402
|
}
|
|
429
|
-
/*
|
|
403
|
+
/* Zoomed by `f` around a point of the window (its middle by default). */
|
|
404
|
+
function zoomBy(f, cx, cy) {
|
|
405
|
+
const sc = scroller(); const x = cx ?? sc.clientWidth / 2; const y = cy ?? sc.clientHeight / 2;
|
|
406
|
+
const k = Math.min(MAX_ZOOM, Math.max(zoom.min, zoom.k * f));
|
|
407
|
+
if (k === zoom.k) return;
|
|
408
|
+
zoom.x = x - ((x - zoom.x) * k) / zoom.k; zoom.y = y - ((y - zoom.y) * k) / zoom.k; zoom.k = k; zoom.fit = false;
|
|
409
|
+
apply();
|
|
410
|
+
}
|
|
411
|
+
/* The board takes the height left on the screen, and the whole of it is fitted there. */
|
|
430
412
|
function fit() {
|
|
431
|
-
const bd = board(); const a = $('access');
|
|
413
|
+
const sc = scroller(); const bd = board(); const a = $('access');
|
|
432
414
|
if (phone() || !shownNow()) return;
|
|
433
|
-
const
|
|
434
|
-
const
|
|
435
|
-
|
|
415
|
+
const n = VIEWS[view].cols.length;
|
|
416
|
+
const natural = n * COL_W + (n - 1) * COL_GAP + 36;
|
|
417
|
+
const top = sc.getBoundingClientRect().top - a.getBoundingClientRect().top + a.scrollTop;
|
|
418
|
+
const room = Math.round(Math.max(320, a.clientHeight - top - 20));
|
|
419
|
+
/* The card of a box touched takes room above: the scale stays the one without it, the map moves under it. */
|
|
420
|
+
const card = $('links-card'); const cardH = card.hidden ? 0 : card.offsetHeight + 10;
|
|
421
|
+
const W = sc.clientWidth;
|
|
422
|
+
bd.style.width = `${natural}px`;
|
|
423
|
+
const bh = bd.offsetHeight;
|
|
424
|
+
const kh = Math.min(1, (room + cardH - BAR_H) / bh);
|
|
425
|
+
const width = Math.max(natural, W / kh);
|
|
426
|
+
bd.style.width = `${Math.floor(width)}px`;
|
|
427
|
+
const k = Math.min(kh, W / width);
|
|
428
|
+
zoom.min = Math.min(k, 1);
|
|
429
|
+
sc.style.height = `${Math.max(160, Math.min(room, Math.ceil(bh * k) + BAR_H))}px`;
|
|
430
|
+
if (zoom.fit) { zoom.k = k; zoom.x = 0; zoom.y = 0; }
|
|
431
|
+
apply();
|
|
432
|
+
}
|
|
433
|
+
function zoomBar() {
|
|
434
|
+
const b = (z, text, label, onclick) => h('button', { type: 'button', 'data-zoom': z, id: `links-zoom-${z}`, 'aria-label': label, title: label, text, onclick });
|
|
435
|
+
return h('div', { class: 'lk-zoom', role: 'group', 'aria-label': 'Zoom of the map' },
|
|
436
|
+
b('out', '−', 'Zoom out', () => zoomBy(1 / 1.25)), b('in', '+', 'Zoom in', () => zoomBy(1.25)),
|
|
437
|
+
b('fit', 'Fit', 'See everything', () => { zoom.fit = true; fit(); }));
|
|
438
|
+
}
|
|
439
|
+
/* A finger or the mouse moves the map (zoomed in), two fingers zoom it; a box or a link touched without moving is a tap. */
|
|
440
|
+
function gestures() {
|
|
441
|
+
const sc = scroller(); const pts = new Map(); let pan = null; let pinch = null; let moved = false;
|
|
442
|
+
const at = (e) => { const r = sc.getBoundingClientRect(); return { x: e.clientX - r.left, y: e.clientY - r.top }; };
|
|
443
|
+
sc.prepend(zoomBar());
|
|
444
|
+
sc.addEventListener('pointerdown', (e) => {
|
|
445
|
+
if (e.button > 0 || e.target.closest('.lk-handle, .lk-pop, .lk-zoom')) return;
|
|
446
|
+
pts.set(e.pointerId, at(e));
|
|
447
|
+
if (pts.size === 1) { moved = false; pan = { ...at(e), x0: zoom.x, y0: zoom.y }; pinch = null; }
|
|
448
|
+
if (pts.size === 2) {
|
|
449
|
+
const [p, q] = [...pts.values()];
|
|
450
|
+
pinch = { d: Math.hypot(p.x - q.x, p.y - q.y) || 1, k: zoom.k, mx: (p.x + q.x) / 2, my: (p.y + q.y) / 2, x0: zoom.x, y0: zoom.y }; pan = null; moved = true;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
sc.addEventListener('pointermove', (e) => {
|
|
454
|
+
if (!pts.has(e.pointerId) || drag) return;
|
|
455
|
+
const p = at(e); pts.set(e.pointerId, p);
|
|
456
|
+
if (pinch && pts.size >= 2) {
|
|
457
|
+
const [a, b] = [...pts.values()];
|
|
458
|
+
const k = Math.min(MAX_ZOOM, Math.max(zoom.min, (pinch.k * Math.hypot(a.x - b.x, a.y - b.y)) / pinch.d));
|
|
459
|
+
const mx = (a.x + b.x) / 2; const my = (a.y + b.y) / 2;
|
|
460
|
+
zoom.x = mx - ((pinch.mx - pinch.x0) * k) / pinch.k; zoom.y = my - ((pinch.my - pinch.y0) * k) / pinch.k; zoom.k = k; zoom.fit = false;
|
|
461
|
+
apply(); return;
|
|
462
|
+
}
|
|
463
|
+
if (!pan) return;
|
|
464
|
+
if (!moved && Math.hypot(p.x - pan.x, p.y - pan.y) < 6) return;
|
|
465
|
+
if (!moved) { moved = true; sc.setPointerCapture?.(e.pointerId); sc.classList.add('panning'); }
|
|
466
|
+
zoom.x = pan.x0 + p.x - pan.x; zoom.y = pan.y0 + p.y - pan.y; apply();
|
|
467
|
+
});
|
|
468
|
+
const up = (e) => { pts.delete(e.pointerId); if (!pts.size) { pan = null; pinch = null; sc.classList.remove('panning'); } };
|
|
469
|
+
sc.addEventListener('pointerup', up); sc.addEventListener('pointercancel', up);
|
|
470
|
+
/* Moved, not tapped: the click that follows is not a tap on a box. */
|
|
471
|
+
sc.addEventListener('click', (e) => { if (moved) { moved = false; e.stopPropagation(); e.preventDefault(); } }, true);
|
|
472
|
+
/* Ctrl (or cmd) + wheel, and a pinch on a trackpad: the map's zoom. The wheel alone moves it, zoomed in. */
|
|
473
|
+
sc.addEventListener('wheel', (e) => {
|
|
474
|
+
if (phone() || e.target.closest('.lk-pop')) return;
|
|
475
|
+
if (e.ctrlKey || e.metaKey) { e.preventDefault(); const p = at(e); zoomBy(Math.exp(-Math.max(-50, Math.min(50, e.deltaY)) * 0.01), p.x, p.y); return; }
|
|
476
|
+
if (!sc.classList.contains('zoomed')) return;
|
|
477
|
+
e.preventDefault(); zoom.x -= e.shiftKey ? e.deltaY : e.deltaX; zoom.y -= e.shiftKey ? 0 : e.deltaY; zoom.fit = false; apply();
|
|
478
|
+
}, { passive: false });
|
|
479
|
+
/* Never scrolled (a box reached with Tab would scroll it): the zoom alone moves the board. */
|
|
480
|
+
sc.addEventListener('scroll', () => { sc.scrollTop = 0; sc.scrollLeft = 0; });
|
|
436
481
|
}
|
|
437
482
|
function hint() {
|
|
438
483
|
card();
|
|
@@ -492,17 +537,20 @@
|
|
|
492
537
|
try { await request('/setup/drop', { id }); pinned = null; await changed(); } catch (e) { err(e.message); }
|
|
493
538
|
}
|
|
494
539
|
|
|
495
|
-
/* Dragging near
|
|
540
|
+
/* Dragging near an edge of the map's window, zoomed in, moves the map, so a target out of sight can be reached. */
|
|
496
541
|
function startDrag(ev, n) {
|
|
497
542
|
ev.preventDefault(); ev.stopPropagation(); closePop(); picked = null;
|
|
498
543
|
drag = { from: n, at: null, x: 0, y: 0 };
|
|
544
|
+
const follow = () => { const b = board().getBoundingClientRect(); drag.at = { x: (drag.x - b.left) / zoom.k, y: (drag.y - b.top) / zoom.k }; };
|
|
499
545
|
const tick = () => {
|
|
500
546
|
if (!drag) return;
|
|
501
|
-
const
|
|
502
|
-
|
|
547
|
+
const c = scroller().getBoundingClientRect(); const step = 10;
|
|
548
|
+
const dx = drag.x < c.left + 40 ? step : drag.x > c.right - 40 ? -step : 0;
|
|
549
|
+
const dy = drag.y < c.top + 40 ? step : drag.y > c.bottom - 40 ? -step : 0;
|
|
550
|
+
if (drag.at && (dx || dy)) { const x = zoom.x; const y = zoom.y; zoom.x += dx; zoom.y += dy; apply(); if (x !== zoom.x || y !== zoom.y) { follow(); draw(); } }
|
|
503
551
|
requestAnimationFrame(tick);
|
|
504
552
|
};
|
|
505
|
-
const move = (e) => {
|
|
553
|
+
const move = (e) => { drag.x = e.clientX; drag.y = e.clientY; follow(); draw(); };
|
|
506
554
|
const up = (e) => {
|
|
507
555
|
removeEventListener('pointermove', move); removeEventListener('pointerup', up);
|
|
508
556
|
const t = document.elementFromPoint(e.clientX, e.clientY)?.closest('.lk-node');
|
|
@@ -584,16 +632,18 @@
|
|
|
584
632
|
if (l.pending) rm.hidden = true;
|
|
585
633
|
row.append(rm, h('button', { type: 'button', class: 'primary', text: 'Done', onclick: () => { closePop(); draw(); } }));
|
|
586
634
|
pop.append(row);
|
|
587
|
-
board
|
|
635
|
+
/* Over the map's window, not in the board: its size is the page's, whatever the zoom. */
|
|
636
|
+
scroller().append(pop); place();
|
|
588
637
|
/* Whole in sight: the board may reach below the screen. */
|
|
589
638
|
pop.scrollIntoView({ block: 'nearest' });
|
|
590
639
|
pop.querySelector('input')?.focus({ preventScroll: true });
|
|
591
640
|
}
|
|
592
641
|
function place() {
|
|
593
642
|
if (!pop || !popLink || !el(popLink.from) || !el(popLink.to)) return;
|
|
594
|
-
const a = anchor(popLink.from, 'out'); const z = anchor(popLink.to, 'in'); const
|
|
595
|
-
const
|
|
596
|
-
const
|
|
643
|
+
const a = anchor(popLink.from, 'out'); const z = anchor(popLink.to, 'in'); const sc = scroller();
|
|
644
|
+
const mx = ((a.x + z.x) / 2) * zoom.k + zoom.x; const my = ((a.y + z.y) / 2) * zoom.k + zoom.y;
|
|
645
|
+
const x = Math.min(Math.max(8, mx - pop.offsetWidth / 2), sc.clientWidth - pop.offsetWidth - 8);
|
|
646
|
+
const y = Math.min(Math.max(8, my + 16), Math.max(8, sc.clientHeight - pop.offsetHeight - 8));
|
|
597
647
|
pop.style.left = `${x}px`; pop.style.top = `${y}px`;
|
|
598
648
|
}
|
|
599
649
|
|
|
@@ -991,7 +1041,7 @@
|
|
|
991
1041
|
err(''); picked = null; ph.screen = 'list';
|
|
992
1042
|
showPane('links');
|
|
993
1043
|
await load();
|
|
994
|
-
pinned = pin && byId.has(pin) ? pin : null;
|
|
1044
|
+
pinned = pin && byId.has(pin) ? pin : null; zoom.fit = true;
|
|
995
1045
|
if (pinned && phone()) { ph.kind = COLUMN[node(pinned).kind]; ph.sheet = pinned; }
|
|
996
1046
|
paint();
|
|
997
1047
|
if (document.fonts?.ready) document.fonts.ready.then(() => draw());
|
|
@@ -1003,7 +1053,7 @@
|
|
|
1003
1053
|
traceOf = of ?? '*';
|
|
1004
1054
|
paintFlows();
|
|
1005
1055
|
}
|
|
1006
|
-
for (const b of document.querySelectorAll('#links-tabs [data-view]')) b.addEventListener('click', () => { view = b.dataset.view; picked = null; pinned = null; try { localStorage.setItem('clavarium-links-view', view); } catch { /* not kept */ } paint(); });
|
|
1056
|
+
for (const b of document.querySelectorAll('#links-tabs [data-view]')) b.addEventListener('click', () => { view = b.dataset.view; picked = null; pinned = null; zoom.fit = true; try { localStorage.setItem('clavarium-links-view', view); } catch { /* not kept */ } paint(); });
|
|
1007
1057
|
$('links-all').addEventListener('change', () => { allLines = $('links-all').checked; try { localStorage.setItem('clavarium-links-all', allLines ? '1' : '0'); } catch { /* not kept */ } draw(); });
|
|
1008
1058
|
$('flows-of').addEventListener('change', (e) => { traceOf = e.target.value; paintFlows(); });
|
|
1009
1059
|
$('flows-export').addEventListener('click', () => { void exportFile(); });
|
|
@@ -1038,7 +1088,7 @@
|
|
|
1038
1088
|
/* A click away from it closes the knob's card (a button it just replaced is not "away"). */
|
|
1039
1089
|
document.addEventListener('click', (e) => { if (pop && e.target.isConnected && !e.target.closest('.lk-pop, .lk-knob, .lk-node, svg')) { closePop(); draw(); } });
|
|
1040
1090
|
addEventListener('resize', () => { if (shownNow()) { legend(); paintPhone(); fit(); draw(); place(); } });
|
|
1041
|
-
|
|
1091
|
+
gestures();
|
|
1042
1092
|
return { open, openFlows, close, changed };
|
|
1043
1093
|
};
|
|
1044
1094
|
})();
|
package/web/style.css
CHANGED
|
@@ -559,15 +559,29 @@ footer button[data-keys="backspace"] { display: none; }
|
|
|
559
559
|
.lk-key-w { color: var(--ink2); }
|
|
560
560
|
.lk-dim { color: var(--ink2); }
|
|
561
561
|
.lk-pending-key { display: inline-block; width: 18px; height: 12px; border: 1.5px dashed var(--ink2); border-radius: 4px; }
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
.lk-
|
|
565
|
-
.lk-
|
|
566
|
-
.lk-
|
|
567
|
-
.lk-
|
|
568
|
-
.lk-
|
|
562
|
+
/* The map's own window: the whole board, fitted to it; zoomed and moved by itself (pinch, ctrl + wheel, the
|
|
563
|
+
buttons), never by the page's text size. Its height is the room left on the screen (links.js, fit()). */
|
|
564
|
+
.lk-scroller { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); flex: none; touch-action: none; user-select: none; -webkit-user-select: none; }
|
|
565
|
+
.lk-scroller.zoomed { cursor: grab; }
|
|
566
|
+
.lk-scroller.panning { cursor: grabbing; }
|
|
567
|
+
.lk-zoom { position: absolute; right: 8px; bottom: 8px; z-index: 5; display: flex; gap: 4px; }
|
|
568
|
+
.lk-zoom button { min-width: 34px; height: 34px; padding: 0 10px; border-radius: 999px; background: var(--bar); font: 600 .9375rem/1 var(--sans); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
|
|
569
|
+
.lk-zoom button[data-zoom="fit"] { font-size: .8125rem; }
|
|
570
|
+
/* Laid out whole, at its natural size; the scale is a transform of this layer alone. */
|
|
571
|
+
.lk-board { position: absolute; left: 0; top: 0; transform-origin: 0 0; display: grid; justify-content: space-between; gap: 0 96px; padding: 0 22px 16px 14px; --lk-inv: 1; }
|
|
572
|
+
.lk-board.two { grid-template-columns: repeat(2, minmax(0, 300px)); }
|
|
573
|
+
.lk-board.three { grid-template-columns: repeat(3, minmax(0, 300px)); }
|
|
574
|
+
.lk-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; position: relative; z-index: 2; }
|
|
575
|
+
.lk-col h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; padding: 10px 0 6px; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
|
|
569
576
|
.lk-gap { height: 12px; flex: none; }
|
|
570
|
-
|
|
577
|
+
/* One line: the icon says the kind; the name, cut short, whole in its title. */
|
|
578
|
+
.lk-node { position: relative; flex: none; display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 10px; padding: 5px 10px 5px 6px; background: var(--panel); cursor: pointer; user-select: none; min-width: 0; }
|
|
579
|
+
.lk-node .lk-tx { flex: 1; }
|
|
580
|
+
.lk-node .lk-nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
581
|
+
/* What the icon cannot say: a conversation's chat on, or one not ready. */
|
|
582
|
+
.lk-st { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-right: 6px; }
|
|
583
|
+
.lk-st[data-state="chat"] { background: var(--k-chat); }
|
|
584
|
+
.lk-st[data-state="off"] { border: 1.5px solid var(--ink2); }
|
|
571
585
|
.lk-node.pending { border-style: dashed; }
|
|
572
586
|
.lk-ic { font: 600 .75rem ui-monospace, Menlo, monospace; width: 1.9em; height: 1.9em; border-radius: 6px; display: grid; place-items: center; flex: none; }
|
|
573
587
|
.lk-node.lk-c-device .lk-ic { background: var(--k-device-bg); color: var(--k-device); }
|
|
@@ -583,37 +597,28 @@ footer button[data-keys="backspace"] { display: none; }
|
|
|
583
597
|
.lk-cnt { margin-left: auto; flex: none; font: 700 .6875rem var(--sans); color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 6px; display: none; }
|
|
584
598
|
.lk-board.simple .lk-cnt { display: inline-block; }
|
|
585
599
|
/* The dot to drag from: 28px to touch, drawn 14px. */
|
|
586
|
-
|
|
600
|
+
/* Its size on the screen stays the same, the map zoomed out: still a finger to drag from. */
|
|
601
|
+
.lk-handle { position: absolute; right: -14px; top: 50%; width: 28px; height: 28px; margin-top: -14px; border-radius: 50%; cursor: crosshair; touch-action: none; display: grid; place-items: center; z-index: 4; transform: scale(var(--lk-inv)); }
|
|
587
602
|
.lk-handle::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2px solid var(--ink2); }
|
|
588
603
|
.lk-handle:hover::after { border-color: var(--k-pick); background: var(--k-pick); }
|
|
589
|
-
.lk-edge { position: absolute; z-index: 4; transform: translateX(-50%); font: 700 .6875rem/1 var(--sans); padding: 5px 10px; border-radius: 999px; background: var(--bar); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; }
|
|
590
|
-
.lk-edge:hover { color: var(--ink); border-color: var(--ink2); }
|
|
591
|
-
.lk-edge.up { transform: translateX(-100%); }
|
|
592
|
-
/* Where the links of a box go, out of sight: named small, at the end of their hook. */
|
|
593
|
-
.lk-hook { position: absolute; z-index: 3; transform: translateY(-50%); font: 600 .6875rem/1.2 var(--sans); padding: 2px 7px; border-radius: 999px; background: var(--bar); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
594
|
-
.lk-hook.in { transform: translate(-100%, -50%); }
|
|
595
|
-
.lk-hook.inbox { transform: translate(-100%, -50%); z-index: 4; }
|
|
596
604
|
.lk-start { display: flex; flex-direction: column; gap: 14px; }
|
|
597
|
-
.lk-hook:hover { color: var(--ink); border-color: var(--ink2); }
|
|
598
605
|
.lk-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
|
|
599
606
|
svg.lk-links { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; overflow: hidden; pointer-events: none; }
|
|
600
607
|
svg.lk-links path { fill: none; stroke-width: 2.6; stroke-linecap: round; }
|
|
601
608
|
svg.lk-links path.hit { stroke: transparent !important; stroke-width: 18; pointer-events: stroke; cursor: pointer; }
|
|
602
609
|
svg.lk-links path.dash { stroke-dasharray: 7 5; }
|
|
603
610
|
svg.lk-links path.later { stroke-dasharray: 2 4; opacity: .7; }
|
|
604
|
-
svg.lk-links path.away { opacity: .35; stroke-dasharray: 2 5; }
|
|
605
611
|
svg.lk-links path.dim { opacity: .12; }
|
|
606
612
|
/* Many links: all drawn, thin and pale, gathered in trunks; those of the box touched in full over them. */
|
|
607
613
|
svg.lk-links path.pale { stroke-width: 1.4; opacity: .5; }
|
|
608
614
|
svg.lk-links path.pale.dim { opacity: .14; }
|
|
609
615
|
svg.lk-links path.pale.dash { stroke-dasharray: 4 4; }
|
|
610
|
-
svg.lk-links path.pale.hook { opacity: .55; }
|
|
611
616
|
svg.lk-links path.temp { stroke: var(--k-pick); stroke-dasharray: 4 4; }
|
|
612
617
|
/* At rest: no line, each box says how many links it has; a tapped box shows its own. */
|
|
613
|
-
.lk-board.simple svg.lk-links path:not(.on):not(.temp), .lk-board.simple .lk-knob:not(.on)
|
|
614
|
-
.lk-knob { position: absolute; z-index: 3; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 3px solid var(--bg); cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--line); }
|
|
618
|
+
.lk-board.simple svg.lk-links path:not(.on):not(.temp), .lk-board.simple .lk-knob:not(.on) { display: none; }
|
|
619
|
+
.lk-knob { position: absolute; z-index: 3; width: 22px; height: 22px; margin: -11px 0 0 -11px; transform: scale(var(--lk-inv)); border-radius: 50%; border: 3px solid var(--bg); cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--line); }
|
|
615
620
|
.lk-knob.dim { opacity: .2; }
|
|
616
|
-
.lk-pop { position: absolute; z-index: 6; width: min(330px, calc(100vw - 48px)); max-height: calc(100% - 16px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
|
|
621
|
+
.lk-pop { touch-action: pan-y; user-select: text; position: absolute; z-index: 6; width: min(330px, calc(100vw - 48px)); max-height: calc(100% - 16px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
|
|
617
622
|
.lk-pop h4 { margin: 0 0 6px; font-size: .9375rem; overflow-wrap: anywhere; }
|
|
618
623
|
.lk-pop h4 small { display: block; font-weight: 400; color: var(--ink2); font-size: .75rem; }
|
|
619
624
|
.lk-pop label { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
|
|
@@ -654,8 +659,6 @@ svg.lk-links path.temp { stroke: var(--k-pick); stroke-dasharray: 4 4; }
|
|
|
654
659
|
/* The icons of the map: the chat's set (Lucide), drawn the same whatever the fonts. */
|
|
655
660
|
.lk-ic .lk-svg { width: 1.05rem; height: 1.05rem; }
|
|
656
661
|
.lk-chev .lk-svg { width: 1.1rem; height: 1.1rem; display: block; }
|
|
657
|
-
.lk-hook, .lk-edge { display: inline-flex; align-items: center; gap: 3px; }
|
|
658
|
-
.lk-arrow { width: 1em; height: 1em; flex: none; }
|
|
659
662
|
.lk-bar { margin: 4px 0; }
|
|
660
663
|
.lk-bar button { border-radius: 999px; }
|
|
661
664
|
.lk-ptitle { margin: 6px 0 0; font-size: 1.25rem; overflow-wrap: anywhere; }
|
|
@@ -722,13 +725,6 @@ svg.lk-links path.temp { stroke: var(--k-pick); stroke-dasharray: 4 4; }
|
|
|
722
725
|
.lk-job li[data-state="failed"] { color: var(--danger); }
|
|
723
726
|
.lk-job li[data-state="skipped"] { color: var(--ink2); }
|
|
724
727
|
.lk-job li[data-state="doing"]::marker { color: var(--brass); }
|
|
725
|
-
/* Where the board is narrow (a phone across, a tablet beside the list), the three columns still fit: names only. */
|
|
726
|
-
@container (max-width: 700px) {
|
|
727
|
-
.lk-board.three { gap: 0 40px; padding: 0 8px 30px; }
|
|
728
|
-
.lk-board.three .lk-node { padding: 5px 6px; gap: 0; flex-direction: column; align-items: flex-start; }
|
|
729
|
-
.lk-board.three .lk-ic, .lk-board.three .lk-sb { display: none; }
|
|
730
|
-
.lk-board.three .lk-node.lk-c-device { border-left: 4px solid var(--k-device); } .lk-board.three .lk-node.lk-c-conversation { border-left: 4px solid var(--k-conv); } .lk-board.three .lk-node.lk-c-asset { border-left: 4px solid var(--k-asset); }
|
|
731
|
-
}
|
|
732
728
|
|
|
733
729
|
.lk-shared { font-size: .75rem; font-weight: 600; color: var(--k-pick); border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; }
|
|
734
730
|
.lk-check { margin: 0; padding-left: 1.1rem; font-size: .875rem; }
|
|
@@ -780,7 +776,6 @@ svg.lk-links path.temp { stroke: var(--k-pick); stroke-dasharray: 4 4; }
|
|
|
780
776
|
#access-map { gap: 8px; }
|
|
781
777
|
.map-mode { align-self: flex-start; }
|
|
782
778
|
.map-mode button { min-height: 32px; padding: 4px 14px; }
|
|
783
|
-
#access-map .lk-board { height: clamp(300px, calc(100dvh - 330px), 900px); }
|
|
784
779
|
#sharing-top { gap: 8px; }
|
|
785
780
|
#sharing-top b { font-size: 1rem; }
|
|
786
781
|
.to-access { margin-top: 2px; }
|
|
@@ -1597,6 +1592,12 @@ details.more[open] > summary { margin-bottom: 4px; }
|
|
|
1597
1592
|
.as-settings dd { color: var(--ink2); font-weight: 400; font-size: .875rem; }
|
|
1598
1593
|
.as-card, .as-lastchecks, .as-graph { background: var(--bar); border-radius: 10px; }
|
|
1599
1594
|
.secret-rename > .set-control > input { width: 14rem; }
|
|
1595
|
+
/* A secret: its expiry said under its title; Replace the value, in its rows. */
|
|
1596
|
+
.secret-replace .set-control > input, .secret-replace .set-control > textarea { width: 14rem; max-width: 100%; }
|
|
1597
|
+
.secret-replace .set-control > .secret-lines { margin-top: 0; }
|
|
1598
|
+
#secret-new .secret-expiry { align-items: center; gap: 8px; margin-top: .5rem; }
|
|
1599
|
+
#secret-new .secret-expiry > label { margin: 0; }
|
|
1600
|
+
#secret-new .secret-expiry > input { flex: 0 1 12rem; width: 12rem; }
|
|
1600
1601
|
.as-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
|
|
1601
1602
|
.as-foot > br { display: none; }
|
|
1602
1603
|
#gitview-remote-box { margin: 0; }
|
|
@@ -1697,4 +1698,4 @@ span.callout.confirm { display: inline-flex; justify-content: flex-end; padding:
|
|
|
1697
1698
|
.ts-tree-files { padding: 4px 4px 4px 12px; }
|
|
1698
1699
|
|
|
1699
1700
|
/* Something asks for the person in this chapter (a callout, a warning): a dot on its title, and on its category. */
|
|
1700
|
-
details.chapter[data-attention] > summary .chapter-title::after, #settings-nav button[data-attention]::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--warn); vertical-align: middle; }
|
|
1701
|
+
details.chapter[data-attention] > summary .chapter-title::after, #settings-nav button[data-attention]::after, #nav-assets[data-attention] > span::after, #view-assets[data-attention] > span::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--warn); vertical-align: middle; }
|