clavarium 0.2.24-next.5 → 0.2.24-next.7
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 +14 -14
- package/package.json +4 -4
- package/server/api.mjs +8 -5
- package/server/binders.mjs +15 -1
- package/server/door.mjs +1 -1
- package/server/voice.mjs +25 -5
- package/web/app.js +152 -57
- package/web/index.html +13 -8
- package/web/style.css +25 -5
- package/web/voice.js +8 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.24-next.
|
|
3
|
+
"version": "0.2.24-next.7",
|
|
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.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
|
-
"clavarium-binder": "0.1.
|
|
15
|
-
"clavarium-docket": "0.1.1
|
|
16
|
-
"clavarium-parley": "0.15.0
|
|
14
|
+
"clavarium-binder": "0.1.1",
|
|
15
|
+
"clavarium-docket": "0.1.1",
|
|
16
|
+
"clavarium-parley": "0.15.0",
|
|
17
17
|
"mermaid": "11.17.2",
|
|
18
18
|
"node-pty": "^1.1.0",
|
|
19
19
|
"pdfjs-dist": "6.4.299",
|
|
@@ -688,9 +688,9 @@
|
|
|
688
688
|
}
|
|
689
689
|
},
|
|
690
690
|
"node_modules/clavarium-binder": {
|
|
691
|
-
"version": "0.1.
|
|
692
|
-
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.
|
|
693
|
-
"integrity": "sha512-
|
|
691
|
+
"version": "0.1.1",
|
|
692
|
+
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.1.tgz",
|
|
693
|
+
"integrity": "sha512-9osufAKNzKUcE6CEQBgJn/frYp6qdjwRYRCy3Fn/zIyQVOb/F/mr4r/WmymMy+knUCeTzwGZjWHD5WIpPMQz7A==",
|
|
694
694
|
"license": "MIT",
|
|
695
695
|
"bin": {
|
|
696
696
|
"binder": "bin/binder.mjs",
|
|
@@ -701,9 +701,9 @@
|
|
|
701
701
|
}
|
|
702
702
|
},
|
|
703
703
|
"node_modules/clavarium-docket": {
|
|
704
|
-
"version": "0.1.1
|
|
705
|
-
"resolved": "https://registry.npmjs.org/clavarium-docket/-/clavarium-docket-0.1.1
|
|
706
|
-
"integrity": "sha512-
|
|
704
|
+
"version": "0.1.1",
|
|
705
|
+
"resolved": "https://registry.npmjs.org/clavarium-docket/-/clavarium-docket-0.1.1.tgz",
|
|
706
|
+
"integrity": "sha512-ssmnIfkBmOeKaHXBrL97qsaBp6Tc6OwX08WksQjpBGZx/QklwRvZqXgOYZ/Nk7Hk3HO0xXrJy5EyHbFcLVXfiA==",
|
|
707
707
|
"license": "MIT",
|
|
708
708
|
"bin": {
|
|
709
709
|
"docket": "bin/docket.mjs",
|
|
@@ -714,9 +714,9 @@
|
|
|
714
714
|
}
|
|
715
715
|
},
|
|
716
716
|
"node_modules/clavarium-parley": {
|
|
717
|
-
"version": "0.15.0
|
|
718
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.15.0
|
|
719
|
-
"integrity": "sha512-
|
|
717
|
+
"version": "0.15.0",
|
|
718
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.15.0.tgz",
|
|
719
|
+
"integrity": "sha512-PPU5EI+A28w1jq1hlm1SfYWa2v4flfINsfUmQvyzC2zg9L9jf9kkrr/3WhCJYrpg97kIZcp8fPz/DZdxPkUx1g==",
|
|
720
720
|
"license": "MIT",
|
|
721
721
|
"bin": {
|
|
722
722
|
"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.7",
|
|
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.",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
|
-
"clavarium-binder": "0.1.
|
|
48
|
-
"clavarium-docket": "0.1.1
|
|
49
|
-
"clavarium-parley": "0.15.0
|
|
47
|
+
"clavarium-binder": "0.1.1",
|
|
48
|
+
"clavarium-docket": "0.1.1",
|
|
49
|
+
"clavarium-parley": "0.15.0",
|
|
50
50
|
"mermaid": "11.17.2",
|
|
51
51
|
"node-pty": "^1.1.0",
|
|
52
52
|
"pdfjs-dist": "6.4.299",
|
package/server/api.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
*
|
|
3
3
|
* GET /api/tools
|
|
4
4
|
* GET /api/conversations
|
|
5
|
+
* each with lists: {lists, waiting} (binders.mjs given) or null
|
|
5
6
|
* POST /api/conversations {name, tool, memoryMb?}
|
|
6
7
|
* POST /api/conversations/<name>/sleep
|
|
7
8
|
* POST /api/conversations/<name>/restart a clean stop (by force if it hangs), then a start
|
|
@@ -96,11 +97,11 @@
|
|
|
96
97
|
* POST /api/shortcuts {label, text, enter}
|
|
97
98
|
* POST /api/shortcuts/<id>/remove
|
|
98
99
|
* GET /api/voice is dictation available?
|
|
99
|
-
* POST /api/voice
|
|
100
|
+
* POST /api/voice?lang= the body IS a WAV recording -> {text}; lang: the device's language
|
|
100
101
|
* GET /api/dictation the engine chosen in Settings (never a key: a secret's name)
|
|
101
102
|
* POST /api/dictation {provider, url, model, secret, language}: chosen, at once
|
|
102
103
|
* POST /api/dictation/off the environment's engine, if any, again
|
|
103
|
-
* POST /api/dictation/try?provider=&url=&model=&secret=&language= a WAV -> {text}, nothing saved
|
|
104
|
+
* POST /api/dictation/try?provider=&url=&model=&secret=&language=&lang= a WAV -> {text}, nothing saved
|
|
104
105
|
* GET /api/files?c=<conversation>&r=<resource>&p=<path> a listing
|
|
105
106
|
* GET /api/flows who gets what: devices, conversations, assets, the rights between them, the flows
|
|
106
107
|
* POST /api/flows/name {around, name}: a flow named by the owner ('' gives it back its own)
|
|
@@ -186,8 +187,9 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
186
187
|
for await (const chunk of request) { size += chunk.length; if (size > AUDIO_MAX) throw new Refusal(413, 'The recording is too long.'); parts.push(chunk); }
|
|
187
188
|
const audio = Buffer.concat(parts);
|
|
188
189
|
/* "Try it": the choice in the form, in the address's parameters (no key in it: a secret's name). */
|
|
189
|
-
|
|
190
|
-
return send(200, { text:
|
|
190
|
+
/* `lang`: the language of the device that dictates (voice.mjs, languageOf). */
|
|
191
|
+
if (pathname === '/api/dictation/try') return send(200, { text: await voice.try(Object.fromEntries(query), audio, query.get('lang') ?? undefined) }), true;
|
|
192
|
+
return send(200, { text: voice ? await voice.transcribe(audio, query.get('lang') ?? undefined) : await transcribe(undefined, audio) }), true;
|
|
191
193
|
}
|
|
192
194
|
if (request.method === 'GET' && pathname === '/api/files') return send(200, await list(attached(), query.get('p') ?? '')), true;
|
|
193
195
|
if (request.method === 'GET' && pathname === '/api/files/machine') {
|
|
@@ -231,7 +233,8 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
231
233
|
if (request.method === 'GET') {
|
|
232
234
|
if (pathname === '/api/tools') return send(200, conversations.tools()), true;
|
|
233
235
|
if (pathname === '/api/conversations') {
|
|
234
|
-
|
|
236
|
+
const lists = binders?.given() ?? {};
|
|
237
|
+
return send(200, conversations.list().map((c) => ({ ...c, lists: lists[c.name] ?? null, resources: resources?.of(c.name) ?? [], secrets: secrets?.of(c.name) ?? [], answerer: answerer?.of(c.name) ?? null, wakeups: wakeups?.of(c.name) ?? null, health: health?.of(c.name) ?? null, talk: talk?.brief(c.name) ?? null }))), true;
|
|
235
238
|
}
|
|
236
239
|
if (pathname === '/api/resources' && resources) return send(200, resources.list()), true;
|
|
237
240
|
if (pathname === '/api/shortcuts' && shortcuts) return send(200, shortcuts.list()), true;
|
package/server/binders.mjs
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* machine: what a tool could write, it could rewrite. A tool asks through
|
|
8
8
|
* its work folder's .binder (beside .parley and .docket), and is answered
|
|
9
9
|
* there; who asks is said by the folder -- conversation:<name> -- never by
|
|
10
|
-
* the ask. The owner changes it from the page
|
|
10
|
+
* the ask. The owner changes it from the page: Assets > Lists, and a
|
|
11
|
+
* conversation's Lists tab (only the lists it was given).
|
|
11
12
|
*
|
|
12
13
|
* A TOOL SEES ONLY THE LISTS IT WAS GIVEN (read, or change), and never
|
|
13
14
|
* approves: a gate (Batches: "Approved") is the owner's tick.
|
|
@@ -85,6 +86,19 @@ export class Binders {
|
|
|
85
86
|
if (!persons.length) persons.push({ id: `person:${identity || 'owner'}`, kind: 'person', name: identity || 'Owner' });
|
|
86
87
|
return [...persons, ...this.#conversations().map((name) => ({ id: `${AGENT}${name}`, kind: 'agent', name }))];
|
|
87
88
|
}
|
|
89
|
+
/* What each conversation was given: { name: { lists, waiting } }, waiting being the
|
|
90
|
+
records of those lists that wait for a person's tick (a list with a gate, not approved). */
|
|
91
|
+
given() {
|
|
92
|
+
const keeper = { id: 'person:keeper', kind: 'person', name: 'keeper' };
|
|
93
|
+
const out = {};
|
|
94
|
+
for (const l of this.#keeper.store.lists(keeper)) {
|
|
95
|
+
const to = Object.keys(l.grants ?? {}).filter((id) => id.startsWith(AGENT));
|
|
96
|
+
if (l.archived || !to.length) continue;
|
|
97
|
+
const waiting = l.states.some((s) => s.gate) ? this.#keeper.store.list(l.id, keeper).records.filter((r) => !r.approved).length : 0;
|
|
98
|
+
for (const id of to) { const one = (out[id.slice(AGENT.length)] ??= { lists: 0, waiting: 0 }); one.lists++; one.waiting += waiting; }
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
88
102
|
/* A number that moves with every change: the page reads again when it moved. */
|
|
89
103
|
changes() { return this.#changes; }
|
|
90
104
|
}
|
package/server/door.mjs
CHANGED
|
@@ -167,7 +167,7 @@ export async function handleDoor(request, response, { devices, conversations, re
|
|
|
167
167
|
if (request.headers['content-type'] !== 'audio/wav') return send(400, { error: 'A recording is a WAV file.' });
|
|
168
168
|
const parts = []; let size = 0;
|
|
169
169
|
for await (const chunk of request) { size += chunk.length; if (size > AUDIO_MAX) throw new Refusal(413, 'The recording is too long.'); parts.push(chunk); }
|
|
170
|
-
return send(200, { text: voice ? await voice.transcribe(Buffer.concat(parts)) : await transcribe(undefined, Buffer.concat(parts)) });
|
|
170
|
+
return send(200, { text: voice ? await voice.transcribe(Buffer.concat(parts), url.searchParams.get('lang') ?? undefined) : await transcribe(undefined, Buffer.concat(parts)) });
|
|
171
171
|
}
|
|
172
172
|
/* Its conversation's chat, whatever conversation the address names: the device's own. */
|
|
173
173
|
/* Only for a pairing given its chat: to read it, or to write there too. */
|
package/server/voice.mjs
CHANGED
|
@@ -174,6 +174,25 @@ export const PROVIDERS = {
|
|
|
174
174
|
other: { label: 'Other (compatible)', url: '', model: '' },
|
|
175
175
|
};
|
|
176
176
|
const LANGUAGE = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
|
|
177
|
+
export const AUTOMATIC = 'auto';
|
|
178
|
+
|
|
179
|
+
/* WHICH LANGUAGE IS ASKED FOR. Left to the engine, the language is guessed
|
|
180
|
+
again on every phrase -- a few seconds of audio, often hesitant -- and a
|
|
181
|
+
French phrase came back as Icelandic. So a language is always given: the
|
|
182
|
+
one chosen (Settings, else CLAVARIUM_TRANSCRIPTION_LANGUAGE), else the
|
|
183
|
+
language of the device that dictates (its browser's first, sent with each
|
|
184
|
+
phrase). Guessed only when "auto" is chosen, or nothing is known.
|
|
185
|
+
The device's tag is cut to its language ("fr-CA" -> "fr"): what the engines take. */
|
|
186
|
+
export function deviceLanguage(tag) {
|
|
187
|
+
const primary = String(tag ?? '').trim().toLowerCase().split(/[-_]/)[0];
|
|
188
|
+
return /^[a-z]{2,3}$/.test(primary) ? primary : undefined;
|
|
189
|
+
}
|
|
190
|
+
export function languageOf(chosen, device) {
|
|
191
|
+
const c = String(chosen ?? '').trim();
|
|
192
|
+
if (c === AUTOMATIC) return undefined;
|
|
193
|
+
if (c !== '' && LANGUAGE.test(c)) return c;
|
|
194
|
+
return deviceLanguage(device);
|
|
195
|
+
}
|
|
177
196
|
const MODEL = /^[A-Za-z0-9._:/-]{1,100}$/;
|
|
178
197
|
|
|
179
198
|
/* An address of this server's own network, written as such. */
|
|
@@ -203,7 +222,7 @@ export function dictationProblem(c) {
|
|
|
203
222
|
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && own)) return 'The address must start with https:// (plain http only for an engine on this server\'s own network).';
|
|
204
223
|
if (!MODEL.test(String(c.model ?? ''))) return 'Give the name of a model.';
|
|
205
224
|
if (c.secret !== undefined && c.secret !== '' && !isSecretName(c.secret)) return 'The key is the name of a secret.';
|
|
206
|
-
if (c.language !== undefined && c.language !== '' && !LANGUAGE.test(String(c.language))) return 'The language is a code such as en or fr, or automatic.';
|
|
225
|
+
if (c.language !== undefined && c.language !== '' && c.language !== AUTOMATIC && !LANGUAGE.test(String(c.language))) return 'The language is a code such as en or fr, or automatic.';
|
|
207
226
|
return undefined;
|
|
208
227
|
}
|
|
209
228
|
|
|
@@ -265,18 +284,19 @@ export class Dictation {
|
|
|
265
284
|
}
|
|
266
285
|
/* An expired key is never sent: said in one line instead (still offered, so the line is seen). */
|
|
267
286
|
#fresh(c) { if (c?.secret && this.#expired(c.secret)) throw new Refusal(409, KEY_EXPIRED); }
|
|
268
|
-
|
|
287
|
+
/* `device`: the language of the device that dictates (a tag such as fr-FR), if it said. */
|
|
288
|
+
async transcribe(audio, device) {
|
|
269
289
|
this.#fresh(this.#saved());
|
|
270
290
|
const config = this.current();
|
|
271
291
|
if (config) await this.#guard(config);
|
|
272
|
-
return transcribe(config, audio, this.#fetcher);
|
|
292
|
+
return transcribe(config && { ...config, language: languageOf(config.language, device) }, audio, this.#fetcher);
|
|
273
293
|
}
|
|
274
294
|
/* "Try it": what is in the form, not saved, on one short recording. */
|
|
275
|
-
async try(body, audio) {
|
|
295
|
+
async try(body, audio, device) {
|
|
276
296
|
const checked = this.#checked(body);
|
|
277
297
|
this.#fresh(checked);
|
|
278
298
|
const config = this.#configOf(checked);
|
|
279
299
|
await this.#guard(config);
|
|
280
|
-
return transcribe(config, audio, this.#fetcher);
|
|
300
|
+
return transcribe({ ...config, language: languageOf(config.language, device) }, audio, this.#fetcher);
|
|
281
301
|
}
|
|
282
302
|
}
|
package/web/app.js
CHANGED
|
@@ -1613,6 +1613,7 @@
|
|
|
1613
1613
|
/* THE BAR (G): Chat | Terminal | Assets N, then its settings. What was
|
|
1614
1614
|
given to it is counted on "Assets", and shown there. */
|
|
1615
1615
|
let assetsShown = false; let roomPick = '';
|
|
1616
|
+
let listsShown = false; let listsOf = ''; let listsView = null; /* its Lists tab: below */
|
|
1616
1617
|
/* A secret near or past its expiry (secrets.mjs, WARN_DAYS): a dot on Assets, and on the
|
|
1617
1618
|
Assets of a conversation that has it. Read with the list, at most once a minute. */
|
|
1618
1619
|
let secretsKnown = []; let secretsReadAt = 0;
|
|
@@ -1633,6 +1634,12 @@
|
|
|
1633
1634
|
if (Date.now() - secretsReadAt > 60_000) { secretsReadAt = Date.now(); void readSecretsNow().catch(() => {}); }
|
|
1634
1635
|
/* Its title names each of them, with what it may do. */
|
|
1635
1636
|
$('view-assets').title = c ? [...(c.offline === true ? ['offline'] : []), ...(c.resources ?? []).map((r) => `${r.name} - ${r.access}`), ...(c.secrets ?? [])].join(', ') || 'Nothing given yet' : '';
|
|
1637
|
+
/* Lists: a tab once it was given one; counted, what waits for the owner's tick. */
|
|
1638
|
+
const given = c?.lists ?? null;
|
|
1639
|
+
$('view-lists').hidden = !given?.lists;
|
|
1640
|
+
$('lists-count').textContent = given?.waiting ? String(given.waiting) : '';
|
|
1641
|
+
$('view-lists').title = given?.waiting ? `${given.waiting} to approve` : LISTS_WORD.its;
|
|
1642
|
+
if (listsShown && !given?.lists) leaveLists();
|
|
1636
1643
|
paintViews();
|
|
1637
1644
|
/* Drawn again only when what it was given changed (not at each look at the list). */
|
|
1638
1645
|
const sig = JSON.stringify([current, c?.resources, c?.secrets, c?.work]);
|
|
@@ -1642,21 +1649,22 @@
|
|
|
1642
1649
|
function paintViews() {
|
|
1643
1650
|
if (DEVICE) return;
|
|
1644
1651
|
const now = tabNow();
|
|
1645
|
-
for (const [id, tab] of [['view-chat', 'chat'], ['view-terminal', 'terminal'], ['view-assets', 'assets'], ['folders', 'settings']]) $(id).setAttribute('aria-pressed', String(now === tab));
|
|
1652
|
+
for (const [id, tab] of [['view-chat', 'chat'], ['view-terminal', 'terminal'], ['view-assets', 'assets'], ['view-lists', 'lists'], ['folders', 'settings']]) $(id).setAttribute('aria-pressed', String(now === tab));
|
|
1646
1653
|
}
|
|
1647
1654
|
/* THE FOUR TABS: Chat, Terminal, Assets, Settings. The one it opened on
|
|
1648
1655
|
takes no step; any other is one step (one only, whichever other tab is
|
|
1649
1656
|
shown), and Back comes back to the first. Changing tab closes what was
|
|
1650
1657
|
open in the one before, and anything over the screen. */
|
|
1651
1658
|
let panelShown = false;
|
|
1652
|
-
const tabNow = () => (assetsShown ? 'assets' : panelShown ? 'settings' : simple ? 'chat' : 'terminal');
|
|
1653
|
-
const TAB_WORD = { chat: 'Chat', terminal: 'Terminal', assets: 'Assets', settings: 'Settings' };
|
|
1654
|
-
function openPanelZone() { if (panelShown) return; panelShown = true; $('panel').hidden = false; paintViews(); }
|
|
1659
|
+
const tabNow = () => (assetsShown ? 'assets' : listsShown ? 'lists' : panelShown ? 'settings' : simple ? 'chat' : 'terminal');
|
|
1660
|
+
const TAB_WORD = { chat: 'Chat', terminal: 'Terminal', assets: 'Assets', get lists() { return LISTS_WORD.many; }, settings: 'Settings' };
|
|
1661
|
+
function openPanelZone() { closeRoomLists(); if (panelShown) return; panelShown = true; $('panel').hidden = false; paintViews(); }
|
|
1655
1662
|
function closePanelZone() { if (!panelShown) return; panelShown = false; $('panel').hidden = true; $('attach-picker').hidden = true; paintViews(); }
|
|
1656
1663
|
function showTab(which, pick) {
|
|
1657
1664
|
if (which === 'assets') { closePanelZone(); void openRoomAssets(pick); return; }
|
|
1658
1665
|
if (which === 'settings') { closeRoomAssets(); openPanelZone(); return; }
|
|
1659
|
-
closeRoomAssets(); closePanelZone();
|
|
1666
|
+
if (which === 'lists') { closeRoomAssets(); closePanelZone(); void openRoomLists(); return; }
|
|
1667
|
+
closeRoomAssets(); closePanelZone(); closeRoomLists();
|
|
1660
1668
|
if ((which === 'chat') !== simple) toggleSimple(); else { paintViews(); if (!simple) focusTerminal(); }
|
|
1661
1669
|
}
|
|
1662
1670
|
/* The tab it opened on: the one shown before any step of a tab, or the one a review came from. */
|
|
@@ -1683,7 +1691,7 @@
|
|
|
1683
1691
|
function resetTabs() {
|
|
1684
1692
|
if (!DEVICE) nav.cut(nav.first(['tab', 'asset', 'review', 'over']));
|
|
1685
1693
|
else nav.cut(nav.first(['over']));
|
|
1686
|
-
closeRoomAssets(); closePanelZone();
|
|
1694
|
+
closeRoomAssets(); closePanelZone(); closeRoomLists();
|
|
1687
1695
|
$('files').hidden = $('copy').hidden = true;
|
|
1688
1696
|
}
|
|
1689
1697
|
/* Its settings closed for a question asked over its screen (a restart, a move). */
|
|
@@ -1691,6 +1699,23 @@
|
|
|
1691
1699
|
$('view-chat').addEventListener('click', () => goTab('chat'));
|
|
1692
1700
|
$('view-terminal').addEventListener('click', () => goTab('terminal'));
|
|
1693
1701
|
$('view-assets').addEventListener('click', () => goTab('assets'));
|
|
1702
|
+
$('view-lists').addEventListener('click', () => goTab('lists'));
|
|
1703
|
+
/* ITS LISTS: Binder's screen, cut to the lists given to it (read or write). */
|
|
1704
|
+
async function openRoomLists() {
|
|
1705
|
+
if (DEVICE || !current) return;
|
|
1706
|
+
listsShown = true; $('clists').hidden = false; paintViews();
|
|
1707
|
+
if (listsView && listsOf === current) { void listsView.refresh(); return; }
|
|
1708
|
+
const name = current; listsOf = name;
|
|
1709
|
+
listsView = null;
|
|
1710
|
+
const view = await mountBinder($('clists-binder'), (l) => Boolean(l.grants?.[`conversation:${name}`]));
|
|
1711
|
+
if (listsOf === name) listsView = view;
|
|
1712
|
+
}
|
|
1713
|
+
function closeRoomLists() { if (!listsShown) return; listsShown = false; $('clists').hidden = true; paintViews(); }
|
|
1714
|
+
/* Its last list taken back: its first tab again. */
|
|
1715
|
+
function leaveLists() {
|
|
1716
|
+
/* Under a place (Assets, where it was taken back): changed in place, the place left open. */
|
|
1717
|
+
if (place !== 'conversations' || !nav.close('tab')) showTab(simple ? 'chat' : 'terminal');
|
|
1718
|
+
}
|
|
1694
1719
|
/* ONE RULE: the left column is the platform, the bar is this conversation.
|
|
1695
1720
|
Its Access chapter what THIS conversation has: attached folders,
|
|
1696
1721
|
repositories and mailboxes, secrets handed to its tool,
|
|
@@ -3003,10 +3028,29 @@
|
|
|
3003
3028
|
own (the bar's "Assets N"): what it was given, the same rows; a folder
|
|
3004
3029
|
opened shows its files (the Files sheet, moved in), a repository its
|
|
3005
3030
|
branches. On a phone, the list, then one asset with "All assets". */
|
|
3006
|
-
|
|
3031
|
+
/* BINDER'S LISTS, AS THIS PAGE NAMES THEM: the one place for the word (Assets, a conversation's tab). */
|
|
3032
|
+
const LISTS_WORD = { many: 'Binders', one: 'Binder', a: 'a binder', its: 'Its binders' };
|
|
3033
|
+
$('view-lists-word').textContent = LISTS_WORD.many; $('listnew-head').textContent = `New ${LISTS_WORD.one.toLowerCase()}`;
|
|
3034
|
+
const ASSET_KINDS = [['git', 'Git repositories', 'git-branch'], ['folder', 'Folders', 'folder'], ['mailbox', 'Mailboxes', 'mail'], ['secret', 'Secrets', 'key-round'], ['list', LISTS_WORD.many, '']];
|
|
3007
3035
|
const getJson = (path, fallback) => fetch(`${API}${path}`).then((r) => (r.ok ? r.json() : fallback)).catch(() => fallback);
|
|
3008
3036
|
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text !== undefined) e.textContent = text; return e; };
|
|
3009
|
-
|
|
3037
|
+
/* A commit: its line, and the rest of its message under it, opened by a click. */
|
|
3038
|
+
function commitRow(c) {
|
|
3039
|
+
const rest = (c.message ?? '').split('\n').slice(1).join('\n').trim();
|
|
3040
|
+
const head = [el('code', '', c.id.slice(0, 8)), el('b', '', c.subject), el('small', '', `${c.author}, ${new Date(c.date).toLocaleString()}`)];
|
|
3041
|
+
if (!rest) { const line = el('div', 'commit'); line.append(...head); return line; }
|
|
3042
|
+
const line = el('details', 'commit'); const summary = el('summary'); summary.append(...head);
|
|
3043
|
+
line.append(summary, el('pre', '', rest));
|
|
3044
|
+
return line;
|
|
3045
|
+
}
|
|
3046
|
+
const kindIcon = (kind) => { const name = kind === 'send' ? 'arrow-up' : ASSET_KINDS.find((k) => k[0] === kind)?.[2]; const holder = el('span', 'as-ic'); holder.dataset.kind = kind; const svg = kind === 'list' ? listIcon() : name ? window.clavariumIcons?.icon(name) : null; if (svg) holder.append(svg); return holder; };
|
|
3047
|
+
/* A list (Binder's): the set has no such sign, so it is drawn here, in its style. */
|
|
3048
|
+
function listIcon() {
|
|
3049
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
3050
|
+
const svg = document.createElementNS(SVG, 'svg'); svg.setAttribute('viewBox', '0 0 24 24'); svg.setAttribute('aria-hidden', 'true');
|
|
3051
|
+
for (const d of ['m3 17 2 2 4-4', 'm3 7 2 2 4-4', 'M13 6h8', 'M13 12h8', 'M13 18h8']) { const path = document.createElementNS(SVG, 'path'); path.setAttribute('d', d); svg.append(path); }
|
|
3052
|
+
return svg;
|
|
3053
|
+
}
|
|
3010
3054
|
const roundPlus = (label, onclick) => { const b = el('button', 'as-add', '+'); b.type = 'button'; b.setAttribute('aria-label', label); b.title = label; b.addEventListener('click', onclick); return b; };
|
|
3011
3055
|
/* The rows, by kind. items: [{key, kind, name, sub, badge, badgeTitle, tone}]. */
|
|
3012
3056
|
function paintAsList(holder, items, { chosen, choose, add, empty }) {
|
|
@@ -3016,7 +3060,7 @@
|
|
|
3016
3060
|
if (mine.length === 0 && !add) continue;
|
|
3017
3061
|
const section = el('section', 'as-kind'); section.dataset.kind = kind;
|
|
3018
3062
|
const head = el('div', 'as-kind-head'); head.append(el('h3', '', title));
|
|
3019
|
-
if (add) head.append(roundPlus(`Add ${{ git: 'a repository', folder: 'a folder', mailbox: 'a mailbox', secret: 'a secret' }[kind]}`, () => add(kind)));
|
|
3063
|
+
if (add) head.append(roundPlus(`Add ${{ git: 'a repository', folder: 'a folder', mailbox: 'a mailbox', secret: 'a secret', list: LISTS_WORD.a }[kind]}`, () => add(kind)));
|
|
3020
3064
|
section.append(head);
|
|
3021
3065
|
if (mine.length === 0) section.append(el('p', 'hint as-none', 'None yet'));
|
|
3022
3066
|
for (const item of mine) {
|
|
@@ -3389,7 +3433,7 @@
|
|
|
3389
3433
|
} else if (tab === 'commits') {
|
|
3390
3434
|
for (const r of p) {
|
|
3391
3435
|
body.append(el('h4', '', `${r.name}: ${r.out.branch} → ${r.out.target}`));
|
|
3392
|
-
for (const c of r.out.commits)
|
|
3436
|
+
for (const c of r.out.commits) body.append(commitRow(c));
|
|
3393
3437
|
if ((r.out.count ?? 0) > r.out.commits.length) body.append(el('p', 'hint', `Only the last ${r.out.commits.length} of ${r.out.count} are listed.`));
|
|
3394
3438
|
}
|
|
3395
3439
|
} else {
|
|
@@ -3564,6 +3608,7 @@
|
|
|
3564
3608
|
$('copy').hidden = true;
|
|
3565
3609
|
if (!$('files').classList.contains('embedded')) $('files').hidden = true;
|
|
3566
3610
|
if (pick !== undefined) roomPick = pick;
|
|
3611
|
+
closeRoomLists();
|
|
3567
3612
|
assetsShown = true; $('cassets').hidden = false; paintViews();
|
|
3568
3613
|
await paintRoomAssets();
|
|
3569
3614
|
}
|
|
@@ -3624,10 +3669,27 @@
|
|
|
3624
3669
|
}
|
|
3625
3670
|
|
|
3626
3671
|
/* ---- the server's ---- */
|
|
3627
|
-
let assetOpen = ''; let assetsAdding = ''; let assetsQuery = ''; let remoteShown = ''; let remoteEditing = false;
|
|
3672
|
+
let assetOpen = ''; let assetsAdding = ''; let assetsQuery = ''; let remoteShown = ''; let remoteEditing = false; let listOpen = ''; let listsSig = '';
|
|
3673
|
+
/* A list given to a conversation, or taken back: a grant of Binder's. */
|
|
3674
|
+
const givenTo = (l) => Object.keys(l.grants ?? {}).filter((id) => id.startsWith('conversation:'));
|
|
3675
|
+
async function grantList(list, name, value) {
|
|
3676
|
+
$('assets-error').hidden = true;
|
|
3677
|
+
const done = await binderCall('grant', { list, to: `conversation:${name}`, access: value === 'none' ? null : value });
|
|
3678
|
+
if (!done.ok) { $('assets-error').textContent = done.text; $('assets-error').hidden = false; }
|
|
3679
|
+
await refresh();
|
|
3680
|
+
}
|
|
3681
|
+
/* A new list: Binder's templates, read once. */
|
|
3682
|
+
async function fillTemplates() {
|
|
3683
|
+
const pick = $('listnew-template');
|
|
3684
|
+
if (pick.options.length) return;
|
|
3685
|
+
const names = await binderCall('templates', {});
|
|
3686
|
+
if (!names.ok || pick.options.length) return;
|
|
3687
|
+
for (const [key, name] of Object.entries(names.data)) { const o = document.createElement('option'); o.value = key; o.textContent = name[binderLang()] ?? name.en; pick.append(o); }
|
|
3688
|
+
}
|
|
3628
3689
|
async function paintAssets() {
|
|
3629
3690
|
if (place !== 'assets' || DEVICE) return;
|
|
3630
|
-
const [all, boxes, secrets, keys] = await Promise.all([getJson('/resources', []), getJson('/mailboxes', []), getJson('/secrets', []), getJson('/git-keys', []), readDevices()]);
|
|
3691
|
+
const [all, boxes, secrets, keys, lists] = await Promise.all([getJson('/resources', []), getJson('/mailboxes', []), getJson('/secrets', []), getJson('/git-keys', []), binderCall('lists', {}), readDevices()]);
|
|
3692
|
+
if (place !== 'assets') return;
|
|
3631
3693
|
paintKeys(keys);
|
|
3632
3694
|
markSecrets(secrets);
|
|
3633
3695
|
const items = [];
|
|
@@ -3638,6 +3700,13 @@
|
|
|
3638
3700
|
sub: kind === 'git' ? `${gitSub(r)}${viaText(r.via)}` : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
3639
3701
|
}
|
|
3640
3702
|
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') });
|
|
3703
|
+
/* Binder's lists: given to a conversation (read, write) in Binder itself. */
|
|
3704
|
+
const shownLists = lists.ok && Array.isArray(lists.data) ? lists.data.filter((l) => !l.archived) : [];
|
|
3705
|
+
listsSig = binderSig(lists.data);
|
|
3706
|
+
for (const l of shownLists) {
|
|
3707
|
+
const users = givenTo(l).length;
|
|
3708
|
+
items.push({ key: `list:${l.id}`, kind: 'list', name: l.title, list: l, badge: String(users), badgeTitle: `Used by ${users} conversation${users === 1 ? '' : 's'}`, badgeTone: 'count', sub: `${l.count} card${l.count === 1 ? '' : 's'}` });
|
|
3709
|
+
}
|
|
3641
3710
|
const shown = assetsQuery ? items.filter((i) => i.name.includes(assetsQuery.toLowerCase()) || i.name.toLowerCase().includes(assetsQuery.toLowerCase())) : items;
|
|
3642
3711
|
const chosen = assetsAdding ? null : items.find((i) => i.key === assetOpen) ?? null;
|
|
3643
3712
|
$('assets-as').dataset.open = chosen || assetsAdding ? 'detail' : 'list';
|
|
@@ -3654,7 +3723,7 @@
|
|
|
3654
3723
|
if (assetsAdding === 'choose') {
|
|
3655
3724
|
detail.append(el('h3', '', 'New asset'));
|
|
3656
3725
|
const kinds = el('div', 'as-kinds');
|
|
3657
|
-
for (const [kind, word] of [['git', 'Git repository'], ['folder', 'Folder'], ['mailbox', 'Mailbox'], ['secret', 'Secret']]) {
|
|
3726
|
+
for (const [kind, word] of [['git', 'Git repository'], ['folder', 'Folder'], ['mailbox', 'Mailbox'], ['secret', 'Secret'], ['list', LISTS_WORD.one]]) {
|
|
3658
3727
|
const b = el('button', '', word); b.type = 'button'; b.dataset.kind = kind;
|
|
3659
3728
|
b.addEventListener('click', () => { assetsAdding = kind; void paintAssets(); });
|
|
3660
3729
|
b.prepend(kindIcon(kind)); kinds.append(b);
|
|
@@ -3665,6 +3734,7 @@
|
|
|
3665
3734
|
const form = $(`${assetsAdding}-box`); form.hidden = false;
|
|
3666
3735
|
detail.append(form);
|
|
3667
3736
|
if (assetsAdding === 'git') { fillKeyChoice(); showVia(); }
|
|
3737
|
+
if (assetsAdding === 'list') void fillTemplates();
|
|
3668
3738
|
focusField(form.querySelector('input:not([type=radio])'));
|
|
3669
3739
|
return;
|
|
3670
3740
|
}
|
|
@@ -3673,6 +3743,7 @@
|
|
|
3673
3743
|
const form = $(`${assetsAdding}-box`); form.hidden = false;
|
|
3674
3744
|
detail.append(all2, form);
|
|
3675
3745
|
if (assetsAdding === 'git') { fillKeyChoice(); showVia(); }
|
|
3746
|
+
if (assetsAdding === 'list') void fillTemplates();
|
|
3676
3747
|
focusField(form.querySelector('input:not([type=radio])'));
|
|
3677
3748
|
return;
|
|
3678
3749
|
}
|
|
@@ -3704,7 +3775,7 @@
|
|
|
3704
3775
|
}
|
|
3705
3776
|
/* Used by: each conversation that has it, what it may do; "+" offers the others. */
|
|
3706
3777
|
const options = chosen.kind === 'secret' ? [['off', 'Off'], ['use', 'Use']] : chosen.kind === 'mailbox' ? [['none', 'Off'], ['read', 'Read']] : [['none', 'Off'], ['read', 'Read'], ['write', 'Write']];
|
|
3707
|
-
const has = (c) => (chosen.kind === 'secret' ? (chosen.secret.conversations.includes(c.name) ? 'use' : 'off') : r.attachments?.[c.name] ?? 'none');
|
|
3778
|
+
const has = (c) => (chosen.kind === 'secret' ? (chosen.secret.conversations.includes(c.name) ? 'use' : 'off') : chosen.kind === 'list' ? chosen.list.grants?.[`conversation:${c.name}`] ?? 'none' : r.attachments?.[c.name] ?? 'none');
|
|
3708
3779
|
const using = ready.filter((c) => !['none', 'off'].includes(has(c)));
|
|
3709
3780
|
const others = ready.filter((c) => ['none', 'off'].includes(has(c)));
|
|
3710
3781
|
const users = el('div', 'as-users');
|
|
@@ -3713,6 +3784,7 @@
|
|
|
3713
3784
|
const line = el('div', 'given-row'); line.dataset.conversation = c.name;
|
|
3714
3785
|
line.append(el('span', '', shownName(c)), modes(options, has(c), async (value) => {
|
|
3715
3786
|
if (chosen.kind === 'secret') await handTo(c.name, chosen.name, value === 'use', 'assets-error');
|
|
3787
|
+
else if (chosen.kind === 'list') await grantList(chosen.list.id, c.name, value);
|
|
3716
3788
|
else await attachTo(c.name, chosen.name, value, 'assets-error');
|
|
3717
3789
|
await paintAssets();
|
|
3718
3790
|
}, `What ${c.name} may do with ${chosen.name}`));
|
|
@@ -3723,6 +3795,15 @@
|
|
|
3723
3795
|
for (const c of others) picker.append(row(c));
|
|
3724
3796
|
if (others.length === 0) picker.append(el('p', 'hint', ready.length ? 'Every conversation has it.' : 'No conversation is ready.'));
|
|
3725
3797
|
detail.append(chapter('Used by', roundPlus('Give it to a conversation', () => { picker.hidden = !picker.hidden; })), users, picker);
|
|
3798
|
+
if (chosen.kind === 'list') {
|
|
3799
|
+
/* The list itself, Binder's screen, here: that list alone. */
|
|
3800
|
+
const open = el('button', '', listOpen === chosen.key ? 'Close' : 'Open'); open.type = 'button'; open.dataset.act = 'open-list';
|
|
3801
|
+
const holder = el('div', 'binder-holder as-binder');
|
|
3802
|
+
open.addEventListener('click', () => { listOpen = listOpen === chosen.key ? '' : chosen.key; void paintAssets(); });
|
|
3803
|
+
detail.append(chapter('Cards', open), holder);
|
|
3804
|
+
const id = chosen.list.id;
|
|
3805
|
+
if (listOpen === chosen.key) void mountBinder(holder, (l) => l.id === id, { onLists: (data) => { if (place === 'assets' && binderSig(data) !== listsSig) void paintAssets(); } });
|
|
3806
|
+
}
|
|
3726
3807
|
if (chosen.kind === 'git') {
|
|
3727
3808
|
const holder = el('div', 'as-git'); detail.append(holder);
|
|
3728
3809
|
/* Settings: where it is sent, with what. */
|
|
@@ -3746,15 +3827,20 @@
|
|
|
3746
3827
|
const remove = el('button', 'as-link danger-link', 'Delete...'); remove.type = 'button';
|
|
3747
3828
|
const why = el('small', 'hint');
|
|
3748
3829
|
const inUse = chosen.kind !== 'secret' && using.length > 0;
|
|
3830
|
+
const lost = { secret: 'Its value is lost for good.', list: 'Its cards are lost for good.' }[chosen.kind] ?? 'Its files are kept aside on the server.';
|
|
3749
3831
|
if (inUse) { remove.disabled = true; why.textContent = ` used by ${using.length} conversation${using.length > 1 ? 's' : ''}: set ${using.length > 1 ? 'them' : 'it'} to Off first`; }
|
|
3750
3832
|
remove.addEventListener('click', () => {
|
|
3751
|
-
const sure = el('button', 'danger', chosen.kind === 'secret' ? `Yes, delete ${chosen.name}` : `Yes, remove ${chosen.name}`); sure.type = 'button';
|
|
3833
|
+
const sure = el('button', 'danger', chosen.kind === 'secret' || chosen.kind === 'list' ? `Yes, delete ${chosen.name}` : `Yes, remove ${chosen.name}`); sure.type = 'button';
|
|
3752
3834
|
const keep = el('button', '', 'Keep'); keep.type = 'button';
|
|
3753
3835
|
keep.addEventListener('click', () => { void paintAssets(); });
|
|
3754
3836
|
const ask = el('div', 'callout bad confirm'); ask.setAttribute('role', 'alertdialog');
|
|
3755
|
-
ask.append(el('span', '',
|
|
3837
|
+
ask.append(el('span', '', lost), keep, sure);
|
|
3756
3838
|
sure.addEventListener('click', async () => {
|
|
3757
|
-
try {
|
|
3839
|
+
try {
|
|
3840
|
+
if (chosen.kind === 'list') { const done = await binderCall('delete-list', { list: chosen.list.id }); if (!done.ok) throw new Error(done.text); }
|
|
3841
|
+
else await post(chosen.kind === 'secret' ? `${API}/secrets/${chosen.name}/remove` : `${API}/resources/${chosen.name}/remove`);
|
|
3842
|
+
assetOpen = '';
|
|
3843
|
+
}
|
|
3758
3844
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3759
3845
|
await paintAssets();
|
|
3760
3846
|
});
|
|
@@ -3764,7 +3850,7 @@
|
|
|
3764
3850
|
/* Given to a device: from here too (the map shows who has it). */
|
|
3765
3851
|
const share = el('button', 'as-link', 'Share with a device...'); share.type = 'button';
|
|
3766
3852
|
share.addEventListener('click', () => { void openCompose([[chosen.key, 'r']]); });
|
|
3767
|
-
const foot = el('div', 'as-foot'); foot.append(...(chosen.kind === 'secret' ? [] : [share, el('br')]), remove, why);
|
|
3853
|
+
const foot = el('div', 'as-foot'); foot.append(...(chosen.kind === 'secret' || chosen.kind === 'list' ? [] : [share, el('br')]), remove, why);
|
|
3768
3854
|
detail.append(foot);
|
|
3769
3855
|
}
|
|
3770
3856
|
/* From the map's "+" of Assets: the Assets page over the map, on "which kind"; Back, the map. */
|
|
@@ -3980,8 +4066,6 @@
|
|
|
3980
4066
|
$('settings').hidden = which !== 'settings';
|
|
3981
4067
|
$('assets').hidden = which !== 'assets';
|
|
3982
4068
|
$('newconv').hidden = which !== 'new';
|
|
3983
|
-
$('lists').hidden = which !== 'lists';
|
|
3984
|
-
if (which === 'lists') void paintLists(); else stopLists();
|
|
3985
4069
|
if (which !== 'access') composing = false;
|
|
3986
4070
|
/* What the conversation had open (its tab) waits under the place, as it was. */
|
|
3987
4071
|
if (which !== 'conversations') { for (const id of ['files', 'copy']) $(id).hidden = true; view('room'); }
|
|
@@ -4054,34 +4138,49 @@
|
|
|
4054
4138
|
}
|
|
4055
4139
|
/* `of`: the conversation it is filtered on ('' for none; left as it is when not given).
|
|
4056
4140
|
`face`: on the devices tab, 'compose' keeps what openCompose prepared. */
|
|
4057
|
-
/*
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4141
|
+
/* BINDER'S SCREEN (clavarium-binder), where a list is seen: one list of Assets opened, a
|
|
4142
|
+
conversation's Lists tab. Binder has no filter: the lists it is answered are cut here to
|
|
4143
|
+
those `keep` says. Every screen shown is read again when the lists changed. */
|
|
4144
|
+
let binderPeople = []; let binderChanges = -1; let binderTimer = null; let binderParts = null;
|
|
4145
|
+
const binderViews = new Set();
|
|
4146
|
+
function binderLang() { return /^fr\b/i.test(navigator.language ?? '') ? 'fr' : 'en'; }
|
|
4147
|
+
function binderCall(op, args) {
|
|
4148
|
+
return fetch(`${API}/binder`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ op, args }) })
|
|
4149
|
+
.then((r) => r.json()).catch(() => ({ ok: false, text: 'The server could not be reached.' }));
|
|
4150
|
+
}
|
|
4151
|
+
/* What a page drew from the lists, to know when they changed. */
|
|
4152
|
+
function binderSig(lists) { return JSON.stringify((Array.isArray(lists) ? lists : []).map((l) => [l.id, l.title, l.archived, l.count, l.grants])); }
|
|
4153
|
+
async function mountBinder(holder, keep, { onLists } = {}) {
|
|
4154
|
+
binderParts ??= Promise.all([import(new URL('vendor/binder-ui.js', new URL('/', location.href)).href), fetch(`/vendor/binder-${binderLang()}.json`).then((r) => r.json()).catch(() => ({}))]);
|
|
4155
|
+
const [[{ mount }, words], seen] = await Promise.all([binderParts, getJson('/binder/people', null)]);
|
|
4063
4156
|
if (seen) { binderPeople = seen.people; binderChanges = seen.changes; }
|
|
4064
|
-
if (!
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
}
|
|
4075
|
-
|
|
4157
|
+
if (!holder.isConnected) return null;
|
|
4158
|
+
const view = mount(holder, {
|
|
4159
|
+
words, lang: binderLang(), people: () => binderPeople,
|
|
4160
|
+
call: async (op, args) => {
|
|
4161
|
+
const r = await binderCall(op, args);
|
|
4162
|
+
if (op === 'lists' && r.ok && Array.isArray(r.data)) { onLists?.(r.data); r.data = r.data.filter(keep); }
|
|
4163
|
+
return r;
|
|
4164
|
+
},
|
|
4165
|
+
/* A thing attached opens where this page opens it. */
|
|
4166
|
+
openAttached: (a) => { if (a.kind === 'asset') void openAssetsPlace(a.ref); },
|
|
4167
|
+
});
|
|
4168
|
+
binderViews.add({ box: holder.firstElementChild, view });
|
|
4169
|
+
watchBinders();
|
|
4170
|
+
return view;
|
|
4171
|
+
}
|
|
4172
|
+
function watchBinders() {
|
|
4173
|
+
if (binderTimer) return;
|
|
4076
4174
|
binderTimer = setInterval(async () => {
|
|
4077
|
-
|
|
4175
|
+
for (const one of binderViews) if (!one.box?.isConnected) { one.view.destroy(); binderViews.delete(one); }
|
|
4176
|
+
if (binderViews.size === 0) { clearInterval(binderTimer); binderTimer = null; return; }
|
|
4177
|
+
if (document.hidden) return;
|
|
4078
4178
|
const now = await getJson('/binder/people', null);
|
|
4079
4179
|
if (!now) return;
|
|
4080
4180
|
binderPeople = now.people;
|
|
4081
|
-
if (now.changes !== binderChanges) { binderChanges = now.changes; void
|
|
4181
|
+
if (now.changes !== binderChanges) { binderChanges = now.changes; for (const one of binderViews) void one.view.refresh(); }
|
|
4082
4182
|
}, 4000);
|
|
4083
4183
|
}
|
|
4084
|
-
function stopLists() { if (binderTimer) clearInterval(binderTimer); binderTimer = null; }
|
|
4085
4184
|
async function openAccessPage(tab = accessTab, { mode, of, face: shown = 'manage', push = true, pin } = {}) {
|
|
4086
4185
|
if (DEVICE) return;
|
|
4087
4186
|
/* Assets left Access: a conversation's own, or the server's. */
|
|
@@ -4116,17 +4215,14 @@
|
|
|
4116
4215
|
if (/^[a-z]{1,20}$/.test(at)) openChapter(`s-${at}`)?.scrollIntoView({ block: 'start' });
|
|
4117
4216
|
return;
|
|
4118
4217
|
}
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
if (open === 'assets' || (open === 'access' && q.get('tab') === 'assets')) { await openAssetsPlace(q.get('a') ?? undefined, { push: false }); return; }
|
|
4218
|
+
/* Assets, a place of its own now (it was a tab of Access); Lists, a kind of asset now. */
|
|
4219
|
+
if (open === 'assets' || open === 'lists' || (open === 'access' && q.get('tab') === 'assets')) { await openAssetsPlace(q.get('a') ?? undefined, { push: false }); return; }
|
|
4122
4220
|
const former = FORMER[open === 'access' ? (q.get('tab') ?? 'map') : open];
|
|
4123
4221
|
if (former) { await openAccessPage(former[0], { mode: former[1], of: q.get('for') ?? '', push: false }); return; }
|
|
4124
4222
|
leftPlace(false);
|
|
4125
4223
|
}
|
|
4126
4224
|
nav.outside = () => { if (!DEVICE) void followAddress(); };
|
|
4127
4225
|
$('nav-conversations').addEventListener('click', () => { leavePlace({ list: true }); });
|
|
4128
|
-
$('nav-lists').addEventListener('click', () => openListsPlace());
|
|
4129
|
-
$('lists-close').addEventListener('click', () => leavePlace());
|
|
4130
4226
|
$('nav-access').addEventListener('click', () => { if (place !== 'access' || accessTab !== 'map' || mapMode !== 'map') void openAccessPage('map', { mode: 'map' }); });
|
|
4131
4227
|
$('nav-assets').addEventListener('click', () => { if (place !== 'assets') void openAssetsPlace(); });
|
|
4132
4228
|
$('map-new-device').addEventListener('click', () => { void openCompose(accessFor ? [[`conversation:${accessFor}`, partsFor(accessFor)]] : []); });
|
|
@@ -5243,7 +5339,7 @@
|
|
|
5243
5339
|
item(`${counted}; ${g.newBytes === null || g.newBytes === undefined ? 'the size of the new data is unknown' : `${sizeText(g.newBytes)} of new data`}.`);
|
|
5244
5340
|
/* What the review could not show: each said, and Send asks to confirm. */
|
|
5245
5341
|
for (const line of g.incomplete ?? []) item(line);
|
|
5246
|
-
if (g.largest?.length) item(`Largest new files: ${g.largest.slice(0, 5).map((b) => `${b.path || '(no path)'} (${sizeText(b.size)})`).join(', ')}.`);
|
|
5342
|
+
if (g.largest?.length) item(`Largest new files: ${g.largest.filter((b, i, all) => !b.path || all.findIndex((x) => x.path === b.path) === i).slice(0, 5).map((b) => `${b.path || '(no path)'} (${sizeText(b.size)})`).join(', ')}.`);
|
|
5247
5343
|
if (g.unchanged?.length) item(`Changed and changed back, so not in the changes below: ${g.unchanged.join(', ')}${g.unchangedAll > g.unchanged.length ? `, and ${g.unchangedAll - g.unchanged.length} more` : ''}.`);
|
|
5248
5344
|
if (g.merges) item(`${g.merges} merge commit${g.merges === 1 ? '' : 's'}: what they bring from their other parents is in the count, not listed.`);
|
|
5249
5345
|
if (out.cut) item('The changes are too long to be shown whole here.');
|
|
@@ -5386,16 +5482,7 @@
|
|
|
5386
5482
|
...(out.guards?.newBytes !== null && out.guards?.newBytes !== undefined ? [bit(`${sizeText(out.guards.newBytes)} of new data`, 'hint')] : []));
|
|
5387
5483
|
$('gitview-n-files').textContent = String(files.length);
|
|
5388
5484
|
$('gitview-n-commits').textContent = String(out.commits.length);
|
|
5389
|
-
for (const c of out.commits)
|
|
5390
|
-
const line = document.createElement('div'); line.className = 'commit';
|
|
5391
|
-
const id = document.createElement('code'); id.textContent = c.id.slice(0, 8);
|
|
5392
|
-
const what = document.createElement('b'); what.textContent = c.subject;
|
|
5393
|
-
const who = document.createElement('small'); who.textContent = `${c.author}, ${new Date(c.date).toLocaleString()}`;
|
|
5394
|
-
line.append(id, what, who);
|
|
5395
|
-
/* The whole message: what a subject line leaves out is part of what is sent. */
|
|
5396
|
-
if (c.message && c.message !== c.subject) { const body = document.createElement('pre'); body.textContent = c.message.split('\n').slice(1).join('\n').trim(); if (body.textContent) line.append(body); }
|
|
5397
|
-
$('gitview-commits').append(line);
|
|
5398
|
-
}
|
|
5485
|
+
for (const c of out.commits) $('gitview-commits').append(commitRow(c));
|
|
5399
5486
|
$('gitview-stat').textContent = out.stat;
|
|
5400
5487
|
gitFile = 0;
|
|
5401
5488
|
drawDiff(out.diff);
|
|
@@ -5522,6 +5609,14 @@
|
|
|
5522
5609
|
button.disabled = false; button.textContent = 'Add';
|
|
5523
5610
|
await paintAssets();
|
|
5524
5611
|
});
|
|
5612
|
+
$('list-new').addEventListener('submit', async (event) => {
|
|
5613
|
+
event.preventDefault();
|
|
5614
|
+
$('assets-error').hidden = true;
|
|
5615
|
+
const made = await binderCall('create-list', { template: $('listnew-template').value, title: $('listnew-title').value.trim(), lang: binderLang() });
|
|
5616
|
+
if (made.ok) { $('listnew-title').value = ''; assetsAdding = ''; assetOpen = `list:${made.data.id}`; listOpen = assetOpen; remember(); }
|
|
5617
|
+
else { $('assets-error').textContent = made.text; $('assets-error').hidden = false; }
|
|
5618
|
+
await paintAssets();
|
|
5619
|
+
});
|
|
5525
5620
|
$('folder-new').addEventListener('submit', async (event) => {
|
|
5526
5621
|
event.preventDefault();
|
|
5527
5622
|
$('assets-error').hidden = true;
|
package/web/index.html
CHANGED
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
<div id="list-resize" role="separator" aria-orientation="vertical" aria-label="Width of the list" title="Drag to widen or narrow the list; double click for its usual width" tabindex="0" hidden></div>
|
|
35
35
|
<nav id="nav" aria-label="Places" hidden>
|
|
36
36
|
<button type="button" id="nav-conversations" data-place="conversations" aria-current="page"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="message-square"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414 .586l-2.202 2.202A.71 .71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"/></svg><span>Conversations</span></button>
|
|
37
|
-
<button type="button" id="nav-lists" data-place="lists"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="list-checks"><path d="m3 17 2 2 4-4"/><path d="m3 7 2 2 4-4"/><path d="M13 6h8"/><path d="M13 12h8"/><path d="M13 18h8"/></svg><span>Lists</span></button>
|
|
38
37
|
<button type="button" id="nav-assets" data-place="assets"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="layers"><path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/></svg><span>Assets</span></button>
|
|
39
38
|
<button type="button" id="nav-access" data-place="access"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="waypoints"><path d="m10.586 5.414-5.172 5.172"/><path d="m18.586 13.414-5.172 5.172"/><path d="M6 12h12"/><circle cx="12" cy="20" r="2"/><circle cx="12" cy="4" r="2"/><circle cx="20" cy="12" r="2"/><circle cx="4" cy="12" r="2"/></svg><span>Access</span></button>
|
|
40
39
|
<button type="button" id="nav-settings" data-place="settings"><svg class="nav-ic" viewBox="0 0 24 24" aria-hidden="true" data-icon="settings"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/></svg><span>Settings</span></button>
|
|
@@ -45,11 +44,12 @@
|
|
|
45
44
|
<button type="button" id="fold" aria-label="Hide the list of conversations" aria-pressed="false" title="Hide or show the list of conversations">«</button>
|
|
46
45
|
<span id="state" data-state="connecting" role="status">connecting</span>
|
|
47
46
|
<b id="name"></b>
|
|
48
|
-
<!-- THE BAR: its chat, its terminal, what it was given, its settings (G)
|
|
47
|
+
<!-- THE BAR: its chat, its terminal, what it was given, its binders (once it has one), its settings (G). -->
|
|
49
48
|
<div id="views" class="views" role="group" aria-label="What to see">
|
|
50
49
|
<button type="button" id="view-chat" aria-pressed="false" title="Its chat"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414 .586l-2.202 2.202A.71 .71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"/></svg><span>Chat</span></button>
|
|
51
50
|
<button type="button" id="view-terminal" aria-pressed="false" title="Its terminal"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m7 11 2-2-2-2"/><path d="M11 13h4"/><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/></svg><span>Terminal</span></button>
|
|
52
51
|
<button type="button" id="view-assets" aria-pressed="false" title="What it was given"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"/><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"/><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"/></svg><span>Assets</span><b id="assets-count" class="count"></b></button>
|
|
52
|
+
<button type="button" id="view-lists" aria-pressed="false" title="Its binders" hidden><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="m3 17 2 2 4-4"/><path d="m3 7 2 2 4-4"/><path d="M13 6h8"/><path d="M13 12h8"/><path d="M13 18h8"/></svg><span id="view-lists-word">Binders</span><b id="lists-count" class="count" title="Waiting for your approval"></b></button>
|
|
53
53
|
<button type="button" id="folders" aria-pressed="false" aria-label="Settings" title="Settings of this conversation" hidden><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/></svg><span class="sr">Settings</span></button>
|
|
54
54
|
</div>
|
|
55
55
|
</header>
|
|
@@ -107,6 +107,8 @@
|
|
|
107
107
|
<div class="as-detail" id="cassets-detail"></div>
|
|
108
108
|
</div>
|
|
109
109
|
</div>
|
|
110
|
+
<!-- ITS LISTS: Binder's screen, only the lists given to it. -->
|
|
111
|
+
<div id="clists" class="sheet as-room" hidden><div id="clists-binder" class="binder-holder"></div></div>
|
|
110
112
|
<div id="panel" class="sheet" hidden>
|
|
111
113
|
<div class="panel-top"><b id="panel-title">This conversation</b></div>
|
|
112
114
|
<p id="panel-error" class="error" role="alert" hidden></p>
|
|
@@ -440,11 +442,6 @@
|
|
|
440
442
|
right: who uses it, its state, its settings. The forms that make
|
|
441
443
|
one, and a repository's remote, wait in #assets-forms and are moved
|
|
442
444
|
into the detail when asked for. -->
|
|
443
|
-
<!-- LISTS: the binder (clavarium-binder), drawn by Binder itself in #lists-binder. -->
|
|
444
|
-
<div id="lists" class="sheet as-place" hidden>
|
|
445
|
-
<div class="panel-top"><b>Lists</b><button type="button" id="lists-close" class="as-link place-back">‹ Conversations</button></div>
|
|
446
|
-
<div id="lists-binder"></div>
|
|
447
|
-
</div>
|
|
448
445
|
<div id="assets" class="sheet as-place" hidden>
|
|
449
446
|
<div class="panel-top"><b>Assets</b><button type="button" id="assets-close" class="as-link place-back">‹ Conversations</button></div>
|
|
450
447
|
<p id="assets-error" class="error" role="alert" hidden></p>
|
|
@@ -519,6 +516,14 @@
|
|
|
519
516
|
<button type="submit" class="primary">Add</button></div>
|
|
520
517
|
<p id="mailbox-error" class="error" role="alert" hidden></p>
|
|
521
518
|
</form>
|
|
519
|
+
</div>
|
|
520
|
+
<div id="list-box" class="as-form" data-kind="list"><h3 id="listnew-head">New binder</h3>
|
|
521
|
+
<form id="list-new" autocomplete="off">
|
|
522
|
+
<label for="listnew-template">Template</label>
|
|
523
|
+
<select id="listnew-template" required></select>
|
|
524
|
+
<label for="listnew-title">Title</label>
|
|
525
|
+
<div class="row"><input id="listnew-title" maxlength="200" placeholder="Optional"><button type="submit" class="primary">Create</button></div>
|
|
526
|
+
</form>
|
|
522
527
|
</div>
|
|
523
528
|
<div id="secret-box" class="as-form" data-kind="secret"><h3>New secret</h3><p class="hint">A value goes in and is never shown again.</p>
|
|
524
529
|
<form id="secret-new" autocomplete="off">
|
|
@@ -619,7 +624,7 @@
|
|
|
619
624
|
<div class="set-row"><div class="set-what"><label for="dictation-url">Address</label><small>Its transcription endpoint</small></div><div class="set-control"><input id="dictation-url" type="url" spellcheck="false" placeholder="https://.../v1/audio/transcriptions"></div></div>
|
|
620
625
|
<div class="set-row"><div class="set-what"><label for="dictation-model">Model</label></div><div class="set-control"><input id="dictation-model" spellcheck="false" maxlength="100"></div></div>
|
|
621
626
|
<div class="set-row"><div class="set-what"><label for="dictation-secret">Key</label><small id="dictation-key-hint">One of your secrets. Never shown</small></div><div class="set-control"><select id="dictation-secret"><option value="">No key</option></select></div></div>
|
|
622
|
-
<div class="set-row"><div class="set-what"><label for="dictation-language">Language</label></div><div class="set-control"><select id="dictation-language"><option value="">Automatic</option><option value="en">English (en)</option><option value="fr">French (fr)</option><option value="de">German (de)</option><option value="es">Spanish (es)</option><option value="it">Italian (it)</option><option value="nl">Dutch (nl)</option><option value="pt">Portuguese (pt)</option><option value="other">Another code...</option></select><input id="dictation-language-code" maxlength="8" spellcheck="false" placeholder="code, such as pl" aria-label="Language code" hidden></div></div>
|
|
627
|
+
<div class="set-row"><div class="set-what"><label for="dictation-language">Language</label></div><div class="set-control"><select id="dictation-language"><option value="">Each device's</option><option value="auto">Automatic</option><option value="en">English (en)</option><option value="fr">French (fr)</option><option value="de">German (de)</option><option value="es">Spanish (es)</option><option value="it">Italian (it)</option><option value="nl">Dutch (nl)</option><option value="pt">Portuguese (pt)</option><option value="other">Another code...</option></select><input id="dictation-language-code" maxlength="8" spellcheck="false" placeholder="code, such as pl" aria-label="Language code" hidden></div></div>
|
|
623
628
|
<p class="hint" id="dictation-other-hint" hidden>Any engine with the same interface (<code>/v1/audio/transcriptions</code>); it alone may be on this server's own network.</p>
|
|
624
629
|
<div class="action-row"><span class="hint" id="dictation-saved" role="status"></span><button type="button" id="dictation-off">Turn off</button><button type="button" id="dictation-try">Try it</button><button type="submit" class="primary" id="dictation-save">Save</button></div>
|
|
625
630
|
<p class="hint" id="dictation-heard" role="status" hidden></p>
|
package/web/style.css
CHANGED
|
@@ -1224,6 +1224,9 @@ select.pill { appearance: auto; }
|
|
|
1224
1224
|
:root:not([data-theme="light"]) .rv-diff .d2h-del del, :root:not([data-theme="light"]) .rv-diff .d2h-del .d2h-change { background: #8a2d33; }
|
|
1225
1225
|
:root:not([data-theme="light"]) .rv-diff .d2h-info { background: var(--bar); color: var(--ink2); border-color: var(--line); }
|
|
1226
1226
|
:root:not([data-theme="light"]) .rv-diff .d2h-emptyplaceholder, :root:not([data-theme="light"]) .rv-diff .d2h-code-side-emptyplaceholder { background: var(--bar); border-color: var(--line); }
|
|
1227
|
+
/* Line numbers in the flow of their row: diff2html places them absolutely, and they slide off their lines when the page scrolls. */
|
|
1228
|
+
.rv-diff .d2h-code-linenumber, .rv-diff .d2h-code-side-linenumber, .ts-diffs .d2h-code-linenumber, .ts-diffs .d2h-code-side-linenumber { position: static; }
|
|
1229
|
+
.rv-diff .d2h-code-line, .rv-diff .d2h-code-side-line, .ts-diffs .d2h-code-line, .ts-diffs .d2h-code-side-line { padding: 0 .6em; width: auto; }
|
|
1227
1230
|
/* Syntax colours (highlight.js classes), both themes. */
|
|
1228
1231
|
.rv-diff .hljs-keyword, .rv-diff .hljs-selector-tag, .rv-diff .hljs-built_in { color: #d73a49; }
|
|
1229
1232
|
.rv-diff .hljs-string, .rv-diff .hljs-attr, .rv-diff .hljs-regexp { color: #22863a; }
|
|
@@ -1242,7 +1245,6 @@ select.pill { appearance: auto; }
|
|
|
1242
1245
|
.rv-acts #gitview-push { flex: 1 1 100%; order: -1; }
|
|
1243
1246
|
.rv-body { grid-template-columns: minmax(0, 1fr); }
|
|
1244
1247
|
.rv-tree { position: static; max-height: none; }
|
|
1245
|
-
.rv-diff .d2h-code-linenumber { position: static; }
|
|
1246
1248
|
}
|
|
1247
1249
|
@media (max-width: 700px) {
|
|
1248
1250
|
html:not([data-door="device"]) #room > header { min-height: 44px; padding-block: 3px; }
|
|
@@ -1434,7 +1436,6 @@ button.inline.more-recent { text-decoration: none; }
|
|
|
1434
1436
|
.ts-diff:first-child h4 { margin-top: 0; }
|
|
1435
1437
|
.ts-tree { position: static; max-height: none; margin-bottom: 12px; }
|
|
1436
1438
|
.ts-diffs { min-width: 0; }
|
|
1437
|
-
.ts-diffs .d2h-code-linenumber { position: static; }
|
|
1438
1439
|
.ts-note { grid-column: 2 / -1; margin: 0; font-size: .875rem; }
|
|
1439
1440
|
.ts-note.bad { color: var(--danger); }
|
|
1440
1441
|
.ts-output { white-space: pre-wrap; max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: .8125rem; }
|
|
@@ -1699,7 +1700,26 @@ span.callout.confirm { display: inline-flex; justify-content: flex-end; padding:
|
|
|
1699
1700
|
|
|
1700
1701
|
/* Something asks for the person in this chapter (a callout, a warning): a dot on its title, and on its category. */
|
|
1701
1702
|
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; }
|
|
1702
|
-
/* LISTS: Binder's screen, in this page's colours.
|
|
1703
|
-
|
|
1704
|
-
|
|
1703
|
+
/* LISTS: Binder's screen, in this page's colours (above Binder's own dark ones, whatever the theme): a conversation's Lists tab, one list of Assets opened.
|
|
1704
|
+
Lists are made in Assets: Binder's own "+ New list" is not offered here. */
|
|
1705
|
+
.binder-holder { display: flex; flex-direction: column; min-height: 0; }
|
|
1706
|
+
#clists { padding: 0; }
|
|
1707
|
+
#clists-binder { overflow: auto; padding: 16px 16px 24px; }
|
|
1708
|
+
body .binder-holder .binder { --binder-bg: var(--bg); --binder-text: var(--ink); --binder-dim: var(--ink2); --binder-line: var(--line); --binder-panel: var(--panel);
|
|
1705
1709
|
--binder-action: var(--brass); --binder-on-action: #1b1405; --binder-ok: var(--ok); --binder-ask: var(--warn); --binder-danger: var(--danger); }
|
|
1710
|
+
.binder-holder .binder-new-list, .binder-holder .binder-empty .binder-primary { display: none; }
|
|
1711
|
+
/* One list opened in Assets: no row of tabs for it alone. */
|
|
1712
|
+
.as-binder .binder-top { display: none; }
|
|
1713
|
+
.as-binder { margin-top: 8px; }
|
|
1714
|
+
/* A box to tick stays a box on a touch screen (buttons are 44px high there), a little larger. */
|
|
1715
|
+
@media (pointer: coarse) { .binder-holder .binder-tick { min-height: 0; width: 1.75rem; height: 1.75rem; } }
|
|
1716
|
+
/* On the tab, what waits for the owner's tick: the colour of what asks. */
|
|
1717
|
+
.views #lists-count { background: var(--brass); color: var(--on-brass, #1b1405); font-weight: 700; }
|
|
1718
|
+
/* A commit with more to its message: a click on its line opens the rest. */
|
|
1719
|
+
details.commit { display: block; }
|
|
1720
|
+
details.commit > summary { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; cursor: pointer; list-style: none; }
|
|
1721
|
+
details.commit > summary::-webkit-details-marker { display: none; }
|
|
1722
|
+
details.commit > summary::before { content: '▸'; color: var(--ink2); width: 1em; flex: none; }
|
|
1723
|
+
details.commit[open] > summary::before { content: '▾'; }
|
|
1724
|
+
div.commit::before { content: ''; width: 1em; flex: none; }
|
|
1725
|
+
details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink2); font-size: .85em; }
|
package/web/voice.js
CHANGED
|
@@ -7,6 +7,13 @@ import { RATE, BLOCK, BLOCK_MS, Detector, Segmenter, loudness, toWav } from './v
|
|
|
7
7
|
known once it has signed in (the page writes it on the document). */
|
|
8
8
|
const api = () => (document.documentElement.dataset.door === 'device' ? `/c/api/${document.documentElement.dataset.pairing ?? ''}` : '/api');
|
|
9
9
|
|
|
10
|
+
/* The language this device speaks, sent with each phrase: the server asks the
|
|
11
|
+
engine for it unless another is chosen in Settings (server/voice.mjs). */
|
|
12
|
+
const withLanguage = (to) => {
|
|
13
|
+
const lang = navigator.languages?.[0] || navigator.language || '';
|
|
14
|
+
return lang ? `${to}${to.includes('?') ? '&' : '?'}lang=${encodeURIComponent(lang)}` : to;
|
|
15
|
+
};
|
|
16
|
+
|
|
10
17
|
/* Opens the microphone; resolves with a function that closes it.
|
|
11
18
|
`on.phrase(text)`, `on.state(word)`: calibrating, listening, hearing,
|
|
12
19
|
transcribing; `on.error(message)`. `to`: where phrases go, if not the
|
|
@@ -25,7 +32,7 @@ async function listen(on, { to } = {}) {
|
|
|
25
32
|
onPhrase: async (blocks) => {
|
|
26
33
|
pending++; tell();
|
|
27
34
|
try {
|
|
28
|
-
const r = await fetch(to ?? `${api()}/voice
|
|
35
|
+
const r = await fetch(withLanguage(to ?? `${api()}/voice`), { method: 'POST', headers: { 'content-type': 'audio/wav' }, body: toWav(blocks) });
|
|
29
36
|
const j = await r.json().catch(() => ({}));
|
|
30
37
|
if (!r.ok) throw new Error(j.error || 'The phrase could not be transcribed.');
|
|
31
38
|
if (!closed && j.text) on.phrase(j.text);
|