@estiva-app/protocol 0.30.0 → 0.32.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,33 @@ 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.32.0 — 2026-10-13
8
+
9
+ **Wire behaviour: none.** A reader reads a message's links as references (OPT-18,
10
+ SPEC §13.6.2). New `linksAsReferences(blocks, resolveLink)` returns a message's
11
+ render tree with each bare app link that the caller's `LinkResolver` resolves (§7.7)
12
+ turned into a `reference` run for what it names. The run's text stays the URL.
13
+ A reader then draws it as that object's chip, the same as a `nostr:` reference.
14
+ These are left as they are: a link on words (`[words](url)`), a URL in code, and a link
15
+ nothing resolves. `cardsIn` names the same card for the tree before and after.
16
+ `standaloneReference` is now documented as for block documents only. In a
17
+ message, every reference is a chip and a card comes only from `embed`.
18
+
19
+ ## 0.31.0 — 2026-10-13
20
+
21
+ **Wire behaviour: a message can ask for a reference's card** (OPT-16, SPEC
22
+ §13.6.2). New tag `["embed", <address or event id>, "compact" | "detailed" |
23
+ "none"]` on a `kind:9`, a `kind:1111` and their `40003` edits. `embedsOf` reads
24
+ it (first per value, an unknown layout as `compact`), `embedTag` writes it, and
25
+ `cardsIn` says which cards a message draws: the values its folded body still
26
+ names — by `nostr:` reference, or by an app link the caller's `LinkResolver`
27
+ resolves by §7.7 (without one, a link names nothing) — in body order, with a
28
+ `part` winning over an `embed`.
29
+ There is no `a`/`q` match, so an edit can give a card to a reference it added.
30
+ Nothing this package publishes changes: nothing writes `embed` yet, and a
31
+ reader on 0.30 ignores the tag and draws the reference as before.
32
+ `standaloneReference` is unchanged.
33
+
7
34
  ## 0.30.0 — 2026-10-13
8
35
 
9
36
  **Wire behaviour: a block document can hold a checklist item and a callout**
@@ -0,0 +1,72 @@
1
+ import type { PartPointer } from './anchors.js';
2
+ import type { RenderBlock } from './render.js';
3
+ export declare const EMBED_TAG = "embed";
4
+ /** How much of a referenced object a card shows, or `none` for no card. */
5
+ export type EmbedLayout = 'compact' | 'detailed' | 'none';
6
+ /** One `embed` tag, read. */
7
+ export interface Embed {
8
+ /** An address (`kind:pubkey:d`) or a 64-hex event id, lowercase hex. */
9
+ value: string;
10
+ layout: EmbedLayout;
11
+ }
12
+ /** The `embed` tag for one reference. */
13
+ export declare function embedTag(value: string, layout: EmbedLayout): string[];
14
+ /**
15
+ * The `embed` tags on one event, one per value, in tag order.
16
+ *
17
+ * The first tag for a value wins. A layout this reader does not know draws as
18
+ * `compact` rather than nothing: the author asked for a card, and the smallest
19
+ * one is the safe reading of a density added after this reader was written. A
20
+ * value that is neither an address nor an event id is skipped.
21
+ *
22
+ * **This is the tags only**, of one event. For a message, fold its edits first
23
+ * (`foldEmbeds` in `@estiva-app/conversation`), then ask {@link cardsIn} which
24
+ * of them the body still names.
25
+ */
26
+ export declare function embedsOf(event: {
27
+ tags: readonly (readonly string[])[];
28
+ }): Embed[];
29
+ /**
30
+ * What an app link names, as the reader resolved it by §7.7 — the host and the
31
+ * `<type>` segment against a published `urls` pattern, then the one author who
32
+ * holds that `d` — or undefined. Never a match on the link's trailing
33
+ * identifier alone: that resolves any site's URL as somebody's object, and puts
34
+ * a real issue's card under a link that does not open it (§7.7).
35
+ */
36
+ export type LinkResolver = (url: string) => string | undefined;
37
+ /**
38
+ * The cards a message asks for, in the order the body first names them.
39
+ *
40
+ * `embeds` is the message's folded set; `blocks` its folded body as a render
41
+ * tree; `parts` its `part` pointers (§13.6.1). A value appears here only while
42
+ * the body names it — by a `nostr:` reference, or by an app link that
43
+ * `resolveLink` resolves to it (§7.7) — and only when no `part` names the
44
+ * same address, because the live block already stands for that object. Text in
45
+ * a code span names nothing (§13.1). Without `resolveLink` a link names nothing:
46
+ * resolving one needs the manifests and the relay, which this package does not hold.
47
+ *
48
+ * `none` entries are kept: they draw no card, but they still override any
49
+ * default a reader has for that value. Filter them out to get the cards to draw.
50
+ */
51
+ export declare function cardsIn(embeds: readonly Embed[], blocks: readonly RenderBlock[], parts?: readonly PartPointer[], resolveLink?: LinkResolver): Embed[];
52
+ /**
53
+ * A message's tree with each bare app link turned into the reference it names,
54
+ * so a reader draws it as that object's chip (SPEC §13.6.2, OPT-18).
55
+ *
56
+ * A reference reads as a chip wherever it sits (§13.1), and a link some app
57
+ * claims (§7.7) is a reference written as a URL — the form a message has when
58
+ * it was written before the composer turned pasted links into chips, or by a
59
+ * client that does not. Without this, the two would read differently for no
60
+ * reason the reader can see.
61
+ *
62
+ * Left alone: a link on words (the author chose the words, and they stay a
63
+ * link; its card is the author's `embed`), a URL in code (§13.1: literal), and
64
+ * a link `resolveLink` does not answer — no app claims it, or the answer has
65
+ * not come back yet — which stays a link. The run keeps the URL as its text,
66
+ * so a reader that draws references as text shows what was written.
67
+ *
68
+ * Messages only: a description is a block document, whose links are not this
69
+ * function's business (§13.3).
70
+ */
71
+ export declare function linksAsReferences(blocks: readonly RenderBlock[], resolveLink: LinkResolver): RenderBlock[];
72
+ //# sourceMappingURL=embeds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeds.d.ts","sourceRoot":"","sources":["../src/embeds.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AAE5D,eAAO,MAAM,SAAS,UAAU,CAAA;AAEhC,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAA;AAEzD,6BAA6B;AAC7B,MAAM,WAAW,KAAK;IACpB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,WAAW,CAAA;CACpB;AAED,yCAAyC;AACzC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAErE;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAA;CAAE,GAAG,KAAK,EAAE,CAWjF;AAcD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;AAmC9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,KAAK,GAAE,SAAS,WAAW,EAAO,EAAE,WAAW,CAAC,EAAE,YAAY,GAAG,KAAK,EAAE,CAuCzJ;AAaD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,WAAW,EAAE,YAAY,GAAG,WAAW,EAAE,CA4C1G"}
package/dist/embeds.js ADDED
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Showing a reference as a card — SPEC §13.6.2 (OPT-16).
3
+ *
4
+ * `["embed", <value>, "compact" | "detailed" | "none"]` says how the author
5
+ * wants one reference in a message drawn: as a card under the message, and how
6
+ * much of it. `<value>` is what an `a` or `q` would carry for the same thing —
7
+ * an address or a 64-hex event id. The values are a density, not a widget
8
+ * name: `compact` is §7.5's closed `row` and `detailed` its closed `card`, so
9
+ * a richer card can come later without changing the wire.
10
+ *
11
+ * A reference with no `embed` is drawn by the reader's default (a chip, §13.1).
12
+ * An `embed` for a value overrides that default, which is why `none` exists:
13
+ * it is the author saying "no card" in an edit that replaces the set (§6.8).
14
+ *
15
+ * Like `part` (§13.6.1), the tags are only half the answer. A card is drawn
16
+ * only while the body — as edited — still names its value, and there is no
17
+ * `a`/`q` match: an edit carries no index tags (§6.8), and a value first named
18
+ * in an edit can still carry a card (Miky, 2026-10-13, OPT-16 kickoff).
19
+ * {@link cardsIn} applies that rule; {@link embedsOf} reads the tags alone.
20
+ */
21
+ import { addrToNaddr, bech32Decode, convertBits, decodeNevent, encodeNevent, naddrToAddr } from './nip19.js';
22
+ export const EMBED_TAG = 'embed';
23
+ /** The `embed` tag for one reference. */
24
+ export function embedTag(value, layout) {
25
+ return [EMBED_TAG, value, layout];
26
+ }
27
+ // `partsOf`'s shape: an empty `d` is a valid address (NIP-01).
28
+ const ADDRESS = /^\d+:[0-9a-f]{64}:/;
29
+ const EVENT_ID = /^[0-9a-f]{64}$/;
30
+ /**
31
+ * The `embed` tags on one event, one per value, in tag order.
32
+ *
33
+ * The first tag for a value wins. A layout this reader does not know draws as
34
+ * `compact` rather than nothing: the author asked for a card, and the smallest
35
+ * one is the safe reading of a density added after this reader was written. A
36
+ * value that is neither an address nor an event id is skipped.
37
+ *
38
+ * **This is the tags only**, of one event. For a message, fold its edits first
39
+ * (`foldEmbeds` in `@estiva-app/conversation`), then ask {@link cardsIn} which
40
+ * of them the body still names.
41
+ */
42
+ export function embedsOf(event) {
43
+ const out = [];
44
+ const seen = new Set();
45
+ for (const tag of event.tags) {
46
+ if (tag[0] !== EMBED_TAG || !tag[1])
47
+ continue;
48
+ const value = normalise(tag[1]);
49
+ if (!value || seen.has(value))
50
+ continue;
51
+ seen.add(value);
52
+ out.push({ value, layout: layoutOf(tag[2]) });
53
+ }
54
+ return out;
55
+ }
56
+ function layoutOf(raw) {
57
+ return raw === 'detailed' || raw === 'none' ? raw : 'compact';
58
+ }
59
+ function normalise(value) {
60
+ if (EVENT_ID.test(value.toLowerCase()))
61
+ return value.toLowerCase();
62
+ if (!ADDRESS.test(value))
63
+ return undefined;
64
+ // The kind and pubkey are hex and compared as such; the `d` is the author's and kept as written.
65
+ const [kind, pubkey, ...d] = value.split(':');
66
+ return `${kind}:${pubkey.toLowerCase()}:${d.join(':')}`;
67
+ }
68
+ const TRAILING = new Set(['.', ',', ';', ':', '!', '?', ')', ']']);
69
+ const URL_RUN = /https?:\/\/[^\s<>"'`]+/g;
70
+ /** A URL run without the sentence's trailing punctuation; stripped by a loop, which stays linear on a hostile run of dots. */
71
+ function trimUrl(url) {
72
+ let end = url.length;
73
+ while (end > 0 && TRAILING.has(url[end - 1]))
74
+ end--;
75
+ return url.slice(0, end);
76
+ }
77
+ /** The http(s) links in a text. Trailing punctuation is the sentence's, not the link's. */
78
+ function urlsIn(text) {
79
+ return (text.match(URL_RUN) ?? []).map(trimUrl);
80
+ }
81
+ /** The address or event id a `nostr:` reference names, or undefined for a person or something unreadable. */
82
+ function valueOfReference(reference) {
83
+ const bare = reference.replace(/^nostr:/i, '').toLowerCase();
84
+ try {
85
+ if (bare.startsWith('naddr1'))
86
+ return normalise(naddrToAddr(bare));
87
+ if (bare.startsWith('nevent1'))
88
+ return decodeNevent(bare).id.toLowerCase();
89
+ if (bare.startsWith('note1')) {
90
+ const { hrp, data } = bech32Decode(bare);
91
+ if (hrp !== 'note')
92
+ return undefined;
93
+ const hex = convertBits(data, 5, 8, false).map((b) => b.toString(16).padStart(2, '0')).join('');
94
+ return EVENT_ID.test(hex) ? hex : undefined;
95
+ }
96
+ }
97
+ catch {
98
+ return undefined;
99
+ }
100
+ return undefined;
101
+ }
102
+ /**
103
+ * The cards a message asks for, in the order the body first names them.
104
+ *
105
+ * `embeds` is the message's folded set; `blocks` its folded body as a render
106
+ * tree; `parts` its `part` pointers (§13.6.1). A value appears here only while
107
+ * the body names it — by a `nostr:` reference, or by an app link that
108
+ * `resolveLink` resolves to it (§7.7) — and only when no `part` names the
109
+ * same address, because the live block already stands for that object. Text in
110
+ * a code span names nothing (§13.1). Without `resolveLink` a link names nothing:
111
+ * resolving one needs the manifests and the relay, which this package does not hold.
112
+ *
113
+ * `none` entries are kept: they draw no card, but they still override any
114
+ * default a reader has for that value. Filter them out to get the cards to draw.
115
+ */
116
+ export function cardsIn(embeds, blocks, parts = [], resolveLink) {
117
+ if (embeds.length === 0)
118
+ return [];
119
+ const byValue = new Map(embeds.map((e) => [e.value, e]));
120
+ const withPart = new Set(parts.map((p) => normalise(p.address)).filter((v) => !!v));
121
+ const out = [];
122
+ const seen = new Set();
123
+ const take = (value) => {
124
+ if (!value || seen.has(value) || withPart.has(value))
125
+ return;
126
+ const embed = byValue.get(value);
127
+ if (!embed)
128
+ return;
129
+ seen.add(value);
130
+ out.push(embed);
131
+ };
132
+ // Adjacent plain runs are read as one text, so a link a mark splits in two is still one link.
133
+ const scan = (text) => {
134
+ if (!resolveLink || !text.includes('://'))
135
+ return;
136
+ for (const url of urlsIn(text)) {
137
+ const value = resolveLink(url);
138
+ if (value)
139
+ take(normalise(value));
140
+ }
141
+ };
142
+ const walk = (bs) => {
143
+ for (const block of bs) {
144
+ if (block.type !== 'codeBlock') {
145
+ let text = '';
146
+ for (const run of block.inline ?? []) {
147
+ if (run.reference || run.marks.includes('code')) {
148
+ scan(text);
149
+ text = '';
150
+ if (run.reference)
151
+ take(valueOfReference(run.reference));
152
+ }
153
+ else
154
+ text += run.text;
155
+ }
156
+ scan(text);
157
+ }
158
+ if (block.children)
159
+ walk(block.children);
160
+ }
161
+ };
162
+ walk(blocks);
163
+ return out;
164
+ }
165
+ /**
166
+ * One pass over a run: a link on words, `[words](https://…)` as the marker
167
+ * format writes it (group 1 — its URL is the target of words the author chose),
168
+ * or a bare URL (group 2). The same alternation the ui package's `RichText`
169
+ * draws links by, so what is skipped here is what it draws as a link. Alone,
170
+ * the first alternative is quadratic on a run of `[a](https://x` with no space
171
+ * or `)`; the bare-URL alternative after it swallows the rest, so this stays
172
+ * linear (OPT-18's security review).
173
+ */
174
+ const LINK_OR_URL = /(\[[^[\]\n]+\]\((?:https?:\/\/|mailto:)[^\s)]+\))|(https?:\/\/[^\s<>"'`]+)/g;
175
+ /**
176
+ * A message's tree with each bare app link turned into the reference it names,
177
+ * so a reader draws it as that object's chip (SPEC §13.6.2, OPT-18).
178
+ *
179
+ * A reference reads as a chip wherever it sits (§13.1), and a link some app
180
+ * claims (§7.7) is a reference written as a URL — the form a message has when
181
+ * it was written before the composer turned pasted links into chips, or by a
182
+ * client that does not. Without this, the two would read differently for no
183
+ * reason the reader can see.
184
+ *
185
+ * Left alone: a link on words (the author chose the words, and they stay a
186
+ * link; its card is the author's `embed`), a URL in code (§13.1: literal), and
187
+ * a link `resolveLink` does not answer — no app claims it, or the answer has
188
+ * not come back yet — which stays a link. The run keeps the URL as its text,
189
+ * so a reader that draws references as text shows what was written.
190
+ *
191
+ * Messages only: a description is a block document, whose links are not this
192
+ * function's business (§13.3).
193
+ */
194
+ export function linksAsReferences(blocks, resolveLink) {
195
+ const referenceOf = (url) => {
196
+ const value = normalise(resolveLink(url) ?? '');
197
+ if (!value)
198
+ return undefined;
199
+ // An address no naddr can hold (a `d` over 255 bytes) stays a link rather than taking the message down with it.
200
+ try {
201
+ return `nostr:${EVENT_ID.test(value) ? encodeNevent({ id: value, relays: [] }) : addrToNaddr(value)}`;
202
+ }
203
+ catch {
204
+ return undefined;
205
+ }
206
+ };
207
+ const split = (run) => {
208
+ if (run.reference || run.marks.includes('code') || !run.text.includes('://'))
209
+ return [run];
210
+ const out = [];
211
+ let at = 0;
212
+ for (const m of run.text.matchAll(LINK_OR_URL)) {
213
+ // A link on words: neither its target nor a URL in its words is taken.
214
+ if (m[1])
215
+ continue;
216
+ const start = m.index;
217
+ // A link on words whose words carry a mark arrives split across runs: its target follows `](`, and a URL as its words follows `[`.
218
+ if (run.text.slice(Math.max(0, start - 2), start) === '](' || run.text[start - 1] === '[')
219
+ continue;
220
+ const url = trimUrl(m[0]);
221
+ const reference = referenceOf(url);
222
+ if (!reference)
223
+ continue;
224
+ if (start > at)
225
+ out.push({ ...run, text: run.text.slice(at, start) });
226
+ out.push({ text: url, marks: run.marks, reference });
227
+ at = start + url.length;
228
+ }
229
+ if (at === 0)
230
+ return [run];
231
+ if (at < run.text.length)
232
+ out.push({ ...run, text: run.text.slice(at) });
233
+ return out;
234
+ };
235
+ // A block with nothing to turn is returned as it was, so a body without app links costs no copies.
236
+ const walk = (bs) => bs.map((block) => {
237
+ if (block.type === 'codeBlock')
238
+ return block;
239
+ const inline = block.inline?.flatMap(split);
240
+ const children = block.children && walk(block.children);
241
+ const unchanged = (next, was) => !next || (next.length === was?.length && next.every((x, i) => x === was[i]));
242
+ const same = unchanged(inline, block.inline) && unchanged(children, block.children);
243
+ return same ? block : { ...block, ...(inline ? { inline } : {}), ...(children ? { children } : {}) };
244
+ });
245
+ return walk(blocks);
246
+ }
247
+ //# sourceMappingURL=embeds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeds.js","sourceRoot":"","sources":["../src/embeds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAI5G,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAA;AAYhC,yCAAyC;AACzC,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,MAAmB;IACzD,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AACnC,CAAC;AAED,+DAA+D;AAC/D,MAAM,OAAO,GAAG,oBAAoB,CAAA;AACpC,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,KAA+C;IACtE,MAAM,GAAG,GAAY,EAAE,CAAA;IACvB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,SAAQ;QAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAA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,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACvD,MAAM,SAAS,GAAG,CAAK,IAA8B,EAAE,GAA6B,EAAE,EAAE,CACtF,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9E,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;QACnF,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IACtG,CAAC,CAAC,CAAA;IACJ,OAAO,IAAI,CAAC,MAAM,CAAC,CAAA;AACrB,CAAC"}
package/dist/index.d.ts 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 declare const PROTOCOL_VERSION = "0.30.0";
49
+ export declare const PROTOCOL_VERSION = "0.32.0";
50
50
  export { type NostrTag, type UnsignedEvent, type SignedEvent, type Profile, type ThreadRef, type ChannelVisibility, type ChannelKind, type MemberRole, type FolderOp, type Label, type ResolutionAction, KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE, computeEventId, toNostrSeconds, canonicalChannelName, threadTags, addr, relayAuthUrl, buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditChannelMetadata, buildFolderCommand, buildAddMember, buildDmOpen, buildDmHide, buildReaction, buildDeletion, buildEdit, buildMessage, buildResolution, buildBareFile, 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, encodeNpub, decodeNpub, NOSTR_URI_RE, findNostrUris, } from './nip19.js';
52
52
  export { type AuthEventArgs, TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
@@ -60,5 +60,6 @@ export { type RenderInline, type RenderBlock, type RenderFormat, type ContentFor
60
60
  export { markerTextToBlockDocument, blockDocumentToMarkerText, type DescriptionTextOptions, } from './bridge-content.js';
61
61
  export { type EditorNode, type EditorDocument, EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
62
62
  export { type BlockAnchor, type Part, type PartPointer, type PartSource, BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
63
+ export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences } from './embeds.js';
63
64
  export { type BlossomVerb, type Imeta, BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, type BlobFetchLike, type BlobResponseLike, type FetchedBlob, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, type UploadedBlob, type BlobUploadFetchLike, } from './media.js';
64
65
  //# 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,WAAW,CAAA;AAExC,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,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,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,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,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,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,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AY,EACZ,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,WAAW,CAAA;AAExC,OAAO,EAEL,K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AAqB,CAAA;AAE5B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACxI,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,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.30.0';
49
+ export const PROTOCOL_VERSION = '0.32.0';
50
50
  export {
51
51
  // constants
52
52
  KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE,
@@ -66,5 +66,6 @@ export { CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTre
66
66
  export { markerTextToBlockDocument, blockDocumentToMarkerText, } from './bridge-content.js';
67
67
  export { EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
68
68
  export { BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
69
+ export { EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences } from './embeds.js';
69
70
  export { BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, } from './media.js';
70
71
  //# 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,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,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,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eA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ACnB,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAGL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAGL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EAIrB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,GAGlB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,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,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAE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BAAyB,GAE1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAGL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAAmD,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACxI,OAAO,EAGL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EAIrB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,GAGlB,MAAM,YAAY,CAAA"}
package/dist/render.d.ts CHANGED
@@ -165,6 +165,11 @@ export declare function renderTreeText(blocks: readonly RenderBlock[]): string;
165
165
  * Whitespace around the reference does not change the answer — a pointer alone
166
166
  * on its line is alone on its line whether or not somebody left a space after
167
167
  * it.
168
+ *
169
+ * **For a block document (a description) only, since OPT-18.** In a message a
170
+ * reference reads as its chip wherever it sits, and a card comes only from the
171
+ * author's `embed` (§13.6.2). A description has no `embed` yet, so its readers
172
+ * still draw a reference alone on its line as a card until it can choose one.
168
173
  */
169
174
  export declare function standaloneReference(block: RenderBlock): string | undefined;
170
175
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAkC,KAAK,WAAW,EAAkF,MAAM,aAAa,CAAA;AAC9J,OAAO,KAAK,E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,WAAW,EAAE,GAAG,MAAM,EAAE,CAUrE"}
package/dist/render.js CHANGED
@@ -233,6 +233,11 @@ export function renderTreeText(blocks) {
233
233
  * Whitespace around the reference does not change the answer — a pointer alone
234
234
  * on its line is alone on its line whether or not somebody left a space after
235
235
  * it.
236
+ *
237
+ * **For a block document (a description) only, since OPT-18.** In a message a
238
+ * reference reads as its chip wherever it sits, and a card comes only from the
239
+ * author's `embed` (§13.6.2). A description has no `embed` yet, so its readers
240
+ * still draw a reference alone on its line as a card until it can choose one.
236
241
  */
237
242
  export function standaloneReference(block) {
238
243
  if (block.type !== 'paragraph' || block.children?.length)
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAIL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAoD,kBAAkB,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAuF9J,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;AAElD,wCAAwC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAA;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACzE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAA;IAC9D,OAAO,QAAQ,KAAK,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;AAClE,CAAC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+1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/protocol",
3
- "version": "0.30.0",
3
+ "version": "0.32.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/embeds.ts ADDED
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Showing a reference as a card — SPEC §13.6.2 (OPT-16).
3
+ *
4
+ * `["embed", <value>, "compact" | "detailed" | "none"]` says how the author
5
+ * wants one reference in a message drawn: as a card under the message, and how
6
+ * much of it. `<value>` is what an `a` or `q` would carry for the same thing —
7
+ * an address or a 64-hex event id. The values are a density, not a widget
8
+ * name: `compact` is §7.5's closed `row` and `detailed` its closed `card`, so
9
+ * a richer card can come later without changing the wire.
10
+ *
11
+ * A reference with no `embed` is drawn by the reader's default (a chip, §13.1).
12
+ * An `embed` for a value overrides that default, which is why `none` exists:
13
+ * it is the author saying "no card" in an edit that replaces the set (§6.8).
14
+ *
15
+ * Like `part` (§13.6.1), the tags are only half the answer. A card is drawn
16
+ * only while the body — as edited — still names its value, and there is no
17
+ * `a`/`q` match: an edit carries no index tags (§6.8), and a value first named
18
+ * in an edit can still carry a card (Miky, 2026-10-13, OPT-16 kickoff).
19
+ * {@link cardsIn} applies that rule; {@link embedsOf} reads the tags alone.
20
+ */
21
+ import { addrToNaddr, bech32Decode, convertBits, decodeNevent, encodeNevent, naddrToAddr } from './nip19.js'
22
+ import type { PartPointer } from './anchors.js'
23
+ import type { RenderBlock, RenderInline } from './render.js'
24
+
25
+ export const EMBED_TAG = 'embed'
26
+
27
+ /** How much of a referenced object a card shows, or `none` for no card. */
28
+ export type EmbedLayout = 'compact' | 'detailed' | 'none'
29
+
30
+ /** One `embed` tag, read. */
31
+ export interface Embed {
32
+ /** An address (`kind:pubkey:d`) or a 64-hex event id, lowercase hex. */
33
+ value: string
34
+ layout: EmbedLayout
35
+ }
36
+
37
+ /** The `embed` tag for one reference. */
38
+ export function embedTag(value: string, layout: EmbedLayout): string[] {
39
+ return [EMBED_TAG, value, layout]
40
+ }
41
+
42
+ // `partsOf`'s shape: an empty `d` is a valid address (NIP-01).
43
+ const ADDRESS = /^\d+:[0-9a-f]{64}:/
44
+ const EVENT_ID = /^[0-9a-f]{64}$/
45
+
46
+ /**
47
+ * The `embed` tags on one event, one per value, in tag order.
48
+ *
49
+ * The first tag for a value wins. A layout this reader does not know draws as
50
+ * `compact` rather than nothing: the author asked for a card, and the smallest
51
+ * one is the safe reading of a density added after this reader was written. A
52
+ * value that is neither an address nor an event id is skipped.
53
+ *
54
+ * **This is the tags only**, of one event. For a message, fold its edits first
55
+ * (`foldEmbeds` in `@estiva-app/conversation`), then ask {@link cardsIn} which
56
+ * of them the body still names.
57
+ */
58
+ export function embedsOf(event: { tags: readonly (readonly string[])[] }): Embed[] {
59
+ const out: Embed[] = []
60
+ const seen = new Set<string>()
61
+ for (const tag of event.tags) {
62
+ if (tag[0] !== EMBED_TAG || !tag[1]) continue
63
+ const value = normalise(tag[1])
64
+ if (!value || seen.has(value)) continue
65
+ seen.add(value)
66
+ out.push({ value, layout: layoutOf(tag[2]) })
67
+ }
68
+ return out
69
+ }
70
+
71
+ function layoutOf(raw: string | undefined): EmbedLayout {
72
+ return raw === 'detailed' || raw === 'none' ? raw : 'compact'
73
+ }
74
+
75
+ function normalise(value: string): string | undefined {
76
+ if (EVENT_ID.test(value.toLowerCase())) return value.toLowerCase()
77
+ if (!ADDRESS.test(value)) return undefined
78
+ // The kind and pubkey are hex and compared as such; the `d` is the author's and kept as written.
79
+ const [kind, pubkey, ...d] = value.split(':')
80
+ return `${kind}:${pubkey.toLowerCase()}:${d.join(':')}`
81
+ }
82
+
83
+ /**
84
+ * What an app link names, as the reader resolved it by §7.7 — the host and the
85
+ * `<type>` segment against a published `urls` pattern, then the one author who
86
+ * holds that `d` — or undefined. Never a match on the link's trailing
87
+ * identifier alone: that resolves any site's URL as somebody's object, and puts
88
+ * a real issue's card under a link that does not open it (§7.7).
89
+ */
90
+ export type LinkResolver = (url: string) => string | undefined
91
+
92
+ const TRAILING = new Set(['.', ',', ';', ':', '!', '?', ')', ']'])
93
+ const URL_RUN = /https?:\/\/[^\s<>"'`]+/g
94
+
95
+ /** A URL run without the sentence's trailing punctuation; stripped by a loop, which stays linear on a hostile run of dots. */
96
+ function trimUrl(url: string): string {
97
+ let end = url.length
98
+ while (end > 0 && TRAILING.has(url[end - 1])) end--
99
+ return url.slice(0, end)
100
+ }
101
+
102
+ /** The http(s) links in a text. Trailing punctuation is the sentence's, not the link's. */
103
+ function urlsIn(text: string): string[] {
104
+ return (text.match(URL_RUN) ?? []).map(trimUrl)
105
+ }
106
+
107
+ /** The address or event id a `nostr:` reference names, or undefined for a person or something unreadable. */
108
+ function valueOfReference(reference: string): string | undefined {
109
+ const bare = reference.replace(/^nostr:/i, '').toLowerCase()
110
+ try {
111
+ if (bare.startsWith('naddr1')) return normalise(naddrToAddr(bare))
112
+ if (bare.startsWith('nevent1')) return decodeNevent(bare).id.toLowerCase()
113
+ if (bare.startsWith('note1')) {
114
+ const { hrp, data } = bech32Decode(bare)
115
+ if (hrp !== 'note') return undefined
116
+ const hex = convertBits(data, 5, 8, false).map((b) => b.toString(16).padStart(2, '0')).join('')
117
+ return EVENT_ID.test(hex) ? hex : undefined
118
+ }
119
+ } catch {
120
+ return undefined
121
+ }
122
+ return undefined
123
+ }
124
+
125
+ /**
126
+ * The cards a message asks for, in the order the body first names them.
127
+ *
128
+ * `embeds` is the message's folded set; `blocks` its folded body as a render
129
+ * tree; `parts` its `part` pointers (§13.6.1). A value appears here only while
130
+ * the body names it — by a `nostr:` reference, or by an app link that
131
+ * `resolveLink` resolves to it (§7.7) — and only when no `part` names the
132
+ * same address, because the live block already stands for that object. Text in
133
+ * a code span names nothing (§13.1). Without `resolveLink` a link names nothing:
134
+ * resolving one needs the manifests and the relay, which this package does not hold.
135
+ *
136
+ * `none` entries are kept: they draw no card, but they still override any
137
+ * default a reader has for that value. Filter them out to get the cards to draw.
138
+ */
139
+ export function cardsIn(embeds: readonly Embed[], blocks: readonly RenderBlock[], parts: readonly PartPointer[] = [], resolveLink?: LinkResolver): Embed[] {
140
+ if (embeds.length === 0) return []
141
+ const byValue = new Map(embeds.map((e) => [e.value, e]))
142
+ const withPart = new Set(parts.map((p) => normalise(p.address)).filter((v): v is string => !!v))
143
+ const out: Embed[] = []
144
+ const seen = new Set<string>()
145
+ const take = (value: string | undefined) => {
146
+ if (!value || seen.has(value) || withPart.has(value)) return
147
+ const embed = byValue.get(value)
148
+ if (!embed) return
149
+ seen.add(value)
150
+ out.push(embed)
151
+ }
152
+ // Adjacent plain runs are read as one text, so a link a mark splits in two is still one link.
153
+ const scan = (text: string) => {
154
+ if (!resolveLink || !text.includes('://')) return
155
+ for (const url of urlsIn(text)) {
156
+ const value = resolveLink(url)
157
+ if (value) take(normalise(value))
158
+ }
159
+ }
160
+ const walk = (bs: readonly RenderBlock[]) => {
161
+ for (const block of bs) {
162
+ if (block.type !== 'codeBlock') {
163
+ let text = ''
164
+ for (const run of block.inline ?? []) {
165
+ if (run.reference || run.marks.includes('code')) {
166
+ scan(text)
167
+ text = ''
168
+ if (run.reference) take(valueOfReference(run.reference))
169
+ } else text += run.text
170
+ }
171
+ scan(text)
172
+ }
173
+ if (block.children) walk(block.children)
174
+ }
175
+ }
176
+ walk(blocks)
177
+ return out
178
+ }
179
+
180
+ /**
181
+ * One pass over a run: a link on words, `[words](https://…)` as the marker
182
+ * format writes it (group 1 — its URL is the target of words the author chose),
183
+ * or a bare URL (group 2). The same alternation the ui package's `RichText`
184
+ * draws links by, so what is skipped here is what it draws as a link. Alone,
185
+ * the first alternative is quadratic on a run of `[a](https://x` with no space
186
+ * or `)`; the bare-URL alternative after it swallows the rest, so this stays
187
+ * linear (OPT-18's security review).
188
+ */
189
+ const LINK_OR_URL = /(\[[^[\]\n]+\]\((?:https?:\/\/|mailto:)[^\s)]+\))|(https?:\/\/[^\s<>"'`]+)/g
190
+
191
+ /**
192
+ * A message's tree with each bare app link turned into the reference it names,
193
+ * so a reader draws it as that object's chip (SPEC §13.6.2, OPT-18).
194
+ *
195
+ * A reference reads as a chip wherever it sits (§13.1), and a link some app
196
+ * claims (§7.7) is a reference written as a URL — the form a message has when
197
+ * it was written before the composer turned pasted links into chips, or by a
198
+ * client that does not. Without this, the two would read differently for no
199
+ * reason the reader can see.
200
+ *
201
+ * Left alone: a link on words (the author chose the words, and they stay a
202
+ * link; its card is the author's `embed`), a URL in code (§13.1: literal), and
203
+ * a link `resolveLink` does not answer — no app claims it, or the answer has
204
+ * not come back yet — which stays a link. The run keeps the URL as its text,
205
+ * so a reader that draws references as text shows what was written.
206
+ *
207
+ * Messages only: a description is a block document, whose links are not this
208
+ * function's business (§13.3).
209
+ */
210
+ export function linksAsReferences(blocks: readonly RenderBlock[], resolveLink: LinkResolver): RenderBlock[] {
211
+ const referenceOf = (url: string): string | undefined => {
212
+ const value = normalise(resolveLink(url) ?? '')
213
+ if (!value) return undefined
214
+ // An address no naddr can hold (a `d` over 255 bytes) stays a link rather than taking the message down with it.
215
+ try {
216
+ return `nostr:${EVENT_ID.test(value) ? encodeNevent({ id: value, relays: [] }) : addrToNaddr(value)}`
217
+ } catch {
218
+ return undefined
219
+ }
220
+ }
221
+ const split = (run: RenderInline): RenderInline[] => {
222
+ if (run.reference || run.marks.includes('code') || !run.text.includes('://')) return [run]
223
+ const out: RenderInline[] = []
224
+ let at = 0
225
+ for (const m of run.text.matchAll(LINK_OR_URL)) {
226
+ // A link on words: neither its target nor a URL in its words is taken.
227
+ if (m[1]) continue
228
+ const start = m.index
229
+ // A link on words whose words carry a mark arrives split across runs: its target follows `](`, and a URL as its words follows `[`.
230
+ if (run.text.slice(Math.max(0, start - 2), start) === '](' || run.text[start - 1] === '[') continue
231
+ const url = trimUrl(m[0])
232
+ const reference = referenceOf(url)
233
+ if (!reference) continue
234
+ if (start > at) out.push({ ...run, text: run.text.slice(at, start) })
235
+ out.push({ text: url, marks: run.marks, reference })
236
+ at = start + url.length
237
+ }
238
+ if (at === 0) return [run]
239
+ if (at < run.text.length) out.push({ ...run, text: run.text.slice(at) })
240
+ return out
241
+ }
242
+ // A block with nothing to turn is returned as it was, so a body without app links costs no copies.
243
+ const walk = (bs: readonly RenderBlock[]): RenderBlock[] =>
244
+ bs.map((block) => {
245
+ if (block.type === 'codeBlock') return block
246
+ const inline = block.inline?.flatMap(split)
247
+ const children = block.children && walk(block.children)
248
+ const unchanged = <T,>(next: readonly T[] | undefined, was: readonly T[] | undefined) =>
249
+ !next || (next.length === was?.length && next.every((x, i) => x === was[i]))
250
+ const same = unchanged(inline, block.inline) && unchanged(children, block.children)
251
+ return same ? block : { ...block, ...(inline ? { inline } : {}), ...(children ? { children } : {}) }
252
+ })
253
+ return walk(blocks)
254
+ }
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.30.0'
50
+ export const PROTOCOL_VERSION = '0.32.0'
51
51
 
52
52
  export {
53
53
  // types
@@ -259,6 +259,7 @@ export {
259
259
  resolveBlockAnchor,
260
260
  resolvePart,
261
261
  } from './anchors.js'
262
+ export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences } from './embeds.js'
262
263
  export {
263
264
  type BlossomVerb,
264
265
  type Imeta,
package/src/render.ts CHANGED
@@ -327,6 +327,11 @@ export function renderTreeText(blocks: readonly RenderBlock[]): string {
327
327
  * Whitespace around the reference does not change the answer — a pointer alone
328
328
  * on its line is alone on its line whether or not somebody left a space after
329
329
  * it.
330
+ *
331
+ * **For a block document (a description) only, since OPT-18.** In a message a
332
+ * reference reads as its chip wherever it sits, and a card comes only from the
333
+ * author's `embed` (§13.6.2). A description has no `embed` yet, so its readers
334
+ * still draw a reference alone on its line as a card until it can choose one.
330
335
  */
331
336
  export function standaloneReference(block: RenderBlock): string | undefined {
332
337
  if (block.type !== 'paragraph' || block.children?.length) return undefined