atmosphere explorer
pds.ls
tool
typescript
atproto
1import { Client } from "@atcute/client";
2import { DidDocument } from "@atcute/identity";
3import { Accessor, createContext, useContext } from "solid-js";
4
5export interface RepoContextValue {
6 did: Accessor<string>;
7 pds: Accessor<string | undefined>;
8 rpc: Accessor<Client | undefined>;
9 didDoc: Accessor<DidDocument | undefined>;
10 error: Accessor<string | undefined>;
11}
12
13const RepoContext = createContext<RepoContextValue>();
14
15export const RepoProvider = RepoContext.Provider;
16
17export const useRepo = () => {
18 const ctx = useContext(RepoContext);
19 if (!ctx) throw new Error("useRepo must be used within RepoProvider");
20 return ctx;
21};