An application to use Bluesky lexicons in a slightly different way
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 248 lines 5.5 kB view raw
1/** 2 * Leaflet types based on the pub.leaflet lexicon. 3 * Leaflet is a tool for shared writing and social publishing on the AT Protocol. 4 */ 5 6import type { AtUri, BlueskyPost, BlueskyProfile, Did, Timestamp } from './atproto' 7 8/** 9 * Strong reference to an AT Protocol record (com.atproto.repo.strongRef) 10 */ 11export interface StrongRef { 12 uri: AtUri 13 cid: string 14} 15 16/** 17 * Text alignment options for blocks 18 */ 19export type TextAlignment = 'left' | 'center' | 'right' | 'justify' 20 21/** 22 * Position within a document for quotes/selections 23 */ 24export interface LeafletPosition { 25 block: number[] 26 offset: number 27} 28 29/** 30 * Quote/selection range in a document 31 */ 32export interface LeafletQuote { 33 start: LeafletPosition 34 end: LeafletPosition 35} 36 37/** 38 * Rich text facet (pub.leaflet.richtext.facet) 39 * Note: This is a placeholder - actual structure depends on the facet lexicon 40 */ 41export interface LeafletFacet { 42 index: { 43 byteStart: number 44 byteEnd: number 45 } 46 features: Array<{ 47 $type: string 48 [key: string]: unknown 49 }> 50} 51 52/** 53 * Base block wrapper that contains a union of block types 54 */ 55export interface LeafletBlockWrapper { 56 block: LeafletBlock 57 alignment?: TextAlignment 58} 59 60/** 61 * Union type for all possible Leaflet blocks 62 */ 63export type LeafletBlock = 64 | LeafletBlockIframe 65 | LeafletBlockText 66 | LeafletBlockBlockquote 67 | LeafletBlockHeader 68 | LeafletBlockImage 69 | LeafletBlockUnorderedList 70 | LeafletBlockWebsite 71 | LeafletBlockMath 72 | LeafletBlockCode 73 | LeafletBlockHorizontalRule 74 | LeafletBlockBskyPost 75 | LeafletBlockPage 76 | LeafletBlockPoll 77 | LeafletBlockButton 78 79/** 80 * Text block (pub.leaflet.blocks.text) 81 */ 82export interface LeafletBlockText { 83 $type: 'pub.leaflet.blocks.text' 84 plaintext: string 85 facets?: LeafletFacet[] 86} 87 88/** 89 * Blockquote block (pub.leaflet.blocks.blockquote) 90 */ 91export interface LeafletBlockBlockquote { 92 $type: 'pub.leaflet.blocks.blockquote' 93 plaintext: string 94 facets?: LeafletFacet[] 95} 96 97/** 98 * Header block (pub.leaflet.blocks.header) 99 */ 100export interface LeafletBlockHeader { 101 $type: 'pub.leaflet.blocks.header' 102 level?: number 103 plaintext: string 104 facets?: LeafletFacet[] 105} 106 107/** 108 * Code block (pub.leaflet.blocks.code) 109 */ 110export interface LeafletBlockCode { 111 $type: 'pub.leaflet.blocks.code' 112 plaintext: string 113 language?: string 114 syntaxHighlightingTheme?: string 115} 116 117/** 118 * Unordered list block (pub.leaflet.blocks.unorderedList) 119 */ 120export interface LeafletBlockUnorderedList { 121 $type: 'pub.leaflet.blocks.unorderedList' 122 children: LeafletListItem[] 123} 124 125export interface LeafletListItem { 126 content: LeafletBlockText | LeafletBlockHeader | LeafletBlockImage 127 children?: LeafletListItem[] 128} 129 130/** 131 * Website block (pub.leaflet.blocks.website) 132 */ 133export interface LeafletBlockWebsite { 134 $type: 'pub.leaflet.blocks.website' 135 src: string 136 previewImage?: string 137 title?: string 138 description?: string 139} 140 141/** 142 * Math block (pub.leaflet.blocks.math) 143 */ 144export interface LeafletBlockMath { 145 $type: 'pub.leaflet.blocks.math' 146 tex: string 147} 148 149/** 150 * Horizontal rule block (pub.leaflet.blocks.horizontalRule) 151 */ 152export interface LeafletBlockHorizontalRule { 153 $type: 'pub.leaflet.blocks.horizontalRule' 154} 155 156/** 157 * Bluesky post block (pub.leaflet.blocks.bskyPost) 158 */ 159export interface LeafletBlockBskyPost { 160 $type: 'pub.leaflet.blocks.bskyPost' 161 postRef: StrongRef 162} 163 164/** 165 * Poll block (pub.leaflet.blocks.poll) 166 */ 167export interface LeafletBlockPoll { 168 $type: 'pub.leaflet.blocks.poll' 169 pollRef: StrongRef 170} 171 172/** 173 * Iframe block (pub.leaflet.blocks.iframe) 174 * Note: Structure not fully defined, placeholder 175 */ 176export interface LeafletBlockIframe { 177 $type: 'pub.leaflet.blocks.iframe' 178 [key: string]: unknown 179} 180 181/** 182 * Image block (pub.leaflet.blocks.image) 183 * Note: Structure not fully defined, placeholder 184 */ 185export interface LeafletBlockImage { 186 $type: 'pub.leaflet.blocks.image' 187 [key: string]: unknown 188} 189 190/** 191 * Page block (pub.leaflet.blocks.page) 192 * Note: Structure not fully defined, placeholder 193 */ 194export interface LeafletBlockPage { 195 $type: 'pub.leaflet.blocks.page' 196 [key: string]: unknown 197} 198 199/** 200 * Button block (pub.leaflet.blocks.button) 201 * Note: Structure not fully defined, placeholder 202 */ 203export interface LeafletBlockButton { 204 $type: 'pub.leaflet.blocks.button' 205 [key: string]: unknown 206} 207 208/** 209 * Leaflet Linear Document (pub.leaflet.pages.linearDocument) 210 * This is the main document type that contains an array of blocks. 211 */ 212export interface LeafletLinearDoc { 213 /** The URI of this document (if stored as an AT Protocol record) */ 214 uri?: AtUri 215 /** The CID of this document record */ 216 cid?: string 217 /** Optional document ID */ 218 id?: string 219 /** Array of blocks that make up the document */ 220 blocks: LeafletBlockWrapper[] 221 /** The author of the document */ 222 author?: BlueskyProfile 223 /** When the document was created */ 224 createdAt?: Timestamp 225 /** When the document was last updated */ 226 updatedAt?: Timestamp 227 /** Reply information (if this is a reply) */ 228 replyCount?: number 229 repostCount?: number 230 likeCount?: number 231 quoteCount?: number 232 /** When this document record was indexed */ 233 indexedAt?: Timestamp 234} 235 236/** 237 * Union type for thread posts - can be either a LeafletLinearDoc or BlueskyPost 238 */ 239export type ThreadPost = LeafletLinearDoc | BlueskyPost 240 241/** 242 * Thread view that can contain mixed post types 243 */ 244export interface LeafletThreadView { 245 root: LeafletLinearDoc 246 replies?: ThreadPost[] 247} 248