Lines 3–15 at 318 (were 3–13 at 166)
33// 2 MB) is split across rows and joined on load. Ported from the platform's worker/src/engine-project.ts; the 44// writer-adoption and R2 version parts are left out. 6+import { jsonValueChunks } from "../../src/engine/json-value-chunks.ts"; 67import { blame, folderBlame, why } from "../../worker/project/blame.ts"; 78import { feedEvents } from "../../worker/project/feed.ts"; 89import { type Entry, type ProjectStore as LogStore, MemoryStore, Project } from "../../worker/project/project.ts"; 910import type { EditBody, ProjectCalls, ProjectHistory } from "../../worker/project/project-api.ts"; 1011import { where } from "../../worker/project/where.ts"; 12+import type { PushSnapshotMetadata } from "./push-snapshot.ts"; 1214/** The parts of a Durable Object's storage the log and blob store use, declared structurally so tests can stand in. */ 1315export interface SqliteStorage { Lines 35–56 at 318 (were 33–38 at 166)
38+/** Retains one log row plus an encoder fragment, preserving legacy row boundaries. */ 39+export function* streamedLogParts(value: unknown): IterableIterator<string> { 41+ for (const chunk of jsonValueChunks(value)) { 43+ while (pending.length > LOG_PART_CHARACTERS) { 44+ let end = LOG_PART_CHARACTERS; 45+ const last = pending.charCodeAt(end - 1); 46+ if (last >= 0xd800 && last <= 0xdbff) end--; 47+ yield pending.slice(0, end); 48+ pending = pending.slice(end); 51+ if (pending) yield pending; 3654/** The lines an entry's atoms write: what a loaded project's size grows with (#46, #56). */ 3755function linesIn(entry: Entry): number { Lines 442–452 at 318 (were 424–434 at 166)
424442 if (keys > 0) this.storage.sql.exec("UPDATE counts SET value = value + ? WHERE name = 'keys'", keys); 426444 for (const entry of entries) { 427− const json = JSON.stringify(entry);
428− logParts(json).forEach((text, part) => {
446+ for (const text of streamedLogParts(entry)) { 429447 chars += text.length; 430− this.storage.sql.exec("INSERT INTO log (seq, part, text) VALUES (?, ?, ?)", next, part, text);
431− });
448+ this.storage.sql.exec("INSERT INTO log (seq, part, text) VALUES (?, ?, ?)", next, part++, text); 434452 // Chars are only added to once counted: a log from before the count is summed whole first (logSize). Lines 496–507 at 318 (were 478–485 at 166)
478496 ...(folder !== undefined ? { folder } : {}), 481− why(file: string, line: number, draft?: string, agent?: string) {
482− return why(this.project, file, line, { ...(draft ? { draft } : {}), ...(agent ? { agent } : {}) });
499+ why(file: string, line: number, draft?: string, agent?: string, version?: number) { 500+ return why(this.project, file, line, { 501+ ...(draft ? { draft } : {}), 502+ ...(agent ? { agent } : {}), 503+ ...(version !== undefined ? { version } : {}), 485507 return where(this.project); Lines 523–535 at 318 (were 501–509 at 166)
501523 fileAt(path: string, version: number, draft: string | null, agent?: string) { 502524 return this.project.fileAt(path, version, { draft, ...(agent ? { agent } : {}) }); 504− compare(from: number, to: number, draft: string | null, agent?: string) {
505− return this.project.compare(from, to, { draft, ...(agent ? { agent } : {}) });
526+ compare(from: number, to: number, draft: string | null, agent?: string, summary?: boolean) { 527+ const where = { draft, ...(agent ? { agent } : {}) }; 528+ return summary ? this.project.compareSummary(from, to, where) : this.project.compare(from, to, where); 530+ without(version: number, versions: readonly number[]) { 531+ return this.project.without(version, versions); 507533 show(version: number, draft: string | null, agent?: string) { 508534 return this.project.show(version, { draft, ...(agent ? { agent } : {}) }); Lines 572–581 at 318 (were 546–551 at 166)
546572 announcePerson(person: { id: string; name: string }, text: string, to?: string[]) { 547573 return this.project.announcePerson(person, text, to, Date.now()); 575+ /** A seat's earlier chat hears that another chat used the seat (277, groups); as abso's worker has it. */ 576+ seatNotice(agent: string, place: string, key: string) { 577+ return this.project.seatNotice(agent, place, key); 549579 starting(agent: string, text: string | null, files?: string[], options: { issue?: unknown; done?: unknown } = {}) { 550580 return this.project.starting(agent, text, files, Date.now(), options); Lines 820–857 at 318 (were 790–795 at 166)
790820 filesAt(version: number) { 791821 return this.project.viewAt(version).files(); 823+ fileTextAt(version: number, path: string): string { 824+ return this.project.viewAt(version).text(path); 826+ /** One scoped batch: at most 64 files and 64 Ki characters plus one whole file. */ 827+ fileTextsAt(version: number, paths: readonly string[]): Record<string, string> { 828+ const view = this.project.viewAt(version); 829+ const files: Record<string, string> = Object.create(null); 831+ for (const path of paths.slice(0, 64)) { 832+ const text = view.attrs(path).link !== null ? "" : view.text(path); 834+ characters += text.length; 835+ if (characters >= 65536) break; 839+ /** Capture metadata now; each text read reopens the captured version in a fresh host scope. */ 840+ sharedPushMetadata(): PushSnapshotMetadata { 841+ const version = this.project.version; 842+ const view = this.project.viewAt(version); 843+ const paths: string[] = []; 844+ const modes: PushSnapshotMetadata["modes"] = Object.create(null); 845+ const blobs: Record<string, string> = Object.create(null); 846+ for (const path of view.paths()) { 847+ const attrs = view.attrs(path); 848+ modes[path] = { exec: attrs.exec, link: attrs.link }; 849+ if (attrs.blob !== null) blobs[path] = attrs.blob; 850+ else paths.push(path); 852+ const by = version > 0 ? this.project.published(version) : undefined; 853+ return { version, paths, modes, blobs, ...(by ? { last: { agent: by.agent, message: by.message } } : {}) }; 793855 blobsAt(version: number) { 794856 return this.project.viewAt(version).blobs();