Buckets:
| import type { TuiPluginApi, TuiRouteDefinition } from "@opencode-ai/plugin/tui" | |
| import { createSignal } from "solid-js" | |
| type RouteEntry = { | |
| key: symbol | |
| render: TuiRouteDefinition["render"] | |
| } | |
| export type RouteMap = Map<string, RouteEntry[]> | |
| export function createPluginRoutes() { | |
| const routes: RouteMap = new Map() | |
| const [revision, setRevision] = createSignal(0) | |
| return { | |
| register(list: TuiRouteDefinition[]) { | |
| const key = Symbol() | |
| list.forEach((item) => routes.set(item.name, [...(routes.get(item.name) ?? []), { key, render: item.render }])) | |
| setRevision((value) => value + 1) | |
| return () => { | |
| list.forEach((item) => { | |
| const next = routes.get(item.name)?.filter((entry) => entry.key !== key) ?? [] | |
| if (next.length) { | |
| routes.set(item.name, next) | |
| return | |
| } | |
| routes.delete(item.name) | |
| }) | |
| setRevision((value) => value + 1) | |
| } | |
| }, | |
| get(name: string) { | |
| revision() | |
| return routes.get(name)?.at(-1)?.render | |
| }, | |
| } | |
| } | |
| export type PluginRoutes = ReturnType<typeof createPluginRoutes> | |
| export function createTuiApi(input: Omit<TuiPluginApi, "lifecycle">): TuiPluginApi { | |
| return { | |
| ...input, | |
| lifecycle: { | |
| signal: new AbortController().signal, | |
| onDispose() { | |
| return () => {} | |
| }, | |
| }, | |
| } | |
| } | |
Xet Storage Details
- Size:
- 1.36 kB
- Xet hash:
- 7eff856ff8ad29bff462205cb1b342bcd9dde585db36048999c157745ef42797
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.