@beff/aula-cli 0.6.0 → 0.6.2
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/aula-render.core.wasm +0 -0
- package/dist/src/{chunk-2NMVSQG4.js → chunk-3MPFI4UE.js} +17 -0
- package/dist/src/{chunk-DQ2NGXNI.js → chunk-6CZECZIX.js} +1 -1
- package/dist/src/{chunk-EQ3DVZV5.js → chunk-7C6QW2TD.js} +1 -1
- package/dist/src/{chunk-2TQ4F6GS.js → chunk-EB67KE2S.js} +14 -14
- package/dist/src/chunk-EZROW2IP.js +127 -0
- package/dist/src/{chunk-5VYKT646.js → chunk-J7LNPVU2.js} +5 -4
- package/dist/src/{chunk-YBHISJLN.js → chunk-LSXILCMB.js} +132 -16
- package/dist/src/{chunk-6LC3WXJ7.js → chunk-PLBRKNMD.js} +20 -5
- package/dist/src/cli.js +23 -13
- package/dist/src/{commands-IECUGFP2.js → commands-7MTNNJKO.js} +8 -8
- package/dist/src/problems-CCUJW4H4.js +14 -0
- package/dist/src/project-PF77AQKF.js +12 -0
- package/dist/src/{run-ASNQVEK4.js → run-VCOTEL37.js} +8 -8
- package/dist/src/{server-YQYW4FT4.js → server-5W36J7WM.js} +4 -4
- package/dist/src/{site-SVNNSF72.js → site-NA5QNSHF.js} +74 -24
- package/dist/web/app/assets/{32426b96 → 3cdff963}/aula-method.js +1 -1
- package/dist/web/app/assets/{32426b96 → 3cdff963}/aula.js +1 -1
- package/dist/web/app/assets/{32426b96 → 3cdff963}/build-worker.js +2 -2
- package/dist/web/app/assets/3cdff963/index.js +53 -0
- package/dist/web/app/assets/__vite-browser-external-CTDtqMqs.js +1 -0
- package/dist/web/app/assets/{aula-voice-worker-BG_u7zxq.js → aula-voice-worker-C7UeMloK.js} +2 -2
- package/dist/web/app/assets/{aula.core5-CPBL2gnc.wasm → aula.core5-DVDCNzCV.wasm} +0 -0
- package/dist/web/{site/assets/index-Dcly6eU3.css → app/assets/index-BirjmJbl.css} +1 -1
- package/dist/web/app/assets/{protocol-n-0ok9fE.js → protocol-C3MGnf_t.js} +4 -4
- package/dist/web/app/assets/{src-KAOnACo0.js → src-CTZjQYUv.js} +2 -2
- package/dist/web/app/index.html +27 -4
- package/dist/web/site/assets/__vite-browser-external-D1sFDdqr.js +1 -0
- package/dist/web/site/assets/{aula-voice-worker-BefmgHnb.js → aula-voice-worker-DHEZKCCg.js} +2 -2
- package/dist/web/site/assets/{aula.core5-CPBL2gnc.wasm → aula.core5-DVDCNzCV.wasm} +0 -0
- package/dist/web/site/assets/{e2472609 → fbc21d75}/aula-method.js +1 -1
- package/dist/web/site/assets/{e2472609 → fbc21d75}/aula.js +1 -1
- package/dist/web/site/assets/{e2472609 → fbc21d75}/build-worker.js +2 -2
- package/dist/web/site/assets/fbc21d75/index.js +53 -0
- package/dist/web/{app/assets/index-DtOukfzG.css → site/assets/index-BirjmJbl.css} +1 -1
- package/dist/web/site/assets/{protocol-FHUBS3VF.js → protocol-CzWPeNPI.js} +4 -4
- package/dist/web/site/assets/{src-BOEiwkOC.js → src-1_dQqt80.js} +2 -2
- package/dist/web/site/index.html +27 -4
- package/package.json +2 -2
- package/dist/src/chunk-JVCECTG2.js +0 -77
- package/dist/src/problems-U4QXN6RO.js +0 -14
- package/dist/src/project-WS7P5VIH.js +0 -12
- package/dist/web/app/assets/32426b96/index.js +0 -52
- package/dist/web/app/assets/__vite-browser-external-FFXyTDbk.js +0 -1
- package/dist/web/site/assets/__vite-browser-external-BFOz4dSd.js +0 -1
- package/dist/web/site/assets/e2472609/index.js +0 -52
|
Binary file
|
|
@@ -1012,6 +1012,22 @@ var parser_default = {
|
|
|
1012
1012
|
var Parsers = parser_default.buildParsers();
|
|
1013
1013
|
|
|
1014
1014
|
// ../aula-bundle/src/index.ts
|
|
1015
|
+
function pathsTree(paths, read) {
|
|
1016
|
+
const all = [...paths];
|
|
1017
|
+
return {
|
|
1018
|
+
read,
|
|
1019
|
+
list: (folder) => {
|
|
1020
|
+
const prefix = folder === "" ? "" : `${folder}/`;
|
|
1021
|
+
const names = /* @__PURE__ */ new Set();
|
|
1022
|
+
for (const path of all) {
|
|
1023
|
+
if (!path.startsWith(prefix)) continue;
|
|
1024
|
+
const [first, ...rest] = path.slice(prefix.length).split("/");
|
|
1025
|
+
if (first !== void 0 && rest.length > 0) names.add(first);
|
|
1026
|
+
}
|
|
1027
|
+
return Promise.resolve([...names].toSorted());
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1015
1031
|
var SOURCE_PREFIX = "tree:";
|
|
1016
1032
|
function dirname(path) {
|
|
1017
1033
|
const at = path.lastIndexOf("/");
|
|
@@ -1261,6 +1277,7 @@ export {
|
|
|
1261
1277
|
RefRuntype,
|
|
1262
1278
|
buildParsers,
|
|
1263
1279
|
Parsers,
|
|
1280
|
+
pathsTree,
|
|
1264
1281
|
bundle,
|
|
1265
1282
|
projectName,
|
|
1266
1283
|
projectModules,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
projectFiles,
|
|
3
3
|
zipBytes
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6CZECZIX.js";
|
|
5
5
|
import {
|
|
6
6
|
VIDEO,
|
|
7
7
|
assemble,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-BLKXJGEO.js";
|
|
11
11
|
import {
|
|
12
12
|
printDiagnostics
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7C6QW2TD.js";
|
|
14
14
|
import {
|
|
15
15
|
chapterIndexes,
|
|
16
16
|
checkProject,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
targetChapters,
|
|
31
31
|
timelineView,
|
|
32
32
|
wordNotes
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LSXILCMB.js";
|
|
34
34
|
import {
|
|
35
35
|
narrateScript,
|
|
36
36
|
scriptAudio,
|
|
@@ -38,11 +38,11 @@ import {
|
|
|
38
38
|
} from "./chunk-S74JLCZK.js";
|
|
39
39
|
import {
|
|
40
40
|
host
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-J7LNPVU2.js";
|
|
42
42
|
import {
|
|
43
43
|
folderOf,
|
|
44
44
|
nameOf
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-EZROW2IP.js";
|
|
46
46
|
import {
|
|
47
47
|
ObjectRuntype,
|
|
48
48
|
OptionalFieldRuntype,
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
buildParsers,
|
|
52
52
|
isError,
|
|
53
53
|
wrongArgument
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-3MPFI4UE.js";
|
|
55
55
|
|
|
56
56
|
// src/commands.ts
|
|
57
57
|
import path from "node:path";
|
|
@@ -201,23 +201,23 @@ async function timeline(capabilities, root, project, only) {
|
|
|
201
201
|
}
|
|
202
202
|
async function preview(capabilities, root, project, folder, given) {
|
|
203
203
|
const targets = previewTargets(project, given);
|
|
204
|
-
const
|
|
204
|
+
const only = targetChapters(targets, given);
|
|
205
|
+
const checked = checkProject(project, host(capabilities, root), only);
|
|
205
206
|
await printChecked(capabilities, root, project, checked);
|
|
206
207
|
if (checked.errors > 0) return false;
|
|
207
208
|
const all = checked.texts;
|
|
208
|
-
const n = await clock(capabilities.narrator, narrationScript(project, all));
|
|
209
209
|
const jobs = previewJobs(targets, all).map((job) => ({
|
|
210
210
|
...job,
|
|
211
211
|
out: path.join(folder, job.base),
|
|
212
212
|
written: []
|
|
213
213
|
}));
|
|
214
214
|
return withWork(capabilities, async (work) => {
|
|
215
|
-
for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
|
|
216
215
|
const stopped = [];
|
|
217
216
|
const waits = [];
|
|
218
|
-
await withHeavy(
|
|
219
|
-
capabilities,
|
|
220
|
-
(
|
|
217
|
+
await withHeavy(capabilities, async () => {
|
|
218
|
+
const n = await clock(capabilities.narrator, narrationScript(project, all), only, chapterNames(project));
|
|
219
|
+
for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
|
|
220
|
+
await parallel(jobs, capabilities.env.parallelism, async (job) => {
|
|
221
221
|
const lottie = path.join(work, `${job.base}.json`);
|
|
222
222
|
const drawn = await drawChapter(capabilities, root, project, job.index, narrationAt(n, job.index), lottie);
|
|
223
223
|
if (!drawn.ok) {
|
|
@@ -232,8 +232,8 @@ async function preview(capabilities, root, project, folder, given) {
|
|
|
232
232
|
await capabilities.fs.mkdir(out, { recursive: true });
|
|
233
233
|
await capabilities.fs.writeFile(path.join(out, "moves.md"), movesMarkdown(stills));
|
|
234
234
|
job.written.push(path.join(out, "moves.md"), ...sheets);
|
|
235
|
-
})
|
|
236
|
-
);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
237
|
if (stopped.length) {
|
|
238
238
|
await printDiagnostics(capabilities, root, stopped);
|
|
239
239
|
return false;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Problems,
|
|
3
|
+
diagnosticsOf,
|
|
4
|
+
error,
|
|
5
|
+
projectName,
|
|
6
|
+
wrongArgument
|
|
7
|
+
} from "./chunk-3MPFI4UE.js";
|
|
8
|
+
|
|
9
|
+
// ../aula-project/src/node.ts
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { pathToFileURL } from "node:url";
|
|
12
|
+
import { isProjectDefinition } from "@beff/aula";
|
|
13
|
+
import { definedAt, importUserModule, loadEngine, v8Frames } from "@beff/aula/run";
|
|
14
|
+
var PROJECT_MODULE = "index.ts";
|
|
15
|
+
var GLUE = [
|
|
16
|
+
`${path.dirname(new URL(import.meta.resolve("@beff/aula")).pathname)}/`,
|
|
17
|
+
new URL(import.meta.url).pathname
|
|
18
|
+
];
|
|
19
|
+
function host(capabilities, root, glue = []) {
|
|
20
|
+
const all = [...GLUE, ...glue];
|
|
21
|
+
return {
|
|
22
|
+
frames: v8Frames,
|
|
23
|
+
name: (file) => file.startsWith("/") && !file.includes("/node_modules/") && !all.some((g) => file.startsWith(g)) ? path.relative(root, file) : void 0,
|
|
24
|
+
exists: (file) => capabilities.fs.existsSync(path.resolve(root, file)),
|
|
25
|
+
media: (file) => {
|
|
26
|
+
const full = path.resolve(root, file);
|
|
27
|
+
const stat = capabilities.fs.statSync(full, { throwIfNoEntry: false });
|
|
28
|
+
if (stat === void 0 || !stat.isFile()) return void 0;
|
|
29
|
+
let bytes;
|
|
30
|
+
return { size: stat.size, read: () => bytes ??= capabilities.fs.readFileSync(full) };
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function propertyOf(e, key) {
|
|
35
|
+
return typeof e === "object" && e !== null ? Reflect.get(e, key) : void 0;
|
|
36
|
+
}
|
|
37
|
+
function slugOf(text) {
|
|
38
|
+
return text.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
39
|
+
}
|
|
40
|
+
function listedChapters(capabilities, folder, projectFile) {
|
|
41
|
+
const source = capabilities.fs.readFileSync(projectFile, "utf8");
|
|
42
|
+
const imports = /* @__PURE__ */ new Map();
|
|
43
|
+
for (const match of source.matchAll(/^\s*import\s+([A-Za-z_$][\w$]*)\s+from\s+["'](\.[^"']+)["']/gm)) {
|
|
44
|
+
if (match[1] !== void 0 && match[2] !== void 0) {
|
|
45
|
+
imports.set(match[1], path.resolve(folder, match[2]));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const list = /chapters\s*:\s*\[([^\]]*)\]/s.exec(source)?.[1];
|
|
49
|
+
if (list === void 0) return [];
|
|
50
|
+
const ids = list.replace(/\/\/.*$/gm, "").split(",").map((part) => part.trim()).filter((part) => /^[A-Za-z_$][\w$]*$/.test(part));
|
|
51
|
+
return ids.flatMap((id, index) => {
|
|
52
|
+
const chapterFile = imports.get(id);
|
|
53
|
+
if (chapterFile === void 0) return [];
|
|
54
|
+
const number = index + 1;
|
|
55
|
+
const body = capabilities.fs.existsSync(chapterFile) ? capabilities.fs.readFileSync(chapterFile, "utf8") : "";
|
|
56
|
+
const heading = /heading\s*:\s*(?:say\s*`([^`$]+)`|"([^"]+)"|'([^']+)')/.exec(body);
|
|
57
|
+
const raw = heading?.[1] ?? heading?.[2] ?? heading?.[3] ?? path.basename(chapterFile, path.extname(chapterFile));
|
|
58
|
+
const slug = slugOf(raw) || path.basename(chapterFile, path.extname(chapterFile));
|
|
59
|
+
return [{ number, file: chapterFile, name: `${String(number).padStart(2, "0")}-${slug}` }];
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function stoppedByOtherChapter(capabilities, root, folder, projectFile, only, glue, thrown) {
|
|
63
|
+
if (only.length === 0) return void 0;
|
|
64
|
+
const chapters = listedChapters(capabilities, folder, projectFile);
|
|
65
|
+
if (chapters.length === 0) return void 0;
|
|
66
|
+
const wanted = only.map((arg) => arg.split(":")[0] ?? arg);
|
|
67
|
+
const isWanted = (entry) => wanted.some((w) => w === entry.name || Number(/^(\d+)-/.exec(w)?.[1]) === entry.number);
|
|
68
|
+
const diagnostics = diagnosticsOf(thrown, host(capabilities, root, glue));
|
|
69
|
+
const [first] = diagnostics;
|
|
70
|
+
if (first === void 0) return void 0;
|
|
71
|
+
const files = [
|
|
72
|
+
...first.location === void 0 ? [] : [path.resolve(root, first.location.file)],
|
|
73
|
+
...thrown instanceof Error ? v8Frames(thrown).map((frame) => frame.file) : []
|
|
74
|
+
];
|
|
75
|
+
const byFile = new Map(chapters.map((entry) => [entry.file, entry]));
|
|
76
|
+
const hit = files.map((candidate) => byFile.get(candidate)).find((entry) => entry !== void 0);
|
|
77
|
+
if (hit === void 0 || isWanted(hit)) return void 0;
|
|
78
|
+
return new Problems(
|
|
79
|
+
diagnostics.map((d, i) => i === 0 ? { ...d, message: `stopped by an error in ${hit.name}: ${d.message}` } : d)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
async function loadProject(capabilities, load, root, folder, only = [], glue = []) {
|
|
83
|
+
const file = path.join(folder, PROJECT_MODULE);
|
|
84
|
+
if (!capabilities.fs.existsSync(file)) {
|
|
85
|
+
throw wrongArgument(
|
|
86
|
+
`${path.relative(root, folder) || "."} has no ${PROJECT_MODULE}`,
|
|
87
|
+
`give the project folder: the folder with ${PROJECT_MODULE}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
await loadEngine();
|
|
91
|
+
const loaded = await importUserModule(() => load(pathToFileURL(file).href));
|
|
92
|
+
if (loaded._tag === "Left") {
|
|
93
|
+
throw stoppedByOtherChapter(capabilities, root, folder, file, only, glue, loaded.left) ?? loaded.left;
|
|
94
|
+
}
|
|
95
|
+
const module = loaded.right;
|
|
96
|
+
const exported = propertyOf(module, "default");
|
|
97
|
+
if (!isProjectDefinition(exported)) {
|
|
98
|
+
const rel = path.relative(root, file);
|
|
99
|
+
throw new Problems([
|
|
100
|
+
error(`the default export of ${rel} is not made by defineProject`, {
|
|
101
|
+
location: { file: rel, line: 1, col: 0 },
|
|
102
|
+
hint: "write `export default defineProject({ title, theme, chapters: [ \u2026 ] })`"
|
|
103
|
+
})
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
return exported;
|
|
107
|
+
}
|
|
108
|
+
var folderOf = (project) => path.dirname(definedAt(project).file);
|
|
109
|
+
var nameOf = (project) => projectName(path.basename(folderOf(project)));
|
|
110
|
+
async function withSource(capabilities, root, d) {
|
|
111
|
+
if (d.source !== void 0 || d.location === void 0) return d;
|
|
112
|
+
const file = path.resolve(root, d.location.file);
|
|
113
|
+
if (!capabilities.fs.existsSync(file)) return d;
|
|
114
|
+
const text = await capabilities.fs.readFile(file, "utf8");
|
|
115
|
+
const lines = text.split("\n");
|
|
116
|
+
if (lines.at(-1) === "") lines.pop();
|
|
117
|
+
const line = lines[d.location.line - 1];
|
|
118
|
+
return line === void 0 || d.location.line < 1 ? d : { ...d, source: line.replace(/\r$/, "") };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
host,
|
|
123
|
+
loadProject,
|
|
124
|
+
folderOf,
|
|
125
|
+
nameOf,
|
|
126
|
+
withSource
|
|
127
|
+
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
host,
|
|
3
3
|
loadProject
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EZROW2IP.js";
|
|
5
5
|
|
|
6
6
|
// src/project.ts
|
|
7
7
|
function exists(capabilities, file) {
|
|
8
8
|
return capabilities.fs.existsSync(file);
|
|
9
9
|
}
|
|
10
|
+
var SELF = new URL(import.meta.url).pathname;
|
|
10
11
|
function host2(capabilities, root) {
|
|
11
|
-
return host(capabilities, root, [
|
|
12
|
+
return host(capabilities, root, [SELF]);
|
|
12
13
|
}
|
|
13
|
-
function loadProject2(capabilities, root, folder) {
|
|
14
|
-
return loadProject(capabilities, (url) => import(url), root, folder);
|
|
14
|
+
function loadProject2(capabilities, root, folder, only = []) {
|
|
15
|
+
return loadProject(capabilities, (url) => import(url), root, folder, only, [SELF]);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export {
|
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
} from "./chunk-S74JLCZK.js";
|
|
4
4
|
import {
|
|
5
5
|
Problems,
|
|
6
|
+
bundle,
|
|
6
7
|
error,
|
|
7
8
|
isError,
|
|
9
|
+
projectModules,
|
|
8
10
|
wrongArgument
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-3MPFI4UE.js";
|
|
10
12
|
|
|
11
13
|
// ../aula-project/src/chapters.ts
|
|
12
14
|
import { readChapter } from "@beff/aula";
|
|
@@ -58,18 +60,39 @@ function openCount(chapters, indexes) {
|
|
|
58
60
|
// ../aula-project/src/check.ts
|
|
59
61
|
import { checkChapter, checkLexicon, checkTitle, readChapter as readChapter2 } from "@beff/aula";
|
|
60
62
|
import { chapterNames } from "@beff/aula/run";
|
|
61
|
-
import { check as rules } from "@beff/aula/text";
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
import { check as rules, phonemize } from "@beff/aula/text";
|
|
64
|
+
var hasSpokenSound = (spoken) => Array.from(phonemize(spoken)).some((c) => new RegExp("\\p{L}", "u").test(c) && c !== "\u02C8" && c !== "\u02CC");
|
|
65
|
+
function cueLocation(place) {
|
|
66
|
+
if (place === void 0) return void 0;
|
|
67
|
+
const colon = place.lastIndexOf(":");
|
|
68
|
+
const line = Number(place.slice(colon + 1));
|
|
69
|
+
return colon > 0 && Number.isInteger(line) ? { file: place.slice(0, colon), line, col: 0 } : void 0;
|
|
70
|
+
}
|
|
71
|
+
async function clock(narrator, chapters, only = null, names = []) {
|
|
72
|
+
const narrations = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const [index, cues] of chapters.entries()) {
|
|
74
|
+
if (only !== null && !only.includes(index)) continue;
|
|
65
75
|
const timings = [];
|
|
66
|
-
for (const cue of cues)
|
|
67
|
-
|
|
76
|
+
for (const cue of cues) {
|
|
77
|
+
const spoken = cue.words.join(" ");
|
|
78
|
+
if (!cue.words.length || !hasSpokenSound(spoken)) {
|
|
79
|
+
const chapter = names[index] ?? `chapter ${String(index)}`;
|
|
80
|
+
const location = cueLocation(cue.place);
|
|
81
|
+
throw new Problems([
|
|
82
|
+
error(`cannot narrate ${cue.kind} in ${chapter}: ${JSON.stringify(cue.text)} has no spoken words`, {
|
|
83
|
+
...location === void 0 ? {} : { location },
|
|
84
|
+
hint: `give the ${cue.kind} words that the narrator can say`
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
timings.push(await narrator.time(cue.words));
|
|
89
|
+
}
|
|
90
|
+
narrations.set(index, timeChapter(cues, timings));
|
|
68
91
|
}
|
|
69
92
|
return narrations;
|
|
70
93
|
}
|
|
71
94
|
function narrationAt(narrations, index) {
|
|
72
|
-
const narration = narrations
|
|
95
|
+
const narration = narrations.get(index);
|
|
73
96
|
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
74
97
|
return narration;
|
|
75
98
|
}
|
|
@@ -296,17 +319,24 @@ function movesMarkdown(stills) {
|
|
|
296
319
|
}
|
|
297
320
|
|
|
298
321
|
// ../aula-project/src/timeline.ts
|
|
299
|
-
import { renderChapter } from "@beff/aula";
|
|
322
|
+
import { readChapter as readChapter3, renderChapter } from "@beff/aula";
|
|
300
323
|
import { chapterNames as chapterNames3 } from "@beff/aula/run";
|
|
301
324
|
import { narrationScript, timeline as timelineOf } from "@beff/aula/text";
|
|
325
|
+
var EMPTY2 = { heading: "", headingSpoken: "", metaphor: "", paragraphs: [] };
|
|
302
326
|
async function timelineView(project, host, narrator, only) {
|
|
303
327
|
const names = chapterNames3(project);
|
|
304
328
|
const indexes = only.length === 0 ? project.chapters.map((_, i) => i + 1) : only.map((name) => chapterIndex(names, name));
|
|
305
329
|
if (indexes.includes(0)) throw wrongArgument("the title card has no timeline: give a chapter name");
|
|
306
|
-
const
|
|
330
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
331
|
+
for (const index of indexes) loaded.set(index, chapterText(project, host, index));
|
|
332
|
+
const all = project.chapters.map((_, i) => {
|
|
333
|
+
const index = i + 1;
|
|
334
|
+
return loaded.get(index) ?? readChapter3(project, index, { host }).value ?? EMPTY2;
|
|
335
|
+
});
|
|
336
|
+
const n = await clock(narrator, narrationScript(project, all), indexes, names);
|
|
307
337
|
let out = header(project);
|
|
308
338
|
for (const index of indexes) {
|
|
309
|
-
const text = chapterText(project, host, index);
|
|
339
|
+
const text = loaded.get(index) ?? chapterText(project, host, index);
|
|
310
340
|
const run = renderChapter(project, index, { host, narration: narrationAt(n, index), lint: true });
|
|
311
341
|
if (!run.ok || run.value === void 0) throw new Problems(run.diagnostics);
|
|
312
342
|
out += `
|
|
@@ -319,16 +349,100 @@ Metaphor: ${text.metaphor}
|
|
|
319
349
|
return out;
|
|
320
350
|
}
|
|
321
351
|
|
|
322
|
-
// ../aula-project/src/videos.ts
|
|
323
|
-
import { FPS as FPS4 } from "@beff/aula/run";
|
|
324
|
-
import { estimateNarration } from "@beff/aula/text";
|
|
325
|
-
|
|
326
352
|
// ../aula-project/src/workspace.ts
|
|
327
353
|
import * as Engine from "@beff/aula";
|
|
328
354
|
import { diagnosticOf, importUserModule, loadEngine } from "@beff/aula/run";
|
|
329
355
|
import {
|
|
330
356
|
narrationScript as narrationScript2
|
|
331
357
|
} from "@beff/aula/text";
|
|
358
|
+
var workspaceHost = (frames, media) => ({
|
|
359
|
+
frames,
|
|
360
|
+
name: (file) => /^[a-z][a-z0-9+.-]*:/.test(file) ? void 0 : file,
|
|
361
|
+
exists: () => true,
|
|
362
|
+
...media ? { media } : {}
|
|
363
|
+
});
|
|
364
|
+
var propertyOf = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
|
|
365
|
+
var LIST = "aula-projects.ts";
|
|
366
|
+
async function loadProjects(files, host, modules, esbuild, player, engineLoaded) {
|
|
367
|
+
const root = await files.name();
|
|
368
|
+
const listed = await projectModules(files, root);
|
|
369
|
+
if (listed._tag === "Left") return listed;
|
|
370
|
+
const found = listed.right.map((project) => project.module);
|
|
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)] };
|
|
391
|
+
const exported = propertyOf(loaded.right.exports, "default");
|
|
392
|
+
if (!Array.isArray(exported)) throw new Error(`${LIST} has no list of projects`);
|
|
393
|
+
const out = exported.map((definition, i) => {
|
|
394
|
+
if (!Engine.isProjectDefinition(definition)) {
|
|
395
|
+
throw new Error(
|
|
396
|
+
`the default export of ${found[i] ?? ""} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ \u2026 ] })\``
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
const { name, section } = listed.right[i] ?? { name: "" };
|
|
400
|
+
return localProject(name, section, definition, host);
|
|
401
|
+
});
|
|
402
|
+
return { _tag: "Right", right: out };
|
|
403
|
+
}
|
|
404
|
+
function localProject(name, section, definition, host) {
|
|
405
|
+
const count = definition.chapters.length + 1;
|
|
406
|
+
return {
|
|
407
|
+
name,
|
|
408
|
+
...section === void 0 ? {} : { section },
|
|
409
|
+
title: definition.title,
|
|
410
|
+
chapters: count,
|
|
411
|
+
titles: [definition.title, ...definition.chapters.map((c) => c.heading)],
|
|
412
|
+
script: () => {
|
|
413
|
+
const chapters = [];
|
|
414
|
+
for (const i of definition.chapters.keys()) {
|
|
415
|
+
const run = Engine.readChapter(definition, i + 1, { host });
|
|
416
|
+
if (run.value === void 0) return { _tag: "Left", left: run.diagnostics };
|
|
417
|
+
chapters.push(run.value);
|
|
418
|
+
}
|
|
419
|
+
const script = narrationScript2(definition, chapters);
|
|
420
|
+
return { _tag: "Right", right: { script } };
|
|
421
|
+
},
|
|
422
|
+
walk: (index) => {
|
|
423
|
+
if (index > 0) Engine.checkChapter(definition, index, { host });
|
|
424
|
+
},
|
|
425
|
+
render: (index, narration) => {
|
|
426
|
+
const run = Engine.renderChapter(definition, index, { host, narration });
|
|
427
|
+
if (!run.ok || run.value === void 0) return { _tag: "Left", left: run.diagnostics };
|
|
428
|
+
const { lottie, waits, embeds, diagnostics } = run.value;
|
|
429
|
+
return {
|
|
430
|
+
_tag: "Right",
|
|
431
|
+
right: {
|
|
432
|
+
lottie,
|
|
433
|
+
waits,
|
|
434
|
+
embeds,
|
|
435
|
+
background: (definition.theme ?? Engine.m.theme).background,
|
|
436
|
+
warnings: diagnostics
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// ../aula-project/src/videos.ts
|
|
444
|
+
import { FPS as FPS4 } from "@beff/aula/run";
|
|
445
|
+
import { estimateNarration } from "@beff/aula/text";
|
|
332
446
|
|
|
333
447
|
export {
|
|
334
448
|
scriptView,
|
|
@@ -348,5 +462,7 @@ export {
|
|
|
348
462
|
pictureStills,
|
|
349
463
|
pictureGroups,
|
|
350
464
|
movesMarkdown,
|
|
351
|
-
timelineView
|
|
465
|
+
timelineView,
|
|
466
|
+
workspaceHost,
|
|
467
|
+
loadProjects
|
|
352
468
|
};
|
|
@@ -151,10 +151,15 @@ async function tokenBatches(vocab, phonemize2, text) {
|
|
|
151
151
|
var STRESS = "\u02C8\u02CC";
|
|
152
152
|
var isSound = (phoneme) => new RegExp("\\p{L}", "u").test(phoneme) && !STRESS.includes(phoneme);
|
|
153
153
|
async function timesOfWords(phonemize2, words, timings) {
|
|
154
|
-
const spoken = timings.filter((timing) => isSound(timing.phoneme));
|
|
155
|
-
if (!spoken.length) throw new Error("the model gave no phoneme timings");
|
|
156
154
|
const read = [];
|
|
157
155
|
for (const word of words) read.push(Array.from(await phonemize2(word)).filter(isSound));
|
|
156
|
+
const spoken = timings.filter((timing) => isSound(timing.phoneme));
|
|
157
|
+
if (!spoken.length) {
|
|
158
|
+
const text = JSON.stringify(words.join(" "));
|
|
159
|
+
throw new Error(
|
|
160
|
+
read.some((w) => w.length > 0) ? `the narrator gave no phoneme timings for ${text}` : `Nothing to say: ${text} has no spoken sounds`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
158
163
|
return alignWords(words, spoken, read);
|
|
159
164
|
}
|
|
160
165
|
|
|
@@ -319,12 +324,22 @@ async function layout(parts, words, audio) {
|
|
|
319
324
|
const text = words.join(" ");
|
|
320
325
|
const batches = await batchesOf(parts.phonemize, text, MAX_TOKENS);
|
|
321
326
|
if (!batches.length) throw new Error(`Nothing to say: ${JSON.stringify(text)} has no phonemes`);
|
|
327
|
+
const tokenized = batches.map((batch) => {
|
|
328
|
+
const { ids, known } = tokenize(KOKORO_VOCAB, batch);
|
|
329
|
+
if (!ids.length) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
`No phonemes of ${JSON.stringify(text)} (${JSON.stringify(batch)}) are in the model's token table`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return { batch, ids, known };
|
|
335
|
+
});
|
|
336
|
+
if (!tokenized.some(({ known }) => known.some(isSound))) {
|
|
337
|
+
throw new Error(`Nothing to say: ${JSON.stringify(text)} has no spoken sounds`);
|
|
338
|
+
}
|
|
322
339
|
const pieces = [];
|
|
323
340
|
const timings = [];
|
|
324
341
|
let offset = 0;
|
|
325
|
-
for (const [index, batch] of
|
|
326
|
-
const { ids, known } = tokenize(KOKORO_VOCAB, batch);
|
|
327
|
-
if (!ids.length) throw new Error(`No phonemes of ${JSON.stringify(batch)} are in the model's token table`);
|
|
342
|
+
for (const [index, { batch, ids, known }] of tokenized.entries()) {
|
|
328
343
|
const padded = [0, ...ids, 0];
|
|
329
344
|
const spoken = audio ? parts.model.speak(padded, VOICE) : { audio: null, durations: parts.model.durations(padded, VOICE) };
|
|
330
345
|
const edges = [0];
|
package/dist/src/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
studentWeightFile,
|
|
15
15
|
timeAulaVoice,
|
|
16
16
|
tokenBatches
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-PLBRKNMD.js";
|
|
18
18
|
|
|
19
19
|
// src/cli.ts
|
|
20
20
|
import { spawn } from "node:child_process";
|
|
@@ -178,6 +178,18 @@ import { createHash } from "node:crypto";
|
|
|
178
178
|
import path2 from "node:path";
|
|
179
179
|
import { fault } from "@beff/aula/errors";
|
|
180
180
|
var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
181
|
+
async function writeAtomic(capabilities2, destination, bytes) {
|
|
182
|
+
const folder = path2.dirname(destination);
|
|
183
|
+
await capabilities2.fs.mkdir(folder, { recursive: true });
|
|
184
|
+
const work = await capabilities2.fs.mkdtemp(path2.join(folder, `.${path2.basename(destination)}.`));
|
|
185
|
+
try {
|
|
186
|
+
const staged = path2.join(work, path2.basename(destination));
|
|
187
|
+
await capabilities2.fs.writeFile(staged, bytes);
|
|
188
|
+
await capabilities2.fs.rename(staged, destination);
|
|
189
|
+
} finally {
|
|
190
|
+
await capabilities2.fs.rm(work, { recursive: true, force: true });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
181
193
|
async function download(capabilities2, fetch2, downloading, destination, url, hash) {
|
|
182
194
|
if (capabilities2.fs.existsSync(destination)) {
|
|
183
195
|
const kept = new Uint8Array(await capabilities2.fs.readFile(destination));
|
|
@@ -192,9 +204,7 @@ async function download(capabilities2, fetch2, downloading, destination, url, ha
|
|
|
192
204
|
if (sha256(bytes) !== hash) {
|
|
193
205
|
fault(`the download of ${url} has the wrong SHA-256`, "run the command again; if it fails again, report it");
|
|
194
206
|
}
|
|
195
|
-
await capabilities2
|
|
196
|
-
await capabilities2.fs.writeFile(`${destination}.part`, bytes);
|
|
197
|
-
await capabilities2.fs.rename(`${destination}.part`, destination);
|
|
207
|
+
await writeAtomic(capabilities2, destination, bytes);
|
|
198
208
|
return bytes;
|
|
199
209
|
}
|
|
200
210
|
var phonemize = britishPhonemizer(new Set(KOKORO_VOCAB.keys()));
|
|
@@ -216,8 +226,7 @@ async function aulaVoiceWeightFile(capabilities2, options2) {
|
|
|
216
226
|
if (sha256(avw) !== AULA_VOICE_WEIGHTS.sha256) {
|
|
217
227
|
fault("the weight file made from aula-voice's release has the wrong SHA-256", "report it");
|
|
218
228
|
}
|
|
219
|
-
await capabilities2
|
|
220
|
-
await capabilities2.fs.rename(`${destination}.part`, destination);
|
|
229
|
+
await writeAtomic(capabilities2, destination, avw);
|
|
221
230
|
return avw;
|
|
222
231
|
}
|
|
223
232
|
function aulaVoice(capabilities2, options2) {
|
|
@@ -271,9 +280,9 @@ var base = Capabilities.create({
|
|
|
271
280
|
},
|
|
272
281
|
spawn
|
|
273
282
|
});
|
|
274
|
-
var { diagnosticsOf, printDiagnostics } = await import("./problems-
|
|
275
|
-
var { host, loadProject } = await import("./project-
|
|
276
|
-
var { USAGE, folderArgs, isHelp, optionsOf, parse, run: run2, siteOptions, webOptions } = await import("./run-
|
|
283
|
+
var { diagnosticsOf, printDiagnostics } = await import("./problems-CCUJW4H4.js");
|
|
284
|
+
var { host, loadProject } = await import("./project-PF77AQKF.js");
|
|
285
|
+
var { USAGE, folderArgs, isHelp, optionsOf, parse, run: run2, siteOptions, webOptions } = await import("./run-VCOTEL37.js");
|
|
277
286
|
var locks = createLocks(base, path3.join(os.homedir(), ".cache/aula/heavy.lock"));
|
|
278
287
|
var render = createRender(base, process.execPath);
|
|
279
288
|
var models = path3.join(os.homedir(), ".cache/aula/models");
|
|
@@ -296,7 +305,7 @@ async function main(argv) {
|
|
|
296
305
|
}
|
|
297
306
|
const args = parse(rest, optionsOf(command));
|
|
298
307
|
if (command === "web") {
|
|
299
|
-
const { serve } = await import("./server-
|
|
308
|
+
const { serve } = await import("./server-5W36J7WM.js");
|
|
300
309
|
const stop = new AbortController();
|
|
301
310
|
for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => stop.abort());
|
|
302
311
|
const web = Capabilities.create({
|
|
@@ -312,18 +321,19 @@ async function main(argv) {
|
|
|
312
321
|
return 0;
|
|
313
322
|
}
|
|
314
323
|
if (command === "site") {
|
|
315
|
-
const { site } = await import("./site-
|
|
324
|
+
const { site } = await import("./site-NA5QNSHF.js");
|
|
316
325
|
const weights = Capabilities.create({ weights: aulaVoiceWeights(base, fetch, models) });
|
|
317
326
|
return await site(Capabilities.extend(capabilities, weights), siteOptions(cwd, args)) ? 0 : 1;
|
|
318
327
|
}
|
|
319
328
|
if (command === "tokens") {
|
|
320
|
-
const { tokens, tokensArgs } = await import("./commands-
|
|
329
|
+
const { tokens, tokensArgs } = await import("./commands-7MTNNJKO.js");
|
|
321
330
|
tokensArgs(args.positional);
|
|
322
331
|
const tokensOf = createTokens();
|
|
323
332
|
return await tokens(capabilities, tokensOf, createInterface({ input: process.stdin, crlfDelay: Infinity })) ? 0 : 1;
|
|
324
333
|
}
|
|
325
334
|
const { folder, rest: after } = folderArgs(cwd, command, args);
|
|
326
|
-
const
|
|
335
|
+
const only = command === "preview" ? after.slice(1) : command === "check" || command === "timeline" ? after : [];
|
|
336
|
+
const project = await loadProject(capabilities, cwd, folder, only);
|
|
327
337
|
return await run2(capabilities, cwd, command, project, after, args.flags) ? 0 : 1;
|
|
328
338
|
}
|
|
329
339
|
try {
|
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
timeline,
|
|
8
8
|
tokens,
|
|
9
9
|
tokensArgs
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-EB67KE2S.js";
|
|
11
|
+
import "./chunk-6CZECZIX.js";
|
|
12
12
|
import "./chunk-BLKXJGEO.js";
|
|
13
13
|
import "./chunk-2XGNOG2U.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-7C6QW2TD.js";
|
|
15
|
+
import "./chunk-LSXILCMB.js";
|
|
16
16
|
import "./chunk-S74JLCZK.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-PLBRKNMD.js";
|
|
18
|
+
import "./chunk-J7LNPVU2.js";
|
|
19
|
+
import "./chunk-EZROW2IP.js";
|
|
20
|
+
import "./chunk-3MPFI4UE.js";
|
|
21
21
|
export {
|
|
22
22
|
bundle,
|
|
23
23
|
check,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
printDiagnostics
|
|
3
|
+
} from "./chunk-7C6QW2TD.js";
|
|
4
|
+
import "./chunk-LSXILCMB.js";
|
|
5
|
+
import "./chunk-S74JLCZK.js";
|
|
6
|
+
import "./chunk-PLBRKNMD.js";
|
|
7
|
+
import "./chunk-EZROW2IP.js";
|
|
8
|
+
import {
|
|
9
|
+
diagnosticsOf
|
|
10
|
+
} from "./chunk-3MPFI4UE.js";
|
|
11
|
+
export {
|
|
12
|
+
diagnosticsOf,
|
|
13
|
+
printDiagnostics
|
|
14
|
+
};
|