mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-08-31 02:41:44 +00:00
Restores the 208 catalog items reverted after their previews 404'd in production, this time on the payload mechanism rather than the .html files that caused the outage. The generator no longer writes a preview document to docs/public. That writer, and the machinery under it, existed only to produce files the docs host discards, so it is gone rather than bypassed. Items now embed the composition itself via a payload, which is what the previous change already does for the items that were already in the catalog. The variables explorer is parked, not restored: it drove its preview through the same unpublished .html path, so it would have shown an empty frame. Items that declare variables get the live player plus the static variables table, and reconnecting the explorer to payloads is a follow-up.
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { globSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const repoRoot = resolve(import.meta.dirname, "..");
|
|
// Any element, not just the <div> this started as: a payload that moved to a
|
|
// <script type="application/json"> to survive the formatter must stay guarded.
|
|
const PAYLOAD = /<(\w+)[^>]*\sdata-hf-primitive-data[^>]*>([\s\S]*?)<\/\1>/g;
|
|
|
|
describe("registry primitive payloads", () => {
|
|
it("stay parseable JSON in the shipped source", () => {
|
|
const files = globSync("registry/**/*.html", { cwd: repoRoot });
|
|
const broken: string[] = [];
|
|
for (const file of files) {
|
|
const html = readFileSync(resolve(repoRoot, file), "utf-8");
|
|
for (const match of html.matchAll(PAYLOAD)) {
|
|
const payload = match[2] ?? "";
|
|
try {
|
|
// Same normalization the compositions apply: this is inert text in
|
|
// HTML, so the formatter may reflow it, and whitespace is not
|
|
// significant. A payload that fails even after this is genuinely
|
|
// malformed rather than merely wrapped.
|
|
JSON.parse(payload.replace(/\s*[\r\n]+\s*/g, " "));
|
|
} catch (error) {
|
|
broken.push(`${file}: ${(error as Error).message}`);
|
|
}
|
|
}
|
|
}
|
|
assert.deepEqual(broken, []);
|
|
});
|
|
});
|