@beff/aula 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/generated/aula.core5.wasm +0 -0
  2. package/dist/index.d.ts +7304 -6
  3. package/dist/index.js +14864 -11
  4. package/dist/index.js.map +1 -0
  5. package/package.json +8 -25
  6. package/dist/animations.d.ts +0 -635
  7. package/dist/animations.js +0 -1778
  8. package/dist/braces.d.ts +0 -84
  9. package/dist/braces.js +0 -253
  10. package/dist/card.d.ts +0 -17
  11. package/dist/card.js +0 -90
  12. package/dist/colors-palette.d.ts +0 -2242
  13. package/dist/colors-palette.js +0 -2241
  14. package/dist/colors.d.ts +0 -120
  15. package/dist/colors.js +0 -403
  16. package/dist/curves.d.ts +0 -10
  17. package/dist/curves.js +0 -128
  18. package/dist/engine.d.ts +0 -1705
  19. package/dist/engine.js +0 -3561
  20. package/dist/errors.d.ts +0 -19
  21. package/dist/errors.js +0 -25
  22. package/dist/geometry.d.ts +0 -551
  23. package/dist/geometry.js +0 -1555
  24. package/dist/graph.d.ts +0 -117
  25. package/dist/graph.js +0 -526
  26. package/dist/graphing.d.ts +0 -597
  27. package/dist/graphing.js +0 -1504
  28. package/dist/host.d.ts +0 -19
  29. package/dist/host.js +0 -85
  30. package/dist/lexicon.d.ts +0 -10
  31. package/dist/lexicon.js +0 -23
  32. package/dist/load.d.ts +0 -21
  33. package/dist/load.js +0 -109
  34. package/dist/logo.d.ts +0 -30
  35. package/dist/logo.js +0 -186
  36. package/dist/manim.d.ts +0 -22
  37. package/dist/manim.js +0 -19
  38. package/dist/media.d.ts +0 -34
  39. package/dist/media.js +0 -391
  40. package/dist/mobjects.d.ts +0 -127
  41. package/dist/mobjects.js +0 -316
  42. package/dist/picture.d.ts +0 -23
  43. package/dist/picture.js +0 -291
  44. package/dist/pointcloud.d.ts +0 -144
  45. package/dist/pointcloud.js +0 -384
  46. package/dist/rates.d.ts +0 -19
  47. package/dist/rates.js +0 -54
  48. package/dist/run.d.ts +0 -101
  49. package/dist/run.js +0 -323
  50. package/dist/tables.d.ts +0 -179
  51. package/dist/tables.js +0 -403
  52. package/dist/tex.d.ts +0 -8
  53. package/dist/tex.js +0 -257
  54. package/dist/text-layouts.d.ts +0 -64
  55. package/dist/text-layouts.js +0 -225
  56. package/dist/text.d.ts +0 -61
  57. package/dist/text.js +0 -78
  58. package/dist/theme.d.ts +0 -25
  59. package/dist/theme.js +0 -12
  60. package/dist/user-code.d.ts +0 -5
  61. package/dist/user-code.js +0 -20
  62. package/dist/utils.d.ts +0 -152
  63. package/dist/utils.js +0 -517
  64. package/dist/vector-field.d.ts +0 -132
  65. package/dist/vector-field.js +0 -361
package/dist/run.d.ts DELETED
@@ -1,101 +0,0 @@
1
- import type { ChapterRun, ProjectDefinition, StackFrame } from "./engine.ts";
2
- import type { Diagnostic, Location, ChapterText, Narration } from "./text.ts";
3
- import { type MediaSource } from "./media.ts";
4
- export { importUserModule } from "./user-code.ts";
5
- export { renderScene } from "./engine.ts";
6
- export type { Leaf, SceneRun } from "./engine.ts";
7
- export type { StackFrame } from "./engine.ts";
8
- export { MAX_CLIP_BYTES, MEDIA_FORMATS, probeMedia } from "./media.ts";
9
- export type { MediaInfo, MediaSource } from "./media.ts";
10
- /** How a host reads stack frames and names their files. */
11
- export interface Host {
12
- /** The frames of an error: of a call that the core keeps, or of a thrown error. The first
13
- * frame is the function that made the error. */
14
- frames(error: Error): StackFrame[];
15
- /** The name of a frame's file in diagnostics (a path from the workspace root), or undefined
16
- * for a frame that is not a workspace file. */
17
- name(file: string): string | undefined;
18
- /** True when `path`, from the working directory (as the paths in diagnostics are), is a
19
- * file. The paragraph checks get it (`CheckedChapter.exists`). The CLI reads the file
20
- * system; the web app has no files, and gives true. */
21
- exists(path: string): boolean;
22
- /** The file at `path` (from the working directory, as `exists`), or undefined when there is
23
- * none: what an `embed` reads in its header (`probeMedia`). A host with no files gives none. */
24
- media?(path: string): MediaSource | undefined;
25
- }
26
- /** Frames per second of the Lottie files: the engine's rate (`engine.fps()`, which
27
- * `constants.test.ts` checks), as a value here: an import does not load the engine. */
28
- export declare const FPS = 60;
29
- /** `tts`: the narrator engine (tokens to audio), after `loadEngine()`. */
30
- export { initG2p, loadEngine, tts } from "./load.ts";
31
- /** The name of chapter 0, the title card. */
32
- export declare const TITLE = "title";
33
- /** The slug of a title or heading: lower-case words joined by `-`. */
34
- export declare function slugOf(text: string): string;
35
- /** The chapter names of a project in narration order: the title card, then `NN-<heading slug>`. */
36
- export declare function chapterNames(project: Pick<ProjectDefinition, "chapters">): string[];
37
- /** The frames of an error from the V8 text of its stack (Node), with `file:` URLs as paths. */
38
- export declare function v8Frames(made: Error): StackFrame[];
39
- /** The place of a define call (`defineChapter`, `defineProject`): the frame of its caller, as
40
- * `host` reads it. */
41
- export declare function definedAt(definition: {
42
- readonly call: Error;
43
- }, host?: Host): StackFrame;
44
- /** An error diagnostic. */
45
- export declare function error(message: string, more?: {
46
- location?: Location;
47
- hint?: string;
48
- }): Diagnostic;
49
- /** The diagnostic of a thrown value: the first frame in the chapter file `chapterFile` (as the stack names
50
- * it) is the location, the workspace frames before it are the stack. When a callback threw inside
51
- * the engine call, that error is the one reported, with its own stack. */
52
- export declare function diagnosticOf(value: unknown, chapterFile: string, host: Host): Diagnostic;
53
- /** The result of a read or a drawing: `ok` is false when there are errors; `value` is there when the chapter
54
- * ran to its end. */
55
- export interface ChapterResult<T> {
56
- ok: boolean;
57
- diagnostics: Diagnostic[];
58
- value?: T | undefined;
59
- }
60
- /** How aula reads a chapter. */
61
- export interface ReadOptions {
62
- /** How aula reads the stack frames and names their files (default: V8 frames, each file
63
- * named by its path). */
64
- host?: Host | undefined;
65
- }
66
- /** Reads chapter `index` (from 1) of `project`: its text and its text problems, with no move
67
- * run. The paragraph checks run only when the chapter is checked (`checkChapter`). */
68
- export declare function readChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "lexicon" | "call">, index: number, options?: ReadOptions): ChapterResult<ChapterText>;
69
- /** Checks chapter `index` (0 is the title card) of `project`, as `aula check` does: it runs
70
- * the moves in list order with no clock and no narration, and gives the text problems, the
71
- * engine's checks of the picture after each animation, the kit findings and the paragraph
72
- * checks. With sync by construction, no check depends on the length of a `say`. */
73
- export declare function checkChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "lexicon" | "theme" | "card" | "call">, index: number, options?: ReadOptions): ChapterResult<{
74
- diagnostics: Diagnostic[];
75
- }>;
76
- /** The problems of the project lexicon (`defineProject({ lexicon })`), at the `defineProject`
77
- * call: a key that is not one word, a reading that is not `{ say: string }` or
78
- * `{ phonemes: string }`, an empty `say` reading, and a phoneme that is not in Kokoro's token
79
- * table. `aula check` gives them once for the project. A chapter leaves out an entry with a
80
- * problem. */
81
- export declare function checkLexicon(project: Pick<ProjectDefinition, "lexicon" | "call">, options?: ReadOptions): Diagnostic[];
82
- /** The problems of the `pronounce` words of the project title (``defineProject({ title: say`…` })``),
83
- * at the line of its `say`: the problems that a `say` row with the same text gives (the written
84
- * part is not one word, a phoneme is not in Kokoro's token table, the reading has no
85
- * phonemes). `aula check` gives them once for the project. A plain string has none. */
86
- export declare function checkTitle(project: Pick<ProjectDefinition, "titleParts" | "titleCall" | "call">, options?: ReadOptions): Diagnostic[];
87
- /** How aula draws a chapter against a narration. */
88
- export interface RenderOptions extends ReadOptions {
89
- /** The narration of this chapter: a cue for its heading and for each paragraph. */
90
- narration: Narration;
91
- /** Draw no frames: only the clock (the waits and the narration on the clock of the
92
- * picture). */
93
- lint?: boolean | undefined;
94
- /** Leave out the linear keyframes of the Lottie that a player interpolates to within a small
95
- * error (default `true`). Only the test of that rule turns it off. */
96
- prune?: boolean | undefined;
97
- }
98
- /** Draws chapter `index` (0 is the title card) of `project` on its narration: its Lottie, its
99
- * length in frames, the waits of the narration and the warnings at the moves that the
100
- * narration waits for. */
101
- export declare function renderChapter(project: Pick<ProjectDefinition, "title" | "chapters" | "lexicon" | "theme" | "card" | "call">, index: number, options: RenderOptions): ChapterResult<ChapterRun>;
package/dist/run.js DELETED
@@ -1,323 +0,0 @@
1
- import { checkRows, checkTitleCard, drawRows, drawTitle, readRows } from "./engine.js";
2
- import { card as defaultCard } from "./card.js";
3
- import { theme as defaultTheme } from "./theme.js";
4
- import { AulaError } from "./errors.js";
5
- import { engine, isComponentError } from "./load.js";
6
- import { hasPending, takePending } from "./host.js";
7
- import { runUserCode } from "./user-code.js";
8
- import { badReadings, lexiconEntries } from "./lexicon.js";
9
- import { probeMedia, projectPath } from "./media.js";
10
- import { probePicture } from "./picture.js";
11
- export { importUserModule } from "./user-code.js";
12
- export { renderScene } from "./engine.js";
13
- export { MAX_CLIP_BYTES, MEDIA_FORMATS, probeMedia } from "./media.js";
14
- /** Frames per second of the Lottie files: the engine's rate (`engine.fps()`, which
15
- * `constants.test.ts` checks), as a value here: an import does not load the engine. */
16
- export const FPS = 60;
17
- /** `tts`: the narrator engine (tokens to audio), after `loadEngine()`. */
18
- export { initG2p, loadEngine, tts } from "./load.js";
19
- /** The name of chapter 0, the title card. */
20
- export const TITLE = "title";
21
- /** The slug of a title or heading: lower-case words joined by `-`. */
22
- export function slugOf(text) {
23
- return text
24
- .normalize("NFKD")
25
- .replace(/[̀-ͯ]/g, "")
26
- .toLowerCase()
27
- .replace(/[^a-z0-9]+/g, "-")
28
- .replace(/^-|-$/g, "");
29
- }
30
- /** The chapter names of a project in narration order: the title card, then `NN-<heading slug>`. */
31
- export function chapterNames(project) {
32
- return [TITLE, ...project.chapters.map((c, i) => `${String(i + 1).padStart(2, "0")}-${slugOf(c.heading)}`)];
33
- }
34
- /** The hint of a wrong name: `tsc` names the name and its line. */
35
- const TSC = "run tsc: it finds wrong names before aula runs";
36
- /** A frame's file: a `file:` URL as its path. */
37
- function framePath(at) {
38
- return at.startsWith("file:") ? decodeURIComponent(new URL(at).pathname) : at;
39
- }
40
- /** The frames of an error from the V8 text of its stack (Node), with `file:` URLs as paths. */
41
- export function v8Frames(made) {
42
- const out = [];
43
- for (const raw of (made.stack ?? "").split("\n")) {
44
- const line = raw.trim();
45
- if (!line.startsWith("at "))
46
- continue;
47
- const body = line.slice(3);
48
- const paren = /^(.*) \((.*)\)$/.exec(body);
49
- const fn = paren?.[1] ?? "";
50
- const at = paren?.[2] ?? body;
51
- const m = /^(.*):(\d+):(\d+)$/.exec(at);
52
- if (m?.[1] === undefined || m[2] === undefined || m[3] === undefined)
53
- continue;
54
- out.push({
55
- function: fn.replace(/^(async |new )/, ""),
56
- file: framePath(m[1]),
57
- line: Number(m[2]),
58
- col: Number(m[3]),
59
- });
60
- }
61
- return out;
62
- }
63
- /** The host of Node: V8 frames, each file named by its path, and each path taken as a file. */
64
- const NODE = { frames: v8Frames, name: (file) => file, exists: () => true };
65
- /** The place of a define call (`defineChapter`, `defineProject`): the frame of its caller, as
66
- * `host` reads it. */
67
- export function definedAt(definition, host = NODE) {
68
- return host.frames(definition.call)[1] ?? { function: "", file: "", line: 0, col: 0 };
69
- }
70
- /** The location of a syntax error in an imported module: V8 and Node's TypeScript parser start
71
- * the stack with `file:line` (either a `file:` URL or an absolute path). */
72
- function syntaxLocation(stack) {
73
- const first = stack.split("\n")[0] ?? "";
74
- const m = /^((?:file:|\/)\S+?):(\d+)(?::\d+)?$/.exec(first);
75
- if (m?.[1] === undefined || m[2] === undefined)
76
- return undefined;
77
- return { file: framePath(m[1]), line: Number(m[2]) };
78
- }
79
- function propertyOf(e, key) {
80
- return typeof e === "object" && e !== null ? Reflect.get(e, key) : undefined;
81
- }
82
- function stringOf(e, key) {
83
- const v = propertyOf(e, key);
84
- return typeof v === "string" ? v : undefined;
85
- }
86
- /** An error diagnostic. */
87
- export function error(message, more = {}) {
88
- return { severity: "error", message, ...more, stack: [], related: [] };
89
- }
90
- function isDiagnostic(v) {
91
- return typeof v === "object" && v !== null && "message" in v && "severity" in v;
92
- }
93
- /** The engine's own diagnostic of a thrown value: a AulaError's, or the error of a WIT `result`
94
- * (jco throws it as a ComponentError). */
95
- function engineDiagnostic(thrown) {
96
- if (thrown instanceof AulaError)
97
- return thrown.diagnostic;
98
- if (isComponentError(thrown) && isDiagnostic(thrown.payload))
99
- return thrown.payload;
100
- return undefined;
101
- }
102
- /** The diagnostic of a thrown value: the first frame in the chapter file `chapterFile` (as the stack names
103
- * it) is the location, the workspace frames before it are the stack. When a callback threw inside
104
- * the engine call, that error is the one reported, with its own stack. */
105
- export function diagnosticOf(value, chapterFile, host) {
106
- const thrown = hasPending() ? takePending() : value;
107
- if (!(thrown instanceof Error)) {
108
- return error(`threw ${typeof thrown === "string" ? thrown : String(thrown)}, not an Error`, {
109
- hint: "throw an Error: throw new Error(message)",
110
- });
111
- }
112
- const stack = thrown.stack ?? "";
113
- const named = (file) => host.name(file) ?? file;
114
- const all = host.frames(thrown).filter((f) => host.name(f.file) !== undefined);
115
- const primary = all.findIndex((f) => f.file === chapterFile);
116
- const own = engineDiagnostic(thrown);
117
- const at = primary >= 0 ? all[primary] : own !== undefined ? undefined : all[0];
118
- const kit = (primary >= 0 ? all.slice(0, primary) : all.slice(1)).map((f) => ({
119
- function: f.function,
120
- location: { file: named(f.file), line: f.line, col: f.col },
121
- }));
122
- let location = at === undefined ? undefined : { file: named(at.file), line: at.line, col: at.col };
123
- let message = thrown.message;
124
- let hint = stringOf(thrown, "hint");
125
- const related = [];
126
- if (own !== undefined) {
127
- message = own.message;
128
- hint = own.hint;
129
- if (own.location !== undefined) {
130
- if (location !== undefined && (own.location.line !== location.line || own.location.file !== location.file)) {
131
- related.push({ label: "called at", location });
132
- }
133
- location = own.location;
134
- }
135
- related.push(...own.related);
136
- }
137
- else {
138
- if (thrown.name === "SyntaxError") {
139
- const where = syntaxLocation(stack);
140
- if (where !== undefined)
141
- location = { file: named(where.file), line: where.line, col: 0 };
142
- if (/does not provide an export named/.test(message)) {
143
- hint = TSC;
144
- }
145
- else {
146
- message = `syntax error: ${message}`;
147
- }
148
- }
149
- else if (thrown.name === "ReferenceError") {
150
- hint = TSC;
151
- }
152
- else if (thrown.name === "TypeError") {
153
- if (/ is not a function/.test(message)) {
154
- hint = TSC;
155
- }
156
- else if (message.startsWith("Cannot read properties of")) {
157
- hint =
158
- "the value before the dot is undefined or null: check that it was made, or returned by the function that made it";
159
- }
160
- }
161
- else if (thrown.name === "RangeError") {
162
- if (message.includes("call stack"))
163
- hint = "too much recursion or a loop that never ends";
164
- }
165
- else if (message.startsWith("unreachable")) {
166
- hint = "an engine bug, not a chapter error: report it with the chapter line";
167
- }
168
- }
169
- return {
170
- severity: "error",
171
- message,
172
- ...(location === undefined ? {} : { location }),
173
- stack: kit,
174
- ...(hint === undefined ? {} : { hint }),
175
- related,
176
- };
177
- }
178
- const isError = (d) => d.severity === "error";
179
- /** Runs a chapter; a throw is a diagnostic at the line of the chapter file `file`. */
180
- function attempt(file, host, f) {
181
- const run = runUserCode(f);
182
- if (run._tag === "Left")
183
- return { ok: false, diagnostics: [diagnosticOf(run.left, file, host)] };
184
- return { ok: !run.right.diagnostics.some(isError), diagnostics: run.right.diagnostics, value: run.right };
185
- }
186
- /** Chapter `index` (from 1) of `project`. */
187
- function chapterOf(project, index) {
188
- return (project.chapters[index - 1] ??
189
- error(`the project has chapters 1 to ${String(project.chapters.length)}; there is no chapter ${String(index)}`));
190
- }
191
- /** The folder of the project, as the host names it (`.` for the working directory): where the
192
- * path of an `embed` starts. */
193
- function projectFolder(project, host) {
194
- const file = definedAt(project, host).file;
195
- const name = host.name(file) ?? file;
196
- const slash = name.lastIndexOf("/");
197
- return slash === -1 ? "." : name.slice(0, slash);
198
- }
199
- /** The file `given` of an `embed` (a path from the project folder): what it is, or why it
200
- * cannot play. */
201
- function clipOf(host, folder, given) {
202
- const found = projectPath(given);
203
- if ("problem" in found)
204
- return `embed: ${JSON.stringify(given)} ${found.problem}`;
205
- const source = host.media?.(folder === "." ? found.path : `${folder}/${found.path}`);
206
- if (source === undefined)
207
- return `embed: no file ${JSON.stringify(given)} in the project folder`;
208
- const probed = probeMedia(source);
209
- return typeof probed === "string" ? `embed: ${JSON.stringify(given)} ${probed}` : probed;
210
- }
211
- /** The folder of the chapter file `file`, from the project folder ("" for the project folder). */
212
- function chapterFolder(project, file, host) {
213
- const folder = projectFolder(project, host);
214
- const name = host.name(file) ?? file;
215
- const slash = name.lastIndexOf("/");
216
- const dir = slash === -1 ? "." : name.slice(0, slash);
217
- if (dir === folder)
218
- return "";
219
- return dir.startsWith(`${folder}/`) ? dir.slice(folder.length + 1) : "";
220
- }
221
- /** The file `given` of an `m.Image` (a path from the chapter file, in the folder `from` of the
222
- * project): its picture, or why it cannot be drawn. */
223
- function pictureOf(host, folder, from, given) {
224
- const found = projectPath(given, from);
225
- if ("problem" in found)
226
- return `m.Image: ${JSON.stringify(given)} ${found.problem}`;
227
- const source = host.media?.(folder === "." ? found.path : `${folder}/${found.path}`);
228
- if (source === undefined) {
229
- return `m.Image: no file ${JSON.stringify(given)} in the project folder (the path starts at the chapter file)`;
230
- }
231
- const probed = probePicture(source);
232
- return typeof probed === "string" ? `m.Image: ${JSON.stringify(given)} ${probed}` : { ...probed, path: found.path };
233
- }
234
- /** The slot of chapter `index` (from 1) of `project`. */
235
- function slotOf(project, chapter, index, host) {
236
- const source = definedAt(chapter, host).file;
237
- return {
238
- number: index,
239
- count: project.chapters.length,
240
- source,
241
- file: host.name(source) ?? source,
242
- frames: (e) => host.frames(e),
243
- lexicon: lexiconEntries(project.lexicon),
244
- clip: (given) => clipOf(host, projectFolder(project, host), given),
245
- picture: (given) => pictureOf(host, projectFolder(project, host), chapterFolder(project, source, host), given),
246
- };
247
- }
248
- /** Reads chapter `index` (from 1) of `project`: its text and its text problems, with no move
249
- * run. The paragraph checks run only when the chapter is checked (`checkChapter`). */
250
- export function readChapter(project, index, options = {}) {
251
- const host = options.host ?? NODE;
252
- const chapter = chapterOf(project, index);
253
- if (!("call" in chapter))
254
- return { ok: false, diagnostics: [chapter] };
255
- const slot = slotOf(project, chapter, index, host);
256
- const run = attempt(slot.source, host, () => readRows(chapter, slot));
257
- return { ok: run.ok, diagnostics: run.diagnostics, value: run.value?.text };
258
- }
259
- /** Checks chapter `index` (0 is the title card) of `project`, as `aula check` does: it runs
260
- * the moves in list order with no clock and no narration, and gives the text problems, the
261
- * engine's checks of the picture after each animation, the kit findings and the paragraph
262
- * checks. With sync by construction, no check depends on the length of a `say`. */
263
- export function checkChapter(project, index, options = {}) {
264
- const host = options.host ?? NODE;
265
- const card = project.card ?? defaultCard;
266
- const theme = project.theme ?? defaultTheme;
267
- if (index === 0) {
268
- return attempt("", host, () => checkTitleCard(project.title, theme, card, project.chapters.length));
269
- }
270
- const chapter = chapterOf(project, index);
271
- if (!("call" in chapter))
272
- return { ok: false, diagnostics: [chapter] };
273
- const slot = slotOf(project, chapter, index, host);
274
- return attempt(slot.source, host, () => checkRows(chapter, theme, card, slot, (p) => host.exists(p)));
275
- }
276
- /** The problems of the project lexicon (`defineProject({ lexicon })`), at the `defineProject`
277
- * call: a key that is not one word, a reading that is not `{ say: string }` or
278
- * `{ phonemes: string }`, an empty `say` reading, and a phoneme that is not in Kokoro's token
279
- * table. `aula check` gives them once for the project. A chapter leaves out an entry with a
280
- * problem. */
281
- export function checkLexicon(project, options = {}) {
282
- const host = options.host ?? NODE;
283
- const frame = definedAt(project, host);
284
- const location = { file: host.name(frame.file) ?? frame.file, line: frame.line, col: frame.col };
285
- const shapes = badReadings(project.lexicon).map((word) => error(`lexicon: the reading of ${JSON.stringify(word)} is not { say: string } or { phonemes: string }`, {
286
- location,
287
- hint: 'give the reading as { say: "words" } or { phonemes: "fˈQnimz" }, as for pronounce',
288
- }));
289
- return [...shapes, ...engine.checkLexicon(location, lexiconEntries(project.lexicon))];
290
- }
291
- /** The problems of the `pronounce` words of the project title (``defineProject({ title: say`…` })``),
292
- * at the line of its `say`: the problems that a `say` row with the same text gives (the written
293
- * part is not one word, a phoneme is not in Kokoro's token table, the reading has no
294
- * phonemes). `aula check` gives them once for the project. A plain string has none. */
295
- export function checkTitle(project, options = {}) {
296
- const host = options.host ?? NODE;
297
- const at = definedAt(project, host);
298
- const frame = host.frames(project.titleCall).find((f) => f.file === at.file) ?? at;
299
- const location = { file: host.name(frame.file) ?? frame.file, line: frame.line, col: frame.col };
300
- return engine.checkTitle(location, [...project.titleParts]);
301
- }
302
- /** Draws chapter `index` (0 is the title card) of `project` on its narration: its Lottie, its
303
- * length in frames, the waits of the narration and the warnings at the moves that the
304
- * narration waits for. */
305
- export function renderChapter(project, index, options) {
306
- const host = options.host ?? NODE;
307
- const drawing = {
308
- narration: options.narration,
309
- name: chapterNames(project)[index] ?? "",
310
- lint: options.lint ?? false,
311
- prune: options.prune ?? true,
312
- count: project.chapters.length + 1,
313
- };
314
- const card = project.card ?? defaultCard;
315
- const theme = project.theme ?? defaultTheme;
316
- if (index === 0)
317
- return attempt("", host, () => drawTitle(project.title, theme, card, drawing));
318
- const chapter = chapterOf(project, index);
319
- if (!("call" in chapter))
320
- return { ok: false, diagnostics: [chapter] };
321
- const slot = slotOf(project, chapter, index, host);
322
- return attempt(slot.source, host, () => drawRows(chapter, theme, card, slot, drawing));
323
- }
package/dist/tables.d.ts DELETED
@@ -1,179 +0,0 @@
1
- import { type Animation, type Color, type DecimalNumberOptions, type Point, type StyleOptions, type TexOptions, type TextOptions, Mobject } from "./engine.ts";
2
- import type { Mobject as RawMobject } from "./generated/interfaces/aula-engine-engine.js";
3
- /** An entry of a table or a matrix: a string, a number or a mobject. */
4
- export type Entry = string | number | Mobject;
5
- /** The options that `elementToMobjectConfig` gives each entry. */
6
- export type ElementConfig = TextOptions & TexOptions & DecimalNumberOptions;
7
- /** Manim's `element_to_mobject`: makes the mobject of an entry, with `elementToMobjectConfig`. */
8
- export type ElementToMobject = {
9
- bivariance(item: Entry, config: ElementConfig): Mobject;
10
- }["bivariance"];
11
- /** The options of the grid of a Table (Manim's `arrange_in_grid` keyword arguments). */
12
- export interface GridConfig {
13
- /** The edge or corner of each cell that its entry goes to (default the center). */
14
- cellAlignment?: Point;
15
- /** One letter for each row: `"u"` (up), `"c"` (center) or `"d"` (down). */
16
- rowAlignments?: string;
17
- /** One letter for each column: `"l"` (left), `"c"` (center) or `"r"` (right). */
18
- colAlignments?: string;
19
- /** The height of each row; undefined gives the tallest entry. */
20
- rowHeights?: readonly (number | undefined)[];
21
- /** The width of each column; undefined gives the widest entry. */
22
- colWidths?: readonly (number | undefined)[];
23
- }
24
- /** The options of Table (Manim's keyword arguments). */
25
- export interface TableOptions {
26
- rowLabels?: readonly Mobject[];
27
- colLabels?: readonly Mobject[];
28
- topLeftEntry?: Mobject;
29
- vBuff?: number;
30
- hBuff?: number;
31
- includeOuterLines?: boolean;
32
- includeInnerLines?: boolean;
33
- addBackgroundRectanglesToEntries?: boolean;
34
- entriesBackgroundColor?: Color;
35
- includeBackgroundRectangle?: boolean;
36
- backgroundRectangleColor?: Color;
37
- elementToMobject?: ElementToMobject;
38
- elementToMobjectConfig?: ElementConfig;
39
- arrangeInGridConfig?: GridConfig;
40
- lineConfig?: StyleOptions;
41
- }
42
- /** What Table keeps besides its node. */
43
- interface TableParts {
44
- mobTable: Mobject[][];
45
- elements: Mobject;
46
- elementsWithoutLabels: Mobject;
47
- rowLabels: readonly Mobject[] | undefined;
48
- colLabels: readonly Mobject[] | undefined;
49
- topLeftEntry: Mobject | undefined;
50
- colDim: number;
51
- horizontalLines: Mobject;
52
- verticalLines: Mobject;
53
- backgrounds: Map<Mobject, Mobject>;
54
- }
55
- /** A table: Manim's `Table`. Rows and columns count from 1, labels included. */
56
- export declare class TableMobject extends Mobject {
57
- #private;
58
- hBuff: number;
59
- vBuff: number;
60
- constructor(handle: RawMobject, parts: TableParts, hBuff: number, vBuff: number);
61
- /** The entries, labels included (Manim `elements`). */
62
- get elements(): Mobject;
63
- /** The grid of entries, labels included (Manim `mob_table`). */
64
- get mobTable(): Mobject[][];
65
- getHorizontalLines(): Mobject;
66
- getVerticalLines(): Mobject;
67
- /** One VGroup for each column. */
68
- getColumns(): Mobject;
69
- /** One VGroup for each row. */
70
- getRows(): Mobject;
71
- setColumnColors(...colors: Color[]): this;
72
- setRowColors(...colors: Color[]): this;
73
- /** All the entries with the labels, or the entry at `pos` (`[row, column]`, from 1). */
74
- getEntries(pos?: readonly [number, number]): Mobject;
75
- /** The entries without the labels, or the one at `pos` (`[row, column]`, from 1). */
76
- getEntriesWithoutLabels(pos?: readonly [number, number]): Mobject;
77
- getRowLabels(): Mobject;
78
- getColLabels(): Mobject;
79
- /** The top-left entry, the column labels and the row labels. */
80
- getLabels(): Mobject;
81
- /** A BackgroundRectangle behind each entry. */
82
- addBackgroundToEntries(color?: Color): this;
83
- /** The rectangle of the cell at `pos` (`[row, column]`, from 1), with half the buffs around the
84
- * entries, as a Polygon with the style options. */
85
- getCell(pos?: readonly [number, number], opts?: StyleOptions): Mobject;
86
- /** A BackgroundRectangle on the cell at `pos`, in `color` (Manim's `PURE_YELLOW`). */
87
- getHighlightedCell(pos?: readonly [number, number], color?: Color, opts?: {
88
- fillOpacity?: number;
89
- buff?: number;
90
- }): Mobject;
91
- /** Puts `getHighlightedCell(pos, color)` behind the table. */
92
- addHighlightedCell(pos?: readonly [number, number], color?: Color, opts?: {
93
- fillOpacity?: number;
94
- buff?: number;
95
- }): this;
96
- /** Draws the lines, then the entries, the labels and the highlighted cells, one after the
97
- * other by `lagRatio` (Manim `Table.create`). */
98
- create(opts?: {
99
- lagRatio?: number;
100
- lineAnimation?: (m: Mobject) => Animation;
101
- labelAnimation?: (m: Mobject) => Animation;
102
- elementAnimation?: (m: Mobject) => Animation;
103
- entryAnimation?: (m: Mobject) => Animation;
104
- }): Animation;
105
- /** Scales the table and its buffs. With `scaleStroke`, the stroke widths scale too. */
106
- scale(scaleFactor: number, opts?: {
107
- aboutPoint?: Point;
108
- aboutEdge?: Point;
109
- scaleStroke?: boolean;
110
- }): this;
111
- copy(): TableMobject;
112
- }
113
- /** Manim's `Table(table, opts)`: each entry becomes `elementToMobject(entry, elementToMobjectConfig)`
114
- * (a `Paragraph` by default), in a grid with lines between the rows and the columns. */
115
- export declare function Table(table: readonly (readonly Entry[])[], opts?: TableOptions): TableMobject;
116
- /** A Table of `MathTex` entries (Manim `MathTable`). */
117
- export declare function MathTable(table: readonly (readonly Entry[])[], opts?: TableOptions): TableMobject;
118
- /** A Table of mobjects as they are (Manim `MobjectTable`). */
119
- export declare function MobjectTable(table: readonly (readonly Mobject[])[], opts?: TableOptions): TableMobject;
120
- /** A Table of `Integer` entries (Manim `IntegerTable`). */
121
- export declare function IntegerTable(table: readonly (readonly Entry[])[], opts?: TableOptions): TableMobject;
122
- /** A Table of `DecimalNumber` entries with one decimal place (Manim `DecimalTable`). */
123
- export declare function DecimalTable(table: readonly (readonly Entry[])[], opts?: TableOptions): TableMobject;
124
- /** The options of Matrix (Manim's keyword arguments). */
125
- export interface MatrixOptions {
126
- vBuff?: number;
127
- hBuff?: number;
128
- bracketHBuff?: number;
129
- bracketVBuff?: number;
130
- addBackgroundRectanglesToEntries?: boolean;
131
- includeBackgroundRectangle?: boolean;
132
- elementToMobject?: ElementToMobject;
133
- elementToMobjectConfig?: ElementConfig;
134
- elementAlignmentCorner?: Point;
135
- leftBracket?: string;
136
- rightBracket?: string;
137
- stretchBrackets?: boolean;
138
- bracketConfig?: {
139
- fontSize?: number;
140
- color?: Color;
141
- };
142
- }
143
- /** A matrix: Manim's `Matrix`. Its submobjects are the entries (one VGroup) and the brackets. */
144
- export declare class MatrixMobject extends Mobject {
145
- #private;
146
- constructor(handle: RawMobject, mobMatrix: Mobject[][], elements: Mobject, brackets: Mobject);
147
- getColumns(): Mobject;
148
- getRows(): Mobject;
149
- setColumnColors(...colors: Color[]): this;
150
- setRowColors(...colors: Color[]): this;
151
- /** A BackgroundRectangle behind each entry. */
152
- addBackgroundToEntries(): this;
153
- /** The entries as rows of mobjects (Manim `mob_matrix`). */
154
- getMobMatrix(): Mobject[][];
155
- getEntries(): Mobject;
156
- /** The left and the right bracket. */
157
- getBrackets(): Mobject;
158
- copy(): MatrixMobject;
159
- }
160
- /** Manim's `Matrix(matrix, opts)`: each entry is `elementToMobject(entry, elementToMobjectConfig)`
161
- * (a `MathTex` by default), between brackets that `\\left` and `\\right` draw. */
162
- export declare function Matrix(matrix: readonly (readonly Entry[])[], opts?: MatrixOptions): MatrixMobject;
163
- /** A Matrix of `DecimalNumber` entries with one decimal place (Manim `DecimalMatrix`). */
164
- export declare function DecimalMatrix(matrix: readonly (readonly Entry[])[], opts?: MatrixOptions): MatrixMobject;
165
- /** A Matrix of `Integer` entries (Manim `IntegerMatrix`). */
166
- export declare function IntegerMatrix(matrix: readonly (readonly Entry[])[], opts?: MatrixOptions): MatrixMobject;
167
- /** A Matrix of mobjects as they are (Manim `MobjectMatrix`). */
168
- export declare function MobjectMatrix(matrix: readonly (readonly Mobject[])[], opts?: MatrixOptions): MatrixMobject;
169
- /** The LaTeX of a matrix (a list is one column) in brackets (Manim `matrix_to_tex_string`). */
170
- export declare function matrixToTexString(matrix: readonly (readonly Entry[])[] | readonly Entry[]): string;
171
- /** `MathTex(matrixToTexString(matrix))` (Manim `matrix_to_mobject`). */
172
- export declare function matrixToMobject(matrix: readonly (readonly Entry[])[] | readonly Entry[]): Mobject;
173
- /** `det(…)` around a Matrix, and `= determinant` with a determinant (Manim `get_det_text`). */
174
- export declare function getDetText(matrix: Mobject, opts?: {
175
- determinant?: number | string;
176
- backgroundRect?: boolean;
177
- initialScaleFactor?: number;
178
- }): Mobject;
179
- export {};