api #

Declarations
#

Mastodon components and helpers for Svelte, SvelteKit, and Fuz

29 declarations

CreateReplyFilters
#

CustomReplyFilter
#

mastodon.ts view source

CustomReplyFilter

type

type 'custom'

should_include

type ( status: MastodonStatus, root_status: MastodonStatus, status_context: MastodonStatusContext, ) => boolean

FavouritedByReplyFilter
#

fetch_mastodon_favourites
#

mastodon.ts view source

(host: string, status_id: string, cache?: Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined, log?: Logger | undefined, request?: RequestInit | undefined, token?: string | undefined, fetch?: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<...>) | undefined): Promise<...>

host

type string

status_id

type string

cache?

type Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined
optional

log?

type Logger | undefined
optional

request?

type RequestInit | undefined
optional

token?

type string | undefined
optional

fetch?

type ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>) | undefined
optional

returns

Promise<MastodonFavourite[] | null>

fetch_mastodon_status
#

mastodon.ts view source

(host: string, id: string, cache?: Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined, log?: Logger | undefined, request?: RequestInit | undefined, token?: string | undefined, fetch?: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<...>) | undefined): Promise<...>

host

type string

id

type string

cache?

type Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined
optional

log?

type Logger | undefined
optional

request?

type RequestInit | undefined
optional

token?

type string | undefined
optional

fetch?

type ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>) | undefined
optional

returns

Promise<MastodonStatus | null>

fetch_mastodon_status_context
#

mastodon.ts view source

(host: string, id: string, cache?: Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined, log?: Logger | undefined, request?: RequestInit | undefined, token?: string | undefined, fetch?: ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<...>) | undefined): Promise<...>

host

type string

id

type string

cache?

type Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined
optional

log?

type Logger | undefined
optional

request?

type RequestInit | undefined
optional

token?

type string | undefined
optional

fetch?

type ((input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>) | undefined
optional

returns

Promise<MastodonStatusContext | null>

filter_valid_replies
#

mastodon.ts view source

(root_status: MastodonStatus, status_context: MastodonStatusContext, reply_filter: ReplyFilter | ReplyFilter[] | null, cache: Map<...> | ... 1 more ... | undefined, log: Logger | undefined): Promise<...>

root_status

status_context

reply_filter

type ReplyFilter | ReplyFilter[] | null

cache

type Map<string, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }> | null | undefined

log

type Logger | undefined

returns

Promise<MastodonStatus[]>

load_from_storage
#

storage.ts view source

<T>(key: string, to_default_value: () => T, validate?: ((value: any) => asserts value is T) | undefined): T

Loads key and falls back to defaultValue. If validate is provided and throws, it removes the key and returns undefined.

key

type string

to_default_value

type () => T

validate?

type ((value: any) => asserts value is T) | undefined
optional

returns

T

mastodon_cache_context
#

mastodon_cache.svelte.ts view source

{ get: (error_message?: string | undefined) => MastodonCache; get_maybe: () => MastodonCache | undefined; set: (value: MastodonCache) => MastodonCache; }

MastodonCache
#

mastodon_cache.svelte.ts view source

load_data

type () => Promise<Array<[Url, FetchValueCacheItem]> | null>

readonly

data

If undefined, it's still loading. null means no data.

type FetchValueCache | undefined | null

constructor

type new (load_data: () => Promise<[Url, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }][] | null>, load_on_mount?: boolean): MastodonCache

load_data
type () => Promise<[Url, { key: string; url: string; params: any; value: any; etag: string | null; last_modified: string | null; }][] | null>
load_on_mount
type boolean
default true

load

MastodonFavourite
#

mastodon.ts view source

MastodonFavourite

id

type string

username

type string

acct

type string

display_name

type string

locked

type boolean

bot

type boolean

discoverable

type boolean

group

type boolean

created_at

type string

note

type string

url

type string

avatar

type string

avatar_static

type string

header

type string

header_static

type string

followers_count

type number

following_count

type number

statuses_count

type number

last_status_at

type string

emojis

type Array<unknown>

fields

type Array<{ name: string; value: string; verified_at: string; // Datetime }>

MastodonStatus
#

mastodon.ts view source

MastodonStatus

id

type string

created_at

type string

in_reply_to_id

type string

in_reply_to_account_id

type string

sensitive

type boolean

spoiler_text

type string

visibility

type string

language

type string

uri

type string

url

type string

replies_count

type number

reblogs_count

type number

favourites_count

type number

edited_at

type null | string

favourited

type boolean

reblogged

type boolean

muted

type boolean

bookmarked

type boolean

content

type string

filtered

type Array<unknown>

reblog

type unknown

account

type { id: string; username: string; acct: string; display_name: string; locked: boolean; bot: boolean; discoverable: boolean; group: boolean; created_at: string; note: string; url: string; avatar: string; avatar_static: string; header: string; header_static: string; followers_count: number; following_count: number; statuses_count: number; last_status_at: string; emojis: Array<unknown>; fields: Array<unknown>; }

media_attachments

type Array<unknown>

mentions

type [ { id: string; username: string; url: string; acct: string; }, ]

tags

type [ { name: string; url: string; }, ]

emojis

type Array<unknown>

card

type unknown

poll

type unknown

MastodonStatusContext
#

MastodonStatusItem
#

MastodonStatusTree
#

MastodonStatusUrl
#

mastodon.ts view source

MastodonStatusUrl

href

type string

host

type string

status_id

type string

author

type string

MinimumFavouritesReplyFilter
#

mastodon.ts view source

MinimumFavouritesReplyFilter

type

type 'minimum_favourites'

minimum_favourites

type number

parse_mastodon_status_url
#

mastodon.ts view source

(url: string): MastodonStatusUrl | null

Parses a url to a post or API endpoint for a post, aka Mastodon status context.

url

type string

returns

MastodonStatusUrl | null

the parsed host and id params, if any

ReplyFilter
#

mastodon.ts view source

ReplyFilter

When filtering replies, at least one rule must pass for a reply to be included.

set_in_storage
#

storage.ts view source

(key: string, value: any): void

Sets value at key. Importantly, if value is undefined the key is removed, but a value of null is stored.

key

type string

value

type any

returns

void

to_mastodon_api_favourites_url
#

to_mastodon_api_status_context_url
#

to_mastodon_api_status_url
#

to_mastodon_status_url
#

to_mastodon_status_url_with_author
#

mastodon.ts view source

(host: string, id: string, author: string): string

host

type string

id

type string

author

type string

returns

string

to_mastodon_status_url_with_users_author
#

Toot
#

Toot.svelte view source

url

type string

updated_url?

Defaults to the url, but can be updated by user input.

type string
optional bindable

include_ancestors?

Whether to fetch and display the ancestors in the status context.

type boolean
optional

include_replies?

Whether to fetch and display replies aka descendants in the status context.

type boolean
optional

reply_filter?

Get a list of rules that controls whether replies are shown or not.

type ReplyFilter | Array<ReplyFilter> | CreateReplyFilters | null
optional

cache?

Optional API result cache. See MastodonCache and get_mastodon_cache/set_mastodon_cache.

type FetchValueCache | null | undefined
optional

log?

Optional logger for network calls.

type Logger | undefined
optional

loading?

type boolean | undefined
optional bindable

load_time?

type number | undefined
optional bindable

settings_storage_key?

type string | undefined
optional

initial_show_settings?

type boolean
optional

show_settings?

type boolean
optional bindable

autoload_storage_key?

type string | undefined
optional

initial_autoload?

type boolean
optional

autoload?

type boolean
optional

onreset?

type () => void
optional

settings?

type Snippet
optional

TootInput
#

TootLoader
#

TootLoader.svelte view source

host

The host part of the url, like 'mastodon.ryanatkn.com'.

type string | null

id

The status id to fetch, like '110702983310017651'.

type string | null

include_ancestors?

Whether to fetch and display the ancestors in the status context.

type boolean
optional

include_replies?

Whether to fetch and display replies aka descendants in the status context.

type boolean
optional

cache?

Optional API result cache.

type FetchValueCache | null | undefined
optional

log?

Optional logger for network calls.

type Logger | undefined
optional

loading?

type boolean | undefined
optional bindable

item?

type MastodonStatus | null | undefined
optional bindable

status_context?

type MastodonStatusContext | null | undefined
optional bindable

replies?

type Array<MastodonStatus> | null | undefined
optional bindable

reply_filter?

Get a list of rules that controls whether replies are shown or not. If omitted, all replies are included.

type ReplyFilter | Array<ReplyFilter> | CreateReplyFilters | null
optional

load_time?

type number | undefined
optional bindable

children

type Snippet< [ { /** * `null` here is a failed loading condition. */ item: MastodonStatus | null | undefined; /** * `null` here is a failed loading condition. */ status_context: MastodonStatusContext | null | undefined; /** * `null` here is a failed loading condition for `item` or `status_context`. */ replies: Array<MastodonStatus> | null | undefined; load: () => Promise<void>; loading: boolean | undefined; load_time: number | undefined; }, ] >