diff --git a/packages/core/src/compiler/htmlBundler.test.ts b/packages/core/src/compiler/htmlBundler.test.ts
index 2d0005ad58..7011c39482 100644
--- a/packages/core/src/compiler/htmlBundler.test.ts
+++ b/packages/core/src/compiler/htmlBundler.test.ts
@@ -2679,6 +2679,27 @@ describe("bundleToSingleHtml", () => {
}
});
+ it("reads a timeline registered by a local script, as hyperframes lint does", async () => {
+ const dir = makeTempProject({
+ "index.html": `
+
+
+`,
+ "timeline.js": `window.__timelines = window.__timelines || {};
+window.__timelines.root = { duration: () => 1, seek() {}, pause() {} };`,
+ });
+ const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
+ try {
+ await bundleToSingleHtml(dir);
+ const guard = warnSpy.mock.calls
+ .map((call) => String(call[0] ?? ""))
+ .filter((line) => line.includes("[StaticGuard]"));
+ expect(guard).toEqual([]);
+ } finally {
+ warnSpy.mockRestore();
+ }
+ });
+
it("runs the StaticGuard lint unless staticGuard is false", async () => {
const dir = makeTempProject({
"index.html": `
diff --git a/packages/core/src/compiler/staticGuard.ts b/packages/core/src/compiler/staticGuard.ts
index d13be15214..42c0e0c5d1 100644
--- a/packages/core/src/compiler/staticGuard.ts
+++ b/packages/core/src/compiler/staticGuard.ts
@@ -1,4 +1,4 @@
-import { collectExternalStyles, lintHyperframeHtml } from "@hyperframes/lint";
+import { linkedSources, lintHyperframeHtml } from "@hyperframes/lint";
export type HyperframeStaticFailureReason =
| "missing_composition_id"
@@ -19,9 +19,7 @@ export async function validateHyperframeHtmlContract(
): Promise {
const result = await lintHyperframeHtml(
html,
- project && {
- externalStyles: collectExternalStyles(project.dir, html, project.compSrcPath),
- },
+ project && linkedSources(project.dir, html, project.compSrcPath),
);
const missingKeys = result.findings
.filter((finding) => finding.severity === "error")
diff --git a/packages/lint/src/index.ts b/packages/lint/src/index.ts
index a862a6e8ee..7752ca4334 100644
--- a/packages/lint/src/index.ts
+++ b/packages/lint/src/index.ts
@@ -11,7 +11,7 @@ export {
LINT_RULE_COUNT,
LINT_RULE_GROUP_COUNTS,
} from "./hyperframeLinter.js";
-export { collectExternalStyles, lintProject, shouldBlockRender } from "./project.js";
+export { linkedSources, lintProject, shouldBlockRender } from "./project.js";
export type { ProjectLintResult } from "./project.js";
export { projectIgnore } from "./projectIgnore.js";
export { audioAttributeShapeError, type AudioAttribute } from "./rules/audioAttributes.js";
diff --git a/packages/lint/src/project.ts b/packages/lint/src/project.ts
index efa00370b2..d1c57a339b 100644
--- a/packages/lint/src/project.ts
+++ b/packages/lint/src/project.ts
@@ -140,7 +140,7 @@ function collectLocalStylesheets(
return styles;
}
-export function collectExternalStyles(
+function collectExternalStyles(
projectDir: string,
html: string,
compSrcPath?: string,
@@ -159,6 +159,17 @@ export function collectExternalStyles(
const MAX_EXTERNAL_SCRIPT_BYTES = 1_000_000;
+export function linkedSources(
+ projectDir: string,
+ html: string,
+ compSrcPath?: string,
+): Pick {
+ return {
+ externalStyles: collectExternalStyles(projectDir, html, compSrcPath),
+ externalScripts: collectExternalScripts(projectDir, html, compSrcPath),
+ };
+}
+
function collectExternalScripts(
projectDir: string,
html: string,
@@ -304,9 +315,8 @@ export async function lintProject(
...hostOptions,
filePath: indexPath,
compSrcPath: rootFile,
- externalStyles: collectExternalStyles(projectDir, rootHtml, rootCompSrcPath),
+ ...linkedSources(projectDir, rootHtml, rootCompSrcPath),
projectFontFamilies,
- externalScripts: collectExternalScripts(projectDir, rootHtml, rootCompSrcPath),
});
results.push({ file: rootFile, result: rootResult, contentHash: contentDigest(rootHtml) });
totalErrors += rootResult.errorCount;
@@ -350,9 +360,8 @@ export async function lintProject(
filePath,
isSubComposition: true,
compSrcPath,
- externalStyles: collectExternalStyles(projectDir, html, compSrcPath),
+ ...linkedSources(projectDir, html, compSrcPath),
projectFontFamilies,
- externalScripts: collectExternalScripts(projectDir, html, compSrcPath),
});
results.push({
file: `compositions/${file}`,