Skip to content
Open
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
46 changes: 46 additions & 0 deletions packages/cli/src/registry/registryBlocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ function loadRegistryManifest(itemDir: string): RegistryManifest {
return JSON.parse(readFileSync(join(itemDir, "registry-item.json"), "utf8")) as RegistryManifest;
}

function loadBlocks(): Array<{ name: string; itemDir: string; manifest: RegistryManifest }> {
return readdirSync(blocksDir, { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => {
const itemDir = join(blocksDir, entry.name);
return { name: entry.name, itemDir, manifest: loadRegistryManifest(itemDir) };
});
}

function findMissingLocalScripts(itemDir: string, manifest: RegistryManifest): string[] {
const manifestPaths = new Set(manifest.files.map((file) => file.path));
const missing: string[] = [];
Expand Down Expand Up @@ -110,6 +119,43 @@ describe("registry blocks", () => {
expect(missing).toEqual([]);
});

// Blocks installing the same shared library overwrite each other's copy, so a stale one downgrades the rest.
it("ships the same bytes from every block that installs a shared library", () => {
// target -> bytes -> blocks installing those bytes there
const installs = new Map<string, Map<string, string[]>>();
for (const { name, itemDir, manifest } of loadBlocks()) {
for (const file of manifest.files) {
if (!file.target.startsWith("compositions/lib/")) continue;
const content = readFileSync(join(itemDir, file.path), "latin1");
const byContent = installs.get(file.target) ?? new Map<string, string[]>();
byContent.set(content, [...(byContent.get(content) ?? []), name]);
installs.set(file.target, byContent);
}
}

expect(installs.has("compositions/lib/shaders.iife.js")).toBe(true);
const diverged = [...installs]
.filter(([, byContent]) => byContent.size > 1)
.map(([target, byContent]) => `${target}: ${[...byContent.values()].join(" vs ")}`);
expect(diverged).toEqual([]);
});

it("names a shader the shared bundle holds, and installs its licences, in every shader block", () => {
const missing: string[] = [];
for (const { name, itemDir, manifest } of loadBlocks()) {
const bundle = manifest.files.find((f) => f.target === "compositions/lib/shaders.iife.js");
const composition = manifest.files.find((f) => f.type === "hyperframes:composition");
if (!bundle || !composition) continue;
const html = readFileSync(join(itemDir, composition.path), "utf8");
const shader = html.match(/data-shader="([^"]+)"/)?.[1];
const code = readFileSync(join(itemDir, bundle.path), "utf8");
if (!shader || !code.includes(`name:"${shader}",role:`)) missing.push(`${name}: ${shader}`);
const licences = "compositions/lib/shaders.THIRD-PARTY-LICENSES.txt";
if (!manifest.files.some((f) => f.target === licences)) missing.push(`${name}: no licences`);
}
expect(missing).toEqual([]);
});

it("keeps the Camcorder HUD seekable inside a differently named host composition", async () => {
const bundled = await bundleToSingleHtml(resolve(blocksDir, "camcorder-hud"), {
entryFile: "demo.html",
Expand Down
31 changes: 31 additions & 0 deletions registry/blocks/aurora/aurora.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
[data-composition-id="aurora"] canvas[data-shader] {
position: absolute;
inset: 0;
width: 1920px;
height: 1080px;
display: block;
background: #000;
}
</style>
</head>
<body>
<div
data-composition-id="aurora"
data-start="0"
data-duration="2"
data-width="1920"
data-height="1080"
data-requires-webgpu
data-no-timeline
style="position: relative; width: 1920px; height: 1080px; overflow: hidden; background: #000"
>
<canvas data-shader="Aurora" width="1920" height="1080"></canvas>
</div>
<script src="lib/shaders.iife.js"></script>
</body>
</html>
314 changes: 314 additions & 0 deletions registry/blocks/aurora/lib/shaders.THIRD-PARTY-LICENSES.txt

Large diffs are not rendered by default.

267 changes: 267 additions & 0 deletions registry/blocks/aurora/lib/shaders.iife.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions registry/blocks/aurora/registry-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://hyperframes.heygen.com/schema/registry-item.json",
"name": "aurora",
"type": "hyperframes:block",
"title": "Aurora",
"description": "Green and violet aurora curtains ripple across a night sky. A WebGPU shader from the Shaders library (shaders.com, MIT).",
"tags": ["webgpu", "webgpu-shader", "background", "light", "aurora", "sky"],
"license": "Apache-2.0 AND MIT",
"dimensions": {
"width": 1920,
"height": 1080
},
"duration": 2,
"files": [
{
"path": "aurora.html",
"target": "compositions/aurora.html",
"type": "hyperframes:composition"
},
{
"path": "lib/shaders.iife.js",
"target": "compositions/lib/shaders.iife.js",
"type": "hyperframes:asset"
},
{
"path": "lib/shaders.THIRD-PARTY-LICENSES.txt",
"target": "compositions/lib/shaders.THIRD-PARTY-LICENSES.txt",
"type": "hyperframes:asset"
}
],
"preview": {
"video": "https://static.heygen.ai/hyperframes-oss/docs/images/catalog/blocks/aurora.mp4"
}
}
365 changes: 183 additions & 182 deletions registry/blocks/flowing-gradient/lib/shaders.iife.js

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions registry/blocks/frost/frost.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
[data-composition-id="frost"] canvas[data-shader] {
position: absolute;
inset: 0;
width: 1920px;
height: 1080px;
display: block;
background: #000;
}
</style>
</head>
<body>
<div
data-composition-id="frost"
data-start="0"
data-duration="2"
data-width="1920"
data-height="1080"
data-requires-webgpu
data-no-timeline
style="position: relative; width: 1920px; height: 1080px; overflow: hidden; background: #000"
>
<canvas data-shader="Frost" width="1920" height="1080"></canvas>
</div>
<script src="lib/shaders.iife.js"></script>
</body>
</html>
Loading
Loading