MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / rewriteStyleBlocks

Function rewriteStyleBlocks

packages/cli/src/utils/publishProject.ts:266–292  ·  view source on GitHub ↗
(
  ctx: ExternalAssetContext,
  document: Document,
  referrerAbsDir: string,
  entryPath: string,
)

Source from the content-addressed store, hash-verified

264}
265
266function rewriteStyleBlocks(
267 ctx: ExternalAssetContext,
268 document: Document,
269 referrerAbsDir: string,
270 entryPath: string,
271): boolean {
272 let modified = false;
273 for (const styleEl of document.querySelectorAll("style")) {
274 const css = styleEl.textContent || "";
275 if (!css.includes("url(")) continue;
276 const result = rewriteCssUrls(ctx, css, referrerAbsDir, entryPath);
277 if (result.modified) {
278 styleEl.textContent = result.css;
279 modified = true;
280 }
281 }
282 for (const el of document.querySelectorAll("[style]")) {
283 const style = el.getAttribute("style") || "";
284 if (!style.includes("url(")) continue;
285 const result = rewriteCssUrls(ctx, style, referrerAbsDir, entryPath);
286 if (result.modified) {
287 el.setAttribute("style", result.css);
288 modified = true;
289 }
290 }
291 return modified;
292}
293
294function localizeHtmlEntry(ctx: ExternalAssetContext, entryPath: string, content: Buffer): void {
295 const referrerAbsDir = resolve(ctx.absProjectDir, dirname(entryPath));

Callers 1

localizeHtmlEntryFunction · 0.85

Calls 3

rewriteCssUrlsFunction · 0.85
getAttributeMethod · 0.65
setAttributeMethod · 0.65

Tested by

no test coverage detected