@beff/aula-cli 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/src/aula-render.core.wasm +0 -0
- package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-FEFKNA2I.js} +1 -1
- package/dist/src/aula.js +2 -2
- package/dist/src/{chunk-DC7A435Z.js → chunk-2BEUK7M7.js} +1 -1
- package/dist/src/{chunk-2PAZTBSE.js → chunk-2VD3JPLV.js} +3 -5
- package/dist/src/chunk-4N5SDSCV.js +63 -0
- package/dist/src/{chunk-AXQBWV7J.js → chunk-F37DXY3P.js} +219 -115
- package/dist/src/{chunk-PZXFW6ZD.js → chunk-FGTN34N7.js} +3 -3
- package/dist/src/{chunk-RAGZAJKD.js → chunk-GQSFMINU.js} +3 -33
- package/dist/src/chunk-N3YZ7K5L.js +111 -0
- package/dist/src/{chunk-DN2LVJO3.js → chunk-T7S65ZHW.js} +4307 -1645
- package/dist/src/{chunk-TDAWUJ2L.js → chunk-V3GJ4XSW.js} +118 -66
- package/dist/src/{chunk-T6CAPT32.js → chunk-VJAXVLXZ.js} +3 -2
- package/dist/src/{chunk-HD6FTA3H.js → chunk-Z7VLJSDG.js} +211 -92
- package/dist/src/cli.js +44 -155
- package/dist/src/{commands-BSDNHYB3.js → commands-ZTGXXVOO.js} +12 -10
- package/dist/src/generated/aula.core5.wasm +0 -0
- package/dist/src/generated/aula.js +4076 -1341
- package/dist/src/generated/interfaces/aula-engine-engine.d.ts +39 -0
- package/dist/src/problems-BDPV4IRL.js +17 -0
- package/dist/src/project-XHL7FN7B.js +16 -0
- package/dist/src/run-LZVKYMKT.js +238 -0
- package/dist/src/{server-TJTMSDO2.js → server-H7XOUJNL.js} +24 -21
- package/dist/src/{site-RGPJOWSU.js → site-7MLO35NA.js} +16 -89
- package/dist/src/workspace-load-OQXB2ZOC.js +16 -0
- package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula-method.js +1 -1
- package/dist/web/app/assets/{bf5dd884 → 15e78332}/aula.js +1 -1
- package/dist/web/app/assets/15e78332/build-worker.js +2 -0
- package/dist/web/app/assets/15e78332/index.js +51 -0
- package/dist/web/app/assets/__vite-browser-external-CCI-9X_7.js +1 -0
- package/dist/web/app/assets/aula-voice-worker-bYZ7BKji.js +1 -0
- package/dist/web/app/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
- package/dist/web/app/assets/protocol-j759xoXL.js +15 -0
- package/dist/web/app/assets/src-BjcN7H3T.js +6 -0
- package/dist/web/{site/assets/tex-mathjax-DrZV_cwB.js → app/assets/tex-mathjax-Bbh2jsAv.js} +1 -1
- package/dist/web/app/index.html +4 -4
- package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula-method.js +1 -1
- package/dist/web/site/assets/{07fb5cf0 → 671a8ee2}/aula.js +1 -1
- package/dist/web/site/assets/671a8ee2/build-worker.js +2 -0
- package/dist/web/site/assets/671a8ee2/index.js +51 -0
- package/dist/web/site/assets/__vite-browser-external-CrZYh5ba.js +1 -0
- package/dist/web/site/assets/aula-voice-worker-Doyh20uI.js +1 -0
- package/dist/web/site/assets/{aula.core5-CQ2oHbtB.wasm → aula.core5-CtBp7wFf.wasm} +0 -0
- package/dist/web/site/assets/protocol-ByKVs3Yn.js +15 -0
- package/dist/web/site/assets/src-BwnY0kQu.js +6 -0
- package/dist/web/{app/assets/tex-mathjax-eWNptbJg.js → site/assets/tex-mathjax-DKtiwFu-.js} +1 -1
- package/dist/web/site/index.html +4 -4
- package/package.json +1 -1
- package/dist/src/chunk-4QGX7XXO.js +0 -104
- package/dist/src/problems-CGKCPETU.js +0 -18
- package/dist/src/project-EUFMRQXR.js +0 -16
- package/dist/src/run-ER27SVTA.js +0 -183
- package/dist/web/app/assets/__vite-browser-external-BHESVS8k.js +0 -1
- package/dist/web/app/assets/aula-voice-worker-CJpoa9h-.js +0 -1
- package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
- package/dist/web/app/assets/bf5dd884/index.js +0 -51
- package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
- package/dist/web/app/assets/src-DWqZcp-P.js +0 -6
- package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
- package/dist/web/site/assets/07fb5cf0/index.js +0 -51
- package/dist/web/site/assets/__vite-browser-external-DQubyTsZ.js +0 -1
- package/dist/web/site/assets/aula-voice-worker-BRrzyFz3.js +0 -1
- package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
- package/dist/web/site/assets/src-DfPcHwz-.js +0 -6
|
@@ -28,6 +28,18 @@ export function polyline(points: Array<Point>): Mobject;
|
|
|
28
28
|
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
29
29
|
*/
|
|
30
30
|
export function pathBoolean(op: BooleanOp, shapes: Array<Array<Array<Point>>>): Array<Point>;
|
|
31
|
+
/**
|
|
32
|
+
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
33
|
+
*/
|
|
34
|
+
export function smoothHandles(anchors: Array<Point>): [Array<Point>, Array<Point>];
|
|
35
|
+
/**
|
|
36
|
+
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
37
|
+
*/
|
|
38
|
+
export function cubicPartial(curve: Array<Point>, t0: number, t1: number): Array<Point>;
|
|
39
|
+
/**
|
|
40
|
+
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
41
|
+
*/
|
|
42
|
+
export function insertCurves(points: Array<Point>, n: number): Array<Point>;
|
|
31
43
|
/**
|
|
32
44
|
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
33
45
|
*/
|
|
@@ -224,6 +236,7 @@ export function narrationScript(title: Array<SayPart>, lexicon: Array<LexiconEnt
|
|
|
224
236
|
export function chapterNarration(cues: Array<ScriptCue>, spoken: Array<SpokenCue>, sampleRate: number): Narration;
|
|
225
237
|
export function check(text: ChapterText): Array<Diagnostic>;
|
|
226
238
|
export function timeline(narration: Narration, text: ChapterText): Array<string>;
|
|
239
|
+
export function scriptBeats(narration: Narration, text: ChapterText): Array<ScriptBeat>;
|
|
227
240
|
export function moveFrames(narration: Narration, text: ChapterText): Array<ParagraphFrames>;
|
|
228
241
|
export function estimateNarration(cues: Array<ScriptCue>): Narration;
|
|
229
242
|
export function words(text: string): Array<string>;
|
|
@@ -234,6 +247,10 @@ export function fps(): number;
|
|
|
234
247
|
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
235
248
|
*/
|
|
236
249
|
export function phonemize(text: string, lexicon: Array<LexiconEntry>): string;
|
|
250
|
+
/**
|
|
251
|
+
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
252
|
+
*/
|
|
253
|
+
export function phonemizeWithUnknowns(text: string, lexicon: Array<LexiconEntry>): G2pResult;
|
|
237
254
|
/**
|
|
238
255
|
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
239
256
|
*/
|
|
@@ -244,6 +261,10 @@ export function checkTitle(place: Location, parts: Array<SayPart>): Array<Diagno
|
|
|
244
261
|
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
245
262
|
*/
|
|
246
263
|
export function unclearWords(words: Array<string>): Array<UnclearWord>;
|
|
264
|
+
/**
|
|
265
|
+
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
266
|
+
*/
|
|
267
|
+
export function unclearWordsFrom(words: Array<string>, unknowns: Array<string>, alonePhonemes: Array<string>): Array<UnclearWord>;
|
|
247
268
|
/**
|
|
248
269
|
* @throws {Error & { payload: Diagnostic }} The error of the result, as the `payload` of the thrown error.
|
|
249
270
|
*/
|
|
@@ -591,6 +612,10 @@ export interface UnclearWord {
|
|
|
591
612
|
kind: UnclearKind,
|
|
592
613
|
reading: string,
|
|
593
614
|
}
|
|
615
|
+
export interface G2pResult {
|
|
616
|
+
phonemes: string,
|
|
617
|
+
unknowns: Array<string>,
|
|
618
|
+
}
|
|
594
619
|
export interface LexiconEntry {
|
|
595
620
|
word: string,
|
|
596
621
|
reading: Pronunciation,
|
|
@@ -617,6 +642,20 @@ export interface SpokenCue {
|
|
|
617
642
|
samples: number,
|
|
618
643
|
starts?: Float64Array,
|
|
619
644
|
}
|
|
645
|
+
/**
|
|
646
|
+
* # Variants
|
|
647
|
+
*
|
|
648
|
+
* ## `"say"`
|
|
649
|
+
*
|
|
650
|
+
* ## `"embed"`
|
|
651
|
+
*/
|
|
652
|
+
export type ScriptBeatKind = "say" | "embed";
|
|
653
|
+
export interface ScriptBeat {
|
|
654
|
+
seconds: number,
|
|
655
|
+
kind: ScriptBeatKind,
|
|
656
|
+
text: string,
|
|
657
|
+
onScreen: Array<string>,
|
|
658
|
+
}
|
|
620
659
|
export interface ParagraphFrames {
|
|
621
660
|
start: number,
|
|
622
661
|
moves: Uint32Array,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
printDiagnostics
|
|
3
|
+
} from "./chunk-FGTN34N7.js";
|
|
4
|
+
import "./chunk-F37DXY3P.js";
|
|
5
|
+
import "./chunk-V3GJ4XSW.js";
|
|
6
|
+
import "./chunk-2VD3JPLV.js";
|
|
7
|
+
import {
|
|
8
|
+
diagnosticsOf
|
|
9
|
+
} from "./chunk-VJAXVLXZ.js";
|
|
10
|
+
import "./chunk-GQSFMINU.js";
|
|
11
|
+
import "./chunk-T7S65ZHW.js";
|
|
12
|
+
import "./chunk-VX7UVLQW.js";
|
|
13
|
+
import "./chunk-CZ7CSFO4.js";
|
|
14
|
+
export {
|
|
15
|
+
diagnosticsOf,
|
|
16
|
+
printDiagnostics
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exists,
|
|
3
|
+
host,
|
|
4
|
+
loadProject
|
|
5
|
+
} from "./chunk-2BEUK7M7.js";
|
|
6
|
+
import "./chunk-2VD3JPLV.js";
|
|
7
|
+
import "./chunk-VJAXVLXZ.js";
|
|
8
|
+
import "./chunk-GQSFMINU.js";
|
|
9
|
+
import "./chunk-T7S65ZHW.js";
|
|
10
|
+
import "./chunk-VX7UVLQW.js";
|
|
11
|
+
import "./chunk-CZ7CSFO4.js";
|
|
12
|
+
export {
|
|
13
|
+
exists,
|
|
14
|
+
host,
|
|
15
|
+
loadProject
|
|
16
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bundle,
|
|
3
|
+
exportVideo,
|
|
4
|
+
preview,
|
|
5
|
+
script,
|
|
6
|
+
timeline
|
|
7
|
+
} from "./chunk-Z7VLJSDG.js";
|
|
8
|
+
import "./chunk-THQ5Y74K.js";
|
|
9
|
+
import "./chunk-4N5SDSCV.js";
|
|
10
|
+
import "./chunk-F4XRXW6M.js";
|
|
11
|
+
import "./chunk-4N4NUMKP.js";
|
|
12
|
+
import "./chunk-FGTN34N7.js";
|
|
13
|
+
import "./chunk-F37DXY3P.js";
|
|
14
|
+
import "./chunk-V3GJ4XSW.js";
|
|
15
|
+
import "./chunk-2BEUK7M7.js";
|
|
16
|
+
import "./chunk-2VD3JPLV.js";
|
|
17
|
+
import {
|
|
18
|
+
wrongArgument
|
|
19
|
+
} from "./chunk-VJAXVLXZ.js";
|
|
20
|
+
import "./chunk-GQSFMINU.js";
|
|
21
|
+
import "./chunk-T7S65ZHW.js";
|
|
22
|
+
import "./chunk-VX7UVLQW.js";
|
|
23
|
+
import "./chunk-CZ7CSFO4.js";
|
|
24
|
+
|
|
25
|
+
// src/run.ts
|
|
26
|
+
import path from "node:path";
|
|
27
|
+
var USAGE = `aula: storyboard-first narrated aula videos.
|
|
28
|
+
|
|
29
|
+
<folder> is the root: the path you pass. . means the current folder.
|
|
30
|
+
A project folder (index.ts / defineProject) is a list of one; a playlist
|
|
31
|
+
folder is its subprojects. Drafts are skipped unless --include-drafts.
|
|
32
|
+
check, web and site run on that list; preview, export, bundle, script and
|
|
33
|
+
timeline need exactly one project after filtering; tokens takes no folder.
|
|
34
|
+
<chapter> is a chapter id such as 01-double-the-side. title is not a
|
|
35
|
+
chapter argument. The title card is the first scene of the video. It shows
|
|
36
|
+
the project title from defineProject({ title }). A check or preview of the
|
|
37
|
+
whole project includes the title card.
|
|
38
|
+
Each chapter module holds its script, storyboard notes and animations;
|
|
39
|
+
messages name its lines (file:line:col).
|
|
40
|
+
|
|
41
|
+
aula check <folder> [<chapter> ...] [--json] [--include-drafts]
|
|
42
|
+
every check, with no narration and no frames, and
|
|
43
|
+
a note for each word whose reading is not clear;
|
|
44
|
+
finds the projects in the folder; skips draft:
|
|
45
|
+
true unless --include-drafts; a playlist prints
|
|
46
|
+
progress and a short summary on stderr, and checks
|
|
47
|
+
projects at the same time up to the CPU count;
|
|
48
|
+
--json prints each result as one JSON object
|
|
49
|
+
aula preview <folder> <out> [<chapter>[:<line>] ...] [--include-drafts]
|
|
50
|
+
PNG pictures for review: per chapter, stills,
|
|
51
|
+
motion stills, contact sheets and moves.md
|
|
52
|
+
aula export <folder> <file.mp4> [--include-drafts]
|
|
53
|
+
the video to send: narrated in this run, H.264 and
|
|
54
|
+
AAC at 1280x720 and 60 fps; needs ffmpeg
|
|
55
|
+
aula web <folder> [--port N] [--host H] [--include-drafts]
|
|
56
|
+
the web app for a project folder (index.ts) or a
|
|
57
|
+
playlist folder; do not point it at a monorepo root
|
|
58
|
+
that also holds kits; skips draft: true unless
|
|
59
|
+
--include-drafts; the page narrates in the
|
|
60
|
+
browser; --host defaults to 127.0.0.1 (use
|
|
61
|
+
0.0.0.0 to listen on all interfaces)
|
|
62
|
+
aula bundle <folder> <file.zip> [--include-drafts]
|
|
63
|
+
the project zip: the project folder, and the
|
|
64
|
+
packages it imports, to share or host
|
|
65
|
+
aula site <folder> <out> [--title <text>] [--base <path>] [--include-drafts]
|
|
66
|
+
a website of a project or playlist folder (same as
|
|
67
|
+
aula web; do not point it at a monorepo root that
|
|
68
|
+
also holds kits; skips draft: true unless
|
|
69
|
+
--include-drafts): the folder's files with the
|
|
70
|
+
packages they import, and the web app, as plain
|
|
71
|
+
files in <out> for any static host; --title is the
|
|
72
|
+
site's title (default: the folder's name); --base
|
|
73
|
+
pins the site to a base path such as /aula/
|
|
74
|
+
(default: it works at any path)
|
|
75
|
+
aula script <folder> [<chapter> ...] [--include-drafts]
|
|
76
|
+
the review script: each chapter with its length,
|
|
77
|
+
each spoken beat and what is on screen
|
|
78
|
+
aula timeline <folder> [<chapter> ...] [--include-drafts]
|
|
79
|
+
print each say and move with its line, second
|
|
80
|
+
and note (agent view)
|
|
81
|
+
aula tokens Kokoro v1.0's token ids of texts, for training
|
|
82
|
+
data: reads JSON lines {"id"?, "text"} on
|
|
83
|
+
stdin, writes {"id"?, "batches": [{"phonemes",
|
|
84
|
+
"ids"}]} on stdout, one batch per model run
|
|
85
|
+
|
|
86
|
+
Errors make the exit code 1. Warnings do not change it.`;
|
|
87
|
+
var VALUED = {
|
|
88
|
+
"--port": { what: "a port number", number: true },
|
|
89
|
+
"--host": { what: "a host", number: false },
|
|
90
|
+
"--title": { what: "a title", number: false },
|
|
91
|
+
"--base": { what: "a base path", number: false }
|
|
92
|
+
};
|
|
93
|
+
function parse(argv, allowed) {
|
|
94
|
+
const args = { positional: [], values: /* @__PURE__ */ new Map(), flags: /* @__PURE__ */ new Set() };
|
|
95
|
+
for (let i = 0; i < argv.length; i++) {
|
|
96
|
+
const arg = argv[i] ?? "";
|
|
97
|
+
const what = VALUED[arg];
|
|
98
|
+
if (what !== void 0 && allowed.includes(arg)) {
|
|
99
|
+
i += 1;
|
|
100
|
+
const value = argv[i];
|
|
101
|
+
if (value === void 0) throw wrongArgument(`${arg} needs ${what.what}`);
|
|
102
|
+
if (!what.number) {
|
|
103
|
+
args.values.set(arg, value);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!/^[0-9]+$/.test(value)) throw wrongArgument(`${arg} ${value} is not a number`);
|
|
107
|
+
args.values.set(arg, Number(value));
|
|
108
|
+
} else if (allowed.includes(arg)) {
|
|
109
|
+
args.flags.add(arg);
|
|
110
|
+
} else if (arg.startsWith("--")) {
|
|
111
|
+
throw wrongArgument(`unknown option ${arg}`, "run `aula help` for the options of each command");
|
|
112
|
+
} else {
|
|
113
|
+
args.positional.push(arg);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return args;
|
|
117
|
+
}
|
|
118
|
+
var OPTIONS = {
|
|
119
|
+
check: ["--json", "--include-drafts"],
|
|
120
|
+
web: ["--port", "--host", "--include-drafts"],
|
|
121
|
+
site: ["--title", "--base", "--include-drafts"],
|
|
122
|
+
preview: ["--include-drafts"],
|
|
123
|
+
export: ["--include-drafts"],
|
|
124
|
+
bundle: ["--include-drafts"],
|
|
125
|
+
script: ["--include-drafts"],
|
|
126
|
+
timeline: ["--include-drafts"]
|
|
127
|
+
};
|
|
128
|
+
var isHelp = (command) => command === void 0 || command === "help" || command === "-h" || command === "--help";
|
|
129
|
+
function missingFolder() {
|
|
130
|
+
throw wrongArgument("missing <folder>: the project folder, which has index.ts");
|
|
131
|
+
}
|
|
132
|
+
var ARITY = {
|
|
133
|
+
preview: [1, Infinity],
|
|
134
|
+
export: [1, 1],
|
|
135
|
+
bundle: [1, 1],
|
|
136
|
+
script: [0, Infinity],
|
|
137
|
+
timeline: [0, Infinity]
|
|
138
|
+
};
|
|
139
|
+
function folderArgs(cwd, command, args) {
|
|
140
|
+
const arity = ARITY[command];
|
|
141
|
+
if (arity === void 0) throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
|
|
142
|
+
const [folder, ...rest] = args.positional;
|
|
143
|
+
if (folder === void 0) missingFolder();
|
|
144
|
+
if (rest.length < arity[0] || rest.length > arity[1])
|
|
145
|
+
throw wrongArgument("wrong number of arguments", "run `aula help` for the usage");
|
|
146
|
+
return { folder: path.resolve(cwd, folder), rest };
|
|
147
|
+
}
|
|
148
|
+
function checkOptions(cwd, args) {
|
|
149
|
+
const [folder, ...only] = args.positional;
|
|
150
|
+
if (folder === void 0) missingFolder();
|
|
151
|
+
return {
|
|
152
|
+
root: path.resolve(cwd, folder),
|
|
153
|
+
only,
|
|
154
|
+
json: args.flags.has("--json"),
|
|
155
|
+
includeDrafts: args.flags.has("--include-drafts")
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function extensionList(extensions) {
|
|
159
|
+
const [first, second, ...rest] = extensions;
|
|
160
|
+
if (first === void 0) throw new Error("fileArgument needs at least one file ending");
|
|
161
|
+
if (second === void 0) return first;
|
|
162
|
+
if (rest.length === 0) return `${first} or ${second}`;
|
|
163
|
+
return `${[first, second, ...rest.slice(0, -1)].join(", ")} or ${rest[rest.length - 1] ?? ""}`;
|
|
164
|
+
}
|
|
165
|
+
function fileArgument(cwd, value, options) {
|
|
166
|
+
const file = path.resolve(cwd, value);
|
|
167
|
+
if (!options.extensions.some((extension) => file.endsWith(extension)))
|
|
168
|
+
throw wrongArgument(
|
|
169
|
+
`The ${options.what} path must end with ${extensionList(options.extensions)}.`,
|
|
170
|
+
`Bad path: ${file}`
|
|
171
|
+
);
|
|
172
|
+
return file;
|
|
173
|
+
}
|
|
174
|
+
async function run(capabilities, cwd, command, project, rest, _flags = /* @__PURE__ */ new Set()) {
|
|
175
|
+
const [first = "", ...more] = rest;
|
|
176
|
+
switch (command) {
|
|
177
|
+
case "preview":
|
|
178
|
+
return preview(capabilities, cwd, project, path.resolve(cwd, first), more);
|
|
179
|
+
case "export":
|
|
180
|
+
return exportVideo(
|
|
181
|
+
capabilities,
|
|
182
|
+
cwd,
|
|
183
|
+
project,
|
|
184
|
+
fileArgument(cwd, first, { extensions: [".mp4"], what: "video" })
|
|
185
|
+
);
|
|
186
|
+
case "bundle":
|
|
187
|
+
return bundle(capabilities, project, fileArgument(cwd, first, { extensions: [".zip"], what: "zip" }));
|
|
188
|
+
case "script":
|
|
189
|
+
return script(capabilities, cwd, project, rest);
|
|
190
|
+
case "timeline":
|
|
191
|
+
return timeline(capabilities, cwd, project, rest);
|
|
192
|
+
default:
|
|
193
|
+
throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function webOptions(cwd, args) {
|
|
197
|
+
const [folder, ...more] = args.positional;
|
|
198
|
+
if (folder === void 0) missingFolder();
|
|
199
|
+
if (more.length > 0) throw wrongArgument("aula web takes one folder", "run `aula help` for the usage");
|
|
200
|
+
const port = args.values.get("--port");
|
|
201
|
+
const host = args.values.get("--host");
|
|
202
|
+
return {
|
|
203
|
+
root: path.resolve(cwd, folder),
|
|
204
|
+
port: typeof port === "number" ? port : 0,
|
|
205
|
+
host: typeof host === "string" ? host : "127.0.0.1",
|
|
206
|
+
includeDrafts: args.flags.has("--include-drafts")
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function siteOptions(cwd, args) {
|
|
210
|
+
const [folder, out, ...more] = args.positional;
|
|
211
|
+
if (folder === void 0 || out === void 0 || more.length > 0)
|
|
212
|
+
throw wrongArgument("aula site takes a folder and an output folder", "run `aula help` for the usage");
|
|
213
|
+
const title = args.values.get("--title");
|
|
214
|
+
const base = args.values.get("--base");
|
|
215
|
+
if (typeof base === "string" && !(base.startsWith("/") && base.endsWith("/")))
|
|
216
|
+
throw wrongArgument(`--base ${base} must start and end with /`, "for example --base /aula/");
|
|
217
|
+
const root = path.resolve(cwd, folder);
|
|
218
|
+
return {
|
|
219
|
+
folder: root,
|
|
220
|
+
out: path.resolve(cwd, out),
|
|
221
|
+
title: typeof title === "string" ? title : path.basename(root),
|
|
222
|
+
base: typeof base === "string" ? base : null,
|
|
223
|
+
includeDrafts: args.flags.has("--include-drafts")
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
var optionsOf = (command) => OPTIONS[command] ?? [];
|
|
227
|
+
export {
|
|
228
|
+
USAGE,
|
|
229
|
+
checkOptions,
|
|
230
|
+
fileArgument,
|
|
231
|
+
folderArgs,
|
|
232
|
+
isHelp,
|
|
233
|
+
optionsOf,
|
|
234
|
+
parse,
|
|
235
|
+
run,
|
|
236
|
+
siteOptions,
|
|
237
|
+
webOptions
|
|
238
|
+
};
|
|
@@ -2,22 +2,24 @@ import {
|
|
|
2
2
|
PACKAGE
|
|
3
3
|
} from "./chunk-A5QHTZKT.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
resolveRootProjects
|
|
6
|
+
} from "./chunk-N3YZ7K5L.js";
|
|
7
|
+
import {
|
|
6
8
|
nodeTree
|
|
7
9
|
} from "./chunk-THQ5Y74K.js";
|
|
8
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-F37DXY3P.js";
|
|
9
11
|
import {
|
|
10
12
|
SERVER_WEIGHTS_PATH
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-V3GJ4XSW.js";
|
|
12
14
|
import {
|
|
13
15
|
exists
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-2BEUK7M7.js";
|
|
17
|
+
import "./chunk-2VD3JPLV.js";
|
|
16
18
|
import {
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
Problems
|
|
20
|
+
} from "./chunk-VJAXVLXZ.js";
|
|
21
|
+
import "./chunk-GQSFMINU.js";
|
|
22
|
+
import "./chunk-T7S65ZHW.js";
|
|
21
23
|
import {
|
|
22
24
|
AulaError,
|
|
23
25
|
fault
|
|
@@ -27,7 +29,7 @@ import "./chunk-CZ7CSFO4.js";
|
|
|
27
29
|
// src/web/server.ts
|
|
28
30
|
import { once } from "node:events";
|
|
29
31
|
import { createServer } from "node:http";
|
|
30
|
-
import {
|
|
32
|
+
import { dirname, join } from "node:path";
|
|
31
33
|
|
|
32
34
|
// src/web/page.ts
|
|
33
35
|
var APP = new URL("web/app/", PACKAGE);
|
|
@@ -162,34 +164,36 @@ function openHost(host) {
|
|
|
162
164
|
}
|
|
163
165
|
async function serve(capabilities, options) {
|
|
164
166
|
const host = options.host ?? "127.0.0.1";
|
|
167
|
+
const includeDrafts = options.includeDrafts === true;
|
|
165
168
|
let generation = 0;
|
|
166
169
|
let cached = null;
|
|
167
170
|
const watching = changes(capabilities, () => {
|
|
168
171
|
generation += 1;
|
|
169
172
|
cached = null;
|
|
170
173
|
});
|
|
171
|
-
const bundler = createNodeBundler();
|
|
172
174
|
const tree = nodeTree(capabilities, options.root);
|
|
173
175
|
const buildBundle = () => {
|
|
174
176
|
if (cached !== null && cached.generation === generation) return cached.result;
|
|
175
177
|
const at = generation;
|
|
176
178
|
const result = (async () => {
|
|
177
179
|
await watchWorkspaceFolders(capabilities, options.root, watching);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
for (const
|
|
180
|
+
try {
|
|
181
|
+
const resolved = await resolveRootProjects(capabilities, options.root, includeDrafts);
|
|
182
|
+
for (const input of resolved.inputs) {
|
|
183
|
+
const disk = tree.diskPath(input);
|
|
184
|
+
if (disk !== null) watching.served(disk);
|
|
185
|
+
}
|
|
186
|
+
return { _tag: "Right", right: resolved.bundle };
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (!(error instanceof Problems)) throw error;
|
|
189
|
+
for (const diagnostic of error.diagnostics) {
|
|
181
190
|
const file = diagnostic.location?.file;
|
|
182
191
|
if (file === void 0) continue;
|
|
183
192
|
const disk = tree.diskPath(file);
|
|
184
193
|
if (disk !== null && exists(capabilities, disk)) watching.served(disk);
|
|
185
194
|
}
|
|
186
|
-
return
|
|
187
|
-
}
|
|
188
|
-
for (const input of bundled.right.inputs) {
|
|
189
|
-
const disk = tree.diskPath(input);
|
|
190
|
-
if (disk !== null) watching.served(disk);
|
|
195
|
+
return { _tag: "Left", left: error.diagnostics };
|
|
191
196
|
}
|
|
192
|
-
return { _tag: "Right", right: bundled.right.bundle };
|
|
193
197
|
})();
|
|
194
198
|
const entry = { generation: at, result };
|
|
195
199
|
cached = entry;
|
|
@@ -218,7 +222,6 @@ async function serve(capabilities, options) {
|
|
|
218
222
|
capabilities.log.out(`aula web: open ${open} in a browser${bindNote} (Ctrl-C stops it)`);
|
|
219
223
|
options.stop.addEventListener("abort", () => {
|
|
220
224
|
watching.close();
|
|
221
|
-
void bundler.stop();
|
|
222
225
|
server.close();
|
|
223
226
|
server.closeAllConnections();
|
|
224
227
|
});
|
|
@@ -2,39 +2,26 @@ import {
|
|
|
2
2
|
PACKAGE
|
|
3
3
|
} from "./chunk-A5QHTZKT.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
listedProjects,
|
|
10
|
-
loadBuiltProjects,
|
|
11
|
-
workspaceHost
|
|
12
|
-
} from "./chunk-AXQBWV7J.js";
|
|
13
|
-
import "./chunk-4QGX7XXO.js";
|
|
5
|
+
resolveRootProjects
|
|
6
|
+
} from "./chunk-N3YZ7K5L.js";
|
|
7
|
+
import "./chunk-THQ5Y74K.js";
|
|
8
|
+
import "./chunk-F37DXY3P.js";
|
|
14
9
|
import {
|
|
15
10
|
AULA_VOICE_WEIGHTS
|
|
16
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-V3GJ4XSW.js";
|
|
17
12
|
import {
|
|
18
|
-
Problems,
|
|
19
|
-
bundleProjects,
|
|
20
|
-
bundleWorkspace,
|
|
21
|
-
projectModules,
|
|
22
13
|
wrongArgument
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import
|
|
26
|
-
v8Frames
|
|
27
|
-
} from "./chunk-DN2LVJO3.js";
|
|
14
|
+
} from "./chunk-VJAXVLXZ.js";
|
|
15
|
+
import "./chunk-GQSFMINU.js";
|
|
16
|
+
import "./chunk-T7S65ZHW.js";
|
|
28
17
|
import {
|
|
29
18
|
fault
|
|
30
19
|
} from "./chunk-VX7UVLQW.js";
|
|
31
20
|
import "./chunk-CZ7CSFO4.js";
|
|
32
21
|
|
|
33
22
|
// src/site.ts
|
|
34
|
-
import { existsSync } from "node:fs";
|
|
35
|
-
import os from "node:os";
|
|
36
23
|
import path from "node:path";
|
|
37
|
-
import { fileURLToPath
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
38
25
|
var PAGE = new URL("web/site/", PACKAGE);
|
|
39
26
|
var PAGE_FOLDER = fileURLToPath(PAGE);
|
|
40
27
|
var WRITTEN = ["index.html", "assets", "bundle.json", "media", "tree", "tree.json"];
|
|
@@ -64,34 +51,6 @@ async function mediaFiles(capabilities, folder, projects) {
|
|
|
64
51
|
const inProject = (file) => folders.some((own) => own === "." || file.startsWith(`${own}/`));
|
|
65
52
|
return (await walk(capabilities, folder)).filter((file) => MEDIA_FILE.test(file) && inProject(file)).toSorted();
|
|
66
53
|
}
|
|
67
|
-
var METHOD_STUB = "export const paragraph = () => () => ({});\n";
|
|
68
|
-
async function loadSiteProjects(capabilities, workspaceBundle) {
|
|
69
|
-
const scratch = await capabilities.fs.mkdtemp(path.join(os.tmpdir(), "aula-site-videos-"));
|
|
70
|
-
let count = 0;
|
|
71
|
-
try {
|
|
72
|
-
const method = path.join(scratch, "aula-method.mjs");
|
|
73
|
-
await capabilities.fs.writeFile(method, METHOD_STUB);
|
|
74
|
-
const bundledAula = path.join(path.dirname(fileURLToPath(import.meta.url)), "aula.js");
|
|
75
|
-
const player = {
|
|
76
|
-
"@beff/aula": existsSync(bundledAula) ? pathToFileURL(bundledAula).href : import.meta.resolve("@beff/aula"),
|
|
77
|
-
"@beff/aula-method": pathToFileURL(method).href
|
|
78
|
-
};
|
|
79
|
-
const modules = {
|
|
80
|
-
load: async ({ code }) => {
|
|
81
|
-
count += 1;
|
|
82
|
-
const file = path.join(scratch, `bundle-${String(count)}.mjs`);
|
|
83
|
-
await capabilities.fs.writeFile(file, code);
|
|
84
|
-
const url = pathToFileURL(file).href;
|
|
85
|
-
return { url, exports: await import(url) };
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const loaded = await loadBuiltProjects(workspaceBundle, workspaceHost(v8Frames), modules, player);
|
|
89
|
-
if (loaded._tag === "Left") throw new Problems(loaded.left);
|
|
90
|
-
return loaded.right;
|
|
91
|
-
} finally {
|
|
92
|
-
await capabilities.fs.rm(scratch, { recursive: true, force: true });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
54
|
var videosOf = (projects) => projects.map(({ name: projectName, title, section }) => ({
|
|
96
55
|
name: projectName,
|
|
97
56
|
title,
|
|
@@ -108,51 +67,19 @@ var inside = (outer, inner) => {
|
|
|
108
67
|
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
109
68
|
};
|
|
110
69
|
async function site(capabilities, options) {
|
|
111
|
-
const { folder, out, title, base } = options;
|
|
70
|
+
const { folder, out, title, base, includeDrafts = false } = options;
|
|
112
71
|
if (!capabilities.fs.existsSync(folder) || !(await capabilities.fs.stat(folder)).isDirectory()) {
|
|
113
|
-
throw wrongArgument(`${folder} is not a folder`, "give
|
|
72
|
+
throw wrongArgument(`${folder} is not a folder`, "give a project or playlist folder");
|
|
114
73
|
}
|
|
115
74
|
if (inside(folder, out) || inside(out, folder)) {
|
|
116
75
|
throw wrongArgument(
|
|
117
|
-
"the output folder and the
|
|
118
|
-
"give an output folder that is outside the
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
const tree = nodeTree(capabilities, folder);
|
|
122
|
-
const folderName = path.basename(folder);
|
|
123
|
-
const listed = await projectModules(tree, folderName);
|
|
124
|
-
if (listed._tag === "Left") throw new Problems(listed.left);
|
|
125
|
-
if (listed.right.length === 0) {
|
|
126
|
-
throw wrongArgument(
|
|
127
|
-
`no project in ${folder}: run from a project or playlist folder, or pass it (for example: aula site examples site-out)`
|
|
76
|
+
"the output folder and the root folder hold each other",
|
|
77
|
+
"give an output folder that is outside the root folder"
|
|
128
78
|
);
|
|
129
79
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
const bundled = await bundleWorkspace(bundler, tree, folderName);
|
|
135
|
-
if (bundled._tag === "Left") throw new Problems(bundled.left);
|
|
136
|
-
workspaceBundle = bundled.right.bundle;
|
|
137
|
-
const loaded = await loadSiteProjects(capabilities, workspaceBundle);
|
|
138
|
-
const published = listedProjects(loaded);
|
|
139
|
-
if (published.length === 0) {
|
|
140
|
-
throw wrongArgument(
|
|
141
|
-
`no published project in ${folder}`,
|
|
142
|
-
"give a folder with at least one project that is not draft: true, or open a draft by its folder path"
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
if (published.length !== loaded.length) {
|
|
146
|
-
const keep = new Set(published.map((project) => project.name));
|
|
147
|
-
const filtered = workspaceBundle.projects.filter((project) => keep.has(project.name));
|
|
148
|
-
const rebundled = await bundleProjects(bundler, tree, folderName, filtered);
|
|
149
|
-
if (rebundled._tag === "Left") throw new Problems(rebundled.left);
|
|
150
|
-
workspaceBundle = rebundled.right.bundle;
|
|
151
|
-
}
|
|
152
|
-
videos = videosOf(published);
|
|
153
|
-
} finally {
|
|
154
|
-
await bundler.stop();
|
|
155
|
-
}
|
|
80
|
+
const { projects, bundle: workspaceBundle } = await resolveRootProjects(capabilities, folder, includeDrafts);
|
|
81
|
+
if (projects.length === 0) return true;
|
|
82
|
+
const videos = videosOf(projects);
|
|
156
83
|
const media = await mediaFiles(capabilities, folder, workspaceBundle.projects);
|
|
157
84
|
const bundleJson = JSON.stringify({ ...workspaceBundle, videos, media });
|
|
158
85
|
const weights = await capabilities.weights();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveOneProject,
|
|
3
|
+
resolveRootProjects
|
|
4
|
+
} from "./chunk-N3YZ7K5L.js";
|
|
5
|
+
import "./chunk-THQ5Y74K.js";
|
|
6
|
+
import "./chunk-F37DXY3P.js";
|
|
7
|
+
import "./chunk-V3GJ4XSW.js";
|
|
8
|
+
import "./chunk-VJAXVLXZ.js";
|
|
9
|
+
import "./chunk-GQSFMINU.js";
|
|
10
|
+
import "./chunk-T7S65ZHW.js";
|
|
11
|
+
import "./chunk-VX7UVLQW.js";
|
|
12
|
+
import "./chunk-CZ7CSFO4.js";
|
|
13
|
+
export {
|
|
14
|
+
resolveOneProject,
|
|
15
|
+
resolveRootProjects
|
|
16
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as e}from"../src-
|
|
1
|
+
import{f as e}from"../src-BjcN7H3T.js";import"./aula.js";var t=e=>JSON.stringify(e);function n(e){return!/\s/.test(e)&&!e.includes(`://`)&&/[/.]/.test(e)}function r(e,t){if(t.length!==1||t.raw.length!==1)throw Error(`${e}: a \${…} is not allowed in this tag`);let n=t[0]??``;if(n.includes(`
|
|
2
2
|
`))throw Error(`${e}: the text must be one line`);return n}function i(e,r,i){let a=[],o=(t,n,r=e.place)=>{a.push({code:t,message:n,...r===void 0?{}:{at:r}})};i.mechanism.trim()===``&&o(`method-no-mechanism`,`the paragraph has no mechanism: name the one mechanism that the viewer must understand`);for(let e of i.sources)n(e)&&!r.exists(e)&&o(`method-missing-source`,`${t(e)}: this path is not a file: correct the path or add the file`);return a}function a(t){let n=r(`paragraph`,t);return({sources:t},r)=>e({mechanism:n,sources:t},(e,a)=>[...i(e,a,{mechanism:n,sources:t}),...r?.(e,a)??[]])}export{a as paragraph};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as defineChapter,l as defineProject,u as embed,y as loadEngine,o as m,f as paragraph,p as pronounce,m as say,h as show}from"../src-
|
|
1
|
+
export{c as defineChapter,l as defineProject,u as embed,y as loadEngine,o as m,f as paragraph,p as pronounce,m as say,h as show}from"../src-BjcN7H3T.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e,t}from"../rolldown-runtime-BLXQ4ufn.js";import{_ as n,a as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,u as f,v as p}from"../protocol-j759xoXL.js";import{S as m,g as h,v as g,y as _}from"../src-BjcN7H3T.js";var v=44,y=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,b=new Uint8Array(64),x=new Uint8Array(128);for(let e=0;e<y.length;e++){let t=y.charCodeAt(e);b[e]=t,x[t]=e}function S(e){let t=0,n=0,r=0;do r=x[e.next()],t|=(r&31)<<n,n+=5;while(r&32);return t}function C(e){return e&1?-0x80000000|-(e>>>1):e>>>1}function w(e,t){return e.pos>=t?!1:e.peek()!==v}var ee=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){let{buffer:t,pos:n}=this,r=t.indexOf(e,n);return r===-1?t.length:r}};function te(e){let{length:t}=e,n=new ee(e),r=[],i=0,a=0,o=0,s=0,c=0;do{let e=n.indexOf(`;`),t=[],l=!0,u=0;for(i=0;n.pos<e;){let r;i+=C(S(n)),i<u&&(l=!1),u=i,w(n,e)?(a+=C(S(n)),o+=C(S(n)),s+=C(S(n)),w(n,e)?(c+=C(S(n)),r=[i,a,o,s,c]):r=[i,a,o,s]):r=[i],t.push(r),n.pos++}l||T(t),r.push(t),n.pos=e+1}while(n.pos<=t);return r}function T(e){e.sort(E)}function E(e,t){return e[0]-t[0]}var ne=e(t(((e,t,n)=>{var r;(function(n,i){typeof e==`object`&&t!==void 0?t.exports=i():typeof r==`function`&&r.amd?r(i):(n=typeof globalThis<`u`?globalThis:n||self,n.resolveURI=i())})(n,(function(){let e=/^[\w+.-]+:\/\//,t=/^([\w+.-]+:)\/\/([^@/#?]*@)?(\[[^\]]+\]|[^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,n=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function r(t){return e.test(t)}function i(e){return e.startsWith(`//`)}function a(e){return e.startsWith(`/`)}function o(e){return e.startsWith(`file:`)}function s(e){return/^[.?#]/.test(e)}function c(e){let n=t.exec(e);return u(n[1],n[2]||``,n[3],n[4]||``,n[5]||`/`,n[6]||``,n[7]||``)}function l(e){let t=n.exec(e),r=t[2];return u(`file:`,``,t[1]||``,``,a(r)?r:`/`+r,t[3]||``,t[4]||``)}function u(e,t,n,r,i,a,o){return{scheme:e,user:t,host:n,port:r,path:i,query:a,hash:o,type:7}}function d(e){if(i(e)){let t=c(`http:`+e);return t.scheme=``,t.type=6,t}if(a(e)){let t=c(`http://foo.com`+e);return t.scheme=``,t.host=``,t.type=5,t}if(o(e))return l(e);if(r(e))return c(e);let t=c(`http://foo.com/`+e);return t.scheme=``,t.host=``,t.type=e?e.startsWith(`?`)?3:e.startsWith(`#`)?2:4:1,t}function f(e){if(e.endsWith(`/..`))return e;let t=e.lastIndexOf(`/`);return e.slice(0,t+1)}function p(e,t){m(t,t.type),e.path=e.path===`/`?t.path:f(t.path)+e.path}function m(e,t){let n=t<=4,r=e.path.split(`/`),i=1,a=0,o=!1;for(let e=1;e<r.length;e++){let t=r[e];t?(o=!1,t!==`.`&&(t===`..`?a?(o=!0,a--,i--):n&&(r[i++]=t):(r[i++]=t,a++))):o=!0}let s=``;for(let e=1;e<i;e++)s+=`/`+r[e];(!s||o&&!s.endsWith(`/..`))&&(s+=`/`),e.path=s}function h(e,t){if(!e&&!t)return``;let n=d(e),r=n.type;if(t&&r!==7){let e=d(t),i=e.type;switch(r){case 1:n.hash=e.hash;case 2:n.query=e.query;case 3:case 4:p(n,e);case 5:n.user=e.user,n.host=e.host,n.port=e.port;case 6:n.scheme=e.scheme}i>r&&(r=i)}m(n,r);let i=n.query+n.hash;switch(r){case 2:case 3:return i;case 4:{let r=n.path.slice(1);return r?s(t||e)&&!s(r)?`./`+r+i:r+i:i||`.`}case 5:return n.path+i;default:return n.scheme+`//`+n.user+n.host+n.port+n.path+i}}return h}))}))(),1);function D(e){if(!e)return``;let t=e.lastIndexOf(`/`);return e.slice(0,t+1)}function re(e,t){let n=D(e),r=t?t+`/`:``;return e=>(0,ne.default)(r+(e||``),n)}var O=0,ie=1,ae=2,k=3,A=4;function j(e,t){let n=M(e,0);if(n===e.length)return e;t||(e=e.slice());for(let r=n;r<e.length;r=M(e,r+1))e[r]=P(e[r],t);return e}function M(e,t){for(let n=t;n<e.length;n++)if(!N(e[n]))return n;return e.length}function N(e){for(let t=1;t<e.length;t++)if(e[t][O]<e[t-1][O])return!1;return!0}function P(e,t){return t||(e=e.slice()),e.sort(F)}function F(e,t){return e[O]-t[O]}var I=!1;function L(e,t,n,r){for(;n<=r;){let i=n+(r-n>>1),a=e[i][O]-t;if(a===0)return I=!0,i;a<0?n=i+1:r=i-1}return I=!1,n-1}function R(e,t,n){for(let r=n+1;r<e.length&&e[r][O]===t;n=r++);return n}function z(e,t,n){for(let r=n-1;r>=0&&e[r][O]===t;n=r--);return n}function B(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function V(e,t,n,r){let{lastKey:i,lastNeedle:a,lastIndex:o}=n,s=0,c=e.length-1;if(r===i){if(t===a)return I=o!==-1&&e[o][O]===t,o;t>=a?s=o===-1?0:o:c=o}return n.lastKey=r,n.lastNeedle=t,n.lastIndex=L(e,t,s,c)}function H(e){return typeof e==`string`?JSON.parse(e):e}var U="`line` must be greater than 0 (lines start at line 1)",oe="`column` must be greater than or equal to 0 (columns start at column 0)",W=class{constructor(e,t){let n=typeof e==`string`;if(!n&&e._decodedMemo)return e;let r=H(e),{version:i,file:a,names:o,sourceRoot:s,sources:c,sourcesContent:l}=r;this.version=i,this.file=a,this.names=o||[],this.sourceRoot=s,this.sources=c,this.sourcesContent=l,this.ignoreList=r.ignoreList||r.x_google_ignoreList||void 0;let u=re(t,s);this.resolvedSources=c.map(u);let{mappings:d}=r;if(typeof d==`string`)this._encoded=d,this._decoded=void 0;else if(Array.isArray(d))this._encoded=void 0,this._decoded=j(d,n);else if(r.sections)throw Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);else throw Error(`invalid source map: ${JSON.stringify(r)}`);this._decodedMemo=B(),this._bySources=void 0,this._bySourceMemos=void 0}};function G(e){return e}function K(e){var t;return(t=G(e))._decoded||(t._decoded=te(G(e)._encoded))}function q(e,t){let{line:n,column:r,bias:i}=t;if(n--,n<0)throw Error(U);if(r<0)throw Error(oe);let a=K(e);if(n>=a.length)return J(null,null,null,null);let o=a[n],s=se(o,G(e)._decodedMemo,n,r,i||1);if(s===-1)return J(null,null,null,null);let c=o[s];if(c.length===1)return J(null,null,null,null);let{names:l,resolvedSources:u}=e;return J(u[c[ie]],c[ae]+1,c[k],c.length===5?l[c[A]]:null)}function J(e,t,n,r){return{source:e,line:t,column:n,name:r}}function se(e,t,n,r,i){let a=V(e,r,t,n);return I?a=(i===-1?R:z)(e,r,a):i===-1&&a++,a===-1||a===e.length?-1:a}var Y=new Map;function ce(e,t,n){Y.set(e,{map:new W(t),prefix:n})}function le(e,t,n){let r=Y.get(e);if(!r)return{file:e,line:t,column:n};let i=q(r.map,{line:t,column:n-1});return i.source===null||i.line===null||i.column===null?{file:e,line:t,column:n}:{file:i.source.startsWith(r.prefix)?i.source.slice(r.prefix.length):i.source,line:i.line,column:i.column+1}}var X=p(le);function ue(e){let t=0,n=new Map;e.then(e=>{e.addEventListener(`message`,t=>{let i=t.data;if(i.kind===`error`)throw e.close(),new r(`the narrator stopped: ${i.message}`,i.stack);let a=n.get(i.id);n.delete(i.id),a?.(i)}),e.start()});let i=async(r,i)=>{let a=await e;return new Promise(e=>{let o=t++;n.set(o,e),a.postMessage({id:o,kind:r,words:i})})};return{speak:async e=>{let t=await i(`speak`,e);if(t.kind!==`speech`)throw Error(`the narrator answered ${t.kind} to a speech`);return{samples:t.samples,sampleRate:t.sampleRate,words:t.words}},time:async e=>{let t=await i(`time`,e);if(t.kind!==`timing`)throw Error(`the narrator answered ${t.kind} to a clock`);return{samples:t.samples,sampleRate:t.sampleRate,words:t.words}}}}function de(e){let t=0,r=0,c=!1,u=new Map,p=n=>{let r=r=>{let i=t++,{promise:a,resolve:o}=Promise.withResolvers();return u.set(i,o),e.post({kind:`files`,id:i,tree:n,question:r},[]),a};return{bundle:async()=>{let e=await r({kind:`bundle`});if(e.kind!==`bundle`)throw Error(`the page answered ${e.kind} to a question of the bundle`);return e.result},name:async()=>{let e=await r({kind:`name`});if(e.kind!==`name`)throw Error(`the page answered ${e.kind} to a question of the name`);return e.name},read:async e=>{let t=await r({kind:`read`,path:e});if(t.kind!==`read`)throw Error(`the page answered ${t.kind} to a read of ${e}`);return t.text},bytes:async e=>{let t=await r({kind:`bytes`,path:e});if(t.kind!==`bytes`)throw Error(`the page answered ${t.kind} to a read of the bytes of ${e}`);return t.bytes},list:async e=>{let t=await r({kind:`list`,folder:e});if(t.kind!==`list`)throw Error(`the page answered ${t.kind} to a list of ${e}`);return t.names}}},m=async()=>{let t=p(r++),n=new Map,o=new Set,s=e=>{let t=n.get(e);return t===void 0&&o.add(e),t?{size:t.length,read:()=>t}:void 0},[l]=await Promise.all([t.bundle(),_().then(async()=>{await g(),e.post({kind:`stage`,stage:`engine`},[])})]),u,m=!1;if(l!==null){if(l._tag===`Left`)return e.post({kind:`stage`,stage:`project`},[]),l;m=l.right.includeDrafts===!0,u=await i(l.right,d(X,s),e.modules,e.player)}else{let n=await t.name();if(n===null)return e.post({kind:`stage`,stage:`project`},[]),{_tag:`Right`,right:[]};let r={name:()=>Promise.resolve(n),read:t.read,list:t.list},i=await e.bundler();u=await a(r,d(X,s),e.modules,i,e.player)}if(e.post({kind:`stage`,stage:`project`},[]),u._tag===`Left`)return u;u={_tag:`Right`,right:f(u.right,{includeDrafts:m})},c||(c=!0,e.post({kind:`narrator`},[]));let v=async e=>{for(;;){o.clear();let r=e(),i=[...o].filter(e=>!n.has(e));if(i.length===0)return r;await Promise.all(i.map(async e=>n.set(e,await t.bytes(e))))}};return{_tag:`Right`,right:u.right.map(e=>{let t=new Set;return{...e,readScript:async()=>(await h(),v(()=>e.script())),readChapter:async n=>{t.has(n)||(await h(),await v(()=>e.walk?.(n)),t.add(n))}}})}},v=Promise.withResolvers(),y=n(s.create({voice:ue(v.promise),workspace:{projects:m}})),b=[],x=(t,{chapters:n,...r})=>{let i=[],a=[],s=[];n.forEach((e,t)=>{let n=b[t];if(e===n)return;if(!e){i.push([t,void 0]);return}let r=n?.cues.map(e=>e.samples)??[];if(e.animation!==n?.animation){let{animation:n,cues:a,...s}=e,c=a.map(e=>{let t=e.samples?r.indexOf(e.samples):-1;return t===-1?null:t}),l=a.map(({at:e,length:t},n)=>({at:e,length:t,keep:c[n]??null}));i.push([t,{...s,lottie:o(n),cues:l}]),r=c.map(e=>e===null?void 0:r[e])}e.cues.forEach((e,n)=>{if(!e.samples||e.samples===r[n])return;let i=e.samples.slice();s.push(i.buffer),a.push({chapter:t,cue:n,samples:i})})}),b=n;let c={building:r.building,timeline:r.timeline,duration:r.duration,errors:l(r.errors)};e.post({kind:`state`,watch:t,state:c,count:n.length,drawings:i,sounds:a},s)};return t=>{switch(t.kind){case`list`:y.build.list().then(n=>{let r=n._tag===`Left`?{_tag:`Left`,left:l(n.left)}:n;e.post({kind:`listed`,id:t.id,videos:r},[])});return;case`watch`:b=[],y.build.watch(t.name,{changed:e=>{x(t.watch,e)}});return;case`seek`:y.build.seek(t.name,t.place);return;case`halt`:y.halt();return;case`refresh`:y.refresh(t.place);return;case`files`:{let e=u.get(t.id);u.delete(t.id),e?.(t.answer);return}case`narrator`:v.resolve(t.port);return}}}var Z=(e,t=[])=>{self.postMessage(e,{transfer:t})},Q=e=>{let t=u(e,X);Z({kind:`error`,message:t.message,stack:t.stack.map(e=>` ${e}`).join(`
|
|
2
|
+
`)})};self.addEventListener(`error`,e=>{e.preventDefault(),Q(e.error??Error(e.message))}),self.addEventListener(`unhandledrejection`,e=>{e.preventDefault(),Q(e.reason)});var fe={"@beff/aula":new URL(`./aula.js`,import.meta.url).href,"@beff/aula-method":new URL(`./aula-method.js`,import.meta.url).href},pe={load:async({code:e,map:t})=>{let n=URL.createObjectURL(new Blob([e],{type:`text/javascript`}));return ce(n,t,c),{url:n,exports:await import(n)}}},$=null;function me(){return $??=(async()=>{let t=performance.now(),[n,r]=await Promise.all([m(()=>import(`../browser-sNTR4ahh.js`).then(t=>e(t.default,1)),[]),m(()=>import(`../esbuild-D6hmBtXM.js`),[])]);return await n.initialize({wasmURL:r.default,worker:!1}),console.log(`aula: esbuild loaded in ${((performance.now()-t)/1e3).toFixed(1)} s`),n})(),$}var he=de({post:Z,bundler:me,modules:pe,player:fe});self.addEventListener(`message`,e=>{he(e.data)});
|