clavarium 0.2.319-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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.319-next.1",
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.319-next.1",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.319-next.1",
3
+ "version": "0.2.321-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -29,5 +29,19 @@ export const SETTINGS_WORDS_FR = {
29
29
  'set-device': '1 appareil', 'set-devices': '{n} appareils', 'set-no-device': 'Aucun appareil', 'set-chat': 'Chat',
30
30
  'set-wakeups-on': '{on} sur {n} actifs', 'set-asleep': 'Endormie', 'set-not-looked': 'Pas encore regardée',
31
31
  'set-running-well': 'En marche · rien d\'anormal', 'set-conv-advanced': 'Archiver · remettre à neuf · supprimer',
32
+ /* New asset, one box (05-11, step 3): one verb per gesture -- Créer, Attacher, Terminé. */
33
+ 'set-na-new': 'Nouvel asset', 'set-na-attach': 'Attacher', 'set-na-there': 'Déjà là', 'set-na-or-new': 'ou un nouveau',
34
+ 'set-na-step-kind': 'Type', 'set-na-step-set': 'Réglage', 'set-na-step-made': 'Créé', 'set-na-back': 'Retour',
35
+ 'set-na-will': 'Sera relié à {name}', 'set-na-level': 'Ce qu\'il pourra faire', 'set-na-read': 'Lecture', 'set-na-write': 'Écriture',
36
+ 'set-na-made': '{name} créé', 'set-na-made-to': '{name} créé et relié à {to}', 'set-na-another': 'En créer un autre', 'set-na-done': 'Terminé',
37
+ 'set-na-create': 'Créer', 'set-na-new-key': '+ Nouvelle clé…',
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
+ '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}',
32
46
  };
33
47
  export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
package/web/app.js CHANGED
@@ -2309,7 +2309,6 @@
2309
2309
  paintConvStates(here);
2310
2310
  /* What can still be attached, for the picker. */
2311
2311
  const picker = $('attach-rows'); picker.replaceChildren();
2312
- $('attach-title').textContent = `Attach to "${current}"`;
2313
2312
  const offer = (name, kind, buttons) => {
2314
2313
  const row = document.createElement('div'); row.className = 'folder'; row.dataset.name = name;
2315
2314
  const label = document.createElement('b'); label.textContent = name;
@@ -3661,13 +3660,54 @@
3661
3660
  await refresh();
3662
3661
  await paintPanel();
3663
3662
  $('attach-picker').hidden = !picking;
3663
+ if (picking) openAttach();
3664
3664
  /* The folders button shows the folders: their chapter opened, in its tab. */
3665
3665
  openChapter('access', { show: !picking });
3666
3666
  if (picking) $('attach-picker').scrollIntoView({ block: 'nearest' });
3667
3667
  }
3668
3668
  $('folders').addEventListener('click', () => { void openAccess(false); });
3669
- $('attach-open').addEventListener('click', () => { openChapter('access'); $('attach-picker').hidden = false; $('attach-picker').scrollIntoView({ block: 'nearest' }); });
3670
- $('attach-close').addEventListener('click', () => { $('attach-picker').hidden = true; });
3669
+ /* ATTACH: ONE BUTTON (05-11). What is there already, to tick, or a new one -- the New asset box, with this
3670
+ conversation as its context: what is made there is attached to it at the end. */
3671
+ let attachNew = { kind: '', level: 'write' };
3672
+ function openAttach() {
3673
+ attachNew = { kind: '', level: 'write' };
3674
+ if (justMade?.to) justMade = null;
3675
+ $('attach-error').hidden = true;
3676
+ paintAttach();
3677
+ }
3678
+ function closeAttach() {
3679
+ $('attach-picker').hidden = true; $('attach-close').hidden = false;
3680
+ attachNew.kind = ''; if (justMade?.to) justMade = null;
3681
+ for (const f of $('attach-box').querySelectorAll('.as-form')) $('assets-forms').append(f);
3682
+ }
3683
+ function paintAttach() {
3684
+ const box = $('attach-box');
3685
+ for (const f of box.querySelectorAll('.as-form')) $('assets-forms').append(f);
3686
+ $('attach-park').append($('attach-there'));
3687
+ const who = shownName(conversations.find((c) => c.name === current)) || current;
3688
+ const made = justMade?.to === current ? justMade : null;
3689
+ const kind = made ? '' : attachNew.kind;
3690
+ /* At its ending, one Done: the box's own. */
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
+ box.replaceChildren(newAssetBox({
3695
+ kind, existing: $('attach-there'), title: '',
3696
+ context: made ? null : { line: uiSaid('set-na-will', 'Will be attached to {name}', { name: who }), level },
3697
+ made: made ? { said: uiSaid('set-na-made-to', '{name} created and attached to {to}', { name: made.name, to: who }), note: made.note } : null,
3698
+ onKind: (k) => {
3699
+ attachNew.kind = k; justMade = null; $('attach-error').hidden = true; paintAttach(); focusFirst(box);
3700
+ /* Its keys, read here too: Assets may not have been opened yet. */
3701
+ if (k === 'git') void getJson('/git-keys', []).then((keys) => paintKeys(keys));
3702
+ },
3703
+ onBack: () => { attachNew.kind = ''; $('attach-error').hidden = true; paintAttach(); },
3704
+ onAnother: () => { attachNew.kind = made.kind; justMade = null; paintAttach(); focusFirst(box); },
3705
+ onDone: () => { closeAttach(); },
3706
+ boxHost: { where: current, repaint: () => paintAttach(), close: () => closeAttach() },
3707
+ }));
3708
+ }
3709
+ $('attach-open').addEventListener('click', () => { openChapter('access'); $('attach-picker').hidden = false; openAttach(); $('attach-picker').scrollIntoView({ block: 'nearest' }); });
3710
+ $('attach-close').addEventListener('click', () => { closeAttach(); });
3671
3711
  $('attach-manage').addEventListener('click', () => { void openAssets(); });
3672
3712
 
3673
3713
  /* ---------- ASSETS: one design, two pages (G and H) ----------
@@ -3724,7 +3764,7 @@
3724
3764
  line.append(summary, el('pre', '', rest));
3725
3765
  return line;
3726
3766
  }
3727
- 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; };
3728
3768
  /* A list (Binder's): the set has no such sign, so it is drawn here, in its style. */
3729
3769
  function listIcon() {
3730
3770
  const SVG = 'http://www.w3.org/2000/svg';
@@ -4555,7 +4595,7 @@
4555
4595
  const as = $('cassets-as');
4556
4596
  as.dataset.open = chosen ? 'detail' : 'list';
4557
4597
  paintAsList($('cassets-rows'), items, { chosen: chosen?.key, choose: (key) => pickRoomAsset(key), empty: 'Nothing is given to it yet.' });
4558
- const top = el('div', 'as-kind-head as-list-top'); top.append(el('h3', '', 'This conversation'), roundPlus('Attach an asset', () => { void openAccess(true); }));
4598
+ const top = el('div', 'as-kind-head as-list-top'); top.append(el('h3', '', 'This conversation'), roundPlus(uiSaid('set-na-attach', 'Attach'), () => { void openAccess(true); }));
4559
4599
  const pinnedRow = (entry, extra) => {
4560
4600
  const row = el('button', `as-row ts-entry${extra ? ` ${extra}` : ''}`); row.type = 'button'; row.dataset.asset = entry.key;
4561
4601
  if (chosen === entry) row.setAttribute('aria-current', 'true');
@@ -4884,7 +4924,7 @@
4884
4924
  row.hidden = true;
4885
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 }; } };
4886
4926
  /* A device that pairs (a voice box): a one-use code for the conversation that asked, made here. */
4887
- const pair = async (room) => { const r = await post(`${API}/boxes/code`, { conversation: String(job.agent).replace(/^conversation:/, ''), name: room, zone: Intl.DateTimeFormat().resolvedOptions().timeZone }); return { url: location.origin, code: r.code }; };
4927
+ const pair = async (room) => { const r = await pairCode({ conversation: String(job.agent).replace(/^conversation:/, ''), name: room }); return { url: location.origin, code: r.code }; };
4888
4928
  try { const { runJob } = await import('/vendor/tether/jobs.js'); await runJob(job, { call, root: place, pair }); }
4889
4929
  catch (error) { place.textContent = `It could not start: ${error.message}`; }
4890
4930
  setTimeout(() => { jobPlaces.delete(job.id); after?.(); }, 4000);
@@ -4930,6 +4970,76 @@
4930
4970
  if (!names.ok || pick.options.length) return;
4931
4971
  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); }
4932
4972
  }
4973
+ /* NEW ASSET (05-11, step 3): ONE BOX (kit.js NewAsset) wherever an asset is made -- Assets (the "+" of a
4974
+ kind, the map's "+"), a conversation's Attach: the same kinds, the same forms (#assets-forms, moved in
4975
+ when asked for), one ending. The words, once each. */
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')],
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')]]
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`. */
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;
4991
+ return KIT.NewAsset({
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
+ },
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'),
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')],
5004
+ back: uiSaid('set-na-back', 'Back'), another: uiSaid('set-na-another', 'Create another'), done: uiSaid('set-na-done', 'Done') },
5005
+ form: (kind) => {
5006
+ if (kind === 'box') return paintBoxFlow();
5007
+ const form = $(`${addForm(kind)}-box`); form.hidden = false;
5008
+ if (kind === 'git') { fillKeyChoice(); showVia(); }
5009
+ if (kind === 'list') void fillTemplates();
5010
+ return form;
5011
+ },
5012
+ });
5013
+ }
5014
+ /* The first field of the form shown in `holder`, focused. */
5015
+ const focusFirst = (holder) => { const f = holder.querySelector('.as-form input:not([type=radio])'); if (f) focusField(f); };
5016
+ /* What was just made: the box's ending ("✓ <name> created"), until Done. `to`: the conversation it was attached to. */
5017
+ let justMade = null;
5018
+ /* A form is in the conversation's Attach (its context), or in Assets. */
5019
+ const inAttach = (form) => $('attach-box').contains(form);
5020
+ const newAssetError = (form, message) => { const e = inAttach(form) ? $('attach-error') : $('assets-error'); e.textContent = message; e.hidden = false; };
5021
+ /* THE ONE ENDING. `give(conversation, level)` attaches it, when the box was opened from a conversation; in
5022
+ Assets it is opened, the ending above it. */
5023
+ async function assetMade(form, { key, name, give = null, note = '' }) {
5024
+ if (inAttach(form) && current) {
5025
+ const kind = attachNew.kind;
5026
+ if (give) await give(current, attachNew.level);
5027
+ justMade = { kind, key, name, note, to: current };
5028
+ attachNew.kind = '';
5029
+ await paintPanel();
5030
+ paintAttach();
5031
+ return;
5032
+ }
5033
+ justMade = { kind: assetsAdding, key, name, note };
5034
+ assetOpen = key; assetsAdding = '';
5035
+ }
5036
+ /* Another kind asked from inside a form (New mailbox's Google, Microsoft: the account's form). */
5037
+ async function newAssetKind(form, kind) {
5038
+ if (inAttach(form)) { attachNew.kind = kind; paintAttach(); return; }
5039
+ assetsAdding = kind; await paintAssets();
5040
+ }
5041
+ /* A Tether target given from Attach: Read watches, Write proposes (asks before each action). */
5042
+ const targetLevel = (level) => (level === 'write' ? 'propose' : 'watch');
4933
5043
  async function paintAssets() {
4934
5044
  if (place !== 'assets' || DEVICE) return;
4935
5045
  watchTether();
@@ -4965,6 +5075,7 @@
4965
5075
  }
4966
5076
  const shown = assetsQuery ? items.filter((i) => i.name.includes(assetsQuery.toLowerCase()) || i.name.toLowerCase().includes(assetsQuery.toLowerCase())) : items;
4967
5077
  const chosen = assetsAdding ? null : items.find((i) => i.key === assetOpen) ?? null;
5078
+ if (justMade && !justMade.to && justMade.key !== chosen?.key) justMade = null;
4968
5079
  /* A group can be the open thing too (its own detail: give it, rename it). */
4969
5080
  const chosenGroup = !assetsAdding && !chosen && assetOpen.startsWith('group:') ? assetGroups.find((g) => `group:${g.id}` === assetOpen) ?? null : null;
4970
5081
  /* Every call waiting for the owner, across all the connexions, gathered in one place
@@ -4995,35 +5106,14 @@
4995
5106
  for (const form of detail.querySelectorAll('.as-form, #gitview-remote-box')) $('assets-forms').append(form);
4996
5107
  detail.replaceChildren();
4997
5108
  const back = () => { assetOpen = ''; assetsAdding = ''; remember(); void paintAssets(); };
4998
- if (assetsAdding === 'choose' || (assetsAdding && assetsFromMap)) {
4999
- /* From the map's "+" of Assets: which kind, then its form; "<" goes back to the map. */
5000
- const out = el('button', 'as-link', '‹ Access'); out.type = 'button'; out.addEventListener('click', () => { if (!nav.close('compose')) back(); });
5001
- detail.append(out);
5002
- if (assetsAdding === 'choose') {
5003
- detail.append(el('h3', '', 'New asset'));
5004
- const kinds = el('div', 'as-kinds');
5005
- for (const [kind, word] of [['git', 'Git repository'], ['folder', 'Folder'], ['mailbox', 'Mailbox'], ['agenda', 'Calendar'], ['contacts', 'Address book'], ['secret', 'Secret'], ['list', LISTS_WORD.one]]) {
5006
- const b = el('button', '', word); b.type = 'button'; b.dataset.kind = kind;
5007
- b.addEventListener('click', () => { assetsAdding = kind; void paintAssets(); });
5008
- b.prepend(kindIcon(kind)); kinds.append(b);
5009
- }
5010
- detail.append(kinds);
5011
- return;
5012
- }
5013
- const form = $(`${addForm(assetsAdding)}-box`); form.hidden = false;
5014
- detail.append(form);
5015
- if (assetsAdding === 'git') { fillKeyChoice(); showVia(); }
5016
- if (assetsAdding === 'list') void fillTemplates();
5017
- focusField(form.querySelector('input:not([type=radio])'));
5018
- return;
5019
- }
5020
5109
  if (assetsAdding) {
5021
- const all2 = el('button', 'as-link as-back', '‹ Assets'); all2.type = 'button'; all2.addEventListener('click', () => { if (!nav.close('asset')) back(); });
5022
- const form = $(`${addForm(assetsAdding)}-box`); form.hidden = false;
5023
- detail.append(all2, form);
5024
- if (assetsAdding === 'git') { fillKeyChoice(); showVia(); }
5025
- if (assetsAdding === 'list') void fillTemplates();
5026
- focusField(form.querySelector('input:not([type=radio])'));
5110
+ /* The New asset box: from the map's "+" of Assets, which kind first ("<" goes back to the map);
5111
+ from the "+" of a kind, its form ("<" Assets). */
5112
+ const out = assetsFromMap || assetsAdding === 'choose' ? el('button', 'as-link', '‹ Access') : el('button', 'as-link as-back', '‹ Assets'); out.type = 'button';
5113
+ out.addEventListener('click', () => { if (!nav.close(assetsFromMap || assetsAdding === 'choose' ? 'compose' : 'asset')) back(); });
5114
+ const kind = assetsAdding === 'choose' ? '' : assetsAdding;
5115
+ detail.append(out, newAssetBox({ kind, onKind: (k) => { assetsAdding = k; void paintAssets(); }, boxHost: { where: '', repaint: () => { void paintAssets(); }, close: back } }));
5116
+ if (kind) focusFirst(detail);
5027
5117
  return;
5028
5118
  }
5029
5119
  if (chosenGroup) { groupDetail(detail, chosenGroup, items, back); return; }
@@ -5035,6 +5125,13 @@
5035
5125
  return;
5036
5126
  }
5037
5127
  if (!chosen) { if (items.length) detail.append(noAssetChosen()); return; }
5128
+ /* Just made here: the box's ending above it -- Create another, or Done. */
5129
+ if (justMade && !justMade.to && justMade.key === chosen.key) {
5130
+ const made = justMade;
5131
+ detail.append(newAssetBox({ kind: made.kind, made: { said: uiSaid('set-na-made', '{name} created', { name: made.name }), note: made.note },
5132
+ onAnother: () => { justMade = null; placeAssetStep(); assetsAdding = made.kind || 'choose'; void paintAssets(); },
5133
+ onDone: () => { justMade = null; void paintAssets(); } }));
5134
+ }
5038
5135
  detail.append(asTitle(chosen, back));
5039
5136
  detail.append(groupPicker(chosen, assetGroups));
5040
5137
  const ready = conversations.filter((c) => c.phase === 'ready');
@@ -5401,6 +5498,31 @@
5401
5498
  }));
5402
5499
  }
5403
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
+ });
5404
5526
  let salonDragged = '';
5405
5527
  $('salon-new-ais').addEventListener('dragstart', (e) => { salonDragged = e.target.closest?.('.salon-member-row')?.dataset.name ?? ''; });
5406
5528
  $('salon-new-host').addEventListener('dragover', (e) => { e.preventDefault(); $('salon-new-host').classList.add('over'); });
@@ -5420,7 +5542,9 @@
5420
5542
  salonBoxes = new Set(editing ? editing.members.filter((m) => m.kind === 'box').map((m) => m.ref) : []);
5421
5543
  try { const x = await fetch(`${API}/boxes`); salonBoxList = x.ok ? await x.json() : []; } catch { salonBoxList = []; }
5422
5544
  if (Array.isArray(salonBoxList)) boxesKnown = salonBoxList; else salonBoxList = [];
5423
- $('salon-new-boxes-card').hidden = $('salon-new-voice-head').hidden = salonBoxList.length === 0;
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();
5424
5548
  paintSalonMembers();
5425
5549
  $('salon-new-name').focus();
5426
5550
  }
@@ -5462,7 +5586,13 @@
5462
5586
  async function openFeature(what, s = {}) {
5463
5587
  const chapter = String(s.chapter ?? '');
5464
5588
  if (what === 'new' || (chapter === 'new' && what === 'settings')) { await openNew(); return; }
5465
- if (what === 'boxes' || chapter === 'boxes') { await openAccessPage('devices'); $('boxes')?.scrollIntoView({ block: 'start' }); return; }
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
+ }
5466
5596
  if (what === 'mail' || chapter === 'access') { await openAssetsPlace(); return; }
5467
5597
  if (what === 'import') { await openAccessPage('map', { mode: 'flows' }); document.getElementById('flows-import')?.click(); return; }
5468
5598
  if (what === 'opencode') {
@@ -5575,16 +5705,35 @@
5575
5705
  }
5576
5706
  fillKeyChoice();
5577
5707
  }
5578
- /* The key offered in "Add a repository": the one chosen stays chosen. */
5708
+ /* The key of "New repository": the kit's SecretPicker -- its keys, "+ New key…" made in place, and
5709
+ the new one chosen (its public half shown under it, to give the hosting service). */
5710
+ const gitKeyPick = KIT.SecretPicker({
5711
+ ids: { select: 'git-key', add: 'git-key-new', row: 'git-key-make', name: 'git-key-name', go: 'git-key-make-go' },
5712
+ none: 'No key yet: make one', addLabel: uiSaid('set-na-new-key', '+ New key…'), makeLabel: uiSaid('set-na-create', 'Create'), nameLabel: 'Name of the new key',
5713
+ nameAttrs: { maxlength: '32', pattern: '[a-z]([a-z0-9-]{0,30}[a-z0-9])?', placeholder: 'deploy-key', spellcheck: 'false', autocapitalize: 'off' },
5714
+ suggest: () => {
5715
+ const taken = new Set(gitKeys.map((k) => k.name));
5716
+ const wanted = $('git-name').value.trim();
5717
+ let suggestion = wanted && !taken.has(wanted) ? wanted : '';
5718
+ for (let n = 1; !suggestion; n += 1) if (!taken.has(`key-${n}`)) suggestion = `key-${n}`;
5719
+ return suggestion;
5720
+ },
5721
+ onMake: async (name) => {
5722
+ $('git-error').hidden = true;
5723
+ try {
5724
+ const made = await post(`${API}/git-keys`, { name });
5725
+ paintKeys(await fetch(`${API}/git-keys`).then((r) => r.json()));
5726
+ fillKeyChoice(made.name);
5727
+ return true;
5728
+ } catch (error) { $('git-error').textContent = error.message; $('git-error').hidden = false; return false; }
5729
+ },
5730
+ onChange: () => showChosenKey(),
5731
+ });
5732
+ $('git-key-pick').append(gitKeyPick);
5733
+ for (const [id, key] of [['git-key-new', 'set-na-new-key'], ['git-key-make-go', 'set-na-create']]) { const b = gitKeyPick.querySelector?.(`#${id}`); if (b) b.dataset.said = key; }
5734
+ /* The key offered in "New repository": the one chosen stays chosen. */
5579
5735
  function fillKeyChoice(chosen = $('git-key').value) {
5580
- const select = $('git-key'); select.replaceChildren();
5581
- if (gitKeys.length === 0) { const none = document.createElement('option'); none.value = ''; none.textContent = 'No key yet: make one'; select.append(none); }
5582
- for (const key of gitKeys) {
5583
- const o = document.createElement('option'); o.value = key.name;
5584
- o.textContent = key.usedBy.length ? `${key.name} (used by ${key.usedBy.join(', ')})` : key.name;
5585
- select.append(o);
5586
- }
5587
- if (gitKeys.some((k) => k.name === chosen)) select.value = chosen;
5736
+ gitKeyPick.set(gitKeys.map((key) => ({ value: key.name, label: key.usedBy.length ? `${key.name} (used by ${key.usedBy.join(', ')})` : key.name })), chosen);
5588
5737
  showChosenKey();
5589
5738
  }
5590
5739
  function showChosenKey() {
@@ -5605,25 +5754,6 @@
5605
5754
  const pick = looksSsh(from) ? 'ssh-key' : /^https:\/\//i.test(from) ? 'none' : '';
5606
5755
  if (pick) { $('git-new').querySelector(`input[name="git-via"][value="${pick}"]`).checked = true; showVia(); }
5607
5756
  });
5608
- $('git-key').addEventListener('change', showChosenKey);
5609
- $('git-key-new').addEventListener('click', () => {
5610
- const taken = new Set(gitKeys.map((k) => k.name));
5611
- const wanted = $('git-name').value.trim();
5612
- let suggestion = wanted && !taken.has(wanted) ? wanted : '';
5613
- for (let n = 1; !suggestion; n += 1) if (!taken.has(`key-${n}`)) suggestion = `key-${n}`;
5614
- $('git-key-name').value = suggestion;
5615
- $('git-key-make').hidden = false; focusField($('git-key-name'));
5616
- });
5617
- $('git-key-make-go').addEventListener('click', async () => {
5618
- $('git-error').hidden = true;
5619
- try {
5620
- const made = await post(`${API}/git-keys`, { name: $('git-key-name').value.trim() });
5621
- $('git-key-make').hidden = true;
5622
- gitKeys = await fetch(`${API}/git-keys`).then((r) => r.json());
5623
- fillKeyChoice(made.name);
5624
- await paintAssets();
5625
- } catch (error) { $('git-error').textContent = error.message; $('git-error').hidden = false; }
5626
- });
5627
5757
  $('git-key-copy').addEventListener('click', () => { void copyField($('git-key-public'), $('git-key-copy')); });
5628
5758
  /* Secrets: a name, and which conversations' tools are handed it. A value goes in and never comes back. */
5629
5759
  /* A VALUE OF SEVERAL LINES (a PEM or SSH key, a certificate): a box of its own, masked like the
@@ -5644,13 +5774,20 @@
5644
5774
  });
5645
5775
  $('secret-new').addEventListener('submit', async (event) => {
5646
5776
  event.preventDefault();
5647
- $('assets-error').hidden = true;
5777
+ $('assets-error').hidden = true; $('attach-error').hidden = true;
5648
5778
  const lines = !$('secret-lines').hidden;
5649
5779
  /* A key's last line ends with a line break: kept as it was pasted. */
5650
5780
  const value = lines ? $('secret-lines').value.replace(/\r\n?/g, '\n') : $('secret-value').value;
5651
5781
  const expires = $('secret-expires').value;
5652
- try { await post(`${API}/secrets`, { name: $('secret-name').value.trim(), value, ...(expires ? { expires } : {}) }); assetOpen = `secret:${$('secret-name').value.trim()}`; assetsAdding = ''; $('secret-name').value = ''; $('secret-expires').value = ''; secretLines(false, ''); }
5653
- catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
5782
+ const name = $('secret-name').value.trim();
5783
+ try {
5784
+ await post(`${API}/secrets`, { name, value, ...(expires ? { expires } : {}) });
5785
+ $('secret-name').value = ''; $('secret-expires').value = ''; secretLines(false, '');
5786
+ await assetMade($('secret-box'), { key: `secret:${name}`, name, give: async (to) => {
5787
+ await handTo(to, name, true, 'attach-error');
5788
+ $('secret-note').textContent = `${name} will be handed to the tool the next time it starts (leave the tool, then "Start it again").`;
5789
+ } });
5790
+ } catch (error) { newAssetError($('secret-box'), error.message); }
5654
5791
  await paintAssets();
5655
5792
  });
5656
5793
 
@@ -5658,7 +5795,7 @@
5658
5795
  /* What those sheets share with the rest of the page: the requests, the
5659
5796
  automatic sending form of Access, the share sheet for a device to pair. */
5660
5797
  const links = DEVICE ? undefined : window.clavariumLinks?.({
5661
- API: () => API, refresh, focusTerminal, openAssets: () => { void openAssets(); }, newDevice: () => { void openCompose([]); }, newConversation: () => createFromMap(),
5798
+ API: () => API, refresh, focusTerminal, openAssets: () => { void openAssets(); }, newDevice: () => newDevice(''), newConversation: () => createFromMap(),
5662
5799
  newAsset: () => newAssetFromMap(),
5663
5800
  autoSending: (conversation, name) => autoSending(conversation, name),
5664
5801
  partsFor: (name) => partsFor(name),
@@ -6040,7 +6177,7 @@
6040
6177
  $('nav-conversations').addEventListener('click', () => { leavePlace({ list: true }); });
6041
6178
  $('nav-access').addEventListener('click', () => { if (place !== 'access' || accessTab !== 'map' || mapMode !== 'map') void openAccessPage('map', { mode: 'map' }); });
6042
6179
  $('nav-assets').addEventListener('click', () => { if (place !== 'assets') void openAssetsPlace(); });
6043
- $('map-new-device').addEventListener('click', () => { void openCompose(accessFor ? [[`conversation:${accessFor}`, partsFor(accessFor)]] : []); });
6180
+ $('map-new-device').addEventListener('click', () => newDevice(accessFor));
6044
6181
  /* Every device and what each was given, by device or by thing: a step over the map. */
6045
6182
  $('map-all-devices').addEventListener('click', () => { void openAccessPage('devices'); });
6046
6183
  /* Voice boxes are on the page of all devices: opened there, at them. */
@@ -6051,7 +6188,6 @@
6051
6188
  $('access-for-clear').addEventListener('click', () => { accessFor = ''; void openAccessPage(accessTab, { push: false }); });
6052
6189
  for (const b of $('map-mode').querySelectorAll('[data-mode]')) b.addEventListener('click', () => { if (b.dataset.mode !== mapMode || accessTab !== 'map') void openAccessPage('map', { mode: b.dataset.mode }); });
6053
6190
  /* From a conversation's own sheet: Access, on that conversation alone. */
6054
- $('access-assets-here').addEventListener('click', () => { goTab('assets'); });
6055
6191
  $('access-devices-here').addEventListener('click', () => { void openAccessPage('map', { of: current }); });
6056
6192
 
6057
6193
  /* ---------- Settings: this device, and the platform ---------- */
@@ -7623,14 +7759,15 @@
7623
7759
  const made = await post(`${API}/resources`, { name: $('git-name').value.trim(), type: 'git', from, ...(from ? { via } : {}) });
7624
7760
  /* The secrets typed are not kept in the page a moment longer. */
7625
7761
  $('git-new').reset(); viaTouched = false; showVia(); fillKeyChoice(via.key);
7626
- /* A new repository opens on its card, where it is attached: the next thing to do. */
7627
- assetOpen = `git:${made.name}`;
7762
+ /* First contact with its host: said in the ending, kept there. */
7628
7763
  if (made.firstSeen) {
7629
7764
  $('git-said').textContent = `${made.name} was cloned. First contact with ${hostOf(made.from)}: its host key (${made.firstSeen.join(', ')}) was recorded. A different key later will be refused.`;
7630
7765
  $('git-said').hidden = false;
7631
- } else assetsAdding = '';
7766
+ }
7767
+ /* A new repository opens on its card, where it is attached: the next thing to do. */
7768
+ await assetMade($('git-box'), { key: `git:${made.name}`, name: made.name, note: made.firstSeen ? $('git-said').textContent : '', give: (to, level) => attachTo(to, made.name, level, 'attach-error') });
7632
7769
  } catch (error) { $('git-error').textContent = error.message; $('git-error').hidden = false; }
7633
- button.disabled = false; button.textContent = 'Add';
7770
+ button.disabled = false; button.textContent = 'Create';
7634
7771
  await paintAssets();
7635
7772
  });
7636
7773
  /* ---------- a repository: what would go out, then send it ---------- */
@@ -7996,6 +8133,11 @@
7996
8133
  same levels, through Tether -- with its sending server (SMTP) too, unless "No sending". The former
7997
8134
  read-only copy as files stays, ticked on purpose. */
7998
8135
  let mailboxLooked = '';
8136
+ /* An account connected: its targets (mail, calendar, contacts), the first opened, all given from Attach. */
8137
+ const targetsMade = (made, user) => {
8138
+ const targets = Array.isArray(made?.targets) ? made.targets : [];
8139
+ return { key: targets[0] ? `connexion:${targets[0].id}` : '', name: targets[0]?.title ?? user, give: (to, level) => Promise.all(targets.map((t) => grantTarget(t.id, to, targetLevel(level)))) };
8140
+ };
7999
8141
  $('mailbox-user').addEventListener('change', async () => {
8000
8142
  const user = $('mailbox-user').value.trim();
8001
8143
  if (!user.includes('@') || user === mailboxLooked) return;
@@ -8013,11 +8155,12 @@
8013
8155
  button.disabled = true; button.textContent = 'Trying it...';
8014
8156
  const host = $('mailbox-host').value.trim(); const port = $('mailbox-port').value.trim();
8015
8157
  try {
8016
- const made = await post(`${API}/accounts/classic`, { user: $('mailbox-user').value.trim(), password: $('mailbox-password').value, imap: port ? `${host}:${port}` : host, smtp: $('mailbox-smtp').value.trim(), kinds: ['mail'] });
8017
- if (made?.targets?.[0]?.id) assetOpen = `connexion:${made.targets[0].id}`;
8018
- assetsAdding = ''; $('mailbox-new').reset(); mailboxLooked = '';
8158
+ const user = $('mailbox-user').value.trim();
8159
+ const made = await post(`${API}/accounts/classic`, { user, password: $('mailbox-password').value, imap: port ? `${host}:${port}` : host, smtp: $('mailbox-smtp').value.trim(), kinds: ['mail'] });
8160
+ $('mailbox-new').reset(); mailboxLooked = '';
8161
+ await assetMade($('mailbox-box'), targetsMade(made, user));
8019
8162
  } catch (error) { $('mailbox-error').textContent = error.message; $('mailbox-error').hidden = false; }
8020
- button.disabled = false; button.textContent = 'Connect';
8163
+ button.disabled = false; button.textContent = 'Create';
8021
8164
  await paintAssets();
8022
8165
  });
8023
8166
  /* New mailbox: IMAP and SMTP, connected live (02-11). Gmail and Microsoft sign in instead (token kept on
@@ -8032,7 +8175,7 @@
8032
8175
  const provider = b.dataset.provider;
8033
8176
  if (provider === 'classic') return;
8034
8177
  const user = $('mailbox-user').value.trim();
8035
- assetsAdding = 'connexion'; await paintAssets();
8178
+ await newAssetKind($('mailbox-box'), 'connexion');
8036
8179
  setConnexionProvider(provider);
8037
8180
  if (user.includes('@')) $('connexion-email').value = user;
8038
8181
  });
@@ -8087,9 +8230,10 @@
8087
8230
  try {
8088
8231
  const made = await post(`${API}/accounts/classic`, { user: $('connexion-email').value.trim(), password: $('connexion-password').value, kinds,
8089
8232
  imap: $('connexion-imap').value.trim(), smtp: $('connexion-smtp').value.trim(), caldav: $('connexion-caldav').value.trim(), carddav: $('connexion-carddav').value.trim() });
8090
- if (made?.targets?.[0]) assetOpen = `connexion:${made.targets[0].id}`;
8091
- assetsAdding = ''; lookedUp = '';
8233
+ const user = $('connexion-email').value.trim();
8234
+ lookedUp = '';
8092
8235
  $('connexion-new').reset(); setConnexionProvider('google');
8236
+ await assetMade($('connexion-box'), targetsMade(made, user));
8093
8237
  } catch (error) { $('connexion-error').textContent = error.message; $('connexion-error').hidden = false; }
8094
8238
  $('connexion-password').value = '';
8095
8239
  btn.disabled = false; btn.textContent = was;
@@ -8125,9 +8269,9 @@
8125
8269
  $('connexion-error').hidden = false;
8126
8270
  $('connexion-code').value = ''; $('connexion-paste').hidden = true;
8127
8271
  } else {
8128
- if (made?.targets?.[0]) assetOpen = `connexion:${made.targets[0].id}`;
8129
- assetsAdding = '';
8272
+ const user = $('connexion-email').value.trim();
8130
8273
  $('connexion-new').reset(); setConnexionProvider('google');
8274
+ await assetMade($('connexion-box'), targetsMade(made, user));
8131
8275
  }
8132
8276
  } catch (error) { $('connexion-error').textContent = error.message; $('connexion-error').hidden = false; }
8133
8277
  btn.disabled = false; btn.textContent = was;
@@ -8137,17 +8281,26 @@
8137
8281
  getJson('/accounts', null).then((d) => { if (d?.supported) { accountSupported = { ...d.supported, classic: ['mail', 'calendar', 'contacts'] }; setConnexionProvider($('connexion-new').dataset.provider || 'google'); } });
8138
8282
  $('list-new').addEventListener('submit', async (event) => {
8139
8283
  event.preventDefault();
8140
- $('assets-error').hidden = true;
8284
+ $('assets-error').hidden = true; $('attach-error').hidden = true;
8141
8285
  const made = await binderCall('create-list', { template: $('listnew-template').value, title: $('listnew-title').value.trim(), lang: binderLang() });
8142
- if (made.ok) { $('listnew-title').value = ''; assetsAdding = ''; assetOpen = `list:${made.data.id}`; listOpen = assetOpen; remember(); }
8143
- else { $('assets-error').textContent = made.text; $('assets-error').hidden = false; }
8286
+ if (made.ok) {
8287
+ $('listnew-title').value = '';
8288
+ const key = `list:${made.data.id}`;
8289
+ const attaching = inAttach($('list-box'));
8290
+ await assetMade($('list-box'), { key, name: made.data.title ?? $('listnew-template').selectedOptions[0]?.textContent ?? '', give: (to, level) => grantList(made.data.id, to, level) });
8291
+ if (!attaching) { listOpen = key; remember(); }
8292
+ } else newAssetError($('list-box'), made.text);
8144
8293
  await paintAssets();
8145
8294
  });
8146
8295
  $('folder-new').addEventListener('submit', async (event) => {
8147
8296
  event.preventDefault();
8148
8297
  $('assets-error').hidden = true;
8149
- try { const made = await post(`${API}/resources`, { name: $('folder-name').value.trim() }); $('folder-name').value = ''; assetsAdding = ''; if (made?.name) assetOpen = `folder:${made.name}`; }
8150
- catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
8298
+ $('attach-error').hidden = true;
8299
+ try {
8300
+ const made = await post(`${API}/resources`, { name: $('folder-name').value.trim() }); $('folder-name').value = '';
8301
+ const name = made?.name ?? '';
8302
+ await assetMade($('folder-box'), { key: name ? `folder:${name}` : '', name, give: name ? (to, level) => attachTo(to, name, level, 'attach-error') : null });
8303
+ } catch (error) { newAssetError($('folder-box'), error.message); }
8151
8304
  await paintAssets();
8152
8305
  });
8153
8306
 
@@ -10154,15 +10307,88 @@
10154
10307
  rows.append(card);
10155
10308
  }
10156
10309
  }
10157
- $('box-new').addEventListener('click', () => {
10158
- const add = $('box-add'); add.hidden = !add.hidden;
10159
- /* Which conversation it speaks in: chosen on purpose, never a silent default. */
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() {
10160
10331
  const pick = $('box-conversation'); pick.replaceChildren();
10161
10332
  const none = el('option', '', 'Choose a conversation...'); none.value = ''; pick.append(none);
10162
10333
  for (const c of conversations) { const o = el('option', '', shownName(c)); o.value = c.name; pick.append(o); }
10163
- pick.value = accessFor && conversations.some((c) => c.name === accessFor) ? accessFor : '';
10164
- $('box-ready').hidden = true;
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);
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);
10165
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
+ }
10166
10392
  $('box-key-copy').addEventListener('click', async () => {
10167
10393
  const key = $('box-key').textContent;
10168
10394
  try { await navigator.clipboard.writeText(key); $('box-key-copy').textContent = 'Copied'; }
@@ -10170,16 +10396,36 @@
10170
10396
  setTimeout(() => { $('box-key-copy').textContent = 'Copy the key'; }, 2000);
10171
10397
  });
10172
10398
  $('box-code').addEventListener('click', async () => {
10173
- if (!$('box-conversation').value) { $('box-conversation').focus(); $('box-code-minutes').textContent = 'Choose the conversation it speaks in first.'; $('box-ready').hidden = false; return; }
10399
+ if (!$('box-conversation').value) { boxGo('where'); $('box-error').textContent = 'Choose the conversation it speaks in first.'; $('box-error').hidden = false; return; }
10174
10400
  try {
10175
- const r = await post(`${API}/boxes/code`, { conversation: $('box-conversation').value, name: $('box-room').value.trim(), origin: location.origin, zone: Intl.DateTimeFormat().resolvedOptions().timeZone });
10401
+ const before = await getJson('/boxes', null);
10402
+ const r = await pairCode({ conversation: $('box-conversation').value, name: $('box-room').value.trim(), origin: location.origin });
10176
10403
  $('box-code-shown').textContent = r.code; $('box-code-minutes').textContent = `valid ${r.minutes} minutes, once`;
10177
10404
  $('box-key').textContent = r.key ?? '';
10178
10405
  $('box-link').href = r.link ?? '#';
10179
10406
  $('box-qr').innerHTML = r.qr ?? '';
10180
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
+ }
10181
10413
  } catch (error) { $('box-code-minutes').textContent = error.message; $('box-ready').hidden = false; }
10182
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(); });
10183
10429
  async function paintManage() {
10184
10430
  await readDevices();
10185
10431
  void paintBoxes();
@@ -10228,8 +10474,14 @@
10228
10474
  async function openManage() { await openAccessPage('devices'); }
10229
10475
  $('share-by-device').addEventListener('click', () => { manageBy = 'device'; void paintManage(); });
10230
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
+ }
10231
10483
  /* Filtered on a conversation, a new device is offered that conversation. */
10232
- $('share-new-device').addEventListener('click', () => { void openCompose(accessFor ? [[`conversation:${accessFor}`, partsFor(accessFor)]] : []); });
10484
+ $('share-new-device').addEventListener('click', () => newDevice(accessFor));
10233
10485
  /* From a conversation: that conversation, and nothing else, is in the basket. */
10234
10486
  $('share').addEventListener('click', () => { void openCompose([[`conversation:${current}`, partsFor(current)]]); });
10235
10487
  /* The Sharing chapter of a conversation: who has it, and which parts -- changed there, at once. */
package/web/index.html CHANGED
@@ -227,20 +227,23 @@
227
227
  <details class="chapter" id="chapter-access" data-chapter="access">
228
228
  <summary><span class="chapter-title" data-said="set-ch-access">Access</span><span class="chapter-about">Folders, repositories, secrets, network.</span></summary>
229
229
  <div class="chapter-body">
230
- <div class="panel-top"><b>Folders, repositories, mailboxes</b><button type="button" id="attach-open" class="primary">+ Attach</button></div>
230
+ <div class="panel-top"><b>Folders, repositories, mailboxes</b><button type="button" id="attach-open" class="primary" data-said="set-na-attach">Attach</button></div>
231
231
  <p class="hint tip" hidden>In its machine under <code>/resources/</code>. Read-only cannot be lifted by the tool.</p>
232
232
  <div id="panel-rows"></div>
233
233
  <p id="panel-empty" class="hint" hidden>Nothing is attached to this conversation.</p>
234
- <div class="row to-access"><button type="button" id="access-assets-here">Attach an asset</button><span class="hint">Every asset, in Access.</span></div>
235
234
  <div class="panel-top"><b>Secrets handed to its tool</b></div>
236
235
  <div id="access-secrets"></div>
237
236
  <p id="access-secrets-empty" class="hint" hidden>No secret is handed to it.</p>
238
237
  <p id="secret-note" class="hint" role="status"></p>
238
+ <!-- ATTACH: the New asset box (kit.js NewAsset) with this conversation as its context: what is
239
+ there already (#attach-there, moved into it), or a new one, attached at the end. -->
239
240
  <div id="attach-picker" hidden>
240
- <div class="panel-top"><b id="attach-title">Attach</b><button type="button" id="attach-close">Done</button></div>
241
- <div id="attach-rows"></div>
242
- <p id="attach-empty" class="hint" hidden>Everything there is is attached already.</p>
243
- <button type="button" id="attach-manage">Manage all assets</button>
241
+ <div class="panel-top"><b id="attach-title" data-said="set-na-attach">Attach</b><button type="button" id="attach-close" data-said="set-na-done">Done</button></div>
242
+ <div id="attach-box"></div>
243
+ <p id="attach-error" class="error" role="alert" hidden></p>
244
+ <div id="attach-park" hidden><div id="attach-there"><div id="attach-rows"></div>
245
+ <p id="attach-empty" class="hint" hidden>Everything there is is attached already.</p></div></div>
246
+ <button type="button" id="attach-manage" class="as-link">Manage all assets</button>
244
247
  </div>
245
248
  <div id="signin-setup" hidden>
246
249
  <div class="panel-top"><b>Sign-in mailbox</b></div>
@@ -663,18 +666,32 @@
663
666
  <!-- Voice boxes: a speaker in a room, bound to one conversation (boxes.mjs). -->
664
667
  <section id="boxes" aria-label="Voice boxes">
665
668
  <div class="row"><b>Voice boxes</b><span class="sp"></span><button type="button" id="box-new" class="primary">+ Voice box</button></div>
666
- <div id="box-add" class="card" hidden>
667
- <div class="row">
668
- <label>Conversation <select id="box-conversation"></select></label>
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>
669
676
  <label>Room <input id="box-room" maxlength="40" placeholder="Living room"></label>
670
- <button type="button" id="box-code" class="primary">Get a code</button>
671
677
  </div>
672
- <div id="box-ready" hidden>
673
- <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>
674
- <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>
675
- <div class="row"><code id="box-key" class="box-key"></code><button type="button" id="box-key-copy">Copy the key</button></div>
676
- <p class="hint">Pairing code alone: <b id="box-code-shown"></b></p>
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>
677
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>
678
695
  </div>
679
696
  <div id="box-list"></div>
680
697
  </section>
@@ -718,7 +735,8 @@
718
735
  </div>
719
736
  <h3 class="room-group" id="salon-new-voice-head" data-said="set-tab-chat">Chat &amp; voice</h3>
720
737
  <div class="nc-card" id="salon-new-boxes-card">
721
- <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>
722
740
  <div id="salon-new-boxes" class="salon-member-list" role="list" aria-label="Voice boxes"></div>
723
741
  </div>
724
742
  <h3 class="room-group" id="salon-new-advanced-head" data-said="set-tab-advanced" hidden>Advanced</h3>
@@ -760,8 +778,8 @@
760
778
  </fieldset>
761
779
  <div id="git-via-ssh-key" class="git-via-part">
762
780
  <label for="git-key">Key</label>
763
- <div class="row"><select id="git-key"></select><button type="button" id="git-key-new">New key</button></div>
764
- <div id="git-key-make" class="row" hidden><input id="git-key-name" maxlength="32" pattern="[a-z]([a-z0-9-]{0,30}[a-z0-9])?" aria-label="Name of the new key" placeholder="deploy-key" spellcheck="false" autocapitalize="off"><button type="button" id="git-key-make-go" class="primary">Make the key</button></div>
781
+ <!-- A SecretPicker (kit.js): #git-key, "+ New key…" (#git-key-new), made in place (#git-key-make). -->
782
+ <div id="git-key-pick"></div>
765
783
  <div id="git-key-shown" hidden>
766
784
  <label for="git-key-public">Public key: add it to the repository on the hosting service, then press Add</label>
767
785
  <div class="row"><textarea id="git-key-public" class="public-key" readonly rows="3" spellcheck="false"></textarea><button type="button" id="git-key-copy">Copy</button></div>
@@ -781,13 +799,13 @@
781
799
  <label for="git-pass">Password (kept sealed here)</label>
782
800
  <input id="git-pass" type="password" autocomplete="new-password">
783
801
  </div>
784
- <div class="row"><button type="submit" class="primary">Add</button></div>
802
+ <div class="row"><button type="submit" class="primary">Create</button></div>
785
803
  <p id="git-said" class="hint" role="status" hidden></p>
786
804
  <p id="git-error" class="error" role="alert" hidden></p>
787
805
  </form>
788
806
  <div class="panel-top"><b id="git-keys-title">SSH keys made here</b><small class="hint">the private half never leaves this server</small></div>
789
807
  <div id="git-keys"></div>
790
- <p id="git-keys-empty" class="hint">No key yet: "New key" in Add a repository makes one.</p>
808
+ <p id="git-keys-empty" class="hint">No key yet: "+ New key…" in New repository makes one.</p>
791
809
  </div>
792
810
  <div id="mailbox-box" class="as-form" data-kind="mailbox"><h3>New mailbox</h3>
793
811
  <div id="mailbox-provider" class="choices" role="group" aria-label="Kind of mailbox">
@@ -805,7 +823,7 @@
805
823
  <input id="mailbox-smtp" class="mailbox-live" placeholder="smtp.example.com — empty: no sending" spellcheck="false" autocapitalize="off">
806
824
  <label for="mailbox-password">Password</label>
807
825
  <div class="row"><input id="mailbox-password" type="password" autocomplete="new-password">
808
- <button type="submit" class="primary">Connect</button></div>
826
+ <button type="submit" class="primary">Create</button></div>
809
827
  <p id="mailbox-error" class="error" role="alert" hidden></p>
810
828
  </form>
811
829
  </div>
@@ -836,13 +854,13 @@
836
854
  <label for="connexion-carddav" id="connexion-carddav-label">Contacts address (CardDAV)</label>
837
855
  <input id="connexion-carddav" spellcheck="false" autocapitalize="off" placeholder="https://dav.example.com">
838
856
  <p class="hint">Filled from the email address when known; your host's help pages give them otherwise. The password stays on the server and never enters a machine.</p>
839
- <div class="row"><button type="button" id="connexion-classic-connect" class="primary">Connect</button></div>
857
+ <div class="row"><button type="button" id="connexion-classic-connect" class="primary">Create</button></div>
840
858
  </div>
841
859
  <p class="hint" id="connexion-notice"></p>
842
860
  <div class="row" id="connexion-open-row"><button type="button" id="connexion-open" class="primary">Open the sign-in page</button></div>
843
861
  <div id="connexion-paste" hidden>
844
862
  <label for="connexion-code">After you allow, the page will not load — copy its full address and paste it here</label>
845
- <div class="row"><input id="connexion-code" spellcheck="false" autocapitalize="off" placeholder="Paste the whole address from the bar"><button type="button" id="connexion-connect" class="primary">Connect</button></div>
863
+ <div class="row"><input id="connexion-code" spellcheck="false" autocapitalize="off" placeholder="Paste the whole address from the bar"><button type="button" id="connexion-connect" class="primary">Create</button></div>
846
864
  </div>
847
865
  <p id="connexion-error" class="error" role="alert" hidden></p>
848
866
  </form>
@@ -860,7 +878,7 @@
860
878
  <label for="secret-name">New secret, or a new value for an existing one</label>
861
879
  <div class="row"><input id="secret-name" maxlength="40" pattern="[A-Z][A-Z0-9_]*" title="Capitals, digits and underscores, starting with a letter. Example: MODEL_KEY" placeholder="MODEL_KEY" spellcheck="false" autocapitalize="characters" required>
862
880
  <input id="secret-value" type="password" placeholder="value (never shown again)" autocomplete="new-password" required>
863
- <button type="submit" class="primary">Save</button></div>
881
+ <button type="submit" class="primary">Create</button></div>
864
882
  <div class="row secret-expiry"><label for="secret-expires">Expires</label><input id="secret-expires" type="date"><small class="hint">Optional</small></div>
865
883
  <!-- A key or a certificate is several lines: pasted into the line above, they come here by themselves. -->
866
884
  <textarea id="secret-lines" class="secret-lines" rows="7" spellcheck="false" autocomplete="off" autocapitalize="off" placeholder="-----BEGIN ...-----&#10;...&#10;-----END ...-----" aria-label="Value, several lines (never shown again)" hidden></textarea>
package/web/kit.js CHANGED
@@ -10,6 +10,11 @@
10
10
  * ConvCard ONE CONVERSATION, three sizes: `row` (the list, Recent), `card` (the home deck),
11
11
  * `member` (a room's members, and the one that welcomes it). Same dot, name, line
12
12
  * of what it does now, chips; each place adds its own gestures (`actions`).
13
+ * StepFlow the steps of a gesture, the one at hand marked, "2 / 3"
14
+ * SecretPicker a key to choose, or "+ New key…" made in place
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). A voice box and
17
+ * a device are two of its kinds too (step 4).
13
18
  *
14
19
  * No framework: each piece is a function that returns an element. Words: English here; the page
15
20
  * hands its own (`setWords`, app.js `uiSaid`) for the few the kit says by itself.
@@ -144,9 +149,116 @@
144
149
  return root;
145
150
  }
146
151
 
152
+ /* The steps of a gesture: done ones ticked, the one at hand `aria-current="step"`, and "2 / 3".
153
+ `at`: the step at hand (0 is the first); `steps.length`: all done. */
154
+ function StepFlow({ steps = [], at = 0, label = '' } = {}) {
155
+ const box = node('div', 'kit-steps');
156
+ const list = node('ol', 'kit-steps-list');
157
+ if (label) list.setAttribute('aria-label', label);
158
+ steps.forEach((s, i) => {
159
+ const li = node('li', i < at ? 'done' : '');
160
+ if (i === at) li.setAttribute('aria-current', 'step');
161
+ const n = node('span', 'kit-step-n', i < at ? '✓' : String(i + 1)); n.setAttribute('aria-hidden', 'true');
162
+ li.append(n, node('span', 'kit-step-w', s));
163
+ list.append(li);
164
+ });
165
+ box.append(list, node('small', 'kit-steps-count', `${Math.min(at + 1, steps.length)} / ${steps.length}`));
166
+ return box;
167
+ }
168
+
169
+ /* A KEY TO CHOOSE, or one made in place: its keys, then "+ New key…" opens a name and Create right
170
+ there. `ids` keeps the page's names for its parts { select, add, row, name, go }. `keys` [{ value,
171
+ label }]; `none`: said when there is none. `suggest()`: the name offered; `onMake(name)`: the page
172
+ makes it (and calls `.set` with the new list). `.set(keys, chosen)` fills it again, the chosen kept. */
173
+ function SecretPicker({ ids = {}, keys = [], value = '', label = '', none = '', addLabel, makeLabel, nameLabel = '', nameAttrs = {}, suggest = () => '', onMake = async () => {}, onChange = () => {} } = {}) {
174
+ const box = node('div', 'kit-secret');
175
+ const select = node('select'); if (ids.select) select.id = ids.select;
176
+ if (label) select.setAttribute('aria-label', label);
177
+ const add = node('button', 'kit-secret-add', addLabel ?? say('kit-new-key', '+ New key…')); add.type = 'button'; if (ids.add) add.id = ids.add;
178
+ const pick = node('div', 'row'); pick.append(select, add);
179
+ const make = node('div', 'row kit-secret-make'); if (ids.row) make.id = ids.row; make.hidden = true;
180
+ const name = node('input'); if (ids.name) name.id = ids.name;
181
+ if (nameLabel) name.setAttribute('aria-label', nameLabel);
182
+ for (const [k, v] of Object.entries(nameAttrs)) name.setAttribute(k, v);
183
+ const go = node('button', 'primary', makeLabel ?? say('kit-create', 'Create')); go.type = 'button'; if (ids.go) go.id = ids.go;
184
+ make.append(name, go);
185
+ box.append(pick, make);
186
+ box.set = (list, chosen = select.value) => {
187
+ select.replaceChildren();
188
+ if (!list.length && none) { const o = node('option', '', none); o.value = ''; select.append(o); }
189
+ for (const k of list) { const o = node('option', '', k.label ?? k.value); o.value = k.value; select.append(o); }
190
+ if (list.some((k) => k.value === chosen)) select.value = chosen;
191
+ };
192
+ box.set(keys, value);
193
+ select.addEventListener('change', () => onChange(select.value));
194
+ add.addEventListener('click', () => { name.value = suggest() ?? ''; make.hidden = false; name.focus?.(); });
195
+ go.addEventListener('click', async () => {
196
+ go.disabled = true;
197
+ try { if ((await onMake(name.value.trim())) !== false) make.hidden = true; } finally { go.disabled = false; }
198
+ });
199
+ return box;
200
+ }
201
+
202
+ /* NEW ASSET: ONE BOX, wherever an asset is made (Assets, a conversation's Attach). Its kinds, then
203
+ that kind's form (the page's own: `form(kind)`), then one ending: "✓ <name> created", Create
204
+ another, Done. Opened with a context, it says it on top (`context`: { line, level? }, `level` a
205
+ Segmented's options) and the page attaches what is made at the end. `existing`: what is there
206
+ already, offered above "or a new one". `made`: { said, note? } draws the ending.
207
+ kinds [{ kind, label, icon? }] kind '' : choose one words { title, there, orNew, steps[3], back, another, done }
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 = () => {} } = {}) {
211
+ const root = node('div', 'kit-newasset');
212
+ root.dataset.step = made ? 'done' : kind ? 'form' : 'kind';
213
+ const steps = w.steps ?? [say('kit-step-kind', 'Kind'), say('kit-step-set', 'Set up'), say('kit-step-made', 'Created')];
214
+ if (context) {
215
+ const top = node('div', 'kit-na-context');
216
+ top.append(node('span', '', context.line ?? ''));
217
+ if (context.level) top.append(Segmented(context.level));
218
+ root.append(top);
219
+ }
220
+ const head = node('div', 'kit-na-head');
221
+ const title = w.title ?? say('kit-new-asset', 'New asset');
222
+ if (!kind && !made && title) head.append(node('h3', '', title));
223
+ head.append(StepFlow({ steps, at: made ? steps.length : kind ? (Number.isInteger(at) ? at : 1) : 0 }));
224
+ root.append(head);
225
+ if (made) {
226
+ const end = node('div', 'kit-na-made');
227
+ const line = node('p', ''); line.setAttribute('role', 'status');
228
+ line.append(StatusDot({ state: 'ok' }), node('span', '', `✓ ${made.said}`));
229
+ end.append(line);
230
+ if (made.note) end.append(node('p', 'hint', made.note));
231
+ const acts = node('div', 'row kit-na-acts');
232
+ const again = node('button', '', w.another ?? say('kit-create-another', 'Create another')); again.type = 'button'; again.dataset.act = 'another';
233
+ const done = node('button', 'primary', w.done ?? say('kit-done', 'Done')); done.type = 'button'; done.dataset.act = 'done';
234
+ again.addEventListener('click', () => onAnother());
235
+ done.addEventListener('click', () => onDone());
236
+ acts.append(again, done); end.append(acts);
237
+ root.append(end);
238
+ return root;
239
+ }
240
+ if (kind) {
241
+ /* Back to the kinds, when the frame has no way back of its own. */
242
+ if (onBack) { const back = node('button', 'as-link kit-na-back', `\u2039 ${w.back ?? say('kit-back', 'Back')}`); back.type = 'button'; back.addEventListener('click', () => onBack()); root.append(back); }
243
+ const f = form(kind); if (f) root.append(f);
244
+ return root;
245
+ }
246
+ if (existing) root.append(node('h4', 'kit-na-sub', w.there ?? say('kit-already-there', 'Already there')), existing, node('h4', 'kit-na-sub', w.orNew ?? say('kit-or-new', 'or a new one')));
247
+ /* `.as-kinds`, `data-kind`: the names the page's rules and tests know. */
248
+ const list = node('div', 'as-kinds');
249
+ for (const k of kinds) {
250
+ const b = node('button', '', k.label ?? k.kind); b.type = 'button'; b.dataset.kind = k.kind;
251
+ if (k.icon) b.prepend(k.icon);
252
+ b.addEventListener('click', () => onKind(k.kind));
253
+ list.append(b);
254
+ }
255
+ root.append(list);
256
+ return root;
257
+ }
258
+
147
259
  window.clavariumKit = {
148
260
  STATES, STATE_WORDS, stateOf, hueOf, initialOf,
149
261
  setWords(fn) { if (typeof fn === 'function') words = fn; },
150
- StatusDot, Avatar, Chips, Switch, Segmented, InlineConfirm, ConvCard,
262
+ StatusDot, Avatar, Chips, Switch, Segmented, InlineConfirm, ConvCard, StepFlow, SecretPicker, NewAsset,
151
263
  };
152
264
  })();
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
 
@@ -2647,6 +2654,30 @@ button.kit-switch[aria-checked="true"]::after { left: 18px; background: var(--ok
2647
2654
  /* INLINE CONFIRM: in place of its button, Keep first. */
2648
2655
  .kit-confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
2649
2656
  .kit-confirm-q { color: var(--ink); }
2657
+ /* STEPFLOW: the steps of a gesture, the one at hand marked, and "2 / 3". */
2658
+ .kit-steps { display: flex; align-items: center; gap: 10px; min-width: 0; }
2659
+ .kit-steps-list { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 0; list-style: none; min-width: 0; font-size: .8125rem; color: var(--ink2); }
2660
+ .kit-steps-list > li { display: inline-flex; align-items: center; gap: 5px; }
2661
+ .kit-step-n { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); font-size: .6875rem; font-weight: 600; }
2662
+ .kit-steps-list > li.done .kit-step-n { border-color: var(--ok); color: var(--ok); }
2663
+ .kit-steps-list > li[aria-current="step"] { color: var(--ink); font-weight: 600; }
2664
+ .kit-steps-list > li[aria-current="step"] .kit-step-n { border-color: var(--brass); background: var(--brass); color: var(--bg); }
2665
+ .kit-steps-count { margin-left: auto; flex: none; color: var(--ink2); font-size: .75rem; }
2666
+ /* SECRETPICKER: its keys, "+ New key…", and the new one's name made in place. */
2667
+ .kit-secret { display: flex; flex-direction: column; gap: 6px; }
2668
+ .kit-secret .row > select, .kit-secret .row > input { flex: 1; min-width: 0; }
2669
+ /* NEW ASSET: one box -- its context on top, its steps, the kinds or a form, one ending. */
2670
+ .kit-newasset { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
2671
+ .kit-na-context { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--brass) 10%, transparent); color: var(--brass-ink); font-size: .875rem; }
2672
+ .kit-na-context > .kit-seg { margin-left: auto; }
2673
+ .kit-na-head { display: flex; flex-direction: column; gap: 6px; }
2674
+ .kit-na-head > h3 { margin: 0; font-size: 1.125rem; }
2675
+ .kit-na-sub { margin: 4px 0 0; font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
2676
+ .kit-na-made { display: flex; flex-direction: column; gap: 8px; }
2677
+ .kit-na-made > p[role="status"] { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; color: var(--ink); }
2678
+ .kit-na-made > .hint { margin: 0; }
2679
+ .kit-na-acts { gap: 8px; justify-content: flex-end; }
2680
+ .as-detail > .kit-newasset[data-step="done"] { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
2650
2681
  /* THE CONVERSATION CARD: its avatar with its point on the corner, its name, what it does now, its chips;
2651
2682
  the gestures of its place at its end. Sizes: row (the list), card (the deck), member (a room's). */
2652
2683
  .kit-conv { --kc-av: 28px; --kc-ring: var(--bar); position: relative; display: grid; grid-template-columns: var(--kc-av) minmax(0, 1fr) auto; column-gap: 10px; align-items: start; text-align: left; color: var(--ink); min-width: 0; }