@beff/aula-cli 0.6.2 → 0.7.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.
- package/dist/src/{chunk-LSXILCMB.js → chunk-HLRTXRAC.js} +23 -35
- package/dist/src/{chunk-6CZECZIX.js → chunk-JWAUET3S.js} +374 -15
- package/dist/src/{chunk-3MPFI4UE.js → chunk-RRS3SD7K.js} +41 -18
- package/dist/src/{chunk-EZROW2IP.js → chunk-STW7EAFL.js} +1 -1
- package/dist/src/chunk-THQ5Y74K.js +64 -0
- package/dist/src/{chunk-7C6QW2TD.js → chunk-UKSA5OFC.js} +1 -1
- package/dist/src/{chunk-J7LNPVU2.js → chunk-WY3AMP6M.js} +1 -1
- package/dist/src/cli.js +6 -6
- package/dist/src/{commands-7MTNNJKO.js → commands-NDTPHXGF.js} +7 -7
- package/dist/src/{problems-CCUJW4H4.js → problems-CQXPY4G5.js} +4 -4
- package/dist/src/project-ICPIW4MO.js +12 -0
- package/dist/src/{run-VCOTEL37.js → run-IBCNVZ4J.js} +7 -7
- package/dist/src/{server-5W36J7WM.js → server-QQ2V343V.js} +83 -26
- package/dist/src/{site-NA5QNSHF.js → site-XYQKQZLZ.js} +32 -64
- package/dist/web/app/assets/{3cdff963 → 7ca1e7de}/aula-method.js +1 -1
- package/dist/web/app/assets/{3cdff963 → 7ca1e7de}/aula.js +1 -1
- package/dist/web/app/assets/7ca1e7de/build-worker.js +2 -0
- package/dist/web/app/assets/{3cdff963 → 7ca1e7de}/index.js +3 -4
- package/dist/web/app/assets/__vite-browser-external-CZjgZoe-.js +1 -0
- package/dist/web/{site/assets/aula-voice-worker-DHEZKCCg.js → app/assets/aula-voice-worker-CjeRSu86.js} +10 -12
- package/dist/web/app/assets/{3cdff963/build-worker.js → browser-sNTR4ahh.js} +4 -5
- package/dist/web/app/assets/esbuild-D6hmBtXM.js +1 -0
- package/dist/web/{site/assets/index-BirjmJbl.css → app/assets/index-CFRTa3wf.css} +1 -1
- package/dist/web/app/assets/protocol-CVAj9kTL.js +15 -0
- package/dist/web/app/assets/{src-CTZjQYUv.js → src-uzFdGdZX.js} +2 -3
- package/dist/web/app/index.html +5 -4
- package/dist/web/site/assets/{fbc21d75 → 8f69161f}/aula-method.js +1 -1
- package/dist/web/site/assets/{fbc21d75 → 8f69161f}/aula.js +1 -1
- package/dist/web/site/assets/8f69161f/build-worker.js +2 -0
- package/dist/web/site/assets/{fbc21d75 → 8f69161f}/index.js +3 -4
- package/dist/web/site/assets/__vite-browser-external-lWmWnTMm.js +1 -0
- package/dist/web/{app/assets/aula-voice-worker-C7UeMloK.js → site/assets/aula-voice-worker-Sm-si1oe.js} +10 -10
- package/dist/web/site/assets/{fbc21d75/build-worker.js → browser-sNTR4ahh.js} +4 -5
- package/dist/web/site/assets/esbuild-CW5RQptO.js +1 -0
- package/dist/web/{app/assets/index-BirjmJbl.css → site/assets/index-CFRTa3wf.css} +1 -1
- package/dist/web/site/assets/protocol-47nVPHKy.js +15 -0
- package/dist/web/site/assets/{src-1_dQqt80.js → src-DWVrqSqZ.js} +2 -3
- package/dist/web/site/index.html +5 -4
- package/package.json +2 -2
- package/dist/src/chunk-EB67KE2S.js +0 -369
- package/dist/src/project-PF77AQKF.js +0 -12
- package/dist/web/app/assets/__vite-browser-external-CTDtqMqs.js +0 -1
- package/dist/web/app/assets/protocol-C3MGnf_t.js +0 -15
- package/dist/web/site/assets/__vite-browser-external-D1sFDdqr.js +0 -1
- package/dist/web/site/assets/protocol-CzWPeNPI.js +0 -15
package/dist/web/site/index.html
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
<script>(function(){var p=fetch(new URL("aula-voice.avw",document.baseURI));p.catch(function(){});window.aulaVoice=p})();</script>
|
|
4
5
|
<script>addEventListener("error",function(){var s=document.getElementById("splash");if(!s||s.hasAttribute("data-live"))return;s.setAttribute("data-failed","");var t=s.querySelector(".splash-status");if(t)t.textContent="The app did not load. Reload the page."},true);</script>
|
|
5
6
|
<style>#splash{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:#fff;color:#1d1d1f;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;opacity:1;visibility:visible}
|
|
6
7
|
#splash[data-state="done"]{opacity:0;visibility:hidden;pointer-events:none;transition:opacity .25s ease,visibility 0s linear .25s}
|
|
@@ -25,11 +26,11 @@
|
|
|
25
26
|
<meta charset="utf-8" />
|
|
26
27
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
27
28
|
<title>Aula videos</title>
|
|
28
|
-
<script type="module" crossorigin src="./assets/
|
|
29
|
+
<script type="module" crossorigin src="./assets/8f69161f/index.js"></script>
|
|
29
30
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-BLXQ4ufn.js">
|
|
30
|
-
<link rel="modulepreload" crossorigin href="./assets/src-
|
|
31
|
-
<link rel="modulepreload" crossorigin href="./assets/protocol-
|
|
32
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
31
|
+
<link rel="modulepreload" crossorigin href="./assets/src-DWVrqSqZ.js">
|
|
32
|
+
<link rel="modulepreload" crossorigin href="./assets/protocol-47nVPHKy.js">
|
|
33
|
+
<link rel="stylesheet" crossorigin href="./assets/index-CFRTa3wf.css">
|
|
33
34
|
</head>
|
|
34
35
|
<body>
|
|
35
36
|
<div id="splash"><div class="splash-card"><p class="splash-name">aula</p><p class="splash-status" role="status">Loading aula…</p><div class="splash-bar" aria-hidden="true"><span></span></div><ul class="splash-stages"><li data-stage="app" data-mode="loading"><span class="splash-mark"></span><span class="splash-label">App</span><span class="splash-detail">Loading…</span></li><li data-stage="engine" data-mode="waiting"><span class="splash-mark"></span><span class="splash-label">Engine</span><span class="splash-detail">Waiting</span></li><li data-stage="videos" data-mode="waiting"><span class="splash-mark"></span><span class="splash-label">Videos</span><span class="splash-detail">Waiting</span></li><li data-stage="voice" data-mode="waiting"><span class="splash-mark"></span><span class="splash-label">Voice</span><span class="splash-detail">Waiting</span></li></ul><noscript><style>#splash .splash-status,#splash .splash-bar,#splash .splash-stages{display:none}</style><p class="splash-status">aula needs JavaScript to run.</p></noscript></div></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beff/aula-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The aula command: runs chapter modules on the @beff/aula engine, checks and lints them, writes PNG pictures for review, makes project zips, and serves the web player with narration.",
|
|
6
6
|
"license": "MIT AND GPL-3.0-or-later",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"esbuild-wasm": "^0.28.2",
|
|
27
|
-
"@beff/aula": "0.
|
|
27
|
+
"@beff/aula": "0.7.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
projectFiles,
|
|
3
|
-
zipBytes
|
|
4
|
-
} from "./chunk-6CZECZIX.js";
|
|
5
|
-
import {
|
|
6
|
-
VIDEO,
|
|
7
|
-
assemble,
|
|
8
|
-
ffmpeg,
|
|
9
|
-
hasAudio
|
|
10
|
-
} from "./chunk-BLKXJGEO.js";
|
|
11
|
-
import {
|
|
12
|
-
printDiagnostics
|
|
13
|
-
} from "./chunk-7C6QW2TD.js";
|
|
14
|
-
import {
|
|
15
|
-
chapterIndexes,
|
|
16
|
-
checkProject,
|
|
17
|
-
clipPlan,
|
|
18
|
-
clock,
|
|
19
|
-
exportCheck,
|
|
20
|
-
movesMarkdown,
|
|
21
|
-
narrationAt,
|
|
22
|
-
noteLine,
|
|
23
|
-
notesLine,
|
|
24
|
-
overlayPlan,
|
|
25
|
-
pictureGroups,
|
|
26
|
-
pictureStills,
|
|
27
|
-
previewJobs,
|
|
28
|
-
previewTargets,
|
|
29
|
-
scriptView,
|
|
30
|
-
targetChapters,
|
|
31
|
-
timelineView,
|
|
32
|
-
wordNotes
|
|
33
|
-
} from "./chunk-LSXILCMB.js";
|
|
34
|
-
import {
|
|
35
|
-
narrateScript,
|
|
36
|
-
scriptAudio,
|
|
37
|
-
wav
|
|
38
|
-
} from "./chunk-S74JLCZK.js";
|
|
39
|
-
import {
|
|
40
|
-
host
|
|
41
|
-
} from "./chunk-J7LNPVU2.js";
|
|
42
|
-
import {
|
|
43
|
-
folderOf,
|
|
44
|
-
nameOf
|
|
45
|
-
} from "./chunk-EZROW2IP.js";
|
|
46
|
-
import {
|
|
47
|
-
ObjectRuntype,
|
|
48
|
-
OptionalFieldRuntype,
|
|
49
|
-
RefRuntype,
|
|
50
|
-
TypeofRuntype,
|
|
51
|
-
buildParsers,
|
|
52
|
-
isError,
|
|
53
|
-
wrongArgument
|
|
54
|
-
} from "./chunk-3MPFI4UE.js";
|
|
55
|
-
|
|
56
|
-
// src/commands.ts
|
|
57
|
-
import path from "node:path";
|
|
58
|
-
import { m, renderChapter } from "@beff/aula";
|
|
59
|
-
import { chapterNames } from "@beff/aula/run";
|
|
60
|
-
import { narrationScript } from "@beff/aula/text";
|
|
61
|
-
|
|
62
|
-
// src/narrate.ts
|
|
63
|
-
function narrate(capabilities, chapters) {
|
|
64
|
-
return narrateScript(
|
|
65
|
-
(words) => capabilities.narrator.speak(words),
|
|
66
|
-
chapters,
|
|
67
|
-
(spoken, count, cue) => {
|
|
68
|
-
capabilities.log.out(`[${String(spoken)}/${String(count)}] Narrating: ${cue.text.slice(0, 70)}`);
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// generated/parser.js
|
|
74
|
-
var RequiredStringFormats = [];
|
|
75
|
-
var RequiredNumberFormats = [];
|
|
76
|
-
var namedRuntypes = {};
|
|
77
|
-
var stringFormatters = {};
|
|
78
|
-
var numberFormatters = {};
|
|
79
|
-
var direct_hoist_0 = new RefRuntype(void 0, "TokensLine", namedRuntypes);
|
|
80
|
-
var direct_hoist_1 = new TypeofRuntype(void 0, "string");
|
|
81
|
-
var direct_hoist_2 = new ObjectRuntype({
|
|
82
|
-
"description": "One input line of `aula tokens`: a text, and an optional id that the output line repeats."
|
|
83
|
-
}, {
|
|
84
|
-
"id": new OptionalFieldRuntype(direct_hoist_1),
|
|
85
|
-
"text": direct_hoist_1
|
|
86
|
-
}, []);
|
|
87
|
-
Object.assign(namedRuntypes, {
|
|
88
|
-
"TokensLine": direct_hoist_2
|
|
89
|
-
});
|
|
90
|
-
var buildParsersInput = {
|
|
91
|
-
"TokensLine": direct_hoist_0
|
|
92
|
-
};
|
|
93
|
-
var parser_default = {
|
|
94
|
-
buildParsers: (args) => buildParsers(
|
|
95
|
-
{
|
|
96
|
-
parsers: buildParsersInput,
|
|
97
|
-
stringFormatters,
|
|
98
|
-
numberFormatters,
|
|
99
|
-
requiredStringFormats: RequiredStringFormats,
|
|
100
|
-
requiredNumberFormats: RequiredNumberFormats
|
|
101
|
-
},
|
|
102
|
-
args
|
|
103
|
-
)
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// src/parsers.ts
|
|
107
|
-
var Parsers = parser_default.buildParsers();
|
|
108
|
-
|
|
109
|
-
// src/commands.ts
|
|
110
|
-
async function withHeavy(capabilities, f) {
|
|
111
|
-
const release = await capabilities.locks.heavy();
|
|
112
|
-
try {
|
|
113
|
-
return await f();
|
|
114
|
-
} finally {
|
|
115
|
-
await release();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
async function withWork(capabilities, f) {
|
|
119
|
-
const work = await capabilities.fs.mkdtemp(path.join(capabilities.env.temp, "aula-"));
|
|
120
|
-
try {
|
|
121
|
-
return await f(work);
|
|
122
|
-
} finally {
|
|
123
|
-
await capabilities.fs.rm(work, { recursive: true, force: true });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async function parallel(items, limit, task) {
|
|
127
|
-
let next = 0;
|
|
128
|
-
const worker = async () => {
|
|
129
|
-
for (let item = items[next++]; item !== void 0; item = items[next++]) await task(item);
|
|
130
|
-
};
|
|
131
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
132
|
-
}
|
|
133
|
-
async function drawChapter(capabilities, root, project, index, narration, lottie) {
|
|
134
|
-
const built = renderChapter(project, index, { host: host(capabilities, root), narration });
|
|
135
|
-
if (!built.ok || built.value === void 0) {
|
|
136
|
-
return { ok: false, findings: built.diagnostics, frames: 0, waits: [], embeds: [], narration };
|
|
137
|
-
}
|
|
138
|
-
await capabilities.fs.writeFile(lottie, built.value.lottie, "utf8");
|
|
139
|
-
const { frames, waits, embeds } = built.value;
|
|
140
|
-
return { ok: true, findings: built.diagnostics, frames, waits, embeds, narration: built.value.narration };
|
|
141
|
-
}
|
|
142
|
-
async function placedClips(capabilities, folder, overlays) {
|
|
143
|
-
return Promise.all(
|
|
144
|
-
overlays.map(async (o) => {
|
|
145
|
-
const file = path.join(folder, o.path);
|
|
146
|
-
const picture = o.image === void 0 ? void 0 : path.join(folder, o.image);
|
|
147
|
-
const video = o.kind === "video";
|
|
148
|
-
return {
|
|
149
|
-
file,
|
|
150
|
-
picture,
|
|
151
|
-
seen: video || picture !== void 0,
|
|
152
|
-
heard: !video || await hasAudio(capabilities, file),
|
|
153
|
-
at: o.at,
|
|
154
|
-
seconds: o.seconds
|
|
155
|
-
};
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
var inFolder = (folder, groups) => groups.map((group) => ({
|
|
160
|
-
...group,
|
|
161
|
-
tiles: group.tiles.map((tile) => {
|
|
162
|
-
const { embed } = tile;
|
|
163
|
-
if (embed?.picture === void 0) return tile;
|
|
164
|
-
return { ...tile, embed: { ...embed, picture: path.join(folder, embed.picture) } };
|
|
165
|
-
})
|
|
166
|
-
}));
|
|
167
|
-
var rowLine = (project, r) => `${nameOf(project)}: ${String(r.errors)} errors, ${String(r.warnings)} warnings, ${String(r.open)} open moves`;
|
|
168
|
-
async function printChecked(capabilities, root, project, checked) {
|
|
169
|
-
await printDiagnostics(capabilities, root, checked.findings);
|
|
170
|
-
printCounts(capabilities, project, checked);
|
|
171
|
-
}
|
|
172
|
-
function printCounts(capabilities, project, checked) {
|
|
173
|
-
const { errors, warnings } = checked.others;
|
|
174
|
-
if (errors + warnings > 0)
|
|
175
|
-
capabilities.log.out(`other chapters: ${String(errors)} errors, ${String(warnings)} warnings`);
|
|
176
|
-
capabilities.log.out(rowLine(project, checked));
|
|
177
|
-
}
|
|
178
|
-
async function check(capabilities, root, project, only, json = false) {
|
|
179
|
-
const chapters = chapterIndexes(project, only);
|
|
180
|
-
const checked = checkProject(project, host(capabilities, root), chapters);
|
|
181
|
-
const notes = wordNotes(narrationScript(project, checked.texts), chapters);
|
|
182
|
-
if (json) {
|
|
183
|
-
const { findings, others, errors, warnings, open } = checked;
|
|
184
|
-
const result = { name: nameOf(project), errors, warnings, openMoves: open, others, findings, notes };
|
|
185
|
-
capabilities.log.out(JSON.stringify(result, null, 2));
|
|
186
|
-
return errors === 0;
|
|
187
|
-
}
|
|
188
|
-
await printDiagnostics(capabilities, root, checked.findings);
|
|
189
|
-
for (const note of notes) capabilities.log.out(noteLine(note));
|
|
190
|
-
if (notes.length > 0) capabilities.log.out(notesLine(notes));
|
|
191
|
-
printCounts(capabilities, project, checked);
|
|
192
|
-
return checked.errors === 0;
|
|
193
|
-
}
|
|
194
|
-
async function script(capabilities, root, project) {
|
|
195
|
-
capabilities.log.write(scriptView(project, host(capabilities, root)));
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
async function timeline(capabilities, root, project, only) {
|
|
199
|
-
capabilities.log.write(await timelineView(project, host(capabilities, root), capabilities.narrator, only));
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
async function preview(capabilities, root, project, folder, given) {
|
|
203
|
-
const targets = previewTargets(project, given);
|
|
204
|
-
const only = targetChapters(targets, given);
|
|
205
|
-
const checked = checkProject(project, host(capabilities, root), only);
|
|
206
|
-
await printChecked(capabilities, root, project, checked);
|
|
207
|
-
if (checked.errors > 0) return false;
|
|
208
|
-
const all = checked.texts;
|
|
209
|
-
const jobs = previewJobs(targets, all).map((job) => ({
|
|
210
|
-
...job,
|
|
211
|
-
out: path.join(folder, job.base),
|
|
212
|
-
written: []
|
|
213
|
-
}));
|
|
214
|
-
return withWork(capabilities, async (work) => {
|
|
215
|
-
const stopped = [];
|
|
216
|
-
const waits = [];
|
|
217
|
-
await withHeavy(capabilities, async () => {
|
|
218
|
-
const n = await clock(capabilities.narrator, narrationScript(project, all), only, chapterNames(project));
|
|
219
|
-
for (const job of jobs) await capabilities.fs.rm(job.out, { recursive: true, force: true });
|
|
220
|
-
await parallel(jobs, capabilities.env.parallelism, async (job) => {
|
|
221
|
-
const lottie = path.join(work, `${job.base}.json`);
|
|
222
|
-
const drawn = await drawChapter(capabilities, root, project, job.index, narrationAt(n, job.index), lottie);
|
|
223
|
-
if (!drawn.ok) {
|
|
224
|
-
stopped.push(...drawn.findings);
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
waits.push(...drawn.findings.filter((d) => !isError(d)));
|
|
228
|
-
const { out } = job;
|
|
229
|
-
const { window, stills } = pictureStills(drawn.narration, job, drawn.frames, drawn.embeds);
|
|
230
|
-
const groups = inFolder(folderOf(project), pictureGroups(window, stills));
|
|
231
|
-
const sheets = await capabilities.render.pictures({ lottie, out, groups });
|
|
232
|
-
await capabilities.fs.mkdir(out, { recursive: true });
|
|
233
|
-
await capabilities.fs.writeFile(path.join(out, "moves.md"), movesMarkdown(stills));
|
|
234
|
-
job.written.push(path.join(out, "moves.md"), ...sheets);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
if (stopped.length) {
|
|
238
|
-
await printDiagnostics(capabilities, root, stopped);
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
await printDiagnostics(capabilities, root, waits);
|
|
242
|
-
for (const line of jobs.flatMap((job) => job.written)) capabilities.log.out(line);
|
|
243
|
-
return true;
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
async function exportVideo(capabilities, root, project, file) {
|
|
247
|
-
if (!file.endsWith(".mp4")) throw wrongArgument(`the video path must end in .mp4: ${file}`);
|
|
248
|
-
const names = chapterNames(project);
|
|
249
|
-
const checked = exportCheck(project, host(capabilities, root));
|
|
250
|
-
await printChecked(capabilities, root, project, checked);
|
|
251
|
-
if (checked.errors > 0) {
|
|
252
|
-
capabilities.log.out(`export ${nameOf(project)}: stopped at check: fix the errors above`);
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
await ffmpeg(capabilities, ["-version"]);
|
|
256
|
-
return withWork(capabilities, async (work) => {
|
|
257
|
-
const audio = path.join(work, "narration.wav");
|
|
258
|
-
const cues = narrationScript(project, checked.texts);
|
|
259
|
-
const narrated = await withHeavy(capabilities, () => narrate(capabilities, cues));
|
|
260
|
-
const lotties = names.map((name) => path.join(work, `${name}.json`));
|
|
261
|
-
const drawn = [];
|
|
262
|
-
const problems = [];
|
|
263
|
-
let done = 0;
|
|
264
|
-
await withHeavy(
|
|
265
|
-
capabilities,
|
|
266
|
-
() => parallel(
|
|
267
|
-
names.map((_, index) => index),
|
|
268
|
-
capabilities.env.parallelism,
|
|
269
|
-
async (index) => {
|
|
270
|
-
const narration = narrated[index]?.narration;
|
|
271
|
-
if (narration === void 0) throw new Error(`no narration of chapter ${String(index)}`);
|
|
272
|
-
const chapter = await drawChapter(capabilities, root, project, index, narration, lotties[index] ?? "");
|
|
273
|
-
drawn[index] = chapter;
|
|
274
|
-
if (!chapter.ok) problems.push(...chapter.findings);
|
|
275
|
-
done += 1;
|
|
276
|
-
capabilities.log.out(
|
|
277
|
-
`[${String(done)}/${String(names.length)}] ${names[index] ?? ""}: ${chapter.ok ? "drawn" : "FAILED"}`
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
)
|
|
281
|
-
);
|
|
282
|
-
if (problems.length) {
|
|
283
|
-
await printDiagnostics(capabilities, root, problems);
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
const { samples, sampleRate } = scriptAudio(
|
|
287
|
-
narrated,
|
|
288
|
-
drawn.map((d) => d.waits)
|
|
289
|
-
);
|
|
290
|
-
await capabilities.fs.writeFile(audio, wav(samples, sampleRate));
|
|
291
|
-
capabilities.log.out(`Narrated ${(samples.length / sampleRate / 60).toFixed(1)} minutes`);
|
|
292
|
-
const plan = clipPlan(
|
|
293
|
-
drawn.map((d) => d.narration),
|
|
294
|
-
VIDEO.fps
|
|
295
|
-
);
|
|
296
|
-
const clips = names.map((name) => path.join(work, `${name}.mp4`));
|
|
297
|
-
await withHeavy(
|
|
298
|
-
capabilities,
|
|
299
|
-
() => parallel(
|
|
300
|
-
names.map((_, index) => index),
|
|
301
|
-
capabilities.env.parallelism,
|
|
302
|
-
async (index) => {
|
|
303
|
-
const clip = plan.clips[index] ?? { from: 0, frames: 0 };
|
|
304
|
-
await capabilities.render.clip({ lottie: lotties[index] ?? "", out: clips[index] ?? "", ...clip });
|
|
305
|
-
}
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
await capabilities.fs.mkdir(path.dirname(file), { recursive: true });
|
|
309
|
-
const placed = await placedClips(
|
|
310
|
-
capabilities,
|
|
311
|
-
folderOf(project),
|
|
312
|
-
overlayPlan(
|
|
313
|
-
drawn.map((d) => d.narration),
|
|
314
|
-
drawn.map((d) => d.embeds)
|
|
315
|
-
)
|
|
316
|
-
);
|
|
317
|
-
const background = (project.theme ?? m.theme).background;
|
|
318
|
-
await assemble(capabilities, { work, clips, audio, seconds: plan.seconds, out: file, placed, background });
|
|
319
|
-
capabilities.log.out(file);
|
|
320
|
-
return true;
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
async function bundle(capabilities, project, file) {
|
|
324
|
-
if (!file.endsWith(".zip")) throw new Error(`the zip path must end in .zip: ${file}`);
|
|
325
|
-
const home = folderOf(project);
|
|
326
|
-
const root = path.parse(home).root;
|
|
327
|
-
const folder = path.relative(root, home).split(path.sep).join("/");
|
|
328
|
-
const esbuild = await import("esbuild-wasm");
|
|
329
|
-
let files;
|
|
330
|
-
try {
|
|
331
|
-
files = await projectFiles(capabilities, esbuild, root, folder);
|
|
332
|
-
} finally {
|
|
333
|
-
await esbuild.stop();
|
|
334
|
-
}
|
|
335
|
-
const entries = /* @__PURE__ */ new Map();
|
|
336
|
-
for (const [at, from] of files)
|
|
337
|
-
entries.set(at, new Uint8Array(await capabilities.fs.readFile(path.join(root, from))));
|
|
338
|
-
const zip = zipBytes(entries);
|
|
339
|
-
await capabilities.fs.mkdir(path.dirname(file), { recursive: true });
|
|
340
|
-
await capabilities.fs.writeFile(file, zip);
|
|
341
|
-
capabilities.log.out(`${file}: ${String(files.size)} files, ${String(Math.ceil(zip.length / 1024))} kB`);
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
async function tokens(capabilities, tokensOf, lines) {
|
|
345
|
-
let number = 0;
|
|
346
|
-
for await (const line of lines) {
|
|
347
|
-
number += 1;
|
|
348
|
-
if (!line.trim()) continue;
|
|
349
|
-
const parsed = Parsers.TokensLine.safeParse(JSON.parse(line));
|
|
350
|
-
if (!parsed.success) throw wrongArgument(`stdin line ${String(number)}: expected {"id"?: string, "text": string}`);
|
|
351
|
-
const { id, text } = parsed.data;
|
|
352
|
-
capabilities.log.out(JSON.stringify({ ...id === void 0 ? {} : { id }, batches: await tokensOf(text) }));
|
|
353
|
-
}
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
function tokensArgs(positional) {
|
|
357
|
-
if (positional.length > 0) throw wrongArgument("aula tokens takes no arguments", "run `aula help` for the usage");
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export {
|
|
361
|
-
check,
|
|
362
|
-
script,
|
|
363
|
-
timeline,
|
|
364
|
-
preview,
|
|
365
|
-
exportVideo,
|
|
366
|
-
bundle,
|
|
367
|
-
tokens,
|
|
368
|
-
tokensArgs
|
|
369
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./aula-voice-worker-C7UeMloK.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,b as n,i as r,l as i,o as a,p as o,s,t as c,x as l}from"./src-CTZjQYUv.js";function u(e,t){let r=e.titleParts??[{text:e.title}];return n.narrationScript([...r],s(e.lexicon??{}),[...t])}function d(e,t,r){return n.chapterNarration([...e],[...t],r)}function f(e){return n.estimateNarration([...e])}function p(e){return n.renderDiagnostic(e)}var m=`.!?…`,h=`,;:`,g=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?<=[${g(m)}])\\s+`),RegExp(`(?<=[${g(h)}])\\s+`),`${{path:`aula-voice.avw`,bytes:33478208,sha256:`7a6039017a2783f7f3954a3531148e761b683807ebd3bb1436505f72379e81a1`}.path}`;var ee=e=>Float64Array.from(e,e=>e.start);function te(e,t){if(t.length===0)return e;let n=new Float32Array(e.length+t.reduce((e,t)=>e+t.samples,0)),r=0,i=0;for(let a of t.toSorted((e,t)=>e.sample-t.sample)){let t=Math.min(a.sample,e.length);n.set(e.subarray(r,t),i),i+=t-r+a.samples,r=t}return n.set(e.subarray(r),i),n}function ne(e,t){let n=t.toSorted((e,t)=>e.sample-t.sample);return e.cues.map(e=>{let t=e.speechStartFrame,r=e.endFrame,i=n.filter(e=>e.sample<=t).reduce((e,t)=>e+t.samples,0),a=n.filter(e=>e.sample>t&&e.sample<r).map(e=>({sample:e.sample-t,samples:e.samples})),o=r-t+a.reduce((e,t)=>e+t.samples,0);return{at:t+i,length:o,waits:a}})}function re(e,t){let n=e.samples.length+t.waits.reduce((e,t)=>e+t.samples,0);if(n!==t.length)throw Error(`a speech of ${String(n)} samples with its waits, at a place of ${String(t.length)}`);return te(new Float32Array(e.samples),t.waits)}function ie(e,t){let n=t[0]?.sampleRate??0;if(t.some(e=>e.sampleRate!==n))throw Error(`the narrator changed its sample rate`);return d(e,t.map(e=>e.words?{samples:e.samples,starts:ee(e.words)}:{samples:e.samples}),n)}function ae(e){let t=e.trim(),n=``,r;if(t.startsWith(`at `)){let e=t.slice(3),i=/^(.*) \((.*)\)$/.exec(e);n=i?.[1]??``,r=i?.[2]??e}else{let e=t.lastIndexOf(`@`,t.search(/:\d+:\d+$/));if(e<0)return null;n=t.slice(0,e),r=t.slice(e+1)}let i=/^(.*):(\d+):(\d+)$/.exec(r);return i?.[1]===void 0||i[2]===void 0||i[3]===void 0?null:{functionName:n.replace(/^(async |new )/,``),url:i[1],line:Number(i[2]),column:Number(i[3])}}var oe=e=>t=>{let n=[];for(let r of(t.stack??``).split(`
|
|
2
|
-
`)){let t=ae(r);if(!t)continue;let i=e(t.url,t.line,t.column);n.push({function:t.functionName,file:i.file,line:i.line,col:i.column})}return n},_=e=>JSON.stringify(e.words);function se(e){let t=0xdeadbeef,n=0x41c6ce57;for(let r of e){for(let e=0;e<r.length;e++){let i=r.charCodeAt(e);t=Math.imul(t^i,0x9e3779b1),n=Math.imul(n^i,0x5f356495)}t=Math.imul(t^r.length^0x9e3779b9,0x9e3779b1),n=Math.imul(n^r.length^0x85ebca6b,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35),n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35),(n>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}function ce(e,t,n){let r=t=>{throw Error(`the speech of ${JSON.stringify(e.text)} is not on its clock: ${t}`)};(t.sampleRate!==n.sampleRate||t.samples.length!==n.samples)&&r(`${String(t.samples.length)} samples, and the clock has ${String(n.samples)}`);let i=n.words??[];t.words.length!==i.length&&r(`${String(t.words.length)} words, and the clock has ${String(i.length)}`),t.words.forEach((e,t)=>{let n=i[t]?.start;e.start!==n&&r(`word ${String(t+1)} starts at ${String(e.start)} s, and at ${String(n)} s on the clock`)})}var le=class{name;constructor(e){this.name=e}project=null;titles=[];script=[];estimates=[];knownRate=void 0;lengths=[];warnings=[];drawings=[];drawn=[];kept=new Map;place={chapter:0,seconds:0};stale=!1;halted=!1;running=!1;errors=[];watcher=null;done=Promise.resolve();changed(){this.watcher?.changed(this.state())}window(){if(this.script.length===0)return[];let e=Math.min(Math.max(this.place.chapter,0),this.script.length-1);return e+1<this.script.length?[e,e+1]:[e]}prune(){let e=this.window(),t=!1;for(let n=0;n<this.drawings.length;n++)e.includes(n)||(this.drawings[n]!==void 0&&(this.drawings[n]=void 0,t=!0),this.drawn[n]=!1);return t}rate(){return this.knownRate??this.drawings.find(e=>e!==void 0)?.chapter.rate??this.estimates[0]?.sampleRate??1}samples(e){let t=[0];return this.script.forEach((n,r)=>{let i=this.drawings[r]?.chapter.length??this.lengths[r],a=this.estimates[r],o=i===void 0?a?Math.round(a.endFrame*e/a.sampleRate):0:i;t.push((t[r]??0)+o)}),t}seconds(){let e=this.rate();return this.samples(e).map(t=>t/e)}order(){let e=this.window(),t=e[0];if(t===void 0)return[];let n=this.script[t]??[],r=this.drawn[t]?this.drawings[t]:void 0,i=0;if(r){let e=this.place.seconds*r.chapter.rate,t=r.places.findIndex(t=>t.at+t.length>e);i=t===-1?r.places.length:t}let a=n.map((e,n)=>[t,n]),o=e[1],s=o===void 0?[]:(this.script[o]??[]).map((e,t)=>[o,t]);return[...a.slice(i),...s,...a.slice(0,i)]}next(){for(let[e,t]of this.order()){let n=this.script[e]??[];if(!this.drawn[e]){let t=n.find(e=>!this.kept.has(_(e)));return t?{kind:`time`,cue:t}:{kind:`draw`,chapter:e}}let r=n[t];if(r&&!this.kept.get(_(r))?.speech)return{kind:`speak`,cue:r}}return null}sound(e,t){let n=this.kept.get(e);if(!n?.speech)return;let r=JSON.stringify(t.waits),i=n.sounds.get(r);return i||(i=re(n.speech,t),n.sounds.set(r,i)),i}draw(e,t){let n=this.script[t]??[],r=n.map(_),i=ie(n,r.map(e=>{let t=this.kept.get(e);if(!t)throw Error(`no clock of the cue ${e}`);return t.timing})),a=e.render(t,i);if(a._tag===`Left`)return a;let{lottie:o,waits:s,embeds:c,background:l,warnings:u}=a.right;this.drawn[t]=!0;let d=i.endFrame+s.reduce((e,t)=>e+t.samples,0);this.knownRate=i.sampleRate,this.lengths[t]=d,this.warnings[t]=u;let f=se([JSON.stringify([r,i,s,c,l]),o]);if(this.drawings[t]?.made===f)return{_tag:`Right`,right:void 0};let p=ne(i,s),m={animation:JSON.parse(o),rate:i.sampleRate,length:d,cues:p.map((e,t)=>({at:e.at,length:e.length,samples:this.sound(r[t]??``,e)})),embeds:c.map(({path:e,image:t,kind:n,start:r,frames:i})=>({path:e,...t===void 0?{}:{image:t},kind:n,background:l,at:r,seconds:i/60}))};return this.drawings[t]={made:f,chapter:m,keys:r,places:p},this.changed(),{_tag:`Right`,right:void 0}}spoken(e){let t=!1;this.drawings.forEach((n,r)=>{if(!n?.keys.includes(e))return;let i=n.chapter.cues.map((t,r)=>{let i=n.places[r];return n.keys[r]===e&&i?{...t,samples:this.sound(e,i)}:t});this.drawings[r]={...n,chapter:{...n.chapter,cues:i}},t=!0}),t&&this.changed()}forget(){let e=new Set(this.script.flat().map(_));for(let t of this.kept.keys())e.has(t)||this.kept.delete(t)}state(){let e=this.seconds(),t=e.pop()??0;return{building:this.running,timeline:this.script.map((t,n)=>({title:this.titles[n]??``,start:e[n]??0})),duration:t,errors:this.errors,warnings:this.warnings.flat(),chapters:this.drawings.map(e=>e?.chapter)}}};function ue(e){let t=null,n=!1,r=null,i=()=>(r=e.workspace.projects(),r),a=async t=>{if(!t.project){let e=await(r??i());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(e._tag===`Left`)return e;let n=e.right.find(e=>e.name===t.name);if(!n)throw Error(`the workspace has no project ${t.name}`);let a=await(n.readScript?.()??n.script());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(a._tag===`Left`)return a;let{script:o}=a.right;t.project=n,t.titles=n.titles,t.script=o,t.estimates=o.map(e=>f(e)),t.drawings.length!==o.length&&(t.drawings=Array.from({length:o.length},()=>void 0),t.lengths=Array.from({length:o.length},()=>void 0)),t.warnings=Array.from({length:o.length},()=>[]),t.drawn=Array.from({length:o.length},()=>!1),t.prune(),t.changed()}let n=t.project;for(let r=t.next();r&&!t.stale&&!t.halted;r=t.next()){if(r.kind===`draw`){if(await n.readChapter?.(r.chapter),t.stale||t.halted)break;let e=t.draw(n,r.chapter);if(e._tag===`Left`)return e;continue}let{cue:i}=r,a=_(i);if(r.kind===`time`){let n=await e.voice.time(i.words);t.kept.set(a,{timing:n,sounds:new Map});continue}let o=await e.voice.speak(i.words),s=t.kept.get(a);if(!s)throw Error(`no clock of the cue ${a}`);ce(i,o,s.timing),s.speech=o,t.spoken(a)}return!t.stale&&!t.halted&&t.forget(),{_tag:`Right`,right:void 0}},o=e=>{e.running=!0,e.done=(async()=>{try{for(;;){e.stale=!1;let t=await a(e);if(e.errors=t._tag===`Left`?t.left:[],!e.stale||e.halted)break}}finally{e.running=!1,e.changed()}})()};return{refresh:e=>{r=null;let i=t;!n&&i&&(i.place=e,i.project=null,i.running?i.stale=!0:o(i))},halt:()=>{r=null,t&&=(t.halted=!0,t.watcher=null,null)},stop:()=>{n=!0,t&&(t.halted=!0,t.watcher=null)},idle:()=>t?.done??Promise.resolve(),build:{list:async()=>{let e=await i();return e._tag===`Left`?e:{_tag:`Right`,right:e.right.map(({name:e,title:t,section:n})=>({name:e,title:t,...n===void 0?{}:{section:n}}))}},watch:(e,r)=>{n||(t?.name!==e&&(t&&(t.halted=!0,t.watcher=null),t=new le(e),o(t)),t.watcher=r,t.changed())},seek:(e,r)=>{t?.name===e&&(t.place=r,t.prune()&&t.changed(),!n&&!t.running&&t.project&&t.errors.length===0&&t.next()!==null&&o(t))}}}}var v=e=>{if(typeof e==`boolean`)return null;let t=e.anyOf==null?e.oneOf==null?null:`oneOf`:`anyOf`;if(t==null)return null;let n=e[t];if(n==null)return null;let r=n.filter(e=>!de(e));if(r.length===n.length||r.length===0)return null;let i=r.map(e=>v(e)??e);return i.length===1?i[0]:{...e,[t]:i}},de=e=>typeof e!=`boolean`&&e.type===`null`,y=e=>typeof e==`string`?`"${e}"`:typeof e==`number`||typeof e==`boolean`?`${e}`:typeof e==`bigint`?`${e}n`:e===null?`null`:Array.isArray(e)?`Array`:typeof e==`object`?`Object`:JSON.stringify(e),fe=e=>{if(e.length===0)return``;let t=e[0];for(let n of e.slice(1))n.startsWith(`[`)?t+=n:t+=`.`+n;return t},pe=(e,t)=>{let n=[...e,...t];return n.length>0?`(${fe(n)})`:``},b=e=>e.filter(e=>e.length>0).join(` `),me=(e,t,n)=>b([pe(t,e.path),[e.message,n?`received: ${y(e.received)}`:``].filter(e=>e.length>0).join(`, `)]),he=(e,t)=>{let n=pe(t,e.path),r=x(e.errors,[],!1);return b([n,[`Failed to decode one of (${r.length>5?r.slice(0,5).join(` OR `)+` and more...`:r.join(` | `)})`,`received: ${y(e.received)}`].filter(e=>e.length>0).join(`, `)])},x=(e,t,n)=>e.map(e=>`isUnionError`in e?he(e,t):me(e,t,n)),ge=(e,t=[])=>x(e,t,!0).map((e,t,n)=>n.length==1?b([e]):b([`#${t}`,e])).join(` | `),S=Object.getPrototypeOf({});function _e(e){function t(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function n(e){let t=0,n=e.length,r=Array(n);for(;t<n;++t)r[t]=p(e[t]);return r}function r(e){let n={};if(c&&Object.getPrototypeOf(e)!==S)return c(e);let r=s(e),i,a,o;for(i=0,a=r.length;i<a;++i)o=r[i],t(n,o,p(e[o]));return n}function i(e,t){let n=e.length,r=t.length,i=0,a=Array(n+r);for(;i<n;++i)a[i]=p(e[i]);for(i=0;i<r;++i)a[i+n]=p(t[i]);return a}let a=Object.prototype.propertyIsEnumerable;function o(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);for(let r=0,i=n.length;r<i;++r)a.call(e,n[r])&&t.push(n[r]);return t}let s=e?.symbols?o:Object.keys,c=typeof e?.cloneProtoObject==`function`?e.cloneProtoObject:void 0;function l(e){return typeof e==`object`&&!!e&&!(e instanceof RegExp)&&!(e instanceof Date)&&!(e instanceof Map)&&!(e instanceof Set)&&!ArrayBuffer.isView(e)}function u(e){return typeof e!=`object`||!e}let d=typeof Buffer<`u`?e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e)||e instanceof Buffer:e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e),f=e&&typeof e.mergeArray==`function`?e.mergeArray({clone:p,deepmerge:h,getKeys:s,isMergeableObject:l}):i;function p(e){return l(e)?Array.isArray(e)?n(e):r(e):e}function m(e,n){let r={},i=s(e),a=s(n),o,u,d;for(o=0,u=i.length;o<u;++o)d=i[o],a.indexOf(d)===-1&&t(r,d,p(e[d]));for(o=0,u=a.length;o<u;++o)d=a[o],i.indexOf(d)===-1?t(r,d,p(n[d])):c&&l(n[d])&&Object.getPrototypeOf(n[d])!==S?t(r,d,c(n[d])):t(r,d,h(e[d],n[d]));return r}function h(e,t){let n=Array.isArray(t),r=Array.isArray(e);return u(t)||t instanceof Map||t instanceof Set?t:d(e)?p(t):n&&r?f(e,t):n===r?m(e,t):p(t)}function g(){switch(arguments.length){case 0:return{};case 1:return p(arguments[0]);case 2:return h(arguments[0],arguments[1])}let e;for(let t=0,n=arguments.length;t<n;++t)e=h(e,arguments[t]);return e}return g}function ve(e){let t=e.deepmerge,n=e.clone;return function(e,r){let i=0,a=r.length,o=Math.max(e.length,r.length),s=Array(o);for(i=0;i<o;++i)i<a?s[i]=t(e[i],r[i]):s[i]=n(e[i]);return s}}_e({mergeArray:ve});function C(e,t,n){return[{message:t,path:[...e.path],received:n}]}function ye(e,t){let n=[];for(let r=0;r<=e.length;r++){n.push([r]);for(let i=1;i<=t.length;i++)n[r][i]=r===0?i:Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+(e[r-1]===t[i-1]?0:1)),r>1&&i>1&&e[r-1]===t[i-2]&&e[r-2]===t[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1))}return n[e.length][t.length]}function be(e,t,n,r){if(n==null){T(e,t);let n=C(e,`extra property`,r);return E(e),n}let i=null,a=Math.max(1,Math.floor(t.length/3));for(let e of n){let n=ye(t,e);n<=a&&n<t.length&&(i==null||n<a)&&(i=e,a=n)}let o=i==null?``:` Did you mean ${JSON.stringify(i)}?`,s=n.length===0?`none`:n.map(e=>JSON.stringify(e)).join(`, `);T(e,t);let c=C(e,`extra property.${o} Allowed: ${s}`,r);return E(e),c}function w(e,t,n,r,i){r.validate(e,i)||(T(e,n),t.push(...r.reportDecodeError(e,i)),E(e))}function T(e,t){e.path.push(t)}function E(e){e.path.pop()}function xe(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function Se(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function D(e,t){return e?.description==null?t:{...t,description:e.description}}function O(e){let t=e.replace(/\*\//g,`* /`).split(`
|
|
3
|
-
`);return t.length===1?`/** ${t[0]} */`:[`/**`,...t.map(e=>` * ${e}`),` */`].join(`
|
|
4
|
-
`)}function k(e,t){return t==null?{typeExpr:e}:{typeExpr:e,docText:t}}var A=class{metadata;constructor(e){this.metadata=e}describe(e){return k(this.describeTypeExpr(e),this.metadata?.description)}describeChildren(){return[]}};function j(e,t){return t.describe(e).typeExpr}function Ce(e){return e.docText==null?e.typeExpr:`${O(e.docText)}\n${e.typeExpr}`}function M(e,t){let n=`type ${e} = ${t.typeExpr};`;return t.docText==null?n:`${O(t.docText)}\n${n}`}function we(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)||/^(0|[1-9][0-9]*)$/.test(e)?e:JSON.stringify(e)}function N(e,t,n){let r=n instanceof I?`?`:``,i=n.describe(e);return{docText:i.docText,member:`${t}${r}: ${i.typeExpr}`}}function Te(e,t,n){return N(e,`[K in ${j(e,t)}]`,n)}function Ee(e){let t=`${e.member};`;return e.docText==null?t:`${O(e.docText)}\n${t}`}function P(e,t){if(e instanceof z)e.collectDescribeRefs(t);else for(let n of e.describeChildren())P(n,t)}var De=class extends A{typeName;constructor(e,t){super(e),this.typeName=t}describeTypeExpr(e){return this.typeName}schema(e){return D(this.metadata,{type:this.typeName})}validate(e,t){return typeof t===this.typeName}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return C(e,`expected `+this.typeName,t)}},F=class extends A{constructor(e){super(e)}describeTypeExpr(e){return`any`}schema(e){return D(this.metadata,{})}validate(e,t){return!0}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return C(e,`expected any`,t)}},Oe=class extends A{constructor(e){super(e)}describeTypeExpr(e){return`never`}schema(e){return D(this.metadata,{anyOf:[]})}validate(e,t){return!1}parseAfterValidation(e,t){throw Error(`unreachable`)}reportDecodeError(e,t){return C(e,`expected never`,t)}},ke=class extends A{itemParser;constructor(e,t){super(e),this.itemParser=t}schema(e){T(e,`[]`);let t=this.itemParser.schema(e);return E(e),D(this.metadata,{type:`array`,items:t})}validate(e,t){if(Array.isArray(t)){for(let n=0;n<t.length;n++){let r=t[n];if(!this.itemParser.validate(e,r))return!1}return!0}return!1}parseAfterValidation(e,t){return t.map(t=>this.itemParser.parseAfterValidation(e,t))}reportDecodeError(e,t){if(!Array.isArray(t))return C(e,`expected array`,t);let n=[];for(let r=0;r<t.length;r++)w(e,n,`[${r}]`,this.itemParser,t[r]);return n}describeTypeExpr(e){return`Array<${j(e,this.itemParser)}>`}describeChildren(){return[this.itemParser]}},I=class{t;constructor(e){this.t=e}schema(e){return{anyOf:[this.t.schema(e),{type:`null`}]}}validate(e,t){return t==null||this.t.validate(e,t)}parseAfterValidation(e,t){return t==null?t:this.t.parseAfterValidation(e,t)}reportDecodeError(e,t){return this.t.reportDecodeError(e,t)}describe(e){return this.t.describe(e)}describeChildren(){return[this.t]}},L=Object.prototype.hasOwnProperty;function R(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var Ae=class extends A{properties;indexedPropertiesParser;constructor(e,t,n){super(e),this.properties=t,this.indexedPropertiesParser=n}describeTypeExpr(e){let t=Object.keys(this.properties).sort().map(t=>{let n=this.properties[t];return N(e,we(t),n)}),n=this.indexedPropertiesParser.map(({key:t,value:n})=>Te(e,t,n)),r=[...t,...n];return r.some(e=>e.docText!=null)?r.length===0?`{}`:`{\n${r.map(Ee).join(`
|
|
5
|
-
`)}\n}`:`{ ${r.map(e=>e.member).join(`, `)} }`}describeChildren(){return[...Object.values(this.properties),...this.indexedPropertiesParser.flatMap(({key:e,value:t})=>[e,t])]}schema(e){let t={},n=new Set;for(let r in this.properties){T(e,r);let i=this.properties[r].schema(e),a=v(i);a==null?t[r]=i:(t[r]=a,n.add(r)),E(e)}let r=Object.keys(this.properties).filter(e=>!n.has(e)),i={type:`object`,properties:t,...r.length>0?{required:r}:{}},a=this.indexedPropertiesParser.map(({key:t,value:n})=>{T(e,`[key]`);let r=t.schema(e);E(e),T(e,`[value]`);let i=n.schema(e);return E(e),{type:`object`,additionalProperties:i,propertyNames:r}});if(a.length===0)return D(this.metadata,{...i,additionalProperties:!1});if(Object.keys(t).length===0&&a.length===1){let e=this.indexedPropertiesParser[0].value;return e instanceof Oe?D(this.metadata,{type:`object`,additionalProperties:!1}):e instanceof F?D(this.metadata,{...a[0],additionalProperties:!0}):D(this.metadata,a[0])}return D(this.metadata,{allOf:[i,...a]})}validate(e,t){if(typeof t==`object`&&!Array.isArray(t)&&t!==null){let n=Object.keys(this.properties);for(let r of n)if(!this.properties[r].validate(e,t[r]))return!1;if(this.indexedPropertiesParser.length>0){let n=Object.keys(t).filter(e=>!L.call(this.properties,e));for(let r of n){let n=!1;for(let i of this.indexedPropertiesParser){if(!i.key.validate(e,r))continue;let a=t[r];if(i.value.validate(e,a)){n=!0;break}}if(!n&&!this.leavesKeyToIntersection(e,t,r))return!1}}else if(e.disallowExtraProperties&&e.intersectionInput!==t&&Object.keys(t).filter(e=>!L.call(this.properties,e)).length>0)return!1;return!0}return!1}parseAfterValidation(e,t){let n={},r=Object.keys(t);if(e.objectKeyOrder===`input`)for(let i of r)if(L.call(this.properties,i))R(n,i,this.properties[i].parseAfterValidation(e,t[i]));else for(let r of this.indexedPropertiesParser){let a=t[i];if(r.key.validate(e,i)&&r.value.validate(e,a)){let t=r.value.parseAfterValidation(e,a);R(n,r.key.parseAfterValidation(e,i),t)}}else{let i=Object.keys(this.properties).sort();for(let r of i){if(!L.call(t,r))continue;let i=t[r];R(n,r,this.properties[r].parseAfterValidation(e,i))}if(this.indexedPropertiesParser.length>0){let i=r.filter(e=>!L.call(this.properties,e)).sort();for(let r of i){let i=t[r];for(let t of this.indexedPropertiesParser)if(t.key.validate(e,r)&&t.value.validate(e,i)){let a=t.value.parseAfterValidation(e,i);R(n,t.key.parseAfterValidation(e,r),a)}}}}return n}reportDecodeError(e,t){if(typeof t!=`object`||Array.isArray(t)||t===null)return C(e,`expected object`,t);let n=[],r=Object.keys(this.properties);for(let i of r)w(e,n,i,this.properties[i],t[i]);if(this.indexedPropertiesParser.length>0){let r=Object.keys(t).filter(e=>!L.call(this.properties,e));for(let i of r)if(!this.leavesKeyToIntersection(e,t,i))for(let r of this.indexedPropertiesParser){let a=r.key.validate(e,i),o=r.value.validate(e,t[i]);if(!(a&&o)){if(T(e,i),!a){let t=r.key.reportDecodeError(e,i);n.push(...t)}if(!o){let a=r.value.reportDecodeError(e,t[i]);n.push(...a)}E(e)}}}else if(e.disallowExtraProperties&&e.intersectionInput!==t){let n=Object.keys(t).filter(e=>!L.call(this.properties,e));if(n.length>0)return n.flatMap(n=>be(e,n,r,t[n]))}return n}allowedKeys(){return this.indexedPropertiesParser.length>0?null:Object.keys(this.properties)}leavesKeyToIntersection(e,t,n){return e.intersectionInput===t&&!this.indexedPropertiesParser.some(t=>t.key.validate(e,n))}},z=class extends A{refName;namedRuntypes;constructor(e,t,n){super(e),this.refName=t,this.namedRuntypes=n}getNamedRuntypes(){return this.namedRuntypes}describeTypeExpr(e){return this.refName}collectDescribeRefs(e){let t=this.refName;e.refCounts[t]=(e.refCounts[t]||0)+1,e.activeRefs.has(t)||e.visitedRefs.has(t)||(e.visitedRefs.add(t),e.activeRefs.add(t),P(this.getNamedRuntypes()[t],e),e.activeRefs.delete(t))}describe(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName],r=()=>k(t,this.metadata?.description);if(e.refCounts[t]>1)return e.activeRefs.has(t)||(e.definitions[t]??(e.activeRefs.add(t),e.definitions[t]=n.describe(e),e.activeRefs.delete(t))),r();let i=n.describe(e);return this.metadata?.description==null?i:k(i.typeExpr,this.metadata.description)}schema(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName];if(e.mode===`contextual`){let r=e.printingContext;if(r==null)throw Error(`INTERNAL ERROR: Missing SchemaPrintingContext`);if(!r.hasDefinition(t)&&!r.isDefinitionInProgress(t)){r.markDefinitionInProgress(t);let i=(r.getNamedTypeSchemaOverride(t)??n).schema(e);r.storeDefinition(t,i)}return D(this.metadata,{$ref:r.getRef(t)})}if(e.seen[t])return D(this.metadata,{});e.seen[t]=!0;var r=n.schema(e);return delete e.seen[t],D(this.metadata,r)}validate(e,t){return this.getNamedRuntypes()[this.refName].validate(e,t)}parseAfterValidation(e,t){return this.getNamedRuntypes()[this.refName].parseAfterValidation(e,t)}reportDecodeError(e,t){return this.getNamedRuntypes()[this.refName].reportDecodeError(e,t)}},je=class{_runtype;name;hideTypeNameInDescribe;constructor(e,t,n){this._runtype=e,this.name=t,this.hideTypeNameInDescribe=n}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;let r=ge(n.errors,[]);throw Error(`Failed to parse ${this.name} - ${r}`)}safeParse(e,t){let n=t?.disallowExtraProperties??!1,r=t?.objectKeyOrder??`input`;if(this.validate(e,t)){let t={disallowExtraProperties:n,objectKeyOrder:r};return{success:!0,data:this._runtype.parseAfterValidation(t,e)}}let i={path:[],disallowExtraProperties:n};return{success:!1,errors:this._runtype.reportDecodeError(i,e).slice(0,10)}}validate(e,t){let n={disallowExtraProperties:t?.disallowExtraProperties??!1},r=this._runtype.validate(n,e);if(typeof r!=`boolean`)throw Error(`INTERNAL ERROR: Expected boolean`);return r}schema(){return this._runtype.schema({path:[],seen:{},mode:`flat`})}schemaWithContext(e){let t={path:[],seen:{},mode:`contextual`,printingContext:e};return this._runtype.schema(t)}describe(){let e={activeRefs:new Set,definitions:{},refCounts:{},visitedRefs:new Set};P(this._runtype,e);let t=this._runtype.describe(e),n=Object.keys(e.definitions).sort().map(t=>[t,e.definitions[t]]).map(([e,t])=>M(e,t)).join(`
|
|
6
|
-
|
|
7
|
-
`);return this.hideTypeNameInDescribe?[n,Ce(t)].filter(e=>e!=null&&e.length>0).join(`
|
|
8
|
-
|
|
9
|
-
`):[n,M(`Codec${this.name}`,t)].filter(e=>e!=null&&e.length>0).join(`
|
|
10
|
-
|
|
11
|
-
`)}},Me=(e,t,n)=>new je(e,t,n),Ne=(e,t)=>{let n=t?.stringFormats??{};for(let t of e.requiredStringFormats)if(n[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(n).forEach(t=>{let r=n[t];xe(e.stringFormatters,t,r)});let r=t?.numberFormats??{};for(let t of e.requiredNumberFormats)if(r[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(r).forEach(t=>{let n=r[t];Se(e.numberFormatters,t,n)});let i={};for(let t of Object.keys(e.parsers))i[t]=Me(e.parsers[t],t,!1);return i},Pe=[],Fe=[],B={},Ie={},Le={},Re=new z(void 0,`PackageJson`,B),ze=new F(void 0),V=new De(void 0,`string`),Be=new ke(void 0,V),Ve=new Ae({description:`The part of a package.json that aula reads: how a package names its module and its
|
|
12
|
-
workspace packages.`},{exports:new I(ze),main:new I(V),module:new I(V),name:new I(V),workspaces:new I(Be)},[]);Object.assign(B,{PackageJson:Ve});var He={PackageJson:Re},Ue={buildParsers:e=>Ne({parsers:He,stringFormatters:Ie,numberFormatters:Le,requiredStringFormats:Pe,requiredNumberFormats:Fe},e)}.buildParsers();function We(e,t){let n=[...e];return{read:t,list:e=>{let t=e===``?``:`${e}/`,r=new Set;for(let e of n){if(!e.startsWith(t))continue;let[n,...i]=e.slice(t.length).split(`/`);n!==void 0&&i.length>0&&r.add(n)}return Promise.resolve([...r].toSorted())}}}var H=`tree:`;function U(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function W(e,t){let n=e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(!n.length)return null;n.pop()}else n.push(e)}return n.join(`/`)}var Ge=new Map([[`ts`,`ts`],[`mts`,`ts`],[`js`,`js`],[`mjs`,`js`],[`json`,`json`]]),Ke=e=>Ge.get(e.slice(e.lastIndexOf(`.`)+1))??`ts`;function qe(e,t){return{name:`aula-tree`,setup(n){n.onResolve({filter:/.*/},async n=>{let r=t[n.path];if(r!==void 0)return{path:r,external:!0};if(n.kind===`entry-point`)return{path:W(``,n.path)??n.path,namespace:`tree`};if(!n.path.startsWith(`./`)&&!n.path.startsWith(`../`)){let t=await et(e,n.path,n.importer);return t===null?{errors:[{text:`cannot find the package "${n.path}" in node_modules or the workspace packages`}]}:{path:t,namespace:`tree`}}let i=W(U(n.importer),n.path);if(i===null)return{errors:[{text:`"${n.path}" is outside the folder you opened`}]};for(let t of[i,`${i}.ts`,`${i}/index.ts`])if(await e.read(t)!==null)return{path:t,namespace:`tree`};return{errors:[{text:`cannot find "${n.path}" (${i})`}]}}),n.onLoad({filter:/.*/,namespace:`tree`},async t=>{let n=await e.read(t.path);return n===null?{errors:[{text:`cannot read ${t.path}`}]}:{contents:n,loader:Ke(t.path)}})}}}function Je(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`text`)==`string`}var Ye=({text:e,location:t})=>({severity:`error`,message:e,...t?{location:{file:t.file.replace(H,``),line:t.line,col:t.column+1}}:{},stack:[],related:[]});async function Xe(e,t,n,r){let i;try{i=await e.build({entryPoints:[n],bundle:!0,write:!1,format:`esm`,platform:`browser`,target:`es2024`,outfile:`bundle.js`,sourcemap:`both`,sourcesContent:!1,metafile:!0,logLevel:`silent`,plugins:[qe(t,r)]})}catch(e){let t=typeof e==`object`&&e?Reflect.get(e,`errors`):void 0;if(Array.isArray(t)&&t.every(Je))return{_tag:`Left`,left:t.map(Ye)};throw e}let a=i.outputFiles.find(e=>e.path.endsWith(`.js`))?.text,o=i.outputFiles.find(e=>e.path.endsWith(`.js.map`))?.text;if(a===void 0||o===void 0)throw Error(`esbuild wrote no bundle`);return{_tag:`Right`,right:{code:a,map:o,inputs:Object.keys(i.metafile?.inputs??{}).filter(e=>e.startsWith(H)).map(e=>e.slice(5))}}}function G(e,t){if(typeof e==`string`)return t===`.`?e:null;if(typeof e!=`object`||!e)return null;if(Object.keys(e).some(e=>e.startsWith(`.`)))return t in e?G(Reflect.get(e,t),`.`):null;for(let t of[`browser`,`import`,`default`])if(t in e)return G(Reflect.get(e,t),`.`);return null}function K(e){let t=e.split(`/`),n=e.startsWith(`@`)?2:1,r=t.slice(n).join(`/`);return{name:t.slice(0,n).join(`/`),subpath:r===``?`.`:`./${r}`}}async function Ze(e,t,n){let r=q(`${t}/package.json`,await e.read(`${t}/package.json`));return r?W(t,G(r.exports,n)??(n===`.`?r.module??r.main??`index.js`:n)):null}async function Qe(e,t,n){let{name:r,subpath:i}=K(t);for(let t=U(n);;t=U(t)){let n=await Ze(e,t===``?`node_modules/${r}`:`${t}/node_modules/${r}`,i);if(n!==null)return n;if(t===``)return null}}function q(e,t){if(t===null)return null;let n=Ue.PackageJson.safeParse(JSON.parse(t));return n.success?n.data:null}async function $e(e){let t=[],n=await e.read(`pnpm-workspace.yaml`);if(n!==null){let e=!1;for(let r of n.split(`
|
|
13
|
-
`))if(/^packages:\s*$/.test(r))e=!0;else if(/^\S/.test(r))e=!1;else if(e){let e=/^\s*-\s*["']?([^"'#]+?)["']?\s*(#.*)?$/.exec(r)?.[1];e!==void 0&&t.push(e)}}t.push(...q(`package.json`,await e.read(`package.json`))?.workspaces??[]);let r=[];for(let n of t){let t=n.replace(/^\.\//,``).replace(/\/$/,``);if(t.endsWith(`/*`)){let n=t.slice(0,-2);r.push(...(await e.list(n)).map(e=>`${n}/${e}`))}else t.includes(`*`)||r.push(t)}return r}async function et(e,t,n){let r=await Qe(e,t,n);if(r!==null)return r;let{name:i,subpath:a}=K(t);for(let t of await $e(e))if(q(`${t}/package.json`,await e.read(`${t}/package.json`))?.name===i)return Ze(e,t,a);return null}var J=/^(\d+)-/,Y=e=>e.replace(J,``);function tt(e){let t=Y(e).replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var X=(e,t)=>e<t?-1:+(e>t);function nt(e,t){let n=J.exec(e)?.[1],r=J.exec(t)?.[1];if(n===void 0||r===void 0){if(n!==r)return n===void 0?1:-1}else{let[e,t]=[n.replace(/^0+/,``),r.replace(/^0+/,``)],i=e.length-t.length||X(e,t);if(i!==0)return i}return X(Y(e),Y(t))||X(e,t)}async function rt(e,t){return(await e.list(t)).filter(e=>e!==`node_modules`&&!e.startsWith(`.`)).toSorted(nt)}var Z=async(e,t)=>await e.read(t)!==null;async function it(e,t){if(await Z(e,`index.ts`))return{_tag:`Right`,right:[{module:`index.ts`,name:Y(t)}]};let n=[];for(let t of await rt(e,``))if(await Z(e,`${t}/index.ts`))n.push({module:`${t}/index.ts`,name:Y(t)});else for(let r of await rt(e,t)){let i=`${t}/${r}/index.ts`;await Z(e,i)&&n.push({module:i,name:Y(r),section:tt(t)})}let r=[];return n.forEach((e,t)=>{let i=n.findIndex(t=>t.name===e.name);if(i===t)return;let a=[n[i],e].map(e=>(e?.module??``).slice(0,-9));r.push({severity:`error`,message:`two projects have the name ${e.name}: ${a.join(` and `)}`,hint:`the name of a project is its folder name without the order prefix: rename one of the folders`,stack:[],related:[]})}),r.length>0?{_tag:`Left`,left:r}:{_tag:`Right`,right:n}}var at=(e,t)=>({frames:e,name:e=>/^[a-z][a-z0-9+.-]*:/.test(e)?void 0:e,exists:()=>!0,...t?{media:t}:{}}),ot=(e,t)=>typeof e==`object`&&e?Reflect.get(e,t):void 0,Q=`aula-projects.ts`;async function st(t,n,i,a,s,c){let u=await it(t,await t.name());if(u._tag===`Left`)return u;let d=u.right.map(e=>e.module);if(d.length===0)throw Error(`no project here: open a folder that has index.ts, or whose subfolders have index.ts`);let f=[...d.map((e,t)=>`import p${String(t)} from ${JSON.stringify(`./${e}`)};`),`export default [${d.map((e,t)=>`p${String(t)}`).join(`, `)}];`].join(`
|
|
14
|
-
`),[p]=await Promise.all([Xe(a,{read:e=>e===Q?Promise.resolve(f):t.read(e),list:e=>t.list(e)},Q,s),l().then(()=>{c?.()})]);if(p._tag===`Left`)return p;let m=await e(()=>i.load(p.right));if(m._tag===`Left`)return{_tag:`Left`,left:[r(m.left,Q,n)]};let h=ot(m.right.exports,`default`);if(!Array.isArray(h))throw Error(`${Q} has no list of projects`);return{_tag:`Right`,right:h.map((e,t)=>{if(!o(e))throw Error(`the default export of ${d[t]??``} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ … ] })\``);let{name:r,section:i}=u.right[t]??{name:``};return ct(r,i,e,n)})}}function ct(e,n,r,o){let s=r.chapters.length+1;return{name:e,...n===void 0?{}:{section:n},title:r.title,chapters:s,titles:[r.title,...r.chapters.map(e=>e.heading)],script:()=>{let e=[];for(let n of r.chapters.keys()){let i=t(r,n+1,{host:o});if(i.value===void 0)return{_tag:`Left`,left:i.diagnostics};e.push(i.value)}return{_tag:`Right`,right:{script:u(r,e)}}},walk:e=>{e>0&&c(r,e,{host:o})},render:(e,t)=>{let n=a(r,e,{host:o,narration:t});if(!n.ok||n.value===void 0)return{_tag:`Left`,left:n.diagnostics};let{lottie:s,waits:c,embeds:l,diagnostics:u}=n.value;return{_tag:`Right`,right:{lottie:s,waits:c,embeds:l,background:(r.theme??i).background,warnings:u}}}}}function lt(e){return e}function ut(e,t){return Object.assign({},e,t)}function dt(e,t){return{...e,...t}}function ft(...e){return Object.assign({},...e)}var pt={create:lt,extend:ut,merge:ft,override:dt},mt=class extends Error{constructor(e,t){super(e),this.stack=t}};function ht(e,t,n){return e===``?``:` at ${e}:${String(t)}:${String(n)}`}var $=e=>`${e.file}:${String(e.line)}:${String(e.col)}`;function gt(e,t){if(!(e instanceof Error))return{message:String(e),place:null,stack:[]};let n=t(e),[r]=n;return{message:e.name===`Error`||e.name===``?e.message:`${e.name}: ${e.message}`,place:r?$(r):null,stack:n.map(e=>e.function===``?`at ${$(e)}`:`at ${e.function} (${$(e)})`)}}function _t(e,t,n){let r=(t,n,r)=>{let i=e.createElement(t);return i.className=n,i.textContent=r,i},i=r(`div`,`crash`,``);i.setAttribute(`role`,`alert`),i.append(r(`h1`,``,`The app stopped because of an error.`),r(`p`,`message`,t.message)),t.place!==null&&i.append(r(`p`,`place`,`at ${t.place}`)),t.stack.length>0&&i.append(r(`pre`,`stack`,t.stack.join(`
|
|
15
|
-
`)));let a=r(`button`,`reload`,`Reload`);a.addEventListener(`click`,n),i.append(a),e.body.replaceChildren(i)}var vt=2e5;function yt(e){let{layers:t,...n}=e,r=[JSON.stringify({...n,layers:[]})],i=[],a=0;for(let e of t){let t=JSON.stringify(e);a>0&&a+t.length>vt&&(r.push(`[${i.join(`,`)}]`),i=[],a=0),i.push(t),a+=t.length+1}return i.length>0&&r.push(`[${i.join(`,`)}]`),r}async function bt(e,t){let[n,...r]=e;if(n===void 0)throw Error(`a Lottie animation with no parts`);let i=JSON.parse(n);for(let e of r){await t();let n=JSON.parse(e);i.layers.push(...n)}return i}var xt=e=>e.map(e=>({...e,text:p(e)}));function St(e){let t=Reflect.get(e,`text`);if(typeof t!=`string`)throw Error(`a diagnostic with no text: ${e.message}`);return t}export{mt as a,_t as c,at as d,H as f,oe as h,yt as i,pt as l,ue as m,xt as n,gt as o,We as p,bt as r,ht as s,St as t,st as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./aula-voice-worker-DHEZKCCg.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{S as e,a as t,b as n,i as r,l as i,o as a,p as o,s,t as c,x as l}from"./src-1_dQqt80.js";function u(e,t){let r=e.titleParts??[{text:e.title}];return n.narrationScript([...r],s(e.lexicon??{}),[...t])}function d(e,t,r){return n.chapterNarration([...e],[...t],r)}function f(e){return n.estimateNarration([...e])}function p(e){return n.renderDiagnostic(e)}var m=`.!?…`,h=`,;:`,g=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?<=[${g(m)}])\\s+`),RegExp(`(?<=[${g(h)}])\\s+`),`${{path:`aula-voice.avw`,bytes:33478208,sha256:`7a6039017a2783f7f3954a3531148e761b683807ebd3bb1436505f72379e81a1`}.path}`;var ee=e=>Float64Array.from(e,e=>e.start);function te(e,t){if(t.length===0)return e;let n=new Float32Array(e.length+t.reduce((e,t)=>e+t.samples,0)),r=0,i=0;for(let a of t.toSorted((e,t)=>e.sample-t.sample)){let t=Math.min(a.sample,e.length);n.set(e.subarray(r,t),i),i+=t-r+a.samples,r=t}return n.set(e.subarray(r),i),n}function ne(e,t){let n=t.toSorted((e,t)=>e.sample-t.sample);return e.cues.map(e=>{let t=e.speechStartFrame,r=e.endFrame,i=n.filter(e=>e.sample<=t).reduce((e,t)=>e+t.samples,0),a=n.filter(e=>e.sample>t&&e.sample<r).map(e=>({sample:e.sample-t,samples:e.samples})),o=r-t+a.reduce((e,t)=>e+t.samples,0);return{at:t+i,length:o,waits:a}})}function re(e,t){let n=e.samples.length+t.waits.reduce((e,t)=>e+t.samples,0);if(n!==t.length)throw Error(`a speech of ${String(n)} samples with its waits, at a place of ${String(t.length)}`);return te(new Float32Array(e.samples),t.waits)}function ie(e,t){let n=t[0]?.sampleRate??0;if(t.some(e=>e.sampleRate!==n))throw Error(`the narrator changed its sample rate`);return d(e,t.map(e=>e.words?{samples:e.samples,starts:ee(e.words)}:{samples:e.samples}),n)}function ae(e){let t=e.trim(),n=``,r;if(t.startsWith(`at `)){let e=t.slice(3),i=/^(.*) \((.*)\)$/.exec(e);n=i?.[1]??``,r=i?.[2]??e}else{let e=t.lastIndexOf(`@`,t.search(/:\d+:\d+$/));if(e<0)return null;n=t.slice(0,e),r=t.slice(e+1)}let i=/^(.*):(\d+):(\d+)$/.exec(r);return i?.[1]===void 0||i[2]===void 0||i[3]===void 0?null:{functionName:n.replace(/^(async |new )/,``),url:i[1],line:Number(i[2]),column:Number(i[3])}}var oe=e=>t=>{let n=[];for(let r of(t.stack??``).split(`
|
|
2
|
-
`)){let t=ae(r);if(!t)continue;let i=e(t.url,t.line,t.column);n.push({function:t.functionName,file:i.file,line:i.line,col:i.column})}return n},_=e=>JSON.stringify(e.words);function se(e){let t=0xdeadbeef,n=0x41c6ce57;for(let r of e){for(let e=0;e<r.length;e++){let i=r.charCodeAt(e);t=Math.imul(t^i,0x9e3779b1),n=Math.imul(n^i,0x5f356495)}t=Math.imul(t^r.length^0x9e3779b9,0x9e3779b1),n=Math.imul(n^r.length^0x85ebca6b,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35),n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35),(n>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}function ce(e,t,n){let r=t=>{throw Error(`the speech of ${JSON.stringify(e.text)} is not on its clock: ${t}`)};(t.sampleRate!==n.sampleRate||t.samples.length!==n.samples)&&r(`${String(t.samples.length)} samples, and the clock has ${String(n.samples)}`);let i=n.words??[];t.words.length!==i.length&&r(`${String(t.words.length)} words, and the clock has ${String(i.length)}`),t.words.forEach((e,t)=>{let n=i[t]?.start;e.start!==n&&r(`word ${String(t+1)} starts at ${String(e.start)} s, and at ${String(n)} s on the clock`)})}var le=class{name;constructor(e){this.name=e}project=null;titles=[];script=[];estimates=[];knownRate=void 0;lengths=[];warnings=[];drawings=[];drawn=[];kept=new Map;place={chapter:0,seconds:0};stale=!1;halted=!1;running=!1;errors=[];watcher=null;done=Promise.resolve();changed(){this.watcher?.changed(this.state())}window(){if(this.script.length===0)return[];let e=Math.min(Math.max(this.place.chapter,0),this.script.length-1);return e+1<this.script.length?[e,e+1]:[e]}prune(){let e=this.window(),t=!1;for(let n=0;n<this.drawings.length;n++)e.includes(n)||(this.drawings[n]!==void 0&&(this.drawings[n]=void 0,t=!0),this.drawn[n]=!1);return t}rate(){return this.knownRate??this.drawings.find(e=>e!==void 0)?.chapter.rate??this.estimates[0]?.sampleRate??1}samples(e){let t=[0];return this.script.forEach((n,r)=>{let i=this.drawings[r]?.chapter.length??this.lengths[r],a=this.estimates[r],o=i===void 0?a?Math.round(a.endFrame*e/a.sampleRate):0:i;t.push((t[r]??0)+o)}),t}seconds(){let e=this.rate();return this.samples(e).map(t=>t/e)}order(){let e=this.window(),t=e[0];if(t===void 0)return[];let n=this.script[t]??[],r=this.drawn[t]?this.drawings[t]:void 0,i=0;if(r){let e=this.place.seconds*r.chapter.rate,t=r.places.findIndex(t=>t.at+t.length>e);i=t===-1?r.places.length:t}let a=n.map((e,n)=>[t,n]),o=e[1],s=o===void 0?[]:(this.script[o]??[]).map((e,t)=>[o,t]);return[...a.slice(i),...s,...a.slice(0,i)]}next(){for(let[e,t]of this.order()){let n=this.script[e]??[];if(!this.drawn[e]){let t=n.find(e=>!this.kept.has(_(e)));return t?{kind:`time`,cue:t}:{kind:`draw`,chapter:e}}let r=n[t];if(r&&!this.kept.get(_(r))?.speech)return{kind:`speak`,cue:r}}return null}sound(e,t){let n=this.kept.get(e);if(!n?.speech)return;let r=JSON.stringify(t.waits),i=n.sounds.get(r);return i||(i=re(n.speech,t),n.sounds.set(r,i)),i}draw(e,t){let n=this.script[t]??[],r=n.map(_),i=ie(n,r.map(e=>{let t=this.kept.get(e);if(!t)throw Error(`no clock of the cue ${e}`);return t.timing})),a=e.render(t,i);if(a._tag===`Left`)return a;let{lottie:o,waits:s,embeds:c,background:l,warnings:u}=a.right;this.drawn[t]=!0;let d=i.endFrame+s.reduce((e,t)=>e+t.samples,0);this.knownRate=i.sampleRate,this.lengths[t]=d,this.warnings[t]=u;let f=se([JSON.stringify([r,i,s,c,l]),o]);if(this.drawings[t]?.made===f)return{_tag:`Right`,right:void 0};let p=ne(i,s),m={animation:JSON.parse(o),rate:i.sampleRate,length:d,cues:p.map((e,t)=>({at:e.at,length:e.length,samples:this.sound(r[t]??``,e)})),embeds:c.map(({path:e,image:t,kind:n,start:r,frames:i})=>({path:e,...t===void 0?{}:{image:t},kind:n,background:l,at:r,seconds:i/60}))};return this.drawings[t]={made:f,chapter:m,keys:r,places:p},this.changed(),{_tag:`Right`,right:void 0}}spoken(e){let t=!1;this.drawings.forEach((n,r)=>{if(!n?.keys.includes(e))return;let i=n.chapter.cues.map((t,r)=>{let i=n.places[r];return n.keys[r]===e&&i?{...t,samples:this.sound(e,i)}:t});this.drawings[r]={...n,chapter:{...n.chapter,cues:i}},t=!0}),t&&this.changed()}forget(){let e=new Set(this.script.flat().map(_));for(let t of this.kept.keys())e.has(t)||this.kept.delete(t)}state(){let e=this.seconds(),t=e.pop()??0;return{building:this.running,timeline:this.script.map((t,n)=>({title:this.titles[n]??``,start:e[n]??0})),duration:t,errors:this.errors,warnings:this.warnings.flat(),chapters:this.drawings.map(e=>e?.chapter)}}};function ue(e){let t=null,n=!1,r=null,i=()=>(r=e.workspace.projects(),r),a=async t=>{if(!t.project){let e=await(r??i());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(e._tag===`Left`)return e;let n=e.right.find(e=>e.name===t.name);if(!n)throw Error(`the workspace has no project ${t.name}`);let a=await(n.readScript?.()??n.script());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(a._tag===`Left`)return a;let{script:o}=a.right;t.project=n,t.titles=n.titles,t.script=o,t.estimates=o.map(e=>f(e)),t.drawings.length!==o.length&&(t.drawings=Array.from({length:o.length},()=>void 0),t.lengths=Array.from({length:o.length},()=>void 0)),t.warnings=Array.from({length:o.length},()=>[]),t.drawn=Array.from({length:o.length},()=>!1),t.prune(),t.changed()}let n=t.project;for(let r=t.next();r&&!t.stale&&!t.halted;r=t.next()){if(r.kind===`draw`){if(await n.readChapter?.(r.chapter),t.stale||t.halted)break;let e=t.draw(n,r.chapter);if(e._tag===`Left`)return e;continue}let{cue:i}=r,a=_(i);if(r.kind===`time`){let n=await e.voice.time(i.words);t.kept.set(a,{timing:n,sounds:new Map});continue}let o=await e.voice.speak(i.words),s=t.kept.get(a);if(!s)throw Error(`no clock of the cue ${a}`);ce(i,o,s.timing),s.speech=o,t.spoken(a)}return!t.stale&&!t.halted&&t.forget(),{_tag:`Right`,right:void 0}},o=e=>{e.running=!0,e.done=(async()=>{try{for(;;){e.stale=!1;let t=await a(e);if(e.errors=t._tag===`Left`?t.left:[],!e.stale||e.halted)break}}finally{e.running=!1,e.changed()}})()};return{refresh:e=>{r=null;let i=t;!n&&i&&(i.place=e,i.project=null,i.running?i.stale=!0:o(i))},halt:()=>{r=null,t&&=(t.halted=!0,t.watcher=null,null)},stop:()=>{n=!0,t&&(t.halted=!0,t.watcher=null)},idle:()=>t?.done??Promise.resolve(),build:{list:async()=>{let e=await i();return e._tag===`Left`?e:{_tag:`Right`,right:e.right.map(({name:e,title:t,section:n})=>({name:e,title:t,...n===void 0?{}:{section:n}}))}},watch:(e,r)=>{n||(t?.name!==e&&(t&&(t.halted=!0,t.watcher=null),t=new le(e),o(t)),t.watcher=r,t.changed())},seek:(e,r)=>{t?.name===e&&(t.place=r,t.prune()&&t.changed(),!n&&!t.running&&t.project&&t.errors.length===0&&t.next()!==null&&o(t))}}}}var v=e=>{if(typeof e==`boolean`)return null;let t=e.anyOf==null?e.oneOf==null?null:`oneOf`:`anyOf`;if(t==null)return null;let n=e[t];if(n==null)return null;let r=n.filter(e=>!de(e));if(r.length===n.length||r.length===0)return null;let i=r.map(e=>v(e)??e);return i.length===1?i[0]:{...e,[t]:i}},de=e=>typeof e!=`boolean`&&e.type===`null`,y=e=>typeof e==`string`?`"${e}"`:typeof e==`number`||typeof e==`boolean`?`${e}`:typeof e==`bigint`?`${e}n`:e===null?`null`:Array.isArray(e)?`Array`:typeof e==`object`?`Object`:JSON.stringify(e),fe=e=>{if(e.length===0)return``;let t=e[0];for(let n of e.slice(1))n.startsWith(`[`)?t+=n:t+=`.`+n;return t},pe=(e,t)=>{let n=[...e,...t];return n.length>0?`(${fe(n)})`:``},b=e=>e.filter(e=>e.length>0).join(` `),me=(e,t,n)=>b([pe(t,e.path),[e.message,n?`received: ${y(e.received)}`:``].filter(e=>e.length>0).join(`, `)]),he=(e,t)=>{let n=pe(t,e.path),r=x(e.errors,[],!1);return b([n,[`Failed to decode one of (${r.length>5?r.slice(0,5).join(` OR `)+` and more...`:r.join(` | `)})`,`received: ${y(e.received)}`].filter(e=>e.length>0).join(`, `)])},x=(e,t,n)=>e.map(e=>`isUnionError`in e?he(e,t):me(e,t,n)),ge=(e,t=[])=>x(e,t,!0).map((e,t,n)=>n.length==1?b([e]):b([`#${t}`,e])).join(` | `),S=Object.getPrototypeOf({});function _e(e){function t(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function n(e){let t=0,n=e.length,r=Array(n);for(;t<n;++t)r[t]=p(e[t]);return r}function r(e){let n={};if(c&&Object.getPrototypeOf(e)!==S)return c(e);let r=s(e),i,a,o;for(i=0,a=r.length;i<a;++i)o=r[i],t(n,o,p(e[o]));return n}function i(e,t){let n=e.length,r=t.length,i=0,a=Array(n+r);for(;i<n;++i)a[i]=p(e[i]);for(i=0;i<r;++i)a[i+n]=p(t[i]);return a}let a=Object.prototype.propertyIsEnumerable;function o(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);for(let r=0,i=n.length;r<i;++r)a.call(e,n[r])&&t.push(n[r]);return t}let s=e?.symbols?o:Object.keys,c=typeof e?.cloneProtoObject==`function`?e.cloneProtoObject:void 0;function l(e){return typeof e==`object`&&!!e&&!(e instanceof RegExp)&&!(e instanceof Date)&&!(e instanceof Map)&&!(e instanceof Set)&&!ArrayBuffer.isView(e)}function u(e){return typeof e!=`object`||!e}let d=typeof Buffer<`u`?e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e)||e instanceof Buffer:e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e),f=e&&typeof e.mergeArray==`function`?e.mergeArray({clone:p,deepmerge:h,getKeys:s,isMergeableObject:l}):i;function p(e){return l(e)?Array.isArray(e)?n(e):r(e):e}function m(e,n){let r={},i=s(e),a=s(n),o,u,d;for(o=0,u=i.length;o<u;++o)d=i[o],a.indexOf(d)===-1&&t(r,d,p(e[d]));for(o=0,u=a.length;o<u;++o)d=a[o],i.indexOf(d)===-1?t(r,d,p(n[d])):c&&l(n[d])&&Object.getPrototypeOf(n[d])!==S?t(r,d,c(n[d])):t(r,d,h(e[d],n[d]));return r}function h(e,t){let n=Array.isArray(t),r=Array.isArray(e);return u(t)||t instanceof Map||t instanceof Set?t:d(e)?p(t):n&&r?f(e,t):n===r?m(e,t):p(t)}function g(){switch(arguments.length){case 0:return{};case 1:return p(arguments[0]);case 2:return h(arguments[0],arguments[1])}let e;for(let t=0,n=arguments.length;t<n;++t)e=h(e,arguments[t]);return e}return g}function ve(e){let t=e.deepmerge,n=e.clone;return function(e,r){let i=0,a=r.length,o=Math.max(e.length,r.length),s=Array(o);for(i=0;i<o;++i)i<a?s[i]=t(e[i],r[i]):s[i]=n(e[i]);return s}}_e({mergeArray:ve});function C(e,t,n){return[{message:t,path:[...e.path],received:n}]}function ye(e,t){let n=[];for(let r=0;r<=e.length;r++){n.push([r]);for(let i=1;i<=t.length;i++)n[r][i]=r===0?i:Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+(e[r-1]===t[i-1]?0:1)),r>1&&i>1&&e[r-1]===t[i-2]&&e[r-2]===t[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1))}return n[e.length][t.length]}function be(e,t,n,r){if(n==null){T(e,t);let n=C(e,`extra property`,r);return E(e),n}let i=null,a=Math.max(1,Math.floor(t.length/3));for(let e of n){let n=ye(t,e);n<=a&&n<t.length&&(i==null||n<a)&&(i=e,a=n)}let o=i==null?``:` Did you mean ${JSON.stringify(i)}?`,s=n.length===0?`none`:n.map(e=>JSON.stringify(e)).join(`, `);T(e,t);let c=C(e,`extra property.${o} Allowed: ${s}`,r);return E(e),c}function w(e,t,n,r,i){r.validate(e,i)||(T(e,n),t.push(...r.reportDecodeError(e,i)),E(e))}function T(e,t){e.path.push(t)}function E(e){e.path.pop()}function xe(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function Se(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function D(e,t){return e?.description==null?t:{...t,description:e.description}}function O(e){let t=e.replace(/\*\//g,`* /`).split(`
|
|
3
|
-
`);return t.length===1?`/** ${t[0]} */`:[`/**`,...t.map(e=>` * ${e}`),` */`].join(`
|
|
4
|
-
`)}function k(e,t){return t==null?{typeExpr:e}:{typeExpr:e,docText:t}}var A=class{metadata;constructor(e){this.metadata=e}describe(e){return k(this.describeTypeExpr(e),this.metadata?.description)}describeChildren(){return[]}};function j(e,t){return t.describe(e).typeExpr}function Ce(e){return e.docText==null?e.typeExpr:`${O(e.docText)}\n${e.typeExpr}`}function M(e,t){let n=`type ${e} = ${t.typeExpr};`;return t.docText==null?n:`${O(t.docText)}\n${n}`}function we(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)||/^(0|[1-9][0-9]*)$/.test(e)?e:JSON.stringify(e)}function N(e,t,n){let r=n instanceof I?`?`:``,i=n.describe(e);return{docText:i.docText,member:`${t}${r}: ${i.typeExpr}`}}function Te(e,t,n){return N(e,`[K in ${j(e,t)}]`,n)}function Ee(e){let t=`${e.member};`;return e.docText==null?t:`${O(e.docText)}\n${t}`}function P(e,t){if(e instanceof z)e.collectDescribeRefs(t);else for(let n of e.describeChildren())P(n,t)}var De=class extends A{typeName;constructor(e,t){super(e),this.typeName=t}describeTypeExpr(e){return this.typeName}schema(e){return D(this.metadata,{type:this.typeName})}validate(e,t){return typeof t===this.typeName}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return C(e,`expected `+this.typeName,t)}},F=class extends A{constructor(e){super(e)}describeTypeExpr(e){return`any`}schema(e){return D(this.metadata,{})}validate(e,t){return!0}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return C(e,`expected any`,t)}},Oe=class extends A{constructor(e){super(e)}describeTypeExpr(e){return`never`}schema(e){return D(this.metadata,{anyOf:[]})}validate(e,t){return!1}parseAfterValidation(e,t){throw Error(`unreachable`)}reportDecodeError(e,t){return C(e,`expected never`,t)}},ke=class extends A{itemParser;constructor(e,t){super(e),this.itemParser=t}schema(e){T(e,`[]`);let t=this.itemParser.schema(e);return E(e),D(this.metadata,{type:`array`,items:t})}validate(e,t){if(Array.isArray(t)){for(let n=0;n<t.length;n++){let r=t[n];if(!this.itemParser.validate(e,r))return!1}return!0}return!1}parseAfterValidation(e,t){return t.map(t=>this.itemParser.parseAfterValidation(e,t))}reportDecodeError(e,t){if(!Array.isArray(t))return C(e,`expected array`,t);let n=[];for(let r=0;r<t.length;r++)w(e,n,`[${r}]`,this.itemParser,t[r]);return n}describeTypeExpr(e){return`Array<${j(e,this.itemParser)}>`}describeChildren(){return[this.itemParser]}},I=class{t;constructor(e){this.t=e}schema(e){return{anyOf:[this.t.schema(e),{type:`null`}]}}validate(e,t){return t==null||this.t.validate(e,t)}parseAfterValidation(e,t){return t==null?t:this.t.parseAfterValidation(e,t)}reportDecodeError(e,t){return this.t.reportDecodeError(e,t)}describe(e){return this.t.describe(e)}describeChildren(){return[this.t]}},L=Object.prototype.hasOwnProperty;function R(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var Ae=class extends A{properties;indexedPropertiesParser;constructor(e,t,n){super(e),this.properties=t,this.indexedPropertiesParser=n}describeTypeExpr(e){let t=Object.keys(this.properties).sort().map(t=>{let n=this.properties[t];return N(e,we(t),n)}),n=this.indexedPropertiesParser.map(({key:t,value:n})=>Te(e,t,n)),r=[...t,...n];return r.some(e=>e.docText!=null)?r.length===0?`{}`:`{\n${r.map(Ee).join(`
|
|
5
|
-
`)}\n}`:`{ ${r.map(e=>e.member).join(`, `)} }`}describeChildren(){return[...Object.values(this.properties),...this.indexedPropertiesParser.flatMap(({key:e,value:t})=>[e,t])]}schema(e){let t={},n=new Set;for(let r in this.properties){T(e,r);let i=this.properties[r].schema(e),a=v(i);a==null?t[r]=i:(t[r]=a,n.add(r)),E(e)}let r=Object.keys(this.properties).filter(e=>!n.has(e)),i={type:`object`,properties:t,...r.length>0?{required:r}:{}},a=this.indexedPropertiesParser.map(({key:t,value:n})=>{T(e,`[key]`);let r=t.schema(e);E(e),T(e,`[value]`);let i=n.schema(e);return E(e),{type:`object`,additionalProperties:i,propertyNames:r}});if(a.length===0)return D(this.metadata,{...i,additionalProperties:!1});if(Object.keys(t).length===0&&a.length===1){let e=this.indexedPropertiesParser[0].value;return e instanceof Oe?D(this.metadata,{type:`object`,additionalProperties:!1}):e instanceof F?D(this.metadata,{...a[0],additionalProperties:!0}):D(this.metadata,a[0])}return D(this.metadata,{allOf:[i,...a]})}validate(e,t){if(typeof t==`object`&&!Array.isArray(t)&&t!==null){let n=Object.keys(this.properties);for(let r of n)if(!this.properties[r].validate(e,t[r]))return!1;if(this.indexedPropertiesParser.length>0){let n=Object.keys(t).filter(e=>!L.call(this.properties,e));for(let r of n){let n=!1;for(let i of this.indexedPropertiesParser){if(!i.key.validate(e,r))continue;let a=t[r];if(i.value.validate(e,a)){n=!0;break}}if(!n&&!this.leavesKeyToIntersection(e,t,r))return!1}}else if(e.disallowExtraProperties&&e.intersectionInput!==t&&Object.keys(t).filter(e=>!L.call(this.properties,e)).length>0)return!1;return!0}return!1}parseAfterValidation(e,t){let n={},r=Object.keys(t);if(e.objectKeyOrder===`input`)for(let i of r)if(L.call(this.properties,i))R(n,i,this.properties[i].parseAfterValidation(e,t[i]));else for(let r of this.indexedPropertiesParser){let a=t[i];if(r.key.validate(e,i)&&r.value.validate(e,a)){let t=r.value.parseAfterValidation(e,a);R(n,r.key.parseAfterValidation(e,i),t)}}else{let i=Object.keys(this.properties).sort();for(let r of i){if(!L.call(t,r))continue;let i=t[r];R(n,r,this.properties[r].parseAfterValidation(e,i))}if(this.indexedPropertiesParser.length>0){let i=r.filter(e=>!L.call(this.properties,e)).sort();for(let r of i){let i=t[r];for(let t of this.indexedPropertiesParser)if(t.key.validate(e,r)&&t.value.validate(e,i)){let a=t.value.parseAfterValidation(e,i);R(n,t.key.parseAfterValidation(e,r),a)}}}}return n}reportDecodeError(e,t){if(typeof t!=`object`||Array.isArray(t)||t===null)return C(e,`expected object`,t);let n=[],r=Object.keys(this.properties);for(let i of r)w(e,n,i,this.properties[i],t[i]);if(this.indexedPropertiesParser.length>0){let r=Object.keys(t).filter(e=>!L.call(this.properties,e));for(let i of r)if(!this.leavesKeyToIntersection(e,t,i))for(let r of this.indexedPropertiesParser){let a=r.key.validate(e,i),o=r.value.validate(e,t[i]);if(!(a&&o)){if(T(e,i),!a){let t=r.key.reportDecodeError(e,i);n.push(...t)}if(!o){let a=r.value.reportDecodeError(e,t[i]);n.push(...a)}E(e)}}}else if(e.disallowExtraProperties&&e.intersectionInput!==t){let n=Object.keys(t).filter(e=>!L.call(this.properties,e));if(n.length>0)return n.flatMap(n=>be(e,n,r,t[n]))}return n}allowedKeys(){return this.indexedPropertiesParser.length>0?null:Object.keys(this.properties)}leavesKeyToIntersection(e,t,n){return e.intersectionInput===t&&!this.indexedPropertiesParser.some(t=>t.key.validate(e,n))}},z=class extends A{refName;namedRuntypes;constructor(e,t,n){super(e),this.refName=t,this.namedRuntypes=n}getNamedRuntypes(){return this.namedRuntypes}describeTypeExpr(e){return this.refName}collectDescribeRefs(e){let t=this.refName;e.refCounts[t]=(e.refCounts[t]||0)+1,e.activeRefs.has(t)||e.visitedRefs.has(t)||(e.visitedRefs.add(t),e.activeRefs.add(t),P(this.getNamedRuntypes()[t],e),e.activeRefs.delete(t))}describe(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName],r=()=>k(t,this.metadata?.description);if(e.refCounts[t]>1)return e.activeRefs.has(t)||(e.definitions[t]??(e.activeRefs.add(t),e.definitions[t]=n.describe(e),e.activeRefs.delete(t))),r();let i=n.describe(e);return this.metadata?.description==null?i:k(i.typeExpr,this.metadata.description)}schema(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName];if(e.mode===`contextual`){let r=e.printingContext;if(r==null)throw Error(`INTERNAL ERROR: Missing SchemaPrintingContext`);if(!r.hasDefinition(t)&&!r.isDefinitionInProgress(t)){r.markDefinitionInProgress(t);let i=(r.getNamedTypeSchemaOverride(t)??n).schema(e);r.storeDefinition(t,i)}return D(this.metadata,{$ref:r.getRef(t)})}if(e.seen[t])return D(this.metadata,{});e.seen[t]=!0;var r=n.schema(e);return delete e.seen[t],D(this.metadata,r)}validate(e,t){return this.getNamedRuntypes()[this.refName].validate(e,t)}parseAfterValidation(e,t){return this.getNamedRuntypes()[this.refName].parseAfterValidation(e,t)}reportDecodeError(e,t){return this.getNamedRuntypes()[this.refName].reportDecodeError(e,t)}},je=class{_runtype;name;hideTypeNameInDescribe;constructor(e,t,n){this._runtype=e,this.name=t,this.hideTypeNameInDescribe=n}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;let r=ge(n.errors,[]);throw Error(`Failed to parse ${this.name} - ${r}`)}safeParse(e,t){let n=t?.disallowExtraProperties??!1,r=t?.objectKeyOrder??`input`;if(this.validate(e,t)){let t={disallowExtraProperties:n,objectKeyOrder:r};return{success:!0,data:this._runtype.parseAfterValidation(t,e)}}let i={path:[],disallowExtraProperties:n};return{success:!1,errors:this._runtype.reportDecodeError(i,e).slice(0,10)}}validate(e,t){let n={disallowExtraProperties:t?.disallowExtraProperties??!1},r=this._runtype.validate(n,e);if(typeof r!=`boolean`)throw Error(`INTERNAL ERROR: Expected boolean`);return r}schema(){return this._runtype.schema({path:[],seen:{},mode:`flat`})}schemaWithContext(e){let t={path:[],seen:{},mode:`contextual`,printingContext:e};return this._runtype.schema(t)}describe(){let e={activeRefs:new Set,definitions:{},refCounts:{},visitedRefs:new Set};P(this._runtype,e);let t=this._runtype.describe(e),n=Object.keys(e.definitions).sort().map(t=>[t,e.definitions[t]]).map(([e,t])=>M(e,t)).join(`
|
|
6
|
-
|
|
7
|
-
`);return this.hideTypeNameInDescribe?[n,Ce(t)].filter(e=>e!=null&&e.length>0).join(`
|
|
8
|
-
|
|
9
|
-
`):[n,M(`Codec${this.name}`,t)].filter(e=>e!=null&&e.length>0).join(`
|
|
10
|
-
|
|
11
|
-
`)}},Me=(e,t,n)=>new je(e,t,n),Ne=(e,t)=>{let n=t?.stringFormats??{};for(let t of e.requiredStringFormats)if(n[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(n).forEach(t=>{let r=n[t];xe(e.stringFormatters,t,r)});let r=t?.numberFormats??{};for(let t of e.requiredNumberFormats)if(r[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(r).forEach(t=>{let n=r[t];Se(e.numberFormatters,t,n)});let i={};for(let t of Object.keys(e.parsers))i[t]=Me(e.parsers[t],t,!1);return i},Pe=[],Fe=[],B={},Ie={},Le={},Re=new z(void 0,`PackageJson`,B),ze=new F(void 0),V=new De(void 0,`string`),Be=new ke(void 0,V),Ve=new Ae({description:`The part of a package.json that aula reads: how a package names its module and its
|
|
12
|
-
workspace packages.`},{exports:new I(ze),main:new I(V),module:new I(V),name:new I(V),workspaces:new I(Be)},[]);Object.assign(B,{PackageJson:Ve});var He={PackageJson:Re},Ue={buildParsers:e=>Ne({parsers:He,stringFormatters:Ie,numberFormatters:Le,requiredStringFormats:Pe,requiredNumberFormats:Fe},e)}.buildParsers();function We(e,t){let n=[...e];return{read:t,list:e=>{let t=e===``?``:`${e}/`,r=new Set;for(let e of n){if(!e.startsWith(t))continue;let[n,...i]=e.slice(t.length).split(`/`);n!==void 0&&i.length>0&&r.add(n)}return Promise.resolve([...r].toSorted())}}}var H=`tree:`;function U(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function W(e,t){let n=e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(!n.length)return null;n.pop()}else n.push(e)}return n.join(`/`)}var Ge=new Map([[`ts`,`ts`],[`mts`,`ts`],[`js`,`js`],[`mjs`,`js`],[`json`,`json`]]),Ke=e=>Ge.get(e.slice(e.lastIndexOf(`.`)+1))??`ts`;function qe(e,t){return{name:`aula-tree`,setup(n){n.onResolve({filter:/.*/},async n=>{let r=t[n.path];if(r!==void 0)return{path:r,external:!0};if(n.kind===`entry-point`)return{path:W(``,n.path)??n.path,namespace:`tree`};if(!n.path.startsWith(`./`)&&!n.path.startsWith(`../`)){let t=await et(e,n.path,n.importer);return t===null?{errors:[{text:`cannot find the package "${n.path}" in node_modules or the workspace packages`}]}:{path:t,namespace:`tree`}}let i=W(U(n.importer),n.path);if(i===null)return{errors:[{text:`"${n.path}" is outside the folder you opened`}]};for(let t of[i,`${i}.ts`,`${i}/index.ts`])if(await e.read(t)!==null)return{path:t,namespace:`tree`};return{errors:[{text:`cannot find "${n.path}" (${i})`}]}}),n.onLoad({filter:/.*/,namespace:`tree`},async t=>{let n=await e.read(t.path);return n===null?{errors:[{text:`cannot read ${t.path}`}]}:{contents:n,loader:Ke(t.path)}})}}}function Je(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`text`)==`string`}var Ye=({text:e,location:t})=>({severity:`error`,message:e,...t?{location:{file:t.file.replace(H,``),line:t.line,col:t.column+1}}:{},stack:[],related:[]});async function Xe(e,t,n,r){let i;try{i=await e.build({entryPoints:[n],bundle:!0,write:!1,format:`esm`,platform:`browser`,target:`es2024`,outfile:`bundle.js`,sourcemap:`both`,sourcesContent:!1,metafile:!0,logLevel:`silent`,plugins:[qe(t,r)]})}catch(e){let t=typeof e==`object`&&e?Reflect.get(e,`errors`):void 0;if(Array.isArray(t)&&t.every(Je))return{_tag:`Left`,left:t.map(Ye)};throw e}let a=i.outputFiles.find(e=>e.path.endsWith(`.js`))?.text,o=i.outputFiles.find(e=>e.path.endsWith(`.js.map`))?.text;if(a===void 0||o===void 0)throw Error(`esbuild wrote no bundle`);return{_tag:`Right`,right:{code:a,map:o,inputs:Object.keys(i.metafile?.inputs??{}).filter(e=>e.startsWith(H)).map(e=>e.slice(5))}}}function G(e,t){if(typeof e==`string`)return t===`.`?e:null;if(typeof e!=`object`||!e)return null;if(Object.keys(e).some(e=>e.startsWith(`.`)))return t in e?G(Reflect.get(e,t),`.`):null;for(let t of[`browser`,`import`,`default`])if(t in e)return G(Reflect.get(e,t),`.`);return null}function K(e){let t=e.split(`/`),n=e.startsWith(`@`)?2:1,r=t.slice(n).join(`/`);return{name:t.slice(0,n).join(`/`),subpath:r===``?`.`:`./${r}`}}async function Ze(e,t,n){let r=q(`${t}/package.json`,await e.read(`${t}/package.json`));return r?W(t,G(r.exports,n)??(n===`.`?r.module??r.main??`index.js`:n)):null}async function Qe(e,t,n){let{name:r,subpath:i}=K(t);for(let t=U(n);;t=U(t)){let n=await Ze(e,t===``?`node_modules/${r}`:`${t}/node_modules/${r}`,i);if(n!==null)return n;if(t===``)return null}}function q(e,t){if(t===null)return null;let n=Ue.PackageJson.safeParse(JSON.parse(t));return n.success?n.data:null}async function $e(e){let t=[],n=await e.read(`pnpm-workspace.yaml`);if(n!==null){let e=!1;for(let r of n.split(`
|
|
13
|
-
`))if(/^packages:\s*$/.test(r))e=!0;else if(/^\S/.test(r))e=!1;else if(e){let e=/^\s*-\s*["']?([^"'#]+?)["']?\s*(#.*)?$/.exec(r)?.[1];e!==void 0&&t.push(e)}}t.push(...q(`package.json`,await e.read(`package.json`))?.workspaces??[]);let r=[];for(let n of t){let t=n.replace(/^\.\//,``).replace(/\/$/,``);if(t.endsWith(`/*`)){let n=t.slice(0,-2);r.push(...(await e.list(n)).map(e=>`${n}/${e}`))}else t.includes(`*`)||r.push(t)}return r}async function et(e,t,n){let r=await Qe(e,t,n);if(r!==null)return r;let{name:i,subpath:a}=K(t);for(let t of await $e(e))if(q(`${t}/package.json`,await e.read(`${t}/package.json`))?.name===i)return Ze(e,t,a);return null}var J=/^(\d+)-/,Y=e=>e.replace(J,``);function tt(e){let t=Y(e).replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var X=(e,t)=>e<t?-1:+(e>t);function nt(e,t){let n=J.exec(e)?.[1],r=J.exec(t)?.[1];if(n===void 0||r===void 0){if(n!==r)return n===void 0?1:-1}else{let[e,t]=[n.replace(/^0+/,``),r.replace(/^0+/,``)],i=e.length-t.length||X(e,t);if(i!==0)return i}return X(Y(e),Y(t))||X(e,t)}async function rt(e,t){return(await e.list(t)).filter(e=>e!==`node_modules`&&!e.startsWith(`.`)).toSorted(nt)}var Z=async(e,t)=>await e.read(t)!==null;async function it(e,t){if(await Z(e,`index.ts`))return{_tag:`Right`,right:[{module:`index.ts`,name:Y(t)}]};let n=[];for(let t of await rt(e,``))if(await Z(e,`${t}/index.ts`))n.push({module:`${t}/index.ts`,name:Y(t)});else for(let r of await rt(e,t)){let i=`${t}/${r}/index.ts`;await Z(e,i)&&n.push({module:i,name:Y(r),section:tt(t)})}let r=[];return n.forEach((e,t)=>{let i=n.findIndex(t=>t.name===e.name);if(i===t)return;let a=[n[i],e].map(e=>(e?.module??``).slice(0,-9));r.push({severity:`error`,message:`two projects have the name ${e.name}: ${a.join(` and `)}`,hint:`the name of a project is its folder name without the order prefix: rename one of the folders`,stack:[],related:[]})}),r.length>0?{_tag:`Left`,left:r}:{_tag:`Right`,right:n}}var at=(e,t)=>({frames:e,name:e=>/^[a-z][a-z0-9+.-]*:/.test(e)?void 0:e,exists:()=>!0,...t?{media:t}:{}}),ot=(e,t)=>typeof e==`object`&&e?Reflect.get(e,t):void 0,Q=`aula-projects.ts`;async function st(t,n,i,a,s,c){let u=await it(t,await t.name());if(u._tag===`Left`)return u;let d=u.right.map(e=>e.module);if(d.length===0)throw Error(`no project here: open a folder that has index.ts, or whose subfolders have index.ts`);let f=[...d.map((e,t)=>`import p${String(t)} from ${JSON.stringify(`./${e}`)};`),`export default [${d.map((e,t)=>`p${String(t)}`).join(`, `)}];`].join(`
|
|
14
|
-
`),[p]=await Promise.all([Xe(a,{read:e=>e===Q?Promise.resolve(f):t.read(e),list:e=>t.list(e)},Q,s),l().then(()=>{c?.()})]);if(p._tag===`Left`)return p;let m=await e(()=>i.load(p.right));if(m._tag===`Left`)return{_tag:`Left`,left:[r(m.left,Q,n)]};let h=ot(m.right.exports,`default`);if(!Array.isArray(h))throw Error(`${Q} has no list of projects`);return{_tag:`Right`,right:h.map((e,t)=>{if(!o(e))throw Error(`the default export of ${d[t]??``} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ … ] })\``);let{name:r,section:i}=u.right[t]??{name:``};return ct(r,i,e,n)})}}function ct(e,n,r,o){let s=r.chapters.length+1;return{name:e,...n===void 0?{}:{section:n},title:r.title,chapters:s,titles:[r.title,...r.chapters.map(e=>e.heading)],script:()=>{let e=[];for(let n of r.chapters.keys()){let i=t(r,n+1,{host:o});if(i.value===void 0)return{_tag:`Left`,left:i.diagnostics};e.push(i.value)}return{_tag:`Right`,right:{script:u(r,e)}}},walk:e=>{e>0&&c(r,e,{host:o})},render:(e,t)=>{let n=a(r,e,{host:o,narration:t});if(!n.ok||n.value===void 0)return{_tag:`Left`,left:n.diagnostics};let{lottie:s,waits:c,embeds:l,diagnostics:u}=n.value;return{_tag:`Right`,right:{lottie:s,waits:c,embeds:l,background:(r.theme??i).background,warnings:u}}}}}function lt(e){return e}function ut(e,t){return Object.assign({},e,t)}function dt(e,t){return{...e,...t}}function ft(...e){return Object.assign({},...e)}var pt={create:lt,extend:ut,merge:ft,override:dt},mt=class extends Error{constructor(e,t){super(e),this.stack=t}};function ht(e,t,n){return e===``?``:` at ${e}:${String(t)}:${String(n)}`}var $=e=>`${e.file}:${String(e.line)}:${String(e.col)}`;function gt(e,t){if(!(e instanceof Error))return{message:String(e),place:null,stack:[]};let n=t(e),[r]=n;return{message:e.name===`Error`||e.name===``?e.message:`${e.name}: ${e.message}`,place:r?$(r):null,stack:n.map(e=>e.function===``?`at ${$(e)}`:`at ${e.function} (${$(e)})`)}}function _t(e,t,n){let r=(t,n,r)=>{let i=e.createElement(t);return i.className=n,i.textContent=r,i},i=r(`div`,`crash`,``);i.setAttribute(`role`,`alert`),i.append(r(`h1`,``,`The app stopped because of an error.`),r(`p`,`message`,t.message)),t.place!==null&&i.append(r(`p`,`place`,`at ${t.place}`)),t.stack.length>0&&i.append(r(`pre`,`stack`,t.stack.join(`
|
|
15
|
-
`)));let a=r(`button`,`reload`,`Reload`);a.addEventListener(`click`,n),i.append(a),e.body.replaceChildren(i)}var vt=2e5;function yt(e){let{layers:t,...n}=e,r=[JSON.stringify({...n,layers:[]})],i=[],a=0;for(let e of t){let t=JSON.stringify(e);a>0&&a+t.length>vt&&(r.push(`[${i.join(`,`)}]`),i=[],a=0),i.push(t),a+=t.length+1}return i.length>0&&r.push(`[${i.join(`,`)}]`),r}async function bt(e,t){let[n,...r]=e;if(n===void 0)throw Error(`a Lottie animation with no parts`);let i=JSON.parse(n);for(let e of r){await t();let n=JSON.parse(e);i.layers.push(...n)}return i}var xt=e=>e.map(e=>({...e,text:p(e)}));function St(e){let t=Reflect.get(e,`text`);if(typeof t!=`string`)throw Error(`a diagnostic with no text: ${e.message}`);return t}export{mt as a,_t as c,at as d,H as f,oe as h,yt as i,pt as l,ue as m,xt as n,gt as o,We as p,bt as r,ht as s,St as t,st as u};
|