@beff/aula 0.2.0 → 0.3.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 CHANGED
@@ -1333,8 +1333,9 @@ export interface Untimed {
1333
1333
  }
1334
1334
  /** The fields of `defineChapter`: one chapter of a project. */
1335
1335
  export interface ChapterFields {
1336
- /** The `##` heading, spoken first. */
1337
- heading: string;
1336
+ /** The `##` heading, spoken first: a plain string (the usual form), or a ``say`…` `` when a word
1337
+ * needs `pronounce`. The cards show the written text, and the narrator speaks the reading. */
1338
+ heading: string | SayRow;
1338
1339
  /** The one recurring picture that the chapter is built on. */
1339
1340
  metaphor: string;
1340
1341
  /** Makes the objects of the chapter and returns its rows in time order. aula calls it for
@@ -1342,7 +1343,13 @@ export interface ChapterFields {
1342
1343
  rows: () => Row[];
1343
1344
  }
1344
1345
  /** What `defineChapter` returns. */
1345
- export interface ChapterDefinition extends Readonly<ChapterFields> {
1346
+ export interface ChapterDefinition extends Readonly<Omit<ChapterFields, "heading">> {
1347
+ /** The heading as written: the cards, the chapter names and `aula script` show it. */
1348
+ readonly heading: string;
1349
+ /** The parts of the heading's `say`: a plain string is one part with no reading. */
1350
+ readonly headingParts: readonly SayPart[];
1351
+ /** The call of the heading's `say` (its line), or the defineChapter call for a plain string. */
1352
+ readonly headingCall: Error;
1346
1353
  /** The defineChapter call: its second frame is the chapter file (`definedAt` in
1347
1354
  * `@beff/aula/run`). */
1348
1355
  readonly call: Error;
@@ -1353,8 +1360,10 @@ export declare function defineChapter(fields: ChapterFields): ChapterDefinition;
1353
1360
  declare const PROJECT: unique symbol;
1354
1361
  /** The fields of `defineProject`: one project. */
1355
1362
  export interface ProjectFields {
1356
- /** The project title: the title card (chapter 0). The name of the project is its folder name. */
1357
- title: string;
1363
+ /** The project title: the title card (chapter 0). The name of the project is its folder name.
1364
+ * A plain string (the usual form), or a ``say`…` `` when a word needs `pronounce`. The title card
1365
+ * shows the written text, and the narrator speaks the reading. */
1366
+ title: string | SayRow;
1358
1367
  /** The storyboard header: recurring objects, symbols and colour rules. */
1359
1368
  storyboard?: string;
1360
1369
  /** The colours and text sizes of the chrome (title card, chapter cards, docked heading) and
@@ -1374,7 +1383,13 @@ export interface ProjectFields {
1374
1383
  lexicon?: Lexicon;
1375
1384
  }
1376
1385
  /** What `defineProject` returns. */
1377
- export interface ProjectDefinition extends Required<Omit<ProjectFields, "card" | "theme">> {
1386
+ export interface ProjectDefinition extends Required<Omit<ProjectFields, "card" | "theme" | "title">> {
1387
+ /** The title as written: the title card, the list of videos and `aula script` show it. */
1388
+ readonly title: string;
1389
+ /** The parts of the title's `say`: a plain string is one part with no reading. */
1390
+ readonly titleParts: readonly SayPart[];
1391
+ /** The call of the title's `say` (its line), or the defineProject call for a plain string. */
1392
+ readonly titleCall: Error;
1378
1393
  /** The theme that the project gives, if any. */
1379
1394
  readonly theme?: Theme;
1380
1395
  /** The card that the project gives, if any. */
@@ -1402,7 +1417,8 @@ export type Reading = {
1402
1417
  } | {
1403
1418
  readonly phonemes: string;
1404
1419
  };
1405
- /** What `pronounce` returns: one written word and its reading. Only a `say` takes it. */
1420
+ /** What `pronounce` returns: one written word and its reading. Only a `say` takes it: a `say` row,
1421
+ * or a `say` that is the `title` of `defineProject` or the `heading` of `defineChapter`. */
1406
1422
  export interface Pronounce {
1407
1423
  readonly [PRONOUNCE]: true;
1408
1424
  readonly written: string;
@@ -1411,7 +1427,8 @@ export interface Pronounce {
1411
1427
  /** ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``: one word that the
1412
1428
  * screen, the word times and `aula script` show as `written`, and that the narrator reads as
1413
1429
  * `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
1430
+ * only for a word whose reading changes with the context. It goes in a `say`: a row, the
1431
+ * `title` of `defineProject` or the `heading` of `defineChapter`. `aula check` gives an error when the
1415
1432
  * written part is not one word, or when a phoneme is not in Kokoro's token table. */
1416
1433
  export declare function pronounce(written: string, reading: Reading): Pronounce;
1417
1434
  /** The text of a row tag (`name` is the tag), as written: one template with no invalid escape
@@ -1419,9 +1436,18 @@ export declare function pronounce(written: string, reading: Reading): Pronounce;
1419
1436
  * the text. Throws a AulaError at the row. A kit's own row tag calls it with the values of its
1420
1437
  * template. */
1421
1438
  export declare function tagText(name: string, strings: TemplateStringsArray, ...values: readonly unknown[]): string;
1439
+ declare const SAY: unique symbol;
1440
+ /** What ``say`…` `` returns: a row of the narration, or the `title` of `defineProject` or the
1441
+ * `heading` of `defineChapter`. */
1442
+ export interface SayRow extends Row {
1443
+ readonly [SAY]: true;
1444
+ }
1422
1445
  /** ``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;
1446
+ * `pronounce(written, reading)`: ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``.
1447
+ * The written text is on the screen where aula shows the text (the cards, for a title or a
1448
+ * heading), in the word times and in `aula script`, and the narrator speaks the reading. A
1449
+ * `say` is a row, the `title` of `defineProject` or the `heading` of `defineChapter`. */
1450
+ export declare function say(strings: TemplateStringsArray, ...words: readonly Pronounce[]): SayRow;
1425
1451
  /** ``show`note``timing` ``: a move. The note says what changes on screen. The timing, a
1426
1452
  * second template right after the note, gives the length of the move: ``25%`` is a share of the
1427
1453
  * `say` above it (0 < N <= 100) and scales with the narration, and ``3s`` is seconds (N > 0).
@@ -1563,7 +1589,7 @@ export declare function checkRows(chapter: ChapterDefinition, theme: Theme, card
1563
1589
  diagnostics: Diagnostic[];
1564
1590
  };
1565
1591
  /** Checks chapter 0: the card of the project `title`, with no clock. */
1566
- export declare function checkTitle(title: string, theme: Theme, card: Card, count: number): {
1592
+ export declare function checkTitleCard(title: string, theme: Theme, card: Card, count: number): {
1567
1593
  diagnostics: Diagnostic[];
1568
1594
  };
1569
1595
  /** How a chapter is drawn against a narration. */
package/dist/engine.js CHANGED
@@ -2912,13 +2912,39 @@ const ROW = Symbol("aula.row");
2912
2912
  /** `export default defineChapter({ heading, metaphor, rows: () => [ … ] })`: one chapter.
2913
2913
  * Makes no engine call. */
2914
2914
  export function defineChapter(fields) {
2915
- return { ...fields, call: new Error("defineChapter") };
2915
+ const call = new Error("defineChapter");
2916
+ const heading = spokenField("defineChapter", "heading", fields.heading, call);
2917
+ return { ...fields, heading: heading.text, headingParts: heading.parts, headingCall: heading.call, call };
2918
+ }
2919
+ /** The written text, the parts and the call of a `title` or a `heading` (`field`): a plain
2920
+ * string (one part with no reading, at `call`), or a `say` (its parts, at its own call). Any
2921
+ * other value is a fault. */
2922
+ function spokenField(name, field, value, call) {
2923
+ if (typeof value === "string")
2924
+ return { text: value, parts: [{ text: value }], call };
2925
+ if (!isSay(value)) {
2926
+ fault(`${name}: the ${field} must be a string or a say`, `${field}: "text" or ${field}: say\`text \${pronounce("word", { say: "words" })}\``);
2927
+ }
2928
+ const data = value[ROW];
2929
+ const parts = data.kind === "say" ? data.parts : [];
2930
+ return { text: parts.map((p) => p.text).join(""), parts, call: data.call };
2916
2931
  }
2917
2932
  const PROJECT = Symbol("aula.project");
2918
2933
  /** `export default defineProject({ title, storyboard, theme, lexicon, chapters })`: one project,
2919
2934
  * in the `index.ts` of its folder. Makes no engine call. */
2920
2935
  export function defineProject(fields) {
2921
- return { [PROJECT]: true, storyboard: "", lexicon: {}, ...fields, call: new Error("defineProject") };
2936
+ const call = new Error("defineProject");
2937
+ const title = spokenField("defineProject", "title", fields.title, call);
2938
+ return {
2939
+ [PROJECT]: true,
2940
+ storyboard: "",
2941
+ lexicon: {},
2942
+ ...fields,
2943
+ title: title.text,
2944
+ titleParts: title.parts,
2945
+ titleCall: title.call,
2946
+ call,
2947
+ };
2922
2948
  }
2923
2949
  /** True for a value that defineProject made. */
2924
2950
  export function isProjectDefinition(v) {
@@ -2942,7 +2968,8 @@ const PRONOUNCE = Symbol("aula.pronounce");
2942
2968
  /** ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``: one word that the
2943
2969
  * screen, the word times and `aula script` show as `written`, and that the narrator reads as
2944
2970
  * `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
2971
+ * only for a word whose reading changes with the context. It goes in a `say`: a row, the
2972
+ * `title` of `defineProject` or the `heading` of `defineChapter`. `aula check` gives an error when the
2946
2973
  * written part is not one word, or when a phoneme is not in Kokoro's token table. */
2947
2974
  export function pronounce(written, reading) {
2948
2975
  const usage = 'pronounce("word", { say: "words" }) or pronounce("word", { phonemes: "fˈQnimz" })';
@@ -2999,11 +3026,19 @@ export function tagText(name, strings, ...values) {
2999
3026
  .map((p) => p.text)
3000
3027
  .join("");
3001
3028
  }
3029
+ const SAY = Symbol("aula.say");
3030
+ /** True for a value that `say` made. */
3031
+ function isSay(v) {
3032
+ return typeof v === "object" && v !== null && SAY in v;
3033
+ }
3002
3034
  /** ``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" })}.` ``. */
3035
+ * `pronounce(written, reading)`: ``say`The file is 4 ${pronounce("GB", { say: "gigabytes" })}.` ``.
3036
+ * The written text is on the screen where aula shows the text (the cards, for a title or a
3037
+ * heading), in the word times and in `aula script`, and the narrator speaks the reading. A
3038
+ * `say` is a row, the `title` of `defineProject` or the `heading` of `defineChapter`. */
3004
3039
  export function say(strings, ...words) {
3005
3040
  const parts = tagParts("say", strings, words);
3006
- return row("say", (call) => ({ kind: "say", call, parts }));
3041
+ return { ...row("say", (call) => ({ kind: "say", call, parts })), [SAY]: true };
3007
3042
  }
3008
3043
  /** ``show`note``timing` ``: a move. The note says what changes on screen. The timing, a
3009
3044
  * second template right after the note, gives the length of the move: ``25%`` is a share of the
@@ -3226,7 +3261,7 @@ function noteList(notes) {
3226
3261
  /** Gives the rows to the engine in order; with a scene, it runs each move after its `show`. */
3227
3262
  function write(handle, chapter, rows, slot, scene, card) {
3228
3263
  handle.lexicon([...slot.lexicon]);
3229
- handle.header(placeIn(chapter.call, slot), chapter.heading, chapter.metaphor);
3264
+ handle.header(placeIn(chapter.headingCall, slot), [...chapter.headingParts], chapter.metaphor);
3230
3265
  card?.();
3231
3266
  for (const r of rows) {
3232
3267
  const at = placeIn(r.call, slot);
@@ -3345,7 +3380,7 @@ export function checkRows(chapter, theme, card, slot, exists) {
3345
3380
  };
3346
3381
  }
3347
3382
  /** Checks chapter 0: the card of the project `title`, with no clock. */
3348
- export function checkTitle(title, theme, card, count) {
3383
+ export function checkTitleCard(title, theme, card, count) {
3349
3384
  freshSeed();
3350
3385
  const handle = engine.Chapter.orderPass(0, count + 1);
3351
3386
  const slot = { number: 0, count, source: "", file: "", frames: () => [], lexicon: [] };
Binary file
Binary file
Binary file