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

Function hoistCompositionScripts

packages/core/src/compiler/htmlBundler.ts:655–697  ·  view source on GitHub ↗
(
  container: { querySelectorAll: (sel: string) => NodeListOf<Element> },
  opts: {
    projectDir: string;
    document: Document;
    compId: string | null;
    runtimeScope: string | undefined;
    runtimeCompId: string | undefined;
    authoredRootId: string | undefined;
    seenCompScriptSrcs: Set<string>;
    compScriptChunks: string[];
  },
)

Source from the content-addressed store, hash-verified

653}
654
655function hoistCompositionScripts(
656 container: { querySelectorAll: (sel: string) => NodeListOf<Element> },
657 opts: {
658 projectDir: string;
659 document: Document;
660 compId: string | null;
661 runtimeScope: string | undefined;
662 runtimeCompId: string | undefined;
663 authoredRootId: string | undefined;
664 seenCompScriptSrcs: Set<string>;
665 compScriptChunks: string[];
666 },
667): void {
668 for (const scriptEl of [...container.querySelectorAll("script")]) {
669 const externalSrc = (scriptEl.getAttribute("src") || "").trim();
670 if (externalSrc) {
671 hoistExternalScript(
672 externalSrc,
673 opts.projectDir,
674 opts.document,
675 opts.seenCompScriptSrcs,
676 opts.compScriptChunks,
677 );
678 } else {
679 opts.compScriptChunks.push(
680 opts.compId
681 ? wrapScopedCompositionScript(
682 scriptEl.textContent || "",
683 opts.compId,
684 "[HyperFrames] composition script error:",
685 opts.runtimeScope,
686 opts.runtimeCompId || opts.compId,
687 opts.authoredRootId,
688 )
689 : wrapInlineScriptWithErrorBoundary(
690 scriptEl.textContent || "",
691 "[HyperFrames] composition script error:",
692 ),
693 );
694 }
695 scriptEl.remove();
696 }
697}
698
699export async function bundleToSingleHtml(
700 projectDir: string,

Callers 1

bundleToSingleHtmlFunction · 0.85

Calls 4

hoistExternalScriptFunction · 0.85
getAttributeMethod · 0.65

Tested by

no test coverage detected