@estiva-app/conversation 0.10.0 → 0.11.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 +12 -0
- package/dist/edits.d.ts +13 -4
- package/dist/edits.d.ts.map +1 -1
- package/dist/edits.js +32 -4
- package/dist/edits.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/edits.ts +30 -4
- package/src/index.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ 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.11.0 — 2026-10-13
|
|
10
|
+
|
|
11
|
+
**Cards fold like attachments** (OPT-16): `foldEmbeds(events)` is every
|
|
12
|
+
message's `embed` set, replaced by the latest edit carrying any, as
|
|
13
|
+
`foldAttachments` does for `imeta`. An edit with none leaves the set, and
|
|
14
|
+
`["embed", v, "none"]` removes a card. An edit that changes only the cards,
|
|
15
|
+
with a byte-identical body, is still not marked edited. Needs
|
|
16
|
+
`@estiva-app/protocol` 0.31.0 for `embedsOf`.
|
|
17
|
+
|
|
18
|
+
SPEC: §6.8 (an edit changes the body, the attachments and the cards) and
|
|
19
|
+
§13.6.2, with conformance row C20. Nothing this package writes changes.
|
|
20
|
+
|
|
9
21
|
## 0.10.0 — 2026-10-06
|
|
10
22
|
|
|
11
23
|
**Edit and Delete only on your own message** (SHI-29):
|
package/dist/edits.d.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* is held, not dropped: the target may arrive later, and the caller looks
|
|
8
8
|
* edits up by id.
|
|
9
9
|
*
|
|
10
|
-
* An edit changes the body and the
|
|
11
|
-
* fold separately: the set is the `imeta` of the latest edit
|
|
12
|
-
* one, and a set replaces rather than appends.
|
|
10
|
+
* An edit changes the body, the attachments and the cards, and nothing else.
|
|
11
|
+
* Attachments fold separately: the set is the `imeta` of the latest edit
|
|
12
|
+
* carrying at least one, and a set replaces rather than appends. Cards
|
|
13
|
+
* (`embed`, §13.6.2) fold the same way ({@link foldEmbeds}). The "edited" mark is about the
|
|
13
14
|
* **body**: an edit byte-identical to the body it replaces, judged against the
|
|
14
15
|
* body as it then stood, does not mark the message edited.
|
|
15
16
|
*
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
* relay adjudicates writes; a `40003` it stored is one it accepted — **for
|
|
18
19
|
* the `e` it checked**, which is why an edit lands only on {@link editTargetOf}.
|
|
19
20
|
*/
|
|
20
|
-
import { type Imeta, type SignedEvent } from '@estiva-app/protocol';
|
|
21
|
+
import { type Embed, type Imeta, type SignedEvent } from '@estiva-app/protocol';
|
|
21
22
|
/**
|
|
22
23
|
* The message a `kind:40003` edits: **the first `e` whose value is 64 hex,
|
|
23
24
|
* marker ignored**, lowercased (SPEC §6.8, PEE-38). That is exactly the event
|
|
@@ -73,4 +74,12 @@ export declare function foldEdits(events: readonly SignedEvent[], targets?: read
|
|
|
73
74
|
* latest edit carrying any (§6.8, C15). Messages with none are absent.
|
|
74
75
|
*/
|
|
75
76
|
export declare function foldAttachments(events: readonly SignedEvent[]): Record<string, Imeta[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Every message's current card set: its own `embed` tags, replaced by the
|
|
79
|
+
* latest edit carrying any (§6.8, §13.6.2, C20) — the same fold as
|
|
80
|
+
* {@link foldAttachments}. An edit with none leaves the set; `none` is how an
|
|
81
|
+
* edit removes a card. Which of these the body still names is
|
|
82
|
+
* `cardsIn`'s question, asked of the folded body. Messages with none are absent.
|
|
83
|
+
*/
|
|
84
|
+
export declare function foldEmbeds(events: readonly SignedEvent[]): Record<string, Embed[]>;
|
|
76
85
|
//# sourceMappingURL=edits.d.ts.map
|
package/dist/edits.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edits.d.ts","sourceRoot":"","sources":["../src/edits.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"edits.d.ts","sourceRoot":"","sources":["../src/edits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAqB,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAIlG;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAGjF;AAED,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;IACf,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;CACtB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAcxF;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,GAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAO,GACpD,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAwB1B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAgBvF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAgBlF"}
|
package/dist/edits.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* is held, not dropped: the target may arrive later, and the caller looks
|
|
8
8
|
* edits up by id.
|
|
9
9
|
*
|
|
10
|
-
* An edit changes the body and the
|
|
11
|
-
* fold separately: the set is the `imeta` of the latest edit
|
|
12
|
-
* one, and a set replaces rather than appends.
|
|
10
|
+
* An edit changes the body, the attachments and the cards, and nothing else.
|
|
11
|
+
* Attachments fold separately: the set is the `imeta` of the latest edit
|
|
12
|
+
* carrying at least one, and a set replaces rather than appends. Cards
|
|
13
|
+
* (`embed`, §13.6.2) fold the same way ({@link foldEmbeds}). The "edited" mark is about the
|
|
13
14
|
* **body**: an edit byte-identical to the body it replaces, judged against the
|
|
14
15
|
* body as it then stood, does not mark the message edited.
|
|
15
16
|
*
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
* relay adjudicates writes; a `40003` it stored is one it accepted — **for
|
|
18
19
|
* the `e` it checked**, which is why an edit lands only on {@link editTargetOf}.
|
|
19
20
|
*/
|
|
20
|
-
import { imetaOf } from '@estiva-app/protocol';
|
|
21
|
+
import { embedsOf, imetaOf } from '@estiva-app/protocol';
|
|
21
22
|
import { isConversationKind, isEventId, KIND_EDIT } from './kinds.js';
|
|
22
23
|
import { byOrder, orderingMs } from './order.js';
|
|
23
24
|
/**
|
|
@@ -120,4 +121,31 @@ export function foldAttachments(events) {
|
|
|
120
121
|
}
|
|
121
122
|
return out;
|
|
122
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Every message's current card set: its own `embed` tags, replaced by the
|
|
126
|
+
* latest edit carrying any (§6.8, §13.6.2, C20) — the same fold as
|
|
127
|
+
* {@link foldAttachments}. An edit with none leaves the set; `none` is how an
|
|
128
|
+
* edit removes a card. Which of these the body still names is
|
|
129
|
+
* `cardsIn`'s question, asked of the folded body. Messages with none are absent.
|
|
130
|
+
*/
|
|
131
|
+
export function foldEmbeds(events) {
|
|
132
|
+
const out = {};
|
|
133
|
+
for (const event of events) {
|
|
134
|
+
if (!isConversationKind(event.kind))
|
|
135
|
+
continue;
|
|
136
|
+
const embeds = embedsOf(event);
|
|
137
|
+
if (embeds.length > 0)
|
|
138
|
+
out[event.id.toLowerCase()] = embeds;
|
|
139
|
+
}
|
|
140
|
+
for (const [target, list] of editsByTarget(events)) {
|
|
141
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
142
|
+
const embeds = embedsOf(list[i]);
|
|
143
|
+
if (embeds.length === 0)
|
|
144
|
+
continue;
|
|
145
|
+
out[target] = embeds;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
123
151
|
//# sourceMappingURL=edits.js.map
|
package/dist/edits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edits.js","sourceRoot":"","sources":["../src/edits.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"edits.js","sourceRoot":"","sources":["../src/edits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAA4C,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgC;IAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnE,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC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,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;YAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAQ;YACjC,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;YACpB,MAAK;QACP,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
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.11.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';
|
|
19
19
|
export { parentOf, groupThreads, type Threaded } from './threads.js';
|
|
20
|
-
export { editTargetOf, editsByTarget, foldEdits, foldAttachments, type EditFold } from './edits.js';
|
|
20
|
+
export { editTargetOf, editsByTarget, foldEdits, foldAttachments, foldEmbeds, type EditFold } from './edits.js';
|
|
21
21
|
export { REACTION_HORIZON, REACTION_EMOJI, reactionTargetOf, reactionEmojiOf, reactionHorizon, reactionEventsOf, foldReactions, groupReactions, type ReactionHorizon, type ReactionEvent, type Reaction, } from './reactions.js';
|
|
22
22
|
export { decorationsOf, type Decoration, type Decorations, type Resolution, type QueryFn } from './decorations.js';
|
|
23
23
|
export { buildComment, buildReply, offersEditAndDelete, type CommentRef } from './builders.js';
|
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,KAAK,QAAQ,EAAE,MAAM,YAAY,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,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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T,iBAAiB,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,12 +12,12 @@
|
|
|
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.11.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';
|
|
19
19
|
export { parentOf, groupThreads } from './threads.js';
|
|
20
|
-
export { editTargetOf, editsByTarget, foldEdits, foldAttachments } from './edits.js';
|
|
20
|
+
export { editTargetOf, editsByTarget, foldEdits, foldAttachments, foldEmbeds } from './edits.js';
|
|
21
21
|
export { REACTION_HORIZON, REACTION_EMOJI, reactionTargetOf, reactionEmojiOf, reactionHorizon, reactionEventsOf, foldReactions, groupReactions, } from './reactions.js';
|
|
22
22
|
export { decorationsOf } from './decorations.js';
|
|
23
23
|
export { buildComment, buildReply, offersEditAndDelete } from './builders.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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Aa,EAAE,MAAM,cAAc,CAAA;AAExH,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/conversation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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.
|
|
50
|
+
"@estiva-app/protocol": ">=0.31.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@estiva-app/protocol": ">=0.
|
|
53
|
+
"@estiva-app/protocol": ">=0.31.0",
|
|
54
54
|
"typescript": "~5.9.3"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/src/edits.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* is held, not dropped: the target may arrive later, and the caller looks
|
|
8
8
|
* edits up by id.
|
|
9
9
|
*
|
|
10
|
-
* An edit changes the body and the
|
|
11
|
-
* fold separately: the set is the `imeta` of the latest edit
|
|
12
|
-
* one, and a set replaces rather than appends.
|
|
10
|
+
* An edit changes the body, the attachments and the cards, and nothing else.
|
|
11
|
+
* Attachments fold separately: the set is the `imeta` of the latest edit
|
|
12
|
+
* carrying at least one, and a set replaces rather than appends. Cards
|
|
13
|
+
* (`embed`, §13.6.2) fold the same way ({@link foldEmbeds}). The "edited" mark is about the
|
|
13
14
|
* **body**: an edit byte-identical to the body it replaces, judged against the
|
|
14
15
|
* body as it then stood, does not mark the message edited.
|
|
15
16
|
*
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
* relay adjudicates writes; a `40003` it stored is one it accepted — **for
|
|
18
19
|
* the `e` it checked**, which is why an edit lands only on {@link editTargetOf}.
|
|
19
20
|
*/
|
|
20
|
-
import { imetaOf, type Imeta, type SignedEvent } from '@estiva-app/protocol'
|
|
21
|
+
import { embedsOf, imetaOf, type Embed, type Imeta, type SignedEvent } from '@estiva-app/protocol'
|
|
21
22
|
import { isConversationKind, isEventId, KIND_EDIT } from './kinds.js'
|
|
22
23
|
import { byOrder, orderingMs } from './order.js'
|
|
23
24
|
|
|
@@ -137,3 +138,28 @@ export function foldAttachments(events: readonly SignedEvent[]): Record<string,
|
|
|
137
138
|
}
|
|
138
139
|
return out
|
|
139
140
|
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Every message's current card set: its own `embed` tags, replaced by the
|
|
144
|
+
* latest edit carrying any (§6.8, §13.6.2, C20) — the same fold as
|
|
145
|
+
* {@link foldAttachments}. An edit with none leaves the set; `none` is how an
|
|
146
|
+
* edit removes a card. Which of these the body still names is
|
|
147
|
+
* `cardsIn`'s question, asked of the folded body. Messages with none are absent.
|
|
148
|
+
*/
|
|
149
|
+
export function foldEmbeds(events: readonly SignedEvent[]): Record<string, Embed[]> {
|
|
150
|
+
const out: Record<string, Embed[]> = {}
|
|
151
|
+
for (const event of events) {
|
|
152
|
+
if (!isConversationKind(event.kind)) continue
|
|
153
|
+
const embeds = embedsOf(event)
|
|
154
|
+
if (embeds.length > 0) out[event.id.toLowerCase()] = embeds
|
|
155
|
+
}
|
|
156
|
+
for (const [target, list] of editsByTarget(events)) {
|
|
157
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
158
|
+
const embeds = embedsOf(list[i])
|
|
159
|
+
if (embeds.length === 0) continue
|
|
160
|
+
out[target] = embeds
|
|
161
|
+
break
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return out
|
|
165
|
+
}
|
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.11.0'
|
|
16
16
|
|
|
17
17
|
export {
|
|
18
18
|
KIND_MESSAGE,
|
|
@@ -44,7 +44,7 @@ export {
|
|
|
44
44
|
|
|
45
45
|
export { parentOf, groupThreads, type Threaded } from './threads.js'
|
|
46
46
|
|
|
47
|
-
export { editTargetOf, editsByTarget, foldEdits, foldAttachments, type EditFold } from './edits.js'
|
|
47
|
+
export { editTargetOf, editsByTarget, foldEdits, foldAttachments, foldEmbeds, type EditFold } from './edits.js'
|
|
48
48
|
|
|
49
49
|
export {
|
|
50
50
|
REACTION_HORIZON,
|