api #

Mastodon components and helpers for Svelte, SvelteKit, and Fuz

8 modules ยท 29 declarations

Modules
#

CreateReplyFilters
#

mastodon.ts view source

CreateReplyFilters import type {CreateReplyFilters} from '@fuzdev/fuz_mastodon/mastodon.js';

(call)

type (item: MastodonStatus, status_context: MastodonStatusContext): ReplyFilter | ReplyFilter[] | null

item

status_context

returns ReplyFilter | ReplyFilter[] | null

CustomReplyFilter
#

mastodon.ts view source

CustomReplyFilter import type {CustomReplyFilter} from '@fuzdev/fuz_mastodon/mastodon.js';

type

type 'custom'

should_include

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

FavouritedByReplyFilter
#

mastodon.ts view source

FavouritedByReplyFilter import type {FavouritedByReplyFilter} from '@fuzdev/fuz_mastodon/mastodon.js';

type

type 'favourited_by'

favourited_by

type Array<string>

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?: { ...; } | undefined): Promise<...> import {fetch_mastodon_favourites} from '@fuzdev/fuz_mastodon/mastodon.js';

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>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; } | 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?: { ...; } | undefined): Promise<...> import {fetch_mastodon_status} from '@fuzdev/fuz_mastodon/mastodon.js';

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>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; } | 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?: { ...; } | undefined): Promise<...> import {fetch_mastodon_status_context} from '@fuzdev/fuz_mastodon/mastodon.js';

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>; (input: string | Request | URL, init?: RequestInit | undefined): Promise<...>; } | 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<...> import {filter_valid_replies} from '@fuzdev/fuz_mastodon/mastodon.js';

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 import {load_from_storage} from '@fuzdev/fuz_mastodon/storage.js';

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

generics

load_from_storage<T>
T

mastodon_cache_context
#

mastodon_cache.svelte.ts view source

{ get: (error_message?: string | undefined) => MastodonCache; get_maybe: () => MastodonCache | undefined; set: (value: MastodonCache) => MastodonCache; } import {mastodon_cache_context} from '@fuzdev/fuz_mastodon/mastodon_cache.svelte.js';

MastodonCache
#

mastodon_cache.svelte.ts view source

import {MastodonCache} from '@fuzdev/fuz_mastodon/mastodon_cache.svelte.js';

load_data

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

readonly

data

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

type FetchValueCache | undefined | null

$state.raw

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

type () => Promise<void>

MastodonFavourite
#

mastodon.ts view source

MastodonFavourite import type {MastodonFavourite} from '@fuzdev/fuz_mastodon/mastodon.js';

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 import type {MastodonStatus} from '@fuzdev/fuz_mastodon/mastodon.js';

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 import type {MastodonStatusUrl} from '@fuzdev/fuz_mastodon/mastodon.js';

href

type string

host

type string

status_id

type string

author?

type string

MinimumFavouritesReplyFilter
#

mastodon.ts view source

MinimumFavouritesReplyFilter import type {MinimumFavouritesReplyFilter} from '@fuzdev/fuz_mastodon/mastodon.js';

type

type 'minimum_favourites'

minimum_favourites

type number

parse_mastodon_status_url
#

mastodon.ts view source

(url: string): MastodonStatusUrl | null import {parse_mastodon_status_url} from '@fuzdev/fuz_mastodon/mastodon.js';

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 import type {ReplyFilter} from '@fuzdev/fuz_mastodon/mastodon.js';

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 import {set_in_storage} from '@fuzdev/fuz_mastodon/storage.js';

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
#

mastodon.ts view source

(host: string, id: string): string import {to_mastodon_api_favourites_url} from '@fuzdev/fuz_mastodon/mastodon.js';

host

type string

id

type string

returns

string

to_mastodon_api_status_context_url
#

mastodon.ts view source

(host: string, id: string): string import {to_mastodon_api_status_context_url} from '@fuzdev/fuz_mastodon/mastodon.js';

host

type string

id

type string

returns

string

to_mastodon_api_status_url
#

mastodon.ts view source

(host: string, id: string): string import {to_mastodon_api_status_url} from '@fuzdev/fuz_mastodon/mastodon.js';

host

type string

id

type string

returns

string

to_mastodon_status_url
#

mastodon.ts view source

(host: string, id: string): string import {to_mastodon_status_url} from '@fuzdev/fuz_mastodon/mastodon.js';

host

type string

id

type string

returns

string

to_mastodon_status_url_with_author
#

mastodon.ts view source

(host: string, id: string, author: string): string import {to_mastodon_status_url_with_author} from '@fuzdev/fuz_mastodon/mastodon.js';

host

type string

id

type string

author

type string

returns

string

to_mastodon_status_url_with_users_author
#

mastodon.ts view source

(host: string, id: string, author: string): string import {to_mastodon_status_url_with_users_author} from '@fuzdev/fuz_mastodon/mastodon.js';

longhand for to_mastodon_status_url_with_author, apperas.

host

type string

id

type string

author

type string

returns

string

Toot
#

Toot.svelte view source

import Toot from '@fuzdev/fuz_mastodon/Toot.svelte';

url

type string

updated_url?

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

type string
optional bindable default url

include_ancestors?

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

type boolean
optional default false

include_replies?

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

type boolean
optional default false

reply_filter?

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

type ReplyFilter | ReplyFilter[] | CreateReplyFilters
optional

cache?

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

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

log?

Optional logger for network calls.

type Logger
optional

loading?

type boolean
optional bindable

load_time?

type number
optional bindable

settings_storage_key?

type string
optional

initial_show_settings?

type boolean
optional default false

show_settings?

type boolean
optional bindable

autoload_storage_key?

type string
optional default 'autoload'

initial_autoload?

type boolean
optional default false

autoload?

type boolean
optional default autoload_storage_key ? load_from_storage(autoload_storage_key, () => initial_autoload) : initial_autoload

onreset?

type () => void
optional

settings?

type Snippet<[]>
optional

TootInput
#

TootInput.svelte view source

import TootInput from '@fuzdev/fuz_mastodon/TootInput.svelte';

url

type string
bindable

attrs?

type HTMLInputAttributes
optional

TootLoader
#

TootLoader.svelte view source

accepts children

import TootLoader from '@fuzdev/fuz_mastodon/TootLoader.svelte';

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 default false

include_replies?

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

type boolean
optional default false

cache?

Optional API result cache.

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

log?

Optional logger for network calls.

type Logger
optional

loading?

type boolean
optional bindable

item?

optional bindable

status_context?

optional bindable

replies?

type MastodonStatus[]
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 | ReplyFilter[] | CreateReplyFilters
optional

load_time?

type number
optional bindable

children

type Snippet<[{ item: MastodonStatus | null | undefined; status_context: MastodonStatusContext | null | undefined; replies: MastodonStatus[] | null | undefined; load: () => Promise<...>; loading: boolean | undefined; load_time: number | undefined; }]>
snippet parameters
arg0 { item: MastodonStatus | null | undefined; status_context: MastodonStatusContext | null | undefined; replies: MastodonStatus[] | null | undefined; load: () => Promise<...>; loading: boolean | undefined; load_time: number | undefined; }