@patterkit/model 0.18.0 → 0.19.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
@@ -64,6 +64,8 @@ __export(index_exports, {
64
64
  projectQualifiers: () => projectQualifiers,
65
65
  propertyNameify: () => import_expr.propertyNameify,
66
66
  qualifierStringKey: () => qualifierStringKey,
67
+ resolveSceneRef: () => resolveSceneRef,
68
+ sceneAddressIndex: () => sceneAddressIndex,
67
69
  speakerLabelKey: () => speakerLabelKey,
68
70
  textIsAction: () => textIsAction,
69
71
  usedQualifiers: () => usedQualifiers,
@@ -96,6 +98,14 @@ function effectiveGameId(entity) {
96
98
  const g = entity.gameId?.trim();
97
99
  return g ? g : gameIdify(entity.name);
98
100
  }
101
+ function sceneAddressIndex(scenes) {
102
+ const byAddress = /* @__PURE__ */ new Map();
103
+ for (const [id, scene] of Object.entries(scenes)) byAddress.set(effectiveGameId(scene), id);
104
+ return byAddress;
105
+ }
106
+ function resolveSceneRef(scenes, ref, byAddress) {
107
+ return (byAddress ?? sceneAddressIndex(scenes)).get(ref) ?? (Object.hasOwn(scenes, ref) ? ref : void 0);
108
+ }
99
109
  var COMMON_GENDERS = ["male", "female", "neuter"];
100
110
  var DEFAULT_QUALIFIERS = [
101
111
  { gameId: "vo", name: "V.O.", description: "Voice-over: the character isn't in the scene (a thought, narration, a voice in the ear)." },
@@ -288,6 +298,8 @@ var UNRESOLVED_KEY = "unresolved";
288
298
  projectQualifiers,
289
299
  propertyNameify,
290
300
  qualifierStringKey,
301
+ resolveSceneRef,
302
+ sceneAddressIndex,
291
303
  speakerLabelKey,
292
304
  textIsAction,
293
305
  usedQualifiers,
package/dist/index.d.cts CHANGED
@@ -257,6 +257,25 @@ declare function effectiveGameId(entity: {
257
257
  gameId?: string;
258
258
  name: string;
259
259
  }): string;
260
+ /** A bundle's scenes by their address (effective gameId), for `resolveSceneRef` to look up in. */
261
+ declare function sceneAddressIndex(scenes: Readonly<Record<string, {
262
+ gameId?: string;
263
+ name: string;
264
+ }>>): Map<string, string>;
265
+ /**
266
+ * THE rule for resolving a scene reference to its internal id: its address (the effective gameId, the
267
+ * host-facing name, spec §6) first, then its internal id. Undefined when neither names a scene.
268
+ *
269
+ * One rule for the runtime's openFlow, goto and every engine lookup, and for every tool that has to land
270
+ * where the game will (the Storylet Engine's Board and pairing check, Patterpad's Show Card). Each used to
271
+ * keep a copy, and the copies tried the internal id first, so where one scene's id was another's gameId
272
+ * they picked a different scene from the one the game opened (family parity item 1). Pass `byAddress`
273
+ * (from `sceneAddressIndex`) to look up many references in one bundle without rebuilding it.
274
+ */
275
+ declare function resolveSceneRef(scenes: Readonly<Record<string, {
276
+ gameId?: string;
277
+ name: string;
278
+ }>>, ref: string, byAddress?: ReadonlyMap<string, string>): string | undefined;
260
279
  type PropertyType = "boolean" | "number" | "string" | "flags" | "enum" | "quality";
261
280
  interface PropertyDecl {
262
281
  name: string;
@@ -1383,4 +1402,4 @@ interface ExtensionFieldDecl {
1383
1402
  /** A node's extension values in a bundle: extension id -> field -> value, raw. */
1384
1403
  type NodeExtensions = Record<string, Record<string, unknown>>;
1385
1404
 
1386
- export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, 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_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowSnapshotV2, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, 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 SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, formatSpeakerLabel, gameIdify, isContentlessBeat, isDialogueScene, isValidGameId, projectLayout, projectQualifiers, qualifierStringKey, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
1405
+ export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, 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_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowSnapshotV2, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, 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 SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, formatSpeakerLabel, gameIdify, isContentlessBeat, isDialogueScene, isValidGameId, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
package/dist/index.d.ts CHANGED
@@ -257,6 +257,25 @@ declare function effectiveGameId(entity: {
257
257
  gameId?: string;
258
258
  name: string;
259
259
  }): string;
260
+ /** A bundle's scenes by their address (effective gameId), for `resolveSceneRef` to look up in. */
261
+ declare function sceneAddressIndex(scenes: Readonly<Record<string, {
262
+ gameId?: string;
263
+ name: string;
264
+ }>>): Map<string, string>;
265
+ /**
266
+ * THE rule for resolving a scene reference to its internal id: its address (the effective gameId, the
267
+ * host-facing name, spec §6) first, then its internal id. Undefined when neither names a scene.
268
+ *
269
+ * One rule for the runtime's openFlow, goto and every engine lookup, and for every tool that has to land
270
+ * where the game will (the Storylet Engine's Board and pairing check, Patterpad's Show Card). Each used to
271
+ * keep a copy, and the copies tried the internal id first, so where one scene's id was another's gameId
272
+ * they picked a different scene from the one the game opened (family parity item 1). Pass `byAddress`
273
+ * (from `sceneAddressIndex`) to look up many references in one bundle without rebuilding it.
274
+ */
275
+ declare function resolveSceneRef(scenes: Readonly<Record<string, {
276
+ gameId?: string;
277
+ name: string;
278
+ }>>, ref: string, byAddress?: ReadonlyMap<string, string>): string | undefined;
260
279
  type PropertyType = "boolean" | "number" | "string" | "flags" | "enum" | "quality";
261
280
  interface PropertyDecl {
262
281
  name: string;
@@ -1383,4 +1402,4 @@ interface ExtensionFieldDecl {
1383
1402
  /** A node's extension values in a bundle: extension id -> field -> value, raw. */
1384
1403
  type NodeExtensions = Record<string, Record<string, unknown>>;
1385
1404
 
1386
- export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, 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_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowSnapshotV2, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, 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 SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, formatSpeakerLabel, gameIdify, isContentlessBeat, isDialogueScene, isValidGameId, projectLayout, projectQualifiers, qualifierStringKey, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
1405
+ export { AUTHORING_SCHEMA, type AuthoringFile, type Beat, type Block, type Bundle, type BundleCastMember, type BundleExtension, type BundleQualifier, 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_LAYOUT, DEFAULT_PAD_AFTER, DEFAULT_QUALIFIERS, DEFAULT_RECORDING_STATUSES, DEFAULT_SPEAKER_PATTERN, DEFAULT_WRITING_STATUSES, type DocLine, type DocumentationClass, EXTENSIONS_DIR, EXTENSION_SCHEMA, EXTENSION_SHARD, type EditRecord, type Effect, type EngineSave, type EstimatingConfig, type Expression, type ExtensionFieldDecl, type ExtensionShard, FLOW_SCHEMA, type FlowCursor, type FlowFile, type FlowNode, type FlowSnapshot, type FlowSnapshotV2, type FlowState, type FlowValues, type GameData, type GameDataField, type GameDataFieldType, type GameDataFields, type GameDataNodeKind, type GameEventBeat, type GrammaticalGender, type Group, HANDOFF_SCHEMA, type HandoffFile, type HandoffImport, type HandoffLine, type HandoffRow, type HostScopeDecl, type HostScopeRegistry, type HostScopeSpec, type Jump, type JumpTarget, type LineBeat, type LocaleFile, MANIFEST_EXTENSION, type NodeExtensions, PAD_AFTER_MAX, PAD_AFTER_MIN, PROJECT_EXTENSION_STEM, PROJECT_LOCALE_SCENE, PROJECT_SCHEMA, type ProjectDictionary, type ProjectExtension, type ProjectFile, type ProjectLayout, type PromptBeat, type PropertyDecl, type PropertyType, RERECORD_STATUS, RERECORD_STATUS_DECL, type RecordingFolder, type RecordingStatusDecl, SAVE_SCHEMA, SAVE_VERSION, SPEAKER_PATTERN_KEY, STRINGS_SCHEMA, 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 SpeakerQualifier, type StackFrame, type Suggestion, type SuggestionSource, type TextBeat, UNRESOLVED_KEY, type VcsKind, type WritingStatusDecl, castStringKey, deriveRecordingFolders, effectiveGameId, formatSpeakerLabel, gameIdify, isContentlessBeat, isDialogueScene, isValidGameId, projectLayout, projectQualifiers, qualifierStringKey, resolveSceneRef, sceneAddressIndex, speakerLabelKey, textIsAction, usedQualifiers, usedSpeakerPairs, walkNodes };
package/dist/index.js CHANGED
@@ -29,6 +29,14 @@ function effectiveGameId(entity) {
29
29
  const g = entity.gameId?.trim();
30
30
  return g ? g : gameIdify(entity.name);
31
31
  }
32
+ function sceneAddressIndex(scenes) {
33
+ const byAddress = /* @__PURE__ */ new Map();
34
+ for (const [id, scene] of Object.entries(scenes)) byAddress.set(effectiveGameId(scene), id);
35
+ return byAddress;
36
+ }
37
+ function resolveSceneRef(scenes, ref, byAddress) {
38
+ return (byAddress ?? sceneAddressIndex(scenes)).get(ref) ?? (Object.hasOwn(scenes, ref) ? ref : void 0);
39
+ }
32
40
  var COMMON_GENDERS = ["male", "female", "neuter"];
33
41
  var DEFAULT_QUALIFIERS = [
34
42
  { gameId: "vo", name: "V.O.", description: "Voice-over: the character isn't in the scene (a thought, narration, a voice in the ear)." },
@@ -220,6 +228,8 @@ export {
220
228
  projectQualifiers,
221
229
  propertyNameify,
222
230
  qualifierStringKey,
231
+ resolveSceneRef,
232
+ sceneAddressIndex,
223
233
  speakerLabelKey,
224
234
  textIsAction,
225
235
  usedQualifiers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patterkit/model",
3
- "version": "0.18.0",
3
+ "version": "0.19.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",