chore: refactoring and tests, splitting up files (#12495)

This commit is contained in:
Adam
2026-02-06 10:02:31 -06:00
committed by GitHub
parent a4bc883595
commit 2c58dd6203
117 changed files with 9457 additions and 5827 deletions
@@ -0,0 +1,26 @@
export const deepLinkEvent = "opencode:deep-link"
export const parseDeepLink = (input: string) => {
if (!input.startsWith("opencode://")) return
const url = new URL(input)
if (url.hostname !== "open-project") return
const directory = url.searchParams.get("directory")
if (!directory) return
return directory
}
export const collectOpenProjectDeepLinks = (urls: string[]) =>
urls.map(parseDeepLink).filter((directory): directory is string => !!directory)
type OpenCodeWindow = Window & {
__OPENCODE__?: {
deepLinks?: string[]
}
}
export const drainPendingDeepLinks = (target: OpenCodeWindow) => {
const pending = target.__OPENCODE__?.deepLinks ?? []
if (pending.length === 0) return []
if (target.__OPENCODE__) target.__OPENCODE__.deepLinks = []
return pending
}