@patterkit/model 0.5.0 → 0.7.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.cjs CHANGED
@@ -116,7 +116,7 @@ function castStringKey(name) {
116
116
  var DEFAULT_CAPTION_DELIMITERS = { open: "[", close: "]" };
117
117
  var DEFAULT_CAPTION_CHARACTER = "SFX";
118
118
  var SAVE_SCHEMA = "patter/save@0";
119
- var SAVE_VERSION = 2;
119
+ var SAVE_VERSION = 3;
120
120
  // Annotate the CommonJS export names for ESM import in node:
121
121
  0 && (module.exports = {
122
122
  COMMON_GENDERS,
package/dist/index.d.cts CHANGED
@@ -554,6 +554,12 @@ interface ProjectFile {
554
554
  * resolver is bound, and coverage drives their values. Omitted = no host scopes (`@world.x` is then a
555
555
  * compile error). See design/scope-registry.md §6. */
556
556
  scopeRegistry?: HostScopeRegistry;
557
+ /** Where the game's shared scopes folder is, relative to this project file's folder
558
+ * (`"../../shared/game-scopes"`), for a folder the walk-up would not find. Omitted = walk up from the
559
+ * project to the first `game-scopes/`, stopping at the version-control root; none found = the project
560
+ * works alone. A path that doesn't exist is a project error. See the Patter site's World properties
561
+ * page and patterkit/design/shared-scopes.md. Editor and compiler only; never reaches the bundle. */
562
+ gameScopes?: string;
557
563
  /** Coverage input drivers (#159): values to feed host scopes (`@world`) during a coverage run so
558
564
  * externally-gated branches get exercised. Authoring-only (never reaches the runtime bundle). */
559
565
  coverageDrivers?: CoverageDriver[];
@@ -809,6 +815,10 @@ interface Bundle {
809
815
  /** Host / world scope declarations, baked from the project so the runtime can self-back a declared
810
816
  * scope (`@world`, ...) when no host resolver claims its token. Absent = no host scopes. */
811
817
  scopeRegistry?: HostScopeRegistry;
818
+ /** Other engines' game-wide scopes the content names (`story`), sorted: the family's shared vocabulary,
819
+ * opaque to the compiler and never self-backed. The engine reports when the game has not registered
820
+ * one. Absent when none. */
821
+ externalScopes?: string[];
812
822
  gameDataFields?: GameDataFields;
813
823
  scenes: Record<string, CompiledScene>;
814
824
  /** locale -> (beatId -> text). In "embedded" localisation this carries every included locale; in "ids"
@@ -847,13 +857,13 @@ declare const DEFAULT_CAPTION_DELIMITERS: CaptionDelimiters;
847
857
  declare const DEFAULT_CAPTION_CHARACTER = "SFX";
848
858
  declare const SAVE_SCHEMA = "patter/save@0";
849
859
  /** The `save.version` inside the envelope. Bumped only when a reader would MISREAD an older save. */
850
- declare const SAVE_VERSION = 2;
860
+ declare const SAVE_VERSION = 3;
851
861
  /** The tagged envelope a host stores: `serializeState` writes it, `deserializeState` refuses anything else. */
852
862
  interface SaveEnvelope {
853
863
  schema: typeof SAVE_SCHEMA;
854
864
  save: SaveGame;
855
865
  }
856
- /** A property-state snapshot: owned scope -> property name -> value (`{ patter: { gold: 7 } }`). */
866
+ /** A registry's values: registry key -> property name -> value (`{ patter: { gold: 7 } }`). */
857
867
  type EngineSave = Record<string, Record<string, ScalarValue>>;
858
868
  /** Serialised `sequence` selector visit state for one group (spec §4 / §7). Every key is OPTIONAL and
859
869
  * present only once the selector has used it: `seq` after the first sequential pick, `bag` once a
@@ -911,31 +921,46 @@ interface FlowCursor {
911
921
  /** This flow's (non-shared) selector cursors, keyed by group id. */
912
922
  selectors: Record<string, SelectorSnapshot>;
913
923
  }
914
- /** The serialised cursor + scopes + PRNG of a single flow. */
924
+ /** The serialised cursor + PRNG + visits of a single flow. Its properties are the registry's. */
915
925
  interface FlowSnapshot {
916
- /** This flow's owned-scope values = the NOT-shared `@patter` globals, under token "patter". */
917
- scopes: EngineSave;
918
- /** Per-scene NOT-shared `@scene` bags (scene id -> name -> value); persist across re-entries (spec §7). */
919
- sceneBags: Record<string, Record<string, ScalarValue>>;
920
926
  /** This flow's built-in PRNG position (mulberry32 state, uint32; older saves may carry it signed). */
921
927
  rngState: number;
922
928
  /** This flow's per-node entry counts (node id -> times entered by this flow). */
923
929
  visits: Record<string, number>;
924
930
  cursor: FlowCursor;
925
931
  }
926
- /** A full resumable save-game: shared `@patter` state + every live flow. */
932
+ /** A full resumable save-game (version 3): everything that is not a property, plus the registry's
933
+ * values when the engine made its own registry. */
927
934
  interface SaveGame {
928
- version: number;
929
- /** Shared `@patter` globals (owned scope "patter"). */
930
- shared: EngineSave;
935
+ version: 3;
936
+ /** The engine's own registry's values, keyed by registry key: present only when the engine made the
937
+ * registry itself (a standalone game). A game that passed a registry saves it once, beside this. */
938
+ registry?: EngineSave;
931
939
  /** World-wide per-node entry counts (node id -> times entered by any flow). */
932
940
  sharedVisits: Record<string, number>;
933
941
  /** Shared selector cursors (node id -> snapshot) for `shared` memoried selectors. */
934
942
  sharedSelectors: Record<string, SelectorSnapshot>;
935
- /** Shared, scene-namespaced `@scene` bags (scene id -> name -> value) - the shared scene props. */
936
- stageBags: Record<string, Record<string, ScalarValue>>;
937
943
  /** Each live flow's snapshot, keyed by flow id. */
938
944
  flows: Record<string, FlowSnapshot>;
939
945
  }
946
+ /** A version 2 flow snapshot, which carried the flow's property values itself. Still read. */
947
+ interface FlowSnapshotV2 extends FlowSnapshot {
948
+ /** The NOT-shared `@patter` globals, under token "patter". */
949
+ scopes: EngineSave;
950
+ /** Per-scene NOT-shared `@scene` bags (scene id -> name -> value). */
951
+ sceneBags: Record<string, Record<string, ScalarValue>>;
952
+ }
953
+ /** A version 2 save, from before the registry held the properties. Every runtime still reads it: its
954
+ * property sections move into the registry (under the keys in the header above) as it loads. */
955
+ interface SaveGameV2 {
956
+ version: 2;
957
+ /** Shared `@patter` globals (owned scope "patter"). */
958
+ shared: EngineSave;
959
+ sharedVisits: Record<string, number>;
960
+ sharedSelectors: Record<string, SelectorSnapshot>;
961
+ /** Shared, scene-namespaced `@scene` bags (scene id -> name -> value). */
962
+ stageBags: Record<string, Record<string, ScalarValue>>;
963
+ flows: Record<string, FlowSnapshotV2>;
964
+ }
940
965
 
941
- export { type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, 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_RECORDING_STATUSES, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, PROJECT_LOCALE_SCENE, type ProjectDictionary, type ProjectFile, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, type SaveEnvelope, type SaveGame, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type StackFrame, type Suggestion, type TextBeat, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, gameIdify, isContentlessBeat, isValidGameId, walkNodes };
966
+ export { type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, 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_RECORDING_STATUSES, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowSnapshotV2, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, PROJECT_LOCALE_SCENE, type ProjectDictionary, type ProjectFile, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, type SaveEnvelope, type SaveGame, type SaveGameV2, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type StackFrame, type Suggestion, type TextBeat, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, gameIdify, isContentlessBeat, isValidGameId, walkNodes };
package/dist/index.d.ts CHANGED
@@ -554,6 +554,12 @@ interface ProjectFile {
554
554
  * resolver is bound, and coverage drives their values. Omitted = no host scopes (`@world.x` is then a
555
555
  * compile error). See design/scope-registry.md §6. */
556
556
  scopeRegistry?: HostScopeRegistry;
557
+ /** Where the game's shared scopes folder is, relative to this project file's folder
558
+ * (`"../../shared/game-scopes"`), for a folder the walk-up would not find. Omitted = walk up from the
559
+ * project to the first `game-scopes/`, stopping at the version-control root; none found = the project
560
+ * works alone. A path that doesn't exist is a project error. See the Patter site's World properties
561
+ * page and patterkit/design/shared-scopes.md. Editor and compiler only; never reaches the bundle. */
562
+ gameScopes?: string;
557
563
  /** Coverage input drivers (#159): values to feed host scopes (`@world`) during a coverage run so
558
564
  * externally-gated branches get exercised. Authoring-only (never reaches the runtime bundle). */
559
565
  coverageDrivers?: CoverageDriver[];
@@ -809,6 +815,10 @@ interface Bundle {
809
815
  /** Host / world scope declarations, baked from the project so the runtime can self-back a declared
810
816
  * scope (`@world`, ...) when no host resolver claims its token. Absent = no host scopes. */
811
817
  scopeRegistry?: HostScopeRegistry;
818
+ /** Other engines' game-wide scopes the content names (`story`), sorted: the family's shared vocabulary,
819
+ * opaque to the compiler and never self-backed. The engine reports when the game has not registered
820
+ * one. Absent when none. */
821
+ externalScopes?: string[];
812
822
  gameDataFields?: GameDataFields;
813
823
  scenes: Record<string, CompiledScene>;
814
824
  /** locale -> (beatId -> text). In "embedded" localisation this carries every included locale; in "ids"
@@ -847,13 +857,13 @@ declare const DEFAULT_CAPTION_DELIMITERS: CaptionDelimiters;
847
857
  declare const DEFAULT_CAPTION_CHARACTER = "SFX";
848
858
  declare const SAVE_SCHEMA = "patter/save@0";
849
859
  /** The `save.version` inside the envelope. Bumped only when a reader would MISREAD an older save. */
850
- declare const SAVE_VERSION = 2;
860
+ declare const SAVE_VERSION = 3;
851
861
  /** The tagged envelope a host stores: `serializeState` writes it, `deserializeState` refuses anything else. */
852
862
  interface SaveEnvelope {
853
863
  schema: typeof SAVE_SCHEMA;
854
864
  save: SaveGame;
855
865
  }
856
- /** A property-state snapshot: owned scope -> property name -> value (`{ patter: { gold: 7 } }`). */
866
+ /** A registry's values: registry key -> property name -> value (`{ patter: { gold: 7 } }`). */
857
867
  type EngineSave = Record<string, Record<string, ScalarValue>>;
858
868
  /** Serialised `sequence` selector visit state for one group (spec §4 / §7). Every key is OPTIONAL and
859
869
  * present only once the selector has used it: `seq` after the first sequential pick, `bag` once a
@@ -911,31 +921,46 @@ interface FlowCursor {
911
921
  /** This flow's (non-shared) selector cursors, keyed by group id. */
912
922
  selectors: Record<string, SelectorSnapshot>;
913
923
  }
914
- /** The serialised cursor + scopes + PRNG of a single flow. */
924
+ /** The serialised cursor + PRNG + visits of a single flow. Its properties are the registry's. */
915
925
  interface FlowSnapshot {
916
- /** This flow's owned-scope values = the NOT-shared `@patter` globals, under token "patter". */
917
- scopes: EngineSave;
918
- /** Per-scene NOT-shared `@scene` bags (scene id -> name -> value); persist across re-entries (spec §7). */
919
- sceneBags: Record<string, Record<string, ScalarValue>>;
920
926
  /** This flow's built-in PRNG position (mulberry32 state, uint32; older saves may carry it signed). */
921
927
  rngState: number;
922
928
  /** This flow's per-node entry counts (node id -> times entered by this flow). */
923
929
  visits: Record<string, number>;
924
930
  cursor: FlowCursor;
925
931
  }
926
- /** A full resumable save-game: shared `@patter` state + every live flow. */
932
+ /** A full resumable save-game (version 3): everything that is not a property, plus the registry's
933
+ * values when the engine made its own registry. */
927
934
  interface SaveGame {
928
- version: number;
929
- /** Shared `@patter` globals (owned scope "patter"). */
930
- shared: EngineSave;
935
+ version: 3;
936
+ /** The engine's own registry's values, keyed by registry key: present only when the engine made the
937
+ * registry itself (a standalone game). A game that passed a registry saves it once, beside this. */
938
+ registry?: EngineSave;
931
939
  /** World-wide per-node entry counts (node id -> times entered by any flow). */
932
940
  sharedVisits: Record<string, number>;
933
941
  /** Shared selector cursors (node id -> snapshot) for `shared` memoried selectors. */
934
942
  sharedSelectors: Record<string, SelectorSnapshot>;
935
- /** Shared, scene-namespaced `@scene` bags (scene id -> name -> value) - the shared scene props. */
936
- stageBags: Record<string, Record<string, ScalarValue>>;
937
943
  /** Each live flow's snapshot, keyed by flow id. */
938
944
  flows: Record<string, FlowSnapshot>;
939
945
  }
946
+ /** A version 2 flow snapshot, which carried the flow's property values itself. Still read. */
947
+ interface FlowSnapshotV2 extends FlowSnapshot {
948
+ /** The NOT-shared `@patter` globals, under token "patter". */
949
+ scopes: EngineSave;
950
+ /** Per-scene NOT-shared `@scene` bags (scene id -> name -> value). */
951
+ sceneBags: Record<string, Record<string, ScalarValue>>;
952
+ }
953
+ /** A version 2 save, from before the registry held the properties. Every runtime still reads it: its
954
+ * property sections move into the registry (under the keys in the header above) as it loads. */
955
+ interface SaveGameV2 {
956
+ version: 2;
957
+ /** Shared `@patter` globals (owned scope "patter"). */
958
+ shared: EngineSave;
959
+ sharedVisits: Record<string, number>;
960
+ sharedSelectors: Record<string, SelectorSnapshot>;
961
+ /** Shared, scene-namespaced `@scene` bags (scene id -> name -> value). */
962
+ stageBags: Record<string, Record<string, ScalarValue>>;
963
+ flows: Record<string, FlowSnapshotV2>;
964
+ }
940
965
 
941
- export { type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, 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_RECORDING_STATUSES, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, PROJECT_LOCALE_SCENE, type ProjectDictionary, type ProjectFile, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, type SaveEnvelope, type SaveGame, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type StackFrame, type Suggestion, type TextBeat, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, gameIdify, isContentlessBeat, isValidGameId, walkNodes };
966
+ export { type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, 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_RECORDING_STATUSES, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowSnapshotV2, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, PROJECT_LOCALE_SCENE, type ProjectDictionary, type ProjectFile, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, type SaveEnvelope, type SaveGame, type SaveGameV2, type SavedChoice, type SavedChoiceOption, type SavedChoicePrompt, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SelectorSnapshot, type SequenceOptions, type Snippet, type StackFrame, type Suggestion, type TextBeat, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, gameIdify, isContentlessBeat, isValidGameId, walkNodes };
package/dist/index.js CHANGED
@@ -76,7 +76,7 @@ function castStringKey(name) {
76
76
  var DEFAULT_CAPTION_DELIMITERS = { open: "[", close: "]" };
77
77
  var DEFAULT_CAPTION_CHARACTER = "SFX";
78
78
  var SAVE_SCHEMA = "patter/save@0";
79
- var SAVE_VERSION = 2;
79
+ var SAVE_VERSION = 3;
80
80
  export {
81
81
  COMMON_GENDERS,
82
82
  DEFAULT_CAPTION_CHARACTER,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patterkit/model",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Patter data-model types: source (scene/block/group/snippet/beat/jump), project, locale, authoring. The shape source-of-truth.",
5
5
  "type": "module",
6
6
  "license": "MIT",