@beff/aula-cli 0.0.1 → 0.1.1

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 (38) hide show
  1. package/README.md +11 -1
  2. package/dist/licenses/aula-g2p-NOTICE.txt +13 -0
  3. package/dist/licenses/espeak-ng-COPYING.txt +674 -0
  4. package/dist/licenses/fonts-OFL-JetBrainsMono.txt +93 -0
  5. package/dist/licenses/fonts-OFL-NunitoSans.txt +93 -0
  6. package/dist/src/aula-render.core.wasm +0 -0
  7. package/dist/src/aula-voice-tts-ZXQ7XXHJ.js +14 -0
  8. package/dist/src/chunk-2XGNOG2U.js +28 -0
  9. package/dist/src/chunk-46KT47TH.js +21 -0
  10. package/dist/src/chunk-7KT36JRP.js +1282 -0
  11. package/dist/src/chunk-GFCJYE75.js +42 -0
  12. package/dist/src/chunk-IAQZ6DTC.js +271 -0
  13. package/dist/src/chunk-QWNBVWUQ.js +1105 -0
  14. package/dist/src/chunk-XUBCUJW5.js +104 -0
  15. package/dist/src/chunk-YX73KJQ6.js +577 -0
  16. package/dist/src/cli.js +334 -0
  17. package/dist/src/commands-M246OWYJ.js +27 -0
  18. package/dist/src/problems-Y67BY7WB.js +12 -0
  19. package/dist/src/project-NWT5MDQI.js +11 -0
  20. package/dist/src/render-child.js +3771 -0
  21. package/dist/src/run-CTVGU7EK.js +127 -0
  22. package/dist/src/server-5OGXX6BF.js +220 -0
  23. package/dist/web/app/assets/__vite-browser-external-BN30sEqc.js +1 -0
  24. package/dist/web/app/assets/__vite-browser-external-BtQTJ51O.js +1 -0
  25. package/dist/web/app/assets/aula-method.js +1 -0
  26. package/dist/web/app/assets/aula-voice-worker-DymX5vwM.js +52 -0
  27. package/dist/web/app/assets/aula.core-BtiPQSZi.wasm +0 -0
  28. package/dist/web/app/assets/aula.core5-YhDIb7Me.wasm +0 -0
  29. package/dist/web/app/assets/aula.js +1 -0
  30. package/dist/web/app/assets/build-worker.js +696 -0
  31. package/dist/web/app/assets/esbuild-BaXVPFT2.wasm +0 -0
  32. package/dist/web/app/assets/index-B8_aMtuI.js +53 -0
  33. package/dist/web/app/assets/index-cL-Dm_aw.css +2 -0
  34. package/dist/web/app/assets/protocol-CnlzsyRt.js +15 -0
  35. package/dist/web/app/assets/rolldown-runtime-BLXQ4ufn.js +1 -0
  36. package/dist/web/app/assets/src-CmWmmzpF.js +25 -0
  37. package/dist/web/app/index.html +15 -0
  38. package/package.json +27 -5
@@ -0,0 +1,127 @@
1
+ import {
2
+ bundle,
3
+ check,
4
+ exportVideo,
5
+ preview,
6
+ script,
7
+ timeline
8
+ } from "./chunk-QWNBVWUQ.js";
9
+ import "./chunk-GFCJYE75.js";
10
+ import "./chunk-2XGNOG2U.js";
11
+ import "./chunk-IAQZ6DTC.js";
12
+ import "./chunk-XUBCUJW5.js";
13
+ import "./chunk-YX73KJQ6.js";
14
+ import "./chunk-46KT47TH.js";
15
+ import {
16
+ wrongArgument
17
+ } from "./chunk-7KT36JRP.js";
18
+
19
+ // src/run.ts
20
+ import path from "node:path";
21
+ var USAGE = `aula: storyboard-first narrated aula videos.
22
+
23
+ <folder> is a project folder: it has index.ts, which exports
24
+ defineProject({ title, theme, chapters }). <chapter> is a chapter name such as
25
+ 01-double-the-side (its number and the slug of its heading), or title (the
26
+ title card). Each chapter module holds its script, storyboard notes and
27
+ animations; messages name its lines (file:line:col).
28
+
29
+ aula check <folder> [<chapter> ...]
30
+ every check, with no narration and no frames
31
+ aula preview <folder> <out> [<chapter>[:<line>] ...]
32
+ PNG pictures for review: per chapter, stills,
33
+ motion stills, contact sheets and moves.md
34
+ aula export <folder> <file.mp4> the video to send: narrated in this run, H.264 and
35
+ AAC at 1280x720 and 30 fps; needs ffmpeg
36
+ aula web [<folder>] [--port N] the web app for the folder if it has index.ts, else
37
+ for each subfolder with index.ts, in the order of
38
+ the folder names (default: the current folder);
39
+ the page narrates in the browser
40
+ aula bundle <folder> <file.zip> the project zip: the project folder, and the
41
+ packages it imports, to share or host
42
+ aula script <folder> print the narration text with lines
43
+ aula timeline <folder> [<chapter> ...]
44
+ print each say and move with its line, second
45
+ and note
46
+ aula tokens Kokoro v1.0's token ids of texts, for training
47
+ data: reads JSON lines {"id"?, "text"} on
48
+ stdin, writes {"id"?, "batches": [{"phonemes",
49
+ "ids"}]} on stdout, one batch per model run
50
+
51
+ Errors make the exit code 1. Warnings do not change it.`;
52
+ var VALUED = {
53
+ "--port": "a port number"
54
+ };
55
+ function parse(argv, allowed) {
56
+ const args = { positional: [], values: /* @__PURE__ */ new Map() };
57
+ for (let i = 0; i < argv.length; i++) {
58
+ const arg = argv[i] ?? "";
59
+ const what = VALUED[arg];
60
+ if (what !== void 0 && allowed.includes(arg)) {
61
+ i += 1;
62
+ const value = argv[i];
63
+ if (value === void 0) throw wrongArgument(`${arg} needs ${what}`);
64
+ if (!/^[0-9]+$/.test(value)) throw wrongArgument(`${arg} ${value} is not a number`);
65
+ args.values.set(arg, Number(value));
66
+ } else if (arg.startsWith("--")) {
67
+ throw wrongArgument(`unknown option ${arg}`, "run `aula help` for the options of each command");
68
+ } else {
69
+ args.positional.push(arg);
70
+ }
71
+ }
72
+ return args;
73
+ }
74
+ var OPTIONS = {
75
+ web: ["--port"]
76
+ };
77
+ var isHelp = (command) => command === void 0 || command === "help" || command === "-h" || command === "--help";
78
+ var ARITY = {
79
+ check: [0, Infinity],
80
+ preview: [1, Infinity],
81
+ export: [1, 1],
82
+ bundle: [1, 1],
83
+ script: [0, 0],
84
+ timeline: [0, Infinity]
85
+ };
86
+ function folderArgs(cwd, command, args) {
87
+ const arity = ARITY[command];
88
+ if (arity === void 0) throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
89
+ const [folder, ...rest] = args.positional;
90
+ if (folder === void 0) throw wrongArgument("missing <folder>: the project folder, which has index.ts");
91
+ if (rest.length < arity[0] || rest.length > arity[1])
92
+ throw wrongArgument("wrong number of arguments", "run `aula help` for the usage");
93
+ return { folder: path.resolve(cwd, folder), rest };
94
+ }
95
+ async function run(capabilities, cwd, command, project, rest) {
96
+ const [first = "", ...more] = rest;
97
+ switch (command) {
98
+ case "check":
99
+ return check(capabilities, cwd, project, rest);
100
+ case "preview":
101
+ return preview(capabilities, cwd, project, path.resolve(cwd, first), more);
102
+ case "export":
103
+ return exportVideo(capabilities, cwd, project, path.resolve(cwd, first));
104
+ case "bundle":
105
+ return bundle(capabilities, project, path.resolve(cwd, first));
106
+ case "script":
107
+ return script(capabilities, cwd, project);
108
+ case "timeline":
109
+ return timeline(capabilities, cwd, project, rest);
110
+ default:
111
+ throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
112
+ }
113
+ }
114
+ function webOptions(cwd, args) {
115
+ if (args.positional.length > 1) throw wrongArgument("aula web takes one folder", "run `aula help` for the usage");
116
+ return { root: path.resolve(cwd, args.positional[0] ?? "."), port: args.values.get("--port") ?? 0 };
117
+ }
118
+ var optionsOf = (command) => OPTIONS[command] ?? [];
119
+ export {
120
+ USAGE,
121
+ folderArgs,
122
+ isHelp,
123
+ optionsOf,
124
+ parse,
125
+ run,
126
+ webOptions
127
+ };
@@ -0,0 +1,220 @@
1
+ import "./chunk-XUBCUJW5.js";
2
+ import {
3
+ SERVER_WEIGHTS_PATH
4
+ } from "./chunk-YX73KJQ6.js";
5
+ import {
6
+ exists
7
+ } from "./chunk-46KT47TH.js";
8
+ import "./chunk-7KT36JRP.js";
9
+
10
+ // src/web/server.ts
11
+ import { once } from "node:events";
12
+ import { createServer } from "node:http";
13
+ import { basename, dirname, join } from "node:path";
14
+ import { AulaError } from "@beff/aula/errors";
15
+
16
+ // src/package.ts
17
+ var PACKAGE = new URL("../", import.meta.url);
18
+
19
+ // src/web/page.ts
20
+ import { fault } from "@beff/aula/errors";
21
+ var APP = new URL("web/app/", PACKAGE);
22
+ var KINDS = /* @__PURE__ */ new Map([
23
+ [".html", "text/html; charset=utf-8"],
24
+ [".js", "text/javascript"],
25
+ [".css", "text/css"],
26
+ [".svg", "image/svg+xml"],
27
+ [".wasm", "application/wasm"],
28
+ [".json", "application/json"]
29
+ ]);
30
+ var plain = (name) => name !== "" && !/[/\\]/.test(name) && !name.startsWith(".");
31
+ async function asset(capabilities, path) {
32
+ const read = async (file) => {
33
+ const url = new URL(file, APP);
34
+ return exists(capabilities, url) ? capabilities.fs.readFile(url) : null;
35
+ };
36
+ if (path === "/") {
37
+ const body2 = await read("index.html");
38
+ if (!body2) fault("the web player is not built", "run `pnpm --filter aula-web-node build`");
39
+ return { body: body2, kind: "text/html; charset=utf-8" };
40
+ }
41
+ if (!path.startsWith("/assets/")) return null;
42
+ const name = path.slice("/assets/".length);
43
+ const kind = KINDS.get(name.slice(name.lastIndexOf(".")));
44
+ if (!plain(name) || kind === void 0) return null;
45
+ const body = await read(`assets/${name}`);
46
+ return body ? { body, kind } : null;
47
+ }
48
+
49
+ // src/web/reload.ts
50
+ var QUIET = 0.1;
51
+ function watcher(capabilities, reload) {
52
+ let quiet = null;
53
+ const watched = /* @__PURE__ */ new Map();
54
+ const changed = () => {
55
+ const signal = capabilities.clock.timeout(QUIET);
56
+ quiet = signal;
57
+ signal.addEventListener(
58
+ "abort",
59
+ () => {
60
+ if (quiet !== signal) return;
61
+ quiet = null;
62
+ reload();
63
+ },
64
+ { once: true }
65
+ );
66
+ };
67
+ return {
68
+ follow: (folders) => {
69
+ for (const [folder, handle] of watched) {
70
+ if (folders.includes(folder)) continue;
71
+ handle.close();
72
+ watched.delete(folder);
73
+ }
74
+ for (const folder of folders) {
75
+ if (!watched.has(folder)) watched.set(folder, capabilities.watch(folder, changed));
76
+ }
77
+ },
78
+ close: () => {
79
+ for (const handle of watched.values()) handle.close();
80
+ watched.clear();
81
+ }
82
+ };
83
+ }
84
+
85
+ // src/web/server.ts
86
+ function changes(capabilities) {
87
+ const streams = /* @__PURE__ */ new Set();
88
+ const folders = /* @__PURE__ */ new Set();
89
+ const files = watcher(capabilities, () => {
90
+ for (const response of streams) response.write("data: changed\n\n");
91
+ });
92
+ return {
93
+ served: (file) => {
94
+ const folder = dirname(file);
95
+ if (folders.has(folder)) return;
96
+ folders.add(folder);
97
+ files.follow([...folders]);
98
+ },
99
+ stream: (response) => {
100
+ response.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-cache" });
101
+ response.write(": watching\n\n");
102
+ streams.add(response);
103
+ response.on("close", () => streams.delete(response));
104
+ },
105
+ close: () => {
106
+ files.close();
107
+ for (const response of streams) response.end();
108
+ streams.clear();
109
+ }
110
+ };
111
+ }
112
+ function shared(load) {
113
+ let running;
114
+ return () => {
115
+ running ??= load().finally(() => {
116
+ running = void 0;
117
+ });
118
+ return running;
119
+ };
120
+ }
121
+ async function serve(capabilities, options) {
122
+ const watching = changes(capabilities);
123
+ const weights = shared(capabilities.weights);
124
+ const server = createServer((request, response) => {
125
+ answer(capabilities, options.root, watching, weights, request, response).catch((error) => {
126
+ const fix = error instanceof AulaError && error.hint !== void 0 ? `: ${error.hint}` : "";
127
+ const message = `${error instanceof Error ? error.message : String(error)}${fix}`;
128
+ capabilities.log.err(`aula web: ${request.url ?? ""}: ${message}`);
129
+ if (!response.headersSent) send(request, response, `${message}
130
+ `, "text/plain", 500);
131
+ else response.destroy();
132
+ });
133
+ });
134
+ server.listen(options.port, "127.0.0.1");
135
+ await once(server, "listening");
136
+ const address = server.address();
137
+ const port = typeof address === "object" && address !== null ? address.port : options.port;
138
+ capabilities.log.out(`aula web: open http://127.0.0.1:${String(port)}/ in a browser (Ctrl-C stops it)`);
139
+ options.stop.addEventListener("abort", () => {
140
+ watching.close();
141
+ server.close();
142
+ server.closeAllConnections();
143
+ });
144
+ await once(server, "close");
145
+ }
146
+ function send(request, response, body, kind, status) {
147
+ const data = typeof body === "string" ? Buffer.from(body) : body;
148
+ response.writeHead(status, {
149
+ "Content-Type": kind,
150
+ "Cache-Control": "no-cache",
151
+ "Content-Length": data.length
152
+ });
153
+ if (request.method === "HEAD") response.end();
154
+ else response.end(data);
155
+ }
156
+ var notFound = (request, response) => {
157
+ send(request, response, "Not found\n", "text/plain", 404);
158
+ };
159
+ function pathParts(path) {
160
+ const parts = decodeURIComponent(path).split("/");
161
+ return parts.every((part) => part !== "" && !part.startsWith(".") && !part.includes("\\")) ? parts : null;
162
+ }
163
+ async function folderFile(capabilities, root, path, request, response, served) {
164
+ const folder = path.startsWith("/folders/") || path === "/folders";
165
+ if (!folder && !path.startsWith("/files/")) return false;
166
+ const rest = path.replace(/^\/(files|folders)\/?/, "");
167
+ const parts = rest === "" && folder ? [] : pathParts(rest);
168
+ if (parts === null) {
169
+ notFound(request, response);
170
+ return true;
171
+ }
172
+ const target = join(root, ...parts);
173
+ if (!exists(capabilities, target)) {
174
+ notFound(request, response);
175
+ return true;
176
+ }
177
+ if (folder) {
178
+ const entries = await capabilities.fs.readdir(target, { withFileTypes: true });
179
+ const names = entries.filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith(".")).map((e) => e.name);
180
+ send(request, response, JSON.stringify(names.toSorted()), "application/json", 200);
181
+ return true;
182
+ }
183
+ const data = await capabilities.fs.readFile(target);
184
+ served(target);
185
+ send(request, response, data, "text/plain; charset=utf-8", 200);
186
+ return true;
187
+ }
188
+ async function answer(capabilities, root, watching, weights, request, response) {
189
+ const path = new URL(request.url ?? "/", "http://localhost").pathname;
190
+ if (request.method !== "GET" && request.method !== "HEAD") {
191
+ notFound(request, response);
192
+ return;
193
+ }
194
+ if (path === "/changes") {
195
+ watching.stream(response);
196
+ return;
197
+ }
198
+ if (path === SERVER_WEIGHTS_PATH) {
199
+ send(request, response, await weights(), "application/octet-stream", 200);
200
+ return;
201
+ }
202
+ if (path === "/name") {
203
+ send(request, response, basename(root), "text/plain; charset=utf-8", 200);
204
+ return;
205
+ }
206
+ const file = await asset(capabilities, path);
207
+ if (file) {
208
+ send(request, response, file.body, file.kind, 200);
209
+ return;
210
+ }
211
+ const served = (target) => {
212
+ watching.served(target);
213
+ };
214
+ if (await folderFile(capabilities, root, path, request, response, served)) return;
215
+ notFound(request, response);
216
+ }
217
+ export {
218
+ pathParts,
219
+ serve
220
+ };
@@ -0,0 +1 @@
1
+ import{t as e}from"./aula-voice-worker-DymX5vwM.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
@@ -0,0 +1 @@
1
+ import{t as e}from"./rolldown-runtime-BLXQ4ufn.js";var t=e(((e,t)=>{t.exports={}}));export default t();
@@ -0,0 +1 @@
1
+ import{l as e,p as t}from"./src-CmWmmzpF.js";var n=8,r=.5,i=3,a=3,o=[`view`,`claim`,`forecast`,`estimate`,`proposed`,`external`,`schematic`,`not measured`,`expected`,`alleged`],s=1,c=e=>JSON.stringify(e);function l(e){return e.toLowerCase().match(/[a-z0-9$%]+/g)??[]}function u(e){return!/\s/.test(e)&&!e.includes(`://`)&&/[/.]/.test(e)}function d(e,t){let n=l(e),r=` ${l(t).join(` `)} `;for(let e=0;e+a<=n.length;e++)if(r.includes(` ${n.slice(e,e+a).join(` `)} `))return!0;return!1}function f(e){let t=e.toLowerCase();return o.some(e=>t.includes(e))||/(^|[^\p{L}\p{N}_])\p{Lu}[\p{L}\p{N}_.&-]*['’]s(?![\p{L}\p{N}_])/u.test(e)}function p(e,t){let n=Math.max(e.low[0]-t.high[0],t.low[0]-e.high[0],0),r=Math.max(e.low[1]-t.high[1],t.low[1]-e.high[1],0);return Math.hypot(n,r)<=s}function m(e,t,a){let o=[],s=(t,n=e.place)=>{o.push({message:t,...n===void 0?{}:{at:n}})};a.mechanism.trim()===``&&s(`the paragraph has no mechanism: name the one mechanism that the viewer must understand`),a.sources.length===0&&s(`the paragraph has no sources (give its sources, or ["recap"])`);for(let e of a.sources)u(e)&&!t.exists(e)&&s(`${c(e)}: this path is not a file: correct the path or add the file`);let l=t.paragraphs.flatMap(e=>e.says.map(e=>e.text)).join(` `),m=new Map;for(let t of e.screen.instants)for(let e of t.texts)m.set(JSON.stringify([e.place,e.text]),e);for(let e of m.values())e.text.split(/\s+/).filter(Boolean).length>i&&s(`text on screen over ${String(i)} words: ${c(e.text)}; make it shorter`,e.place),d(e.text,l)&&s(`text on screen repeats the narration: ${c(e.text)}; use other words`,e.place);let h=new Map;for(let t of e.screen.instants){let e=new Set(t.texts.filter(e=>e.opacity>r).map(e=>e.id)).size,i=JSON.stringify(t.place);e>(h.get(i)?.count??n)&&h.set(i,{count:e,at:t.place})}for(let{count:e,at:t}of h.values())s(`${String(e)} labels on screen (about ${String(n)} at most): show fewer labels at one time, or split the picture`,t);let g=new Map,_=new Set;for(let t of e.screen.instants)for(let e of t.dashed)t.texts.some(t=>f(t.text)&&p(t,e))?_.add(e.id):g.set(e.id,e);for(let[e,t]of g)_.has(e)||s(`dashed shape with no attribution text near it: put a text that says whose view it is, such as "Smith's view", next to it`,t.place);return t.number===t.count&&e.index===t.paragraphs.length-1&&(a.sources.length!==1||a.sources[0]!==`recap`)&&s(`the video must end with a recap paragraph (sources: ["recap"])`),o}function h(n){let r=t(`paragraph`,n);return({sources:t},n)=>e({mechanism:r,sources:t},n??((e,n)=>m(e,n,{mechanism:r,sources:t})))}export{m as findings,h as paragraph};