Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
8 changes: 7 additions & 1 deletion packages/dev/app/playground/buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { Button } from "@fedibtc/ui"

export default function Buttons() {
const sizes = ["md", "sm"] as const
const variants = ["primary", "secondary", "tertiary", "outline", "offWhite"] as const
const variants = [
"primary",
"secondary",
"tertiary",
"outline",
"offWhite"
] as const
const [isLoading, setIsLoading] = useState(false)
const [isDisabled, setIsDisabled] = useState(false)

Expand Down
5 changes: 3 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-toast": "^1.1.5",
"@tabler/icons-react": "^2.40.0",
"qr-scanner": "^1.4.2",
"nostr-tools": "^2.1.5",
"react-tailwind-variants": "^1.0.2"
"qr-scanner": "^1.4.2",
"react-tailwind-variants": "^1.0.2",
"tailwind-merge": "^3.4.0"
},
"devDependencies": {
"@fedibtc/tailwind-theme": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const fediAPIVersion = ["legacy", 0] as const
export const fediAPIVersion = ["legacy", 0, 1, 2] as const
88 changes: 86 additions & 2 deletions packages/ui/src/types/injection/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,47 @@ export interface FediAPIV0 {
getLanguageCode: () => Promise<string>
}

export interface FediAPIV1 extends Omit<FediAPIV0, "version"> {
version: 1
}

export interface FediAPIV2 extends Omit<FediAPIV0, "version"> {
version: 2
listCreatedCommunities: () => Promise<{
communities: RpcCommunity[]
}>
createCommunity(community: CreateCommunityRequest): Promise<
| { success: true; inviteCode: string }
| {
success: false
errors: Record<string, string[] | undefined>
}
>
joinCommunity(inviteCode: string): Promise<
| { success: true; community: RpcCommunity }
| {
success: false
errors: Record<string, string[] | undefined>
}
>
refreshCommunities(): Promise<void>
setSelectedCommunity(communityId: string): Promise<
| { success: true }
| {
success: false
errors: Record<string, string[] | undefined>
}
>
editCommunity(editCommunityRequest: EditCommunityRequest): Promise<
| { success: true }
| {
success: false
errors: Record<string, string[] | undefined>
}
>
selectPublicChats(): Promise<Array<string>>
}

// ! Do not update
/** The legacy Fedi API Version before the `version` number was introduced */
export interface FediAPILegacy {
Expand All @@ -23,6 +64,49 @@ export interface FediAPILegacy {
getLanguageCode?: FediAPIV0["getLanguageCode"]
}

export type RpcCommunity = {
communityInvite: RpcCommunityInvite
name: string
meta: { [key in string]?: string }
}

export type RpcNostrPubkey = { hex: string; npub: string }

export type RpcCommunityInvite =
// a created community with this tool will never be a legacy one
// | { type: "legacy"; invite_code_str: string; community_meta_url: string }
{
type: "nostr"
invite_code_str: string
author_pubkey: RpcNostrPubkey
community_uuid_hex: string
}

export type CreateCommunityRequest = {
welcome_message?: string
name: string
tos_url?: string
federation_icon_url?: string
invite_codes_disabled?: "true" | "false"
new_members_disabled?: "true" | "false"
preview_message?: string
pinned_message?: string
// Will get stringified before passing to the bridge
default_group_chats?: string[]
// Will get stringified before passing to the bridge
fedimods?: {
id: string
title: string
url: string
imageUrl: string
}[]
}

export type EditCommunityRequest = {
communityId: string
editedCommunity: CreateCommunityRequest
}

export interface AuthenticatedMemberResponse {
id: string
username: string
Expand All @@ -43,6 +127,6 @@ export interface GenerateEcashArgs {

export type BitcoinNetwork = "signet" | "bitcoin"

export type FediAPILatest = FediAPIV0
export type FediAPILatest = FediAPIV2

export type InjectionFediAPIProvider = FediAPILegacy | FediAPIV0
export type InjectionFediAPIProvider = FediAPILegacy | FediAPIV0 | FediAPIV1 | FediAPIV2