@patterkit/runtime 0.14.2 → 0.15.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
@@ -69,6 +69,8 @@ interface OutlineBlock {
69
69
  id: string;
70
70
  gameId?: string;
71
71
  name: string;
72
+ /** The block's own author gameData overrides (raw, not merged with defaults). Omitted when empty. */
73
+ gameData?: GameData;
72
74
  tags?: string[];
73
75
  children: OutlineNode[];
74
76
  }
@@ -77,6 +79,8 @@ interface OutlineScene {
77
79
  id: string;
78
80
  gameId?: string;
79
81
  name: string;
82
+ /** The scene's own author gameData overrides (raw, not merged with defaults). Omitted when empty. */
83
+ gameData?: GameData;
80
84
  tags?: string[];
81
85
  blocks: OutlineBlock[];
82
86
  }
@@ -483,6 +487,16 @@ declare class Engine {
483
487
  tagsForScene(sceneRef: string): string[];
484
488
  /** A block's accumulated tags (scene + block), by scene + block ref (id or gameId). Empty when none / unknown. */
485
489
  tagsForBlock(sceneRef: string, blockRef: string): string[];
490
+ /**
491
+ * A scene's own author gameData (by internal id or gameId address): the RAW sparse overrides, exactly
492
+ * as a beat's step carries its own, not merged with the project's declared field defaults (resolve
493
+ * those with `effectiveGameData(gameDataFields(bundle, "scene"), ...)`). Not inherited by its blocks.
494
+ * A fresh object each call; empty when the scene sets none or the ref is unknown.
495
+ */
496
+ gameDataForScene(sceneRef: string): GameData;
497
+ /** A block's own author gameData, by scene + block ref (id or gameId). Raw overrides, like
498
+ * {@link gameDataForScene}; the scene's gameData is not folded in. Empty when none / unknown. */
499
+ gameDataForBlock(sceneRef: string, blockRef: string): GameData;
486
500
  /**
487
501
  * Every cast member the PROJECT declares, in authored order - the same list `describeBundle` counts.
488
502
  * A superset of any scene's cast: the validator holds a beat's `character` to a declared member, so
package/dist/index.d.ts CHANGED
@@ -69,6 +69,8 @@ interface OutlineBlock {
69
69
  id: string;
70
70
  gameId?: string;
71
71
  name: string;
72
+ /** The block's own author gameData overrides (raw, not merged with defaults). Omitted when empty. */
73
+ gameData?: GameData;
72
74
  tags?: string[];
73
75
  children: OutlineNode[];
74
76
  }
@@ -77,6 +79,8 @@ interface OutlineScene {
77
79
  id: string;
78
80
  gameId?: string;
79
81
  name: string;
82
+ /** The scene's own author gameData overrides (raw, not merged with defaults). Omitted when empty. */
83
+ gameData?: GameData;
80
84
  tags?: string[];
81
85
  blocks: OutlineBlock[];
82
86
  }
@@ -483,6 +487,16 @@ declare class Engine {
483
487
  tagsForScene(sceneRef: string): string[];
484
488
  /** A block's accumulated tags (scene + block), by scene + block ref (id or gameId). Empty when none / unknown. */
485
489
  tagsForBlock(sceneRef: string, blockRef: string): string[];
490
+ /**
491
+ * A scene's own author gameData (by internal id or gameId address): the RAW sparse overrides, exactly
492
+ * as a beat's step carries its own, not merged with the project's declared field defaults (resolve
493
+ * those with `effectiveGameData(gameDataFields(bundle, "scene"), ...)`). Not inherited by its blocks.
494
+ * A fresh object each call; empty when the scene sets none or the ref is unknown.
495
+ */
496
+ gameDataForScene(sceneRef: string): GameData;
497
+ /** A block's own author gameData, by scene + block ref (id or gameId). Raw overrides, like
498
+ * {@link gameDataForScene}; the scene's gameData is not folded in. Empty when none / unknown. */
499
+ gameDataForBlock(sceneRef: string, blockRef: string): GameData;
486
500
  /**
487
501
  * Every cast member the PROJECT declares, in authored order - the same list `describeBundle` counts.
488
502
  * A superset of any scene's cast: the validator holds a beat's `character` to a declared member, so
package/dist/index.js CHANGED
@@ -388,6 +388,24 @@ var Engine = class _Engine {
388
388
  const id = this.resolveBlockRef(sceneId, blockRef);
389
389
  return (id != null ? this.host.tagIndex.get(id) : void 0) ?? [];
390
390
  }
391
+ /**
392
+ * A scene's own author gameData (by internal id or gameId address): the RAW sparse overrides, exactly
393
+ * as a beat's step carries its own, not merged with the project's declared field defaults (resolve
394
+ * those with `effectiveGameData(gameDataFields(bundle, "scene"), ...)`). Not inherited by its blocks.
395
+ * A fresh object each call; empty when the scene sets none or the ref is unknown.
396
+ */
397
+ gameDataForScene(sceneRef) {
398
+ const id = this.resolveSceneRef(sceneRef);
399
+ const scene = id != null ? this.host.bundle.scenes[id] : void 0;
400
+ return { ...scene?.gameData };
401
+ }
402
+ /** A block's own author gameData, by scene + block ref (id or gameId). Raw overrides, like
403
+ * {@link gameDataForScene}; the scene's gameData is not folded in. Empty when none / unknown. */
404
+ gameDataForBlock(sceneRef, blockRef) {
405
+ const id = this.resolveBlockRef(this.resolveSceneRef(sceneRef), blockRef);
406
+ const block = id != null ? this.host.blockById.get(id) : void 0;
407
+ return { ...block?.gameData };
408
+ }
391
409
  /**
392
410
  * Every cast member the PROJECT declares, in authored order - the same list `describeBundle` counts.
393
411
  * A superset of any scene's cast: the validator holds a beat's `character` to a declared member, so
@@ -434,11 +452,13 @@ var Engine = class _Engine {
434
452
  id: scene.id,
435
453
  ...effectiveGameId(scene) ? { gameId: effectiveGameId(scene) } : {},
436
454
  name: scene.name,
455
+ ...gameDataField(scene.gameData),
437
456
  ...this.tagsField(scene.id),
438
457
  blocks: scene.blocks.map((block) => ({
439
458
  id: block.id,
440
459
  ...effectiveGameId(block) ? { gameId: effectiveGameId(block) } : {},
441
460
  name: block.name,
461
+ ...gameDataField(block.gameData),
442
462
  ...this.tagsField(block.id),
443
463
  children: block.children.map((n) => this.outlineNode(n))
444
464
  }))
@@ -1641,6 +1661,9 @@ function collectCast(nodes, out) {
1641
1661
  for (const beat of n.beats ?? []) if (beat.kind === "line" && beat.character) out.add(beat.character);
1642
1662
  });
1643
1663
  }
1664
+ function gameDataField(gameData) {
1665
+ return gameData && Object.keys(gameData).length ? { gameData } : {};
1666
+ }
1644
1667
  function serialiseSelectors(map) {
1645
1668
  const out = {};
1646
1669
  for (const [id, st] of map) {