Download packages/tui/src/context/location.tsx from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 562 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/src/context/location.tsx
- Command line
-
hf download hf://SaylorTwift/opencode/packages/tui/src/context/location.tsx
-
curl -L -o location.tsx https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/src/context/location.tsx
562 Bytes
| import type { LocationRef } from "@opencode-ai/sdk/v2" | |
| import { createContext, useContext, type Accessor, type ParentProps } from "solid-js" | |
| const context = createContext<Accessor<LocationRef | undefined>>() | |
| export function LocationProvider(props: ParentProps<{ location?: LocationRef }>) { | |
| return <context.Provider value={() => props.location}>{props.children}</context.Provider> | |
| } | |
| export function useLocation() { | |
| const value = useContext(context) | |
| if (!value) throw new Error("Location context must be used within a LocationProvider") | |
| return value | |
| } | |