jsdoc typing round, phases 3-4: the clerk (tool/memory.mjs) and the SPA (web/) typed under strict -- row shapes local to their owners (the clerk's five tables in its header; the SPA's response envelopes in the new web/shapes.mjs, the server's shared shapes imported at their use sites: User, LogEvent, JobState, HttpError); the db boundary cast at every .get()/.all(), fail as @returns {never} so guard-narrowing works; web via a second tsconfig (tsconfig.web.json: DOM libs in their own program, node types riding along because shapes.mjs's Provider typedef pulls provider.mjs in), npm run typecheck runs both; every non-annotation delta audited onto a small intended list (COUNT(*) Number() wraps, impossible-path guards, ?? ''/?? undefined null-absorbers, the RewordOp reason fix -- the validator demands it, the reminder-find naming its tag); smoke 110/110 + restart + reminder + repo checks + a zero-console-error browser pass green; the typing round is complete
This commit is contained in:
+13
-2
@@ -8,9 +8,15 @@
|
||||
// delta tags on player turns are machinery, not prose -- they render
|
||||
// as chips and pane state, mirroring the live-context policy.
|
||||
|
||||
/** @typedef {import('../server/shapes.mjs').LogEvent} LogEvent */
|
||||
/** @typedef {import('../server/shapes.mjs').BundleEvent} BundleEvent */
|
||||
/** @typedef {import('../server/shapes.mjs').MsgEvent} MsgEvent */
|
||||
/** @typedef {import('../server/shapes.mjs').NoteEvent} NoteEvent */
|
||||
|
||||
import { $, el } from './dom.mjs';
|
||||
|
||||
// splits text into spans: *italics* = narration, **bold** = emphasis
|
||||
/** @param {HTMLElement} target @param {string} text */
|
||||
function renderSpans(target, text) {
|
||||
const parts = String(text).split(/(\*\*[^*]+\*\*|\*[^*\n]+\*)/g);
|
||||
for (const p of parts) {
|
||||
@@ -34,6 +40,7 @@ function renderSpans(target, text) {
|
||||
// the riding blocks (status/conflict/agenda) out of GM prose; the
|
||||
// delta tags on player turns always render as chips. Exported for
|
||||
// the story view, which renders the same registers.
|
||||
/** @param {HTMLElement} target @param {?string} text @param {{ extract?: boolean }} opts @returns {{ status: ?string, conflict: ?string, agenda: ?string }} */
|
||||
export function renderContent(target, text, { extract }) {
|
||||
let body = String(text ?? '');
|
||||
let status = null;
|
||||
@@ -128,10 +135,11 @@ export function renderContent(target, text, { extract }) {
|
||||
// turn -- the play view owns where it lands (the status pane). The
|
||||
// opening event (her opening status) renders as machinery, mirroring
|
||||
// the wire policy: it is set once, never re-sent.
|
||||
/** @param {LogEvent[]} entries @param {{ onConflict?: (text: string) => void }} [opts] */
|
||||
export function renderTranscript(entries, { onConflict } = {}) {
|
||||
const t = $('transcript');
|
||||
t.textContent = '';
|
||||
const bundleParts = [];
|
||||
/** @type {BundleEvent[]} */ const bundleParts = [];
|
||||
const flushBundle = () => {
|
||||
if (!bundleParts.length) return;
|
||||
const d = el('details', 'bundle');
|
||||
@@ -158,7 +166,7 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
// the turn reminder: the transcript mirrors the live-context
|
||||
// policy -- one collapsed card for the newest copy, superseded
|
||||
// ones elide (the log keeps every as-sent chunk)
|
||||
const newest = [...entries].reverse().find((x) => x.reminder);
|
||||
const newest = [...entries].reverse().find((x) => x.t === 'msg' && x.reminder);
|
||||
if (e === newest) {
|
||||
const d = el('details', 'bundle');
|
||||
d.appendChild(el('summary', null, 'turn reminder -- rides every GM turn'));
|
||||
@@ -190,6 +198,7 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
flushBundle();
|
||||
t.scrollTop = t.scrollHeight;
|
||||
|
||||
/** @param {?string} content @param {string} who */
|
||||
function gmTurn(content, who) {
|
||||
const d = el('div', 'turn gm');
|
||||
d.appendChild(el('div', 'who', who));
|
||||
@@ -199,6 +208,7 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
if (conflict) onConflict?.(conflict);
|
||||
t.appendChild(d);
|
||||
}
|
||||
/** @param {MsgEvent} e */
|
||||
function playerTurn(e) {
|
||||
const d = el('div', 'turn player');
|
||||
d.appendChild(el('div', 'who', 'player'));
|
||||
@@ -210,6 +220,7 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
}
|
||||
t.appendChild(d);
|
||||
}
|
||||
/** @param {NoteEvent} e */
|
||||
function renderNote(e) {
|
||||
let text = null;
|
||||
if (e.kind === 'session') text = `session ${e.n} opened`;
|
||||
|
||||
Reference in New Issue
Block a user