1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import { readFileSync, writeFileSync } from "node:fs";
import {
buildProjectArchive,
parseProjectArchive,
} from "../apps/web/src/project/transfer/container";
const direction = process.argv[2];
if (direction === "build") {
const projectJson = JSON.stringify({
version: 7,
metadata: { id: "web-built" },
nested: { value: 42 },
});
const archive = buildProjectArchive({
projectJson,
media: [
{
metadata: {
id: "web-asset",
name: "web clip.mov",
mediaType: "video",
fileType: "video/quicktime",
lastModified: 1_753_000_000_000,
width: 1280,
height: 720,
duration: 3.25,
},
data: new Uint8Array([9, 8, 7, 6]),
},
],
});
writeFileSync("/tmp/web-built.ocp", archive);
console.log("web-built.ocp written");
} else if (direction === "parse") {
const archive = readFileSync("/tmp/rust-built.ocp");
const parsed = parseProjectArchive({ archive });
console.log(
JSON.stringify({
project: parsed.project,
media: parsed.media,
firstBytes: Array.from(
parsed.readMediaData({ entry: parsed.media[0]?.entry ?? "" }),
),
}),
);
} else {
throw new Error("usage: bun cross-check.ts build|parse");
}
|