@beff/aula-cli 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/src/{aula-voice-tts-HPJAJO2Q.js → aula-voice-tts-H2OQFQ5J.js} +1 -1
- package/dist/src/aula.js +2 -2
- package/dist/src/{chunk-KCGXC2RV.js → chunk-4FWDTPLR.js} +1 -1
- package/dist/src/{chunk-XCPBFMEA.js → chunk-D5N3QDDF.js} +1 -1
- package/dist/src/{chunk-Y56UHOZ2.js → chunk-F5RPEFZR.js} +2 -0
- package/dist/src/{chunk-5ABPFV55.js → chunk-G44UMBPW.js} +2 -2
- package/dist/src/{chunk-5TUGYMFH.js → chunk-S6IM5XXK.js} +3 -3
- package/dist/src/{chunk-5XVICDLW.js → chunk-THZNJBUF.js} +133 -18
- package/dist/src/{chunk-4PZYWKO5.js → chunk-UBVMGS2E.js} +1 -1
- package/dist/src/{chunk-3RB5T3CC.js → chunk-UQOXT6QN.js} +109 -87
- package/dist/src/{chunk-DFXG2P7A.js → chunk-WV2UYZND.js} +12 -7
- package/dist/src/chunk-XIVHJMET.js +111 -0
- package/dist/src/cli.js +29 -93
- package/dist/src/{commands-BUM4AG3N.js → commands-PLST75CP.js} +11 -10
- package/dist/src/problems-EI4DOEZ4.js +17 -0
- package/dist/src/project-7EROVEUE.js +16 -0
- package/dist/src/run-NE5HOAXA.js +235 -0
- package/dist/src/{server-ALRN2C2W.js → server-KXIU66BB.js} +35 -23
- package/dist/src/{site-A2I4P4GX.js → site-HUWODSZ3.js} +21 -77
- package/dist/src/workspace-load-DOHFEZFR.js +16 -0
- package/dist/web/app/assets/{56cf58c4 → 62289de9}/aula-method.js +1 -1
- package/dist/web/app/assets/{56cf58c4 → 62289de9}/aula.js +1 -1
- package/dist/web/app/assets/62289de9/build-worker.js +2 -0
- package/dist/web/app/assets/{56cf58c4 → 62289de9}/index.js +2 -2
- package/dist/web/app/assets/{protocol-C3Pseh4g.js → protocol-kcdbhuRm.js} +4 -4
- package/dist/web/app/assets/{src-DTLT9Lbm.js → src-DWqZcp-P.js} +1 -1
- package/dist/web/app/assets/{tex-mathjax-8QilZX4j.js → tex-mathjax-eWNptbJg.js} +1 -1
- package/dist/web/app/index.html +3 -3
- package/dist/web/site/assets/{82624cbe → 82618540}/aula-method.js +1 -1
- package/dist/web/site/assets/{82624cbe → 82618540}/aula.js +1 -1
- package/dist/web/site/assets/82618540/build-worker.js +2 -0
- package/dist/web/site/assets/{82624cbe → 82618540}/index.js +2 -2
- package/dist/web/site/assets/{protocol-BOv1ch3F.js → protocol-XMWr-E-D.js} +4 -4
- package/dist/web/site/assets/{src-DpS3WA7l.js → src-DfPcHwz-.js} +1 -1
- package/dist/web/site/assets/{tex-mathjax-CVHS5J80.js → tex-mathjax-DrZV_cwB.js} +1 -1
- package/dist/web/site/index.html +3 -3
- package/package.json +1 -1
- package/dist/src/chunk-JWBPHDVP.js +0 -104
- package/dist/src/problems-2IXR6RUV.js +0 -18
- package/dist/src/project-36YBXKCD.js +0 -16
- package/dist/src/run-YLF62D3C.js +0 -173
- package/dist/web/app/assets/56cf58c4/build-worker.js +0 -2
- package/dist/web/site/assets/82624cbe/build-worker.js +0 -2
package/dist/src/cli.js
CHANGED
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
studentWeightFile,
|
|
15
15
|
timeAulaVoice,
|
|
16
16
|
tokenBatches
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-4FWDTPLR.js";
|
|
18
|
+
import "./chunk-F5RPEFZR.js";
|
|
19
19
|
import {
|
|
20
20
|
fault
|
|
21
21
|
} from "./chunk-VX7UVLQW.js";
|
|
@@ -27,7 +27,7 @@ import { existsSync, readFileSync, statSync, watch } from "node:fs";
|
|
|
27
27
|
import * as fs from "node:fs/promises";
|
|
28
28
|
import os from "node:os";
|
|
29
29
|
import { createInterface } from "node:readline";
|
|
30
|
-
import
|
|
30
|
+
import path2 from "node:path";
|
|
31
31
|
|
|
32
32
|
// ../../node_modules/.pnpm/@beff+diy@0.0.36/node_modules/@beff/diy/dist/esm/capabilities.js
|
|
33
33
|
function create(serviceMap) {
|
|
@@ -89,74 +89,6 @@ var Capabilities = {
|
|
|
89
89
|
override
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
// src/locks.ts
|
|
93
|
-
import path from "node:path";
|
|
94
|
-
import { DatabaseSync } from "node:sqlite";
|
|
95
|
-
import { setTimeout as sleep } from "node:timers/promises";
|
|
96
|
-
var RETRY = 250;
|
|
97
|
-
var YIELD = 4 * RETRY;
|
|
98
|
-
var SQLITE_BUSY = 5;
|
|
99
|
-
function tryLock(file) {
|
|
100
|
-
const db = new DatabaseSync(file, { timeout: 0 });
|
|
101
|
-
try {
|
|
102
|
-
db.exec("BEGIN EXCLUSIVE");
|
|
103
|
-
return db;
|
|
104
|
-
} catch (e) {
|
|
105
|
-
db.close();
|
|
106
|
-
if (e instanceof Error && "errcode" in e && e.errcode === SQLITE_BUSY) return null;
|
|
107
|
-
throw e;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function createLocks(capabilities2, file) {
|
|
111
|
-
const heavy = {
|
|
112
|
-
count: 0,
|
|
113
|
-
held: null,
|
|
114
|
-
waiting: false,
|
|
115
|
-
/** When this process last released it (clock milliseconds). */
|
|
116
|
-
released: null
|
|
117
|
-
};
|
|
118
|
-
const acquireHeavy = async () => {
|
|
119
|
-
await capabilities2.fs.mkdir(path.dirname(file), { recursive: true });
|
|
120
|
-
if (heavy.released !== null) {
|
|
121
|
-
const left = heavy.released + YIELD - capabilities2.clock.now();
|
|
122
|
-
if (left > 0) await sleep(left);
|
|
123
|
-
}
|
|
124
|
-
for (; ; ) {
|
|
125
|
-
const db = tryLock(file);
|
|
126
|
-
if (db !== null) {
|
|
127
|
-
if (heavy.waiting) capabilities2.log.err("Acquired lock 'heavy'");
|
|
128
|
-
return db;
|
|
129
|
-
}
|
|
130
|
-
if (!heavy.waiting) {
|
|
131
|
-
heavy.waiting = true;
|
|
132
|
-
capabilities2.log.err(`Waiting for lock 'heavy': ${file}`);
|
|
133
|
-
}
|
|
134
|
-
await sleep(RETRY);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
return {
|
|
138
|
-
async heavy() {
|
|
139
|
-
let held;
|
|
140
|
-
do {
|
|
141
|
-
held = heavy.held ??= acquireHeavy();
|
|
142
|
-
await held;
|
|
143
|
-
} while (heavy.held !== held);
|
|
144
|
-
heavy.count += 1;
|
|
145
|
-
let released = false;
|
|
146
|
-
return async () => {
|
|
147
|
-
if (released) return;
|
|
148
|
-
released = true;
|
|
149
|
-
heavy.count -= 1;
|
|
150
|
-
if (heavy.count > 0) return;
|
|
151
|
-
heavy.held = null;
|
|
152
|
-
heavy.waiting = false;
|
|
153
|
-
(await held).close();
|
|
154
|
-
heavy.released = capabilities2.clock.now();
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
92
|
// src/render.ts
|
|
161
93
|
import { fileURLToPath } from "node:url";
|
|
162
94
|
var CHILD = fileURLToPath(
|
|
@@ -180,14 +112,14 @@ function createRender(capabilities2, node) {
|
|
|
180
112
|
|
|
181
113
|
// ../aula-narration/src/node.ts
|
|
182
114
|
import { createHash } from "node:crypto";
|
|
183
|
-
import
|
|
115
|
+
import path from "node:path";
|
|
184
116
|
var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
185
117
|
async function writeAtomic(capabilities2, destination, bytes) {
|
|
186
|
-
const folder =
|
|
118
|
+
const folder = path.dirname(destination);
|
|
187
119
|
await capabilities2.fs.mkdir(folder, { recursive: true });
|
|
188
|
-
const work = await capabilities2.fs.mkdtemp(
|
|
120
|
+
const work = await capabilities2.fs.mkdtemp(path.join(folder, `.${path.basename(destination)}.`));
|
|
189
121
|
try {
|
|
190
|
-
const staged =
|
|
122
|
+
const staged = path.join(work, path.basename(destination));
|
|
191
123
|
await capabilities2.fs.writeFile(staged, bytes);
|
|
192
124
|
await capabilities2.fs.rename(staged, destination);
|
|
193
125
|
} finally {
|
|
@@ -199,7 +131,7 @@ async function download(capabilities2, fetch2, downloading, destination, url, ha
|
|
|
199
131
|
const kept = new Uint8Array(await capabilities2.fs.readFile(destination));
|
|
200
132
|
if (sha256(kept) === hash) return kept;
|
|
201
133
|
}
|
|
202
|
-
downloading(
|
|
134
|
+
downloading(path.basename(destination));
|
|
203
135
|
const response = await fetch2(url, { headers: { "User-Agent": "aula" } });
|
|
204
136
|
if (!response.ok) throw new Error(`Cannot download ${url}: HTTP ${String(response.status)}`);
|
|
205
137
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
@@ -215,17 +147,17 @@ var phonemize = britishPhonemizer(new Set(KOKORO_VOCAB.keys()));
|
|
|
215
147
|
function textTokens() {
|
|
216
148
|
return (text) => tokenBatches(KOKORO_VOCAB, phonemize, text);
|
|
217
149
|
}
|
|
218
|
-
var aulaVoiceFolder = (models2) =>
|
|
150
|
+
var aulaVoiceFolder = (models2) => path.join(models2, "aula-voice", AULA_VOICE_RELEASE);
|
|
219
151
|
async function aulaVoiceWeightFile(capabilities2, options2) {
|
|
220
152
|
const { fetch: fetch2, models: models2, downloading } = options2;
|
|
221
153
|
const folder = aulaVoiceFolder(models2);
|
|
222
|
-
const destination =
|
|
154
|
+
const destination = path.join(folder, AULA_VOICE_WEIGHTS.path);
|
|
223
155
|
if (capabilities2.fs.existsSync(destination)) {
|
|
224
156
|
const kept = new Uint8Array(await capabilities2.fs.readFile(destination));
|
|
225
157
|
if (sha256(kept) === AULA_VOICE_WEIGHTS.sha256) return kept;
|
|
226
158
|
}
|
|
227
159
|
const { model, config } = AULA_VOICE_FILES;
|
|
228
|
-
const raw = (file) => download(capabilities2, fetch2, downloading,
|
|
160
|
+
const raw = (file) => download(capabilities2, fetch2, downloading, path.join(folder, file.path), aulaVoiceUrl(file), file.sha256);
|
|
229
161
|
const avw = studentWeightFile(await raw(model), await raw(config));
|
|
230
162
|
if (sha256(avw) !== AULA_VOICE_WEIGHTS.sha256) {
|
|
231
163
|
fault("the weight file made from aula-voice's release has the wrong SHA-256", "report it");
|
|
@@ -236,7 +168,7 @@ async function aulaVoiceWeightFile(capabilities2, options2) {
|
|
|
236
168
|
function aulaVoice(capabilities2, options2) {
|
|
237
169
|
let loading = null;
|
|
238
170
|
const parts = () => loading ??= (async () => {
|
|
239
|
-
const { aulaVoiceModel } = await import("./aula-voice-tts-
|
|
171
|
+
const { aulaVoiceModel } = await import("./aula-voice-tts-H2OQFQ5J.js");
|
|
240
172
|
return { model: await aulaVoiceModel(await aulaVoiceWeightFile(capabilities2, options2)), phonemize };
|
|
241
173
|
})();
|
|
242
174
|
return {
|
|
@@ -284,17 +216,15 @@ var base = Capabilities.create({
|
|
|
284
216
|
},
|
|
285
217
|
spawn
|
|
286
218
|
});
|
|
287
|
-
var { diagnosticsOf, printDiagnostics } = await import("./problems-
|
|
288
|
-
var { host, loadProject } = await import("./project-
|
|
289
|
-
var { USAGE, folderArgs, isHelp, optionsOf, parse, run: run2, siteOptions, webOptions } = await import("./run-
|
|
290
|
-
var locks = createLocks(base, path3.join(os.homedir(), ".cache/aula/heavy.lock"));
|
|
219
|
+
var { diagnosticsOf, printDiagnostics } = await import("./problems-EI4DOEZ4.js");
|
|
220
|
+
var { host, loadProject } = await import("./project-7EROVEUE.js");
|
|
221
|
+
var { USAGE, checkOptions, folderArgs, isHelp, optionsOf, parse, run: run2, siteOptions, webOptions } = await import("./run-NE5HOAXA.js");
|
|
291
222
|
var render = createRender(base, process.execPath);
|
|
292
|
-
var models =
|
|
223
|
+
var models = path2.join(os.homedir(), ".cache/aula/models");
|
|
293
224
|
var narrator = createAulaVoice(base, fetch, models);
|
|
294
225
|
var capabilities = Capabilities.extend(
|
|
295
226
|
base,
|
|
296
227
|
Capabilities.create({
|
|
297
|
-
locks,
|
|
298
228
|
narrator,
|
|
299
229
|
render
|
|
300
230
|
})
|
|
@@ -302,15 +232,14 @@ var capabilities = Capabilities.extend(
|
|
|
302
232
|
var cwd = process.cwd();
|
|
303
233
|
async function main(argv) {
|
|
304
234
|
const [command, ...rest] = argv;
|
|
305
|
-
if (command === void 0
|
|
306
|
-
if (isHelp(command)) {
|
|
235
|
+
if (command === void 0 || isHelp(command)) {
|
|
307
236
|
capabilities.log.out(USAGE);
|
|
308
237
|
return 0;
|
|
309
238
|
}
|
|
310
239
|
const args = parse(rest, optionsOf(command));
|
|
311
240
|
if (command === "web") {
|
|
312
241
|
const options2 = webOptions(cwd, args);
|
|
313
|
-
const { serve } = await import("./server-
|
|
242
|
+
const { serve } = await import("./server-KXIU66BB.js");
|
|
314
243
|
const stop = new AbortController();
|
|
315
244
|
for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => stop.abort());
|
|
316
245
|
const web = Capabilities.create({
|
|
@@ -326,18 +255,25 @@ async function main(argv) {
|
|
|
326
255
|
return 0;
|
|
327
256
|
}
|
|
328
257
|
if (command === "site") {
|
|
329
|
-
const { site } = await import("./site-
|
|
258
|
+
const { site } = await import("./site-HUWODSZ3.js");
|
|
330
259
|
const weights = Capabilities.create({ weights: aulaVoiceWeights(base, fetch, models) });
|
|
331
260
|
return await site(Capabilities.extend(capabilities, weights), siteOptions(cwd, args)) ? 0 : 1;
|
|
332
261
|
}
|
|
262
|
+
if (command === "check") {
|
|
263
|
+
const { checkRoot } = await import("./commands-PLST75CP.js");
|
|
264
|
+
const options2 = checkOptions(cwd, args);
|
|
265
|
+
return await checkRoot(capabilities, cwd, options2.root, options2.only, options2.json, options2.includeDrafts) ? 0 : 1;
|
|
266
|
+
}
|
|
333
267
|
if (command === "tokens") {
|
|
334
|
-
const { tokens, tokensArgs } = await import("./commands-
|
|
268
|
+
const { tokens, tokensArgs } = await import("./commands-PLST75CP.js");
|
|
335
269
|
tokensArgs(args.positional);
|
|
336
270
|
const tokensOf = createTokens();
|
|
337
271
|
return await tokens(capabilities, tokensOf, createInterface({ input: process.stdin, crlfDelay: Infinity })) ? 0 : 1;
|
|
338
272
|
}
|
|
339
|
-
const { folder, rest: after } = folderArgs(cwd, command, args);
|
|
340
|
-
const
|
|
273
|
+
const { folder: root, rest: after } = folderArgs(cwd, command, args);
|
|
274
|
+
const { resolveOneProject } = await import("./workspace-load-DOHFEZFR.js");
|
|
275
|
+
const { folder } = await resolveOneProject(capabilities, root, args.flags.has("--include-drafts"), command);
|
|
276
|
+
const only = command === "preview" ? after.slice(1) : command === "timeline" || command === "script" ? after : [];
|
|
341
277
|
const project = await loadProject(capabilities, cwd, folder, only);
|
|
342
278
|
return await run2(capabilities, cwd, command, project, after, args.flags) ? 0 : 1;
|
|
343
279
|
}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bundle,
|
|
3
3
|
check,
|
|
4
|
+
checkRoot,
|
|
4
5
|
exportVideo,
|
|
5
6
|
preview,
|
|
6
7
|
script,
|
|
7
8
|
timeline,
|
|
8
9
|
tokens,
|
|
9
10
|
tokensArgs
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UQOXT6QN.js";
|
|
11
12
|
import "./chunk-THQ5Y74K.js";
|
|
12
13
|
import "./chunk-F4XRXW6M.js";
|
|
13
14
|
import "./chunk-4N4NUMKP.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-Y56UHOZ2.js";
|
|
15
|
+
import "./chunk-S6IM5XXK.js";
|
|
16
|
+
import "./chunk-THZNJBUF.js";
|
|
17
|
+
import "./chunk-4FWDTPLR.js";
|
|
18
|
+
import "./chunk-UBVMGS2E.js";
|
|
19
|
+
import "./chunk-G44UMBPW.js";
|
|
20
|
+
import "./chunk-WV2UYZND.js";
|
|
21
|
+
import "./chunk-D5N3QDDF.js";
|
|
22
|
+
import "./chunk-F5RPEFZR.js";
|
|
23
23
|
import "./chunk-VX7UVLQW.js";
|
|
24
24
|
import "./chunk-CZ7CSFO4.js";
|
|
25
25
|
export {
|
|
26
26
|
bundle,
|
|
27
27
|
check,
|
|
28
|
+
checkRoot,
|
|
28
29
|
exportVideo,
|
|
29
30
|
preview,
|
|
30
31
|
script,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
printDiagnostics
|
|
3
|
+
} from "./chunk-S6IM5XXK.js";
|
|
4
|
+
import "./chunk-THZNJBUF.js";
|
|
5
|
+
import "./chunk-4FWDTPLR.js";
|
|
6
|
+
import "./chunk-G44UMBPW.js";
|
|
7
|
+
import {
|
|
8
|
+
diagnosticsOf
|
|
9
|
+
} from "./chunk-WV2UYZND.js";
|
|
10
|
+
import "./chunk-D5N3QDDF.js";
|
|
11
|
+
import "./chunk-F5RPEFZR.js";
|
|
12
|
+
import "./chunk-VX7UVLQW.js";
|
|
13
|
+
import "./chunk-CZ7CSFO4.js";
|
|
14
|
+
export {
|
|
15
|
+
diagnosticsOf,
|
|
16
|
+
printDiagnostics
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exists,
|
|
3
|
+
host,
|
|
4
|
+
loadProject
|
|
5
|
+
} from "./chunk-UBVMGS2E.js";
|
|
6
|
+
import "./chunk-G44UMBPW.js";
|
|
7
|
+
import "./chunk-WV2UYZND.js";
|
|
8
|
+
import "./chunk-D5N3QDDF.js";
|
|
9
|
+
import "./chunk-F5RPEFZR.js";
|
|
10
|
+
import "./chunk-VX7UVLQW.js";
|
|
11
|
+
import "./chunk-CZ7CSFO4.js";
|
|
12
|
+
export {
|
|
13
|
+
exists,
|
|
14
|
+
host,
|
|
15
|
+
loadProject
|
|
16
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bundle,
|
|
3
|
+
exportVideo,
|
|
4
|
+
preview,
|
|
5
|
+
script,
|
|
6
|
+
timeline
|
|
7
|
+
} from "./chunk-UQOXT6QN.js";
|
|
8
|
+
import "./chunk-THQ5Y74K.js";
|
|
9
|
+
import "./chunk-F4XRXW6M.js";
|
|
10
|
+
import "./chunk-4N4NUMKP.js";
|
|
11
|
+
import "./chunk-S6IM5XXK.js";
|
|
12
|
+
import "./chunk-THZNJBUF.js";
|
|
13
|
+
import "./chunk-4FWDTPLR.js";
|
|
14
|
+
import "./chunk-UBVMGS2E.js";
|
|
15
|
+
import "./chunk-G44UMBPW.js";
|
|
16
|
+
import {
|
|
17
|
+
wrongArgument
|
|
18
|
+
} from "./chunk-WV2UYZND.js";
|
|
19
|
+
import "./chunk-D5N3QDDF.js";
|
|
20
|
+
import "./chunk-F5RPEFZR.js";
|
|
21
|
+
import "./chunk-VX7UVLQW.js";
|
|
22
|
+
import "./chunk-CZ7CSFO4.js";
|
|
23
|
+
|
|
24
|
+
// src/run.ts
|
|
25
|
+
import path from "node:path";
|
|
26
|
+
var USAGE = `aula: storyboard-first narrated aula videos.
|
|
27
|
+
|
|
28
|
+
<folder> is the root: the path you pass. . means the current folder.
|
|
29
|
+
A project folder (index.ts / defineProject) is a list of one; a playlist
|
|
30
|
+
folder is its subprojects. Drafts are skipped unless --include-drafts.
|
|
31
|
+
check, web and site run on that list; preview, export, bundle, script and
|
|
32
|
+
timeline need exactly one project after filtering; tokens takes no folder.
|
|
33
|
+
<chapter> is a chapter id such as 01-double-the-side. title is not a
|
|
34
|
+
chapter argument. The title card is the first scene of the video. It shows
|
|
35
|
+
the project title from defineProject({ title }). A check or preview of the
|
|
36
|
+
whole project includes the title card.
|
|
37
|
+
Each chapter module holds its script, storyboard notes and animations;
|
|
38
|
+
messages name its lines (file:line:col).
|
|
39
|
+
|
|
40
|
+
aula check <folder> [<chapter> ...] [--json] [--include-drafts]
|
|
41
|
+
every check, with no narration and no frames, and
|
|
42
|
+
a note for each word whose reading is not clear;
|
|
43
|
+
finds the projects in the folder; skips draft:
|
|
44
|
+
true unless --include-drafts; --json prints each
|
|
45
|
+
result as one JSON object
|
|
46
|
+
aula preview <folder> <out> [<chapter>[:<line>] ...] [--include-drafts]
|
|
47
|
+
PNG pictures for review: per chapter, stills,
|
|
48
|
+
motion stills, contact sheets and moves.md
|
|
49
|
+
aula export <folder> <file.mp4> [--include-drafts]
|
|
50
|
+
the video to send: narrated in this run, H.264 and
|
|
51
|
+
AAC at 1280x720 and 60 fps; needs ffmpeg
|
|
52
|
+
aula web <folder> [--port N] [--host H] [--include-drafts]
|
|
53
|
+
the web app for a project folder (index.ts) or a
|
|
54
|
+
playlist folder; do not point it at a monorepo root
|
|
55
|
+
that also holds kits; skips draft: true unless
|
|
56
|
+
--include-drafts; the page narrates in the
|
|
57
|
+
browser; --host defaults to 127.0.0.1 (use
|
|
58
|
+
0.0.0.0 to listen on all interfaces)
|
|
59
|
+
aula bundle <folder> <file.zip> [--include-drafts]
|
|
60
|
+
the project zip: the project folder, and the
|
|
61
|
+
packages it imports, to share or host
|
|
62
|
+
aula site <folder> <out> [--title <text>] [--base <path>] [--include-drafts]
|
|
63
|
+
a website of a project or playlist folder (same as
|
|
64
|
+
aula web; do not point it at a monorepo root that
|
|
65
|
+
also holds kits; skips draft: true unless
|
|
66
|
+
--include-drafts): the folder's files with the
|
|
67
|
+
packages they import, and the web app, as plain
|
|
68
|
+
files in <out> for any static host; --title is the
|
|
69
|
+
site's title (default: the folder's name); --base
|
|
70
|
+
pins the site to a base path such as /aula/
|
|
71
|
+
(default: it works at any path)
|
|
72
|
+
aula script <folder> [<chapter> ...] [--include-drafts]
|
|
73
|
+
the review script: each chapter with its length,
|
|
74
|
+
each spoken beat and what is on screen
|
|
75
|
+
aula timeline <folder> [<chapter> ...] [--include-drafts]
|
|
76
|
+
print each say and move with its line, second
|
|
77
|
+
and note (agent view)
|
|
78
|
+
aula tokens Kokoro v1.0's token ids of texts, for training
|
|
79
|
+
data: reads JSON lines {"id"?, "text"} on
|
|
80
|
+
stdin, writes {"id"?, "batches": [{"phonemes",
|
|
81
|
+
"ids"}]} on stdout, one batch per model run
|
|
82
|
+
|
|
83
|
+
Errors make the exit code 1. Warnings do not change it.`;
|
|
84
|
+
var VALUED = {
|
|
85
|
+
"--port": { what: "a port number", number: true },
|
|
86
|
+
"--host": { what: "a host", number: false },
|
|
87
|
+
"--title": { what: "a title", number: false },
|
|
88
|
+
"--base": { what: "a base path", number: false }
|
|
89
|
+
};
|
|
90
|
+
function parse(argv, allowed) {
|
|
91
|
+
const args = { positional: [], values: /* @__PURE__ */ new Map(), flags: /* @__PURE__ */ new Set() };
|
|
92
|
+
for (let i = 0; i < argv.length; i++) {
|
|
93
|
+
const arg = argv[i] ?? "";
|
|
94
|
+
const what = VALUED[arg];
|
|
95
|
+
if (what !== void 0 && allowed.includes(arg)) {
|
|
96
|
+
i += 1;
|
|
97
|
+
const value = argv[i];
|
|
98
|
+
if (value === void 0) throw wrongArgument(`${arg} needs ${what.what}`);
|
|
99
|
+
if (!what.number) {
|
|
100
|
+
args.values.set(arg, value);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!/^[0-9]+$/.test(value)) throw wrongArgument(`${arg} ${value} is not a number`);
|
|
104
|
+
args.values.set(arg, Number(value));
|
|
105
|
+
} else if (allowed.includes(arg)) {
|
|
106
|
+
args.flags.add(arg);
|
|
107
|
+
} else if (arg.startsWith("--")) {
|
|
108
|
+
throw wrongArgument(`unknown option ${arg}`, "run `aula help` for the options of each command");
|
|
109
|
+
} else {
|
|
110
|
+
args.positional.push(arg);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return args;
|
|
114
|
+
}
|
|
115
|
+
var OPTIONS = {
|
|
116
|
+
check: ["--json", "--include-drafts"],
|
|
117
|
+
web: ["--port", "--host", "--include-drafts"],
|
|
118
|
+
site: ["--title", "--base", "--include-drafts"],
|
|
119
|
+
preview: ["--include-drafts"],
|
|
120
|
+
export: ["--include-drafts"],
|
|
121
|
+
bundle: ["--include-drafts"],
|
|
122
|
+
script: ["--include-drafts"],
|
|
123
|
+
timeline: ["--include-drafts"]
|
|
124
|
+
};
|
|
125
|
+
var isHelp = (command) => command === void 0 || command === "help" || command === "-h" || command === "--help";
|
|
126
|
+
function missingFolder() {
|
|
127
|
+
throw wrongArgument("missing <folder>: the project folder, which has index.ts");
|
|
128
|
+
}
|
|
129
|
+
var ARITY = {
|
|
130
|
+
preview: [1, Infinity],
|
|
131
|
+
export: [1, 1],
|
|
132
|
+
bundle: [1, 1],
|
|
133
|
+
script: [0, Infinity],
|
|
134
|
+
timeline: [0, Infinity]
|
|
135
|
+
};
|
|
136
|
+
function folderArgs(cwd, command, args) {
|
|
137
|
+
const arity = ARITY[command];
|
|
138
|
+
if (arity === void 0) throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
|
|
139
|
+
const [folder, ...rest] = args.positional;
|
|
140
|
+
if (folder === void 0) missingFolder();
|
|
141
|
+
if (rest.length < arity[0] || rest.length > arity[1])
|
|
142
|
+
throw wrongArgument("wrong number of arguments", "run `aula help` for the usage");
|
|
143
|
+
return { folder: path.resolve(cwd, folder), rest };
|
|
144
|
+
}
|
|
145
|
+
function checkOptions(cwd, args) {
|
|
146
|
+
const [folder, ...only] = args.positional;
|
|
147
|
+
if (folder === void 0) missingFolder();
|
|
148
|
+
return {
|
|
149
|
+
root: path.resolve(cwd, folder),
|
|
150
|
+
only,
|
|
151
|
+
json: args.flags.has("--json"),
|
|
152
|
+
includeDrafts: args.flags.has("--include-drafts")
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function extensionList(extensions) {
|
|
156
|
+
const [first, second, ...rest] = extensions;
|
|
157
|
+
if (first === void 0) throw new Error("fileArgument needs at least one file ending");
|
|
158
|
+
if (second === void 0) return first;
|
|
159
|
+
if (rest.length === 0) return `${first} or ${second}`;
|
|
160
|
+
return `${[first, second, ...rest.slice(0, -1)].join(", ")} or ${rest[rest.length - 1] ?? ""}`;
|
|
161
|
+
}
|
|
162
|
+
function fileArgument(cwd, value, options) {
|
|
163
|
+
const file = path.resolve(cwd, value);
|
|
164
|
+
if (!options.extensions.some((extension) => file.endsWith(extension)))
|
|
165
|
+
throw wrongArgument(
|
|
166
|
+
`The ${options.what} path must end with ${extensionList(options.extensions)}.`,
|
|
167
|
+
`Bad path: ${file}`
|
|
168
|
+
);
|
|
169
|
+
return file;
|
|
170
|
+
}
|
|
171
|
+
async function run(capabilities, cwd, command, project, rest, _flags = /* @__PURE__ */ new Set()) {
|
|
172
|
+
const [first = "", ...more] = rest;
|
|
173
|
+
switch (command) {
|
|
174
|
+
case "preview":
|
|
175
|
+
return preview(capabilities, cwd, project, path.resolve(cwd, first), more);
|
|
176
|
+
case "export":
|
|
177
|
+
return exportVideo(
|
|
178
|
+
capabilities,
|
|
179
|
+
cwd,
|
|
180
|
+
project,
|
|
181
|
+
fileArgument(cwd, first, { extensions: [".mp4"], what: "video" })
|
|
182
|
+
);
|
|
183
|
+
case "bundle":
|
|
184
|
+
return bundle(capabilities, project, fileArgument(cwd, first, { extensions: [".zip"], what: "zip" }));
|
|
185
|
+
case "script":
|
|
186
|
+
return script(capabilities, cwd, project, rest);
|
|
187
|
+
case "timeline":
|
|
188
|
+
return timeline(capabilities, cwd, project, rest);
|
|
189
|
+
default:
|
|
190
|
+
throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function webOptions(cwd, args) {
|
|
194
|
+
const [folder, ...more] = args.positional;
|
|
195
|
+
if (folder === void 0) missingFolder();
|
|
196
|
+
if (more.length > 0) throw wrongArgument("aula web takes one folder", "run `aula help` for the usage");
|
|
197
|
+
const port = args.values.get("--port");
|
|
198
|
+
const host = args.values.get("--host");
|
|
199
|
+
return {
|
|
200
|
+
root: path.resolve(cwd, folder),
|
|
201
|
+
port: typeof port === "number" ? port : 0,
|
|
202
|
+
host: typeof host === "string" ? host : "127.0.0.1",
|
|
203
|
+
includeDrafts: args.flags.has("--include-drafts")
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function siteOptions(cwd, args) {
|
|
207
|
+
const [folder, out, ...more] = args.positional;
|
|
208
|
+
if (folder === void 0 || out === void 0 || more.length > 0)
|
|
209
|
+
throw wrongArgument("aula site takes a folder and an output folder", "run `aula help` for the usage");
|
|
210
|
+
const title = args.values.get("--title");
|
|
211
|
+
const base = args.values.get("--base");
|
|
212
|
+
if (typeof base === "string" && !(base.startsWith("/") && base.endsWith("/")))
|
|
213
|
+
throw wrongArgument(`--base ${base} must start and end with /`, "for example --base /aula/");
|
|
214
|
+
const root = path.resolve(cwd, folder);
|
|
215
|
+
return {
|
|
216
|
+
folder: root,
|
|
217
|
+
out: path.resolve(cwd, out),
|
|
218
|
+
title: typeof title === "string" ? title : path.basename(root),
|
|
219
|
+
base: typeof base === "string" ? base : null,
|
|
220
|
+
includeDrafts: args.flags.has("--include-drafts")
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
var optionsOf = (command) => OPTIONS[command] ?? [];
|
|
224
|
+
export {
|
|
225
|
+
USAGE,
|
|
226
|
+
checkOptions,
|
|
227
|
+
fileArgument,
|
|
228
|
+
folderArgs,
|
|
229
|
+
isHelp,
|
|
230
|
+
optionsOf,
|
|
231
|
+
parse,
|
|
232
|
+
run,
|
|
233
|
+
siteOptions,
|
|
234
|
+
webOptions
|
|
235
|
+
};
|
|
@@ -2,22 +2,24 @@ import {
|
|
|
2
2
|
PACKAGE
|
|
3
3
|
} from "./chunk-A5QHTZKT.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
resolveRootProjects
|
|
6
|
+
} from "./chunk-XIVHJMET.js";
|
|
7
|
+
import {
|
|
6
8
|
nodeTree
|
|
7
9
|
} from "./chunk-THQ5Y74K.js";
|
|
8
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-THZNJBUF.js";
|
|
9
11
|
import {
|
|
10
12
|
SERVER_WEIGHTS_PATH
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4FWDTPLR.js";
|
|
12
14
|
import {
|
|
13
15
|
exists
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-UBVMGS2E.js";
|
|
17
|
+
import "./chunk-G44UMBPW.js";
|
|
16
18
|
import {
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
Problems
|
|
20
|
+
} from "./chunk-WV2UYZND.js";
|
|
21
|
+
import "./chunk-D5N3QDDF.js";
|
|
22
|
+
import "./chunk-F5RPEFZR.js";
|
|
21
23
|
import {
|
|
22
24
|
AulaError,
|
|
23
25
|
fault
|
|
@@ -27,7 +29,7 @@ import "./chunk-CZ7CSFO4.js";
|
|
|
27
29
|
// src/web/server.ts
|
|
28
30
|
import { once } from "node:events";
|
|
29
31
|
import { createServer } from "node:http";
|
|
30
|
-
import {
|
|
32
|
+
import { dirname, join } from "node:path";
|
|
31
33
|
|
|
32
34
|
// src/web/page.ts
|
|
33
35
|
var APP = new URL("web/app/", PACKAGE);
|
|
@@ -155,35 +157,43 @@ async function watchWorkspaceFolders(capabilities, root, watching) {
|
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
}
|
|
160
|
+
function openHost(host) {
|
|
161
|
+
if (host === "0.0.0.0") return "127.0.0.1";
|
|
162
|
+
if (host === "::" || host === "[::]") return "[::1]";
|
|
163
|
+
return host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
164
|
+
}
|
|
158
165
|
async function serve(capabilities, options) {
|
|
166
|
+
const host = options.host ?? "127.0.0.1";
|
|
167
|
+
const includeDrafts = options.includeDrafts === true;
|
|
159
168
|
let generation = 0;
|
|
160
169
|
let cached = null;
|
|
161
170
|
const watching = changes(capabilities, () => {
|
|
162
171
|
generation += 1;
|
|
163
172
|
cached = null;
|
|
164
173
|
});
|
|
165
|
-
const bundler = createNodeBundler();
|
|
166
174
|
const tree = nodeTree(capabilities, options.root);
|
|
167
175
|
const buildBundle = () => {
|
|
168
176
|
if (cached !== null && cached.generation === generation) return cached.result;
|
|
169
177
|
const at = generation;
|
|
170
178
|
const result = (async () => {
|
|
171
179
|
await watchWorkspaceFolders(capabilities, options.root, watching);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
for (const
|
|
180
|
+
try {
|
|
181
|
+
const resolved = await resolveRootProjects(capabilities, options.root, includeDrafts);
|
|
182
|
+
for (const input of resolved.inputs) {
|
|
183
|
+
const disk = tree.diskPath(input);
|
|
184
|
+
if (disk !== null) watching.served(disk);
|
|
185
|
+
}
|
|
186
|
+
return { _tag: "Right", right: resolved.bundle };
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (!(error instanceof Problems)) throw error;
|
|
189
|
+
for (const diagnostic of error.diagnostics) {
|
|
175
190
|
const file = diagnostic.location?.file;
|
|
176
191
|
if (file === void 0) continue;
|
|
177
192
|
const disk = tree.diskPath(file);
|
|
178
193
|
if (disk !== null && exists(capabilities, disk)) watching.served(disk);
|
|
179
194
|
}
|
|
180
|
-
return
|
|
181
|
-
}
|
|
182
|
-
for (const input of bundled.right.inputs) {
|
|
183
|
-
const disk = tree.diskPath(input);
|
|
184
|
-
if (disk !== null) watching.served(disk);
|
|
195
|
+
return { _tag: "Left", left: error.diagnostics };
|
|
185
196
|
}
|
|
186
|
-
return { _tag: "Right", right: bundled.right.bundle };
|
|
187
197
|
})();
|
|
188
198
|
const entry = { generation: at, result };
|
|
189
199
|
cached = entry;
|
|
@@ -203,14 +213,15 @@ async function serve(capabilities, options) {
|
|
|
203
213
|
else response.destroy();
|
|
204
214
|
});
|
|
205
215
|
});
|
|
206
|
-
server.listen(options.port,
|
|
216
|
+
server.listen(options.port, host);
|
|
207
217
|
await once(server, "listening");
|
|
208
218
|
const address = server.address();
|
|
209
219
|
const port = typeof address === "object" && address !== null ? address.port : options.port;
|
|
210
|
-
|
|
220
|
+
const open = `http://${openHost(host)}:${String(port)}/`;
|
|
221
|
+
const bindNote = host === "0.0.0.0" || host === "::" || host === "[::]" ? ` (listening on ${host})` : "";
|
|
222
|
+
capabilities.log.out(`aula web: open ${open} in a browser${bindNote} (Ctrl-C stops it)`);
|
|
211
223
|
options.stop.addEventListener("abort", () => {
|
|
212
224
|
watching.close();
|
|
213
|
-
void bundler.stop();
|
|
214
225
|
server.close();
|
|
215
226
|
server.closeAllConnections();
|
|
216
227
|
});
|
|
@@ -280,6 +291,7 @@ async function answer(capabilities, root, watching, weights, buildBundle, reques
|
|
|
280
291
|
notFound(request, response);
|
|
281
292
|
}
|
|
282
293
|
export {
|
|
294
|
+
openHost,
|
|
283
295
|
pathParts,
|
|
284
296
|
serve
|
|
285
297
|
};
|