@beff/aula-cli 0.4.2 → 0.5.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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/licenses/fonts-OFL-NotoSans.txt +94 -0
  3. package/dist/src/aula-render.core.wasm +0 -0
  4. package/dist/src/{chunk-7KT36JRP.js → chunk-2NMVSQG4.js} +83 -93
  5. package/dist/src/{chunk-46KT47TH.js → chunk-5VYKT646.js} +1 -1
  6. package/dist/src/chunk-A5QHTZKT.js +6 -0
  7. package/dist/src/{chunk-CIFP475T.js → chunk-DQ2NGXNI.js} +6 -321
  8. package/dist/src/chunk-EQ3DVZV5.js +15 -0
  9. package/dist/src/chunk-IKKANHTF.js +94 -0
  10. package/dist/src/chunk-JDXHKYLZ.js +369 -0
  11. package/dist/src/chunk-JVCECTG2.js +77 -0
  12. package/dist/src/{chunk-BT3Z5CJI.js → chunk-YBHISJLN.js} +70 -31
  13. package/dist/src/cli.js +12 -7
  14. package/dist/src/{commands-QCUCX2GF.js → commands-34YCDSR5.js} +8 -5
  15. package/dist/src/{problems-7BVC64RO.js → problems-U4QXN6RO.js} +4 -2
  16. package/dist/src/project-WS7P5VIH.js +12 -0
  17. package/dist/src/render-child.js +284 -9
  18. package/dist/src/{run-5WC5WRZ2.js → run-7PM6EPND.js} +45 -9
  19. package/dist/src/{server-GK3EWFX3.js → server-YQYW4FT4.js} +6 -5
  20. package/dist/src/site-SVNNSF72.js +139 -0
  21. package/dist/web/app/assets/9733ee91/aula-method.js +1 -0
  22. package/dist/web/app/assets/9733ee91/aula.js +1 -0
  23. package/dist/web/app/assets/{dcda3118 → 9733ee91}/build-worker.js +2 -2
  24. package/dist/web/app/assets/9733ee91/index.js +52 -0
  25. package/dist/web/app/assets/__vite-browser-external-B57JSoUh.js +1 -0
  26. package/dist/web/app/assets/aula-voice-worker-CjOTYyla.js +52 -0
  27. package/dist/web/app/assets/{aula.core5-BhR-OOvz.wasm → aula.core5-CfWXNps1.wasm} +0 -0
  28. package/dist/web/app/assets/{index-C_rGCAZR.css → index-BXxc0ZmT.css} +1 -1
  29. package/dist/web/app/assets/protocol-CylXac4E.js +15 -0
  30. package/dist/web/app/assets/src-CkCfHCj6.js +25 -0
  31. package/dist/web/app/index.html +4 -4
  32. package/dist/web/site/assets/64cc3acd/aula-method.js +1 -0
  33. package/dist/web/site/assets/64cc3acd/aula.js +1 -0
  34. package/dist/web/site/assets/64cc3acd/build-worker.js +696 -0
  35. package/dist/web/site/assets/64cc3acd/index.js +52 -0
  36. package/dist/web/site/assets/__vite-browser-external-BtQTJ51O.js +1 -0
  37. package/dist/web/site/assets/__vite-browser-external-uE9Q5hLF.js +1 -0
  38. package/dist/web/site/assets/aula-voice-worker-CbfByYTT.js +54 -0
  39. package/dist/web/site/assets/aula.core-BtiPQSZi.wasm +0 -0
  40. package/dist/web/site/assets/aula.core5-CfWXNps1.wasm +0 -0
  41. package/dist/web/site/assets/esbuild-BaXVPFT2.wasm +0 -0
  42. package/dist/web/site/assets/index-Dn5gqwRn.css +2 -0
  43. package/dist/web/site/assets/protocol-C4jhAcOf.js +15 -0
  44. package/dist/web/site/assets/rolldown-runtime-BLXQ4ufn.js +1 -0
  45. package/dist/web/site/assets/src-BlEGe8aL.js +25 -0
  46. package/dist/web/site/index.html +39 -0
  47. package/package.json +2 -2
  48. package/dist/src/chunk-GFCJYE75.js +0 -42
  49. package/dist/src/project-NWT5MDQI.js +0 -11
  50. package/dist/web/app/assets/__vite-browser-external-BTgt74Au.js +0 -1
  51. package/dist/web/app/assets/aula-voice-worker-CZGtnmSr.js +0 -52
  52. package/dist/web/app/assets/dcda3118/aula-method.js +0 -1
  53. package/dist/web/app/assets/dcda3118/aula.js +0 -1
  54. package/dist/web/app/assets/dcda3118/index.js +0 -52
  55. package/dist/web/app/assets/protocol-OKrdpPQW.js +0 -15
  56. package/dist/web/app/assets/src-DYumAKNc.js +0 -25
@@ -0,0 +1,369 @@
1
+ import {
2
+ projectFiles,
3
+ zipBytes
4
+ } from "./chunk-DQ2NGXNI.js";
5
+ import {
6
+ VIDEO,
7
+ assemble,
8
+ ffmpeg,
9
+ hasAudio
10
+ } from "./chunk-IKKANHTF.js";
11
+ import {
12
+ printDiagnostics
13
+ } from "./chunk-EQ3DVZV5.js";
14
+ import {
15
+ chapterIndexes,
16
+ checkProject,
17
+ clipPlan,
18
+ clock,
19
+ exportCheck,
20
+ movesMarkdown,
21
+ narrationAt,
22
+ noteLine,
23
+ notesLine,
24
+ overlayPlan,
25
+ pictureGroups,
26
+ pictureStills,
27
+ previewJobs,
28
+ previewTargets,
29
+ scriptView,
30
+ targetChapters,
31
+ timelineView,
32
+ wordNotes
33
+ } from "./chunk-YBHISJLN.js";
34
+ import {
35
+ narrateScript,
36
+ scriptAudio,
37
+ wav
38
+ } from "./chunk-S74JLCZK.js";
39
+ import {
40
+ host
41
+ } from "./chunk-5VYKT646.js";
42
+ import {
43
+ folderOf,
44
+ nameOf
45
+ } from "./chunk-JVCECTG2.js";
46
+ import {
47
+ ObjectRuntype,
48
+ OptionalFieldRuntype,
49
+ RefRuntype,
50
+ TypeofRuntype,
51
+ buildParsers,
52
+ isError,
53
+ wrongArgument
54
+ } from "./chunk-2NMVSQG4.js";
55
+
56
+ // src/commands.ts
57
+ import path from "node:path";
58
+ import { m, renderChapter } from "@beff/aula";
59
+ import { chapterNames } from "@beff/aula/run";
60
+ import { narrationScript } from "@beff/aula/text";
61
+
62
+ // src/narrate.ts
63
+ function narrate(capabilities, chapters) {
64
+ return narrateScript(
65
+ (words) => capabilities.narrator.speak(words),
66
+ chapters,
67
+ (spoken, count, cue) => {
68
+ capabilities.log.out(`[${String(spoken)}/${String(count)}] Narrating: ${cue.text.slice(0, 70)}`);
69
+ }
70
+ );
71
+ }
72
+
73
+ // generated/parser.js
74
+ var RequiredStringFormats = [];
75
+ var RequiredNumberFormats = [];
76
+ var namedRuntypes = {};
77
+ var stringFormatters = {};
78
+ var numberFormatters = {};
79
+ var direct_hoist_0 = new RefRuntype(void 0, "TokensLine", namedRuntypes);
80
+ var direct_hoist_1 = new TypeofRuntype(void 0, "string");
81
+ var direct_hoist_2 = new ObjectRuntype({
82
+ "description": "One input line of `aula tokens`: a text, and an optional id that the output line repeats."
83
+ }, {
84
+ "id": new OptionalFieldRuntype(direct_hoist_1),
85
+ "text": direct_hoist_1
86
+ }, []);
87
+ Object.assign(namedRuntypes, {
88
+ "TokensLine": direct_hoist_2
89
+ });
90
+ var buildParsersInput = {
91
+ "TokensLine": direct_hoist_0
92
+ };
93
+ var parser_default = {
94
+ buildParsers: (args) => buildParsers(
95
+ {
96
+ parsers: buildParsersInput,
97
+ stringFormatters,
98
+ numberFormatters,
99
+ requiredStringFormats: RequiredStringFormats,
100
+ requiredNumberFormats: RequiredNumberFormats
101
+ },
102
+ args
103
+ )
104
+ };
105
+
106
+ // src/parsers.ts
107
+ var Parsers = parser_default.buildParsers();
108
+
109
+ // src/commands.ts
110
+ async function withHeavy(capabilities, f) {
111
+ const release = await capabilities.locks.heavy();
112
+ try {
113
+ return await f();
114
+ } finally {
115
+ await release();
116
+ }
117
+ }
118
+ async function withWork(capabilities, f) {
119
+ const work = await capabilities.fs.mkdtemp(path.join(capabilities.env.temp, "aula-"));
120
+ try {
121
+ return await f(work);
122
+ } finally {
123
+ await capabilities.fs.rm(work, { recursive: true, force: true });
124
+ }
125
+ }
126
+ async function parallel(items, limit, task) {
127
+ let next = 0;
128
+ const worker = async () => {
129
+ for (let item = items[next++]; item !== void 0; item = items[next++]) await task(item);
130
+ };
131
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
132
+ }
133
+ async function drawChapter(capabilities, root, project, index, narration, lottie) {
134
+ const built = renderChapter(project, index, { host: host(capabilities, root), narration });
135
+ if (!built.ok || built.value === void 0) {
136
+ return { ok: false, findings: built.diagnostics, frames: 0, waits: [], embeds: [], narration };
137
+ }
138
+ await capabilities.fs.writeFile(lottie, built.value.lottie, "utf8");
139
+ const { frames, waits, embeds } = built.value;
140
+ return { ok: true, findings: built.diagnostics, frames, waits, embeds, narration: built.value.narration };
141
+ }
142
+ async function placedClips(capabilities, folder, overlays) {
143
+ return Promise.all(
144
+ overlays.map(async (o) => {
145
+ const file = path.join(folder, o.path);
146
+ const picture = o.image === void 0 ? void 0 : path.join(folder, o.image);
147
+ const video = o.kind === "video";
148
+ return {
149
+ file,
150
+ picture,
151
+ seen: video || picture !== void 0,
152
+ heard: !video || await hasAudio(capabilities, file),
153
+ at: o.at,
154
+ seconds: o.seconds
155
+ };
156
+ })
157
+ );
158
+ }
159
+ var inFolder = (folder, groups) => groups.map((group) => ({
160
+ ...group,
161
+ tiles: group.tiles.map((tile) => {
162
+ const { embed } = tile;
163
+ if (embed?.picture === void 0) return tile;
164
+ return { ...tile, embed: { ...embed, picture: path.join(folder, embed.picture) } };
165
+ })
166
+ }));
167
+ var rowLine = (project, r) => `${nameOf(project)}: ${String(r.errors)} errors, ${String(r.warnings)} warnings, ${String(r.open)} open moves`;
168
+ async function printChecked(capabilities, root, project, checked) {
169
+ await printDiagnostics(capabilities, root, checked.findings);
170
+ printCounts(capabilities, project, checked);
171
+ }
172
+ function printCounts(capabilities, project, checked) {
173
+ const { errors, warnings } = checked.others;
174
+ if (errors + warnings > 0)
175
+ capabilities.log.out(`other chapters: ${String(errors)} errors, ${String(warnings)} warnings`);
176
+ capabilities.log.out(rowLine(project, checked));
177
+ }
178
+ async function check(capabilities, root, project, only, json = false) {
179
+ const chapters = chapterIndexes(project, only);
180
+ const checked = checkProject(project, host(capabilities, root), chapters);
181
+ const notes = wordNotes(narrationScript(project, checked.texts), chapters);
182
+ if (json) {
183
+ const { findings, others, errors, warnings, open } = checked;
184
+ const result = { name: nameOf(project), errors, warnings, openMoves: open, others, findings, notes };
185
+ capabilities.log.out(JSON.stringify(result, null, 2));
186
+ return errors === 0;
187
+ }
188
+ await printDiagnostics(capabilities, root, checked.findings);
189
+ for (const note of notes) capabilities.log.out(noteLine(note));
190
+ if (notes.length > 0) capabilities.log.out(notesLine(notes));
191
+ printCounts(capabilities, project, checked);
192
+ return checked.errors === 0;
193
+ }
194
+ async function script(capabilities, root, project) {
195
+ capabilities.log.write(scriptView(project, host(capabilities, root)));
196
+ return true;
197
+ }
198
+ async function timeline(capabilities, root, project, only) {
199
+ capabilities.log.write(await timelineView(project, host(capabilities, root), capabilities.narrator, only));
200
+ return true;
201
+ }
202
+ async function preview(capabilities, root, project, folder, given) {
203
+ const targets = previewTargets(project, given);
204
+ const checked = checkProject(project, host(capabilities, root), targetChapters(targets, given));
205
+ await printChecked(capabilities, root, project, checked);
206
+ if (checked.errors > 0) return false;
207
+ const all = checked.texts;
208
+ const n = await clock(capabilities.narrator, narrationScript(project, all));
209
+ const jobs = previewJobs(targets, all).map((job) => ({
210
+ ...job,
211
+ out: path.join(folder, job.base),
212
+ written: []
213
+ }));
214
+ return withWork(capabilities, async (work) => {
215
+ for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
216
+ const stopped = [];
217
+ const waits = [];
218
+ await withHeavy(
219
+ capabilities,
220
+ () => parallel(jobs, capabilities.env.parallelism, async (job) => {
221
+ const lottie = path.join(work, `${job.base}.json`);
222
+ const drawn = await drawChapter(capabilities, root, project, job.index, narrationAt(n, job.index), lottie);
223
+ if (!drawn.ok) {
224
+ stopped.push(...drawn.findings);
225
+ return;
226
+ }
227
+ waits.push(...drawn.findings.filter((d) => !isError(d)));
228
+ const { out } = job;
229
+ const { window, stills } = pictureStills(drawn.narration, job, drawn.frames, drawn.embeds);
230
+ const groups = inFolder(folderOf(project), pictureGroups(window, stills));
231
+ const sheets = await capabilities.render.pictures({ lottie, out, groups });
232
+ await capabilities.fs.mkdir(out, { recursive: true });
233
+ await capabilities.fs.writeFile(path.join(out, "moves.md"), movesMarkdown(stills));
234
+ job.written.push(path.join(out, "moves.md"), ...sheets);
235
+ })
236
+ );
237
+ if (stopped.length) {
238
+ await printDiagnostics(capabilities, root, stopped);
239
+ return false;
240
+ }
241
+ await printDiagnostics(capabilities, root, waits);
242
+ for (const line of jobs.flatMap((job) => job.written)) capabilities.log.out(line);
243
+ return true;
244
+ });
245
+ }
246
+ async function exportVideo(capabilities, root, project, file) {
247
+ if (!file.endsWith(".mp4")) throw wrongArgument(`the video path must end in .mp4: ${file}`);
248
+ const names = chapterNames(project);
249
+ const checked = exportCheck(project, host(capabilities, root));
250
+ await printChecked(capabilities, root, project, checked);
251
+ if (checked.errors > 0) {
252
+ capabilities.log.out(`export ${nameOf(project)}: stopped at check: fix the errors above`);
253
+ return false;
254
+ }
255
+ await ffmpeg(capabilities, ["-version"]);
256
+ return withWork(capabilities, async (work) => {
257
+ const audio = path.join(work, "narration.wav");
258
+ const cues = narrationScript(project, checked.texts);
259
+ const narrated = await withHeavy(capabilities, () => narrate(capabilities, cues));
260
+ const lotties = names.map((name) => path.join(work, `${name}.json`));
261
+ const drawn = [];
262
+ const problems = [];
263
+ let done = 0;
264
+ await withHeavy(
265
+ capabilities,
266
+ () => parallel(
267
+ names.map((_, index) => index),
268
+ capabilities.env.parallelism,
269
+ async (index) => {
270
+ const narration = narrated[index]?.narration;
271
+ if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
272
+ const chapter = await drawChapter(capabilities, root, project, index, narration, lotties[index] ?? "");
273
+ drawn[index] = chapter;
274
+ if (!chapter.ok) problems.push(...chapter.findings);
275
+ done += 1;
276
+ capabilities.log.out(
277
+ `[${String(done)}/${String(names.length)}] ${names[index] ?? ""}: ${chapter.ok ? "drawn" : "FAILED"}`
278
+ );
279
+ }
280
+ )
281
+ );
282
+ if (problems.length) {
283
+ await printDiagnostics(capabilities, root, problems);
284
+ return false;
285
+ }
286
+ const { samples, sampleRate } = scriptAudio(
287
+ narrated,
288
+ drawn.map((d) => d.waits)
289
+ );
290
+ await capabilities.fs.writeFile(audio, wav(samples, sampleRate));
291
+ capabilities.log.out(`Narrated ${(samples.length / sampleRate / 60).toFixed(1)} minutes`);
292
+ const plan = clipPlan(
293
+ drawn.map((d) => d.narration),
294
+ VIDEO.fps
295
+ );
296
+ const clips = names.map((name) => path.join(work, `${name}.mp4`));
297
+ await withHeavy(
298
+ capabilities,
299
+ () => parallel(
300
+ names.map((_, index) => index),
301
+ capabilities.env.parallelism,
302
+ async (index) => {
303
+ const clip = plan.clips[index] ?? { from: 0, frames: 0 };
304
+ await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
305
+ }
306
+ )
307
+ );
308
+ await capabilities.fs.mkdir(path.dirname(file), { recursive: true });
309
+ const placed = await placedClips(
310
+ capabilities,
311
+ folderOf(project),
312
+ overlayPlan(
313
+ drawn.map((d) => d.narration),
314
+ drawn.map((d) => d.embeds)
315
+ )
316
+ );
317
+ const background = (project.theme ?? m.theme).background;
318
+ await assemble(capabilities, { work, clips, audio, seconds: plan.seconds, out: file, placed, background });
319
+ capabilities.log.out(file);
320
+ return true;
321
+ });
322
+ }
323
+ async function bundle(capabilities, project, file) {
324
+ if (!file.endsWith(".zip")) throw new Error(`the zip path must end in .zip: ${file}`);
325
+ const home = folderOf(project);
326
+ const root = path.parse(home).root;
327
+ const folder = path.relative(root, home).split(path.sep).join("/");
328
+ const esbuild = await import("esbuild-wasm");
329
+ let files;
330
+ try {
331
+ files = await projectFiles(capabilities, esbuild, root, folder);
332
+ } finally {
333
+ await esbuild.stop();
334
+ }
335
+ const entries = /* @__PURE__ */ new Map();
336
+ for (const [at, from] of files)
337
+ entries.set(at, new Uint8Array(await capabilities.fs.readFile(path.join(root, from))));
338
+ const zip = zipBytes(entries);
339
+ await capabilities.fs.mkdir(path.dirname(file), { recursive: true });
340
+ await capabilities.fs.writeFile(file, zip);
341
+ capabilities.log.out(`${file}: ${String(files.size)} files, ${String(Math.ceil(zip.length / 1024))} kB`);
342
+ return true;
343
+ }
344
+ async function tokens(capabilities, tokensOf, lines) {
345
+ let number = 0;
346
+ for await (const line of lines) {
347
+ number += 1;
348
+ if (!line.trim()) continue;
349
+ const parsed = Parsers.TokensLine.safeParse(JSON.parse(line));
350
+ if (!parsed.success) throw wrongArgument(`stdin line ${String(number)}: expected {"id"?: string, "text": string}`);
351
+ const { id, text } = parsed.data;
352
+ capabilities.log.out(JSON.stringify({ ...id === void 0 ? {} : { id }, batches: await tokensOf(text) }));
353
+ }
354
+ return true;
355
+ }
356
+ function tokensArgs(positional) {
357
+ if (positional.length > 0) throw wrongArgument("aula tokens takes no arguments", "run `aula help` for the usage");
358
+ }
359
+
360
+ export {
361
+ check,
362
+ script,
363
+ timeline,
364
+ preview,
365
+ exportVideo,
366
+ bundle,
367
+ tokens,
368
+ tokensArgs
369
+ };
@@ -0,0 +1,77 @@
1
+ import {
2
+ Problems,
3
+ error,
4
+ projectName,
5
+ wrongArgument
6
+ } from "./chunk-2NMVSQG4.js";
7
+
8
+ // ../aula-project/src/node.ts
9
+ import path from "node:path";
10
+ import { pathToFileURL } from "node:url";
11
+ import { isProjectDefinition } from "@beff/aula";
12
+ import { definedAt, loadEngine, v8Frames } from "@beff/aula/run";
13
+ var PROJECT_MODULE = "index.ts";
14
+ var GLUE = [
15
+ `${path.dirname(new URL(import.meta.resolve("@beff/aula")).pathname)}/`,
16
+ new URL(import.meta.url).pathname
17
+ ];
18
+ function host(capabilities, root, glue = []) {
19
+ const all = [...GLUE, ...glue];
20
+ return {
21
+ frames: v8Frames,
22
+ name: (file) => file.startsWith("/") && !file.includes("/node_modules/") && !all.some((g) => file.startsWith(g)) ? path.relative(root, file) : void 0,
23
+ exists: (file) => capabilities.fs.existsSync(path.resolve(root, file)),
24
+ media: (file) => {
25
+ const full = path.resolve(root, file);
26
+ const stat = capabilities.fs.statSync(full, { throwIfNoEntry: false });
27
+ if (stat === void 0 || !stat.isFile()) return void 0;
28
+ let bytes;
29
+ return { size: stat.size, read: () => bytes ??= capabilities.fs.readFileSync(full) };
30
+ }
31
+ };
32
+ }
33
+ function propertyOf(e, key) {
34
+ return typeof e === "object" && e !== null ? Reflect.get(e, key) : void 0;
35
+ }
36
+ async function loadProject(capabilities, load, root, folder) {
37
+ const file = path.join(folder, PROJECT_MODULE);
38
+ if (!capabilities.fs.existsSync(file)) {
39
+ throw wrongArgument(
40
+ `${path.relative(root, folder) || "."} has no ${PROJECT_MODULE}`,
41
+ `give the project folder: the folder with ${PROJECT_MODULE}`
42
+ );
43
+ }
44
+ await loadEngine();
45
+ const module = await load(pathToFileURL(file).href);
46
+ const exported = propertyOf(module, "default");
47
+ if (!isProjectDefinition(exported)) {
48
+ const rel = path.relative(root, file);
49
+ throw new Problems([
50
+ error(`the default export of ${rel} is not made by defineProject`, {
51
+ location: { file: rel, line: 1, col: 0 },
52
+ hint: "write `export default defineProject({ title, theme, chapters: [ \u2026 ] })`"
53
+ })
54
+ ]);
55
+ }
56
+ return exported;
57
+ }
58
+ var folderOf = (project) => path.dirname(definedAt(project).file);
59
+ var nameOf = (project) => projectName(path.basename(folderOf(project)));
60
+ async function withSource(capabilities, root, d) {
61
+ if (d.source !== void 0 || d.location === void 0) return d;
62
+ const file = path.resolve(root, d.location.file);
63
+ if (!capabilities.fs.existsSync(file)) return d;
64
+ const text = await capabilities.fs.readFile(file, "utf8");
65
+ const lines = text.split("\n");
66
+ if (lines.at(-1) === "") lines.pop();
67
+ const line = lines[d.location.line - 1];
68
+ return line === void 0 || d.location.line < 1 ? d : { ...d, source: line.replace(/\r$/, "") };
69
+ }
70
+
71
+ export {
72
+ host,
73
+ loadProject,
74
+ folderOf,
75
+ nameOf,
76
+ withSource
77
+ };
@@ -5,13 +5,8 @@ import {
5
5
  Problems,
6
6
  error,
7
7
  isError,
8
- withSource,
9
8
  wrongArgument
10
- } from "./chunk-7KT36JRP.js";
11
-
12
- // src/problems.ts
13
- import { loadEngine as loadEngine2 } from "@beff/aula/run";
14
- import { renderDiagnostic } from "@beff/aula/text";
9
+ } from "./chunk-2NMVSQG4.js";
15
10
 
16
11
  // ../aula-project/src/chapters.ts
17
12
  import { readChapter } from "@beff/aula";
@@ -54,7 +49,7 @@ function scriptView(project, host) {
54
49
  return scriptMarkdown(project.title, texts(project, host));
55
50
  }
56
51
  function openMoves(text) {
57
- return text.paragraphs.flatMap((p) => p.moves).filter((m) => !m.done);
52
+ return text.paragraphs.flatMap((p) => p.moves).filter((m2) => !m2.done);
58
53
  }
59
54
  function openCount(chapters, indexes) {
60
55
  return chapters.filter((_, i) => indexes.includes(i + 1)).reduce((sum, t) => sum + openMoves(t).length, 0);
@@ -123,12 +118,13 @@ function chapterIndexes(project, only) {
123
118
  }
124
119
 
125
120
  // ../aula-project/src/export.ts
121
+ import { FPS } from "@beff/aula/run";
126
122
  function exportCheck(project, host) {
127
123
  const checked = checkProject(project, host, null);
128
124
  const open = checked.texts.flatMap(
129
125
  (t) => openMoves(t).map(
130
- (m) => error(`show: the move "${m.note}" has no animation yet`, {
131
- location: m.place,
126
+ (m2) => error(`show: the move "${m2.note}" has no animation yet`, {
127
+ location: m2.place,
132
128
  hint: "give the show its move, show`note``25%`((s) => { \u2026 }), or make it a hold, show`note``25%`(() => {})"
133
129
  })
134
130
  )
@@ -145,6 +141,23 @@ function clipPlan(narrations, fps) {
145
141
  });
146
142
  return { clips, seconds: starts.at(-1) ?? 0 };
147
143
  }
144
+ function overlayPlan(narrations, embeds) {
145
+ let offset = 0;
146
+ const out = [];
147
+ narrations.forEach((narration, index) => {
148
+ for (const e of embeds[index] ?? []) {
149
+ out.push({
150
+ path: e.path,
151
+ image: e.image,
152
+ kind: e.kind,
153
+ at: offset + e.start / narration.sampleRate,
154
+ seconds: e.frames / FPS
155
+ });
156
+ }
157
+ offset += narration.endFrame / narration.sampleRate;
158
+ });
159
+ return out;
160
+ }
148
161
 
149
162
  // ../aula-project/src/notes.ts
150
163
  import { unclearWords } from "@beff/aula/text";
@@ -179,11 +192,15 @@ function notesLine(notes) {
179
192
  }
180
193
 
181
194
  // ../aula-project/src/preview.ts
182
- import { chapterNames as chapterNames2, FPS } from "@beff/aula/run";
195
+ import { chapterNames as chapterNames2, FPS as FPS3 } from "@beff/aula/run";
183
196
 
184
197
  // ../aula-project/src/stills.ts
185
- import { moveFrames } from "@beff/aula/text";
186
- function stillsOf(narration, text, frames) {
198
+ import { FPS as FPS2 } from "@beff/aula/run";
199
+ import {
200
+ moveFrames
201
+ } from "@beff/aula/text";
202
+ var clipLength = (frames) => `${(frames / FPS2).toFixed(1)} s`;
203
+ function stillsOf(narration, text, frames, embeds = []) {
187
204
  if (text === null) {
188
205
  return [{ name: "title", cue: 0, place: null, note: "title card", frame: Math.floor(0.6 * frames) }];
189
206
  }
@@ -191,12 +208,24 @@ function stillsOf(narration, text, frames) {
191
208
  const moves = paragraphs.flatMap(
192
209
  (p, k) => Array.from(p.moves, (start, i) => ({ start, cue: k + 1, move: text.paragraphs[k]?.moves[i] }))
193
210
  );
194
- return moves.flatMap(({ start, cue, move }, i) => {
211
+ const ofMoves = moves.flatMap(({ start, cue, move }, i) => {
195
212
  if (move === void 0) return [];
196
213
  const next = moves[i + 1]?.start ?? frames;
197
214
  const name = `L${String(move.place.line).padStart(4, "0")}`;
198
215
  return [{ name, cue, place: move.place, note: move.note, frame: Math.max(start, next - 1) }];
199
216
  });
217
+ const rows = text.paragraphs.flatMap((p, k) => p.embeds.map((embed) => ({ embed, cue: k + 1 })));
218
+ const ofEmbeds = rows.flatMap(({ embed, cue }, i) => {
219
+ const played = embeds[i];
220
+ if (played === void 0) return [];
221
+ const frame = Math.min(Math.round(played.start / narration.sampleRate * FPS2), Math.max(frames - 1, 0));
222
+ const name = `E${String(embed.place?.line ?? 0).padStart(4, "0")}`;
223
+ const note = `embed: ${embed.note}`;
224
+ const length = clipLength(played.frames);
225
+ const clip = { path: played.path, image: played.image, kind: played.kind, length };
226
+ return [{ name, cue, place: embed.place ?? null, note, frame, embed: clip }];
227
+ });
228
+ return [...ofMoves, ...ofEmbeds].toSorted((a, b) => a.frame - b.frame);
200
229
  }
201
230
  function paragraphWindow(narration, text, cue, frames) {
202
231
  const paragraphs = moveFrames(narration, text);
@@ -210,10 +239,10 @@ function previewTargets(project, given) {
210
239
  const names = chapterNames2(project);
211
240
  if (given.length === 0) return names.map((name, index) => ({ index, name, line: null }));
212
241
  return given.map((target) => {
213
- const m = /^(.*):([0-9]+)$/.exec(target);
214
- const index = chapterIndex(names, m?.[1] ?? target);
215
- if (index === 0 && m !== null) throw wrongArgument("the title card has no lines: give a chapter name with :<line>");
216
- return { index, name: names[index] ?? target, line: m?.[2] === void 0 ? null : Number(m[2]) };
242
+ const m2 = /^(.*):([0-9]+)$/.exec(target);
243
+ const index = chapterIndex(names, m2?.[1] ?? target);
244
+ if (index === 0 && m2 !== null) throw wrongArgument("the title card has no lines: give a chapter name with :<line>");
245
+ return { index, name: names[index] ?? target, line: m2?.[2] === void 0 ? null : Number(m2[2]) };
217
246
  });
218
247
  }
219
248
  var targetChapters = (targets, given) => given.length === 0 ? null : [...new Set(targets.map((t) => t.index))];
@@ -226,27 +255,42 @@ function previewJobs(targets, chapters) {
226
255
  return { ...t, base, text, cue };
227
256
  });
228
257
  }
229
- function pictureStills(narration, job, frames) {
258
+ function pictureStills(narration, job, frames, embeds = []) {
230
259
  const { text, cue } = job;
231
260
  const window = text === null || cue === null ? [0, frames] : paragraphWindow(narration, text, cue, frames);
232
- const stills = stillsOf(narration, text, frames).filter((s) => cue === null || s.cue === cue);
261
+ const stills = stillsOf(narration, text, frames, embeds).filter((s) => cue === null || s.cue === cue);
233
262
  return { window, stills };
234
263
  }
264
+ function tileEmbed(still) {
265
+ const clip = still.embed;
266
+ if (clip === void 0) return void 0;
267
+ if (clip.kind === "sound") return { picture: clip.image, lines: [] };
268
+ return { picture: void 0, lines: [still.note.replace(/^embed: /, ""), `${clip.path} \xB7 ${clip.length}`] };
269
+ }
235
270
  function pictureGroups(window, stills) {
236
271
  const [from, to] = window;
237
272
  const motion = [];
238
- for (let k = Math.ceil(from * 2 / FPS); Math.floor(k * FPS / 2) < to; k++) {
239
- motion.push({ name: `t${(k / 2).toFixed(1).padStart(5, "0")}s`, frame: Math.floor(k * FPS / 2) });
273
+ for (let k = Math.ceil(from * 2 / FPS3); Math.floor(k * FPS3 / 2) < to; k++) {
274
+ motion.push({ name: `t${(k / 2).toFixed(1).padStart(5, "0")}s`, frame: Math.floor(k * FPS3 / 2) });
240
275
  }
241
276
  return [
242
- { folder: "stills", cols: 3, rows: 3, tiles: stills.map((s) => ({ name: s.name, frame: s.frame })) },
277
+ {
278
+ folder: "stills",
279
+ cols: 3,
280
+ rows: 3,
281
+ tiles: stills.map((s) => {
282
+ const embed = tileEmbed(s);
283
+ return embed === void 0 ? { name: s.name, frame: s.frame } : { name: s.name, frame: s.frame, embed };
284
+ })
285
+ },
243
286
  { folder: "motion", cols: 4, rows: 4, tiles: motion }
244
287
  ];
245
288
  }
246
289
  function movesMarkdown(stills) {
247
290
  return stills.map((still) => {
248
291
  const at = still.place ? placeText(still.place) : "title card";
249
- return `- ${at}, ${(still.frame / FPS).toFixed(1)} s: ${still.note} (stills/${still.name}.png)
292
+ const clip = still.embed === void 0 ? "" : ` (${still.embed.path}, ${still.embed.length})`;
293
+ return `- ${at}, ${(still.frame / FPS3).toFixed(1)} s: ${still.note}${clip} (stills/${still.name}.png)
250
294
  `;
251
295
  }).join("");
252
296
  }
@@ -276,6 +320,7 @@ Metaphor: ${text.metaphor}
276
320
  }
277
321
 
278
322
  // ../aula-project/src/videos.ts
323
+ import { FPS as FPS4 } from "@beff/aula/run";
279
324
  import { estimateNarration } from "@beff/aula/text";
280
325
 
281
326
  // ../aula-project/src/workspace.ts
@@ -285,12 +330,6 @@ import {
285
330
  narrationScript as narrationScript2
286
331
  } from "@beff/aula/text";
287
332
 
288
- // src/problems.ts
289
- async function printDiagnostics(capabilities, root, diagnostics, print = (text) => capabilities.log.out(text)) {
290
- await loadEngine2();
291
- for (const d of diagnostics) print(renderDiagnostic(await withSource(capabilities, root, d)));
292
- }
293
-
294
333
  export {
295
334
  scriptView,
296
335
  clock,
@@ -299,6 +338,7 @@ export {
299
338
  chapterIndexes,
300
339
  exportCheck,
301
340
  clipPlan,
341
+ overlayPlan,
302
342
  wordNotes,
303
343
  noteLine,
304
344
  notesLine,
@@ -308,6 +348,5 @@ export {
308
348
  pictureStills,
309
349
  pictureGroups,
310
350
  movesMarkdown,
311
- timelineView,
312
- printDiagnostics
351
+ timelineView
313
352
  };