@beff/aula-cli 0.1.0 → 0.2.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 (34) hide show
  1. package/README.md +2 -2
  2. package/dist/src/aula-render.core.wasm +0 -0
  3. package/dist/src/{chunk-3IBMAZRS.js → chunk-46KT47TH.js} +1 -1
  4. package/dist/src/{chunk-SDFXIMLW.js → chunk-7KT36JRP.js} +312 -113
  5. package/dist/src/chunk-BMP6H3SZ.js +104 -0
  6. package/dist/src/{chunk-OMBYV6CK.js → chunk-D2BDOCX7.js} +56 -14
  7. package/dist/src/{chunk-UREQAEFC.js → chunk-PSI7MMGP.js} +9 -226
  8. package/dist/src/{chunk-EYXQ2I7K.js → chunk-SW5BNPAM.js} +10 -36
  9. package/dist/src/cli.js +81 -16
  10. package/dist/src/{commands-VDGWDVWT.js → commands-CEBO6WWE.js} +6 -7
  11. package/dist/src/problems-FFAR72WZ.js +12 -0
  12. package/dist/src/{project-M63R4ENB.js → project-NWT5MDQI.js} +2 -2
  13. package/dist/src/{run-CY72QGZJ.js → run-DU2H6FZI.js} +10 -10
  14. package/dist/src/{server-ZG6K7Z7H.js → server-7AN6XCTF.js} +6 -66
  15. package/dist/web/app/assets/__vite-browser-external-B6HdzU1j.js +1 -0
  16. package/dist/web/app/assets/aula-method.js +1 -1
  17. package/dist/web/app/assets/{aula-voice-worker-BL6WcrSe.js → aula-voice-worker-DNzLI-en.js} +10 -10
  18. package/dist/web/app/assets/{aula.core5-BdGB-M10.wasm → aula.core5-BmrvjVro.wasm} +0 -0
  19. package/dist/web/app/assets/aula.js +1 -1
  20. package/dist/web/app/assets/build-worker.js +8 -9
  21. package/dist/web/app/assets/index-D6yaOVRx.js +53 -0
  22. package/dist/web/app/assets/index-cL-Dm_aw.css +2 -0
  23. package/dist/web/app/assets/protocol-CDkth-6D.js +15 -0
  24. package/dist/web/app/assets/{src-BbJ5r410.js → src-B22P60S6.js} +6 -6
  25. package/dist/web/app/index.html +4 -4
  26. package/package.json +2 -2
  27. package/dist/src/chunk-KLE5UOUB.js +0 -57
  28. package/dist/src/chunk-PYRORQA5.js +0 -88
  29. package/dist/src/chunk-X3HJY34X.js +0 -81
  30. package/dist/src/problems-OGUR4BLZ.js +0 -12
  31. package/dist/web/app/assets/__vite-browser-external-Bbi05A7N.js +0 -1
  32. package/dist/web/app/assets/index-BVQqteYG.js +0 -53
  33. package/dist/web/app/assets/index-CS60sOpp.css +0 -2
  34. package/dist/web/app/assets/protocol-Ds4jI5bY.js +0 -15
@@ -2,8 +2,8 @@ import {
2
2
  exists,
3
3
  host,
4
4
  loadProject
5
- } from "./chunk-3IBMAZRS.js";
6
- import "./chunk-PYRORQA5.js";
5
+ } from "./chunk-46KT47TH.js";
6
+ import "./chunk-7KT36JRP.js";
7
7
  export {
8
8
  exists,
9
9
  host,
@@ -5,17 +5,16 @@ import {
5
5
  preview,
6
6
  script,
7
7
  timeline
8
- } from "./chunk-OMBYV6CK.js";
8
+ } from "./chunk-D2BDOCX7.js";
9
9
  import "./chunk-GFCJYE75.js";
10
10
  import "./chunk-2XGNOG2U.js";
11
- import "./chunk-UREQAEFC.js";
12
- import "./chunk-KLE5UOUB.js";
13
- import "./chunk-SDFXIMLW.js";
14
- import "./chunk-EYXQ2I7K.js";
15
- import "./chunk-3IBMAZRS.js";
11
+ import "./chunk-PSI7MMGP.js";
12
+ import "./chunk-BMP6H3SZ.js";
13
+ import "./chunk-SW5BNPAM.js";
14
+ import "./chunk-46KT47TH.js";
16
15
  import {
17
16
  wrongArgument
18
- } from "./chunk-PYRORQA5.js";
17
+ } from "./chunk-7KT36JRP.js";
19
18
 
20
19
  // src/run.ts
21
20
  import path from "node:path";
@@ -34,9 +33,10 @@ aula preview <folder> <out> [<chapter>[:<line>] ...]
34
33
  motion stills, contact sheets and moves.md
35
34
  aula export <folder> <file.mp4> the video to send: narrated in this run, H.264 and
36
35
  AAC at 1280x720 and 30 fps; needs ffmpeg
37
- aula web [<folder>] [--port N] the web app for each subfolder with index.ts, and the
38
- folder itself if it has one (default: the current
39
- folder); also the narration API (POST /speak)
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
40
  aula bundle <folder> <file.zip> the project zip: the project folder, and the
41
41
  packages it imports, to share or host
42
42
  aula script <folder> print the narration text with lines
@@ -1,18 +1,11 @@
1
- import {
2
- speakAnswer,
3
- timeAnswer
4
- } from "./chunk-X3HJY34X.js";
5
- import {
6
- Parsers
7
- } from "./chunk-KLE5UOUB.js";
8
- import "./chunk-SDFXIMLW.js";
1
+ import "./chunk-BMP6H3SZ.js";
9
2
  import {
10
3
  SERVER_WEIGHTS_PATH
11
- } from "./chunk-EYXQ2I7K.js";
4
+ } from "./chunk-SW5BNPAM.js";
12
5
  import {
13
6
  exists
14
- } from "./chunk-3IBMAZRS.js";
15
- import "./chunk-PYRORQA5.js";
7
+ } from "./chunk-46KT47TH.js";
8
+ import "./chunk-7KT36JRP.js";
16
9
 
17
10
  // src/web/server.ts
18
11
  import { once } from "node:events";
@@ -125,13 +118,11 @@ function shared(load) {
125
118
  return running;
126
119
  };
127
120
  }
128
- var MAX_BODY = 1 << 20;
129
121
  async function serve(capabilities, options) {
130
- const narration = narrator(capabilities);
131
122
  const watching = changes(capabilities);
132
123
  const weights = shared(capabilities.weights);
133
124
  const server = createServer((request, response) => {
134
- answer(capabilities, options.root, narration, watching, weights, request, response).catch((error) => {
125
+ answer(capabilities, options.root, watching, weights, request, response).catch((error) => {
135
126
  const fix = error instanceof AulaError && error.hint !== void 0 ? `: ${error.hint}` : "";
136
127
  const message = `${error instanceof Error ? error.message : String(error)}${fix}`;
137
128
  capabilities.log.err(`aula web: ${request.url ?? ""}: ${message}`);
@@ -152,31 +143,6 @@ async function serve(capabilities, options) {
152
143
  });
153
144
  await once(server, "close");
154
145
  }
155
- function narrator(capabilities) {
156
- let turn = Promise.resolve();
157
- const speak = async (text, speed) => {
158
- const release = await capabilities.locks.heavy();
159
- try {
160
- return speakAnswer(await capabilities.narrator.speak(text, speed));
161
- } finally {
162
- await release();
163
- }
164
- };
165
- return {
166
- time: async (text, speed) => timeAnswer(await capabilities.narrator.time(text, speed)),
167
- speak: async (text, speed) => {
168
- const before = turn;
169
- const { promise, resolve: done } = Promise.withResolvers();
170
- turn = promise;
171
- await before;
172
- try {
173
- return await speak(text, speed);
174
- } finally {
175
- done();
176
- }
177
- }
178
- };
179
- }
180
146
  function send(request, response, body, kind, status) {
181
147
  const data = typeof body === "string" ? Buffer.from(body) : body;
182
148
  response.writeHead(status, {
@@ -194,17 +160,6 @@ function pathParts(path) {
194
160
  const parts = decodeURIComponent(path).split("/");
195
161
  return parts.every((part) => part !== "" && !part.startsWith(".") && !part.includes("\\")) ? parts : null;
196
162
  }
197
- async function readBody(request) {
198
- const chunks = [];
199
- let size = 0;
200
- for await (const chunk of request) {
201
- const piece = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
202
- size += piece.length;
203
- if (size > MAX_BODY) throw new Error("the request is too large");
204
- chunks.push(piece);
205
- }
206
- return Buffer.concat(chunks).toString("utf8");
207
- }
208
163
  async function folderFile(capabilities, root, path, request, response, served) {
209
164
  const folder = path.startsWith("/folders/") || path === "/folders";
210
165
  if (!folder && !path.startsWith("/files/")) return false;
@@ -230,23 +185,8 @@ async function folderFile(capabilities, root, path, request, response, served) {
230
185
  send(request, response, data, "text/plain; charset=utf-8", 200);
231
186
  return true;
232
187
  }
233
- async function answer(capabilities, root, narration, watching, weights, request, response) {
188
+ async function answer(capabilities, root, watching, weights, request, response) {
234
189
  const path = new URL(request.url ?? "/", "http://localhost").pathname;
235
- if (path === "/speak" || path === "/time") {
236
- if (request.method !== "POST") {
237
- send(request, response, "Use POST\n", "text/plain", 405);
238
- return;
239
- }
240
- const parsed = Parsers.SpeakRequest.safeParse(JSON.parse(await readBody(request)));
241
- if (!parsed.success) {
242
- send(request, response, 'The body must be {"text": <text>, "speed": <number>}\n', "text/plain", 400);
243
- return;
244
- }
245
- const { text, speed } = parsed.data;
246
- const answered = path === "/speak" ? await narration.speak(text, speed) : await narration.time(text, speed);
247
- send(request, response, JSON.stringify(answered), "application/json", 200);
248
- return;
249
- }
250
190
  if (request.method !== "GET" && request.method !== "HEAD") {
251
191
  notFound(request, response);
252
192
  return;
@@ -0,0 +1 @@
1
+ import{t as e}from"./aula-voice-worker-DNzLI-en.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
@@ -1 +1 @@
1
- import{l as e,p as t}from"./src-BbJ5r410.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};
1
+ import{d as e,g as t}from"./src-B22P60S6.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};