@patterkit/model 0.22.0 → 0.24.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/index.d.cts CHANGED
@@ -2,6 +2,33 @@ import { AstNode } from '@wildwinter/expr';
2
2
  export { RESERVED_PROPERTY_NAMES, isCaseOnlyPropertyName, isValidPropertyName, propertyNameify } from '@wildwinter/expr';
3
3
  export { gameIdify, isValidGameId } from '@wildwinter/toolkit';
4
4
 
5
+ /** What a speech unit is: a syllable (the mouth opens), a beat with the mouth shut (っ), or a pause. */
6
+ type SpeechUnitKind = "syllable" | "closed" | "pause";
7
+ /** One unit of a line as it would be spoken. `start` and `end` are code-point offsets into the text, end exclusive. */
8
+ interface SpeechUnit {
9
+ kind: SpeechUnitKind;
10
+ weight: number;
11
+ start: number;
12
+ end: number;
13
+ }
14
+ /** A digit's weight: most read as one or two syllables. */
15
+ declare const SPEECH_DIGIT_WEIGHT = 1.5;
16
+ /** A Han character's weight in Japanese text. */
17
+ declare const SPEECH_KANJI_WEIGHT = 2;
18
+ /** A short pause's weight (`,` `;` `、`), and a long one's (`.` `?` `。`). */
19
+ declare const SPEECH_PAUSE_SHORT_WEIGHT = 1;
20
+ declare const SPEECH_PAUSE_LONG_WEIGHT = 2;
21
+ /**
22
+ * A line broken into the units it would be spoken in: its syllables, its beats with the mouth shut, and its pauses,
23
+ * in order, each with a weight. `locale` is the language the line is spoken in (the project's main language, not the
24
+ * one being shown); it decides English's and French's silent e, and Japanese kanji, which also apply when the line
25
+ * has any kana in it.
26
+ */
27
+ declare function speechUnits(text: string, locale?: string): SpeechUnit[];
28
+ /** How many syllables a line would be spoken in: its syllables' and shut beats' weights, pauses aside. `locale` is
29
+ * the language it's spoken in, as for `speechUnits`. */
30
+ declare function countSyllables(text: string, locale?: string): number;
31
+
5
32
  type ScalarValue = boolean | number | string | string[];
6
33
  /** Developer-defined host metadata (spec §17). Opaque to Patter. */
7
34
  type GameData = Record<string, unknown>;
@@ -431,17 +458,22 @@ declare const DEFAULT_PAD_AFTER = 0.6;
431
458
  /** The range validation keeps a `padAfter` or `padAfterDefault` within, in seconds. */
432
459
  declare const PAD_AFTER_MIN = -10;
433
460
  declare const PAD_AFTER_MAX = 60;
434
- /** The reading rate a line with no recording is timed by, in characters a second (`estimateLineDuration`). */
435
- declare const LINE_CHARS_PER_SECOND = 14;
461
+ /** How many syllables a second a line with no recording is timed at, unless the project sets its own
462
+ * (`estimateSyllablesPerSecond`), and the range validation keeps a project's within. */
463
+ declare const DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND = 4;
464
+ declare const ESTIMATE_SYLLABLES_PER_SECOND_MIN = 2;
465
+ declare const ESTIMATE_SYLLABLES_PER_SECOND_MAX = 10;
436
466
  /** The shortest and longest a line with no recording lasts, in seconds (`estimateLineDuration`). */
437
467
  declare const LINE_DURATION_MIN = 1.5;
438
468
  declare const LINE_DURATION_MAX = 18;
439
- /** How long a line with no recording lasts, in seconds: its characters at 14 a second, clamped to 1.5 to 18
440
- * seconds. A character is a Unicode code point (one outside the Basic Multilingual Plane counts once), and soft
441
- * hyphens (U+00AD) aren't counted. This is the one rule every Patter tool and runtime times a line by: Patterpad's
442
- * Play window, the playable HTML page, and the Unity, Unreal, and Godot runtimes, which the conformance corpus
443
- * holds to the same numbers. `locale` is reserved for per-language reading rates and is unused for now. */
444
- declare function estimateLineDuration(text: string, _locale?: string): number;
469
+ /** How long a line with no recording lasts, in seconds: the total weight of its speech units (its syllables and its
470
+ * pauses, `speechUnits`) at `syllablesPerSecond` (default 4, the project's `estimateSyllablesPerSecond` when it
471
+ * sets one), clamped to 1.5 to 18 seconds. `text` and `locale` are the line as it's spoken, in the project's main
472
+ * language (a line result's `spokenText` and `spokenLocale`), never a translation being shown. This is the one
473
+ * rule every Patter tool and runtime times a line by: Patterpad's Play window, the playable HTML page, and the
474
+ * Unity, Unreal, and Godot runtimes, which the conformance corpus holds to the same numbers. A rate that isn't a
475
+ * positive number is the default. A line with a recording lasts as long as the recording, whatever this says. */
476
+ declare function estimateLineDuration(text: string, locale?: string, syllablesPerSecond?: number): number;
445
477
  /** A qualifier as it reaches a compiled bundle: its `gameId` and authored name (the unlocalised fallback). */
446
478
  interface BundleQualifier {
447
479
  gameId: string;
@@ -599,6 +631,43 @@ interface EstimatingConfig {
599
631
  lines: number;
600
632
  }[];
601
633
  }
634
+ /** A folder in the scene list (ProjectFile.sceneFolders): organisational only, it carries no meaning. */
635
+ interface SceneFolder {
636
+ id: string;
637
+ name: string;
638
+ /** The folder it sits in; omitted = the top level. A parent that doesn't exist, or a loop of parents
639
+ * (only a bad merge makes one), reads as the top level. */
640
+ parent?: string;
641
+ }
642
+ /** One row of the scene list as laid out by `sceneFolderLayout`, top to bottom with every folder open. */
643
+ interface SceneNavRow {
644
+ kind: "folder" | "scene";
645
+ id: string;
646
+ /** 0 = the top level. */
647
+ depth: number;
648
+ /** The folder this row sits in, if any. */
649
+ folder?: string;
650
+ }
651
+ interface SceneFolderLayout {
652
+ /** Every folder and scene, depth first, in authored order. */
653
+ rows: SceneNavRow[];
654
+ /** The scene ids in that order: what the nav, the exports, and the bundle list scenes by. */
655
+ sceneIds: string[];
656
+ /** Each folder's effective parent (undefined = top level), after the forgiving rules. */
657
+ folderParent: Map<string, string | undefined>;
658
+ /** Each scene's effective folder (undefined = top level). */
659
+ sceneFolder: Map<string, string | undefined>;
660
+ }
661
+ /**
662
+ * Lay out the scene list: folders and scenes, nested and ordered. Forgiving, as `sceneOrder` always was:
663
+ * a scene filed in a missing folder, or a folder with a missing parent, sits at the top level; a loop of
664
+ * parents is broken at the first folder of it in `sceneFolders`; ids in `sceneOrder` that are neither
665
+ * are ignored. In each level the rows `sceneOrder` lists come first, in its order, then unlisted scenes in
666
+ * the order given, then unlisted folders in `sceneFolders` order.
667
+ */
668
+ declare function sceneFolderLayout(project: Pick<ProjectFile, "sceneOrder" | "sceneFolders" | "sceneFolder">, sceneIds: readonly string[]): SceneFolderLayout;
669
+ /** A scene's folder path for display ("Act 1 / The docks"), or "" at the top level. */
670
+ declare function sceneFolderPath(project: Pick<ProjectFile, "sceneFolders">, layout: Pick<SceneFolderLayout, "folderParent" | "sceneFolder">, sceneId: string): string;
602
671
  interface ProjectFile {
603
672
  schema: string;
604
673
  root?: boolean;
@@ -619,8 +688,17 @@ interface ProjectFile {
619
688
  };
620
689
  /** The authored scene order (scene ids) for navigation. Scenes not listed follow in file order;
621
690
  * listed ids that no longer exist are ignored. Omitted = plain file order. Presentation only:
622
- * it never affects play, which always starts from `start` / an explicit address. */
691
+ * it never affects play, which always starts from `start` / an explicit address.
692
+ * Holds scene folder ids too (`sceneFolders`): folders and scenes mix in one order, and Patterpad keeps
693
+ * the list equal to the scene list as shown, read top to bottom with every folder open. */
623
694
  sceneOrder?: string[];
695
+ /** Folders for organising the scene list (design/proposals/scene-folders.md). Navigation only, like
696
+ * `sceneOrder`: no file moves, nothing reaches the bundle. The list's own order means nothing; where a
697
+ * folder is shown comes from `sceneOrder`. Omitted = no folders. */
698
+ sceneFolders?: SceneFolder[];
699
+ /** Scene id -> the id of the folder it's filed in. A scene not listed sits at the top level; an entry
700
+ * naming a folder that doesn't exist is ignored. A map, so two people filing different scenes merge. */
701
+ sceneFolder?: Record<string, string>;
624
702
  /** Version-control system (spec §12); omitted = unset / none. */
625
703
  vcs?: VcsKind;
626
704
  /** Project-wide VO mode (spec §16) - one boolean, no per-scene override. */
@@ -704,6 +782,10 @@ interface ProjectFile {
704
782
  /** The project's default `padAfter` for every line and text beat that sets none and has no default above it.
705
783
  * Absent = `DEFAULT_PAD_AFTER`. */
706
784
  padAfterDefault?: number;
785
+ /** How many syllables a second a line with no recording is timed at (`estimateLineDuration`), from 2 to 10.
786
+ * Only estimates use it: a line with a recording lasts as long as the recording. Absent =
787
+ * `DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND`. */
788
+ estimateSyllablesPerSecond?: number;
707
789
  /** Localise text lines in dialogue scenes (design/proposals/action-text.md). Off (absent) by default: a
708
790
  * dialogue scene's text beats (`isDialogueScene`) are then ACTION, left out of the loc files and the
709
791
  * written word counts, and compiled with `action: true`. On: they're localised and shown as a text
@@ -1120,6 +1202,9 @@ interface Bundle {
1120
1202
  speakerPattern?: string;
1121
1203
  /** The project's own `padAfterDefault`, when it sets one; absent = `DEFAULT_PAD_AFTER`. */
1122
1204
  padAfterDefault?: number;
1205
+ /** The project's own `estimateSyllablesPerSecond`, when it sets one; absent =
1206
+ * `DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND`. */
1207
+ estimateSyllablesPerSecond?: number;
1123
1208
  properties?: PropertyDecl[];
1124
1209
  /** Host / world scope declarations, baked from the project so the runtime can self-back a declared
1125
1210
  * scope (`@world`, ...) when no host resolver claims its token. Absent = no host scopes. */
@@ -1235,6 +1320,8 @@ interface SavedChoice {
1235
1320
  /** The flow's execution position: where it is, and what it is waiting on. */
1236
1321
  interface FlowCursor {
1237
1322
  flowEnded: boolean;
1323
+ /** The choice group whose running dry ended the flow (its `end` step's reason "ran-dry"). Present only then. */
1324
+ ranDry?: string;
1238
1325
  currentSceneId: string | null;
1239
1326
  /** The continuation stack (call frames + the active block run), root first. */
1240
1327
  stack: StackFrame[];
@@ -1412,4 +1499,4 @@ interface ExtensionFieldDecl {
1412
1499
  /** A node's extension values in a bundle: extension id -> field -> value, raw. */
1413
1500
  type NodeExtensions = Record<string, Record<string, unknown>>;
1414
1501
 
1415
- export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, LINE_CHARS_PER_SECOND, LINE_DURATION_MAX, LINE_DURATION_MIN, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, estimateLineDuration, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
1502
+ export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, ESTIMATE_SYLLABLES_PER_SECOND_MAX, ESTIMATE_SYLLABLES_PER_SECOND_MIN, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, LINE_DURATION_MAX, LINE_DURATION_MIN, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, SPEECH_DIGIT_WEIGHT, SPEECH_KANJI_WEIGHT, SPEECH_PAUSE_LONG_WEIGHT, SPEECH_PAUSE_SHORT_WEIGHT, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type SceneFolder, type SceneFolderLayout, type SceneNavRow, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type SpeechUnit, type SpeechUnitKind, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, countSyllables, deriveRecordingFolders, effectiveGameId, estimateLineDuration, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, sceneFolderLayout, sceneFolderPath, speakerLabelKey, speechUnits, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,33 @@ import { AstNode } from '@wildwinter/expr';
2
2
  export { RESERVED_PROPERTY_NAMES, isCaseOnlyPropertyName, isValidPropertyName, propertyNameify } from '@wildwinter/expr';
3
3
  export { gameIdify, isValidGameId } from '@wildwinter/toolkit';
4
4
 
5
+ /** What a speech unit is: a syllable (the mouth opens), a beat with the mouth shut (っ), or a pause. */
6
+ type SpeechUnitKind = "syllable" | "closed" | "pause";
7
+ /** One unit of a line as it would be spoken. `start` and `end` are code-point offsets into the text, end exclusive. */
8
+ interface SpeechUnit {
9
+ kind: SpeechUnitKind;
10
+ weight: number;
11
+ start: number;
12
+ end: number;
13
+ }
14
+ /** A digit's weight: most read as one or two syllables. */
15
+ declare const SPEECH_DIGIT_WEIGHT = 1.5;
16
+ /** A Han character's weight in Japanese text. */
17
+ declare const SPEECH_KANJI_WEIGHT = 2;
18
+ /** A short pause's weight (`,` `;` `、`), and a long one's (`.` `?` `。`). */
19
+ declare const SPEECH_PAUSE_SHORT_WEIGHT = 1;
20
+ declare const SPEECH_PAUSE_LONG_WEIGHT = 2;
21
+ /**
22
+ * A line broken into the units it would be spoken in: its syllables, its beats with the mouth shut, and its pauses,
23
+ * in order, each with a weight. `locale` is the language the line is spoken in (the project's main language, not the
24
+ * one being shown); it decides English's and French's silent e, and Japanese kanji, which also apply when the line
25
+ * has any kana in it.
26
+ */
27
+ declare function speechUnits(text: string, locale?: string): SpeechUnit[];
28
+ /** How many syllables a line would be spoken in: its syllables' and shut beats' weights, pauses aside. `locale` is
29
+ * the language it's spoken in, as for `speechUnits`. */
30
+ declare function countSyllables(text: string, locale?: string): number;
31
+
5
32
  type ScalarValue = boolean | number | string | string[];
6
33
  /** Developer-defined host metadata (spec §17). Opaque to Patter. */
7
34
  type GameData = Record<string, unknown>;
@@ -431,17 +458,22 @@ declare const DEFAULT_PAD_AFTER = 0.6;
431
458
  /** The range validation keeps a `padAfter` or `padAfterDefault` within, in seconds. */
432
459
  declare const PAD_AFTER_MIN = -10;
433
460
  declare const PAD_AFTER_MAX = 60;
434
- /** The reading rate a line with no recording is timed by, in characters a second (`estimateLineDuration`). */
435
- declare const LINE_CHARS_PER_SECOND = 14;
461
+ /** How many syllables a second a line with no recording is timed at, unless the project sets its own
462
+ * (`estimateSyllablesPerSecond`), and the range validation keeps a project's within. */
463
+ declare const DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND = 4;
464
+ declare const ESTIMATE_SYLLABLES_PER_SECOND_MIN = 2;
465
+ declare const ESTIMATE_SYLLABLES_PER_SECOND_MAX = 10;
436
466
  /** The shortest and longest a line with no recording lasts, in seconds (`estimateLineDuration`). */
437
467
  declare const LINE_DURATION_MIN = 1.5;
438
468
  declare const LINE_DURATION_MAX = 18;
439
- /** How long a line with no recording lasts, in seconds: its characters at 14 a second, clamped to 1.5 to 18
440
- * seconds. A character is a Unicode code point (one outside the Basic Multilingual Plane counts once), and soft
441
- * hyphens (U+00AD) aren't counted. This is the one rule every Patter tool and runtime times a line by: Patterpad's
442
- * Play window, the playable HTML page, and the Unity, Unreal, and Godot runtimes, which the conformance corpus
443
- * holds to the same numbers. `locale` is reserved for per-language reading rates and is unused for now. */
444
- declare function estimateLineDuration(text: string, _locale?: string): number;
469
+ /** How long a line with no recording lasts, in seconds: the total weight of its speech units (its syllables and its
470
+ * pauses, `speechUnits`) at `syllablesPerSecond` (default 4, the project's `estimateSyllablesPerSecond` when it
471
+ * sets one), clamped to 1.5 to 18 seconds. `text` and `locale` are the line as it's spoken, in the project's main
472
+ * language (a line result's `spokenText` and `spokenLocale`), never a translation being shown. This is the one
473
+ * rule every Patter tool and runtime times a line by: Patterpad's Play window, the playable HTML page, and the
474
+ * Unity, Unreal, and Godot runtimes, which the conformance corpus holds to the same numbers. A rate that isn't a
475
+ * positive number is the default. A line with a recording lasts as long as the recording, whatever this says. */
476
+ declare function estimateLineDuration(text: string, locale?: string, syllablesPerSecond?: number): number;
445
477
  /** A qualifier as it reaches a compiled bundle: its `gameId` and authored name (the unlocalised fallback). */
446
478
  interface BundleQualifier {
447
479
  gameId: string;
@@ -599,6 +631,43 @@ interface EstimatingConfig {
599
631
  lines: number;
600
632
  }[];
601
633
  }
634
+ /** A folder in the scene list (ProjectFile.sceneFolders): organisational only, it carries no meaning. */
635
+ interface SceneFolder {
636
+ id: string;
637
+ name: string;
638
+ /** The folder it sits in; omitted = the top level. A parent that doesn't exist, or a loop of parents
639
+ * (only a bad merge makes one), reads as the top level. */
640
+ parent?: string;
641
+ }
642
+ /** One row of the scene list as laid out by `sceneFolderLayout`, top to bottom with every folder open. */
643
+ interface SceneNavRow {
644
+ kind: "folder" | "scene";
645
+ id: string;
646
+ /** 0 = the top level. */
647
+ depth: number;
648
+ /** The folder this row sits in, if any. */
649
+ folder?: string;
650
+ }
651
+ interface SceneFolderLayout {
652
+ /** Every folder and scene, depth first, in authored order. */
653
+ rows: SceneNavRow[];
654
+ /** The scene ids in that order: what the nav, the exports, and the bundle list scenes by. */
655
+ sceneIds: string[];
656
+ /** Each folder's effective parent (undefined = top level), after the forgiving rules. */
657
+ folderParent: Map<string, string | undefined>;
658
+ /** Each scene's effective folder (undefined = top level). */
659
+ sceneFolder: Map<string, string | undefined>;
660
+ }
661
+ /**
662
+ * Lay out the scene list: folders and scenes, nested and ordered. Forgiving, as `sceneOrder` always was:
663
+ * a scene filed in a missing folder, or a folder with a missing parent, sits at the top level; a loop of
664
+ * parents is broken at the first folder of it in `sceneFolders`; ids in `sceneOrder` that are neither
665
+ * are ignored. In each level the rows `sceneOrder` lists come first, in its order, then unlisted scenes in
666
+ * the order given, then unlisted folders in `sceneFolders` order.
667
+ */
668
+ declare function sceneFolderLayout(project: Pick<ProjectFile, "sceneOrder" | "sceneFolders" | "sceneFolder">, sceneIds: readonly string[]): SceneFolderLayout;
669
+ /** A scene's folder path for display ("Act 1 / The docks"), or "" at the top level. */
670
+ declare function sceneFolderPath(project: Pick<ProjectFile, "sceneFolders">, layout: Pick<SceneFolderLayout, "folderParent" | "sceneFolder">, sceneId: string): string;
602
671
  interface ProjectFile {
603
672
  schema: string;
604
673
  root?: boolean;
@@ -619,8 +688,17 @@ interface ProjectFile {
619
688
  };
620
689
  /** The authored scene order (scene ids) for navigation. Scenes not listed follow in file order;
621
690
  * listed ids that no longer exist are ignored. Omitted = plain file order. Presentation only:
622
- * it never affects play, which always starts from `start` / an explicit address. */
691
+ * it never affects play, which always starts from `start` / an explicit address.
692
+ * Holds scene folder ids too (`sceneFolders`): folders and scenes mix in one order, and Patterpad keeps
693
+ * the list equal to the scene list as shown, read top to bottom with every folder open. */
623
694
  sceneOrder?: string[];
695
+ /** Folders for organising the scene list (design/proposals/scene-folders.md). Navigation only, like
696
+ * `sceneOrder`: no file moves, nothing reaches the bundle. The list's own order means nothing; where a
697
+ * folder is shown comes from `sceneOrder`. Omitted = no folders. */
698
+ sceneFolders?: SceneFolder[];
699
+ /** Scene id -> the id of the folder it's filed in. A scene not listed sits at the top level; an entry
700
+ * naming a folder that doesn't exist is ignored. A map, so two people filing different scenes merge. */
701
+ sceneFolder?: Record<string, string>;
624
702
  /** Version-control system (spec §12); omitted = unset / none. */
625
703
  vcs?: VcsKind;
626
704
  /** Project-wide VO mode (spec §16) - one boolean, no per-scene override. */
@@ -704,6 +782,10 @@ interface ProjectFile {
704
782
  /** The project's default `padAfter` for every line and text beat that sets none and has no default above it.
705
783
  * Absent = `DEFAULT_PAD_AFTER`. */
706
784
  padAfterDefault?: number;
785
+ /** How many syllables a second a line with no recording is timed at (`estimateLineDuration`), from 2 to 10.
786
+ * Only estimates use it: a line with a recording lasts as long as the recording. Absent =
787
+ * `DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND`. */
788
+ estimateSyllablesPerSecond?: number;
707
789
  /** Localise text lines in dialogue scenes (design/proposals/action-text.md). Off (absent) by default: a
708
790
  * dialogue scene's text beats (`isDialogueScene`) are then ACTION, left out of the loc files and the
709
791
  * written word counts, and compiled with `action: true`. On: they're localised and shown as a text
@@ -1120,6 +1202,9 @@ interface Bundle {
1120
1202
  speakerPattern?: string;
1121
1203
  /** The project's own `padAfterDefault`, when it sets one; absent = `DEFAULT_PAD_AFTER`. */
1122
1204
  padAfterDefault?: number;
1205
+ /** The project's own `estimateSyllablesPerSecond`, when it sets one; absent =
1206
+ * `DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND`. */
1207
+ estimateSyllablesPerSecond?: number;
1123
1208
  properties?: PropertyDecl[];
1124
1209
  /** Host / world scope declarations, baked from the project so the runtime can self-back a declared
1125
1210
  * scope (`@world`, ...) when no host resolver claims its token. Absent = no host scopes. */
@@ -1235,6 +1320,8 @@ interface SavedChoice {
1235
1320
  /** The flow's execution position: where it is, and what it is waiting on. */
1236
1321
  interface FlowCursor {
1237
1322
  flowEnded: boolean;
1323
+ /** The choice group whose running dry ended the flow (its `end` step's reason "ran-dry"). Present only then. */
1324
+ ranDry?: string;
1238
1325
  currentSceneId: string | null;
1239
1326
  /** The continuation stack (call frames + the active block run), root first. */
1240
1327
  stack: StackFrame[];
@@ -1412,4 +1499,4 @@ interface ExtensionFieldDecl {
1412
1499
  /** A node's extension values in a bundle: extension id -> field -> value, raw. */
1413
1500
  type NodeExtensions = Record<string, Record<string, unknown>>;
1414
1501
 
1415
- export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, LINE_CHARS_PER_SECOND, LINE_DURATION_MAX, LINE_DURATION_MIN, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, estimateLineDuration, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
1502
+ export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, COMMON_GENDERS, type CaptionDelimiters, type CastMember, type Comment, type CommentMessage, type CommentRange, type CompiledBlock, type CompiledEffect, type CompiledGroup, type CompiledScene, type CompiledSnippet, type CoverageDriver, DEFAULT_CAPTION_CHARACTER, DEFAULT_CAPTION_DELIMITERS, DEFAULT_DOCUMENTATION_CLASSES, DEFAULT_ESTIMATE_SYLLABLES_PER_SECOND, DEFAULT_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, ESTIMATE_SYLLABLES_PER_SECOND_MAX, ESTIMATE_SYLLABLES_PER_SECOND_MIN, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, LINE_DURATION_MAX, LINE_DURATION_MIN, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, SPEECH_DIGIT_WEIGHT, SPEECH_KANJI_WEIGHT, SPEECH_PAUSE_LONG_WEIGHT, SPEECH_PAUSE_SHORT_WEIGHT, STRINGS_SCHEMA, type SaveEnvelope, type SaveGame, type SaveGameV3, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type SceneFolder, type SceneFolderLayout, type SceneNavRow, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type SpeakerQualifier, type SpeechUnit, type SpeechUnitKind, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, countSyllables, deriveRecordingFolders, effectiveGameId, estimateLineDuration, formatSpeakerLabel, isContentlessBeat, isDialogueScene, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, sceneFolderLayout, sceneFolderPath, speakerLabelKey, speechUnits, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };