@estiva-app/protocol 0.4.0 → 0.6.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,99 @@ 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.6.0 — 2026-09-02
8
+
9
+ **Wire behaviour: unchanged.** No builder, tag layout, id computation or
10
+ signature input moved. This release adds a parser, and a parser reads bytes
11
+ somebody else already published.
12
+
13
+ **What it does change is what readers draw**, which is not the wire and is not
14
+ nothing: an app that upgrades starts rendering backtick spans in messages that
15
+ have been on the relay for weeks. Measured 2026-09-02, that is **200 of 548
16
+ published message bodies** — the most common construct in the corpus, more
17
+ common than bold, and until now rendered by nobody. Upgrading is visible to
18
+ users on history, not only on new messages.
19
+
20
+ - **New: `content.ts` — the message marker dialect, SPEC §13.2.** `parseInlineMarks`,
21
+ `wrapInlineMarks`, `parseBodySegments` and `stripInlineFormatting`, moved out
22
+ of Peek's `src/lib/textParsing.ts` rather than written fresh, so the behaviour
23
+ that was already shipping is preserved by construction. Peek's own tests for
24
+ them are ported verbatim into `test/content.test.ts` as the proof.
25
+
26
+ Only the **mark** layer moved. Peek's mentions and bracket references resolve
27
+ against its own directory and fixtures, and they stay there — a mention is
28
+ RIC-2's, and dragging its regexes along would have imported one app's mock
29
+ data into the shared package.
30
+
31
+ - **New in the dialect: `code` and fenced code** (SPEC §13.1, §13.2). A code
32
+ span carries `code` and never combines with another mark, and its content is
33
+ never parsed for further marks — so `` `**x**` `` is four literal characters
34
+ and a name.
35
+
36
+ - **SPEC §13.2's rule 2 does not fence a backtick**, and the corpus is why.
37
+ Rule 2 keeps `2*3*4` literal, which an asymmetric prose marker needs and a
38
+ backtick does not — applying it anyway left `` `main`s `` unparsed, a code
39
+ span followed by a plural or possessive. Eight such spans in six published
40
+ messages. SPEC was amended to say so (estiva-docs#56) rather than the parser
41
+ quietly disagreeing with it.
42
+
43
+ - **Fixed while extracting: `stripInlineFormatting` was not idempotent.** It
44
+ removed the heading prefix before the quote prefix, so `> # Heading` — the
45
+ shape every project brief in this workspace is written in — came back as
46
+ `# Heading` and previews showed a stray `#`. Prefixes are now stripped until
47
+ the line stops changing. **This bug was invisible to the tests it shipped
48
+ with** and was found by running the function over 152 real published bodies.
49
+
50
+ - **New: `test/corpus-bodies.json`** — 152 real message bodies from production.
51
+ A parser checked only against fixtures written beside it is checked against
52
+ its own assumptions; both defects above came from this file and neither came
53
+ from the unit tests.
54
+
55
+ ## 0.5.0 — 2026-09-01
56
+
57
+ **Wire behaviour: unchanged.** No builder, tag layout, id computation or
58
+ signature input moved. `queryAll` returns the same events; it asks for them in
59
+ half as many requests.
60
+
61
+ - **A short page no longer always costs a confirming round trip.** `queryAll`
62
+ spent two requests on every filter, including one holding three events, and
63
+ on Ship's `loadAll` that doubling was **33 filters → 66 requests** against a
64
+ relay that meters `POST /query` at 300 a minute.
65
+
66
+ The confirmation existed for a real reason: a page shorter than the requested
67
+ `limit` is ambiguous, because the relay clamps to `min(requested, ceiling)`
68
+ and may have clamped at exactly that many. The ambiguity dissolves
69
+ arithmetically rather than by trusting anyone — a clamp at `n` requires the
70
+ ceiling to *equal* `n`, the ceiling is one constant for the relay, and the
71
+ largest page it has already handed back is a lower bound on it. So
72
+ `n < observedPageCeiling` rules the clamp out on evidence the relay itself
73
+ produced.
74
+
75
+ **Deliberately not NIP-11's `limitation.max_limit`.** That number is a claim,
76
+ and a relay advertising more than it clamps to would make every page look
77
+ short and the first one get mistaken for the whole set — the SHA-8 bug, back.
78
+ Buzz currently advertises 1000 and clamps at 1000, so trusting it would work
79
+ today; the source default in `nip11.rs` is 10000 against a `buzz-db` clamp of
80
+ 1000, so it has not always been true, and being right by luck is not a
81
+ design. Substituting a trusted 1000 for the observed bound fails the SHA-8
82
+ regression test outright, which is the control that settles it.
83
+
84
+ Conservative before it has evidence: the first filter through a fresh `Relay`
85
+ still confirms, and so does the **widest** filter on every read, since it
86
+ ties its own bound. The floor is therefore one request per filter *plus one*.
87
+
88
+ Measured on Ship's `loadAll` against production, published client versus this
89
+ one: **66 requests → 35 cold, 34 warm — 48% fewer — 8.8 s → 0.9 s, and the
90
+ fold compares equal event for event** (every project and issue address with
91
+ its status, every change id, every conversation id).
92
+
93
+ - **This still does not fit a five-second poll.** 34 requests × 12 reads a
94
+ minute is 408 against a 300 budget; at a ten-second poll it is 204 and fits.
95
+ The remaining half is the caller's cadence, not this package's.
96
+
97
+ Additive with no signature change, but the request pattern a caller produces
98
+ changes, so a MINOR: ADR 0002 §4b puts the break on MINOR within `0.x`.
99
+
7
100
  ## 0.4.0 — 2026-09-01
8
101
 
9
102
  **Wire behaviour: unchanged.** No builder, tag layout, id computation or
package/dist/bridge.d.ts CHANGED
@@ -137,6 +137,18 @@ export declare class Relay {
137
137
  private readonly signer;
138
138
  private readonly headers;
139
139
  private readonly transport;
140
+ /**
141
+ * The largest page this relay has ever handed back, across every call.
142
+ *
143
+ * A *lower bound* on the relay's real clamp, and the only one obtainable
144
+ * without trusting anybody: the relay returned this many events in one
145
+ * response, so its ceiling is at least this large. {@link Relay.pageFilter}
146
+ * uses it to tell a short page apart from a clamped one — see there.
147
+ *
148
+ * Per instance and never reset, so the second read through a long-lived
149
+ * `Relay` is cheaper than the first.
150
+ */
151
+ private observedPageCeiling;
140
152
  constructor(url: string, signer: Signer, options?: RelayOptions | RelayHeaders);
141
153
  private post;
142
154
  publish(event: SignedEvent): Promise<PublishResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,WAAW,aAAa;IAC5B,EAA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
138
  transport;
139
+ /**
140
+ * The largest page this relay has ever handed back, across every call.
141
+ *
142
+ * A *lower bound* on the relay's real clamp, and the only one obtainable
143
+ * without trusting anybody: the relay returned this many events in one
144
+ * response, so its ceiling is at least this large. {@link Relay.pageFilter}
145
+ * uses it to tell a short page apart from a clamped one — see there.
146
+ *
147
+ * Per instance and never reset, so the second read through a long-lived
148
+ * `Relay` is cheaper than the first.
149
+ */
150
+ observedPageCeiling = 0;
139
151
  constructor(url, signer, options = {}) {
140
152
  this.url = url.replace(/\/+$/, '');
141
153
  this.signer = signer;
@@ -306,6 +318,38 @@ export class Relay {
306
318
  if (events.length === 0)
307
319
  break;
308
320
  out.push(...events);
321
+ /*
322
+ A page smaller than one this relay has already delivered is the end of
323
+ the filter, and no confirming round trip is needed to know it.
324
+
325
+ The reason the confirmation existed is real: a page shorter than the
326
+ `limit` we asked for is ambiguous, because the relay clamps to
327
+ `min(requested, ceiling)` and might have clamped at exactly this many.
328
+ But that requires the ceiling to *equal* this page's size — and the
329
+ ceiling is one constant for the relay, already known to be at least
330
+ `observedPageCeiling`. So `n < observedPageCeiling` rules the clamp out
331
+ arithmetically rather than by trusting anything.
332
+
333
+ Deliberately not NIP-11's `limitation.max_limit`. That number is a
334
+ claim: a relay advertising more than it clamps to would make every page
335
+ look short and the first one get mistaken for the whole set, which is
336
+ exactly the SHA-8 bug this loop exists to prevent. An observed page is
337
+ evidence — the relay demonstrably produced it.
338
+
339
+ Conservative before it has evidence: the first filter through a fresh
340
+ `Relay` still pays the confirmation, and so does any page that ties the
341
+ largest seen so far — which means **the widest filter always confirms**,
342
+ since it ties its own bound on every read. So the floor is one request
343
+ per filter plus one, not one per filter.
344
+
345
+ Measured on Ship's `loadAll` against production: **66 requests to 35
346
+ cold and 34 warm**, the same fold event for event, and 8.8 s to 0.9 s
347
+ alongside the concurrency of 0.4.0.
348
+ */
349
+ if (events.length > this.observedPageCeiling)
350
+ this.observedPageCeiling = events.length;
351
+ if (events.length < pageSize && events.length < this.observedPageCeiling)
352
+ break;
309
353
  const oldest = Math.min(...events.map((e) => e.created_at));
310
354
  if (until !== undefined && oldest >= until) {
311
355
  if (events.length >= pageSize) {
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAchD;;;;;;;;GAQG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAA;AAW1C,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,IAAY;IAC/D,IAAI,MAAmF,CAAA;IACvF,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAyB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;IACjG,CAAC;IACD,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;QAClC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;IACtF,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;QACjE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CAAC,CAAA;YACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAK;YAC9B,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAA;YAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2BE;YACF,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB;gBAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAA;YACtF,IAAI,MAAM,CAAC,MAAM,GAAG,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB;gBAAE,MAAK;YAE/E,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;YAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC3C,IAAI,MAAM,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;oBAC9B,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,4BAA4B,KAAK,iCAAiC,CAClG,CAAA;gBACH,CAAC;gBACD,MAAK;YACP,CAAC;YACD,KAAK,GAAG,MAAM,CAAA;QAChB,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The message marker dialect — SPEC §13.1 and §13.2.
3
+ *
4
+ * ## Why content is in a package that "interprets nothing"
5
+ *
6
+ * `index.ts` draws the line at *interpretation*: the fold stays in the apps,
7
+ * because how an app turns events into current truth is where apps are supposed
8
+ * to differ. A body's formatting is on the other side of that line for the same
9
+ * reason the event id is — **it is wire-visible, and two apps disagreeing about
10
+ * it produces a divergence each copy is self-consistent about and nobody
11
+ * notices.** That is not a hypothetical: measured on production 2026-09-02,
12
+ * 261 of 548 published messages carry structure, Peek parses it, Ship renders
13
+ * it literally, and neither is wrong about its own behaviour.
14
+ *
15
+ * Being honest about the usual test: the relay would *not* notice if two apps
16
+ * disagreed here, so §10's question is a poor fit. What makes this belong is the
17
+ * failure shape rather than the arbiter — see RFC 0.4 §14.3, which put the
18
+ * inline layer here, and SPEC §13.1, which made it normative.
19
+ *
20
+ * **What is deliberately not here.** Mentions resolved against a directory,
21
+ * bracket references to an app's own objects, and anything that needs to know
22
+ * what a topic or a file is. Peek's `textParsing.ts` mixes those with the marks;
23
+ * only the marks moved. A `nostr:` reference is a mark and its *token* is in
24
+ * scope, but what a mention does is RIC-2's.
25
+ */
26
+ /** Marks a run of text can carry. `code` is exclusive — see {@link parseInlineMarks}. */
27
+ export type InlineMark = 'bold' | 'italic' | 'underline' | 'code';
28
+ /** A run of text and the marks on it. */
29
+ export interface InlineMarkSpan {
30
+ text: string;
31
+ bold?: boolean;
32
+ italic?: boolean;
33
+ underline?: boolean;
34
+ code?: boolean;
35
+ }
36
+ /** A block-level run, parsed from line prefixes. */
37
+ export type BodySegment = {
38
+ type: 'text';
39
+ lines: string[];
40
+ } | {
41
+ type: 'bullet';
42
+ items: string[];
43
+ } | {
44
+ type: 'numbered';
45
+ items: string[];
46
+ } | {
47
+ type: 'heading';
48
+ level: 1 | 2;
49
+ text: string;
50
+ } | {
51
+ type: 'quote';
52
+ lines: string[];
53
+ } | {
54
+ type: 'code';
55
+ language?: string;
56
+ lines: string[];
57
+ };
58
+ /**
59
+ * Parse one plain-text run into styled spans.
60
+ *
61
+ * Split mentions and app-specific references out first — this function knows
62
+ * about marks and nothing else.
63
+ */
64
+ export declare function parseInlineMarks(text: string): InlineMarkSpan[];
65
+ /**
66
+ * Wrap a run of text in the markers for the marks it carries.
67
+ *
68
+ * Edge whitespace is hoisted outside the markers, because `**word **` would not
69
+ * parse back under rule 1 — so bolding "word " round-trips as `**word** `.
70
+ *
71
+ * `code` wins alone, for the same reason the parser never emits it combined.
72
+ */
73
+ export declare function wrapInlineMarks(text: string, markNames: ReadonlySet<string>): string;
74
+ /**
75
+ * Split a body into block segments.
76
+ *
77
+ * Blank lines split runs of plain text into separate `text` segments. `# ` and
78
+ * `## ` become headings; three or more `#`s, and a `#123` reference with no
79
+ * space, stay plain text.
80
+ */
81
+ export declare function parseBodySegments(body: string): BodySegment[];
82
+ export declare function stripInlineFormatting(text: string): string;
83
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,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;CACf;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,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GACrC;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;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAwFxD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CAE/D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAiBpF;AAqBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAoE7D;AAuBD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1D"}
@@ -0,0 +1,281 @@
1
+ /**
2
+ * The message marker dialect — SPEC §13.1 and §13.2.
3
+ *
4
+ * ## Why content is in a package that "interprets nothing"
5
+ *
6
+ * `index.ts` draws the line at *interpretation*: the fold stays in the apps,
7
+ * because how an app turns events into current truth is where apps are supposed
8
+ * to differ. A body's formatting is on the other side of that line for the same
9
+ * reason the event id is — **it is wire-visible, and two apps disagreeing about
10
+ * it produces a divergence each copy is self-consistent about and nobody
11
+ * notices.** That is not a hypothetical: measured on production 2026-09-02,
12
+ * 261 of 548 published messages carry structure, Peek parses it, Ship renders
13
+ * it literally, and neither is wrong about its own behaviour.
14
+ *
15
+ * Being honest about the usual test: the relay would *not* notice if two apps
16
+ * disagreed here, so §10's question is a poor fit. What makes this belong is the
17
+ * failure shape rather than the arbiter — see RFC 0.4 §14.3, which put the
18
+ * inline layer here, and SPEC §13.1, which made it normative.
19
+ *
20
+ * **What is deliberately not here.** Mentions resolved against a directory,
21
+ * bracket references to an app's own objects, and anything that needs to know
22
+ * what a topic or a file is. Peek's `textParsing.ts` mixes those with the marks;
23
+ * only the marks moved. A `nostr:` reference is a mark and its *token* is in
24
+ * scope, but what a mention does is RIC-2's.
25
+ */
26
+ /**
27
+ * Longest token first so `***` is not consumed as `**` plus a dangling `*`.
28
+ *
29
+ * Order only decides ties at one index — the scanner walks left to right, so the
30
+ * leftmost opening delimiter wins regardless of what is listed first.
31
+ */
32
+ const MARK_TOKENS = [
33
+ { token: '***', keys: ['bold', 'italic'] },
34
+ { token: '**', keys: ['bold'] },
35
+ { token: '__', keys: ['underline'] },
36
+ { token: '*', keys: ['italic'] },
37
+ { token: '`', keys: ['code'], literal: true },
38
+ ];
39
+ const isWordChar = (ch) => ch !== undefined && /[A-Za-z0-9]/.test(ch);
40
+ /**
41
+ * SPEC §13.2 rule 2 — a marker adjacent to an alphanumeric is not a marker, so
42
+ * `2*3*4` stays literal math.
43
+ *
44
+ * **It does not apply to a backtick.** Rule 2 resolves an ambiguity that only
45
+ * asymmetric prose markers have: `*` is multiplication and a glob, `_` is in
46
+ * identifiers. A backtick is not used as ordinary punctuation, so there is no
47
+ * ambiguity to resolve — and applying the fence anyway leaves `` `main`s ``
48
+ * literal, which is a code span followed by a plural or possessive. Measured
49
+ * against production 2026-09-02: 8 such spans in 6 published messages, and zero
50
+ * cases of the opening side needing the fence. CommonMark agrees.
51
+ */
52
+ function findMarkClose(text, token, from, fenced) {
53
+ let idx = text.indexOf(token, from);
54
+ while (idx !== -1) {
55
+ if (!fenced || !isWordChar(text[idx + token.length]))
56
+ return idx;
57
+ idx = text.indexOf(token, idx + 1);
58
+ }
59
+ return -1;
60
+ }
61
+ function toMarkSpan(text, active) {
62
+ const span = { text };
63
+ for (const key of active)
64
+ span[key] = true;
65
+ return span;
66
+ }
67
+ function scanMarks(text, active) {
68
+ for (let i = 0; i < text.length; i++) {
69
+ for (const { token, keys, literal } of MARK_TOKENS) {
70
+ if (keys.some((k) => active.includes(k)))
71
+ continue;
72
+ if (!text.startsWith(token, i))
73
+ continue;
74
+ const fenced = !literal;
75
+ if (fenced && isWordChar(text[i - 1]))
76
+ continue;
77
+ const close = findMarkClose(text, token, i + token.length, fenced);
78
+ if (close === -1)
79
+ continue;
80
+ const inner = text.slice(i + token.length, close);
81
+ // SPEC §13.2 rule 1: whitespace at the inner edges means it is not a pair.
82
+ if (!inner || /^\s/.test(inner) || /\s$/.test(inner))
83
+ continue;
84
+ const spans = [];
85
+ const before = text.slice(0, i);
86
+ if (before)
87
+ spans.push(toMarkSpan(before, active));
88
+ if (literal) {
89
+ /*
90
+ SPEC §13.1: code MUST NOT combine with any other mark, and its content
91
+ MUST NOT be parsed for further marks. So the span carries `code` alone
92
+ even inside an enclosing bold — dropping the outer mark rather than
93
+ emitting a combination the spec forbids.
94
+ */
95
+ spans.push({ text: inner, code: true });
96
+ }
97
+ else {
98
+ spans.push(...scanMarks(inner, [...active, ...keys]));
99
+ }
100
+ spans.push(...scanMarks(text.slice(close + token.length), active));
101
+ return spans;
102
+ }
103
+ }
104
+ return text ? [toMarkSpan(text, active)] : [];
105
+ }
106
+ /**
107
+ * Parse one plain-text run into styled spans.
108
+ *
109
+ * Split mentions and app-specific references out first — this function knows
110
+ * about marks and nothing else.
111
+ */
112
+ export function parseInlineMarks(text) {
113
+ return scanMarks(text, []);
114
+ }
115
+ /**
116
+ * Wrap a run of text in the markers for the marks it carries.
117
+ *
118
+ * Edge whitespace is hoisted outside the markers, because `**word **` would not
119
+ * parse back under rule 1 — so bolding "word " round-trips as `**word** `.
120
+ *
121
+ * `code` wins alone, for the same reason the parser never emits it combined.
122
+ */
123
+ export function wrapInlineMarks(text, markNames) {
124
+ if (!text)
125
+ return text;
126
+ const bold = markNames.has('bold');
127
+ const italic = markNames.has('italic');
128
+ const underline = markNames.has('underline');
129
+ const code = markNames.has('code');
130
+ if (!bold && !italic && !underline && !code)
131
+ return text;
132
+ const m = text.match(/^(\s*)([\s\S]*?)(\s*)$/);
133
+ const [, lead, core, trail] = m;
134
+ if (!core)
135
+ return text;
136
+ if (code)
137
+ return `${lead}\`${core}\`${trail}`;
138
+ let out = core;
139
+ if (bold && italic)
140
+ out = `***${out}***`;
141
+ else if (bold)
142
+ out = `**${out}**`;
143
+ else if (italic)
144
+ out = `*${out}*`;
145
+ if (underline)
146
+ out = `__${out}__`;
147
+ return lead + out + trail;
148
+ }
149
+ const HEADING_LINE_RE = /^#{1,2}\s/;
150
+ /** `> ` with the space required — a bare `>` typed at a line start ("5 > 3")
151
+ * stays literal, the same conservatism as the inline markers. */
152
+ const QUOTE_LINE_RE = /^>\s/;
153
+ const FENCE_RE = /^```/;
154
+ /**
155
+ * Where the fence opened at `from` closes, or -1 if it never does.
156
+ *
157
+ * An unclosed fence is not a fence: SPEC §13.2 requires an unmatched marker to
158
+ * render literally, and swallowing the rest of the body because somebody typed
159
+ * three backticks is the opposite of that.
160
+ */
161
+ function fenceCloses(lines, from) {
162
+ if (!FENCE_RE.test(lines[from]))
163
+ return -1;
164
+ for (let j = from + 1; j < lines.length; j++)
165
+ if (FENCE_RE.test(lines[j]))
166
+ return j;
167
+ return -1;
168
+ }
169
+ /**
170
+ * Split a body into block segments.
171
+ *
172
+ * Blank lines split runs of plain text into separate `text` segments. `# ` and
173
+ * `## ` become headings; three or more `#`s, and a `#123` reference with no
174
+ * space, stay plain text.
175
+ */
176
+ export function parseBodySegments(body) {
177
+ const lines = body.split('\n');
178
+ const segments = [];
179
+ let i = 0;
180
+ while (i < lines.length) {
181
+ const line = lines[i];
182
+ const fenceEnd = fenceCloses(lines, i);
183
+ if (fenceEnd !== -1) {
184
+ const language = line.slice(3).trim();
185
+ segments.push({
186
+ type: 'code',
187
+ ...(language ? { language } : {}),
188
+ lines: lines.slice(i + 1, fenceEnd),
189
+ });
190
+ i = fenceEnd + 1;
191
+ }
192
+ else if (HEADING_LINE_RE.test(line) && !line.startsWith('###')) {
193
+ segments.push({
194
+ type: 'heading',
195
+ level: line.startsWith('##') ? 2 : 1,
196
+ text: line.replace(HEADING_LINE_RE, ''),
197
+ });
198
+ i++;
199
+ }
200
+ else if (/^[-•]\s/.test(line)) {
201
+ const items = [];
202
+ while (i < lines.length && /^[-•]\s/.test(lines[i])) {
203
+ items.push(lines[i].replace(/^[-•]\s/, ''));
204
+ i++;
205
+ }
206
+ segments.push({ type: 'bullet', items });
207
+ }
208
+ else if (/^\d+\.\s/.test(line)) {
209
+ const items = [];
210
+ while (i < lines.length && /^\d+\.\s/.test(lines[i])) {
211
+ items.push(lines[i].replace(/^\d+\.\s/, ''));
212
+ i++;
213
+ }
214
+ segments.push({ type: 'numbered', items });
215
+ }
216
+ else if (QUOTE_LINE_RE.test(line)) {
217
+ const quoteLines = [];
218
+ while (i < lines.length && QUOTE_LINE_RE.test(lines[i])) {
219
+ quoteLines.push(lines[i].replace(QUOTE_LINE_RE, ''));
220
+ i++;
221
+ }
222
+ segments.push({ type: 'quote', lines: quoteLines });
223
+ }
224
+ else {
225
+ const textLines = [];
226
+ while (i < lines.length &&
227
+ fenceCloses(lines, i) === -1 &&
228
+ !/^[-•]\s/.test(lines[i]) &&
229
+ !/^\d+\.\s/.test(lines[i]) &&
230
+ !QUOTE_LINE_RE.test(lines[i]) &&
231
+ !(HEADING_LINE_RE.test(lines[i]) && !lines[i].startsWith('###'))) {
232
+ textLines.push(lines[i]);
233
+ i++;
234
+ }
235
+ let chunk = [];
236
+ for (const l of textLines) {
237
+ if (l === '') {
238
+ if (chunk.length > 0) {
239
+ segments.push({ type: 'text', lines: chunk });
240
+ chunk = [];
241
+ }
242
+ }
243
+ else {
244
+ chunk.push(l);
245
+ }
246
+ }
247
+ if (chunk.length > 0)
248
+ segments.push({ type: 'text', lines: chunk });
249
+ }
250
+ }
251
+ return segments;
252
+ }
253
+ /**
254
+ * Markers, heading prefixes and fences removed — for one-line previews that
255
+ * render body text raw, outside any renderer.
256
+ *
257
+ * **Prefixes stack, and the order they are removed in is not cosmetic.** The
258
+ * version this was extracted from removed the heading prefix first and the
259
+ * quote prefix second, so `> # Heading` — a quoted heading, which the corpus is
260
+ * full of because every project brief quotes one — came back as `# Heading` and
261
+ * a preview showed a stray `#`. Stripping until the line stops changing removes
262
+ * whatever order they were written in. Found by running this over 152 real
263
+ * published bodies, not by reading the code.
264
+ */
265
+ function stripLinePrefixes(line) {
266
+ let out = line;
267
+ for (;;) {
268
+ const next = out.replace(/^>\s/, '').replace(/^#{1,2}\s/, '');
269
+ if (next === out)
270
+ return out;
271
+ out = next;
272
+ }
273
+ }
274
+ export function stripInlineFormatting(text) {
275
+ return text
276
+ .split('\n')
277
+ .filter((line) => !FENCE_RE.test(line))
278
+ .map((line) => parseInlineMarks(stripLinePrefixes(line)).map((s) => s.text).join(''))
279
+ .join('\n');
280
+ }
281
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAiCH;;;;;GAKG;AACH,MAAM,WAAW,GAAgB;IAC/B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;IAC1C,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE;IAC/B,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE;IACpC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE;IAChC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;CAC9C,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,EAAsB,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAEzF;;;;;;;;;;;GAWG;AACH,SAAS,aAAa,CAAC,IAAY,EAAE,KAAa,EAAE,IAAY,EAAE,MAAe;IAC/E,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACnC,OAAO,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,GAAG,K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  * pins the two together. It exists so "the upgrade reached the app" can be
48
48
  * checked by grepping a built bundle rather than by trusting a lockfile. */
49
- export declare const PROTOCOL_VERSION = "0.4.0";
49
+ export declare const PROTOCOL_VERSION = "0.6.0";
50
50
  export { type NostrTag, type UnsignedEvent, type SignedEvent, type Profile, type ThreadRef, type ChannelVisibility, type ChannelKind, type MemberRole, type Label, type ResolutionAction, KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE, computeEventId, toNostrSeconds, canonicalChannelName, threadTags, addr, relayAuthUrl, buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditChannelMetadata, buildAddMember, buildReaction, buildDeletion, buildMessage, buildResolution, buildFile, buildComponent, buildHighlight, buildUnsignedRelayAuthEvent, } from './events.js';
51
51
  export { type AddressPointer, type EventPointer, encodeNevent, decodeNevent, convertBits, bech32Encode, bech32Decode, encodeNaddr, decodeNaddr, pointerToAddress, addressToPointer, addrToNaddr, naddrToAddr, referenceToPointer, NADDR_RE, findNaddrs, stripNaddrs, } from './nip19.js';
52
52
  export { type AuthEventArgs, TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
@@ -54,4 +54,5 @@ export { type Signer, type SignerKind, publicKeyFromSecret, signEvent, secretKey
54
54
  export { type PublishResult, type QueryResult, type RelayHeaders, type RelayOptions, type FetchLike, type QueryAllOptions, parsePublishResponse, parseQueryResponse, RELAY_PAGE_CEILING, DEFAULT_QUERY_CONCURRENCY, Relay, } from './bridge.js';
55
55
  export { type RelayState, type SocketLike, type RelayCredential, type LiveRelayOptions, type Subscription, type LiveRelay, toWebSocketUrl, parseFrame, createLiveRelay, } from './live.js';
56
56
  export { type ChannelEventHandler, type ChannelSubscription, type ChannelSubscriptions, createChannelSubscriptions, } from './subscriptions.js';
57
+ export { type InlineMark, type InlineMarkSpan, type BodySegment, parseInlineMarks, wrapInlineMarks, parseBodySegments, stripInlineFormatting, } from './content.js';
57
58
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,EAEZ,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,aAAa,EAClB,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,EAEZ,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EACl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BAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@
46
46
  /** Bumped by hand with the version in package.json — `test/version.test.ts`
47
47
  * pins the two together. It exists so "the upgrade reached the app" can be
48
48
  * checked by grepping a built bundle rather than by trusting a lockfile. */
49
- export const PROTOCOL_VERSION = '0.4.0';
49
+ export const PROTOCOL_VERSION = '0.6.0';
50
50
  export {
51
51
  // constants
52
52
  KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE,
@@ -60,4 +60,5 @@ export { publicKeyFromSecret, signEvent, secretKeySigner, } from './sign.js';
60
60
  export { parsePublishResponse, parseQueryResponse, RELAY_PAGE_CEILING, DEFAULT_QUERY_CONCURRENCY, Relay, } from './bridge.js';
61
61
  export { toWebSocketUrl, parseFrame, createLiveRelay, } from './live.js';
62
62
  export { createChannelSubscriptions, } from './subscriptions.js';
63
+ export { parseInlineMarks, wrapInlineMarks, parseBodySegments, stripInlineFormatting, } from './content.js';
63
64
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAEvC,OAAO;AAYL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB;AACjB,8CAA8C;AAC9C,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY;AACZ,WAAW;AACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,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kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EAEL,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAGL,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAOL,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EAOL,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAIL,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAIL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/protocol",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "The Estiva wire format: Buzz-shaped Nostr event builders, NIP-01 ids, NIP-19 naddr, NIP-98 HTTP auth, and the relay clients. Speaks the protocol; interprets nothing.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/bridge.ts CHANGED
@@ -205,6 +205,18 @@ export class Relay {
205
205
  private readonly signer: Signer
206
206
  private readonly headers: RelayHeaders
207
207
  private readonly transport: FetchLike | undefined
208
+ /**
209
+ * The largest page this relay has ever handed back, across every call.
210
+ *
211
+ * A *lower bound* on the relay's real clamp, and the only one obtainable
212
+ * without trusting anybody: the relay returned this many events in one
213
+ * response, so its ceiling is at least this large. {@link Relay.pageFilter}
214
+ * uses it to tell a short page apart from a clamped one — see there.
215
+ *
216
+ * Per instance and never reset, so the second read through a long-lived
217
+ * `Relay` is cheaper than the first.
218
+ */
219
+ private observedPageCeiling = 0
208
220
 
209
221
  constructor(url: string, signer: Signer, options: RelayOptions | RelayHeaders = {}) {
210
222
  this.url = url.replace(/\/+$/, '')
@@ -391,6 +403,38 @@ export class Relay {
391
403
  ])
392
404
  if (events.length === 0) break
393
405
  out.push(...events)
406
+
407
+ /*
408
+ A page smaller than one this relay has already delivered is the end of
409
+ the filter, and no confirming round trip is needed to know it.
410
+
411
+ The reason the confirmation existed is real: a page shorter than the
412
+ `limit` we asked for is ambiguous, because the relay clamps to
413
+ `min(requested, ceiling)` and might have clamped at exactly this many.
414
+ But that requires the ceiling to *equal* this page's size — and the
415
+ ceiling is one constant for the relay, already known to be at least
416
+ `observedPageCeiling`. So `n < observedPageCeiling` rules the clamp out
417
+ arithmetically rather than by trusting anything.
418
+
419
+ Deliberately not NIP-11's `limitation.max_limit`. That number is a
420
+ claim: a relay advertising more than it clamps to would make every page
421
+ look short and the first one get mistaken for the whole set, which is
422
+ exactly the SHA-8 bug this loop exists to prevent. An observed page is
423
+ evidence — the relay demonstrably produced it.
424
+
425
+ Conservative before it has evidence: the first filter through a fresh
426
+ `Relay` still pays the confirmation, and so does any page that ties the
427
+ largest seen so far — which means **the widest filter always confirms**,
428
+ since it ties its own bound on every read. So the floor is one request
429
+ per filter plus one, not one per filter.
430
+
431
+ Measured on Ship's `loadAll` against production: **66 requests to 35
432
+ cold and 34 warm**, the same fold event for event, and 8.8 s to 0.9 s
433
+ alongside the concurrency of 0.4.0.
434
+ */
435
+ if (events.length > this.observedPageCeiling) this.observedPageCeiling = events.length
436
+ if (events.length < pageSize && events.length < this.observedPageCeiling) break
437
+
394
438
  const oldest = Math.min(...events.map((e) => e.created_at))
395
439
  if (until !== undefined && oldest >= until) {
396
440
  if (events.length >= pageSize) {
package/src/content.ts ADDED
@@ -0,0 +1,294 @@
1
+ /**
2
+ * The message marker dialect — SPEC §13.1 and §13.2.
3
+ *
4
+ * ## Why content is in a package that "interprets nothing"
5
+ *
6
+ * `index.ts` draws the line at *interpretation*: the fold stays in the apps,
7
+ * because how an app turns events into current truth is where apps are supposed
8
+ * to differ. A body's formatting is on the other side of that line for the same
9
+ * reason the event id is — **it is wire-visible, and two apps disagreeing about
10
+ * it produces a divergence each copy is self-consistent about and nobody
11
+ * notices.** That is not a hypothetical: measured on production 2026-09-02,
12
+ * 261 of 548 published messages carry structure, Peek parses it, Ship renders
13
+ * it literally, and neither is wrong about its own behaviour.
14
+ *
15
+ * Being honest about the usual test: the relay would *not* notice if two apps
16
+ * disagreed here, so §10's question is a poor fit. What makes this belong is the
17
+ * failure shape rather than the arbiter — see RFC 0.4 §14.3, which put the
18
+ * inline layer here, and SPEC §13.1, which made it normative.
19
+ *
20
+ * **What is deliberately not here.** Mentions resolved against a directory,
21
+ * bracket references to an app's own objects, and anything that needs to know
22
+ * what a topic or a file is. Peek's `textParsing.ts` mixes those with the marks;
23
+ * only the marks moved. A `nostr:` reference is a mark and its *token* is in
24
+ * scope, but what a mention does is RIC-2's.
25
+ */
26
+
27
+ /** Marks a run of text can carry. `code` is exclusive — see {@link parseInlineMarks}. */
28
+ export type InlineMark = 'bold' | 'italic' | 'underline' | 'code'
29
+
30
+ /** A run of text and the marks on it. */
31
+ export interface InlineMarkSpan {
32
+ text: string
33
+ bold?: boolean
34
+ italic?: boolean
35
+ underline?: boolean
36
+ code?: boolean
37
+ }
38
+
39
+ /** A block-level run, parsed from line prefixes. */
40
+ export type BodySegment =
41
+ | { type: 'text'; lines: string[] }
42
+ | { type: 'bullet'; items: string[] }
43
+ | { type: 'numbered'; items: string[] }
44
+ | { type: 'heading'; level: 1 | 2; text: string }
45
+ | { type: 'quote'; lines: string[] }
46
+ | { type: 'code'; language?: string; lines: string[] }
47
+
48
+ interface MarkToken {
49
+ token: string
50
+ keys: InlineMark[]
51
+ /**
52
+ * The content is taken literally and no mark may nest inside it, and the
53
+ * adjacency fence below does not apply to the delimiter.
54
+ */
55
+ literal?: boolean
56
+ }
57
+
58
+ /**
59
+ * Longest token first so `***` is not consumed as `**` plus a dangling `*`.
60
+ *
61
+ * Order only decides ties at one index — the scanner walks left to right, so the
62
+ * leftmost opening delimiter wins regardless of what is listed first.
63
+ */
64
+ const MARK_TOKENS: MarkToken[] = [
65
+ { token: '***', keys: ['bold', 'italic'] },
66
+ { token: '**', keys: ['bold'] },
67
+ { token: '__', keys: ['underline'] },
68
+ { token: '*', keys: ['italic'] },
69
+ { token: '`', keys: ['code'], literal: true },
70
+ ]
71
+
72
+ const isWordChar = (ch: string | undefined) => ch !== undefined && /[A-Za-z0-9]/.test(ch)
73
+
74
+ /**
75
+ * SPEC §13.2 rule 2 — a marker adjacent to an alphanumeric is not a marker, so
76
+ * `2*3*4` stays literal math.
77
+ *
78
+ * **It does not apply to a backtick.** Rule 2 resolves an ambiguity that only
79
+ * asymmetric prose markers have: `*` is multiplication and a glob, `_` is in
80
+ * identifiers. A backtick is not used as ordinary punctuation, so there is no
81
+ * ambiguity to resolve — and applying the fence anyway leaves `` `main`s ``
82
+ * literal, which is a code span followed by a plural or possessive. Measured
83
+ * against production 2026-09-02: 8 such spans in 6 published messages, and zero
84
+ * cases of the opening side needing the fence. CommonMark agrees.
85
+ */
86
+ function findMarkClose(text: string, token: string, from: number, fenced: boolean): number {
87
+ let idx = text.indexOf(token, from)
88
+ while (idx !== -1) {
89
+ if (!fenced || !isWordChar(text[idx + token.length])) return idx
90
+ idx = text.indexOf(token, idx + 1)
91
+ }
92
+ return -1
93
+ }
94
+
95
+ function toMarkSpan(text: string, active: InlineMark[]): InlineMarkSpan {
96
+ const span: InlineMarkSpan = { text }
97
+ for (const key of active) span[key] = true
98
+ return span
99
+ }
100
+
101
+ function scanMarks(text: string, active: InlineMark[]): InlineMarkSpan[] {
102
+ for (let i = 0; i < text.length; i++) {
103
+ for (const { token, keys, literal } of MARK_TOKENS) {
104
+ if (keys.some((k) => active.includes(k))) continue
105
+ if (!text.startsWith(token, i)) continue
106
+ const fenced = !literal
107
+ if (fenced && isWordChar(text[i - 1])) continue
108
+ const close = findMarkClose(text, token, i + token.length, fenced)
109
+ if (close === -1) continue
110
+ const inner = text.slice(i + token.length, close)
111
+ // SPEC §13.2 rule 1: whitespace at the inner edges means it is not a pair.
112
+ if (!inner || /^\s/.test(inner) || /\s$/.test(inner)) continue
113
+ const spans: InlineMarkSpan[] = []
114
+ const before = text.slice(0, i)
115
+ if (before) spans.push(toMarkSpan(before, active))
116
+ if (literal) {
117
+ /*
118
+ SPEC §13.1: code MUST NOT combine with any other mark, and its content
119
+ MUST NOT be parsed for further marks. So the span carries `code` alone
120
+ even inside an enclosing bold — dropping the outer mark rather than
121
+ emitting a combination the spec forbids.
122
+ */
123
+ spans.push({ text: inner, code: true })
124
+ } else {
125
+ spans.push(...scanMarks(inner, [...active, ...keys]))
126
+ }
127
+ spans.push(...scanMarks(text.slice(close + token.length), active))
128
+ return spans
129
+ }
130
+ }
131
+ return text ? [toMarkSpan(text, active)] : []
132
+ }
133
+
134
+ /**
135
+ * Parse one plain-text run into styled spans.
136
+ *
137
+ * Split mentions and app-specific references out first — this function knows
138
+ * about marks and nothing else.
139
+ */
140
+ export function parseInlineMarks(text: string): InlineMarkSpan[] {
141
+ return scanMarks(text, [])
142
+ }
143
+
144
+ /**
145
+ * Wrap a run of text in the markers for the marks it carries.
146
+ *
147
+ * Edge whitespace is hoisted outside the markers, because `**word **` would not
148
+ * parse back under rule 1 — so bolding "word " round-trips as `**word** `.
149
+ *
150
+ * `code` wins alone, for the same reason the parser never emits it combined.
151
+ */
152
+ export function wrapInlineMarks(text: string, markNames: ReadonlySet<string>): string {
153
+ if (!text) return text
154
+ const bold = markNames.has('bold')
155
+ const italic = markNames.has('italic')
156
+ const underline = markNames.has('underline')
157
+ const code = markNames.has('code')
158
+ if (!bold && !italic && !underline && !code) return text
159
+ const m = text.match(/^(\s*)([\s\S]*?)(\s*)$/)!
160
+ const [, lead, core, trail] = m
161
+ if (!core) return text
162
+ if (code) return `${lead}\`${core}\`${trail}`
163
+ let out = core
164
+ if (bold && italic) out = `***${out}***`
165
+ else if (bold) out = `**${out}**`
166
+ else if (italic) out = `*${out}*`
167
+ if (underline) out = `__${out}__`
168
+ return lead + out + trail
169
+ }
170
+
171
+ const HEADING_LINE_RE = /^#{1,2}\s/
172
+ /** `> ` with the space required — a bare `>` typed at a line start ("5 > 3")
173
+ * stays literal, the same conservatism as the inline markers. */
174
+ const QUOTE_LINE_RE = /^>\s/
175
+ const FENCE_RE = /^```/
176
+
177
+ /**
178
+ * Where the fence opened at `from` closes, or -1 if it never does.
179
+ *
180
+ * An unclosed fence is not a fence: SPEC §13.2 requires an unmatched marker to
181
+ * render literally, and swallowing the rest of the body because somebody typed
182
+ * three backticks is the opposite of that.
183
+ */
184
+ function fenceCloses(lines: string[], from: number): number {
185
+ if (!FENCE_RE.test(lines[from])) return -1
186
+ for (let j = from + 1; j < lines.length; j++) if (FENCE_RE.test(lines[j])) return j
187
+ return -1
188
+ }
189
+
190
+ /**
191
+ * Split a body into block segments.
192
+ *
193
+ * Blank lines split runs of plain text into separate `text` segments. `# ` and
194
+ * `## ` become headings; three or more `#`s, and a `#123` reference with no
195
+ * space, stay plain text.
196
+ */
197
+ export function parseBodySegments(body: string): BodySegment[] {
198
+ const lines = body.split('\n')
199
+ const segments: BodySegment[] = []
200
+ let i = 0
201
+ while (i < lines.length) {
202
+ const line = lines[i]
203
+ const fenceEnd = fenceCloses(lines, i)
204
+ if (fenceEnd !== -1) {
205
+ const language = line.slice(3).trim()
206
+ segments.push({
207
+ type: 'code',
208
+ ...(language ? { language } : {}),
209
+ lines: lines.slice(i + 1, fenceEnd),
210
+ })
211
+ i = fenceEnd + 1
212
+ } else if (HEADING_LINE_RE.test(line) && !line.startsWith('###')) {
213
+ segments.push({
214
+ type: 'heading',
215
+ level: line.startsWith('##') ? 2 : 1,
216
+ text: line.replace(HEADING_LINE_RE, ''),
217
+ })
218
+ i++
219
+ } else if (/^[-•]\s/.test(line)) {
220
+ const items: string[] = []
221
+ while (i < lines.length && /^[-•]\s/.test(lines[i])) {
222
+ items.push(lines[i].replace(/^[-•]\s/, ''))
223
+ i++
224
+ }
225
+ segments.push({ type: 'bullet', items })
226
+ } else if (/^\d+\.\s/.test(line)) {
227
+ const items: string[] = []
228
+ while (i < lines.length && /^\d+\.\s/.test(lines[i])) {
229
+ items.push(lines[i].replace(/^\d+\.\s/, ''))
230
+ i++
231
+ }
232
+ segments.push({ type: 'numbered', items })
233
+ } else if (QUOTE_LINE_RE.test(line)) {
234
+ const quoteLines: string[] = []
235
+ while (i < lines.length && QUOTE_LINE_RE.test(lines[i])) {
236
+ quoteLines.push(lines[i].replace(QUOTE_LINE_RE, ''))
237
+ i++
238
+ }
239
+ segments.push({ type: 'quote', lines: quoteLines })
240
+ } else {
241
+ const textLines: string[] = []
242
+ while (
243
+ i < lines.length &&
244
+ fenceCloses(lines, i) === -1 &&
245
+ !/^[-•]\s/.test(lines[i]) &&
246
+ !/^\d+\.\s/.test(lines[i]) &&
247
+ !QUOTE_LINE_RE.test(lines[i]) &&
248
+ !(HEADING_LINE_RE.test(lines[i]) && !lines[i].startsWith('###'))
249
+ ) {
250
+ textLines.push(lines[i])
251
+ i++
252
+ }
253
+ let chunk: string[] = []
254
+ for (const l of textLines) {
255
+ if (l === '') {
256
+ if (chunk.length > 0) { segments.push({ type: 'text', lines: chunk }); chunk = [] }
257
+ } else {
258
+ chunk.push(l)
259
+ }
260
+ }
261
+ if (chunk.length > 0) segments.push({ type: 'text', lines: chunk })
262
+ }
263
+ }
264
+ return segments
265
+ }
266
+
267
+ /**
268
+ * Markers, heading prefixes and fences removed — for one-line previews that
269
+ * render body text raw, outside any renderer.
270
+ *
271
+ * **Prefixes stack, and the order they are removed in is not cosmetic.** The
272
+ * version this was extracted from removed the heading prefix first and the
273
+ * quote prefix second, so `> # Heading` — a quoted heading, which the corpus is
274
+ * full of because every project brief quotes one — came back as `# Heading` and
275
+ * a preview showed a stray `#`. Stripping until the line stops changing removes
276
+ * whatever order they were written in. Found by running this over 152 real
277
+ * published bodies, not by reading the code.
278
+ */
279
+ function stripLinePrefixes(line: string): string {
280
+ let out = line
281
+ for (;;) {
282
+ const next = out.replace(/^>\s/, '').replace(/^#{1,2}\s/, '')
283
+ if (next === out) return out
284
+ out = next
285
+ }
286
+ }
287
+
288
+ export function stripInlineFormatting(text: string): string {
289
+ return text
290
+ .split('\n')
291
+ .filter((line) => !FENCE_RE.test(line))
292
+ .map((line) => parseInlineMarks(stripLinePrefixes(line)).map((s) => s.text).join(''))
293
+ .join('\n')
294
+ }
package/src/index.ts CHANGED
@@ -47,7 +47,7 @@
47
47
  /** Bumped by hand with the version in package.json — `test/version.test.ts`
48
48
  * pins the two together. It exists so "the upgrade reached the app" can be
49
49
  * checked by grepping a built bundle rather than by trusting a lockfile. */
50
- export const PROTOCOL_VERSION = '0.4.0'
50
+ export const PROTOCOL_VERSION = '0.6.0'
51
51
 
52
52
  export {
53
53
  // types
@@ -163,3 +163,13 @@ export {
163
163
  type ChannelSubscriptions,
164
164
  createChannelSubscriptions,
165
165
  } from './subscriptions.js'
166
+
167
+ export {
168
+ type InlineMark,
169
+ type InlineMarkSpan,
170
+ type BodySegment,
171
+ parseInlineMarks,
172
+ wrapInlineMarks,
173
+ parseBodySegments,
174
+ stripInlineFormatting,
175
+ } from './content.js'