MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / classifyRenderableSource

Function classifyRenderableSource

packages/runtime/src/index.ts:76–87  ·  view source on GitHub ↗
(
  source: string,
  path?: string | undefined,
)

Source from the content-addressed store, hash-verified

74}
75
76export function classifyRenderableSource(
77 source: string,
78 path?: string | undefined,
79): RenderableSourceKind {
80 if (looksLikeFullHtmlDocument(source)) return 'html';
81 const ext = extensionKind(path);
82 if (ext === 'tsx') return 'tsx';
83 if (ext === 'jsx') return 'jsx';
84 if (looksLikeJsxSource(source)) return 'jsx';
85 if (ext === 'html') return 'html';
86 return 'unknown';
87}
88
89export function isRenderableSourceKind(kind: RenderableSourceKind): kind is 'html' | 'jsx' | 'tsx' {
90 return kind === 'html' || kind === 'jsx' || kind === 'tsx';

Callers 7

shouldRenderForStaticDomFunction · 0.90
index.test.tsFile · 0.90
inferPreviewSourcePathFunction · 0.90
referencedSourcePathFunction · 0.90
requiresPreviewScriptsFunction · 0.85
buildPreviewDocumentFunction · 0.85
buildStandaloneDocumentFunction · 0.85

Calls 3

extensionKindFunction · 0.85
looksLikeJsxSourceFunction · 0.85

Tested by

no test coverage detected