@patterkit/runtime 0.4.5 → 0.5.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
@@ -439,6 +439,23 @@ declare class Engine {
439
439
  tagsForScene(sceneRef: string): string[];
440
440
  /** A block's accumulated tags (scene + block), by scene + block ref (id or gameId). Empty when none / unknown. */
441
441
  tagsForBlock(sceneRef: string, blockRef: string): string[];
442
+ /**
443
+ * Every cast member the PROJECT declares, in authored order - the same list `describeBundle` counts.
444
+ * A superset of any scene's cast: the validator holds a beat's `character` to a declared member, so
445
+ * {@link castForScene} and {@link castForBlock} only ever return names that appear here.
446
+ */
447
+ getCast(): string[];
448
+ /**
449
+ * A scene's cast: the `character` token of every speaker with a line anywhere in it, deduped, in
450
+ * first-appearance order. Static, like {@link getOutline}: it walks the authored structure, so a
451
+ * speaker behind a condition, inside any group, or voicing a choice prompt counts - this is who CAN
452
+ * speak in the scene, not who a given playthrough heard. Empty for an unknown ref, or a scene with no
453
+ * dialogue. Tokens, not display names: resolve those through the delivered step (`characterName`),
454
+ * which is what follows `setLocale`.
455
+ */
456
+ castForScene(sceneRef: string): string[];
457
+ /** One block's cast, by scene + block ref (id or gameId). {@link castForScene} scoped to a block. */
458
+ castForBlock(sceneRef: string, blockRef: string): string[];
442
459
  /**
443
460
  * The authored structure as a nested tree: scenes -> blocks -> children (groups + snippets, groups
444
461
  * preserved) -> a snippet's beats. Static (no flow / play state); per-beat data is read at the source
package/dist/index.d.ts CHANGED
@@ -439,6 +439,23 @@ declare class Engine {
439
439
  tagsForScene(sceneRef: string): string[];
440
440
  /** A block's accumulated tags (scene + block), by scene + block ref (id or gameId). Empty when none / unknown. */
441
441
  tagsForBlock(sceneRef: string, blockRef: string): string[];
442
+ /**
443
+ * Every cast member the PROJECT declares, in authored order - the same list `describeBundle` counts.
444
+ * A superset of any scene's cast: the validator holds a beat's `character` to a declared member, so
445
+ * {@link castForScene} and {@link castForBlock} only ever return names that appear here.
446
+ */
447
+ getCast(): string[];
448
+ /**
449
+ * A scene's cast: the `character` token of every speaker with a line anywhere in it, deduped, in
450
+ * first-appearance order. Static, like {@link getOutline}: it walks the authored structure, so a
451
+ * speaker behind a condition, inside any group, or voicing a choice prompt counts - this is who CAN
452
+ * speak in the scene, not who a given playthrough heard. Empty for an unknown ref, or a scene with no
453
+ * dialogue. Tokens, not display names: resolve those through the delivered step (`characterName`),
454
+ * which is what follows `setLocale`.
455
+ */
456
+ castForScene(sceneRef: string): string[];
457
+ /** One block's cast, by scene + block ref (id or gameId). {@link castForScene} scoped to a block. */
458
+ castForBlock(sceneRef: string, blockRef: string): string[];
442
459
  /**
443
460
  * The authored structure as a nested tree: scenes -> blocks -> children (groups + snippets, groups
444
461
  * preserved) -> a snippet's beats. Static (no flow / play state); per-beat data is read at the source
package/dist/index.js CHANGED
@@ -328,6 +328,42 @@ var Engine = class _Engine {
328
328
  const id = this.resolveBlockRef(sceneId, blockRef);
329
329
  return (id != null ? this.host.tagIndex.get(id) : void 0) ?? [];
330
330
  }
331
+ /**
332
+ * Every cast member the PROJECT declares, in authored order - the same list `describeBundle` counts.
333
+ * A superset of any scene's cast: the validator holds a beat's `character` to a declared member, so
334
+ * {@link castForScene} and {@link castForBlock} only ever return names that appear here.
335
+ */
336
+ getCast() {
337
+ const names = [];
338
+ for (const c of this.host.bundle.cast ?? []) if (c?.name) names.push(c.name);
339
+ return names;
340
+ }
341
+ /**
342
+ * A scene's cast: the `character` token of every speaker with a line anywhere in it, deduped, in
343
+ * first-appearance order. Static, like {@link getOutline}: it walks the authored structure, so a
344
+ * speaker behind a condition, inside any group, or voicing a choice prompt counts - this is who CAN
345
+ * speak in the scene, not who a given playthrough heard. Empty for an unknown ref, or a scene with no
346
+ * dialogue. Tokens, not display names: resolve those through the delivered step (`characterName`),
347
+ * which is what follows `setLocale`.
348
+ */
349
+ castForScene(sceneRef) {
350
+ const id = this.resolveSceneRef(sceneRef);
351
+ const scene = id != null ? this.host.bundle.scenes[id] : void 0;
352
+ if (!scene) return [];
353
+ const out = /* @__PURE__ */ new Set();
354
+ for (const block of scene.blocks) collectCast(block.children, out);
355
+ return [...out];
356
+ }
357
+ /** One block's cast, by scene + block ref (id or gameId). {@link castForScene} scoped to a block. */
358
+ castForBlock(sceneRef, blockRef) {
359
+ const sceneId = this.resolveSceneRef(sceneRef);
360
+ const id = this.resolveBlockRef(sceneId, blockRef);
361
+ const block = id != null ? this.host.blockById.get(id) : void 0;
362
+ if (!block) return [];
363
+ const out = /* @__PURE__ */ new Set();
364
+ collectCast(block.children, out);
365
+ return [...out];
366
+ }
331
367
  /**
332
368
  * The authored structure as a nested tree: scenes -> blocks -> children (groups + snippets, groups
333
369
  * preserved) -> a snippet's beats. Static (no flow / play state); per-beat data is read at the source
@@ -1321,6 +1357,15 @@ var Flow = class {
1321
1357
  }
1322
1358
  }
1323
1359
  };
1360
+ function collectCast(nodes, out) {
1361
+ walkNodes(nodes, (n) => {
1362
+ if (n.type === "group") {
1363
+ if (n.prompt?.kind === "line" && n.prompt.character) out.add(n.prompt.character);
1364
+ return;
1365
+ }
1366
+ for (const beat of n.beats ?? []) if (beat.kind === "line" && beat.character) out.add(beat.character);
1367
+ });
1368
+ }
1324
1369
  function serialiseSelectors(map) {
1325
1370
  const out = {};
1326
1371
  for (const [id, st] of map) {