import { type Identity } from "./crypto/identity"; import type { Anchor, Mention, PlaceHow, SignedOp, Thread } from "./model/types"; import type { OpStore } from "./storage/store"; export interface OpenOptions { doc: string; key: CryptoKey | null; store: OpStore; identity: Identity; /** The reviewer's name; "" until they add one (they show as their animal). */ name: string; } /** `added`: the ops behind the change ([] for a rename). `source`: "local", "file", an add-on's id, or "" (a rename). */ export type Listener = (threads: Thread[], added: readonly SignedOp[], source: string) => void; /** The change is recorded and shown, but the store refused it; it is saved with the next change. */ export declare class UnsavedChangeError extends Error { readonly id: string; readonly cause: unknown; /** How many changes were recorded but not saved (an import can carry several). */ readonly count: number; constructor(id: string, cause: unknown, /** How many changes were recorded but not saved (an import can carry several). */ count?: number); } /** One document's comments for one reviewer: what the UI and CLI build on. */ export declare class PipeupDocument { private readonly log; private readonly options; private readonly listeners; private cache; private readonly comments; private displayName; private queue; private unsaved; private constructor(); static open(options: OpenOptions): Promise; get id(): string; get me(): string; get name(): string; /** Names new comments, and this reviewer's earlier unnamed ones, which listeners hear about. */ set name(value: string); threads(): readonly Thread[]; /** Every verified op this browser holds, as {body, sig}. A new array each call; don't change the ops. */ ops(): readonly SignedOp[]; onChange(fn: Listener): () => void; comment(anchor: Anchor, text: string, mentions?: Mention[]): Promise; /** * Sets a thread's place from now on, for everyone: `confirmed` keeps it where it was found (described again, so its * clues follow the page), `moved` puts it somewhere else, `gone` makes it Lost on purpose. */ place(threadId: string, anchor: Anchor, how: PlaceHow): Promise; reply(parentId: string, text: string, mentions?: Mention[]): Promise; edit(commentId: string, text: string, mentions?: Mention[]): Promise; remove(commentId: string): Promise; /** Shares a way to reach this reviewer (an email address, or `gh:`) with everyone who has the comments. */ contact(value: string): Promise; /** Stops sharing it: people who learn of this later won't see it. */ uncontact(): Promise; /** The ways people have chosen to be reached, by writer: the latest each shared, unless they stopped sharing. */ contacts(): Map; /** This reviewer's identity was made portable, so it has a recovery code (an ordinary one can't leave the browser). */ get portable(): boolean; /** The 32-byte seed of a portable identity, for backing it up; null for an ordinary one. */ seed(): Promise; /** Marks comments read by this reviewer (one `seen` op each, for those not already marked), so every device knows. */ seen(commentIds: readonly string[]): Promise; /** Reacts to a comment with one emoji; reacting twice with the same emoji changes nothing. */ react(commentId: string, emoji: string): Promise; /** Takes back this reviewer's own reaction. */ unreact(commentId: string, emoji: string): Promise; resolve(threadId: string): Promise; reopen(threadId: string): Promise; /** * Adds an agent's reply the reviewer pasted, to the thread's first comment: signed by this reviewer, under the agent's * name ("AI assistant ยท Muse"), so it is drawn as an AI's and says who put it here. With `note`, also marks the thread * addressed. It never resolves, reopens, edits or deletes. */ paste(threadId: string, agent: string, text: string, note?: string): Promise; /** * Signs `data` for `purpose` ("/") with this reviewer's identity, as base64url. The signed * text starts "pipeup:", never "{", so it can never verify as an op. */ sign(purpose: string, data: string): Promise; /** Saves any changes the store has not yet accepted. Rejects while the store still fails. */ flush(): Promise; /** Everything this browser knows about the document, sealed when the page has a key. */ exportFile(): Promise; /** * Merges a feedback file. Returns how many new, authentic changes it contained. * Throws UnsavedChangeError (id of the first added change) if they were applied but the store refused them. */ importFile(json: string): Promise; /** * Verifies and merges ops from elsewhere, exactly as a feedback file's are; resolves to how many were new. * Listeners hear once per call, only if something was added. More than 5,000 ops rejects with a RangeError. */ merge(ops: readonly unknown[], source: string): Promise; /** Runs one change at a time, in call order; a failed call does not stop later ones. */ private enqueue; /** Records a change and returns its id. */ private write; /** Hands every unsaved change to the store; they stay unsaved if it fails. */ private persist; private refresh; private find; private mine; private thread; }