@patterkit/model 0.4.1 → 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.cjs +6 -0
- package/dist/index.d.cts +93 -1
- package/dist/index.d.ts +93 -1
- package/dist/index.js +4 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,8 @@ __export(index_exports, {
|
|
|
30
30
|
RERECORD_STATUS: () => RERECORD_STATUS,
|
|
31
31
|
RERECORD_STATUS_DECL: () => RERECORD_STATUS_DECL,
|
|
32
32
|
RESERVED_PROPERTY_NAMES: () => import_expr.RESERVED_PROPERTY_NAMES,
|
|
33
|
+
SAVE_SCHEMA: () => SAVE_SCHEMA,
|
|
34
|
+
SAVE_VERSION: () => SAVE_VERSION,
|
|
33
35
|
castStringKey: () => castStringKey,
|
|
34
36
|
deriveRecordingFolders: () => deriveRecordingFolders,
|
|
35
37
|
effectiveGameId: () => effectiveGameId,
|
|
@@ -113,6 +115,8 @@ function castStringKey(name) {
|
|
|
113
115
|
}
|
|
114
116
|
var DEFAULT_CAPTION_DELIMITERS = { open: "[", close: "]" };
|
|
115
117
|
var DEFAULT_CAPTION_CHARACTER = "SFX";
|
|
118
|
+
var SAVE_SCHEMA = "patter/save@0";
|
|
119
|
+
var SAVE_VERSION = 2;
|
|
116
120
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117
121
|
0 && (module.exports = {
|
|
118
122
|
COMMON_GENDERS,
|
|
@@ -125,6 +129,8 @@ var DEFAULT_CAPTION_CHARACTER = "SFX";
|
|
|
125
129
|
RERECORD_STATUS,
|
|
126
130
|
RERECORD_STATUS_DECL,
|
|
127
131
|
RESERVED_PROPERTY_NAMES,
|
|
132
|
+
SAVE_SCHEMA,
|
|
133
|
+
SAVE_VERSION,
|
|
128
134
|
castStringKey,
|
|
129
135
|
deriveRecordingFolders,
|
|
130
136
|
effectiveGameId,
|
package/dist/index.d.cts
CHANGED
|
@@ -845,5 +845,97 @@ declare const DEFAULT_CAPTION_DELIMITERS: CaptionDelimiters;
|
|
|
845
845
|
/** The default caption character: a cast member named `SFX` whose lines are pure captions (omitted when
|
|
846
846
|
* captions are off). Applies even to a project that pins no `closedCaptions`. */
|
|
847
847
|
declare const DEFAULT_CAPTION_CHARACTER = "SFX";
|
|
848
|
+
declare const SAVE_SCHEMA = "patter/save@0";
|
|
849
|
+
/** The `save.version` inside the envelope. Bumped only when a reader would MISREAD an older save. */
|
|
850
|
+
declare const SAVE_VERSION = 2;
|
|
851
|
+
/** The tagged envelope a host stores: `serializeState` writes it, `deserializeState` refuses anything else. */
|
|
852
|
+
interface SaveEnvelope {
|
|
853
|
+
schema: typeof SAVE_SCHEMA;
|
|
854
|
+
save: SaveGame;
|
|
855
|
+
}
|
|
856
|
+
/** A property-state snapshot: owned scope -> property name -> value (`{ patter: { gold: 7 } }`). */
|
|
857
|
+
type EngineSave = Record<string, Record<string, ScalarValue>>;
|
|
858
|
+
/** Serialised `sequence` selector visit state for one group (spec §4 / §7). Every key is OPTIONAL and
|
|
859
|
+
* present only once the selector has used it: `seq` after the first sequential pick, `bag` once a
|
|
860
|
+
* shuffle has drawn, `last` once there is a no-immediate-repeat memory. A port that stores "started"
|
|
861
|
+
* flags derives them from key presence rather than writing them. */
|
|
862
|
+
interface SelectorSnapshot {
|
|
863
|
+
seq?: number;
|
|
864
|
+
bag?: string[];
|
|
865
|
+
last?: string;
|
|
866
|
+
}
|
|
867
|
+
/** One entry on a flow's continuation stack: a position within a container's children. */
|
|
868
|
+
interface StackFrame {
|
|
869
|
+
sceneId: string;
|
|
870
|
+
/** A block id or a run-group id (both are sequential containers). */
|
|
871
|
+
containerId: string;
|
|
872
|
+
index: number;
|
|
873
|
+
/** SNAPSHOT-ONLY (never on a live frame): the id of the child at `index` when the save was taken, so a
|
|
874
|
+
* restore against an EDITED bundle re-finds the position by id. Absent when the frame sat at its
|
|
875
|
+
* container's end (no next child), or in an older save. */
|
|
876
|
+
nextId?: string;
|
|
877
|
+
}
|
|
878
|
+
/** The prompt of a saved choice option: the choice text as a structured line/text beat. */
|
|
879
|
+
interface SavedChoicePrompt {
|
|
880
|
+
kind: "line" | "text";
|
|
881
|
+
text: string;
|
|
882
|
+
character?: string;
|
|
883
|
+
characterName?: string;
|
|
884
|
+
direction?: string;
|
|
885
|
+
}
|
|
886
|
+
/** One option of a pending choice, saved VERBATIM: re-deriving on load would re-evaluate conditions. */
|
|
887
|
+
interface SavedChoiceOption {
|
|
888
|
+
id: string;
|
|
889
|
+
prompt?: SavedChoicePrompt;
|
|
890
|
+
eligible: boolean;
|
|
891
|
+
gameData?: GameData;
|
|
892
|
+
}
|
|
893
|
+
/** A pending choice as saved: the option set the player was shown, replayed on load (schema 9.3). */
|
|
894
|
+
interface SavedChoice {
|
|
895
|
+
groupId: string;
|
|
896
|
+
options: SavedChoiceOption[];
|
|
897
|
+
}
|
|
898
|
+
/** The flow's execution position: where it is, and what it is waiting on. */
|
|
899
|
+
interface FlowCursor {
|
|
900
|
+
flowEnded: boolean;
|
|
901
|
+
currentSceneId: string | null;
|
|
902
|
+
/** The continuation stack (call frames + the active block run), root first. */
|
|
903
|
+
stack: StackFrame[];
|
|
904
|
+
activeSnippetId: string | null;
|
|
905
|
+
beatIndex: number;
|
|
906
|
+
/** Present (non-null) iff the flow is stopped at a choice. */
|
|
907
|
+
pendingChoice: SavedChoice | null;
|
|
908
|
+
/** The chosen option owning a prompt still to be replayed (a save taken between choose + advance).
|
|
909
|
+
* Optional / null in older saves -> no pending prompt. */
|
|
910
|
+
pendingPromptOwnerId?: string | null;
|
|
911
|
+
/** This flow's (non-shared) selector cursors, keyed by group id. */
|
|
912
|
+
selectors: Record<string, SelectorSnapshot>;
|
|
913
|
+
}
|
|
914
|
+
/** The serialised cursor + scopes + PRNG of a single flow. */
|
|
915
|
+
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
|
+
/** This flow's built-in PRNG position (mulberry32 state, uint32; older saves may carry it signed). */
|
|
921
|
+
rngState: number;
|
|
922
|
+
/** This flow's per-node entry counts (node id -> times entered by this flow). */
|
|
923
|
+
visits: Record<string, number>;
|
|
924
|
+
cursor: FlowCursor;
|
|
925
|
+
}
|
|
926
|
+
/** A full resumable save-game: shared `@patter` state + every live flow. */
|
|
927
|
+
interface SaveGame {
|
|
928
|
+
version: number;
|
|
929
|
+
/** Shared `@patter` globals (owned scope "patter"). */
|
|
930
|
+
shared: EngineSave;
|
|
931
|
+
/** World-wide per-node entry counts (node id -> times entered by any flow). */
|
|
932
|
+
sharedVisits: Record<string, number>;
|
|
933
|
+
/** Shared selector cursors (node id -> snapshot) for `shared` memoried selectors. */
|
|
934
|
+
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
|
+
/** Each live flow's snapshot, keyed by flow id. */
|
|
938
|
+
flows: Record<string, FlowSnapshot>;
|
|
939
|
+
}
|
|
848
940
|
|
|
849
|
-
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 EstimatingConfig, type Expression, type FlowFile, type FlowNode, 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, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SequenceOptions, type Snippet, type Suggestion, type TextBeat, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, gameIdify, isContentlessBeat, isValidGameId, walkNodes };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -845,5 +845,97 @@ declare const DEFAULT_CAPTION_DELIMITERS: CaptionDelimiters;
|
|
|
845
845
|
/** The default caption character: a cast member named `SFX` whose lines are pure captions (omitted when
|
|
846
846
|
* captions are off). Applies even to a project that pins no `closedCaptions`. */
|
|
847
847
|
declare const DEFAULT_CAPTION_CHARACTER = "SFX";
|
|
848
|
+
declare const SAVE_SCHEMA = "patter/save@0";
|
|
849
|
+
/** The `save.version` inside the envelope. Bumped only when a reader would MISREAD an older save. */
|
|
850
|
+
declare const SAVE_VERSION = 2;
|
|
851
|
+
/** The tagged envelope a host stores: `serializeState` writes it, `deserializeState` refuses anything else. */
|
|
852
|
+
interface SaveEnvelope {
|
|
853
|
+
schema: typeof SAVE_SCHEMA;
|
|
854
|
+
save: SaveGame;
|
|
855
|
+
}
|
|
856
|
+
/** A property-state snapshot: owned scope -> property name -> value (`{ patter: { gold: 7 } }`). */
|
|
857
|
+
type EngineSave = Record<string, Record<string, ScalarValue>>;
|
|
858
|
+
/** Serialised `sequence` selector visit state for one group (spec §4 / §7). Every key is OPTIONAL and
|
|
859
|
+
* present only once the selector has used it: `seq` after the first sequential pick, `bag` once a
|
|
860
|
+
* shuffle has drawn, `last` once there is a no-immediate-repeat memory. A port that stores "started"
|
|
861
|
+
* flags derives them from key presence rather than writing them. */
|
|
862
|
+
interface SelectorSnapshot {
|
|
863
|
+
seq?: number;
|
|
864
|
+
bag?: string[];
|
|
865
|
+
last?: string;
|
|
866
|
+
}
|
|
867
|
+
/** One entry on a flow's continuation stack: a position within a container's children. */
|
|
868
|
+
interface StackFrame {
|
|
869
|
+
sceneId: string;
|
|
870
|
+
/** A block id or a run-group id (both are sequential containers). */
|
|
871
|
+
containerId: string;
|
|
872
|
+
index: number;
|
|
873
|
+
/** SNAPSHOT-ONLY (never on a live frame): the id of the child at `index` when the save was taken, so a
|
|
874
|
+
* restore against an EDITED bundle re-finds the position by id. Absent when the frame sat at its
|
|
875
|
+
* container's end (no next child), or in an older save. */
|
|
876
|
+
nextId?: string;
|
|
877
|
+
}
|
|
878
|
+
/** The prompt of a saved choice option: the choice text as a structured line/text beat. */
|
|
879
|
+
interface SavedChoicePrompt {
|
|
880
|
+
kind: "line" | "text";
|
|
881
|
+
text: string;
|
|
882
|
+
character?: string;
|
|
883
|
+
characterName?: string;
|
|
884
|
+
direction?: string;
|
|
885
|
+
}
|
|
886
|
+
/** One option of a pending choice, saved VERBATIM: re-deriving on load would re-evaluate conditions. */
|
|
887
|
+
interface SavedChoiceOption {
|
|
888
|
+
id: string;
|
|
889
|
+
prompt?: SavedChoicePrompt;
|
|
890
|
+
eligible: boolean;
|
|
891
|
+
gameData?: GameData;
|
|
892
|
+
}
|
|
893
|
+
/** A pending choice as saved: the option set the player was shown, replayed on load (schema 9.3). */
|
|
894
|
+
interface SavedChoice {
|
|
895
|
+
groupId: string;
|
|
896
|
+
options: SavedChoiceOption[];
|
|
897
|
+
}
|
|
898
|
+
/** The flow's execution position: where it is, and what it is waiting on. */
|
|
899
|
+
interface FlowCursor {
|
|
900
|
+
flowEnded: boolean;
|
|
901
|
+
currentSceneId: string | null;
|
|
902
|
+
/** The continuation stack (call frames + the active block run), root first. */
|
|
903
|
+
stack: StackFrame[];
|
|
904
|
+
activeSnippetId: string | null;
|
|
905
|
+
beatIndex: number;
|
|
906
|
+
/** Present (non-null) iff the flow is stopped at a choice. */
|
|
907
|
+
pendingChoice: SavedChoice | null;
|
|
908
|
+
/** The chosen option owning a prompt still to be replayed (a save taken between choose + advance).
|
|
909
|
+
* Optional / null in older saves -> no pending prompt. */
|
|
910
|
+
pendingPromptOwnerId?: string | null;
|
|
911
|
+
/** This flow's (non-shared) selector cursors, keyed by group id. */
|
|
912
|
+
selectors: Record<string, SelectorSnapshot>;
|
|
913
|
+
}
|
|
914
|
+
/** The serialised cursor + scopes + PRNG of a single flow. */
|
|
915
|
+
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
|
+
/** This flow's built-in PRNG position (mulberry32 state, uint32; older saves may carry it signed). */
|
|
921
|
+
rngState: number;
|
|
922
|
+
/** This flow's per-node entry counts (node id -> times entered by this flow). */
|
|
923
|
+
visits: Record<string, number>;
|
|
924
|
+
cursor: FlowCursor;
|
|
925
|
+
}
|
|
926
|
+
/** A full resumable save-game: shared `@patter` state + every live flow. */
|
|
927
|
+
interface SaveGame {
|
|
928
|
+
version: number;
|
|
929
|
+
/** Shared `@patter` globals (owned scope "patter"). */
|
|
930
|
+
shared: EngineSave;
|
|
931
|
+
/** World-wide per-node entry counts (node id -> times entered by any flow). */
|
|
932
|
+
sharedVisits: Record<string, number>;
|
|
933
|
+
/** Shared selector cursors (node id -> snapshot) for `shared` memoried selectors. */
|
|
934
|
+
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
|
+
/** Each live flow's snapshot, keyed by flow id. */
|
|
938
|
+
flows: Record<string, FlowSnapshot>;
|
|
939
|
+
}
|
|
848
940
|
|
|
849
|
-
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 EstimatingConfig, type Expression, type FlowFile, type FlowNode, 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, type ScalarValue, type Scene, type Selector, type SelectorExhaust, type SelectorOrder, type SequenceOptions, type Snippet, type Suggestion, type TextBeat, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, gameIdify, isContentlessBeat, isValidGameId, walkNodes };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,8 @@ function castStringKey(name) {
|
|
|
75
75
|
}
|
|
76
76
|
var DEFAULT_CAPTION_DELIMITERS = { open: "[", close: "]" };
|
|
77
77
|
var DEFAULT_CAPTION_CHARACTER = "SFX";
|
|
78
|
+
var SAVE_SCHEMA = "patter/save@0";
|
|
79
|
+
var SAVE_VERSION = 2;
|
|
78
80
|
export {
|
|
79
81
|
COMMON_GENDERS,
|
|
80
82
|
DEFAULT_CAPTION_CHARACTER,
|
|
@@ -86,6 +88,8 @@ export {
|
|
|
86
88
|
RERECORD_STATUS,
|
|
87
89
|
RERECORD_STATUS_DECL,
|
|
88
90
|
RESERVED_PROPERTY_NAMES,
|
|
91
|
+
SAVE_SCHEMA,
|
|
92
|
+
SAVE_VERSION,
|
|
89
93
|
castStringKey,
|
|
90
94
|
deriveRecordingFolders,
|
|
91
95
|
effectiveGameId,
|
package/package.json
CHANGED