MCPcopy Create free account
hub / github.com/anomalyco/opencode / createScopedKeymap

Function createScopedKeymap

packages/opencode/src/plugin/tui/runtime.ts:143–160  ·  view source on GitHub ↗
(keymap: TuiPluginApi["keymap"], scope: PluginScope)

Source from the content-addressed store, hash-verified

141}
142
143function createScopedKeymap(keymap: TuiPluginApi["keymap"], scope: PluginScope): TuiPluginApi["keymap"] {
144 const cache = new Map<PropertyKey, unknown>()
145 return new Proxy(keymap, {
146 get(target, prop) {
147 const value = Reflect.get(target, prop, target)
148 if (typeof value !== "function") return value
149 if (cache.has(prop)) return cache.get(prop)
150 const fn = ScopedKeymapMethods.has(prop)
151 ? (...args: unknown[]) => {
152 const dispose = (value as (...args: unknown[]) => unknown).apply(target, args)
153 return scope.track(typeof dispose === "function" ? (dispose as () => void) : undefined)
154 }
155 : (...args: unknown[]) => (value as (...args: unknown[]) => unknown).apply(target, args)
156 cache.set(prop, fn)
157 return fn
158 },
159 })
160}
161
162function createScopedAttention(
163 attention: TuiPluginApi["attention"],

Callers 1

pluginApiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected