@storylet-studio/model 0.4.0 → 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 CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  RESERVED_PROPERTY_NAMES: () => import_expr.RESERVED_PROPERTY_NAMES,
38
38
  SAVEFILE_SCHEMA: () => SAVEFILE_SCHEMA,
39
39
  SAVE_SCHEMA: () => SAVE_SCHEMA,
40
+ SAVE_SCHEMA_V1: () => SAVE_SCHEMA_V1,
40
41
  SHARD_EXTENSIONS: () => SHARD_EXTENSIONS,
41
42
  SPATIAL: () => SPATIAL,
42
43
  TAGS_SCHEMA: () => TAGS_SCHEMA,
@@ -552,7 +553,8 @@ var parseHoleRef = (value) => {
552
553
  };
553
554
  var BUNDLE_SCHEMA = "storylets/bundle@0";
554
555
  var DEFAULT_PLAY_RUNG = "solo";
555
- var SAVE_SCHEMA = "storylets/save@1";
556
+ var SAVE_SCHEMA = "storylets/save@2";
557
+ var SAVE_SCHEMA_V1 = "storylets/save@1";
556
558
  var SAVEFILE_SCHEMA = "storylets/savefile@1";
557
559
  var PROJECT_FOLDER_EXTENSION = ".storylets";
558
560
  var BUNDLE_EXTENSION = ".storyletsc";
@@ -626,6 +628,7 @@ var FURNITURE_COLOURS = ["paper", "amber", "sage", "sky", "rose", "slate"];
626
628
  RESERVED_PROPERTY_NAMES,
627
629
  SAVEFILE_SCHEMA,
628
630
  SAVE_SCHEMA,
631
+ SAVE_SCHEMA_V1,
629
632
  SHARD_EXTENSIONS,
630
633
  SPATIAL,
631
634
  TAGS_SCHEMA,
package/dist/index.d.cts CHANGED
@@ -976,11 +976,19 @@ interface Bundle {
976
976
  boxes: Box<Expression>[];
977
977
  /** Maps, when the project asked for them. Absent is the normal state. */
978
978
  maps?: BundleMap[];
979
+ /** Other engines' game-wide scopes the content names (`patter`), sorted: the
980
+ * family's shared vocabulary, let through unchecked by the compiler. The
981
+ * engine reports when the game has not registered one. Absent when none. */
982
+ externalScopes?: string[];
979
983
  }
980
- declare const SAVE_SCHEMA = "storylets/save@1";
984
+ declare const SAVE_SCHEMA = "storylets/save@2";
985
+ /** The version 1 envelope's schema tag, still read. */
986
+ declare const SAVE_SCHEMA_V1 = "storylets/save@1";
981
987
  interface PlayRecord {
982
988
  /** Card and outcome by gameId (feeds the play-history functions). */
983
989
  card: string;
990
+ /** "" for a card with no outcomes, played with none: the key is always
991
+ * there, so a save's shape does not depend on the card. */
984
992
  outcome: string;
985
993
  turn: number;
986
994
  }
@@ -1000,10 +1008,13 @@ interface PropsPartition {
1000
1008
  /** Tag state, keyed by tag id. */
1001
1009
  value: Record<string, PropertyBag>;
1002
1010
  }
1003
- /** One flow's snapshot inside the envelope (schema 4). */
1011
+ /** One flow's snapshot inside the envelope (schema 4), and the blob
1012
+ * `saveFlow` parks. */
1004
1013
  interface FlowSave {
1005
- /** The per-flow property partitions. */
1006
- props: PropsPartition;
1014
+ /** The per-flow property partitions. Carried by `saveFlow`, which parks one
1015
+ * flow whole; absent from a version 2 envelope's flows, whose properties
1016
+ * are the registry's. Present in every flow of a version 1 envelope. */
1017
+ props?: PropsPartition;
1007
1018
  /** Per-box turn counters, keyed by box id (schema 3.4) - per flow: there
1008
1019
  * is deliberately no global turn. */
1009
1020
  turns: Record<string, number>;
@@ -1026,16 +1037,33 @@ interface FlowSave {
1026
1037
  * (design/shared-scarcity.md). Claims are NOT here: they are derived from the
1027
1038
  * live boards, and each flow's board rides its own blob. */
1028
1039
  interface SharedSave {
1029
- props: PropsPartition;
1040
+ /** The shared property partitions: version 1 only. */
1041
+ props?: PropsPartition;
1030
1042
  /** Card ids, sorted, so a save is byte-stable for a diff. */
1031
1043
  spent: string[];
1032
1044
  }
1033
1045
  interface SaveEnvelope {
1034
1046
  schema: typeof SAVE_SCHEMA;
1035
1047
  content: BundleContent;
1048
+ /** The engine's own registry's values, keyed by registry key: present only
1049
+ * when the engine made the registry itself (a standalone game). A game that
1050
+ * passed a registry saves it once, beside this envelope. */
1051
+ registry?: Record<string, PropertyBag>;
1036
1052
  shared: SharedSave;
1037
1053
  flows: Record<string, FlowSave>;
1038
1054
  }
1055
+ /** A version 1 envelope, from before the registry held the properties. Every
1056
+ * runtime still reads it: its partitions move into the registry as it loads. */
1057
+ interface SaveEnvelopeV1 {
1058
+ schema: typeof SAVE_SCHEMA_V1;
1059
+ content: BundleContent;
1060
+ shared: SharedSave & {
1061
+ props: PropsPartition;
1062
+ };
1063
+ flows: Record<string, FlowSave & {
1064
+ props: PropsPartition;
1065
+ }>;
1066
+ }
1039
1067
  /** One card that a restore refused to put back on the board.
1040
1068
  *
1041
1069
  * `vanished` and `hand-vanished` are the edit's doing (the card, or the hand
@@ -1113,7 +1141,8 @@ interface LoadReport {
1113
1141
  declare const SAVEFILE_SCHEMA = "storylets/savefile@1";
1114
1142
  interface SaveFile {
1115
1143
  schema: typeof SAVEFILE_SCHEMA;
1116
- engine: SaveEnvelope;
1144
+ /** The engine's envelope: version 2 when written today, version 1 still read. */
1145
+ engine: SaveEnvelope | SaveEnvelopeV1;
1117
1146
  /** The host's @world values, saved and restored by the host. */
1118
1147
  world?: PropertyBag;
1119
1148
  }
@@ -1506,4 +1535,4 @@ interface DeckShard {
1506
1535
  cards: Card<string>[];
1507
1536
  }
1508
1537
 
1509
- export { BOX_SCHEMA, BUNDLE_EXTENSION, BUNDLE_SCHEMA, type Box, type BoxMap, type BoxShard, type Bundle, type BundleBackground, type BundleContent, type BundleMap, type BundleSettings, CONTRACTS_DIR, CONTRACT_SCHEMA, type CanvasFurniture, type Card, type Comment, type CommentMark, type CommentMessage, type ContractProperty, type ContractShard, type CoverageConfig, type CoverageDriver, DECK_SCHEMA, DEFAULT_PLAY_RUNG, type Deck, type DeckCanvas, type DeckShard, FURNITURE_COLOURS, type FieldDecl, type FlowSave, type Frame, type FurnitureColour, HANDS_SCHEMA, type Hand, type HandBinding, type HandRule, type HandTemplate, type HandsShard, type HoleRef, type HoleRefScope, type LoadEviction, type LoadProperty, type LoadReport, MAP_SCHEMA, type MapShard, NOTES_SCHEMA, type NotesShard, type Outcome, PLACE_GROUP, PROJECT_FOLDER_EXTENSION, PROJECT_SCHEMA, type PlayRecord, type PlayRung, type Polygon, type ProjectSettings, type ProjectShard, type PropertyBag, type PropertyDecl, type PropertyType, type PropsPartition, type Rect, type RedrawPolicy, SAVEFILE_SCHEMA, SAVE_SCHEMA, SHARD_EXTENSIONS, SPATIAL, type SaveEnvelope, type SaveFile, type SharedSave, type SpatialBackground, type SpatialGroup, type StackMove, type Stacked, TAGS_SCHEMA, type Tag, type TagGroup, type TagsShard, VIEW_SCHEMA, type ValueAddresses, type ViewPoint, type ViewShard, ambiguousValueAddressMessage, backgroundsOf, bindHand, bundleAssetPath, byDisplayOrder, centroid, commentsOf, contractPropertyPath, contractPropertyType, droppedRect, effectiveGameId, framesOf, freeGameId, freeTitle, gameIdify, handBinding, inferDeclFromWrite, isHoleRef, isSpatial, isValidGameId, labelPoint, markOf, marksOn, openThreadCounts, parseHoleRef, pointInPolygon, polygonBounds, polygonOf, restack, spatialOf, stacked, threadsFor, turnSpan, unbindHand, valueAddresses, withBackgrounds, withPolygon, withSpatialGroup, withZ, zOf, zoneAt, zonesAt };
1538
+ export { BOX_SCHEMA, BUNDLE_EXTENSION, BUNDLE_SCHEMA, type Box, type BoxMap, type BoxShard, type Bundle, type BundleBackground, type BundleContent, type BundleMap, type BundleSettings, CONTRACTS_DIR, CONTRACT_SCHEMA, type CanvasFurniture, type Card, type Comment, type CommentMark, type CommentMessage, type ContractProperty, type ContractShard, type CoverageConfig, type CoverageDriver, DECK_SCHEMA, DEFAULT_PLAY_RUNG, type Deck, type DeckCanvas, type DeckShard, FURNITURE_COLOURS, type FieldDecl, type FlowSave, type Frame, type FurnitureColour, HANDS_SCHEMA, type Hand, type HandBinding, type HandRule, type HandTemplate, type HandsShard, type HoleRef, type HoleRefScope, type LoadEviction, type LoadProperty, type LoadReport, MAP_SCHEMA, type MapShard, NOTES_SCHEMA, type NotesShard, type Outcome, PLACE_GROUP, PROJECT_FOLDER_EXTENSION, PROJECT_SCHEMA, type PlayRecord, type PlayRung, type Polygon, type ProjectSettings, type ProjectShard, type PropertyBag, type PropertyDecl, type PropertyType, type PropsPartition, type Rect, type RedrawPolicy, SAVEFILE_SCHEMA, SAVE_SCHEMA, SAVE_SCHEMA_V1, SHARD_EXTENSIONS, SPATIAL, type SaveEnvelope, type SaveEnvelopeV1, type SaveFile, type SharedSave, type SpatialBackground, type SpatialGroup, type StackMove, type Stacked, TAGS_SCHEMA, type Tag, type TagGroup, type TagsShard, VIEW_SCHEMA, type ValueAddresses, type ViewPoint, type ViewShard, ambiguousValueAddressMessage, backgroundsOf, bindHand, bundleAssetPath, byDisplayOrder, centroid, commentsOf, contractPropertyPath, contractPropertyType, droppedRect, effectiveGameId, framesOf, freeGameId, freeTitle, gameIdify, handBinding, inferDeclFromWrite, isHoleRef, isSpatial, isValidGameId, labelPoint, markOf, marksOn, openThreadCounts, parseHoleRef, pointInPolygon, polygonBounds, polygonOf, restack, spatialOf, stacked, threadsFor, turnSpan, unbindHand, valueAddresses, withBackgrounds, withPolygon, withSpatialGroup, withZ, zOf, zoneAt, zonesAt };
package/dist/index.d.ts CHANGED
@@ -976,11 +976,19 @@ interface Bundle {
976
976
  boxes: Box<Expression>[];
977
977
  /** Maps, when the project asked for them. Absent is the normal state. */
978
978
  maps?: BundleMap[];
979
+ /** Other engines' game-wide scopes the content names (`patter`), sorted: the
980
+ * family's shared vocabulary, let through unchecked by the compiler. The
981
+ * engine reports when the game has not registered one. Absent when none. */
982
+ externalScopes?: string[];
979
983
  }
980
- declare const SAVE_SCHEMA = "storylets/save@1";
984
+ declare const SAVE_SCHEMA = "storylets/save@2";
985
+ /** The version 1 envelope's schema tag, still read. */
986
+ declare const SAVE_SCHEMA_V1 = "storylets/save@1";
981
987
  interface PlayRecord {
982
988
  /** Card and outcome by gameId (feeds the play-history functions). */
983
989
  card: string;
990
+ /** "" for a card with no outcomes, played with none: the key is always
991
+ * there, so a save's shape does not depend on the card. */
984
992
  outcome: string;
985
993
  turn: number;
986
994
  }
@@ -1000,10 +1008,13 @@ interface PropsPartition {
1000
1008
  /** Tag state, keyed by tag id. */
1001
1009
  value: Record<string, PropertyBag>;
1002
1010
  }
1003
- /** One flow's snapshot inside the envelope (schema 4). */
1011
+ /** One flow's snapshot inside the envelope (schema 4), and the blob
1012
+ * `saveFlow` parks. */
1004
1013
  interface FlowSave {
1005
- /** The per-flow property partitions. */
1006
- props: PropsPartition;
1014
+ /** The per-flow property partitions. Carried by `saveFlow`, which parks one
1015
+ * flow whole; absent from a version 2 envelope's flows, whose properties
1016
+ * are the registry's. Present in every flow of a version 1 envelope. */
1017
+ props?: PropsPartition;
1007
1018
  /** Per-box turn counters, keyed by box id (schema 3.4) - per flow: there
1008
1019
  * is deliberately no global turn. */
1009
1020
  turns: Record<string, number>;
@@ -1026,16 +1037,33 @@ interface FlowSave {
1026
1037
  * (design/shared-scarcity.md). Claims are NOT here: they are derived from the
1027
1038
  * live boards, and each flow's board rides its own blob. */
1028
1039
  interface SharedSave {
1029
- props: PropsPartition;
1040
+ /** The shared property partitions: version 1 only. */
1041
+ props?: PropsPartition;
1030
1042
  /** Card ids, sorted, so a save is byte-stable for a diff. */
1031
1043
  spent: string[];
1032
1044
  }
1033
1045
  interface SaveEnvelope {
1034
1046
  schema: typeof SAVE_SCHEMA;
1035
1047
  content: BundleContent;
1048
+ /** The engine's own registry's values, keyed by registry key: present only
1049
+ * when the engine made the registry itself (a standalone game). A game that
1050
+ * passed a registry saves it once, beside this envelope. */
1051
+ registry?: Record<string, PropertyBag>;
1036
1052
  shared: SharedSave;
1037
1053
  flows: Record<string, FlowSave>;
1038
1054
  }
1055
+ /** A version 1 envelope, from before the registry held the properties. Every
1056
+ * runtime still reads it: its partitions move into the registry as it loads. */
1057
+ interface SaveEnvelopeV1 {
1058
+ schema: typeof SAVE_SCHEMA_V1;
1059
+ content: BundleContent;
1060
+ shared: SharedSave & {
1061
+ props: PropsPartition;
1062
+ };
1063
+ flows: Record<string, FlowSave & {
1064
+ props: PropsPartition;
1065
+ }>;
1066
+ }
1039
1067
  /** One card that a restore refused to put back on the board.
1040
1068
  *
1041
1069
  * `vanished` and `hand-vanished` are the edit's doing (the card, or the hand
@@ -1113,7 +1141,8 @@ interface LoadReport {
1113
1141
  declare const SAVEFILE_SCHEMA = "storylets/savefile@1";
1114
1142
  interface SaveFile {
1115
1143
  schema: typeof SAVEFILE_SCHEMA;
1116
- engine: SaveEnvelope;
1144
+ /** The engine's envelope: version 2 when written today, version 1 still read. */
1145
+ engine: SaveEnvelope | SaveEnvelopeV1;
1117
1146
  /** The host's @world values, saved and restored by the host. */
1118
1147
  world?: PropertyBag;
1119
1148
  }
@@ -1506,4 +1535,4 @@ interface DeckShard {
1506
1535
  cards: Card<string>[];
1507
1536
  }
1508
1537
 
1509
- export { BOX_SCHEMA, BUNDLE_EXTENSION, BUNDLE_SCHEMA, type Box, type BoxMap, type BoxShard, type Bundle, type BundleBackground, type BundleContent, type BundleMap, type BundleSettings, CONTRACTS_DIR, CONTRACT_SCHEMA, type CanvasFurniture, type Card, type Comment, type CommentMark, type CommentMessage, type ContractProperty, type ContractShard, type CoverageConfig, type CoverageDriver, DECK_SCHEMA, DEFAULT_PLAY_RUNG, type Deck, type DeckCanvas, type DeckShard, FURNITURE_COLOURS, type FieldDecl, type FlowSave, type Frame, type FurnitureColour, HANDS_SCHEMA, type Hand, type HandBinding, type HandRule, type HandTemplate, type HandsShard, type HoleRef, type HoleRefScope, type LoadEviction, type LoadProperty, type LoadReport, MAP_SCHEMA, type MapShard, NOTES_SCHEMA, type NotesShard, type Outcome, PLACE_GROUP, PROJECT_FOLDER_EXTENSION, PROJECT_SCHEMA, type PlayRecord, type PlayRung, type Polygon, type ProjectSettings, type ProjectShard, type PropertyBag, type PropertyDecl, type PropertyType, type PropsPartition, type Rect, type RedrawPolicy, SAVEFILE_SCHEMA, SAVE_SCHEMA, SHARD_EXTENSIONS, SPATIAL, type SaveEnvelope, type SaveFile, type SharedSave, type SpatialBackground, type SpatialGroup, type StackMove, type Stacked, TAGS_SCHEMA, type Tag, type TagGroup, type TagsShard, VIEW_SCHEMA, type ValueAddresses, type ViewPoint, type ViewShard, ambiguousValueAddressMessage, backgroundsOf, bindHand, bundleAssetPath, byDisplayOrder, centroid, commentsOf, contractPropertyPath, contractPropertyType, droppedRect, effectiveGameId, framesOf, freeGameId, freeTitle, gameIdify, handBinding, inferDeclFromWrite, isHoleRef, isSpatial, isValidGameId, labelPoint, markOf, marksOn, openThreadCounts, parseHoleRef, pointInPolygon, polygonBounds, polygonOf, restack, spatialOf, stacked, threadsFor, turnSpan, unbindHand, valueAddresses, withBackgrounds, withPolygon, withSpatialGroup, withZ, zOf, zoneAt, zonesAt };
1538
+ export { BOX_SCHEMA, BUNDLE_EXTENSION, BUNDLE_SCHEMA, type Box, type BoxMap, type BoxShard, type Bundle, type BundleBackground, type BundleContent, type BundleMap, type BundleSettings, CONTRACTS_DIR, CONTRACT_SCHEMA, type CanvasFurniture, type Card, type Comment, type CommentMark, type CommentMessage, type ContractProperty, type ContractShard, type CoverageConfig, type CoverageDriver, DECK_SCHEMA, DEFAULT_PLAY_RUNG, type Deck, type DeckCanvas, type DeckShard, FURNITURE_COLOURS, type FieldDecl, type FlowSave, type Frame, type FurnitureColour, HANDS_SCHEMA, type Hand, type HandBinding, type HandRule, type HandTemplate, type HandsShard, type HoleRef, type HoleRefScope, type LoadEviction, type LoadProperty, type LoadReport, MAP_SCHEMA, type MapShard, NOTES_SCHEMA, type NotesShard, type Outcome, PLACE_GROUP, PROJECT_FOLDER_EXTENSION, PROJECT_SCHEMA, type PlayRecord, type PlayRung, type Polygon, type ProjectSettings, type ProjectShard, type PropertyBag, type PropertyDecl, type PropertyType, type PropsPartition, type Rect, type RedrawPolicy, SAVEFILE_SCHEMA, SAVE_SCHEMA, SAVE_SCHEMA_V1, SHARD_EXTENSIONS, SPATIAL, type SaveEnvelope, type SaveEnvelopeV1, type SaveFile, type SharedSave, type SpatialBackground, type SpatialGroup, type StackMove, type Stacked, TAGS_SCHEMA, type Tag, type TagGroup, type TagsShard, VIEW_SCHEMA, type ValueAddresses, type ViewPoint, type ViewShard, ambiguousValueAddressMessage, backgroundsOf, bindHand, bundleAssetPath, byDisplayOrder, centroid, commentsOf, contractPropertyPath, contractPropertyType, droppedRect, effectiveGameId, framesOf, freeGameId, freeTitle, gameIdify, handBinding, inferDeclFromWrite, isHoleRef, isSpatial, isValidGameId, labelPoint, markOf, marksOn, openThreadCounts, parseHoleRef, pointInPolygon, polygonBounds, polygonOf, restack, spatialOf, stacked, threadsFor, turnSpan, unbindHand, valueAddresses, withBackgrounds, withPolygon, withSpatialGroup, withZ, zOf, zoneAt, zonesAt };
package/dist/index.js CHANGED
@@ -468,7 +468,8 @@ var parseHoleRef = (value) => {
468
468
  };
469
469
  var BUNDLE_SCHEMA = "storylets/bundle@0";
470
470
  var DEFAULT_PLAY_RUNG = "solo";
471
- var SAVE_SCHEMA = "storylets/save@1";
471
+ var SAVE_SCHEMA = "storylets/save@2";
472
+ var SAVE_SCHEMA_V1 = "storylets/save@1";
472
473
  var SAVEFILE_SCHEMA = "storylets/savefile@1";
473
474
  var PROJECT_FOLDER_EXTENSION = ".storylets";
474
475
  var BUNDLE_EXTENSION = ".storyletsc";
@@ -541,6 +542,7 @@ export {
541
542
  RESERVED_PROPERTY_NAMES,
542
543
  SAVEFILE_SCHEMA,
543
544
  SAVE_SCHEMA,
545
+ SAVE_SCHEMA_V1,
544
546
  SHARD_EXTENSIONS,
545
547
  SPATIAL,
546
548
  TAGS_SCHEMA,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storylet-studio/model",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Storylets data-model types: source shards (project / box / tags / hands / deck), the compiled bundle, the save envelope. The shape source-of-truth.",
5
5
  "type": "module",
6
6
  "license": "MIT",