@estiva-app/conversation 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +3 -0
- package/dist/decorations.d.ts +9 -14
- package/dist/decorations.d.ts.map +1 -1
- package/dist/decorations.js +7 -25
- package/dist/decorations.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lines.d.ts +76 -0
- package/dist/lines.d.ts.map +1 -0
- package/dist/lines.js +126 -0
- package/dist/lines.js.map +1 -0
- package/dist/resolution.d.ts +59 -0
- package/dist/resolution.d.ts.map +1 -0
- package/dist/resolution.js +82 -0
- package/dist/resolution.js.map +1 -0
- package/dist/shape.d.ts +98 -0
- package/dist/shape.d.ts.map +1 -0
- package/dist/shape.js +148 -0
- package/dist/shape.js.map +1 -0
- package/package.json +2 -2
- package/src/decorations.ts +13 -34
- package/src/index.ts +15 -2
- package/src/lines.ts +166 -0
- package/src/resolution.ts +112 -0
- package/src/shape.ts +228 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,39 @@ 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.32.0 — 2026-11-04
|
|
10
|
+
|
|
11
|
+
**SPEC: §6.4's new "Resolving a thread", §6.5's three states of a top-level
|
|
12
|
+
message, and C51 — read differently; nothing written** (ONE-2; record
|
|
13
|
+
anyone-who-may-comment-resolves-or-reopens-a-thread-and-the-newest-counts).
|
|
14
|
+
|
|
15
|
+
- `foldThreads` (new): one shape for a message, a reply and a thread, folded
|
|
16
|
+
from a conversation's events — its messages, and the edits, reactions,
|
|
17
|
+
deletions and resolutions read by `#e` on them. A `Message` carries its
|
|
18
|
+
author, time, folded body and edited mark, files, cards, parts, links, a
|
|
19
|
+
comment's block run and quoted words, and its reactions by key. A `Thread`'s
|
|
20
|
+
top-level message is `present`, `deleted` (its author's `kind:5` came back)
|
|
21
|
+
or `missing` (only replies were read), and a deleted one keeps its replies
|
|
22
|
+
and its last state and is not `resolvable`. A reply or reaction its author
|
|
23
|
+
deleted is left out; a `kind:5` by anyone else hides nothing.
|
|
24
|
+
- `resolutionOf` (new): a thread's state is its newest `kind:9101` in §6.3's
|
|
25
|
+
order (`ts`, then `created_at`, then the higher id), whoever wrote it. One
|
|
26
|
+
filed outside the message's Folder, or with no `h`, changes nothing, and a
|
|
27
|
+
`support` outside the thread is dropped. **Read differently:** a resolve and
|
|
28
|
+
a reopen in one second now fold by `ts`, where `decorationsOf` sorted by
|
|
29
|
+
`created_at` then id.
|
|
30
|
+
- `decorationsOf`: a resolution's target is its **first unmarked `e`** and no
|
|
31
|
+
later one (it skipped to the first `e` naming a target). `Resolution` gains
|
|
32
|
+
`orderMs` and `folder`; its last entry is no longer the state on its own.
|
|
33
|
+
- `placeLines`, `writtenUrlOf`, `urlNames` (moved in): the one line rule for a
|
|
34
|
+
link alone on its line (§13.2, §13.6.2, C21), replacing Peek's and Ship's
|
|
35
|
+
`messageLines.ts`, Leaf's `commentLines.ts` and Peek's `urlNames`. A row's
|
|
36
|
+
`url` is the URL as written only when it names the row's own file.
|
|
37
|
+
- The conformance fixture folds real events read back off production, written
|
|
38
|
+
by QA-1 and QA-2: a deleted comment with a reply, a resolve carried by a
|
|
39
|
+
reply, a resolve and a reopen in one second, an edit and a comment on quoted
|
|
40
|
+
words.
|
|
41
|
+
|
|
9
42
|
## 0.31.0 — 2026-11-04
|
|
10
43
|
|
|
11
44
|
**SPEC: §6.13's `matches` is read for `[`; nothing written** (ALO-5; record
|
package/README.md
CHANGED
|
@@ -24,6 +24,9 @@ pass, the clock is a `createdAtMs` you pass, and drafts take their storage.
|
|
|
24
24
|
| --- | --- | --- |
|
|
25
25
|
| comment or mention | §6.4 | `isCommentOn`, `strengthOn`, `threadStrength`, `anchorsOf`, `isReply`, `namedInBody` |
|
|
26
26
|
| threading | §6.4 *Replies* | `parentOf`, `groupThreads` |
|
|
27
|
+
| one shape for a message, a reply and a thread, every app's: a top-level message present, deleted or not returned | §6.3–§6.8 | `foldThreads`, `Message`, `Thread` |
|
|
28
|
+
| resolving a thread: the newest counts, in its message's Folder | §6.4 *Resolving a thread*, C51 | `resolutionOf`, `resolutionsByTarget`, `resolutionTargetOf` |
|
|
29
|
+
| where a message's lines draw: a link alone on its line is its file's row | §13.2, §13.6.2, C21 | `placeLines`, `writtenUrlOf`, `urlNames` |
|
|
27
30
|
| writing | §6.4, §13.6 | `buildComment`, `buildReply`, `placeOf`, `referenceTagsFor`, `mentionTagsFor` |
|
|
28
31
|
| what a composer's pick writes | §13.1 | `mentionText`, `messageReference`, `urgentTagsFor`, `URGENT_TAG` |
|
|
29
32
|
| what the shared comment box holds, as the message it writes, and back | §13.1 | `composerText`, `composerDocument`, `withoutNewUrgency`, `composerDraft` |
|
package/dist/decorations.d.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { type SignedEvent } from '@estiva-app/protocol';
|
|
12
12
|
import { type EditFold } from './edits.js';
|
|
13
|
+
import { type Resolution } from './resolution.js';
|
|
14
|
+
export type { Resolution };
|
|
13
15
|
import { type ReactionEvent } from './reactions.js';
|
|
14
16
|
/**
|
|
15
17
|
* How a caller reads the relay: filters in, events out. The environment's
|
|
@@ -17,24 +19,17 @@ import { type ReactionEvent } from './reactions.js';
|
|
|
17
19
|
* Structurally the same as `@estiva-app/interop`'s `QueryFn`.
|
|
18
20
|
*/
|
|
19
21
|
export type QueryFn = (filters: Record<string, unknown>[]) => Promise<SignedEvent[]>;
|
|
20
|
-
/** A `kind:9101` resolution assertion on a message (PEEK-128). */
|
|
21
|
-
export interface Resolution {
|
|
22
|
-
id: string;
|
|
23
|
-
action: 'resolved' | 'reopened';
|
|
24
|
-
by: string;
|
|
25
|
-
at: number;
|
|
26
|
-
/** The assertion's free text, when it carried one. */
|
|
27
|
-
message?: string;
|
|
28
|
-
/** The reply that carried the resolution, when the writer named one. */
|
|
29
|
-
supportingEventId?: string;
|
|
30
|
-
}
|
|
31
22
|
/** What has been done to one message since it was written. */
|
|
32
23
|
export interface Decoration {
|
|
33
24
|
/** Its edits, folded (§6.8). Absent when nobody edited it. */
|
|
34
25
|
edit?: EditFold;
|
|
35
26
|
/** Its reactions, one per `(pubkey, emoji)`, oldest first. Empty inside the horizon means none. */
|
|
36
27
|
reactions: ReactionEvent[];
|
|
37
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Every resolve and reopen naming it, oldest first by §6.3. Which one counts
|
|
30
|
+
* — `h` checked, a `support` outside the thread dropped — is
|
|
31
|
+
* `resolutionOf`'s: the last one here is not the state on its own.
|
|
32
|
+
*/
|
|
38
33
|
resolutions: Resolution[];
|
|
39
34
|
}
|
|
40
35
|
/** The answer of {@link decorationsOf}. */
|
|
@@ -72,8 +67,8 @@ export interface Decorations {
|
|
|
72
67
|
* one per `(target, pubkey, emoji)`.
|
|
73
68
|
* - **Resolutions** are `kind:9101` carrying `t=resolution`; the `action` tag
|
|
74
69
|
* is the state, the content the rationale, and an `e` marked `support` names
|
|
75
|
-
* the reply that carried it. The target is the first unmarked `e`
|
|
76
|
-
*
|
|
70
|
+
* the reply that carried it. The target is the first unmarked `e`
|
|
71
|
+
* ({@link resolutionTargetOf}), and a thread's state is `resolutionOf`'s.
|
|
77
72
|
*
|
|
78
73
|
* Edits and resolutions have no horizon: they are one event per change, not
|
|
79
74
|
* one per reader. A refused read is whatever `query` does with one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorations.d.ts","sourceRoot":"","sources":["../src/decorations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAA6C,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,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G;AACH,wBAAsB,aAAa;AACjC,kDAAkD;AAClD,OAAO,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EAC7D,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,WAAW,CAAC,CAsEtB"}
|
package/dist/decorations.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { MAX_FILTERS_PER_QUERY, RELAY_PAGE_CEILING } from '@estiva-app/protocol';
|
|
12
12
|
import { editTargetOf, foldEdits } from './edits.js';
|
|
13
13
|
import { KIND_ASSERTION, KIND_EDIT, KIND_REACTION } from './kinds.js';
|
|
14
|
+
import { resolutionsByTarget, resolutionTargetOf } from './resolution.js';
|
|
14
15
|
import { reactionEventsOf, reactionHorizon, reactionTargetOf } from './reactions.js';
|
|
15
16
|
/** Ids per `#e` filter. A comfortable fraction of the relay's page, so one filter's answer is rarely cut. */
|
|
16
17
|
const TARGETS_PER_FILTER = 100;
|
|
@@ -20,7 +21,6 @@ const chunked = (list) => {
|
|
|
20
21
|
out.push(list.slice(i, i + TARGETS_PER_FILTER));
|
|
21
22
|
return out;
|
|
22
23
|
};
|
|
23
|
-
const tagValue = (event, name) => event.tags.find((t) => t[0] === name)?.[1];
|
|
24
24
|
/**
|
|
25
25
|
* Edits, reactions and resolutions for `targets`, in as few requests as the
|
|
26
26
|
* relay allows.
|
|
@@ -34,8 +34,8 @@ const tagValue = (event, name) => event.tags.find((t) => t[0] === name)?.[1];
|
|
|
34
34
|
* one per `(target, pubkey, emoji)`.
|
|
35
35
|
* - **Resolutions** are `kind:9101` carrying `t=resolution`; the `action` tag
|
|
36
36
|
* is the state, the content the rationale, and an `e` marked `support` names
|
|
37
|
-
* the reply that carried it. The target is the first unmarked `e`
|
|
38
|
-
*
|
|
37
|
+
* the reply that carried it. The target is the first unmarked `e`
|
|
38
|
+
* ({@link resolutionTargetOf}), and a thread's state is `resolutionOf`'s.
|
|
39
39
|
*
|
|
40
40
|
* Edits and resolutions have no horizon: they are one event per change, not
|
|
41
41
|
* one per reader. A refused read is whatever `query` does with one.
|
|
@@ -99,35 +99,17 @@ targets, query) {
|
|
|
99
99
|
return answered.some((n) => n >= RELAY_PAGE_CEILING);
|
|
100
100
|
};
|
|
101
101
|
const reactionEventsCut = cut(reactionChunks, [KIND_REACTION], reactionTargetOf);
|
|
102
|
-
const editEventsCut = cut(editChunks, [KIND_EDIT, KIND_ASSERTION], (e) => e.kind === KIND_EDIT ? editTargetOf(e) :
|
|
102
|
+
const editEventsCut = cut(editChunks, [KIND_EDIT, KIND_ASSERTION], (e) => e.kind === KIND_EDIT ? editTargetOf(e) : resolutionTargetOf(e));
|
|
103
103
|
const inHorizon = new Set(asked);
|
|
104
104
|
const reactions = events.filter((e) => e.kind === KIND_REACTION);
|
|
105
105
|
for (const reaction of reactionEventsOf(reactions)) {
|
|
106
106
|
if (ours(reaction.target) && inHorizon.has(reaction.target))
|
|
107
107
|
byId[reaction.target].reactions.push(reaction);
|
|
108
108
|
}
|
|
109
|
-
for (const
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
const action = tagValue(event, 'action');
|
|
113
|
-
if (action !== 'resolved' && action !== 'reopened')
|
|
114
|
-
continue;
|
|
115
|
-
const target = event.tags.find((t) => t[0] === 'e' && ours(t[1]) && !t[3])?.[1];
|
|
116
|
-
if (!ours(target))
|
|
117
|
-
continue;
|
|
118
|
-
const support = event.tags.find((t) => t[0] === 'e' && t[3] === 'support')?.[1];
|
|
119
|
-
byId[target].resolutions.push({
|
|
120
|
-
id: event.id,
|
|
121
|
-
action,
|
|
122
|
-
by: event.pubkey,
|
|
123
|
-
at: event.created_at,
|
|
124
|
-
...(event.content ? { message: event.content } : {}),
|
|
125
|
-
...(support ? { supportingEventId: support } : {}),
|
|
126
|
-
});
|
|
109
|
+
for (const [target, list] of Object.entries(resolutionsByTarget(events))) {
|
|
110
|
+
if (ours(target))
|
|
111
|
+
byId[target].resolutions = list;
|
|
127
112
|
}
|
|
128
|
-
const oldestFirst = (a, b) => a.at - b.at || (a.id < b.id ? -1 : 1);
|
|
129
|
-
for (const decoration of Object.values(byId))
|
|
130
|
-
decoration.resolutions.sort(oldestFirst);
|
|
131
113
|
return { byId, reactionTargetsOmitted: omitted, reactionEventsCut, editEventsCut };
|
|
132
114
|
}
|
|
133
115
|
//# sourceMappingURL=decorations.js.map
|
package/dist/decorations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorations.js","sourceRoot":"","sources":["../src/decorations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAoB,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAAE,YAAY,EAAE,SAAS,EAAiB,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAsB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"decorations.js","sourceRoot":"","sources":["../src/decorations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAoB,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAAE,YAAY,EAAE,SAAS,EAAiB,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAmB,MAAM,iBAAiB,CAAA;AAG1F,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAsB,MAAM,gBAAgB,CAAA;AA8CxG,6GAA6G;AAC7G,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAE9B,MAAM,OAAO,GAAG,CA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
package/dist/index.d.ts
CHANGED
|
@@ -12,14 +12,17 @@
|
|
|
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.32.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, anchorIdsOf, isAbout, isCrossedComment, isCrossedCommentOn, 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
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
|
-
export { decorationsOf, type Decoration, type Decorations, type
|
|
22
|
+
export { decorationsOf, type Decoration, type Decorations, type QueryFn } from './decorations.js';
|
|
23
|
+
export { resolutionOf, resolutionOfEvent, resolutionTargetOf, resolutionsByTarget, byResolutionOrder, type Resolution, } from './resolution.js';
|
|
24
|
+
export { foldThreads, type Message, type Thread, type RootState } from './shape.js';
|
|
25
|
+
export { placeLines, writtenUrlOf, urlNames, ROW_BLOCK, type RowLine, type PlacedLines, type LineContext } from './lines.js';
|
|
23
26
|
export { buildComment, buildReply, offersEditAndDelete, placeOf, type CommentRef } from './builders.js';
|
|
24
27
|
export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js';
|
|
25
28
|
export { composerDocument, composerDraft, composerText, withoutNewUrgency, type ComposerDraft, type ComposerLabels, type ComposerText, } from './composer.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,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE/G,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAA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AAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAA;AAE1B,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,YAAY,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAEvG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,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.32.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, anchorIdsOf, isAbout, isCrossedComment, isCrossedCommentOn, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, } from './strength.js';
|
|
@@ -20,6 +20,9 @@ export { parentOf, groupThreads } from './threads.js';
|
|
|
20
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
|
+
export { resolutionOf, resolutionOfEvent, resolutionTargetOf, resolutionsByTarget, byResolutionOrder, } from './resolution.js';
|
|
24
|
+
export { foldThreads } from './shape.js';
|
|
25
|
+
export { placeLines, writtenUrlOf, urlNames, ROW_BLOCK } from './lines.js';
|
|
23
26
|
export { buildComment, buildReply, offersEditAndDelete, placeOf } from './builders.js';
|
|
24
27
|
export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js';
|
|
25
28
|
export { composerDocument, composerDraft, composerText, withoutNewUrgency, } from './composer.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,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,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EhD,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
|
package/dist/lines.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a message's lines draw — the one line rule (SPEC §13.2, §13.6.2, C21),
|
|
3
|
+
* shared since ONE-2. It replaces Peek's and Ship's `messageLines.ts`, Leaf's
|
|
4
|
+
* `commentLines.ts` and Peek's `urlNames`, three copies that had drifted.
|
|
5
|
+
*
|
|
6
|
+
* A sentence keeps its chips; a line that is only a link to a file or a
|
|
7
|
+
* message is that file's row; and one whose file has a card or a part under
|
|
8
|
+
* the message draws nothing, since the card stands for it (C26). A person or a
|
|
9
|
+
* Folder alone on its line stays a chip, and a quote's or a heading's line is a
|
|
10
|
+
* sentence (protocol `lineDrawOf`).
|
|
11
|
+
*
|
|
12
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
|
|
13
|
+
*/
|
|
14
|
+
import { type Embed, type LinkResolver, type PartPointer, type RenderBlock, type RenderInline } from '@estiva-app/protocol';
|
|
15
|
+
/**
|
|
16
|
+
* A line of a message that is only a link to a file or a message, drawn as
|
|
17
|
+
* that file's row in place. `reference` is the `nostr:` reference the line
|
|
18
|
+
* names; `unreadable` is one that names no address or event id, drawn as the
|
|
19
|
+
* not-available row.
|
|
20
|
+
*/
|
|
21
|
+
export interface RowLine {
|
|
22
|
+
reference: string;
|
|
23
|
+
/** The file's value (an address or an id), when the line names one. */
|
|
24
|
+
value?: string;
|
|
25
|
+
unreadable?: true;
|
|
26
|
+
/** The URL the line was written as, when it names that same file: the row opens it as written (LTX-6). */
|
|
27
|
+
url?: string;
|
|
28
|
+
}
|
|
29
|
+
/** A paragraph's line that is a row, lifted out as a block of its own, so the row is not drawn inside a `<p>`. */
|
|
30
|
+
export declare const ROW_BLOCK = "linkRow";
|
|
31
|
+
/** The answer of {@link placeLines}. */
|
|
32
|
+
export interface PlacedLines {
|
|
33
|
+
blocks: RenderBlock[];
|
|
34
|
+
/** The row a block of type {@link ROW_BLOCK} draws. */
|
|
35
|
+
rowOf: (block: {
|
|
36
|
+
type: string;
|
|
37
|
+
attrs?: Record<string, unknown>;
|
|
38
|
+
}) => RowLine | undefined;
|
|
39
|
+
/** The row a list item's only run draws, by that run: a bullet that is only a link keeps its bullet. */
|
|
40
|
+
rowRuns: ReadonlyMap<object, RowLine>;
|
|
41
|
+
}
|
|
42
|
+
/** What a line's drawing reads beyond the line. */
|
|
43
|
+
export interface LineContext {
|
|
44
|
+
/** The message's cards (`foldEmbeds`, `cardsIn`): a line whose file has one draws nothing. */
|
|
45
|
+
cards?: readonly Embed[];
|
|
46
|
+
/** The `part`s drawn under the message: a line whose file has one draws nothing. */
|
|
47
|
+
parts?: readonly PartPointer[];
|
|
48
|
+
/** What an app link names (§7.7), as answered so far. */
|
|
49
|
+
resolveLink?: LinkResolver;
|
|
50
|
+
/**
|
|
51
|
+
* Values whose lines stay sentences, their chip only: the file the message
|
|
52
|
+
* is shown on draws no row of itself there (Miky, WID-3).
|
|
53
|
+
*/
|
|
54
|
+
stayChip?: (value: string) => boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The URL a run wrote for its reference, when the URL names that same file:
|
|
58
|
+
* what its chip or row opens (LTX-6). A marker or a block comment can set any
|
|
59
|
+
* URL's text on a reference to another file, so the text must itself read as
|
|
60
|
+
* it; without `resolveLink` nothing can be checked and there is none.
|
|
61
|
+
*/
|
|
62
|
+
export declare function writtenUrlOf(run: Pick<RenderInline, 'text' | 'reference'>, resolveLink: LinkResolver | undefined): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Whether a pasted app link names this address: its path ends in the
|
|
65
|
+
* address's `d` (§7.2 puts the identity last, `…/<slug>-<d>`), and that `d` is
|
|
66
|
+
* long enough to be one. A `d` comes from somebody's tag, so a short one would
|
|
67
|
+
* otherwise match half the links in a body.
|
|
68
|
+
*/
|
|
69
|
+
export declare function urlNames(url: string, address: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Where each of a message's lines draws. `blocks` is its tree after
|
|
72
|
+
* `linksAsReferences`, so a lone app URL this reader can read is already its
|
|
73
|
+
* reference, and one it cannot stays the URL as written.
|
|
74
|
+
*/
|
|
75
|
+
export declare function placeLines(blocks: readonly RenderBlock[], context?: LineContext): PlacedLines;
|
|
76
|
+
//# sourceMappingURL=lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../src/lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAA;AAE7B;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,0GAA0G;IAC1G,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,kHAAkH;AAClH,eAAO,MAAM,SAAS,YAAY,CAAA;AAElC,wCAAwC;AACxC,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,uDAAuD;IACvD,KAAK,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,OAAO,GAAG,SAAS,CAAA;IACxF,wGAAwG;IACxG,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC;AAED,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,8FAA8F;IAC9F,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,CAAA;IACxB,oFAAoF;IACpF,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;IAC9B,yDAAyD;IACzD,WAAW,CAAC,EAAE,YAAY,CAAA;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;CACtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAAC,EAAE,WAAW,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGrI;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAK9D;AAiBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,OAAO,GAAE,WAAgB,GAAG,WAAW,CAuDjG"}
|
package/dist/lines.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a message's lines draw — the one line rule (SPEC §13.2, §13.6.2, C21),
|
|
3
|
+
* shared since ONE-2. It replaces Peek's and Ship's `messageLines.ts`, Leaf's
|
|
4
|
+
* `commentLines.ts` and Peek's `urlNames`, three copies that had drifted.
|
|
5
|
+
*
|
|
6
|
+
* A sentence keeps its chips; a line that is only a link to a file or a
|
|
7
|
+
* message is that file's row; and one whose file has a card or a part under
|
|
8
|
+
* the message draws nothing, since the card stands for it (C26). A person or a
|
|
9
|
+
* Folder alone on its line stays a chip, and a quote's or a heading's line is a
|
|
10
|
+
* sentence (protocol `lineDrawOf`).
|
|
11
|
+
*
|
|
12
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
|
|
13
|
+
*/
|
|
14
|
+
import { lineDrawOf, linesOf, referenceOfLink, } from '@estiva-app/protocol';
|
|
15
|
+
/** A paragraph's line that is a row, lifted out as a block of its own, so the row is not drawn inside a `<p>`. */
|
|
16
|
+
export const ROW_BLOCK = 'linkRow';
|
|
17
|
+
/**
|
|
18
|
+
* The URL a run wrote for its reference, when the URL names that same file:
|
|
19
|
+
* what its chip or row opens (LTX-6). A marker or a block comment can set any
|
|
20
|
+
* URL's text on a reference to another file, so the text must itself read as
|
|
21
|
+
* it; without `resolveLink` nothing can be checked and there is none.
|
|
22
|
+
*/
|
|
23
|
+
export function writtenUrlOf(run, resolveLink) {
|
|
24
|
+
if (!run.reference || !resolveLink || !/^https?:\/\//i.test(run.text))
|
|
25
|
+
return undefined;
|
|
26
|
+
return referenceOfLink(run.text, resolveLink) === run.reference ? run.text : undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether a pasted app link names this address: its path ends in the
|
|
30
|
+
* address's `d` (§7.2 puts the identity last, `…/<slug>-<d>`), and that `d` is
|
|
31
|
+
* long enough to be one. A `d` comes from somebody's tag, so a short one would
|
|
32
|
+
* otherwise match half the links in a body.
|
|
33
|
+
*/
|
|
34
|
+
export function urlNames(url, address) {
|
|
35
|
+
const d = address.split(':')[2] ?? '';
|
|
36
|
+
if (d.length < 8)
|
|
37
|
+
return false;
|
|
38
|
+
const path = url.split(/[?#]/)[0].replace(/\/+$/, '');
|
|
39
|
+
return path.endsWith(`-${d}`) || path.endsWith(`/${d}`);
|
|
40
|
+
}
|
|
41
|
+
const BREAK = { text: '\n', marks: [] };
|
|
42
|
+
function rowLineOf(line, block, context) {
|
|
43
|
+
const drawn = lineDrawOf(line, block, context);
|
|
44
|
+
if ((drawn.draw === 'row' || drawn.draw === 'nothing') && context.stayChip?.(drawn.value))
|
|
45
|
+
return undefined;
|
|
46
|
+
if (drawn.draw === 'nothing')
|
|
47
|
+
return 'nothing';
|
|
48
|
+
if (drawn.draw === 'unreadable')
|
|
49
|
+
return { reference: drawn.reference, unreadable: true };
|
|
50
|
+
// A URL whose file is not read yet stays the link it was; once read, `linksAsReferences` made it a reference.
|
|
51
|
+
if (drawn.draw !== 'row' || drawn.url)
|
|
52
|
+
return undefined;
|
|
53
|
+
const run = line.find((r) => r.reference);
|
|
54
|
+
if (!run?.reference)
|
|
55
|
+
return undefined;
|
|
56
|
+
const url = writtenUrlOf(run, context.resolveLink);
|
|
57
|
+
return { reference: run.reference, value: drawn.value, ...(url ? { url } : {}) };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Where each of a message's lines draws. `blocks` is its tree after
|
|
61
|
+
* `linksAsReferences`, so a lone app URL this reader can read is already its
|
|
62
|
+
* reference, and one it cannot stays the URL as written.
|
|
63
|
+
*/
|
|
64
|
+
export function placeLines(blocks, context = {}) {
|
|
65
|
+
const rows = new Map();
|
|
66
|
+
const rowRuns = new Map();
|
|
67
|
+
const out = [];
|
|
68
|
+
for (const block of blocks) {
|
|
69
|
+
if (block.type === 'paragraph') {
|
|
70
|
+
const lines = linesOf(block);
|
|
71
|
+
const drawn = lines.map((line) => rowLineOf(line, block, context));
|
|
72
|
+
if (drawn.every((d) => d === undefined)) {
|
|
73
|
+
out.push(block);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
let sentence = [];
|
|
77
|
+
let first = true;
|
|
78
|
+
const flush = () => {
|
|
79
|
+
if (!sentence.length)
|
|
80
|
+
return;
|
|
81
|
+
const inline = sentence.flatMap((line, i) => (i > 0 ? [BREAK, ...line] : line));
|
|
82
|
+
out.push({ ...block, inline, ...(first ? {} : { id: undefined }) });
|
|
83
|
+
first = false;
|
|
84
|
+
sentence = [];
|
|
85
|
+
};
|
|
86
|
+
lines.forEach((line, i) => {
|
|
87
|
+
const d = drawn[i];
|
|
88
|
+
if (d === undefined) {
|
|
89
|
+
sentence.push(line);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
flush();
|
|
93
|
+
if (d === 'nothing')
|
|
94
|
+
return;
|
|
95
|
+
// Not a protocol block: a drawer hands a type it has no design for to its own renderer.
|
|
96
|
+
const row = { type: ROW_BLOCK, attrs: {} };
|
|
97
|
+
rows.set(row, d);
|
|
98
|
+
out.push(row);
|
|
99
|
+
});
|
|
100
|
+
flush();
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (block.type === 'bulletList' || block.type === 'orderedList') {
|
|
104
|
+
const items = (block.children ?? []).flatMap((item) => {
|
|
105
|
+
const lines = linesOf(item);
|
|
106
|
+
if (lines.length !== 1)
|
|
107
|
+
return [item];
|
|
108
|
+
const d = rowLineOf(lines[0], item, context);
|
|
109
|
+
if (d === undefined)
|
|
110
|
+
return [item];
|
|
111
|
+
if (d === 'nothing')
|
|
112
|
+
return [];
|
|
113
|
+
// A fresh run, so the map names this line and no other drawing of the same body.
|
|
114
|
+
const run = { ...lines[0].find((r) => r.reference || r.text.trim()) };
|
|
115
|
+
rowRuns.set(run, d);
|
|
116
|
+
return [{ ...item, inline: [run] }];
|
|
117
|
+
});
|
|
118
|
+
if (items.length)
|
|
119
|
+
out.push({ ...block, children: items });
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
out.push(block);
|
|
123
|
+
}
|
|
124
|
+
return { blocks: out, rowOf: (block) => rows.get(block), rowRuns };
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.js","sourceRoot":"","sources":["../src/lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,UAAU,EACV,OAAO,EACP,eAAe,GAMhB,MAAM,sBAAsB,CAAA;AAiB7B,kHAAkH;AAClH,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AA0BlC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,GAA6C,EAAE,WAAqC;IAC/G,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,WAAW,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,I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,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolving a thread — SPEC §6.4, "Resolving a thread" (ONE-2), and C51.
|
|
3
|
+
*
|
|
4
|
+
* A `kind:9101` with `t=resolution` resolves or reopens the thread of the
|
|
5
|
+
* top-level message its first unmarked `e` names. Anyone who may write in that
|
|
6
|
+
* message's Folder may write one, and **the newest counts, in §6.3's order**
|
|
7
|
+
* (`byOrder`): `ts` when trusted, then `created_at`, then the higher id.
|
|
8
|
+
* A reader ignores one whose `h` is not its target's Folder, one about a reply
|
|
9
|
+
* (never walked to its root), and drops a `support` outside the thread.
|
|
10
|
+
*
|
|
11
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/anyone-who-may-comment-resolves-or-reopens-a-thread-and-the-newest-counts.md
|
|
12
|
+
*/
|
|
13
|
+
import type { SignedEvent } from '@estiva-app/protocol';
|
|
14
|
+
/** A `kind:9101` resolution assertion on a message (PEEK-128, SPEC §6.4). */
|
|
15
|
+
export interface Resolution {
|
|
16
|
+
id: string;
|
|
17
|
+
action: 'resolved' | 'reopened';
|
|
18
|
+
by: string;
|
|
19
|
+
/** `created_at`, seconds. */
|
|
20
|
+
at: number;
|
|
21
|
+
/** Where it sorts, epoch milliseconds: the trusted `ts`, else `at` × 1000 (§6.3). */
|
|
22
|
+
orderMs: number;
|
|
23
|
+
/** Its `h`: the Folder it was filed in, which must be its target's. */
|
|
24
|
+
folder?: string;
|
|
25
|
+
/** The assertion's free text, when it carried one. */
|
|
26
|
+
message?: string;
|
|
27
|
+
/** The reply that carried the resolution, when the writer named one. */
|
|
28
|
+
supportingEventId?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The message a `kind:9101` is about: its **first unmarked `e`**, lowercased.
|
|
32
|
+
* Not the first one a reader happens to hold — a resolve listing a stranger
|
|
33
|
+
* first and a thread second is about the stranger.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolutionTargetOf(event: Pick<SignedEvent, 'tags'>): string | undefined;
|
|
36
|
+
/** The event read as a {@link Resolution} with its target, or undefined when it is not one. */
|
|
37
|
+
export declare function resolutionOfEvent(event: SignedEvent): {
|
|
38
|
+
target: string;
|
|
39
|
+
resolution: Resolution;
|
|
40
|
+
} | undefined;
|
|
41
|
+
/** Oldest first by §6.3: `ts` when trusted, then `created_at`, then the lower id. */
|
|
42
|
+
export declare const byResolutionOrder: (a: Resolution, b: Resolution) => number;
|
|
43
|
+
/**
|
|
44
|
+
* A thread's state: the newest of `resolutions` that counts, or undefined when
|
|
45
|
+
* none does (never resolved, or only ones a reader ignores).
|
|
46
|
+
*
|
|
47
|
+
* `resolutions` are those whose target is the thread's **top-level** message;
|
|
48
|
+
* one about a reply is never passed here. `folder` is that message's Folder
|
|
49
|
+
* (for a top-level message the read did not return, its replies'), and
|
|
50
|
+
* `replies` the thread's reply ids: a `support` naming anything else is
|
|
51
|
+
* dropped and the resolve stands.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolutionOf(resolutions: readonly Resolution[], thread: {
|
|
54
|
+
folder: string | undefined;
|
|
55
|
+
replies: readonly string[];
|
|
56
|
+
}): Resolution | undefined;
|
|
57
|
+
/** Every resolution in `events`, by target id, oldest first (§6.3). */
|
|
58
|
+
export declare function resolutionsByTarget(events: readonly SignedEvent[]): Record<string, Resolution[]>;
|
|
59
|
+
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../src/resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAIvD,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,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