@beff/aula-cli 0.1.0 → 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 (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-UREQAEFC.js → chunk-IAQZ6DTC.js} +2 -222
  6. package/dist/src/{chunk-OMBYV6CK.js → chunk-QWNBVWUQ.js} +54 -12
  7. package/dist/src/chunk-XUBCUJW5.js +104 -0
  8. package/dist/src/{chunk-EYXQ2I7K.js → chunk-YX73KJQ6.js} +4 -31
  9. package/dist/src/cli.js +81 -16
  10. package/dist/src/{commands-VDGWDVWT.js → commands-M246OWYJ.js} +6 -7
  11. package/dist/src/problems-Y67BY7WB.js +12 -0
  12. package/dist/src/{project-M63R4ENB.js → project-NWT5MDQI.js} +2 -2
  13. package/dist/src/{run-CY72QGZJ.js → run-CTVGU7EK.js} +10 -10
  14. package/dist/src/{server-ZG6K7Z7H.js → server-5OGXX6BF.js} +6 -66
  15. package/dist/web/app/assets/__vite-browser-external-BN30sEqc.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-DymX5vwM.js} +10 -10
  18. package/dist/web/app/assets/{aula.core5-BdGB-M10.wasm → aula.core5-YhDIb7Me.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-B8_aMtuI.js +53 -0
  22. package/dist/web/app/assets/index-cL-Dm_aw.css +2 -0
  23. package/dist/web/app/assets/protocol-CnlzsyRt.js +15 -0
  24. package/dist/web/app/assets/{src-BbJ5r410.js → src-CmWmmzpF.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
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @beff/aula-cli
2
2
 
3
- The `aula` command of [aula](https://github.com/lucasavila00/aula): it runs chapter modules on the [`@beff/aula`](https://www.npmjs.com/package/@beff/aula) engine, checks and lints them, writes PNG pictures for review, exports MP4 videos, makes project zips, and serves the web player with narration: aula-voice on WebAssembly.
3
+ The `aula` command of [aula](https://github.com/lucasavila00/aula): it runs chapter modules on the [`@beff/aula`](https://www.npmjs.com/package/@beff/aula) engine, checks and lints them, writes PNG pictures for review, exports MP4 videos, makes project zips, and serves the web player, which narrates in the browser: aula-voice on WebAssembly.
4
4
 
5
5
  It needs Node 24. Narration (aula-voice) needs only Node. `aula export` needs ffmpeg. Refer to [CLI](https://github.com/lucasavila00/aula/blob/main/docs/agents/cli.md) for the commands and [Getting started](https://github.com/lucasavila00/aula/blob/main/docs/agents/getting-started.md) for the setup.
6
6
 
7
- The package has no model file. The first command that narrates or times a video (`preview`, `timeline`, `export`, `aula web`) downloads the narrator's model into `~/.cache/aula/models/aula-voice/`: the raw model of aula-voice's release [v0.1.1](https://github.com/lucasavila00/aula-voice/releases/tag/v0.1.1) (`model.safetensors` and `config.json`, approximately 34 MB). The CLI checks the SHA-256 of each file, makes the engine's weight file (`aula-voice.avw`) from them, and checks its SHA-256 too. `aula web` serves that file to its page from the same folder. The [model card](https://github.com/lucasavila00/aula-voice/releases/download/v0.1.1/MODEL_CARD.md) has the license of the model, its sources and its training data, and their attribution.
7
+ The package has no model file. The first command that narrates or times a video (`preview`, `timeline`, `export`, `aula web`) downloads the narrator's model into `~/.cache/aula/models/aula-voice/`: the raw model of aula-voice's release [v0.1.1](https://github.com/lucasavila00/aula-voice/releases/tag/v0.1.1) (`model.safetensors` and `config.json`, approximately 34 MB). The CLI checks the SHA-256 of each file, makes the engine's weight file (`aula-voice.avw`) from them, and checks its SHA-256 too. `aula web` narrates in the browser: it serves that file to its page from the same folder. The [model card](https://github.com/lucasavila00/aula-voice/releases/download/v0.1.1/MODEL_CARD.md) has the license of the model, its sources and its training data, and their attribution.
8
8
 
9
9
  ## Licenses
10
10
 
Binary file
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  host,
3
3
  loadProject
4
- } from "./chunk-PYRORQA5.js";
4
+ } from "./chunk-7KT36JRP.js";
5
5
 
6
6
  // src/project.ts
7
7
  function exists(capabilities, file) {
@@ -1,100 +1,28 @@
1
- // ../aula-narration/src/script.ts
2
- import { chapterNarration } from "@beff/aula/text";
3
- function joinChapter(cues, speeches) {
4
- let rate = 0;
5
- for (const [i, speech] of speeches.entries()) {
6
- if (!speech.samples.length || speech.samples.some((s) => !Number.isFinite(s))) {
7
- const text = cues[i]?.text.slice(0, 60) ?? "";
8
- throw new Error(`the narrator returned empty or invalid audio for ${JSON.stringify(text)}`);
9
- }
10
- if (rate !== 0 && speech.sampleRate !== rate) throw new Error("the narrator changed its sample rate");
11
- rate = speech.sampleRate;
12
- }
13
- const spoken = speeches.map((s) => ({
14
- samples: s.samples.length,
15
- words: s.words.map((w) => ({ text: w.text, char: w.char, start: w.start }))
16
- }));
17
- const narration = chapterNarration(cues, spoken, rate);
18
- const samples = new Float32Array(narration.endFrame);
19
- for (const [i, speech] of speeches.entries()) samples.set(speech.samples, narration.cues[i]?.speechStartFrame ?? 0);
20
- return { samples, narration };
21
- }
22
- function withWaits(samples, waits) {
23
- if (waits.length === 0) return samples;
24
- const out = new Float32Array(samples.length + waits.reduce((sum, w) => sum + w.samples, 0));
25
- let from = 0;
26
- let to = 0;
27
- for (const wait of waits.toSorted((a, b) => a.sample - b.sample)) {
28
- const at = Math.min(wait.sample, samples.length);
29
- out.set(samples.subarray(from, at), to);
30
- to += at - from + wait.samples;
31
- from = at;
32
- }
33
- out.set(samples.subarray(from), to);
34
- return out;
35
- }
36
- function timeChapter(cues, timings) {
37
- const rate = timings[0]?.sampleRate ?? 0;
38
- if (timings.some((t) => t.sampleRate !== rate)) throw new Error("the narrator changed its sample rate");
39
- const spoken = timings.map((t) => ({
40
- samples: t.samples,
41
- words: t.words.map((w) => ({ text: w.text, char: w.char, start: w.start }))
42
- }));
43
- return chapterNarration(cues, spoken, rate);
1
+ // ../aula-project/src/diagnostics.ts
2
+ import { diagnosticOf } from "@beff/aula/run";
3
+ function error(message, more = {}) {
4
+ return { severity: "error", message, ...more, stack: [], related: [] };
44
5
  }
45
- async function narrateScript(narrator, chapters, speaking) {
46
- const count = chapters.reduce((sum, c) => sum + c.length, 0);
47
- let spoken = 0;
48
- const narrated = [];
49
- for (const cues of chapters) {
50
- const speeches = [];
51
- for (const cue of cues) {
52
- spoken += 1;
53
- speaking(spoken, count, cue);
54
- speeches.push(await narrator.speak(cue.text, cue.speed));
55
- }
56
- narrated.push(joinChapter(cues, speeches));
6
+ var isError = (d) => d.severity === "error";
7
+ var Problems = class extends Error {
8
+ diagnostics;
9
+ constructor(diagnostics) {
10
+ super(diagnostics.map((d) => d.message).join("\n"));
11
+ this.diagnostics = diagnostics;
57
12
  }
58
- if (!narrated.some((c) => c.narration.sampleRate > 0)) throw new Error("the script has no cues");
59
- return narrated;
13
+ };
14
+ function wrongArgument(message, hint) {
15
+ return new Problems([error(message, hint === void 0 ? {} : { hint })]);
60
16
  }
61
- function scriptAudio(chapters, waits) {
62
- const sounds = chapters.map((c, i) => withWaits(c.samples, waits[i] ?? []));
63
- const samples = new Float32Array(sounds.reduce((sum, s) => sum + s.length, 0));
64
- let at = 0;
65
- for (const sound of sounds) {
66
- samples.set(sound, at);
67
- at += sound.length;
68
- }
69
- const sampleRate = chapters.find((c) => c.narration.sampleRate > 0)?.narration.sampleRate ?? 0;
70
- return { samples, sampleRate };
17
+ function diagnosticsOf(e, host2) {
18
+ return e instanceof Problems ? e.diagnostics : [diagnosticOf(e, "", host2)];
71
19
  }
72
20
 
73
- // ../aula-narration/src/wav.ts
74
- function wav(samples, rate) {
75
- const bytes = new Uint8Array(44 + samples.length * 2);
76
- const view = new DataView(bytes.buffer);
77
- const text = (at, value) => {
78
- for (let i = 0; i < value.length; i++) view.setUint8(at + i, value.charCodeAt(i));
79
- };
80
- text(0, "RIFF");
81
- view.setUint32(4, 36 + samples.length * 2, true);
82
- text(8, "WAVE");
83
- text(12, "fmt ");
84
- view.setUint32(16, 16, true);
85
- view.setUint16(20, 1, true);
86
- view.setUint16(22, 1, true);
87
- view.setUint32(24, rate, true);
88
- view.setUint32(28, rate * 2, true);
89
- view.setUint16(32, 2, true);
90
- view.setUint16(34, 16, true);
91
- text(36, "data");
92
- view.setUint32(40, samples.length * 2, true);
93
- samples.forEach((sample, i) => {
94
- view.setInt16(44 + i * 2, Math.round(Math.min(1, Math.max(-1, sample)) * 32767), true);
95
- });
96
- return bytes;
97
- }
21
+ // ../aula-project/src/node.ts
22
+ import path from "node:path";
23
+ import { pathToFileURL } from "node:url";
24
+ import { isProjectDefinition } from "@beff/aula";
25
+ import { definedAt, loadEngine, v8Frames } from "@beff/aula/run";
98
26
 
99
27
  // ../../node_modules/.pnpm/@beff+client@1.0.1/node_modules/@beff/client/dist/esm/openapi-pp.js
100
28
  var removeNullUnionBranch = (definition) => {
@@ -165,24 +93,24 @@ var joinWithDot = (it) => {
165
93
  }
166
94
  return acc;
167
95
  };
168
- var printPath = (parentPath, path) => {
169
- const mergedPath = [...parentPath, ...path];
96
+ var printPath = (parentPath, path2) => {
97
+ const mergedPath = [...parentPath, ...path2];
170
98
  return mergedPath.length > 0 ? `(${joinWithDot(mergedPath)})` : "";
171
99
  };
172
100
  var joinFilteredStrings = (it) => {
173
101
  return it.filter((it2) => it2.length > 0).join(" ");
174
102
  };
175
103
  var printRegularError = (err, parentPath, showReceived) => {
176
- const path = printPath(parentPath, err.path);
104
+ const path2 = printPath(parentPath, err.path);
177
105
  const msg = [err.message, showReceived ? `received: ${prettyPrintValue(err.received)}` : ""].filter((it) => it.length > 0).join(", ");
178
- return joinFilteredStrings([path, msg]);
106
+ return joinFilteredStrings([path2, msg]);
179
107
  };
180
108
  var printUnionError = (err, parentPath) => {
181
- const path = printPath(parentPath, err.path);
109
+ const path2 = printPath(parentPath, err.path);
182
110
  const printedErrors = printErrorsPart(err.errors, [], false);
183
111
  const innerMessages = printedErrors.length > 5 ? printedErrors.slice(0, 5).join(" OR ") + " and more..." : printedErrors.join(" | ");
184
112
  const msg = [`Failed to decode one of (${innerMessages})`, `received: ${prettyPrintValue(err.received)}`].filter((it) => it.length > 0).join(", ");
185
- return joinFilteredStrings([path, msg]);
113
+ return joinFilteredStrings([path2, msg]);
186
114
  };
187
115
  var printErrorsPart = (it, parentPath, showReceived) => {
188
116
  return it.map((err) => {
@@ -399,23 +327,23 @@ function pushPath(ctx, key) {
399
327
  function popPath(ctx) {
400
328
  ctx.path.pop();
401
329
  }
402
- function registerStringFormatter(stringFormatters, name, value) {
330
+ function registerStringFormatter(stringFormatters2, name, value) {
403
331
  if (typeof value === "function") {
404
- stringFormatters[name] = {
332
+ stringFormatters2[name] = {
405
333
  validator: value
406
334
  };
407
335
  return;
408
336
  }
409
- stringFormatters[name] = value;
337
+ stringFormatters2[name] = value;
410
338
  }
411
- function registerNumberFormatter(numberFormatters, name, value) {
339
+ function registerNumberFormatter(numberFormatters2, name, value) {
412
340
  if (typeof value === "function") {
413
- numberFormatters[name] = {
341
+ numberFormatters2[name] = {
414
342
  validator: value
415
343
  };
416
344
  return;
417
345
  }
418
- numberFormatters[name] = value;
346
+ numberFormatters2[name] = value;
419
347
  }
420
348
  function annotateSchema(metadata, schema) {
421
349
  if (metadata?.description == null) {
@@ -882,10 +810,10 @@ ${content2}
882
810
  var RefRuntype = class extends BaseRuntype {
883
811
  refName;
884
812
  namedRuntypes;
885
- constructor(metadata, refName, namedRuntypes) {
813
+ constructor(metadata, refName, namedRuntypes2) {
886
814
  super(metadata);
887
815
  this.refName = refName;
888
- this.namedRuntypes = namedRuntypes;
816
+ this.namedRuntypes = namedRuntypes2;
889
817
  }
890
818
  getNamedRuntypes() {
891
819
  return this.namedRuntypes;
@@ -1068,16 +996,287 @@ var buildParsers = (generated, args) => {
1068
996
  return acc;
1069
997
  };
1070
998
 
999
+ // ../aula-bundle/generated/parser.js
1000
+ var RequiredStringFormats = [];
1001
+ var RequiredNumberFormats = [];
1002
+ var namedRuntypes = {};
1003
+ var stringFormatters = {};
1004
+ var numberFormatters = {};
1005
+ var direct_hoist_0 = new RefRuntype(void 0, "PackageJson", namedRuntypes);
1006
+ var direct_hoist_1 = new AnyRuntype(void 0);
1007
+ var direct_hoist_2 = new TypeofRuntype(void 0, "string");
1008
+ var direct_hoist_3 = new ArrayRuntype(void 0, direct_hoist_2);
1009
+ var direct_hoist_4 = new ObjectRuntype({
1010
+ "description": "The part of a package.json that aula reads: how a package names its module and its\nworkspace packages."
1011
+ }, {
1012
+ "exports": new OptionalFieldRuntype(direct_hoist_1),
1013
+ "main": new OptionalFieldRuntype(direct_hoist_2),
1014
+ "module": new OptionalFieldRuntype(direct_hoist_2),
1015
+ "name": new OptionalFieldRuntype(direct_hoist_2),
1016
+ "workspaces": new OptionalFieldRuntype(direct_hoist_3)
1017
+ }, []);
1018
+ Object.assign(namedRuntypes, {
1019
+ "PackageJson": direct_hoist_4
1020
+ });
1021
+ var buildParsersInput = {
1022
+ "PackageJson": direct_hoist_0
1023
+ };
1024
+ var parser_default = {
1025
+ buildParsers: (args) => buildParsers(
1026
+ {
1027
+ parsers: buildParsersInput,
1028
+ stringFormatters,
1029
+ numberFormatters,
1030
+ requiredStringFormats: RequiredStringFormats,
1031
+ requiredNumberFormats: RequiredNumberFormats
1032
+ },
1033
+ args
1034
+ )
1035
+ };
1036
+
1037
+ // ../aula-bundle/src/parsers.ts
1038
+ var Parsers = parser_default.buildParsers();
1039
+
1040
+ // ../aula-bundle/src/index.ts
1041
+ var SOURCE_PREFIX = "tree:";
1042
+ function dirname(path2) {
1043
+ const at = path2.lastIndexOf("/");
1044
+ return at < 0 ? "" : path2.slice(0, at);
1045
+ }
1046
+ function join(from, relative) {
1047
+ const parts = from === "" ? [] : from.split("/");
1048
+ for (const part of relative.split("/")) {
1049
+ if (part === "" || part === ".") continue;
1050
+ if (part === "..") {
1051
+ if (!parts.length) return null;
1052
+ parts.pop();
1053
+ } else parts.push(part);
1054
+ }
1055
+ return parts.join("/");
1056
+ }
1057
+ var LOADERS = /* @__PURE__ */ new Map([
1058
+ ["ts", "ts"],
1059
+ ["mts", "ts"],
1060
+ ["js", "js"],
1061
+ ["mjs", "js"],
1062
+ ["json", "json"]
1063
+ ]);
1064
+ var loaderOf = (path2) => LOADERS.get(path2.slice(path2.lastIndexOf(".") + 1)) ?? "ts";
1065
+ function treePlugin(tree, imports) {
1066
+ return {
1067
+ name: "aula-tree",
1068
+ setup(build) {
1069
+ build.onResolve({ filter: /.*/ }, async (args) => {
1070
+ const url = imports[args.path];
1071
+ if (url !== void 0) return { path: url, external: true };
1072
+ if (args.kind === "entry-point") return { path: join("", args.path) ?? args.path, namespace: "tree" };
1073
+ if (!args.path.startsWith("./") && !args.path.startsWith("../")) {
1074
+ const found = await resolvePackage(tree, args.path, args.importer);
1075
+ if (found !== null) return { path: found, namespace: "tree" };
1076
+ return {
1077
+ errors: [{ text: `cannot find the package "${args.path}" in node_modules or the workspace packages` }]
1078
+ };
1079
+ }
1080
+ const path2 = join(dirname(args.importer), args.path);
1081
+ if (path2 === null) return { errors: [{ text: `"${args.path}" is outside the folder you opened` }] };
1082
+ for (const candidate of [path2, `${path2}.ts`, `${path2}/index.ts`]) {
1083
+ if (await tree.read(candidate) !== null) return { path: candidate, namespace: "tree" };
1084
+ }
1085
+ return { errors: [{ text: `cannot find "${args.path}" (${path2})` }] };
1086
+ });
1087
+ build.onLoad({ filter: /.*/, namespace: "tree" }, async (args) => {
1088
+ const contents = await tree.read(args.path);
1089
+ if (contents === null) return { errors: [{ text: `cannot read ${args.path}` }] };
1090
+ return { contents, loader: loaderOf(args.path) };
1091
+ });
1092
+ }
1093
+ };
1094
+ }
1095
+ function isMessage(value) {
1096
+ return typeof value === "object" && value !== null && typeof Reflect.get(value, "text") === "string";
1097
+ }
1098
+ var diagnostic = ({ text, location: at }) => ({
1099
+ severity: "error",
1100
+ message: text,
1101
+ ...at ? { location: { file: at.file.replace(SOURCE_PREFIX, ""), line: at.line, col: at.column + 1 } } : {},
1102
+ stack: [],
1103
+ related: []
1104
+ });
1105
+ async function bundle(esbuild, tree, entry, imports) {
1106
+ let result;
1107
+ try {
1108
+ result = await esbuild.build({
1109
+ entryPoints: [entry],
1110
+ bundle: true,
1111
+ write: false,
1112
+ format: "esm",
1113
+ platform: "browser",
1114
+ target: "es2024",
1115
+ outfile: "bundle.js",
1116
+ sourcemap: "both",
1117
+ sourcesContent: false,
1118
+ metafile: true,
1119
+ logLevel: "silent",
1120
+ plugins: [treePlugin(tree, imports)]
1121
+ });
1122
+ } catch (error2) {
1123
+ const errors = typeof error2 === "object" && error2 !== null ? Reflect.get(error2, "errors") : void 0;
1124
+ if (Array.isArray(errors) && errors.every(isMessage)) return { _tag: "Left", left: errors.map(diagnostic) };
1125
+ throw error2;
1126
+ }
1127
+ const code = result.outputFiles.find((f) => f.path.endsWith(".js"))?.text;
1128
+ const map = result.outputFiles.find((f) => f.path.endsWith(".js.map"))?.text;
1129
+ if (code === void 0 || map === void 0) throw new Error("esbuild wrote no bundle");
1130
+ const inputs = Object.keys(result.metafile?.inputs ?? {}).filter((input) => input.startsWith(SOURCE_PREFIX)).map((input) => input.slice(SOURCE_PREFIX.length));
1131
+ return { _tag: "Right", right: { code, map, inputs } };
1132
+ }
1133
+ function exportTarget(exports, subpath) {
1134
+ if (typeof exports === "string") return subpath === "." ? exports : null;
1135
+ if (typeof exports !== "object" || exports === null) return null;
1136
+ const keys = Object.keys(exports);
1137
+ if (keys.some((key) => key.startsWith("."))) {
1138
+ return subpath in exports ? exportTarget(Reflect.get(exports, subpath), ".") : null;
1139
+ }
1140
+ for (const key of ["browser", "import", "default"]) {
1141
+ if (key in exports) return exportTarget(Reflect.get(exports, key), ".");
1142
+ }
1143
+ return null;
1144
+ }
1145
+ function packageOf(specifier) {
1146
+ const parts = specifier.split("/");
1147
+ const size = specifier.startsWith("@") ? 2 : 1;
1148
+ const rest = parts.slice(size).join("/");
1149
+ return { name: parts.slice(0, size).join("/"), subpath: rest === "" ? "." : `./${rest}` };
1150
+ }
1151
+ async function packageModule(tree, folder, subpath) {
1152
+ const found = manifest(`${folder}/package.json`, await tree.read(`${folder}/package.json`));
1153
+ if (!found) return null;
1154
+ const target = exportTarget(found.exports, subpath) ?? (subpath === "." ? found.module ?? found.main ?? "index.js" : subpath);
1155
+ return join(folder, target);
1156
+ }
1157
+ async function resolveBare(tree, specifier, importer) {
1158
+ const { name, subpath } = packageOf(specifier);
1159
+ for (let dir = dirname(importer); ; dir = dirname(dir)) {
1160
+ const found = await packageModule(
1161
+ tree,
1162
+ dir === "" ? `node_modules/${name}` : `${dir}/node_modules/${name}`,
1163
+ subpath
1164
+ );
1165
+ if (found !== null) return found;
1166
+ if (dir === "") return null;
1167
+ }
1168
+ }
1169
+ function manifest(file, text) {
1170
+ if (text === null) return null;
1171
+ const parsed = Parsers.PackageJson.safeParse(JSON.parse(text));
1172
+ return parsed.success ? parsed.data : null;
1173
+ }
1174
+ async function workspaceFolders(tree) {
1175
+ const patterns = [];
1176
+ const pnpm = await tree.read("pnpm-workspace.yaml");
1177
+ if (pnpm !== null) {
1178
+ let inside = false;
1179
+ for (const line of pnpm.split("\n")) {
1180
+ if (/^packages:\s*$/.test(line)) inside = true;
1181
+ else if (/^\S/.test(line)) inside = false;
1182
+ else if (inside) {
1183
+ const item = /^\s*-\s*["']?([^"'#]+?)["']?\s*(#.*)?$/.exec(line)?.[1];
1184
+ if (item !== void 0) patterns.push(item);
1185
+ }
1186
+ }
1187
+ }
1188
+ patterns.push(...manifest("package.json", await tree.read("package.json"))?.workspaces ?? []);
1189
+ const folders = [];
1190
+ for (const pattern of patterns) {
1191
+ const clean = pattern.replace(/^\.\//, "").replace(/\/$/, "");
1192
+ if (clean.endsWith("/*")) {
1193
+ const parent = clean.slice(0, -2);
1194
+ folders.push(...(await tree.list(parent)).map((name) => `${parent}/${name}`));
1195
+ } else if (!clean.includes("*")) folders.push(clean);
1196
+ }
1197
+ return folders;
1198
+ }
1199
+ async function resolvePackage(tree, specifier, importer) {
1200
+ const installed = await resolveBare(tree, specifier, importer);
1201
+ if (installed !== null) return installed;
1202
+ const { name, subpath } = packageOf(specifier);
1203
+ for (const folder of await workspaceFolders(tree)) {
1204
+ if (manifest(`${folder}/package.json`, await tree.read(`${folder}/package.json`))?.name !== name) continue;
1205
+ return packageModule(tree, folder, subpath);
1206
+ }
1207
+ return null;
1208
+ }
1209
+ var ORDER = /^(\d+)-/;
1210
+ var projectName = (folder) => folder.replace(ORDER, "");
1211
+
1212
+ // ../aula-project/src/node.ts
1213
+ var PROJECT_MODULE = "index.ts";
1214
+ var GLUE = [
1215
+ `${path.dirname(new URL(import.meta.resolve("@beff/aula")).pathname)}/`,
1216
+ new URL(import.meta.url).pathname
1217
+ ];
1218
+ function host(capabilities, root, glue = []) {
1219
+ const all = [...GLUE, ...glue];
1220
+ return {
1221
+ frames: v8Frames,
1222
+ name: (file) => file.startsWith("/") && !file.includes("/node_modules/") && !all.some((g) => file.startsWith(g)) ? path.relative(root, file) : void 0,
1223
+ exists: (file) => capabilities.fs.existsSync(path.resolve(root, file))
1224
+ };
1225
+ }
1226
+ function propertyOf(e, key) {
1227
+ return typeof e === "object" && e !== null ? Reflect.get(e, key) : void 0;
1228
+ }
1229
+ async function loadProject(capabilities, load, root, folder) {
1230
+ const file = path.join(folder, PROJECT_MODULE);
1231
+ if (!capabilities.fs.existsSync(file)) {
1232
+ throw wrongArgument(
1233
+ `${path.relative(root, folder) || "."} has no ${PROJECT_MODULE}`,
1234
+ `give the project folder: the folder with ${PROJECT_MODULE}`
1235
+ );
1236
+ }
1237
+ await loadEngine();
1238
+ const module = await load(pathToFileURL(file).href);
1239
+ const exported = propertyOf(module, "default");
1240
+ if (!isProjectDefinition(exported)) {
1241
+ const rel = path.relative(root, file);
1242
+ throw new Problems([
1243
+ error(`the default export of ${rel} is not made by defineProject`, {
1244
+ location: { file: rel, line: 1, col: 0 },
1245
+ hint: "write `export default defineProject({ title, theme, chapters: [ \u2026 ] })`"
1246
+ })
1247
+ ]);
1248
+ }
1249
+ return exported;
1250
+ }
1251
+ var folderOf = (project) => path.dirname(definedAt(project).file);
1252
+ var nameOf = (project) => projectName(path.basename(folderOf(project)));
1253
+ async function withSource(capabilities, root, d) {
1254
+ if (d.source !== void 0 || d.location === void 0) return d;
1255
+ const file = path.resolve(root, d.location.file);
1256
+ if (!capabilities.fs.existsSync(file)) return d;
1257
+ const text = await capabilities.fs.readFile(file, "utf8");
1258
+ const lines = text.split("\n");
1259
+ if (lines.at(-1) === "") lines.pop();
1260
+ const line = lines[d.location.line - 1];
1261
+ return line === void 0 || d.location.line < 1 ? d : { ...d, source: line.replace(/\r$/, "") };
1262
+ }
1263
+
1071
1264
  export {
1072
- timeChapter,
1073
- narrateScript,
1074
- scriptAudio,
1075
- wav,
1076
1265
  TypeofRuntype,
1077
- AnyRuntype,
1078
- ArrayRuntype,
1079
1266
  OptionalFieldRuntype,
1080
1267
  ObjectRuntype,
1081
1268
  RefRuntype,
1082
- buildParsers
1269
+ buildParsers,
1270
+ Parsers,
1271
+ bundle,
1272
+ error,
1273
+ isError,
1274
+ Problems,
1275
+ wrongArgument,
1276
+ diagnosticsOf,
1277
+ host,
1278
+ loadProject,
1279
+ folderOf,
1280
+ nameOf,
1281
+ withSource
1083
1282
  };