@estiva-app/conversation 0.19.0 → 0.20.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 +17 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/openingWords.d.ts +5 -0
- package/dist/openingWords.d.ts.map +1 -0
- package/dist/openingWords.js +86 -0
- package/dist/openingWords.js.map +1 -0
- package/dist/people.d.ts +48 -0
- package/dist/people.d.ts.map +1 -0
- package/dist/people.js +68 -0
- package/dist/people.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/openingWords.ts +87 -0
- package/src/people.ts +85 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,23 @@ 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.20.0 — 2026-10-27
|
|
10
|
+
|
|
11
|
+
**Who `@` offers, and a comment's opening words, once for every app**
|
|
12
|
+
(PEEKM-6; record *a-conversation-is-one-shared-thing-and-only-its-colours-are-the-apps*).
|
|
13
|
+
`namedProfilesOf`, `rosterOf` and `mentionablePeople` map the relay's NIP-43
|
|
14
|
+
roster (`kind:13534`) and each key's `kind:0` into the people `@` and `!@`
|
|
15
|
+
offer: the roster's named profiles, agents included, never the viewer, by
|
|
16
|
+
name ignoring case and accents (`byName`). `openingWords` is a message's
|
|
17
|
+
caption on one line, as `[`'s row for a comment shows it: marks and line
|
|
18
|
+
prefixes gone, a link as its words, a person as `@Name`, and any other
|
|
19
|
+
reference by its type word ("Issue", "Message", "File") so it is never blank
|
|
20
|
+
(SPEC §13.1). Peek, Ship and Leaf each had their own copy, and Ship's and
|
|
21
|
+
Leaf's dropped a reference and kept a link's raw `[words](url)`.
|
|
22
|
+
|
|
23
|
+
SPEC: none changed. These read §13.1's references and NIP-43's roster as
|
|
24
|
+
before; they only move the reading into one place.
|
|
25
|
+
|
|
9
26
|
## 0.19.0 — 2026-10-27
|
|
10
27
|
|
|
11
28
|
**An edit with no files takes every file off** (SPEC §6.8 as amended in
|
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
|
+
export declare const CONVERSATION_VERSION = "0.20.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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,MAA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AAe,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,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.
|
|
15
|
+
export const CONVERSATION_VERSION = '0.20.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,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Aa,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,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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AiB,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,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, ' ')
|
|
84
|
+
.trim();
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=openingWords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openingWords.js","sourceRoot":"","sources":["../src/openingWords.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAA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E,MAAM,CAAC,CAAC;SACjG,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAA;AACX,CAAC"}
|
package/dist/people.d.ts
ADDED
|
@@ -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,SAAS,UAAU,CAAC,CAAsC,EAAE,CAAsC;IAChG,OAAO,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AAC9E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAA+B;IAC7D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAA;IAC9C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;YAAE,SAAQ;QAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtI,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,MAAM,CAAC,CAAmB,EAAE,CAAmB;IAC7D,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAqB,EACrB,MAAkC,EAClC,EAA6B;IAE7B,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,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.
|
|
3
|
+
"version": "0.20.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",
|
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
|
+
export const CONVERSATION_VERSION = '0.20.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
|
+
}
|