mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(media-use): carve runs its own copy of core's analysis, never the project's (#7926)
* fix(media-use): carve runs its own copy of core's analysis, never the project's carve.mjs loaded @hyperframes/core from the composition's own node_modules, so carving a project ran whatever that project shipped under that name. It now imports a bundle of core's carve and audio-fx functions generated beside it, with a test that fails when the bundle drifts from core's source. * fix(media-use): lint and format skip the carve bundle on the CLI path too
This commit is contained in:
+3
-1
@@ -17,7 +17,9 @@
|
||||
"registry/blocks/frost-sequence-camera-orbit/source/**",
|
||||
"registry/examples/path-traced-3d/assets/vendor/*.min.js",
|
||||
"chrome/",
|
||||
"packages/cli/src/media-use/lib/svg-sanitize.mjs"
|
||||
"packages/cli/src/media-use/lib/svg-sanitize.mjs",
|
||||
"skills/media-use/audio/scripts/lib/audio-carve.mjs",
|
||||
"packages/cli/src/audio/scripts/lib/audio-carve.mjs"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
|
||||
@@ -59,3 +59,6 @@ skills/slideshow/SKILL.md
|
||||
skills/remotion-to-hyperframes/SKILL.md
|
||||
skills/reverse-any-video/SKILL.md
|
||||
skills/style-sampling/SKILL.md
|
||||
# scripts/generate-media-use-audio-carve.mjs — never hand-edit or reformat.
|
||||
skills/media-use/audio/scripts/lib/audio-carve.mjs
|
||||
packages/cli/src/audio/scripts/lib/audio-carve.mjs
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@
|
||||
"player:perf": "bun run --filter @hyperframes/player perf",
|
||||
"format:check": "oxfmt --check .",
|
||||
"knip": "knip",
|
||||
"test:scripts": "node --import tsx --test scripts/animejs-v4-guidance.test.mjs scripts/check-tracked-artifacts.test.mjs scripts/check-committed-keys.test.mjs scripts/check-symlinks.test.mjs scripts/upload-docs-images.test.mjs scripts/check-registry-set-delta.test.mjs scripts/check-no-main-deletions.test.mjs scripts/check-pr-captures.test.mjs scripts/check-comment-citations.test.mjs scripts/comments-workflow.test.mjs scripts/comment-ratchet.test.mjs scripts/check-docs-snippet-motion.test.mjs scripts/registry-target-paths.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-media-use-copy-parity.test.mjs scripts/check-svg-sanitize-parity.test.mjs scripts/check-media-use-svg-sanitize-generated.test.mjs scripts/check-package-cycles.test.mjs scripts/check-cli-process-ownership.test.mjs scripts/check-cli-lazy-deps.test.mjs scripts/file-url-paths.test.mjs scripts/check-studio-copy-dashes.test.mjs scripts/check-large-files.test.mjs scripts/check-registry-innerhtml.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/clawhub-sync.test.mjs scripts/clawhub-unlist-retired.test.mjs scripts/publish-workflow.test.mjs scripts/release-lambda-assets.test.mjs scripts/publish-main-only-workflows.test.mjs scripts/pr-edit-concurrency.test.mjs scripts/merge-queue-workflows.test.mjs scripts/ci-cache-workflows.test.mjs scripts/install-workspace-dependencies.test.mjs scripts/check-edit-accuracy-filter.test.mjs scripts/edit-accuracy-retry.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/catalog-payload-assets.test.ts scripts/host-registry-assets.test.ts scripts/catalog-preview-temp.test.ts scripts/backfill-block-previews.test.ts scripts/catalog-hosted-files.test.ts scripts/player-cdn-pin.test.ts scripts/registry-cdn-pins.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs scripts/rewrite-relative-import-extensions.test.mjs scripts/lint-skills.test.mjs scripts/check-core-skills.test.mjs scripts/creator-editing-recipes.test.mjs packages/gcp-cloud-run/check-dockerfile-workspaces.test.mjs packages/core/scripts/writeGeneratedFile.test.ts scripts/catalog-publication.test.mjs scripts/ci/resolve-workflow-pr.test.mjs scripts/lefthook-order.test.mjs scripts/inline-gsap.test.mjs scripts/ci/flake-gate.test.mjs scripts/ci/motion-blur-nightly-report.test.mjs scripts/ci/base-file.test.mjs scripts/ci/release-only-diff.test.mjs scripts/check-catalog-source-pr.test.mjs scripts/generate-registry-items.test.ts scripts/catalog-drift.test.ts scripts/catalog-fetch-mirror.test.ts scripts/catalog-script-inlining.test.ts scripts/catalog-detail.test.ts scripts/generate-catalog-pages.test.ts scripts/verify-catalog-payloads.test.ts scripts/registry-theme-fallbacks.test.ts scripts/registry-skill-files.test.ts scripts/creator-editing-capabilities.test.mjs scripts/generate-catalog-previews.test.ts scripts/registry-primitive-payloads.test.ts registry/components/pan-stations/pan-stations.test.mjs registry/components/filmed-screen/filmed-screen.test.mjs registry/components/echo-smear/echo-smear.test.mjs registry/examples/path-traced-3d/source/path-traced-3d.test.mjs && vitest run scripts/catalog/ scripts/contrastRatchet.test.ts scripts/generate-catalog-payloads.test.ts",
|
||||
"test:scripts": "node --import tsx --test scripts/animejs-v4-guidance.test.mjs scripts/check-tracked-artifacts.test.mjs scripts/check-committed-keys.test.mjs scripts/check-symlinks.test.mjs scripts/upload-docs-images.test.mjs scripts/check-registry-set-delta.test.mjs scripts/check-no-main-deletions.test.mjs scripts/check-pr-captures.test.mjs scripts/check-comment-citations.test.mjs scripts/comments-workflow.test.mjs scripts/comment-ratchet.test.mjs scripts/check-docs-snippet-motion.test.mjs scripts/registry-target-paths.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-media-use-copy-parity.test.mjs scripts/check-svg-sanitize-parity.test.mjs scripts/check-media-use-svg-sanitize-generated.test.mjs scripts/check-media-use-audio-carve-generated.test.mjs scripts/check-package-cycles.test.mjs scripts/check-cli-process-ownership.test.mjs scripts/check-cli-lazy-deps.test.mjs scripts/file-url-paths.test.mjs scripts/check-studio-copy-dashes.test.mjs scripts/check-large-files.test.mjs scripts/check-registry-innerhtml.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/clawhub-sync.test.mjs scripts/clawhub-unlist-retired.test.mjs scripts/publish-workflow.test.mjs scripts/release-lambda-assets.test.mjs scripts/publish-main-only-workflows.test.mjs scripts/pr-edit-concurrency.test.mjs scripts/merge-queue-workflows.test.mjs scripts/ci-cache-workflows.test.mjs scripts/install-workspace-dependencies.test.mjs scripts/check-edit-accuracy-filter.test.mjs scripts/edit-accuracy-retry.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/catalog-payload-assets.test.ts scripts/host-registry-assets.test.ts scripts/catalog-preview-temp.test.ts scripts/backfill-block-previews.test.ts scripts/catalog-hosted-files.test.ts scripts/player-cdn-pin.test.ts scripts/registry-cdn-pins.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs scripts/rewrite-relative-import-extensions.test.mjs scripts/lint-skills.test.mjs scripts/check-core-skills.test.mjs scripts/creator-editing-recipes.test.mjs packages/gcp-cloud-run/check-dockerfile-workspaces.test.mjs packages/core/scripts/writeGeneratedFile.test.ts scripts/catalog-publication.test.mjs scripts/ci/resolve-workflow-pr.test.mjs scripts/lefthook-order.test.mjs scripts/inline-gsap.test.mjs scripts/ci/flake-gate.test.mjs scripts/ci/motion-blur-nightly-report.test.mjs scripts/ci/base-file.test.mjs scripts/ci/release-only-diff.test.mjs scripts/check-catalog-source-pr.test.mjs scripts/generate-registry-items.test.ts scripts/catalog-drift.test.ts scripts/catalog-fetch-mirror.test.ts scripts/catalog-script-inlining.test.ts scripts/catalog-detail.test.ts scripts/generate-catalog-pages.test.ts scripts/verify-catalog-payloads.test.ts scripts/registry-theme-fallbacks.test.ts scripts/registry-skill-files.test.ts scripts/creator-editing-capabilities.test.mjs scripts/generate-catalog-previews.test.ts scripts/registry-primitive-payloads.test.ts registry/components/pan-stations/pan-stations.test.mjs registry/components/filmed-screen/filmed-screen.test.mjs registry/components/echo-smear/echo-smear.test.mjs registry/examples/path-traced-3d/source/path-traced-3d.test.mjs && vitest run scripts/catalog/ scripts/contrastRatchet.test.ts scripts/generate-catalog-payloads.test.ts",
|
||||
"typecheck:scripts": "tsc --noEmit -p scripts/tsconfig.json",
|
||||
"test:skills": "HYPERFRAMES_MEDIA_HOME_REQUIRED=1 node --import ./packages/cli/scripts/test-home.mjs --test 'skills/**/*.test.mjs' 'packages/cli/src/media-use/**/*.test.mjs'",
|
||||
"generate:previews": "tsx scripts/generate-template-previews.ts",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { describe, it } from "node:test";
|
||||
import { generate } from "./generate-media-use-audio-carve.mjs";
|
||||
|
||||
// The carve analysis lives in packages/core/src/audioCarve.ts and audioFx.ts; the skill's copy is a generated
|
||||
// bundle. This trips on a hand edit of the bundle or a source change that was not regenerated.
|
||||
describe("media-use audio-carve.mjs matches a fresh regeneration", () => {
|
||||
it("is byte-identical to `node scripts/generate-media-use-audio-carve.mjs`", async () => {
|
||||
const committed = readFileSync(
|
||||
resolve(import.meta.dirname, "../skills/media-use/audio/scripts/lib/audio-carve.mjs"),
|
||||
"utf8",
|
||||
);
|
||||
assert.equal(
|
||||
committed,
|
||||
await generate(),
|
||||
"skills/media-use/audio/scripts/lib/audio-carve.mjs is stale. Run: node scripts/generate-media-use-audio-carve.mjs",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env node
|
||||
// Bundles the carve analysis carve.mjs uses (packages/core/src/audioCarve.ts and audioFx.ts) into a single
|
||||
// import-free .mjs beside the skill, so the skill never loads @hyperframes/core from the project it edits.
|
||||
// Regenerate after editing the source: node scripts/generate-media-use-audio-carve.mjs
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, resolve } from "node:path";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const CORE_SRC = resolve(here, "../packages/core/src");
|
||||
const OUTFILE = resolve(here, "../skills/media-use/audio/scripts/lib/audio-carve.mjs");
|
||||
// scripts/ has no node_modules of its own (bun's per-consumer linking); reach into the one
|
||||
// package that already depends on esbuild rather than adding a root-level dependency.
|
||||
const { build } = await import(resolve(here, "../packages/core/node_modules/esbuild/lib/main.js"));
|
||||
|
||||
const ENTRY = `export {
|
||||
analyseCarveBands,
|
||||
analyseCarveDuck,
|
||||
carveBandsToChain,
|
||||
carveProfile,
|
||||
classifyAudioName,
|
||||
clipsOverlap,
|
||||
mixCarveSources,
|
||||
} from "./audioCarve.ts";
|
||||
export {
|
||||
defaultAudioFxParams,
|
||||
mintAudioFxNodeId,
|
||||
parseAudioFxChain,
|
||||
serializeAudioFxChain,
|
||||
} from "./audioFx.ts";
|
||||
`;
|
||||
|
||||
const HEADER = `// GENERATED: do not hand-edit. Source: packages/core/src/audioCarve.ts and audioFx.ts, bundled by
|
||||
// scripts/generate-media-use-audio-carve.mjs so carve.mjs runs the same analysis as Studio without
|
||||
// loading @hyperframes/core from the project. Regenerate: node scripts/generate-media-use-audio-carve.mjs
|
||||
`;
|
||||
|
||||
export async function generate() {
|
||||
const result = await build({
|
||||
stdin: {
|
||||
contents: ENTRY,
|
||||
resolveDir: CORE_SRC,
|
||||
loader: "ts",
|
||||
sourcefile: "audio-carve-entry.ts",
|
||||
},
|
||||
bundle: true,
|
||||
format: "esm",
|
||||
platform: "node",
|
||||
write: false,
|
||||
minify: true,
|
||||
legalComments: "none",
|
||||
});
|
||||
return HEADER + result.outputFiles[0].text;
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
const code = await generate();
|
||||
writeFileSync(OUTFILE, code);
|
||||
console.log(`wrote ${OUTFILE} (${code.length} bytes)`);
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
"files": 13
|
||||
},
|
||||
"media-use": {
|
||||
"hash": "71ce3fd61360ec79",
|
||||
"files": 127
|
||||
"hash": "bffe3f288782b86a",
|
||||
"files": 128
|
||||
},
|
||||
"remotion-to-hyperframes": {
|
||||
"hash": "e7982839c333759e",
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
* voice is analysed together, so a bed running under a narrator and an answer makes
|
||||
* room for both.
|
||||
*
|
||||
* Needs `ffmpeg` on PATH (to decode the audio) and `@hyperframes/core` resolvable
|
||||
* from the composition's project (`npm i -D @hyperframes/core`) — the CLI bundles
|
||||
* core inline rather than shipping it as a package, so it cannot be borrowed from
|
||||
* there.
|
||||
* Needs `ffmpeg` on PATH (to decode the audio). The analysis ships beside this
|
||||
* script (`lib/audio-carve.mjs`, generated from core), so nothing in the
|
||||
* composition's project is loaded.
|
||||
*/
|
||||
|
||||
import "../../scripts/lib/windows-exe-search.mjs";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { createRequire } from "node:module";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import * as carveApi from "./lib/audio-carve.mjs";
|
||||
import { isMainModule } from "./lib/main-module.mjs";
|
||||
|
||||
/** Sample rate the analysis runs at. Matches Studio's own decode rate, so the
|
||||
@@ -40,13 +38,12 @@ const SAMPLE_RATE = 48000;
|
||||
export const DEFAULT_STRENGTH = 0.8;
|
||||
|
||||
const usage = `carve.mjs --comp <file.html> [--bed <elementId>] [--voice <elementId> ...]
|
||||
[--strength 0..1] [--dry-run] [--core <dir>]
|
||||
[--strength 0..1] [--dry-run]
|
||||
|
||||
--bed id of the music track that gets carved (detected if omitted)
|
||||
--voice id of a voice to make room for; repeatable (detected if omitted)
|
||||
--strength how hard to carve, 0..1 (default ${DEFAULT_STRENGTH})
|
||||
--dry-run report what it would write, touch nothing
|
||||
--core directory to resolve @hyperframes/core from (default: the comp's)`;
|
||||
--dry-run report what it would write, touch nothing`;
|
||||
|
||||
export function parseArgs(argv) {
|
||||
const args = { strength: DEFAULT_STRENGTH, dryRun: false, voices: [] };
|
||||
@@ -62,7 +59,6 @@ export function parseArgs(argv) {
|
||||
else if (flag === "--bed") args.bed = next();
|
||||
else if (flag === "--voice") args.voices.push(next());
|
||||
else if (flag === "--strength") args.strength = Number(next());
|
||||
else if (flag === "--core") args.core = next();
|
||||
else if (flag === "--dry-run") args.dryRun = true;
|
||||
else if (flag === "-h" || flag === "--help") fail(usage, 0);
|
||||
else fail(`unknown flag: ${flag}\n\n${usage}`);
|
||||
@@ -79,73 +75,6 @@ function fail(message, code = 1) {
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the carve analysis out of `@hyperframes/core`.
|
||||
*
|
||||
* Resolved from the project rather than from this script, which lives wherever
|
||||
* the skill was installed — a sibling of the composition is what has the
|
||||
* dependency.
|
||||
*/
|
||||
export async function loadCore(fromDir) {
|
||||
const require = createRequire(pathToFileURL(resolve(fromDir, "package.json")));
|
||||
|
||||
/*
|
||||
* Two constraints at once, and satisfying either alone is broken:
|
||||
*
|
||||
* 1. Anchored at the PROJECT, not at this script. This file lives wherever
|
||||
* the skill was installed, which has no @hyperframes/core; the
|
||||
* composition's project is what holds the dependency. So a bare
|
||||
* `import("@hyperframes/core/audio-carve")` from here cannot work — bare
|
||||
* specifiers resolve relative to the importing module.
|
||||
* 2. Honouring the package's export CONDITIONS. `require.resolve` asks for
|
||||
* "require"/"node". The workspace manifest declares `node`, so this
|
||||
* resolved fine inside the monorepo — but the PUBLISHED manifest carries
|
||||
* only `import` + `types`, so every consumer of the released package got
|
||||
* ERR_PACKAGE_PATH_NOT_EXPORTED for a package that ships the file. That
|
||||
* is the audience this skill is shipped to, so the script was broken
|
||||
* everywhere except where it was developed.
|
||||
*
|
||||
* Keep the project anchor; fall back to the package's declared `import`
|
||||
* target when no require-resolvable condition exists.
|
||||
*/
|
||||
const load = async (subpath) => {
|
||||
const spec = `@hyperframes/core/${subpath}`;
|
||||
try {
|
||||
return await import(pathToFileURL(require.resolve(spec)).href);
|
||||
} catch (error) {
|
||||
if (error?.code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") throw error;
|
||||
// `./package.json` is exported by every manifest, so this always resolves
|
||||
// and gives us the package root without guessing at node_modules layout.
|
||||
const pkgPath = require.resolve("@hyperframes/core/package.json");
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
||||
const entry = pkg.exports?.[`./${subpath}`];
|
||||
const target = typeof entry === "string" ? entry : (entry?.import ?? entry?.default ?? null);
|
||||
if (!target) {
|
||||
fail(
|
||||
`@hyperframes/core does not export ./${subpath}\n` +
|
||||
` found at: ${pkgPath} (version ${pkg.version})\n` +
|
||||
` update it: npm i -D @hyperframes/core`,
|
||||
);
|
||||
}
|
||||
return import(pathToFileURL(resolve(dirname(pkgPath), target)).href);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
return {
|
||||
carve: await load("audio-carve"),
|
||||
fx: await load("audio-fx"),
|
||||
};
|
||||
} catch (error) {
|
||||
fail(
|
||||
`cannot load @hyperframes/core from ${fromDir}\n` +
|
||||
` is it installed there? npm i -D @hyperframes/core\n` +
|
||||
` or point at one: --core <dir containing node_modules/@hyperframes/core>\n` +
|
||||
` (${error.code ?? "error"}: ${error.message.split("\n")[0]})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The `sources` a carve should record for these voices, on this bed.
|
||||
*
|
||||
@@ -383,7 +312,6 @@ async function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const compPath = resolve(args.comp);
|
||||
const compDir = dirname(compPath);
|
||||
const { carve: carveApi, fx: fxApi } = await loadCore(args.core ? resolve(args.core) : compDir);
|
||||
|
||||
const html = readFileSync(compPath, "utf-8");
|
||||
const {
|
||||
@@ -433,7 +361,7 @@ async function main() {
|
||||
// carve's own nodes are replaced. That is what `fromCarve` is for.
|
||||
const existingChain = attrOf(bedTag, "data-fx-chain");
|
||||
const existingNodes = existingChain
|
||||
? fxApi.parseAudioFxChain(unescapeAttr(existingChain)).nodes
|
||||
? carveApi.parseAudioFxChain(unescapeAttr(existingChain)).nodes
|
||||
: [];
|
||||
const kept = existingNodes.filter((n) => !n.fromCarve);
|
||||
// Lanes belonging to the carve being replaced, addressed by the ids the OLD
|
||||
@@ -444,7 +372,7 @@ async function main() {
|
||||
|
||||
let claimed = { version: 1, nodes: kept };
|
||||
const mint = (node) => {
|
||||
const withId = { ...node, id: fxApi.mintAudioFxNodeId(claimed), fromCarve: true };
|
||||
const withId = { ...node, id: carveApi.mintAudioFxNodeId(claimed), fromCarve: true };
|
||||
claimed = { version: 1, nodes: [...claimed.nodes, withId] };
|
||||
return withId;
|
||||
};
|
||||
@@ -456,7 +384,7 @@ async function main() {
|
||||
type: "gain",
|
||||
enabled: true,
|
||||
params: {
|
||||
...fxApi.defaultAudioFxParams("gain"),
|
||||
...carveApi.defaultAudioFxParams("gain"),
|
||||
gain: 0,
|
||||
},
|
||||
})
|
||||
@@ -522,7 +450,7 @@ async function main() {
|
||||
}
|
||||
const written =
|
||||
` data-fx-carve="${escapeAttr(JSON.stringify(settings))}"` +
|
||||
` data-fx-chain="${escapeAttr(fxApi.serializeAudioFxChain(chain))}"` +
|
||||
` data-fx-chain="${escapeAttr(carveApi.serializeAudioFxChain(chain))}"` +
|
||||
(lanes.length > 0
|
||||
? ` data-automation="${escapeAttr(JSON.stringify({ version: 1, lanes }))}"`
|
||||
: "");
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import {
|
||||
DEFAULT_STRENGTH,
|
||||
carveSources,
|
||||
groupSourceRefusal,
|
||||
loadCore,
|
||||
parseArgs,
|
||||
} from "./carve.mjs";
|
||||
import { DEFAULT_STRENGTH, carveSources, groupSourceRefusal, parseArgs } from "./carve.mjs";
|
||||
|
||||
const SCRIPTS_DIR = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -202,33 +196,48 @@ test("the CLI still runs when invoked through a symlinked path", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("loadCore honours an import-only export map, as the published core has", () => {
|
||||
// The published manifest carries only `import` + `types` for these subpaths, so
|
||||
// `require.resolve` cannot resolve them at all and the fallback has to read the
|
||||
// export map itself. A fixture pins that without depending on npm.
|
||||
test("carve never loads @hyperframes/core from the composition's project", () => {
|
||||
// A received project is untrusted: a core planted in its node_modules must not run.
|
||||
return inTempDir(async (dir) => {
|
||||
const pkgDir = join(dir, "node_modules", "@hyperframes", "core");
|
||||
mkdirSync(join(pkgDir, "dist"), { recursive: true });
|
||||
writeFileSync(join(dir, "package.json"), JSON.stringify({ name: "fixture-project" }));
|
||||
mkdirSync(pkgDir, { recursive: true });
|
||||
writeFileSync(join(dir, "package.json"), JSON.stringify({ name: "received-project" }));
|
||||
const planted =
|
||||
'import { writeFileSync } from "node:fs";\nwriteFileSync(new URL("./RAN", import.meta.url), "");\n';
|
||||
writeFileSync(join(pkgDir, "planted.mjs"), planted);
|
||||
writeFileSync(
|
||||
join(pkgDir, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "@hyperframes/core",
|
||||
version: "0.0.0-fixture",
|
||||
type: "module",
|
||||
exports: {
|
||||
"./package.json": "./package.json",
|
||||
"./audio-carve": { import: "./dist/audioCarve.js" },
|
||||
"./audio-fx": { import: "./dist/audioFx.js" },
|
||||
"./audio-carve": "./planted.mjs",
|
||||
"./audio-fx": "./planted.mjs",
|
||||
},
|
||||
}),
|
||||
);
|
||||
writeFileSync(join(pkgDir, "dist", "audioCarve.js"), 'export const marker = "carve";\n');
|
||||
writeFileSync(join(pkgDir, "dist", "audioFx.js"), 'export const marker = "fx";\n');
|
||||
writeFileSync(join(dir, "index.html"), "<html><body></body></html>");
|
||||
|
||||
const core = await loadCore(dir);
|
||||
assert.equal(core.carve.marker, "carve");
|
||||
assert.equal(core.fx.marker, "fx");
|
||||
let stderr = "";
|
||||
try {
|
||||
execFileSync(
|
||||
process.execPath,
|
||||
[join(SCRIPTS_DIR, "carve.mjs"), "--comp", "index.html", "--dry-run"],
|
||||
{
|
||||
cwd: dir,
|
||||
stdio: "pipe",
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
stderr = String(error.stderr);
|
||||
}
|
||||
assert.equal(existsSync(join(pkgDir, "RAN")), false, "the project's @hyperframes/core ran");
|
||||
assert.match(
|
||||
stderr,
|
||||
/media in the composition/,
|
||||
"carve stopped before it read the composition",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -65,7 +65,7 @@ A crossfade is two clips on different tracks that overlap, each with a fade.
|
||||
|
||||
## Music under a voice
|
||||
|
||||
Duck the bed with a `volume` lane on the music: full level before the voice, down to about 0.3–0.4 while anyone speaks (word timings from `npx hyperframes transcribe` or the voiceover give the times), back up after. Then carve the bed, which dips only the bands the voice uses: `node <SKILL_DIR>/audio/scripts/carve.mjs --comp index.html` (needs `ffmpeg` and `@hyperframes/core` in the project; `--dry-run` to see the plan). It is the same analysis as Studio's carve panel. It reads only double-quoted attributes (JSON quotes as `"`), so write the bed's chain and lanes that way or it overwrites them. Never put a carve on a voice track.
|
||||
Duck the bed with a `volume` lane on the music: full level before the voice, down to about 0.3–0.4 while anyone speaks (word timings from `npx hyperframes transcribe` or the voiceover give the times), back up after. Then carve the bed, which dips only the bands the voice uses: `node <SKILL_DIR>/audio/scripts/carve.mjs --comp index.html` (needs `ffmpeg`; `--dry-run` to see the plan). It is the same analysis as Studio's carve panel. It reads only double-quoted attributes (JSON quotes as `"`), so write the bed's chain and lanes that way or it overwrites them. Never put a carve on a voice track.
|
||||
|
||||
## Group buses
|
||||
|
||||
|
||||
Reference in New Issue
Block a user