mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 19:36:04 +00:00
Advertise the CLI sharing bridge before bootstrapping it so standalone Studio does not request unsupported routes. Preserve origin and session checks. Budget the intended sharing artifact: clean main packs at 8,060,519 bytes versus 8,162,979 with sharing (8,169,168 in CI). Required policy and Unicode tables, bundled sharing code, and Studio controls account for the growth. Set the packed-only budget to 8,577,627, following the 5% headroom convention; retain the unpacked cap and all package checks.
29 lines
1.3 KiB
JavaScript
29 lines
1.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join, resolve } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
// Exercise the bundled CLI, whose import.meta.url differs from the share source tree.
|
|
const dist = resolve(process.argv[2]);
|
|
const chunk = readdirSync(dist).find((name) => {
|
|
if (!name.endsWith(".js")) return false;
|
|
const source = readFileSync(join(dist, name), "utf8");
|
|
return /export\s*\{[^}]*\bshareContentFingerprint\b/s.test(source);
|
|
});
|
|
assert.ok(chunk, "CLI must expose its bundled source fingerprint to the share command");
|
|
const { shareContentFingerprint } = await import(pathToFileURL(join(dist, chunk)).href);
|
|
const project = mkdtempSync(join(tmpdir(), "hyperframes-packed-share-"));
|
|
try {
|
|
writeFileSync(join(project, "index.html"), "<html><body>Video</body></html>");
|
|
const asset = join(project, "café.txt");
|
|
writeFileSync(asset, "first");
|
|
const before = await shareContentFingerprint(project);
|
|
assert.match(before, /^[a-f0-9]{64}$/);
|
|
writeFileSync(asset, "second");
|
|
assert.notEqual(await shareContentFingerprint(project), before);
|
|
console.log("Bundled CLI captures portable source with its policy and Unicode registries.");
|
|
} finally {
|
|
rmSync(project, { recursive: true, force: true });
|
|
}
|