@beff/aula-cli 0.12.0 → 0.13.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 (65) hide show
  1. package/README.md +6 -1
  2. package/dist/src/aula-render.core.wasm +0 -0
  3. package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-FEFKNA2I.js} +1 -1
  4. package/dist/src/aula.js +2 -2
  5. package/dist/src/{chunk-DC7A435Z.js → chunk-2BEUK7M7.js} +1 -1
  6. package/dist/src/{chunk-2PAZTBSE.js → chunk-2VD3JPLV.js} +3 -5
  7. package/dist/src/chunk-4N5SDSCV.js +63 -0
  8. package/dist/src/{chunk-AXQBWV7J.js → chunk-F37DXY3P.js} +219 -115
  9. package/dist/src/{chunk-PZXFW6ZD.js → chunk-FGTN34N7.js} +3 -3
  10. package/dist/src/{chunk-RAGZAJKD.js → chunk-GQSFMINU.js} +3 -33
  11. package/dist/src/chunk-N3YZ7K5L.js +111 -0
  12. package/dist/src/{chunk-DN2LVJO3.js → chunk-T7S65ZHW.js} +4307 -1645
  13. package/dist/src/{chunk-TDAWUJ2L.js → chunk-V3GJ4XSW.js} +118 -66
  14. package/dist/src/{chunk-T6CAPT32.js → chunk-VJAXVLXZ.js} +3 -2
  15. package/dist/src/{chunk-HD6FTA3H.js → chunk-Z7VLJSDG.js} +211 -92
  16. package/dist/src/cli.js +44 -155
  17. package/dist/src/{commands-BSDNHYB3.js → commands-ZTGXXVOO.js} +12 -10
  18. package/dist/src/generated/aula.core5.wasm +0 -0
  19. package/dist/src/generated/aula.js +4076 -1341
  20. package/dist/src/generated/interfaces/aula-engine-engine.d.ts +39 -0
  21. package/dist/src/problems-BDPV4IRL.js +17 -0
  22. package/dist/src/project-XHL7FN7B.js +16 -0
  23. package/dist/src/run-LZVKYMKT.js +238 -0
  24. package/dist/src/{server-TJTMSDO2.js → server-H7XOUJNL.js} +24 -21
  25. package/dist/src/{site-RGPJOWSU.js → site-7MLO35NA.js} +16 -89
  26. package/dist/src/workspace-load-OQXB2ZOC.js +16 -0
  27. package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula-method.js +1 -1
  28. package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula.js +1 -1
  29. package/dist/web/app/assets/15e78332/build-worker.js +2 -0
  30. package/dist/web/app/assets/15e78332/index.js +51 -0
  31. package/dist/web/app/assets/__vite-browser-external-CCI-9X_7.js +1 -0
  32. package/dist/web/app/assets/aula-voice-worker-bYZ7BKji.js +1 -0
  33. package/dist/web/app/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
  34. package/dist/web/app/assets/protocol-j759xoXL.js +15 -0
  35. package/dist/web/app/assets/src-BjcN7H3T.js +6 -0
  36. package/dist/web/{site/assets/tex-mathjax-DrZV_cwB.js → app/assets/tex-mathjax-Bbh2jsAv.js} +1 -1
  37. package/dist/web/app/index.html +4 -4
  38. package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula-method.js +1 -1
  39. package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula.js +1 -1
  40. package/dist/web/site/assets/671a8ee2/build-worker.js +2 -0
  41. package/dist/web/site/assets/671a8ee2/index.js +51 -0
  42. package/dist/web/site/assets/__vite-browser-external-CrZYh5ba.js +1 -0
  43. package/dist/web/site/assets/aula-voice-worker-Doyh20uI.js +1 -0
  44. package/dist/web/site/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
  45. package/dist/web/site/assets/protocol-ByKVs3Yn.js +15 -0
  46. package/dist/web/site/assets/src-BwnY0kQu.js +6 -0
  47. package/dist/web/{app/assets/tex-mathjax-eWNptbJg.js → site/assets/tex-mathjax-DKtiwFu-.js} +1 -1
  48. package/dist/web/site/index.html +4 -4
  49. package/package.json +1 -1
  50. package/dist/src/chunk-4QGX7XXO.js +0 -104
  51. package/dist/src/problems-CGKCPETU.js +0 -18
  52. package/dist/src/project-EUFMRQXR.js +0 -16
  53. package/dist/src/run-ER27SVTA.js +0 -183
  54. package/dist/web/app/assets/__vite-browser-external-BHESVS8k.js +0 -1
  55. package/dist/web/app/assets/aula-voice-worker-CJpoa9h-.js +0 -1
  56. package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
  57. package/dist/web/app/assets/bf5dd884/index.js +0 -51
  58. package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
  59. package/dist/web/app/assets/src-DWqZcp-P.js +0 -6
  60. package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
  61. package/dist/web/site/assets/07fb5cf0/index.js +0 -51
  62. package/dist/web/site/assets/__vite-browser-external-DQubyTsZ.js +0 -1
  63. package/dist/web/site/assets/aula-voice-worker-BRrzyFz3.js +0 -1
  64. package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
  65. package/dist/web/site/assets/src-DfPcHwz-.js +0 -6
package/dist/src/cli.js CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ Capabilities
4
+ } from "./chunk-4N5SDSCV.js";
2
5
  import {
3
6
  run,
4
7
  status
@@ -13,9 +16,10 @@ import {
13
16
  speakAulaVoice,
14
17
  studentWeightFile,
15
18
  timeAulaVoice,
16
- tokenBatches
17
- } from "./chunk-TDAWUJ2L.js";
18
- import "./chunk-DN2LVJO3.js";
19
+ tokenBatches,
20
+ tryTimeAulaVoice
21
+ } from "./chunk-V3GJ4XSW.js";
22
+ import "./chunk-T7S65ZHW.js";
19
23
  import {
20
24
  fault
21
25
  } from "./chunk-VX7UVLQW.js";
@@ -27,135 +31,7 @@ import { existsSync, readFileSync, statSync, watch } from "node:fs";
27
31
  import * as fs from "node:fs/promises";
28
32
  import os from "node:os";
29
33
  import { createInterface } from "node:readline";
30
- import path3 from "node:path";
31
-
32
- // ../../node_modules/.pnpm/@beff+diy@0.0.36/node_modules/@beff/diy/dist/esm/capabilities.js
33
- function create(serviceMap) {
34
- return serviceMap;
35
- }
36
- function extend(capabilities2, extra) {
37
- return Object.assign({}, capabilities2, extra);
38
- }
39
- function override(capabilities2, replacement) {
40
- return { ...capabilities2, ...replacement };
41
- }
42
- function merge(...capabilitiesList) {
43
- return Object.assign({}, ...capabilitiesList);
44
- }
45
- var Capabilities = {
46
- /**
47
- * Build the app's concrete services.
48
- *
49
- * @example
50
- * ```ts
51
- * const capabilities = Capabilities.create<AppCapability>({
52
- * clock: { now: () => new Date() },
53
- * fs,
54
- * });
55
- * ```
56
- */
57
- create,
58
- /**
59
- * Add scoped services around an existing bag.
60
- *
61
- * @example
62
- * ```ts
63
- * const jobCapabilities = Capabilities.extend(
64
- * capabilities,
65
- * Capabilities.create<ProgressCapability>({ progress }),
66
- * );
67
- * ```
68
- */
69
- extend,
70
- /**
71
- * Combine capability bags built by separate modules.
72
- *
73
- * @example
74
- * ```ts
75
- * const appCapabilities = Capabilities.merge(nodeCapabilities, databaseCapabilities);
76
- * ```
77
- */
78
- merge,
79
- /**
80
- * Replace services without changing the capability type.
81
- *
82
- * @example
83
- * ```ts
84
- * const quietCapabilities = Capabilities.override(capabilities, {
85
- * logger: { info: () => undefined },
86
- * });
87
- * ```
88
- */
89
- override
90
- };
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
- }
34
+ import path2 from "node:path";
159
35
 
160
36
  // src/render.ts
161
37
  import { fileURLToPath } from "node:url";
@@ -180,14 +56,14 @@ function createRender(capabilities2, node) {
180
56
 
181
57
  // ../aula-narration/src/node.ts
182
58
  import { createHash } from "node:crypto";
183
- import path2 from "node:path";
59
+ import path from "node:path";
184
60
  var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
185
61
  async function writeAtomic(capabilities2, destination, bytes) {
186
- const folder = path2.dirname(destination);
62
+ const folder = path.dirname(destination);
187
63
  await capabilities2.fs.mkdir(folder, { recursive: true });
188
- const work = await capabilities2.fs.mkdtemp(path2.join(folder, `.${path2.basename(destination)}.`));
64
+ const work = await capabilities2.fs.mkdtemp(path.join(folder, `.${path.basename(destination)}.`));
189
65
  try {
190
- const staged = path2.join(work, path2.basename(destination));
66
+ const staged = path.join(work, path.basename(destination));
191
67
  await capabilities2.fs.writeFile(staged, bytes);
192
68
  await capabilities2.fs.rename(staged, destination);
193
69
  } finally {
@@ -199,7 +75,7 @@ async function download(capabilities2, fetch2, downloading, destination, url, ha
199
75
  const kept = new Uint8Array(await capabilities2.fs.readFile(destination));
200
76
  if (sha256(kept) === hash) return kept;
201
77
  }
202
- downloading(path2.basename(destination));
78
+ downloading(path.basename(destination));
203
79
  const response = await fetch2(url, { headers: { "User-Agent": "aula" } });
204
80
  if (!response.ok) throw new Error(`Cannot download ${url}: HTTP ${String(response.status)}`);
205
81
  const bytes = new Uint8Array(await response.arrayBuffer());
@@ -215,17 +91,17 @@ var phonemize = britishPhonemizer(new Set(KOKORO_VOCAB.keys()));
215
91
  function textTokens() {
216
92
  return (text) => tokenBatches(KOKORO_VOCAB, phonemize, text);
217
93
  }
218
- var aulaVoiceFolder = (models2) => path2.join(models2, "aula-voice", AULA_VOICE_RELEASE);
94
+ var aulaVoiceFolder = (models2) => path.join(models2, "aula-voice", AULA_VOICE_RELEASE);
219
95
  async function aulaVoiceWeightFile(capabilities2, options2) {
220
96
  const { fetch: fetch2, models: models2, downloading } = options2;
221
97
  const folder = aulaVoiceFolder(models2);
222
- const destination = path2.join(folder, AULA_VOICE_WEIGHTS.path);
98
+ const destination = path.join(folder, AULA_VOICE_WEIGHTS.path);
223
99
  if (capabilities2.fs.existsSync(destination)) {
224
100
  const kept = new Uint8Array(await capabilities2.fs.readFile(destination));
225
101
  if (sha256(kept) === AULA_VOICE_WEIGHTS.sha256) return kept;
226
102
  }
227
103
  const { model, config } = AULA_VOICE_FILES;
228
- const raw = (file) => download(capabilities2, fetch2, downloading, path2.join(folder, file.path), aulaVoiceUrl(file), file.sha256);
104
+ const raw = (file) => download(capabilities2, fetch2, downloading, path.join(folder, file.path), aulaVoiceUrl(file), file.sha256);
229
105
  const avw = studentWeightFile(await raw(model), await raw(config));
230
106
  if (sha256(avw) !== AULA_VOICE_WEIGHTS.sha256) {
231
107
  fault("the weight file made from aula-voice's release has the wrong SHA-256", "report it");
@@ -236,12 +112,13 @@ async function aulaVoiceWeightFile(capabilities2, options2) {
236
112
  function aulaVoice(capabilities2, options2) {
237
113
  let loading = null;
238
114
  const parts = () => loading ??= (async () => {
239
- const { aulaVoiceModel } = await import("./aula-voice-tts-YOS4IQXV.js");
115
+ const { aulaVoiceModel } = await import("./aula-voice-tts-FEFKNA2I.js");
240
116
  return { model: await aulaVoiceModel(await aulaVoiceWeightFile(capabilities2, options2)), phonemize };
241
117
  })();
242
118
  return {
243
119
  speak: async (words) => speakAulaVoice(await parts(), words),
244
- time: async (words) => timeAulaVoice(await parts(), words)
120
+ time: async (words) => timeAulaVoice(await parts(), words),
121
+ tryTime: async (words) => tryTimeAulaVoice(await parts(), words)
245
122
  };
246
123
  }
247
124
 
@@ -284,17 +161,15 @@ var base = Capabilities.create({
284
161
  },
285
162
  spawn
286
163
  });
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"));
164
+ var { diagnosticsOf, printDiagnostics } = await import("./problems-BDPV4IRL.js");
165
+ var { host, loadProject } = await import("./project-XHL7FN7B.js");
166
+ var { USAGE, checkOptions, folderArgs, isHelp, optionsOf, parse, run: run2, siteOptions, webOptions } = await import("./run-LZVKYMKT.js");
291
167
  var render = createRender(base, process.execPath);
292
- var models = path3.join(os.homedir(), ".cache/aula/models");
168
+ var models = path2.join(os.homedir(), ".cache/aula/models");
293
169
  var narrator = createAulaVoice(base, fetch, models);
294
170
  var capabilities = Capabilities.extend(
295
171
  base,
296
172
  Capabilities.create({
297
- locks,
298
173
  narrator,
299
174
  render
300
175
  })
@@ -302,15 +177,14 @@ var capabilities = Capabilities.extend(
302
177
  var cwd = process.cwd();
303
178
  async function main(argv) {
304
179
  const [command, ...rest] = argv;
305
- if (command === void 0) throw new Error(USAGE);
306
- if (isHelp(command)) {
180
+ if (command === void 0 || isHelp(command)) {
307
181
  capabilities.log.out(USAGE);
308
182
  return 0;
309
183
  }
310
184
  const args = parse(rest, optionsOf(command));
311
185
  if (command === "web") {
312
186
  const options2 = webOptions(cwd, args);
313
- const { serve } = await import("./server-TJTMSDO2.js");
187
+ const { serve } = await import("./server-H7XOUJNL.js");
314
188
  const stop = new AbortController();
315
189
  for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => stop.abort());
316
190
  const web = Capabilities.create({
@@ -326,18 +200,33 @@ async function main(argv) {
326
200
  return 0;
327
201
  }
328
202
  if (command === "site") {
329
- const { site } = await import("./site-RGPJOWSU.js");
203
+ const { site } = await import("./site-7MLO35NA.js");
330
204
  const weights = Capabilities.create({ weights: aulaVoiceWeights(base, fetch, models) });
331
205
  return await site(Capabilities.extend(capabilities, weights), siteOptions(cwd, args)) ? 0 : 1;
332
206
  }
207
+ if (command === "check") {
208
+ const { checkRoot } = await import("./commands-ZTGXXVOO.js");
209
+ const options2 = checkOptions(cwd, args);
210
+ return await checkRoot(
211
+ capabilities,
212
+ cwd,
213
+ options2.root,
214
+ options2.only,
215
+ options2.json,
216
+ options2.includeDrafts,
217
+ process.execPath
218
+ ) ? 0 : 1;
219
+ }
333
220
  if (command === "tokens") {
334
- const { tokens, tokensArgs } = await import("./commands-BSDNHYB3.js");
221
+ const { tokens, tokensArgs } = await import("./commands-ZTGXXVOO.js");
335
222
  tokensArgs(args.positional);
336
223
  const tokensOf = createTokens();
337
224
  return await tokens(capabilities, tokensOf, createInterface({ input: process.stdin, crlfDelay: Infinity })) ? 0 : 1;
338
225
  }
339
- const { folder, rest: after } = folderArgs(cwd, command, args);
340
- const only = command === "preview" ? after.slice(1) : command === "check" || command === "timeline" || command === "script" ? after : [];
226
+ const { folder: root, rest: after } = folderArgs(cwd, command, args);
227
+ const { resolveOneProject } = await import("./workspace-load-OQXB2ZOC.js");
228
+ const { folder } = await resolveOneProject(capabilities, root, args.flags.has("--include-drafts"), command);
229
+ const only = command === "preview" ? after.slice(1) : command === "timeline" || command === "script" ? after : [];
341
230
  const project = await loadProject(capabilities, cwd, folder, only);
342
231
  return await run2(capabilities, cwd, command, project, after, args.flags) ? 0 : 1;
343
232
  }
@@ -1,30 +1,32 @@
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-Z7VLJSDG.js";
11
12
  import "./chunk-THQ5Y74K.js";
13
+ import "./chunk-4N5SDSCV.js";
12
14
  import "./chunk-F4XRXW6M.js";
13
15
  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";
16
+ import "./chunk-FGTN34N7.js";
17
+ import "./chunk-F37DXY3P.js";
18
+ import "./chunk-V3GJ4XSW.js";
19
+ import "./chunk-2BEUK7M7.js";
20
+ import "./chunk-2VD3JPLV.js";
21
+ import "./chunk-VJAXVLXZ.js";
22
+ import "./chunk-GQSFMINU.js";
23
+ import "./chunk-T7S65ZHW.js";
23
24
  import "./chunk-VX7UVLQW.js";
24
25
  import "./chunk-CZ7CSFO4.js";
25
26
  export {
26
27
  bundle,
27
28
  check,
29
+ checkRoot,
28
30
  exportVideo,
29
31
  preview,
30
32
  script,
Binary file