import { extractInlineFormatHeredocOpenerCommand, findInlineFormatHeredocRange, findInlineFormatHeredocRanges, type InlineFormatMatch, type InlineFormatPlugin, } from "@pi-inline-format/shared-contract"; export const TYPESCRIPT_HEREDOC_MARKERS = ["<<'TS'", '<<"TS"', "< 0) { return explicitRanges; } return findInlineFormatHeredocRanges(command).filter((range) => { const openerCommand = extractInlineFormatHeredocOpenerCommand( range.openerLine, ); return isTypeScriptHeredocOpener(openerCommand); }); } export function findTypeScriptHeredocRange(command: string): { startLineIndex: number; endLineIndex: number; } | null { return findTypeScriptHeredocRanges(command)[0] ?? null; } function detectTypeScriptHeredoc(command: string): InlineFormatMatch[] | null { const heredocRanges = findTypeScriptHeredocRanges(command); if (heredocRanges.length === 0) { return null; } return heredocRanges.map((heredocRange) => ({ pluginName: "typescript", language: "typescript", startLineIndex: heredocRange.startLineIndex + 1, endLineIndex: heredocRange.endLineIndex - 1, })); } export const typescriptInlineFormatPlugin: InlineFormatPlugin = { name: "typescript", language: "typescript", detect: detectTypeScriptHeredoc, };