@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/host.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import type { Point } from "./generated/interfaces/aula-engine-types.js";
2
- /** Keeps `f` for the engine; the engine drops it with its owner. */
3
- export declare function register(f: (...args: never[]) => unknown): number;
4
- /** True when a callback threw since the last `takePending`. */
5
- export declare function hasPending(): boolean;
6
- /** The first error a callback threw since the last call, taken. */
7
- export declare function takePending(): unknown;
8
- export declare function callUpdater(id: number, dt: number): boolean;
9
- export declare function callAlpha(id: number, alpha: number): boolean;
10
- export declare function callRedraw(id: number): boolean;
11
- export declare function callPoint(id: number, p: Point): Point | undefined;
12
- /** A rate function's value. When it returns no finite number, the error is kept as if it threw. */
13
- export declare function callRate(id: number, t: number): number | undefined;
14
- /** The points of a path function. When it returns no list of points, the error is kept as if
15
- * it threw. */
16
- export declare function callPath(id: number, starts: Point[], ends: Point[], t: number): Point[] | undefined;
17
- export declare function dropCallback(id: number): void;
18
- /** A Rust panic: an engine bug. The instance traps right after this. */
19
- export declare function reportPanic(message: string): void;
package/dist/host.js DELETED
@@ -1,85 +0,0 @@
1
- // The host side of the engine component (WIT interface `aula:engine/host`): JS callbacks
2
- // by id. A callback that throws never unwinds through the component: the error is kept here,
3
- // the host call returns a failure, the export returns an error, and `diagnosticOf` (run.ts)
4
- // reports the original error, with its own stack, instead of the export's error.
5
- import { aulaError } from "./errors.js";
6
- import { runUserCode } from "./user-code.js";
7
- const table = new Map();
8
- let next = 1;
9
- let pending = [];
10
- /** Keeps `f` for the engine; the engine drops it with its owner. */
11
- export function register(f) {
12
- const id = next++;
13
- table.set(id, f);
14
- return id;
15
- }
16
- /** True when a callback threw since the last `takePending`. */
17
- export function hasPending() {
18
- return pending.length > 0;
19
- }
20
- /** The first error a callback threw since the last call, taken. */
21
- export function takePending() {
22
- const first = pending[0];
23
- pending = [];
24
- return first;
25
- }
26
- /** Runs callback `id`: its value, or null when it threw (the error is kept). */
27
- function run(id, args) {
28
- const f = table.get(id);
29
- if (f === undefined)
30
- return { value: undefined };
31
- const r = runUserCode(() => Reflect.apply(f, undefined, args));
32
- if (r._tag === "Left") {
33
- pending.push(r.left);
34
- return null;
35
- }
36
- return { value: r.right };
37
- }
38
- export function callUpdater(id, dt) {
39
- return run(id, [dt]) !== null;
40
- }
41
- export function callAlpha(id, alpha) {
42
- return run(id, [alpha]) !== null;
43
- }
44
- export function callRedraw(id) {
45
- return run(id, []) !== null;
46
- }
47
- export function callPoint(id, p) {
48
- const r = run(id, [p]);
49
- if (r === null)
50
- return undefined;
51
- const v = r.value;
52
- return Array.isArray(v) && typeof v[0] === "number" && typeof v[1] === "number" ? [v[0], v[1]] : undefined;
53
- }
54
- /** A rate function's value. When it returns no finite number, the error is kept as if it threw. */
55
- export function callRate(id, t) {
56
- const r = run(id, [t]);
57
- if (r === null)
58
- return undefined;
59
- if (typeof r.value === "number" && Number.isFinite(r.value))
60
- return r.value;
61
- pending.push(aulaError(`rateFunc: returned ${String(r.value)} for t = ${String(t)}`, "a rate function returns a finite number, like m.smooth or (t) => t * t"));
62
- return undefined;
63
- }
64
- /** The points of a path function. When it returns no list of points, the error is kept as if
65
- * it threw. */
66
- export function callPath(id, starts, ends, t) {
67
- const r = run(id, [starts, ends, t]);
68
- if (r === null)
69
- return undefined;
70
- const v = r.value;
71
- const ok = Array.isArray(v) &&
72
- v.length === starts.length &&
73
- v.every((p) => Array.isArray(p) && typeof p[0] === "number" && typeof p[1] === "number");
74
- if (ok)
75
- return v.map((p) => [p[0], p[1]]);
76
- pending.push(aulaError(`pathFunc: returned ${String(v)} for t = ${String(t)}`, "a path function returns one point [x, y] for each start point"));
77
- return undefined;
78
- }
79
- export function dropCallback(id) {
80
- table.delete(id);
81
- }
82
- /** A Rust panic: an engine bug. The instance traps right after this. */
83
- export function reportPanic(message) {
84
- console.error(`error: ${message}\n = hint: an engine bug, not a chapter error: report it with the chapter line`);
85
- }
package/dist/lexicon.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { Reading } from "./engine.ts";
2
- import type { LexiconEntry } from "./generated/interfaces/aula-engine-engine.js";
3
- /** The project lexicon: each key is a written word, and each value is its reading, the same
4
- * object that `pronounce` takes. A kit exports one, and a project spreads it into its own. */
5
- export type Lexicon = Readonly<Record<string, Reading>>;
6
- /** The entries of `lexicon` in the engine's form, in the order of the object. An entry whose
7
- * reading has the wrong form is left out: `badReadings` gives its key. */
8
- export declare function lexiconEntries(lexicon: Lexicon): LexiconEntry[];
9
- /** The keys of `lexicon` whose reading is not `{ say: string }` or `{ phonemes: string }`. */
10
- export declare function badReadings(lexicon: Lexicon): string[];
package/dist/lexicon.js DELETED
@@ -1,23 +0,0 @@
1
- /** A reading in the engine's form, or undefined when it is not `{ say: string }` or
2
- * `{ phonemes: string }` (a value from JavaScript with no types). */
3
- function rawReading(reading) {
4
- if (typeof reading !== "object" || reading === null || Object.keys(reading).length !== 1)
5
- return undefined;
6
- if ("say" in reading && typeof reading.say === "string")
7
- return { tag: "words", val: reading.say };
8
- if ("phonemes" in reading && typeof reading.phonemes === "string")
9
- return { tag: "phonemes", val: reading.phonemes };
10
- return undefined;
11
- }
12
- /** The entries of `lexicon` in the engine's form, in the order of the object. An entry whose
13
- * reading has the wrong form is left out: `badReadings` gives its key. */
14
- export function lexiconEntries(lexicon) {
15
- return Object.entries(lexicon).flatMap(([word, reading]) => {
16
- const raw = rawReading(reading);
17
- return raw === undefined ? [] : [{ word, reading: raw }];
18
- });
19
- }
20
- /** The keys of `lexicon` whose reading is not `{ say: string }` or `{ phonemes: string }`. */
21
- export function badReadings(lexicon) {
22
- return Object.entries(lexicon).flatMap(([word, reading]) => (rawReading(reading) === undefined ? [word] : []));
23
- }
package/dist/load.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import type * as EngineExports from "./generated/interfaces/aula-engine-engine.js";
2
- import type * as TtsExports from "./generated/interfaces/aula-engine-tts.js";
3
- type Engine = typeof EngineExports;
4
- type Tts = typeof TtsExports;
5
- /** The engine's functions: `unloaded` until `loadEngine()` is done. A live binding: the modules
6
- * that import it see the loaded engine. */
7
- export declare let engine: Engine;
8
- /** The narrator's inference engine (crates/aula-tts): `unloaded` until `loadEngine()` is done. */
9
- export declare let tts: Tts;
10
- /** Loads the engine: on the first call only; every call gives the same promise. */
11
- export declare function loadEngine(): Promise<void>;
12
- /** Downloads the G2P's data and gives it to the engine, on the first call only: every call
13
- * gives the same promise. Call it after `loadEngine()` where words are read (the narrator,
14
- * the checks): the data is not compiled into the engine any more (#600), so the engine's G2P
15
- * functions fail without it. */
16
- export declare function initG2p(): Promise<void>;
17
- /** True when `value` is the error of a WIT `result` of the engine (jco's ComponentError). */
18
- export declare function isComponentError(value: unknown): value is Error & {
19
- readonly payload: unknown;
20
- };
21
- export {};
package/dist/load.js DELETED
@@ -1,109 +0,0 @@
1
- // The engine component, loaded on its first use. An import of @beff/aula does no async work: a
2
- // module that imports it (a worker, a test, a project) is ready at once. `loadEngine()` compiles
3
- // the core wasm files of the component and instantiates it with the host (host.ts) one time;
4
- // each caller gets the same promise. The engine's functions are synchronous, so the operation
5
- // that runs project code awaits `loadEngine()` first (`loadProject`, `loadProjects`), and so does
6
- // an entry file that calls the engine directly.
7
- import { instantiate } from "./generated/aula.js";
8
- import * as host from "./host.js";
9
- import { fault } from "./errors.js";
10
- /** The core wasm files of the component, by the name that jco gives them: the engine with
11
- * eSpeak NG plugged in (scripts/engine-build.ts). Each URL is written out, so that a bundler
12
- * finds the file. */
13
- const CORE = {
14
- "aula.core.wasm": new URL("./generated/aula.core.wasm", import.meta.url),
15
- "aula.core2.wasm": new URL("./generated/aula.core2.wasm", import.meta.url),
16
- "aula.core3.wasm": new URL("./generated/aula.core3.wasm", import.meta.url),
17
- "aula.core4.wasm": new URL("./generated/aula.core4.wasm", import.meta.url),
18
- "aula.core5.wasm": new URL("./generated/aula.core5.wasm", import.meta.url),
19
- "aula.core6.wasm": new URL("./generated/aula.core6.wasm", import.meta.url),
20
- "aula.core7.wasm": new URL("./generated/aula.core7.wasm", import.meta.url),
21
- "aula.core8.wasm": new URL("./generated/aula.core8.wasm", import.meta.url),
22
- "aula.conditional-suspending-3-i32-to-void.wasm": new URL("./generated/aula.conditional-suspending-3-i32-to-void.wasm", import.meta.url),
23
- };
24
- /** The G2P's data files (#600): the prebuilt tables of crates/aula-g2p, copied into
25
- * `generated/` by `scripts/engine-build.ts`. Each URL is written out, so that a bundler
26
- * finds the file, as with the core wasm files. */
27
- const G2PDATA = {
28
- "gb_gold.bin": new URL("./generated/gb_gold.bin", import.meta.url),
29
- "gb_silver.bin": new URL("./generated/gb_silver.bin", import.meta.url),
30
- "spacy_en.bin": new URL("./generated/spacy_en.bin", import.meta.url),
31
- "tagger.bin": new URL("./generated/tagger.bin", import.meta.url),
32
- "symbols.bin": new URL("./generated/symbols.bin", import.meta.url),
33
- };
34
- /** The engine before `loadEngine()`: each use fails with the fix. */
35
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- each property of the proxy throws
36
- const unloaded = new Proxy({}, {
37
- get: (_, name) => fault(`the aula engine is not loaded (engine.${String(name)})`, 'await loadEngine() of "@beff/aula/run" before the first call to the engine'),
38
- });
39
- /** The engine's functions: `unloaded` until `loadEngine()` is done. A live binding: the modules
40
- * that import it see the loaded engine. */
41
- export let engine = unloaded;
42
- /** The narrator's inference engine (crates/aula-tts): `unloaded` until `loadEngine()` is done. */
43
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the same proxy: each use throws
44
- export let tts = unloaded;
45
- let root;
46
- let loading;
47
- let data;
48
- /** The compiled core module at `url`: a file in Node, else a download. */
49
- async function compile(url) {
50
- if (url.protocol === "file:") {
51
- const { readFile } = await import("node:fs/promises");
52
- return WebAssembly.compile(await readFile(url));
53
- }
54
- const response = await fetch(url);
55
- if (!response.ok)
56
- throw new Error(`${url.href}: HTTP ${String(response.status)}`);
57
- return response.headers.get("Content-Type") === "application/wasm"
58
- ? WebAssembly.compileStreaming(response)
59
- : WebAssembly.compile(await response.arrayBuffer());
60
- }
61
- /** Loads the engine: on the first call only; every call gives the same promise. */
62
- export function loadEngine() {
63
- loading ??= (async () => {
64
- // jco's `instantiate` gives the root, or a promise of it when the core modules come from
65
- // a promise, as here.
66
- const loaded = await Promise.resolve(instantiate((path) => compile(CORE[path] ?? fault(`the engine component has no core file ${path}`)), {
67
- "aula:engine/host": host,
68
- "aula:engine/types": {},
69
- }));
70
- root = loaded;
71
- engine = loaded.engine;
72
- tts = loaded.tts;
73
- })();
74
- return loading;
75
- }
76
- /** The bytes at `url`: a file in Node, else a download. */
77
- async function bytes(url) {
78
- if (url.protocol === "file:") {
79
- const { readFile } = await import("node:fs/promises");
80
- return readFile(url);
81
- }
82
- const response = await fetch(url);
83
- if (!response.ok)
84
- throw new Error(`${url.href}: HTTP ${String(response.status)}`);
85
- return new Uint8Array(await response.arrayBuffer());
86
- }
87
- /** Downloads the G2P's data and gives it to the engine, on the first call only: every call
88
- * gives the same promise. Call it after `loadEngine()` where words are read (the narrator,
89
- * the checks): the data is not compiled into the engine any more (#600), so the engine's G2P
90
- * functions fail without it. */
91
- export function initG2p() {
92
- data ??= (async () => {
93
- const [gold, silver, spacy, tagger, symbols] = await Promise.all([
94
- bytes(G2PDATA["gb_gold.bin"] ?? fault("the G2P data has no file gb_gold.bin")),
95
- bytes(G2PDATA["gb_silver.bin"] ?? fault("the G2P data has no file gb_silver.bin")),
96
- bytes(G2PDATA["spacy_en.bin"] ?? fault("the G2P data has no file spacy_en.bin")),
97
- bytes(G2PDATA["tagger.bin"] ?? fault("the G2P data has no file tagger.bin")),
98
- bytes(G2PDATA["symbols.bin"] ?? fault("the G2P data has no file symbols.bin")),
99
- ]);
100
- await loadEngine();
101
- engine.loadG2pData(gold, silver, spacy, tagger, symbols);
102
- })();
103
- return data;
104
- }
105
- /** True when `value` is the error of a WIT `result` of the engine (jco's ComponentError). */
106
- export function isComponentError(value) {
107
- // oxlint-disable-next-line no-underscore-dangle -- the name that jco gives it
108
- return root !== undefined && root._util.isComponentError(value);
109
- }
package/dist/logo.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import { type Animation, type Point, Mobject } from "./engine.ts";
2
- /** Manim's banner: `ManimBanner({ darkTheme })`. Its submobjects are `shapes` and `M`;
3
- * `expand` adds `anim`, the letters "anim". */
4
- export declare class ManimBannerMobject extends Mobject {
5
- fontColor: string;
6
- scaleFactor: number;
7
- /** The letter M. */
8
- M: Mobject;
9
- circle: Mobject;
10
- square: Mobject;
11
- triangle: Mobject;
12
- /** The triangle, the square and the circle. */
13
- shapes: Mobject;
14
- /** The letters "anim", which `expand` shows. */
15
- anim: Mobject;
16
- copy(): ManimBannerMobject;
17
- /** Scales the banner, also the letters that are not shown yet (Manim `scale`). */
18
- scale(scaleFactor: number, opts?: {
19
- scaleStroke?: boolean;
20
- aboutPoint?: Point;
21
- aboutEdge?: Point;
22
- }): this;
23
- /** The shapes spiral in and the M fades in (Manim `create`). */
24
- create(runTime?: number): Animation;
25
- /** The shapes slide away and uncover the letters "anim" (Manim `expand`). `direction` is
26
- * `"left"`, `"right"` or `"center"`. After it, `anim` is a submobject of the banner. */
27
- expand(runTime?: number, direction?: "left" | "right" | "center"): Animation;
28
- }
29
- /** Manim's banner (Manim `ManimBanner`): `ManimBanner({ darkTheme })`, light letters by default. */
30
- export declare function ManimBanner(darkTheme?: boolean): ManimBannerMobject;
package/dist/logo.js DELETED
@@ -1,186 +0,0 @@
1
- // Manim CE's banner: ManimBanner, the logo of Manim (a circle, a square, a triangle and the
2
- // letter M), with its animations `create` and `expand`. The letters are Manim's own SVG paths.
3
- import { DOWN, LEFT, ORIGIN, RIGHT, TAU, UP, Mobject, Polyline, VGroup, add, easeInOutCubic, mul, raw, smooth, sub, wrong, } from "./engine.js";
4
- import { AnimationGroup, FadeIn, Succession, UpdateFromAlphaFunc } from "./animations.js";
5
- import { svgPathPoints } from "./curves.js";
6
- import { engine } from "./load.js";
7
- import { Circle, Square, Triangle } from "./geometry.js";
8
- /** Manim's `MANIM_SVG_PATHS`: the letters M, a, n, i and m. */
9
- const PATHS = [
10
- "M4.64259-2.092154L2.739726-6.625156C2.660025-6.824408 2.650062-6.824408 2.381071-6.824408H.52802C.348692-6.824408 .199253-6.824408 .199253-6.645081C.199253-6.475716 .37858-6.475716 .428394-6.475716C.547945-6.475716 .816936-6.455791 1.036115-6.37609V-1.05604C1.036115-.846824 1.036115-.408468 .358655-.348692C.169365-.328767 .169365-.18929 .169365-.179328C.169365 0 .328767 0 .508095 0H2.052304C2.231631 0 2.381071 0 2.381071-.179328C2.381071-.268991 2.30137-.33873 2.221669-.348692C1.454545-.408468 1.454545-.826899 1.454545-1.05604V-6.017435L1.464508-6.027397L3.895392-.209215C3.975093-.029888 4.044832 0 4.104608 0C4.224159 0 4.254047-.079701 4.303861-.199253L6.744707-6.027397L6.75467-6.017435V-1.05604C6.75467-.846824 6.75467-.408468 6.07721-.348692C5.88792-.328767 5.88792-.18929 5.88792-.179328C5.88792 0 6.047323 0 6.22665 0H8.886675C9.066002 0 9.215442 0 9.215442-.179328C9.215442-.268991 9.135741-.33873 9.05604-.348692C8.288917-.408468 8.288917-.826899 8.288917-1.05604V-5.768369C8.288917-5.977584 8.288917-6.41594 8.966376-6.475716C9.066002-6.485679 9.155666-6.535492 9.155666-6.645081C9.155666-6.824408 9.006227-6.824408 8.826899-6.824408H6.90411C6.645081-6.824408 6.625156-6.824408 6.535492-6.615193L4.64259-2.092154ZM4.343711-1.912827C4.423412-1.743462 4.433375-1.733499 4.552927-1.693649L4.11457-.637609H4.094645L1.823163-6.057285C1.77335-6.1868 1.693649-6.356164 1.554172-6.475716H2.420922L4.343711-1.912827ZM1.334994-.348692H1.165629C1.185554-.37858 1.205479-.408468 1.225405-.428394C1.235367-.438356 1.235367-.448319 1.24533-.458281L1.334994-.348692ZM7.103362-6.475716H8.159402C7.940224-6.22665 7.940224-5.967621 7.940224-5.788294V-1.036115C7.940224-.856787 7.940224-.597758 8.169365-.348692H6.884184C7.103362-.597758 7.103362-.856787 7.103362-1.036115V-6.475716Z",
11
- "M1.464508-4.024907C1.464508-4.234122 1.743462-4.393524 2.092154-4.393524C2.669988-4.393524 2.929016-4.124533 2.929016-3.516812V-2.789539C1.77335-2.440847 .249066-2.042341 .249066-.916563C.249066-.308842 .71731 .139477 1.354919 .139477C1.92279 .139477 2.381071-.059776 2.929016-.557908C3.038605-.049813 3.257783 .139477 3.745953 .139477C4.174346 .139477 4.483188-.019925 4.861768-.428394L4.712329-.637609L4.612702-.537983C4.582814-.508095 4.552927-.498132 4.503113-.498132C4.363636-.498132 4.293898-.587796 4.293898-.747198V-3.347447C4.293898-4.184309 3.536737-4.712329 2.321295-4.712329C1.195517-4.712329 .438356-4.204234 .438356-3.457036C.438356-3.048568 .67746-2.799502 1.085928-2.799502C1.484433-2.799502 1.763387-3.038605 1.763387-3.377335C1.763387-3.676214 1.464508-3.88543 1.464508-4.024907ZM2.919054-.996264C2.650062-.687422 2.450809-.56787 2.211706-.56787C1.912827-.56787 1.703611-.836862 1.703611-1.235367C1.703611-1.8132 2.122042-2.231631 2.919054-2.440847V-.996264Z",
12
- "M2.948941-4.044832C3.297634-4.044832 3.466999-3.775841 3.466999-3.217933V-.806974C3.466999-.438356 3.337484-.278954 2.998755-.239103V0H5.339975V-.239103C4.951432-.268991 4.851806-.388543 4.851806-.806974V-3.307597C4.851806-4.164384 4.323786-4.712329 3.506849-4.712329C2.909091-4.712329 2.450809-4.433375 2.082192-3.845579V-4.592777H.179328V-4.353674C.617684-4.283935 .707347-4.184309 .707347-3.765878V-.836862C.707347-.418431 .627646-.328767 .179328-.239103V0H2.580324V-.239103C2.211706-.288917 2.092154-.438356 2.092154-.806974V-3.466999C2.092154-3.576588 2.530511-4.044832 2.948941-4.044832Z",
13
- "M2.15193-4.592777H.239103V-4.353674C.67746-4.26401 .767123-4.174346 .767123-3.765878V-.836862C.767123-.428394 .697385-.348692 .239103-.239103V0H2.6401V-.239103C2.291407-.288917 2.15193-.428394 2.15193-.806974V-4.592777ZM1.454545-6.884184C1.026152-6.884184 .67746-6.535492 .67746-6.117061C.67746-5.668742 1.006227-5.339975 1.444583-5.339975S2.221669-5.668742 2.221669-6.107098C2.221669-6.535492 1.882939-6.884184 1.454545-6.884184Z",
14
- "M2.929016-4.044832C3.317559-4.044832 3.466999-3.815691 3.466999-3.217933V-.806974C3.466999-.398506 3.35741-.268991 2.988792-.239103V0H5.32005V-.239103C4.971357-.278954 4.851806-.428394 4.851806-.806974V-3.466999C4.851806-3.576588 5.310087-4.044832 5.69863-4.044832C6.07721-4.044832 6.22665-3.805729 6.22665-3.217933V-.806974C6.22665-.388543 6.117061-.268991 5.738481-.239103V0H8.109589V-.239103C7.721046-.259029 7.611457-.37858 7.611457-.806974V-3.307597C7.611457-4.164384 7.083437-4.712329 6.266501-4.712329C5.69863-4.712329 5.32005-4.483188 4.801993-3.845579C4.503113-4.473225 4.154421-4.712329 3.526775-4.712329S2.440847-4.443337 2.062267-3.845579V-4.592777H.179328V-4.353674C.617684-4.293898 .707347-4.174346 .707347-3.765878V-.836862C.707347-.428394 .617684-.318804 .179328-.239103V0H2.550436V-.239103C2.201743-.288917 2.092154-.428394 2.092154-.806974V-3.466999C2.092154-3.58655 2.530511-4.044832 2.929016-4.044832Z",
15
- ];
16
- /** A filled letter from SVG path data, upright (Manim `VMobjectFromSVGPath(...).flip(RIGHT)`). */
17
- function letter(d) {
18
- const points = svgPathPoints(d).map(([x, y]) => [x, -y]);
19
- return Polyline(ORIGIN, ORIGIN).setPoints(points).setStroke({ width: 0 }).center();
20
- }
21
- /** Moves the children of `parent` so that `first` is the first one (Manim `add_to_back`). */
22
- function toBack(parent, first) {
23
- const rest = parent.submobjects.filter((s) => s !== first);
24
- parent.remove(...parent.submobjects);
25
- parent.add(first, ...rest);
26
- }
27
- /** Manim's banner: `ManimBanner({ darkTheme })`. Its submobjects are `shapes` and `M`;
28
- * `expand` adds `anim`, the letters "anim". */
29
- export class ManimBannerMobject extends Mobject {
30
- fontColor = "#ece6e2";
31
- scaleFactor = 1;
32
- /** The letter M. */
33
- M = VGroup();
34
- circle = VGroup();
35
- square = VGroup();
36
- triangle = VGroup();
37
- /** The triangle, the square and the circle. */
38
- shapes = VGroup();
39
- /** The letters "anim", which `expand` shows. */
40
- anim = VGroup();
41
- copy() {
42
- const c = new ManimBannerMobject(raw(this).copy());
43
- const [from, to] = [this.getFamily(), c.getFamily()];
44
- const same = (m) => to[from.indexOf(m)] ?? m.copy();
45
- c.fontColor = this.fontColor;
46
- c.scaleFactor = this.scaleFactor;
47
- c.M = same(this.M);
48
- c.circle = same(this.circle);
49
- c.square = same(this.square);
50
- c.triangle = same(this.triangle);
51
- c.shapes = same(this.shapes);
52
- c.anim = same(this.anim);
53
- return c;
54
- }
55
- /** Scales the banner, also the letters that are not shown yet (Manim `scale`). */
56
- scale(scaleFactor, opts = {}) {
57
- const { scaleStroke = false, ...about } = opts;
58
- this.scaleFactor *= scaleFactor;
59
- if (!this.submobjects.includes(this.anim))
60
- this.anim.scale(scaleFactor, about);
61
- super.scale(scaleFactor, about);
62
- if (scaleStroke) {
63
- for (const m of this.getFamily()) {
64
- if (m.hasPoints() && m.getStrokeWidth() > 0)
65
- m.setStroke({ width: m.getStrokeWidth() * scaleFactor });
66
- }
67
- }
68
- return this;
69
- }
70
- /** The shapes spiral in and the M fades in (Manim `create`). */
71
- create(runTime = 2) {
72
- return AnimationGroup(spiralIn(this.shapes, runTime), FadeIn(this.M, { runTime: runTime / 2 }), { lagRatio: 0.1 });
73
- }
74
- /** The shapes slide away and uncover the letters "anim" (Manim `expand`). `direction` is
75
- * `"left"`, `"right"` or `"center"`. After it, `anim` is a submobject of the banner. */
76
- expand(runTime = 1.5, direction = "center") {
77
- if (!["left", "right", "center"].includes(direction)) {
78
- wrong("expand", `direction must be "left", "right" or "center"; got ${JSON.stringify(direction)}`);
79
- }
80
- const offset = 6.25 * this.scaleFactor;
81
- const overshoot = this.scaleFactor * 0.8;
82
- this.anim.nextTo(this.M, RIGHT, { buff: 0.06 }).alignTo(this.M, DOWN);
83
- this.anim.setOpacity(0);
84
- this.shapes.saveState();
85
- const clone = (this.anim.submobjects.at(-1) ?? this.anim).copy();
86
- this.add(clone);
87
- clone.moveTo(this.shapes);
88
- const savedLeft = this.M.getLeft()[0];
89
- const left = [this.M, this.anim, clone];
90
- const shift = (vector) => {
91
- this.shapes.restore();
92
- const now = Math.min(...left.map((m) => m.getLeft()[0]));
93
- for (const m of left)
94
- m.shift([savedLeft - now, 0]);
95
- if (direction === "right")
96
- this.shapes.shift(vector);
97
- else if (direction === "center") {
98
- this.shapes.shift(mul(vector, 0.5));
99
- for (const m of left)
100
- m.shift(mul(vector, -0.5));
101
- }
102
- else
103
- for (const m of left)
104
- m.shift(mul(vector, -1));
105
- };
106
- const slide = UpdateFromAlphaFunc(this, (_mob, alpha) => {
107
- shift(mul(RIGHT, alpha * (offset + overshoot)));
108
- for (const l of this.anim.submobjects) {
109
- if (this.square.getCenter()[0] > l.getCenter()[0])
110
- l.setOpacity(1);
111
- }
112
- if (alpha === 1) {
113
- if (!this.submobjects.includes(this.anim))
114
- this.add(this.anim);
115
- toBack(this, this.anim);
116
- this.shapes.saveState();
117
- }
118
- }, { runTime: (runTime * 2) / 3, rateFunc: easeInOutCubic });
119
- const back = UpdateFromAlphaFunc(this, (_mob, alpha) => {
120
- if (alpha === 0) {
121
- clone.setOpacity(1);
122
- clone.moveTo(this.anim.submobjects.at(-1) ?? this.anim);
123
- this.anim.setOpacity(1);
124
- }
125
- shift(mul(LEFT, alpha * overshoot));
126
- if (alpha === 1) {
127
- this.remove(clone);
128
- toBack(this, this.shapes);
129
- }
130
- }, { runTime: runTime / 3, rateFunc: smooth });
131
- return Succession(slide, back);
132
- }
133
- }
134
- /** Manim's `SpiralIn`: each shape flies in on a spiral from 8 times its distance to the
135
- * centre, and fades in during the first 0.3 of the time. */
136
- function spiralIn(shapes, runTime) {
137
- const centre = shapes.getCenter();
138
- const originals = shapes.submobjects.map((s) => s.copy());
139
- const finals = shapes.submobjects.map((s) => s.getCenter());
140
- const starts = finals.map((f) => add(f, mul(sub(f, centre), 8)));
141
- return UpdateFromAlphaFunc(shapes, (mob, alpha) => {
142
- mob.submobjects.forEach((shape, i) => {
143
- const original = originals[i];
144
- const [start, final] = [starts[i] ?? ORIGIN, finals[i] ?? ORIGIN];
145
- if (original === undefined)
146
- return;
147
- shape.become(original).moveTo(start);
148
- shape.shift(mul(sub(final, start), alpha));
149
- shape.rotate(TAU * alpha, { aboutPoint: centre });
150
- shape.rotate(-TAU * alpha, { aboutPoint: shape.getCenter() });
151
- shape.setFill({ opacity: Math.min(original.getFillOpacity(), (alpha * original.getFillOpacity()) / 0.3) });
152
- shape.setStroke({
153
- opacity: Math.min(original.getStrokeOpacity(), (alpha * original.getStrokeOpacity()) / 0.3),
154
- });
155
- });
156
- }, { runTime });
157
- }
158
- function banner(darkTheme) {
159
- const b = new ManimBannerMobject(engine.vGroup([]));
160
- b.fontColor = darkTheme ? "#ece6e2" : "#343434";
161
- const [mPath = "", ...letters] = PATHS;
162
- b.M = letter(mPath).scale((7 * 48) / 960);
163
- b.M.setFill(b.fontColor, { opacity: 1 }).shift(add(mul(LEFT, 2.25), mul(UP, 1.5)));
164
- b.circle = Circle({ color: "#81b29a", fillOpacity: 1 }).shift(LEFT);
165
- b.square = Square({ color: "#454866", fillOpacity: 1 }).shift(UP);
166
- b.triangle = Triangle({ color: "#e07a5f", fillOpacity: 1 }).shift(RIGHT);
167
- b.shapes = VGroup(b.triangle, b.square, b.circle);
168
- b.add(b.shapes, b.M);
169
- b.moveTo(ORIGIN);
170
- const anim = VGroup();
171
- letters.forEach((d, i) => {
172
- const l = letter(d).scale(48 / 960);
173
- if (i > 0)
174
- l.nextTo(anim, RIGHT, { buff: 0.01 });
175
- l.alignTo(b.M, DOWN);
176
- anim.add(l);
177
- });
178
- anim.setFill(b.fontColor, { opacity: 1 });
179
- anim.height = 0.75748 * b.M.height;
180
- b.anim = anim;
181
- return b;
182
- }
183
- /** Manim's banner (Manim `ManimBanner`): `ManimBanner({ darkTheme })`, light letters by default. */
184
- export function ManimBanner(darkTheme = true) {
185
- return banner(darkTheme);
186
- }
package/dist/manim.d.ts DELETED
@@ -1,22 +0,0 @@
1
- export type { Card, Color, Heading, Location } from "./engine.ts";
2
- export { card, chapterCard, dockedHeading, NUMBER_GAP } from "./card.ts";
3
- export { theme, type Theme } from "./theme.ts";
4
- export type { AboutOptions, StyleSettings, VMobjectOptions, BackgroundRectangleOptions, GridOptions, ImageOptions, MobjectAttributes, MobjectOptions, RadialGradientOptions, UpdaterBuilder, AnimationBuilder, BoundMethod, PathFunc, AnimationOptions, Animations, DecimalNumberMobject, DecimalNumberOptions, IntegerMobject, CodeBackgroundConfig, CodeMobject, CodeOptions, CodeParagraphConfig, Mobjects, Points, RateFunc, StyleOptions, TexMatch, TexOptions, TextOptions, DashedVMobjectOptions, Weight, Slant, TrackerBuilder, } from "./engine.ts";
5
- export { BLACK, BOLD, DEGREES, DL, DOWN, DR, FRAME_HEIGHT, FRAME_WIDTH, LARGE_BUFF, LEFT, MED_LARGE_BUFF, MED_SMALL_BUFF, NORMAL, ORIGIN, PI, RIGHT, SMALL_BUFF, TAU, UL, UP, UR, WHITE, YELLOW, PURE_YELLOW, doubleSmooth, linear, rushFrom, rushInto, slowInto, smooth, thereAndBack, thereAndBackWithPause, easeInSine, easeOutSine, easeInOutSine, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeInBounce, easeOutBounce, easeInOutBounce, add, lerp, mul, norm, sub, Animation, Mobject, ValueTracker, MathTex, Code, CubicBezier, DecimalNumber, DashedVMobject, Integer, Polyline, Tex, Text, Image, VGroup, VMobject, alwaysRedraw, Scene, } from "./engine.ts";
6
- export type { AddTipOptions, AngleMobject, AngleOptions, AnnularSectorOptions, ArcBetweenPointsOptions, ArcMobject, ArcOptions, ArcPolygonMobject, ArcPolygonOptions, ArrowMobject, ArrowSettings, ArrowTipMobject, BackgroundRectangleMobject, CircleMobject, CurvedArrowOptions, DashedLineMobject, DashedLineOptions, FunctionGraphMobject, LabelOptions, LabeledLineOptions, LineMobject, LineOptions, ParametricFunctionMobject, ParametricFunctionOptions, PolygramMobject, RectangleOptions, RegularPolygramOptions, Scaling, SquareMobject, StarOptions, StealthTipMobject, TRange, TipOptions, TipShape, TipableOptions, TipableVMobjectMobject, VectorMobject, } from "./geometry.ts";
7
- export { Angle, AnnotationDot, AnnularSector, Annulus, Arc, ArcBetweenPoints, ArcPolygon, ArcPolygonFromArcs, Arrow, ArrowCircleFilledTip, ArrowCircleTip, ArrowSquareFilledTip, ArrowSquareTip, ArrowTip, ArrowTriangleFilledTip, ArrowTriangleTip, BackgroundRectangle, Circle, ConvexHull, Cross, CurvedArrow, CurvedDoubleArrow, Cutout, DashedLine, Difference, Dot, DoubleArrow, Elbow, Ellipse, Exclusion, FunctionGraph, ImplicitFunction, Intersection, Label, LabeledArrow, LabeledDot, LabeledLine, LabeledPolygram, Line, ParametricFunction, Polygon, Polygram, Rectangle, RegularPolygon, RegularPolygram, RightAngle, RoundedRectangle, Sector, Square, Star, StealthTip, SurroundingRectangle, TangentLine, TangentialArc, TipableVMobject, Triangle, Underline, Union, Vector, } from "./geometry.ts";
8
- export * from "./colors-palette.ts";
9
- export { HSV, ManimColor, RGBA, RandomColorGenerator, averageColor, colorGradient, colorToIntRgb, colorToIntRgba, colorToRgb, colorToRgba, hexToRgb, interpolateColor, invertColor, randomBrightColor, randomColor, rgbToColor, rgbToHex, rgbaToColor, } from "./colors.ts";
10
- export type { ParsableManimColor } from "./colors.ts";
11
- export * from "./rates.ts";
12
- export * from "./utils.ts";
13
- export * from "./braces.ts";
14
- export * from "./mobjects.ts";
15
- export * from "./tables.ts";
16
- export * from "./text-layouts.ts";
17
- export * from "./animations.ts";
18
- export * from "./graphing.ts";
19
- export * from "./graph.ts";
20
- export * from "./pointcloud.ts";
21
- export * from "./vector-field.ts";
22
- export * from "./logo.ts";
package/dist/manim.js DELETED
@@ -1,19 +0,0 @@
1
- // The chapter card, the docked heading and the theme: the defaults of every project.
2
- export { card, chapterCard, dockedHeading, NUMBER_GAP } from "./card.js";
3
- export { theme } from "./theme.js";
4
- export { BLACK, BOLD, DEGREES, DL, DOWN, DR, FRAME_HEIGHT, FRAME_WIDTH, LARGE_BUFF, LEFT, MED_LARGE_BUFF, MED_SMALL_BUFF, NORMAL, ORIGIN, PI, RIGHT, SMALL_BUFF, TAU, UL, UP, UR, WHITE, YELLOW, PURE_YELLOW, doubleSmooth, linear, rushFrom, rushInto, slowInto, smooth, thereAndBack, thereAndBackWithPause, easeInSine, easeOutSine, easeInOutSine, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeInBounce, easeOutBounce, easeInOutBounce, add, lerp, mul, norm, sub, Animation, Mobject, ValueTracker, MathTex, Code, CubicBezier, DecimalNumber, DashedVMobject, Integer, Polyline, Tex, Text, Image, VGroup, VMobject, alwaysRedraw, Scene, } from "./engine.js";
5
- export { Angle, AnnotationDot, AnnularSector, Annulus, Arc, ArcBetweenPoints, ArcPolygon, ArcPolygonFromArcs, Arrow, ArrowCircleFilledTip, ArrowCircleTip, ArrowSquareFilledTip, ArrowSquareTip, ArrowTip, ArrowTriangleFilledTip, ArrowTriangleTip, BackgroundRectangle, Circle, ConvexHull, Cross, CurvedArrow, CurvedDoubleArrow, Cutout, DashedLine, Difference, Dot, DoubleArrow, Elbow, Ellipse, Exclusion, FunctionGraph, ImplicitFunction, Intersection, Label, LabeledArrow, LabeledDot, LabeledLine, LabeledPolygram, Line, ParametricFunction, Polygon, Polygram, Rectangle, RegularPolygon, RegularPolygram, RightAngle, RoundedRectangle, Sector, Square, Star, StealthTip, SurroundingRectangle, TangentLine, TangentialArc, TipableVMobject, Triangle, Underline, Union, Vector, } from "./geometry.js";
6
- export * from "./colors-palette.js";
7
- export { HSV, ManimColor, RGBA, RandomColorGenerator, averageColor, colorGradient, colorToIntRgb, colorToIntRgba, colorToRgb, colorToRgba, hexToRgb, interpolateColor, invertColor, randomBrightColor, randomColor, rgbToColor, rgbToHex, rgbaToColor, } from "./colors.js";
8
- export * from "./rates.js";
9
- export * from "./utils.js";
10
- export * from "./braces.js";
11
- export * from "./mobjects.js";
12
- export * from "./tables.js";
13
- export * from "./text-layouts.js";
14
- export * from "./animations.js";
15
- export * from "./graphing.js";
16
- export * from "./graph.js";
17
- export * from "./pointcloud.js";
18
- export * from "./vector-field.js";
19
- export * from "./logo.js";
package/dist/media.d.ts DELETED
@@ -1,34 +0,0 @@
1
- /** The most bytes of one file of an `embed`. */
2
- export declare const MAX_CLIP_BYTES: number;
3
- /** What a file is: a video, a sound or a picture (the picture of a sound), its format and, for a
4
- * video and a sound, its length in seconds. */
5
- export type MediaInfo = {
6
- readonly kind: "video";
7
- readonly format: "mp4" | "webm";
8
- readonly seconds: number;
9
- } | {
10
- readonly kind: "sound";
11
- readonly format: "wav" | "mp3";
12
- readonly seconds: number;
13
- } | {
14
- readonly kind: "image";
15
- readonly format: "png" | "jpeg";
16
- };
17
- /** A file of the project that the host can read: its size, and its bytes. */
18
- export interface MediaSource {
19
- readonly size: number;
20
- read(): Uint8Array;
21
- }
22
- /** The formats that an `embed` plays, for the messages. */
23
- export declare const MEDIA_FORMATS = "MP4 (H.264, AAC) or WebM (VP8 or VP9, Opus or Vorbis) video; WAV (PCM) or MP3 sound; PNG or JPEG picture";
24
- /** What the file `source` is, or why aula cannot play it (a problem that fits after the path of
25
- * the file). The size is checked before the read. */
26
- export declare function probeMedia(source: MediaSource): MediaInfo | string;
27
- /** The path `given` of a file of the project, from the folder `from` of the project (default: the
28
- * project folder), as a path from the project folder with no `.` and no `..`, or the problem with
29
- * it: a URL, an absolute path, or a path outside the project folder. */
30
- export declare function projectPath(given: string, from?: string): {
31
- path: string;
32
- } | {
33
- problem: string;
34
- };