@beff/aula-cli 0.6.1 → 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/{chunk-32AJJP3R.js → chunk-7C6QW2TD.js} +1 -1
- package/dist/src/{chunk-KQJVAXSC.js → chunk-EB67KE2S.js} +12 -12
- package/dist/src/chunk-EZROW2IP.js +127 -0
- package/dist/src/{chunk-ZASMFCUL.js → chunk-J7LNPVU2.js} +5 -4
- package/dist/src/{chunk-XYBGXFIM.js → chunk-LSXILCMB.js} +47 -14
- package/dist/src/{chunk-6LC3WXJ7.js → chunk-PLBRKNMD.js} +20 -5
- package/dist/src/cli.js +23 -13
- package/dist/src/{commands-KNPNJHDC.js → commands-7MTNNJKO.js} +6 -6
- package/dist/src/{problems-P6M3366O.js → problems-CCUJW4H4.js} +4 -4
- package/dist/src/{project-BZL5K5BR.js → project-PF77AQKF.js} +2 -2
- package/dist/src/{run-V3U7HCKB.js → run-VCOTEL37.js} +6 -6
- package/dist/src/{server-KTS6ORJM.js → server-5W36J7WM.js} +3 -3
- package/dist/src/{site-VW2NSQV5.js → site-NA5QNSHF.js} +2 -2
- package/dist/web/app/assets/{72474bf9 → 3cdff963}/aula-method.js +1 -1
- package/dist/web/app/assets/{72474bf9 → 3cdff963}/aula.js +1 -1
- package/dist/web/app/assets/{72474bf9 → 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-DxzRCbJL.js → aula-voice-worker-C7UeMloK.js} +2 -2
- package/dist/web/app/assets/{aula.core5-BdGr7QcG.wasm → aula.core5-DVDCNzCV.wasm} +0 -0
- package/dist/web/app/assets/{index-DtOukfzG.css → index-BirjmJbl.css} +1 -1
- package/dist/web/app/assets/{protocol-DqAun5Af.js → protocol-C3MGnf_t.js} +4 -4
- package/dist/web/app/assets/{src-Cz8PghaR.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-CzRFydP2.js → aula-voice-worker-DHEZKCCg.js} +2 -2
- package/dist/web/site/assets/{aula.core5-BdGr7QcG.wasm → aula.core5-DVDCNzCV.wasm} +0 -0
- package/dist/web/site/assets/{9db97082 → fbc21d75}/aula-method.js +1 -1
- package/dist/web/site/assets/{9db97082 → fbc21d75}/aula.js +1 -1
- package/dist/web/site/assets/{9db97082 → fbc21d75}/build-worker.js +2 -2
- package/dist/web/site/assets/fbc21d75/index.js +53 -0
- package/dist/web/site/assets/{index-Dcly6eU3.css → index-BirjmJbl.css} +1 -1
- package/dist/web/site/assets/{protocol-DPaQDdsV.js → protocol-CzWPeNPI.js} +4 -4
- package/dist/web/site/assets/{src-71sAnADq.js → src-1_dQqt80.js} +2 -2
- package/dist/web/site/index.html +27 -4
- package/package.json +2 -2
- package/dist/src/chunk-NAMV5OAS.js +0 -77
- package/dist/web/app/assets/72474bf9/index.js +0 -53
- package/dist/web/app/assets/__vite-browser-external-CS_r4ncq.js +0 -1
- package/dist/web/site/assets/9db97082/index.js +0 -53
- package/dist/web/site/assets/__vite-browser-external-CTYaiPUZ.js +0 -1
|
@@ -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,
|
|
@@ -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 {
|
|
@@ -60,18 +60,39 @@ function openCount(chapters, indexes) {
|
|
|
60
60
|
// ../aula-project/src/check.ts
|
|
61
61
|
import { checkChapter, checkLexicon, checkTitle, readChapter as readChapter2 } from "@beff/aula";
|
|
62
62
|
import { chapterNames } from "@beff/aula/run";
|
|
63
|
-
import { check as rules } from "@beff/aula/text";
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
|
67
75
|
const timings = [];
|
|
68
|
-
for (const cue of cues)
|
|
69
|
-
|
|
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));
|
|
70
91
|
}
|
|
71
92
|
return narrations;
|
|
72
93
|
}
|
|
73
94
|
function narrationAt(narrations, index) {
|
|
74
|
-
const narration = narrations
|
|
95
|
+
const narration = narrations.get(index);
|
|
75
96
|
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
76
97
|
return narration;
|
|
77
98
|
}
|
|
@@ -298,17 +319,24 @@ function movesMarkdown(stills) {
|
|
|
298
319
|
}
|
|
299
320
|
|
|
300
321
|
// ../aula-project/src/timeline.ts
|
|
301
|
-
import { renderChapter } from "@beff/aula";
|
|
322
|
+
import { readChapter as readChapter3, renderChapter } from "@beff/aula";
|
|
302
323
|
import { chapterNames as chapterNames3 } from "@beff/aula/run";
|
|
303
324
|
import { narrationScript, timeline as timelineOf } from "@beff/aula/text";
|
|
325
|
+
var EMPTY2 = { heading: "", headingSpoken: "", metaphor: "", paragraphs: [] };
|
|
304
326
|
async function timelineView(project, host, narrator, only) {
|
|
305
327
|
const names = chapterNames3(project);
|
|
306
328
|
const indexes = only.length === 0 ? project.chapters.map((_, i) => i + 1) : only.map((name) => chapterIndex(names, name));
|
|
307
329
|
if (indexes.includes(0)) throw wrongArgument("the title card has no timeline: give a chapter name");
|
|
308
|
-
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);
|
|
309
337
|
let out = header(project);
|
|
310
338
|
for (const index of indexes) {
|
|
311
|
-
const text = chapterText(project, host, index);
|
|
339
|
+
const text = loaded.get(index) ?? chapterText(project, host, index);
|
|
312
340
|
const run = renderChapter(project, index, { host, narration: narrationAt(n, index), lint: true });
|
|
313
341
|
if (!run.ok || run.value === void 0) throw new Problems(run.diagnostics);
|
|
314
342
|
out += `
|
|
@@ -335,7 +363,7 @@ var workspaceHost = (frames, media) => ({
|
|
|
335
363
|
});
|
|
336
364
|
var propertyOf = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
|
|
337
365
|
var LIST = "aula-projects.ts";
|
|
338
|
-
async function loadProjects(files, host, modules, esbuild, player) {
|
|
366
|
+
async function loadProjects(files, host, modules, esbuild, player, engineLoaded) {
|
|
339
367
|
const root = await files.name();
|
|
340
368
|
const listed = await projectModules(files, root);
|
|
341
369
|
if (listed._tag === "Left") return listed;
|
|
@@ -351,7 +379,12 @@ async function loadProjects(files, host, modules, esbuild, player) {
|
|
|
351
379
|
read: (path) => path === LIST ? Promise.resolve(list) : files.read(path),
|
|
352
380
|
list: (folder) => files.list(folder)
|
|
353
381
|
};
|
|
354
|
-
const [bundled] = await Promise.all([
|
|
382
|
+
const [bundled] = await Promise.all([
|
|
383
|
+
bundle(esbuild, tree, LIST, player),
|
|
384
|
+
loadEngine().then(() => {
|
|
385
|
+
engineLoaded?.();
|
|
386
|
+
})
|
|
387
|
+
]);
|
|
355
388
|
if (bundled._tag === "Left") return bundled;
|
|
356
389
|
const loaded = await importUserModule(() => modules.load(bundled.right));
|
|
357
390
|
if (loaded._tag === "Left") return { _tag: "Left", left: [diagnosticOf(loaded.left, LIST, host)] };
|
|
@@ -386,8 +419,8 @@ function localProject(name, section, definition, host) {
|
|
|
386
419
|
const script = narrationScript2(definition, chapters);
|
|
387
420
|
return { _tag: "Right", right: { script } };
|
|
388
421
|
},
|
|
389
|
-
walk: () => {
|
|
390
|
-
|
|
422
|
+
walk: (index) => {
|
|
423
|
+
if (index > 0) Engine.checkChapter(definition, index, { host });
|
|
391
424
|
},
|
|
392
425
|
render: (index, narration) => {
|
|
393
426
|
const run = Engine.renderChapter(definition, index, { host, narration });
|
|
@@ -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,16 +7,16 @@ import {
|
|
|
7
7
|
timeline,
|
|
8
8
|
tokens,
|
|
9
9
|
tokensArgs
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EB67KE2S.js";
|
|
11
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-
|
|
17
|
+
import "./chunk-PLBRKNMD.js";
|
|
18
|
+
import "./chunk-J7LNPVU2.js";
|
|
19
|
+
import "./chunk-EZROW2IP.js";
|
|
20
20
|
import "./chunk-3MPFI4UE.js";
|
|
21
21
|
export {
|
|
22
22
|
bundle,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
printDiagnostics
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-7C6QW2TD.js";
|
|
4
|
+
import "./chunk-LSXILCMB.js";
|
|
5
5
|
import "./chunk-S74JLCZK.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-PLBRKNMD.js";
|
|
7
|
+
import "./chunk-EZROW2IP.js";
|
|
8
8
|
import {
|
|
9
9
|
diagnosticsOf
|
|
10
10
|
} from "./chunk-3MPFI4UE.js";
|
|
@@ -5,16 +5,16 @@ import {
|
|
|
5
5
|
preview,
|
|
6
6
|
script,
|
|
7
7
|
timeline
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EB67KE2S.js";
|
|
9
9
|
import "./chunk-6CZECZIX.js";
|
|
10
10
|
import "./chunk-BLKXJGEO.js";
|
|
11
11
|
import "./chunk-2XGNOG2U.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-7C6QW2TD.js";
|
|
13
|
+
import "./chunk-LSXILCMB.js";
|
|
14
14
|
import "./chunk-S74JLCZK.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-PLBRKNMD.js";
|
|
16
|
+
import "./chunk-J7LNPVU2.js";
|
|
17
|
+
import "./chunk-EZROW2IP.js";
|
|
18
18
|
import {
|
|
19
19
|
wrongArgument
|
|
20
20
|
} from "./chunk-3MPFI4UE.js";
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import "./chunk-S74JLCZK.js";
|
|
5
5
|
import {
|
|
6
6
|
SERVER_WEIGHTS_PATH
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PLBRKNMD.js";
|
|
8
8
|
import {
|
|
9
9
|
exists
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-J7LNPVU2.js";
|
|
11
|
+
import "./chunk-EZROW2IP.js";
|
|
12
12
|
import "./chunk-3MPFI4UE.js";
|
|
13
13
|
|
|
14
14
|
// src/web/server.ts
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
loadProjects,
|
|
7
7
|
workspaceHost
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LSXILCMB.js";
|
|
9
9
|
import {
|
|
10
10
|
PACKAGE
|
|
11
11
|
} from "./chunk-A5QHTZKT.js";
|
|
12
12
|
import "./chunk-S74JLCZK.js";
|
|
13
13
|
import {
|
|
14
14
|
AULA_VOICE_WEIGHTS
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-PLBRKNMD.js";
|
|
16
16
|
import {
|
|
17
17
|
Problems,
|
|
18
18
|
pathsTree,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e,y as t}from"../src-
|
|
1
|
+
import{m as e,y as t}from"../src-CTZjQYUv.js";var n=e=>JSON.stringify(e);function r(e){return!/\s/.test(e)&&!e.includes(`://`)&&/[/.]/.test(e)}function i(e,t,i){let a=[],o=(t,n=e.place)=>{a.push({message:t,...n===void 0?{}:{at:n}})};i.mechanism.trim()===``&&o(`the paragraph has no mechanism: name the one mechanism that the viewer must understand`);for(let e of i.sources)r(e)&&!t.exists(e)&&o(`${n(e)}: this path is not a file: correct the path or add the file`);return a}function a(n){let r=t(`paragraph`,n);return({sources:t},n)=>e({mechanism:r,sources:t},n??((e,n)=>i(e,n,{mechanism:r,sources:t})))}export{i as findings,a as paragraph};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as checkChapter,n as checkLexicon,r as checkTitle,u as defineChapter,d as defineProject,f as embed,p as isProjectDefinition,c as m,m as paragraph,h as pronounce,a as readChapter,o as renderChapter,g as renderScene,_ as say,v as show,y as tagText}from"../src-
|
|
1
|
+
export{t as checkChapter,n as checkLexicon,r as checkTitle,u as defineChapter,d as defineProject,f as embed,p as isProjectDefinition,c as m,m as paragraph,h as pronounce,a as readChapter,o as renderChapter,g as renderScene,_ as say,v as show,y as tagText}from"../src-CTZjQYUv.js";
|