| 1 | import { classifyMarkdownImageSource } from "@t3tools/client-runtime/markdown-images"; |
| 2 | import { |
| 3 | resolveMediaSource, |
| 4 | type ResolveMediaSourceInput, |
| 5 | } from "@t3tools/client-runtime/media-source"; |
| 6 | |
| 7 | /** A project draft names its workspace explicitly because it has no thread. */ |
| 8 | export function resolveMobileMarkdownMediaSource(href: string, input: ResolveMediaSourceInput) { |
| 9 | const media = resolveMediaSource(href, input); |
| 10 | if (media?.access !== "unavailable" || !input.workspaceRoot) return media; |
| 11 | const source = classifyMarkdownImageSource(href, input.workspaceRoot); |
| 12 | if (source._tag !== "WorkspaceFile") return media; |
| 13 | return { |
| 14 | ...media, |
| 15 | access: "environment" as const, |
| 16 | resource: { |
| 17 | _tag: "draft-workspace-file" as const, |
| 18 | cwd: input.workspaceRoot, |
| 19 | path: source.path, |
| 20 | }, |
| 21 | }; |
| 22 | } |