@norskvideo/ctl-test-harness 0.1.111 → 0.1.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/dev-loop.d.ts +9 -0
- package/demo/dev-loop.js +13 -1
- package/demo/run.js +12 -3
- package/package.json +6 -1
package/demo/dev-loop.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export interface StandaloneSource {
|
|
|
22
22
|
streamId: string;
|
|
23
23
|
asset: SourceAsset;
|
|
24
24
|
}
|
|
25
|
+
/** Fetch a sample into the cache, leaving `$f` set to it. Downloads land in
|
|
26
|
+
* `$f.part` and are renamed on success, so an interrupted fetch never poses
|
|
27
|
+
* as a cached file; a cached file whose size disagrees with the remote
|
|
28
|
+
* Content-Length (a truncation from before this was atomic) is re-fetched.
|
|
29
|
+
* Offline (HEAD fails), a non-empty cache is used as it is. No `set -e`. */
|
|
30
|
+
export declare function sampleFetchLines(file: string, at: {
|
|
31
|
+
base: string;
|
|
32
|
+
dir: string;
|
|
33
|
+
}): string[];
|
|
25
34
|
/** The pump script the sources pane runs on Enter: every source in
|
|
26
35
|
* parallel with the host's ffmpeg, into the from-source engine. A preset is
|
|
27
36
|
* fetched into the daemon's sample-media cache if it is not there yet; a
|
package/demo/dev-loop.js
CHANGED
|
@@ -20,6 +20,18 @@ function generated(pattern) {
|
|
|
20
20
|
const video = pattern === "bars" ? "smptebars=size=1280x720:rate=25" : "testsrc=size=1280x720:rate=25";
|
|
21
21
|
return `ffmpeg -hide_banner -loglevel warning -re -f lavfi -i "${video}" -f lavfi -i "sine=frequency=440:sample_rate=48000" -c:v libx264 -preset veryfast -tune zerolatency -g 50 -c:a aac`;
|
|
22
22
|
}
|
|
23
|
+
/** Fetch a sample into the cache, leaving `$f` set to it. Downloads land in
|
|
24
|
+
* `$f.part` and are renamed on success, so an interrupted fetch never poses
|
|
25
|
+
* as a cached file; a cached file whose size disagrees with the remote
|
|
26
|
+
* Content-Length (a truncation from before this was atomic) is re-fetched.
|
|
27
|
+
* Offline (HEAD fails), a non-empty cache is used as it is. No `set -e`. */
|
|
28
|
+
export function sampleFetchLines(file, at) {
|
|
29
|
+
return [
|
|
30
|
+
`f="${at.dir}/${file}"; u="${at.base}/${file}"; get=1`,
|
|
31
|
+
`if [ -s "$f" ]; then get=0; n=$(curl -fsIL "$u" 2>/dev/null | tr -d '\\r' | awk 'tolower($1)=="content-length:"{n=$2} END{print n}'); [ -n "$n" ] && [ "$n" != "$(wc -c < "$f" | tr -d ' ')" ] && get=1; fi`,
|
|
32
|
+
`[ "$get" = 0 ] || { mkdir -p "\${f%/*}" && curl -fL -o "$f.part" "$u" && mv -f "$f.part" "$f"; } || rm -f "$f.part"`,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
23
35
|
function pumpLines(asset, target) {
|
|
24
36
|
if ("mediaFile" in asset) {
|
|
25
37
|
return [
|
|
@@ -32,7 +44,7 @@ function pumpLines(asset, target) {
|
|
|
32
44
|
if (!file)
|
|
33
45
|
throw new Error(`unknown preset '${asset.preset}'; the daemon's presets are ${Object.keys(SAMPLE_MEDIA_FILES).join(", ")}`);
|
|
34
46
|
return [
|
|
35
|
-
|
|
47
|
+
...sampleFetchLines(file, { base: SAMPLE_MEDIA_BASE, dir: SAMPLE_MEDIA_DIR }),
|
|
36
48
|
`ffmpeg -hide_banner -loglevel warning -re -stream_loop -1 -i "$f" -c copy -f mpegts "${target}" &`,
|
|
37
49
|
];
|
|
38
50
|
}
|
package/demo/run.js
CHANGED
|
@@ -969,11 +969,20 @@ export async function exportStandaloneWorkdir(s, templateName, to) {
|
|
|
969
969
|
const argv = ["template", "export-workdir", templateName, "--to", to];
|
|
970
970
|
for (const [k, v] of Object.entries(spec.standalone?.params ?? {}))
|
|
971
971
|
argv.push("--param", `${k}=${v}`);
|
|
972
|
+
// ctl copies rather than links a source that is missing, and brokenSymlinks
|
|
973
|
+
// cannot see a link that was never made, so check the sources up front (#487).
|
|
974
|
+
const mustExist = (flag, path) => {
|
|
975
|
+
if (!deps.fileExists(path)) {
|
|
976
|
+
throw new Error(`${flag} source ${path} does not exist — does it need building first (e.g. \`bun run build:dashboard\`)?`);
|
|
977
|
+
}
|
|
978
|
+
return path;
|
|
979
|
+
};
|
|
972
980
|
for (const [pkg, path] of Object.entries(spec.standalone?.links ?? {})) {
|
|
973
|
-
argv.push("--link-component", `${pkg}=${resolve(cwd, path)}`);
|
|
981
|
+
argv.push("--link-component", `${pkg}=${mustExist(`--link-component ${pkg}`, resolve(cwd, path))}`);
|
|
982
|
+
}
|
|
983
|
+
if (spec.standalone?.dashboards) {
|
|
984
|
+
argv.push("--link-dashboards", mustExist("--link-dashboards", resolve(cwd, spec.standalone.dashboards)));
|
|
974
985
|
}
|
|
975
|
-
if (spec.standalone?.dashboards)
|
|
976
|
-
argv.push("--link-dashboards", resolve(cwd, spec.standalone.dashboards));
|
|
977
986
|
await s.cliOk(argv);
|
|
978
987
|
const broken = deps.brokenSymlinks(to);
|
|
979
988
|
if (broken.length) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norskvideo/ctl-test-harness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.113",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/id3as/norsk-ctl.git",
|
|
8
|
+
"directory": "packages/test-harness"
|
|
9
|
+
},
|
|
5
10
|
"exports": {
|
|
6
11
|
".": {
|
|
7
12
|
"types": "./index.d.ts",
|