visualproof 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/dist/assets/tips/tour-library.webp +0 -0
- package/dist/assets/tips/tour-source.webp +0 -0
- package/dist/assets/tips/tour.json +90 -90
- package/dist/extractor/Extract.lean +34 -11
- package/dist/mcp/visualproof-mcp.mjs +30 -5
- package/dist/server/agent.js +19 -7
- package/dist/server/agententry.js +13 -6
- package/dist/server/agentexport.js +2 -1
- package/dist/server/agentfollow.js +13 -3
- package/dist/server/agentlean.js +91 -1
- package/dist/server/agentnotes.js +6 -4
- package/dist/server/agentread.js +33 -1
- package/dist/server/app.js +7 -3
- package/dist/server/appagent.js +1 -1
- package/dist/server/appgraph.js +24 -0
- package/dist/server/appshare.js +119 -1
- package/dist/server/apptalk.js +26 -0
- package/dist/server/boardspots.js +1 -1
- package/dist/server/children.js +6 -2
- package/dist/server/claudetokens.js +113 -0
- package/dist/server/doctor.js +7 -0
- package/dist/server/goals.js +224 -0
- package/dist/server/hosted.js +480 -0
- package/dist/server/hover.js +281 -8
- package/dist/server/live.js +34 -2
- package/dist/server/main.js +30 -2
- package/dist/server/mcptools.js +15 -7
- package/dist/server/options.js +30 -2
- package/dist/server/presence.js +2 -2
- package/dist/server/prompt.js +25 -0
- package/dist/server/readonlygate.js +2 -1
- package/dist/server/reviewapi.js +5 -2
- package/dist/server/status.js +43 -5
- package/dist/server/tokens.js +7 -4
- package/dist/shared/build.js +9 -0
- package/dist/shared/collab.js +17 -2
- package/dist/shared/declfind.js +23 -3
- package/dist/shared/goals.js +309 -0
- package/dist/shared/hygiene.js +18 -0
- package/dist/shared/noteplace.js +45 -19
- package/dist/shared/scope.js +74 -45
- package/dist/shared/sharesnap.js +4 -2
- package/dist/web/bundle/app.js +2368 -591
- package/dist/web/index.html +2 -1
- package/dist/web/src/highlight.js +53 -3
- package/dist/web/style.css +151 -0
- package/docs/agent-api/README.md +1 -1
- package/docs/agent-api/mcp.md +4 -2
- package/docs/agent-api/notes.md +3 -2
- package/docs/agent-api/reading.md +38 -2
- package/docs/agent-api/talking.md +7 -0
- package/docs/agent-api/words.md +3 -2
- package/package.json +1 -1
package/dist/web/bundle/app.js
CHANGED
|
@@ -221,9 +221,15 @@ function cleanView(v2) {
|
|
|
221
221
|
const activity = av && typeof av.open === "boolean" && kind && who ? { open: av.open, kind, who, ...typeof av.mine === "string" && validName(av.mine) ? { mine: av.mine } : {} } : null;
|
|
222
222
|
const lost = o2.lostFound && typeof o2.lostFound === "object" ? o2.lostFound.open : void 0;
|
|
223
223
|
const scheme = one2(BOARD_SCHEMES, o2.scheme);
|
|
224
|
+
const cv = o2.caret && typeof o2.caret === "object" ? o2.caret : null;
|
|
225
|
+
const place2 = (n3, max) => Number.isInteger(n3) && n3 >= 0 && n3 <= max;
|
|
226
|
+
const caretDecl = cv ? str2(cv.decl) : null;
|
|
227
|
+
const caret = cv && caretDecl && place2(cv.line, 1e7) && place2(cv.character, 1e5) ? { decl: caretDecl, line: cv.line, character: cv.character, ...cv.after === true ? { after: true } : {}, ...cv.pinned === true ? { pinned: true } : {} } : null;
|
|
224
228
|
const pinned = Array.isArray(o2.pinned) ? o2.pinned.slice(0, MAX_PINNED).map((w2) => {
|
|
225
|
-
const
|
|
226
|
-
|
|
229
|
+
const x2 = w2 && typeof w2 === "object" ? w2 : null;
|
|
230
|
+
const decl = x2 ? str2(x2.decl) : null, file = x2 && !decl ? str2(x2.file, 300) : null;
|
|
231
|
+
if (decl) return { decl, collapsed: x2.collapsed === true, ...x2.mode === "file" ? { mode: "file" } : {} };
|
|
232
|
+
return file ? { file, collapsed: x2.collapsed === true } : null;
|
|
227
233
|
}).filter((w2) => w2 !== null) : [];
|
|
228
234
|
return {
|
|
229
235
|
mode: str2(o2.mode, 16) ?? "tcb",
|
|
@@ -231,6 +237,7 @@ function cleanView(v2) {
|
|
|
231
237
|
...selection !== null ? { selection } : {},
|
|
232
238
|
source,
|
|
233
239
|
...source && o2.sourceCollapsed === true ? { sourceCollapsed: true } : {},
|
|
240
|
+
...source && o2.sourceMode === "file" ? { sourceMode: "file" } : {},
|
|
234
241
|
...pinned.length ? { pinned } : {},
|
|
235
242
|
clusterMode: str2(o2.clusterMode, 16) ?? "namespace",
|
|
236
243
|
cam: cx !== null && cy !== null && ck !== null ? { x: cx, y: cy, k: ck } : null,
|
|
@@ -242,6 +249,7 @@ function cleanView(v2) {
|
|
|
242
249
|
...o2.focus === null || str2(o2.focus) ? { focus: o2.focus } : {},
|
|
243
250
|
...visitors.length ? { visitors } : {},
|
|
244
251
|
...paper ? { paper } : {},
|
|
252
|
+
...caret ? { caret } : {},
|
|
245
253
|
...activity ? { activity } : {},
|
|
246
254
|
...typeof lost === "boolean" ? { lostFound: { open: lost } } : {},
|
|
247
255
|
...scheme ? { scheme } : {},
|
|
@@ -2645,9 +2653,9 @@ function defaultLabel(place2, type) {
|
|
|
2645
2653
|
function wordsText(words, lines) {
|
|
2646
2654
|
let text2 = "";
|
|
2647
2655
|
const starts = [];
|
|
2648
|
-
const
|
|
2656
|
+
const lineStart2 = new Set(lines);
|
|
2649
2657
|
words.forEach((w2, k2) => {
|
|
2650
|
-
if (k2 > 0) text2 +=
|
|
2658
|
+
if (k2 > 0) text2 += lineStart2.has(k2) ? "\n" : " ";
|
|
2651
2659
|
starts.push(text2.length);
|
|
2652
2660
|
text2 += w2[0];
|
|
2653
2661
|
});
|
|
@@ -5332,6 +5340,9 @@ function snapshotSource(info2) {
|
|
|
5332
5340
|
shareAgent: async () => ({ error: "a snapshot has no server to share with an agent" }),
|
|
5333
5341
|
agentPrompt: async () => ({ error: "a snapshot has no server" }),
|
|
5334
5342
|
revokeAgent: async () => ({ error: "a snapshot has no server" }),
|
|
5343
|
+
giveClaude: async () => ({ error: "a snapshot has no server" }),
|
|
5344
|
+
removeClaude: async () => ({ error: "a snapshot has no server" }),
|
|
5345
|
+
stopAgent: async () => ({ error: "a snapshot has no server" }),
|
|
5335
5346
|
setIdentity: async () => ({ error: "a snapshot has no server" }),
|
|
5336
5347
|
invites: async () => null,
|
|
5337
5348
|
invite: async () => ({ error: "a snapshot has no server to invite anyone to" }),
|
|
@@ -5351,6 +5362,8 @@ function snapshotSource(info2) {
|
|
|
5351
5362
|
hover: async () => null,
|
|
5352
5363
|
hoverOpen: () => {
|
|
5353
5364
|
},
|
|
5365
|
+
goals: async () => null,
|
|
5366
|
+
subterm: async () => null,
|
|
5354
5367
|
names: async () => null,
|
|
5355
5368
|
describe: async () => null,
|
|
5356
5369
|
print: async () => null,
|
|
@@ -5395,6 +5408,8 @@ function serverSource() {
|
|
|
5395
5408
|
hover: (module, line, character, hash) => fetch(`/api/hover?module=${encodeURIComponent(module)}&line=${line}&character=${character}&hash=${hash}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5396
5409
|
hoverOpen: (module) => void fetch(`/api/hover/open?module=${encodeURIComponent(module)}`, { method: "POST" }).catch(() => {
|
|
5397
5410
|
}),
|
|
5411
|
+
goals: (module, line, character, hash) => fetch(`/api/hover/goals?module=${encodeURIComponent(module)}&line=${line}&character=${character}&hash=${hash}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5412
|
+
subterm: (module, line, character, hash, k2) => fetch(`/api/hover/goals/info?module=${encodeURIComponent(module)}&line=${line}&character=${character}&hash=${hash}&k=${k2}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5398
5413
|
describe: (module, name) => fetch(`/api/hover/describe?module=${encodeURIComponent(module)}&name=${encodeURIComponent(name)}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5399
5414
|
print: (module, name) => fetch(`/api/hover/print?module=${encodeURIComponent(module)}&name=${encodeURIComponent(name)}`).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5400
5415
|
names: (module, positions, hash) => fetch(`/api/hover/names?module=${encodeURIComponent(module)}&hash=${hash}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(positions) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
@@ -5419,10 +5434,14 @@ function serverSource() {
|
|
|
5419
5434
|
updates: () => fetch("/api/updates").then((r2) => r2.ok ? r2.json() : null).then((b2) => b2 && typeof b2.running === "string" ? b2 : null).catch(() => null),
|
|
5420
5435
|
tipClips: () => fetch("/tips/index.json").then((r2) => r2.ok ? r2.json() : null).then((b2) => new Set(Array.isArray(b2?.clips) ? b2.clips.filter((c3) => typeof c3 === "string") : [])).catch(() => /* @__PURE__ */ new Set()),
|
|
5421
5436
|
tourJson: () => fetch("/tips/tour.json").then((r2) => r2.ok ? r2.json() : null).catch(() => null),
|
|
5422
|
-
|
|
5437
|
+
// with the reader's name: whether they gave a Claude token is told under it
|
|
5438
|
+
agentShares: () => fetch("/api/share/agents", { headers: headers() }).then((r2) => r2.ok ? r2.json() : null).catch(() => null),
|
|
5423
5439
|
shareAgent: (body) => fetch("/api/share/agents", { method: "POST", headers: headers(), body: JSON.stringify(body) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5424
5440
|
agentPrompt: (id) => fetch("/api/share/agents/prompt", { method: "POST", headers: headers(), body: JSON.stringify({ id }) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5425
5441
|
revokeAgent: (id) => fetch("/api/share/agents/revoke", { method: "POST", headers: headers(), body: JSON.stringify({ id }) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5442
|
+
giveClaude: (token) => fetch("/api/share/claude", { method: "POST", headers: headers(), body: JSON.stringify({ token }) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5443
|
+
removeClaude: () => fetch("/api/share/claude/remove", { method: "POST", headers: headers(), body: "{}" }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5444
|
+
stopAgent: (agent) => fetch("/api/chat/stop", { method: "POST", headers: headers(), body: JSON.stringify({ agent }) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
5426
5445
|
chat: (channel, before) => fetch(`/api/chat?channel=${encodeURIComponent(channel)}${before ? `&before=${before}` : ""}`, { headers: headers() }).then((r2) => r2.ok ? r2.json() : null).catch(() => null),
|
|
5427
5446
|
// a private reader's message says who wrote it, not where they are (CollabSpec decision 8)
|
|
5428
5447
|
sendChat: (channel, text2, place2) => fetch("/api/chat", { method: "POST", headers: headers(), body: JSON.stringify({ channel, text: text2, place: src.privateSession ? null : place2 }) }).then((r2) => r2.json()).catch(() => ({ error: "the server could not be reached" })),
|
|
@@ -5822,15 +5841,52 @@ function tokenHtml(t2, isRef) {
|
|
|
5822
5841
|
}
|
|
5823
5842
|
}
|
|
5824
5843
|
var HANG_MAX = 24;
|
|
5825
|
-
function highlightLines(src, isRef, first) {
|
|
5844
|
+
function highlightLines(src, isRef, first, decor) {
|
|
5826
5845
|
const lines = tokenLines(tokenizeLean(src));
|
|
5846
|
+
const folds = decor?.folds ?? [];
|
|
5847
|
+
let ls = 0;
|
|
5827
5848
|
return src.split("\n").map((text2, k2) => {
|
|
5828
5849
|
const indent = Math.min(/^ */.exec(text2)[0].length, HANG_MAX);
|
|
5829
|
-
const
|
|
5850
|
+
const start = ls;
|
|
5851
|
+
ls += text2.length + 1;
|
|
5852
|
+
const own2 = decor?.line?.(k2);
|
|
5853
|
+
const tokens2 = lines[k2] ?? [];
|
|
5854
|
+
const html = folds.length ? foldedHtml(src, tokens2, start, start + text2.length, folds, isRef) : { html: tokens2.map((t2) => tokenHtml(t2, isRef)).join(""), hidden: null };
|
|
5830
5855
|
const n3 = first !== void 0 ? ` data-n="${first + k2}"` : "";
|
|
5831
|
-
|
|
5856
|
+
const pf = html.hidden !== null ? ` data-pf="${html.hidden}"` : "";
|
|
5857
|
+
return `<span class="ln${own2?.cls ?? ""}${html.hidden !== null ? " pf-l" : ""}"${n3}${pf} style="--in:${indent}">${own2?.lead ?? ""}${html.html}${k2 < lines.length - 1 ? "\n" : ""}</span>`;
|
|
5832
5858
|
}).join("");
|
|
5833
5859
|
}
|
|
5860
|
+
function foldedHtml(src, tokens2, start, end, folds, isRef) {
|
|
5861
|
+
const over = folds.find((f2) => f2.from < start && f2.to > start);
|
|
5862
|
+
const hidden = over && (over.to >= end || !src.slice(over.to, end).trim()) ? over.id : null;
|
|
5863
|
+
const out = [];
|
|
5864
|
+
let open = null;
|
|
5865
|
+
const close = () => {
|
|
5866
|
+
if (open !== null) out.push("</span>");
|
|
5867
|
+
open = null;
|
|
5868
|
+
};
|
|
5869
|
+
for (const t2 of tokens2) {
|
|
5870
|
+
let p2 = t2.at;
|
|
5871
|
+
const e2 = t2.at + t2.text.length;
|
|
5872
|
+
while (p2 < e2) {
|
|
5873
|
+
const f2 = folds.find((x2) => x2.from <= p2 && p2 < x2.to);
|
|
5874
|
+
const next = f2 ? Math.min(e2, f2.to) : Math.min(e2, ...folds.filter((x2) => x2.from > p2).map((x2) => x2.from));
|
|
5875
|
+
if (f2 && open !== f2.id) {
|
|
5876
|
+
close();
|
|
5877
|
+
if (p2 === f2.from) out.push(`<button type="button" class="pf-mark" data-pf-open="${escapeHtml(f2.id)}" title="Show this proof" aria-label="Show this proof"></button>`);
|
|
5878
|
+
out.push(`<span class="pf-t" data-pf="${escapeHtml(f2.id)}">`);
|
|
5879
|
+
open = f2.id;
|
|
5880
|
+
} else if (!f2) close();
|
|
5881
|
+
out.push(tokenHtml(p2 === t2.at && next === e2 ? t2 : { ...t2, at: p2, text: src.slice(p2, next) }, isRef));
|
|
5882
|
+
p2 = next;
|
|
5883
|
+
}
|
|
5884
|
+
}
|
|
5885
|
+
close();
|
|
5886
|
+
const at = folds.find((f2) => f2.from === end && f2.to > end);
|
|
5887
|
+
if (at && !hidden) out.push(`<button type="button" class="pf-mark" data-pf-open="${escapeHtml(at.id)}" title="Show this proof" aria-label="Show this proof"></button>`);
|
|
5888
|
+
return { html: out.join(""), hidden };
|
|
5889
|
+
}
|
|
5834
5890
|
function renderHover(md, isRef) {
|
|
5835
5891
|
let html = "";
|
|
5836
5892
|
let at = 0;
|
|
@@ -6289,7 +6345,7 @@ var FocusMenu = class {
|
|
|
6289
6345
|
};
|
|
6290
6346
|
|
|
6291
6347
|
// src/web/src/reload.ts
|
|
6292
|
-
var PAGE_VERSION = true ? "0.
|
|
6348
|
+
var PAGE_VERSION = true ? "0.10.0" : null;
|
|
6293
6349
|
var KEY = "visualproof:reload";
|
|
6294
6350
|
var FOR_KEY = "visualproof:reloaded-for";
|
|
6295
6351
|
var FRESH_MS = 10 * 6e4;
|
|
@@ -6309,7 +6365,12 @@ function keep(k2, storage = session()) {
|
|
|
6309
6365
|
var pairs = (x2, ok) => Array.isArray(x2) ? x2.filter((p2) => Array.isArray(p2) && p2.length === 2 && typeof p2[0] === "string" && ok(p2[1])) : [];
|
|
6310
6366
|
var isString = (v2) => typeof v2 === "string";
|
|
6311
6367
|
var isBool = (v2) => typeof v2 === "boolean";
|
|
6312
|
-
var win = (v2) =>
|
|
6368
|
+
var win = (v2) => {
|
|
6369
|
+
if (!v2 || typeof v2 !== "object") return null;
|
|
6370
|
+
const o2 = v2;
|
|
6371
|
+
if (typeof o2.name === "string") return { name: o2.name, collapsed: o2.collapsed === true, ...o2.mode === "file" ? { mode: "file" } : {} };
|
|
6372
|
+
return typeof o2.file === "string" ? { file: o2.file, collapsed: o2.collapsed === true } : null;
|
|
6373
|
+
};
|
|
6313
6374
|
function takeKept(root, now = Date.now(), storage = session()) {
|
|
6314
6375
|
let raw = null;
|
|
6315
6376
|
try {
|
|
@@ -6323,7 +6384,8 @@ function takeKept(root, now = Date.now(), storage = session()) {
|
|
|
6323
6384
|
const k2 = JSON.parse(raw);
|
|
6324
6385
|
if (k2.root !== root || typeof k2.at !== "number" || now - k2.at > FRESH_MS || now < k2.at) return null;
|
|
6325
6386
|
const pinned = Array.isArray(k2.sources?.pinned) ? k2.sources.pinned.map(win).filter((w2) => w2 !== null) : [];
|
|
6326
|
-
|
|
6387
|
+
const f2 = win(k2.sources?.following);
|
|
6388
|
+
return { root, at: k2.at, sources: { following: f2 && "name" in f2 ? f2 : null, pinned }, review: pairs(k2.review, isString), talk: pairs(k2.talk, isString), notes: pairs(k2.notes, isBool) };
|
|
6327
6389
|
} catch {
|
|
6328
6390
|
return null;
|
|
6329
6391
|
}
|
|
@@ -6414,6 +6476,608 @@ var Reloader = class {
|
|
|
6414
6476
|
}
|
|
6415
6477
|
};
|
|
6416
6478
|
|
|
6479
|
+
// src/shared/excerpt.ts
|
|
6480
|
+
var DECL = /^\s*(?:@\[[^\]]*\]\s*)*(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def)\s+(\S+)/;
|
|
6481
|
+
var NEXT = /^(?:@\[|\/--|\/-!|--|#|(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def|namespace|section|end|open|variable|universe|attribute|set_option|mutual|macro|syntax|notation|infix|infixl|infixr|prefix|postfix|elab|deriving)\b)/;
|
|
6482
|
+
function withPreamble(lines, line) {
|
|
6483
|
+
let start = line;
|
|
6484
|
+
while (start > 0 && line - start < 40) {
|
|
6485
|
+
const above = lines[start - 1];
|
|
6486
|
+
if (/^\s*@\[[^\]]*\]\s*$/.test(above) || /^\s*--/.test(above)) {
|
|
6487
|
+
start--;
|
|
6488
|
+
continue;
|
|
6489
|
+
}
|
|
6490
|
+
if (/-\/\s*$/.test(above)) {
|
|
6491
|
+
let k2 = start - 1;
|
|
6492
|
+
while (k2 > 0 && line - k2 < 60 && !/^\s*\/-/.test(lines[k2])) k2--;
|
|
6493
|
+
if (/^\s*\/--/.test(lines[k2])) {
|
|
6494
|
+
start = k2;
|
|
6495
|
+
continue;
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
break;
|
|
6499
|
+
}
|
|
6500
|
+
return start;
|
|
6501
|
+
}
|
|
6502
|
+
function compiledExcerpt(lines, range) {
|
|
6503
|
+
const l0 = Math.max(0, range[0] - 1);
|
|
6504
|
+
const l1 = Math.min(lines.length - 1, Math.max(l0, range[2] - 1));
|
|
6505
|
+
return { start: withPreamble(lines, l0), end: l1 };
|
|
6506
|
+
}
|
|
6507
|
+
function excerptOf(lines, edited, name, range) {
|
|
6508
|
+
return edited ? findExcerpt(lines, name, range[0]) : compiledExcerpt(lines, range);
|
|
6509
|
+
}
|
|
6510
|
+
function findExcerpt(lines, name, near) {
|
|
6511
|
+
const parts = name.split(".");
|
|
6512
|
+
const short6 = parts[parts.length - 1].replace(/^«|»$/g, "");
|
|
6513
|
+
const tail2 = parts.slice(-2).join(".");
|
|
6514
|
+
let best = -1;
|
|
6515
|
+
let bestScore = Infinity;
|
|
6516
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
6517
|
+
const m3 = DECL.exec(lines[i2]);
|
|
6518
|
+
if (!m3) continue;
|
|
6519
|
+
const declared = m3[1].replace(/[«»]/g, "");
|
|
6520
|
+
if (declared !== short6 && declared !== tail2.replace(/[«»]/g, "") && declared !== name && !name.endsWith("." + declared)) continue;
|
|
6521
|
+
const score2 = near ? Math.abs(i2 + 1 - near) : i2;
|
|
6522
|
+
if (score2 < bestScore) {
|
|
6523
|
+
bestScore = score2;
|
|
6524
|
+
best = i2;
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6527
|
+
if (best < 0) return null;
|
|
6528
|
+
let end = best;
|
|
6529
|
+
for (let i2 = best + 1; i2 < lines.length && i2 < best + 400; i2++) {
|
|
6530
|
+
if (NEXT.test(lines[i2])) break;
|
|
6531
|
+
end = i2;
|
|
6532
|
+
}
|
|
6533
|
+
while (end > best && !lines[end].trim()) end--;
|
|
6534
|
+
return { start: withPreamble(lines, best), end };
|
|
6535
|
+
}
|
|
6536
|
+
|
|
6537
|
+
// src/shared/doc/proof.ts
|
|
6538
|
+
var OPEN = "([{\u2983\u27E8\u27E6\u27EA\u2985\u2987\u2045";
|
|
6539
|
+
var CLOSE = ")]}\u2984\u27E9\u27E7\u27EB\u2986\u2988\u2046";
|
|
6540
|
+
var BINDS = /* @__PURE__ */ new Set(["let", "have", "haveI", "letI"]);
|
|
6541
|
+
function valueStart(text2) {
|
|
6542
|
+
let depth = 0;
|
|
6543
|
+
let claimed = 0;
|
|
6544
|
+
for (const t2 of tokenizeLean(text2)) {
|
|
6545
|
+
if (t2.kind === "comment" || t2.kind === "doc" || t2.kind === "string" || t2.kind === "attr") continue;
|
|
6546
|
+
if (t2.kind === "keyword" || t2.kind === "ident") {
|
|
6547
|
+
if (depth === 0 && BINDS.has(t2.text)) claimed++;
|
|
6548
|
+
else if (depth === 0 && t2.text === "where") return t2.at;
|
|
6549
|
+
else if (depth === 0 && t2.text === "by") return null;
|
|
6550
|
+
continue;
|
|
6551
|
+
}
|
|
6552
|
+
if (t2.kind !== "text" && t2.kind !== "op") continue;
|
|
6553
|
+
for (let k2 = 0; k2 < t2.text.length; k2++) {
|
|
6554
|
+
const c3 = t2.text[k2];
|
|
6555
|
+
const at = t2.at + k2;
|
|
6556
|
+
if (OPEN.includes(c3)) depth++;
|
|
6557
|
+
else if (CLOSE.includes(c3)) depth = Math.max(0, depth - 1);
|
|
6558
|
+
else if (depth === 0 && c3 === ":" && t2.text[k2 + 1] === "=") {
|
|
6559
|
+
if (claimed > 0) {
|
|
6560
|
+
claimed--;
|
|
6561
|
+
k2++;
|
|
6562
|
+
continue;
|
|
6563
|
+
}
|
|
6564
|
+
return at;
|
|
6565
|
+
} else if (depth === 0 && c3 === "|" && lineStart(text2, at) && equation(text2, at)) return at;
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6568
|
+
return null;
|
|
6569
|
+
}
|
|
6570
|
+
function lineStart(text2, at) {
|
|
6571
|
+
const nl = text2.lastIndexOf("\n", at - 1);
|
|
6572
|
+
return nl >= 0 && /^[ \t]*$/.test(text2.slice(nl + 1, at));
|
|
6573
|
+
}
|
|
6574
|
+
function equation(text2, at) {
|
|
6575
|
+
const end = text2.indexOf("\n", at);
|
|
6576
|
+
return text2.slice(at, end < 0 ? text2.length : end).includes("=>");
|
|
6577
|
+
}
|
|
6578
|
+
|
|
6579
|
+
// src/shared/reviewqueue.ts
|
|
6580
|
+
var TCB_SITES = SITE_STMT | SITE_BODY;
|
|
6581
|
+
function inTargets(g2, targets) {
|
|
6582
|
+
const out = new Uint16Array(g2.n);
|
|
6583
|
+
for (const t2 of targets) {
|
|
6584
|
+
const tcb = g2.reach([t2], TCB_SITES, "out");
|
|
6585
|
+
for (let i2 = 0; i2 < g2.n; i2++) out[i2] += tcb[i2];
|
|
6586
|
+
}
|
|
6587
|
+
return out;
|
|
6588
|
+
}
|
|
6589
|
+
function nonStandardAxiom(g2, i2) {
|
|
6590
|
+
return g2.nodes[i2].kind === "axiom" && !STANDARD_AXIOMS.includes(g2.nodes[i2].name);
|
|
6591
|
+
}
|
|
6592
|
+
function needsReview(g2, d2, i2) {
|
|
6593
|
+
return nonStandardAxiom(g2, i2) || !trusted(d2, g2.nodes[i2].name, g2.nodes[i2].module, g2.isExt(i2));
|
|
6594
|
+
}
|
|
6595
|
+
function trustSplit(g2, d2, s2, skip = -1) {
|
|
6596
|
+
let counted2 = 0, t2 = 0;
|
|
6597
|
+
for (let j2 = 0; j2 < s2.length; j2++) {
|
|
6598
|
+
if (!s2[j2] || j2 === skip) continue;
|
|
6599
|
+
if (needsReview(g2, d2, j2)) counted2++;
|
|
6600
|
+
else t2++;
|
|
6601
|
+
}
|
|
6602
|
+
return { counted: counted2, trusted: t2 };
|
|
6603
|
+
}
|
|
6604
|
+
function reviewSet(g2, d2, root) {
|
|
6605
|
+
return evaluate(reviewScope(g2.nodes[root].name), { g: g2, review: d2 });
|
|
6606
|
+
}
|
|
6607
|
+
var VIA = 8;
|
|
6608
|
+
function axiomsReached(g2, root, set) {
|
|
6609
|
+
const meta = g2.meta;
|
|
6610
|
+
const reach = g2.reach([root], ALL_SITES, "out");
|
|
6611
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
6612
|
+
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
6613
|
+
if (!reach[i2]) continue;
|
|
6614
|
+
if (nonStandardAxiom(g2, i2)) names2.add(g2.nodes[i2].name);
|
|
6615
|
+
for (const k2 of meta.axiomSets[g2.nodes[i2].ax] ?? []) if (!STANDARD_AXIOMS.includes(meta.axioms[k2])) names2.add(meta.axioms[k2]);
|
|
6616
|
+
}
|
|
6617
|
+
const out = [];
|
|
6618
|
+
for (const name of [...names2].sort()) {
|
|
6619
|
+
const j2 = g2.byName.get(name);
|
|
6620
|
+
const node = j2 !== void 0 && set[j2] ? j2 : null;
|
|
6621
|
+
const via = [];
|
|
6622
|
+
if (node !== null) {
|
|
6623
|
+
for (let e2 = g2.inStart[node]; e2 < g2.inStart[node + 1]; e2++) if (reach[g2.inSrc[e2]] && g2.inSrc[e2] !== node && !via.includes(g2.inSrc[e2])) via.push(g2.inSrc[e2]);
|
|
6624
|
+
} else {
|
|
6625
|
+
const k2 = meta.axioms.indexOf(name);
|
|
6626
|
+
const rests = (i2) => k2 >= 0 && (meta.axiomSets[g2.nodes[i2].ax] ?? []).includes(k2);
|
|
6627
|
+
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
6628
|
+
if (!reach[i2] || !rests(i2)) continue;
|
|
6629
|
+
let deeper = false;
|
|
6630
|
+
for (let e2 = g2.outStart[i2]; e2 < g2.outStart[i2 + 1] && !deeper; e2++) deeper = g2.outDst[e2] !== i2 && rests(g2.outDst[e2]);
|
|
6631
|
+
if (!deeper) via.push(i2);
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
via.sort((a3, b2) => Number(g2.isExt(a3)) - Number(g2.isExt(b2)) || (g2.nodes[a3].name < g2.nodes[b2].name ? -1 : 1));
|
|
6635
|
+
out.push({ name, node, via: via.slice(0, VIA) });
|
|
6636
|
+
}
|
|
6637
|
+
return out;
|
|
6638
|
+
}
|
|
6639
|
+
function reviewQueue(g2, d2, root, shared) {
|
|
6640
|
+
const set = reviewSet(g2, d2, root);
|
|
6641
|
+
const order = reviewOrder(g2, set, shared);
|
|
6642
|
+
const ax = order.filter((i2) => g2.nodes[i2].kind === "axiom");
|
|
6643
|
+
return { order: [...ax, ...order.filter((i2) => g2.nodes[i2].kind !== "axiom")], axioms: axiomsReached(g2, root, set) };
|
|
6644
|
+
}
|
|
6645
|
+
function offBoard(q2) {
|
|
6646
|
+
return q2.axioms.filter((a3) => a3.node === null);
|
|
6647
|
+
}
|
|
6648
|
+
function queueProgress(g2, d2, q2) {
|
|
6649
|
+
const p2 = { total: 0, approved: 0, commented: 0, stale: 0 };
|
|
6650
|
+
const count2 = (name, hash) => {
|
|
6651
|
+
p2.total++;
|
|
6652
|
+
const s2 = statusOf(d2, name, hash);
|
|
6653
|
+
if (s2 === "approved") p2.approved++;
|
|
6654
|
+
else if (s2 === "commented") p2.commented++;
|
|
6655
|
+
else if (s2 === "stale") p2.stale++;
|
|
6656
|
+
};
|
|
6657
|
+
for (const i2 of q2.order) count2(g2.nodes[i2].name, g2.nodes[i2].hash);
|
|
6658
|
+
for (const a3 of offBoard(q2)) count2(a3.name, void 0);
|
|
6659
|
+
return p2;
|
|
6660
|
+
}
|
|
6661
|
+
function reviewCount(g2, d2, root) {
|
|
6662
|
+
const set = reviewSet(g2, d2, root);
|
|
6663
|
+
let n3 = 0;
|
|
6664
|
+
for (let i2 = 0; i2 < g2.n; i2++) n3 += set[i2];
|
|
6665
|
+
return n3 + axiomsReached(g2, root, set).filter((a3) => a3.node === null).length;
|
|
6666
|
+
}
|
|
6667
|
+
function settled(d2, reader, name, hash, axiom) {
|
|
6668
|
+
return reviewedBy(d2, reader, name, hash) && (!axiom || statusOf(d2, name, hash) === "approved");
|
|
6669
|
+
}
|
|
6670
|
+
function reviewOrder(g2, set, shared) {
|
|
6671
|
+
const members = [];
|
|
6672
|
+
for (let i2 = 0; i2 < g2.n; i2++) if (set[i2]) members.push(i2);
|
|
6673
|
+
return dependencyOrder(g2, members, (x2, y2) => shared[x2] !== shared[y2] ? shared[x2] > shared[y2] : g2.nodes[x2].name < g2.nodes[y2].name);
|
|
6674
|
+
}
|
|
6675
|
+
function dependencyOrder(g2, members, before = (x2, y2) => g2.nodes[x2].name < g2.nodes[y2].name) {
|
|
6676
|
+
const local = /* @__PURE__ */ new Map();
|
|
6677
|
+
members.forEach((v2, k2) => local.set(v2, k2));
|
|
6678
|
+
const uses = members.map(() => []);
|
|
6679
|
+
members.forEach((u2, a3) => {
|
|
6680
|
+
for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
|
|
6681
|
+
const b2 = g2.outSite[e2] & TCB_SITES ? local.get(g2.outDst[e2]) : void 0;
|
|
6682
|
+
if (b2 !== void 0 && b2 !== a3) uses[a3].push(b2);
|
|
6683
|
+
}
|
|
6684
|
+
});
|
|
6685
|
+
return stepOrder(uses, (a3, b2) => before(members[a3], members[b2])).map((a3) => members[a3]);
|
|
6686
|
+
}
|
|
6687
|
+
function stepOrder(uses, before) {
|
|
6688
|
+
const m3 = uses.length;
|
|
6689
|
+
const comp = components(uses);
|
|
6690
|
+
const nc = comp.reduce((x2, c3) => Math.max(x2, c3 + 1), 0);
|
|
6691
|
+
const steps = Array.from({ length: nc }, () => []);
|
|
6692
|
+
for (let a3 = 0; a3 < m3; a3++) steps[comp[a3]].push(a3);
|
|
6693
|
+
for (const s2 of steps) s2.sort((a3, b2) => before(a3, b2) ? -1 : before(b2, a3) ? 1 : 0);
|
|
6694
|
+
const waiting = new Int32Array(nc);
|
|
6695
|
+
const usedBy = Array.from({ length: nc }, () => []);
|
|
6696
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6697
|
+
for (let a3 = 0; a3 < m3; a3++) {
|
|
6698
|
+
for (const b2 of uses[a3]) {
|
|
6699
|
+
const c3 = comp[a3], d2 = comp[b2];
|
|
6700
|
+
if (c3 === d2 || seen.has(c3 * nc + d2)) continue;
|
|
6701
|
+
seen.add(c3 * nc + d2);
|
|
6702
|
+
waiting[c3]++;
|
|
6703
|
+
usedBy[d2].push(c3);
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6706
|
+
const ready = new Heap((c3, d2) => before(steps[c3][0], steps[d2][0]));
|
|
6707
|
+
for (let c3 = 0; c3 < nc; c3++) if (!waiting[c3]) ready.push(c3);
|
|
6708
|
+
const out = [];
|
|
6709
|
+
while (ready.size) {
|
|
6710
|
+
const c3 = ready.pop();
|
|
6711
|
+
for (const a3 of steps[c3]) out.push(a3);
|
|
6712
|
+
for (const d2 of usedBy[c3]) if (--waiting[d2] === 0) ready.push(d2);
|
|
6713
|
+
}
|
|
6714
|
+
return out;
|
|
6715
|
+
}
|
|
6716
|
+
function components(succ) {
|
|
6717
|
+
const n3 = succ.length;
|
|
6718
|
+
const index = new Int32Array(n3).fill(-1);
|
|
6719
|
+
const low = new Int32Array(n3);
|
|
6720
|
+
const comp = new Int32Array(n3).fill(-1);
|
|
6721
|
+
const onStack = new Uint8Array(n3);
|
|
6722
|
+
const stack2 = [];
|
|
6723
|
+
let next = 0, nc = 0;
|
|
6724
|
+
const enter = (v2) => {
|
|
6725
|
+
index[v2] = low[v2] = next++;
|
|
6726
|
+
stack2.push(v2);
|
|
6727
|
+
onStack[v2] = 1;
|
|
6728
|
+
};
|
|
6729
|
+
for (let s2 = 0; s2 < n3; s2++) {
|
|
6730
|
+
if (index[s2] >= 0) continue;
|
|
6731
|
+
enter(s2);
|
|
6732
|
+
const path = [[s2, 0]];
|
|
6733
|
+
while (path.length) {
|
|
6734
|
+
const top = path[path.length - 1];
|
|
6735
|
+
const v2 = top[0];
|
|
6736
|
+
if (top[1] < succ[v2].length) {
|
|
6737
|
+
const w2 = succ[v2][top[1]++];
|
|
6738
|
+
if (index[w2] < 0) {
|
|
6739
|
+
enter(w2);
|
|
6740
|
+
path.push([w2, 0]);
|
|
6741
|
+
} else if (onStack[w2]) low[v2] = Math.min(low[v2], index[w2]);
|
|
6742
|
+
continue;
|
|
6743
|
+
}
|
|
6744
|
+
path.pop();
|
|
6745
|
+
if (path.length) {
|
|
6746
|
+
const u2 = path[path.length - 1][0];
|
|
6747
|
+
low[u2] = Math.min(low[u2], low[v2]);
|
|
6748
|
+
}
|
|
6749
|
+
if (low[v2] === index[v2]) {
|
|
6750
|
+
let w2;
|
|
6751
|
+
do {
|
|
6752
|
+
w2 = stack2.pop();
|
|
6753
|
+
onStack[w2] = 0;
|
|
6754
|
+
comp[w2] = nc;
|
|
6755
|
+
} while (w2 !== v2);
|
|
6756
|
+
nc++;
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
return comp;
|
|
6761
|
+
}
|
|
6762
|
+
var Heap = class {
|
|
6763
|
+
xs = [];
|
|
6764
|
+
before;
|
|
6765
|
+
constructor(before) {
|
|
6766
|
+
this.before = before;
|
|
6767
|
+
}
|
|
6768
|
+
get size() {
|
|
6769
|
+
return this.xs.length;
|
|
6770
|
+
}
|
|
6771
|
+
push(x2) {
|
|
6772
|
+
const xs = this.xs;
|
|
6773
|
+
xs.push(x2);
|
|
6774
|
+
for (let k2 = xs.length - 1; k2 > 0; ) {
|
|
6775
|
+
const p2 = k2 - 1 >> 1;
|
|
6776
|
+
if (!this.before(xs[k2], xs[p2])) break;
|
|
6777
|
+
[xs[k2], xs[p2]] = [xs[p2], xs[k2]];
|
|
6778
|
+
k2 = p2;
|
|
6779
|
+
}
|
|
6780
|
+
}
|
|
6781
|
+
pop() {
|
|
6782
|
+
const xs = this.xs;
|
|
6783
|
+
const top = xs[0];
|
|
6784
|
+
const last2 = xs.pop();
|
|
6785
|
+
if (xs.length) {
|
|
6786
|
+
xs[0] = last2;
|
|
6787
|
+
for (let k2 = 0; ; ) {
|
|
6788
|
+
const l2 = 2 * k2 + 1, r2 = l2 + 1;
|
|
6789
|
+
let best = k2;
|
|
6790
|
+
if (l2 < xs.length && this.before(xs[l2], xs[best])) best = l2;
|
|
6791
|
+
if (r2 < xs.length && this.before(xs[r2], xs[best])) best = r2;
|
|
6792
|
+
if (best === k2) break;
|
|
6793
|
+
[xs[k2], xs[best]] = [xs[best], xs[k2]];
|
|
6794
|
+
k2 = best;
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
return top;
|
|
6798
|
+
}
|
|
6799
|
+
};
|
|
6800
|
+
function whyChain(g2, from, to) {
|
|
6801
|
+
const parent = new Int32Array(g2.n).fill(-1);
|
|
6802
|
+
parent[from] = from;
|
|
6803
|
+
const queue = [from];
|
|
6804
|
+
for (let k2 = 0; k2 < queue.length && parent[to] < 0; k2++) {
|
|
6805
|
+
const u2 = queue[k2];
|
|
6806
|
+
for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
|
|
6807
|
+
const v2 = g2.outDst[e2];
|
|
6808
|
+
if (!(g2.outSite[e2] & TCB_SITES) || parent[v2] >= 0) continue;
|
|
6809
|
+
parent[v2] = u2;
|
|
6810
|
+
queue.push(v2);
|
|
6811
|
+
}
|
|
6812
|
+
}
|
|
6813
|
+
if (parent[to] < 0) return null;
|
|
6814
|
+
const path = [to];
|
|
6815
|
+
while (path[path.length - 1] !== from) path.push(parent[path[path.length - 1]]);
|
|
6816
|
+
return path.reverse();
|
|
6817
|
+
}
|
|
6818
|
+
function reviewedBy(d2, reader, name, hash) {
|
|
6819
|
+
return !!reader && current(d2, name).some((o2) => o2.by === reader && fresh(o2, hash));
|
|
6820
|
+
}
|
|
6821
|
+
|
|
6822
|
+
// src/web/src/status.ts
|
|
6823
|
+
var SCHEMES_SHOWN = ["kind", "status", "mine"];
|
|
6824
|
+
var STATUSES2 = ["failed", "building", "sorry", "commented", "stale", "approved", "unreviewed", "trusted"];
|
|
6825
|
+
var ST_FAILED = 0;
|
|
6826
|
+
var ST_BUILDING = 1;
|
|
6827
|
+
var ST_SORRY = 2;
|
|
6828
|
+
var ST_COMMENTED = 3;
|
|
6829
|
+
var ST_STALE = 4;
|
|
6830
|
+
var ST_APPROVED = 5;
|
|
6831
|
+
var ST_UNREVIEWED = 6;
|
|
6832
|
+
var ST_TRUSTED = 7;
|
|
6833
|
+
var STATUS_LABEL = {
|
|
6834
|
+
failed: "failed or not built",
|
|
6835
|
+
building: "building",
|
|
6836
|
+
sorry: "contains sorry",
|
|
6837
|
+
commented: "commented",
|
|
6838
|
+
stale: "stale",
|
|
6839
|
+
approved: "approved",
|
|
6840
|
+
unreviewed: "not yet reviewed",
|
|
6841
|
+
trusted: "trusted"
|
|
6842
|
+
};
|
|
6843
|
+
var STATUS_HINT = {
|
|
6844
|
+
failed: "Its file failed to compile in the last build, or was never built: shown as it was last built",
|
|
6845
|
+
building: "Its file is being compiled right now",
|
|
6846
|
+
sorry: "It rests on sorry: its own, or through anything it uses",
|
|
6847
|
+
commented: "A reviewer's latest word on its present version is a comment",
|
|
6848
|
+
stale: "It has opinions, none on its present version",
|
|
6849
|
+
approved: "A reviewer approved its present version, and no reviewer's latest word on it is a comment",
|
|
6850
|
+
unreviewed: "Nobody has given an opinion on it yet, and nothing trusts it",
|
|
6851
|
+
trusted: "Trusted without review (Mathlib, Lean core, a trusted prefix, the standard axioms), with no opinion on it"
|
|
6852
|
+
};
|
|
6853
|
+
var MINE_STATES = [ST_COMMENTED, ST_STALE, ST_APPROVED, ST_UNREVIEWED, ST_TRUSTED];
|
|
6854
|
+
function mineLabel(code, whose) {
|
|
6855
|
+
const who = whose ?? "you";
|
|
6856
|
+
switch (code) {
|
|
6857
|
+
case ST_COMMENTED:
|
|
6858
|
+
return `${who} commented`;
|
|
6859
|
+
case ST_STALE:
|
|
6860
|
+
return `${whose ? `${whose}'s` : "your"} opinion is stale`;
|
|
6861
|
+
case ST_APPROVED:
|
|
6862
|
+
return `${who} approved`;
|
|
6863
|
+
case ST_TRUSTED:
|
|
6864
|
+
return "trusted";
|
|
6865
|
+
default:
|
|
6866
|
+
return `not reviewed by ${whose ?? "you"}`;
|
|
6867
|
+
}
|
|
6868
|
+
}
|
|
6869
|
+
function mineHint(code, whose) {
|
|
6870
|
+
const your = whose ? `${whose}'s` : "Your";
|
|
6871
|
+
switch (code) {
|
|
6872
|
+
case ST_COMMENTED:
|
|
6873
|
+
return `${your} current opinion on its present version is a comment`;
|
|
6874
|
+
case ST_STALE:
|
|
6875
|
+
return `${your} current opinion is on an earlier version: it changed since`;
|
|
6876
|
+
case ST_APPROVED:
|
|
6877
|
+
return `${your} current opinion approves its present version`;
|
|
6878
|
+
case ST_TRUSTED:
|
|
6879
|
+
return `Trusted without review, and no opinion of ${whose ? `${whose}'s` : "yours"} on it`;
|
|
6880
|
+
default:
|
|
6881
|
+
return `It needs review, and ${whose ? `${whose} has` : "you have"} no opinion on it (none given, or withdrawn)`;
|
|
6882
|
+
}
|
|
6883
|
+
}
|
|
6884
|
+
function mineState(d2, g2, i2, me) {
|
|
6885
|
+
const v2 = g2.nodes[i2];
|
|
6886
|
+
const s2 = me ? ownStatus(d2, v2.name, me, v2.hash) : "none";
|
|
6887
|
+
if (s2 === "stale") return ST_STALE;
|
|
6888
|
+
if (s2 === "commented") return ST_COMMENTED;
|
|
6889
|
+
if (s2 === "approved") return ST_APPROVED;
|
|
6890
|
+
return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
|
|
6891
|
+
}
|
|
6892
|
+
function mineCodes(d2, g2, me) {
|
|
6893
|
+
const out = new Uint8Array(g2.n);
|
|
6894
|
+
for (let i2 = 0; i2 < g2.n; i2++) out[i2] = mineState(d2, g2, i2, me);
|
|
6895
|
+
return out;
|
|
6896
|
+
}
|
|
6897
|
+
function statusState(d2, g2, i2, file, sorryAx) {
|
|
6898
|
+
if (file?.state === "building") return ST_BUILDING;
|
|
6899
|
+
if (file?.state === "failed" || file?.state === "unbuilt") return ST_FAILED;
|
|
6900
|
+
if (sorryAx) return ST_SORRY;
|
|
6901
|
+
const v2 = g2.nodes[i2];
|
|
6902
|
+
const s2 = statusOf(d2, v2.name, v2.hash);
|
|
6903
|
+
if (s2 === "commented") return ST_COMMENTED;
|
|
6904
|
+
if (s2 === "stale") return ST_STALE;
|
|
6905
|
+
if (s2 === "approved") return ST_APPROVED;
|
|
6906
|
+
return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
|
|
6907
|
+
}
|
|
6908
|
+
function statusCodes(d2, g2, files) {
|
|
6909
|
+
const out = new Uint8Array(g2.n);
|
|
6910
|
+
const sorrySets = /* @__PURE__ */ new Map();
|
|
6911
|
+
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
6912
|
+
const ax = g2.nodes[i2].ax;
|
|
6913
|
+
let s2 = sorrySets.get(ax);
|
|
6914
|
+
if (s2 === void 0) sorrySets.set(ax, s2 = g2.axiomsOf(i2).includes("sorryAx"));
|
|
6915
|
+
out[i2] = statusState(d2, g2, i2, g2.isExt(i2) ? void 0 : files.get(g2.nodes[i2].module), s2);
|
|
6916
|
+
}
|
|
6917
|
+
return out;
|
|
6918
|
+
}
|
|
6919
|
+
function fileTrouble(f2) {
|
|
6920
|
+
switch (f2?.state) {
|
|
6921
|
+
case "failed":
|
|
6922
|
+
case "unbuilt":
|
|
6923
|
+
return ST_FAILED;
|
|
6924
|
+
case "building":
|
|
6925
|
+
return ST_BUILDING;
|
|
6926
|
+
case "sorry":
|
|
6927
|
+
return ST_SORRY;
|
|
6928
|
+
default:
|
|
6929
|
+
return -1;
|
|
6930
|
+
}
|
|
6931
|
+
}
|
|
6932
|
+
function clusterTroubles(clusters, clustering, files) {
|
|
6933
|
+
const out = new Int8Array(clusters.length).fill(-1);
|
|
6934
|
+
if (clustering === "module") clusters.forEach((c3, k2) => out[k2] = fileTrouble(files.get(c3.key)));
|
|
6935
|
+
return out;
|
|
6936
|
+
}
|
|
6937
|
+
|
|
6938
|
+
// src/web/src/filemode.ts
|
|
6939
|
+
var byModule = /* @__PURE__ */ new WeakMap();
|
|
6940
|
+
function moduleDecls(g2, module) {
|
|
6941
|
+
let m3 = byModule.get(g2);
|
|
6942
|
+
if (!m3) {
|
|
6943
|
+
m3 = /* @__PURE__ */ new Map();
|
|
6944
|
+
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
6945
|
+
const k2 = g2.nodes[i2].module;
|
|
6946
|
+
const list2 = m3.get(k2);
|
|
6947
|
+
if (list2) list2.push(i2);
|
|
6948
|
+
else m3.set(k2, [i2]);
|
|
6949
|
+
}
|
|
6950
|
+
byModule.set(g2, m3);
|
|
6951
|
+
}
|
|
6952
|
+
return m3.get(module) ?? [];
|
|
6953
|
+
}
|
|
6954
|
+
var preamble = (l2) => /^\s*(?:$|--|@\[[^\]]*\]\s*$)/.test(l2);
|
|
6955
|
+
function headLine(lines, start, end) {
|
|
6956
|
+
let k2 = start;
|
|
6957
|
+
if (/^\s*\/--/.test(lines[k2] ?? "")) {
|
|
6958
|
+
const first = lines[k2].indexOf("/--");
|
|
6959
|
+
while (k2 <= end && lines[k2].indexOf("-/", k2 === start ? first + 3 : 0) < 0) k2++;
|
|
6960
|
+
if (k2 > end) return start;
|
|
6961
|
+
const rest = lines[k2].slice(lines[k2].indexOf("-/", k2 === start ? first + 3 : 0) + 2);
|
|
6962
|
+
if (rest.trim()) return k2;
|
|
6963
|
+
k2++;
|
|
6964
|
+
}
|
|
6965
|
+
while (k2 < end && preamble(lines[k2])) k2++;
|
|
6966
|
+
return k2 <= end ? k2 : start;
|
|
6967
|
+
}
|
|
6968
|
+
function fileDecls(g2, module, lines, edited) {
|
|
6969
|
+
const out = [];
|
|
6970
|
+
for (const i2 of moduleDecls(g2, module)) {
|
|
6971
|
+
const v2 = g2.nodes[i2];
|
|
6972
|
+
if (!v2.range || v2.gen !== void 0) continue;
|
|
6973
|
+
const at = edited ? excerptOf(lines, true, v2.name, v2.range) : compiledExcerpt(lines, v2.range);
|
|
6974
|
+
if (!at || at.start >= lines.length) continue;
|
|
6975
|
+
out.push({ i: i2, start: at.start, end: at.end, head: headLine(lines, at.start, at.end) });
|
|
6976
|
+
}
|
|
6977
|
+
return out.sort((a3, b2) => a3.start - b2.start || a3.end - b2.end || (g2.nodes[a3.i].name < g2.nodes[b2.i].name ? -1 : 1));
|
|
6978
|
+
}
|
|
6979
|
+
var CHUNK_LINES = 60;
|
|
6980
|
+
function chunksOf(decls, n3, max = CHUNK_LINES) {
|
|
6981
|
+
const out = [];
|
|
6982
|
+
const gap = (from, to) => {
|
|
6983
|
+
for (let s2 = from; s2 <= to; s2 += max) out.push({ start: s2, end: Math.min(to, s2 + max - 1) });
|
|
6984
|
+
};
|
|
6985
|
+
let at = 0;
|
|
6986
|
+
let k2 = 0;
|
|
6987
|
+
while (k2 < decls.length) {
|
|
6988
|
+
const start = Math.max(at, decls[k2].start);
|
|
6989
|
+
let end = Math.max(start, decls[k2].end);
|
|
6990
|
+
k2++;
|
|
6991
|
+
while (k2 < decls.length && decls[k2].start <= end) end = Math.max(end, decls[k2++].end);
|
|
6992
|
+
end = Math.min(end, n3 - 1);
|
|
6993
|
+
if (start > end) continue;
|
|
6994
|
+
if (start > at) gap(at, start - 1);
|
|
6995
|
+
out.push({ start, end });
|
|
6996
|
+
at = end + 1;
|
|
6997
|
+
}
|
|
6998
|
+
if (at < n3) gap(at, n3 - 1);
|
|
6999
|
+
return out;
|
|
7000
|
+
}
|
|
7001
|
+
function declAt(decls, line) {
|
|
7002
|
+
let best = null;
|
|
7003
|
+
for (const d2 of decls) {
|
|
7004
|
+
if (d2.start > line) break;
|
|
7005
|
+
if (d2.end >= line && (!best || d2.start >= best.start)) best = d2;
|
|
7006
|
+
}
|
|
7007
|
+
return best;
|
|
7008
|
+
}
|
|
7009
|
+
var VALUE_KINDS = /* @__PURE__ */ new Set(["def", "abbrev", "instance", "opaque"]);
|
|
7010
|
+
var FOLD_MARK = "\u22EF proof";
|
|
7011
|
+
function utf16At(line, col) {
|
|
7012
|
+
let i2 = 0;
|
|
7013
|
+
for (let cp = 0; cp < col && i2 < line.length; cp++) i2 += (line.codePointAt(i2) ?? 0) > 65535 ? 2 : 1;
|
|
7014
|
+
return i2;
|
|
7015
|
+
}
|
|
7016
|
+
function proofFolds(g2, decls, lines, passRead) {
|
|
7017
|
+
const out = [];
|
|
7018
|
+
const add = (d2, start, text2, a3, b2) => {
|
|
7019
|
+
while (b2 > a3 && /\s/.test(text2[b2 - 1])) b2--;
|
|
7020
|
+
if (b2 - a3 <= FOLD_MARK.length) return;
|
|
7021
|
+
const pos = (o2) => {
|
|
7022
|
+
let line = start, at = 0;
|
|
7023
|
+
for (let nl = text2.indexOf("\n"); nl >= 0 && nl < o2; nl = text2.indexOf("\n", at)) {
|
|
7024
|
+
line++;
|
|
7025
|
+
at = nl + 1;
|
|
7026
|
+
}
|
|
7027
|
+
return [line, o2 - at];
|
|
7028
|
+
};
|
|
7029
|
+
out.push({ from: pos(a3), to: pos(b2), decl: d2 });
|
|
7030
|
+
};
|
|
7031
|
+
decls.forEach((fd, d2) => {
|
|
7032
|
+
const v2 = g2.nodes[fd.i];
|
|
7033
|
+
const text2 = lines.slice(fd.start, fd.end + 1).join("\n");
|
|
7034
|
+
if (v2.kind === "theorem") {
|
|
7035
|
+
const at = valueStart(text2);
|
|
7036
|
+
if (at === null) return;
|
|
7037
|
+
let from = text2.startsWith(":=", at) ? at + 2 : at;
|
|
7038
|
+
while (from < text2.length && (text2[from] === " " || text2[from] === " ")) from++;
|
|
7039
|
+
add(d2, fd.start, text2, from, text2.length);
|
|
7040
|
+
return;
|
|
7041
|
+
}
|
|
7042
|
+
if (!VALUE_KINDS.has(v2.kind) || !v2.proofs?.length || !passRead(fd.i)) return;
|
|
7043
|
+
const starts = [];
|
|
7044
|
+
let o2 = 0;
|
|
7045
|
+
for (let l2 = fd.start; l2 <= fd.end; l2++) {
|
|
7046
|
+
starts.push(o2);
|
|
7047
|
+
o2 += lines[l2].length + 1;
|
|
7048
|
+
}
|
|
7049
|
+
const off = (line, col) => {
|
|
7050
|
+
const k2 = line - 1 - fd.start;
|
|
7051
|
+
return k2 < 0 || k2 >= starts.length ? null : starts[k2] + utf16At(lines[line - 1], col);
|
|
7052
|
+
};
|
|
7053
|
+
for (const [l0, c0, l1, c1] of v2.proofs) {
|
|
7054
|
+
const a3 = off(l0, c0), b2 = off(l1, c1);
|
|
7055
|
+
if (a3 !== null && b2 !== null && a3 < b2) add(d2, fd.start, text2, a3, b2);
|
|
7056
|
+
}
|
|
7057
|
+
});
|
|
7058
|
+
out.sort((x2, y2) => x2.from[0] - y2.from[0] || x2.from[1] - y2.from[1]);
|
|
7059
|
+
const apart2 = [];
|
|
7060
|
+
const before = (p2, q2) => p2[0] < q2[0] || p2[0] === q2[0] && p2[1] < q2[1];
|
|
7061
|
+
for (const f2 of out) {
|
|
7062
|
+
const last2 = apart2[apart2.length - 1];
|
|
7063
|
+
if (last2 && before(f2.from, last2.to)) {
|
|
7064
|
+
if (before(last2.to, f2.to)) last2.to = f2.to;
|
|
7065
|
+
} else apart2.push({ ...f2, from: [...f2.from], to: [...f2.to] });
|
|
7066
|
+
}
|
|
7067
|
+
return apart2;
|
|
7068
|
+
}
|
|
7069
|
+
var FILE_MARK_LABEL = { ...STATUS_LABEL, free: "in no target's review set" };
|
|
7070
|
+
function fileMark(d2, g2, i2, inReview, file) {
|
|
7071
|
+
const s2 = STATUSES2[statusState(d2, g2, i2, g2.isExt(i2) ? void 0 : file, g2.axiomsOf(i2).includes("sorryAx"))];
|
|
7072
|
+
return s2 === "unreviewed" && inReview && !inReview(i2) ? "free" : s2;
|
|
7073
|
+
}
|
|
7074
|
+
function sameText(compiled, range, lines, now) {
|
|
7075
|
+
const at = compiledExcerpt(compiled, range);
|
|
7076
|
+
if (at.end - at.start !== now.end - now.start) return false;
|
|
7077
|
+
for (let k2 = 0; k2 <= at.end - at.start; k2++) if (compiled[at.start + k2] !== lines[now.start + k2]) return false;
|
|
7078
|
+
return true;
|
|
7079
|
+
}
|
|
7080
|
+
|
|
6417
7081
|
// src/shared/sharesnap.ts
|
|
6418
7082
|
var SNAP_PARAM = "snap";
|
|
6419
7083
|
var SNAPSHOT_MAX = 32e3;
|
|
@@ -6477,8 +7141,10 @@ var SNAPSHOT_FORMS = {
|
|
|
6477
7141
|
read: (o2, clean) => "visitors" in o2 && clean.visitors ? { visitors: clean.visitors } : {}
|
|
6478
7142
|
},
|
|
6479
7143
|
panel: same("sel"),
|
|
6480
|
-
sources: same("source", "sourceCollapsed", "pinned"),
|
|
7144
|
+
sources: same("source", "sourceCollapsed", "sourceMode", "pinned"),
|
|
6481
7145
|
paper: same("paper"),
|
|
7146
|
+
// the InfoView's caret, in the window it is in (the owner's decision of 2026-11-01)
|
|
7147
|
+
caret: same("caret"),
|
|
6482
7148
|
activity: same("activity"),
|
|
6483
7149
|
lostFound: same("lostFound"),
|
|
6484
7150
|
colouring: same("scheme"),
|
|
@@ -6547,7 +7213,7 @@ function sortOut(v2, has) {
|
|
|
6547
7213
|
return { view, gone };
|
|
6548
7214
|
}
|
|
6549
7215
|
function goneNames(v2, picked, has) {
|
|
6550
|
-
const named2 = [v2.sel, ...picked, ...(v2.visitors ?? []).map((w2) => w2.decl), ...(v2.pinned ?? []).
|
|
7216
|
+
const named2 = [v2.sel, ...picked, ...(v2.visitors ?? []).map((w2) => w2.decl), ...(v2.pinned ?? []).flatMap((w2) => "decl" in w2 ? [w2.decl] : [])];
|
|
6551
7217
|
const decls = [...new Set(named2.filter((n3) => !!n3 && !has.decl(n3)))];
|
|
6552
7218
|
return { decls, ...typeof v2.focus === "string" && !has.target(v2.focus) ? { focus: v2.focus } : {} };
|
|
6553
7219
|
}
|
|
@@ -7923,7 +8589,7 @@ var NAMESPACE = /^namespace\s+(\S+)/;
|
|
|
7923
8589
|
var SECTION = /^(?:@\[[^\]]*\]\s*)?(?:(?:noncomputable|public|private)\s+)*section\b(?:\s+([^\s-]\S*))?/;
|
|
7924
8590
|
var MUTUAL = /^mutual\b/;
|
|
7925
8591
|
var END = /^end\b(?:\s+([^\s-]\S*))?/;
|
|
7926
|
-
var
|
|
8592
|
+
var OPEN2 = /^open\s+(.*)$/;
|
|
7927
8593
|
var VARIABLE = /^variable\b\s*(.*)$/;
|
|
7928
8594
|
var UNIVERSE = /^universe\s+(.*)$/;
|
|
7929
8595
|
var OPTION = /^set_option\s+(.*)$/;
|
|
@@ -7962,12 +8628,12 @@ function stripComments(line, depth) {
|
|
|
7962
8628
|
}
|
|
7963
8629
|
return { text: out, depth };
|
|
7964
8630
|
}
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
const current3 = () =>
|
|
7969
|
-
const resolveNs = (x2) => {
|
|
7970
|
-
const cur = current3().split(".").filter(Boolean);
|
|
8631
|
+
var copyFrame = (f2) => ({ ...f2, opens: [...f2.opens], aliases: new Map(f2.aliases), open: [...f2.open], variables: [...f2.variables], universes: [...f2.universes], options: [...f2.options], local: [...f2.local] });
|
|
8632
|
+
function walker(lines, hasNamespace) {
|
|
8633
|
+
const live = { stack: [frame("top", "", null, 0)], pending: null };
|
|
8634
|
+
const current3 = (st2) => st2.stack.map((f2) => f2.ns).filter(Boolean).join(".");
|
|
8635
|
+
const resolveNs = (st2, x2) => {
|
|
8636
|
+
const cur = current3(st2).split(".").filter(Boolean);
|
|
7971
8637
|
const out = [];
|
|
7972
8638
|
for (let k2 = cur.length; k2 >= 0; k2--) {
|
|
7973
8639
|
const n3 = [...cur.slice(0, k2), x2].join(".");
|
|
@@ -7975,7 +8641,7 @@ function walk(lines, upto, hasNamespace) {
|
|
|
7975
8641
|
}
|
|
7976
8642
|
return out;
|
|
7977
8643
|
};
|
|
7978
|
-
const open = (args, cmd, into) => {
|
|
8644
|
+
const open = (st2, args, cmd, into) => {
|
|
7979
8645
|
const words = args.trim().split(/\s+/);
|
|
7980
8646
|
const scoped = words[0] === "scoped";
|
|
7981
8647
|
const spaces = [];
|
|
@@ -7983,14 +8649,14 @@ function walk(lines, upto, hasNamespace) {
|
|
|
7983
8649
|
const paren = /^([^\s(]+)\s*\(([^)]*)\)/.exec(rest.trim());
|
|
7984
8650
|
const renaming = /^([^\s]+)\s+renaming\s+(.*)$/.exec(rest.trim());
|
|
7985
8651
|
if (paren) {
|
|
7986
|
-
for (const ns of resolveNs(paren[1])) {
|
|
8652
|
+
for (const ns of resolveNs(st2, paren[1])) {
|
|
7987
8653
|
spaces.push(ns);
|
|
7988
8654
|
if (!scoped) {
|
|
7989
8655
|
for (const x2 of paren[2].trim().split(/\s+/)) if (x2) into.aliases.set(x2, `${ns}.${x2}`);
|
|
7990
8656
|
}
|
|
7991
8657
|
}
|
|
7992
8658
|
} else if (renaming) {
|
|
7993
|
-
for (const ns of resolveNs(renaming[1])) {
|
|
8659
|
+
for (const ns of resolveNs(st2, renaming[1])) {
|
|
7994
8660
|
spaces.push(ns);
|
|
7995
8661
|
if (!scoped)
|
|
7996
8662
|
for (const pair of renaming[2].split(",")) {
|
|
@@ -8002,50 +8668,51 @@ function walk(lines, upto, hasNamespace) {
|
|
|
8002
8668
|
const hiding = rest.indexOf(" hiding ");
|
|
8003
8669
|
for (const w2 of (hiding >= 0 ? rest.slice(0, hiding) : rest).trim().split(/\s+/)) {
|
|
8004
8670
|
if (!w2) continue;
|
|
8005
|
-
const ns = resolveNs(w2);
|
|
8671
|
+
const ns = resolveNs(st2, w2);
|
|
8006
8672
|
spaces.push(...ns);
|
|
8007
8673
|
if (!scoped) into.opens.push(...ns);
|
|
8008
8674
|
}
|
|
8009
8675
|
}
|
|
8010
8676
|
into.open.push({ ...cmd, namespaces: [...new Set(spaces)], ...scoped ? { scoped: true } : {} });
|
|
8011
8677
|
};
|
|
8012
|
-
const finish = (text2, line) => {
|
|
8678
|
+
const finish = (st2, text2, line) => {
|
|
8679
|
+
const stack2 = st2.stack;
|
|
8013
8680
|
let m3;
|
|
8014
8681
|
if (m3 = NAMESPACE.exec(text2)) {
|
|
8015
8682
|
stack2.push(frame("namespace", m3[1], m3[1], line));
|
|
8016
|
-
pending = null;
|
|
8683
|
+
st2.pending = null;
|
|
8017
8684
|
return;
|
|
8018
8685
|
}
|
|
8019
8686
|
if (m3 = SECTION.exec(text2)) {
|
|
8020
8687
|
const f2 = frame("section", "", m3[1] ?? null, line);
|
|
8021
8688
|
if (/\bnoncomputable\s+section\b/.test(text2)) f2.noncomputable = true;
|
|
8022
8689
|
stack2.push(f2);
|
|
8023
|
-
pending = null;
|
|
8690
|
+
st2.pending = null;
|
|
8024
8691
|
return;
|
|
8025
8692
|
}
|
|
8026
8693
|
if (MUTUAL.test(text2)) {
|
|
8027
8694
|
stack2.push(frame("mutual", "", null, line));
|
|
8028
|
-
pending = null;
|
|
8695
|
+
st2.pending = null;
|
|
8029
8696
|
return;
|
|
8030
8697
|
}
|
|
8031
8698
|
if (m3 = END.exec(text2)) {
|
|
8032
8699
|
let parts = m3[1] ? m3[1].split(".").length : 1;
|
|
8033
8700
|
while (parts > 0 && stack2.length > 1) parts -= (stack2.pop().name ?? "_").split(".").length;
|
|
8034
|
-
pending = null;
|
|
8701
|
+
st2.pending = null;
|
|
8035
8702
|
return;
|
|
8036
8703
|
}
|
|
8037
8704
|
if (ATTRIBUTES.test(text2)) return;
|
|
8038
8705
|
const head = IN_HEAD.test(text2);
|
|
8039
8706
|
if (head && !VARIABLE.test(text2) && /\sin\s/.test(text2)) {
|
|
8040
|
-
pending = null;
|
|
8707
|
+
st2.pending = null;
|
|
8041
8708
|
return;
|
|
8042
8709
|
}
|
|
8043
8710
|
const onlyNext = head && IN.test(text2);
|
|
8044
8711
|
const body = onlyNext ? text2.replace(IN, "") : text2;
|
|
8045
|
-
const into = onlyNext ? pending ??= frame("top", "", null, line) : stack2[stack2.length - 1];
|
|
8046
|
-
if (!onlyNext) pending = null;
|
|
8712
|
+
const into = onlyNext ? st2.pending ??= frame("top", "", null, line) : stack2[stack2.length - 1];
|
|
8713
|
+
if (!onlyNext) st2.pending = null;
|
|
8047
8714
|
const cmd = (t2) => ({ line: line + 1, text: t2, ...onlyNext ? { in: true } : {} });
|
|
8048
|
-
if (m3 =
|
|
8715
|
+
if (m3 = OPEN2.exec(body)) open(st2, m3[1], cmd(body), into);
|
|
8049
8716
|
else if (m3 = VARIABLE.exec(body)) into.variables.push(cmd(m3[1]));
|
|
8050
8717
|
else if (m3 = UNIVERSE.exec(body)) into.universes.push(cmd(m3[1]));
|
|
8051
8718
|
else if (m3 = OPTION.exec(body)) into.options.push(cmd(m3[1]));
|
|
@@ -8053,23 +8720,31 @@ function walk(lines, upto, hasNamespace) {
|
|
|
8053
8720
|
};
|
|
8054
8721
|
let depth = 0;
|
|
8055
8722
|
let reading = null;
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8723
|
+
let l2 = 0;
|
|
8724
|
+
return {
|
|
8725
|
+
to(upto) {
|
|
8726
|
+
for (; l2 < upto && l2 < lines.length; l2++) {
|
|
8727
|
+
const line = lines[l2];
|
|
8728
|
+
const inComment = depth > 0;
|
|
8729
|
+
const s2 = stripComments(line, depth);
|
|
8730
|
+
depth = s2.depth;
|
|
8731
|
+
const text2 = s2.text.replace(/\s+/g, " ").trim();
|
|
8732
|
+
if (!text2) continue;
|
|
8733
|
+
if (!inComment && !/^\s/.test(line)) {
|
|
8734
|
+
if (reading) finish(live, reading.text, reading.line);
|
|
8735
|
+
reading = { line: l2, text: text2 };
|
|
8736
|
+
} else if (reading) reading.text += " " + text2;
|
|
8737
|
+
}
|
|
8738
|
+
const st2 = { stack: live.stack.map(copyFrame), pending: live.pending && copyFrame(live.pending) };
|
|
8739
|
+
if (reading) finish(st2, reading.text, reading.line);
|
|
8740
|
+
return st2;
|
|
8741
|
+
}
|
|
8742
|
+
};
|
|
8070
8743
|
}
|
|
8071
|
-
function
|
|
8072
|
-
|
|
8744
|
+
function walk(lines, upto, hasNamespace) {
|
|
8745
|
+
return walker(lines, hasNamespace).to(upto);
|
|
8746
|
+
}
|
|
8747
|
+
function scopeOf({ stack: stack2, pending }) {
|
|
8073
8748
|
const frames = pending ? [...stack2, pending] : stack2;
|
|
8074
8749
|
const cur = stack2.map((f2) => f2.ns).filter(Boolean).join(".").split(".").filter(Boolean);
|
|
8075
8750
|
const namespaces = [];
|
|
@@ -8078,6 +8753,16 @@ function scopeAt(lines, upto, hasNamespace) {
|
|
|
8078
8753
|
for (const f2 of frames) for (const [k2, v2] of f2.aliases) aliases.set(k2, v2);
|
|
8079
8754
|
return { namespaces, opens: [...new Set(frames.flatMap((f2) => f2.opens))], aliases };
|
|
8080
8755
|
}
|
|
8756
|
+
function scopesAt(lines, uptos, hasNamespace) {
|
|
8757
|
+
const w2 = walker(lines, hasNamespace);
|
|
8758
|
+
const out = new Array(uptos.length);
|
|
8759
|
+
const order = uptos.map((_2, k2) => k2).sort((a3, b2) => uptos[a3] - uptos[b2]);
|
|
8760
|
+
for (const k2 of order) out[k2] = scopeOf(w2.to(uptos[k2]));
|
|
8761
|
+
return out;
|
|
8762
|
+
}
|
|
8763
|
+
function scopeAt(lines, upto, hasNamespace) {
|
|
8764
|
+
return scopeOf(walk(lines, upto, hasNamespace));
|
|
8765
|
+
}
|
|
8081
8766
|
function contextAt(lines, upto, hasNamespace) {
|
|
8082
8767
|
const { stack: stack2, pending } = walk(lines, upto, hasNamespace);
|
|
8083
8768
|
const frames = pending ? [...stack2, pending] : stack2;
|
|
@@ -8210,249 +8895,6 @@ function renderComment(text2, on, g2) {
|
|
|
8210
8895
|
return render(text2, 0);
|
|
8211
8896
|
}
|
|
8212
8897
|
|
|
8213
|
-
// src/shared/reviewqueue.ts
|
|
8214
|
-
var TCB_SITES = SITE_STMT | SITE_BODY;
|
|
8215
|
-
function inTargets(g2, targets) {
|
|
8216
|
-
const out = new Uint16Array(g2.n);
|
|
8217
|
-
for (const t2 of targets) {
|
|
8218
|
-
const tcb = g2.reach([t2], TCB_SITES, "out");
|
|
8219
|
-
for (let i2 = 0; i2 < g2.n; i2++) out[i2] += tcb[i2];
|
|
8220
|
-
}
|
|
8221
|
-
return out;
|
|
8222
|
-
}
|
|
8223
|
-
function nonStandardAxiom(g2, i2) {
|
|
8224
|
-
return g2.nodes[i2].kind === "axiom" && !STANDARD_AXIOMS.includes(g2.nodes[i2].name);
|
|
8225
|
-
}
|
|
8226
|
-
function needsReview(g2, d2, i2) {
|
|
8227
|
-
return nonStandardAxiom(g2, i2) || !trusted(d2, g2.nodes[i2].name, g2.nodes[i2].module, g2.isExt(i2));
|
|
8228
|
-
}
|
|
8229
|
-
function trustSplit(g2, d2, s2, skip = -1) {
|
|
8230
|
-
let counted2 = 0, t2 = 0;
|
|
8231
|
-
for (let j2 = 0; j2 < s2.length; j2++) {
|
|
8232
|
-
if (!s2[j2] || j2 === skip) continue;
|
|
8233
|
-
if (needsReview(g2, d2, j2)) counted2++;
|
|
8234
|
-
else t2++;
|
|
8235
|
-
}
|
|
8236
|
-
return { counted: counted2, trusted: t2 };
|
|
8237
|
-
}
|
|
8238
|
-
function reviewSet(g2, d2, root) {
|
|
8239
|
-
return evaluate(reviewScope(g2.nodes[root].name), { g: g2, review: d2 });
|
|
8240
|
-
}
|
|
8241
|
-
var VIA = 8;
|
|
8242
|
-
function axiomsReached(g2, root, set) {
|
|
8243
|
-
const meta = g2.meta;
|
|
8244
|
-
const reach = g2.reach([root], ALL_SITES, "out");
|
|
8245
|
-
const names2 = /* @__PURE__ */ new Set();
|
|
8246
|
-
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
8247
|
-
if (!reach[i2]) continue;
|
|
8248
|
-
if (nonStandardAxiom(g2, i2)) names2.add(g2.nodes[i2].name);
|
|
8249
|
-
for (const k2 of meta.axiomSets[g2.nodes[i2].ax] ?? []) if (!STANDARD_AXIOMS.includes(meta.axioms[k2])) names2.add(meta.axioms[k2]);
|
|
8250
|
-
}
|
|
8251
|
-
const out = [];
|
|
8252
|
-
for (const name of [...names2].sort()) {
|
|
8253
|
-
const j2 = g2.byName.get(name);
|
|
8254
|
-
const node = j2 !== void 0 && set[j2] ? j2 : null;
|
|
8255
|
-
const via = [];
|
|
8256
|
-
if (node !== null) {
|
|
8257
|
-
for (let e2 = g2.inStart[node]; e2 < g2.inStart[node + 1]; e2++) if (reach[g2.inSrc[e2]] && g2.inSrc[e2] !== node && !via.includes(g2.inSrc[e2])) via.push(g2.inSrc[e2]);
|
|
8258
|
-
} else {
|
|
8259
|
-
const k2 = meta.axioms.indexOf(name);
|
|
8260
|
-
const rests = (i2) => k2 >= 0 && (meta.axiomSets[g2.nodes[i2].ax] ?? []).includes(k2);
|
|
8261
|
-
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
8262
|
-
if (!reach[i2] || !rests(i2)) continue;
|
|
8263
|
-
let deeper = false;
|
|
8264
|
-
for (let e2 = g2.outStart[i2]; e2 < g2.outStart[i2 + 1] && !deeper; e2++) deeper = g2.outDst[e2] !== i2 && rests(g2.outDst[e2]);
|
|
8265
|
-
if (!deeper) via.push(i2);
|
|
8266
|
-
}
|
|
8267
|
-
}
|
|
8268
|
-
via.sort((a3, b2) => Number(g2.isExt(a3)) - Number(g2.isExt(b2)) || (g2.nodes[a3].name < g2.nodes[b2].name ? -1 : 1));
|
|
8269
|
-
out.push({ name, node, via: via.slice(0, VIA) });
|
|
8270
|
-
}
|
|
8271
|
-
return out;
|
|
8272
|
-
}
|
|
8273
|
-
function reviewQueue(g2, d2, root, shared) {
|
|
8274
|
-
const set = reviewSet(g2, d2, root);
|
|
8275
|
-
const order = reviewOrder(g2, set, shared);
|
|
8276
|
-
const ax = order.filter((i2) => g2.nodes[i2].kind === "axiom");
|
|
8277
|
-
return { order: [...ax, ...order.filter((i2) => g2.nodes[i2].kind !== "axiom")], axioms: axiomsReached(g2, root, set) };
|
|
8278
|
-
}
|
|
8279
|
-
function offBoard(q2) {
|
|
8280
|
-
return q2.axioms.filter((a3) => a3.node === null);
|
|
8281
|
-
}
|
|
8282
|
-
function queueProgress(g2, d2, q2) {
|
|
8283
|
-
const p2 = { total: 0, approved: 0, commented: 0, stale: 0 };
|
|
8284
|
-
const count2 = (name, hash) => {
|
|
8285
|
-
p2.total++;
|
|
8286
|
-
const s2 = statusOf(d2, name, hash);
|
|
8287
|
-
if (s2 === "approved") p2.approved++;
|
|
8288
|
-
else if (s2 === "commented") p2.commented++;
|
|
8289
|
-
else if (s2 === "stale") p2.stale++;
|
|
8290
|
-
};
|
|
8291
|
-
for (const i2 of q2.order) count2(g2.nodes[i2].name, g2.nodes[i2].hash);
|
|
8292
|
-
for (const a3 of offBoard(q2)) count2(a3.name, void 0);
|
|
8293
|
-
return p2;
|
|
8294
|
-
}
|
|
8295
|
-
function reviewCount(g2, d2, root) {
|
|
8296
|
-
const set = reviewSet(g2, d2, root);
|
|
8297
|
-
let n3 = 0;
|
|
8298
|
-
for (let i2 = 0; i2 < g2.n; i2++) n3 += set[i2];
|
|
8299
|
-
return n3 + axiomsReached(g2, root, set).filter((a3) => a3.node === null).length;
|
|
8300
|
-
}
|
|
8301
|
-
function settled(d2, reader, name, hash, axiom) {
|
|
8302
|
-
return reviewedBy(d2, reader, name, hash) && (!axiom || statusOf(d2, name, hash) === "approved");
|
|
8303
|
-
}
|
|
8304
|
-
function reviewOrder(g2, set, shared) {
|
|
8305
|
-
const members = [];
|
|
8306
|
-
for (let i2 = 0; i2 < g2.n; i2++) if (set[i2]) members.push(i2);
|
|
8307
|
-
return dependencyOrder(g2, members, (x2, y2) => shared[x2] !== shared[y2] ? shared[x2] > shared[y2] : g2.nodes[x2].name < g2.nodes[y2].name);
|
|
8308
|
-
}
|
|
8309
|
-
function dependencyOrder(g2, members, before = (x2, y2) => g2.nodes[x2].name < g2.nodes[y2].name) {
|
|
8310
|
-
const local = /* @__PURE__ */ new Map();
|
|
8311
|
-
members.forEach((v2, k2) => local.set(v2, k2));
|
|
8312
|
-
const uses = members.map(() => []);
|
|
8313
|
-
members.forEach((u2, a3) => {
|
|
8314
|
-
for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
|
|
8315
|
-
const b2 = g2.outSite[e2] & TCB_SITES ? local.get(g2.outDst[e2]) : void 0;
|
|
8316
|
-
if (b2 !== void 0 && b2 !== a3) uses[a3].push(b2);
|
|
8317
|
-
}
|
|
8318
|
-
});
|
|
8319
|
-
return stepOrder(uses, (a3, b2) => before(members[a3], members[b2])).map((a3) => members[a3]);
|
|
8320
|
-
}
|
|
8321
|
-
function stepOrder(uses, before) {
|
|
8322
|
-
const m3 = uses.length;
|
|
8323
|
-
const comp = components(uses);
|
|
8324
|
-
const nc = comp.reduce((x2, c3) => Math.max(x2, c3 + 1), 0);
|
|
8325
|
-
const steps = Array.from({ length: nc }, () => []);
|
|
8326
|
-
for (let a3 = 0; a3 < m3; a3++) steps[comp[a3]].push(a3);
|
|
8327
|
-
for (const s2 of steps) s2.sort((a3, b2) => before(a3, b2) ? -1 : before(b2, a3) ? 1 : 0);
|
|
8328
|
-
const waiting = new Int32Array(nc);
|
|
8329
|
-
const usedBy = Array.from({ length: nc }, () => []);
|
|
8330
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8331
|
-
for (let a3 = 0; a3 < m3; a3++) {
|
|
8332
|
-
for (const b2 of uses[a3]) {
|
|
8333
|
-
const c3 = comp[a3], d2 = comp[b2];
|
|
8334
|
-
if (c3 === d2 || seen.has(c3 * nc + d2)) continue;
|
|
8335
|
-
seen.add(c3 * nc + d2);
|
|
8336
|
-
waiting[c3]++;
|
|
8337
|
-
usedBy[d2].push(c3);
|
|
8338
|
-
}
|
|
8339
|
-
}
|
|
8340
|
-
const ready = new Heap((c3, d2) => before(steps[c3][0], steps[d2][0]));
|
|
8341
|
-
for (let c3 = 0; c3 < nc; c3++) if (!waiting[c3]) ready.push(c3);
|
|
8342
|
-
const out = [];
|
|
8343
|
-
while (ready.size) {
|
|
8344
|
-
const c3 = ready.pop();
|
|
8345
|
-
for (const a3 of steps[c3]) out.push(a3);
|
|
8346
|
-
for (const d2 of usedBy[c3]) if (--waiting[d2] === 0) ready.push(d2);
|
|
8347
|
-
}
|
|
8348
|
-
return out;
|
|
8349
|
-
}
|
|
8350
|
-
function components(succ) {
|
|
8351
|
-
const n3 = succ.length;
|
|
8352
|
-
const index = new Int32Array(n3).fill(-1);
|
|
8353
|
-
const low = new Int32Array(n3);
|
|
8354
|
-
const comp = new Int32Array(n3).fill(-1);
|
|
8355
|
-
const onStack = new Uint8Array(n3);
|
|
8356
|
-
const stack2 = [];
|
|
8357
|
-
let next = 0, nc = 0;
|
|
8358
|
-
const enter = (v2) => {
|
|
8359
|
-
index[v2] = low[v2] = next++;
|
|
8360
|
-
stack2.push(v2);
|
|
8361
|
-
onStack[v2] = 1;
|
|
8362
|
-
};
|
|
8363
|
-
for (let s2 = 0; s2 < n3; s2++) {
|
|
8364
|
-
if (index[s2] >= 0) continue;
|
|
8365
|
-
enter(s2);
|
|
8366
|
-
const path = [[s2, 0]];
|
|
8367
|
-
while (path.length) {
|
|
8368
|
-
const top = path[path.length - 1];
|
|
8369
|
-
const v2 = top[0];
|
|
8370
|
-
if (top[1] < succ[v2].length) {
|
|
8371
|
-
const w2 = succ[v2][top[1]++];
|
|
8372
|
-
if (index[w2] < 0) {
|
|
8373
|
-
enter(w2);
|
|
8374
|
-
path.push([w2, 0]);
|
|
8375
|
-
} else if (onStack[w2]) low[v2] = Math.min(low[v2], index[w2]);
|
|
8376
|
-
continue;
|
|
8377
|
-
}
|
|
8378
|
-
path.pop();
|
|
8379
|
-
if (path.length) {
|
|
8380
|
-
const u2 = path[path.length - 1][0];
|
|
8381
|
-
low[u2] = Math.min(low[u2], low[v2]);
|
|
8382
|
-
}
|
|
8383
|
-
if (low[v2] === index[v2]) {
|
|
8384
|
-
let w2;
|
|
8385
|
-
do {
|
|
8386
|
-
w2 = stack2.pop();
|
|
8387
|
-
onStack[w2] = 0;
|
|
8388
|
-
comp[w2] = nc;
|
|
8389
|
-
} while (w2 !== v2);
|
|
8390
|
-
nc++;
|
|
8391
|
-
}
|
|
8392
|
-
}
|
|
8393
|
-
}
|
|
8394
|
-
return comp;
|
|
8395
|
-
}
|
|
8396
|
-
var Heap = class {
|
|
8397
|
-
xs = [];
|
|
8398
|
-
before;
|
|
8399
|
-
constructor(before) {
|
|
8400
|
-
this.before = before;
|
|
8401
|
-
}
|
|
8402
|
-
get size() {
|
|
8403
|
-
return this.xs.length;
|
|
8404
|
-
}
|
|
8405
|
-
push(x2) {
|
|
8406
|
-
const xs = this.xs;
|
|
8407
|
-
xs.push(x2);
|
|
8408
|
-
for (let k2 = xs.length - 1; k2 > 0; ) {
|
|
8409
|
-
const p2 = k2 - 1 >> 1;
|
|
8410
|
-
if (!this.before(xs[k2], xs[p2])) break;
|
|
8411
|
-
[xs[k2], xs[p2]] = [xs[p2], xs[k2]];
|
|
8412
|
-
k2 = p2;
|
|
8413
|
-
}
|
|
8414
|
-
}
|
|
8415
|
-
pop() {
|
|
8416
|
-
const xs = this.xs;
|
|
8417
|
-
const top = xs[0];
|
|
8418
|
-
const last2 = xs.pop();
|
|
8419
|
-
if (xs.length) {
|
|
8420
|
-
xs[0] = last2;
|
|
8421
|
-
for (let k2 = 0; ; ) {
|
|
8422
|
-
const l2 = 2 * k2 + 1, r2 = l2 + 1;
|
|
8423
|
-
let best = k2;
|
|
8424
|
-
if (l2 < xs.length && this.before(xs[l2], xs[best])) best = l2;
|
|
8425
|
-
if (r2 < xs.length && this.before(xs[r2], xs[best])) best = r2;
|
|
8426
|
-
if (best === k2) break;
|
|
8427
|
-
[xs[k2], xs[best]] = [xs[best], xs[k2]];
|
|
8428
|
-
k2 = best;
|
|
8429
|
-
}
|
|
8430
|
-
}
|
|
8431
|
-
return top;
|
|
8432
|
-
}
|
|
8433
|
-
};
|
|
8434
|
-
function whyChain(g2, from, to) {
|
|
8435
|
-
const parent = new Int32Array(g2.n).fill(-1);
|
|
8436
|
-
parent[from] = from;
|
|
8437
|
-
const queue = [from];
|
|
8438
|
-
for (let k2 = 0; k2 < queue.length && parent[to] < 0; k2++) {
|
|
8439
|
-
const u2 = queue[k2];
|
|
8440
|
-
for (let e2 = g2.outStart[u2]; e2 < g2.outStart[u2 + 1]; e2++) {
|
|
8441
|
-
const v2 = g2.outDst[e2];
|
|
8442
|
-
if (!(g2.outSite[e2] & TCB_SITES) || parent[v2] >= 0) continue;
|
|
8443
|
-
parent[v2] = u2;
|
|
8444
|
-
queue.push(v2);
|
|
8445
|
-
}
|
|
8446
|
-
}
|
|
8447
|
-
if (parent[to] < 0) return null;
|
|
8448
|
-
const path = [to];
|
|
8449
|
-
while (path[path.length - 1] !== from) path.push(parent[path[path.length - 1]]);
|
|
8450
|
-
return path.reverse();
|
|
8451
|
-
}
|
|
8452
|
-
function reviewedBy(d2, reader, name, hash) {
|
|
8453
|
-
return !!reader && current(d2, name).some((o2) => o2.by === reader && fresh(o2, hash));
|
|
8454
|
-
}
|
|
8455
|
-
|
|
8456
8898
|
// src/web/src/linediff.ts
|
|
8457
8899
|
var MAX_CELLS = 4e6;
|
|
8458
8900
|
function lineDiff(before, after, context = 2) {
|
|
@@ -9529,6 +9971,7 @@ var Talk = class {
|
|
|
9529
9971
|
if (t2.closest("[data-fold]")) return this.toggleFold();
|
|
9530
9972
|
if (t2.closest("[data-cv-older]")) return void this.older();
|
|
9531
9973
|
if (t2.closest("[data-cv-new]")) return void this.restart();
|
|
9974
|
+
if (t2.closest("[data-cv-stop]")) return void this.stopTurn();
|
|
9532
9975
|
if (t2.closest("[data-cv-link]")) return void this.insertSeen();
|
|
9533
9976
|
if (t2.closest("[data-cv-name]")) return void this.hooks.ensureName();
|
|
9534
9977
|
const site = t2.closest("[data-site]");
|
|
@@ -9635,11 +10078,21 @@ var Talk = class {
|
|
|
9635
10078
|
else el.scrollTop = top;
|
|
9636
10079
|
}
|
|
9637
10080
|
this.renderPill();
|
|
10081
|
+
this.renderRestart();
|
|
9638
10082
|
if (this.named) {
|
|
9639
10083
|
for (const c3 of this.channels()) if (!this.read.has(c3)) void this.load(c3);
|
|
9640
10084
|
}
|
|
9641
10085
|
this.count();
|
|
9642
10086
|
}
|
|
10087
|
+
/** Stop the answer an agent the server runs is giving (AgentSpec decision 10): its maker's, as
|
|
10088
|
+
* Esc in a terminal is for an agent run there. */
|
|
10089
|
+
async stopTurn() {
|
|
10090
|
+
const a3 = this.agentOf(this.channel);
|
|
10091
|
+
if (!a3 || a3.runs !== "server") return;
|
|
10092
|
+
const r2 = await this.hooks.data.stopAgent(a3.id);
|
|
10093
|
+
this.error = r2.error ?? null;
|
|
10094
|
+
this.renderForm(false);
|
|
10095
|
+
}
|
|
9643
10096
|
/** Read a channel, once per connection: what it holds now, with what came meanwhile. */
|
|
9644
10097
|
async load(channel) {
|
|
9645
10098
|
if (!this.named || this.read.has(channel) || this.loading.has(channel)) return;
|
|
@@ -9934,13 +10387,15 @@ var Talk = class {
|
|
|
9934
10387
|
renderRestart() {
|
|
9935
10388
|
const b2 = this.el.querySelector("[data-cv-new]");
|
|
9936
10389
|
const a3 = this.named ? this.agentOf(this.channel) : null;
|
|
10390
|
+
const stop = this.el.querySelector("[data-cv-stop]");
|
|
10391
|
+
if (stop) stop.hidden = !(a3 && a3.runs === "server" && (a3.talk?.state === "thinking" || a3.talk?.state === "working"));
|
|
9937
10392
|
if (!b2) return;
|
|
9938
10393
|
b2.hidden = !a3;
|
|
9939
10394
|
if (!a3) return;
|
|
9940
10395
|
const t2 = this.threads.get(this.channel) ?? [];
|
|
9941
10396
|
const off = this.loading.has(this.channel) || this.restarting || fresh2(t2);
|
|
9942
10397
|
b2.setAttribute("aria-disabled", String(off));
|
|
9943
|
-
b2.title = fresh2(t2) ? "A new conversation already: nothing was said since it began" : `New conversation: what was said so far folds away, and the next session of ${a3.name ?? "the agent"} starts without it. A session running now is told to disregard it, but keeps what it was told: only /clear in its own terminal erases that.`;
|
|
10398
|
+
b2.title = fresh2(t2) ? "A new conversation already: nothing was said since it began" : a3.runs === "server" ? `New conversation: what was said so far folds away, and ${a3.name ?? "the agent"} starts a new session without it (it runs on this server).` : `New conversation: what was said so far folds away, and the next session of ${a3.name ?? "the agent"} starts without it. A session running now is told to disregard it, but keeps what it was told: only /clear in its own terminal erases that.`;
|
|
9944
10399
|
}
|
|
9945
10400
|
/** The pill the window collapses to: the channel on show and the start of its last message. */
|
|
9946
10401
|
renderPill() {
|
|
@@ -10080,7 +10535,9 @@ var Share = class {
|
|
|
10080
10535
|
people = null;
|
|
10081
10536
|
/** the form as the reader left it: kept while the page is open; the name is null while the reader
|
|
10082
10537
|
* has not written one, and the agent is then theirs ("Alice's AI") */
|
|
10083
|
-
form = { name: null, level: "", days: 0 };
|
|
10538
|
+
form = { name: null, level: "", days: 0, runs: null, claude: "" };
|
|
10539
|
+
/** the reader asked to give their Claude token anew (Replace) */
|
|
10540
|
+
claudeEdit = false;
|
|
10084
10541
|
/** a Revoke pressed once, waiting for the second press */
|
|
10085
10542
|
arming = null;
|
|
10086
10543
|
busy = false;
|
|
@@ -10114,7 +10571,12 @@ var Share = class {
|
|
|
10114
10571
|
else if (t2.closest("[data-again]")) {
|
|
10115
10572
|
this.agent = { kind: "form", error: null };
|
|
10116
10573
|
this.render();
|
|
10117
|
-
} else if (t2.closest("[data-
|
|
10574
|
+
} else if (t2.closest("[data-claude-replace]")) {
|
|
10575
|
+
this.claudeEdit = true;
|
|
10576
|
+
this.render();
|
|
10577
|
+
this.pop.querySelector("[data-f=claude]")?.focus();
|
|
10578
|
+
} else if (t2.closest("[data-claude-remove]")) void this.removeClaude();
|
|
10579
|
+
else if (t2.closest("[data-show]")) void this.showPrompt(t2.closest("[data-show]").dataset.show);
|
|
10118
10580
|
else if (t2.closest("[data-revoke]")) void this.revoke(t2.closest("[data-revoke]").dataset.revoke);
|
|
10119
10581
|
else if (t2.closest("[data-close]")) this.close();
|
|
10120
10582
|
});
|
|
@@ -10124,7 +10586,11 @@ var Share = class {
|
|
|
10124
10586
|
const f2 = t2.dataset.f;
|
|
10125
10587
|
if (!f2) return;
|
|
10126
10588
|
if (f2 === "days") this.form.days = Number(t2.value);
|
|
10127
|
-
else
|
|
10589
|
+
else if (f2 === "runs") {
|
|
10590
|
+
this.form.runs = t2.value === "server" ? "server" : "agent";
|
|
10591
|
+
this.render();
|
|
10592
|
+
return void this.pop.querySelector("[data-f=runs]")?.focus();
|
|
10593
|
+
} else this.form[f2] = t2.value;
|
|
10128
10594
|
const as = this.pop.querySelector("[data-as]");
|
|
10129
10595
|
if (f2 === "name" && as) as.textContent = this.actsAs(t2.value);
|
|
10130
10596
|
});
|
|
@@ -10187,7 +10653,7 @@ var Share = class {
|
|
|
10187
10653
|
this.pop.hidden = false;
|
|
10188
10654
|
this.btn.classList.add("on");
|
|
10189
10655
|
this.arming = null;
|
|
10190
|
-
if (this.agent.kind
|
|
10656
|
+
if (this.agent.kind !== "form") this.agent = { kind: "form", error: null };
|
|
10191
10657
|
this.info = await this.shareInfo();
|
|
10192
10658
|
if (this.info.readOnly) return this.show("readonly");
|
|
10193
10659
|
if (this.tab === "readonly" && !this.readOnlyTab()) this.tab = "person";
|
|
@@ -10244,7 +10710,7 @@ var Share = class {
|
|
|
10244
10710
|
if (!this.shares.levels.includes(this.form.level)) this.form.level = this.shares.defaultLevel;
|
|
10245
10711
|
if (!this.shares.days.includes(this.form.days)) this.form.days = this.shares.defaultDays;
|
|
10246
10712
|
const a3 = this.agent;
|
|
10247
|
-
if (a3.kind
|
|
10713
|
+
if (a3.kind !== "form" && !this.shares.tokens.some((t2) => t2.id === a3.id)) this.agent = { kind: "form", error: null };
|
|
10248
10714
|
}
|
|
10249
10715
|
if (!this.pop.hidden) this.render();
|
|
10250
10716
|
}
|
|
@@ -10386,6 +10852,10 @@ var Share = class {
|
|
|
10386
10852
|
}
|
|
10387
10853
|
agentBody() {
|
|
10388
10854
|
const s2 = this.shares;
|
|
10855
|
+
if (this.agent.kind === "started") {
|
|
10856
|
+
const a3 = this.agent;
|
|
10857
|
+
return `<div class="sh-title">${escapeHtml(a3.name)} runs on this server</div><div class="sh-note">It listens now, on your Claude Code: talk to it in its conversation (its name, above the board), or mention <b>@${escapeHtml(a3.name)}</b> in the public channel. It runs until revoked, below.</div><div class="modal-actions"><button class="rv-btn" data-again>Another agent</button><button class="rv-btn primary" data-close>Done</button></div>`;
|
|
10858
|
+
}
|
|
10389
10859
|
if (this.agent.kind === "prompt") {
|
|
10390
10860
|
const a3 = this.agent;
|
|
10391
10861
|
const how = a3.made ? `Paste it into the agent. <b>It holds the agent's token</b>: give it to that agent only, and revoke it below when done.` : `<b>It holds the agent's token</b>: give it to that agent only.`;
|
|
@@ -10395,8 +10865,34 @@ var Share = class {
|
|
|
10395
10865
|
const f2 = this.form;
|
|
10396
10866
|
const me = this.hooks.me();
|
|
10397
10867
|
const name = f2.name ?? (me ? defaultAgentName(me) : "");
|
|
10398
|
-
const option = (v2, label, on) => `<option value="${v2}"${on ? " selected" : ""}>${escapeHtml(label)}</option>`;
|
|
10399
|
-
|
|
10868
|
+
const option = (v2, label, on, off = "") => `<option value="${v2}"${on ? " selected" : ""}${off ? ` disabled title="${escapeHtml(off)}"` : ""}>${escapeHtml(label)}</option>`;
|
|
10869
|
+
const here = this.runsHere();
|
|
10870
|
+
const sv = s2.server;
|
|
10871
|
+
return `<div class="sh-form"><label class="sh-field"><span>Name</span><input data-f="name" maxlength="60" spellcheck="false" value="${escapeHtml(name)}" placeholder="Your name's AI"></label><label class="sh-field"><span>May</span><select data-f="level">${s2.levels.map((l2) => option(l2, LEVEL_HINT[l2] ?? l2, l2 === f2.level)).join("")}</select></label>` + (sv ? `<label class="sh-field"><span>Runs</span><select data-f="runs">${option("agent", "in your agent \u2014 a prompt to paste", !here)}${option("server", "on this server \u2014 your Claude Code", here, sv.available ? sv.refused ?? "" : "Claude Code is not on this server's machine")}</select></label>` : "") + (here ? "" : `<label class="sh-field"><span>For</span><select data-f="days">${s2.days.map((d2) => option(d2, d2 === 1 ? "1 day" : `${d2} days`, d2 === f2.days)).join("")}</select></label>`) + (here ? this.claudeField() : "") + `</div><div class="sh-note muted">Its own token, under your name: it acts as <i data-as>${escapeHtml(this.actsAs(name))}</i>${here ? ", here until revoked" : ""}.${s2.levels.length < 3 ? ` This server lets agents do at most ${escapeHtml(s2.level)}.` : ""}</div>` + (sv && f2.runs === "server" && sv.refused ? `<div class="modal-err">${escapeHtml(sv.refused)}</div>` : "") + (this.agent.error ? `<div class="modal-err">${escapeHtml(this.agent.error)}</div>` : "") + `<div class="modal-actions"><button class="rv-btn" data-close>Close</button><button class="rv-btn primary" data-create${this.busy ? " disabled" : ""}>${here ? "Start" : "Create"}</button></div>`;
|
|
10872
|
+
}
|
|
10873
|
+
/** Whether the agent is to run on this server (AgentSpec decision 10): as the reader chose; else
|
|
10874
|
+
* where they may and have given a Claude token in use, there; else a prompt. */
|
|
10875
|
+
runsHere() {
|
|
10876
|
+
const sv = this.shares?.server;
|
|
10877
|
+
if (!sv || !sv.available || sv.refused) return false;
|
|
10878
|
+
if (this.form.runs) return this.form.runs === "server";
|
|
10879
|
+
return !!sv.token && !sv.token.refused;
|
|
10880
|
+
}
|
|
10881
|
+
/** The reader's Claude Code token, for the agent on this server: given (Replace, Remove), refused,
|
|
10882
|
+
* or none yet — a password field, never filled back. */
|
|
10883
|
+
claudeField() {
|
|
10884
|
+
const t2 = this.shares?.server?.token ?? null;
|
|
10885
|
+
if (t2 && !t2.refused && !this.claudeEdit)
|
|
10886
|
+
return `<div class="sh-note">On your Claude Code token, given ${escapeHtml(ago(t2.given))}. <button class="rv-btn sh-act" data-claude-replace title="Give a new one: the agents you run here use it from their next answer">Replace</button> <button class="rv-btn sh-act" data-claude-remove title="This server forgets it, and your agents here stop">Remove</button></div>`;
|
|
10887
|
+
return `<label class="sh-field"><span>Claude token</span><input type="password" data-f="claude" autocomplete="off" spellcheck="false" placeholder="sk-ant-oat01-\u2026" value="${escapeHtml(this.form.claude)}"></label><div class="sh-note muted">${t2?.refused ? `<b>Claude Code refused your token</b> ${escapeHtml(ago(t2.refused))}: give a new one. ` : ""}In a terminal: <code>claude setup-token</code>, then paste what it prints. Kept on this server for your agents only, never shown again. Every answer spends your Claude usage, whoever asks (experimental).</div>`;
|
|
10888
|
+
}
|
|
10889
|
+
/** Remove the reader's Claude token: the server forgets it, and their agents here stop. */
|
|
10890
|
+
async removeClaude() {
|
|
10891
|
+
if (!await this.hooks.ensureName()) return;
|
|
10892
|
+
const r2 = await this.hooks.data.removeClaude();
|
|
10893
|
+
if (r2.error) this.agent = { kind: "form", error: r2.error };
|
|
10894
|
+
await this.refresh();
|
|
10895
|
+
this.render();
|
|
10400
10896
|
}
|
|
10401
10897
|
/** The name an agent named `name` would act under: the reader's AI when the field is empty,
|
|
10402
10898
|
* numbered when one in force has it. */
|
|
@@ -10418,7 +10914,9 @@ var Share = class {
|
|
|
10418
10914
|
const shown2 = this.agent.kind === "prompt" && this.agent.id === t2.id && this.tab === "agent";
|
|
10419
10915
|
const id = escapeHtml(t2.id);
|
|
10420
10916
|
const mine = madeBy(t2, { name: this.hooks.me(), person: this.hooks.person?.() ?? null });
|
|
10421
|
-
|
|
10917
|
+
const here = t2.runs === "server";
|
|
10918
|
+
const prompt = mine && !here;
|
|
10919
|
+
return `<div class="sh-tok${shown2 ? " on" : ""}"><div class="sh-tok-text"${prompt ? ` data-show="${id}" title="Show its prompt again"` : here ? ` title="It runs on this server, on ${escapeHtml(t2.by)}'s Claude Code"` : ` title="Its prompt is shown again to ${escapeHtml(t2.by)} alone, who made it"`}><div>${BOT}<b>${escapeHtml(t2.name)}</b> <span class="sh-lvl">${escapeHtml(t2.level)}</span>${here ? ` <span class="sh-lvl">on this server</span>` : ""}</div><div class="muted">by ${escapeHtml(t2.by)}, ${escapeHtml(ago(t2.created))} \xB7 ${here ? "until revoked" : `expires ${escapeHtml(until(t2.expires))}`} \xB7 ${t2.lastUsed ? `last used ${escapeHtml(ago(t2.lastUsed))}` : "not used yet"}</div></div>` + (prompt ? `<button class="rv-btn sh-act" data-show="${id}" aria-pressed="${shown2}" title="Its prompt, with the token, to give the agent again">Show prompt</button>` : "") + `<button class="rv-btn sh-act${armed ? " bad" : ""}" data-revoke="${id}" title="It lets the agent in no more, at once">${armed ? "Revoke it" : "Revoke"}</button></div>`;
|
|
10422
10920
|
}
|
|
10423
10921
|
/** Make the token and its prompt, under the reader's name (asked for if there is none). */
|
|
10424
10922
|
async create() {
|
|
@@ -10431,13 +10929,29 @@ var Share = class {
|
|
|
10431
10929
|
this.busy = true;
|
|
10432
10930
|
this.render();
|
|
10433
10931
|
const f2 = this.form;
|
|
10434
|
-
const
|
|
10932
|
+
const here = this.runsHere();
|
|
10933
|
+
if (here && f2.claude.trim()) {
|
|
10934
|
+
const g2 = await this.hooks.data.giveClaude(f2.claude.trim());
|
|
10935
|
+
if ("error" in g2) {
|
|
10936
|
+
this.busy = false;
|
|
10937
|
+
this.agent = { kind: "form", error: g2.error };
|
|
10938
|
+
return this.render();
|
|
10939
|
+
}
|
|
10940
|
+
f2.claude = "";
|
|
10941
|
+
this.claudeEdit = false;
|
|
10942
|
+
if (this.shares?.server) this.shares.server.token = g2.token;
|
|
10943
|
+
}
|
|
10944
|
+
const r2 = await this.hooks.data.shareAgent({ name: f2.name?.trim() || void 0, level: f2.level, days: f2.days, ...here ? { runs: "server" } : {} });
|
|
10435
10945
|
this.busy = false;
|
|
10436
10946
|
if ("error" in r2) {
|
|
10437
10947
|
this.agent = { kind: "form", error: r2.error };
|
|
10438
10948
|
return this.render();
|
|
10439
10949
|
}
|
|
10440
10950
|
if (this.shares) this.shares.tokens = r2.tokens;
|
|
10951
|
+
if (r2.prompt === void 0) {
|
|
10952
|
+
this.agent = { kind: "started", id: r2.token.id, name: r2.token.name };
|
|
10953
|
+
return this.render();
|
|
10954
|
+
}
|
|
10441
10955
|
const copied = await copy(r2.prompt);
|
|
10442
10956
|
this.agent = { kind: "prompt", id: r2.token.id, prompt: r2.prompt, name: r2.token.name, made: true, copied };
|
|
10443
10957
|
this.showArea();
|
|
@@ -10986,8 +11500,12 @@ var FOLLOWED = [
|
|
|
10986
11500
|
},
|
|
10987
11501
|
{
|
|
10988
11502
|
part: "sources",
|
|
10989
|
-
what: "the source windows: the one following the selection and each pinned one \u2014 open, collapsed or not, on what",
|
|
10990
|
-
fields: ["source", "sourceCollapsed", "pinned"],
|
|
11503
|
+
what: "the source windows: the one following the selection and each pinned one \u2014 open, collapsed or not, on what, showing the declaration or the whole file (File mode); a file window, opened on a file",
|
|
11504
|
+
fields: ["source", "sourceCollapsed", "sourceMode", "pinned"],
|
|
11505
|
+
// a file opened from the Files tree, where a press opens a file window (the owner's decision of
|
|
11506
|
+
// 2026-11-01); in a window, its switch between the declaration and the file is a control of it,
|
|
11507
|
+
// as its pin is
|
|
11508
|
+
changes: "#outline [data-o-file]",
|
|
10991
11509
|
reads: ".sw-win",
|
|
10992
11510
|
keys: [" "],
|
|
10993
11511
|
dblclick: ".sw-win:not(.collapsed) .sw-head",
|
|
@@ -11002,6 +11520,17 @@ var FOLLOWED = [
|
|
|
11002
11520
|
dblclick: ".pw-win:not(.collapsed) .pw-head",
|
|
11003
11521
|
place: true
|
|
11004
11522
|
},
|
|
11523
|
+
{
|
|
11524
|
+
part: "caret",
|
|
11525
|
+
// ReviewSpec, "The InfoView" (the owner's decision of 2026-11-01): one reader steps through a
|
|
11526
|
+
// proof, those following them watch. ↑ and ↓ step it, in a source window: no page's key, they end
|
|
11527
|
+
// following as any key does that is not the reader's own
|
|
11528
|
+
what: "the InfoView's caret: the source window it is in, where in the file, and the goals before or after the tactic there",
|
|
11529
|
+
fields: ["caret"],
|
|
11530
|
+
changes: ".sw-info [data-iv-when]",
|
|
11531
|
+
reads: ".sw-info",
|
|
11532
|
+
place: true
|
|
11533
|
+
},
|
|
11005
11534
|
{
|
|
11006
11535
|
part: "activity",
|
|
11007
11536
|
what: "Activity: open or closed, and its filters",
|
|
@@ -11065,6 +11594,9 @@ var YOURS = [
|
|
|
11065
11594
|
{ id: "tcbOrder", what: "the TCB list's order, and what of it is kept to by the reader's own review", where: "[data-tcb-order], [data-q-own]" },
|
|
11066
11595
|
// the review box's opinions all folded or all shown (ReviewSpec, "One review box", the owner's
|
|
11067
11596
|
// decision of 2026-10-20), a reading preference, and What changed under a stale one opened
|
|
11597
|
+
// File mode's proofs folded (the owner's decision of 2026-11-01): the reader's own, kept in the
|
|
11598
|
+
// browser, as is a folded proof opened
|
|
11599
|
+
{ id: "proofFolds", what: "File mode's proofs folded to a line each, and a folded proof opened", where: "[data-sw-folds], [data-pf-open]" },
|
|
11068
11600
|
{ id: "opinions", what: "the review box's opinions, all folded or all shown, and What changed under a stale one", where: "[data-rv-fold], [data-rv-changes] > summary" },
|
|
11069
11601
|
{ id: "outline", what: "the outline's levels opened", where: "#outline .tw" },
|
|
11070
11602
|
{ id: "whatChanged", what: `"What changed" opened: the Time Machine's counts and the lists they open`, where: "#tmbar .tm-sum, [data-tm-list], #tm-list" },
|
|
@@ -11101,8 +11633,10 @@ var YOURS = [
|
|
|
11101
11633
|
// link followed from a message — the reader's own tool changing a followed part, which says so
|
|
11102
11634
|
// itself (web/src/talk.ts) — and Esc; its button and a mention's notice open it
|
|
11103
11635
|
{ id: "conversation", what: "the conversation window \u2014 its channels, its thread, its box, a link to what you see \u2014, the conversation button and a mention's notice", where: "#convo, #talk-btn, #talk-notice", whole: true },
|
|
11104
|
-
{ id: "followingStrip", what: "the following strip: whom you follow, and its \u2715", where: "#following", whole: true },
|
|
11636
|
+
{ id: "followingStrip", what: "the following strip: whom you follow, and its \u2715; once following has ended by a move, Follow again", where: "#following", whole: true },
|
|
11105
11637
|
{ id: "hoverCards", what: "hover cards", where: ".hcard" },
|
|
11638
|
+
// the InfoView hidden or shown (ReviewSpec, "The InfoView"): how the reader looks at the source
|
|
11639
|
+
{ id: "infoView", what: "the InfoView hidden or shown, in every source window (kept in the browser)", where: "[data-iv-hide], [data-iv-show]" },
|
|
11106
11640
|
// the downloads of a followed reader's Export window (the owner's decision of 2026-10-21): taking
|
|
11107
11641
|
// the file is reading, as copying text is; every other control of the window ends following
|
|
11108
11642
|
{ id: "exportDownloads", what: "the downloads the Export window offers: the PDF, the LaTeX sources, the .tex and the .sty", where: "#export-modal .ex-dl a" },
|
|
@@ -11382,6 +11916,10 @@ var People = class {
|
|
|
11382
11916
|
store;
|
|
11383
11917
|
hooks;
|
|
11384
11918
|
followed = null;
|
|
11919
|
+
/** whom following last ended with by the reader's own action (the owner's decision of
|
|
11920
|
+
* 2026-10-30): the strip offers to follow them again until the reader answers it, follows anyone,
|
|
11921
|
+
* or they leave */
|
|
11922
|
+
again = null;
|
|
11385
11923
|
/** the followed reader's place as last gone to: their place again (a presence list that changed
|
|
11386
11924
|
* elsewhere) is not gone to again */
|
|
11387
11925
|
applied = "";
|
|
@@ -11654,7 +12192,7 @@ var People = class {
|
|
|
11654
12192
|
return this.unfollow();
|
|
11655
12193
|
}
|
|
11656
12194
|
if (!acts(e2)) return;
|
|
11657
|
-
this.
|
|
12195
|
+
this.leave();
|
|
11658
12196
|
};
|
|
11659
12197
|
window.addEventListener(
|
|
11660
12198
|
"keydown",
|
|
@@ -11667,14 +12205,20 @@ var People = class {
|
|
|
11667
12205
|
{ capture: true }
|
|
11668
12206
|
);
|
|
11669
12207
|
for (const ev of ["pointerdown", "wheel", "keydown", "dblclick"]) window.addEventListener(ev, stop, { capture: true });
|
|
11670
|
-
window.addEventListener("popstate", () => this.
|
|
12208
|
+
window.addEventListener("popstate", () => this.leave());
|
|
11671
12209
|
$3("#peers").addEventListener("click", (e2) => {
|
|
11672
12210
|
const b2 = e2.target.closest("[data-person]");
|
|
11673
12211
|
if (!b2) return;
|
|
11674
12212
|
if (!this.hooks.menu?.(b2.dataset.person, b2)) this.follow(b2.dataset.person);
|
|
11675
12213
|
});
|
|
11676
12214
|
$3("#following").addEventListener("click", (e2) => {
|
|
11677
|
-
|
|
12215
|
+
const t2 = e2.target;
|
|
12216
|
+
if (t2.closest("[data-unfollow]")) this.unfollow();
|
|
12217
|
+
else if (t2.closest("[data-again]")) {
|
|
12218
|
+
const key = this.again?.key;
|
|
12219
|
+
this.dropAgain();
|
|
12220
|
+
if (key) this.follow(key);
|
|
12221
|
+
} else if (t2.closest("[data-dismiss]")) this.dropAgain();
|
|
11678
12222
|
});
|
|
11679
12223
|
void this.beat();
|
|
11680
12224
|
}
|
|
@@ -11736,6 +12280,7 @@ var People = class {
|
|
|
11736
12280
|
this.followersChanged();
|
|
11737
12281
|
this.hooks.changed();
|
|
11738
12282
|
this.hooks.roomChanged?.();
|
|
12283
|
+
if (this.again && !this.people().some((x2) => x2.key === this.again.key)) this.dropAgain();
|
|
11739
12284
|
if (!this.followed) return;
|
|
11740
12285
|
const p2 = this.people().find((x2) => x2.key === this.followed.key);
|
|
11741
12286
|
if (!p2) {
|
|
@@ -11796,7 +12341,7 @@ var People = class {
|
|
|
11796
12341
|
const s2 = p2.sessions[0];
|
|
11797
12342
|
const where = s2.view ? this.hooks.describe(s2.view) : "";
|
|
11798
12343
|
const who = p2.name ? this.nameOf(p2) : "A reader without a name";
|
|
11799
|
-
const talk = s2.talk ? ` \xB7 ${stateWords(s2.talk)}` : "";
|
|
12344
|
+
const talk = s2.talk ? `${s2.runs === "server" ? ` \xB7 on this server, ${s2.by ?? "its maker"}'s Claude Code` : ""} \xB7 ${stateWords(s2.talk)}` : "";
|
|
11800
12345
|
const ask = p2.agent ? null : this.hooks.asked?.(p2) ?? null;
|
|
11801
12346
|
const does = !this.hooks.menu ? "click to follow" : p2.agent ? `click to follow${s2.talk ? " or talk with it" : " it"}` : "click to follow, or to ask them to follow you";
|
|
11802
12347
|
const fol = following.has(p2.key);
|
|
@@ -11818,11 +12363,13 @@ var People = class {
|
|
|
11818
12363
|
if (!p2) return;
|
|
11819
12364
|
if (this.followed?.key === key) return this.unfollow();
|
|
11820
12365
|
if (this.followed) this.hooks.unfollowed();
|
|
12366
|
+
this.again = null;
|
|
11821
12367
|
this.followed = { key, name: this.nameOf(p2) };
|
|
11822
12368
|
this.applied = "";
|
|
11823
12369
|
this.toldFollowing();
|
|
11824
12370
|
const box = $3("#following");
|
|
11825
12371
|
box.style.setProperty("--c", this.colorOf(p2));
|
|
12372
|
+
box.classList.remove("again");
|
|
11826
12373
|
this.renderStrip(p2.agent);
|
|
11827
12374
|
box.hidden = false;
|
|
11828
12375
|
document.body.classList.add("following");
|
|
@@ -11843,10 +12390,36 @@ var People = class {
|
|
|
11843
12390
|
const strip = $3(".fl-strip");
|
|
11844
12391
|
strip.textContent = why;
|
|
11845
12392
|
setTimeout(() => {
|
|
11846
|
-
if (!this.followed) box.hidden = true;
|
|
12393
|
+
if (!this.followed && !this.again) box.hidden = true;
|
|
11847
12394
|
}, 2500);
|
|
11848
12395
|
} else box.hidden = true;
|
|
11849
12396
|
}
|
|
12397
|
+
/** Following ended by the reader's own action — a move, a control of what they were shown, Back or
|
|
12398
|
+
* Forward, a link followed from the conversation (CollabSpec decision 4): the strip stays, offering
|
|
12399
|
+
* to follow the same reader again (the owner's decision of 2026-10-30). Esc and the strip's ✕,
|
|
12400
|
+
* which mean to stop, end it without the offer, as the followed reader leaving does. */
|
|
12401
|
+
leave() {
|
|
12402
|
+
const was = this.followed;
|
|
12403
|
+
if (!was) return;
|
|
12404
|
+
this.unfollow();
|
|
12405
|
+
const p2 = this.people().find((x2) => x2.key === was.key);
|
|
12406
|
+
if (!p2) return;
|
|
12407
|
+
this.again = was;
|
|
12408
|
+
const box = $3("#following");
|
|
12409
|
+
box.style.setProperty("--c", this.colorOf(p2));
|
|
12410
|
+
box.classList.add("again");
|
|
12411
|
+
$3(".fl-strip").innerHTML = `<span class="dot"></span>${p2.agent ? BOT : ""}<span class="fl-who">Stopped following <b>${escapeHtml(was.name)}</b></span><button data-again type="button" class="fl-again">Follow again</button><button data-dismiss type="button" title="Close" aria-label="Close">\u2715</button>`;
|
|
12412
|
+
box.hidden = false;
|
|
12413
|
+
}
|
|
12414
|
+
/** Put the offer to follow again away. */
|
|
12415
|
+
dropAgain() {
|
|
12416
|
+
if (!this.again) return;
|
|
12417
|
+
this.again = null;
|
|
12418
|
+
const box = $3("#following");
|
|
12419
|
+
box.classList.remove("again");
|
|
12420
|
+
if (box.contains(document.activeElement)) document.activeElement.blur();
|
|
12421
|
+
if (!this.followed) box.hidden = true;
|
|
12422
|
+
}
|
|
11850
12423
|
/** The strip: "Following X · Esc to stop", and its ✕. */
|
|
11851
12424
|
renderStrip(agent) {
|
|
11852
12425
|
$3(".fl-strip").innerHTML = `<span class="dot"></span>${agent ? BOT : ""}<span class="fl-who">Following <b>${escapeHtml(this.followed?.name ?? "")}</b> \xB7 Esc to stop</span><button data-unfollow type="button" title="Stop following" aria-label="Stop following">\u2715</button>`;
|
|
@@ -14232,64 +14805,6 @@ var WholeReview = class {
|
|
|
14232
14805
|
}
|
|
14233
14806
|
};
|
|
14234
14807
|
|
|
14235
|
-
// src/shared/excerpt.ts
|
|
14236
|
-
var DECL = /^\s*(?:@\[[^\]]*\]\s*)*(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def)\s+(\S+)/;
|
|
14237
|
-
var NEXT = /^(?:@\[|\/--|\/-!|--|#|(?:(?:private|protected|noncomputable|partial|unsafe|nonrec|scoped|local)\s+)*(?:theorem|lemma|def|abbrev|instance|structure|class|inductive|axiom|opaque|example|irreducible_def|namespace|section|end|open|variable|universe|attribute|set_option|mutual|macro|syntax|notation|infix|infixl|infixr|prefix|postfix|elab|deriving)\b)/;
|
|
14238
|
-
function withPreamble(lines, line) {
|
|
14239
|
-
let start = line;
|
|
14240
|
-
while (start > 0 && line - start < 40) {
|
|
14241
|
-
const above = lines[start - 1];
|
|
14242
|
-
if (/^\s*@\[[^\]]*\]\s*$/.test(above) || /^\s*--/.test(above)) {
|
|
14243
|
-
start--;
|
|
14244
|
-
continue;
|
|
14245
|
-
}
|
|
14246
|
-
if (/-\/\s*$/.test(above)) {
|
|
14247
|
-
let k2 = start - 1;
|
|
14248
|
-
while (k2 > 0 && line - k2 < 60 && !/^\s*\/-/.test(lines[k2])) k2--;
|
|
14249
|
-
if (/^\s*\/--/.test(lines[k2])) {
|
|
14250
|
-
start = k2;
|
|
14251
|
-
continue;
|
|
14252
|
-
}
|
|
14253
|
-
}
|
|
14254
|
-
break;
|
|
14255
|
-
}
|
|
14256
|
-
return start;
|
|
14257
|
-
}
|
|
14258
|
-
function compiledExcerpt(lines, range) {
|
|
14259
|
-
const l0 = Math.max(0, range[0] - 1);
|
|
14260
|
-
const l1 = Math.min(lines.length - 1, Math.max(l0, range[2] - 1));
|
|
14261
|
-
return { start: withPreamble(lines, l0), end: l1 };
|
|
14262
|
-
}
|
|
14263
|
-
function excerptOf(lines, edited, name, range) {
|
|
14264
|
-
return edited ? findExcerpt(lines, name, range[0]) : compiledExcerpt(lines, range);
|
|
14265
|
-
}
|
|
14266
|
-
function findExcerpt(lines, name, near) {
|
|
14267
|
-
const parts = name.split(".");
|
|
14268
|
-
const short6 = parts[parts.length - 1].replace(/^«|»$/g, "");
|
|
14269
|
-
const tail2 = parts.slice(-2).join(".");
|
|
14270
|
-
let best = -1;
|
|
14271
|
-
let bestScore = Infinity;
|
|
14272
|
-
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
14273
|
-
const m3 = DECL.exec(lines[i2]);
|
|
14274
|
-
if (!m3) continue;
|
|
14275
|
-
const declared = m3[1].replace(/[«»]/g, "");
|
|
14276
|
-
if (declared !== short6 && declared !== tail2.replace(/[«»]/g, "") && declared !== name && !name.endsWith("." + declared)) continue;
|
|
14277
|
-
const score2 = near ? Math.abs(i2 + 1 - near) : i2;
|
|
14278
|
-
if (score2 < bestScore) {
|
|
14279
|
-
bestScore = score2;
|
|
14280
|
-
best = i2;
|
|
14281
|
-
}
|
|
14282
|
-
}
|
|
14283
|
-
if (best < 0) return null;
|
|
14284
|
-
let end = best;
|
|
14285
|
-
for (let i2 = best + 1; i2 < lines.length && i2 < best + 400; i2++) {
|
|
14286
|
-
if (NEXT.test(lines[i2])) break;
|
|
14287
|
-
end = i2;
|
|
14288
|
-
}
|
|
14289
|
-
while (end > best && !lines[end].trim()) end--;
|
|
14290
|
-
return { start: withPreamble(lines, best), end };
|
|
14291
|
-
}
|
|
14292
|
-
|
|
14293
14808
|
// src/shared/context.ts
|
|
14294
14809
|
function exactContext(m3, name, hash) {
|
|
14295
14810
|
if (!m3 || !hash || m3.hash !== hash) return null;
|
|
@@ -14726,6 +15241,25 @@ var ReviewFlow = class {
|
|
|
14726
15241
|
}
|
|
14727
15242
|
};
|
|
14728
15243
|
|
|
15244
|
+
// src/shared/build.ts
|
|
15245
|
+
function applyBuildDelta(held2, d2) {
|
|
15246
|
+
if (d2.epoch !== held2.epoch || d2.base !== held2.rev) return null;
|
|
15247
|
+
const changed2 = new Map(d2.files.map((f2) => [f2.module, f2]));
|
|
15248
|
+
const gone = new Set(d2.gone);
|
|
15249
|
+
const files = [];
|
|
15250
|
+
for (const f2 of held2.status?.files ?? []) {
|
|
15251
|
+
if (gone.has(f2.module)) continue;
|
|
15252
|
+
const c3 = changed2.get(f2.module);
|
|
15253
|
+
files.push(c3 ?? f2);
|
|
15254
|
+
if (c3) changed2.delete(f2.module);
|
|
15255
|
+
}
|
|
15256
|
+
files.push(...changed2.values());
|
|
15257
|
+
return { epoch: d2.epoch, rev: d2.rev, status: { active: d2.active, progress: d2.progress, files, counts: d2.counts } };
|
|
15258
|
+
}
|
|
15259
|
+
function isCompiledText(compiled, now) {
|
|
15260
|
+
return !!compiled && !!now && compiled === now;
|
|
15261
|
+
}
|
|
15262
|
+
|
|
14729
15263
|
// src/web/src/pagereview.ts
|
|
14730
15264
|
function reviewPart(page) {
|
|
14731
15265
|
const { data, store: store2, S: S7, kept, reader } = page;
|
|
@@ -14748,7 +15282,7 @@ function reviewPart(page) {
|
|
|
14748
15282
|
if (known2 !== void 0) return known2;
|
|
14749
15283
|
const c3 = page.compiled.get(mod);
|
|
14750
15284
|
const src = await data.source(mod);
|
|
14751
|
-
const e2 = !!
|
|
15285
|
+
const e2 = !!src && !isCompiledText(c3, src.hash);
|
|
14752
15286
|
edits.set(mod, e2);
|
|
14753
15287
|
served.set(mod, src ? src.text.split("\n") : null);
|
|
14754
15288
|
servedContexts.set(mod, { contexts: src?.contexts ?? null, hash: src?.hash ?? null });
|
|
@@ -15012,6 +15546,15 @@ function reviewPart(page) {
|
|
|
15012
15546
|
};
|
|
15013
15547
|
}
|
|
15014
15548
|
|
|
15549
|
+
// src/shared/hygiene.ts
|
|
15550
|
+
function hygienic(name) {
|
|
15551
|
+
return name.includes("._@.");
|
|
15552
|
+
}
|
|
15553
|
+
function withoutMacroScopes(name) {
|
|
15554
|
+
const k2 = name.indexOf("._@.");
|
|
15555
|
+
return k2 < 0 ? name : name.slice(0, k2);
|
|
15556
|
+
}
|
|
15557
|
+
|
|
15015
15558
|
// src/web/src/targetlist.ts
|
|
15016
15559
|
function targetRows(targets, views) {
|
|
15017
15560
|
const linked = new Map(views.flatMap((v2) => (v2.targets ?? []).map((t2) => [t2, v2])));
|
|
@@ -15337,10 +15880,15 @@ function interpretsHtml(g2, i2) {
|
|
|
15337
15880
|
function genNote() {
|
|
15338
15881
|
return "Generated by Lean from the command at this place: not written in the source.";
|
|
15339
15882
|
}
|
|
15883
|
+
function generatedName(unit, a3) {
|
|
15884
|
+
const n3 = withoutMacroScopes(a3);
|
|
15885
|
+
return { short: n3.startsWith(unit + ".") ? n3.slice(unit.length + 1) : n3.split(".").pop(), hygienic: hygienic(a3) };
|
|
15886
|
+
}
|
|
15340
15887
|
function alsoList(unit, also) {
|
|
15341
15888
|
return also.map((a3) => {
|
|
15342
|
-
const short6
|
|
15343
|
-
|
|
15889
|
+
const { short: short6, hygienic: hygienic2 } = generatedName(unit, a3);
|
|
15890
|
+
const title = hygienic2 ? `${withoutMacroScopes(a3)}: written by the macro of the command that writes ${unit}, under a name of its hygiene (${a3}), and part of it` : `${a3}: generated by Lean from the command that writes ${unit}, and part of it`;
|
|
15891
|
+
return `<span class="p-decl" title="${escapeHtml(title)}">${escapeHtml(short6)}</span>`;
|
|
15344
15892
|
}).join(", ");
|
|
15345
15893
|
}
|
|
15346
15894
|
|
|
@@ -15711,6 +16259,11 @@ var FloatWindow = class {
|
|
|
15711
16259
|
this.watch.observe(el);
|
|
15712
16260
|
}
|
|
15713
16261
|
}
|
|
16262
|
+
/** Whether it is fitted to its content now: it grows and shrinks with it (the InfoView beside the
|
|
16263
|
+
* code, web/src/infoview.ts). */
|
|
16264
|
+
get fitted() {
|
|
16265
|
+
return this.fitting;
|
|
16266
|
+
}
|
|
15714
16267
|
/** Bring the window to the front of the others; one on top is there already. */
|
|
15715
16268
|
front() {
|
|
15716
16269
|
if (this.o.onTop || stack[stack.length - 1] === this.el) return;
|
|
@@ -15928,6 +16481,9 @@ function pastNote(when, commit, check, outside2) {
|
|
|
15928
16481
|
}
|
|
15929
16482
|
|
|
15930
16483
|
// src/web/src/hovercards.ts
|
|
16484
|
+
function afterClick(clicked, word) {
|
|
16485
|
+
return clicked && word === clicked ? { show: false, clicked } : { show: true, clicked: "" };
|
|
16486
|
+
}
|
|
15931
16487
|
var GRACE_MS = 350;
|
|
15932
16488
|
var OPEN_MS = 280;
|
|
15933
16489
|
var HoverCards = class {
|
|
@@ -16087,6 +16643,411 @@ var HoverCards = class {
|
|
|
16087
16643
|
}
|
|
16088
16644
|
};
|
|
16089
16645
|
|
|
16646
|
+
// src/shared/goals.ts
|
|
16647
|
+
function codeLines(text2) {
|
|
16648
|
+
const lines = text2.split("\n");
|
|
16649
|
+
const out = lines.map(() => false);
|
|
16650
|
+
let inComment = 0;
|
|
16651
|
+
lines.forEach((l2, k2) => {
|
|
16652
|
+
let i2 = 0;
|
|
16653
|
+
while (i2 < l2.length) {
|
|
16654
|
+
if (inComment) {
|
|
16655
|
+
if (l2.startsWith("-/", i2)) {
|
|
16656
|
+
inComment--;
|
|
16657
|
+
i2 += 2;
|
|
16658
|
+
} else if (l2.startsWith("/-", i2)) {
|
|
16659
|
+
inComment++;
|
|
16660
|
+
i2 += 2;
|
|
16661
|
+
} else i2++;
|
|
16662
|
+
continue;
|
|
16663
|
+
}
|
|
16664
|
+
if (l2.startsWith("/-", i2)) {
|
|
16665
|
+
inComment++;
|
|
16666
|
+
i2 += 2;
|
|
16667
|
+
continue;
|
|
16668
|
+
}
|
|
16669
|
+
if (l2.startsWith("--", i2)) break;
|
|
16670
|
+
if (l2[i2] === '"') {
|
|
16671
|
+
out[k2] = true;
|
|
16672
|
+
let j2 = i2 + 1;
|
|
16673
|
+
while (j2 < l2.length && l2[j2] !== '"') j2 += l2[j2] === "\\" ? 2 : 1;
|
|
16674
|
+
i2 = j2 + 1;
|
|
16675
|
+
continue;
|
|
16676
|
+
}
|
|
16677
|
+
if (!/\s/.test(l2[i2])) out[k2] = true;
|
|
16678
|
+
i2++;
|
|
16679
|
+
}
|
|
16680
|
+
});
|
|
16681
|
+
return out;
|
|
16682
|
+
}
|
|
16683
|
+
function stepLine(text2, k2, dir) {
|
|
16684
|
+
const has = codeLines(text2);
|
|
16685
|
+
const lines = text2.split("\n");
|
|
16686
|
+
for (let j2 = k2 + dir; j2 >= 0 && j2 < lines.length; j2 += dir) if (has[j2]) return { line: j2, ch: /^\s*/.exec(lines[j2])[0].length };
|
|
16687
|
+
return null;
|
|
16688
|
+
}
|
|
16689
|
+
|
|
16690
|
+
// src/web/src/infoview.ts
|
|
16691
|
+
var SLOW_MS = 300;
|
|
16692
|
+
var AGAIN_MS = 900;
|
|
16693
|
+
var SIDE_MIN = 700;
|
|
16694
|
+
var FITTED_MIN = 540;
|
|
16695
|
+
var SCREEN_MIN = 1e3;
|
|
16696
|
+
function paneSide(winWidth, fitted, screenWidth) {
|
|
16697
|
+
if (screenWidth < SCREEN_MIN && winWidth < SIDE_MIN) return false;
|
|
16698
|
+
return winWidth >= (fitted && screenWidth >= SCREEN_MIN ? FITTED_MIN : SIDE_MIN);
|
|
16699
|
+
}
|
|
16700
|
+
function caretOf(text2, offset) {
|
|
16701
|
+
const before = text2.slice(0, Math.max(0, Math.min(offset, text2.length)));
|
|
16702
|
+
const nl = before.lastIndexOf("\n");
|
|
16703
|
+
return { line: before.split("\n").length - 1, ch: before.length - (nl + 1) };
|
|
16704
|
+
}
|
|
16705
|
+
function taggedHtml(t2, isRef) {
|
|
16706
|
+
if (typeof t2 === "string") return highlightLean(t2, (w2) => isRef(w2));
|
|
16707
|
+
if (Array.isArray(t2)) return t2.map((x2) => taggedHtml(x2, isRef)).join("");
|
|
16708
|
+
return `<span class="iv-t${t2.d ? ` iv-${t2.d}` : ""}" data-k="${t2.k}">${taggedHtml(t2.t, isRef)}</span>`;
|
|
16709
|
+
}
|
|
16710
|
+
function locals(hyps) {
|
|
16711
|
+
return new Set(hyps.flatMap((h2) => h2.names));
|
|
16712
|
+
}
|
|
16713
|
+
function hypHtml(h2, isRef) {
|
|
16714
|
+
const d2 = h2.d ? ` iv-${h2.d}` : "";
|
|
16715
|
+
return `<div class="iv-hyp${d2}"><span class="iv-names">${h2.names.map(escapeHtml).join(" ")}</span><span class="iv-colon"> : </span><span class="iv-type">${taggedHtml(h2.type, isRef)}${h2.val !== void 0 ? `<span class="iv-colon"> := </span>${taggedHtml(h2.val, isRef)}` : ""}</span></div>`;
|
|
16716
|
+
}
|
|
16717
|
+
function goalHtml(g2, resolve) {
|
|
16718
|
+
const own2 = locals(g2.hyps);
|
|
16719
|
+
const isRef = (w2) => own2.has(w2) || own2.has(w2.split(".")[0]) ? null : resolve(w2);
|
|
16720
|
+
const d2 = g2.d ? ` iv-${g2.d}` : "";
|
|
16721
|
+
return `<div class="iv-goal${d2}">` + (g2.case ? `<div class="iv-case">case <b>${escapeHtml(g2.case)}</b></div>` : "") + g2.hyps.map((h2) => hypHtml(h2, isRef)).join("") + `<div class="iv-target"><span class="iv-turn">${escapeHtml((g2.prefix ?? "\u22A2 ").trim())}</span> ${taggedHtml(g2.type, isRef)}</div></div>`;
|
|
16722
|
+
}
|
|
16723
|
+
function paneView(caret, off, answer, resolve) {
|
|
16724
|
+
const say = (cls, text2) => ({ show: true, sides: false, html: `<p class="${cls}">${escapeHtml(text2)}</p>` });
|
|
16725
|
+
if (!caret) return { show: false, sides: false, html: "" };
|
|
16726
|
+
if (off) return say("iv-off", off);
|
|
16727
|
+
if (!answer) return say("iv-wait", "Asking Lean\u2026");
|
|
16728
|
+
if (answer.off) return say("iv-off", answer.off);
|
|
16729
|
+
if (answer.pending) return say("iv-wait", `Lean has elaborated line ${answer.pending.line.toLocaleString("en")} of ${answer.pending.of.toLocaleString("en")}\u2026`);
|
|
16730
|
+
if (answer.error) return say("iv-err", `Lean could not be asked: ${answer.error}`);
|
|
16731
|
+
const goals = caret.after ? answer.after : answer.before;
|
|
16732
|
+
const any = answer.before != null || answer.after != null;
|
|
16733
|
+
if (!any && !answer.term && !answer.widgets) return { show: false, sides: false, html: "" };
|
|
16734
|
+
let html = "";
|
|
16735
|
+
if (answer.widgets) html += `<p class="iv-widget" title="Its JavaScript is the project's own code: VisualProof never runs it in a reader's browser.">A widget here: open it in your editor.</p>`;
|
|
16736
|
+
if (any) {
|
|
16737
|
+
const n3 = goals?.length ?? 0;
|
|
16738
|
+
html += `<div class="iv-h">${goals == null ? "No tactic state here" : n3 === 0 ? "No goals" : n3 === 1 ? "1 goal" : `${n3} goals`}</div>`;
|
|
16739
|
+
if (caret.after && answer.afterFrom !== void 0 && goals)
|
|
16740
|
+
html += `<p class="iv-note" title="The tactic holds a proof of its own, which ends inside it: these are the goals after the whole line, where the proof goes on">As line ${answer.afterFrom + 1} begins, after the whole line</p>`;
|
|
16741
|
+
html += (goals ?? []).map((g2) => goalHtml(g2, resolve)).join("");
|
|
16742
|
+
}
|
|
16743
|
+
if (answer.term) {
|
|
16744
|
+
html += `<div class="iv-h">Expected type</div>`;
|
|
16745
|
+
html += goalHtml({ hyps: goals?.length ? [] : answer.term.hyps, type: answer.term.type }, resolve);
|
|
16746
|
+
}
|
|
16747
|
+
return { show: true, sides: any, html };
|
|
16748
|
+
}
|
|
16749
|
+
function headHtml(caret, sides, interactive) {
|
|
16750
|
+
const seg = sides ? `<span class="iv-seg" role="group" aria-label="The goals before or after the tactic"><button type="button" data-iv-when="before" aria-pressed="${!caret.after}" title="The goals before the tactic at the caret">Before</button><button type="button" data-iv-when="after" aria-pressed="${caret.after}" title="The goals after it">After</button></span>` : "";
|
|
16751
|
+
return `<div class="iv-head"><span class="iv-title">InfoView</span><span class="iv-where" title="${interactive ? "Hover a subterm for its type" : ""}">line ${caret.line + 1}, column ${caret.ch + 1}</span>${seg}<button type="button" class="icon iv-hide" data-iv-hide aria-label="Hide the InfoView" title="Hide the InfoView in every source window (kept in this browser)">${HIDE}</button></div>`;
|
|
16752
|
+
}
|
|
16753
|
+
var HIDE = `<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M6 4l4 4-4 4"/></svg>`;
|
|
16754
|
+
var InfoView = class {
|
|
16755
|
+
hooks;
|
|
16756
|
+
code = null;
|
|
16757
|
+
caret = null;
|
|
16758
|
+
answer = null;
|
|
16759
|
+
/** bumped at each new question, so that a slow answer to an earlier one is dropped */
|
|
16760
|
+
turn = 0;
|
|
16761
|
+
pane = null;
|
|
16762
|
+
/** a line of the file in the code on show: the code's element, or the window's way of finding
|
|
16763
|
+
* one (File mode's pieces, drawn as they are reached) */
|
|
16764
|
+
lines = null;
|
|
16765
|
+
again = null;
|
|
16766
|
+
slow = null;
|
|
16767
|
+
/** the subterm the pointer rests on, and the wait before its card */
|
|
16768
|
+
hot = null;
|
|
16769
|
+
hoverWait = null;
|
|
16770
|
+
hoverTurn = 0;
|
|
16771
|
+
sizer = null;
|
|
16772
|
+
constructor(hooks) {
|
|
16773
|
+
this.hooks = hooks;
|
|
16774
|
+
}
|
|
16775
|
+
/** The window drew its frame: the pane's element in it, the code's element — or how the element of
|
|
16776
|
+
* a line of the file is found (File mode, the owner's decision of 2026-11-01: the whole file, in
|
|
16777
|
+
* pieces) —, and the code on show (null: none). A caret outside the code on show goes. */
|
|
16778
|
+
attach(pane, lines, code) {
|
|
16779
|
+
const was = this.code;
|
|
16780
|
+
this.code = code;
|
|
16781
|
+
this.lines = lines;
|
|
16782
|
+
if (this.pane !== pane) {
|
|
16783
|
+
this.pane = pane;
|
|
16784
|
+
if (pane) this.listen(pane);
|
|
16785
|
+
}
|
|
16786
|
+
const same2 = !!was && !!code && was.module === code.module && was.hash === code.hash;
|
|
16787
|
+
if (!same2) this.answer = null;
|
|
16788
|
+
if (this.caret && !this.holds(this.caret.line)) this.caret = null;
|
|
16789
|
+
this.watchSize();
|
|
16790
|
+
if (this.caret && !same2) this.ask();
|
|
16791
|
+
else this.draw();
|
|
16792
|
+
}
|
|
16793
|
+
/** The element of line `line` of the file in the code on show, or null. */
|
|
16794
|
+
lineEl(line) {
|
|
16795
|
+
const c3 = this.code, l2 = this.lines;
|
|
16796
|
+
if (!c3 || !l2) return null;
|
|
16797
|
+
return typeof l2 === "function" ? l2(line) : l2.querySelectorAll(".ln")[line - c3.start] ?? null;
|
|
16798
|
+
}
|
|
16799
|
+
/** Whether line `line` of the file is in the code on show. */
|
|
16800
|
+
holds(line) {
|
|
16801
|
+
const c3 = this.code;
|
|
16802
|
+
return !!c3 && line >= c3.start && line < c3.start + c3.text.split("\n").length;
|
|
16803
|
+
}
|
|
16804
|
+
/** The caret put at (line, ch) of the file by the reader: a click, the keyboard's caret. */
|
|
16805
|
+
place(line, ch) {
|
|
16806
|
+
if (!this.holds(line)) return;
|
|
16807
|
+
const after = this.caret?.after ?? false;
|
|
16808
|
+
if (this.caret && this.caret.line === line && this.caret.ch === ch) return;
|
|
16809
|
+
this.caret = { line, ch, after };
|
|
16810
|
+
this.ask();
|
|
16811
|
+
this.hooks.moved();
|
|
16812
|
+
}
|
|
16813
|
+
/** ↑ or ↓: the caret to the previous or next line of code, where its code starts, the line
|
|
16814
|
+
* scrolled into sight. False where there is nothing to step to. */
|
|
16815
|
+
step(dir) {
|
|
16816
|
+
const c3 = this.code, k2 = this.caret;
|
|
16817
|
+
if (!c3 || !k2) return false;
|
|
16818
|
+
const to = stepLine(c3.text, k2.line - c3.start, dir);
|
|
16819
|
+
if (!to) return false;
|
|
16820
|
+
this.caret = { line: c3.start + to.line, ch: to.ch, after: k2.after };
|
|
16821
|
+
this.ask();
|
|
16822
|
+
this.hooks.moved();
|
|
16823
|
+
this.lineEl(c3.start + to.line)?.scrollIntoView({ block: "nearest" });
|
|
16824
|
+
return true;
|
|
16825
|
+
}
|
|
16826
|
+
/** The caret as a followed reader's is (CollabSpec, "Surfaces"), or none: nobody is told. */
|
|
16827
|
+
follow(c3) {
|
|
16828
|
+
const k2 = this.caret;
|
|
16829
|
+
if (!c3) return void (k2 && this.clear());
|
|
16830
|
+
if (k2 && k2.line === c3.line && k2.ch === c3.ch && k2.after === c3.after) return;
|
|
16831
|
+
const moved = !k2 || k2.line !== c3.line || k2.ch !== c3.ch;
|
|
16832
|
+
this.caret = { ...c3 };
|
|
16833
|
+
if (!this.code) return;
|
|
16834
|
+
if (!this.holds(c3.line)) return;
|
|
16835
|
+
if (moved) {
|
|
16836
|
+
this.ask();
|
|
16837
|
+
this.lineEl(c3.line)?.scrollIntoView({ block: "nearest" });
|
|
16838
|
+
} else this.draw();
|
|
16839
|
+
}
|
|
16840
|
+
/** No caret here any more: another window holds the page's. */
|
|
16841
|
+
clear() {
|
|
16842
|
+
if (!this.caret) return;
|
|
16843
|
+
this.caret = null;
|
|
16844
|
+
this.turn++;
|
|
16845
|
+
this.stopWaits();
|
|
16846
|
+
this.draw();
|
|
16847
|
+
}
|
|
16848
|
+
/** The window goes. */
|
|
16849
|
+
dispose() {
|
|
16850
|
+
this.turn++;
|
|
16851
|
+
this.stopWaits();
|
|
16852
|
+
this.sizer?.disconnect();
|
|
16853
|
+
this.sizer = null;
|
|
16854
|
+
this.pane = null;
|
|
16855
|
+
this.lines = null;
|
|
16856
|
+
}
|
|
16857
|
+
stopWaits() {
|
|
16858
|
+
if (this.again) clearTimeout(this.again);
|
|
16859
|
+
if (this.slow) clearTimeout(this.slow);
|
|
16860
|
+
if (this.hoverWait) clearTimeout(this.hoverWait);
|
|
16861
|
+
this.again = this.slow = this.hoverWait = null;
|
|
16862
|
+
}
|
|
16863
|
+
/** Lean asked what is at the caret; until it answers, the pane shows what it showed, and after a
|
|
16864
|
+
* moment that it asks. A place Lean has not reached yet is asked again until it has, the pane
|
|
16865
|
+
* saying how far Lean is meanwhile. */
|
|
16866
|
+
ask(again = false) {
|
|
16867
|
+
const c3 = this.code, k2 = this.caret;
|
|
16868
|
+
this.stopWaits();
|
|
16869
|
+
const turn = ++this.turn;
|
|
16870
|
+
if (!c3 || !k2 || c3.off) {
|
|
16871
|
+
this.answer = null;
|
|
16872
|
+
return this.draw();
|
|
16873
|
+
}
|
|
16874
|
+
if (!again)
|
|
16875
|
+
this.slow = setTimeout(() => {
|
|
16876
|
+
if (turn !== this.turn) return;
|
|
16877
|
+
this.answer = null;
|
|
16878
|
+
this.draw();
|
|
16879
|
+
}, SLOW_MS);
|
|
16880
|
+
this.marks();
|
|
16881
|
+
void this.hooks.goals(c3.module, k2.line, k2.ch, c3.hash).then((a3) => {
|
|
16882
|
+
if (turn !== this.turn) return;
|
|
16883
|
+
if (this.slow) clearTimeout(this.slow);
|
|
16884
|
+
this.slow = null;
|
|
16885
|
+
if (a3?.stale) return this.hooks.stale();
|
|
16886
|
+
this.answer = a3 ?? { off: "There is no Lean to ask here." };
|
|
16887
|
+
this.draw();
|
|
16888
|
+
if (a3?.pending) this.again = setTimeout(() => turn === this.turn && this.ask(true), AGAIN_MS);
|
|
16889
|
+
});
|
|
16890
|
+
}
|
|
16891
|
+
/** The pane drawn again as it stands, and the caret's line and tactic marked in the code. */
|
|
16892
|
+
draw() {
|
|
16893
|
+
this.marks();
|
|
16894
|
+
const pane = this.pane;
|
|
16895
|
+
if (!pane) return;
|
|
16896
|
+
const k2 = this.caret;
|
|
16897
|
+
const split = pane.parentElement;
|
|
16898
|
+
const v2 = paneView(k2, this.code?.off ?? null, this.answer, (w2) => this.hooks.resolve(w2));
|
|
16899
|
+
const hidden = this.hooks.hidden();
|
|
16900
|
+
const focused = document.activeElement;
|
|
16901
|
+
pane.hidden = !v2.show || hidden;
|
|
16902
|
+
split?.classList.toggle("iv-on", v2.show && !hidden);
|
|
16903
|
+
let tab = split?.querySelector(":scope > .iv-show") ?? null;
|
|
16904
|
+
if (v2.show && hidden && split) {
|
|
16905
|
+
if (!tab) {
|
|
16906
|
+
tab = document.createElement("button");
|
|
16907
|
+
tab.type = "button";
|
|
16908
|
+
tab.className = "iv-show";
|
|
16909
|
+
tab.dataset.ivShow = "";
|
|
16910
|
+
tab.title = "Show the InfoView: what Lean says at the caret (kept in this browser)";
|
|
16911
|
+
tab.innerHTML = `<span aria-hidden="true">\u22A2</span> Lean`;
|
|
16912
|
+
split.prepend(tab);
|
|
16913
|
+
}
|
|
16914
|
+
} else tab?.remove();
|
|
16915
|
+
const had = focused instanceof HTMLElement && (pane.contains(focused) || focused.matches("[data-iv-show]")) ? focused : null;
|
|
16916
|
+
const when = had?.closest("[data-iv-when]")?.dataset.ivWhen;
|
|
16917
|
+
if (!v2.show || hidden || !k2) {
|
|
16918
|
+
if (had) this.hooks.win().focus({ preventScroll: true });
|
|
16919
|
+
return;
|
|
16920
|
+
}
|
|
16921
|
+
pane.innerHTML = headHtml(k2, v2.sides, !!this.answer?.interactive) + `<div class="iv-body">${v2.html}</div>`;
|
|
16922
|
+
pane.setAttribute("aria-label", "What Lean says at the caret");
|
|
16923
|
+
if (had && !had.isConnected) (pane.querySelector(`[data-iv-when="${when}"]`) ?? this.hooks.win()).focus({ preventScroll: true });
|
|
16924
|
+
}
|
|
16925
|
+
/** The caret's line marked in the code, and its tactic, where the browser can (the CSS Custom
|
|
16926
|
+
* Highlight API): marks the code keeps however often it is drawn again. */
|
|
16927
|
+
marks() {
|
|
16928
|
+
const c3 = this.code, k2 = this.caret;
|
|
16929
|
+
for (const l2 of this.hooks.win().querySelectorAll(".ln.ln-caret")) l2.classList.remove("ln-caret");
|
|
16930
|
+
const hl = globalThis.CSS?.highlights;
|
|
16931
|
+
const Hl = globalThis.Highlight;
|
|
16932
|
+
if (!c3 || !k2 || !this.holds(k2.line)) return;
|
|
16933
|
+
const ln = this.lineEl(k2.line);
|
|
16934
|
+
ln?.classList.add("ln-caret");
|
|
16935
|
+
const a3 = this.answer;
|
|
16936
|
+
const t2 = a3 && (a3.before || a3.after) ? a3.tactic : null;
|
|
16937
|
+
if (!hl || !Hl || !ln) return;
|
|
16938
|
+
if (!t2 || t2.line !== k2.line || t2.to <= t2.from) return void hl.delete("vp-tactic");
|
|
16939
|
+
const r2 = rangeIn(ln, t2.from, t2.to);
|
|
16940
|
+
if (r2) hl.set("vp-tactic", new Hl(r2));
|
|
16941
|
+
}
|
|
16942
|
+
/** The pane's own controls and hover: before or after, hide and show, a subterm's card. */
|
|
16943
|
+
listen(pane) {
|
|
16944
|
+
const split = pane.parentElement;
|
|
16945
|
+
split?.addEventListener("click", (e2) => {
|
|
16946
|
+
const t2 = e2.target;
|
|
16947
|
+
if (t2.closest("[data-iv-show]")) {
|
|
16948
|
+
this.hooks.hide(false);
|
|
16949
|
+
return;
|
|
16950
|
+
}
|
|
16951
|
+
if (!pane.contains(t2)) return;
|
|
16952
|
+
if (t2.closest("[data-iv-hide]")) return this.hooks.hide(true);
|
|
16953
|
+
const when = t2.closest("[data-iv-when]")?.dataset.ivWhen;
|
|
16954
|
+
if (when && this.caret && this.caret.after !== (when === "after")) {
|
|
16955
|
+
this.caret = { ...this.caret, after: when === "after" };
|
|
16956
|
+
this.draw();
|
|
16957
|
+
this.hooks.moved();
|
|
16958
|
+
}
|
|
16959
|
+
});
|
|
16960
|
+
pane.addEventListener("mousemove", (e2) => {
|
|
16961
|
+
if (e2.buttons) return;
|
|
16962
|
+
const t2 = e2.target;
|
|
16963
|
+
const sub = this.answer?.interactive ? t2.closest(".iv-t") : null;
|
|
16964
|
+
const ref = t2.closest("[data-ref]");
|
|
16965
|
+
const on = sub ?? ref;
|
|
16966
|
+
if (this.hoverWait) clearTimeout(this.hoverWait);
|
|
16967
|
+
if (!on || !pane.contains(on)) {
|
|
16968
|
+
this.heat(null);
|
|
16969
|
+
return this.hooks.cards.leave();
|
|
16970
|
+
}
|
|
16971
|
+
if (on === this.hot && this.hooks.cards.open) return;
|
|
16972
|
+
this.hoverWait = setTimeout(() => this.hover(on), 150);
|
|
16973
|
+
});
|
|
16974
|
+
pane.addEventListener("mouseleave", () => {
|
|
16975
|
+
if (this.hoverWait) clearTimeout(this.hoverWait);
|
|
16976
|
+
this.heat(null);
|
|
16977
|
+
this.hooks.cards.leave();
|
|
16978
|
+
});
|
|
16979
|
+
}
|
|
16980
|
+
/** The subterm the pointer rests on, outlined. */
|
|
16981
|
+
heat(el) {
|
|
16982
|
+
if (this.hot === el) return;
|
|
16983
|
+
this.hot?.classList.remove("iv-hot");
|
|
16984
|
+
this.hot = el;
|
|
16985
|
+
el?.classList.add("iv-hot");
|
|
16986
|
+
}
|
|
16987
|
+
/** A card for what the pointer rests on in the pane: a subterm's type and doc, as Lean says them;
|
|
16988
|
+
* a name's card, as in the code, where Lean's goals are plain. */
|
|
16989
|
+
async hover(on) {
|
|
16990
|
+
const turn = ++this.hoverTurn;
|
|
16991
|
+
this.heat(on.matches(".iv-t") ? on : null);
|
|
16992
|
+
const box = on.getBoundingClientRect();
|
|
16993
|
+
const k2 = on.dataset.k;
|
|
16994
|
+
const c3 = this.code, caret = this.caret;
|
|
16995
|
+
if (k2 === void 0 || !c3 || !caret) {
|
|
16996
|
+
const name = on.dataset.ref;
|
|
16997
|
+
if (!name) return;
|
|
16998
|
+
const card = this.hooks.card(name);
|
|
16999
|
+
this.hooks.cards.show(card.html ?? `<pre class="code">${escapeHtml(name)}</pre><div class="sw-tip-wait">Asking Lean\u2026</div>`, box, name);
|
|
17000
|
+
void card.more?.then((html) => {
|
|
17001
|
+
if (turn === this.hoverTurn && html) this.hooks.cards.show(html, on.getBoundingClientRect(), name);
|
|
17002
|
+
});
|
|
17003
|
+
return;
|
|
17004
|
+
}
|
|
17005
|
+
const r2 = await this.hooks.subterm(c3.module, caret.line, caret.ch, c3.hash, Number(k2));
|
|
17006
|
+
if (turn !== this.hoverTurn || !on.isConnected) return;
|
|
17007
|
+
if (!r2 || r2.error || r2.pending || r2.stale || !r2.type && !r2.expr) return;
|
|
17008
|
+
this.hooks.cards.show(subtermHtml(r2, (w2) => this.hooks.resolve(w2)), box);
|
|
17009
|
+
}
|
|
17010
|
+
/** Keep the pane beside the code where the window is wide enough, else below it; and tell the
|
|
17011
|
+
* pane how tall the window's scrolled view is, which it stays within. */
|
|
17012
|
+
watchSize() {
|
|
17013
|
+
if (this.sizer || typeof ResizeObserver === "undefined") return this.size();
|
|
17014
|
+
this.sizer = new ResizeObserver(() => this.size());
|
|
17015
|
+
this.sizer.observe(this.hooks.win());
|
|
17016
|
+
this.size();
|
|
17017
|
+
}
|
|
17018
|
+
size() {
|
|
17019
|
+
const split = this.pane?.parentElement;
|
|
17020
|
+
const scroll = split?.closest(".sw-scroll");
|
|
17021
|
+
if (!split || !scroll) return;
|
|
17022
|
+
const side2 = paneSide(this.hooks.win().offsetWidth, this.hooks.fitted(), document.documentElement.clientWidth || innerWidth);
|
|
17023
|
+
split.classList.toggle("iv-side", side2);
|
|
17024
|
+
scroll.style.setProperty("--sw-view", `${scroll.clientHeight}px`);
|
|
17025
|
+
}
|
|
17026
|
+
};
|
|
17027
|
+
function subtermHtml(r2, resolve) {
|
|
17028
|
+
const isRef = (w2) => resolve(w2);
|
|
17029
|
+
const head = r2.expr && r2.type ? `${r2.expr} : ${r2.type}` : r2.type ?? r2.expr ?? "";
|
|
17030
|
+
return `<pre class="code">${highlightLean(head, isRef)}</pre>${r2.doc ? `<hr>${renderDoc(r2.doc)}` : ""}`;
|
|
17031
|
+
}
|
|
17032
|
+
function rangeIn(el, from, to) {
|
|
17033
|
+
const r2 = document.createRange();
|
|
17034
|
+
let acc = 0, started = false;
|
|
17035
|
+
const walker2 = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
|
|
17036
|
+
for (let n3 = walker2.nextNode(); n3; n3 = walker2.nextNode()) {
|
|
17037
|
+
const len = n3.data.length;
|
|
17038
|
+
if (!started && from < acc + len) {
|
|
17039
|
+
r2.setStart(n3, from - acc);
|
|
17040
|
+
started = true;
|
|
17041
|
+
}
|
|
17042
|
+
if (started && to <= acc + len) {
|
|
17043
|
+
r2.setEnd(n3, to - acc);
|
|
17044
|
+
return r2;
|
|
17045
|
+
}
|
|
17046
|
+
acc += len;
|
|
17047
|
+
}
|
|
17048
|
+
return null;
|
|
17049
|
+
}
|
|
17050
|
+
|
|
16090
17051
|
// src/web/src/sources.ts
|
|
16091
17052
|
var MIN = { w: 360, h: 160 };
|
|
16092
17053
|
var FIT_W = 560;
|
|
@@ -16136,7 +17097,7 @@ var Sources = class {
|
|
|
16136
17097
|
reveal(p2) {
|
|
16137
17098
|
if (p2.collapsed) p2.collapse(false);
|
|
16138
17099
|
p2.front();
|
|
16139
|
-
if (p2.decl >= 0) this.hooks.shown?.(p2, p2.decl);
|
|
17100
|
+
if (p2.decl >= 0 && p2.file === null) this.hooks.shown?.(p2, p2.decl);
|
|
16140
17101
|
}
|
|
16141
17102
|
/** Space: the following window closes; collapsed, it opens again; with none, one opens on the
|
|
16142
17103
|
* selection `i`. */
|
|
@@ -16169,7 +17130,7 @@ var Sources = class {
|
|
|
16169
17130
|
const states = [];
|
|
16170
17131
|
const missing = [];
|
|
16171
17132
|
for (const e2 of s2.pinned) {
|
|
16172
|
-
const on = [...left].filter((p3) => p3.decl === e2.decl);
|
|
17133
|
+
const on = [...left].filter((p3) => "file" in e2 ? p3.file === e2.file : p3.file === null && p3.decl === e2.decl);
|
|
16173
17134
|
const p2 = on.find((q2) => this.mirrored.has(q2)) ?? on[0];
|
|
16174
17135
|
if (!p2) {
|
|
16175
17136
|
missing.push(e2);
|
|
@@ -16177,32 +17138,48 @@ var Sources = class {
|
|
|
16177
17138
|
}
|
|
16178
17139
|
left.delete(p2);
|
|
16179
17140
|
this.mirrored.add(p2);
|
|
16180
|
-
states.push([p2, e2.collapsed]);
|
|
17141
|
+
states.push([p2, e2.collapsed, modeOf(e2)]);
|
|
16181
17142
|
}
|
|
16182
17143
|
for (const p2 of left) if (this.mirrored.has(p2)) this.close(p2);
|
|
16183
17144
|
for (const e2 of missing) {
|
|
16184
17145
|
if (this.pinned.length >= MAX_PINNED) break;
|
|
16185
17146
|
const f3 = this.following;
|
|
16186
17147
|
let p2;
|
|
16187
|
-
if (f3 && f3.decl === e2.decl && s2.following?.decl !== e2.decl) {
|
|
17148
|
+
if (!("file" in e2) && f3 && f3.decl === e2.decl && s2.following?.decl !== e2.decl) {
|
|
16188
17149
|
this.pinAt(f3);
|
|
16189
17150
|
p2 = f3;
|
|
16190
17151
|
} else {
|
|
16191
17152
|
p2 = this.hooks.make();
|
|
16192
17153
|
p2.pinAside(this.pinned.length + 1);
|
|
16193
|
-
p2.
|
|
17154
|
+
if ("file" in e2) p2.showFile(e2.file);
|
|
17155
|
+
else {
|
|
17156
|
+
if (p2.mode !== modeOf(e2)) p2.setMode(modeOf(e2));
|
|
17157
|
+
p2.show(e2.decl);
|
|
17158
|
+
}
|
|
16194
17159
|
this.pinned.push(p2);
|
|
16195
17160
|
this.hooks.changed();
|
|
16196
17161
|
}
|
|
16197
17162
|
this.mirrored.add(p2);
|
|
16198
|
-
states.push([p2, e2.collapsed]);
|
|
17163
|
+
states.push([p2, e2.collapsed, modeOf(e2)]);
|
|
17164
|
+
}
|
|
17165
|
+
for (const [p2, on, mode] of states) {
|
|
17166
|
+
if (p2.mode !== mode) p2.setMode(mode);
|
|
17167
|
+
if (p2.collapsed !== on) p2.collapse(on);
|
|
16199
17168
|
}
|
|
16200
|
-
for (const [p2, on] of states) if (p2.collapsed !== on) p2.collapse(on);
|
|
16201
17169
|
const f2 = s2.following;
|
|
16202
17170
|
if (f2 && f2.decl !== null) {
|
|
16203
17171
|
let p2 = this.following;
|
|
16204
|
-
|
|
16205
|
-
|
|
17172
|
+
const mode = f2.mode ?? "decl";
|
|
17173
|
+
if (!p2) {
|
|
17174
|
+
p2 = this.hooks.make();
|
|
17175
|
+
if (mode !== p2.mode) p2.setMode(mode);
|
|
17176
|
+
this.following = p2;
|
|
17177
|
+
p2.show(f2.decl);
|
|
17178
|
+
this.hooks.changed();
|
|
17179
|
+
p2.front();
|
|
17180
|
+
this.hooks.shown?.(p2, f2.decl);
|
|
17181
|
+
} else if (p2.mode !== mode) p2.setMode(mode);
|
|
17182
|
+
if (p2.decl !== f2.decl) {
|
|
16206
17183
|
p2.show(f2.decl);
|
|
16207
17184
|
this.hooks.shown?.(p2, f2.decl);
|
|
16208
17185
|
}
|
|
@@ -16225,11 +17202,33 @@ var Sources = class {
|
|
|
16225
17202
|
this.pinAt(p2);
|
|
16226
17203
|
return true;
|
|
16227
17204
|
}
|
|
17205
|
+
/** A file opened from the Files tree or the board's menu (the owner's decision of 2026-11-01): a
|
|
17206
|
+
* file window on module `module`, pinned as it opens a step aside from the middle of the screen,
|
|
17207
|
+
* in File mode at the file's top; one on it already comes in front instead. It is no
|
|
17208
|
+
* declaration's: nothing is paired. Refused, with why, when MAX_PINNED are pinned already. */
|
|
17209
|
+
openFile(module) {
|
|
17210
|
+
const have = this.pinned.find((p3) => p3.file === module);
|
|
17211
|
+
if (have) {
|
|
17212
|
+
this.reveal(have);
|
|
17213
|
+
return have;
|
|
17214
|
+
}
|
|
17215
|
+
if (this.pinned.length >= MAX_PINNED) {
|
|
17216
|
+
this.hooks.say(PIN_CAP);
|
|
17217
|
+
return null;
|
|
17218
|
+
}
|
|
17219
|
+
const p2 = this.hooks.make();
|
|
17220
|
+
p2.pinAside(this.pinned.length + 1);
|
|
17221
|
+
p2.showFile(module);
|
|
17222
|
+
this.pinned.push(p2);
|
|
17223
|
+
p2.front();
|
|
17224
|
+
this.hooks.changed();
|
|
17225
|
+
return p2;
|
|
17226
|
+
}
|
|
16228
17227
|
/** "Open in a pinned window" (the canvas's menu): declaration `i` in a window of its own, pinned
|
|
16229
17228
|
* as it opens a step aside from the middle of the screen; a pinned window on it already comes
|
|
16230
17229
|
* in front instead. Either is paired. Refused, with why, when MAX_PINNED are pinned already. */
|
|
16231
17230
|
openPinned(i2) {
|
|
16232
|
-
const have = this.pinned.find((p3) => p3.decl === i2);
|
|
17231
|
+
const have = this.pinned.find((p3) => p3.file === null && p3.decl === i2);
|
|
16233
17232
|
if (have) {
|
|
16234
17233
|
this.reveal(have);
|
|
16235
17234
|
return have;
|
|
@@ -16275,15 +17274,22 @@ var Sources = class {
|
|
|
16275
17274
|
for (const p2 of this.pinned) p2.redrawReview();
|
|
16276
17275
|
}
|
|
16277
17276
|
/** A new graph, or files that changed: each pinned window shows its declaration again, found by
|
|
16278
|
-
* name; one whose declaration the graph no longer holds
|
|
17277
|
+
* name, a file window its file; one whose declaration — or file — the graph no longer holds
|
|
17278
|
+
* closes. */
|
|
16279
17279
|
redraw(find) {
|
|
16280
17280
|
for (const p2 of [...this.pinned]) {
|
|
17281
|
+
if (p2.file !== null) {
|
|
17282
|
+
if (this.hooks.hasFile && !this.hooks.hasFile(p2.file)) this.close(p2);
|
|
17283
|
+
else p2.showFile(p2.file);
|
|
17284
|
+
continue;
|
|
17285
|
+
}
|
|
16281
17286
|
const i2 = find(p2.name);
|
|
16282
17287
|
if (i2 === void 0) this.close(p2);
|
|
16283
17288
|
else p2.show(i2);
|
|
16284
17289
|
}
|
|
16285
17290
|
}
|
|
16286
17291
|
};
|
|
17292
|
+
var modeOf = (e2) => "file" in e2 ? "file" : e2.mode ?? "decl";
|
|
16287
17293
|
function openBounds(vp, top = EDGE) {
|
|
16288
17294
|
const max = { w: Math.min(0.92 * vp.w, vp.w - 2 * EDGE), h: Math.min(0.88 * vp.h, vp.h - top - EDGE) };
|
|
16289
17295
|
return { max, min: { w: Math.min(FIT_W, max.w), h: Math.min(MIN.h, max.h) } };
|
|
@@ -16316,6 +17322,28 @@ var FORWARD = `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true
|
|
|
16316
17322
|
var PIN = `<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"><path d="M6 2.5h4l-.6 4 2.1 2.2v.8H4.5v-.8L6.6 6.5 6 2.5zM8 9.5v4"/></svg>`;
|
|
16317
17323
|
var COLLAPSE = `<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 8.5h8"/></svg>`;
|
|
16318
17324
|
var READ_WAIT = 1e3;
|
|
17325
|
+
var FILE_ANCHOR = "\u27E8file\u27E9";
|
|
17326
|
+
var FILE_GLYPH = `<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M4 1.8h5.2L12.5 5v9.2H4zM9 1.8V5.2h3.4"/></svg>`;
|
|
17327
|
+
var FILE_W = 1040;
|
|
17328
|
+
var LINE_H = 19.4;
|
|
17329
|
+
var NAMES_MAX = 5e3;
|
|
17330
|
+
function notThere(v2, era) {
|
|
17331
|
+
return v2.range ? `<div class="banner bad">${escapeHtml(v2.name)} is not in this text${era === "then" ? " at this build" : " any more under this name"}.</div>` : `<div class="banner">No source position was recorded for ${escapeHtml(v2.name)}.</div>`;
|
|
17332
|
+
}
|
|
17333
|
+
function chunkAt(chunks, line) {
|
|
17334
|
+
let lo = 0, hi = chunks.length - 1;
|
|
17335
|
+
while (lo <= hi) {
|
|
17336
|
+
const mid = lo + hi >> 1;
|
|
17337
|
+
if (chunks[mid].end < line) lo = mid + 1;
|
|
17338
|
+
else if (chunks[mid].start > line) hi = mid - 1;
|
|
17339
|
+
else return mid;
|
|
17340
|
+
}
|
|
17341
|
+
return -1;
|
|
17342
|
+
}
|
|
17343
|
+
function modeSwitch(mode, fileOnly) {
|
|
17344
|
+
const b2 = (m3, label, title) => `<button type="button" data-sw-mode="${m3}" aria-pressed="${mode === m3}"${m3 === "decl" && fileOnly ? " disabled" : ""} title="${escapeHtml(title)}">${label}</button>`;
|
|
17345
|
+
return `<span class="sw-mode" role="group" aria-label="Show">` + b2("decl", "Declaration", fileOnly ? "This window is on the file, not on a declaration: a name in it, or the bar over the code, selects one" : "The declaration, with the context it is written in") + b2("file", "File", "The whole file it is in, the declaration highlighted") + `</span>`;
|
|
17346
|
+
}
|
|
16319
17347
|
var SourceWindow = class {
|
|
16320
17348
|
g;
|
|
16321
17349
|
/** the window, in the windows' layer (#windows); what is drawn in it, and the pill it collapses to */
|
|
@@ -16345,6 +17373,9 @@ var SourceWindow = class {
|
|
|
16345
17373
|
/** the hover cards, and the word of the code the first one is for */
|
|
16346
17374
|
cards;
|
|
16347
17375
|
tipAt = "";
|
|
17376
|
+
/** the word the reader last clicked into with the mouse: no card for it until the pointer is on
|
|
17377
|
+
* another word (hovercards.ts, afterClick); "" for none */
|
|
17378
|
+
clicked = "";
|
|
16348
17379
|
hoverTurn = 0;
|
|
16349
17380
|
hoverWait = null;
|
|
16350
17381
|
/** where the pointer last was over the code, to ask again when scrolling stops under it */
|
|
@@ -16383,6 +17414,26 @@ var SourceWindow = class {
|
|
|
16383
17414
|
reading = 0;
|
|
16384
17415
|
readWait = null;
|
|
16385
17416
|
waiting = [];
|
|
17417
|
+
/** the InfoView: what Lean says at the caret (web/src/infoview.ts) */
|
|
17418
|
+
info;
|
|
17419
|
+
/** when a key was last pressed in the window: the keyboard's caret moves the selection */
|
|
17420
|
+
keyAt = 0;
|
|
17421
|
+
/** what it shows (the owner's decision of 2026-11-01): the declaration, or the whole file it is in */
|
|
17422
|
+
mode = "decl";
|
|
17423
|
+
/** a file window, opened on a file by its module (the Files tree, the board's menu; the owner's
|
|
17424
|
+
* decision of 2026-11-01): File mode alone, with no declaration of its own; null on a declaration */
|
|
17425
|
+
file = null;
|
|
17426
|
+
/** File mode as drawn: kept while the window steps to another declaration of the same text, which
|
|
17427
|
+
* moves only what is the declaration's, the reader's place staying */
|
|
17428
|
+
whole = null;
|
|
17429
|
+
/** the proofs opened one by one while proofs are folded, by where they start */
|
|
17430
|
+
openFolds = /* @__PURE__ */ new Set();
|
|
17431
|
+
/** where File mode, once drawn, scrolls: to the window's declaration (opening, a switch of mode),
|
|
17432
|
+
* a file window's top */
|
|
17433
|
+
scrollWanted = false;
|
|
17434
|
+
stickyWait = 0;
|
|
17435
|
+
/** File mode's pieces coming into sight: Lean is asked about the names of each then */
|
|
17436
|
+
seen = null;
|
|
16386
17437
|
/** A window in `layer`, following the selection until it is pinned. */
|
|
16387
17438
|
constructor(layer, g2, data, box, hooks, memory) {
|
|
16388
17439
|
this.g = g2;
|
|
@@ -16411,7 +17462,11 @@ var SourceWindow = class {
|
|
|
16411
17462
|
// beside the reference window it is paired with, it leaves that window its room, and is as
|
|
16412
17463
|
// tall as it, so that their tops and bottoms line up
|
|
16413
17464
|
bounds: (vp) => {
|
|
16414
|
-
|
|
17465
|
+
let b2 = openBounds(vp, this.aside ? this.hooks.top() : EDGE);
|
|
17466
|
+
if (this.mode === "file") {
|
|
17467
|
+
const w2 = Math.min(b2.max.w, Math.max(b2.min.w, FILE_W));
|
|
17468
|
+
b2 = { max: { w: w2, h: b2.max.h }, min: { w: w2, h: b2.max.h } };
|
|
17469
|
+
}
|
|
16415
17470
|
const d2 = this.hooks.docked?.(this);
|
|
16416
17471
|
if (!d2) return b2;
|
|
16417
17472
|
const r2 = d2.room(vp);
|
|
@@ -16430,6 +17485,13 @@ var SourceWindow = class {
|
|
|
16430
17485
|
const keep2 = (e2) => e2.target.closest?.("[data-sw-quote]") && e2.preventDefault();
|
|
16431
17486
|
el.addEventListener("pointerdown", keep2);
|
|
16432
17487
|
el.addEventListener("mousedown", keep2);
|
|
17488
|
+
el.addEventListener("pointerdown", (e2) => {
|
|
17489
|
+
if (e2.pointerType === "touch" || e2.button !== 0) return;
|
|
17490
|
+
const pre = e2.target.closest?.("pre.src");
|
|
17491
|
+
if (!pre || !this.shown) return;
|
|
17492
|
+
this.hideTip();
|
|
17493
|
+
this.clicked = this.positionAt(pre, e2.clientX, e2.clientY)?.word ?? "";
|
|
17494
|
+
});
|
|
16433
17495
|
document.addEventListener("selectionchange", this.onSelection);
|
|
16434
17496
|
el.addEventListener("click", (e2) => {
|
|
16435
17497
|
const t2 = e2.target;
|
|
@@ -16439,11 +17501,23 @@ var SourceWindow = class {
|
|
|
16439
17501
|
if (t2.closest("[data-sw-back]")) return this.hooks.back();
|
|
16440
17502
|
if (t2.closest("[data-sw-fwd]")) return this.hooks.forward();
|
|
16441
17503
|
if (t2.closest(".sw-pill, [data-sw-collapse]")) return;
|
|
17504
|
+
const mode = t2.closest("[data-sw-mode]");
|
|
17505
|
+
if (mode) return this.setMode(mode.dataset.swMode === "file" ? "file" : "decl");
|
|
17506
|
+
if (t2.closest("[data-sw-folds]")) return this.foldProofs(!this.hooks.foldProofs());
|
|
17507
|
+
const fold2 = t2.closest("[data-pf-open]");
|
|
17508
|
+
if (fold2) return this.openFold(fold2.dataset.pfOpen);
|
|
17509
|
+
const here = t2.closest("[data-sw-at]");
|
|
17510
|
+
if (here) {
|
|
17511
|
+
if (this.g.byName.has(here.dataset.swAt)) this.hooks.go(here.dataset.swAt);
|
|
17512
|
+
return;
|
|
17513
|
+
}
|
|
16442
17514
|
const ref = t2.closest("[data-ref]");
|
|
16443
17515
|
if (ref) {
|
|
16444
17516
|
if (this.g.byName.has(ref.dataset.ref)) this.hooks.go(ref.dataset.ref);
|
|
16445
17517
|
return;
|
|
16446
17518
|
}
|
|
17519
|
+
const pre = t2.closest("pre.src");
|
|
17520
|
+
if (pre && document.getSelection()?.isCollapsed !== false) return this.caretAtPoint(pre, e2.clientX, e2.clientY);
|
|
16447
17521
|
const ctx = t2.closest("[data-sw-ctx]");
|
|
16448
17522
|
if (ctx) {
|
|
16449
17523
|
const box2 = ctx.closest(".sw-ctx");
|
|
@@ -16477,17 +17551,46 @@ var SourceWindow = class {
|
|
|
16477
17551
|
if (this.g.byName.has(name)) this.hooks.go(name);
|
|
16478
17552
|
}
|
|
16479
17553
|
});
|
|
17554
|
+
this.info = new InfoView({
|
|
17555
|
+
goals: (m3, line, ch, hash) => this.data.goals(m3, line, ch, hash),
|
|
17556
|
+
subterm: (m3, line, ch, hash, k2) => this.data.subterm(m3, line, ch, hash, k2),
|
|
17557
|
+
// as the names of the code at the caret resolve: the declaration's, or in File mode the piece's
|
|
17558
|
+
resolve: (w2) => {
|
|
17559
|
+
const r2 = this.namesAt(this.info?.caret?.line ?? 0).resolve;
|
|
17560
|
+
return r2 ? r2(w2) : this.g.byName.has(w2) ? w2 : null;
|
|
17561
|
+
},
|
|
17562
|
+
cards: this.cards,
|
|
17563
|
+
card: (name) => ({ html: this.fromGraph(name), more: this.describe(name) }),
|
|
17564
|
+
hidden: () => this.hooks.infoHidden?.() ?? false,
|
|
17565
|
+
hide: (on) => this.hooks.hideInfo?.(on),
|
|
17566
|
+
moved: () => this.hooks.caretMoved?.(this),
|
|
17567
|
+
win: () => this.el,
|
|
17568
|
+
fitted: () => this.win.fitted,
|
|
17569
|
+
stale: () => void this.render(false)
|
|
17570
|
+
});
|
|
17571
|
+
el.addEventListener("keydown", (e2) => {
|
|
17572
|
+
this.keyAt = Date.now();
|
|
17573
|
+
if (e2.key !== "ArrowUp" && e2.key !== "ArrowDown" || e2.altKey || e2.ctrlKey || e2.metaKey || e2.shiftKey) return;
|
|
17574
|
+
const t2 = e2.target;
|
|
17575
|
+
if (t2.closest?.("input, textarea, select, [contenteditable]")) return;
|
|
17576
|
+
if (this.info.step(e2.key === "ArrowDown" ? 1 : -1)) e2.preventDefault();
|
|
17577
|
+
});
|
|
16480
17578
|
el.addEventListener("mousemove", (e2) => {
|
|
17579
|
+
if (e2.target.closest?.(".sw-info")) return;
|
|
16481
17580
|
const pre = e2.target.closest?.("pre.src");
|
|
16482
17581
|
this.pointer = pre ? { pre, x: e2.clientX, y: e2.clientY } : null;
|
|
16483
17582
|
if (this.hoverWait) clearTimeout(this.hoverWait);
|
|
16484
17583
|
if (e2.buttons || this.picked) return;
|
|
16485
|
-
if (!pre || !this.shown)
|
|
17584
|
+
if (!pre || !this.shown) {
|
|
17585
|
+
this.clicked = "";
|
|
17586
|
+
return this.cards.leave();
|
|
17587
|
+
}
|
|
16486
17588
|
const { clientX: x2, clientY: y2 } = e2;
|
|
16487
17589
|
this.hoverWait = setTimeout(() => this.pointAt(pre, x2, y2), 120);
|
|
16488
17590
|
});
|
|
16489
17591
|
el.addEventListener("mouseleave", () => {
|
|
16490
17592
|
this.pointer = null;
|
|
17593
|
+
this.clicked = "";
|
|
16491
17594
|
if (this.hoverWait) clearTimeout(this.hoverWait);
|
|
16492
17595
|
this.cards.leave();
|
|
16493
17596
|
});
|
|
@@ -16495,6 +17598,7 @@ var SourceWindow = class {
|
|
|
16495
17598
|
"scroll",
|
|
16496
17599
|
() => {
|
|
16497
17600
|
this.hideTip();
|
|
17601
|
+
this.stickyLater();
|
|
16498
17602
|
if (this.scrollEnd) clearTimeout(this.scrollEnd);
|
|
16499
17603
|
this.scrollEnd = setTimeout(() => {
|
|
16500
17604
|
const p2 = this.pointer;
|
|
@@ -16520,10 +17624,40 @@ var SourceWindow = class {
|
|
|
16520
17624
|
void this.render(fresh3);
|
|
16521
17625
|
if (first) this.win.layout();
|
|
16522
17626
|
}
|
|
17627
|
+
/** A file window on module `module` (the owner's decision of 2026-11-01): the whole file in File
|
|
17628
|
+
* mode from its top, not tied to the selection, with no declaration of its own; drawn again where
|
|
17629
|
+
* it is on it already. */
|
|
17630
|
+
showFile(module) {
|
|
17631
|
+
const first = !this.drawnOnce && this.file === null && this.current < 0;
|
|
17632
|
+
const fresh3 = module !== this.file;
|
|
17633
|
+
this.file = module;
|
|
17634
|
+
this.mode = "file";
|
|
17635
|
+
this.current = -1;
|
|
17636
|
+
this.name = "";
|
|
17637
|
+
if (fresh3) this.scrollWanted = true;
|
|
17638
|
+
void this.render(fresh3);
|
|
17639
|
+
if (first) this.win.layout();
|
|
17640
|
+
}
|
|
17641
|
+
/** What a page finds it by in its windows, and others' pointers in it: its declaration's name, a
|
|
17642
|
+
* file window's module under a mark of its own (no declaration's name is written so). */
|
|
17643
|
+
get anchor() {
|
|
17644
|
+
return this.file !== null ? `${FILE_ANCHOR}${this.file}` : this.name;
|
|
17645
|
+
}
|
|
17646
|
+
/** Shown in mode `m` (the owner's decision of 2026-11-01): its declaration, or the whole file it
|
|
17647
|
+
* is in, scrolled to it; switched by the reader in the title bar, or as a followed reader's window
|
|
17648
|
+
* is. A file window has File mode alone. */
|
|
17649
|
+
setMode(m3) {
|
|
17650
|
+
if (m3 === this.mode || this.file !== null && m3 === "decl") return;
|
|
17651
|
+
this.mode = m3;
|
|
17652
|
+
this.scrollWanted = true;
|
|
17653
|
+
this.unpick();
|
|
17654
|
+
if (this.current >= 0) void this.render(true).then(() => this.win.layout());
|
|
17655
|
+
this.hooks.moded(this);
|
|
17656
|
+
}
|
|
16523
17657
|
/** Laid out again where it is kept or fitted: a reference window paired beside it, or gone,
|
|
16524
17658
|
* changes the room it has. */
|
|
16525
17659
|
relayout() {
|
|
16526
|
-
if (this.current >= 0) this.win.layout();
|
|
17660
|
+
if (this.current >= 0 || this.file !== null) this.win.layout();
|
|
16527
17661
|
}
|
|
16528
17662
|
/** Whether the reader moved or resized it since the page last placed it: paired, their choice is
|
|
16529
17663
|
* kept where the reference window can stand beside it (AttachmentSpec decision 8). */
|
|
@@ -16559,6 +17693,7 @@ var SourceWindow = class {
|
|
|
16559
17693
|
* code of another declaration is read, the frame is still the one before's: the new frame draws
|
|
16560
17694
|
* the review. */
|
|
16561
17695
|
redrawReview() {
|
|
17696
|
+
if (this.mode === "file" && !this.reading) this.refreshMarks();
|
|
16562
17697
|
const r2 = this.el.querySelector(".sw-review");
|
|
16563
17698
|
if (!r2 || this.current < 0 || this.reading) return;
|
|
16564
17699
|
const a3 = document.activeElement;
|
|
@@ -16587,7 +17722,7 @@ var SourceWindow = class {
|
|
|
16587
17722
|
this.pinned = true;
|
|
16588
17723
|
this.aside = step2;
|
|
16589
17724
|
this.el.classList.add("pinned");
|
|
16590
|
-
if (this.current < 0) return;
|
|
17725
|
+
if (this.current < 0 && this.file === null) return;
|
|
16591
17726
|
this.win.layout();
|
|
16592
17727
|
void this.render(false);
|
|
16593
17728
|
}
|
|
@@ -16656,9 +17791,12 @@ var SourceWindow = class {
|
|
|
16656
17791
|
if (this.selWait) cancelAnimationFrame(this.selWait);
|
|
16657
17792
|
this.unpick();
|
|
16658
17793
|
if (this.scrollEnd) clearTimeout(this.scrollEnd);
|
|
17794
|
+
if (this.stickyWait) cancelAnimationFrame(this.stickyWait);
|
|
17795
|
+
this.seen?.disconnect();
|
|
16659
17796
|
this.pointer = null;
|
|
16660
17797
|
this.shown = null;
|
|
16661
17798
|
this.cards.dispose();
|
|
17799
|
+
this.info.dispose();
|
|
16662
17800
|
this.win.dispose();
|
|
16663
17801
|
if (this.el.contains(document.activeElement)) document.activeElement.blur();
|
|
16664
17802
|
this.el.remove();
|
|
@@ -16675,18 +17813,23 @@ var SourceWindow = class {
|
|
|
16675
17813
|
* a comment box, the lines it touches are picked, with the button that quotes them under the
|
|
16676
17814
|
* last; elsewhere, nothing is. Hover cards close as text is picked. */
|
|
16677
17815
|
selectionChanged() {
|
|
16678
|
-
const pre = this.el.querySelector("pre.src");
|
|
16679
17816
|
const s2 = document.getSelection();
|
|
17817
|
+
this.caretChanged(s2);
|
|
16680
17818
|
const range = s2 && !s2.isCollapsed && s2.rangeCount ? s2.getRangeAt(0) : null;
|
|
16681
17819
|
const c3 = this.code;
|
|
16682
|
-
|
|
17820
|
+
const pres = range ? [...this.el.querySelectorAll("pre.src")].filter((p2) => range.intersectsNode(p2)) : [];
|
|
17821
|
+
if (!pres.length || !c3 || !range || this.collapsed || !this.el.querySelector("[data-rv-comment]")) return this.unpick();
|
|
16683
17822
|
const text2 = c3.lines.join("\n");
|
|
16684
|
-
const
|
|
16685
|
-
|
|
17823
|
+
const starts = [0];
|
|
17824
|
+
for (let k2 = 0; k2 < c3.lines.length; k2++) starts.push(starts[k2] + c3.lines[k2].length + 1);
|
|
17825
|
+
const base = (pre) => starts[Math.max(0, Math.min(c3.lines.length - 1, Number(pre.dataset.line ?? c3.start) - c3.start))];
|
|
17826
|
+
const first = pres[0], last2 = pres[pres.length - 1];
|
|
17827
|
+
const from = first.contains(range.startContainer) ? base(first) + offsetIn(first, range.startContainer, range.startOffset) : base(first);
|
|
17828
|
+
const to = last2.contains(range.endContainer) ? base(last2) + offsetIn(last2, range.endContainer, range.endOffset) : base(last2) + (last2.textContent ?? "").length;
|
|
16686
17829
|
const picked = selectedLines(text2, from, to);
|
|
16687
|
-
const body =
|
|
16688
|
-
const
|
|
16689
|
-
if (!picked || !body || !
|
|
17830
|
+
const body = first.closest(".sw-body");
|
|
17831
|
+
const end = picked && this.lineEl(c3.start + picked.last);
|
|
17832
|
+
if (!picked || !body || !end) return this.unpick();
|
|
16690
17833
|
if (!this.picked) this.hideTip();
|
|
16691
17834
|
this.picked = picked;
|
|
16692
17835
|
let b2 = this.quoteBtn;
|
|
@@ -16702,7 +17845,57 @@ var SourceWindow = class {
|
|
|
16702
17845
|
const n3 = picked.last - picked.first + 1;
|
|
16703
17846
|
b2.textContent = "\u275D Quote in comment";
|
|
16704
17847
|
b2.title = `Quote ${n3 === 1 ? "this line" : `these ${n3} lines`} in your comment on ${this.name}, with where they are`;
|
|
16705
|
-
b2.style.top = `${
|
|
17848
|
+
b2.style.top = `${end.getBoundingClientRect().bottom - body.getBoundingClientRect().top + 3}px`;
|
|
17849
|
+
}
|
|
17850
|
+
/** The element of line `line` of the file (from 0) in the code on show, or null: the code's
|
|
17851
|
+
* blocks each say the line they start at (`data-line`), one block in Declaration mode, File
|
|
17852
|
+
* mode's pieces. */
|
|
17853
|
+
lineEl(line) {
|
|
17854
|
+
for (const pre of this.el.querySelectorAll("pre.src")) {
|
|
17855
|
+
const from = Number(pre.dataset.line ?? 0);
|
|
17856
|
+
const to = pre.dataset.end !== void 0 ? Number(pre.dataset.end) : from + pre.children.length - 1;
|
|
17857
|
+
if (line < from || line > to) continue;
|
|
17858
|
+
if (pre.dataset.end !== void 0) this.fill(pre);
|
|
17859
|
+
return pre.children[line - from] ?? null;
|
|
17860
|
+
}
|
|
17861
|
+
return null;
|
|
17862
|
+
}
|
|
17863
|
+
/** The keyboard's caret moved in the code (caret browsing: the selection collapsed there, a key just
|
|
17864
|
+
* pressed) puts the InfoView's caret there, as a click does (caretAtPoint). */
|
|
17865
|
+
caretChanged(s2) {
|
|
17866
|
+
if (!s2 || !s2.isCollapsed || !s2.rangeCount || Date.now() - this.keyAt > 500) return;
|
|
17867
|
+
const r2 = s2.getRangeAt(0);
|
|
17868
|
+
const at = r2.startContainer.nodeType === Node.ELEMENT_NODE ? r2.startContainer : r2.startContainer.parentElement;
|
|
17869
|
+
const pre = at?.closest("pre.src");
|
|
17870
|
+
if (pre && this.el.contains(pre)) this.caretIn(pre, r2.startContainer, r2.startOffset);
|
|
17871
|
+
}
|
|
17872
|
+
/** A click or a tap in the code puts the InfoView's caret where it landed. */
|
|
17873
|
+
caretAtPoint(pre, x2, y2) {
|
|
17874
|
+
const d2 = document;
|
|
17875
|
+
const r2 = d2.caretRangeFromPoint?.(x2, y2);
|
|
17876
|
+
const c3 = r2 ? null : d2.caretPositionFromPoint?.(x2, y2);
|
|
17877
|
+
const node = r2 ? r2.startContainer : c3?.offsetNode;
|
|
17878
|
+
if (node && pre.contains(node)) this.caretIn(pre, node, r2 ? r2.startOffset : c3.offset);
|
|
17879
|
+
}
|
|
17880
|
+
/** The InfoView's caret at a place of the code (a node and an offset there), at its line and column
|
|
17881
|
+
* in the file; not while the reader follows someone, whose caret it is (a click is reading then). */
|
|
17882
|
+
caretIn(pre, node, off) {
|
|
17883
|
+
if (!this.shown || !this.code || this.collapsed || this.hooks.following?.()) return;
|
|
17884
|
+
const at = caretOf(pre.textContent ?? "", offsetIn(pre, node, off));
|
|
17885
|
+
this.info.place(Number(pre.dataset.line ?? this.shown.start) + at.line, at.ch);
|
|
17886
|
+
}
|
|
17887
|
+
/** The InfoView's caret: where it is in the file, and whether the goals after the tactic are on
|
|
17888
|
+
* show; null where there is none in this window. */
|
|
17889
|
+
get caret() {
|
|
17890
|
+
return this.info.caret ? { ...this.info.caret } : null;
|
|
17891
|
+
}
|
|
17892
|
+
/** The caret as a followed reader's is, or none here (the page's one caret is in another window). */
|
|
17893
|
+
followCaret(c3) {
|
|
17894
|
+
this.info.follow(c3);
|
|
17895
|
+
}
|
|
17896
|
+
/** The InfoView hidden or shown again by the reader, in every window. */
|
|
17897
|
+
infoChanged() {
|
|
17898
|
+
this.info.draw();
|
|
16706
17899
|
}
|
|
16707
17900
|
/** Nothing picked: the quote button goes. */
|
|
16708
17901
|
unpick() {
|
|
@@ -16734,26 +17927,25 @@ var SourceWindow = class {
|
|
|
16734
17927
|
flashLines() {
|
|
16735
17928
|
const w2 = this.linesWanted;
|
|
16736
17929
|
const c3 = this.code;
|
|
16737
|
-
|
|
16738
|
-
if (!w2 || !c3 || !pre) return;
|
|
17930
|
+
if (!w2 || !c3 || !this.el.querySelector("pre.src")) return;
|
|
16739
17931
|
const now = Date.now();
|
|
16740
17932
|
if (now > (w2.since ? w2.since + FLASH_MS : w2.until)) {
|
|
16741
17933
|
this.linesWanted = null;
|
|
16742
17934
|
return;
|
|
16743
17935
|
}
|
|
16744
17936
|
const span = locateLines(c3.lines, c3.start, w2.from, w2.to, w2.quoted);
|
|
17937
|
+
if (!span && this.mode === "decl" && !this.still) return this.setMode("file");
|
|
16745
17938
|
if (!span) {
|
|
16746
17939
|
this.linesWanted = null;
|
|
16747
17940
|
return this.hooks.say(`Line${w2.to > w2.from ? `s ${w2.from}\u2013${w2.to} are` : ` ${w2.from} is`} not in the text of ${this.name} ${this.era === "then" ? "at this build" : "now"}.`);
|
|
16748
17941
|
}
|
|
16749
|
-
const lns = pre.querySelectorAll(".ln");
|
|
16750
17942
|
for (let k2 = span[0]; k2 <= span[1]; k2++) {
|
|
16751
|
-
const l2 =
|
|
17943
|
+
const l2 = this.lineEl(c3.start + k2);
|
|
16752
17944
|
if (!l2) continue;
|
|
16753
17945
|
l2.style.animationDelay = w2.since ? `${w2.since - now}ms` : "";
|
|
16754
17946
|
l2.classList.add("ln-flash");
|
|
16755
17947
|
}
|
|
16756
|
-
if (!w2.since)
|
|
17948
|
+
if (!w2.since) this.lineEl(c3.start + span[0])?.scrollIntoView({ block: "center", behavior: reducedMotion() ? "auto" : "smooth" });
|
|
16757
17949
|
w2.since ||= now;
|
|
16758
17950
|
}
|
|
16759
17951
|
// ---------------------------------------------------------------- what Lean says
|
|
@@ -16780,11 +17972,12 @@ var SourceWindow = class {
|
|
|
16780
17972
|
}
|
|
16781
17973
|
return null;
|
|
16782
17974
|
}
|
|
16783
|
-
/** The character of `pre` under (x, y): its line and UTF-16 column
|
|
16784
|
-
* the word it is in (one part of a dotted name: `o` and `elim` in `o.elim` are different
|
|
17975
|
+
/** The character of `pre` under (x, y): its line in the file (from 0) and UTF-16 column, and the
|
|
17976
|
+
* box of the word it is in (one part of a dotted name: `o` and `elim` in `o.elim` are different
|
|
16785
17977
|
* things); null over nothing (past the end of a line, between lines, in the indentation a
|
|
16786
17978
|
* wrapped line hangs from). Lines are counted by the line breaks in the text, which the code
|
|
16787
|
-
* keeps as it wraps (highlightLines): a line wrapped on the screen is one line here
|
|
17979
|
+
* keeps as it wraps (highlightLines): a line wrapped on the screen is one line here; from the
|
|
17980
|
+
* line the block starts at in the file (`data-line`), so that both modes count in the file. */
|
|
16788
17981
|
positionAt(pre, x2, y2) {
|
|
16789
17982
|
const d2 = document;
|
|
16790
17983
|
let node = null, off = 0;
|
|
@@ -16796,8 +17989,8 @@ var SourceWindow = class {
|
|
|
16796
17989
|
}
|
|
16797
17990
|
if (!node || node.nodeType !== Node.TEXT_NODE || !pre.contains(node)) return null;
|
|
16798
17991
|
const texts2 = [];
|
|
16799
|
-
const
|
|
16800
|
-
for (let t2 =
|
|
17992
|
+
const walker2 = document.createTreeWalker(pre, NodeFilter.SHOW_TEXT);
|
|
17993
|
+
for (let t2 = walker2.nextNode(); t2; t2 = walker2.nextNode()) texts2.push(t2);
|
|
16801
17994
|
let abs = 0;
|
|
16802
17995
|
for (const t2 of texts2) {
|
|
16803
17996
|
if (t2 === node) break;
|
|
@@ -16835,7 +18028,8 @@ var SourceWindow = class {
|
|
|
16835
18028
|
while (isWord(text2[to])) to++;
|
|
16836
18029
|
}
|
|
16837
18030
|
const range = this.rangeIn(texts2, from, to);
|
|
16838
|
-
|
|
18031
|
+
const at = Number(pre.dataset.line ?? 0) + line;
|
|
18032
|
+
return { line: at, ch: abs - (before + 1), word: `${at}:${from - (before + 1)}`, box: range ? range.getBoundingClientRect() : hit.rect };
|
|
16839
18033
|
}
|
|
16840
18034
|
/** A range over characters `from`–`to` of the text nodes `texts`. */
|
|
16841
18035
|
rangeIn(texts2, from, to) {
|
|
@@ -16858,6 +18052,9 @@ var SourceWindow = class {
|
|
|
16858
18052
|
pointAt(pre, x2, y2) {
|
|
16859
18053
|
const at = this.positionAt(pre, x2, y2);
|
|
16860
18054
|
if (!at || document.elementFromPoint(x2, y2)?.closest(".tk-doc, .tk-comment")) return this.cards.leave();
|
|
18055
|
+
const quiet = afterClick(this.clicked, at.word);
|
|
18056
|
+
this.clicked = quiet.clicked;
|
|
18057
|
+
if (!quiet.show) return;
|
|
16861
18058
|
if (at.word === this.tipAt && this.cards.open) return;
|
|
16862
18059
|
this.tipAt = at.word;
|
|
16863
18060
|
const node = document.elementFromPoint(x2, y2);
|
|
@@ -16875,6 +18072,32 @@ var SourceWindow = class {
|
|
|
16875
18072
|
const isRef = (w2) => w2 === v2.name ? w2 : own2(w2);
|
|
16876
18073
|
return `<div class="hc-where"><span class="dot ${kindDot(v2.kind, g2.isExt(i2))}"></span>${escapeHtml(v2.kind)} \xB7 ${escapeHtml(v2.module)}</div><pre class="code">${highlightLean(v2.type ? `${v2.name} : ${v2.type}` : v2.name, isRef)}</pre>` + (v2.doc ? `<hr>${renderDoc(v2.doc)}` : "");
|
|
16877
18074
|
}
|
|
18075
|
+
/** Where a place in the code on show is in its file, as Lean counts it: the line from 0 and the
|
|
18076
|
+
* UTF-16 character, in the module and the text (its Lake hash) on show — in either mode, the
|
|
18077
|
+
* code's blocks each counting from the line they start at in the file (`data-line`), a folded
|
|
18078
|
+
* proof's text being there still, hidden. `node` and `offset` as a caret or a selection's end
|
|
18079
|
+
* gives them; null outside the code, or where no text Lean knows is on show (a past build's).
|
|
18080
|
+
* What the hovers ask Lean at; what a pane beside the code may ask it at too. */
|
|
18081
|
+
positionOf(node, offset) {
|
|
18082
|
+
const s2 = this.shown;
|
|
18083
|
+
const e2 = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
|
|
18084
|
+
const pre = e2?.closest("pre.src");
|
|
18085
|
+
if (!s2 || !s2.hash || !pre || !this.el.contains(pre)) return null;
|
|
18086
|
+
const o2 = offsetIn(pre, node, offset);
|
|
18087
|
+
const before = (pre.textContent ?? "").slice(0, o2);
|
|
18088
|
+
const nl = before.lastIndexOf("\n");
|
|
18089
|
+
let line = 0;
|
|
18090
|
+
for (let k2 = before.indexOf("\n"); k2 >= 0; k2 = before.indexOf("\n", k2 + 1)) line++;
|
|
18091
|
+
return { module: s2.module, hash: s2.hash, line: Number(pre.dataset.line ?? 0) + line, character: o2 - nl - 1 };
|
|
18092
|
+
}
|
|
18093
|
+
/** How a name written at line `line` of the file on show resolves, and whose own name links
|
|
18094
|
+
* nowhere there: the declaration on show's; in File mode, the piece's there. */
|
|
18095
|
+
namesAt(line) {
|
|
18096
|
+
const w2 = this.whole;
|
|
18097
|
+
if (this.mode !== "file" || !w2) return { self: this.current >= 0 ? this.g.nodes[this.current].name : "", resolve: this.resolve };
|
|
18098
|
+
const k2 = chunkAt(w2.chunks, line);
|
|
18099
|
+
return k2 < 0 ? { self: "", resolve: null } : { self: w2.selfs[k2], resolve: w2.resolvers[k2] };
|
|
18100
|
+
}
|
|
16878
18101
|
async ask(line, ch, box, ref) {
|
|
16879
18102
|
const s2 = this.shown;
|
|
16880
18103
|
if (!s2) return;
|
|
@@ -16883,7 +18106,7 @@ var SourceWindow = class {
|
|
|
16883
18106
|
return graph2 ? this.showTip(graph2, box) : this.cards.leave();
|
|
16884
18107
|
}
|
|
16885
18108
|
const turn = ++this.hoverTurn;
|
|
16886
|
-
const res = await this.data.hover(s2.module,
|
|
18109
|
+
const res = await this.data.hover(s2.module, line, ch, s2.hash);
|
|
16887
18110
|
if (turn !== this.hoverTurn) return;
|
|
16888
18111
|
const graph = this.fromGraph(ref);
|
|
16889
18112
|
if (res === null) return graph ? this.showTip(graph, box) : this.cards.leave();
|
|
@@ -16900,15 +18123,16 @@ var SourceWindow = class {
|
|
|
16900
18123
|
}
|
|
16901
18124
|
if (res.error) return this.showTip(`${graph ?? ""}<div class="sw-tip-err">Lean could not be asked: ${escapeHtml(res.error)}</div>`, box);
|
|
16902
18125
|
if (!res.contents) return graph ? this.showTip(graph, box) : this.cards.leave();
|
|
16903
|
-
const
|
|
16904
|
-
const resolve = this.resolve;
|
|
18126
|
+
const { self: self2, resolve } = this.namesAt(line);
|
|
16905
18127
|
const head = /^```[^\n]*\n(\S+)/.exec(res.contents)?.[1]?.replace(/\.\{.*$/, "") ?? null;
|
|
16906
18128
|
const subject = head && this.g.byName.has(head) ? head : null;
|
|
16907
18129
|
this.showTip(renderHover(res.contents, (w2) => w2 === self2 ? w2 : resolve ? resolve(w2) : this.g.byName.has(w2) ? w2 : null), box, subject);
|
|
16908
18130
|
}
|
|
16909
18131
|
async render(fresh3) {
|
|
18132
|
+
if (this.mode === "file") return this.renderFile(fresh3);
|
|
16910
18133
|
const i2 = this.current;
|
|
16911
18134
|
if (i2 < 0) return;
|
|
18135
|
+
this.leaveFile();
|
|
16912
18136
|
const turn = ++this.turn;
|
|
16913
18137
|
this.hideTip();
|
|
16914
18138
|
this.shown = null;
|
|
@@ -16933,20 +18157,23 @@ var SourceWindow = class {
|
|
|
16933
18157
|
const nav = () => `<span class="nav"><button data-sw-back title="Back (Alt \u2190)" aria-label="Back"${steps().back ? "" : " disabled"}>${BACK}</button><button data-sw-fwd title="Forward (Alt \u2192)" aria-label="Forward"${steps().forward ? "" : " disabled"}>${FORWARD}</button></span>`;
|
|
16934
18158
|
const pin = pinned ? `<span class="sw-pinned" role="img" aria-label="Pinned" title="Pinned: it stays on ${escapeHtml(v2.name)}, whatever is selected">${PIN}</span>` : `<button class="icon sw-pin" data-sw-pin aria-label="Pin" title="Pin: keep this window on ${escapeHtml(v2.name)}; the next source you open (Space) opens in a new window beside it">${PIN}</button>`;
|
|
16935
18159
|
let remote = null;
|
|
16936
|
-
const head = (where, editor) => `<div class="sw-head">${pinned ? "" : nav()}<span class="dot ${kindDot(v2.kind, ext)}"></span><span class="sw-name" title="${escapeHtml(v2.name)}">${short6}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span><span class="sw-loc">${where}</span>` + (editor ? editorAnchor(editor) : "") + (remote ? githubAnchor(remote.href, remote.commit, remote.what) : "") + `<span class="sw-acts">${pin}<button class="icon" data-sw-collapse aria-label="Collapse" title="Collapse to one line (or double-click the title bar)">${COLLAPSE}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="${pinned ? "Close (Esc)" : "Close (Esc, or Space)"}">\u2715</button></span></div>`;
|
|
18160
|
+
const head = (where, editor) => `<div class="sw-head">${pinned ? "" : nav()}<span class="dot ${kindDot(v2.kind, ext)}"></span><span class="sw-name" title="${escapeHtml(v2.name)}">${short6}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span><span class="sw-loc">${where}</span>` + (editor ? editorAnchor(editor) : "") + (remote ? githubAnchor(remote.href, remote.commit, remote.what) : "") + modeSwitch("decl", false) + `<span class="sw-acts">${pin}<button class="icon" data-sw-collapse aria-label="Collapse" title="Collapse to one line (or double-click the title bar)">${COLLAPSE}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="${pinned ? "Close (Esc)" : "Close (Esc, or Space)"}">\u2715</button></span></div>`;
|
|
16937
18161
|
const frame2 = (where, notes2, body, editor = this.still ? null : this.hooks.editorLink(g2, i2), final = true) => {
|
|
16938
18162
|
this.el.setAttribute("aria-label", `Source of ${v2.name}${pinned ? ", pinned" : ""}`);
|
|
16939
|
-
this.frameEl.innerHTML = `${head(where, editor)}${this.pairHtml()}${notes2}<div class="sw-scroll"><div class="sw-body">${body}</div><div class="sw-review">${this.box.html(i2)}</div></div>`;
|
|
18163
|
+
this.frameEl.innerHTML = `${head(where, editor)}${this.pairHtml()}${notes2}<div class="sw-scroll"><div class="sw-split"><div class="sw-body">${body}</div><aside class="sw-info" hidden></aside></div><div class="sw-review">${this.box.html(i2)}</div></div>`;
|
|
16940
18164
|
this.pillEl.innerHTML = `<button class="sw-pill-open" type="button" title="Open the source of ${escapeHtml(v2.name)} again"><span class="dot ${kindDot(v2.kind, ext)}"></span><span class="sw-pill-name">${short6}</span>${pinned ? `<span class="sw-pinned" aria-label="Pinned">${PIN}</span>` : ""}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="Close">\u2715</button>`;
|
|
16941
18165
|
if (final) this.drew();
|
|
16942
18166
|
};
|
|
16943
18167
|
if (!v2.range) {
|
|
16944
18168
|
frame2(escapeHtml(v2.module), "", `<div class="sw-none">No source position was recorded for it.</div>`);
|
|
18169
|
+
this.attachInfo(null);
|
|
16945
18170
|
this.box.reveal(this.el);
|
|
16946
18171
|
return;
|
|
16947
18172
|
}
|
|
16948
18173
|
if (fresh3) this.awaitCode(turn, () => frame2(escapeHtml(v2.module), "", `<div class="sw-none">Reading the source\u2026</div>`, void 0, false));
|
|
18174
|
+
let infoCode = null;
|
|
16949
18175
|
const settle2 = () => {
|
|
18176
|
+
this.attachInfo(infoCode);
|
|
16950
18177
|
const scrolled = this.el.querySelector(".sw-scroll");
|
|
16951
18178
|
if (scrolled && keep2 !== null) scrolled.scrollTop = keep2;
|
|
16952
18179
|
if (hadFocus) {
|
|
@@ -16981,6 +18208,7 @@ var SourceWindow = class {
|
|
|
16981
18208
|
if (href) remote = { href, commit: pc.hash };
|
|
16982
18209
|
}
|
|
16983
18210
|
this.shown = { module: v2.module, start: shot.start, hash: "" };
|
|
18211
|
+
infoCode = { module: v2.module, start: shot.start, text: shot.text, hash: "", off: "A past build has no InfoView: Lean knows only the latest build. Its goals are there, in the window of the board of now." };
|
|
16984
18212
|
const notes2 = [`<div class="banner sw-then">${escapeHtml(pastNote(then.when, commit, got.check, got.outside))}</div>`];
|
|
16985
18213
|
if (v2.gen !== void 0) notes2.unshift(`<div class="banner">${genNote()}</div>`);
|
|
16986
18214
|
frame2(
|
|
@@ -16994,13 +18222,14 @@ var SourceWindow = class {
|
|
|
16994
18222
|
if (turn !== this.turn || this.current !== i2) return;
|
|
16995
18223
|
if (!src) {
|
|
16996
18224
|
frame2(escapeHtml(v2.module), "", `<div class="sw-none">${ext ? "A declaration from outside the project: its source is not found here." : "The file could not be read."}</div>`);
|
|
18225
|
+
this.attachInfo(null);
|
|
16997
18226
|
this.box.reveal(this.el);
|
|
16998
18227
|
return;
|
|
16999
18228
|
}
|
|
17000
18229
|
const lines = src.text.split("\n");
|
|
17001
18230
|
const out = src.outside;
|
|
17002
18231
|
const compiled = this.hooks.compiledOf(v2.module);
|
|
17003
|
-
const edited = out ? !!out.changed :
|
|
18232
|
+
const edited = out ? !!out.changed : !isCompiledText(compiled, src.hash);
|
|
17004
18233
|
const at = excerptOf(lines, edited, v2.name, v2.range);
|
|
17005
18234
|
const notes = [];
|
|
17006
18235
|
if (v2.gen !== void 0) notes.push(`<div class="banner">${genNote()}${this.still ? "" : " What Lean made of it is below the command."}</div>`);
|
|
@@ -17017,6 +18246,7 @@ var SourceWindow = class {
|
|
|
17017
18246
|
const place2 = (out ? `${packageWords(out)} \xB7 ` : "") + src.file;
|
|
17018
18247
|
if (!at) {
|
|
17019
18248
|
frame2(escapeHtml(place2), notes.join(""), `<div class="sw-none">Not found in the present text.</div>`);
|
|
18249
|
+
this.attachInfo(null);
|
|
17020
18250
|
this.box.reveal(this.el);
|
|
17021
18251
|
return;
|
|
17022
18252
|
}
|
|
@@ -17031,7 +18261,7 @@ var SourceWindow = class {
|
|
|
17031
18261
|
}
|
|
17032
18262
|
const resolve = resolver(g2, v2.name, scopeAt(lines, at.start, (n3) => namespacesOf(g2).has(n3)));
|
|
17033
18263
|
this.resolve = resolve;
|
|
17034
|
-
const key = `${v2.module}:${src.hash ?? ""}:${at.start}`;
|
|
18264
|
+
const key = `${v2.module}:${src.hash ?? ""}:${at.start}-${at.end}`;
|
|
17035
18265
|
const known2 = this.still ? void 0 : this.memory.learned.get(key);
|
|
17036
18266
|
const words = [];
|
|
17037
18267
|
const code = highlightLines(
|
|
@@ -17042,6 +18272,13 @@ var SourceWindow = class {
|
|
|
17042
18272
|
},
|
|
17043
18273
|
at.start + 1
|
|
17044
18274
|
);
|
|
18275
|
+
infoCode = {
|
|
18276
|
+
module: v2.module,
|
|
18277
|
+
start: at.start,
|
|
18278
|
+
text: text2,
|
|
18279
|
+
hash: src.hash ?? "",
|
|
18280
|
+
off: this.data.snapshot ? "A snapshot of the page has no InfoView: there is no Lean in it. The server's page shows the goals." : edited && out ? `${out.core ? "The toolchain" : out.package} is at another revision than when the graph was read: its goals would be another text's than Lean checked.` : edited ? "This file has changed since it was compiled: its goals would be the present text's, not what Lean checked. They come back once it is compiled again." : !src.hash ? "Lean cannot be asked about this file here." : null
|
|
18281
|
+
};
|
|
17045
18282
|
if (src.hash) {
|
|
17046
18283
|
this.shown = { module: v2.module, start: at.start, hash: src.hash };
|
|
17047
18284
|
if (fresh3 && !this.still) this.data.hoverOpen(v2.module);
|
|
@@ -17063,7 +18300,531 @@ var SourceWindow = class {
|
|
|
17063
18300
|
if (name && !this.memory.printed.has(name)) void this.printInto(turn, i2, name, out2);
|
|
17064
18301
|
}
|
|
17065
18302
|
settle2();
|
|
17066
|
-
if (src.hash && !known2 && !this.still)
|
|
18303
|
+
if (src.hash && !known2 && !this.still)
|
|
18304
|
+
void this.learn(() => turn === this.turn, v2.name, key, v2.module, src.hash, text2, at.start, words, (learned) => {
|
|
18305
|
+
const pre = this.el.querySelector("pre.src");
|
|
18306
|
+
if (!pre) return;
|
|
18307
|
+
pre.innerHTML = highlightLines(text2, (w2, off) => learned.has(off) ? learned.get(off) : resolve(w2), at.start + 1);
|
|
18308
|
+
this.flashLines();
|
|
18309
|
+
this.info.marks();
|
|
18310
|
+
});
|
|
18311
|
+
}
|
|
18312
|
+
// ---------------------------------------------------------------- File mode
|
|
18313
|
+
/** Out of File mode: what it drew of the file goes. */
|
|
18314
|
+
leaveFile() {
|
|
18315
|
+
this.whole = null;
|
|
18316
|
+
this.seen?.disconnect();
|
|
18317
|
+
this.seen = null;
|
|
18318
|
+
this.el.classList.remove("sw-file-mode", "sw-folds");
|
|
18319
|
+
}
|
|
18320
|
+
/** File mode's title bar: the declaration's, as Declaration mode's (its name, its namespace, where
|
|
18321
|
+
* it is, the editor's and GitHub's links), or a file window's, the file's name and folder; the
|
|
18322
|
+
* switch, set on File; the pin, collapse and close. */
|
|
18323
|
+
fileHead(where, editor, remote) {
|
|
18324
|
+
const pinned = this.pinned;
|
|
18325
|
+
const nav = `<span class="nav"><button data-sw-back title="Back (Alt \u2190)" aria-label="Back"${this.hooks.steps().back ? "" : " disabled"}>${BACK}</button><button data-sw-fwd title="Forward (Alt \u2192)" aria-label="Forward"${this.hooks.steps().forward ? "" : " disabled"}>${FORWARD}</button></span>`;
|
|
18326
|
+
const what = this.file !== null ? `the file ${this.file}` : this.g.nodes[this.current].name;
|
|
18327
|
+
const pin = pinned ? `<span class="sw-pinned" role="img" aria-label="Pinned" title="Pinned: it stays on ${escapeHtml(what)}, whatever is selected">${PIN}</span>` : `<button class="icon sw-pin" data-sw-pin aria-label="Pin" title="Pin: keep this window on ${escapeHtml(what)}; the next source you open (Space) opens in a new window beside it">${PIN}</button>`;
|
|
18328
|
+
let title;
|
|
18329
|
+
if (this.file !== null) {
|
|
18330
|
+
const parts = this.file.split(".");
|
|
18331
|
+
title = `<span class="sw-glyph">${FILE_GLYPH}</span><span class="sw-name" title="${escapeHtml(this.file)}">${escapeHtml(parts[parts.length - 1])}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span>`;
|
|
18332
|
+
} else {
|
|
18333
|
+
const v2 = this.g.nodes[this.current];
|
|
18334
|
+
const parts = v2.name.split(".");
|
|
18335
|
+
title = `<span class="dot ${kindDot(v2.kind, this.g.isExt(this.current))}"></span><span class="sw-name" title="${escapeHtml(v2.name)}">${escapeHtml(v2.display ?? parts[parts.length - 1])}</span><span class="sw-ns">${escapeHtml(parts.slice(0, -1).join("."))}</span>`;
|
|
18336
|
+
}
|
|
18337
|
+
return `<div class="sw-head">${pinned ? "" : nav}${title}<span class="sw-loc">${where}</span>` + (editor ? editorAnchor(editor) : "") + (remote ? githubAnchor(remote.href, remote.commit, remote.what) : "") + modeSwitch("file", this.file !== null) + `<span class="sw-acts">${pin}<button class="icon" data-sw-collapse aria-label="Collapse" title="Collapse to one line (or double-click the title bar)">${COLLAPSE}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="${pinned ? "Close (Esc)" : "Close (Esc, or Space)"}">\u2715</button></span></div>`;
|
|
18338
|
+
}
|
|
18339
|
+
/** File mode's frame: the title bar, the notes under it, and what scrolls — the sticky header and
|
|
18340
|
+
* the code, with the review box under the declaration's lines; `final`: the file's own, not
|
|
18341
|
+
* what stands for it while it is read. */
|
|
18342
|
+
paintFile(head, notes, inner, final = true) {
|
|
18343
|
+
const pinned = this.pinned;
|
|
18344
|
+
const v2 = this.current >= 0 ? this.g.nodes[this.current] : null;
|
|
18345
|
+
this.el.setAttribute("aria-label", v2 ? `Source of ${v2.name}, the whole file${pinned ? ", pinned" : ""}` : `The file ${this.file}${pinned ? ", pinned" : ""}`);
|
|
18346
|
+
this.frameEl.innerHTML = `${head}${this.pairHtml()}${notes}<div class="sw-scroll">${inner}</div>`;
|
|
18347
|
+
const name = v2 ? escapeHtml(v2.display ?? v2.name.split(".").pop()) : escapeHtml(this.file.split(".").pop());
|
|
18348
|
+
this.pillEl.innerHTML = `<button class="sw-pill-open" type="button" title="Open ${v2 ? `the source of ${escapeHtml(v2.name)}` : `the file ${escapeHtml(this.file)}`} again">` + (v2 ? `<span class="dot ${kindDot(v2.kind, this.g.isExt(this.current))}"></span>` : `<span class="sw-glyph">${FILE_GLYPH}</span>`) + `<span class="sw-pill-name">${name}</span>${pinned ? `<span class="sw-pinned" aria-label="Pinned">${PIN}</span>` : ""}</button><button class="icon sw-close" data-sw-close aria-label="Close" title="Close">\u2715</button>`;
|
|
18349
|
+
if (final) this.drew();
|
|
18350
|
+
}
|
|
18351
|
+
/** File mode (ReviewSpec, "The source window", the owner's decisions of 2026-11-01): the whole
|
|
18352
|
+
* file the window's declaration is in — a file window's, the file it was opened on — as the graph
|
|
18353
|
+
* was read from it, as it is now under the warning where it changed since, or as a past build
|
|
18354
|
+
* compiled it. The declaration is highlighted and scrolled to as the window opens or switches
|
|
18355
|
+
* mode; each declaration has its mark in the gutter; the review box is the declaration's, under
|
|
18356
|
+
* its lines; a sticky header names the declaration the reading position is in. A step to another
|
|
18357
|
+
* declaration of the same text moves only what is the declaration's, the reader's place staying. */
|
|
18358
|
+
async renderFile(fresh3) {
|
|
18359
|
+
const g2 = this.g;
|
|
18360
|
+
const i2 = this.current;
|
|
18361
|
+
const v2 = i2 >= 0 ? g2.nodes[i2] : null;
|
|
18362
|
+
const module = this.file ?? v2?.module;
|
|
18363
|
+
if (!module) return;
|
|
18364
|
+
const turn = ++this.turn;
|
|
18365
|
+
this.hideTip();
|
|
18366
|
+
this.unpick();
|
|
18367
|
+
const past = this.hooks.pastOf(g2);
|
|
18368
|
+
this.still = !!past;
|
|
18369
|
+
this.era = past ? "then" : "now";
|
|
18370
|
+
this.el.classList.add("sw-file-mode");
|
|
18371
|
+
this.el.classList.toggle("sw-folds", this.hooks.foldProofs());
|
|
18372
|
+
const before = this.whole;
|
|
18373
|
+
const scroll = this.el.querySelector(".sw-scroll");
|
|
18374
|
+
const keep2 = !this.scrollWanted && before?.module === module && scroll ? scroll.scrollTop : null;
|
|
18375
|
+
if (fresh3 && !(before && before.module === module && before.g === g2)) this.awaitCode(turn, () => this.paintFile(this.fileHead(escapeHtml(module), null, null), "", `<div class="sw-body"><div class="sw-none">Reading the file\u2026</div></div>`, false));
|
|
18376
|
+
let text2, file, hash = "", edited = false, out;
|
|
18377
|
+
let passRead = () => false;
|
|
18378
|
+
const notes = [];
|
|
18379
|
+
let remoteFor = () => null;
|
|
18380
|
+
const nowhere = (where, note, why) => {
|
|
18381
|
+
this.leaveFile();
|
|
18382
|
+
this.paintFile(this.fileHead(escapeHtml(where), null, null), note, `<div class="sw-body"><div class="sw-none">${why}</div></div>${v2 ? `<div class="sw-review">${this.box.html(i2)}</div>` : ""}`);
|
|
18383
|
+
this.attachInfo(null);
|
|
18384
|
+
this.box.reveal(this.el);
|
|
18385
|
+
};
|
|
18386
|
+
if (past) {
|
|
18387
|
+
const got = await this.data.pastSource(past.past.snapshot.id, module);
|
|
18388
|
+
if (turn !== this.turn) return;
|
|
18389
|
+
const commit = past.past.snapshot.commit?.hash ?? null;
|
|
18390
|
+
if ("missing" in got) {
|
|
18391
|
+
const why = got.why ? `: ${escapeHtml(got.why)}` : "";
|
|
18392
|
+
return nowhere(got.file || module, `<div class="banner sw-then">As built ${escapeHtml(past.when)}${commit ? ` \xB7 <code>${escapeHtml(commit.slice(0, 7))}</code>` : ""}</div>`, `This file at this build ${got.outside ? "was" : "is"} not kept${why}.`);
|
|
18393
|
+
}
|
|
18394
|
+
({ text: text2, file, outside: out } = got);
|
|
18395
|
+
notes.push(`<div class="banner sw-then">${escapeHtml(pastNote(past.when, commit, got.check, got.outside))}</div>`);
|
|
18396
|
+
const pc = past.past.snapshot.commit;
|
|
18397
|
+
const o2 = out;
|
|
18398
|
+
remoteFor = (from, to) => {
|
|
18399
|
+
const href = o2?.github ? outsideLink(o2, from, to) : !o2 && pc && !pc.dirty && !pc.guessed && (got.from === "tree" || got.from === `git:${pc.hash}`) ? this.hooks.githubLink?.(file, pc.hash, from, to) : null;
|
|
18400
|
+
return href ? o2?.github ? { href, commit: o2.github.rev, what: packageWords(o2) } : { href, commit: pc.hash } : null;
|
|
18401
|
+
};
|
|
18402
|
+
} else {
|
|
18403
|
+
const src = await this.data.source(module);
|
|
18404
|
+
if (turn !== this.turn) return;
|
|
18405
|
+
if (!src) return nowhere(module, "", this.file === null && v2 && g2.isExt(i2) ? "A declaration from outside the project: its source is not found here." : "The file could not be read.");
|
|
18406
|
+
({ text: text2, file, outside: out } = src);
|
|
18407
|
+
hash = src.hash ?? "";
|
|
18408
|
+
const compiled2 = this.hooks.compiledOf(module);
|
|
18409
|
+
edited = out ? !!out.changed : !isCompiledText(compiled2, src.hash);
|
|
18410
|
+
const o2 = out, e2 = edited, at = file;
|
|
18411
|
+
remoteFor = (from, to) => this.nowRemote(at, o2, e2, from, to);
|
|
18412
|
+
passRead = (j2) => !edited && !!src.hash && src.contexts?.hash === src.hash && Object.hasOwn(src.contexts.decls, g2.nodes[j2].name);
|
|
18413
|
+
const f2 = this.hooks.fileOf(module);
|
|
18414
|
+
if (f2 && (f2.state === "failed" || f2.state === "unbuilt")) notes.push(`<div class="banner bad">The last build of this file failed: the graph shows it as it was last compiled.</div>`);
|
|
18415
|
+
if (edited && out)
|
|
18416
|
+
notes.push(`<div class="banner warn">${escapeHtml(out.core ? "The toolchain" : out.package)} is at another revision than when the graph was read (${escapeHtml(packageWords(out))} now). Below is its present text; the graph refers to what was read then, and no declaration's mark is shown.</div>`);
|
|
18417
|
+
else if (edited)
|
|
18418
|
+
notes.push(`<div class="banner warn">This file has changed since it was compiled. Below is its present text; the statements, the TCBs and the review refer to the compiled version, and a declaration's mark shows only where its text is still the one compiled.</div>`);
|
|
18419
|
+
}
|
|
18420
|
+
const place2 = (out ? `${packageWords(out)} \xB7 ` : "") + file;
|
|
18421
|
+
if (before && before.g === g2 && before.module === module && before.text === text2 && before.era === this.era && this.el.querySelector(".sw-file")) {
|
|
18422
|
+
this.whole = before;
|
|
18423
|
+
this.placeOwn(fresh3, notes, place2, edited, remoteFor, out);
|
|
18424
|
+
return;
|
|
18425
|
+
}
|
|
18426
|
+
const lines = text2.split("\n");
|
|
18427
|
+
const decls = fileDecls(g2, module, lines, edited);
|
|
18428
|
+
const chunks = chunksOf(decls, lines.length);
|
|
18429
|
+
const spaces = namespacesOf(g2);
|
|
18430
|
+
const scopes = scopesAt(lines, chunks.map((c3) => c3.start), (n3) => spaces.has(n3));
|
|
18431
|
+
let d2 = 0;
|
|
18432
|
+
const selfs = chunks.map((c3) => {
|
|
18433
|
+
while (d2 < decls.length && decls[d2].start < c3.start) d2++;
|
|
18434
|
+
return d2 < decls.length && decls[d2].start <= c3.end ? g2.nodes[decls[d2].i].name : "";
|
|
18435
|
+
});
|
|
18436
|
+
const resolvers = chunks.map((_2, k2) => resolver(g2, selfs[k2], scopes[k2]));
|
|
18437
|
+
const folds = proofFolds(g2, decls, lines, passRead);
|
|
18438
|
+
const compiled = edited && !out && !past ? await this.hooks.compiledText(module) : null;
|
|
18439
|
+
if (turn !== this.turn) return;
|
|
18440
|
+
if (before?.module !== module) this.openFolds.clear();
|
|
18441
|
+
const w2 = { g: g2, module, text: text2, file, hash, lines, era: this.era, edited, decls, chunks, selfs, resolvers, folds, marks: [], compiled };
|
|
18442
|
+
this.whole = w2;
|
|
18443
|
+
this.marksOf(w2);
|
|
18444
|
+
const own2 = this.ownDecl();
|
|
18445
|
+
const ownAt = own2 ? chunkAt(chunks, own2.start) : -1;
|
|
18446
|
+
const review = v2 ? `<div class="sw-review">${this.box.html(i2)}</div>` : "";
|
|
18447
|
+
if (v2 && !own2) notes.push(notThere(v2, this.era));
|
|
18448
|
+
const body = chunks.map((_2, k2) => this.pieceHtml(k2) + (k2 === ownAt ? review : "")).join("");
|
|
18449
|
+
this.paintFile(
|
|
18450
|
+
this.fileHead(this.fileWhere(place2, edited), this.ownEditor(edited), remoteFor(...this.ownLines())),
|
|
18451
|
+
notes.join(""),
|
|
18452
|
+
`<div class="sw-sticky"><span class="sw-at-slot"></span>${this.foldsButton()}</div><div class="sw-split"><div class="sw-body sw-file">${own2 || !v2 ? "" : review}${body}</div><aside class="sw-info" hidden></aside></div>`
|
|
18453
|
+
);
|
|
18454
|
+
this.code = { file, start: 0, lines };
|
|
18455
|
+
this.resolve = null;
|
|
18456
|
+
this.shown = { module, start: 0, hash };
|
|
18457
|
+
this.attachInfo(this.fileInfo(w2, past !== null, out));
|
|
18458
|
+
if (fresh3 && !this.still && hash) this.data.hoverOpen(module);
|
|
18459
|
+
this.fillAround(own2 ? own2.start : 0);
|
|
18460
|
+
this.watchPieces(w2);
|
|
18461
|
+
const sc = this.el.querySelector(".sw-scroll");
|
|
18462
|
+
if (sc && keep2 !== null) sc.scrollTop = keep2;
|
|
18463
|
+
if (this.scrollWanted || fresh3) this.scrollToOwn();
|
|
18464
|
+
this.scrollWanted = false;
|
|
18465
|
+
this.updateSticky();
|
|
18466
|
+
this.box.reveal(this.el);
|
|
18467
|
+
this.flashLines();
|
|
18468
|
+
}
|
|
18469
|
+
/** The InfoView's code in File mode: the whole file from its first line; why Lean is not asked
|
|
18470
|
+
* about it, as in Declaration mode — a past build's, a snapshot's, a text changed since it was
|
|
18471
|
+
* compiled. */
|
|
18472
|
+
fileInfo(w2, past, out) {
|
|
18473
|
+
const off = past ? "A past build has no InfoView: Lean knows only the latest build. Its goals are there, in the window of the board of now." : this.data.snapshot ? "A snapshot of the page has no InfoView: there is no Lean in it. The server's page shows the goals." : w2.edited && out ? `${out.core ? "The toolchain" : out.package} is at another revision than when the graph was read: its goals would be another text's than Lean checked.` : w2.edited ? "This file has changed since it was compiled: its goals would be the present text's, not what Lean checked. They come back once it is compiled again." : !w2.hash ? "Lean cannot be asked about this file here." : null;
|
|
18474
|
+
return { module: w2.module, start: 0, text: w2.text, hash: w2.hash, off };
|
|
18475
|
+
}
|
|
18476
|
+
/** Where File mode's file is, as the title bar says it: the file, the declaration's lines in it. */
|
|
18477
|
+
fileWhere(place2, edited) {
|
|
18478
|
+
const own2 = this.ownDecl();
|
|
18479
|
+
return `${escapeHtml(place2)}${own2 ? `:${own2.start + 1}\u2013${own2.end + 1}` : ""}${edited ? " \xB7 present text" : ""}`;
|
|
18480
|
+
}
|
|
18481
|
+
/** The editor's link to the window's declaration in File mode, as in Declaration mode; none for a
|
|
18482
|
+
* file window or a past build. */
|
|
18483
|
+
ownEditor(edited) {
|
|
18484
|
+
const own2 = this.ownDecl();
|
|
18485
|
+
if (this.still || this.current < 0) return null;
|
|
18486
|
+
return this.hooks.editorLink(this.g, this.current, edited && own2 ? { line: own2.start + 1, col: 1 } : void 0);
|
|
18487
|
+
}
|
|
18488
|
+
/** GitHub's link to lines `from`–`to` of the file of now (DeploySpec decision 13): at the build's
|
|
18489
|
+
* commit, outside the project in its package at its revision; none for a text changed since. */
|
|
18490
|
+
nowRemote(file, out, edited, from, to) {
|
|
18491
|
+
if (edited) return null;
|
|
18492
|
+
if (out) {
|
|
18493
|
+
const href2 = outsideLink(out, from, to);
|
|
18494
|
+
return href2 && out.github ? { href: href2, commit: out.github.rev, what: packageWords(out) } : null;
|
|
18495
|
+
}
|
|
18496
|
+
const built = this.hooks.builtCommit?.();
|
|
18497
|
+
const href = built ? this.hooks.githubLink?.(file, built, from, to) : null;
|
|
18498
|
+
return href && built ? { href, commit: built } : null;
|
|
18499
|
+
}
|
|
18500
|
+
/** The window's declaration's lines (from 1), what GitHub's link shows; a file window's first. */
|
|
18501
|
+
ownLines() {
|
|
18502
|
+
const own2 = this.ownDecl();
|
|
18503
|
+
return own2 ? [own2.start + 1, own2.end + 1] : [1, 1];
|
|
18504
|
+
}
|
|
18505
|
+
/** The window's declaration among the file's, where it is in this text; null for a file window,
|
|
18506
|
+
* or one not found. */
|
|
18507
|
+
ownDecl() {
|
|
18508
|
+
const w2 = this.whole;
|
|
18509
|
+
if (!w2 || this.current < 0) return null;
|
|
18510
|
+
const d2 = w2.decls.find((x2) => x2.i === this.current);
|
|
18511
|
+
if (d2) return d2;
|
|
18512
|
+
const v2 = w2.g.nodes[this.current];
|
|
18513
|
+
if (v2.gen === void 0 || !v2.range || v2.module !== w2.module) return null;
|
|
18514
|
+
const at = excerptOf(w2.lines, w2.edited, v2.name, v2.range);
|
|
18515
|
+
return at ? { i: this.current, start: at.start, end: at.end, head: at.start } : null;
|
|
18516
|
+
}
|
|
18517
|
+
/** The window stepped to another declaration of the text on show (the selection followed, the
|
|
18518
|
+
* sticky header pressed), or drawn again: the title bar and the notes are the new declaration's,
|
|
18519
|
+
* its lines are highlighted, the review box goes under them; the reader's place stays, scrolled
|
|
18520
|
+
* to the declaration only where none of it is in sight. */
|
|
18521
|
+
placeOwn(fresh3, notes, place2, edited, remoteFor, out) {
|
|
18522
|
+
const w2 = this.whole;
|
|
18523
|
+
const v2 = this.current >= 0 ? this.g.nodes[this.current] : null;
|
|
18524
|
+
const own2 = this.ownDecl();
|
|
18525
|
+
if (v2 && !own2) notes.push(notThere(v2, this.era));
|
|
18526
|
+
const headEl = this.frameEl.querySelector(".sw-head");
|
|
18527
|
+
if (headEl) headEl.outerHTML = this.fileHead(this.fileWhere(place2, edited), this.ownEditor(edited), remoteFor(...this.ownLines()));
|
|
18528
|
+
for (const b2 of this.frameEl.querySelectorAll(":scope > .banner")) b2.remove();
|
|
18529
|
+
(this.frameEl.querySelector(".sw-pair") ?? this.frameEl.querySelector(".sw-head"))?.insertAdjacentHTML("afterend", notes.join(""));
|
|
18530
|
+
for (const l2 of this.frameEl.querySelectorAll(".ln.hl")) l2.classList.remove("hl");
|
|
18531
|
+
if (own2) for (let l2 = own2.start; l2 <= own2.end; l2++) this.lineEl(l2)?.classList.add("hl");
|
|
18532
|
+
const body = this.frameEl.querySelector(".sw-file");
|
|
18533
|
+
let r2 = this.frameEl.querySelector(".sw-review");
|
|
18534
|
+
if (!v2) r2?.remove();
|
|
18535
|
+
else if (!fresh3 && r2) this.redrawReview();
|
|
18536
|
+
else if (body) {
|
|
18537
|
+
if (!r2) {
|
|
18538
|
+
r2 = document.createElement("div");
|
|
18539
|
+
r2.className = "sw-review";
|
|
18540
|
+
}
|
|
18541
|
+
r2.innerHTML = this.box.html(this.current);
|
|
18542
|
+
const at = own2 ? body.querySelector(`pre.src[data-piece="${chunkAt(w2.chunks, own2.start)}"]`) : null;
|
|
18543
|
+
if (at) at.after(r2);
|
|
18544
|
+
else body.prepend(r2);
|
|
18545
|
+
}
|
|
18546
|
+
this.el.setAttribute("aria-label", v2 ? `Source of ${v2.name}, the whole file${this.pinned ? ", pinned" : ""}` : `The file ${this.file}${this.pinned ? ", pinned" : ""}`);
|
|
18547
|
+
this.refreshMarks();
|
|
18548
|
+
this.drew();
|
|
18549
|
+
this.code = { file: w2.file, start: 0, lines: w2.lines };
|
|
18550
|
+
this.shown = { module: w2.module, start: 0, hash: w2.hash };
|
|
18551
|
+
this.attachInfo(this.fileInfo(w2, w2.era === "then", out));
|
|
18552
|
+
if (this.scrollWanted || fresh3 && !this.ownInSight()) this.scrollToOwn();
|
|
18553
|
+
this.scrollWanted = false;
|
|
18554
|
+
this.updateSticky();
|
|
18555
|
+
this.box.reveal(this.el);
|
|
18556
|
+
this.flashLines();
|
|
18557
|
+
}
|
|
18558
|
+
/** Piece `k` of the file on show as a code block of its own, empty until it comes near the screen
|
|
18559
|
+
* (`fill`), standing meanwhile as tall as its lines would be unwrapped: a file of thousands of
|
|
18560
|
+
* lines is highlighted and laid out where it is read, not all at once. */
|
|
18561
|
+
pieceHtml(k2) {
|
|
18562
|
+
const w2 = this.whole;
|
|
18563
|
+
const c3 = w2.chunks[k2];
|
|
18564
|
+
const h2 = Math.round((c3.end - c3.start + 1) * LINE_H);
|
|
18565
|
+
return `<pre class="code src sw-piece" data-line="${c3.start}" data-end="${c3.end}" data-piece="${k2}" style="--gw:${gutterDigits(w2.lines.length)};height:${h2}px;contain-intrinsic-block-size:auto ${h2}px"></pre>`;
|
|
18566
|
+
}
|
|
18567
|
+
/** A piece drawn, where it is not yet: its lines highlighted, the names in them linked (as Lean
|
|
18568
|
+
* said, where it was asked), the window's declaration's lines highlighted, a declaration's mark
|
|
18569
|
+
* where its command starts, its proofs marked to fold, those opened one by one open. Laid out
|
|
18570
|
+
* only near the screen after that (web/style.css). */
|
|
18571
|
+
fill(pre) {
|
|
18572
|
+
if (pre.dataset.end === void 0 || !this.whole) return;
|
|
18573
|
+
delete pre.dataset.end;
|
|
18574
|
+
pre.innerHTML = this.pieceLines(Number(pre.dataset.piece));
|
|
18575
|
+
pre.style.height = "";
|
|
18576
|
+
this.applyOpen(pre);
|
|
18577
|
+
const k2 = this.info.caret;
|
|
18578
|
+
if (k2 && k2.line >= Number(pre.dataset.line) && k2.line < Number(pre.dataset.line) + pre.children.length) this.info.marks();
|
|
18579
|
+
}
|
|
18580
|
+
/** The pieces of the file around line `line` drawn at once, `n` lines either way: what is on the
|
|
18581
|
+
* screen as the window opens on it, before the pieces coming near are drawn as they come. */
|
|
18582
|
+
fillAround(line, n3 = 120) {
|
|
18583
|
+
for (const pre of this.el.querySelectorAll("pre.sw-piece[data-end]")) {
|
|
18584
|
+
const from = Number(pre.dataset.line), to = Number(pre.dataset.end);
|
|
18585
|
+
if (to >= line - n3 && from <= line + n3) this.fill(pre);
|
|
18586
|
+
}
|
|
18587
|
+
}
|
|
18588
|
+
pieceLines(k2) {
|
|
18589
|
+
const w2 = this.whole;
|
|
18590
|
+
const c3 = w2.chunks[k2];
|
|
18591
|
+
const lines = w2.lines.slice(c3.start, c3.end + 1);
|
|
18592
|
+
const text2 = lines.join("\n");
|
|
18593
|
+
const known2 = this.still ? void 0 : this.memory.learned.get(`${w2.module}:${w2.hash}:${c3.start}-${c3.end}`);
|
|
18594
|
+
const resolve = w2.resolvers[k2];
|
|
18595
|
+
const own2 = this.ownDecl();
|
|
18596
|
+
const heads = /* @__PURE__ */ new Map();
|
|
18597
|
+
w2.decls.forEach((fd, d2) => {
|
|
18598
|
+
if (fd.head >= c3.start && fd.head <= c3.end && !heads.has(fd.head)) heads.set(fd.head, d2);
|
|
18599
|
+
});
|
|
18600
|
+
const starts = [0];
|
|
18601
|
+
for (const l2 of lines) starts.push(starts[starts.length - 1] + l2.length + 1);
|
|
18602
|
+
const off = ([line, col]) => starts[Math.max(0, Math.min(lines.length, line - c3.start))] + col;
|
|
18603
|
+
const folds = w2.folds.filter((f2) => f2.from[0] >= c3.start && f2.from[0] <= c3.end).map((f2) => ({ from: off(f2.from), to: Math.min(text2.length, off(f2.to)), id: `${f2.from[0]}:${f2.from[1]}` }));
|
|
18604
|
+
const decor = {
|
|
18605
|
+
line: (j2) => {
|
|
18606
|
+
const l2 = c3.start + j2;
|
|
18607
|
+
const hl = !!own2 && l2 >= own2.start && l2 <= own2.end;
|
|
18608
|
+
const d2 = heads.get(l2);
|
|
18609
|
+
const lead = d2 === void 0 ? "" : this.markHtml(d2);
|
|
18610
|
+
return hl || lead ? { cls: hl ? " hl" : "", lead } : void 0;
|
|
18611
|
+
},
|
|
18612
|
+
folds
|
|
18613
|
+
};
|
|
18614
|
+
return highlightLines(text2, (word, at) => known2?.has(at) ? known2.get(at) : resolve(word), c3.start + 1, decor);
|
|
18615
|
+
}
|
|
18616
|
+
/** Declaration `d`'s mark in the gutter, where its command starts: its review state in the Status
|
|
18617
|
+
* scheme's colours, with its name and state as its tooltip; nothing where none is shown. No
|
|
18618
|
+
* text: the code's text stays the source's. */
|
|
18619
|
+
markHtml(d2) {
|
|
18620
|
+
const w2 = this.whole;
|
|
18621
|
+
const m3 = w2.marks[d2];
|
|
18622
|
+
if (!m3) return "";
|
|
18623
|
+
const v2 = w2.g.nodes[w2.decls[d2].i];
|
|
18624
|
+
return `<span class="dm s-${m3}" data-dm="${d2}" aria-hidden="true" title="${escapeHtml(`${v2.name}: ${FILE_MARK_LABEL[m3]}`)}"></span>`;
|
|
18625
|
+
}
|
|
18626
|
+
/** Each declaration's mark, as Status shows it — the build, `sorry`, the review as it is now —:
|
|
18627
|
+
* shown only where the text is the one compiled, which they are about (a file changed since:
|
|
18628
|
+
* where its text is still that). */
|
|
18629
|
+
marksOf(w2) {
|
|
18630
|
+
const d2 = this.hooks.review(w2.g);
|
|
18631
|
+
const inReview = this.hooks.inReview(w2.g);
|
|
18632
|
+
const file = w2.era === "now" ? this.hooks.fileOf(w2.module) : void 0;
|
|
18633
|
+
w2.marks = w2.decls.map((fd) => {
|
|
18634
|
+
const r2 = w2.g.nodes[fd.i].range;
|
|
18635
|
+
if (w2.edited && !(w2.compiled && r2 && sameText(w2.compiled, r2, w2.lines, fd))) return null;
|
|
18636
|
+
return fileMark(d2, w2.g, fd.i, inReview, file);
|
|
18637
|
+
});
|
|
18638
|
+
}
|
|
18639
|
+
/** The review changed: the marks again, where they are drawn, and the sticky header's. */
|
|
18640
|
+
refreshMarks() {
|
|
18641
|
+
const w2 = this.whole;
|
|
18642
|
+
if (!w2) return;
|
|
18643
|
+
this.marksOf(w2);
|
|
18644
|
+
for (const el of this.frameEl.querySelectorAll(".dm[data-dm]")) {
|
|
18645
|
+
const d2 = Number(el.dataset.dm);
|
|
18646
|
+
const m3 = w2.marks[d2];
|
|
18647
|
+
if (!m3) {
|
|
18648
|
+
el.remove();
|
|
18649
|
+
continue;
|
|
18650
|
+
}
|
|
18651
|
+
el.className = `dm s-${m3}`;
|
|
18652
|
+
el.title = `${w2.g.nodes[w2.decls[d2].i].name}: ${FILE_MARK_LABEL[m3]}`;
|
|
18653
|
+
}
|
|
18654
|
+
this.stickyAt = null;
|
|
18655
|
+
this.updateSticky();
|
|
18656
|
+
}
|
|
18657
|
+
/** "Fold proofs", in the sticky header: the reader's own, remembered in this browser. */
|
|
18658
|
+
foldsButton() {
|
|
18659
|
+
const on = this.hooks.foldProofs();
|
|
18660
|
+
return `<button type="button" class="sw-folds-btn" data-sw-folds aria-pressed="${on}" title="${on ? "Show every proof again" : "Fold every proof to one line, \u22EF proof: a click on one shows it"} (in every window, in this browser)">Fold proofs</button>`;
|
|
18661
|
+
}
|
|
18662
|
+
/** Proofs folded or shown, the reader's choice, in every window of the page (the page tells each,
|
|
18663
|
+
* `refold`). */
|
|
18664
|
+
foldProofs(on) {
|
|
18665
|
+
this.hooks.setFoldProofs(on);
|
|
18666
|
+
}
|
|
18667
|
+
/** Proofs folded or shown as the reader chose: the place in the file stays where it was read. */
|
|
18668
|
+
refold() {
|
|
18669
|
+
if (this.mode !== "file") return;
|
|
18670
|
+
const on = this.hooks.foldProofs();
|
|
18671
|
+
if (on) this.openFolds.clear();
|
|
18672
|
+
this.keepPlace(() => {
|
|
18673
|
+
this.el.classList.toggle("sw-folds", on);
|
|
18674
|
+
for (const el of this.el.querySelectorAll(".pf-open")) el.classList.remove("pf-open");
|
|
18675
|
+
this.applyOpen();
|
|
18676
|
+
});
|
|
18677
|
+
const b2 = this.el.querySelector("[data-sw-folds]");
|
|
18678
|
+
if (b2) b2.outerHTML = this.foldsButton();
|
|
18679
|
+
this.updateSticky();
|
|
18680
|
+
}
|
|
18681
|
+
/** A folded proof opened: that one alone, its place staying. */
|
|
18682
|
+
openFold(id) {
|
|
18683
|
+
this.openFolds.add(id);
|
|
18684
|
+
this.keepPlace(() => this.applyOpen());
|
|
18685
|
+
}
|
|
18686
|
+
/** The proofs opened one by one shown, in the code as drawn now. */
|
|
18687
|
+
applyOpen(root = this.frameEl) {
|
|
18688
|
+
for (const id of this.openFolds) for (const el of root.querySelectorAll(`[data-pf="${CSS.escape(id)}"], [data-pf-open="${CSS.escape(id)}"]`)) el.classList.add("pf-open");
|
|
18689
|
+
}
|
|
18690
|
+
/** Do `change` to what is drawn, the line read at the top of the code staying where it was. */
|
|
18691
|
+
keepPlace(change) {
|
|
18692
|
+
const sc = this.el.querySelector(".sw-scroll");
|
|
18693
|
+
const top = sc ? this.topLine() : null;
|
|
18694
|
+
const el = top ? this.lineEl(top.line) ?? null : null;
|
|
18695
|
+
const was = el?.getBoundingClientRect().top ?? null;
|
|
18696
|
+
change();
|
|
18697
|
+
if (!sc || !el || was === null) return;
|
|
18698
|
+
const now = (el.getClientRects().length ? el : el.parentElement).getBoundingClientRect().top;
|
|
18699
|
+
sc.scrollTop += now - was;
|
|
18700
|
+
}
|
|
18701
|
+
/** The line of the file at the top of the code, under the sticky header, and the element there;
|
|
18702
|
+
* null where nothing is. */
|
|
18703
|
+
topLine() {
|
|
18704
|
+
const sc = this.el.querySelector(".sw-scroll");
|
|
18705
|
+
const body = this.el.querySelector(".sw-file");
|
|
18706
|
+
if (!sc || !body) return null;
|
|
18707
|
+
const r2 = sc.getBoundingClientRect();
|
|
18708
|
+
const y2 = r2.top + (sc.querySelector(".sw-sticky")?.offsetHeight ?? 0) + LINE_H * 0.75;
|
|
18709
|
+
const x2 = body.getBoundingClientRect().left + 24;
|
|
18710
|
+
const hit = document.elementFromPoint(x2, y2);
|
|
18711
|
+
if (!hit || !this.el.contains(hit)) return null;
|
|
18712
|
+
if (hit.closest(".sw-review")) {
|
|
18713
|
+
const own2 = this.ownDecl();
|
|
18714
|
+
return own2 ? { line: own2.end, inReview: true } : null;
|
|
18715
|
+
}
|
|
18716
|
+
const ln = hit.closest(".ln");
|
|
18717
|
+
const pre = ln?.parentElement ?? hit.closest("pre.src");
|
|
18718
|
+
if (!pre?.matches("pre.src")) return null;
|
|
18719
|
+
return { line: Number(pre.dataset.line ?? 0) + (ln ? Array.prototype.indexOf.call(pre.children, ln) : 0), inReview: false };
|
|
18720
|
+
}
|
|
18721
|
+
/** what the sticky header names, as last drawn */
|
|
18722
|
+
stickyAt = null;
|
|
18723
|
+
stickyLater() {
|
|
18724
|
+
if (this.mode !== "file" || this.stickyWait) return;
|
|
18725
|
+
this.stickyWait = requestAnimationFrame(() => {
|
|
18726
|
+
this.stickyWait = 0;
|
|
18727
|
+
this.updateSticky();
|
|
18728
|
+
});
|
|
18729
|
+
}
|
|
18730
|
+
/** The sticky header: the declaration the reading position is in, with its state — pressed, it is
|
|
18731
|
+
* selected (the owner's decision of 2026-11-01: scrolling never selects) —, or the file between
|
|
18732
|
+
* declarations. */
|
|
18733
|
+
updateSticky() {
|
|
18734
|
+
const w2 = this.whole;
|
|
18735
|
+
const slot = this.el.querySelector(".sw-at-slot");
|
|
18736
|
+
if (!w2 || !slot) return;
|
|
18737
|
+
const top = this.topLine();
|
|
18738
|
+
const fd = top ? declAt(w2.decls, top.line) : null;
|
|
18739
|
+
const d2 = fd ? w2.decls.indexOf(fd) : -1;
|
|
18740
|
+
const key = fd ? `${fd.i}:${w2.marks[d2] ?? ""}:${fd.i === this.current}` : `-${w2.file}`;
|
|
18741
|
+
if (key === this.stickyAt) return;
|
|
18742
|
+
this.stickyAt = key;
|
|
18743
|
+
if (!fd) {
|
|
18744
|
+
slot.innerHTML = `<span class="sw-at-file">${escapeHtml(w2.file)}</span>`;
|
|
18745
|
+
return;
|
|
18746
|
+
}
|
|
18747
|
+
const v2 = w2.g.nodes[fd.i];
|
|
18748
|
+
const m3 = w2.marks[d2];
|
|
18749
|
+
const short6 = v2.display ?? v2.name.split(".").pop();
|
|
18750
|
+
slot.innerHTML = `<button type="button" class="sw-at" data-sw-at="${escapeHtml(v2.name)}" title="${escapeHtml(fd.i === this.current ? `${v2.name}: on show in this window` : `Select ${v2.name}`)}">${m3 ? `<span class="dm s-${m3}" aria-hidden="true"></span>` : ""}<span class="sw-at-name">${escapeHtml(short6)}</span><span class="sw-at-st">${m3 ? escapeHtml(FILE_MARK_LABEL[m3]) : ""}</span></button>`;
|
|
18751
|
+
}
|
|
18752
|
+
/** Scrolled to the window's declaration, under the sticky header; a file window, to its top. */
|
|
18753
|
+
scrollToOwn() {
|
|
18754
|
+
const sc = this.el.querySelector(".sw-scroll");
|
|
18755
|
+
if (!sc) return;
|
|
18756
|
+
const own2 = this.ownDecl();
|
|
18757
|
+
if (!own2) {
|
|
18758
|
+
if (this.file !== null) sc.scrollTop = 0;
|
|
18759
|
+
return;
|
|
18760
|
+
}
|
|
18761
|
+
const go = () => {
|
|
18762
|
+
const el = this.lineEl(own2.start);
|
|
18763
|
+
if (!el) return;
|
|
18764
|
+
const sticky = sc.querySelector(".sw-sticky")?.offsetHeight ?? 0;
|
|
18765
|
+
sc.scrollTop += el.getBoundingClientRect().top - sc.getBoundingClientRect().top - sticky - 10;
|
|
18766
|
+
};
|
|
18767
|
+
go();
|
|
18768
|
+
requestAnimationFrame(() => {
|
|
18769
|
+
go();
|
|
18770
|
+
this.updateSticky();
|
|
18771
|
+
});
|
|
18772
|
+
}
|
|
18773
|
+
/** Whether some of the window's declaration's lines are in sight. */
|
|
18774
|
+
ownInSight() {
|
|
18775
|
+
const sc = this.el.querySelector(".sw-scroll");
|
|
18776
|
+
const own2 = this.ownDecl();
|
|
18777
|
+
const a3 = own2 && this.lineEl(own2.start), b2 = own2 && this.lineEl(own2.end);
|
|
18778
|
+
if (!sc || !a3 || !b2) return false;
|
|
18779
|
+
const r2 = sc.getBoundingClientRect();
|
|
18780
|
+
return a3.getBoundingClientRect().top < r2.bottom && b2.getBoundingClientRect().bottom > r2.top + (sc.querySelector(".sw-sticky")?.offsetHeight ?? 0);
|
|
18781
|
+
}
|
|
18782
|
+
/** Lean asked what the names of each piece mean as it comes into sight (or near it), once per
|
|
18783
|
+
* text: a file's thousands of names are not asked at once. */
|
|
18784
|
+
watchPieces(w2) {
|
|
18785
|
+
this.seen?.disconnect();
|
|
18786
|
+
this.seen = null;
|
|
18787
|
+
const sc = this.el.querySelector(".sw-scroll");
|
|
18788
|
+
if (!sc) return;
|
|
18789
|
+
const learn = !this.still && !!w2.hash;
|
|
18790
|
+
if (typeof IntersectionObserver === "undefined") return void this.fillAround(0, Infinity);
|
|
18791
|
+
const seen = new IntersectionObserver(
|
|
18792
|
+
(es) => {
|
|
18793
|
+
for (const e2 of es) {
|
|
18794
|
+
if (!e2.isIntersecting) continue;
|
|
18795
|
+
seen.unobserve(e2.target);
|
|
18796
|
+
this.fill(e2.target);
|
|
18797
|
+
if (learn) void this.learnPiece(w2, Number(e2.target.dataset.piece));
|
|
18798
|
+
}
|
|
18799
|
+
},
|
|
18800
|
+
{ root: sc, rootMargin: "600px 0px" }
|
|
18801
|
+
);
|
|
18802
|
+
for (const pre of sc.querySelectorAll("pre.sw-piece")) seen.observe(pre);
|
|
18803
|
+
this.seen = seen;
|
|
18804
|
+
}
|
|
18805
|
+
/** What Lean says each name of piece `k` means, the piece drawn again with it. */
|
|
18806
|
+
async learnPiece(w2, k2) {
|
|
18807
|
+
const c3 = w2.chunks[k2];
|
|
18808
|
+
if (!c3) return;
|
|
18809
|
+
const key = `${w2.module}:${w2.hash}:${c3.start}-${c3.end}`;
|
|
18810
|
+
if (this.memory.learned.has(key)) return;
|
|
18811
|
+
const text2 = w2.lines.slice(c3.start, c3.end + 1).join("\n");
|
|
18812
|
+
const words = [];
|
|
18813
|
+
highlightLines(text2, (word, at) => (words.push({ word, at }), null));
|
|
18814
|
+
if (!words.length) return;
|
|
18815
|
+
const live = () => this.whole === w2 && this.mode === "file";
|
|
18816
|
+
await this.learn(live, w2.selfs[k2], key, w2.module, w2.hash, text2, c3.start, words, () => {
|
|
18817
|
+
const pre = this.frameEl.querySelector(`pre.sw-piece[data-piece="${k2}"]`);
|
|
18818
|
+
if (!pre) return;
|
|
18819
|
+
pre.innerHTML = this.pieceLines(k2);
|
|
18820
|
+
this.applyOpen(pre);
|
|
18821
|
+
this.flashLines();
|
|
18822
|
+
this.info.marks();
|
|
18823
|
+
});
|
|
18824
|
+
}
|
|
18825
|
+
/** The InfoView told the code drawn now, its element and the code's (none: no code on show). */
|
|
18826
|
+
attachInfo(code) {
|
|
18827
|
+
this.info.attach(this.frameEl.querySelector(".sw-info"), (line) => this.lineEl(line), code);
|
|
17067
18828
|
}
|
|
17068
18829
|
/** The context the code on show is written in, as Lean, muted above it: folded when long to
|
|
17069
18830
|
* its first lines and its namespaces and sections, with the `variable`s the declaration uses
|
|
@@ -17098,10 +18859,12 @@ var SourceWindow = class {
|
|
|
17098
18859
|
* the latest build. */
|
|
17099
18860
|
generatedHtml(unit, also) {
|
|
17100
18861
|
if (!also.length) return "";
|
|
17101
|
-
const shortOf = (a3) =>
|
|
18862
|
+
const shortOf = (a3) => generatedName(unit, a3).short;
|
|
17102
18863
|
if (this.still) return `<div class="sw-print"><div class="sw-print-h">What Lean generated from this command</div>${also.map((a3) => `<div class="sw-gen-row"><code title="${escapeHtml(a3)}">${escapeHtml(shortOf(a3))}</code></div>`).join("")}</div>`;
|
|
17103
18864
|
const rows = also.map((a3) => {
|
|
17104
18865
|
const short6 = shortOf(a3);
|
|
18866
|
+
if (generatedName(unit, a3).hygienic)
|
|
18867
|
+
return `<div class="sw-gen-row"><code class="sw-gen-hyg" title="${escapeHtml(`${a3}: a name of the macro's hygiene, which Lean cannot be asked about`)}">${escapeHtml(short6)}</code> <span class="sw-gen-cmd">\xB7 the macro's own name</span></div>`;
|
|
17105
18868
|
const open = this.printOpen.has(a3);
|
|
17106
18869
|
return `<div class="sw-gen-row"><button class="link sw-gen-name" data-sw-gen="${escapeHtml(a3)}" title="What Lean made of ${escapeHtml(a3)} (#print)"><span class="sw-gen-cmd">#print</span> ${escapeHtml(short6)}</button><pre class="code" data-sw-print${open ? "" : " hidden"}>${this.memory.printed.get(a3) ?? "Asking Lean\u2026"}</pre></div>`;
|
|
17107
18870
|
}).join("");
|
|
@@ -17132,7 +18895,7 @@ var SourceWindow = class {
|
|
|
17132
18895
|
/** Ask Lean what each name in the code on show means (server/hover.ts, `names`), and link the
|
|
17133
18896
|
* names by its answers: a declaration where it names one, nothing where it names a variable;
|
|
17134
18897
|
* the page's own reading stays where Lean says nothing. */
|
|
17135
|
-
async learn(
|
|
18898
|
+
async learn(live, self2, key, module, hash, text2, start, words, apply) {
|
|
17136
18899
|
const g2 = this.g;
|
|
17137
18900
|
const lineStarts = [0];
|
|
17138
18901
|
for (let k2 = 0; k2 < text2.length; k2++) if (text2[k2] === "\n") lineStarts.push(k2 + 1);
|
|
@@ -17156,18 +18919,22 @@ var SourceWindow = class {
|
|
|
17156
18919
|
}
|
|
17157
18920
|
});
|
|
17158
18921
|
if (!positions.length) return;
|
|
18922
|
+
if (positions.length > NAMES_MAX) {
|
|
18923
|
+
positions.length = NAMES_MAX;
|
|
18924
|
+
parts.length = NAMES_MAX;
|
|
18925
|
+
}
|
|
17159
18926
|
let heads;
|
|
17160
18927
|
for (let tries = 0; tries < 120 && !heads; tries++) {
|
|
17161
18928
|
const res = await this.data.names(module, positions, hash);
|
|
17162
|
-
if (
|
|
18929
|
+
if (!live() || !res || res.stale || res.error) return;
|
|
17163
18930
|
if (res.pending) await new Promise((ok) => setTimeout(ok, 1e3));
|
|
17164
18931
|
else heads = res.heads;
|
|
17165
18932
|
}
|
|
17166
|
-
if (!heads ||
|
|
18933
|
+
if (!heads || !live()) return;
|
|
17167
18934
|
const byWord = /* @__PURE__ */ new Map();
|
|
17168
18935
|
parts.forEach((p2, k2) => {
|
|
17169
18936
|
const segs = byWord.get(p2.word) ?? [];
|
|
17170
|
-
segs.push(heads[k2]);
|
|
18937
|
+
segs.push(heads[k2] ?? null);
|
|
17171
18938
|
byWord.set(p2.word, segs);
|
|
17172
18939
|
});
|
|
17173
18940
|
const learned = /* @__PURE__ */ new Map();
|
|
@@ -17190,11 +18957,8 @@ var SourceWindow = class {
|
|
|
17190
18957
|
} else if (segs.length === 1 && each[0] === null) learned.set(at, null);
|
|
17191
18958
|
}
|
|
17192
18959
|
this.memory.learned.set(key, learned);
|
|
17193
|
-
if (this.memory.learned.size >
|
|
17194
|
-
|
|
17195
|
-
if (!pre || turn !== this.turn) return;
|
|
17196
|
-
pre.innerHTML = highlightLines(text2, (w2, off) => learned.has(off) ? learned.get(off) : resolve(w2), start + 1);
|
|
17197
|
-
this.flashLines();
|
|
18960
|
+
if (this.memory.learned.size > 256) this.memory.learned.delete(this.memory.learned.keys().next().value);
|
|
18961
|
+
if (live()) apply(learned);
|
|
17198
18962
|
}
|
|
17199
18963
|
};
|
|
17200
18964
|
function offsetIn(root, node, off) {
|
|
@@ -17204,7 +18968,7 @@ function offsetIn(root, node, off) {
|
|
|
17204
18968
|
return r2.toString().length;
|
|
17205
18969
|
}
|
|
17206
18970
|
function codeHtml(lines, start, text2) {
|
|
17207
|
-
return `<pre class="code src" style="--gw:${gutterDigits(start + text2.split("\n").length)}">${lines}</pre>`;
|
|
18971
|
+
return `<pre class="code src" data-line="${start}" style="--gw:${gutterDigits(start + text2.split("\n").length)}">${lines}</pre>`;
|
|
17208
18972
|
}
|
|
17209
18973
|
function githubAnchor(href, commit, what) {
|
|
17210
18974
|
const title = what ? `These lines of ${what}, on GitHub` : `These lines at ${commit.slice(0, 7)}, the commit of the build shown, on GitHub`;
|
|
@@ -40429,7 +42193,60 @@ function panelsPart(page) {
|
|
|
40429
42193
|
return past && past.graph === G2 ? { past, when: buildWhen(past.snapshot.at) } : null;
|
|
40430
42194
|
},
|
|
40431
42195
|
// the reference window paired with a source window stands beside it, on the right of the two
|
|
40432
|
-
docked: (w2) => papers.dockFor(w2)
|
|
42196
|
+
docked: (w2) => papers.dockFor(w2),
|
|
42197
|
+
// the InfoView (ReviewSpec, "The InfoView"): hidden by the reader in every window, kept in the
|
|
42198
|
+
// browser; the page's one caret, in the window the reader put it in last, which those following
|
|
42199
|
+
// see (CollabSpec, "Surfaces": caret)
|
|
42200
|
+
infoHidden: () => !!store2.data.infoHidden,
|
|
42201
|
+
hideInfo: (on) => {
|
|
42202
|
+
store2.data.infoHidden = on ? true : void 0;
|
|
42203
|
+
store2.save();
|
|
42204
|
+
for (const w2 of sources.all) w2.infoChanged();
|
|
42205
|
+
},
|
|
42206
|
+
caretMoved: (w2) => {
|
|
42207
|
+
for (const o2 of sources.all) if (o2 !== w2) o2.followCaret(null);
|
|
42208
|
+
page.people.report();
|
|
42209
|
+
},
|
|
42210
|
+
following: () => !!page.people.following,
|
|
42211
|
+
// File mode (the owner's decisions of 2026-11-01): the marks are the board's review, as its
|
|
42212
|
+
// Status colouring reads it
|
|
42213
|
+
review: () => page.boardReview(),
|
|
42214
|
+
inReview: (G2) => inReviewOf(G2),
|
|
42215
|
+
compiledText: async (m3) => {
|
|
42216
|
+
if (data.snapshot) return null;
|
|
42217
|
+
await page.tm.load().catch(() => {
|
|
42218
|
+
});
|
|
42219
|
+
const id = page.tm.latest;
|
|
42220
|
+
const got = id === null ? null : await data.pastSource(id, m3);
|
|
42221
|
+
return got && !("missing" in got) ? got.text.split("\n") : null;
|
|
42222
|
+
},
|
|
42223
|
+
foldProofs: () => store2.data.proofsFolded === true,
|
|
42224
|
+
setFoldProofs: (on) => {
|
|
42225
|
+
store2.data.proofsFolded = on ? true : void 0;
|
|
42226
|
+
store2.save();
|
|
42227
|
+
for (const w2 of sources.all) w2.refold();
|
|
42228
|
+
},
|
|
42229
|
+
moded: () => {
|
|
42230
|
+
page.people.report();
|
|
42231
|
+
papers.redock();
|
|
42232
|
+
}
|
|
42233
|
+
};
|
|
42234
|
+
let reviewed = null;
|
|
42235
|
+
const inReviewOf = (G2) => {
|
|
42236
|
+
if (G2 !== page.g) return null;
|
|
42237
|
+
const d2 = page.boardReview();
|
|
42238
|
+
const key = Object.keys(d2.targets).sort().join("\n") + "\n\n" + d2.trusted.join("\n");
|
|
42239
|
+
if (!reviewed || reviewed.g !== G2 || reviewed.key !== key) {
|
|
42240
|
+
const roots3 = Object.keys(d2.targets).map((n3) => G2.byName.get(n3)).filter((i2) => i2 !== void 0);
|
|
42241
|
+
let set2 = null;
|
|
42242
|
+
if (roots3.length) {
|
|
42243
|
+
set2 = new Uint8Array(G2.n);
|
|
42244
|
+
for (const r2 of roots3) for (const i2 of page.flow.order(r2)) set2[i2] = 1;
|
|
42245
|
+
}
|
|
42246
|
+
reviewed = { g: G2, key, set: set2 };
|
|
42247
|
+
}
|
|
42248
|
+
const set = reviewed.set;
|
|
42249
|
+
return set ? (i2) => set[i2] === 1 : null;
|
|
40433
42250
|
};
|
|
40434
42251
|
const memory = sourceMemory();
|
|
40435
42252
|
const sources = new Sources({
|
|
@@ -40445,7 +42262,9 @@ function panelsPart(page) {
|
|
|
40445
42262
|
top: () => pairTop(),
|
|
40446
42263
|
// the reference window opens the declaration's first link beside the window opened or stepped,
|
|
40447
42264
|
// pinned or not (AttachmentSpec decision 8)
|
|
40448
|
-
shown: (w2, i2) => papers.paired(i2, w2)
|
|
42265
|
+
shown: (w2, i2) => papers.paired(i2, w2),
|
|
42266
|
+
// a file window stays while the graph has declarations in its file
|
|
42267
|
+
hasFile: (m3) => moduleDecls(page.g, m3).length > 0
|
|
40449
42268
|
});
|
|
40450
42269
|
const openSourceAt = (name, from, to, quoted, at) => {
|
|
40451
42270
|
const j2 = page.g.byName.get(name) ?? page.g.foldedInto.get(name);
|
|
@@ -42791,122 +44610,6 @@ var Motion = class {
|
|
|
42791
44610
|
}
|
|
42792
44611
|
};
|
|
42793
44612
|
|
|
42794
|
-
// src/web/src/status.ts
|
|
42795
|
-
var SCHEMES_SHOWN = ["kind", "status", "mine"];
|
|
42796
|
-
var STATUSES2 = ["failed", "building", "sorry", "commented", "stale", "approved", "unreviewed", "trusted"];
|
|
42797
|
-
var ST_FAILED = 0;
|
|
42798
|
-
var ST_BUILDING = 1;
|
|
42799
|
-
var ST_SORRY = 2;
|
|
42800
|
-
var ST_COMMENTED = 3;
|
|
42801
|
-
var ST_STALE = 4;
|
|
42802
|
-
var ST_APPROVED = 5;
|
|
42803
|
-
var ST_UNREVIEWED = 6;
|
|
42804
|
-
var ST_TRUSTED = 7;
|
|
42805
|
-
var STATUS_LABEL = {
|
|
42806
|
-
failed: "failed or not built",
|
|
42807
|
-
building: "building",
|
|
42808
|
-
sorry: "contains sorry",
|
|
42809
|
-
commented: "commented",
|
|
42810
|
-
stale: "stale",
|
|
42811
|
-
approved: "approved",
|
|
42812
|
-
unreviewed: "not yet reviewed",
|
|
42813
|
-
trusted: "trusted"
|
|
42814
|
-
};
|
|
42815
|
-
var STATUS_HINT = {
|
|
42816
|
-
failed: "Its file failed to compile in the last build, or was never built: shown as it was last built",
|
|
42817
|
-
building: "Its file is being compiled right now",
|
|
42818
|
-
sorry: "It rests on sorry: its own, or through anything it uses",
|
|
42819
|
-
commented: "A reviewer's latest word on its present version is a comment",
|
|
42820
|
-
stale: "It has opinions, none on its present version",
|
|
42821
|
-
approved: "A reviewer approved its present version, and no reviewer's latest word on it is a comment",
|
|
42822
|
-
unreviewed: "Nobody has given an opinion on it yet, and nothing trusts it",
|
|
42823
|
-
trusted: "Trusted without review (Mathlib, Lean core, a trusted prefix, the standard axioms), with no opinion on it"
|
|
42824
|
-
};
|
|
42825
|
-
var MINE_STATES = [ST_COMMENTED, ST_STALE, ST_APPROVED, ST_UNREVIEWED, ST_TRUSTED];
|
|
42826
|
-
function mineLabel(code, whose) {
|
|
42827
|
-
const who = whose ?? "you";
|
|
42828
|
-
switch (code) {
|
|
42829
|
-
case ST_COMMENTED:
|
|
42830
|
-
return `${who} commented`;
|
|
42831
|
-
case ST_STALE:
|
|
42832
|
-
return `${whose ? `${whose}'s` : "your"} opinion is stale`;
|
|
42833
|
-
case ST_APPROVED:
|
|
42834
|
-
return `${who} approved`;
|
|
42835
|
-
case ST_TRUSTED:
|
|
42836
|
-
return "trusted";
|
|
42837
|
-
default:
|
|
42838
|
-
return `not reviewed by ${whose ?? "you"}`;
|
|
42839
|
-
}
|
|
42840
|
-
}
|
|
42841
|
-
function mineHint(code, whose) {
|
|
42842
|
-
const your = whose ? `${whose}'s` : "Your";
|
|
42843
|
-
switch (code) {
|
|
42844
|
-
case ST_COMMENTED:
|
|
42845
|
-
return `${your} current opinion on its present version is a comment`;
|
|
42846
|
-
case ST_STALE:
|
|
42847
|
-
return `${your} current opinion is on an earlier version: it changed since`;
|
|
42848
|
-
case ST_APPROVED:
|
|
42849
|
-
return `${your} current opinion approves its present version`;
|
|
42850
|
-
case ST_TRUSTED:
|
|
42851
|
-
return `Trusted without review, and no opinion of ${whose ? `${whose}'s` : "yours"} on it`;
|
|
42852
|
-
default:
|
|
42853
|
-
return `It needs review, and ${whose ? `${whose} has` : "you have"} no opinion on it (none given, or withdrawn)`;
|
|
42854
|
-
}
|
|
42855
|
-
}
|
|
42856
|
-
function mineState(d2, g2, i2, me) {
|
|
42857
|
-
const v2 = g2.nodes[i2];
|
|
42858
|
-
const s2 = me ? ownStatus(d2, v2.name, me, v2.hash) : "none";
|
|
42859
|
-
if (s2 === "stale") return ST_STALE;
|
|
42860
|
-
if (s2 === "commented") return ST_COMMENTED;
|
|
42861
|
-
if (s2 === "approved") return ST_APPROVED;
|
|
42862
|
-
return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
|
|
42863
|
-
}
|
|
42864
|
-
function mineCodes(d2, g2, me) {
|
|
42865
|
-
const out = new Uint8Array(g2.n);
|
|
42866
|
-
for (let i2 = 0; i2 < g2.n; i2++) out[i2] = mineState(d2, g2, i2, me);
|
|
42867
|
-
return out;
|
|
42868
|
-
}
|
|
42869
|
-
function statusState(d2, g2, i2, file, sorryAx) {
|
|
42870
|
-
if (file?.state === "building") return ST_BUILDING;
|
|
42871
|
-
if (file?.state === "failed" || file?.state === "unbuilt") return ST_FAILED;
|
|
42872
|
-
if (sorryAx) return ST_SORRY;
|
|
42873
|
-
const v2 = g2.nodes[i2];
|
|
42874
|
-
const s2 = statusOf(d2, v2.name, v2.hash);
|
|
42875
|
-
if (s2 === "commented") return ST_COMMENTED;
|
|
42876
|
-
if (s2 === "stale") return ST_STALE;
|
|
42877
|
-
if (s2 === "approved") return ST_APPROVED;
|
|
42878
|
-
return needsReview(g2, d2, i2) ? ST_UNREVIEWED : ST_TRUSTED;
|
|
42879
|
-
}
|
|
42880
|
-
function statusCodes(d2, g2, files) {
|
|
42881
|
-
const out = new Uint8Array(g2.n);
|
|
42882
|
-
const sorrySets = /* @__PURE__ */ new Map();
|
|
42883
|
-
for (let i2 = 0; i2 < g2.n; i2++) {
|
|
42884
|
-
const ax = g2.nodes[i2].ax;
|
|
42885
|
-
let s2 = sorrySets.get(ax);
|
|
42886
|
-
if (s2 === void 0) sorrySets.set(ax, s2 = g2.axiomsOf(i2).includes("sorryAx"));
|
|
42887
|
-
out[i2] = statusState(d2, g2, i2, g2.isExt(i2) ? void 0 : files.get(g2.nodes[i2].module), s2);
|
|
42888
|
-
}
|
|
42889
|
-
return out;
|
|
42890
|
-
}
|
|
42891
|
-
function fileTrouble(f2) {
|
|
42892
|
-
switch (f2?.state) {
|
|
42893
|
-
case "failed":
|
|
42894
|
-
case "unbuilt":
|
|
42895
|
-
return ST_FAILED;
|
|
42896
|
-
case "building":
|
|
42897
|
-
return ST_BUILDING;
|
|
42898
|
-
case "sorry":
|
|
42899
|
-
return ST_SORRY;
|
|
42900
|
-
default:
|
|
42901
|
-
return -1;
|
|
42902
|
-
}
|
|
42903
|
-
}
|
|
42904
|
-
function clusterTroubles(clusters, clustering, files) {
|
|
42905
|
-
const out = new Int8Array(clusters.length).fill(-1);
|
|
42906
|
-
if (clustering === "module") clusters.forEach((c3, k2) => out[k2] = fileTrouble(files.get(c3.key)));
|
|
42907
|
-
return out;
|
|
42908
|
-
}
|
|
42909
|
-
|
|
42910
44613
|
// src/web/src/visitors.ts
|
|
42911
44614
|
var TRAIL = 6;
|
|
42912
44615
|
function visit(trail, v2) {
|
|
@@ -46986,6 +48689,7 @@ function itemSpot(n3, b2, exists, linked = []) {
|
|
|
46986
48689
|
const at = declOf2(n3, b2, exists);
|
|
46987
48690
|
if (at && typeof at === "object") return { at: "decl", j: at.j, name: at.name, d: [n3.decl.at[0], n3.decl.at[1]] };
|
|
46988
48691
|
if (at === "off") return { at: "ring", angle: null, about: linked.length ? { links: [...linked] } : null };
|
|
48692
|
+
if (at === "gone") return { at: "ring", angle: null, about: placedAbout(n3.places, b2, exists) ?? (linked.length ? { links: [...linked] } : null), gone: n3.decl.name };
|
|
46989
48693
|
const m3 = b2.mode;
|
|
46990
48694
|
const place2 = n3.places[m3];
|
|
46991
48695
|
const h2 = holderOf(place2, m3, exists);
|
|
@@ -47004,6 +48708,15 @@ function itemSpot(n3, b2, exists, linked = []) {
|
|
|
47004
48708
|
const about = linked.length ? { links: [...linked] } : o2 && b2.on[otherMode(m3)].has(o2.key) ? { mode: otherMode(m3), key: o2.key } : null;
|
|
47005
48709
|
return { at: "ring", angle: place2 && "ring" in place2 ? place2.ring : null, about };
|
|
47006
48710
|
}
|
|
48711
|
+
function placedAbout(places, b2, exists) {
|
|
48712
|
+
for (const m3 of [b2.mode, otherMode(b2.mode)]) {
|
|
48713
|
+
const p2 = places[m3];
|
|
48714
|
+
if (!p2 || !("in" in p2)) continue;
|
|
48715
|
+
const key = p2.in.map((e2) => e2[0]).find((k2) => exists(m3, k2) && b2.on[m3].has(k2));
|
|
48716
|
+
if (key) return { mode: m3, key };
|
|
48717
|
+
}
|
|
48718
|
+
return null;
|
|
48719
|
+
}
|
|
47007
48720
|
function aboutMembers(b2, about) {
|
|
47008
48721
|
if (!about) return [];
|
|
47009
48722
|
if ("key" in about) return membersOf2(b2, about.mode, about.key);
|
|
@@ -47017,13 +48730,15 @@ function aboutMembers(b2, about) {
|
|
|
47017
48730
|
}
|
|
47018
48731
|
return [...out].sort((x2, y2) => x2 - y2);
|
|
47019
48732
|
}
|
|
47020
|
-
function viewSpot(n3, b2, index) {
|
|
47021
|
-
const at = declOf2(n3, b2,
|
|
48733
|
+
function viewSpot(n3, b2, index, exists = NO_GRAPH) {
|
|
48734
|
+
const at = declOf2(n3, b2, exists);
|
|
47022
48735
|
if (at && typeof at === "object") return { at: "decl", j: at.j, name: at.name, d: [n3.decl.at[0], n3.decl.at[1]] };
|
|
48736
|
+
const key = n3.place.in.map((e2) => e2[0]).find((k2) => b2.on[n3.place.mode].has(k2));
|
|
48737
|
+
const about = key ? { mode: n3.place.mode, key } : null;
|
|
48738
|
+
if (at === "gone") return { at: "ring", angle: null, about, gone: n3.decl.name };
|
|
47023
48739
|
const r2 = resolvePlace(n3.place, b2.mode, index);
|
|
47024
48740
|
if (r2) return r2.c >= 0 ? { at: "offset", c: r2.c, d: [r2.dx, r2.dy] } : { at: "world", x: r2.dx, y: r2.dy };
|
|
47025
|
-
|
|
47026
|
-
return { at: "ring", angle: null, about: key ? { mode: n3.place.mode, key } : null };
|
|
48741
|
+
return { at: "ring", angle: null, about };
|
|
47027
48742
|
}
|
|
47028
48743
|
var NO_GRAPH = () => true;
|
|
47029
48744
|
function declPlace(L2, i2, d2 = [0, 0]) {
|
|
@@ -47289,7 +49004,7 @@ var Stickies = class {
|
|
|
47289
49004
|
};
|
|
47290
49005
|
const all = [
|
|
47291
49006
|
...project.map((n3) => ({ kind: "project", note: n3, ...projectSpot(n3) })),
|
|
47292
|
-
...view.map((n3) => ({ kind: "view", note: n3, spot: viewSpot(n3, nb, (key) => index.get(key) ?? -1), why: null }))
|
|
49007
|
+
...view.map((n3) => ({ kind: "view", note: n3, spot: viewSpot(n3, nb, (key) => index.get(key) ?? -1, exists), why: null }))
|
|
47293
49008
|
];
|
|
47294
49009
|
for (const { kind, note: n3, spot, why } of all) {
|
|
47295
49010
|
if (!spot || keep2.has(n3.id)) continue;
|
|
@@ -47365,27 +49080,31 @@ var Stickies = class {
|
|
|
47365
49080
|
return ICONS2[iconKind(n3.carries, (sha) => this.hooks.file(sha))] + (count2 ? `<span class="sk-count">${count2}</span>` : "") + `<span class="sk-dot"></span>`;
|
|
47366
49081
|
}
|
|
47367
49082
|
/** What the pointer on an icon says: the note's first line, what it carries, whose it is, what it is
|
|
47368
|
-
* about on the ring,
|
|
49083
|
+
* about on the ring — or the declaration it is attached to, there because this build does not
|
|
49084
|
+
* have it —, and what a click does. */
|
|
47369
49085
|
iconTitle(n3, own2, spot, why) {
|
|
47370
49086
|
const cs = n3.carries ?? [];
|
|
47371
49087
|
const carried = cs.length ? ` \u2014 carries ${cs.map((c3) => this.carryWords(c3)).join("; ")}` : "";
|
|
47372
49088
|
const whose = own2 ? " \u2014 only in this view" : why === "added" ? " \u2014 added to this view" : "";
|
|
47373
|
-
const about = spot.at === "ring" && spot.about ? ` \u2014 ${aboutWords(spot.about)}` : spot.at === "decl" ? ` \u2014 attached to ${spot.name}` : "";
|
|
49089
|
+
const about = spot.at === "ring" && spot.gone ? ` \u2014 attached to ${spot.gone}, not in this build` : spot.at === "ring" && spot.about ? ` \u2014 ${aboutWords(spot.about)}` : spot.at === "decl" ? ` \u2014 attached to ${spot.name}` : "";
|
|
47374
49090
|
const first = noteExcerpt(n3.text.split("\n").find((l2) => l2.trim()) ?? n3.text, 120);
|
|
47375
49091
|
return `${first}${carried}${whose}${about}`;
|
|
47376
49092
|
}
|
|
47377
|
-
/** A note's card: its text, what it carries, who wrote it,
|
|
49093
|
+
/** A note's card: its text, what it carries, who wrote it, for a view's own (`own`) whose it is, and,
|
|
49094
|
+
* on the ring because this build does not have the declaration it is attached to, which that is
|
|
49095
|
+
* (the owner's decision of 2026-10-30). */
|
|
47378
49096
|
cardHtml(n3, own2, spot) {
|
|
47379
49097
|
const by = n3.by ? n3.agent ? `${BOT}${escapeHtml(n3.by)}` : nameHtml(n3.by, n3.person) : "Someone";
|
|
47380
49098
|
const ed = n3.edited;
|
|
47381
49099
|
const other = ed?.by && !(ed.person ? ed.person === n3.person : !n3.person && ed.by === n3.by);
|
|
47382
49100
|
const edited = ed ? ` \xB7 edited${other ? ` by ${nameHtml(ed.by, ed.person)}` : ""}` : "";
|
|
47383
49101
|
const whose = own2 ? `<div class="sk-whose">${VIEW_MARK}only in this view</div>` : "";
|
|
49102
|
+
const gone = spot.at === "ring" && spot.gone ? `<div class="sk-whose sk-gone">attached to <code>${escapeHtml(spot.gone)}</code>, not in this build</div>` : "";
|
|
47384
49103
|
const words = spot.at === "ring" && spot.about ? aboutWords(spot.about) : "";
|
|
47385
49104
|
const about = words ? `${words.charAt(0).toUpperCase()}${words.slice(1)}` : "";
|
|
47386
49105
|
const cs = n3.carries ?? [];
|
|
47387
49106
|
const w2 = (cs.some((c3) => this.pictured(c3)) ? CARRY_W.picture : CARRY_W.paper) - INNER_PAD;
|
|
47388
|
-
return `<div class="sk-text"${about ? ` title="${escapeHtml(about)}"` : ""}>${renderMarkdown(n3.text, (name) => this.hooks.resolve(name))}</div>` + (cs.length ? `<div class="sk-carries">${cs.map((c3, k2) => this.carryHtml(c3, k2, w2)).join("")}</div>` : "") + `<div class="sk-by">${by}${edited}</div>${whose}`;
|
|
49107
|
+
return `<div class="sk-text"${about ? ` title="${escapeHtml(about)}"` : ""}>${renderMarkdown(n3.text, (name) => this.hooks.resolve(name))}</div>` + (cs.length ? `<div class="sk-carries">${cs.map((c3, k2) => this.carryHtml(c3, k2, w2)).join("")}</div>` : "") + `<div class="sk-by">${by}${edited}</div>${whose}${gone}`;
|
|
47389
49108
|
}
|
|
47390
49109
|
// ---------------------------------------------------------------- what a note carries
|
|
47391
49110
|
/** Whether a carry is something to look at, drawn at the note's width: an image, or a clip. */
|
|
@@ -51637,6 +53356,7 @@ var BoardSync = class {
|
|
|
51637
53356
|
};
|
|
51638
53357
|
|
|
51639
53358
|
// src/web/src/outline.ts
|
|
53359
|
+
var FILE_MARK = `<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 1.8h5.2L12.5 5v9.2H4zM9 1.8V5.2h3.4"/></svg>`;
|
|
51640
53360
|
var HIDE_MARK = `<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/><path d="M2.5 13.5l11-11"/></svg>`;
|
|
51641
53361
|
function rowsToWrite(before, after, held2) {
|
|
51642
53362
|
if (before.length !== after.length || held2 !== after.length) return null;
|
|
@@ -51678,6 +53398,8 @@ var Outline2 = class {
|
|
|
51678
53398
|
this.hooks.trustClicked(c3, row);
|
|
51679
53399
|
} else if (t2.closest("[data-hide]")) {
|
|
51680
53400
|
this.hooks.hide(c3);
|
|
53401
|
+
} else if (t2.closest("[data-o-file]")) {
|
|
53402
|
+
this.hooks.openFile?.(c3);
|
|
51681
53403
|
} else this.hooks.select(c3, e2.shiftKey);
|
|
51682
53404
|
});
|
|
51683
53405
|
}
|
|
@@ -51711,7 +53433,7 @@ var Outline2 = class {
|
|
|
51711
53433
|
rows.push(
|
|
51712
53434
|
`<div class="o-row${inactive ? " folded" : ""}${this.hooks.picked(c3) ? " on" : ""}" data-c="${c3}" style="padding-left:${8 + depth * 12}px" title="${escapeHtml(cl.key)}">` + // the arrow opens or folds a level of the list, the name selects: each a button, for the
|
|
51713
53435
|
// keyboard as for the pointer
|
|
51714
|
-
(has ? `<button class="tw" type="button" aria-expanded="${this.open.has(c3)}" aria-label="What ${escapeHtml(cl.label)} holds">${this.open.has(c3) ? "\u25BE" : "\u25B8"}</button>` : `<span class="tw"></span>`) + `<button class="o-label" type="button">${escapeHtml(cl.label)}</button>` + (this.hooks.stateOf(c3) ? `<span class="o-st ${this.hooks.stateOf(c3)}"></span>` : "") + `<span class="o-count">${cl.count}</span>` + this.hooks.trustCell(c3) + `<button class="o-hide" data-hide title="Hide this level, for everyone on this board: what it holds moves up into its parent (\u2699 Board shows it again)" aria-label="Hide this level">${HIDE_MARK}</button><button class="fold" title="${folded ? "Unfold" : "Fold"} on the canvas" aria-label="${folded ? "Unfold" : "Fold"} ${escapeHtml(cl.label)} on the canvas">${folded ? "\u25CB" : "\u25CF"}</button></div>`
|
|
53436
|
+
(has ? `<button class="tw" type="button" aria-expanded="${this.open.has(c3)}" aria-label="What ${escapeHtml(cl.label)} holds">${this.open.has(c3) ? "\u25BE" : "\u25B8"}</button>` : `<span class="tw"></span>`) + `<button class="o-label" type="button">${escapeHtml(cl.label)}</button>` + (this.hooks.stateOf(c3) ? `<span class="o-st ${this.hooks.stateOf(c3)}"></span>` : "") + `<span class="o-count">${cl.count}</span>` + (this.hooks.file?.(c3) ? `<button class="o-file" type="button" data-o-file title="Open the file: the whole of ${escapeHtml(this.hooks.file(c3))} in a window of its own" aria-label="Open the file ${escapeHtml(cl.label)}">${FILE_MARK}</button>` : "") + this.hooks.trustCell(c3) + `<button class="o-hide" data-hide title="Hide this level, for everyone on this board: what it holds moves up into its parent (\u2699 Board shows it again)" aria-label="Hide this level">${HIDE_MARK}</button><button class="fold" title="${folded ? "Unfold" : "Fold"} on the canvas" aria-label="${folded ? "Unfold" : "Fold"} ${escapeHtml(cl.label)} on the canvas">${folded ? "\u25CB" : "\u25CF"}</button></div>`
|
|
51715
53437
|
);
|
|
51716
53438
|
if (has && this.open.has(c3)) for (const k2 of this.kids[c3]) walk2(k2, depth + 1);
|
|
51717
53439
|
};
|
|
@@ -51733,6 +53455,11 @@ var Outline2 = class {
|
|
|
51733
53455
|
};
|
|
51734
53456
|
|
|
51735
53457
|
// src/web/src/pageside.ts
|
|
53458
|
+
function fileCluster(page, key) {
|
|
53459
|
+
if (page.cm() !== "module" || isPhone()) return null;
|
|
53460
|
+
const g2 = page.g;
|
|
53461
|
+
return moduleDecls(g2, key).some((i2) => !g2.isExt(i2)) ? key : null;
|
|
53462
|
+
}
|
|
51736
53463
|
function sidePart(page) {
|
|
51737
53464
|
const { data, store: store2, reader } = page;
|
|
51738
53465
|
const shut = (section) => store2.isShut(section);
|
|
@@ -51782,7 +53509,14 @@ function sidePart(page) {
|
|
|
51782
53509
|
},
|
|
51783
53510
|
trustCell: (c3) => trust.cell(page.canvas.layout.clusters[c3], page.cm()),
|
|
51784
53511
|
trustClicked: (c3, row) => trust.clicked(page.canvas.layout.clusters[c3], page.cm(), row),
|
|
51785
|
-
hide: (c3) => hideLevel(page.canvas.layout.clusters[c3].key)
|
|
53512
|
+
hide: (c3) => hideLevel(page.canvas.layout.clusters[c3].key),
|
|
53513
|
+
// clustered by file, a file of the project opens whole (the owner's decision of 2026-11-01); a
|
|
53514
|
+
// phone pins no window (PhoneSpec decision 13), and opens it by a window's switch alone
|
|
53515
|
+
file: (c3) => fileCluster(page, page.canvas.layout.clusters[c3].key),
|
|
53516
|
+
openFile: (c3) => {
|
|
53517
|
+
const m3 = fileCluster(page, page.canvas.layout.clusters[c3].key);
|
|
53518
|
+
if (m3) page.sources.openFile(m3);
|
|
53519
|
+
}
|
|
51786
53520
|
});
|
|
51787
53521
|
page.fileIndex = files();
|
|
51788
53522
|
const boardPanel = new BoardPanel($("#board"), $("#board-note"), {
|
|
@@ -52419,6 +54153,7 @@ function schemePart(page) {
|
|
|
52419
54153
|
// src/web/src/pagefollow.ts
|
|
52420
54154
|
function followPart(page) {
|
|
52421
54155
|
const { S: S7 } = page;
|
|
54156
|
+
const pinnedOf = (p2) => p2.file !== null ? { file: p2.file, collapsed: p2.collapsed } : { decl: p2.name, collapsed: p2.collapsed, ...p2.mode === "file" ? { mode: "file" } : {} };
|
|
52422
54157
|
const parts = {
|
|
52423
54158
|
read: {
|
|
52424
54159
|
view: () => ({ view: page.nav.board.id, scope: page.nav.query(), clusterMode: page.cm() }),
|
|
@@ -52432,14 +54167,23 @@ function followPart(page) {
|
|
|
52432
54167
|
focus: () => page.mine !== void 0 ? { focus: page.mine } : {},
|
|
52433
54168
|
visitors: () => page.visitors.length ? { visitors: shareVisitors(page.visitors, (k2) => page.canvas.visitorPos(k2)) } : {},
|
|
52434
54169
|
panel: () => ({ sel: page.shown && "decl" in page.shown ? page.shown.decl : null }),
|
|
52435
|
-
// the source windows, the following one and those pinned (decided 2026-10-09)
|
|
54170
|
+
// the source windows, the following one and those pinned (decided 2026-10-09), each in its
|
|
54171
|
+
// mode, and the file windows (the owner's decisions of 2026-11-01)
|
|
52436
54172
|
sources: () => ({
|
|
52437
54173
|
source: page.sources.open,
|
|
52438
54174
|
...page.sources.following?.collapsed ? { sourceCollapsed: true } : {},
|
|
52439
|
-
...page.sources.
|
|
54175
|
+
...page.sources.following?.mode === "file" ? { sourceMode: "file" } : {},
|
|
54176
|
+
...page.sources.pinned.length ? { pinned: page.sources.pinned.map(pinnedOf) } : {}
|
|
52440
54177
|
}),
|
|
52441
54178
|
// the reference window (AttachmentSpec decision 11)
|
|
52442
54179
|
paper: () => page.papers.state() ? { paper: page.papers.state() } : {},
|
|
54180
|
+
// the InfoView's caret (ReviewSpec, "The InfoView"; the owner's decision of 2026-11-01): the
|
|
54181
|
+
// page's one, in the window the reader put it in
|
|
54182
|
+
caret: () => {
|
|
54183
|
+
const w2 = page.sources.all.find((p2) => p2.caret);
|
|
54184
|
+
const c3 = w2?.caret;
|
|
54185
|
+
return w2 && c3 ? { caret: { decl: w2.name, line: c3.line, character: c3.ch, ...c3.after ? { after: true } : {}, ...w2 !== page.sources.following ? { pinned: true } : {} } } : {};
|
|
54186
|
+
},
|
|
52443
54187
|
activity: () => ({ activity: page.activity.state() }),
|
|
52444
54188
|
lostFound: () => ({ lostFound: { open: page.lostDrawer.open } }),
|
|
52445
54189
|
// the reader's own, under an artwork's, which the artwork's part carries
|
|
@@ -52494,14 +54238,20 @@ function followPart(page) {
|
|
|
52494
54238
|
if (ended()) return reached;
|
|
52495
54239
|
applyOwn(v2, parts.apply);
|
|
52496
54240
|
if (!once) page.papers.mirror(v2.paper);
|
|
52497
|
-
if (!page.pastShown())
|
|
54241
|
+
if (!page.pastShown()) {
|
|
52498
54242
|
page.sources.mirror({
|
|
52499
|
-
following: v2.source ? { decl: page.selected(), collapsed: v2.sourceCollapsed === true } : null,
|
|
54243
|
+
following: v2.source ? { decl: page.selected(), collapsed: v2.sourceCollapsed === true, mode: v2.sourceMode === "file" ? "file" : "decl" } : null,
|
|
52500
54244
|
pinned: (v2.pinned ?? []).flatMap((w2) => {
|
|
54245
|
+
if ("file" in w2) return moduleDecls(page.g, w2.file).length ? [{ file: w2.file, collapsed: w2.collapsed }] : [];
|
|
52501
54246
|
const i2 = page.g.byName.get(w2.decl);
|
|
52502
|
-
return i2 === void 0 ? [] : [{ decl: i2, collapsed: w2.collapsed }];
|
|
54247
|
+
return i2 === void 0 ? [] : [{ decl: i2, collapsed: w2.collapsed, ...w2.mode === "file" ? { mode: "file" } : {} }];
|
|
52503
54248
|
})
|
|
52504
54249
|
});
|
|
54250
|
+
const c3 = v2.caret;
|
|
54251
|
+
const f2 = page.sources.following;
|
|
54252
|
+
const at = c3 ? c3.pinned ? page.sources.pinned.find((p2) => p2.name === c3.decl) : f2 && f2.name === c3.decl ? f2 : void 0 : void 0;
|
|
54253
|
+
for (const p2 of page.sources.all) p2.followCaret(p2 === at && c3 ? { line: c3.line, ch: c3.character, after: c3.after === true } : null);
|
|
54254
|
+
}
|
|
52505
54255
|
if (once) {
|
|
52506
54256
|
page.papers.mirror(v2.paper);
|
|
52507
54257
|
page.sources.release();
|
|
@@ -52555,12 +54305,12 @@ function talkPart(page) {
|
|
|
52555
54305
|
peers: () => page.people.peers,
|
|
52556
54306
|
resolve: resolveName,
|
|
52557
54307
|
go: (name) => {
|
|
52558
|
-
page.people.
|
|
54308
|
+
page.people.leave();
|
|
52559
54309
|
const i2 = page.g.byName.get(name);
|
|
52560
54310
|
if (i2 !== void 0) page.go(i2);
|
|
52561
54311
|
},
|
|
52562
54312
|
open: (hash) => {
|
|
52563
|
-
page.people.
|
|
54313
|
+
page.people.leave();
|
|
52564
54314
|
page.openAddress(hash);
|
|
52565
54315
|
},
|
|
52566
54316
|
chip: (url) => chipFor(url),
|
|
@@ -53159,6 +54909,8 @@ function inRoom(page, other) {
|
|
|
53159
54909
|
// src/web/src/pointers.ts
|
|
53160
54910
|
var NOT_TEXT = '[aria-hidden="true"]';
|
|
53161
54911
|
var CODE = "pre.code.src";
|
|
54912
|
+
var baseOf = (code) => Number(code.dataset?.line ?? 0) || 0;
|
|
54913
|
+
var inFile = (code, [line, col]) => [baseOf(code) + line, col];
|
|
53162
54914
|
var BOARD = "#canvas, #labels, #cards, #stickies";
|
|
53163
54915
|
var clamp01 = (n3) => Math.min(1.5, Math.max(-0.5, n3));
|
|
53164
54916
|
var round3 = (n3, d2 = 1e3) => Math.round(n3 * d2) / d2;
|
|
@@ -53297,7 +55049,7 @@ function anchorAt(x2, y2, t2, h2) {
|
|
|
53297
55049
|
const decl = h2.windowDecl(sw);
|
|
53298
55050
|
const c3 = caretAt(x2, y2);
|
|
53299
55051
|
const o2 = decl && c3 ? offsetIn2(code, c3.node, c3.offset) : null;
|
|
53300
|
-
if (decl && o2 !== null) return { sw: decl, lc: lineColOf(textOf2(code), o2) };
|
|
55052
|
+
if (decl && o2 !== null) return { sw: decl, lc: inFile(code, lineColOf(textOf2(code), o2)) };
|
|
53301
55053
|
}
|
|
53302
55054
|
const page = t2.closest(".pw-win .pw-page, .pw-win .pw-img");
|
|
53303
55055
|
if (page) {
|
|
@@ -53319,7 +55071,7 @@ function textAt(node, offset, h2) {
|
|
|
53319
55071
|
if (sw && code) {
|
|
53320
55072
|
const decl = h2.windowDecl(sw);
|
|
53321
55073
|
const o3 = decl ? offsetIn2(code, node, offset) : null;
|
|
53322
|
-
return decl && o3 !== null ? { sw: decl, lc: lineColOf(textOf2(code), o3) } : null;
|
|
55074
|
+
return decl && o3 !== null ? { sw: decl, lc: inFile(code, lineColOf(textOf2(code), o3)) } : null;
|
|
53323
55075
|
}
|
|
53324
55076
|
const from = rootOf(e2, h2);
|
|
53325
55077
|
const path = from ? stepsTo(from.el, e2) : null;
|
|
@@ -53383,9 +55135,9 @@ function caretRect(p2) {
|
|
|
53383
55135
|
function textHere(t2, h2) {
|
|
53384
55136
|
if ("lc" in t2) {
|
|
53385
55137
|
const win2 = h2.windowOf(t2.sw);
|
|
53386
|
-
const code = win2
|
|
55138
|
+
const code = win2 ? [...win2.querySelectorAll(CODE)].find((c3) => t2.lc[0] >= baseOf(c3) && t2.lc[0] < baseOf(c3) + c3.children.length) : void 0;
|
|
53387
55139
|
if (!win2 || !code) return null;
|
|
53388
|
-
const o2 = offsetOf(textOf2(code), t2.lc);
|
|
55140
|
+
const o2 = offsetOf(textOf2(code), [t2.lc[0] - baseOf(code), t2.lc[1]]);
|
|
53389
55141
|
const p3 = o2 === null ? null : pointIn(code, o2);
|
|
53390
55142
|
return p3 ? { p: p3, holder: code, root: win2 } : null;
|
|
53391
55143
|
}
|
|
@@ -53710,10 +55462,11 @@ function pointerPart(page) {
|
|
|
53710
55462
|
return { left: r2.left + i2.left, top: r2.top + i2.top, right: r2.right - i2.right, bottom: r2.bottom - i2.bottom };
|
|
53711
55463
|
},
|
|
53712
55464
|
linear: () => page.linear.shown ? { at: (x2, y2) => page.linear.pointAt(x2, y2), screenOf: (p2) => page.linear.screenOf(p2), room: () => page.linear.room(), reveal: (k2) => page.linear.reveal(k2) } : null,
|
|
53713
|
-
|
|
55465
|
+
// a window by its declaration's name, a file window by its file (SourceWindow.anchor)
|
|
55466
|
+
windowDecl: (el) => page.sources.all.find((w2) => w2.el === el)?.anchor || null,
|
|
53714
55467
|
// the window open on it, the following one first; a collapsed one is a pill, which holds no code
|
|
53715
55468
|
windowOf: (decl) => {
|
|
53716
|
-
const all = page.sources.all.filter((w2) => w2.
|
|
55469
|
+
const all = page.sources.all.filter((w2) => w2.anchor === decl);
|
|
53717
55470
|
return (all.find((w2) => !w2.collapsed) ?? all[0])?.el ?? null;
|
|
53718
55471
|
},
|
|
53719
55472
|
yours: (el) => inYours(el),
|
|
@@ -54825,10 +56578,10 @@ var Activity = class {
|
|
|
54825
56578
|
}
|
|
54826
56579
|
const label = linkRef(h2.id, h2.label);
|
|
54827
56580
|
const file = fileOf(r2, h2.file);
|
|
54828
|
-
const
|
|
56581
|
+
const inFile2 = file ? fileRef(h2.file, file.title) : `<span class="act-gone" title="This server has no record of this file">a file</span>`;
|
|
54829
56582
|
const names2 = (...ss) => [...new Set([...ss, links.get(h2.id)?.subject].flatMap(declIn))];
|
|
54830
56583
|
if (h2.op !== "link-edit") {
|
|
54831
|
-
const html2 = h2.op === "link" ? `${by} linked ${subject(h2.subject)} to ${label} in ${
|
|
56584
|
+
const html2 = h2.op === "link" ? `${by} linked ${subject(h2.subject)} to ${label} in ${inFile2}` : `${by} removed the link ${label} from ${subject(h2.subject)}`;
|
|
54832
56585
|
out.push({ ...base, by: now(h2.by, h2.person), cat: "review", html: html2, names: names2(h2.subject) });
|
|
54833
56586
|
return;
|
|
54834
56587
|
}
|
|
@@ -55879,22 +57632,6 @@ function addressPart(page) {
|
|
|
55879
57632
|
return { current: current3, seenHash, renderNav, writeAddress, commit, openAddress };
|
|
55880
57633
|
}
|
|
55881
57634
|
|
|
55882
|
-
// src/shared/build.ts
|
|
55883
|
-
function applyBuildDelta(held2, d2) {
|
|
55884
|
-
if (d2.epoch !== held2.epoch || d2.base !== held2.rev) return null;
|
|
55885
|
-
const changed2 = new Map(d2.files.map((f2) => [f2.module, f2]));
|
|
55886
|
-
const gone = new Set(d2.gone);
|
|
55887
|
-
const files = [];
|
|
55888
|
-
for (const f2 of held2.status?.files ?? []) {
|
|
55889
|
-
if (gone.has(f2.module)) continue;
|
|
55890
|
-
const c3 = changed2.get(f2.module);
|
|
55891
|
-
files.push(c3 ?? f2);
|
|
55892
|
-
if (c3) changed2.delete(f2.module);
|
|
55893
|
-
}
|
|
55894
|
-
files.push(...changed2.values());
|
|
55895
|
-
return { epoch: d2.epoch, rev: d2.rev, status: { active: d2.active, progress: d2.progress, files, counts: d2.counts } };
|
|
55896
|
-
}
|
|
55897
|
-
|
|
55898
57635
|
// src/web/src/buildread.ts
|
|
55899
57636
|
var MAX_WAITING = 64;
|
|
55900
57637
|
function behindBuild(held2, told) {
|
|
@@ -56132,8 +57869,8 @@ function livePart(page) {
|
|
|
56132
57869
|
root: page.meta.project.root,
|
|
56133
57870
|
at: Date.now(),
|
|
56134
57871
|
sources: {
|
|
56135
|
-
following: page.sources.following ? { name: page.sources.following.name, collapsed: page.sources.following.collapsed } : null,
|
|
56136
|
-
pinned: page.sources.pinned.map((p2) =>
|
|
57872
|
+
following: page.sources.following ? { name: page.sources.following.name, collapsed: page.sources.following.collapsed, ...page.sources.following.mode === "file" ? { mode: "file" } : {} } : null,
|
|
57873
|
+
pinned: page.sources.pinned.map((p2) => p2.file !== null ? { file: p2.file, collapsed: p2.collapsed } : { name: p2.name, collapsed: p2.collapsed, ...p2.mode === "file" ? { mode: "file" } : {} })
|
|
56137
57874
|
},
|
|
56138
57875
|
review: page.reviewBox.keptDrafts,
|
|
56139
57876
|
talk: page.talk.keptDrafts,
|
|
@@ -56512,7 +58249,8 @@ function menuItems(t2, ctx, title = "View") {
|
|
|
56512
58249
|
if (review.length) review[0].sep = true;
|
|
56513
58250
|
out.push(...review, ...note);
|
|
56514
58251
|
} else if (t2.kind === "cluster") {
|
|
56515
|
-
out.push({ act: "
|
|
58252
|
+
if (t2.file) out.push({ act: "file", label: "Open the file" });
|
|
58253
|
+
out.push({ act: "fold", label: t2.folded ? "Unfold" : "Fold", key: "double-click", ...t2.file ? { sep: true } : {} });
|
|
56516
58254
|
if (ctx.arrange && !ctx.preview) out.push({ act: "hide", label: "Hide this level" });
|
|
56517
58255
|
out.push(...link);
|
|
56518
58256
|
if (ctx.arrange) out.push(removeFrom(ctx, title, short5(t2.key)), addTo(ctx, short5(t2.key)));
|
|
@@ -56803,6 +58541,7 @@ function menuPart(page) {
|
|
|
56803
58541
|
key: cl.key,
|
|
56804
58542
|
folded: folded ?? page.canvas.folded.has(t2.c),
|
|
56805
58543
|
folder: page.cm() === "module",
|
|
58544
|
+
...fileCluster(page, cl.key) ? { file: cl.key } : {},
|
|
56806
58545
|
trust: st2.prefix && (st2.on || !st2.by) ? { prefix: st2.prefix, on: st2.on } : null,
|
|
56807
58546
|
...inArt !== void 0 ? { art: inArt } : {}
|
|
56808
58547
|
};
|
|
@@ -56918,6 +58657,9 @@ function menuPart(page) {
|
|
|
56918
58657
|
case "pin":
|
|
56919
58658
|
if (i2 !== void 0) page.sources.openPinned(i2);
|
|
56920
58659
|
return;
|
|
58660
|
+
case "file":
|
|
58661
|
+
if (t2.kind === "cluster" && t2.file) page.sources.openFile(t2.file);
|
|
58662
|
+
return;
|
|
56921
58663
|
case "tcb":
|
|
56922
58664
|
case "deps":
|
|
56923
58665
|
case "apps":
|
|
@@ -57618,7 +59360,7 @@ var SearchBox = class {
|
|
|
57618
59360
|
const dot = name.lastIndexOf(".");
|
|
57619
59361
|
let html = `<div class="hit${k2 === this.cursor ? " on" : ""}" data-i="${h2.i}"><div class="h-line"><span class="dot ${kindDot(v2.kind, g2.isExt(h2.i))}"></span><span class="h-name">${piecesHtml(marked(name, lower, f2.words, dot + 1))}</span><span class="h-ns">${piecesHtml(marked(name, lower, f2.words, 0, Math.max(0, dot)))}</span></div>`;
|
|
57620
59362
|
if (h2.via !== void 0) {
|
|
57621
|
-
const via = h2.via;
|
|
59363
|
+
const via = withoutMacroScopes(h2.via);
|
|
57622
59364
|
html += `<div class="h-snip h-also"><span class="h-where">also declares</span><span class="h-text">${piecesHtml(marked(via, lowerKeepingOffsets(via), f2.words))}</span></div>`;
|
|
57623
59365
|
} else if (h2.where !== "name") {
|
|
57624
59366
|
const p2 = h2.where === "statement" ? 1 : 2;
|
|
@@ -57704,6 +59446,7 @@ function keysPart(page) {
|
|
|
57704
59446
|
if (win2 && route === "own") {
|
|
57705
59447
|
if (e2.ctrlKey || e2.metaKey || e2.altKey || e2.repeat) return;
|
|
57706
59448
|
e2.preventDefault();
|
|
59449
|
+
if (win2.decl < 0) return page.say("This window is on a file, not on a declaration: select one first, from a name in it or the bar over the code.");
|
|
57707
59450
|
if (e2.key === "k") page.toggleKey(win2.decl);
|
|
57708
59451
|
else page.reviewBox.give(e2.key === "a" ? "approve" : "comment", win2.decl, win2.el);
|
|
57709
59452
|
return;
|
|
@@ -57993,6 +59736,28 @@ var TIPS = [
|
|
|
57993
59736
|
showMe: "colour-status",
|
|
57994
59737
|
manual: "what-you-see"
|
|
57995
59738
|
},
|
|
59739
|
+
{
|
|
59740
|
+
id: "whole-file",
|
|
59741
|
+
group: "seeing",
|
|
59742
|
+
title: "The whole file",
|
|
59743
|
+
text: "<b>File</b>, in a source window's title bar, shows the whole file, each declaration marked by its review; <b>Fold proofs</b> folds each proof to a line. On a larger screen, a file's row in <b>Files</b> opens one.",
|
|
59744
|
+
who: "all",
|
|
59745
|
+
where: "both",
|
|
59746
|
+
since: "0.9.0",
|
|
59747
|
+
about: [".sw-win [data-sw-mode=file]", ".sw-win [data-sw-folds]", "#outline [data-o-file]"],
|
|
59748
|
+
manual: "review"
|
|
59749
|
+
},
|
|
59750
|
+
{
|
|
59751
|
+
id: "infoview",
|
|
59752
|
+
group: "seeing",
|
|
59753
|
+
title: "Lean's goals, step by step",
|
|
59754
|
+
text: "Click a tactic in a source window: the <b>InfoView</b> beside the code shows Lean's goals before it, <b>After</b> those after it, a subterm's type as you rest on it. <kbd>\u2191</kbd> <kbd>\u2193</kbd> step through the proof, those following you watching.",
|
|
59755
|
+
who: "all",
|
|
59756
|
+
where: "both",
|
|
59757
|
+
since: "0.9.0",
|
|
59758
|
+
about: [".sw-info", ".sw-info [data-iv-when=after]"],
|
|
59759
|
+
manual: "review"
|
|
59760
|
+
},
|
|
57996
59761
|
// ─────────────────────────────────────────────────────────────── reviewing
|
|
57997
59762
|
{
|
|
57998
59763
|
id: "what-changed",
|
|
@@ -58052,7 +59817,7 @@ var TIPS = [
|
|
|
58052
59817
|
id: "follow",
|
|
58053
59818
|
group: "together",
|
|
58054
59819
|
title: "Follow someone",
|
|
58055
|
-
text: "Click someone's initials to see what they see: their view, camera, selection and windows. Anything you change ends it, and
|
|
59820
|
+
text: "Click someone's initials to see what they see: their view, camera, selection and windows. Anything you change ends it, and <b>Follow again</b> in the strip takes you back; Esc stops it.",
|
|
58056
59821
|
who: "all",
|
|
58057
59822
|
where: "both",
|
|
58058
59823
|
since: "0.1.0",
|
|
@@ -58071,6 +59836,17 @@ var TIPS = [
|
|
|
58071
59836
|
about: ["#talk-btn", "#convo"],
|
|
58072
59837
|
manual: "together"
|
|
58073
59838
|
},
|
|
59839
|
+
{
|
|
59840
|
+
id: "agent-here",
|
|
59841
|
+
group: "together",
|
|
59842
|
+
title: "An agent that stays",
|
|
59843
|
+
text: "Where the server allows it, Share runs your agent <b>on this server</b>, on your Claude Code token: given once, it answers until revoked, with no prompt to paste.",
|
|
59844
|
+
who: "full",
|
|
59845
|
+
where: "both",
|
|
59846
|
+
since: "0.10.0",
|
|
59847
|
+
about: ["#share-pop [data-tab=agent]", "#convo"],
|
|
59848
|
+
manual: "together"
|
|
59849
|
+
},
|
|
58074
59850
|
{
|
|
58075
59851
|
id: "copy-link",
|
|
58076
59852
|
group: "together",
|
|
@@ -60139,11 +61915,12 @@ async function boot() {
|
|
|
60139
61915
|
page.renderBuild();
|
|
60140
61916
|
if (kept && (kept.sources.following || kept.sources.pinned.length)) {
|
|
60141
61917
|
const on = (w2) => {
|
|
61918
|
+
if ("file" in w2) return moduleDecls(page.present, w2.file).length ? { file: w2.file, collapsed: w2.collapsed } : null;
|
|
60142
61919
|
const decl = page.present.byName.get(w2.name);
|
|
60143
|
-
return decl === void 0 ? null : { decl, collapsed: w2.collapsed };
|
|
61920
|
+
return decl === void 0 ? null : { decl, collapsed: w2.collapsed, mode: w2.mode ?? "decl" };
|
|
60144
61921
|
};
|
|
60145
61922
|
const f2 = kept.sources.following && on(kept.sources.following);
|
|
60146
|
-
page.sources.mirror({ following: f2, pinned: kept.sources.pinned.map(on).filter((w2) => w2 !== null) });
|
|
61923
|
+
page.sources.mirror({ following: f2 && "decl" in f2 ? f2 : null, pinned: kept.sources.pinned.map(on).filter((w2) => w2 !== null) });
|
|
60147
61924
|
page.sources.release();
|
|
60148
61925
|
}
|
|
60149
61926
|
$("#loader").classList.add("gone");
|