clavarium 0.2.215-beta.1 → 0.2.216-beta.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.215-beta.1",
3
+ "version": "0.2.216-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.215-beta.1",
9
+ "version": "0.2.216-beta.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -14,7 +14,7 @@
14
14
  "clavarium-binder": "0.1.63-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
16
  "clavarium-parley": "0.17.95-next.1",
17
- "clavarium-tether": "0.1.0-next.67",
17
+ "clavarium-tether": "0.1.0-next.68",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
20
20
  "node-pty": "^1.1.0",
@@ -800,9 +800,9 @@
800
800
  }
801
801
  },
802
802
  "node_modules/clavarium-tether": {
803
- "version": "0.1.0-next.67",
804
- "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.67.tgz",
805
- "integrity": "sha512-lb1C+cqZhLi+reUyiZtZDHjbxl1WUTDu23bQ3YR4X1rNJAST/8gJwpBOVNKok9hlfLo5zDVIYL4xL5jhMuHaWQ==",
803
+ "version": "0.1.0-next.68",
804
+ "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.68.tgz",
805
+ "integrity": "sha512-SVPlyIGWSRUkS0G7OCca38xru05NMxCgc7XSR7pBDetNhdGKJFlSG3p3ZsjY6p5iCdgfpjSFhAyH/VnDFHdMoQ==",
806
806
  "license": "MIT",
807
807
  "bin": {
808
808
  "tether": "bin/cli.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.215-beta.1",
3
+ "version": "0.2.216-beta.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.",
@@ -48,7 +48,7 @@
48
48
  "clavarium-binder": "0.1.63-next.1",
49
49
  "clavarium-docket": "0.1.2-next.2",
50
50
  "clavarium-parley": "0.17.95-next.1",
51
- "clavarium-tether": "0.1.0-next.67",
51
+ "clavarium-tether": "0.1.0-next.68",
52
52
  "mammoth": "1.13.0",
53
53
  "mermaid": "11.17.2",
54
54
  "node-pty": "^1.1.0",
@@ -0,0 +1,127 @@
1
+ /* A CALENDAR, SEEN BY ITS OWNER (16-11): the agenda of a calendar asset (a Tether target of kind calendar), shown
2
+ * in its asset panel, so Outlook need not stay open beside Clavarium.
3
+ *
4
+ * POST /api/tether/agenda {target, from?, to?} from/to: days (YYYY-MM-DD), in the calendar's zone; to is
5
+ * not in the window. Default: today and the next 7 days. -> { target, title, zone,
6
+ * from, to, events: [...], more, partial }
7
+ *
8
+ * READ THROUGH TETHER, as an agent's calendar-list is: the same connector, the same sign-in -- which stays in this
9
+ * server (the keeper reveals it to the connector alone), never in the answer, never in the browser. The read is the
10
+ * owner's own in Tether's journal (keeper read, as a mail opened by its reference: mailref.mjs), never an agent's,
11
+ * never asked of anyone. Nothing is kept here.
12
+ *
13
+ * EACH EVENT: { id, title, start, end, allDay, location, organizer, online, attendees, show }. Times are the
14
+ * calendar's wall clock (Europe/Paris, Tether's zone): 'YYYY-MM-DDTHH:MM', or 'YYYY-MM-DD' all day.
15
+ * A Tether that hands its events as data (`data.events`, the same fields) gives them all; one that gives only its
16
+ * text lines (0.1.0-next.67) gives id, start, title and place: the answer says `partial`. */
17
+ import { Refusal } from './conversations.mjs';
18
+
19
+ /* Tether's own zone (connectors/calendar.mjs TZ): its times are said in it. */
20
+ export const ZONE = 'Europe/Paris';
21
+ export const EVENTS_MAX = 200;
22
+ export const DAYS_DEFAULT = 7; /* one week from today: the pages follow each other, no day twice */
23
+ export const DAYS_MAX = 42; /* six weeks at most in one read */
24
+ export const READ_MS = 30_000;
25
+ const TEXT_MAX = 400;
26
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
27
+ const refused = (status, kind, message) => Object.assign(new Refusal(status, message), { kind });
28
+
29
+ /* ---------- days, in the calendar's zone ---------- */
30
+ const partsAt = (ms, zone) => Object.fromEntries(new Intl.DateTimeFormat('en-CA', { timeZone: zone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23' })
31
+ .formatToParts(new Date(ms)).filter((x) => x.type !== 'literal').map((x) => [x.type, Number(x.value)]));
32
+ /* The day it is now there: 'YYYY-MM-DD'. */
33
+ export function todayIn(zone = ZONE, now = Date.now()) {
34
+ const p = partsAt(now, zone);
35
+ return `${p.year}-${String(p.month).padStart(2, '0')}-${String(p.day).padStart(2, '0')}`;
36
+ }
37
+ /* A day plus n days. */
38
+ export function addDays(day, n) {
39
+ const [y, m, d] = day.split('-').map(Number);
40
+ return new Date(Date.UTC(y, m - 1, d + n)).toISOString().slice(0, 10);
41
+ }
42
+ /* The instant a day starts there (its midnight), as an ISO time: a summer or winter hour made right. */
43
+ export function startOf(day, zone = ZONE) {
44
+ const [y, m, d] = day.split('-').map(Number);
45
+ const wall = Date.UTC(y, m - 1, d);
46
+ let at = wall;
47
+ for (let i = 0; i < 2; i++) {
48
+ const p = partsAt(at, zone);
49
+ at -= Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second) - wall;
50
+ }
51
+ return new Date(at).toISOString();
52
+ }
53
+ const isDay = (s) => DAY.test(s) && !Number.isNaN(Date.parse(`${s}T00:00:00Z`)) && new Date(`${s}T00:00:00Z`).toISOString().slice(0, 10) === s;
54
+
55
+ /* The window asked, checked: days, from before to, six weeks at most. */
56
+ export function windowOf({ from, to } = {}, { zone = ZONE, now = Date.now() } = {}) {
57
+ const f = from === undefined || from === null || from === '' ? todayIn(zone, now) : String(from);
58
+ if (!isDay(f)) throw refused(400, 'bad-window', 'The first day is not a date (YYYY-MM-DD).');
59
+ const t = to === undefined || to === null || to === '' ? addDays(f, DAYS_DEFAULT) : String(to);
60
+ if (!isDay(t)) throw refused(400, 'bad-window', 'The last day is not a date (YYYY-MM-DD).');
61
+ const days = (Date.parse(`${t}T00:00:00Z`) - Date.parse(`${f}T00:00:00Z`)) / 86_400_000;
62
+ if (days < 1) throw refused(400, 'bad-window', 'The last day comes before the first.');
63
+ if (days > DAYS_MAX) throw refused(400, 'bad-window', `${DAYS_MAX} days at most at once.`);
64
+ return { from: f, to: t };
65
+ }
66
+
67
+ /* ---------- events ---------- */
68
+ const line = (v, max = TEXT_MAX) => String(v ?? '').replace(/[\r\n\t]+/g, ' ').trim().slice(0, max);
69
+ /* A time as the page reads it: 'YYYY-MM-DDTHH:MM', 'YYYY-MM-DD', or null. */
70
+ const timeOf = (v) => {
71
+ const m = /^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(String(v ?? '').trim());
72
+ return !m ? null : m[2] ? `${m[1]}T${m[2]}:${m[3]}` : m[1];
73
+ };
74
+ /* An online meeting's link: a web address, nothing else (never a script's). */
75
+ const linkOf = (v) => { try { const u = new URL(String(v ?? '')); return u.protocol === 'https:' ? u.href.slice(0, 2000) : null; } catch { return null; } };
76
+ const SHOW = { busy: 'busy', free: 'free', tentative: 'tentative', oof: 'away', away: 'away', workingelsewhere: 'elsewhere', elsewhere: 'elsewhere' };
77
+
78
+ /* One event Tether handed as data, kept to the fields the page shows. */
79
+ export function eventOf(e) {
80
+ const start = timeOf(e?.start);
81
+ if (!start) return null;
82
+ const allDay = e.allDay === true || (start.length === 10 && e.allDay !== false);
83
+ const n = Number(e.attendees);
84
+ return {
85
+ id: line(e.id, 2048), title: line(e.title) || '(no title)', start, end: timeOf(e.end), allDay,
86
+ location: line(e.location), organizer: line(e.organizer, 320), online: linkOf(e.online),
87
+ attendees: Number.isInteger(n) && n >= 0 ? n : null, show: SHOW[String(e.show ?? '').toLowerCase()] ?? null,
88
+ };
89
+ }
90
+
91
+ /* The text lines Tether's calendar-list says (an id, then " start — title @ place [categories]"), read back. */
92
+ export function eventsOfText(text) {
93
+ const out = [];
94
+ const lines = String(text ?? '').split('\n');
95
+ for (let i = 0; i < lines.length; i++) {
96
+ const head = lines[i];
97
+ if (!head || head.startsWith(' ') || head.startsWith('(')) continue;
98
+ const m = /^ {2}(\d{4}-\d{2}-\d{2}(?: \d{2}:\d{2})?) — (.*)$/.exec(lines[i + 1] ?? '');
99
+ if (!m) continue;
100
+ i++;
101
+ const [, title, location] = /^(.*?)(?: {2}@ (.*?))?(?: {2}\[[^\]]*\])?$/.exec(m[2]);
102
+ const id = head.replace(/ {2}\(repeats:.*\)$/, '');
103
+ out.push(eventOf({ id, title, start: m[1], location }));
104
+ }
105
+ return out.filter(Boolean);
106
+ }
107
+
108
+ /* THE AGENDA OF A CALENDAR TARGET, read now. `tethers`: Tethers (tethers.mjs). `who`: { id, name }, said in
109
+ Tether's journal. `wait`: how long the calendar is waited for. */
110
+ export async function readAgenda(tethers, { target, from, to } = {}, { who, zone = ZONE, now = Date.now(), wait = READ_MS } = {}) {
111
+ if (!tethers) throw refused(503, 'unreachable', 'Calendars are not reached from this server.');
112
+ const t = tethers.store().target(String(target ?? ''));
113
+ if (!t || t.kind !== 'calendar') throw refused(404, 'gone', 'No such calendar.');
114
+ const w = windowOf({ from, to }, { zone, now });
115
+ let timer;
116
+ const late = new Promise((resolve) => { timer = setTimeout(() => resolve(null), wait); timer.unref?.(); });
117
+ let got;
118
+ try { got = await Promise.race([tethers.read('calendar.list', { target: t.id, from: startOf(w.from, zone), to: startOf(w.to, zone) }, who), late]); }
119
+ finally { clearTimeout(timer); }
120
+ if (got === null) throw refused(504, 'late', `${t.title} did not answer in time. Try again.`);
121
+ if (!got?.ok) throw refused(502, 'unreachable', `${t.title} could not be read: ${line(got?.text, 300) || 'no answer'}.`);
122
+ const given = Array.isArray(got.data?.events);
123
+ const all = (given ? got.data.events.map(eventOf).filter(Boolean) : eventsOfText(got.text))
124
+ .sort((a, b) => a.start.localeCompare(b.start));
125
+ const more = all.length > EVENTS_MAX || got.data?.more === true || /\(Showing the first \d+ events/.test(String(got.text ?? ''));
126
+ return { target: t.id, title: t.title, zone, from: w.from, to: w.to, events: all.slice(0, EVENTS_MAX), more, partial: !given };
127
+ }
package/server/api.mjs CHANGED
@@ -172,6 +172,7 @@
172
172
  * POST /api/setup/drop {id}: something an import waits for, not wanted after all
173
173
  * GET /api/files/download?c=...&r=...&p=<path> one file
174
174
  * GET /api/mail/open?ref=mail:...&c= GET /api/mail/page?ref=... a mail cited by its reference, read now (mailref.mjs)
175
+ * POST /api/tether/agenda {target, from?, to?}: a calendar's events of a window, read now (agenda.mjs)
175
176
  * POST /api/files/import?c=...&r=...&p=<folder>&name=<file name>[&dir=<subfolders>&exists=keep|replace|skip&batch=<id>] the body IS the file
176
177
  * GET /api/files/thumb|text POST /api/files/save|make|rename|move|remove|taken ?c=...&r=...&p=... (see files.mjs)
177
178
  *
@@ -188,6 +189,7 @@ import { readRights, typeOf, nameOf } from './grants.mjs';
188
189
  import { VmUnknown } from './vm.mjs';
189
190
  import { list, download, importFile, page, PAGE_HEADERS, changeRoute, IMAGE_HEADERS, mailFile, mailPage } from './files.mjs';
190
191
  import { mailRoute } from './mailref.mjs';
192
+ import { readAgenda } from './agenda.mjs';
191
193
  import { WORK_TAB } from './resources.mjs';
192
194
  import { transcribe, AUDIO_MAX } from './voice.mjs';
193
195
  import { FILE_MAX } from './setup.mjs';
@@ -721,6 +723,9 @@ export async function handleApi(request, response, conversations, headers, resou
721
723
  /* A browser taken away: its tokens and its socket go too. */
722
724
  if (tetherOp && tethers && mcpGone?.kind === 'browser') { const r = await tethers.act('remove-target', body, ''); if (!r.ok) throw new Refusal(400, r.text); tethers.browsers?.forget(mcpGone.id); return send(200, r.data ?? { ok: true }), true; }
723
725
  if (tetherOp && tethers) { const r = await tethers.act(tetherOp[1], body, ''); if (!r.ok) throw new Refusal(400, r.text); return send(200, r.data ?? { ok: true }), true; }
726
+ /* A calendar's agenda, read now through Tether as the owner's own read (agenda.mjs, 16-11): seen in its asset
727
+ panel, so the calendar need not stay open elsewhere. A POST, for this site's own pages only (checked above). */
728
+ if (pathname === '/api/tether/agenda' && tethers) return send(200, await readAgenda(tethers, body ?? {}, { who: { id: `person:${identity || 'owner'}`, name: identity || 'Owner' } })), true;
724
729
  /* A mailbox's signature (Markdown), added under what the agent sends from it. */
725
730
  if (pathname === '/api/tether/signature' && tethers) {
726
731
  const t = tethers.store().target(String(body.target ?? ''));
@@ -299,6 +299,14 @@ export const SETTINGS_WORDS_FR = {
299
299
  'set-ml-answers': 'Répond', 'set-ml-last': 'redémarré {t}', 'set-ml-mute': 'Ne répond pas', 'set-ml-asked': 'attend votre accord',
300
300
  'set-ml-force-q': 'Forcer l’arrêt de {name} ? Rien n’est sauvé.',
301
301
  'set-ml-hang': 'S’il bloque', 'set-ml-hang-what': 'Nuit : de 0 h à 7 h', 'set-ml-night': 'La nuit', 'set-ml-always': 'Toujours', 'set-ml-ask': 'Me demander',
302
+ /* A calendar's agenda, in its asset panel (agenda.mjs, 16-11). */
303
+ 'set-ag-title': 'Agenda', 'set-ag-prev': 'Semaine précédente', 'set-ag-next': 'Semaine suivante', 'set-ag-today': 'Aujourd\'hui',
304
+ 'set-ag-now': 'Maintenant', 'set-ag-allday': 'Journée', 'set-ag-reading': 'Lecture…', 'set-ag-again': 'Réessayer',
305
+ 'set-ag-failed': 'Agenda illisible pour le moment.', 'set-ag-none': 'Aucun événement cette semaine', 'set-ag-free-day': 'Rien aujourd\'hui',
306
+ 'set-ag-more': 'Certains événements ne sont pas affichés', 'set-ag-partial': 'Heures de début seules, pour l\'instant',
307
+ 'set-ag-when': 'Quand', 'set-ag-where': 'Où', 'set-ag-link': 'Lien', 'set-ag-join': 'Rejoindre en ligne', 'set-ag-organizer': 'Organisateur',
308
+ 'set-ag-guests': 'Invités', 'set-ag-shown': 'Affiché comme', 'set-ag-show-free': 'Libre', 'set-ag-show-tentative': 'Provisoire',
309
+ 'set-ag-show-away': 'Absent', 'set-ag-show-elsewhere': 'Ailleurs',
302
310
  'set-ml-short': 'Manque de mémoire', 'set-ml-short-what': 'La plus grosse machine', 'set-ml-force': 'Forcer l’arrêt', 'set-ml-sleep': 'Mettre en veille', 'set-ml-alert': 'Alerter seulement',
303
311
  };
304
312
  export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
package/web/app.js CHANGED
@@ -6076,6 +6076,9 @@
6076
6076
  if (share) { share.type = 'button'; share.addEventListener('click', () => { void openCompose([[chosen.key, 'r']]); }); }
6077
6077
  parts.push(KIT.AccessList(model, { key: KIT.rightsKey(chosen), kind: chosen.kind, name: chosen.name, onChange: (row, level, stored) => setAccess(chosen, row, level, stored), actions: [share] }));
6078
6078
  }
6079
+ /* A CALENDAR'S AGENDA (16-11): its events, under who has it -- read through Tether as the owner's own read
6080
+ (agenda.mjs), so the calendar need not stay open elsewhere. The owner's page only: a device reads no calendar. */
6081
+ if (t?.kind === 'calendar' && !DEVICE) parts.push(agendaPart(t));
6079
6082
  /* WHAT IS IN IT. */
6080
6083
  if (copyBox) {
6081
6084
  /* Its files: at once in a conversation; in the menu, a button opens them in the panel (the files sheet, moved in). */
@@ -6185,6 +6188,125 @@
6185
6188
  detail.append(KIT.AssetPanel(card, { back: back ? { onBack: () => { if (!nav.close('asset')) back(); } } : null, parts, foot }));
6186
6189
  if (gitHolder) await gitDetail(gitHolder, chosen.name, { place: inMenu, others: gits.length > 1 });
6187
6190
  }
6191
+ /* THE AGENDA OF A CALENDAR ASSET (16-11): a week, its days, each event's time, title and place; « now » on today;
6192
+ an event opened says its time, place, link and organiser. Read only. Each read is journaled by Tether, which
6193
+ moves its count and paints the panel again: an answer is kept AGENDA_KEEP_MS here, so a paint reads no calendar. */
6194
+ const AGENDA_KEEP_MS = 5 * 60_000;
6195
+ const AGENDA_DAYS = 7; /* one week; the pages follow each other, no day twice */
6196
+ const agendaKept = new Map(); /* `${target}|${from}` -> { at, answer } or { at, pending } */
6197
+ const agendaFrom = new Map(); /* target -> the first day shown, when moved from today */
6198
+ let agendaOpen = ''; /* the event opened, kept across paints */
6199
+ let agendaZone = 'Europe/Paris'; /* the calendar's zone (Tether's), as the server last said it */
6200
+ const dayAdd = (day, n) => { const [y, m, d] = day.split('-').map(Number); return new Date(Date.UTC(y, m - 1, d + n)).toISOString().slice(0, 10); };
6201
+ /* Now, on the calendar's wall clock (its zone, said by the server): 'YYYY-MM-DDTHH:MM'. */
6202
+ const wallNow = (zone) => {
6203
+ try {
6204
+ const p = Object.fromEntries(new Intl.DateTimeFormat('en-CA', { timeZone: zone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' })
6205
+ .formatToParts(new Date()).filter((x) => x.type !== 'literal').map((x) => [x.type, x.value]));
6206
+ return `${p.year}-${p.month}-${p.day}T${p.hour}:${p.minute}`;
6207
+ } catch { return new Date().toISOString().slice(0, 16); }
6208
+ };
6209
+ const dayWords = (day) => new Date(`${day}T12:00:00Z`).toLocaleDateString([], { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' });
6210
+ const hourOf = (time) => (time && time.length > 10 ? time.slice(11, 16) : '');
6211
+ async function agendaRead(target, from, { fresh = false } = {}) {
6212
+ const key = `${target}|${from}`;
6213
+ const kept = agendaKept.get(key);
6214
+ if (kept && !fresh && (kept.pending || Date.now() - kept.at < AGENDA_KEEP_MS)) return kept.pending ?? kept.answer;
6215
+ const pending = post(`${API}/tether/agenda`, { target, from, to: dayAdd(from, AGENDA_DAYS) })
6216
+ .then((answer) => { agendaKept.set(key, { at: Date.now(), answer }); return answer; })
6217
+ .catch((error) => { agendaKept.delete(key); return { error: error.message || uiSaid('set-ag-failed', 'The calendar could not be read.') }; });
6218
+ agendaKept.set(key, { at: Date.now(), pending });
6219
+ return pending;
6220
+ }
6221
+ function agendaEvent(ev) {
6222
+ const box = el('details', 'ag-event'); box.dataset.show = ev.show ?? 'busy';
6223
+ if (agendaOpen === ev.id) box.open = true;
6224
+ box.addEventListener('toggle', () => { if (box.open) agendaOpen = ev.id; else if (agendaOpen === ev.id) agendaOpen = ''; });
6225
+ const head = el('summary', 'ag-row');
6226
+ head.append(el('span', 'ag-time', ev.allDay ? uiSaid('set-ag-allday', 'All day') : hourOf(ev.start)));
6227
+ const what = el('span', 'ag-what'); what.append(el('span', 'ag-title', ev.title));
6228
+ if (ev.location) what.append(el('span', 'ag-where hint', ev.location));
6229
+ head.append(what);
6230
+ const facts = el('dl', 'ag-facts');
6231
+ const fact = (k, v) => { if (!v) return; facts.append(el('dt', '', k)); const dd = el('dd'); dd.append(v); facts.append(dd); };
6232
+ const when = ev.allDay ? uiSaid('set-ag-allday', 'All day') : `${hourOf(ev.start)}${ev.end ? ` – ${ev.end.slice(0, 10) === ev.start.slice(0, 10) ? hourOf(ev.end) : `${dayWords(ev.end.slice(0, 10))} ${hourOf(ev.end)}`}` : ''}`;
6233
+ fact(uiSaid('set-ag-when', 'When'), document.createTextNode(`${dayWords(ev.start.slice(0, 10))}, ${when}`));
6234
+ fact(uiSaid('set-ag-where', 'Where'), ev.location ? document.createTextNode(ev.location) : null);
6235
+ if (ev.online) { const a = el('a', '', uiSaid('set-ag-join', 'Join online')); a.href = ev.online; a.target = '_blank'; a.rel = 'noopener noreferrer'; fact(uiSaid('set-ag-link', 'Link'), a); }
6236
+ fact(uiSaid('set-ag-organizer', 'Organizer'), ev.organizer ? document.createTextNode(ev.organizer) : null);
6237
+ if (Number.isInteger(ev.attendees) && ev.attendees > 0) fact(uiSaid('set-ag-guests', 'Guests'), document.createTextNode(String(ev.attendees)));
6238
+ if (ev.show && ev.show !== 'busy') fact(uiSaid('set-ag-shown', 'Shown as'), document.createTextNode(uiSaid(`set-ag-show-${ev.show}`, { free: 'Free', tentative: 'Tentative', away: 'Away', elsewhere: 'Elsewhere' }[ev.show] ?? ev.show)));
6239
+ box.append(head, facts);
6240
+ return box;
6241
+ }
6242
+ /* The days of an answer, each with its events; an event of several days on each of them; today always, with « now ». */
6243
+ function agendaDays(holder, answer) {
6244
+ if (answer.zone) agendaZone = answer.zone;
6245
+ const now = wallNow(agendaZone); const today = now.slice(0, 10);
6246
+ const days = new Map();
6247
+ for (let d = answer.from; d < answer.to; d = dayAdd(d, 1)) days.set(d, []);
6248
+ for (const ev of answer.events ?? []) {
6249
+ const first = ev.start.slice(0, 10);
6250
+ /* An all-day event ends the day after its last: it shows on each of its days in the window. */
6251
+ const last = ev.allDay && ev.end ? dayAdd(ev.end.slice(0, 10), -1) : first;
6252
+ for (let d = first; d <= last && d < answer.to; d = dayAdd(d, 1)) if (days.has(d)) days.get(d).push(ev);
6253
+ }
6254
+ const list = el('div', 'ag-days');
6255
+ for (const [day, evs] of days) {
6256
+ if (!evs.length && day !== today) continue;
6257
+ const group = el('section', 'ag-day'); if (day === today) group.dataset.today = '1';
6258
+ const head = el('h4', 'ag-dayhead', dayWords(day));
6259
+ if (day === today) head.append(el('span', 'tag', uiSaid('set-ag-today', 'Today')));
6260
+ group.append(head);
6261
+ const timed = evs.filter((e) => !e.allDay); const whole = evs.filter((e) => e.allDay);
6262
+ for (const ev of whole) group.append(agendaEvent(ev));
6263
+ let marked = day !== today;
6264
+ for (const ev of timed) {
6265
+ if (!marked && ev.start > now) { group.append(el('div', 'ag-now', uiSaid('set-ag-now', 'Now'))); marked = true; }
6266
+ group.append(agendaEvent(ev));
6267
+ }
6268
+ if (!marked) group.append(el('div', 'ag-now', uiSaid('set-ag-now', 'Now')));
6269
+ if (!evs.length) group.append(el('p', 'hint', uiSaid('set-ag-free-day', 'Nothing today')));
6270
+ list.append(group);
6271
+ }
6272
+ const shown = el('p', 'hint ag-range', `${dayWords(answer.from)} – ${dayWords(dayAdd(answer.to, -1))}`);
6273
+ const notes = [];
6274
+ if (!(answer.events ?? []).length) notes.push(el('p', 'hint', uiSaid('set-ag-none', 'No event this week')));
6275
+ if (answer.more) notes.push(el('p', 'hint', uiSaid('set-ag-more', 'Some events not shown')));
6276
+ if (answer.partial) notes.push(el('p', 'hint', uiSaid('set-ag-partial', 'Start times only, for now')));
6277
+ holder.replaceChildren(shown, list, ...notes);
6278
+ }
6279
+ async function agendaFill(holder, target, opts) {
6280
+ const from = agendaFrom.get(target) ?? wallNow(agendaZone).slice(0, 10);
6281
+ holder.setAttribute('aria-busy', 'true');
6282
+ if (!holder.childElementCount) holder.append(el('p', 'hint', uiSaid('set-ag-reading', 'Reading…')));
6283
+ const answer = await agendaRead(target, from, opts);
6284
+ holder.removeAttribute('aria-busy');
6285
+ if (!holder.isConnected) return;
6286
+ if (answer.error) {
6287
+ const again = el('button', '', uiSaid('set-ag-again', 'Try again')); again.type = 'button';
6288
+ again.addEventListener('click', () => { void agendaFill(holder, target, { fresh: true }); });
6289
+ holder.replaceChildren(el('p', 'error', answer.error), again);
6290
+ return;
6291
+ }
6292
+ agendaDays(holder, answer);
6293
+ }
6294
+ function agendaPart(target) {
6295
+ const holder = el('div', 'as-agenda');
6296
+ const move = (days) => {
6297
+ const from = agendaFrom.get(target.id) ?? wallNow(agendaZone).slice(0, 10);
6298
+ agendaFrom.set(target.id, dayAdd(from, days));
6299
+ void agendaFill(holder, target.id);
6300
+ };
6301
+ const btn = (text, label, act) => { const b = el('button', 'quiet', text); b.type = 'button'; b.setAttribute('aria-label', label); b.title = label; b.addEventListener('click', act); return b; };
6302
+ const prev = btn('‹', uiSaid('set-ag-prev', 'Previous week'), () => move(-7));
6303
+ /* Today: back to this week; already there, read again. */
6304
+ const today = btn(uiSaid('set-ag-today', 'Today'), uiSaid('set-ag-today', 'Today'), () => { const was = agendaFrom.has(target.id); agendaFrom.delete(target.id); void agendaFill(holder, target.id, { fresh: !was }); });
6305
+ const next = btn('›', uiSaid('set-ag-next', 'Next week'), () => move(7));
6306
+ const bar = el('div', 'ag-bar'); bar.append(prev, today, next);
6307
+ queueMicrotask(() => { void agendaFill(holder, target.id); });
6308
+ return { title: uiSaid('set-ag-title', 'Agenda'), extra: [bar], body: [holder], cls: 'as-agenda-part' };
6309
+ }
6188
6310
  const ASSET_WORD = { folder: 'Folder', git: 'Repository', mailbox: 'Mailbox', agenda: 'Calendar', contacts: 'Contacts', secret: 'Secret', list: LISTS_WORD.one, acces: 'Access' };
6189
6311
  /* Under its name: its kind (its group, a chip before it, in the menu). */
6190
6312
  function chipsOf(chosen) {
package/web/style.css CHANGED
@@ -1254,6 +1254,41 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
1254
1254
  .as-settings dt { color: var(--ink2); padding-right: 16px; }
1255
1255
  .as-settings dd { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
1256
1256
  .as-settings dt:nth-last-of-type(1), .as-settings dd:last-of-type { border-bottom: 0; }
1257
+ /* A CALENDAR'S AGENDA (16-11, app.js agendaPart): its week, day by day; an event opened shows its facts. Read only. */
1258
+ .ag-bar { display: flex; gap: 4px; }
1259
+ .ag-bar button { padding: 4px 10px; }
1260
+ .as-agenda { display: flex; flex-direction: column; gap: 6px; }
1261
+ .as-agenda[aria-busy="true"] .ag-days { opacity: .6; }
1262
+ .ag-days { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bar); padding: 8px 12px; }
1263
+ .ag-day { display: flex; flex-direction: column; gap: 2px; }
1264
+ .ag-dayhead { display: flex; align-items: center; gap: 8px; margin: 0 0 2px; font-size: .8125rem; color: var(--ink2); text-transform: capitalize; }
1265
+ .ag-day[data-today] .ag-dayhead { color: var(--ink); }
1266
+ .ag-event { border-radius: 6px; }
1267
+ .ag-event[open] { background: var(--panel); }
1268
+ .ag-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 5px 6px; cursor: pointer; list-style: none; border-radius: 6px; }
1269
+ .ag-row::-webkit-details-marker { display: none; }
1270
+ /* The panels' own details (#assets, #panel) give a summary a button's look and a "+ ": not an event's row. */
1271
+ #assets .ag-event > summary.ag-row, #panel .ag-event > summary.ag-row, .ag-event > summary.ag-row { display: grid; padding: 5px 6px; border: 0; background: none; font-weight: inherit; align-self: stretch; min-height: 0; }
1272
+ #assets .ag-event > summary.ag-row::before, #panel .ag-event > summary.ag-row::before, .ag-event > summary.ag-row::before { content: none; }
1273
+ .ag-row:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
1274
+ .ag-row:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
1275
+ .ag-time { font-variant-numeric: tabular-nums; color: var(--ink2); font-size: .8125rem; white-space: nowrap; }
1276
+ .ag-what { display: flex; flex-direction: column; min-width: 0; }
1277
+ .ag-title { font-weight: 600; overflow-wrap: anywhere; }
1278
+ .ag-where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1279
+ .ag-event[data-show="tentative"] .ag-title { font-style: italic; }
1280
+ .ag-event[data-show="free"] .ag-title { font-weight: 400; color: var(--ink2); }
1281
+ .ag-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; padding: 4px 6px 8px calc(4.5em + 14px); font-size: .8125rem; }
1282
+ .ag-facts dt { color: var(--ink2); }
1283
+ .ag-facts dd { margin: 0; overflow-wrap: anywhere; }
1284
+ .ag-facts a { color: var(--brass-ink); }
1285
+ .ag-now { display: flex; align-items: center; gap: 6px; color: var(--brass-ink); font-size: .6875rem; font-weight: 600; text-transform: uppercase; }
1286
+ .ag-now::after { content: ""; flex: 1; border-top: 1.5px solid var(--brass-ink); }
1287
+ @media (max-width: 600px) {
1288
+ .ag-days { padding: 6px 8px; }
1289
+ .ag-row { grid-template-columns: 3.8em minmax(0, 1fr); gap: 6px; }
1290
+ .ag-facts { padding-left: 6px; }
1291
+ }
1257
1292
  .as-foot { margin-top: 10px; }
1258
1293
  .as-form { display: flex; flex-direction: column; gap: 8px; }
1259
1294
  .as-form h3 { margin: 0; font-size: 1.125rem; }