MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / resolveSrcSet

Function resolveSrcSet

frontend/app/element/markdown-util.ts:175–202  ·  view source on GitHub ↗
(srcSet: string, resolveOpts: MarkdownResolveOpts)

Source from the content-addressed store, hash-verified

173};
174
175export const resolveSrcSet = async (srcSet: string, resolveOpts: MarkdownResolveOpts): Promise<string> => {
176 if (!srcSet) return null;
177
178 // Parse the srcset
179 const candidates = parseSrcSet(srcSet);
180
181 // Resolve each URL in the array of candidates
182 const resolvedCandidates = await Promise.all(
183 candidates.map(async (candidate) => {
184 const resolvedUrl = await resolveRemoteFile(candidate.url, resolveOpts);
185 return {
186 ...candidate,
187 url: resolvedUrl,
188 };
189 })
190 );
191
192 // Reconstruct the srcset string
193 return resolvedCandidates
194 .map((candidate) => {
195 let part = candidate.url;
196 if (candidate.w) part += ` ${candidate.w}w`;
197 if (candidate.h) part += ` ${candidate.h}h`;
198 if (candidate.d) part += ` ${candidate.d}x`;
199 return part;
200 })
201 .join(", ");
202};

Callers 2

resolvePathFunction · 0.90
resolveFnFunction · 0.90

Calls 1

resolveRemoteFileFunction · 0.85

Tested by

no test coverage detected