@estiva-app/conversation 0.15.0 → 0.16.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
@@ -6,6 +6,44 @@ none. A change to how an event is read is a MINOR in `0.x` even when no
6
6
  signature moved, because two apps on different versions would then disagree
7
7
  about a conversation.
8
8
 
9
+ ## 0.16.0 — 2026-10-19
10
+
11
+ **What a comment box shows under itself, for every app's box** (COMM-8; record
12
+ *a-link-on-words-counts-toward-the-card*). `boxReadOf(doc, context)` reads the
13
+ shared box's document as a send writes it and answers the one file that gets
14
+ its default card, the live `part` of each block link (one per file, at most
15
+ `MAX_PARTS`), and the URLs it names for the app's resolver to ask about.
16
+ `embedsToSend` / `embedsToEdit` / `withoutCard` / `namedBefore` are Peek's
17
+ `lib/boxCard.ts` rules, moved here so Leaf, and Ship on the shared box, write
18
+ the `embed` set as Peek does. One change from Peek's copy: a link to a block of
19
+ the file the conversation is on is its chip only and writes no `part` (Miky,
20
+ 2026-10-19).
21
+
22
+ **A link on words is sent.** `composerText` writes words carrying a `link`
23
+ mark — a URL pasted over them in the box — as `[words](url)`; until now the
24
+ block bridge wrote the words and dropped the link. Words holding a bracket, or
25
+ in code, keep their words only. `composerDocument` opens `[words](url)` as the
26
+ words with a `link` mark, so an edit shows the link as it was drawn.
27
+
28
+ Takes `@estiva-app/protocol` ≥ 0.40.0, where a link on words names its file.
29
+
30
+ SPEC: §13.6.1, §13.6.2 — no rule changed; this package now writes what they
31
+ already say, as Peek and Ship do.
32
+
33
+ ## 0.15.1 — 2026-10-19
34
+
35
+ **`-"…"` leaves a phrase out**, as the relay reads it (buzz#32).
36
+ `referenceMatch` drops a text that holds those whole words next to each other,
37
+ in order, so `remov -"short summary"` no longer finds *Remove Short summary…*
38
+ while `remov -"summary short"` still does. In 0.15.0 the `-` was dropped and
39
+ the phrase became one to find, the opposite. A `-"` whose quote has not closed
40
+ yet ends the query, so a phrase being typed to leave out never turns into
41
+ words to find, and a query of only `-"…"` matches nothing.
42
+
43
+ SPEC: §5.2 — no rule of §6 or §9 changed. §5.2's text does not name
44
+ `-"phrase"` or an unclosed `-"` yet; an estiva-docs follow-up adds both, and
45
+ until then buzz#32 and this package are where the rule is written down.
46
+
9
47
  ## 0.15.0 — 2026-10-19
10
48
 
11
49
  **Search matches every typed word as the start of a word** (record
package/README.md CHANGED
@@ -27,6 +27,7 @@ pass, the clock is a `createdAtMs` you pass, and drafts take their storage.
27
27
  | writing | §6.4, §13.6 | `buildComment`, `buildReply`, `placeOf`, `referenceTagsFor`, `mentionTagsFor` |
28
28
  | what a composer's pick writes | §13.1 | `mentionText`, `messageReference`, `urgentTagsFor`, `URGENT_TAG` |
29
29
  | what the shared comment box holds, as the message it writes, and back | §13.1 | `composerText`, `composerDocument`, `withoutNewUrgency`, `composerDraft` |
30
+ | what a box shows under itself while a comment is written: the one file's card and each block link's part, and the `embed` a send or an edit writes | §13.6.1, §13.6.2 | `boxReadOf`, `boxLinksOf`, `embedsToSend`, `embedsToEdit`, `namedBefore`, `withoutCard`, `linkTargetOf` |
30
31
  | what `[` offers, and in what order | §13.1 | `rankReferences`, `referenceMatch`, `fileReference`, `referenceSearch`, `MESSAGE_TIER`, `FILE_TIER`, `REFERENCE_CAPS` |
31
32
  | ordering | §6.2, §6.3 | `trustedTs`, `orderingMs`, `byOrder` |
32
33
  | edits and attachments | §6.8 | `editTargetOf`, `foldEdits`, `foldAttachments` |
@@ -0,0 +1,76 @@
1
+ /**
2
+ * What a comment box shows under itself, as it will be sent (SPEC §13.6.1,
3
+ * §13.6.2), for every app's box (COMM-8). Peek wrote this rule itself
4
+ * (`lib/boxCard.ts`) and Ship its copy (`lib/messageCard.ts`); it is here once
5
+ * so Leaf, and Ship on the shared box, read a draft as Peek does.
6
+ *
7
+ * - **One file's card.** When what is written names exactly one file, its
8
+ * default card, `["embed", V, "detailed"]`, by protocol's `defaultCardOf`:
9
+ * a Folder, a person, a message and the file the conversation is on do not
10
+ * count, a link on words counts by its target, and a plain web link counts
11
+ * for nothing. ✕ takes it off (the box's to keep).
12
+ * - **The live part of each block link**, as the `part` the message will
13
+ * carry, one per file. A part counts as its file and draws instead of a card,
14
+ * so linking an issue and a block of a page shows the block and no card. A
15
+ * link to a block of the conversation's own file is its chip only and
16
+ * writes no `part` (Miky, 2026-10-19).
17
+ *
18
+ * Read from the marker text the box would send, by the rules a reader draws it
19
+ * by, so what shows under the box is what shows under the message.
20
+ *
21
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
22
+ */
23
+ import { type EditorDocument, type EditorNode, type Embed, type LinkResolver, type PartPointer } from '@estiva-app/protocol';
24
+ /** At most this many blocks show live under one message (SPEC §13.6.1). */
25
+ export declare const MAX_PARTS = 6;
26
+ export interface BoxLinks {
27
+ /** Every address and event id the text names. */
28
+ values: string[];
29
+ /** The block links' parts, one per file, the first link's; none of the conversation's own file. */
30
+ parts: PartPointer[];
31
+ /** The file that gets the default card, before any ✕. */
32
+ card?: string;
33
+ /**
34
+ * Every URL the text names, bare or as a link's target, once each: what the
35
+ * app asks its resolver about, so an answer that comes back later reads again.
36
+ */
37
+ urls: string[];
38
+ }
39
+ export interface BoxLinkContext {
40
+ /** What an app link names for a card (§7.7), as answered so far. */
41
+ resolveLink: LinkResolver;
42
+ /** The file and block a link to one block names, as answered so far. */
43
+ blockOf: (url: string) => PartPointer | undefined;
44
+ /** The file whose conversation this is: it gets no card here, and its blocks no part. */
45
+ here?: string;
46
+ /** An edit's: the values the message named before it, which get no default again. */
47
+ previous?: readonly string[];
48
+ }
49
+ /**
50
+ * What an app link in the box draws as: the file or message it names, or, for
51
+ * a link to one block, its file (§13.6.1), so a pasted block link reads as its
52
+ * file's chip, the block live under the box.
53
+ */
54
+ export declare function linkTargetOf(url: string, context: Pick<BoxLinkContext, 'resolveLink' | 'blockOf'>): string | undefined;
55
+ /** What a marker text names, and the one file it gives the default card. */
56
+ export declare function boxLinksOf(text: string, context: BoxLinkContext): BoxLinks;
57
+ /** {@link boxLinksOf} of a composer's document (`CommentBox`'s JSON), read as {@link composerText} writes it. */
58
+ export declare function boxReadOf(doc: EditorDocument | EditorNode, context: BoxLinkContext): BoxLinks;
59
+ /**
60
+ * What a message named before an edit, for `defaultCardOf`'s `previous`: its
61
+ * values, and the file of each block link, which was named too.
62
+ */
63
+ export declare function namedBefore(text: string, context: Pick<BoxLinkContext, 'resolveLink' | 'blockOf'>): string[];
64
+ /** The `embed` set a new message sends: the default card, unless ✕ took it off. `none` is never written. */
65
+ export declare function embedsToSend(links: Pick<BoxLinks, 'card'>, removed: ReadonlySet<string>): Embed[];
66
+ /**
67
+ * The `embed` set an edit sends, or undefined to leave the message's as it
68
+ * was. Only an edit that names a file first adds its default (`links` read
69
+ * with `previous`), and then it carries the whole folded set with it, since a
70
+ * set replaces (§13.6.2). A card removed with ✕, before sending or after,
71
+ * stays removed.
72
+ */
73
+ export declare function embedsToEdit(links: Pick<BoxLinks, 'card'>, removed: ReadonlySet<string>, folded: readonly Embed[] | undefined): Embed[] | undefined;
74
+ /** ✕ on a sent message's card: the folded set, with that card `none` and every other kept. */
75
+ export declare function withoutCard(folded: readonly Embed[] | undefined, value: string): Embed[];
76
+ //# sourceMappingURL=boxCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boxCard.d.ts","sourceRoot":"","sources":["../src/boxCard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAG7B,2EAA2E;AAC3E,eAAO,MAAM,SAAS,IAAI,CAAA;AAE1B,MAAM,WAAW,QAAQ;IACvB,iDAAiD;IACjD,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,mGAAmG;IACnG,KAAK,EAAE,WAAW,EAAE,CAAA;I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,SAAS,GAAG,KAAK,EAAE,GAAG,SAAS,CAEnJ;AAED,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,CAExF"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * What a comment box shows under itself, as it will be sent (SPEC §13.6.1,
3
+ * §13.6.2), for every app's box (COMM-8). Peek wrote this rule itself
4
+ * (`lib/boxCard.ts`) and Ship its copy (`lib/messageCard.ts`); it is here once
5
+ * so Leaf, and Ship on the shared box, read a draft as Peek does.
6
+ *
7
+ * - **One file's card.** When what is written names exactly one file, its
8
+ * default card, `["embed", V, "detailed"]`, by protocol's `defaultCardOf`:
9
+ * a Folder, a person, a message and the file the conversation is on do not
10
+ * count, a link on words counts by its target, and a plain web link counts
11
+ * for nothing. ✕ takes it off (the box's to keep).
12
+ * - **The live part of each block link**, as the `part` the message will
13
+ * carry, one per file. A part counts as its file and draws instead of a card,
14
+ * so linking an issue and a block of a page shows the block and no card. A
15
+ * link to a block of the conversation's own file is its chip only and
16
+ * writes no `part` (Miky, 2026-10-19).
17
+ *
18
+ * Read from the marker text the box would send, by the rules a reader draws it
19
+ * by, so what shows under the box is what shows under the message.
20
+ *
21
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
22
+ */
23
+ import { defaultCardOf, toRenderTree, valuesIn, withCard, } from '@estiva-app/protocol';
24
+ import { composerText } from './composer.js';
25
+ /** At most this many blocks show live under one message (SPEC §13.6.1). */
26
+ export const MAX_PARTS = 6;
27
+ /**
28
+ * What an app link in the box draws as: the file or message it names, or, for
29
+ * a link to one block, its file (§13.6.1), so a pasted block link reads as its
30
+ * file's chip, the block live under the box.
31
+ */
32
+ export function linkTargetOf(url, context) {
33
+ return context.resolveLink(url) ?? context.blockOf(url)?.address;
34
+ }
35
+ /** What a marker text names, and the one file it gives the default card. */
36
+ export function boxLinksOf(text, context) {
37
+ // valuesIn asks the resolver about exactly the URLs a reader counts (not one
38
+ // in a code span, nor one in a link's words), so recording its questions
39
+ // gives the URLs without a second URL finder.
40
+ const urls = [];
41
+ const values = valuesIn(text ? toRenderTree(text, 'marker') : [], (url) => {
42
+ if (!urls.includes(url))
43
+ urls.push(url);
44
+ return context.resolveLink(url);
45
+ });
46
+ const parts = new Map();
47
+ for (const url of urls) {
48
+ const part = context.blockOf(url);
49
+ if (part && part.address !== context.here && !parts.has(part.address))
50
+ parts.set(part.address, part);
51
+ }
52
+ const kept = [...parts.values()].slice(0, MAX_PARTS);
53
+ const card = defaultCardOf(values, kept, { here: context.here, previous: context.previous });
54
+ return { values, parts: kept, card, urls };
55
+ }
56
+ /** {@link boxLinksOf} of a composer's document (`CommentBox`'s JSON), read as {@link composerText} writes it. */
57
+ export function boxReadOf(doc, context) {
58
+ return boxLinksOf(composerText(doc).text, context);
59
+ }
60
+ /**
61
+ * What a message named before an edit, for `defaultCardOf`'s `previous`: its
62
+ * values, and the file of each block link, which was named too.
63
+ */
64
+ export function namedBefore(text, context) {
65
+ const { values, urls } = boxLinksOf(text, context);
66
+ const files = urls.map((url) => context.blockOf(url)?.address).filter((v) => !!v);
67
+ return [...new Set([...values, ...files])];
68
+ }
69
+ /** The `embed` set a new message sends: the default card, unless ✕ took it off. `none` is never written. */
70
+ export function embedsToSend(links, removed) {
71
+ return links.card && !removed.has(links.card) ? [{ value: links.card, layout: 'detailed' }] : [];
72
+ }
73
+ /**
74
+ * The `embed` set an edit sends, or undefined to leave the message's as it
75
+ * was. Only an edit that names a file first adds its default (`links` read
76
+ * with `previous`), and then it carries the whole folded set with it, since a
77
+ * set replaces (§13.6.2). A card removed with ✕, before sending or after,
78
+ * stays removed.
79
+ */
80
+ export function embedsToEdit(links, removed, folded) {
81
+ return links.card && !removed.has(links.card) ? withCard(folded ?? [], links.card, 'detailed') : undefined;
82
+ }
83
+ /** ✕ on a sent message's card: the folded set, with that card `none` and every other kept. */
84
+ export function withoutCard(folded, value) {
85
+ return withCard(folded ?? [], value, 'none');
86
+ }
87
+ //# sourceMappingURL=boxCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boxCard.js","sourceRoot":"","sources":["../src/boxCard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,QAAQ,GAMT,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAA;AA2B1B;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,OAAwD;IAChG,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;AAClE,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAuB;IAC9D,6EAA6E;IAC7E,yEAAyE;IACzE,8CAA8C;IAC9C,MAAM,IAAI,GAAa,EAAE,CAAA;IACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;QACxE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACjC,CAAC,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC5C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC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G;AAC5G,MAAM,UAAU,YAAY,CAAC,KAA6B,EAAE,OAA4B;IACtF,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAClG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAA6B,EAAE,OAA4B,EAAE,MAAoC;IAC5H,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAC5G,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,WAAW,CAAC,MAAoC,EAAE,KAAa;IAC7E,OAAO,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC"}
@@ -53,7 +53,8 @@ export interface ComposerLabels {
53
53
  * tag, so marker text alone cannot say it); a message or a file becomes its
54
54
  * `captionedReference` chip. Whatever `labels` does not know stays the
55
55
  * `reference` it was, and so does one with marks or a card, which a chip
56
- * would lose.
56
+ * would lose. A link on words, `[words](url)`, opens as the words with a
57
+ * `link` mark, as the box drew it while it was written.
57
58
  */
58
59
  export declare function composerDocument(text: string, labels?: ComposerLabels, urgent?: readonly string[]): EditorDocument;
59
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"composer.d.ts","sourceRoot":"","sources":["../src/composer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAA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E,MAAM,GAAE,cAAmB,GAAG,aAAa,CAcxG"}
package/dist/composer.js CHANGED
@@ -25,6 +25,54 @@ const keyOf = (node) => {
25
25
  const pubkey = node.attrs?.pubkey;
26
26
  return typeof pubkey === 'string' && HEX_KEY.test(pubkey) ? pubkey : null;
27
27
  };
28
+ /**
29
+ * A link on words as the marker format writes it, `[words](url)`, and back:
30
+ * the same alternation protocol's `valuesIn` and ui's `RichText` read, so a
31
+ * URL starting earlier swallows a bracket inside it here as it does there.
32
+ * Words hold no bracket and no line break (COMM-8; Peek's rule).
33
+ */
34
+ const LINK_OR_URL = /(\[([^[\]\n]+)\]\(((?:https?:\/\/|mailto:)[^\s)]+)\))|(https?:\/\/[^\s<>"'`]+)/g;
35
+ const LINK_TARGET = /^(?:https?:\/\/|mailto:)[^\s)]+$/;
36
+ const LINK_WORDS = /^[^[\]\n]+$/;
37
+ const linkMarkOf = (node) => node.marks?.find((m) => m.type === 'link');
38
+ /**
39
+ * Words the box holds as a link (a URL pasted over them) written as
40
+ * `[words](url)`. The block bridge draws and writes no link on words, so
41
+ * without this the words would be sent and the link dropped. A link whose
42
+ * words are its URL is the URL itself; words that cannot be a marker link (a
43
+ * bracket, code) keep their words and lose the link, as the bridge did.
44
+ */
45
+ function linkOnWordsAsMarker(node) {
46
+ const link = linkMarkOf(node);
47
+ const href = link?.attrs?.href;
48
+ if (!link || node.text === undefined)
49
+ return node;
50
+ const marks = (node.marks ?? []).filter((m) => m !== link);
51
+ const kept = marks.length ? { marks } : {};
52
+ const written = typeof href === 'string' && node.text !== href && LINK_TARGET.test(href) && LINK_WORDS.test(node.text) && !marks.some((m) => m.type === 'code');
53
+ return { type: 'text', text: written ? `[${node.text}](${href})` : node.text, ...kept };
54
+ }
55
+ /** Marker text's `[words](url)` in a text node, as the words with a `link` mark the box draws; anything else as it was. */
56
+ function linksOnWordsAsMarks(node) {
57
+ const text = node.text ?? '';
58
+ if (!text.includes('](') || node.marks?.some((m) => m.type === 'code' || m.type === 'link'))
59
+ return [node];
60
+ const out = [];
61
+ let at = 0;
62
+ for (const m of text.matchAll(LINK_OR_URL)) {
63
+ if (!m[1])
64
+ continue;
65
+ if (m.index > at)
66
+ out.push({ ...node, text: text.slice(at, m.index) });
67
+ out.push({ ...node, text: m[2], marks: [...(node.marks ?? []), { type: 'link', attrs: { href: m[3] } }] });
68
+ at = m.index + m[0].length;
69
+ }
70
+ if (out.length === 0)
71
+ return [node];
72
+ if (at < text.length)
73
+ out.push({ ...node, text: text.slice(at) });
74
+ return out;
75
+ }
28
76
  /**
29
77
  * The chips as the block bridge can write them. `fromEditorDocument` knows a
30
78
  * `reference` and drops any inline node it does not, so a picked person would
@@ -32,6 +80,8 @@ const keyOf = (node) => {
32
80
  * names (§13.1), or `@Name` / `!@Name` for somebody with no key.
33
81
  */
34
82
  function chipsAsReferences(node) {
83
+ if (node.type === 'text')
84
+ return linkOnWordsAsMarker(node);
35
85
  if (node.type === 'mention' || node.type === 'urgentMention') {
36
86
  const pubkey = keyOf(node);
37
87
  const written = mentionText({ pubkey, label: String(node.attrs?.label ?? '') }, node.type === 'urgentMention');
@@ -84,7 +134,8 @@ const plainReference = (node) => {
84
134
  * tag, so marker text alone cannot say it); a message or a file becomes its
85
135
  * `captionedReference` chip. Whatever `labels` does not know stays the
86
136
  * `reference` it was, and so does one with marks or a card, which a chip
87
- * would lose.
137
+ * would lose. A link on words, `[words](url)`, opens as the words with a
138
+ * `link` mark, as the box drew it while it was written.
88
139
  */
89
140
  export function composerDocument(text, labels = {}, urgent) {
90
141
  const keys = new Set(urgent ?? []);
@@ -109,7 +160,7 @@ export function composerDocument(text, labels = {}, urgent) {
109
160
  return { type: 'captionedReference', attrs: { id: uri, label: caption.label, snippet: caption.snippet, uri } };
110
161
  return node;
111
162
  }
112
- return node.content ? { ...node, content: node.content.map(walk) } : node;
163
+ return node.content ? { ...node, content: node.content.flatMap((child) => (child.type === 'text' ? linksOnWordsAsMarks(child) : [walk(child)])) } : node;
113
164
  };
114
165
  return walk(toEditorDocument(documentForEditing(text, 'marker')));
115
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"composer.js","sourceRoot":"","sources":["../src/composer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GAGjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAU1C,MAAM,OAAO,GAAG,gBAAgB,CAAA;AAEhC,MAAM,KAAK,GAAG,CAAC,IAAgB,EAAiB,EAAE;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,CAAA;IACjC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;AAC3E,CAAC,CAAA;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,IAAgB;IACzC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;QAC1B,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;QAC9G,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAClG,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAo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,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAA;AAChH,CAAC;AAWD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB,EAAE,GAAW,EAAE,SAAyB,EAAE;IACvF,OAAO;QACL,IAAI;YACF,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YAClC,OAAO,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACpG,CAAC;QACD,KAAK,CAAC,GAAG;YACP,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;YAC1C,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QAChC,CAAC;QACD,KAAK;YACH,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export declare const CONVERSATION_VERSION = "0.15.0";
15
+ export declare const CONVERSATION_VERSION = "0.16.0";
16
16
  export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
17
17
  export { trustedTs, orderingMs, byOrder } from './order.js';
18
18
  export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, type Strength, } from './strength.js';
@@ -23,6 +23,7 @@ export { decorationsOf, type Decoration, type Decorations, type Resolution, type
23
23
  export { buildComment, buildReply, offersEditAndDelete, placeOf, type CommentRef } from './builders.js';
24
24
  export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js';
25
25
  export { composerDocument, composerDraft, composerText, withoutNewUrgency, type ComposerDraft, type ComposerLabels, type ComposerText, } from './composer.js';
26
+ export { MAX_PARTS, boxLinksOf, boxReadOf, embedsToEdit, embedsToSend, linkTargetOf, namedBefore, withoutCard, type BoxLinkContext, type BoxLinks, } from './boxCard.js';
26
27
  export { FILE_TIER, fileReference, MESSAGE_TIER, rankReferences, REFERENCE_CAPS, referenceMatch, referenceSearch, refMatch, type RankedReferences, type RankReferencesInput, type ReferenceCandidate, type ReferenceSearch, type ReferenceSearchFn, type ReferenceSearchOptions, type ReferenceType, } from './references.js';
27
28
  export { KIND_CHANGE, MEMBER_FIELD_PREFIX, memberField, memberOfField, mentions, streamOf, membershipOf, membersOf, membershipFilters, candidateFilesOf, buildMembershipChange, MUTED_D_TAG, APPDATA_TAG, parseMutedBlob, serializeMutedBlob, buildMutedEvent, mutedFilter, mutedFromFollowed, type Membership, type MutedList, } from './membership.js';
28
29
  export { READ_STATE_TAG, READ_STATE_D_PREFIX, MAX_CONTEXTS, MAX_CONTEXT_ID_BYTES, MAX_TIMESTAMP, MAX_CLIENT_ID_BYTES, MAX_BLOB_BYTES, MAX_CONTEXTS_BYTES, READ_STATE_HORIZON_DAYS, channelContext, fileContext, threadContext, messageContext, toContextSeconds, isPublishableContextId, loadSlotIdentity, rotateSlotId, readStateDTag, parseReadStateBlob, serializeReadStateBlob, capContextsToBytes, capReadStateContexts, THREAD_RULE_FROM, REPLY_FLOOR_CONTEXT, advanceContexts, buildReadStateEvent, allSlotsFilter, mergeSlots, classifyOwnSlots, effectiveReadAt, threadReadAt, belowReplyFloor, fetchReadState, createSlotCache, publishReadState, type SlotCache, type SlotIdentity, type SlotStorage, type SlotSource, type RandomBytes, type ReadStateBlob, type CappedContexts, type SlotBlob, type OwnSlotVerdict, type Nip44, type FetchedReadState, } from './readState.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE/G,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAElH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,OAAO,EAAE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iB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export const CONVERSATION_VERSION = '0.15.0';
15
+ export const CONVERSATION_VERSION = '0.16.0';
16
16
  export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
17
17
  export { trustedTs, orderingMs, byOrder } from './order.js';
18
18
  export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, } from './strength.js';
@@ -23,6 +23,7 @@ export { decorationsOf } from './decorations.js';
23
23
  export { buildComment, buildReply, offersEditAndDelete, placeOf } from './builders.js';
24
24
  export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js';
25
25
  export { composerDocument, composerDraft, composerText, withoutNewUrgency, } from './composer.js';
26
+ export { MAX_PARTS, boxLinksOf, boxReadOf, embedsToEdit, embedsToSend, linkTargetOf, namedBefore, withoutCard, } from './boxCard.js';
26
27
  export { FILE_TIER, fileReference, MESSAGE_TIER, rankReferences, REFERENCE_CAPS, referenceMatch, referenceSearch, refMatch, } from './references.js';
27
28
  export { KIND_CHANGE, MEMBER_FIELD_PREFIX, memberField, memberOfField, mentions, streamOf, membershipOf, membersOf, membershipFilters, candidateFilesOf, buildMembershipChange, MUTED_D_TAG, APPDATA_TAG, parseMutedBlob, serializeMutedBlob, buildMutedEvent, mutedFilter, mutedFromFollowed, } from './membership.js';
28
29
  export { READ_STATE_TAG, READ_STATE_D_PREFIX, MAX_CONTEXTS, MAX_CONTEXT_ID_BYTES, MAX_TIMESTAMP, MAX_CLIENT_ID_BYTES, MAX_BLOB_BYTES, MAX_CONTEXTS_BYTES, READ_STATE_HORIZON_DAYS, channelContext, fileContext, threadContext, messageContext, toContextSeconds, isPublishableContextId, loadSlotIdentity, rotateSlotId, readStateDTag, parseReadStateBlob, serializeReadStateBlob, capContextsToBytes, capReadStateContexts, THREAD_RULE_FROM, REPLY_FLOOR_CONTEXT, advanceContexts, buildReadStateEvent, allSlotsFilter, mergeSlots, classifyOwnSlots, effectiveReadAt, threadReadAt, belowReplyFloor, fetchReadState, createSlotCache, publishReadState, } from './readState.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GAErB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAiB,MAAM,cAAc,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAiB,MAAM,YAAY,CAAA;AAE/G,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,cAAc,GAIf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAoE,MAAM,kBAAkB,CAAA;AAElH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,OAAO,EAAmB,MAAM,eAAe,CAAA;AAEvG,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAExH,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,iBAAiB,GAIlB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,eAAe,EACf,QAAQ,GAQT,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,iBAAiB,GAGlB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,GAYjB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QA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EACd,eAAe,EACf,QAAQ,GAQT,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,iBAAiB,GAGlB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,GAYjB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
@@ -73,7 +73,8 @@ export interface RankReferencesInput {
73
73
  * How well `text` holds `query`, by the rule every Estiva search uses (SPEC
74
74
  * §5.2): each typed word matches the start of a word, in any order; `"…"`
75
75
  * matches those whole words next to each other; `-word` leaves out a text with
76
- * a word starting that way. Punctuation at a typed word's ends is ignored, and
76
+ * a word starting that way, and `-"…"` one with those whole words next to each
77
+ * other. Punctuation at a typed word's ends is ignored, and
77
78
  * so is case. A query with nothing to find but words left out matches nothing.
78
79
  *
79
80
  * Of the texts that match, a hit where every typed word is a whole word ranks
@@ -1 +1 @@
1
- {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAuBA,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;AAElF,+BAA+B;AAC/B,MAAM,WAAW,kBAAkB;IACjC,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAA;IACV,iGAAiG;IACjG,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,aAAa,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAA;IACZ,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gFAAgF;IAChF,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,mEAAmE;AACnE,eAAO,MAAM,YAAY;;;CAAkC,CAAA;AAE3D,+EAA+E;AAC/E,eAAO,MAAM,SAAS;;;;CAA+C,CAAA;AAErE,mGAAmG;AACnG,eAAO,MAAM,cAAc;;;CAAqC,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,EAAE,CAAA;IAC9B,KAAK,EAAE,kBAAkB,EAAE,CAAA;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACvC,KAAK,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACpC,gC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G,MAAM,IAAI,CAAA;IAC3C;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAAA;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,iBAAiB,CAAA;IACzB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,OAAa,EAAE,OAAc,EAAE,SAAa,EAAE,EAAE,sBAAsB,GAAG,eAAe,CAgFjI"}
@@ -32,14 +32,26 @@ const isWordStart = (text, at) => at === 0 || !/[\p{L}\p{N}]/u.test(text[at - 1]
32
32
  const wordsOf = (text) => text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
33
33
  /**
34
34
  * Splits typed text as the relay does (buzz's `parse_word_start`): `"…"` is a
35
- * phrase, a word opening with `-` is left out, anything else is a word, `or`
36
- * and `key:value` included. A quote with no closing partner is ignored, so
37
- * `"short summ` finds by word starts while it is typed.
35
+ * phrase, `-"…"` a phrase left out, a word opening with `-` is left out,
36
+ * anything else is a word, `or` and `key:value` included. A quote with no
37
+ * closing partner is ignored, so `"short summ` finds by word starts while it
38
+ * is typed; after `-"` it ends the query, so a phrase being typed to leave out
39
+ * never turns into words to find.
38
40
  */
39
41
  function searchTerms(query) {
40
42
  const terms = [];
41
43
  let rest = query;
42
44
  while ((rest = rest.trimStart())) {
45
+ if (rest.startsWith('-"')) {
46
+ const end = rest.indexOf('"', 2);
47
+ if (end < 0)
48
+ break;
49
+ const phrase = rest.slice(2, end).trim();
50
+ if (wordsOf(phrase).length > 0)
51
+ terms.push({ kind: 'notPhrase', text: phrase });
52
+ rest = rest.slice(end + 1);
53
+ continue;
54
+ }
43
55
  if (rest.startsWith('"')) {
44
56
  const end = rest.indexOf('"', 1);
45
57
  if (end > 0) {
@@ -83,7 +95,8 @@ const holdsPhrase = (words, phrase) => {
83
95
  * How well `text` holds `query`, by the rule every Estiva search uses (SPEC
84
96
  * §5.2): each typed word matches the start of a word, in any order; `"…"`
85
97
  * matches those whole words next to each other; `-word` leaves out a text with
86
- * a word starting that way. Punctuation at a typed word's ends is ignored, and
98
+ * a word starting that way, and `-"…"` one with those whole words next to each
99
+ * other. Punctuation at a typed word's ends is ignored, and
87
100
  * so is case. A query with nothing to find but words left out matches nothing.
88
101
  *
89
102
  * Of the texts that match, a hit where every typed word is a whole word ranks
@@ -104,7 +117,8 @@ export function referenceMatch(text, query) {
104
117
  return 0;
105
118
  const words = wordsOf(text);
106
119
  const holds = (t) => (t.kind === 'phrase' ? holdsPhrase(words, t.text) : startsWords(words, t.text));
107
- if (!wanted.every(holds) || terms.some((t) => t.kind === 'not' && startsWords(words, t.text)))
120
+ const leftOut = (t) => (t.kind === 'not' && startsWords(words, t.text)) || (t.kind === 'notPhrase' && holdsPhrase(words, t.text));
121
+ if (!wanted.every(holds) || terms.some(leftOut))
108
122
  return 0;
109
123
  const whole = wanted.every((w) => w.kind === 'phrase' || wordsOf(w.text).every((piece) => words.includes(piece))) ? 4 : 0;
110
124
  const t = normalize(text);
@@ -118,8 +132,8 @@ export function referenceMatch(text, query) {
118
132
  return whole + 2;
119
133
  return whole + 1;
120
134
  }
121
- /** The terms that ask for something: words and phrases with a letter or digit, not words left out. */
122
- const wantedOf = (terms) => terms.filter((t) => t.kind !== 'not' && wordsOf(t.text).length > 0);
135
+ /** The terms that ask for something: words and phrases with a letter or digit, not what is left out. */
136
+ const wantedOf = (terms) => terms.filter((t) => (t.kind === 'word' || t.kind === 'phrase') && wordsOf(t.text).length > 0);
123
137
  /**
124
138
  * Whether a longer query's answer is within `query`'s: it asks for a word and
125
139
  * no quote is still open, since closing it can turn `"x -y` (y left out) into
@@ -1 +1 @@
1
- {"version":3,"file":"references.js","sourceRoot":"","sources":["../src/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vB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACzC,CAAC;QACD,KAAK;YACH,MAAM,EAAE,CAAA;YACR,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,QAAQ,CAAC,KAAK,EAAE,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/conversation",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "The conversation rules of the Estiva SPEC (§6.2–§6.8, §11): comment and mention strengths, threading, the edit, reaction and attachment folds, NIP-22 comment and reply builders, drafts, NIP-RS read state, membership and unread. A convenience an app adopts, never a requirement.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,10 +47,10 @@
47
47
  "prepublishOnly": "npm run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "@estiva-app/protocol": ">=0.31.0"
50
+ "@estiva-app/protocol": ">=0.40.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@estiva-app/protocol": ">=0.31.0",
53
+ "@estiva-app/protocol": ">=0.40.0",
54
54
  "typescript": "~5.9.3"
55
55
  }
56
56
  }
package/src/boxCard.ts ADDED
@@ -0,0 +1,127 @@
1
+ /**
2
+ * What a comment box shows under itself, as it will be sent (SPEC §13.6.1,
3
+ * §13.6.2), for every app's box (COMM-8). Peek wrote this rule itself
4
+ * (`lib/boxCard.ts`) and Ship its copy (`lib/messageCard.ts`); it is here once
5
+ * so Leaf, and Ship on the shared box, read a draft as Peek does.
6
+ *
7
+ * - **One file's card.** When what is written names exactly one file, its
8
+ * default card, `["embed", V, "detailed"]`, by protocol's `defaultCardOf`:
9
+ * a Folder, a person, a message and the file the conversation is on do not
10
+ * count, a link on words counts by its target, and a plain web link counts
11
+ * for nothing. ✕ takes it off (the box's to keep).
12
+ * - **The live part of each block link**, as the `part` the message will
13
+ * carry, one per file. A part counts as its file and draws instead of a card,
14
+ * so linking an issue and a block of a page shows the block and no card. A
15
+ * link to a block of the conversation's own file is its chip only and
16
+ * writes no `part` (Miky, 2026-10-19).
17
+ *
18
+ * Read from the marker text the box would send, by the rules a reader draws it
19
+ * by, so what shows under the box is what shows under the message.
20
+ *
21
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
22
+ */
23
+ import {
24
+ defaultCardOf,
25
+ toRenderTree,
26
+ valuesIn,
27
+ withCard,
28
+ type EditorDocument,
29
+ type EditorNode,
30
+ type Embed,
31
+ type LinkResolver,
32
+ type PartPointer,
33
+ } from '@estiva-app/protocol'
34
+ import { composerText } from './composer.js'
35
+
36
+ /** At most this many blocks show live under one message (SPEC §13.6.1). */
37
+ export const MAX_PARTS = 6
38
+
39
+ export interface BoxLinks {
40
+ /** Every address and event id the text names. */
41
+ values: string[]
42
+ /** The block links' parts, one per file, the first link's; none of the conversation's own file. */
43
+ parts: PartPointer[]
44
+ /** The file that gets the default card, before any ✕. */
45
+ card?: string
46
+ /**
47
+ * Every URL the text names, bare or as a link's target, once each: what the
48
+ * app asks its resolver about, so an answer that comes back later reads again.
49
+ */
50
+ urls: string[]
51
+ }
52
+
53
+ export interface BoxLinkContext {
54
+ /** What an app link names for a card (§7.7), as answered so far. */
55
+ resolveLink: LinkResolver
56
+ /** The file and block a link to one block names, as answered so far. */
57
+ blockOf: (url: string) => PartPointer | undefined
58
+ /** The file whose conversation this is: it gets no card here, and its blocks no part. */
59
+ here?: string
60
+ /** An edit's: the values the message named before it, which get no default again. */
61
+ previous?: readonly string[]
62
+ }
63
+
64
+ /**
65
+ * What an app link in the box draws as: the file or message it names, or, for
66
+ * a link to one block, its file (§13.6.1), so a pasted block link reads as its
67
+ * file's chip, the block live under the box.
68
+ */
69
+ export function linkTargetOf(url: string, context: Pick<BoxLinkContext, 'resolveLink' | 'blockOf'>): string | undefined {
70
+ return context.resolveLink(url) ?? context.blockOf(url)?.address
71
+ }
72
+
73
+ /** What a marker text names, and the one file it gives the default card. */
74
+ export function boxLinksOf(text: string, context: BoxLinkContext): BoxLinks {
75
+ // valuesIn asks the resolver about exactly the URLs a reader counts (not one
76
+ // in a code span, nor one in a link's words), so recording its questions
77
+ // gives the URLs without a second URL finder.
78
+ const urls: string[] = []
79
+ const values = valuesIn(text ? toRenderTree(text, 'marker') : [], (url) => {
80
+ if (!urls.includes(url)) urls.push(url)
81
+ return context.resolveLink(url)
82
+ })
83
+ const parts = new Map<string, PartPointer>()
84
+ for (const url of urls) {
85
+ const part = context.blockOf(url)
86
+ if (part && part.address !== context.here && !parts.has(part.address)) parts.set(part.address, part)
87
+ }
88
+ const kept = [...parts.values()].slice(0, MAX_PARTS)
89
+ const card = defaultCardOf(values, kept, { here: context.here, previous: context.previous })
90
+ return { values, parts: kept, card, urls }
91
+ }
92
+
93
+ /** {@link boxLinksOf} of a composer's document (`CommentBox`'s JSON), read as {@link composerText} writes it. */
94
+ export function boxReadOf(doc: EditorDocument | EditorNode, context: BoxLinkContext): BoxLinks {
95
+ return boxLinksOf(composerText(doc).text, context)
96
+ }
97
+
98
+ /**
99
+ * What a message named before an edit, for `defaultCardOf`'s `previous`: its
100
+ * values, and the file of each block link, which was named too.
101
+ */
102
+ export function namedBefore(text: string, context: Pick<BoxLinkContext, 'resolveLink' | 'blockOf'>): string[] {
103
+ const { values, urls } = boxLinksOf(text, context)
104
+ const files = urls.map((url) => context.blockOf(url)?.address).filter((v): v is string => !!v)
105
+ return [...new Set([...values, ...files])]
106
+ }
107
+
108
+ /** The `embed` set a new message sends: the default card, unless ✕ took it off. `none` is never written. */
109
+ export function embedsToSend(links: Pick<BoxLinks, 'card'>, removed: ReadonlySet<string>): Embed[] {
110
+ return links.card && !removed.has(links.card) ? [{ value: links.card, layout: 'detailed' }] : []
111
+ }
112
+
113
+ /**
114
+ * The `embed` set an edit sends, or undefined to leave the message's as it
115
+ * was. Only an edit that names a file first adds its default (`links` read
116
+ * with `previous`), and then it carries the whole folded set with it, since a
117
+ * set replaces (§13.6.2). A card removed with ✕, before sending or after,
118
+ * stays removed.
119
+ */
120
+ export function embedsToEdit(links: Pick<BoxLinks, 'card'>, removed: ReadonlySet<string>, folded: readonly Embed[] | undefined): Embed[] | undefined {
121
+ return links.card && !removed.has(links.card) ? withCard(folded ?? [], links.card, 'detailed') : undefined
122
+ }
123
+
124
+ /** ✕ on a sent message's card: the folded set, with that card `none` and every other kept. */
125
+ export function withoutCard(folded: readonly Embed[] | undefined, value: string): Embed[] {
126
+ return withCard(folded ?? [], value, 'none')
127
+ }
package/src/composer.ts CHANGED
@@ -44,6 +44,52 @@ const keyOf = (node: EditorNode): string | null => {
44
44
  return typeof pubkey === 'string' && HEX_KEY.test(pubkey) ? pubkey : null
45
45
  }
46
46
 
47
+ /**
48
+ * A link on words as the marker format writes it, `[words](url)`, and back:
49
+ * the same alternation protocol's `valuesIn` and ui's `RichText` read, so a
50
+ * URL starting earlier swallows a bracket inside it here as it does there.
51
+ * Words hold no bracket and no line break (COMM-8; Peek's rule).
52
+ */
53
+ const LINK_OR_URL = /(\[([^[\]\n]+)\]\(((?:https?:\/\/|mailto:)[^\s)]+)\))|(https?:\/\/[^\s<>"'`]+)/g
54
+ const LINK_TARGET = /^(?:https?:\/\/|mailto:)[^\s)]+$/
55
+ const LINK_WORDS = /^[^[\]\n]+$/
56
+
57
+ const linkMarkOf = (node: EditorNode) => node.marks?.find((m) => m.type === 'link')
58
+
59
+ /**
60
+ * Words the box holds as a link (a URL pasted over them) written as
61
+ * `[words](url)`. The block bridge draws and writes no link on words, so
62
+ * without this the words would be sent and the link dropped. A link whose
63
+ * words are its URL is the URL itself; words that cannot be a marker link (a
64
+ * bracket, code) keep their words and lose the link, as the bridge did.
65
+ */
66
+ function linkOnWordsAsMarker(node: EditorNode): EditorNode {
67
+ const link = linkMarkOf(node)
68
+ const href = link?.attrs?.href
69
+ if (!link || node.text === undefined) return node
70
+ const marks = (node.marks ?? []).filter((m) => m !== link)
71
+ const kept = marks.length ? { marks } : {}
72
+ const written = typeof href === 'string' && node.text !== href && LINK_TARGET.test(href) && LINK_WORDS.test(node.text) && !marks.some((m) => m.type === 'code')
73
+ return { type: 'text', text: written ? `[${node.text}](${href})` : node.text, ...kept }
74
+ }
75
+
76
+ /** Marker text's `[words](url)` in a text node, as the words with a `link` mark the box draws; anything else as it was. */
77
+ function linksOnWordsAsMarks(node: EditorNode): EditorNode[] {
78
+ const text = node.text ?? ''
79
+ if (!text.includes('](') || node.marks?.some((m) => m.type === 'code' || m.type === 'link')) return [node]
80
+ const out: EditorNode[] = []
81
+ let at = 0
82
+ for (const m of text.matchAll(LINK_OR_URL)) {
83
+ if (!m[1]) continue
84
+ if (m.index > at) out.push({ ...node, text: text.slice(at, m.index) })
85
+ out.push({ ...node, text: m[2], marks: [...(node.marks ?? []), { type: 'link', attrs: { href: m[3] } }] })
86
+ at = m.index + m[0].length
87
+ }
88
+ if (out.length === 0) return [node]
89
+ if (at < text.length) out.push({ ...node, text: text.slice(at) })
90
+ return out
91
+ }
92
+
47
93
  /**
48
94
  * The chips as the block bridge can write them. `fromEditorDocument` knows a
49
95
  * `reference` and drops any inline node it does not, so a picked person would
@@ -51,6 +97,7 @@ const keyOf = (node: EditorNode): string | null => {
51
97
  * names (§13.1), or `@Name` / `!@Name` for somebody with no key.
52
98
  */
53
99
  function chipsAsReferences(node: EditorNode): EditorNode {
100
+ if (node.type === 'text') return linkOnWordsAsMarker(node)
54
101
  if (node.type === 'mention' || node.type === 'urgentMention') {
55
102
  const pubkey = keyOf(node)
56
103
  const written = mentionText({ pubkey, label: String(node.attrs?.label ?? '') }, node.type === 'urgentMention')
@@ -110,7 +157,8 @@ const plainReference = (node: EditorNode): string | null => {
110
157
  * tag, so marker text alone cannot say it); a message or a file becomes its
111
158
  * `captionedReference` chip. Whatever `labels` does not know stays the
112
159
  * `reference` it was, and so does one with marks or a card, which a chip
113
- * would lose.
160
+ * would lose. A link on words, `[words](url)`, opens as the words with a
161
+ * `link` mark, as the box drew it while it was written.
114
162
  */
115
163
  export function composerDocument(text: string, labels: ComposerLabels = {}, urgent?: readonly string[]): EditorDocument {
116
164
  const keys = new Set(urgent ?? [])
@@ -132,7 +180,7 @@ export function composerDocument(text: string, labels: ComposerLabels = {}, urge
132
180
  if (caption) return { type: 'captionedReference', attrs: { id: uri, label: caption.label, snippet: caption.snippet, uri } }
133
181
  return node
134
182
  }
135
- return node.content ? { ...node, content: node.content.map(walk) } : node
183
+ return node.content ? { ...node, content: node.content.flatMap((child) => (child.type === 'text' ? linksOnWordsAsMarks(child) : [walk(child)])) } : node
136
184
  }
137
185
  return walk(toEditorDocument(documentForEditing(text, 'marker')) as EditorNode) as EditorDocument
138
186
  }
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export const CONVERSATION_VERSION = '0.15.0'
15
+ export const CONVERSATION_VERSION = '0.16.0'
16
16
 
17
17
  export {
18
18
  KIND_MESSAGE,
@@ -76,6 +76,19 @@ export {
76
76
  type ComposerText,
77
77
  } from './composer.js'
78
78
 
79
+ export {
80
+ MAX_PARTS,
81
+ boxLinksOf,
82
+ boxReadOf,
83
+ embedsToEdit,
84
+ embedsToSend,
85
+ linkTargetOf,
86
+ namedBefore,
87
+ withoutCard,
88
+ type BoxLinkContext,
89
+ type BoxLinks,
90
+ } from './boxCard.js'
91
+
79
92
  export {
80
93
  FILE_TIER,
81
94
  fileReference,
package/src/references.ts CHANGED
@@ -93,22 +93,32 @@ const isWordStart = (text: string, at: number) => at === 0 || !/[\p{L}\p{N}]/u.t
93
93
  /** The words of `text`: its runs of letters and digits, so `SUM-7.` is `sum`, `7`. */
94
94
  const wordsOf = (text: string): string[] => text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []
95
95
 
96
- /** One piece of a typed query: a word, `"a phrase"`, or `-a word` left out. */
96
+ /** One piece of a typed query: a word, `"a phrase"`, `-a word` or `-"a phrase"` left out. */
97
97
  interface SearchTerm {
98
- kind: 'word' | 'phrase' | 'not'
98
+ kind: 'word' | 'phrase' | 'not' | 'notPhrase'
99
99
  text: string
100
100
  }
101
101
 
102
102
  /**
103
103
  * Splits typed text as the relay does (buzz's `parse_word_start`): `"…"` is a
104
- * phrase, a word opening with `-` is left out, anything else is a word, `or`
105
- * and `key:value` included. A quote with no closing partner is ignored, so
106
- * `"short summ` finds by word starts while it is typed.
104
+ * phrase, `-"…"` a phrase left out, a word opening with `-` is left out,
105
+ * anything else is a word, `or` and `key:value` included. A quote with no
106
+ * closing partner is ignored, so `"short summ` finds by word starts while it
107
+ * is typed; after `-"` it ends the query, so a phrase being typed to leave out
108
+ * never turns into words to find.
107
109
  */
108
110
  function searchTerms(query: string): SearchTerm[] {
109
111
  const terms: SearchTerm[] = []
110
112
  let rest = query
111
113
  while ((rest = rest.trimStart())) {
114
+ if (rest.startsWith('-"')) {
115
+ const end = rest.indexOf('"', 2)
116
+ if (end < 0) break
117
+ const phrase = rest.slice(2, end).trim()
118
+ if (wordsOf(phrase).length > 0) terms.push({ kind: 'notPhrase', text: phrase })
119
+ rest = rest.slice(end + 1)
120
+ continue
121
+ }
112
122
  if (rest.startsWith('"')) {
113
123
  const end = rest.indexOf('"', 1)
114
124
  if (end > 0) {
@@ -146,7 +156,8 @@ const holdsPhrase = (words: readonly string[], phrase: string) => {
146
156
  * How well `text` holds `query`, by the rule every Estiva search uses (SPEC
147
157
  * §5.2): each typed word matches the start of a word, in any order; `"…"`
148
158
  * matches those whole words next to each other; `-word` leaves out a text with
149
- * a word starting that way. Punctuation at a typed word's ends is ignored, and
159
+ * a word starting that way, and `-"…"` one with those whole words next to each
160
+ * other. Punctuation at a typed word's ends is ignored, and
150
161
  * so is case. A query with nothing to find but words left out matches nothing.
151
162
  *
152
163
  * Of the texts that match, a hit where every typed word is a whole word ranks
@@ -166,7 +177,9 @@ export function referenceMatch(text: string, query: string): number {
166
177
  if (wanted.length === 0) return 0
167
178
  const words = wordsOf(text)
168
179
  const holds = (t: SearchTerm) => (t.kind === 'phrase' ? holdsPhrase(words, t.text) : startsWords(words, t.text))
169
- if (!wanted.every(holds) || terms.some((t) => t.kind === 'not' && startsWords(words, t.text))) return 0
180
+ const leftOut = (t: SearchTerm) =>
181
+ (t.kind === 'not' && startsWords(words, t.text)) || (t.kind === 'notPhrase' && holdsPhrase(words, t.text))
182
+ if (!wanted.every(holds) || terms.some(leftOut)) return 0
170
183
  const whole = wanted.every((w) => w.kind === 'phrase' || wordsOf(w.text).every((piece) => words.includes(piece))) ? 4 : 0
171
184
  const t = normalize(text)
172
185
  const q = normalize(wanted.map((w) => w.text.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, '')).join(' '))
@@ -176,8 +189,9 @@ export function referenceMatch(text: string, query: string): number {
176
189
  return whole + 1
177
190
  }
178
191
 
179
- /** The terms that ask for something: words and phrases with a letter or digit, not words left out. */
180
- const wantedOf = (terms: readonly SearchTerm[]) => terms.filter((t) => t.kind !== 'not' && wordsOf(t.text).length > 0)
192
+ /** The terms that ask for something: words and phrases with a letter or digit, not what is left out. */
193
+ const wantedOf = (terms: readonly SearchTerm[]) =>
194
+ terms.filter((t) => (t.kind === 'word' || t.kind === 'phrase') && wordsOf(t.text).length > 0)
181
195
 
182
196
  /**
183
197
  * Whether a longer query's answer is within `query`'s: it asks for a word and