@estiva-app/protocol 0.35.0 → 0.37.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/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@ Every entry answers the wire question explicitly, including when the answer is
4
4
  nothing (ADR 0002 §4b). A change to the bytes an app publishes is a MAJOR — in
5
5
  `0.x`, a MINOR — even when no TypeScript signature moved.
6
6
 
7
+ ## 0.37.0 — 2026-10-15
8
+
9
+ **Wire behaviour: new — a comment can anchor to a run of blocks and the words
10
+ where its selection starts and ends** (SPEC §13.3 "A run of blocks", §13.6;
11
+ LEAF-7; record a-comment-remembers-where-its-selection-starts-and-ends). The
12
+ `block` tag lists every selected id, `["block", id1, …]`, read as a span (the
13
+ rule COM-2 decided for `part`); one id is today's tag unchanged. A new `quote`
14
+ tag carries the words: exact inside one block, the words at each end across
15
+ blocks or past 1,000 characters, and the text around them only when they
16
+ repeat. A selection of whole blocks carries none. New `selectionAnchorTags`
17
+ writes both; `resolveCommentAnchor` reads one into five states, the new one
18
+ `reworded` (the blocks are there, the words are not), which a reader must not
19
+ draw as `detached`. Also `blockRunTag`, `blockRunOf`, `readRunIds`,
20
+ `resolveBlockRun`, `quoteTag`, `quoteOf`. Nothing writes these yet; a reader on
21
+ `blockAnchorOf` still sees the run's first block, so Peek moves to
22
+ `resolveCommentAnchor` before any app writes a run.
23
+
24
+ ## 0.36.0 — 2026-10-15
25
+
26
+ **Wire behaviour: none — the agent already published this; now an editor can
27
+ too** (SPEC §13.3 "A description as text", LEAF-10). New
28
+ `descriptionTextToBlockDocument(text, previous?)` reads a description's text
29
+ whole, as §13.3 has it: `markerTextToBlockDocument` with `{ description: true }`
30
+ plus a GFM pipe table as a `table` block, its ids carried from `previous`. And
31
+ `tableToDescriptionText(block)` prints a table back as GFM, or `undefined` for
32
+ a table §13.3 gives no spelling. Both moved here from the agent CLI (RIC-20,
33
+ estiva-agent#75), so the agent's `edit-issue` and an editor's markdown paste
34
+ read the same text the same way. One fix on the way: text that already held
35
+ the private-use character standing in for a table, spelling table 0's place,
36
+ became a second copy of that table; the stand-in is now a character the text
37
+ does not hold. A message's text is untouched: §13.2 has no table.
38
+
7
39
  ## 0.35.0 — 2026-10-14
8
40
 
9
41
  **Wire behaviour: none for any app's editor; a description written as text can
package/dist/anchors.d.ts CHANGED
@@ -87,6 +87,8 @@ export declare function resolveBlockAnchor(id: string | undefined, value: string
87
87
  * which knows neither draws an ordinary reference to the object.
88
88
  *
89
89
  * Index 3 is left free for an extent (a section, a range), which is not built.
90
+ *
91
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-shared-part-of-a-page-is-a-selected-run-of-blocks.md
90
92
  */
91
93
  export declare const PART_TAG = "part";
92
94
  /** One `part` tag, read. */
@@ -1 +1 @@
1
- {"version":3,"file":"anchors.d.ts","sourceRoot":"","sources":["../src/anchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,KAAK,EAAqD,MAAM,aAAa,CAAA;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,kCAAkC;AAClC,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,WAAW;AACrB,wEAAwE;AACtE;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE;AACzB,6CAA6C;GAC3C;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE;AACjD;;;;;GAKG;GACD;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;AACxC,+DAA+D;GAC7D;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAErC;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE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/anchors.js CHANGED
@@ -69,6 +69,8 @@ export function resolveBlockAnchor(id, value, format) {
69
69
  * which knows neither draws an ordinary reference to the object.
70
70
  *
71
71
  * Index 3 is left free for an extent (a section, a range), which is not built.
72
+ *
73
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-shared-part-of-a-page-is-a-selected-run-of-blocks.md
72
74
  */
73
75
  export const PART_TAG = 'part';
74
76
  /** The `part` tag for one block of one object. */
@@ -1 +1 @@
1
- {"version":3,"file":"anchors.js","sourceRoot":"","sources":["../src/anchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAG3F,kCAAkC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAwBvC;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,KAA0C;IACtE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACrE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACjE,OAAO,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAA;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,EAAsB,EACtB,KAAa,EACb,MAAqB;IAErB,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAA;IACjE,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE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;IACpC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACvC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAA;QAC5F,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;YAAE,OAAO,KAAK,CAAA;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * A comment on a selection — SPEC §13.3 "A run of blocks" and §13.6 (LEAF-7).
3
+ *
4
+ * A comment's anchor is a run of blocks, listed in its `block` tag the way a
5
+ * `part` lists one, narrowed by the words where the selection starts and ends
6
+ * in a `quote` tag:
7
+ *
8
+ * ["block", <first id>, …, <last id>]
9
+ * ["quote", <start words>, <end words> | "", <prefix> | "", <suffix> | ""]
10
+ *
11
+ * - A selection inside one block quotes exactly its words.
12
+ * - Across blocks, the start words lie in the first listed block and the end
13
+ * words in the last, each inside one block's text, so no rule for joining
14
+ * blocks is needed.
15
+ * - A selection of whole blocks carries no `quote`: it is about the blocks and
16
+ * grows with the run.
17
+ * - Prefix and suffix are written only when the words repeat in their block.
18
+ *
19
+ * Resolving one has five outcomes, and the new one is `reworded`: the run is
20
+ * there and the words are not. It is not `detached` — the blocks still are —
21
+ * and it is not `resolved`, because nothing may be highlighted on a guess.
22
+ *
23
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-comment-remembers-where-its-selection-starts-and-ends.md
24
+ */
25
+ import { type Block, type BlockDocument } from './blocks.js';
26
+ import type { ContentFormat } from './render.js';
27
+ /** The tag carrying a comment's words (§13.6). */
28
+ export declare const QUOTE_TAG = "quote";
29
+ /** The most ids a run lists: a longer selection keeps its first and last 32 (§13.3). */
30
+ export declare const MAX_RUN_IDS = 64;
31
+ /** A reader reads no further into a `block` tag than this many entries. */
32
+ export declare const MAX_RUN_ENTRIES_READ = 1024;
33
+ /** Up to this many characters, a selection's words are quoted whole; a reader voids a longer quote string. */
34
+ export declare const QUOTE_WHOLE_MAX = 1000;
35
+ /** Otherwise, about this many characters at each end, cut at a word boundary. */
36
+ export declare const QUOTE_END_LENGTH = 150;
37
+ /** How much of the text around repeated words is kept to tell them apart. */
38
+ export declare const QUOTE_CONTEXT_LENGTH = 32;
39
+ /** A run's ids as §13.3 reads them: an invalid first id voids it; later ones are skipped; duplicates dropped. */
40
+ export declare function readRunIds(ids: readonly string[]): string[] | undefined;
41
+ /** The `block` tag for a run, ids in document order. One id is today's one-block tag, unchanged. */
42
+ export declare function blockRunTag(ids: readonly string[]): string[];
43
+ /**
44
+ * The run a comment anchors to, or `undefined` when it anchors to none.
45
+ *
46
+ * Only a `kind:1111` anchors (§13.6). Every id from index 1 is the run; a
47
+ * reader that knows only one block reads index 1 and gets its first block.
48
+ */
49
+ export declare function blockRunOf(event: {
50
+ kind?: number;
51
+ tags: string[][];
52
+ }): string[] | undefined;
53
+ /**
54
+ * The blocks a run names in the document as it is now — §13.3's span — or
55
+ * `undefined` when none of its ids is present.
56
+ *
57
+ * The parent most of the present ids sit under (on a tie, the one of the
58
+ * earliest listed), and every child of it from the earliest to the latest of
59
+ * those ids, in current order. So a block inserted in the middle joins the run,
60
+ * a deleted end shortens it, and an id that drifted to another parent is left
61
+ * out rather than dragging the run across levels.
62
+ */
63
+ export declare function resolveBlockRun(doc: BlockDocument, ids: readonly string[]): Block[] | undefined;
64
+ /** A comment's words: where the selection starts and, across blocks or when long, where it ends. */
65
+ export interface Quote {
66
+ /** The selected words in the first block, or all of them when they fit. */
67
+ start: string;
68
+ /** The selected words in the last block, when the selection crosses blocks or is long. */
69
+ end?: string;
70
+ /** The text just before `start`, only when `start` repeats in its block. */
71
+ prefix?: string;
72
+ /** The text just after the words, only when they repeat in their block. */
73
+ suffix?: string;
74
+ }
75
+ /** The `quote` tag, with empty placeholders only where a later value needs its index. */
76
+ export declare function quoteTag(quote: Quote): string[];
77
+ /** A comment's `quote` tag, read. An empty start voids it; empty later values mean absent. */
78
+ export declare function quoteOf(event: {
79
+ tags: string[][];
80
+ }): Quote | undefined;
81
+ /** A place in a block's text: an offset into its wire text ({@link inlineTextOf}). */
82
+ export interface TextPoint {
83
+ block: string;
84
+ offset: number;
85
+ }
86
+ /**
87
+ * The anchor tags for a selection: the `block` run, and a `quote` unless the
88
+ * selection covers its first and last blocks whole.
89
+ *
90
+ * `run` is the selected blocks' ids in document order; `start` and `end` are
91
+ * where the selection begins in the first and ends in the last. Omit both for
92
+ * a selection of whole blocks. Nothing is trimmed: the words are exactly the
93
+ * block's text between the two points.
94
+ */
95
+ export declare function selectionAnchorTags(doc: BlockDocument, run: readonly string[], selection?: {
96
+ start: TextPoint;
97
+ end: TextPoint;
98
+ }): string[][];
99
+ /**
100
+ * What a comment's anchor resolved to (§13.6). Five states, none a degree of
101
+ * another:
102
+ *
103
+ * - `unanchored` — no `block` tag: a comment about the whole object. A `quote`
104
+ * without a `block` is ignored.
105
+ * - `resolved` — the run is there and so are its words, or it quotes none.
106
+ * `words` says where to highlight; absent, the comment is about the blocks.
107
+ * - `reworded` — the run is there and its words are not, in order. Show the
108
+ * comment beside `blocks` with no highlight and `quote` as what the commenter
109
+ * quoted, never as what the page says; never as `detached`.
110
+ * - `unaddressable` — the body is not a block document.
111
+ * - `detached` — none of the run's blocks is left.
112
+ */
113
+ export type CommentAnchor = {
114
+ state: 'unanchored';
115
+ } | {
116
+ state: 'resolved';
117
+ ids: string[];
118
+ blocks: Block[];
119
+ words?: {
120
+ start: TextPoint;
121
+ end: TextPoint;
122
+ };
123
+ } | {
124
+ state: 'reworded';
125
+ ids: string[];
126
+ blocks: Block[];
127
+ quote: Quote;
128
+ } | {
129
+ state: 'unaddressable';
130
+ ids: string[];
131
+ } | {
132
+ state: 'detached';
133
+ ids: string[];
134
+ };
135
+ /**
136
+ * Which of §13.6's five states a comment's anchor is in, against the body as it
137
+ * is now — the object's folded `description` (§6.10), never its root alone.
138
+ *
139
+ * `format` comes from the event carrying the body, as for
140
+ * {@link resolveBlockAnchor}. Matching is exact: a reader may suggest where
141
+ * reworded words might be, but never as `resolved`.
142
+ */
143
+ export declare function resolveCommentAnchor(event: {
144
+ kind?: number;
145
+ tags: string[][];
146
+ }, value: string, format: ContentFormat): CommentAnchor;
147
+ //# sourceMappingURL=comment-anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-anchor.d.ts","sourceRoot":"","sources":["../src/comment-anchor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,aAAa,EAAoC,MAAM,aAAa,CAAA;AAE9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,kDAAkD;AAClD,eAAO,MAAM,SAAS,UAAU,CAAA;AAEhC,wFAAwF;AACxF,eAAO,MAAM,WAAW,KAAK,CAAA;AAE7B,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,OAAO,CAAA;AAExC,8GAA8G;AAC9G,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAEnC,6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SAAS,CAAC,EAAE;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAC/C,MAAM,EAAE,EAAE,CA0CZ;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,SAAS,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAA;CAAE,GACnG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GACnE;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,GACzC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAYxC;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,EAC1C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,aAAa,GACpB,aAAa,CA8Cf"}
@@ -0,0 +1,304 @@
1
+ /**
2
+ * A comment on a selection — SPEC §13.3 "A run of blocks" and §13.6 (LEAF-7).
3
+ *
4
+ * A comment's anchor is a run of blocks, listed in its `block` tag the way a
5
+ * `part` lists one, narrowed by the words where the selection starts and ends
6
+ * in a `quote` tag:
7
+ *
8
+ * ["block", <first id>, …, <last id>]
9
+ * ["quote", <start words>, <end words> | "", <prefix> | "", <suffix> | ""]
10
+ *
11
+ * - A selection inside one block quotes exactly its words.
12
+ * - Across blocks, the start words lie in the first listed block and the end
13
+ * words in the last, each inside one block's text, so no rule for joining
14
+ * blocks is needed.
15
+ * - A selection of whole blocks carries no `quote`: it is about the blocks and
16
+ * grows with the run.
17
+ * - Prefix and suffix are written only when the words repeat in their block.
18
+ *
19
+ * Resolving one has five outcomes, and the new one is `reworded`: the run is
20
+ * there and the words are not. It is not `detached` — the blocks still are —
21
+ * and it is not `resolved`, because nothing may be highlighted on a guess.
22
+ *
23
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-comment-remembers-where-its-selection-starts-and-ends.md
24
+ */
25
+ import { inlineTextOf, parseBlockDocument } from './blocks.js';
26
+ import { BLOCK_ANCHOR_TAG } from './anchors.js';
27
+ /** The tag carrying a comment's words (§13.6). */
28
+ export const QUOTE_TAG = 'quote';
29
+ /** The most ids a run lists: a longer selection keeps its first and last 32 (§13.3). */
30
+ export const MAX_RUN_IDS = 64;
31
+ /** A reader reads no further into a `block` tag than this many entries. */
32
+ export const MAX_RUN_ENTRIES_READ = 1024;
33
+ /** Up to this many characters, a selection's words are quoted whole; a reader voids a longer quote string. */
34
+ export const QUOTE_WHOLE_MAX = 1000;
35
+ /** Otherwise, about this many characters at each end, cut at a word boundary. */
36
+ export const QUOTE_END_LENGTH = 150;
37
+ /** How much of the text around repeated words is kept to tell them apart. */
38
+ export const QUOTE_CONTEXT_LENGTH = 32;
39
+ /** The ids a run may name: safe in a URL fragment and a selector (§13.3, §13.6.1). */
40
+ const BLOCK_ID = /^[A-Za-z0-9_-]{1,64}$/;
41
+ /** The first 32 and the last 32 of a list longer than {@link MAX_RUN_IDS}. */
42
+ function capRun(ids) {
43
+ if (ids.length <= MAX_RUN_IDS)
44
+ return [...ids];
45
+ const half = MAX_RUN_IDS / 2;
46
+ return [...ids.slice(0, half), ...ids.slice(ids.length - half)];
47
+ }
48
+ /** A run's ids as §13.3 reads them: an invalid first id voids it; later ones are skipped; duplicates dropped. */
49
+ export function readRunIds(ids) {
50
+ const [first] = ids;
51
+ if (first === undefined || !BLOCK_ID.test(first))
52
+ return undefined;
53
+ // A writer lists at most 64; a list far longer is a stranger's, and is read
54
+ // no further than its first 1,024 entries, so it costs every reader little.
55
+ const out = new Set();
56
+ for (const id of ids.slice(0, MAX_RUN_ENTRIES_READ))
57
+ if (BLOCK_ID.test(id))
58
+ out.add(id);
59
+ return capRun([...out]);
60
+ }
61
+ /** The `block` tag for a run, ids in document order. One id is today's one-block tag, unchanged. */
62
+ export function blockRunTag(ids) {
63
+ return [BLOCK_ANCHOR_TAG, ...capRun(ids)];
64
+ }
65
+ /**
66
+ * The run a comment anchors to, or `undefined` when it anchors to none.
67
+ *
68
+ * Only a `kind:1111` anchors (§13.6). Every id from index 1 is the run; a
69
+ * reader that knows only one block reads index 1 and gets its first block.
70
+ */
71
+ export function blockRunOf(event) {
72
+ if (event.kind !== undefined && event.kind !== 1111)
73
+ return undefined;
74
+ const tag = event.tags.find((t) => t[0] === BLOCK_ANCHOR_TAG);
75
+ return tag ? readRunIds(tag.slice(1)) : undefined;
76
+ }
77
+ /** Where each block sits: its parent's children (the document's own list at the top) and its index there. */
78
+ function placesIn(doc) {
79
+ const out = new Map();
80
+ const walk = (blocks) => {
81
+ blocks.forEach((block, index) => {
82
+ if (typeof block.id === 'string' && block.id !== '' && !out.has(block.id))
83
+ out.set(block.id, { siblings: blocks, index });
84
+ if (Array.isArray(block.content) && block.content.some((c) => c.type !== 'text'))
85
+ walk(block.content);
86
+ });
87
+ };
88
+ walk(doc.content);
89
+ return out;
90
+ }
91
+ /**
92
+ * The blocks a run names in the document as it is now — §13.3's span — or
93
+ * `undefined` when none of its ids is present.
94
+ *
95
+ * The parent most of the present ids sit under (on a tie, the one of the
96
+ * earliest listed), and every child of it from the earliest to the latest of
97
+ * those ids, in current order. So a block inserted in the middle joins the run,
98
+ * a deleted end shortens it, and an id that drifted to another parent is left
99
+ * out rather than dragging the run across levels.
100
+ */
101
+ export function resolveBlockRun(doc, ids) {
102
+ const places = placesIn(doc);
103
+ const groups = [];
104
+ for (const id of ids) {
105
+ const place = places.get(id);
106
+ if (!place)
107
+ continue;
108
+ const group = groups.find((g) => g.siblings === place.siblings);
109
+ if (group)
110
+ group.indexes.push(place.index);
111
+ else
112
+ groups.push({ siblings: place.siblings, indexes: [place.index] });
113
+ }
114
+ if (groups.length === 0)
115
+ return undefined;
116
+ const best = groups.reduce((a, b) => (b.indexes.length > a.indexes.length ? b : a));
117
+ return best.siblings.slice(Math.min(...best.indexes), Math.max(...best.indexes) + 1);
118
+ }
119
+ /** The `quote` tag, with empty placeholders only where a later value needs its index. */
120
+ export function quoteTag(quote) {
121
+ const tag = [QUOTE_TAG, quote.start, quote.end ?? '', quote.prefix ?? '', quote.suffix ?? ''];
122
+ while (tag.length > 2 && tag[tag.length - 1] === '')
123
+ tag.pop();
124
+ return tag;
125
+ }
126
+ /** A comment's `quote` tag, read. An empty start voids it; empty later values mean absent. */
127
+ export function quoteOf(event) {
128
+ const tag = event.tags.find((t) => t[0] === QUOTE_TAG);
129
+ const [, start, end, prefix, suffix] = tag ?? [];
130
+ if (!start || start.length > QUOTE_WHOLE_MAX || (end && end.length > QUOTE_WHOLE_MAX))
131
+ return undefined;
132
+ return {
133
+ start,
134
+ ...(end ? { end } : {}),
135
+ ...(prefix ? { prefix } : {}),
136
+ ...(suffix ? { suffix } : {}),
137
+ };
138
+ }
139
+ /**
140
+ * The text a quote is matched in: §13.3's runs, a mention as its `nostr:` text,
141
+ * exactly as stored — not normalised, so an offset into it is an offset into
142
+ * the block's own text.
143
+ */
144
+ function textOf(block) {
145
+ return inlineTextOf(block);
146
+ }
147
+ /** How many times `words` occurs in `text` (none for empty words). */
148
+ function occurrences(text, words) {
149
+ if (words === '')
150
+ return 0;
151
+ let count = 0;
152
+ for (let at = text.indexOf(words); at !== -1; at = text.indexOf(words, at + 1))
153
+ count++;
154
+ return count;
155
+ }
156
+ /** At most `length` characters from the front of `text`, cut back to a word boundary when one is near. */
157
+ function headOf(text, length) {
158
+ if (text.length <= length)
159
+ return text;
160
+ const cut = text.lastIndexOf(' ', length);
161
+ return text.slice(0, cut > length / 2 ? cut : length);
162
+ }
163
+ /** At most `length` characters from the back of `text`, cut forward to a word boundary when one is near. */
164
+ function tailOf(text, length) {
165
+ if (text.length <= length)
166
+ return text;
167
+ const from = text.length - length;
168
+ const cut = text.indexOf(' ', from);
169
+ return text.slice(cut !== -1 && cut < from + length / 2 ? cut + 1 : from);
170
+ }
171
+ /**
172
+ * The anchor tags for a selection: the `block` run, and a `quote` unless the
173
+ * selection covers its first and last blocks whole.
174
+ *
175
+ * `run` is the selected blocks' ids in document order; `start` and `end` are
176
+ * where the selection begins in the first and ends in the last. Omit both for
177
+ * a selection of whole blocks. Nothing is trimmed: the words are exactly the
178
+ * block's text between the two points.
179
+ */
180
+ export function selectionAnchorTags(doc, run, selection) {
181
+ if (!selection)
182
+ return [blockRunTag(run)];
183
+ const places = placesIn(doc);
184
+ const blockOf = (id) => {
185
+ const place = id === undefined ? undefined : places.get(id);
186
+ if (!place)
187
+ throw new Error(`block ${id} is not in the document`);
188
+ return textOf(place.siblings[place.index]);
189
+ };
190
+ let ids = [...run];
191
+ let { start, end } = selection;
192
+ if (start.block !== ids[0] || end.block !== ids[ids.length - 1])
193
+ throw new Error('a selection starts in the run\'s first block and ends in its last');
194
+ // A selection that starts at the very end of its first block, or ends at the
195
+ // very start of its last, holds no text in it: that block is not in the run.
196
+ if (ids.length > 1 && start.offset >= blockOf(start.block).length) {
197
+ ids = ids.slice(1);
198
+ start = { block: ids[0], offset: 0 };
199
+ }
200
+ if (ids.length > 1 && end.offset <= 0) {
201
+ ids = ids.slice(0, -1);
202
+ end = { block: ids[ids.length - 1], offset: blockOf(ids[ids.length - 1]).length };
203
+ }
204
+ const tags = [blockRunTag(ids)];
205
+ const firstText = blockOf(start.block);
206
+ const lastText = start.block === end.block ? firstText : blockOf(end.block);
207
+ if (start.offset === 0 && end.offset >= lastText.length)
208
+ return tags;
209
+ const quote = { start: '' };
210
+ if (start.block === end.block && end.offset - start.offset <= QUOTE_WHOLE_MAX) {
211
+ quote.start = firstText.slice(start.offset, end.offset);
212
+ }
213
+ else {
214
+ const startWords = start.block === end.block ? firstText.slice(start.offset, end.offset) : firstText.slice(start.offset);
215
+ const endWords = start.block === end.block ? startWords : lastText.slice(0, end.offset);
216
+ quote.start = headOf(startWords, QUOTE_END_LENGTH);
217
+ quote.end = tailOf(endWords, QUOTE_END_LENGTH);
218
+ }
219
+ if (quote.start === '' || quote.end === '')
220
+ return tags;
221
+ if (occurrences(firstText, quote.start) > 1)
222
+ quote.prefix = firstText.slice(Math.max(0, start.offset - QUOTE_CONTEXT_LENGTH), start.offset);
223
+ if (occurrences(lastText, quote.end ?? quote.start) > 1)
224
+ quote.suffix = lastText.slice(end.offset, end.offset + QUOTE_CONTEXT_LENGTH);
225
+ if (quote.prefix === '')
226
+ delete quote.prefix;
227
+ if (quote.suffix === '')
228
+ delete quote.suffix;
229
+ tags.push(quoteTag(quote));
230
+ return tags;
231
+ }
232
+ /** Where `words` sits in `text` at or after `from`: the occurrence whose context matches, else the first. */
233
+ function find(text, words, from, context) {
234
+ let first = -1;
235
+ for (let at = text.indexOf(words, from); at !== -1; at = text.indexOf(words, at + 1)) {
236
+ if (first === -1)
237
+ first = at;
238
+ if (context(at))
239
+ return at;
240
+ }
241
+ return first;
242
+ }
243
+ /**
244
+ * Which of §13.6's five states a comment's anchor is in, against the body as it
245
+ * is now — the object's folded `description` (§6.10), never its root alone.
246
+ *
247
+ * `format` comes from the event carrying the body, as for
248
+ * {@link resolveBlockAnchor}. Matching is exact: a reader may suggest where
249
+ * reworded words might be, but never as `resolved`.
250
+ */
251
+ export function resolveCommentAnchor(event, value, format) {
252
+ const ids = blockRunOf(event);
253
+ if (!ids)
254
+ return { state: 'unanchored' };
255
+ if (format !== 'blocks')
256
+ return { state: 'unaddressable', ids };
257
+ let doc;
258
+ try {
259
+ doc = parseBlockDocument(value);
260
+ }
261
+ catch {
262
+ return { state: 'unaddressable', ids };
263
+ }
264
+ const blocks = resolveBlockRun(doc, ids);
265
+ if (!blocks)
266
+ return { state: 'detached', ids };
267
+ const quote = quoteOf(event);
268
+ if (!quote)
269
+ return { state: 'resolved', ids, blocks };
270
+ const reworded = { state: 'reworded', ids, blocks, quote };
271
+ const first = blocks.findIndex((b) => b.id === ids[0]);
272
+ const last = blocks.findIndex((b) => b.id === ids[ids.length - 1]);
273
+ if (first === -1 || last === -1 || last < first)
274
+ return reworded;
275
+ const firstText = textOf(blocks[first]);
276
+ const lastText = textOf(blocks[last]);
277
+ const { start, end } = quote;
278
+ // Context longer than a writer ever sends is a stranger's, and ignored: each
279
+ // check below is then a short comparison however often the words repeat.
280
+ const prefix = quote.prefix && quote.prefix.length <= QUOTE_CONTEXT_LENGTH ? quote.prefix : undefined;
281
+ const suffix = quote.suffix && quote.suffix.length <= QUOTE_CONTEXT_LENGTH ? quote.suffix : undefined;
282
+ const before = (text, i) => !prefix || text.slice(Math.max(0, i - prefix.length), i) === prefix;
283
+ const after = (text, i) => !suffix || text.slice(i, i + suffix.length) === suffix;
284
+ if (end === undefined) {
285
+ const at = find(firstText, start, 0, (i) => before(firstText, i) && after(firstText, i + start.length));
286
+ if (at === -1)
287
+ return reworded;
288
+ return { state: 'resolved', ids, blocks, words: { start: { block: ids[0], offset: at }, end: { block: ids[0], offset: at + start.length } } };
289
+ }
290
+ const startAt = find(firstText, start, 0, (i) => before(firstText, i));
291
+ if (startAt === -1)
292
+ return reworded;
293
+ const from = first === last ? startAt + start.length : 0;
294
+ const endAt = find(lastText, end, from, (i) => after(lastText, i + end.length));
295
+ if (endAt === -1)
296
+ return reworded;
297
+ return {
298
+ state: 'resolved',
299
+ ids,
300
+ blocks,
301
+ words: { start: { block: ids[0], offset: startAt }, end: { block: ids[ids.length - 1], offset: endAt + end.length } },
302
+ };
303
+ }
304
+ //# sourceMappingURL=comment-anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-anchor.js","sourceR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AC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,CAAA;IAC/I,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAA;IACtE,IAAI,OAAO,KAAK,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAA;IACnC,MAAM,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/E,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAA;IACjC,OAAO;QACL,KAAK,EAAE,UAAU;QACjB,GAAG;QACH,MAAM;QACN,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE;KACtH,CAAA;AACH,CAAC"}
package/dist/content.d.ts CHANGED
@@ -92,6 +92,14 @@ export declare function parseInlineMarks(text: string): InlineMarkSpan[];
92
92
  * `code` wins alone, for the same reason the parser never emits it combined.
93
93
  */
94
94
  export declare function wrapInlineMarks(text: string, markNames: ReadonlySet<string>): string;
95
+ /**
96
+ * Where the fence opened at `from` closes, or -1 if it never does.
97
+ *
98
+ * An unclosed fence is not a fence: SPEC §13.2 requires an unmatched marker to
99
+ * render literally, and swallowing the rest of the body because somebody typed
100
+ * three backticks is the opposite of that.
101
+ */
102
+ export declare function fenceCloses(lines: string[], from: number): number;
95
103
  /**
96
104
  * Split a body into block segments.
97
105
  *
@@ -1 +1 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAA;AAEjE,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,oDAAoD;AACpD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACtD;IACE,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GACD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,OAAO,CAAC;I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AC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CAMnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAI7E;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAE1E"}
package/dist/content.js CHANGED
@@ -192,7 +192,7 @@ const FENCE_RE = /^```/;
192
192
  * render literally, and swallowing the rest of the body because somebody typed
193
193
  * three backticks is the opposite of that.
194
194
  */
195
- function fenceCloses(lines, from) {
195
+ export function fenceCloses(lines, from) {
196
196
  if (!FENCE_RE.test(lines[from]))
197
197
  return -1;
198
198
  for (let j = from + 1; j < lines.length; j++)