@estiva-app/protocol 0.32.0 → 0.33.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 +45 -0
- package/dist/content.d.ts +38 -1
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +8 -0
- package/dist/content.js.map +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +105 -8
- package/dist/editor.js.map +1 -1
- package/dist/embeds.d.ts +23 -2
- package/dist/embeds.d.ts.map +1 -1
- package/dist/embeds.js +52 -14
- package/dist/embeds.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/render.d.ts +49 -4
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +62 -8
- package/dist/render.js.map +1 -1
- package/package.json +1 -1
- package/src/content.ts +30 -2
- package/src/editor.ts +102 -9
- package/src/embeds.ts +48 -12
- package/src/index.ts +5 -2
- package/src/render.ts +81 -7
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
/** Bumped by hand with the version in package.json — `test/version.test.ts`
|
|
47
47
|
* pins the two together. It exists so "the upgrade reached the app" can be
|
|
48
48
|
* checked by grepping a built bundle rather than by trusting a lockfile. */
|
|
49
|
-
export declare const PROTOCOL_VERSION = "0.
|
|
49
|
+
export declare const PROTOCOL_VERSION = "0.33.0";
|
|
50
50
|
export { type NostrTag, type UnsignedEvent, type SignedEvent, type Profile, type ThreadRef, type ChannelVisibility, type ChannelKind, type MemberRole, type FolderOp, type Label, type ResolutionAction, KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE, computeEventId, toNostrSeconds, canonicalChannelName, threadTags, addr, relayAuthUrl, buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditChannelMetadata, buildFolderCommand, buildAddMember, buildDmOpen, buildDmHide, buildReaction, buildDeletion, buildEdit, buildMessage, buildResolution, buildBareFile, buildHighlight, buildUnsignedRelayAuthEvent, } from './events.js';
|
|
51
51
|
export { type AddressPointer, type EventPointer, encodeNevent, decodeNevent, convertBits, bech32Encode, bech32Decode, encodeNaddr, decodeNaddr, pointerToAddress, addressToPointer, addrToNaddr, naddrToAddr, referenceToPointer, NADDR_RE, findNaddrs, stripNaddrs, encodeNpub, decodeNpub, NOSTR_URI_RE, findNostrUris, } from './nip19.js';
|
|
52
52
|
export { type AuthEventArgs, TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
|
|
@@ -56,10 +56,10 @@ export { type RelayState, type SocketLike, type RelayCredential, type LiveRelayO
|
|
|
56
56
|
export { type ChannelEventHandler, type ChannelSubscription, type ChannelSubscriptions, createChannelSubscriptions, } from './subscriptions.js';
|
|
57
57
|
export { type InlineMark, type InlineMarkSpan, type BodySegment, type InlineMarkNode, type InlineTextNode, parseInlineMarks, wrapInlineMarks, parseBodySegments, stripInlineFormatting, markersToInlineNodes, inlineNodesToMarkers, inlineNodesToText, } from './content.js';
|
|
58
58
|
export { type Block, type BlockDocument, type KnownBlockType, KNOWN_BLOCK_TYPES, BlockDocumentError, validateBlockDocument, parseBlockDocument, serializeBlockDocument, newBlockId, assignMissingBlockIds, blockIds, findBlock, listItemDepths, MAX_LIST_DEPTH, listItemChecked, CALLOUT_TONES, type CalloutTone, calloutTone, inlineTextOf, documentText, } from './blocks.js';
|
|
59
|
-
export { type RenderInline, type RenderBlock, type RenderFormat, type ContentFormat, CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, } from './render.js';
|
|
59
|
+
export { type RenderInline, type RenderBlock, type RenderFormat, type ContentFormat, CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, type BlockCard, blockCards, cardLayout, } from './render.js';
|
|
60
60
|
export { markerTextToBlockDocument, blockDocumentToMarkerText, type DescriptionTextOptions, } from './bridge-content.js';
|
|
61
61
|
export { type EditorNode, type EditorDocument, EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
|
|
62
62
|
export { type BlockAnchor, type Part, type PartPointer, type PartSource, BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
|
|
63
|
-
export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences } from './embeds.js';
|
|
63
|
+
export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences, referenceOfLink, urlRunsIn } from './embeds.js';
|
|
64
64
|
export { type BlossomVerb, type Imeta, BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, type BlobFetchLike, type BlobResponseLike, type FetchedBlob, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, type UploadedBlob, type BlobUploadFetchLike, } from './media.js';
|
|
65
65
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,WAAW,CAAA;AAExC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,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oB,EACpB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACb,KAAK,WAAW,EAChB,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4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,UAAU,EACV,UAAU,GACX,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpK,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
/** Bumped by hand with the version in package.json — `test/version.test.ts`
|
|
47
47
|
* pins the two together. It exists so "the upgrade reached the app" can be
|
|
48
48
|
* checked by grepping a built bundle rather than by trusting a lockfile. */
|
|
49
|
-
export const PROTOCOL_VERSION = '0.
|
|
49
|
+
export const PROTOCOL_VERSION = '0.33.0';
|
|
50
50
|
export {
|
|
51
51
|
// constants
|
|
52
52
|
KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE,
|
|
@@ -62,10 +62,10 @@ export { toWebSocketUrl, parseFrame, createLiveRelay, } from './live.js';
|
|
|
62
62
|
export { createChannelSubscriptions, } from './subscriptions.js';
|
|
63
63
|
export { parseInlineMarks, wrapInlineMarks, parseBodySegments, stripInlineFormatting, markersToInlineNodes, inlineNodesToMarkers, inlineNodesToText, } from './content.js';
|
|
64
64
|
export { KNOWN_BLOCK_TYPES, BlockDocumentError, validateBlockDocument, parseBlockDocument, serializeBlockDocument, newBlockId, assignMissingBlockIds, blockIds, findBlock, listItemDepths, MAX_LIST_DEPTH, listItemChecked, CALLOUT_TONES, calloutTone, inlineTextOf, documentText, } from './blocks.js';
|
|
65
|
-
export { CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, } from './render.js';
|
|
65
|
+
export { CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, blockCards, cardLayout, } from './render.js';
|
|
66
66
|
export { markerTextToBlockDocument, blockDocumentToMarkerText, } from './bridge-content.js';
|
|
67
67
|
export { EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
|
|
68
68
|
export { BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
|
|
69
|
-
export { EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences } from './embeds.js';
|
|
69
|
+
export { EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences, referenceOfLink, urlRunsIn } from './embeds.js';
|
|
70
70
|
export { BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, } from './media.js';
|
|
71
71
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB;AACjB,8CAA8C;AAC9C,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY;AACZ,WAAW;AACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAEL,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAGL,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAOL,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EAOL,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAIL,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAML,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EAIL,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EAEb,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAA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rB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EAEb,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,EAEZ,UAAU,EACV,UAAU,GACX,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAGL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAAmD,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpK,OAAO,EAGL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EAIrB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,GAGlB,MAAM,YAAY,CAAA"}
|
package/dist/render.d.ts
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import { type InlineMark } from './content.js';
|
|
33
33
|
import { type CalloutTone } from './blocks.js';
|
|
34
34
|
import type { SignedEvent } from './events.js';
|
|
35
|
+
import { type LinkResolver } from './embeds.js';
|
|
35
36
|
/** A run of text and the marks on it. Nothing here needs escaping; it is text. */
|
|
36
37
|
export interface RenderInline {
|
|
37
38
|
text: string;
|
|
@@ -44,6 +45,18 @@ export interface RenderInline {
|
|
|
44
45
|
* nothing still shows the token rather than a blank.
|
|
45
46
|
*/
|
|
46
47
|
reference?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The card its writer chose for this reference in a block document (§13.3,
|
|
50
|
+
* "A reference's card"): absent for none. A message's cards are its `embed`
|
|
51
|
+
* tags instead (§13.6.2), so a marker body never has one.
|
|
52
|
+
*/
|
|
53
|
+
embed?: 'compact' | 'detailed';
|
|
54
|
+
/**
|
|
55
|
+
* The URL a block document's `link` mark points this run at (§13.3). On a run
|
|
56
|
+
* whose text is the URL, `linksAsReferences` turns it into the reference the
|
|
57
|
+
* URL names, `embed` and all; a link on words keeps it.
|
|
58
|
+
*/
|
|
59
|
+
href?: string;
|
|
47
60
|
}
|
|
48
61
|
/**
|
|
49
62
|
* A resolved block.
|
|
@@ -166,12 +179,44 @@ export declare function renderTreeText(blocks: readonly RenderBlock[]): string;
|
|
|
166
179
|
* on its line is alone on its line whether or not somebody left a space after
|
|
167
180
|
* it.
|
|
168
181
|
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
182
|
+
* @deprecated Since 0.33.0 a reference reads as its chip wherever it sits, in a
|
|
183
|
+
* message (§13.6.2) and in a block document (§13.3, "A reference's card"); a
|
|
184
|
+
* card comes only from what its writer chose. Use {@link blockCards} for a
|
|
185
|
+
* document and `cardsIn` for a message. Kept for one release so a reader on it
|
|
186
|
+
* still builds.
|
|
173
187
|
*/
|
|
174
188
|
export declare function standaloneReference(block: RenderBlock): string | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* `attrs.embed` on a reference mark, read: `compact`, `detailed`, or absent for
|
|
191
|
+
* no card. A string this reader does not know is `compact` — the writer asked
|
|
192
|
+
* for a card, and the smallest is the safe reading, as for a message's `embed`
|
|
193
|
+
* tag (§13.6.2). `none`, a non-string and absence are all no card.
|
|
194
|
+
*/
|
|
195
|
+
export declare function cardLayout(raw: unknown): 'compact' | 'detailed' | undefined;
|
|
196
|
+
/** One card a block document asks for: the reference it hangs from, and how much to show. */
|
|
197
|
+
export interface BlockCard {
|
|
198
|
+
/** The `nostr:` URI, as the reference mark carries it. */
|
|
199
|
+
reference: string;
|
|
200
|
+
layout: 'compact' | 'detailed';
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The cards to draw after this block, in the order their references appear
|
|
204
|
+
* (§13.3, "A reference's card"). Only the block's own runs: a list's cards hang
|
|
205
|
+
* from each item, so a reader asks each item.
|
|
206
|
+
*
|
|
207
|
+
* Each occurrence is its own card, so the same object twice may draw twice. A
|
|
208
|
+
* reference split across runs (part of it bold) is one occurrence, and takes
|
|
209
|
+
* its card from its first run.
|
|
210
|
+
*
|
|
211
|
+
* A link carries its card the same way. Read the block through
|
|
212
|
+
* `linksAsReferences` first and a URL is its reference already; a link on
|
|
213
|
+
* other words draws its card only when `resolveLink` says what its `href`
|
|
214
|
+
* names (§7.7), and without one names nothing.
|
|
215
|
+
*
|
|
216
|
+
* Inside a card's body or a part a reader asks nothing: there every reference
|
|
217
|
+
* is its chip (§13.3), or two objects that card each other nest forever.
|
|
218
|
+
*/
|
|
219
|
+
export declare function blockCards(block: RenderBlock, resolveLink?: LinkResolver): BlockCard[];
|
|
175
220
|
/**
|
|
176
221
|
* Every `nostr:` reference in a resolved tree, in the order they are written.
|
|
177
222
|
*
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAEL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAEL,KA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in each consumer is what stops one app deciding
|
|
30
30
|
* to guess.
|
|
31
31
|
*/
|
|
32
|
-
import { parseBodySegments, parseInlineMarks, } from './content.js';
|
|
32
|
+
import { parseBodySegments, parseInlineMarks, targetMark, } from './content.js';
|
|
33
33
|
import { parseBlockDocument, inlineTextOf, listItemDepths, listItemChecked, calloutTone } from './blocks.js';
|
|
34
|
+
import { referenceOfLink } from './embeds.js';
|
|
34
35
|
/** The tag SPEC §13.4 defines. Absence is a declaration, not an omission. */
|
|
35
36
|
export const CONTENT_FORMAT_TAG = 'content-format';
|
|
36
37
|
/** The one format §13.3 names today. */
|
|
@@ -63,6 +64,7 @@ const KNOWN = new Set([
|
|
|
63
64
|
'paragraph', 'heading', 'bulletList', 'orderedList', 'listItem',
|
|
64
65
|
'blockquote', 'codeBlock', 'table', 'horizontalRule', 'attachment', 'widget',
|
|
65
66
|
]);
|
|
67
|
+
const INLINE_MARKS = new Set(['bold', 'italic', 'underline', 'code']);
|
|
66
68
|
const marksOf = (span) => {
|
|
67
69
|
const out = [];
|
|
68
70
|
if (span.bold)
|
|
@@ -138,11 +140,16 @@ function blockFromDocument(block) {
|
|
|
138
140
|
if (isInlineRun(block.content)) {
|
|
139
141
|
out.inline = block.content.map((node) => {
|
|
140
142
|
const marks = node.marks ?? [];
|
|
141
|
-
const reference = marks
|
|
143
|
+
const reference = targetMark(marks, 'reference');
|
|
144
|
+
const link = reference ? undefined : targetMark(marks, 'link');
|
|
145
|
+
const embed = cardLayout((reference ?? link)?.embed);
|
|
142
146
|
return {
|
|
143
147
|
text: node.text,
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
// Only the four the vocabulary has: a mark this reader does not know is not one to draw (§13.3).
|
|
149
|
+
marks: marks.map((m) => m.type).filter((type) => INLINE_MARKS.has(type)),
|
|
150
|
+
...(reference ? { reference: reference.uri } : {}),
|
|
151
|
+
...(link ? { href: link.href } : {}),
|
|
152
|
+
...(embed ? { embed } : {}),
|
|
146
153
|
};
|
|
147
154
|
});
|
|
148
155
|
}
|
|
@@ -234,10 +241,11 @@ export function renderTreeText(blocks) {
|
|
|
234
241
|
* on its line is alone on its line whether or not somebody left a space after
|
|
235
242
|
* it.
|
|
236
243
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
244
|
+
* @deprecated Since 0.33.0 a reference reads as its chip wherever it sits, in a
|
|
245
|
+
* message (§13.6.2) and in a block document (§13.3, "A reference's card"); a
|
|
246
|
+
* card comes only from what its writer chose. Use {@link blockCards} for a
|
|
247
|
+
* document and `cardsIn` for a message. Kept for one release so a reader on it
|
|
248
|
+
* still builds.
|
|
241
249
|
*/
|
|
242
250
|
export function standaloneReference(block) {
|
|
243
251
|
if (block.type !== 'paragraph' || block.children?.length)
|
|
@@ -248,6 +256,52 @@ export function standaloneReference(block) {
|
|
|
248
256
|
const only = runs[0];
|
|
249
257
|
return only.reference && only.text.trim() === only.reference ? only.reference : undefined;
|
|
250
258
|
}
|
|
259
|
+
// ── A reference's card in a block document — SPEC §13.3 ─────────────────────
|
|
260
|
+
/**
|
|
261
|
+
* `attrs.embed` on a reference mark, read: `compact`, `detailed`, or absent for
|
|
262
|
+
* no card. A string this reader does not know is `compact` — the writer asked
|
|
263
|
+
* for a card, and the smallest is the safe reading, as for a message's `embed`
|
|
264
|
+
* tag (§13.6.2). `none`, a non-string and absence are all no card.
|
|
265
|
+
*/
|
|
266
|
+
export function cardLayout(raw) {
|
|
267
|
+
// An empty string names no layout: no card, as an editor saves it.
|
|
268
|
+
if (typeof raw !== 'string' || raw === '' || raw === 'none')
|
|
269
|
+
return undefined;
|
|
270
|
+
return raw === 'detailed' ? 'detailed' : 'compact';
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The cards to draw after this block, in the order their references appear
|
|
274
|
+
* (§13.3, "A reference's card"). Only the block's own runs: a list's cards hang
|
|
275
|
+
* from each item, so a reader asks each item.
|
|
276
|
+
*
|
|
277
|
+
* Each occurrence is its own card, so the same object twice may draw twice. A
|
|
278
|
+
* reference split across runs (part of it bold) is one occurrence, and takes
|
|
279
|
+
* its card from its first run.
|
|
280
|
+
*
|
|
281
|
+
* A link carries its card the same way. Read the block through
|
|
282
|
+
* `linksAsReferences` first and a URL is its reference already; a link on
|
|
283
|
+
* other words draws its card only when `resolveLink` says what its `href`
|
|
284
|
+
* names (§7.7), and without one names nothing.
|
|
285
|
+
*
|
|
286
|
+
* Inside a card's body or a part a reader asks nothing: there every reference
|
|
287
|
+
* is its chip (§13.3), or two objects that card each other nest forever.
|
|
288
|
+
*/
|
|
289
|
+
export function blockCards(block, resolveLink) {
|
|
290
|
+
const out = [];
|
|
291
|
+
let previous;
|
|
292
|
+
for (const run of block.inline ?? []) {
|
|
293
|
+
const target = run.reference ?? (run.href !== undefined ? `href:${run.href}` : undefined);
|
|
294
|
+
if (target && target === previous)
|
|
295
|
+
continue;
|
|
296
|
+
previous = target;
|
|
297
|
+
if (!run.embed)
|
|
298
|
+
continue;
|
|
299
|
+
const reference = run.reference ?? (run.href !== undefined && resolveLink ? referenceOfLink(run.href, resolveLink) : undefined);
|
|
300
|
+
if (reference)
|
|
301
|
+
out.push({ reference, layout: run.embed });
|
|
302
|
+
}
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
251
305
|
/**
|
|
252
306
|
* Every `nostr:` reference in a resolved tree, in the order they are written.
|
|
253
307
|
*
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAIL,iBAAiB,EACjB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAIL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,GACX,M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,CAAC,CAAA;IACD,IAAI,CAAC,MAAM,CAAC,CAAA;IACZ,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "The Estiva wire format: Buzz-shaped Nostr event builders, NIP-01 ids, NIP-19 naddr, NIP-98 HTTP auth, and the relay clients. Speaks the protocol; interprets nothing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/content.ts
CHANGED
|
@@ -360,8 +360,36 @@ export function stripInlineFormatting(text: string): string {
|
|
|
360
360
|
/** A mark on an inline run, in the JSON encoding. */
|
|
361
361
|
export type InlineMarkNode =
|
|
362
362
|
| { type: InlineMark }
|
|
363
|
-
/**
|
|
364
|
-
|
|
363
|
+
/**
|
|
364
|
+
* §13.1's `reference`, which carries what it points at. In a block document
|
|
365
|
+
* `embed` is the card its writer chose (§13.3, "A reference's card"), and any
|
|
366
|
+
* other key is one a later version added, which an editor carries through.
|
|
367
|
+
*/
|
|
368
|
+
| { type: 'reference'; attrs: { uri: string; embed?: unknown; [key: string]: unknown } }
|
|
369
|
+
/**
|
|
370
|
+
* §13.3's `link`, block documents only: a run that links to `href`. Estiva
|
|
371
|
+
* writes it on a run whose text is the URL itself, and only to carry the card
|
|
372
|
+
* its writer chose for the link (`embed`, §13.3 "A reference's card"); a URL
|
|
373
|
+
* with no card is plain text.
|
|
374
|
+
*/
|
|
375
|
+
| { type: 'link'; attrs: { href: string; embed?: unknown; [key: string]: unknown } }
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* The `reference` or `link` mark on a run, with its attrs, only when they are
|
|
379
|
+
* well formed: an object holding the string the mark points at (`uri`, `href`).
|
|
380
|
+
* A document is somebody else's JSON and the validator checks only a mark's
|
|
381
|
+
* `type`, so a mark with `"attrs": null` is read as no mark rather than taking
|
|
382
|
+
* every reader of the document down with it.
|
|
383
|
+
*/
|
|
384
|
+
export function targetMark(marks: readonly InlineMarkNode[] | undefined, type: 'reference'): { uri: string; embed?: unknown; [key: string]: unknown } | undefined
|
|
385
|
+
export function targetMark(marks: readonly InlineMarkNode[] | undefined, type: 'link'): { href: string; embed?: unknown; [key: string]: unknown } | undefined
|
|
386
|
+
export function targetMark(marks: readonly InlineMarkNode[] | undefined, type: 'reference' | 'link'): Record<string, unknown> | undefined {
|
|
387
|
+
const mark = marks?.find((m) => m.type === type) as { attrs?: unknown } | undefined
|
|
388
|
+
const attrs = mark?.attrs
|
|
389
|
+
if (!attrs || typeof attrs !== 'object' || Array.isArray(attrs)) return undefined
|
|
390
|
+
const target = (attrs as Record<string, unknown>)[type === 'reference' ? 'uri' : 'href']
|
|
391
|
+
return typeof target === 'string' && target !== '' ? (attrs as Record<string, unknown>) : undefined
|
|
392
|
+
}
|
|
365
393
|
|
|
366
394
|
/** One run of text and its marks — §13.3's `{"type":"text","text":…,"marks":[…]}`. */
|
|
367
395
|
export interface InlineTextNode {
|
package/src/editor.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type BlockDocument,
|
|
9
9
|
} from './blocks.js'
|
|
10
10
|
import { markerTextToBlockDocument } from './bridge-content.js'
|
|
11
|
-
import type
|
|
11
|
+
import { targetMark, type InlineMarkNode, type InlineTextNode } from './content.js'
|
|
12
12
|
import { BLOCK_DOCUMENT_FORMAT, type ContentFormat } from './render.js'
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -160,10 +160,23 @@ function textNodes(text: string, marks: EditorNode['marks']): EditorNode[] {
|
|
|
160
160
|
return out
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* A mark's `embed` as the editor node holds it: a layout string goes on the
|
|
165
|
+
* node, and anything else a later version may have put there rides in `extra`
|
|
166
|
+
* with the other unknown keys, so a save writes it back untouched. `none` and
|
|
167
|
+
* `""` are no card, which a writer omits (§13.3).
|
|
168
|
+
*/
|
|
169
|
+
function cardAndExtra(embed: unknown, rest: Record<string, unknown>): { card: { embed?: string }; extra: Record<string, unknown> } {
|
|
170
|
+
if (typeof embed === 'string') return { card: embed && embed !== 'none' ? { embed } : {}, extra: rest }
|
|
171
|
+
return { card: {}, extra: embed === undefined ? rest : { ...rest, embed } }
|
|
172
|
+
}
|
|
173
|
+
|
|
163
174
|
function inlineToEditor(runs: readonly InlineTextNode[]): EditorNode[] {
|
|
164
175
|
return runs.flatMap((run) => {
|
|
165
176
|
const marks = run.marks ?? []
|
|
166
|
-
|
|
177
|
+
// The marks a run keeps as marks; `reference` and `link` become the chip, or nothing when malformed.
|
|
178
|
+
const carried = marks.filter((m) => m.type !== 'reference' && m.type !== 'link').map((m) => m.type)
|
|
179
|
+
const reference = targetMark(marks, 'reference')
|
|
167
180
|
if (reference) {
|
|
168
181
|
/*
|
|
169
182
|
An atom rather than a mark, and the difference is what a person sees.
|
|
@@ -173,18 +186,47 @@ function inlineToEditor(runs: readonly InlineTextNode[]): EditorNode[] {
|
|
|
173
186
|
while reading, which is the mode difference this ticket is about.
|
|
174
187
|
|
|
175
188
|
The run's other marks ride along so a bold reference comes back bold.
|
|
189
|
+
So does its card (`embed`, §13.3), and every key a later version adds
|
|
190
|
+
rides in `extra`: a mark has no id, so a key dropped on save would be
|
|
191
|
+
lost with nothing to say so.
|
|
176
192
|
*/
|
|
193
|
+
const { uri, embed, ...rest } = reference
|
|
194
|
+
const { card, extra } = cardAndExtra(embed, rest)
|
|
177
195
|
return [
|
|
178
196
|
{
|
|
179
197
|
type: REFERENCE_NODE,
|
|
180
198
|
attrs: {
|
|
181
|
-
uri
|
|
182
|
-
marks:
|
|
199
|
+
uri,
|
|
200
|
+
marks: carried,
|
|
201
|
+
...card,
|
|
202
|
+
...(Object.keys(extra).length ? { extra } : {}),
|
|
183
203
|
},
|
|
184
204
|
},
|
|
185
205
|
]
|
|
186
206
|
}
|
|
187
|
-
|
|
207
|
+
const link = targetMark(marks, 'link')
|
|
208
|
+
if (link && run.text === link.href) {
|
|
209
|
+
/*
|
|
210
|
+
A URL whose card its writer chose (§13.3): the chip it reads as, which
|
|
211
|
+
keeps the URL in `href` and writes it back as the same run. `uri` is
|
|
212
|
+
what it names, filled in by the editor's `LinkChips` once the app has
|
|
213
|
+
resolved it; until then the chip draws as the URL.
|
|
214
|
+
|
|
215
|
+
`extra` is always an object here, empty or not: it says the URL came
|
|
216
|
+
with a `link` mark, so a save writes the mark back even with no card,
|
|
217
|
+
and a description somebody else wrote that way saves the same bytes.
|
|
218
|
+
*/
|
|
219
|
+
const { href, embed, ...rest } = link
|
|
220
|
+
const { card, extra } = cardAndExtra(embed, rest)
|
|
221
|
+
return [
|
|
222
|
+
{
|
|
223
|
+
type: REFERENCE_NODE,
|
|
224
|
+
attrs: { uri: '', href, marks: carried, ...card, extra },
|
|
225
|
+
},
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
// A link on other words is not one these editors write or draw: its words stay, the link does not.
|
|
229
|
+
return textNodes(run.text, carried.map((type) => ({ type })))
|
|
188
230
|
})
|
|
189
231
|
}
|
|
190
232
|
|
|
@@ -373,13 +415,49 @@ function idFor(node: EditorNode, claims: IdClaims): string {
|
|
|
373
415
|
|
|
374
416
|
function inlineFromEditor(nodes: readonly EditorNode[]): InlineTextNode[] {
|
|
375
417
|
const out: InlineTextNode[] = []
|
|
376
|
-
for (const node of nodes) {
|
|
418
|
+
for (const [i, node] of nodes.entries()) {
|
|
419
|
+
if (node.type === REFERENCE_NODE && typeof node.attrs?.href === 'string' && node.attrs.href) {
|
|
420
|
+
/*
|
|
421
|
+
A URL chip is its URL on the wire, never rewritten into the reference
|
|
422
|
+
it names (§13.3). With no card it is plain text, merged with the text
|
|
423
|
+
around it, so a description an editor only opened saves the same bytes.
|
|
424
|
+
A `link` mark holds it when it has a card, when it came with one
|
|
425
|
+
(`extra` set), or when what follows would read as more of the URL — a
|
|
426
|
+
word typed right after the chip, or another URL chip — so its end stays
|
|
427
|
+
where it was.
|
|
428
|
+
*/
|
|
429
|
+
const href = node.attrs.href
|
|
430
|
+
const carried = Array.isArray(node.attrs.marks) ? (node.attrs.marks as string[]) : []
|
|
431
|
+
const embed = node.attrs.embed
|
|
432
|
+
const extra = node.attrs.extra && typeof node.attrs.extra === 'object' && !Array.isArray(node.attrs.extra) ? (node.attrs.extra as Record<string, unknown>) : undefined
|
|
433
|
+
const card = typeof embed === 'string' && embed !== '' && embed !== 'none'
|
|
434
|
+
const marks: InlineMarkNode[] = carried.map((type) => ({ type }) as InlineMarkNode)
|
|
435
|
+
if (card || extra || continuesUrl(nodes[i + 1])) {
|
|
436
|
+
// `href` first, as writers put it, so an untouched mark keeps its bytes; `extra` never holds it.
|
|
437
|
+
marks.push({ type: 'link', attrs: { href, ...extra, ...(card ? { embed } : {}) } })
|
|
438
|
+
}
|
|
439
|
+
const last = out[out.length - 1]
|
|
440
|
+
if (last && sameMarks(last.marks ?? [], marks)) last.text += href
|
|
441
|
+
else out.push({ type: 'text', text: href, ...(marks.length ? { marks } : {}) })
|
|
442
|
+
continue
|
|
443
|
+
}
|
|
377
444
|
if (node.type === REFERENCE_NODE) {
|
|
378
445
|
const uri = String(node.attrs?.uri ?? '')
|
|
379
446
|
const carried = Array.isArray(node.attrs?.marks) ? (node.attrs.marks as string[]) : []
|
|
447
|
+
const embed = node.attrs?.embed
|
|
448
|
+
const extra = node.attrs?.extra
|
|
380
449
|
const marks: InlineMarkNode[] = [
|
|
381
450
|
...carried.map((type) => ({ type }) as InlineMarkNode),
|
|
382
|
-
{
|
|
451
|
+
{
|
|
452
|
+
type: 'reference',
|
|
453
|
+
attrs: {
|
|
454
|
+
// `extra` first, so a key it carries can never overwrite the two this code owns.
|
|
455
|
+
...(extra && typeof extra === 'object' && !Array.isArray(extra) ? (extra as Record<string, unknown>) : {}),
|
|
456
|
+
uri,
|
|
457
|
+
// `none` is no attribute (§13.3): a writer omits it.
|
|
458
|
+
...(typeof embed === 'string' && embed !== '' && embed !== 'none' ? { embed } : {}),
|
|
459
|
+
},
|
|
460
|
+
},
|
|
383
461
|
]
|
|
384
462
|
out.push({ type: 'text', text: uri, marks })
|
|
385
463
|
continue
|
|
@@ -388,7 +466,7 @@ function inlineFromEditor(nodes: readonly EditorNode[]): InlineTextNode[] {
|
|
|
388
466
|
// Rejoin onto the previous run where there is one, so a paragraph is not
|
|
389
467
|
// split into three runs by one break.
|
|
390
468
|
const last = out[out.length - 1]
|
|
391
|
-
if (last && !last.marks?.some(
|
|
469
|
+
if (last && !last.marks?.some(holdsTarget)) last.text += '\n'
|
|
392
470
|
else out.push({ type: 'text', text: '\n' })
|
|
393
471
|
continue
|
|
394
472
|
}
|
|
@@ -407,9 +485,24 @@ function inlineFromEditor(nodes: readonly EditorNode[]): InlineTextNode[] {
|
|
|
407
485
|
return out
|
|
408
486
|
}
|
|
409
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Whether this node, written right after a URL as plain text, would be read
|
|
490
|
+
* as more of the URL: another chip (its text is a URL or a `nostr:` URI), or
|
|
491
|
+
* text that does not start with a space or a sentence's closing punctuation.
|
|
492
|
+
*/
|
|
493
|
+
function continuesUrl(next: EditorNode | undefined): boolean {
|
|
494
|
+
if (!next) return false
|
|
495
|
+
if (next.type === REFERENCE_NODE) return true
|
|
496
|
+
if (next.type !== 'text' || !next.text) return false
|
|
497
|
+
return !/^(\s|[.,;:!?)\]]+(\s|$))/.test(next.text) && !/^[<>"'`]/.test(next.text)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** A run that points somewhere is its own run: its text is what it points at, never merged into the next. */
|
|
501
|
+
const holdsTarget = (m: InlineMarkNode) => m.type === 'reference' || m.type === 'link'
|
|
502
|
+
|
|
410
503
|
function sameMarks(a: readonly InlineMarkNode[], b: readonly InlineMarkNode[]): boolean {
|
|
411
504
|
if (a.length !== b.length) return false
|
|
412
|
-
if (a.some(
|
|
505
|
+
if (a.some(holdsTarget) || b.some(holdsTarget)) return false
|
|
413
506
|
return a.every((m, i) => m.type === b[i].type)
|
|
414
507
|
}
|
|
415
508
|
|
package/src/embeds.ts
CHANGED
|
@@ -177,6 +177,42 @@ export function cardsIn(embeds: readonly Embed[], blocks: readonly RenderBlock[]
|
|
|
177
177
|
return out
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/**
|
|
181
|
+
* The `nostr:` reference an app link names, by what `resolveLink` answered for
|
|
182
|
+
* it (§7.7), or undefined: nothing claims it, the answer has not come back, or
|
|
183
|
+
* the address is one no naddr can hold (a `d` over 255 bytes), which stays a
|
|
184
|
+
* link rather than taking the text down with it. What an editor's URL chip
|
|
185
|
+
* draws as (`@estiva-app/ui/editor`'s `LinkChips`).
|
|
186
|
+
*/
|
|
187
|
+
export function referenceOfLink(url: string, resolveLink: LinkResolver): string | undefined {
|
|
188
|
+
const value = normalise(resolveLink(url) ?? '')
|
|
189
|
+
if (!value) return undefined
|
|
190
|
+
try {
|
|
191
|
+
return `nostr:${EVENT_ID.test(value) ? encodeNevent({ id: value, relays: [] }) : addrToNaddr(value)}`
|
|
192
|
+
} catch {
|
|
193
|
+
return undefined
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The app links an editor may turn into chips in one text, where each sits:
|
|
199
|
+
* bare http(s) URLs, trailing punctuation left to the sentence. A
|
|
200
|
+
* `[words](https://…)` is the marker format's link on words and is skipped, as
|
|
201
|
+
* {@link linksAsReferences} skips it.
|
|
202
|
+
*/
|
|
203
|
+
export function urlRunsIn(text: string): { url: string; from: number; to: number }[] {
|
|
204
|
+
if (!text.includes('://')) return []
|
|
205
|
+
const out: { url: string; from: number; to: number }[] = []
|
|
206
|
+
for (const m of text.matchAll(LINK_OR_URL)) {
|
|
207
|
+
if (m[1]) continue
|
|
208
|
+
const start = m.index
|
|
209
|
+
if (text.slice(Math.max(0, start - 2), start) === '](' || text[start - 1] === '[') continue
|
|
210
|
+
const url = trimUrl(m[0])
|
|
211
|
+
out.push({ url, from: start, to: start + url.length })
|
|
212
|
+
}
|
|
213
|
+
return out
|
|
214
|
+
}
|
|
215
|
+
|
|
180
216
|
/**
|
|
181
217
|
* One pass over a run: a link on words, `[words](https://…)` as the marker
|
|
182
218
|
* format writes it (group 1 — its URL is the target of words the author chose),
|
|
@@ -204,21 +240,21 @@ const LINK_OR_URL = /(\[[^[\]\n]+\]\((?:https?:\/\/|mailto:)[^\s)]+\))|(https?:\
|
|
|
204
240
|
* not come back yet — which stays a link. The run keeps the URL as its text,
|
|
205
241
|
* so a reader that draws references as text shows what was written.
|
|
206
242
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
243
|
+
* A block document's too, since 0.33.0 (§13.3): a description's URL reads as
|
|
244
|
+
* its chip as a message's does. There a run whose text is its own `link` mark's
|
|
245
|
+
* `href` is that URL, and keeps the card its writer chose (`embed`); a link on
|
|
246
|
+
* other words stays a link.
|
|
209
247
|
*/
|
|
210
248
|
export function linksAsReferences(blocks: readonly RenderBlock[], resolveLink: LinkResolver): RenderBlock[] {
|
|
211
|
-
const referenceOf = (url: string)
|
|
212
|
-
const value = normalise(resolveLink(url) ?? '')
|
|
213
|
-
if (!value) return undefined
|
|
214
|
-
// An address no naddr can hold (a `d` over 255 bytes) stays a link rather than taking the message down with it.
|
|
215
|
-
try {
|
|
216
|
-
return `nostr:${EVENT_ID.test(value) ? encodeNevent({ id: value, relays: [] }) : addrToNaddr(value)}`
|
|
217
|
-
} catch {
|
|
218
|
-
return undefined
|
|
219
|
-
}
|
|
220
|
-
}
|
|
249
|
+
const referenceOf = (url: string) => referenceOfLink(url, resolveLink)
|
|
221
250
|
const split = (run: RenderInline): RenderInline[] => {
|
|
251
|
+
if (run.href !== undefined) {
|
|
252
|
+
// A block document's link: the URL as its own words is the URL, and takes its card along.
|
|
253
|
+
const reference = !run.reference && run.text === run.href && !run.marks.includes('code') ? referenceOf(run.href) : undefined
|
|
254
|
+
if (!reference) return [run]
|
|
255
|
+
const { href: _href, ...rest } = run
|
|
256
|
+
return [{ ...rest, reference }]
|
|
257
|
+
}
|
|
222
258
|
if (run.reference || run.marks.includes('code') || !run.text.includes('://')) return [run]
|
|
223
259
|
const out: RenderInline[] = []
|
|
224
260
|
let at = 0
|