@beff/aula-cli 0.6.2 → 0.7.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/dist/src/{chunk-LSXILCMB.js → chunk-HLRTXRAC.js} +23 -35
- package/dist/src/{chunk-6CZECZIX.js → chunk-JWAUET3S.js} +374 -15
- package/dist/src/{chunk-3MPFI4UE.js → chunk-RRS3SD7K.js} +41 -18
- package/dist/src/{chunk-EZROW2IP.js → chunk-STW7EAFL.js} +1 -1
- package/dist/src/chunk-THQ5Y74K.js +64 -0
- package/dist/src/{chunk-7C6QW2TD.js → chunk-UKSA5OFC.js} +1 -1
- package/dist/src/{chunk-J7LNPVU2.js → chunk-WY3AMP6M.js} +1 -1
- package/dist/src/cli.js +6 -6
- package/dist/src/{commands-7MTNNJKO.js → commands-NDTPHXGF.js} +7 -7
- package/dist/src/{problems-CCUJW4H4.js → problems-CQXPY4G5.js} +4 -4
- package/dist/src/project-ICPIW4MO.js +12 -0
- package/dist/src/{run-VCOTEL37.js → run-IBCNVZ4J.js} +7 -7
- package/dist/src/{server-5W36J7WM.js → server-QQ2V343V.js} +83 -26
- package/dist/src/{site-NA5QNSHF.js → site-XYQKQZLZ.js} +32 -64
- package/dist/web/app/assets/{3cdff963 → 7ca1e7de}/aula-method.js +1 -1
- package/dist/web/app/assets/{3cdff963 → 7ca1e7de}/aula.js +1 -1
- package/dist/web/app/assets/7ca1e7de/build-worker.js +2 -0
- package/dist/web/app/assets/{3cdff963 → 7ca1e7de}/index.js +3 -4
- package/dist/web/app/assets/__vite-browser-external-CZjgZoe-.js +1 -0
- package/dist/web/{site/assets/aula-voice-worker-DHEZKCCg.js → app/assets/aula-voice-worker-CjeRSu86.js} +10 -12
- package/dist/web/app/assets/{3cdff963/build-worker.js → browser-sNTR4ahh.js} +4 -5
- package/dist/web/app/assets/esbuild-D6hmBtXM.js +1 -0
- package/dist/web/{site/assets/index-BirjmJbl.css → app/assets/index-CFRTa3wf.css} +1 -1
- package/dist/web/app/assets/protocol-CVAj9kTL.js +15 -0
- package/dist/web/app/assets/{src-CTZjQYUv.js → src-uzFdGdZX.js} +2 -3
- package/dist/web/app/index.html +5 -4
- package/dist/web/site/assets/{fbc21d75 → 8f69161f}/aula-method.js +1 -1
- package/dist/web/site/assets/{fbc21d75 → 8f69161f}/aula.js +1 -1
- package/dist/web/site/assets/8f69161f/build-worker.js +2 -0
- package/dist/web/site/assets/{fbc21d75 → 8f69161f}/index.js +3 -4
- package/dist/web/site/assets/__vite-browser-external-lWmWnTMm.js +1 -0
- package/dist/web/{app/assets/aula-voice-worker-C7UeMloK.js → site/assets/aula-voice-worker-Sm-si1oe.js} +10 -10
- package/dist/web/site/assets/{fbc21d75/build-worker.js → browser-sNTR4ahh.js} +4 -5
- package/dist/web/site/assets/esbuild-CW5RQptO.js +1 -0
- package/dist/web/{app/assets/index-BirjmJbl.css → site/assets/index-CFRTa3wf.css} +1 -1
- package/dist/web/site/assets/protocol-47nVPHKy.js +15 -0
- package/dist/web/site/assets/{src-1_dQqt80.js → src-DWVrqSqZ.js} +2 -3
- package/dist/web/site/index.html +5 -4
- package/package.json +2 -2
- package/dist/src/chunk-EB67KE2S.js +0 -369
- package/dist/src/project-PF77AQKF.js +0 -12
- package/dist/web/app/assets/__vite-browser-external-CTDtqMqs.js +0 -1
- package/dist/web/app/assets/protocol-C3MGnf_t.js +0 -15
- package/dist/web/site/assets/__vite-browser-external-D1sFDdqr.js +0 -1
- package/dist/web/site/assets/protocol-CzWPeNPI.js +0 -15
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
timeChapter
|
|
3
3
|
} from "./chunk-S74JLCZK.js";
|
|
4
4
|
import {
|
|
5
|
+
LIST_MODULE,
|
|
5
6
|
Problems,
|
|
6
|
-
bundle,
|
|
7
7
|
error,
|
|
8
8
|
isError,
|
|
9
|
-
|
|
9
|
+
linkBundle,
|
|
10
10
|
wrongArgument
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RRS3SD7K.js";
|
|
12
12
|
|
|
13
13
|
// ../aula-project/src/chapters.ts
|
|
14
14
|
import { readChapter } from "@beff/aula";
|
|
@@ -362,49 +362,37 @@ var workspaceHost = (frames, media) => ({
|
|
|
362
362
|
...media ? { media } : {}
|
|
363
363
|
});
|
|
364
364
|
var propertyOf = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (found.length === 0) {
|
|
372
|
-
throw new Error("no project here: open a folder that has index.ts, or whose subfolders have index.ts");
|
|
373
|
-
}
|
|
374
|
-
const list = [
|
|
375
|
-
...found.map((module, i) => `import p${String(i)} from ${JSON.stringify(`./${module}`)};`),
|
|
376
|
-
`export default [${found.map((_, i) => `p${String(i)}`).join(", ")}];`
|
|
377
|
-
].join("\n");
|
|
378
|
-
const tree = {
|
|
379
|
-
read: (path) => path === LIST ? Promise.resolve(list) : files.read(path),
|
|
380
|
-
list: (folder) => files.list(folder)
|
|
381
|
-
};
|
|
382
|
-
const [bundled] = await Promise.all([
|
|
383
|
-
bundle(esbuild, tree, LIST, player),
|
|
384
|
-
loadEngine().then(() => {
|
|
385
|
-
engineLoaded?.();
|
|
386
|
-
})
|
|
387
|
-
]);
|
|
388
|
-
if (bundled._tag === "Left") return bundled;
|
|
389
|
-
const loaded = await importUserModule(() => modules.load(bundled.right));
|
|
390
|
-
if (loaded._tag === "Left") return { _tag: "Left", left: [diagnosticOf(loaded.left, LIST, host)] };
|
|
365
|
+
async function loadBuiltProjects(bundled, host, modules, player, engineLoaded) {
|
|
366
|
+
await loadEngine();
|
|
367
|
+
engineLoaded?.();
|
|
368
|
+
const code = linkBundle(bundled.code, player);
|
|
369
|
+
const loaded = await importUserModule(() => modules.load({ code, map: bundled.map }));
|
|
370
|
+
if (loaded._tag === "Left") return { _tag: "Left", left: [diagnosticOf(loaded.left, LIST_MODULE, host)] };
|
|
391
371
|
const exported = propertyOf(loaded.right.exports, "default");
|
|
392
|
-
if (!Array.isArray(exported)) throw new Error(`${
|
|
372
|
+
if (!Array.isArray(exported)) throw new Error(`${LIST_MODULE} has no list of projects`);
|
|
393
373
|
const out = exported.map((definition, i) => {
|
|
374
|
+
const project = bundled.projects[i];
|
|
394
375
|
if (!Engine.isProjectDefinition(definition)) {
|
|
395
376
|
throw new Error(
|
|
396
|
-
`the default export of ${
|
|
377
|
+
`the default export of ${project?.module ?? ""} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ \u2026 ] })\``
|
|
397
378
|
);
|
|
398
379
|
}
|
|
399
|
-
|
|
400
|
-
|
|
380
|
+
return localProject(
|
|
381
|
+
project?.name ?? "",
|
|
382
|
+
folderOfModule(project?.module ?? "index.ts"),
|
|
383
|
+
project?.section,
|
|
384
|
+
definition,
|
|
385
|
+
host
|
|
386
|
+
);
|
|
401
387
|
});
|
|
402
388
|
return { _tag: "Right", right: out };
|
|
403
389
|
}
|
|
404
|
-
|
|
390
|
+
var folderOfModule = (module) => module.slice(0, Math.max(0, module.lastIndexOf("/")));
|
|
391
|
+
function localProject(name, folder, section, definition, host) {
|
|
405
392
|
const count = definition.chapters.length + 1;
|
|
406
393
|
return {
|
|
407
394
|
name,
|
|
395
|
+
folder,
|
|
408
396
|
...section === void 0 ? {} : { section },
|
|
409
397
|
title: definition.title,
|
|
410
398
|
chapters: count,
|
|
@@ -464,5 +452,5 @@ export {
|
|
|
464
452
|
movesMarkdown,
|
|
465
453
|
timelineView,
|
|
466
454
|
workspaceHost,
|
|
467
|
-
|
|
455
|
+
loadBuiltProjects
|
|
468
456
|
};
|
|
@@ -1,8 +1,66 @@
|
|
|
1
1
|
import {
|
|
2
|
+
VIDEO,
|
|
3
|
+
assemble,
|
|
4
|
+
ffmpeg,
|
|
5
|
+
hasAudio
|
|
6
|
+
} from "./chunk-BLKXJGEO.js";
|
|
7
|
+
import {
|
|
8
|
+
printDiagnostics
|
|
9
|
+
} from "./chunk-UKSA5OFC.js";
|
|
10
|
+
import {
|
|
11
|
+
chapterIndexes,
|
|
12
|
+
checkProject,
|
|
13
|
+
clipPlan,
|
|
14
|
+
clock,
|
|
15
|
+
exportCheck,
|
|
16
|
+
movesMarkdown,
|
|
17
|
+
narrationAt,
|
|
18
|
+
noteLine,
|
|
19
|
+
notesLine,
|
|
20
|
+
overlayPlan,
|
|
21
|
+
pictureGroups,
|
|
22
|
+
pictureStills,
|
|
23
|
+
previewJobs,
|
|
24
|
+
previewTargets,
|
|
25
|
+
scriptView,
|
|
26
|
+
targetChapters,
|
|
27
|
+
timelineView,
|
|
28
|
+
wordNotes
|
|
29
|
+
} from "./chunk-HLRTXRAC.js";
|
|
30
|
+
import {
|
|
31
|
+
createNodeBundler
|
|
32
|
+
} from "./chunk-THQ5Y74K.js";
|
|
33
|
+
import {
|
|
34
|
+
narrateScript,
|
|
35
|
+
scriptAudio,
|
|
36
|
+
wav
|
|
37
|
+
} from "./chunk-S74JLCZK.js";
|
|
38
|
+
import {
|
|
39
|
+
host
|
|
40
|
+
} from "./chunk-WY3AMP6M.js";
|
|
41
|
+
import {
|
|
42
|
+
folderOf,
|
|
43
|
+
nameOf
|
|
44
|
+
} from "./chunk-STW7EAFL.js";
|
|
45
|
+
import {
|
|
46
|
+
ObjectRuntype,
|
|
47
|
+
OptionalFieldRuntype,
|
|
48
|
+
PROVIDED,
|
|
2
49
|
Parsers,
|
|
3
50
|
Problems,
|
|
4
|
-
|
|
5
|
-
|
|
51
|
+
RefRuntype,
|
|
52
|
+
TypeofRuntype,
|
|
53
|
+
buildParsers,
|
|
54
|
+
bundle,
|
|
55
|
+
isError,
|
|
56
|
+
wrongArgument
|
|
57
|
+
} from "./chunk-RRS3SD7K.js";
|
|
58
|
+
|
|
59
|
+
// src/commands.ts
|
|
60
|
+
import path2 from "node:path";
|
|
61
|
+
import { m, renderChapter } from "@beff/aula";
|
|
62
|
+
import { chapterNames } from "@beff/aula/run";
|
|
63
|
+
import { narrationScript } from "@beff/aula/text";
|
|
6
64
|
|
|
7
65
|
// ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
|
|
8
66
|
import { createRequire } from "module";
|
|
@@ -139,7 +197,7 @@ var hMap = (function(cd, mb, r) {
|
|
|
139
197
|
var sv = i2 << 4 | cd[i2];
|
|
140
198
|
var r_1 = mb - cd[i2];
|
|
141
199
|
var v = le[cd[i2] - 1]++ << r_1;
|
|
142
|
-
for (var
|
|
200
|
+
for (var m2 = v | (1 << r_1) - 1; v <= m2; ++v) {
|
|
143
201
|
co[rev[v] >> rvb] = sv;
|
|
144
202
|
}
|
|
145
203
|
}
|
|
@@ -688,7 +746,7 @@ function zipSync(data, opts) {
|
|
|
688
746
|
var _a2 = r[fn], file = _a2[0], p = _a2[1];
|
|
689
747
|
var compression = p.level == 0 ? 0 : 8;
|
|
690
748
|
var f = strToU8(fn), s = f.length;
|
|
691
|
-
var com = p.comment,
|
|
749
|
+
var com = p.comment, m2 = com && strToU8(com), ms = m2 && m2.length;
|
|
692
750
|
var exl = exfl(p.extra);
|
|
693
751
|
if (s > 65535)
|
|
694
752
|
err(11);
|
|
@@ -700,8 +758,8 @@ function zipSync(data, opts) {
|
|
|
700
758
|
crc: c.d(),
|
|
701
759
|
c: d,
|
|
702
760
|
f,
|
|
703
|
-
m,
|
|
704
|
-
u: s != fn.length ||
|
|
761
|
+
m: m2,
|
|
762
|
+
u: s != fn.length || m2 && com.length != ms,
|
|
705
763
|
o,
|
|
706
764
|
compression
|
|
707
765
|
}));
|
|
@@ -721,7 +779,6 @@ function zipSync(data, opts) {
|
|
|
721
779
|
}
|
|
722
780
|
|
|
723
781
|
// ../aula-bundle/src/zip.ts
|
|
724
|
-
var PROVIDED = ["@beff/aula", "@beff/aula-method"];
|
|
725
782
|
async function workspacePackage(tree, file, project) {
|
|
726
783
|
for (let folder = parent(file); folder !== "."; folder = parent(folder)) {
|
|
727
784
|
const text = await tree.read(`${folder}/package.json`);
|
|
@@ -737,9 +794,9 @@ function parent(file) {
|
|
|
737
794
|
return at < 0 ? "." : at === 0 ? "/" : file.slice(0, at);
|
|
738
795
|
}
|
|
739
796
|
var installedPackage = (file) => /^(.*node_modules\/(?:@[^/]+\/)?[^/]+)\//.exec(file)?.[1] ?? null;
|
|
740
|
-
async function packageFiles(
|
|
797
|
+
async function packageFiles(bundler, tree, folder) {
|
|
741
798
|
const imports = Object.fromEntries(PROVIDED.map((name) => [name, name]));
|
|
742
|
-
const bundled = await bundle(
|
|
799
|
+
const bundled = await bundle(bundler, tree, `${folder}/index.ts`, imports);
|
|
743
800
|
if (bundled._tag === "Left") return bundled;
|
|
744
801
|
const files = /* @__PURE__ */ new Map();
|
|
745
802
|
for (const file of bundled.right.inputs) {
|
|
@@ -765,6 +822,53 @@ function zipBytes(entries) {
|
|
|
765
822
|
return zipSync(sorted, { mtime: "2000-01-01T12:00:00Z" });
|
|
766
823
|
}
|
|
767
824
|
|
|
825
|
+
// src/narrate.ts
|
|
826
|
+
function narrate(capabilities, chapters) {
|
|
827
|
+
return narrateScript(
|
|
828
|
+
(words) => capabilities.narrator.speak(words),
|
|
829
|
+
chapters,
|
|
830
|
+
(spoken, count, cue) => {
|
|
831
|
+
capabilities.log.out(`[${String(spoken)}/${String(count)}] Narrating: ${cue.text.slice(0, 70)}`);
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// generated/parser.js
|
|
837
|
+
var RequiredStringFormats = [];
|
|
838
|
+
var RequiredNumberFormats = [];
|
|
839
|
+
var namedRuntypes = {};
|
|
840
|
+
var stringFormatters = {};
|
|
841
|
+
var numberFormatters = {};
|
|
842
|
+
var direct_hoist_0 = new RefRuntype(void 0, "TokensLine", namedRuntypes);
|
|
843
|
+
var direct_hoist_1 = new TypeofRuntype(void 0, "string");
|
|
844
|
+
var direct_hoist_2 = new ObjectRuntype({
|
|
845
|
+
"description": "One input line of `aula tokens`: a text, and an optional id that the output line repeats."
|
|
846
|
+
}, {
|
|
847
|
+
"id": new OptionalFieldRuntype(direct_hoist_1),
|
|
848
|
+
"text": direct_hoist_1
|
|
849
|
+
}, []);
|
|
850
|
+
Object.assign(namedRuntypes, {
|
|
851
|
+
"TokensLine": direct_hoist_2
|
|
852
|
+
});
|
|
853
|
+
var buildParsersInput = {
|
|
854
|
+
"TokensLine": direct_hoist_0
|
|
855
|
+
};
|
|
856
|
+
var parser_default = {
|
|
857
|
+
buildParsers: (args) => buildParsers(
|
|
858
|
+
{
|
|
859
|
+
parsers: buildParsersInput,
|
|
860
|
+
stringFormatters,
|
|
861
|
+
numberFormatters,
|
|
862
|
+
requiredStringFormats: RequiredStringFormats,
|
|
863
|
+
requiredNumberFormats: RequiredNumberFormats
|
|
864
|
+
},
|
|
865
|
+
args
|
|
866
|
+
)
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// src/parsers.ts
|
|
870
|
+
var Parsers2 = parser_default.buildParsers();
|
|
871
|
+
|
|
768
872
|
// src/project-zip.ts
|
|
769
873
|
import path from "node:path";
|
|
770
874
|
function diskTree(capabilities, root) {
|
|
@@ -786,9 +890,9 @@ function diskTree(capabilities, root) {
|
|
|
786
890
|
}
|
|
787
891
|
};
|
|
788
892
|
}
|
|
789
|
-
async function projectFiles(capabilities,
|
|
893
|
+
async function projectFiles(capabilities, bundler, root, folder) {
|
|
790
894
|
const tree = diskTree(capabilities, root);
|
|
791
|
-
const found = await packageFiles(
|
|
895
|
+
const found = await packageFiles(bundler, tree, folder);
|
|
792
896
|
if (found._tag === "Left") throw new Problems(found.left);
|
|
793
897
|
const files = found.right;
|
|
794
898
|
for (const name of await capabilities.fs.readdir(path.join(root, folder), { recursive: true })) {
|
|
@@ -799,9 +903,264 @@ async function projectFiles(capabilities, esbuild, root, folder) {
|
|
|
799
903
|
return files;
|
|
800
904
|
}
|
|
801
905
|
|
|
906
|
+
// src/commands.ts
|
|
907
|
+
async function withHeavy(capabilities, f) {
|
|
908
|
+
const release = await capabilities.locks.heavy();
|
|
909
|
+
try {
|
|
910
|
+
return await f();
|
|
911
|
+
} finally {
|
|
912
|
+
await release();
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
async function withWork(capabilities, f) {
|
|
916
|
+
const work = await capabilities.fs.mkdtemp(path2.join(capabilities.env.temp, "aula-"));
|
|
917
|
+
try {
|
|
918
|
+
return await f(work);
|
|
919
|
+
} finally {
|
|
920
|
+
await capabilities.fs.rm(work, { recursive: true, force: true });
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
async function parallel(items, limit, task) {
|
|
924
|
+
let next = 0;
|
|
925
|
+
const worker = async () => {
|
|
926
|
+
for (let item = items[next++]; item !== void 0; item = items[next++]) await task(item);
|
|
927
|
+
};
|
|
928
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
929
|
+
}
|
|
930
|
+
async function drawChapter(capabilities, root, project, index, narration, lottie) {
|
|
931
|
+
const built = renderChapter(project, index, { host: host(capabilities, root), narration });
|
|
932
|
+
if (!built.ok || built.value === void 0) {
|
|
933
|
+
return { ok: false, findings: built.diagnostics, frames: 0, waits: [], embeds: [], narration };
|
|
934
|
+
}
|
|
935
|
+
await capabilities.fs.writeFile(lottie, built.value.lottie, "utf8");
|
|
936
|
+
const { frames, waits, embeds } = built.value;
|
|
937
|
+
return { ok: true, findings: built.diagnostics, frames, waits, embeds, narration: built.value.narration };
|
|
938
|
+
}
|
|
939
|
+
async function placedClips(capabilities, folder, overlays) {
|
|
940
|
+
return Promise.all(
|
|
941
|
+
overlays.map(async (o) => {
|
|
942
|
+
const file = path2.join(folder, o.path);
|
|
943
|
+
const picture = o.image === void 0 ? void 0 : path2.join(folder, o.image);
|
|
944
|
+
const video = o.kind === "video";
|
|
945
|
+
return {
|
|
946
|
+
file,
|
|
947
|
+
picture,
|
|
948
|
+
seen: video || picture !== void 0,
|
|
949
|
+
heard: !video || await hasAudio(capabilities, file),
|
|
950
|
+
at: o.at,
|
|
951
|
+
seconds: o.seconds
|
|
952
|
+
};
|
|
953
|
+
})
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
var inFolder = (folder, groups) => groups.map((group) => ({
|
|
957
|
+
...group,
|
|
958
|
+
tiles: group.tiles.map((tile) => {
|
|
959
|
+
const { embed } = tile;
|
|
960
|
+
if (embed?.picture === void 0) return tile;
|
|
961
|
+
return { ...tile, embed: { ...embed, picture: path2.join(folder, embed.picture) } };
|
|
962
|
+
})
|
|
963
|
+
}));
|
|
964
|
+
var rowLine = (project, r) => `${nameOf(project)}: ${String(r.errors)} errors, ${String(r.warnings)} warnings, ${String(r.open)} open moves`;
|
|
965
|
+
async function printChecked(capabilities, root, project, checked) {
|
|
966
|
+
await printDiagnostics(capabilities, root, checked.findings);
|
|
967
|
+
printCounts(capabilities, project, checked);
|
|
968
|
+
}
|
|
969
|
+
function printCounts(capabilities, project, checked) {
|
|
970
|
+
const { errors, warnings } = checked.others;
|
|
971
|
+
if (errors + warnings > 0)
|
|
972
|
+
capabilities.log.out(`other chapters: ${String(errors)} errors, ${String(warnings)} warnings`);
|
|
973
|
+
capabilities.log.out(rowLine(project, checked));
|
|
974
|
+
}
|
|
975
|
+
async function check(capabilities, root, project, only, json = false) {
|
|
976
|
+
const chapters = chapterIndexes(project, only);
|
|
977
|
+
const checked = checkProject(project, host(capabilities, root), chapters);
|
|
978
|
+
const notes = wordNotes(narrationScript(project, checked.texts), chapters);
|
|
979
|
+
if (json) {
|
|
980
|
+
const { findings, others, errors, warnings, open } = checked;
|
|
981
|
+
const result = { name: nameOf(project), errors, warnings, openMoves: open, others, findings, notes };
|
|
982
|
+
capabilities.log.out(JSON.stringify(result, null, 2));
|
|
983
|
+
return errors === 0;
|
|
984
|
+
}
|
|
985
|
+
await printDiagnostics(capabilities, root, checked.findings);
|
|
986
|
+
for (const note of notes) capabilities.log.out(noteLine(note));
|
|
987
|
+
if (notes.length > 0) capabilities.log.out(notesLine(notes));
|
|
988
|
+
printCounts(capabilities, project, checked);
|
|
989
|
+
return checked.errors === 0;
|
|
990
|
+
}
|
|
991
|
+
async function script(capabilities, root, project) {
|
|
992
|
+
capabilities.log.write(scriptView(project, host(capabilities, root)));
|
|
993
|
+
return true;
|
|
994
|
+
}
|
|
995
|
+
async function timeline(capabilities, root, project, only) {
|
|
996
|
+
capabilities.log.write(await timelineView(project, host(capabilities, root), capabilities.narrator, only));
|
|
997
|
+
return true;
|
|
998
|
+
}
|
|
999
|
+
async function preview(capabilities, root, project, folder, given) {
|
|
1000
|
+
const targets = previewTargets(project, given);
|
|
1001
|
+
const only = targetChapters(targets, given);
|
|
1002
|
+
const checked = checkProject(project, host(capabilities, root), only);
|
|
1003
|
+
await printChecked(capabilities, root, project, checked);
|
|
1004
|
+
if (checked.errors > 0) return false;
|
|
1005
|
+
const all = checked.texts;
|
|
1006
|
+
const jobs = previewJobs(targets, all).map((job) => ({
|
|
1007
|
+
...job,
|
|
1008
|
+
out: path2.join(folder, job.base),
|
|
1009
|
+
written: []
|
|
1010
|
+
}));
|
|
1011
|
+
return withWork(capabilities, async (work) => {
|
|
1012
|
+
const stopped = [];
|
|
1013
|
+
const waits = [];
|
|
1014
|
+
await withHeavy(capabilities, async () => {
|
|
1015
|
+
const n = await clock(capabilities.narrator, narrationScript(project, all), only, chapterNames(project));
|
|
1016
|
+
for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
|
|
1017
|
+
await parallel(jobs, capabilities.env.parallelism, async (job) => {
|
|
1018
|
+
const lottie = path2.join(work, `${job.base}.json`);
|
|
1019
|
+
const drawn = await drawChapter(capabilities, root, project, job.index, narrationAt(n, job.index), lottie);
|
|
1020
|
+
if (!drawn.ok) {
|
|
1021
|
+
stopped.push(...drawn.findings);
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
waits.push(...drawn.findings.filter((d) => !isError(d)));
|
|
1025
|
+
const { out } = job;
|
|
1026
|
+
const { window, stills } = pictureStills(drawn.narration, job, drawn.frames, drawn.embeds);
|
|
1027
|
+
const groups = inFolder(folderOf(project), pictureGroups(window, stills));
|
|
1028
|
+
const sheets = await capabilities.render.pictures({ lottie, out, groups });
|
|
1029
|
+
await capabilities.fs.mkdir(out, { recursive: true });
|
|
1030
|
+
await capabilities.fs.writeFile(path2.join(out, "moves.md"), movesMarkdown(stills));
|
|
1031
|
+
job.written.push(path2.join(out, "moves.md"), ...sheets);
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
if (stopped.length) {
|
|
1035
|
+
await printDiagnostics(capabilities, root, stopped);
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
await printDiagnostics(capabilities, root, waits);
|
|
1039
|
+
for (const line of jobs.flatMap((job) => job.written)) capabilities.log.out(line);
|
|
1040
|
+
return true;
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
async function exportVideo(capabilities, root, project, file) {
|
|
1044
|
+
if (!file.endsWith(".mp4")) throw wrongArgument(`the video path must end in .mp4: ${file}`);
|
|
1045
|
+
const names = chapterNames(project);
|
|
1046
|
+
const checked = exportCheck(project, host(capabilities, root));
|
|
1047
|
+
await printChecked(capabilities, root, project, checked);
|
|
1048
|
+
if (checked.errors > 0) {
|
|
1049
|
+
capabilities.log.out(`export ${nameOf(project)}: stopped at check: fix the errors above`);
|
|
1050
|
+
return false;
|
|
1051
|
+
}
|
|
1052
|
+
await ffmpeg(capabilities, ["-version"]);
|
|
1053
|
+
return withWork(capabilities, async (work) => {
|
|
1054
|
+
const audio = path2.join(work, "narration.wav");
|
|
1055
|
+
const cues = narrationScript(project, checked.texts);
|
|
1056
|
+
const narrated = await withHeavy(capabilities, () => narrate(capabilities, cues));
|
|
1057
|
+
const lotties = names.map((name) => path2.join(work, `${name}.json`));
|
|
1058
|
+
const drawn = [];
|
|
1059
|
+
const problems = [];
|
|
1060
|
+
let done = 0;
|
|
1061
|
+
await withHeavy(
|
|
1062
|
+
capabilities,
|
|
1063
|
+
() => parallel(
|
|
1064
|
+
names.map((_, index) => index),
|
|
1065
|
+
capabilities.env.parallelism,
|
|
1066
|
+
async (index) => {
|
|
1067
|
+
const narration = narrated[index]?.narration;
|
|
1068
|
+
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
1069
|
+
const chapter = await drawChapter(capabilities, root, project, index, narration, lotties[index] ?? "");
|
|
1070
|
+
drawn[index] = chapter;
|
|
1071
|
+
if (!chapter.ok) problems.push(...chapter.findings);
|
|
1072
|
+
done += 1;
|
|
1073
|
+
capabilities.log.out(
|
|
1074
|
+
`[${String(done)}/${String(names.length)}] ${names[index] ?? ""}: ${chapter.ok ? "drawn" : "FAILED"}`
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
)
|
|
1078
|
+
);
|
|
1079
|
+
if (problems.length) {
|
|
1080
|
+
await printDiagnostics(capabilities, root, problems);
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
const { samples, sampleRate } = scriptAudio(
|
|
1084
|
+
narrated,
|
|
1085
|
+
drawn.map((d) => d.waits)
|
|
1086
|
+
);
|
|
1087
|
+
await capabilities.fs.writeFile(audio, wav(samples, sampleRate));
|
|
1088
|
+
capabilities.log.out(`Narrated ${(samples.length / sampleRate / 60).toFixed(1)} minutes`);
|
|
1089
|
+
const plan = clipPlan(
|
|
1090
|
+
drawn.map((d) => d.narration),
|
|
1091
|
+
VIDEO.fps
|
|
1092
|
+
);
|
|
1093
|
+
const clips = names.map((name) => path2.join(work, `${name}.mp4`));
|
|
1094
|
+
await withHeavy(
|
|
1095
|
+
capabilities,
|
|
1096
|
+
() => parallel(
|
|
1097
|
+
names.map((_, index) => index),
|
|
1098
|
+
capabilities.env.parallelism,
|
|
1099
|
+
async (index) => {
|
|
1100
|
+
const clip = plan.clips[index] ?? { from: 0, frames: 0 };
|
|
1101
|
+
await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
|
|
1102
|
+
}
|
|
1103
|
+
)
|
|
1104
|
+
);
|
|
1105
|
+
await capabilities.fs.mkdir(path2.dirname(file), { recursive: true });
|
|
1106
|
+
const placed = await placedClips(
|
|
1107
|
+
capabilities,
|
|
1108
|
+
folderOf(project),
|
|
1109
|
+
overlayPlan(
|
|
1110
|
+
drawn.map((d) => d.narration),
|
|
1111
|
+
drawn.map((d) => d.embeds)
|
|
1112
|
+
)
|
|
1113
|
+
);
|
|
1114
|
+
const background = (project.theme ?? m.theme).background;
|
|
1115
|
+
await assemble(capabilities, { work, clips, audio, seconds: plan.seconds, out: file, placed, background });
|
|
1116
|
+
capabilities.log.out(file);
|
|
1117
|
+
return true;
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
async function bundle2(capabilities, project, file) {
|
|
1121
|
+
if (!file.endsWith(".zip")) throw new Error(`the zip path must end in .zip: ${file}`);
|
|
1122
|
+
const home = folderOf(project);
|
|
1123
|
+
const root = path2.parse(home).root;
|
|
1124
|
+
const folder = path2.relative(root, home).split(path2.sep).join("/");
|
|
1125
|
+
const bundler = createNodeBundler();
|
|
1126
|
+
let files;
|
|
1127
|
+
try {
|
|
1128
|
+
files = await projectFiles(capabilities, bundler, root, folder);
|
|
1129
|
+
} finally {
|
|
1130
|
+
await bundler.stop();
|
|
1131
|
+
}
|
|
1132
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1133
|
+
for (const [at, from] of files)
|
|
1134
|
+
entries.set(at, new Uint8Array(await capabilities.fs.readFile(path2.join(root, from))));
|
|
1135
|
+
const zip = zipBytes(entries);
|
|
1136
|
+
await capabilities.fs.mkdir(path2.dirname(file), { recursive: true });
|
|
1137
|
+
await capabilities.fs.writeFile(file, zip);
|
|
1138
|
+
capabilities.log.out(`${file}: ${String(files.size)} files, ${String(Math.ceil(zip.length / 1024))} kB`);
|
|
1139
|
+
return true;
|
|
1140
|
+
}
|
|
1141
|
+
async function tokens(capabilities, tokensOf, lines) {
|
|
1142
|
+
let number = 0;
|
|
1143
|
+
for await (const line of lines) {
|
|
1144
|
+
number += 1;
|
|
1145
|
+
if (!line.trim()) continue;
|
|
1146
|
+
const parsed = Parsers2.TokensLine.safeParse(JSON.parse(line));
|
|
1147
|
+
if (!parsed.success) throw wrongArgument(`stdin line ${String(number)}: expected {"id"?: string, "text": string}`);
|
|
1148
|
+
const { id, text } = parsed.data;
|
|
1149
|
+
capabilities.log.out(JSON.stringify({ ...id === void 0 ? {} : { id }, batches: await tokensOf(text) }));
|
|
1150
|
+
}
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
function tokensArgs(positional) {
|
|
1154
|
+
if (positional.length > 0) throw wrongArgument("aula tokens takes no arguments", "run `aula help` for the usage");
|
|
1155
|
+
}
|
|
1156
|
+
|
|
802
1157
|
export {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1158
|
+
check,
|
|
1159
|
+
script,
|
|
1160
|
+
timeline,
|
|
1161
|
+
preview,
|
|
1162
|
+
exportVideo,
|
|
1163
|
+
bundle2 as bundle,
|
|
1164
|
+
tokens,
|
|
1165
|
+
tokensArgs
|
|
807
1166
|
};
|
|
@@ -1012,21 +1012,16 @@ var parser_default = {
|
|
|
1012
1012
|
var Parsers = parser_default.buildParsers();
|
|
1013
1013
|
|
|
1014
1014
|
// ../aula-bundle/src/index.ts
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
if (first !== void 0 && rest.length > 0) names.add(first);
|
|
1026
|
-
}
|
|
1027
|
-
return Promise.resolve([...names].toSorted());
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1015
|
+
var PROVIDED = ["@beff/aula", "@beff/aula-method"];
|
|
1016
|
+
var PROVIDED_IMPORTS = Object.fromEntries(PROVIDED.map((name) => [name, `aula-provide:${name}`]));
|
|
1017
|
+
var LIST_MODULE = "aula-projects.ts";
|
|
1018
|
+
function linkBundle(code, player) {
|
|
1019
|
+
let out = code;
|
|
1020
|
+
for (const [pkg, placeholder] of Object.entries(PROVIDED_IMPORTS)) {
|
|
1021
|
+
const target = player[pkg];
|
|
1022
|
+
if (target !== void 0) out = out.replaceAll(JSON.stringify(placeholder), JSON.stringify(target));
|
|
1023
|
+
}
|
|
1024
|
+
return out;
|
|
1030
1025
|
}
|
|
1031
1026
|
var SOURCE_PREFIX = "tree:";
|
|
1032
1027
|
function dirname(path) {
|
|
@@ -1092,10 +1087,10 @@ var diagnostic = ({ text, location: at }) => ({
|
|
|
1092
1087
|
stack: [],
|
|
1093
1088
|
related: []
|
|
1094
1089
|
});
|
|
1095
|
-
async function bundle(
|
|
1090
|
+
async function bundle(bundler, tree, entry, imports) {
|
|
1096
1091
|
let result;
|
|
1097
1092
|
try {
|
|
1098
|
-
result = await
|
|
1093
|
+
result = await bundler.build({
|
|
1099
1094
|
entryPoints: [entry],
|
|
1100
1095
|
bundle: true,
|
|
1101
1096
|
write: false,
|
|
@@ -1249,6 +1244,31 @@ async function projectModules(tree, root) {
|
|
|
1249
1244
|
});
|
|
1250
1245
|
return errors.length > 0 ? { _tag: "Left", left: errors } : { _tag: "Right", right: found };
|
|
1251
1246
|
}
|
|
1247
|
+
async function bundleWorkspace(bundler, tree, root) {
|
|
1248
|
+
const listed = await projectModules(tree, root);
|
|
1249
|
+
if (listed._tag === "Left") return listed;
|
|
1250
|
+
const projects = listed.right;
|
|
1251
|
+
if (projects.length === 0) {
|
|
1252
|
+
throw new Error("no project here: open a folder that has index.ts, or whose subfolders have index.ts");
|
|
1253
|
+
}
|
|
1254
|
+
const list = [
|
|
1255
|
+
...projects.map((project, i) => `import p${String(i)} from ${JSON.stringify(`./${project.module}`)};`),
|
|
1256
|
+
`export default [${projects.map((_, i) => `p${String(i)}`).join(", ")}];`
|
|
1257
|
+
].join("\n");
|
|
1258
|
+
const virtual = {
|
|
1259
|
+
read: (path) => path === LIST_MODULE ? Promise.resolve(list) : tree.read(path),
|
|
1260
|
+
list: (folder) => tree.list(folder)
|
|
1261
|
+
};
|
|
1262
|
+
const bundled = await bundle(bundler, virtual, LIST_MODULE, PROVIDED_IMPORTS);
|
|
1263
|
+
if (bundled._tag === "Left") return bundled;
|
|
1264
|
+
return {
|
|
1265
|
+
_tag: "Right",
|
|
1266
|
+
right: {
|
|
1267
|
+
bundle: { name: root, projects, code: bundled.right.code, map: bundled.right.map },
|
|
1268
|
+
inputs: bundled.right.inputs
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1252
1272
|
|
|
1253
1273
|
// ../aula-project/src/diagnostics.ts
|
|
1254
1274
|
import { diagnosticOf } from "@beff/aula/run";
|
|
@@ -1277,10 +1297,13 @@ export {
|
|
|
1277
1297
|
RefRuntype,
|
|
1278
1298
|
buildParsers,
|
|
1279
1299
|
Parsers,
|
|
1280
|
-
|
|
1300
|
+
PROVIDED,
|
|
1301
|
+
LIST_MODULE,
|
|
1302
|
+
linkBundle,
|
|
1281
1303
|
bundle,
|
|
1282
1304
|
projectName,
|
|
1283
1305
|
projectModules,
|
|
1306
|
+
bundleWorkspace,
|
|
1284
1307
|
error,
|
|
1285
1308
|
isError,
|
|
1286
1309
|
Problems,
|