···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+import { type ValidationResult, BlobRef } from '@atproto/lexicon'
55+import { CID } from 'multiformats/cid'
66+import { validate as _validate } from '../../../../lexicons'
77+import {
88+ type $Typed,
99+ is$typed as _is$typed,
1010+ type OmitKey,
1111+} from '../../../../util'
1212+1313+const is$typed = _is$typed,
1414+ validate = _validate
1515+const id = 'pub.leaflet.richtext.facet'
1616+1717+/** Annotation of a sub-string within rich text. */
1818+export interface Main {
1919+ $type?: 'pub.leaflet.richtext.facet'
2020+ index: ByteSlice
2121+ features: (
2222+ | $Typed<Link>
2323+ | $Typed<Code>
2424+ | $Typed<Highlight>
2525+ | $Typed<Underline>
2626+ | $Typed<Strikethrough>
2727+ | $Typed<Id>
2828+ | $Typed<Bold>
2929+ | $Typed<Italic>
3030+ | { $type: string }
3131+ )[]
3232+}
3333+3434+const hashMain = 'main'
3535+3636+export function isMain<V>(v: V) {
3737+ return is$typed(v, id, hashMain)
3838+}
3939+4040+export function validateMain<V>(v: V) {
4141+ return validate<Main & V>(v, id, hashMain)
4242+}
4343+4444+/** Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets. */
4545+export interface ByteSlice {
4646+ $type?: 'pub.leaflet.richtext.facet#byteSlice'
4747+ byteStart: number
4848+ byteEnd: number
4949+}
5050+5151+const hashByteSlice = 'byteSlice'
5252+5353+export function isByteSlice<V>(v: V) {
5454+ return is$typed(v, id, hashByteSlice)
5555+}
5656+5757+export function validateByteSlice<V>(v: V) {
5858+ return validate<ByteSlice & V>(v, id, hashByteSlice)
5959+}
6060+6161+/** Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL. */
6262+export interface Link {
6363+ $type?: 'pub.leaflet.richtext.facet#link'
6464+ uri: string
6565+}
6666+6767+const hashLink = 'link'
6868+6969+export function isLink<V>(v: V) {
7070+ return is$typed(v, id, hashLink)
7171+}
7272+7373+export function validateLink<V>(v: V) {
7474+ return validate<Link & V>(v, id, hashLink)
7575+}
7676+7777+/** Facet feature for inline code. */
7878+export interface Code {
7979+ $type?: 'pub.leaflet.richtext.facet#code'
8080+}
8181+8282+const hashCode = 'code'
8383+8484+export function isCode<V>(v: V) {
8585+ return is$typed(v, id, hashCode)
8686+}
8787+8888+export function validateCode<V>(v: V) {
8989+ return validate<Code & V>(v, id, hashCode)
9090+}
9191+9292+/** Facet feature for highlighted text. */
9393+export interface Highlight {
9494+ $type?: 'pub.leaflet.richtext.facet#highlight'
9595+}
9696+9797+const hashHighlight = 'highlight'
9898+9999+export function isHighlight<V>(v: V) {
100100+ return is$typed(v, id, hashHighlight)
101101+}
102102+103103+export function validateHighlight<V>(v: V) {
104104+ return validate<Highlight & V>(v, id, hashHighlight)
105105+}
106106+107107+/** Facet feature for underline markup */
108108+export interface Underline {
109109+ $type?: 'pub.leaflet.richtext.facet#underline'
110110+}
111111+112112+const hashUnderline = 'underline'
113113+114114+export function isUnderline<V>(v: V) {
115115+ return is$typed(v, id, hashUnderline)
116116+}
117117+118118+export function validateUnderline<V>(v: V) {
119119+ return validate<Underline & V>(v, id, hashUnderline)
120120+}
121121+122122+/** Facet feature for strikethrough markup */
123123+export interface Strikethrough {
124124+ $type?: 'pub.leaflet.richtext.facet#strikethrough'
125125+}
126126+127127+const hashStrikethrough = 'strikethrough'
128128+129129+export function isStrikethrough<V>(v: V) {
130130+ return is$typed(v, id, hashStrikethrough)
131131+}
132132+133133+export function validateStrikethrough<V>(v: V) {
134134+ return validate<Strikethrough & V>(v, id, hashStrikethrough)
135135+}
136136+137137+/** Facet feature for an identifier. Used for linking to a segment */
138138+export interface Id {
139139+ $type?: 'pub.leaflet.richtext.facet#id'
140140+ id?: string
141141+}
142142+143143+const hashId = 'id'
144144+145145+export function isId<V>(v: V) {
146146+ return is$typed(v, id, hashId)
147147+}
148148+149149+export function validateId<V>(v: V) {
150150+ return validate<Id & V>(v, id, hashId)
151151+}
152152+153153+/** Facet feature for bold text */
154154+export interface Bold {
155155+ $type?: 'pub.leaflet.richtext.facet#bold'
156156+}
157157+158158+const hashBold = 'bold'
159159+160160+export function isBold<V>(v: V) {
161161+ return is$typed(v, id, hashBold)
162162+}
163163+164164+export function validateBold<V>(v: V) {
165165+ return validate<Bold & V>(v, id, hashBold)
166166+}
167167+168168+/** Facet feature for italic text */
169169+export interface Italic {
170170+ $type?: 'pub.leaflet.richtext.facet#italic'
171171+}
172172+173173+const hashItalic = 'italic'
174174+175175+export function isItalic<V>(v: V) {
176176+ return is$typed(v, id, hashItalic)
177177+}
178178+179179+export function validateItalic<V>(v: V) {
180180+ return validate<Italic & V>(v, id, hashItalic)
181181+}
+82
src/__generated__/lexicons/util.ts
···11+/**
22+ * GENERATED CODE - DO NOT MODIFY
33+ */
44+55+import { type ValidationResult } from '@atproto/lexicon'
66+77+export type OmitKey<T, K extends keyof T> = {
88+ [K2 in keyof T as K2 extends K ? never : K2]: T[K2]
99+}
1010+1111+export type $Typed<V, T extends string = string> = V & { $type: T }
1212+export type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>
1313+1414+export type $Type<Id extends string, Hash extends string> = Hash extends 'main'
1515+ ? Id
1616+ : `${Id}#${Hash}`
1717+1818+function isObject<V>(v: V): v is V & object {
1919+ return v != null && typeof v === 'object'
2020+}
2121+2222+function is$type<Id extends string, Hash extends string>(
2323+ $type: unknown,
2424+ id: Id,
2525+ hash: Hash,
2626+): $type is $Type<Id, Hash> {
2727+ return hash === 'main'
2828+ ? $type === id
2929+ : // $type === `${id}#${hash}`
3030+ typeof $type === 'string' &&
3131+ $type.length === id.length + 1 + hash.length &&
3232+ $type.charCodeAt(id.length) === 35 /* '#' */ &&
3333+ $type.startsWith(id) &&
3434+ $type.endsWith(hash)
3535+}
3636+3737+export type $TypedObject<
3838+ V,
3939+ Id extends string,
4040+ Hash extends string,
4141+> = V extends {
4242+ $type: $Type<Id, Hash>
4343+}
4444+ ? V
4545+ : V extends { $type?: string }
4646+ ? V extends { $type?: infer T extends $Type<Id, Hash> }
4747+ ? V & { $type: T }
4848+ : never
4949+ : V & { $type: $Type<Id, Hash> }
5050+5151+export function is$typed<V, Id extends string, Hash extends string>(
5252+ v: V,
5353+ id: Id,
5454+ hash: Hash,
5555+): v is $TypedObject<V, Id, Hash> {
5656+ return isObject(v) && '$type' in v && is$type(v.$type, id, hash)
5757+}
5858+5959+export function maybe$typed<V, Id extends string, Hash extends string>(
6060+ v: V,
6161+ id: Id,
6262+ hash: Hash,
6363+): v is V & object & { $type?: $Type<Id, Hash> } {
6464+ return (
6565+ isObject(v) &&
6666+ ('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)
6767+ )
6868+}
6969+7070+export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>
7171+export type ValidatorParam<V extends Validator> =
7272+ V extends Validator<infer R> ? R : never
7373+7474+/**
7575+ * Utility function that allows to convert a "validate*" utility function into a
7676+ * type predicate.
7777+ */
7878+export function asPredicate<V extends Validator>(validate: V) {
7979+ return function <T>(v: T): v is T & ValidatorParam<V> {
8080+ return validate(v).success
8181+ }
8282+}
-8
src/leaflet-live-loader.ts
···2727 }
2828}
29293030-/**
3131- * Flow:
3232- * - Check for valid handle or did [done]
3333- * - Resolve PDS url from handle or did [done, thanks Phil!]
3434- * - Fetch leaflet documents [done]
3535- * - Find out how to use leaflet types here
3636- */
3737-3830export function leafletLiveLoader(
3931 options: LeafletLoaderOptions,
4032): LiveLoader<