@beff/aula-cli 0.12.0 → 0.13.0
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/README.md +6 -1
- package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-H2OQFQ5J.js} +1 -1
- package/dist/src/aula.js +2 -2
- package/dist/src/{chunk-TDAWUJ2L.js → chunk-4FWDTPLR.js} +1 -1
- package/dist/src/{chunk-RAGZAJKD.js → chunk-D5N3QDDF.js} +1 -1
- package/dist/src/{chunk-DN2LVJO3.js → chunk-F5RPEFZR.js} +1 -0
- package/dist/src/{chunk-2PAZTBSE.js → chunk-G44UMBPW.js} +2 -2
- package/dist/src/{chunk-PZXFW6ZD.js → chunk-S6IM5XXK.js} +3 -3
- package/dist/src/{chunk-AXQBWV7J.js → chunk-THZNJBUF.js} +129 -20
- package/dist/src/{chunk-DC7A435Z.js → chunk-UBVMGS2E.js} +1 -1
- package/dist/src/{chunk-HD6FTA3H.js → chunk-UQOXT6QN.js} +109 -87
- package/dist/src/{chunk-T6CAPT32.js → chunk-WV2UYZND.js} +3 -2
- package/dist/src/chunk-XIVHJMET.js +111 -0
- package/dist/src/cli.js +29 -93
- package/dist/src/{commands-BSDNHYB3.js → commands-PLST75CP.js} +11 -10
- package/dist/src/problems-EI4DOEZ4.js +17 -0
- package/dist/src/project-7EROVEUE.js +16 -0
- package/dist/src/run-NE5HOAXA.js +235 -0
- package/dist/src/{server-TJTMSDO2.js → server-KXIU66BB.js} +24 -21
- package/dist/src/{site-RGPJOWSU.js → site-HUWODSZ3.js} +16 -89
- package/dist/src/workspace-load-DOHFEZFR.js +16 -0
- package/dist/web/app/assets/62289de9/build-worker.js +2 -0
- package/dist/web/app/assets/{bf5dd884 → 62289de9}/index.js +2 -2
- package/dist/web/app/assets/protocol-kcdbhuRm.js +15 -0
- package/dist/web/app/index.html +2 -2
- package/dist/web/site/assets/82618540/build-worker.js +2 -0
- package/dist/web/site/assets/{07fb5cf0 → 82618540}/index.js +2 -2
- package/dist/web/site/assets/protocol-XMWr-E-D.js +15 -0
- package/dist/web/site/index.html +2 -2
- package/package.json +1 -1
- package/dist/src/chunk-4QGX7XXO.js +0 -104
- package/dist/src/problems-CGKCPETU.js +0 -18
- package/dist/src/project-EUFMRQXR.js +0 -16
- package/dist/src/run-ER27SVTA.js +0 -183
- package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
- package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
- package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
- package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
- /package/dist/web/app/assets/{bf5dd884 → 62289de9}/aula-method.js +0 -0
- /package/dist/web/app/assets/{bf5dd884 → 62289de9}/aula.js +0 -0
- /package/dist/web/site/assets/{07fb5cf0 → 82618540}/aula-method.js +0 -0
- /package/dist/web/site/assets/{07fb5cf0 → 82618540}/aula.js +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,12 @@ The `aula` command of [aula](https://github.com/lucasavila00/aula): it runs chap
|
|
|
4
4
|
|
|
5
5
|
It needs Node 24. Narration (aula-voice) needs only Node. `aula export` needs ffmpeg. Refer to [CLI](https://github.com/lucasavila00/aula/blob/main/docs/agents/cli.md) for the commands and [Getting started](https://github.com/lucasavila00/aula/blob/main/docs/agents/getting-started.md) for the setup.
|
|
6
6
|
|
|
7
|
-
The package has no model file.
|
|
7
|
+
The package has no model file.
|
|
8
|
+
The first command that narrates or times a video downloads the narrator's model of aula-voice's release [v0.2.4](https://github.com/lucasavila00/aula-voice/releases/tag/v0.2.4) (about 21 MB).
|
|
9
|
+
Those commands are `check`, `script`, `timeline`, `preview`, `export` and `aula web`.
|
|
10
|
+
The CLI checks the SHA-256 of each file, makes the engine's weight file from them, and checks its SHA-256 too.
|
|
11
|
+
`aula web` narrates in the browser and serves that file to its page.
|
|
12
|
+
The [model card](https://github.com/lucasavila00/aula-voice/releases/download/v0.2.4/MODEL_CARD.md) has the license of the model, its sources and its training data, and their attribution.
|
|
8
13
|
|
|
9
14
|
## Licenses
|
|
10
15
|
|
package/dist/src/aula.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
manim_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D5N3QDDF.js";
|
|
4
4
|
import {
|
|
5
5
|
defineChapter,
|
|
6
6
|
defineProject,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
pronounce,
|
|
11
11
|
say,
|
|
12
12
|
show
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-F5RPEFZR.js";
|
|
14
14
|
import "./chunk-VX7UVLQW.js";
|
|
15
15
|
import "./chunk-CZ7CSFO4.js";
|
|
16
16
|
export {
|
|
@@ -73851,6 +73851,7 @@ export {
|
|
|
73851
73851
|
theme,
|
|
73852
73852
|
lexiconEntries,
|
|
73853
73853
|
FPS,
|
|
73854
|
+
TITLE,
|
|
73854
73855
|
chapterNames,
|
|
73855
73856
|
v8Frames,
|
|
73856
73857
|
definedAt,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
error,
|
|
5
5
|
projectName,
|
|
6
6
|
wrongArgument
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WV2UYZND.js";
|
|
8
8
|
import {
|
|
9
9
|
definedAt,
|
|
10
10
|
importUserModule,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
loadEngine,
|
|
14
14
|
loadTex,
|
|
15
15
|
v8Frames
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-F5RPEFZR.js";
|
|
17
17
|
|
|
18
18
|
// ../aula-project/src/node.ts
|
|
19
19
|
import { existsSync } from "node:fs";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderDiagnostic
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4FWDTPLR.js";
|
|
4
4
|
import {
|
|
5
5
|
withSource
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-G44UMBPW.js";
|
|
7
7
|
import {
|
|
8
8
|
loadEngine
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F5RPEFZR.js";
|
|
10
10
|
|
|
11
11
|
// src/problems.ts
|
|
12
12
|
async function printDiagnostics(capabilities, root, diagnostics, print = (text) => capabilities.log.out(text)) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-4QGX7XXO.js";
|
|
4
|
-
import {
|
|
2
|
+
chapterNarration,
|
|
5
3
|
check,
|
|
6
4
|
moveFrames,
|
|
7
5
|
narrationScript,
|
|
@@ -10,7 +8,7 @@ import {
|
|
|
10
8
|
timeline,
|
|
11
9
|
unclearWords,
|
|
12
10
|
words
|
|
13
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4FWDTPLR.js";
|
|
14
12
|
import {
|
|
15
13
|
LIST_MODULE,
|
|
16
14
|
Problems,
|
|
@@ -18,12 +16,13 @@ import {
|
|
|
18
16
|
isError,
|
|
19
17
|
linkBundle,
|
|
20
18
|
wrongArgument
|
|
21
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WV2UYZND.js";
|
|
22
20
|
import {
|
|
23
21
|
manim_exports
|
|
24
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-D5N3QDDF.js";
|
|
25
23
|
import {
|
|
26
24
|
FPS,
|
|
25
|
+
TITLE,
|
|
27
26
|
chapterNames,
|
|
28
27
|
checkChapter,
|
|
29
28
|
checkLexicon,
|
|
@@ -35,13 +34,118 @@ import {
|
|
|
35
34
|
loadEngine,
|
|
36
35
|
readChapter,
|
|
37
36
|
renderChapter
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-F5RPEFZR.js";
|
|
38
|
+
|
|
39
|
+
// ../aula-narration/src/script.ts
|
|
40
|
+
var starts = (words2) => Float64Array.from(words2, (w) => w.start);
|
|
41
|
+
function joinChapter(cues, speeches) {
|
|
42
|
+
let rate = 0;
|
|
43
|
+
for (const [i, speech] of speeches.entries()) {
|
|
44
|
+
if (!speech.samples.length || speech.samples.some((s) => !Number.isFinite(s))) {
|
|
45
|
+
const text = cues[i]?.text.slice(0, 60) ?? "";
|
|
46
|
+
throw new Error(`the narrator returned empty or invalid audio for ${JSON.stringify(text)}`);
|
|
47
|
+
}
|
|
48
|
+
if (rate !== 0 && speech.sampleRate !== rate) throw new Error("the narrator changed its sample rate");
|
|
49
|
+
rate = speech.sampleRate;
|
|
50
|
+
}
|
|
51
|
+
const spoken = speeches.map((s) => ({ samples: s.samples.length, starts: starts(s.words) }));
|
|
52
|
+
const narration = chapterNarration(cues, spoken, rate);
|
|
53
|
+
const samples = new Float32Array(narration.endFrame);
|
|
54
|
+
for (const [i, speech] of speeches.entries()) samples.set(speech.samples, narration.cues[i]?.speechStartFrame ?? 0);
|
|
55
|
+
return { samples, narration };
|
|
56
|
+
}
|
|
57
|
+
function withWaits(samples, waits) {
|
|
58
|
+
if (waits.length === 0) return samples;
|
|
59
|
+
const out = new Float32Array(samples.length + waits.reduce((sum, w) => sum + w.samples, 0));
|
|
60
|
+
let from = 0;
|
|
61
|
+
let to = 0;
|
|
62
|
+
for (const wait of waits.toSorted((a, b) => a.sample - b.sample)) {
|
|
63
|
+
const at = Math.min(wait.sample, samples.length);
|
|
64
|
+
out.set(samples.subarray(from, at), to);
|
|
65
|
+
to += at - from + wait.samples;
|
|
66
|
+
from = at;
|
|
67
|
+
}
|
|
68
|
+
out.set(samples.subarray(from), to);
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
function timeChapter(cues, timings) {
|
|
72
|
+
const rate = timings[0]?.sampleRate ?? 0;
|
|
73
|
+
if (timings.some((t) => t.sampleRate !== rate)) throw new Error("the narrator changed its sample rate");
|
|
74
|
+
const spoken = timings.map(
|
|
75
|
+
(t) => t.words ? { samples: t.samples, starts: starts(t.words) } : { samples: t.samples }
|
|
76
|
+
);
|
|
77
|
+
return chapterNarration(cues, spoken, rate);
|
|
78
|
+
}
|
|
79
|
+
async function narrateScript(speak, chapters, speaking) {
|
|
80
|
+
const count = chapters.reduce((sum, c) => sum + c.length, 0);
|
|
81
|
+
let spoken = 0;
|
|
82
|
+
const narrated = [];
|
|
83
|
+
for (const cues of chapters) {
|
|
84
|
+
const speeches = [];
|
|
85
|
+
for (const cue of cues) {
|
|
86
|
+
spoken += 1;
|
|
87
|
+
speaking(spoken, count, cue);
|
|
88
|
+
speeches.push(await speak(cue.words));
|
|
89
|
+
}
|
|
90
|
+
narrated.push(joinChapter(cues, speeches));
|
|
91
|
+
}
|
|
92
|
+
if (!narrated.some((c) => c.narration.sampleRate > 0)) throw new Error("the script has no cues");
|
|
93
|
+
return narrated;
|
|
94
|
+
}
|
|
95
|
+
function scriptAudio(chapters, waits) {
|
|
96
|
+
const sounds = chapters.map((c, i) => withWaits(c.samples, waits[i] ?? []));
|
|
97
|
+
const samples = new Float32Array(sounds.reduce((sum, s) => sum + s.length, 0));
|
|
98
|
+
let at = 0;
|
|
99
|
+
for (const sound of sounds) {
|
|
100
|
+
samples.set(sound, at);
|
|
101
|
+
at += sound.length;
|
|
102
|
+
}
|
|
103
|
+
const sampleRate = chapters.find((c) => c.narration.sampleRate > 0)?.narration.sampleRate ?? 0;
|
|
104
|
+
return { samples, sampleRate };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ../aula-narration/src/wav.ts
|
|
108
|
+
function wav(samples, rate) {
|
|
109
|
+
const bytes = new Uint8Array(44 + samples.length * 2);
|
|
110
|
+
const view = new DataView(bytes.buffer);
|
|
111
|
+
const text = (at, value) => {
|
|
112
|
+
for (let i = 0; i < value.length; i++) view.setUint8(at + i, value.charCodeAt(i));
|
|
113
|
+
};
|
|
114
|
+
text(0, "RIFF");
|
|
115
|
+
view.setUint32(4, 36 + samples.length * 2, true);
|
|
116
|
+
text(8, "WAVE");
|
|
117
|
+
text(12, "fmt ");
|
|
118
|
+
view.setUint32(16, 16, true);
|
|
119
|
+
view.setUint16(20, 1, true);
|
|
120
|
+
view.setUint16(22, 1, true);
|
|
121
|
+
view.setUint32(24, rate, true);
|
|
122
|
+
view.setUint32(28, rate * 2, true);
|
|
123
|
+
view.setUint16(32, 2, true);
|
|
124
|
+
view.setUint16(34, 16, true);
|
|
125
|
+
text(36, "data");
|
|
126
|
+
view.setUint32(40, samples.length * 2, true);
|
|
127
|
+
samples.forEach((sample, i) => {
|
|
128
|
+
view.setInt16(44 + i * 2, Math.round(Math.min(1, Math.max(-1, sample)) * 32767), true);
|
|
129
|
+
});
|
|
130
|
+
return bytes;
|
|
131
|
+
}
|
|
39
132
|
|
|
40
133
|
// ../aula-project/src/chapters.ts
|
|
134
|
+
function rejectTitleChapter(name) {
|
|
135
|
+
if (name !== TITLE) return;
|
|
136
|
+
throw wrongArgument(
|
|
137
|
+
"title is not a chapter: give a chapter id such as 01-double-the-side",
|
|
138
|
+
"omit <chapter> to check or preview the whole project, including the title card"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
function chapterHintNames(names) {
|
|
142
|
+
return names.filter((name) => name !== TITLE).join(", ");
|
|
143
|
+
}
|
|
41
144
|
function chapterIndex(names, name) {
|
|
145
|
+
rejectTitleChapter(name);
|
|
42
146
|
const at = names.indexOf(name);
|
|
43
147
|
if (at >= 0) return at;
|
|
44
|
-
throw wrongArgument(`No chapter '${name}': use one of [${names
|
|
148
|
+
throw wrongArgument(`No chapter '${name}': use one of [${chapterHintNames(names)}]`);
|
|
45
149
|
}
|
|
46
150
|
function chapterText(project, host, index) {
|
|
47
151
|
const result = readChapter(project, index, { host });
|
|
@@ -51,8 +155,8 @@ function chapterText(project, host, index) {
|
|
|
51
155
|
function paragraphCue(text, name, line) {
|
|
52
156
|
const p = paragraphAt(text, line);
|
|
53
157
|
if (p !== void 0) return p + 1;
|
|
54
|
-
const
|
|
55
|
-
const list =
|
|
158
|
+
const starts2 = text.paragraphs.flatMap((q) => q.place ? [String(q.place.line)] : []);
|
|
159
|
+
const list = starts2.length > 1 ? `${starts2.slice(0, -1).join(", ")} and ${starts2.at(-1) ?? ""}` : starts2.join("");
|
|
56
160
|
throw wrongArgument(`line ${String(line)} of ${name} is in no paragraph; the paragraphs start at lines ${list}`);
|
|
57
161
|
}
|
|
58
162
|
function openMoves(text) {
|
|
@@ -158,14 +262,14 @@ function exportCheck(project, host) {
|
|
|
158
262
|
return { ...checked, findings: [...checked.findings, ...open], errors: checked.errors + open.length };
|
|
159
263
|
}
|
|
160
264
|
function clipPlan(narrations, fps) {
|
|
161
|
-
const
|
|
162
|
-
for (const narration of narrations)
|
|
163
|
-
const firsts =
|
|
265
|
+
const starts2 = [0];
|
|
266
|
+
for (const narration of narrations) starts2.push((starts2.at(-1) ?? 0) + narration.endFrame / narration.sampleRate);
|
|
267
|
+
const firsts = starts2.map((seconds) => Math.round(seconds * fps));
|
|
164
268
|
const clips = narrations.map((_, index) => {
|
|
165
269
|
const first = firsts[index] ?? 0;
|
|
166
|
-
return { from: first / fps - (
|
|
270
|
+
return { from: first / fps - (starts2[index] ?? 0), frames: (firsts[index + 1] ?? first) - first };
|
|
167
271
|
});
|
|
168
|
-
return { clips, seconds:
|
|
272
|
+
return { clips, seconds: starts2.at(-1) ?? 0 };
|
|
169
273
|
}
|
|
170
274
|
function overlayPlan(narrations, embeds) {
|
|
171
275
|
let offset = 0;
|
|
@@ -259,7 +363,6 @@ function previewTargets(project, given) {
|
|
|
259
363
|
return given.map((target) => {
|
|
260
364
|
const m = /^(.*):([0-9]+)$/.exec(target);
|
|
261
365
|
const index = chapterIndex(names, m?.[1] ?? target);
|
|
262
|
-
if (index === 0 && m !== null) throw wrongArgument("the title card has no lines: give a chapter name with :<line>");
|
|
263
366
|
return { index, name: names[index] ?? target, line: m?.[2] === void 0 ? null : Number(m[2]) };
|
|
264
367
|
});
|
|
265
368
|
}
|
|
@@ -364,7 +467,6 @@ function timedChapter(index, name, text, narration) {
|
|
|
364
467
|
async function loadTimed(project, host, narrator, only) {
|
|
365
468
|
const names = chapterNames(project);
|
|
366
469
|
const indexes = only.length === 0 ? project.chapters.map((_, i) => i + 1) : only.map((name) => chapterIndex(names, name));
|
|
367
|
-
if (indexes.includes(0)) throw wrongArgument("the title card has no timeline: give a chapter name");
|
|
368
470
|
const loaded = /* @__PURE__ */ new Map();
|
|
369
471
|
for (const index of indexes) loaded.set(index, chapterText(project, host, index));
|
|
370
472
|
const all = project.chapters.map((_, i) => {
|
|
@@ -486,10 +588,13 @@ async function loadBuiltProjects(bundled, host, modules, player, engineLoaded) {
|
|
|
486
588
|
return { _tag: "Right", right: out };
|
|
487
589
|
}
|
|
488
590
|
var folderOfModule = (module) => module.slice(0, Math.max(0, module.lastIndexOf("/")));
|
|
489
|
-
function listedProjects(projects) {
|
|
490
|
-
if (
|
|
591
|
+
function listedProjects(projects, options = {}) {
|
|
592
|
+
if (options.includeDrafts) return [...projects];
|
|
491
593
|
return projects.filter((project) => !project.draft);
|
|
492
594
|
}
|
|
595
|
+
function draftSkipMessage(folder) {
|
|
596
|
+
return `skipping ${folder} because it is a draft (pass --include-drafts to check it)`;
|
|
597
|
+
}
|
|
493
598
|
function localProject(name, folder, section, definition, host) {
|
|
494
599
|
const count = definition.chapters.length + 1;
|
|
495
600
|
return {
|
|
@@ -532,6 +637,9 @@ function localProject(name, folder, section, definition, host) {
|
|
|
532
637
|
}
|
|
533
638
|
|
|
534
639
|
export {
|
|
640
|
+
narrateScript,
|
|
641
|
+
scriptAudio,
|
|
642
|
+
wav,
|
|
535
643
|
clock,
|
|
536
644
|
narrationAt,
|
|
537
645
|
checkProject,
|
|
@@ -553,5 +661,6 @@ export {
|
|
|
553
661
|
scriptView,
|
|
554
662
|
workspaceHost,
|
|
555
663
|
loadBuiltProjects,
|
|
556
|
-
listedProjects
|
|
664
|
+
listedProjects,
|
|
665
|
+
draftSkipMessage
|
|
557
666
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createNodeBundler
|
|
2
|
+
createNodeBundler,
|
|
3
|
+
nodeTree
|
|
3
4
|
} from "./chunk-THQ5Y74K.js";
|
|
4
5
|
import {
|
|
5
6
|
VIDEO,
|
|
@@ -9,14 +10,16 @@ import {
|
|
|
9
10
|
} from "./chunk-F4XRXW6M.js";
|
|
10
11
|
import {
|
|
11
12
|
printDiagnostics
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-S6IM5XXK.js";
|
|
13
14
|
import {
|
|
14
15
|
chapterIndexes,
|
|
15
16
|
checkProject,
|
|
16
17
|
clipPlan,
|
|
17
18
|
clock,
|
|
19
|
+
draftSkipMessage,
|
|
18
20
|
exportCheck,
|
|
19
21
|
movesMarkdown,
|
|
22
|
+
narrateScript,
|
|
20
23
|
narrationAt,
|
|
21
24
|
noteLine,
|
|
22
25
|
notesLine,
|
|
@@ -25,28 +28,27 @@ import {
|
|
|
25
28
|
pictureStills,
|
|
26
29
|
previewJobs,
|
|
27
30
|
previewTargets,
|
|
31
|
+
scriptAudio,
|
|
28
32
|
scriptView,
|
|
29
33
|
targetChapters,
|
|
30
34
|
timedChapter,
|
|
31
35
|
timelineView,
|
|
36
|
+
wav,
|
|
32
37
|
wordNotes
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import {
|
|
35
|
-
narrateScript,
|
|
36
|
-
scriptAudio,
|
|
37
|
-
wav
|
|
38
|
-
} from "./chunk-4QGX7XXO.js";
|
|
38
|
+
} from "./chunk-THZNJBUF.js";
|
|
39
39
|
import {
|
|
40
40
|
narrationScript
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-4FWDTPLR.js";
|
|
42
42
|
import {
|
|
43
|
-
host
|
|
44
|
-
|
|
43
|
+
host,
|
|
44
|
+
loadProject
|
|
45
|
+
} from "./chunk-UBVMGS2E.js";
|
|
45
46
|
import {
|
|
46
47
|
folderOf,
|
|
47
48
|
nameOf
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-G44UMBPW.js";
|
|
49
50
|
import {
|
|
51
|
+
NO_PROJECT_MESSAGE,
|
|
50
52
|
ObjectRuntype,
|
|
51
53
|
OptionalFieldRuntype,
|
|
52
54
|
PROVIDED,
|
|
@@ -57,15 +59,16 @@ import {
|
|
|
57
59
|
buildParsers,
|
|
58
60
|
bundle,
|
|
59
61
|
isError,
|
|
62
|
+
projectModules,
|
|
60
63
|
wrongArgument
|
|
61
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-WV2UYZND.js";
|
|
62
65
|
import {
|
|
63
66
|
manim_exports
|
|
64
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-D5N3QDDF.js";
|
|
65
68
|
import {
|
|
66
69
|
chapterNames,
|
|
67
70
|
renderChapter
|
|
68
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-F5RPEFZR.js";
|
|
69
72
|
|
|
70
73
|
// src/commands.ts
|
|
71
74
|
import path2 from "node:path";
|
|
@@ -912,14 +915,6 @@ async function projectFiles(capabilities, bundler, root, folder) {
|
|
|
912
915
|
}
|
|
913
916
|
|
|
914
917
|
// src/commands.ts
|
|
915
|
-
async function withHeavy(capabilities, f) {
|
|
916
|
-
const release = await capabilities.locks.heavy();
|
|
917
|
-
try {
|
|
918
|
-
return await f();
|
|
919
|
-
} finally {
|
|
920
|
-
await release();
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
918
|
async function withWork(capabilities, f) {
|
|
924
919
|
const work = await capabilities.fs.mkdtemp(path2.join(capabilities.env.temp, "aula-"));
|
|
925
920
|
try {
|
|
@@ -984,20 +979,18 @@ async function timeChapters(capabilities, root, project, texts, only) {
|
|
|
984
979
|
const names = chapterNames(project);
|
|
985
980
|
const indexes = (only ?? names.map((_, i2) => i2)).filter((i2) => i2 > 0);
|
|
986
981
|
if (indexes.length === 0) return [];
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
return warnings;
|
|
1000
|
-
});
|
|
982
|
+
const n = await clock(capabilities.narrator, narrationScript(project, texts), only, names);
|
|
983
|
+
const h = host(capabilities, root);
|
|
984
|
+
const warnings = [];
|
|
985
|
+
for (const index of indexes) {
|
|
986
|
+
const drawn = renderChapter(project, index, {
|
|
987
|
+
host: h,
|
|
988
|
+
narration: narrationAt(n, index),
|
|
989
|
+
lint: true
|
|
990
|
+
});
|
|
991
|
+
warnings.push(...drawn.diagnostics.filter((d) => !isError(d)));
|
|
992
|
+
}
|
|
993
|
+
return warnings;
|
|
1001
994
|
}
|
|
1002
995
|
async function check(capabilities, root, project, only, json = false) {
|
|
1003
996
|
const chapters = chapterIndexes(project, only);
|
|
@@ -1018,6 +1011,44 @@ async function check(capabilities, root, project, only, json = false) {
|
|
|
1018
1011
|
printCounts(capabilities, project, { ...checked, findings, warnings });
|
|
1019
1012
|
return checked.errors === 0;
|
|
1020
1013
|
}
|
|
1014
|
+
async function checkRoot(capabilities, cwd, folder, only, json = false, includeDrafts = false) {
|
|
1015
|
+
const tree = nodeTree(capabilities, folder);
|
|
1016
|
+
const listed = await projectModules(tree, path2.basename(folder));
|
|
1017
|
+
if (listed._tag === "Left") throw new Problems(listed.left);
|
|
1018
|
+
if (listed.right.length === 0) throw new Error(NO_PROJECT_MESSAGE);
|
|
1019
|
+
const loaded = [];
|
|
1020
|
+
for (const mod of listed.right) {
|
|
1021
|
+
const projectFolder = mod.module === "index.ts" ? folder : path2.join(folder, path2.dirname(mod.module));
|
|
1022
|
+
const label = mod.module === "index.ts" ? path2.basename(folder) : path2.dirname(mod.module);
|
|
1023
|
+
const project = await loadProject(capabilities, cwd, projectFolder, listed.right.length === 1 ? only : []);
|
|
1024
|
+
loaded.push({ label, projectFolder, project });
|
|
1025
|
+
}
|
|
1026
|
+
const projects = [];
|
|
1027
|
+
for (const entry of loaded) {
|
|
1028
|
+
if (entry.project.draft && !includeDrafts) {
|
|
1029
|
+
capabilities.log.out(draftSkipMessage(entry.label));
|
|
1030
|
+
} else {
|
|
1031
|
+
projects.push(entry);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (projects.length === 0) return true;
|
|
1035
|
+
if (projects.length !== 1 && only.length > 0) {
|
|
1036
|
+
throw wrongArgument(
|
|
1037
|
+
"aula check takes chapters only when the folder gives one project",
|
|
1038
|
+
"pass a project folder, or omit the chapters to check every listed project"
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
if (listed.right.length !== 1 && projects.length === 1 && only.length > 0) {
|
|
1042
|
+
const entry = projects[0];
|
|
1043
|
+
if (entry === void 0) throw new Error("checkRoot: missing project after draft filter");
|
|
1044
|
+
entry.project = await loadProject(capabilities, cwd, entry.projectFolder, only);
|
|
1045
|
+
}
|
|
1046
|
+
let ok = true;
|
|
1047
|
+
for (const entry of projects) {
|
|
1048
|
+
ok = await check(capabilities, cwd, entry.project, only, json) && ok;
|
|
1049
|
+
}
|
|
1050
|
+
return ok;
|
|
1051
|
+
}
|
|
1021
1052
|
async function script(capabilities, root, project, only) {
|
|
1022
1053
|
capabilities.log.write(await scriptView(project, host(capabilities, root), capabilities.narrator, only));
|
|
1023
1054
|
return true;
|
|
@@ -1041,26 +1072,24 @@ async function preview(capabilities, root, project, folder, given) {
|
|
|
1041
1072
|
return withWork(capabilities, async (work) => {
|
|
1042
1073
|
const stopped = [];
|
|
1043
1074
|
const waits = [];
|
|
1044
|
-
await
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
job.written.push(path2.join(out, "moves.md"), ...sheets);
|
|
1063
|
-
});
|
|
1075
|
+
const n = await clock(capabilities.narrator, narrationScript(project, all), only, chapterNames(project));
|
|
1076
|
+
for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
|
|
1077
|
+
await parallel(jobs, capabilities.env.parallelism, async (job) => {
|
|
1078
|
+
const lottie = path2.join(work, `${job.base}.json`);
|
|
1079
|
+
const drawn = await drawChapter(capabilities, root, project, job.index, narrationAt(n, job.index), lottie);
|
|
1080
|
+
if (!drawn.ok) {
|
|
1081
|
+
stopped.push(...drawn.findings);
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
waits.push(...drawn.findings.filter((d) => !isError(d)));
|
|
1085
|
+
const { out } = job;
|
|
1086
|
+
const { window, stills } = pictureStills(drawn.narration, job, drawn.frames, drawn.embeds);
|
|
1087
|
+
const groups = inFolder(folderOf(project), pictureGroups(window, stills));
|
|
1088
|
+
const sheets = await capabilities.render.pictures({ lottie, out, groups });
|
|
1089
|
+
await capabilities.fs.mkdir(out, { recursive: true });
|
|
1090
|
+
const moves = job.text === null ? "title card\n" : movesMarkdown(timedChapter(job.index, job.name, job.text, drawn.narration));
|
|
1091
|
+
await capabilities.fs.writeFile(path2.join(out, "moves.md"), moves);
|
|
1092
|
+
job.written.push(path2.join(out, "moves.md"), ...sheets);
|
|
1064
1093
|
});
|
|
1065
1094
|
if (stopped.length) {
|
|
1066
1095
|
await printDiagnostics(capabilities, root, stopped);
|
|
@@ -1072,7 +1101,6 @@ async function preview(capabilities, root, project, folder, given) {
|
|
|
1072
1101
|
});
|
|
1073
1102
|
}
|
|
1074
1103
|
async function exportVideo(capabilities, root, project, file) {
|
|
1075
|
-
if (!file.endsWith(".mp4")) throw wrongArgument(`the video path must end in .mp4: ${file}`);
|
|
1076
1104
|
const names = chapterNames(project);
|
|
1077
1105
|
const checked = exportCheck(project, host(capabilities, root));
|
|
1078
1106
|
await printChecked(capabilities, root, project, checked);
|
|
@@ -1084,28 +1112,25 @@ async function exportVideo(capabilities, root, project, file) {
|
|
|
1084
1112
|
return withWork(capabilities, async (work) => {
|
|
1085
1113
|
const audio = path2.join(work, "narration.wav");
|
|
1086
1114
|
const cues = narrationScript(project, checked.texts);
|
|
1087
|
-
const narrated = await
|
|
1115
|
+
const narrated = await narrate(capabilities, cues);
|
|
1088
1116
|
const lotties = names.map((name) => path2.join(work, `${name}.json`));
|
|
1089
1117
|
const drawn = [];
|
|
1090
1118
|
const problems = [];
|
|
1091
1119
|
let done = 0;
|
|
1092
|
-
await
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
done
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
);
|
|
1107
|
-
}
|
|
1108
|
-
)
|
|
1120
|
+
await parallel(
|
|
1121
|
+
names.map((_, index) => index),
|
|
1122
|
+
capabilities.env.parallelism,
|
|
1123
|
+
async (index) => {
|
|
1124
|
+
const narration = narrated[index]?.narration;
|
|
1125
|
+
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
1126
|
+
const chapter = await drawChapter(capabilities, root, project, index, narration, lotties[index] ?? "");
|
|
1127
|
+
drawn[index] = chapter;
|
|
1128
|
+
if (!chapter.ok) problems.push(...chapter.findings);
|
|
1129
|
+
done += 1;
|
|
1130
|
+
capabilities.log.out(
|
|
1131
|
+
`[${String(done)}/${String(names.length)}] ${names[index] ?? ""}: ${chapter.ok ? "drawn" : "FAILED"}`
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1109
1134
|
);
|
|
1110
1135
|
if (problems.length) {
|
|
1111
1136
|
await printDiagnostics(capabilities, root, problems);
|
|
@@ -1122,16 +1147,13 @@ async function exportVideo(capabilities, root, project, file) {
|
|
|
1122
1147
|
VIDEO.fps
|
|
1123
1148
|
);
|
|
1124
1149
|
const clips = names.map((name) => path2.join(work, `${name}.mp4`));
|
|
1125
|
-
await
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
|
|
1133
|
-
}
|
|
1134
|
-
)
|
|
1150
|
+
await parallel(
|
|
1151
|
+
names.map((_, index) => index),
|
|
1152
|
+
capabilities.env.parallelism,
|
|
1153
|
+
async (index) => {
|
|
1154
|
+
const clip = plan.clips[index] ?? { from: 0, frames: 0 };
|
|
1155
|
+
await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
|
|
1156
|
+
}
|
|
1135
1157
|
);
|
|
1136
1158
|
await capabilities.fs.mkdir(path2.dirname(file), { recursive: true });
|
|
1137
1159
|
const placed = await placedClips(
|
|
@@ -1149,7 +1171,6 @@ async function exportVideo(capabilities, root, project, file) {
|
|
|
1149
1171
|
});
|
|
1150
1172
|
}
|
|
1151
1173
|
async function bundle2(capabilities, project, file) {
|
|
1152
|
-
if (!file.endsWith(".zip")) throw new Error(`the zip path must end in .zip: ${file}`);
|
|
1153
1174
|
const home = folderOf(project);
|
|
1154
1175
|
const root = path2.parse(home).root;
|
|
1155
1176
|
const folder = path2.relative(root, home).split(path2.sep).join("/");
|
|
@@ -1187,6 +1208,7 @@ function tokensArgs(positional) {
|
|
|
1187
1208
|
|
|
1188
1209
|
export {
|
|
1189
1210
|
check,
|
|
1211
|
+
checkRoot,
|
|
1190
1212
|
script,
|
|
1191
1213
|
timeline,
|
|
1192
1214
|
preview,
|