@beff/aula 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine.d.ts +43 -9
- package/dist/engine.js +72 -24
- package/dist/generated/aula.core5.wasm +0 -0
- package/dist/generated/aula.core6.wasm +0 -0
- package/dist/generated/aula.core7.wasm +0 -0
- package/dist/generated/aula.js +2626 -1456
- package/dist/generated/interfaces/aula-engine-engine.d.ts +23 -3
- package/dist/generated/interfaces/aula-engine-types.d.ts +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -2
- package/dist/lexicon.d.ts +10 -0
- package/dist/lexicon.js +23 -0
- package/dist/run.d.ts +9 -3
- package/dist/run.js +18 -1
- package/dist/text.d.ts +16 -6
- package/dist/text.js +14 -8
- package/package.json +1 -1
package/dist/engine.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Animation as RawAnimation, Mobject as RawMobject, Rate as RawRate, Chapter as RawChapter, Narration, NarrationWait, Screen } from "./generated/interfaces/aula-engine-engine.js";
|
|
1
|
+
import type { Animation as RawAnimation, Mobject as RawMobject, Rate as RawRate, Chapter as RawChapter, Narration, NarrationWait, Screen, LexiconEntry, SayPart } from "./generated/interfaces/aula-engine-engine.js";
|
|
2
2
|
import type { Color, Diagnostic, Location, Point, ChapterText as RawChapterText, ParagraphText as RawParagraphText } from "./generated/interfaces/aula-engine-types.js";
|
|
3
|
+
import type { Lexicon } from "./lexicon.ts";
|
|
3
4
|
import type { Theme } from "./theme.ts";
|
|
4
5
|
import { type CapStyleType, type Complex, type LineJointType } from "./utils.ts";
|
|
5
6
|
export type { Instant, Screen, Shown } from "./generated/interfaces/aula-engine-engine.js";
|
|
@@ -1306,7 +1307,7 @@ type RowData = {
|
|
|
1306
1307
|
} | {
|
|
1307
1308
|
readonly kind: "say";
|
|
1308
1309
|
readonly call: Call;
|
|
1309
|
-
readonly
|
|
1310
|
+
readonly parts: readonly SayPart[];
|
|
1310
1311
|
} | {
|
|
1311
1312
|
readonly kind: "show";
|
|
1312
1313
|
readonly call: Call;
|
|
@@ -1364,6 +1365,13 @@ export interface ProjectFields {
|
|
|
1364
1365
|
card?: Card;
|
|
1365
1366
|
/** The chapters, in order: the default exports of their chapter modules. */
|
|
1366
1367
|
chapters: readonly ChapterDefinition[];
|
|
1368
|
+
/** The words that have one reading in all of the video: each key is a written word, and each
|
|
1369
|
+
* value is the reading that the narrator speaks at each use of the word in a `say`, in the
|
|
1370
|
+
* title and in a heading (the reading of `pronounce`). The match is the whole word, with marks around it and a
|
|
1371
|
+
* possessive `'s`, in the same case; a key that starts with a lowercase letter also matches
|
|
1372
|
+
* the word with a capital first letter. `pronounce` comes first, and aula's own lexicon and
|
|
1373
|
+
* misaki come after it. The default is no word. */
|
|
1374
|
+
lexicon?: Lexicon;
|
|
1367
1375
|
}
|
|
1368
1376
|
/** What `defineProject` returns. */
|
|
1369
1377
|
export interface ProjectDefinition extends Required<Omit<ProjectFields, "card" | "theme">> {
|
|
@@ -1376,8 +1384,8 @@ export interface ProjectDefinition extends Required<Omit<ProjectFields, "card" |
|
|
|
1376
1384
|
* `@beff/aula/run`). */
|
|
1377
1385
|
readonly call: Error;
|
|
1378
1386
|
}
|
|
1379
|
-
/** `export default defineProject({ title, storyboard, theme, chapters })`: one project,
|
|
1380
|
-
* `index.ts` of its folder. Makes no engine call. */
|
|
1387
|
+
/** `export default defineProject({ title, storyboard, theme, lexicon, chapters })`: one project,
|
|
1388
|
+
* in the `index.ts` of its folder. Makes no engine call. */
|
|
1381
1389
|
export declare function defineProject(fields: ProjectFields): ProjectDefinition;
|
|
1382
1390
|
/** True for a value that defineProject made. */
|
|
1383
1391
|
export declare function isProjectDefinition(v: unknown): v is ProjectDefinition;
|
|
@@ -1385,11 +1393,35 @@ export declare function isProjectDefinition(v: unknown): v is ProjectDefinition;
|
|
|
1385
1393
|
* under the paragraph. `check` is for kits: aula calls it one time, after the chapter is drawn,
|
|
1386
1394
|
* and reports its findings. */
|
|
1387
1395
|
export declare function paragraph(notes?: Notes, check?: Check): Row;
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
export
|
|
1396
|
+
declare const PRONOUNCE: unique symbol;
|
|
1397
|
+
/** How the narrator reads the word of `pronounce`: `{ say: "…" }` is plain text, which goes
|
|
1398
|
+
* through the normal front end (aula's lexicon, then misaki), and `{ phonemes: "…" }` is
|
|
1399
|
+
* phonemes of Kokoro's token table (misaki's symbols, as `aula tokens` shows them). */
|
|
1400
|
+
export type Reading = {
|
|
1401
|
+
readonly say: string;
|
|
1402
|
+
} | {
|
|
1403
|
+
readonly phonemes: string;
|
|
1404
|
+
};
|
|
1405
|
+
/** What `pronounce` returns: one written word and its reading. Only a `say` takes it. */
|
|
1406
|
+
export interface Pronounce {
|
|
1407
|
+
readonly [PRONOUNCE]: true;
|
|
1408
|
+
readonly written: string;
|
|
1409
|
+
readonly reading: Reading;
|
|
1410
|
+
}
|
|
1411
|
+
/** ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``: one word that the
|
|
1412
|
+
* screen, the word times and `aula script` show as `written`, and that the narrator reads as
|
|
1413
|
+
* `reading`. The written part is one word, and its word time covers all of the reading. Use it
|
|
1414
|
+
* only for a word whose reading changes with the context. `aula check` gives an error when the
|
|
1415
|
+
* written part is not one word, or when a phoneme is not in Kokoro's token table. */
|
|
1416
|
+
export declare function pronounce(written: string, reading: Reading): Pronounce;
|
|
1417
|
+
/** The text of a row tag (`name` is the tag), as written: one template with no invalid escape
|
|
1418
|
+
* and no line break. A `${…}` can only be the value of `pronounce`, and its written word is in
|
|
1419
|
+
* the text. Throws a AulaError at the row. A kit's own row tag calls it with the values of its
|
|
1420
|
+
* template. */
|
|
1421
|
+
export declare function tagText(name: string, strings: TemplateStringsArray, ...values: readonly unknown[]): string;
|
|
1422
|
+
/** ``say`text` ``: the next words of the narration. A `${…}` can only be
|
|
1423
|
+
* `pronounce(written, reading)`: ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``. */
|
|
1424
|
+
export declare function say(strings: TemplateStringsArray, ...words: readonly Pronounce[]): Row;
|
|
1393
1425
|
/** ``show`note``timing` ``: a move. The note says what changes on screen. The timing, a
|
|
1394
1426
|
* second template right after the note, gives the length of the move: ``25%`` is a share of the
|
|
1395
1427
|
* `say` above it (0 < N <= 100) and scales with the narration, and ``3s`` is seconds (N > 0).
|
|
@@ -1513,6 +1545,8 @@ export interface ChapterSlot {
|
|
|
1513
1545
|
file: string;
|
|
1514
1546
|
/** The frames of an error (`Host.frames`). */
|
|
1515
1547
|
frames(error: Error): readonly StackFrame[];
|
|
1548
|
+
/** The project lexicon in the engine's form. */
|
|
1549
|
+
lexicon: readonly LexiconEntry[];
|
|
1516
1550
|
}
|
|
1517
1551
|
/** Reads a chapter: calls `rows` and no move. It gives the text and the text problems; the
|
|
1518
1552
|
* paragraph checks run only in `drawRows`. A chapter error is thrown (a AulaError, a WIT
|
package/dist/engine.js
CHANGED
|
@@ -2915,10 +2915,10 @@ export function defineChapter(fields) {
|
|
|
2915
2915
|
return { ...fields, call: new Error("defineChapter") };
|
|
2916
2916
|
}
|
|
2917
2917
|
const PROJECT = Symbol("aula.project");
|
|
2918
|
-
/** `export default defineProject({ title, storyboard, theme, chapters })`: one project,
|
|
2919
|
-
* `index.ts` of its folder. Makes no engine call. */
|
|
2918
|
+
/** `export default defineProject({ title, storyboard, theme, lexicon, chapters })`: one project,
|
|
2919
|
+
* in the `index.ts` of its folder. Makes no engine call. */
|
|
2920
2920
|
export function defineProject(fields) {
|
|
2921
|
-
return { [PROJECT]: true, storyboard: "", ...fields, call: new Error("defineProject") };
|
|
2921
|
+
return { [PROJECT]: true, storyboard: "", lexicon: {}, ...fields, call: new Error("defineProject") };
|
|
2922
2922
|
}
|
|
2923
2923
|
/** True for a value that defineProject made. */
|
|
2924
2924
|
export function isProjectDefinition(v) {
|
|
@@ -2938,25 +2938,72 @@ function row(name, data) {
|
|
|
2938
2938
|
export function paragraph(notes = {}, check) {
|
|
2939
2939
|
return row("paragraph", (call) => ({ kind: "paragraph", call, notes, check }));
|
|
2940
2940
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2941
|
+
const PRONOUNCE = Symbol("aula.pronounce");
|
|
2942
|
+
/** ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``: one word that the
|
|
2943
|
+
* screen, the word times and `aula script` show as `written`, and that the narrator reads as
|
|
2944
|
+
* `reading`. The written part is one word, and its word time covers all of the reading. Use it
|
|
2945
|
+
* only for a word whose reading changes with the context. `aula check` gives an error when the
|
|
2946
|
+
* written part is not one word, or when a phoneme is not in Kokoro's token table. */
|
|
2947
|
+
export function pronounce(written, reading) {
|
|
2948
|
+
const usage = 'pronounce("word", { say: "words" }) or pronounce("word", { phonemes: "fˈQnimz" })';
|
|
2949
|
+
if (typeof written !== "string")
|
|
2950
|
+
fault("pronounce: the written word must be a string", usage);
|
|
2951
|
+
const r = reading;
|
|
2952
|
+
const one = typeof r === "object" &&
|
|
2953
|
+
r !== null &&
|
|
2954
|
+
Object.keys(r).length === 1 &&
|
|
2955
|
+
(("say" in r && typeof r.say === "string") || ("phonemes" in r && typeof r.phonemes === "string"));
|
|
2956
|
+
if (!one)
|
|
2957
|
+
fault("pronounce: give the reading as { say: string } or { phonemes: string }", usage);
|
|
2958
|
+
return { [PRONOUNCE]: true, written, reading };
|
|
2959
|
+
}
|
|
2960
|
+
/** True for a value that `pronounce` made. */
|
|
2961
|
+
function isPronounce(v) {
|
|
2962
|
+
return typeof v === "object" && v !== null && PRONOUNCE in v;
|
|
2963
|
+
}
|
|
2964
|
+
/** The parts of a row tag's text: each piece of the template, and the written word and the
|
|
2965
|
+
* reading of each `pronounce` between them. Every other `${…}` is an error. */
|
|
2966
|
+
function tagParts(name, strings, values) {
|
|
2967
|
+
if (strings.length !== values.length + 1) {
|
|
2945
2968
|
fault(`${name}: write the text as it is, with no \${…}`, "the text in the source is the text that is spoken");
|
|
2946
2969
|
}
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2970
|
+
const parts = [];
|
|
2971
|
+
strings.forEach((text, i) => {
|
|
2972
|
+
if (text === undefined) {
|
|
2973
|
+
fault(`${name}: the text has an invalid escape`, "escape only a backtick, a backslash and ${ with a backslash");
|
|
2974
|
+
}
|
|
2975
|
+
if (/[\r\n]/.test(text)) {
|
|
2976
|
+
fault(`${name}: write the text on one line`, "a row's text stays on the line of its call");
|
|
2977
|
+
}
|
|
2978
|
+
if (text !== "")
|
|
2979
|
+
parts.push({ text });
|
|
2980
|
+
if (i === values.length)
|
|
2981
|
+
return;
|
|
2982
|
+
const value = values[i];
|
|
2983
|
+
if (!isPronounce(value)) {
|
|
2984
|
+
fault(`${name}: write the text as it is; a \${…} can only be pronounce(written, reading)`, "the text in the source is the text that is spoken");
|
|
2985
|
+
}
|
|
2986
|
+
const reading = "say" in value.reading
|
|
2987
|
+
? { tag: "words", val: value.reading.say }
|
|
2988
|
+
: { tag: "phonemes", val: value.reading.phonemes };
|
|
2989
|
+
parts.push({ text: value.written, reading });
|
|
2990
|
+
});
|
|
2991
|
+
return parts;
|
|
2992
|
+
}
|
|
2993
|
+
/** The text of a row tag (`name` is the tag), as written: one template with no invalid escape
|
|
2994
|
+
* and no line break. A `${…}` can only be the value of `pronounce`, and its written word is in
|
|
2995
|
+
* the text. Throws a AulaError at the row. A kit's own row tag calls it with the values of its
|
|
2996
|
+
* template. */
|
|
2997
|
+
export function tagText(name, strings, ...values) {
|
|
2998
|
+
return tagParts(name, strings, values)
|
|
2999
|
+
.map((p) => p.text)
|
|
3000
|
+
.join("");
|
|
3001
|
+
}
|
|
3002
|
+
/** ``say`text` ``: the next words of the narration. A `${…}` can only be
|
|
3003
|
+
* `pronounce(written, reading)`: ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``. */
|
|
3004
|
+
export function say(strings, ...words) {
|
|
3005
|
+
const parts = tagParts("say", strings, words);
|
|
3006
|
+
return row("say", (call) => ({ kind: "say", call, parts }));
|
|
2960
3007
|
}
|
|
2961
3008
|
/** ``show`note``timing` ``: a move. The note says what changes on screen. The timing, a
|
|
2962
3009
|
* second template right after the note, gives the length of the move: ``25%`` is a share of the
|
|
@@ -3178,6 +3225,7 @@ function noteList(notes) {
|
|
|
3178
3225
|
}
|
|
3179
3226
|
/** Gives the rows to the engine in order; with a scene, it runs each move after its `show`. */
|
|
3180
3227
|
function write(handle, chapter, rows, slot, scene, card) {
|
|
3228
|
+
handle.lexicon([...slot.lexicon]);
|
|
3181
3229
|
handle.header(placeIn(chapter.call, slot), chapter.heading, chapter.metaphor);
|
|
3182
3230
|
card?.();
|
|
3183
3231
|
for (const r of rows) {
|
|
@@ -3186,7 +3234,7 @@ function write(handle, chapter, rows, slot, scene, card) {
|
|
|
3186
3234
|
handle.paragraph(at, noteList(r.notes));
|
|
3187
3235
|
}
|
|
3188
3236
|
else if (r.kind === "say") {
|
|
3189
|
-
handle.say(at, r.
|
|
3237
|
+
handle.say(at, [...r.parts]);
|
|
3190
3238
|
}
|
|
3191
3239
|
else if (r.move === undefined) {
|
|
3192
3240
|
handle.open(at, r.note, r.timing);
|
|
@@ -3300,7 +3348,7 @@ export function checkRows(chapter, theme, card, slot, exists) {
|
|
|
3300
3348
|
export function checkTitle(title, theme, card, count) {
|
|
3301
3349
|
freshSeed();
|
|
3302
3350
|
const handle = engine.Chapter.orderPass(0, count + 1);
|
|
3303
|
-
const slot = { number: 0, count, source: "", file: "", frames: () => [] };
|
|
3351
|
+
const slot = { number: 0, count, source: "", file: "", frames: () => [], lexicon: [] };
|
|
3304
3352
|
const scene = playCard(handle, slot, { file: "", line: 0, col: 0 }, card, { title, chapter: 0, count, theme });
|
|
3305
3353
|
handle.finish();
|
|
3306
3354
|
return { diagnostics: [...handle.report(), ...scene.warnings] };
|
|
@@ -3336,7 +3384,7 @@ export function drawTitle(title, theme, card, drawing) {
|
|
|
3336
3384
|
freshSeed();
|
|
3337
3385
|
const handle = engine.Chapter.render(drawing.narration, theme.background, 0, drawing.count, drawing.name, drawing.lint);
|
|
3338
3386
|
const count = drawing.count - 1;
|
|
3339
|
-
const slot = { number: 0, count, source: "", file: "", frames: () => [] };
|
|
3387
|
+
const slot = { number: 0, count, source: "", file: "", frames: () => [], lexicon: [] };
|
|
3340
3388
|
playCard(handle, slot, { file: "", line: 0, col: 0 }, card, { title, chapter: 0, count, theme });
|
|
3341
3389
|
return finished(handle);
|
|
3342
3390
|
}
|
|
@@ -3344,7 +3392,7 @@ export function drawTitle(title, theme, card, drawing) {
|
|
|
3344
3392
|
* second, on a black background. There is no project, no narration and no heading. */
|
|
3345
3393
|
export function renderScene(draw) {
|
|
3346
3394
|
const handle = engine.Chapter.scene();
|
|
3347
|
-
const slot = { number: 0, count: 1, source: "scene", file: "scene", frames: () => [] };
|
|
3395
|
+
const slot = { number: 0, count: 1, source: "scene", file: "scene", frames: () => [], lexicon: [] };
|
|
3348
3396
|
draw(new Scene(handle, slot));
|
|
3349
3397
|
handle.finish();
|
|
3350
3398
|
const trace = JSON.parse(handle.trace());
|
|
Binary file
|
|
Binary file
|
|
Binary file
|