Update docs

This commit is contained in:
Jon Staab
2026-06-10 14:12:47 -07:00
parent a33af11b1b
commit dbd043f105
35 changed files with 164 additions and 179 deletions
+2 -2
View File
@@ -52,8 +52,8 @@ pin(tag: string[]): Promise<Thunk>
```typescript
type SendWrappedOptions = Omit<ThunkOptions, "event" | "relays"> & {
template: EventTemplate
pubkeys: string[]
event: EventTemplate
recipients: string[]
}
sendWrapped(options: SendWrappedOptions): Promise<MergedThunk>
+1 -1
View File
@@ -52,7 +52,7 @@ const thunk = publishThunk({
thunk.controller.abort()
// Some commands are included
const thunk = follow('97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322')
const thunk = follow(['p', '97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322'])
// Load events as a promise
const events = await load({
+8 -12
View File
@@ -61,14 +61,14 @@ Several common collections are built-in and ready for use:
profiles profilesByPubkey deriveProfile loadProfile
// Lists
follows followsByPubkey deriveFollows loadFollows
mutes mutesByPubkey deriveMutes loadMutes
pins pinsByPubkey derivePins loadPins
followLists followListsByPubkey deriveFollowList loadFollowList
muteLists muteListsByPubkey deriveMuteList loadMuteList
pinLists pinListsByPubkey derivePinList loadPinList
// Relays
relays relaysByUrl deriveRelay loadRelay
relayLists relayListsByPubkey deriveRelayLists loadRelayLists
messagingRelayLists messagingRelayListsByPubkey deriveMessagingRelayLists loadMessagingRelayLists
relayLists relayListsByPubkey deriveRelayList loadRelayList
messagingRelayLists messagingRelayListsByPubkey deriveMessagingRelayList loadMessagingRelayList
// Identity
handles handlesByNip05 deriveHandle loadHandle
@@ -97,24 +97,20 @@ const name = deriveProfileDisplay(pubkey)
Several modules provide user-specific derived stores that automatically load data for the currently signed-in user:
```typescript
import { userProfile, userFollows, userMutes, userPins } from '@welshman/app'
import { userProfile, userFollowList, userMuteList, userPinList } from '@welshman/app'
userProfile.subscribe(profile => {
// Current user's profile data
})
userFollows.subscribe(follows => {
userFollowList.subscribe(follows => {
// Current user's follow list
})
```
### Repository Integration
All events from subscriptions are automatically:
- Saved to the repository
- Tracked to their source relay
- Checked against deletion status
Events from subscriptions are automatically tracked to their source relay and saved to the repository, unless they are DVM-kind or ephemeral events (which are discarded). WRAP (kind 1059) events are handled separately and only processed when `shouldUnwrap` is set to `true`.
The repository serves as an intelligent cache layer, making subsequent queries for the same data faster.
+3 -2
View File
@@ -63,10 +63,11 @@ Several thunk factories are provided for common or more complicated scenarios li
- `unfollow(value: string)`
- `follow(tag: string[])`
- `unmute(value: string)`
- `mute(tag: string[])`
- `mutePublicly(tag: string[])`
- `mutePrivately(tag: string[])`
- `unpin(value: string)`
- `pin(tag: string[])`
- `sendWrapped({template, pubkeys, ...options}: SendWrappedOptions)`
- `sendWrapped({event, recipients, ...options}: SendWrappedOptions)`
- `manageRelay(url: string, request: ManagementRequest)`
- `createRoom(url: string, room: RoomMeta)`
- `deleteRoom(url: string, room: RoomMeta)`
+1 -1
View File
@@ -174,7 +174,7 @@ getNip55().then(signerApps => {
A fun feature of nostr is that you can log in as other people, and see what nostr is like from their perspective (minus encrypted data or course).
```typescript
import {loginWithPubkey} from "@welshman/signer"
import {loginWithPubkey} from "@welshman/app"
// Log in as hodlbod
loginWithPubkey("97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322")
+31 -38
View File
@@ -2,25 +2,6 @@
The User Data module provides utilities for loading and managing user-specific data like profiles, follows, mutes, pins, and relay selections. It includes both reactive stores and manual loading functions.
## Types
### UserDataLoader
```typescript
type UserDataLoader = (pubkey: string, relays?: string[], force?: boolean) => unknown
```
Function type for loading user data with optional relay specification and force refresh.
### MakeUserDataOptions
```typescript
type MakeUserDataOptions<T> = {
mapStore: Readable<Map<string, T>>
loadItem: UserDataLoader
}
```
Configuration for creating user data stores.
## User Data Stores
These reactive stores automatically load and cache user data:
@@ -30,56 +11,68 @@ These reactive stores automatically load and cache user data:
export const userProfile: Store<Profile | undefined>
// User follows list
export const userFollows: Store<List | undefined>
export const userFollowList: Store<List | undefined>
// User mutes list
export const userMutes: Store<List | undefined>
export const userMuteList: Store<List | undefined>
// User pins list
export const userPins: Store<List | undefined>
export const userPinList: Store<List | undefined>
// User relay selections
export const userRelayLists: Store<List | undefined>
export const userRelayList: Store<List | undefined>
// User messaging relay selections
export const userMessagingRelayLists: Store<List | undefined>
export const userMessagingRelayList: Store<List | undefined>
// User blossom servers
export const userBlossomServers: Store<List | undefined>
export const userBlossomServerList: Store<List | undefined>
```
## Manual Loading Functions
These functions allow manual loading of user data with optional relay specification and force refresh:
These functions load user data for the currently signed-in user with optional relay hints:
```typescript
// Load user profile
function loadUserProfile(relays?: string[], force?: boolean): Promise<void>
function loadUserProfile(relays?: string[]): Promise<void>
// Load user follows
function loadUserFollows(relays?: string[], force?: boolean): Promise<void>
function loadUserFollowList(relays?: string[]): Promise<void>
// Load user mutes
function loadUserMutes(relays?: string[], force?: boolean): Promise<void>
function loadUserMuteList(relays?: string[]): Promise<void>
// Load user pins
function loadUserPins(relays?: string[], force?: boolean): Promise<void>
function loadUserPinList(relays?: string[]): Promise<void>
// Load user relay selections
function loadUserRelayLists(relays?: string[], force?: boolean): Promise<void>
function loadUserRelayList(relays?: string[]): Promise<void>
// Load user messaging relay selections
function loadUserMessagingRelayLists(relays?: string[], force?: boolean): Promise<void>
function loadUserMessagingRelayList(relays?: string[]): Promise<void>
// Load user blossom servers
function loadUserBlossomServers(relays?: string[], force?: boolean): Promise<void>
function loadUserBlossomServerList(relays?: string[]): Promise<void>
```
Force-reload variants bypass the cache and always fetch fresh data:
```typescript
function forceLoadUserProfile(relays?: string[]): Promise<void>
function forceLoadUserFollowList(relays?: string[]): Promise<void>
function forceLoadUserMuteList(relays?: string[]): Promise<void>
function forceLoadUserPinList(relays?: string[]): Promise<void>
function forceLoadUserRelayList(relays?: string[]): Promise<void>
function forceLoadUserMessagingRelayList(relays?: string[]): Promise<void>
function forceLoadUserBlossomServerList(relays?: string[]): Promise<void>
```
## Usage Examples
### Using Reactive Stores
```typescript
import { userProfile, userFollows } from '@welshman/app'
import { userProfile, userFollowList } from '@welshman/app'
// Subscribe to user profile changes
userProfile.subscribe(profile => {
@@ -89,18 +82,18 @@ userProfile.subscribe(profile => {
})
// Get current follows list
const follows = userFollows.get()
const follows = userFollowList.get()
```
### Manual Loading
```typescript
import { loadUserMutes, loadUserRelayLists } from '@welshman/app'
import { loadUserMuteList, forceLoadUserRelayList } from '@welshman/app'
// Load user mutes from specific relays
await loadUserMutes(['wss://relay1.com', 'wss://relay2.com'])
await loadUserMuteList(['wss://relay1.com', 'wss://relay2.com'])
// Force refresh user relay selections
await loadUserRelayLists([], true)
await forceLoadUserRelayList([])
// Load from default relays
await loadUserProfile()
+1 -1
View File
@@ -53,7 +53,7 @@ followersByPubkey: Readable<Map<string, Set<string>>>
mutersByPubkey: Readable<Map<string, Set<string>>>
// The full WOT graph with scores (pubkey → score)
wotGraph: Readable<Map<string, number>>
wotGraph: Writable<Map<string, number>>
// The maximum WOT score in the graph
maxWot: Readable<number>