clavarium 0.2.320-next.1 → 0.2.321-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/settingswords.mjs +6 -0
- package/web/app.js +174 -20
- package/web/index.html +25 -10
- package/web/kit.js +6 -4
- package/web/style.css +7 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.321-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.321-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/settingswords.mjs
CHANGED
|
@@ -37,5 +37,11 @@ export const SETTINGS_WORDS_FR = {
|
|
|
37
37
|
'set-na-create': 'Créer', 'set-na-new-key': '+ Nouvelle clé…',
|
|
38
38
|
'set-na-k-folder': 'Dossier', 'set-na-k-git': 'Dépôt git', 'set-na-k-mailbox': 'Boîte mail', 'set-na-k-agenda': 'Agenda',
|
|
39
39
|
'set-na-k-contacts': 'Contacts', 'set-na-k-secret': 'Secret', 'set-na-k-list': 'Classeur',
|
|
40
|
+
/* Step 4: a voice box and a device, two more kinds of the same box. */
|
|
41
|
+
'set-na-k-box': 'Boîtier vocal', 'set-na-k-device': 'Appareil', 'set-na-plus-box': '+ Boîtier vocal', 'set-na-next': 'Suivant',
|
|
42
|
+
'set-na-step-where': 'Où', 'set-na-step-plug': 'Le brancher', 'set-na-step-pair': 'L\'appairer', 'set-na-step-answers': 'Il répond',
|
|
43
|
+
'set-na-speaks': 'Parlera dans {name}', 'set-na-room': 'salon', 'set-na-box-plug': 'Branchez-le sur le secteur.',
|
|
44
|
+
'set-na-box-flash': 'Non flashé : sa conversation le flashe (Tether).', 'set-na-box-waiting': 'En attente de sa réponse…',
|
|
45
|
+
'set-na-box-made': '{name} répond dans {where}',
|
|
40
46
|
};
|
|
41
47
|
export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
|
package/web/app.js
CHANGED
|
@@ -3688,9 +3688,9 @@
|
|
|
3688
3688
|
const made = justMade?.to === current ? justMade : null;
|
|
3689
3689
|
const kind = made ? '' : attachNew.kind;
|
|
3690
3690
|
/* At its ending, one Done: the box's own. */
|
|
3691
|
-
$('attach-close').hidden = Boolean(made);
|
|
3692
|
-
/* A secret is used or not: no level to choose. */
|
|
3693
|
-
const level = kind &&
|
|
3691
|
+
$('attach-close').hidden = Boolean(made) || (kind === 'box' && Boolean(boxFlow?.made));
|
|
3692
|
+
/* A secret is used or not, a voice box speaks there: no level to choose. */
|
|
3693
|
+
const level = kind && !['secret', 'box'].includes(kind) ? { options: [{ value: 'read', label: uiSaid('set-na-read', 'Read') }, { value: 'write', label: uiSaid('set-na-write', 'Write') }], value: attachNew.level, label: uiSaid('set-na-level', 'What it may do'), onChange: (v) => { attachNew.level = v; } } : null;
|
|
3694
3694
|
box.replaceChildren(newAssetBox({
|
|
3695
3695
|
kind, existing: $('attach-there'), title: '',
|
|
3696
3696
|
context: made ? null : { line: uiSaid('set-na-will', 'Will be attached to {name}', { name: who }), level },
|
|
@@ -3703,6 +3703,7 @@
|
|
|
3703
3703
|
onBack: () => { attachNew.kind = ''; $('attach-error').hidden = true; paintAttach(); },
|
|
3704
3704
|
onAnother: () => { attachNew.kind = made.kind; justMade = null; paintAttach(); focusFirst(box); },
|
|
3705
3705
|
onDone: () => { closeAttach(); },
|
|
3706
|
+
boxHost: { where: current, repaint: () => paintAttach(), close: () => closeAttach() },
|
|
3706
3707
|
}));
|
|
3707
3708
|
}
|
|
3708
3709
|
$('attach-open').addEventListener('click', () => { openChapter('access'); $('attach-picker').hidden = false; openAttach(); $('attach-picker').scrollIntoView({ block: 'nearest' }); });
|
|
@@ -3763,7 +3764,7 @@
|
|
|
3763
3764
|
line.append(summary, el('pre', '', rest));
|
|
3764
3765
|
return line;
|
|
3765
3766
|
}
|
|
3766
|
-
const kindIcon = (kind) => { const name = kind === 'send' || kind === 'demandes' ? '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; };
|
|
3767
|
+
const kindIcon = (kind) => { const name = kind === 'send' || kind === 'demandes' ? 'arrow-up' : kind === 'box' ? 'mic' : kind === 'device' ? 'smartphone' : 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; };
|
|
3767
3768
|
/* A list (Binder's): the set has no such sign, so it is drawn here, in its style. */
|
|
3768
3769
|
function listIcon() {
|
|
3769
3770
|
const SVG = 'http://www.w3.org/2000/svg';
|
|
@@ -4923,7 +4924,7 @@
|
|
|
4923
4924
|
row.hidden = true;
|
|
4924
4925
|
const call = async (op, args) => { try { return { ok: true, data: await post(`${API}/tether/${op}`, args) }; } catch (error) { return { ok: false, text: error.message }; } };
|
|
4925
4926
|
/* A device that pairs (a voice box): a one-use code for the conversation that asked, made here. */
|
|
4926
|
-
const pair = async (room) => { const r = await
|
|
4927
|
+
const pair = async (room) => { const r = await pairCode({ conversation: String(job.agent).replace(/^conversation:/, ''), name: room }); return { url: location.origin, code: r.code }; };
|
|
4927
4928
|
try { const { runJob } = await import('/vendor/tether/jobs.js'); await runJob(job, { call, root: place, pair }); }
|
|
4928
4929
|
catch (error) { place.textContent = `It could not start: ${error.message}`; }
|
|
4929
4930
|
setTimeout(() => { jobPlaces.delete(job.id); after?.(); }, 4000);
|
|
@@ -4973,15 +4974,36 @@
|
|
|
4973
4974
|
kind, the map's "+"), a conversation's Attach: the same kinds, the same forms (#assets-forms, moved in
|
|
4974
4975
|
when asked for), one ending. The words, once each. */
|
|
4975
4976
|
const newKinds = () => [['folder', uiSaid('set-na-k-folder', 'Folder')], ['git', uiSaid('set-na-k-git', 'Git repository')], ['mailbox', uiSaid('set-na-k-mailbox', 'Mailbox')],
|
|
4976
|
-
['agenda', uiSaid('set-na-k-agenda', 'Calendar')], ['contacts', uiSaid('set-na-k-contacts', 'Contacts')], ['secret', uiSaid('set-na-k-secret', 'Secret')], ['list', uiSaid('set-na-k-list', LISTS_WORD.one)]
|
|
4977
|
+
['agenda', uiSaid('set-na-k-agenda', 'Calendar')], ['contacts', uiSaid('set-na-k-contacts', 'Contacts')], ['secret', uiSaid('set-na-k-secret', 'Secret')], ['list', uiSaid('set-na-k-list', LISTS_WORD.one)],
|
|
4978
|
+
/* Step 4: a voice box (paired with a code) and a device (the share sheet, its code) are two kinds of it too. */
|
|
4979
|
+
['box', uiSaid('set-na-k-box', 'Voice box')], ['device', uiSaid('set-na-k-device', 'Device')]]
|
|
4977
4980
|
.map(([kind, label]) => ({ kind, label, icon: kindIcon(kind) }));
|
|
4981
|
+
/* A voice box's steps after its kind (the flow: "A NEW VOICE BOX", with the boxes), and the one under way. */
|
|
4982
|
+
const BOX_STEPS = ['where', 'plug', 'pair'];
|
|
4983
|
+
let boxFlow = null;
|
|
4984
|
+
/* `boxHost` { where, repaint, close }: the frame a voice box is added in -- where it speaks (preselected),
|
|
4985
|
+
how that frame draws itself again, and closes. A device is the share sheet itself, opened on `where`. */
|
|
4978
4986
|
function newAssetBox(opts) {
|
|
4987
|
+
const host = opts.boxHost ?? { where: '', repaint: () => {}, close: () => {} };
|
|
4988
|
+
const box = opts.kind === 'box' && !opts.made;
|
|
4989
|
+
const boxMade = box && boxFlow?.made ? boxFlow.made : null;
|
|
4990
|
+
const speaks = box && host.where ? { line: speaksLine(host.where) } : null;
|
|
4979
4991
|
return KIT.NewAsset({
|
|
4980
4992
|
kinds: newKinds(), ...opts,
|
|
4993
|
+
...(box ? { context: boxMade ? null : speaks, at: boxFlow ? 1 + BOX_STEPS.indexOf(boxFlow.step) : 1,
|
|
4994
|
+
made: boxMade ? { said: uiSaid('set-na-box-made', '{name} answers in {where}', { name: boxMade.name, where: whereName(boxMade.where) }) } : null,
|
|
4995
|
+
onAnother: () => { startBoxFlow(host); host.repaint(); }, onDone: () => { stopBoxWait(); boxFlow = null; host.close(); } } : {}),
|
|
4996
|
+
onKind: (k) => {
|
|
4997
|
+
if (k === 'device') { newDevice(host.where); return; }
|
|
4998
|
+
if (k === 'box') startBoxFlow(host);
|
|
4999
|
+
opts.onKind?.(k);
|
|
5000
|
+
},
|
|
4981
5001
|
words: { title: opts.title ?? uiSaid('set-na-new', 'New asset'), there: uiSaid('set-na-there', 'Already there'), orNew: uiSaid('set-na-or-new', 'or a new one'),
|
|
4982
|
-
steps: [uiSaid('set-na-step-kind', 'Kind'), uiSaid('set-na-step-set', '
|
|
5002
|
+
steps: box ? [uiSaid('set-na-step-kind', 'Kind'), uiSaid('set-na-step-where', 'Where'), uiSaid('set-na-step-plug', 'Plug it'), uiSaid('set-na-step-pair', 'Pair it'), uiSaid('set-na-step-answers', 'It answers')]
|
|
5003
|
+
: [uiSaid('set-na-step-kind', 'Kind'), uiSaid('set-na-step-set', 'Set up'), uiSaid('set-na-step-made', 'Created')],
|
|
4983
5004
|
back: uiSaid('set-na-back', 'Back'), another: uiSaid('set-na-another', 'Create another'), done: uiSaid('set-na-done', 'Done') },
|
|
4984
5005
|
form: (kind) => {
|
|
5006
|
+
if (kind === 'box') return paintBoxFlow();
|
|
4985
5007
|
const form = $(`${addForm(kind)}-box`); form.hidden = false;
|
|
4986
5008
|
if (kind === 'git') { fillKeyChoice(); showVia(); }
|
|
4987
5009
|
if (kind === 'list') void fillTemplates();
|
|
@@ -5090,7 +5112,7 @@
|
|
|
5090
5112
|
const out = assetsFromMap || assetsAdding === 'choose' ? el('button', 'as-link', '‹ Access') : el('button', 'as-link as-back', '‹ Assets'); out.type = 'button';
|
|
5091
5113
|
out.addEventListener('click', () => { if (!nav.close(assetsFromMap || assetsAdding === 'choose' ? 'compose' : 'asset')) back(); });
|
|
5092
5114
|
const kind = assetsAdding === 'choose' ? '' : assetsAdding;
|
|
5093
|
-
detail.append(out, newAssetBox({ kind, onKind: (k) => { assetsAdding = k; void paintAssets(); } }));
|
|
5115
|
+
detail.append(out, newAssetBox({ kind, onKind: (k) => { assetsAdding = k; void paintAssets(); }, boxHost: { where: '', repaint: () => { void paintAssets(); }, close: back } }));
|
|
5094
5116
|
if (kind) focusFirst(detail);
|
|
5095
5117
|
return;
|
|
5096
5118
|
}
|
|
@@ -5476,6 +5498,31 @@
|
|
|
5476
5498
|
}));
|
|
5477
5499
|
}
|
|
5478
5500
|
$('salon-new-search').addEventListener('input', paintSalonMembers);
|
|
5501
|
+
/* A ROOM'S "+ Voice box": the New asset box, its kind a voice box, speaking in this room; once it answers, it is
|
|
5502
|
+
among the room's boxes, switched on (kept with Save). */
|
|
5503
|
+
function paintSalonBoxNew() {
|
|
5504
|
+
const holder = $('salon-box-newasset');
|
|
5505
|
+
if (holder.contains($('box-add'))) $('assets-forms').append($('box-add'));
|
|
5506
|
+
holder.hidden = false;
|
|
5507
|
+
holder.replaceChildren(newAssetBox({ kind: 'box', boxHost: boxFlow.host }));
|
|
5508
|
+
}
|
|
5509
|
+
function closeSalonBoxNew() { const holder = $('salon-box-newasset'); if (holder.contains($('box-add'))) $('assets-forms').append($('box-add')); holder.replaceChildren(); holder.hidden = true; }
|
|
5510
|
+
$('salon-new-box-add').addEventListener('click', () => {
|
|
5511
|
+
if (!salonEditing) return;
|
|
5512
|
+
if (!$('salon-box-newasset').hidden) { stopBoxWait(); boxFlow = null; closeSalonBoxNew(); return; }
|
|
5513
|
+
startBoxFlow({ where: `room:${salonEditing.id}`, close: closeSalonBoxNew, repaint: () => {
|
|
5514
|
+
paintSalonBoxNew();
|
|
5515
|
+
if (!boxFlow?.made) return;
|
|
5516
|
+
void getJson('/boxes', null).then((list) => {
|
|
5517
|
+
if (!Array.isArray(list)) return;
|
|
5518
|
+
salonBoxList = list; boxesKnown = list;
|
|
5519
|
+
if (list.some((b) => b.id === boxFlow?.made?.id)) salonBoxes.add(boxFlow.made.id);
|
|
5520
|
+
paintSalonMembers();
|
|
5521
|
+
});
|
|
5522
|
+
} });
|
|
5523
|
+
paintSalonBoxNew();
|
|
5524
|
+
focusFirst($('salon-box-newasset'));
|
|
5525
|
+
});
|
|
5479
5526
|
let salonDragged = '';
|
|
5480
5527
|
$('salon-new-ais').addEventListener('dragstart', (e) => { salonDragged = e.target.closest?.('.salon-member-row')?.dataset.name ?? ''; });
|
|
5481
5528
|
$('salon-new-host').addEventListener('dragover', (e) => { e.preventDefault(); $('salon-new-host').classList.add('over'); });
|
|
@@ -5495,7 +5542,9 @@
|
|
|
5495
5542
|
salonBoxes = new Set(editing ? editing.members.filter((m) => m.kind === 'box').map((m) => m.ref) : []);
|
|
5496
5543
|
try { const x = await fetch(`${API}/boxes`); salonBoxList = x.ok ? await x.json() : []; } catch { salonBoxList = []; }
|
|
5497
5544
|
if (Array.isArray(salonBoxList)) boxesKnown = salonBoxList; else salonBoxList = [];
|
|
5498
|
-
|
|
5545
|
+
/* A room that is there already adds a voice box of its own: "+ Voice box". */
|
|
5546
|
+
$('salon-new-boxes-card').hidden = $('salon-new-voice-head').hidden = salonBoxList.length === 0 && !editing;
|
|
5547
|
+
$('salon-new-box-add').hidden = !editing; closeSalonBoxNew();
|
|
5499
5548
|
paintSalonMembers();
|
|
5500
5549
|
$('salon-new-name').focus();
|
|
5501
5550
|
}
|
|
@@ -5537,7 +5586,13 @@
|
|
|
5537
5586
|
async function openFeature(what, s = {}) {
|
|
5538
5587
|
const chapter = String(s.chapter ?? '');
|
|
5539
5588
|
if (what === 'new' || (chapter === 'new' && what === 'settings')) { await openNew(); return; }
|
|
5540
|
-
if (what === 'boxes' || chapter === 'boxes') {
|
|
5589
|
+
if (what === 'boxes' || chapter === 'boxes') {
|
|
5590
|
+
await openAccessPage('devices');
|
|
5591
|
+
/* "Add a voice box": the New asset box, on its kind, where the boxes are. */
|
|
5592
|
+
if (s.id === 'boxes:add') openBoxNew();
|
|
5593
|
+
$('boxes')?.scrollIntoView({ block: 'start' });
|
|
5594
|
+
return;
|
|
5595
|
+
}
|
|
5541
5596
|
if (what === 'mail' || chapter === 'access') { await openAssetsPlace(); return; }
|
|
5542
5597
|
if (what === 'import') { await openAccessPage('map', { mode: 'flows' }); document.getElementById('flows-import')?.click(); return; }
|
|
5543
5598
|
if (what === 'opencode') {
|
|
@@ -5740,7 +5795,7 @@
|
|
|
5740
5795
|
/* What those sheets share with the rest of the page: the requests, the
|
|
5741
5796
|
automatic sending form of Access, the share sheet for a device to pair. */
|
|
5742
5797
|
const links = DEVICE ? undefined : window.clavariumLinks?.({
|
|
5743
|
-
API: () => API, refresh, focusTerminal, openAssets: () => { void openAssets(); }, newDevice: () =>
|
|
5798
|
+
API: () => API, refresh, focusTerminal, openAssets: () => { void openAssets(); }, newDevice: () => newDevice(''), newConversation: () => createFromMap(),
|
|
5744
5799
|
newAsset: () => newAssetFromMap(),
|
|
5745
5800
|
autoSending: (conversation, name) => autoSending(conversation, name),
|
|
5746
5801
|
partsFor: (name) => partsFor(name),
|
|
@@ -6122,7 +6177,7 @@
|
|
|
6122
6177
|
$('nav-conversations').addEventListener('click', () => { leavePlace({ list: true }); });
|
|
6123
6178
|
$('nav-access').addEventListener('click', () => { if (place !== 'access' || accessTab !== 'map' || mapMode !== 'map') void openAccessPage('map', { mode: 'map' }); });
|
|
6124
6179
|
$('nav-assets').addEventListener('click', () => { if (place !== 'assets') void openAssetsPlace(); });
|
|
6125
|
-
$('map-new-device').addEventListener('click', () =>
|
|
6180
|
+
$('map-new-device').addEventListener('click', () => newDevice(accessFor));
|
|
6126
6181
|
/* Every device and what each was given, by device or by thing: a step over the map. */
|
|
6127
6182
|
$('map-all-devices').addEventListener('click', () => { void openAccessPage('devices'); });
|
|
6128
6183
|
/* Voice boxes are on the page of all devices: opened there, at them. */
|
|
@@ -10252,15 +10307,88 @@
|
|
|
10252
10307
|
rows.append(card);
|
|
10253
10308
|
}
|
|
10254
10309
|
}
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10310
|
+
/* A NEW VOICE BOX: a kind of New asset (05-11, step 4), the same flow wherever it is asked for -- Assets, a
|
|
10311
|
+
conversation's Attach, "+ Voice box" here and in a room, Features. Where it speaks (preselected from where it
|
|
10312
|
+
was asked), plug it (a flash its conversation asked for waits here), pair it (the code, link and QR of before),
|
|
10313
|
+
it answers (it shows among the boxes). The box itself is paired as it always was: one pairCode() for all. */
|
|
10314
|
+
$('assets-forms').append($('box-add'));
|
|
10315
|
+
/* Where it speaks, said: a conversation's name, or "room <name>". */
|
|
10316
|
+
function whereName(where) {
|
|
10317
|
+
const w = String(where ?? '');
|
|
10318
|
+
if (w.startsWith('room:')) return `${uiSaid('set-na-room', 'room')} ${rooms.find((r) => `room:${r.id}` === w)?.name ?? '?'}`;
|
|
10319
|
+
return shownName(conversations.find((c) => c.name === w)) || w;
|
|
10320
|
+
}
|
|
10321
|
+
const speaksLine = (where) => uiSaid('set-na-speaks', 'Will speak in {name}', { name: whereName(where) });
|
|
10322
|
+
function stopBoxWait() { if (boxFlow?.timer) { clearTimeout(boxFlow.timer); boxFlow.timer = null; } }
|
|
10323
|
+
function startBoxFlow(host) {
|
|
10324
|
+
stopBoxWait();
|
|
10325
|
+
boxFlow = { host, where: host.where ?? '', step: 'where', made: null, known: null, timer: null, until: 0 };
|
|
10326
|
+
$('box-room').value = ''; $('box-ready').hidden = true; $('box-error').hidden = true; $('box-waiting').textContent = '';
|
|
10327
|
+
if (!rooms.length) void loadRooms().then(() => { if (boxFlow?.host === host && boxFlow.step === 'where') fillBoxWhere(); });
|
|
10328
|
+
}
|
|
10329
|
+
/* Which conversation it speaks in, or a room (#281): chosen on purpose, never a silent default. */
|
|
10330
|
+
function fillBoxWhere() {
|
|
10258
10331
|
const pick = $('box-conversation'); pick.replaceChildren();
|
|
10259
10332
|
const none = el('option', '', 'Choose a conversation...'); none.value = ''; pick.append(none);
|
|
10260
10333
|
for (const c of conversations) { const o = el('option', '', shownName(c)); o.value = c.name; pick.append(o); }
|
|
10261
|
-
|
|
10262
|
-
|
|
10334
|
+
if (rooms.length) { const g = document.createElement('optgroup'); g.label = 'Rooms'; for (const r of rooms) { const o = el('option', '', r.name); o.value = `room:${r.id}`; g.append(o); } pick.append(g); }
|
|
10335
|
+
pick.value = [...pick.options].some((o) => o.value === boxFlow?.where) ? boxFlow.where : '';
|
|
10336
|
+
}
|
|
10337
|
+
/* The form at its step, for the box that shows it (newAssetBox). */
|
|
10338
|
+
function paintBoxFlow() {
|
|
10339
|
+
if (!boxFlow) startBoxFlow({ where: '', repaint: () => {}, close: () => {} });
|
|
10340
|
+
const form = $('box-add'); form.hidden = false;
|
|
10341
|
+
for (const part of form.querySelectorAll('.box-step')) part.hidden = part.dataset.step !== boxFlow.step;
|
|
10342
|
+
if (boxFlow.step === 'where') fillBoxWhere();
|
|
10343
|
+
if (boxFlow.step === 'plug') void paintBoxJobs();
|
|
10344
|
+
$('box-back').hidden = boxFlow.step === 'where';
|
|
10345
|
+
$('box-next').hidden = boxFlow.step === 'pair';
|
|
10346
|
+
return form;
|
|
10347
|
+
}
|
|
10348
|
+
/* A flash its conversation asked for (Tether, device-flash): its card, as in the thread -- started here. */
|
|
10349
|
+
async function paintBoxJobs() {
|
|
10350
|
+
const tether = await getJson('/tether', {});
|
|
10351
|
+
const jobs = Array.isArray(tether.jobs) ? tether.jobs : [];
|
|
10352
|
+
if (boxFlow?.step !== 'plug') return;
|
|
10353
|
+
$('box-jobs').replaceChildren(...jobs.map((j) => jobCard(j, () => { if (boxFlow?.step === 'plug') void paintBoxJobs(); })));
|
|
10354
|
+
}
|
|
10355
|
+
const boxGo = (step) => { if (!boxFlow) return; boxFlow.step = step; $('box-error').hidden = true; boxFlow.host.repaint(); };
|
|
10356
|
+
$('box-next').addEventListener('click', () => {
|
|
10357
|
+
if (!boxFlow) return;
|
|
10358
|
+
if (boxFlow.step === 'where' && !$('box-conversation').value) { $('box-error').textContent = 'Choose the conversation it speaks in first.'; $('box-error').hidden = false; $('box-conversation').focus(); return; }
|
|
10359
|
+
boxGo(BOX_STEPS[BOX_STEPS.indexOf(boxFlow.step) + 1] ?? boxFlow.step);
|
|
10263
10360
|
});
|
|
10361
|
+
$('box-back').addEventListener('click', () => { if (boxFlow) { stopBoxWait(); boxGo(BOX_STEPS[Math.max(0, BOX_STEPS.indexOf(boxFlow.step) - 1)]); } });
|
|
10362
|
+
$('box-conversation').addEventListener('change', () => {
|
|
10363
|
+
if (!boxFlow) return;
|
|
10364
|
+
boxFlow.where = $('box-conversation').value;
|
|
10365
|
+
const line = $('box-add').closest('.kit-newasset')?.querySelector('.kit-na-context > span');
|
|
10366
|
+
if (line && boxFlow.where) line.textContent = speaksLine(boxFlow.where);
|
|
10367
|
+
});
|
|
10368
|
+
/* ONE PAIRING CODE for a voice box (boxes.mjs), whoever asks: this flow, a flash run from the thread. With
|
|
10369
|
+
`origin` (this page's address), the server adds the setup key, its link and QR code. */
|
|
10370
|
+
function pairCode({ conversation, name, origin = '' }) {
|
|
10371
|
+
return post(`${API}/boxes/code`, { conversation, name, ...(origin ? { origin } : {}), zone: Intl.DateTimeFormat().resolvedOptions().timeZone });
|
|
10372
|
+
}
|
|
10373
|
+
/* It answers: paired, it shows among the boxes -- read again until it does, while the code holds. */
|
|
10374
|
+
function waitBoxPaired() {
|
|
10375
|
+
stopBoxWait();
|
|
10376
|
+
const flow = boxFlow;
|
|
10377
|
+
const look = async () => {
|
|
10378
|
+
if (boxFlow !== flow || flow.made || $('assets-forms').contains($('box-add')) || Date.now() > flow.until) return;
|
|
10379
|
+
const list = await getJson('/boxes', null);
|
|
10380
|
+
const fresh = Array.isArray(list) && flow.known ? list.find((b) => !flow.known.has(b.id)) : null;
|
|
10381
|
+
if (boxFlow !== flow) return;
|
|
10382
|
+
if (fresh) {
|
|
10383
|
+
flow.made = { id: fresh.id, name: fresh.name, where: fresh.conversation };
|
|
10384
|
+
flow.host.repaint();
|
|
10385
|
+
if (!$('boxes').closest('[hidden]')) void paintBoxes();
|
|
10386
|
+
return;
|
|
10387
|
+
}
|
|
10388
|
+
flow.timer = setTimeout(() => { void look(); }, 3000);
|
|
10389
|
+
};
|
|
10390
|
+
flow.timer = setTimeout(() => { void look(); }, 3000);
|
|
10391
|
+
}
|
|
10264
10392
|
$('box-key-copy').addEventListener('click', async () => {
|
|
10265
10393
|
const key = $('box-key').textContent;
|
|
10266
10394
|
try { await navigator.clipboard.writeText(key); $('box-key-copy').textContent = 'Copied'; }
|
|
@@ -10268,16 +10396,36 @@
|
|
|
10268
10396
|
setTimeout(() => { $('box-key-copy').textContent = 'Copy the key'; }, 2000);
|
|
10269
10397
|
});
|
|
10270
10398
|
$('box-code').addEventListener('click', async () => {
|
|
10271
|
-
if (!$('box-conversation').value) {
|
|
10399
|
+
if (!$('box-conversation').value) { boxGo('where'); $('box-error').textContent = 'Choose the conversation it speaks in first.'; $('box-error').hidden = false; return; }
|
|
10272
10400
|
try {
|
|
10273
|
-
const
|
|
10401
|
+
const before = await getJson('/boxes', null);
|
|
10402
|
+
const r = await pairCode({ conversation: $('box-conversation').value, name: $('box-room').value.trim(), origin: location.origin });
|
|
10274
10403
|
$('box-code-shown').textContent = r.code; $('box-code-minutes').textContent = `valid ${r.minutes} minutes, once`;
|
|
10275
10404
|
$('box-key').textContent = r.key ?? '';
|
|
10276
10405
|
$('box-link').href = r.link ?? '#';
|
|
10277
10406
|
$('box-qr').innerHTML = r.qr ?? '';
|
|
10278
10407
|
$('box-ready').hidden = false;
|
|
10408
|
+
if (boxFlow && Array.isArray(before)) {
|
|
10409
|
+
boxFlow.known = new Set(before.map((b) => b.id)); boxFlow.until = Date.now() + Number(r.minutes || 10) * 60_000;
|
|
10410
|
+
$('box-waiting').textContent = uiSaid('set-na-box-waiting', 'Waiting for it to answer…');
|
|
10411
|
+
waitBoxPaired();
|
|
10412
|
+
}
|
|
10279
10413
|
} catch (error) { $('box-code-minutes').textContent = error.message; $('box-ready').hidden = false; }
|
|
10280
10414
|
});
|
|
10415
|
+
/* "+ Voice box" of Access › Boxes: the New asset box, right here, on its kind; on the conversation Access is for. */
|
|
10416
|
+
function paintBoxNew() {
|
|
10417
|
+
const holder = $('box-newasset');
|
|
10418
|
+
if (holder.contains($('box-add'))) $('assets-forms').append($('box-add'));
|
|
10419
|
+
holder.hidden = false;
|
|
10420
|
+
holder.replaceChildren(newAssetBox({ kind: 'box', boxHost: boxFlow.host }));
|
|
10421
|
+
}
|
|
10422
|
+
function closeBoxNew() { const holder = $('box-newasset'); if (holder.contains($('box-add'))) $('assets-forms').append($('box-add')); holder.replaceChildren(); holder.hidden = true; }
|
|
10423
|
+
function openBoxNew() {
|
|
10424
|
+
startBoxFlow({ where: accessFor && conversations.some((c) => c.name === accessFor) ? accessFor : '', repaint: paintBoxNew, close: closeBoxNew });
|
|
10425
|
+
paintBoxNew();
|
|
10426
|
+
focusFirst($('box-newasset'));
|
|
10427
|
+
}
|
|
10428
|
+
$('box-new').addEventListener('click', () => { if (!$('box-newasset').hidden) { stopBoxWait(); boxFlow = null; closeBoxNew(); } else openBoxNew(); });
|
|
10281
10429
|
async function paintManage() {
|
|
10282
10430
|
await readDevices();
|
|
10283
10431
|
void paintBoxes();
|
|
@@ -10326,8 +10474,14 @@
|
|
|
10326
10474
|
async function openManage() { await openAccessPage('devices'); }
|
|
10327
10475
|
$('share-by-device').addEventListener('click', () => { manageBy = 'device'; void paintManage(); });
|
|
10328
10476
|
$('share-by-thing').addEventListener('click', () => { manageBy = 'thing'; void paintManage(); });
|
|
10477
|
+
/* A NEW DEVICE: a kind of New asset (05-11, step 4) -- the share sheet, the same for every way in (the Device
|
|
10478
|
+
kind of the box, the map's "+", "+ New device" here and on the map). On a conversation (`of`), it is offered it. */
|
|
10479
|
+
function newDevice(of = '') {
|
|
10480
|
+
const c = String(of ?? '');
|
|
10481
|
+
void openCompose(c && !c.startsWith('room:') ? [[`conversation:${c}`, partsFor(c)]] : []);
|
|
10482
|
+
}
|
|
10329
10483
|
/* Filtered on a conversation, a new device is offered that conversation. */
|
|
10330
|
-
$('share-new-device').addEventListener('click', () =>
|
|
10484
|
+
$('share-new-device').addEventListener('click', () => newDevice(accessFor));
|
|
10331
10485
|
/* From a conversation: that conversation, and nothing else, is in the basket. */
|
|
10332
10486
|
$('share').addEventListener('click', () => { void openCompose([[`conversation:${current}`, partsFor(current)]]); });
|
|
10333
10487
|
/* The Sharing chapter of a conversation: who has it, and which parts -- changed there, at once. */
|
package/web/index.html
CHANGED
|
@@ -666,18 +666,32 @@
|
|
|
666
666
|
<!-- Voice boxes: a speaker in a room, bound to one conversation (boxes.mjs). -->
|
|
667
667
|
<section id="boxes" aria-label="Voice boxes">
|
|
668
668
|
<div class="row"><b>Voice boxes</b><span class="sp"></span><button type="button" id="box-new" class="primary">+ Voice box</button></div>
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
669
|
+
<!-- "+ Voice box": the New asset box (kit.js NewAsset), its kind a voice box. -->
|
|
670
|
+
<div id="box-newasset" class="card" hidden></div>
|
|
671
|
+
<!-- THE VOICE BOX'S FORM, a kind of New asset (05-11, step 4): where it speaks, plug it, pair it. Moved
|
|
672
|
+
into the box that asks for it (Assets, a conversation's Attach, here, a room); waits in #assets-forms. -->
|
|
673
|
+
<div id="box-add" class="as-form box-flow" hidden>
|
|
674
|
+
<div class="box-step" data-step="where">
|
|
675
|
+
<label>Speaks in <select id="box-conversation"></select></label>
|
|
672
676
|
<label>Room <input id="box-room" maxlength="40" placeholder="Living room"></label>
|
|
673
|
-
<button type="button" id="box-code" class="primary">Get a code</button>
|
|
674
677
|
</div>
|
|
675
|
-
<div
|
|
676
|
-
<p class="hint"
|
|
677
|
-
<
|
|
678
|
-
<div
|
|
679
|
-
|
|
678
|
+
<div class="box-step" data-step="plug" hidden>
|
|
679
|
+
<p class="hint" data-said="set-na-box-plug">Plug it into power.</p>
|
|
680
|
+
<p class="hint" data-said="set-na-box-flash">Not flashed yet: its conversation flashes it (Tether).</p>
|
|
681
|
+
<div id="box-jobs"></div>
|
|
682
|
+
</div>
|
|
683
|
+
<div class="box-step" data-step="pair" hidden>
|
|
684
|
+
<div class="row"><button type="button" id="box-code" class="primary">Get a code</button></div>
|
|
685
|
+
<div id="box-ready" hidden>
|
|
686
|
+
<p class="hint">Phone on the box's Wi-Fi « Gambeli-… »: open this link, or scan the code. Its page opens filled in; choose your Wi-Fi. <span id="box-code-minutes"></span></p>
|
|
687
|
+
<div class="row box-setup"><div id="box-qr" class="box-qr"></div><a id="box-link" class="primary button-link" href="#">Open the box's page</a></div>
|
|
688
|
+
<div class="row"><code id="box-key" class="box-key"></code><button type="button" id="box-key-copy">Copy the key</button></div>
|
|
689
|
+
<p class="hint">Pairing code alone: <b id="box-code-shown"></b></p>
|
|
690
|
+
<p id="box-waiting" class="hint" role="status"></p>
|
|
691
|
+
</div>
|
|
680
692
|
</div>
|
|
693
|
+
<p id="box-error" class="error" role="alert" hidden></p>
|
|
694
|
+
<div class="row box-flow-acts"><button type="button" id="box-back" data-said="set-na-back">Back</button><button type="button" id="box-next" class="primary" data-said="set-na-next">Next</button></div>
|
|
681
695
|
</div>
|
|
682
696
|
<div id="box-list"></div>
|
|
683
697
|
</section>
|
|
@@ -721,7 +735,8 @@
|
|
|
721
735
|
</div>
|
|
722
736
|
<h3 class="room-group" id="salon-new-voice-head" data-said="set-tab-chat">Chat & voice</h3>
|
|
723
737
|
<div class="nc-card" id="salon-new-boxes-card">
|
|
724
|
-
<span class="sub-head">Voice boxes</span>
|
|
738
|
+
<div class="row"><span class="sub-head">Voice boxes</span><span class="sp"></span><button type="button" id="salon-new-box-add" data-said="set-na-plus-box">+ Voice box</button></div>
|
|
739
|
+
<div id="salon-box-newasset" hidden></div>
|
|
725
740
|
<div id="salon-new-boxes" class="salon-member-list" role="list" aria-label="Voice boxes"></div>
|
|
726
741
|
</div>
|
|
727
742
|
<h3 class="room-group" id="salon-new-advanced-head" data-said="set-tab-advanced" hidden>Advanced</h3>
|
package/web/kit.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* StepFlow the steps of a gesture, the one at hand marked, "2 / 3"
|
|
14
14
|
* SecretPicker a key to choose, or "+ New key…" made in place
|
|
15
15
|
* NewAsset ONE BOX to make an asset (05-11, step 3): kinds, the kind's form, one ending;
|
|
16
|
-
* opened with a context (a conversation it will be attached to).
|
|
16
|
+
* opened with a context (a conversation it will be attached to). A voice box and
|
|
17
|
+
* a device are two of its kinds too (step 4).
|
|
17
18
|
*
|
|
18
19
|
* No framework: each piece is a function that returns an element. Words: English here; the page
|
|
19
20
|
* hands its own (`setWords`, app.js `uiSaid`) for the few the kit says by itself.
|
|
@@ -204,8 +205,9 @@
|
|
|
204
205
|
Segmented's options) and the page attaches what is made at the end. `existing`: what is there
|
|
205
206
|
already, offered above "or a new one". `made`: { said, note? } draws the ending.
|
|
206
207
|
kinds [{ kind, label, icon? }] kind '' : choose one words { title, there, orNew, steps[3], back, another, done }
|
|
207
|
-
`onBack`: a way back to the kinds from a form, where the frame has none of its own.
|
|
208
|
-
|
|
208
|
+
`onBack`: a way back to the kinds from a form, where the frame has none of its own.
|
|
209
|
+
`at`: the step at hand, for a kind of more steps than one (a voice box: where, plug it, pair it). */
|
|
210
|
+
function NewAsset({ kinds = [], kind = '', made = null, context = null, existing = null, form = () => null, words: w = {}, at = null, onKind = () => {}, onBack = null, onAnother = () => {}, onDone = () => {} } = {}) {
|
|
209
211
|
const root = node('div', 'kit-newasset');
|
|
210
212
|
root.dataset.step = made ? 'done' : kind ? 'form' : 'kind';
|
|
211
213
|
const steps = w.steps ?? [say('kit-step-kind', 'Kind'), say('kit-step-set', 'Set up'), say('kit-step-made', 'Created')];
|
|
@@ -218,7 +220,7 @@
|
|
|
218
220
|
const head = node('div', 'kit-na-head');
|
|
219
221
|
const title = w.title ?? say('kit-new-asset', 'New asset');
|
|
220
222
|
if (!kind && !made && title) head.append(node('h3', '', title));
|
|
221
|
-
head.append(StepFlow({ steps, at: made ? steps.length : kind ? 1 : 0 }));
|
|
223
|
+
head.append(StepFlow({ steps, at: made ? steps.length : kind ? (Number.isInteger(at) ? at : 1) : 0 }));
|
|
222
224
|
root.append(head);
|
|
223
225
|
if (made) {
|
|
224
226
|
const end = node('div', 'kit-na-made');
|
package/web/style.css
CHANGED
|
@@ -2155,6 +2155,13 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
|
|
|
2155
2155
|
.box-setup { align-items: center; gap: 14px; flex-wrap: wrap; }
|
|
2156
2156
|
.box-qr { width: 180px; max-width: 100%; background: #fff; border-radius: 8px; padding: 6px; }
|
|
2157
2157
|
.box-qr svg { display: block; width: 100%; height: auto; }
|
|
2158
|
+
/* A new voice box, a kind of New asset (step 4): its steps one at a time, Back / Next at the end. */
|
|
2159
|
+
.box-flow .box-step { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
|
|
2160
|
+
.box-flow .box-step label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
2161
|
+
.box-flow .box-step select, .box-flow .box-step input { max-width: 100%; }
|
|
2162
|
+
.box-flow .box-key { overflow-wrap: anywhere; min-width: 0; }
|
|
2163
|
+
.box-flow-acts { justify-content: flex-end; gap: 8px; }
|
|
2164
|
+
#box-newasset, #salon-box-newasset { margin: 8px 0; }
|
|
2158
2165
|
/* A link that looks like the main button (the charter): brass outline, no fill. */
|
|
2159
2166
|
.button-link { display: inline-block; padding: 8px 12px; border-radius: 8px; background: transparent; border: 1px solid var(--brass); color: var(--brass-ink); font-weight: 600; text-decoration: none; }
|
|
2160
2167
|
|