@beff/aula-cli 0.12.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.
Files changed (42) hide show
  1. package/README.md +6 -1
  2. package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-H2OQFQ5J.js} +1 -1
  3. package/dist/src/aula.js +2 -2
  4. package/dist/src/{chunk-TDAWUJ2L.js → chunk-4FWDTPLR.js} +1 -1
  5. package/dist/src/{chunk-RAGZAJKD.js → chunk-D5N3QDDF.js} +1 -1
  6. package/dist/src/{chunk-DN2LVJO3.js → chunk-F5RPEFZR.js} +1 -0
  7. package/dist/src/{chunk-2PAZTBSE.js → chunk-G44UMBPW.js} +2 -2
  8. package/dist/src/{chunk-PZXFW6ZD.js → chunk-S6IM5XXK.js} +3 -3
  9. package/dist/src/{chunk-AXQBWV7J.js → chunk-THZNJBUF.js} +129 -20
  10. package/dist/src/{chunk-DC7A435Z.js → chunk-UBVMGS2E.js} +1 -1
  11. package/dist/src/{chunk-HD6FTA3H.js → chunk-UQOXT6QN.js} +109 -87
  12. package/dist/src/{chunk-T6CAPT32.js → chunk-WV2UYZND.js} +3 -2
  13. package/dist/src/chunk-XIVHJMET.js +111 -0
  14. package/dist/src/cli.js +29 -93
  15. package/dist/src/{commands-BSDNHYB3.js → commands-PLST75CP.js} +11 -10
  16. package/dist/src/problems-EI4DOEZ4.js +17 -0
  17. package/dist/src/project-7EROVEUE.js +16 -0
  18. package/dist/src/run-NE5HOAXA.js +235 -0
  19. package/dist/src/{server-TJTMSDO2.js → server-KXIU66BB.js} +24 -21
  20. package/dist/src/{site-RGPJOWSU.js → site-HUWODSZ3.js} +16 -89
  21. package/dist/src/workspace-load-DOHFEZFR.js +16 -0
  22. package/dist/web/app/assets/62289de9/build-worker.js +2 -0
  23. package/dist/web/app/assets/{bf5dd884 → 62289de9}/index.js +2 -2
  24. package/dist/web/app/assets/protocol-kcdbhuRm.js +15 -0
  25. package/dist/web/app/index.html +2 -2
  26. package/dist/web/site/assets/82618540/build-worker.js +2 -0
  27. package/dist/web/site/assets/{07fb5cf0 → 82618540}/index.js +2 -2
  28. package/dist/web/site/assets/protocol-XMWr-E-D.js +15 -0
  29. package/dist/web/site/index.html +2 -2
  30. package/package.json +1 -1
  31. package/dist/src/chunk-4QGX7XXO.js +0 -104
  32. package/dist/src/problems-CGKCPETU.js +0 -18
  33. package/dist/src/project-EUFMRQXR.js +0 -16
  34. package/dist/src/run-ER27SVTA.js +0 -183
  35. package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
  36. package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
  37. package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
  38. package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
  39. /package/dist/web/app/assets/{bf5dd884 → 62289de9}/aula-method.js +0 -0
  40. /package/dist/web/app/assets/{bf5dd884 → 62289de9}/aula.js +0 -0
  41. /package/dist/web/site/assets/{07fb5cf0 → 82618540}/aula-method.js +0 -0
  42. /package/dist/web/site/assets/{07fb5cf0 → 82618540}/aula.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  diagnosticOf
3
- } from "./chunk-DN2LVJO3.js";
3
+ } from "./chunk-F5RPEFZR.js";
4
4
 
5
5
  // ../../node_modules/.pnpm/@beff+client@1.0.1/node_modules/@beff/client/dist/esm/openapi-pp.js
6
6
  var removeNullUnionBranch = (definition) => {
@@ -1251,7 +1251,7 @@ async function projectModules(tree, root) {
1251
1251
  });
1252
1252
  return errors.length > 0 ? { _tag: "Left", left: errors } : { _tag: "Right", right: found };
1253
1253
  }
1254
- var NO_PROJECT_MESSAGE = "no project here: run from a project or playlist folder, or pass it (for example: aula web examples)";
1254
+ var NO_PROJECT_MESSAGE = "no project here: pass a project or playlist folder (for example: aula web . or aula web examples)";
1255
1255
  async function bundleProjects(bundler, tree, root, projects) {
1256
1256
  if (projects.length === 0) {
1257
1257
  throw new Error(NO_PROJECT_MESSAGE);
@@ -1313,6 +1313,7 @@ export {
1313
1313
  bundle,
1314
1314
  projectName,
1315
1315
  projectModules,
1316
+ NO_PROJECT_MESSAGE,
1316
1317
  bundleProjects,
1317
1318
  bundleWorkspace,
1318
1319
  error,
@@ -0,0 +1,111 @@
1
+ import {
2
+ createNodeBundler,
3
+ nodeTree
4
+ } from "./chunk-THQ5Y74K.js";
5
+ import {
6
+ draftSkipMessage,
7
+ listedProjects,
8
+ loadBuiltProjects,
9
+ workspaceHost
10
+ } from "./chunk-THZNJBUF.js";
11
+ import {
12
+ NO_PROJECT_MESSAGE,
13
+ Problems,
14
+ bundleProjects,
15
+ bundleWorkspace,
16
+ wrongArgument
17
+ } from "./chunk-WV2UYZND.js";
18
+ import {
19
+ v8Frames
20
+ } from "./chunk-F5RPEFZR.js";
21
+
22
+ // src/workspace-load.ts
23
+ import { existsSync } from "node:fs";
24
+ import os from "node:os";
25
+ import path from "node:path";
26
+ import { fileURLToPath, pathToFileURL } from "node:url";
27
+ var METHOD_STUB = "export const paragraph = () => () => ({});\n";
28
+ async function loadWorkspaceProjects(capabilities, workspaceBundle) {
29
+ const scratch = await capabilities.fs.mkdtemp(path.join(os.tmpdir(), "aula-workspace-"));
30
+ let count = 0;
31
+ try {
32
+ const method = path.join(scratch, "aula-method.mjs");
33
+ await capabilities.fs.writeFile(method, METHOD_STUB);
34
+ const bundledAula = path.join(path.dirname(fileURLToPath(import.meta.url)), "aula.js");
35
+ const player = {
36
+ "@beff/aula": existsSync(bundledAula) ? pathToFileURL(bundledAula).href : import.meta.resolve("@beff/aula"),
37
+ "@beff/aula-method": pathToFileURL(method).href
38
+ };
39
+ const modules = {
40
+ load: async ({ code }) => {
41
+ count += 1;
42
+ const file = path.join(scratch, `bundle-${String(count)}.mjs`);
43
+ await capabilities.fs.writeFile(file, code);
44
+ const url = pathToFileURL(file).href;
45
+ return { url, exports: await import(url) };
46
+ }
47
+ };
48
+ const loaded = await loadBuiltProjects(workspaceBundle, workspaceHost(v8Frames), modules, player);
49
+ if (loaded._tag === "Left") throw new Problems(loaded.left);
50
+ return loaded.right;
51
+ } finally {
52
+ await capabilities.fs.rm(scratch, { recursive: true, force: true });
53
+ }
54
+ }
55
+ function projectFolderLabel(root, project) {
56
+ return project.folder === "" ? path.basename(root) : project.folder;
57
+ }
58
+ async function resolveRootProjects(capabilities, root, includeDrafts) {
59
+ const tree = nodeTree(capabilities, root);
60
+ const name = path.basename(root);
61
+ const bundler = createNodeBundler();
62
+ try {
63
+ const bundled = await bundleWorkspace(bundler, tree, name);
64
+ if (bundled._tag === "Left") throw new Problems(bundled.left);
65
+ let bundle = bundled.right.bundle;
66
+ const inputs = bundled.right.inputs;
67
+ const loaded = await loadWorkspaceProjects(capabilities, bundle);
68
+ if (loaded.length === 0) throw new Error(NO_PROJECT_MESSAGE);
69
+ const projects = listedProjects(loaded, { includeDrafts });
70
+ for (const project of loaded) {
71
+ if (project.draft && !includeDrafts) {
72
+ capabilities.log.out(draftSkipMessage(projectFolderLabel(root, project)));
73
+ }
74
+ }
75
+ if (projects.length !== loaded.length) {
76
+ const keep = new Set(projects.map((project) => project.name));
77
+ const filtered = bundle.projects.filter((project) => keep.has(project.name));
78
+ if (filtered.length > 0) {
79
+ const rebundled = await bundleProjects(bundler, tree, name, filtered);
80
+ if (rebundled._tag === "Left") throw new Problems(rebundled.left);
81
+ bundle = rebundled.right.bundle;
82
+ } else {
83
+ bundle = { ...bundle, projects: [], code: "export default [];\n", map: "{}" };
84
+ }
85
+ }
86
+ if (includeDrafts) bundle = { ...bundle, includeDrafts: true };
87
+ return { loaded, projects, bundle, inputs };
88
+ } finally {
89
+ await bundler.stop();
90
+ }
91
+ }
92
+ function projectFolderOf(root, project) {
93
+ return project.folder === "" ? root : path.join(root, project.folder);
94
+ }
95
+ async function resolveOneProject(capabilities, root, includeDrafts, command) {
96
+ const { projects } = await resolveRootProjects(capabilities, root, includeDrafts);
97
+ if (projects.length === 1) {
98
+ const project = projects[0];
99
+ if (project === void 0) throw new Error("resolveOneProject: missing project");
100
+ return { folder: projectFolderOf(root, project), project };
101
+ }
102
+ throw wrongArgument(
103
+ `aula ${command} needs exactly one project after filtering`,
104
+ projects.length === 0 ? "pass a project folder, or pass --include-drafts when the project is a draft" : "pass a project folder, not a playlist folder with more than one project"
105
+ );
106
+ }
107
+
108
+ export {
109
+ resolveRootProjects,
110
+ resolveOneProject
111
+ };
package/dist/src/cli.js CHANGED
@@ -14,8 +14,8 @@ import {
14
14
  studentWeightFile,
15
15
  timeAulaVoice,
16
16
  tokenBatches
17
- } from "./chunk-TDAWUJ2L.js";
18
- import "./chunk-DN2LVJO3.js";
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 path3 from "node:path";
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 path2 from "node:path";
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 = path2.dirname(destination);
118
+ const folder = path.dirname(destination);
187
119
  await capabilities2.fs.mkdir(folder, { recursive: true });
188
- const work = await capabilities2.fs.mkdtemp(path2.join(folder, `.${path2.basename(destination)}.`));
120
+ const work = await capabilities2.fs.mkdtemp(path.join(folder, `.${path.basename(destination)}.`));
189
121
  try {
190
- const staged = path2.join(work, path2.basename(destination));
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(path2.basename(destination));
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) => path2.join(models2, "aula-voice", AULA_VOICE_RELEASE);
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 = path2.join(folder, AULA_VOICE_WEIGHTS.path);
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, path2.join(folder, file.path), aulaVoiceUrl(file), file.sha256);
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-YOS4IQXV.js");
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-CGKCPETU.js");
288
- var { host, loadProject } = await import("./project-EUFMRQXR.js");
289
- var { USAGE, folderArgs, isHelp, optionsOf, parse, run: run2, siteOptions, webOptions } = await import("./run-ER27SVTA.js");
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 = path3.join(os.homedir(), ".cache/aula/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) throw new Error(USAGE);
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-TJTMSDO2.js");
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-RGPJOWSU.js");
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-BSDNHYB3.js");
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 only = command === "preview" ? after.slice(1) : command === "check" || command === "timeline" || command === "script" ? after : [];
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-HD6FTA3H.js";
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-PZXFW6ZD.js";
15
- import "./chunk-AXQBWV7J.js";
16
- import "./chunk-4QGX7XXO.js";
17
- import "./chunk-TDAWUJ2L.js";
18
- import "./chunk-DC7A435Z.js";
19
- import "./chunk-2PAZTBSE.js";
20
- import "./chunk-T6CAPT32.js";
21
- import "./chunk-RAGZAJKD.js";
22
- import "./chunk-DN2LVJO3.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
+ };