Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/commands/check.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { terminalText } from "@hyperframes/core";
import { captureArtifactRevision } from "../utils/artifactCapture.js";
import { pngDimensions } from "../utils/pngDimensions.js";
import { randomUUID } from "node:crypto";
Expand All @@ -18,7 +19,6 @@ import type { ArgsDef } from "citty";
import type { Example } from "./_examples.js";
import { parseAt } from "./layout.js";
import { c } from "../ui/colors.js";
import { terminalText } from "../utils/terminalText.js";
import { registerBrowserSessionCleanup } from "../browser/launch.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { CliUsageError, failUsage, setCommandExitCode } from "../utils/commandResult.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/compositions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { terminalText } from "@hyperframes/core";
import { defineCommand } from "../utils/defineCommand.js";
import type { Example } from "./_examples.js";
import { readFileSync } from "node:fs";
Expand All @@ -15,7 +16,6 @@ import { ensureDOMParser } from "../utils/dom.js";
import { resolveProject } from "../utils/project.js";
import { resolveReferencedStart } from "@hyperframes/engine";
import { withMeta } from "../utils/updateCheck.js";
import { terminalText } from "../utils/terminalText.js";

interface CompositionInfo {
id: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ export const examples: Example[] = [
["List the clips the render hears, on the film's clock", "hyperframes info --media --json"],
];
import { join } from "node:path";
import { parseHtml, CANVAS_DIMENSIONS } from "@hyperframes/core";
import { parseHtml, CANVAS_DIMENSIONS, terminalText } from "@hyperframes/core";
import {
findRootCompositionElement,
readCompositionSize,
} from "@hyperframes/core/runtime/composition-length";
import { readDataDurationSeconds } from "@hyperframes/parsers/media-duration";
import { heardClips } from "../utils/projectMedia.js";
import { terminalText } from "../utils/terminalText.js";
import { c } from "../ui/colors.js";
import { formatBytes, label } from "../ui/format.js";
import { ensureDOMParser } from "../utils/dom.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/keyframes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { terminalText } from "@hyperframes/core";
import { defineCommand } from "../utils/defineCommand.js";
import { existsSync, readFileSync } from "node:fs";
import { isWithinProjectRoot, readProjectFile } from "@hyperframes/parsers/asset-resolution";
Expand All @@ -9,7 +10,6 @@ import {
} from "@hyperframes/core/gsap-parser";
import type { Example } from "./_examples.js";
import { c } from "../ui/colors.js";
import { terminalText } from "../utils/terminalText.js";
import { ensureDOMParser } from "../utils/dom.js";
import { resolveProject } from "../utils/project.js";
import { withMeta } from "../utils/updateCheck.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/lint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { terminalText } from "@hyperframes/core";
import { setCommandExitCode } from "../utils/commandResult.js";
import { defineCommand } from "../utils/defineCommand.js";
import type { Example } from "./_examples.js";
Expand All @@ -18,7 +19,6 @@ import { isUnderCompositions, resolveLintTarget } from "../utils/project.js";
import { trackLintRun } from "../telemetry/lintRun.js";
import { getRunId } from "../telemetry/runId.js";
import { withMeta } from "../utils/updateCheck.js";
import { terminalText } from "../utils/terminalText.js";

export default defineCommand({
meta: {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
sourceTimeAt,
timeAtSourceTime,
type RateSpec,
terminalText,
} from "@hyperframes/core";
import { parseHTML } from "linkedom";
import { resolveProject } from "../utils/project.js";
Expand All @@ -101,7 +102,6 @@ import { normalizeErrorMessage, atStep } from "../utils/errorMessage.js";
import { describeSharpLoadFailure } from "../utils/sharpLoadFailure.js";
import { serveStaticProjectHtml } from "../utils/staticProjectServer.js";
import { c } from "../ui/colors.js";
import { terminalText } from "../utils/terminalText.js";
import { writeCaptureFileSync } from "../capture/captureFile.js";
import { runCancellableProcess } from "../utils/cancellableProcess.js";
import { findFFmpeg, findFFprobe, getFFmpegInstallHint } from "../browser/ffmpeg.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/server/studioServer.renderBrowser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createStudioServer, type StudioServer } from "./studioServer.js";
import { terminalText } from "../utils/terminalText.js";
import { terminalText } from "@hyperframes/core";

const mocks = vi.hoisted(() => ({
resolveRenderBrowser: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/layoutAudit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { terminalText } from "@hyperframes/core";
import { formatFindingTimes } from "./checkFindings.js";
import { terminalText } from "./terminalText.js";
export interface LayoutRect {
left: number;
top: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/leftOutReference.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dirname, join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { stagePublishFiles } from "./publishProject.js";
import type { LeftOutReference } from "./leftOutReference.js";
import { terminalText } from "./terminalText.js";
import { terminalText } from "@hyperframes/core";

const dirs: string[] = [];
afterEach(() => dirs.splice(0).forEach((dir) => rmSync(dir, { recursive: true, force: true })));
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/leftOutReference.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { terminalText } from "@hyperframes/core";
import { isAbsolute, relative } from "node:path";
import {
type LeftOutReason,
leftOutWarning as leftOutText,
} from "@hyperframes/studio-server/outside-file";
import { realFilePath } from "@hyperframes/studio-server/safe-path";
import { namesAnotherNetworkRoot } from "@hyperframes/parsers/asset-resolution";
import { terminalText } from "./terminalText.js";

export type { LeftOutReason };

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/lintFormat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { terminalText } from "@hyperframes/core";
import { c } from "../ui/colors.js";
import { terminalText } from "./terminalText.js";
import type { ProjectLintResult } from "./lintProject.js";

export interface LintFormatOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/receivedRender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { compileForRender } from "../../../producer/src/services/htmlCompiler.js";
import { outsideAssetsAllowed } from "./receivedRender.js";
import { terminalText } from "./terminalText.js";
import { terminalText } from "@hyperframes/core";

const SIGNATURES = {
png: Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0, 0, 0, 0x0d]),
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/utils/receivedRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import {
import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { parseHTML } from "linkedom";
import { isNonRelativeUrl, isPathInside } from "@hyperframes/core";
import { isNonRelativeUrl, isPathInside, terminalText } from "@hyperframes/core";
import {
namesAnotherNetworkRoot,
resolveCompositionSrc,
} from "@hyperframes/parsers/asset-resolution";
import { linksOutside, receivedRecordStatus } from "./privateProjectFile.js";
import { terminalText } from "./terminalText.js";
import { walkBudget } from "./walkBudget.js";

const REFERENCE_ATTRS = ["src", "href", "poster"];
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/atomicFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createHash, randomBytes } from "node:crypto";
import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
import { realpath } from "./safePath.js";
import { renameWithRetry } from "./renameWithRetry.js";
import { terminalText } from "./terminalText.js";

type SiblingFileSystem = Pick<typeof fs, "writeFileSync" | "chmodSync" | "unlinkSync">;
type DirectFileSystem = SiblingFileSystem & Pick<typeof fs, "openSync" | "closeSync">;
Expand Down Expand Up @@ -91,7 +92,11 @@ export function createFileAtomically(
try {
operations.unlinkSync(tempPath);
} catch (error) {
console.warn(`[hyperframes] created ${filePath} but could not remove ${tempPath}: ${error}`);
console.warn(
terminalText(
`[hyperframes] created ${filePath} but could not remove ${tempPath}: ${error}`,
),
);
}
});
}
Expand Down
55 changes: 55 additions & 0 deletions packages/core/src/compiler/htmlBundler.terminalText.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { bundleToSingleHtml } from "./htmlBundler";

afterEach(() => {
vi.restoreAllMocks();
});

describe("bundler warnings that name project files", () => {
it.each([
["raw", "sub\u001b]0;title\u0007\u001b[2K.html"],
["as numeric entities", "sub&#27;]0;title&#7;&#27;[2K.html"],
])(
"write control characters in a sub-composition path out as visible escapes (%s)",
async (_, src) => {
const dir = mkdtempSync(join(tmpdir(), "hf-bundler-terminal-"));
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
try {
writeFileSync(
join(dir, "index.html"),
`<html><body><main data-composition-id="root" data-width="320" data-height="180"><div data-composition-id="sub" data-composition-src="${src}"></div></main></body></html>`,
);
await bundleToSingleHtml(dir, { runtime: "placeholder" });
} finally {
rmSync(dir, { recursive: true, force: true });
}

const printed = warn.mock.calls.map((call) => call.join(" ")).join("\n");
expect(printed).toContain("Skipping sub-composition");
expect(printed).toContain("\\x1b]0;title\\x07");
for (const control of ["\u001b", "\u0007"]) expect(printed).not.toContain(control);
},
);

it("write control characters in an inline template's id out as visible escapes when its import map is skipped", async () => {
const dir = mkdtempSync(join(tmpdir(), "hf-bundler-terminal-"));
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
const id = "sc&#27;]0;title&#7;";
try {
writeFileSync(
join(dir, "index.html"),
`<html><body><main data-composition-id="root" data-width="320" data-height="180"><div data-composition-id="${id}"></div></main><template id="${id}-template"><div data-composition-id="${id}"><script type="importmap">{ not json</script></div></template></body></html>`,
);
await bundleToSingleHtml(dir, { runtime: "placeholder" });
} finally {
rmSync(dir, { recursive: true, force: true });
}

const printed = warn.mock.calls.map((call) => call.join(" ")).join("\n");
expect(printed).toContain("sc\\x1b]0;title\\x07: import map is not valid JSON");
for (const control of ["\u001b", "\u0007"]) expect(printed).not.toContain(control);
});
});
25 changes: 19 additions & 6 deletions packages/core/src/compiler/htmlBundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import { ensureHfIds } from "@hyperframes/parsers/hf-ids";
import { readTextFile } from "@hyperframes/parsers/asset-resolution";
import { HF_COLOR_GRADING_ATTR } from "../colorGrading";
import { assignMediaRenderIds } from "./mediaRenderIds";
import { terminalText } from "../terminalText.js";

const DEFAULT_RUNTIME_SCRIPT_URL = "";

Expand Down Expand Up @@ -382,13 +383,17 @@ function safeStatSize(filePath: string): number | null {
function warnAssetTooLargeToInline(assetPath: string, byteLength: number): void {
const mb = (byteLength / (1024 * 1024)).toFixed(1);
console.warn(
`[HyperFrames] Not inlining "${assetPath}" (${mb} MB exceeds the ${MAX_INLINE_ASSET_BYTES / (1024 * 1024)} MB inline limit). The bundle may not be self-contained.`,
terminalText(
`[HyperFrames] Not inlining "${assetPath}" (${mb} MB exceeds the ${MAX_INLINE_ASSET_BYTES / (1024 * 1024)} MB inline limit). The bundle may not be self-contained.`,
),
);
}

function warnInlineBudgetExhausted(assetPath: string): void {
console.warn(
`[HyperFrames] Not inlining "${assetPath}" and later assets: the bundle already inlines ${MAX_INLINED_BUNDLE_CHARS / (1024 * 1024)} MB of data URLs. The bundle may not be self-contained.`,
terminalText(
`[HyperFrames] Not inlining "${assetPath}" and later assets: the bundle already inlines ${MAX_INLINED_BUNDLE_CHARS / (1024 * 1024)} MB of data URLs. The bundle may not be self-contained.`,
),
);
}

Expand Down Expand Up @@ -461,7 +466,9 @@ function warnColorGradingLutNotInlined(lutSrc: string): void {
const trimmed = lutSrc.trim();
if (!isRelativeUrl(trimmed)) return;
console.warn(
`[HyperFrames] Could not inline color grading LUT "${trimmed}". The rendered bundle may not be self-contained.`,
terminalText(
`[HyperFrames] Could not inline color grading LUT "${trimmed}". The rendered bundle may not be self-contained.`,
),
);
}

Expand Down Expand Up @@ -1024,7 +1031,9 @@ function hoistCompositionScripts(
if (map) opts.importMaps.push(map);
else
console.warn(
`[HyperFrames] ${opts.compId}: import map is not valid JSON, so it is skipped.`,
terminalText(
`[HyperFrames] ${opts.compId}: import map is not valid JSON, so it is skipped.`,
),
);
} else if (!externalSrc && type === "module") {
const prelude = opts.compId ? scopedModulePrelude(opts.runtimeCompId || opts.compId) : "";
Expand Down Expand Up @@ -1137,7 +1146,9 @@ async function bundleProject(projectDir: string, options?: BundleOptions): Promi
});
if (!staticGuard.isValid) {
console.warn(
`[StaticGuard] Invalid HyperFrame contract: ${staticGuard.missingKeys.join("; ")}`,
terminalText(
`[StaticGuard] Invalid HyperFrame contract: ${staticGuard.missingKeys.join("; ")}`,
),
);
}
}
Expand Down Expand Up @@ -1226,7 +1237,9 @@ async function bundleProject(projectDir: string, options?: BundleOptions): Promi
scriptErrorLabel: "[HyperFrames] composition script error:",
onMissingComposition: (srcPath: string, reason?: string) => {
console.warn(
`[Bundler] Skipping sub-composition "${srcPath}": ${reason ?? "the file could not be found"}.`,
terminalText(
`[Bundler] Skipping sub-composition "${srcPath}": ${reason ?? "the file could not be found"}.`,
),
);
},
});
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/compiler/importMaps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { terminalText } from "../terminalText";

type SpecifierMap = Record<string, string | null>;

/** The subset of an import map a composition can declare. */
Expand Down Expand Up @@ -65,7 +67,9 @@ function mergeEntries(into: SpecifierMap, from: SpecifierMap | undefined, where:
});
} else if (into[specifier] !== url) {
console.warn(
`[HyperFrames] import map conflict for "${specifier}"${where}: keeping ${into[specifier]}, ignoring ${url}.`,
terminalText(
`[HyperFrames] import map conflict for "${specifier}"${where}: keeping ${into[specifier]}, ignoring ${url}.`,
),
);
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/compiler/inlineSubCompositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
extractedCompositionAssets,
} from "./compositionAssembly";
import { SCENE_NO_SWAP_ATTR, SCENE_PART_ATTR } from "../sceneParts";
import { terminalText } from "../terminalText";

// Anything a scene script can leave running, pending or registered outside its timeline, or that
// throws when run again: only the timeline is torn down when a scene is swapped, so when unsure, refuse.
Expand Down Expand Up @@ -625,7 +626,10 @@ export function inlineSubCompositions(
return authored.endsWith("/") && !urlLike.endsWith("/") ? `${urlLike}/` : urlLike;
});
if (map) importMaps.push(map);
else console.warn(`[HyperFrames] ${src}: import map is not valid JSON, so it is skipped.`);
else
console.warn(
terminalText(`[HyperFrames] ${src}: import map is not valid JSON, so it is skipped.`),
);
} else if (type === "module" && !externalSrc) {
const prelude = scriptCompositionId
? scopedModulePrelude(runtimeCompId || scopeCompId || scriptCompositionId, src)
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/figma/jsonl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { existsSync, readFileSync } from "node:fs";
import { terminalText } from "../terminalText";

/** Parse a .jsonl file into values, skipping blank/malformed lines. */
export function readJsonlValues(path: string): unknown[] {
Expand All @@ -12,7 +13,9 @@ export function readJsonlValues(path: string): unknown[] {
} catch {
// ponytail: skip malformed lines (partial write from a crash), but say
// so — a silent skip reads as "no record found" downstream.
console.warn(`skipping malformed jsonl line in ${path}: ${trimmed.slice(0, 40)}…`);
console.warn(
terminalText(`skipping malformed jsonl line in ${path}: ${trimmed.slice(0, 40)}…`),
);
}
}
return out;
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/fonts/deterministicFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
type FontDiagPath,
} from "./fontDiagnostics.js";
import { hyperframesCacheDir } from "../cacheDir.js";
import { terminalText } from "../terminalText.js";

export type { FontDiagnostics };

Expand Down Expand Up @@ -1879,8 +1880,8 @@ export interface FontLogger {
}

const STDERR_LOGGER: FontLogger = {
warn: (message) => console.warn(`[WARN] ${message}`),
info: (message) => console.error(`[INFO] ${message}`),
warn: (message) => console.warn(terminalText(`[WARN] ${message}`)),
info: (message) => console.error(terminalText(`[INFO] ${message}`)),
};

export interface InjectDeterministicFontFacesOptions {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,4 @@ export {
type MotionBlurFingerprint,
type MotionBlurFingerprintField,
} from "./motionBlurFingerprint.js";
export { terminalText } from "./terminalText.js";
5 changes: 4 additions & 1 deletion packages/engine/src/services/audioFxRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { createEnvelopeWalker } from "./audioVolumeEnvelope.js";
import { riffChunks, wavFormatTag } from "./wavChunks.js";
import { windowPrerollSeconds } from "./audioFxWarmup.js";
import type { AudioVolumeKeyframe } from "./audioMixer.types.js";
import { terminalText } from "@hyperframes/core";

export class AudioFxRenderError extends Error {
constructor(message: string) {
Expand Down Expand Up @@ -424,7 +425,9 @@ function chainPrerollSeconds(
);
if (capped) {
console.warn(
`Audio FX for track ${trackId}: the chain remembers longer than the ${limits.maxPrerollSeconds}s pre-roll cap, so its oldest repeats are cut at window seams`,
terminalText(
`Audio FX for track ${trackId}: the chain remembers longer than the ${limits.maxPrerollSeconds}s pre-roll cap, so its oldest repeats are cut at window seams`,
),
);
}
return seconds;
Expand Down
Loading
Loading