@estiva-app/conversation 0.19.0 → 0.21.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,29 @@ 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.21.0 — 2026-10-27
10
+
11
+ **Wire behaviour: nothing changes** (PEEKM-7). The composer reads `[words](url)`
12
+ by protocol's `linksOnWordsOf` instead of its own copy of the pattern; the
13
+ words and links it writes are byte for byte as before. Needs protocol 0.45.
14
+
15
+ ## 0.20.0 — 2026-10-27
16
+
17
+ **Who `@` offers, and a comment's opening words, once for every app**
18
+ (PEEKM-6; record *a-conversation-is-one-shared-thing-and-only-its-colours-are-the-apps*).
19
+ `namedProfilesOf`, `rosterOf` and `mentionablePeople` map the relay's NIP-43
20
+ roster (`kind:13534`) and each key's `kind:0` into the people `@` and `!@`
21
+ offer: the roster's named profiles, agents included, never the viewer, by
22
+ name ignoring case and accents (`byName`). `openingWords` is a message's
23
+ caption on one line, as `[`'s row for a comment shows it: marks and line
24
+ prefixes gone, a link as its words, a person as `@Name`, and any other
25
+ reference by its type word ("Issue", "Message", "File") so it is never blank
26
+ (SPEC §13.1). Peek, Ship and Leaf each had their own copy, and Ship's and
27
+ Leaf's dropped a reference and kept a link's raw `[words](url)`.
28
+
29
+ SPEC: none changed. These read §13.1's references and NIP-43's roster as
30
+ before; they only move the reading into one place.
31
+
9
32
  ## 0.19.0 — 2026-10-27
10
33
 
11
34
  **An edit with no files takes every file off** (SPEC §6.8 as amended in
@@ -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;AAE7B,OAAO,KAA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AAmB,GAAG,aAAa,CAcxG"}
package/dist/composer.js CHANGED
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/every-app-writes-and-reacts-with-one-shared-box.md
20
20
  */
21
- import { blockDocumentToMarkerText, decodeNpub, documentForEditing, fromEditorDocument, toEditorDocument, } from '@estiva-app/protocol';
21
+ import { blockDocumentToMarkerText, decodeNpub, documentForEditing, fromEditorDocument, linksOnWordsOf, toEditorDocument, } from '@estiva-app/protocol';
22
22
  import { mentionText } from './compose.js';
23
23
  const HEX_KEY = /^[0-9a-f]{64}$/;
24
24
  const keyOf = (node) => {
@@ -26,12 +26,11 @@ const keyOf = (node) => {
26
26
  return typeof pubkey === 'string' && HEX_KEY.test(pubkey) ? pubkey : null;
27
27
  };
28
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).
29
+ * A link on words as the marker format writes it, `[words](url)`, and back.
30
+ * Read by protocol's `linksOnWordsOf`, the rule `valuesIn` and ui's `RichText`
31
+ * read by, so a URL starting earlier swallows a bracket inside it here as it
32
+ * does there. Words hold no bracket and no line break (COMM-8; Peek's rule).
33
33
  */
34
- const LINK_OR_URL = /(\[([^[\]\n]+)\]\(((?:https?:\/\/|mailto:)[^\s)]+)\))|(https?:\/\/[^\s<>"'`]+)/g;
35
34
  const LINK_TARGET = /^(?:https?:\/\/|mailto:)[^\s)]+$/;
36
35
  const LINK_WORDS = /^[^[\]\n]+$/;
37
36
  const linkMarkOf = (node) => node.marks?.find((m) => m.type === 'link');
@@ -59,13 +58,11 @@ function linksOnWordsAsMarks(node) {
59
58
  return [node];
60
59
  const out = [];
61
60
  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;
61
+ for (const link of linksOnWordsOf(text)) {
62
+ if (link.from > at)
63
+ out.push({ ...node, text: text.slice(at, link.from) });
64
+ out.push({ ...node, text: link.words, marks: [...(node.marks ?? []), { type: 'link', attrs: { href: link.url } }] });
65
+ at = link.to;
69
66
  }
70
67
  if (out.length === 0)
71
68
  return [node];
@@ -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,MAAM,WAAW,GAAG,iFAAiF,CAAA;AACrG,MAAM,WAAW,GAAG,kCAAkC,CAAA;AACtD,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,UAAU,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;AAEnF;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,IAAgB;IAC3C,MAAM,IA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AK,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.19.0";
15
+ export declare const CONVERSATION_VERSION = "0.21.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';
@@ -29,5 +29,7 @@ export { KIND_CHANGE, MEMBER_FIELD_PREFIX, memberField, memberOfField, mentions,
29
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';
30
30
  export { unreadIn, isUnread, type StreamJudge } from './unread.js';
31
31
  export { peopleNamedInText, newlyNamedPeople, mentionAddsFor, type FileText } from './textMentions.js';
32
+ export { KIND_MEMBERSHIP_LIST, namedProfilesOf, rosterOf, byName, mentionablePeople, type NamedProfile } from './people.js';
33
+ export { openingWords, referenceWord } from './openingWords.js';
32
34
  export { createDraftStore, draftKeys, NO_DRAFTS, DRAFT_MAX_AGE_MS, DRAFT_MAX_CHARS, type Draft, type DraftStore, type DraftStorage, } from './drafts.js';
33
35
  //# sourceMappingURL=index.d.ts.map
@@ -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,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K,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,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEtG,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA"}
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,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,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,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEtG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAE3H,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE/D,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.19.0';
15
+ export const CONVERSATION_VERSION = '0.21.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';
@@ -29,5 +29,7 @@ export { KIND_CHANGE, MEMBER_FIELD_PREFIX, memberField, memberOfField, mentions,
29
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';
30
30
  export { unreadIn, isUnread } from './unread.js';
31
31
  export { peopleNamedInText, newlyNamedPeople, mentionAddsFor } from './textMentions.js';
32
+ export { KIND_MEMBERSHIP_LIST, namedProfilesOf, rosterOf, byName, mentionablePeople } from './people.js';
33
+ export { openingWords, referenceWord } from './openingWords.js';
32
34
  export { createDraftStore, draftKeys, NO_DRAFTS, DRAFT_MAX_AGE_MS, DRAFT_MAX_CHARS, } from './drafts.js';
33
35
  //# 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;;;;;;;;;;;;;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,CA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Aa,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,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAiB,MAAM,mBAAmB,CAAA;AAEtG,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,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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c,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,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAiB,MAAM,mBAAmB,CAAA;AAEtG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAA;AAE3H,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,5 @@
1
+ /** What a `nostr:` reference reads as in a caption, by its kind alone, or a person by name. */
2
+ export declare function referenceWord(uri: string, nameOf: (pubkey: string) => string | undefined): string;
3
+ /** A message body's opening words on one line, as a caption: see the module's note. */
4
+ export declare function openingWords(body: string, nameOf: (pubkey: string) => string | undefined): string;
5
+ //# sourceMappingURL=openingWords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openingWords.d.ts","sourceRoot":"","sources":["../src/openingWords.ts"],"names":[],"mappings":"AAuCA,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,MAAM,CAoBjG;AAiBD,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG,MAAM,CAQjG"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * A message's opening words, as a caption — what `[`'s row for a comment
3
+ * shows under its author, the same in every app (PEEKM-6).
4
+ *
5
+ * One line of plain words: marks and line prefixes gone, a link on words as
6
+ * its words, a fenced code block's fences dropped. A `nostr:` reference reads
7
+ * as its chip would without resolving anything (SPEC §13.1: "the URI's own
8
+ * label or its shortened form, never blank"):
9
+ *
10
+ * - a person as `@Name`, or `@` and the key's shortened form when nobody here
11
+ * can name them;
12
+ * - a message as "Message", a file by its type word ("Issue", "Project",
13
+ * "Topic", "Document"), any other address as "File" — never by its title,
14
+ * so the same comment reads the same in an app that has the file loaded and
15
+ * one that does not (Miky, 27 October, PEEKM-6's kickoff).
16
+ *
17
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-conversation-is-one-shared-thing-and-only-its-colours-are-the-apps.md
18
+ */
19
+ import { decodeNpub, parseInlineMarks, referenceToPointer } from '@estiva-app/protocol';
20
+ /** A file's type word by its kind, as `[`'s Files rows name it. */
21
+ const TYPE_WORDS = { 30850: 'Project', 30851: 'Issue', 30840: 'Topic', 30842: 'Document', 39000: 'Folder' };
22
+ const FENCE = /^\s*(?:```|~~~)/;
23
+ /** A line's block prefixes: quotes and headings, then one list or task marker. */
24
+ const LINE_PREFIX = /^\s*(?:(?:>|#{1,6})\s+)*(?:(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?)?/;
25
+ /**
26
+ * A link on words, `[words](url)`: its words are what a reader sees. Swapped before the marks are read, so a `_` in a
27
+ * URL is never one. The grammar is protocol's `parseInlineMarksAndLinks`, so what reads as a link here is what a reader
28
+ * draws as one: a URL with an unclosed `(` (`…/Foo_(bar)`) is no link there, and stays as written here.
29
+ */
30
+ const LINK_ON_WORDS = /(?<!!)\[([^[\]\n]+)\]\(((?:https?:\/\/|mailto:)[^\s)]+)\)/g;
31
+ const linkWords = (whole, words, url) => (url.split('(').length > url.split(')').length ? whole : words);
32
+ /** The shortened form §13.1 asks for when a reference names nobody here. */
33
+ function shortened(uri) {
34
+ return `${uri.replace(/^nostr:/i, '').slice(0, 12)}…`;
35
+ }
36
+ /** What a `nostr:` reference reads as in a caption, by its kind alone, or a person by name. */
37
+ export function referenceWord(uri, nameOf) {
38
+ const bare = uri.replace(/^nostr:/i, '').toLowerCase();
39
+ if (bare.startsWith('npub1')) {
40
+ let name;
41
+ try {
42
+ name = nameOf(decodeNpub(bare));
43
+ }
44
+ catch {
45
+ name = undefined;
46
+ }
47
+ return `@${name || shortened(uri)}`;
48
+ }
49
+ if (bare.startsWith('naddr1')) {
50
+ try {
51
+ return TYPE_WORDS[referenceToPointer(bare).kind] ?? 'File';
52
+ }
53
+ catch {
54
+ return 'File';
55
+ }
56
+ }
57
+ if (bare.startsWith('nevent1') || bare.startsWith('note1'))
58
+ return 'Message';
59
+ return `@${shortened(uri)}`;
60
+ }
61
+ /**
62
+ * One line's words. Protocol's mark reader recurses once per mark, so a line of a few thousand (anyone can post one)
63
+ * overflows the stack; that line then reads as its text with the marker characters dropped, rather than taking down
64
+ * every `[` list that captions it (Peek: Feedback & Bugs 4acb43ac is the reader's own fix).
65
+ */
66
+ function lineWords(line, nameOf) {
67
+ try {
68
+ return parseInlineMarks(line)
69
+ .map((span) => (span.reference ? referenceWord(span.reference, nameOf) : span.text))
70
+ .join('');
71
+ }
72
+ catch {
73
+ return line.replace(/[*_~`]+/g, '');
74
+ }
75
+ }
76
+ /** A message body's opening words on one line, as a caption: see the module's note. */
77
+ export function openingWords(body, nameOf) {
78
+ return body
79
+ .split('\n')
80
+ .filter((line) => !FENCE.test(line))
81
+ .map((line) => lineWords(line.replace(LINE_PREFIX, '').replace(LINK_ON_WORDS, linkWords), nameOf))
82
+ .join(' ')
83
+ .replace(/\s+/g,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X,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;SACjG,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAA;AACX,CAAC"}
@@ -0,0 +1,48 @@
1
+ /** NIP-43's relay membership list. */
2
+ export declare const KIND_MEMBERSHIP_LIST = 13534;
3
+ /** A named profile: what `@`'s row draws, and what a mention of the key reads as. */
4
+ export interface NamedProfile {
5
+ pubkey: string;
6
+ name: string;
7
+ picture?: string;
8
+ /** NIP-24's `bot: true`, an agent's profile. Present only when true. */
9
+ bot?: true;
10
+ }
11
+ type ProfileEvent = {
12
+ kind: number;
13
+ pubkey: string;
14
+ created_at: number;
15
+ content: string;
16
+ id?: string;
17
+ };
18
+ type RosterEvent = {
19
+ kind: number;
20
+ created_at: number;
21
+ tags: string[][];
22
+ id?: string;
23
+ };
24
+ /**
25
+ * Every named profile, newest `kind:0` per key, as protocol's `parseProfile`
26
+ * reads one. Not narrowed to the roster: this answers "what is this key
27
+ * called", which a mention of the viewer, or of someone who has left, still
28
+ * needs answered.
29
+ */
30
+ export declare function namedProfilesOf(events: readonly ProfileEvent[]): Map<string, NamedProfile>;
31
+ /** The newest roster's members, or `null` when the relay keeps no roster. */
32
+ export declare function rosterOf(events: readonly RosterEvent[]): Set<string> | null;
33
+ /** By name, ignoring case and accents: "anna" sits beside "Anna", "Émile" beside "Emile". */
34
+ export declare function byName(a: {
35
+ name: string;
36
+ }, b: {
37
+ name: string;
38
+ }): number;
39
+ /**
40
+ * Whom `@` and `!@` offer: the named profiles on the roster, never the viewer,
41
+ * by name. With no roster (a relay that keeps none), every named profile given.
42
+ */
43
+ export declare function mentionablePeople<P extends {
44
+ pubkey: string;
45
+ name: string;
46
+ }>(profiles: Iterable<P>, roster: ReadonlySet<string> | null, me: string | null | undefined): P[];
47
+ export {};
48
+ //# sourceMappingURL=people.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../src/people.ts"],"names":[],"mappings":"AAmBA,sCAAsC;AACtC,eAAO,MAAM,oBAAoB,QAAQ,CAAA;AAEzC,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wEAAwE;IACxE,GAAG,CAAC,EAAE,IAAI,CAAA;CACX;AAED,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACtG,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAOtF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAe1F;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAI3E;AAED,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEvE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAC1E,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,EAClC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC5B,CAAC,EAAE,CAEL"}
package/dist/people.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Who `@` and `!@` offer in a comment box — one list of people in every app
3
+ * (PEEKM-6; Miky, 20 October: "There is one set of people").
4
+ *
5
+ * The workspace's people are two relay facts: the relay's NIP-43 roster
6
+ * (`kind:13534`, one `member` tag per admitted key) and each key's profile
7
+ * (`kind:0`). `@` offers the roster's keys that have a named profile, agents
8
+ * included (mentioning one is how you ask it something), never the viewer,
9
+ * by name. A roster key with no named profile is left out: the roster also
10
+ * lists keys that are not people (an app's manifest key), and a shortened key
11
+ * is nobody a person can pick.
12
+ *
13
+ * Each app still reads the events its own way; this only maps them, so the
14
+ * same events give the same list, in the same order, everywhere.
15
+ *
16
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-conversation-is-one-shared-thing-and-only-its-colours-are-the-apps.md
17
+ */
18
+ import { parseProfile } from '@estiva-app/protocol';
19
+ /** NIP-43's relay membership list. */
20
+ export const KIND_MEMBERSHIP_LIST = 13534;
21
+ /** Newer first; on the same second, the lowest id (NIP-01), so every app picks the same one whatever order its events came in. */
22
+ function newerFirst(a, b) {
23
+ return b.created_at - a.created_at || (a.id ?? '').localeCompare(b.id ?? '');
24
+ }
25
+ /**
26
+ * Every named profile, newest `kind:0` per key, as protocol's `parseProfile`
27
+ * reads one. Not narrowed to the roster: this answers "what is this key
28
+ * called", which a mention of the viewer, or of someone who has left, still
29
+ * needs answered.
30
+ */
31
+ export function namedProfilesOf(events) {
32
+ const newest = new Map();
33
+ for (const e of events) {
34
+ if (e.kind !== 0)
35
+ continue;
36
+ const seen = newest.get(e.pubkey);
37
+ if (!seen || newerFirst(e, seen) < 0)
38
+ newest.set(e.pubkey, e);
39
+ }
40
+ const out = new Map();
41
+ for (const [pubkey, event] of newest) {
42
+ const { displayName, picture, bot } = parseProfile(event);
43
+ const name = displayName?.trim() ? displayName : undefined;
44
+ if (!name)
45
+ continue;
46
+ out.set(pubkey, { pubkey, name, ...(picture ? { picture } : {}), ...(bot ? { bot } : {}) });
47
+ }
48
+ return out;
49
+ }
50
+ /** The newest roster's members, or `null` when the relay keeps no roster. */
51
+ export function rosterOf(events) {
52
+ const roster = events.filter((e) => e.kind === KIND_MEMBERSHIP_LIST).sort(newerFirst)[0];
53
+ if (!roster)
54
+ return null;
55
+ return new Set(roster.tags.filter((t) => (t[0] === 'member' || t[0] === 'p') && /^[0-9a-f]{64}$/.test(t[1] ?? '')).map((t) => t[1]));
56
+ }
57
+ /** By name, ignoring case and accents: "anna" sits beside "Anna", "Émile" beside "Emile". */
58
+ export function byName(a, b) {
59
+ return a.name.localeCompare(b.name, undefined, { sensitivity: 'base' });
60
+ }
61
+ /**
62
+ * Whom `@` and `!@` offer: the named profiles on the roster, never the viewer,
63
+ * by name. With no roster (a relay that keeps none), every named profile given.
64
+ */
65
+ export function mentionablePeople(profiles, roster, me) {
66
+ return [...profiles].filter((p) => p.pubkey !== me && p.name.trim() !== '' && (!roster || roster.has(p.pubkey))).sort(byName);
67
+ }
68
+ //# sourceMappingURL=people.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"people.js","sourceRoot":"","sources":["../src/people.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,sCAAsC;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAczC,kIAAkI;AAClI,S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AC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC/H,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/conversation",
3
- "version": "0.19.0",
3
+ "version": "0.21.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.42.0"
50
+ "@estiva-app/protocol": ">=0.45.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@estiva-app/protocol": ">=0.42.0",
53
+ "@estiva-app/protocol": ">=0.45.0",
54
54
  "typescript": "~5.9.3"
55
55
  }
56
56
  }
package/src/composer.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  decodeNpub,
24
24
  documentForEditing,
25
25
  fromEditorDocument,
26
+ linksOnWordsOf,
26
27
  toEditorDocument,
27
28
  type EditorDocument,
28
29
  type EditorNode,
@@ -45,12 +46,11 @@ const keyOf = (node: EditorNode): string | null => {
45
46
  }
46
47
 
47
48
  /**
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).
49
+ * A link on words as the marker format writes it, `[words](url)`, and back.
50
+ * Read by protocol's `linksOnWordsOf`, the rule `valuesIn` and ui's `RichText`
51
+ * read by, so a URL starting earlier swallows a bracket inside it here as it
52
+ * does there. Words hold no bracket and no line break (COMM-8; Peek's rule).
52
53
  */
53
- const LINK_OR_URL = /(\[([^[\]\n]+)\]\(((?:https?:\/\/|mailto:)[^\s)]+)\))|(https?:\/\/[^\s<>"'`]+)/g
54
54
  const LINK_TARGET = /^(?:https?:\/\/|mailto:)[^\s)]+$/
55
55
  const LINK_WORDS = /^[^[\]\n]+$/
56
56
 
@@ -79,11 +79,10 @@ function linksOnWordsAsMarks(node: EditorNode): EditorNode[] {
79
79
  if (!text.includes('](') || node.marks?.some((m) => m.type === 'code' || m.type === 'link')) return [node]
80
80
  const out: EditorNode[] = []
81
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
82
+ for (const link of linksOnWordsOf(text)) {
83
+ if (link.from > at) out.push({ ...node, text: text.slice(at, link.from) })
84
+ out.push({ ...node, text: link.words, marks: [...(node.marks ?? []), { type: 'link', attrs: { href: link.url } }] })
85
+ at = link.to
87
86
  }
88
87
  if (out.length === 0) return [node]
89
88
  if (at < text.length) out.push({ ...node, text: text.slice(at) })
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.19.0'
15
+ export const CONVERSATION_VERSION = '0.21.0'
16
16
 
17
17
  export {
18
18
  KIND_MESSAGE,
@@ -183,6 +183,10 @@ export { unreadIn, isUnread, type StreamJudge } from './unread.js'
183
183
 
184
184
  export { peopleNamedInText, newlyNamedPeople, mentionAddsFor, type FileText } from './textMentions.js'
185
185
 
186
+ export { KIND_MEMBERSHIP_LIST, namedProfilesOf, rosterOf, byName, mentionablePeople, type NamedProfile } from './people.js'
187
+
188
+ export { openingWords, referenceWord } from './openingWords.js'
189
+
186
190
  export {
187
191
  createDraftStore,
188
192
  draftKeys,
@@ -0,0 +1,87 @@
1
+ /**
2
+ * A message's opening words, as a caption — what `[`'s row for a comment
3
+ * shows under its author, the same in every app (PEEKM-6).
4
+ *
5
+ * One line of plain words: marks and line prefixes gone, a link on words as
6
+ * its words, a fenced code block's fences dropped. A `nostr:` reference reads
7
+ * as its chip would without resolving anything (SPEC §13.1: "the URI's own
8
+ * label or its shortened form, never blank"):
9
+ *
10
+ * - a person as `@Name`, or `@` and the key's shortened form when nobody here
11
+ * can name them;
12
+ * - a message as "Message", a file by its type word ("Issue", "Project",
13
+ * "Topic", "Document"), any other address as "File" — never by its title,
14
+ * so the same comment reads the same in an app that has the file loaded and
15
+ * one that does not (Miky, 27 October, PEEKM-6's kickoff).
16
+ *
17
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-conversation-is-one-shared-thing-and-only-its-colours-are-the-apps.md
18
+ */
19
+ import { decodeNpub, parseInlineMarks, referenceToPointer } from '@estiva-app/protocol'
20
+
21
+ /** A file's type word by its kind, as `[`'s Files rows name it. */
22
+ const TYPE_WORDS: Record<number, string> = { 30850: 'Project', 30851: 'Issue', 30840: 'Topic', 30842: 'Document', 39000: 'Folder' }
23
+
24
+ const FENCE = /^\s*(?:```|~~~)/
25
+ /** A line's block prefixes: quotes and headings, then one list or task marker. */
26
+ const LINE_PREFIX = /^\s*(?:(?:>|#{1,6})\s+)*(?:(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?)?/
27
+ /**
28
+ * A link on words, `[words](url)`: its words are what a reader sees. Swapped before the marks are read, so a `_` in a
29
+ * URL is never one. The grammar is protocol's `parseInlineMarksAndLinks`, so what reads as a link here is what a reader
30
+ * draws as one: a URL with an unclosed `(` (`…/Foo_(bar)`) is no link there, and stays as written here.
31
+ */
32
+ const LINK_ON_WORDS = /(?<!!)\[([^[\]\n]+)\]\(((?:https?:\/\/|mailto:)[^\s)]+)\)/g
33
+ const linkWords = (whole: string, words: string, url: string) => (url.split('(').length > url.split(')').length ? whole : words)
34
+
35
+ /** The shortened form §13.1 asks for when a reference names nobody here. */
36
+ function shortened(uri: string): string {
37
+ return `${uri.replace(/^nostr:/i, '').slice(0, 12)}…`
38
+ }
39
+
40
+ /** What a `nostr:` reference reads as in a caption, by its kind alone, or a person by name. */
41
+ export function referenceWord(uri: string, nameOf: (pubkey: string) => string | undefined): string {
42
+ const bare = uri.replace(/^nostr:/i, '').toLowerCase()
43
+ if (bare.startsWith('npub1')) {
44
+ let name: string | undefined
45
+ try {
46
+ name = nameOf(decodeNpub(bare))
47
+ } catch {
48
+ name = undefined
49
+ }
50
+ return `@${name || shortened(uri)}`
51
+ }
52
+ if (bare.startsWith('naddr1')) {
53
+ try {
54
+ return TYPE_WORDS[referenceToPointer(bare).kind] ?? 'File'
55
+ } catch {
56
+ return 'File'
57
+ }
58
+ }
59
+ if (bare.startsWith('nevent1') || bare.startsWith('note1')) return 'Message'
60
+ return `@${shortened(uri)}`
61
+ }
62
+
63
+ /**
64
+ * One line's words. Protocol's mark reader recurses once per mark, so a line of a few thousand (anyone can post one)
65
+ * overflows the stack; that line then reads as its text with the marker characters dropped, rather than taking down
66
+ * every `[` list that captions it (Peek: Feedback & Bugs 4acb43ac is the reader's own fix).
67
+ */
68
+ function lineWords(line: string, nameOf: (pubkey: string) => string | undefined): string {
69
+ try {
70
+ return parseInlineMarks(line)
71
+ .map((span) => (span.reference ? referenceWord(span.reference, nameOf) : span.text))
72
+ .join('')
73
+ } catch {
74
+ return line.replace(/[*_~`]+/g, '')
75
+ }
76
+ }
77
+
78
+ /** A message body's opening words on one line, as a caption: see the module's note. */
79
+ export function openingWords(body: string, nameOf: (pubkey: string) => string | undefined): string {
80
+ return body
81
+ .split('\n')
82
+ .filter((line) => !FENCE.test(line))
83
+ .map((line) => lineWords(line.replace(LINE_PREFIX, '').replace(LINK_ON_WORDS, linkWords), nameOf))
84
+ .join(' ')
85
+ .replace(/\s+/g, ' ')
86
+ .trim()
87
+ }
package/src/people.ts ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Who `@` and `!@` offer in a comment box — one list of people in every app
3
+ * (PEEKM-6; Miky, 20 October: "There is one set of people").
4
+ *
5
+ * The workspace's people are two relay facts: the relay's NIP-43 roster
6
+ * (`kind:13534`, one `member` tag per admitted key) and each key's profile
7
+ * (`kind:0`). `@` offers the roster's keys that have a named profile, agents
8
+ * included (mentioning one is how you ask it something), never the viewer,
9
+ * by name. A roster key with no named profile is left out: the roster also
10
+ * lists keys that are not people (an app's manifest key), and a shortened key
11
+ * is nobody a person can pick.
12
+ *
13
+ * Each app still reads the events its own way; this only maps them, so the
14
+ * same events give the same list, in the same order, everywhere.
15
+ *
16
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-conversation-is-one-shared-thing-and-only-its-colours-are-the-apps.md
17
+ */
18
+ import { parseProfile } from '@estiva-app/protocol'
19
+
20
+ /** NIP-43's relay membership list. */
21
+ export const KIND_MEMBERSHIP_LIST = 13534
22
+
23
+ /** A named profile: what `@`'s row draws, and what a mention of the key reads as. */
24
+ export interface NamedProfile {
25
+ pubkey: string
26
+ name: string
27
+ picture?: string
28
+ /** NIP-24's `bot: true`, an agent's profile. Present only when true. */
29
+ bot?: true
30
+ }
31
+
32
+ type ProfileEvent = { kind: number; pubkey: string; created_at: number; content: string; id?: string }
33
+ type RosterEvent = { kind: number; created_at: number; tags: string[][]; id?: string }
34
+
35
+ /** Newer first; on the same second, the lowest id (NIP-01), so every app picks the same one whatever order its events came in. */
36
+ function newerFirst(a: { created_at: number; id?: string }, b: { created_at: number; id?: string }): number {
37
+ return b.created_at - a.created_at || (a.id ?? '').localeCompare(b.id ?? '')
38
+ }
39
+
40
+ /**
41
+ * Every named profile, newest `kind:0` per key, as protocol's `parseProfile`
42
+ * reads one. Not narrowed to the roster: this answers "what is this key
43
+ * called", which a mention of the viewer, or of someone who has left, still
44
+ * needs answered.
45
+ */
46
+ export function namedProfilesOf(events: readonly ProfileEvent[]): Map<string, NamedProfile> {
47
+ const newest = new Map<string, ProfileEvent>()
48
+ for (const e of events) {
49
+ if (e.kind !== 0) continue
50
+ const seen = newest.get(e.pubkey)
51
+ if (!seen || newerFirst(e, seen) < 0) newest.set(e.pubkey, e)
52
+ }
53
+ const out = new Map<string, NamedProfile>()
54
+ for (const [pubkey, event] of newest) {
55
+ const { displayName, picture, bot } = parseProfile(event)
56
+ const name = displayName?.trim() ? displayName : undefined
57
+ if (!name) continue
58
+ out.set(pubkey, { pubkey, name, ...(picture ? { picture } : {}), ...(bot ? { bot } : {}) })
59
+ }
60
+ return out
61
+ }
62
+
63
+ /** The newest roster's members, or `null` when the relay keeps no roster. */
64
+ export function rosterOf(events: readonly RosterEvent[]): Set<string> | null {
65
+ const roster = events.filter((e) => e.kind === KIND_MEMBERSHIP_LIST).sort(newerFirst)[0]
66
+ if (!roster) return null
67
+ return new Set(roster.tags.filter((t) => (t[0] === 'member' || t[0] === 'p') && /^[0-9a-f]{64}$/.test(t[1] ?? '')).map((t) => t[1]))
68
+ }
69
+
70
+ /** By name, ignoring case and accents: "anna" sits beside "Anna", "Émile" beside "Emile". */
71
+ export function byName(a: { name: string }, b: { name: string }): number {
72
+ return a.name.localeCompare(b.name, undefined, { sensitivity: 'base' })
73
+ }
74
+
75
+ /**
76
+ * Whom `@` and `!@` offer: the named profiles on the roster, never the viewer,
77
+ * by name. With no roster (a relay that keeps none), every named profile given.
78
+ */
79
+ export function mentionablePeople<P extends { pubkey: string; name: string }>(
80
+ profiles: Iterable<P>,
81
+ roster: ReadonlySet<string> | null,
82
+ me: string | null | undefined,
83
+ ): P[] {
84
+ return [...profiles].filter((p) => p.pubkey !== me && p.name.trim() !== '' && (!roster || roster.has(p.pubkey))).sort(byName)
85
+ }