@patterkit/runtime 0.21.0 → 0.22.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
@@ -14,6 +14,8 @@ type StepResult = {
14
14
  character?: string;
15
15
  characterName?: string;
16
16
  direction?: string;
17
+ qualifier?: string;
18
+ qualifierName?: string;
17
19
  gameData?: GameData;
18
20
  tags?: string[];
19
21
  } | {
@@ -44,6 +46,10 @@ interface BeatInfo {
44
46
  characterName?: string;
45
47
  /** Performance direction (line only). */
46
48
  direction?: string;
49
+ /** Speaker qualifier `gameId` (line only), e.g. `vo`. */
50
+ qualifier?: string;
51
+ /** The qualifier's shown name (source locale), e.g. `V.O.`. */
52
+ qualifierName?: string;
47
53
  /** Source text, un-interpolated (line / text). Omitted for gameEvent and IDs-only bundles. */
48
54
  text?: string;
49
55
  /** Author gameData overrides on this beat (raw, as the step carries them). Omitted when empty. */
@@ -111,6 +117,9 @@ interface ChoicePrompt {
111
117
  /** The speaker's resolved player-facing name (locale-aware; absent when the character has none). */
112
118
  characterName?: string;
113
119
  direction?: string;
120
+ /** The speaker qualifier's `gameId` (`vo`), and its resolved shown name (locale-aware). */
121
+ qualifier?: string;
122
+ qualifierName?: string;
114
123
  }
115
124
  /** A single option of a pending `choice` group. */
116
125
  interface ChoiceOption {
@@ -352,6 +361,8 @@ interface FlowHost {
352
361
  defaultStrings: Record<string, string>;
353
362
  /** Cast canonical name -> authoring `displayName` (the unlocalised fallback when no loc string exists). */
354
363
  castDisplay: Map<string, string>;
364
+ /** Speaker qualifier gameId -> authored name (the unlocalised fallback when no loc string exists). */
365
+ qualifierDisplay: Map<string, string>;
355
366
  nodeIndex: Map<string, SelectableNode>;
356
367
  blockIndex: Map<string, {
357
368
  sceneId: string;
@@ -994,6 +1005,10 @@ declare class Flow {
994
1005
  * locale, else the authoring `displayName`. Undefined when the character has no display name at all
995
1006
  * (the host falls back to the `character` token itself). */
996
1007
  private resolveCharacterName;
1008
+ /** A speaker qualifier's shown name, resolved as a character's is: the `qualifier:<gameId>` string in the
1009
+ * active locale, else the default locale, else the authored name. Undefined in IDs-only mode (the game
1010
+ * maps the `qualifier` gameId itself). */
1011
+ private resolveQualifierName;
997
1012
  /** Split a ref into scope + name. Tokens: `@scene`, registered tokens, else `@patter` (incl. bare `@name`). */
998
1013
  private splitRef;
999
1014
  /** A fresh, unregistered bag for the NOT-shared `@patter` globals (the shared ones live on the host). */
package/dist/index.d.ts CHANGED
@@ -14,6 +14,8 @@ type StepResult = {
14
14
  character?: string;
15
15
  characterName?: string;
16
16
  direction?: string;
17
+ qualifier?: string;
18
+ qualifierName?: string;
17
19
  gameData?: GameData;
18
20
  tags?: string[];
19
21
  } | {
@@ -44,6 +46,10 @@ interface BeatInfo {
44
46
  characterName?: string;
45
47
  /** Performance direction (line only). */
46
48
  direction?: string;
49
+ /** Speaker qualifier `gameId` (line only), e.g. `vo`. */
50
+ qualifier?: string;
51
+ /** The qualifier's shown name (source locale), e.g. `V.O.`. */
52
+ qualifierName?: string;
47
53
  /** Source text, un-interpolated (line / text). Omitted for gameEvent and IDs-only bundles. */
48
54
  text?: string;
49
55
  /** Author gameData overrides on this beat (raw, as the step carries them). Omitted when empty. */
@@ -111,6 +117,9 @@ interface ChoicePrompt {
111
117
  /** The speaker's resolved player-facing name (locale-aware; absent when the character has none). */
112
118
  characterName?: string;
113
119
  direction?: string;
120
+ /** The speaker qualifier's `gameId` (`vo`), and its resolved shown name (locale-aware). */
121
+ qualifier?: string;
122
+ qualifierName?: string;
114
123
  }
115
124
  /** A single option of a pending `choice` group. */
116
125
  interface ChoiceOption {
@@ -352,6 +361,8 @@ interface FlowHost {
352
361
  defaultStrings: Record<string, string>;
353
362
  /** Cast canonical name -> authoring `displayName` (the unlocalised fallback when no loc string exists). */
354
363
  castDisplay: Map<string, string>;
364
+ /** Speaker qualifier gameId -> authored name (the unlocalised fallback when no loc string exists). */
365
+ qualifierDisplay: Map<string, string>;
355
366
  nodeIndex: Map<string, SelectableNode>;
356
367
  blockIndex: Map<string, {
357
368
  sceneId: string;
@@ -994,6 +1005,10 @@ declare class Flow {
994
1005
  * locale, else the authoring `displayName`. Undefined when the character has no display name at all
995
1006
  * (the host falls back to the `character` token itself). */
996
1007
  private resolveCharacterName;
1008
+ /** A speaker qualifier's shown name, resolved as a character's is: the `qualifier:<gameId>` string in the
1009
+ * active locale, else the default locale, else the authored name. Undefined in IDs-only mode (the game
1010
+ * maps the `qualifier` gameId itself). */
1011
+ private resolveQualifierName;
997
1012
  /** Split a ref into scope + name. Tokens: `@scene`, registered tokens, else `@patter` (incl. bare `@name`). */
998
1013
  private splitRef;
999
1014
  /** A fresh, unregistered bag for the NOT-shared `@patter` globals (the shared ones live on the host). */
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { matchedSpecificity as scoreSpecificity } from "@wildwinter/expr-specifi
4
4
  import { ScopeRegistry } from "@wildwinter/scoperegistry";
5
5
  import { defaultFor, PropertyBag } from "@wildwinter/scoperegistry";
6
6
  import { patterDialect, interpolate, splitRef, stripCaptions } from "@patterkit/dialect";
7
- import { walkNodes, effectiveGameId, castStringKey, DEFAULT_CAPTION_DELIMITERS, DEFAULT_CAPTION_CHARACTER } from "@patterkit/model";
7
+ import { walkNodes, effectiveGameId, castStringKey, qualifierStringKey, DEFAULT_CAPTION_DELIMITERS, DEFAULT_CAPTION_CHARACTER } from "@patterkit/model";
8
8
 
9
9
  // src/tags.ts
10
10
  function dedupe(tags) {
@@ -117,6 +117,8 @@ var Engine = class _Engine {
117
117
  }
118
118
  const castDisplay = /* @__PURE__ */ new Map();
119
119
  for (const c of bundle.cast ?? []) if (c.displayName) castDisplay.set(c.name, c.displayName);
120
+ const qualifierDisplay = /* @__PURE__ */ new Map();
121
+ for (const q of bundle.qualifiers ?? []) if (q?.gameId) qualifierDisplay.set(q.gameId, q.name);
120
122
  this.defaultSeed = (options.seed ?? 2654435769) >>> 0;
121
123
  const nodeIndex = /* @__PURE__ */ new Map();
122
124
  const blockIndex = /* @__PURE__ */ new Map();
@@ -177,6 +179,7 @@ var Engine = class _Engine {
177
179
  strings,
178
180
  defaultStrings,
179
181
  castDisplay,
182
+ qualifierDisplay,
180
183
  nodeIndex,
181
184
  blockIndex,
182
185
  blockById,
@@ -581,6 +584,11 @@ var Engine = class _Engine {
581
584
  if (name !== void 0) info.characterName = name;
582
585
  }
583
586
  if (beat.direction !== void 0) info.direction = beat.direction;
587
+ if (beat.qualifier !== void 0) {
588
+ info.qualifier = beat.qualifier;
589
+ const name = this.host.defaultStrings[qualifierStringKey(beat.qualifier)] ?? this.host.qualifierDisplay.get(beat.qualifier);
590
+ if (name !== void 0) info.qualifierName = name;
591
+ }
584
592
  }
585
593
  if (beat.kind === "line" || beat.kind === "text") {
586
594
  const source = this.host.defaultStrings[beat.id];
@@ -1769,6 +1777,8 @@ var Flow = class {
1769
1777
  character: silent ? void 0 : beat.character,
1770
1778
  characterName: silent ? void 0 : this.resolveCharacterName(beat.character),
1771
1779
  direction: silent ? void 0 : beat.direction,
1780
+ qualifier: silent ? void 0 : beat.qualifier,
1781
+ qualifierName: silent ? void 0 : this.resolveQualifierName(beat.qualifier),
1772
1782
  gameData: beat.gameData,
1773
1783
  ...withTags
1774
1784
  };
@@ -1807,7 +1817,15 @@ var Flow = class {
1807
1817
  const beat = this.promptBeatOf(node);
1808
1818
  if (!beat) return void 0;
1809
1819
  const text = this.interpolate(this.resolveString(beat.id));
1810
- return beat.kind === "line" ? { kind: "line", text: this.captionLine(text), character: beat.character, characterName: this.resolveCharacterName(beat.character), direction: beat.direction } : { kind: "text", text };
1820
+ return beat.kind === "line" ? {
1821
+ kind: "line",
1822
+ text: this.captionLine(text),
1823
+ character: beat.character,
1824
+ characterName: this.resolveCharacterName(beat.character),
1825
+ direction: beat.direction,
1826
+ qualifier: beat.qualifier,
1827
+ qualifierName: this.resolveQualifierName(beat.qualifier)
1828
+ } : { kind: "text", text };
1811
1829
  }
1812
1830
  /** An option's AUTHORED prompt beat: an Option group's own `prompt`. The only prompt a replay speaks. */
1813
1831
  authoredPromptOf(node) {
@@ -1826,6 +1844,8 @@ var Flow = class {
1826
1844
  character: shown.character,
1827
1845
  characterName: shown.characterName,
1828
1846
  direction: shown.direction,
1847
+ qualifier: shown.qualifier,
1848
+ qualifierName: shown.qualifierName,
1829
1849
  gameData: beat.gameData,
1830
1850
  ...withTags
1831
1851
  };
@@ -1862,6 +1882,15 @@ var Flow = class {
1862
1882
  const key = castStringKey(character);
1863
1883
  return this.host.strings[key] ?? this.host.defaultStrings[key] ?? this.host.castDisplay.get(character);
1864
1884
  }
1885
+ /** A speaker qualifier's shown name, resolved as a character's is: the `qualifier:<gameId>` string in the
1886
+ * active locale, else the default locale, else the authored name. Undefined in IDs-only mode (the game
1887
+ * maps the `qualifier` gameId itself). */
1888
+ resolveQualifierName(qualifier) {
1889
+ if (qualifier === void 0) return void 0;
1890
+ if (this.host.emitIds) return void 0;
1891
+ const key = qualifierStringKey(qualifier);
1892
+ return this.host.strings[key] ?? this.host.defaultStrings[key] ?? this.host.qualifierDisplay.get(qualifier);
1893
+ }
1865
1894
  /** Split a ref into scope + name. Tokens: `@scene`, registered tokens, else `@patter` (incl. bare `@name`). */
1866
1895
  splitRef(ref) {
1867
1896
  return splitHostRef(this.host, ref);
@@ -1958,6 +1987,8 @@ function savedPrompt(p) {
1958
1987
  if (p.character !== void 0) out.character = p.character;
1959
1988
  if (p.characterName !== void 0) out.characterName = p.characterName;
1960
1989
  if (p.direction !== void 0) out.direction = p.direction;
1990
+ if (p.qualifier !== void 0) out.qualifier = p.qualifier;
1991
+ if (p.qualifierName !== void 0) out.qualifierName = p.qualifierName;
1961
1992
  return out;
1962
1993
  }
1963
1994
  function serialiseSelectors(map) {