MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / extractInlineSource

Function extractInlineSource

scripts/recover-project.mjs:177–208  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

175}
176
177function extractInlineSource(text) {
178 const matches = Array.from(
179 text.matchAll(
180 /\/\/# sourceMappingURL=data:application\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\s*$/gm,
181 ),
182 )
183 const encoded = matches.at(-1)?.[1]
184 if (!encoded) {
185 return null
186 }
187
188 try {
189 const decoded = Buffer.from(encoded, 'base64').toString('utf8')
190 const map = JSON.parse(decoded)
191 if (!Array.isArray(map.sourcesContent) || map.sourcesContent.length === 0) {
192 return null
193 }
194
195 const content =
196 typeof map.sourcesContent[0] === 'string' ? map.sourcesContent[0] : null
197 if (!content) {
198 return null
199 }
200
201 return {
202 content,
203 sourceName: Array.isArray(map.sources) ? map.sources[0] ?? null : null,
204 }
205 } catch {
206 return null
207 }
208}
209
210function collectDependencyRoots(sourceText, dependencyRoots) {
211 const patterns = [

Callers 1

mainFunction · 0.85

Calls 2

fromMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected