@react-text-game/core 0.1.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.
Files changed (178) hide show
  1. package/README.md +744 -0
  2. package/dist/baseGameObject.d.ts +90 -0
  3. package/dist/baseGameObject.d.ts.map +1 -0
  4. package/dist/baseGameObject.js +109 -0
  5. package/dist/baseGameObject.js.map +1 -0
  6. package/dist/constants.d.ts +12 -0
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/constants.js +12 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/game.d.ts +294 -0
  11. package/dist/game.d.ts.map +1 -0
  12. package/dist/game.js +489 -0
  13. package/dist/game.js.map +1 -0
  14. package/dist/helpers.d.ts +2 -0
  15. package/dist/helpers.d.ts.map +1 -0
  16. package/dist/helpers.js +6 -0
  17. package/dist/helpers.js.map +1 -0
  18. package/dist/hooks/index.d.ts +4 -0
  19. package/dist/hooks/index.d.ts.map +1 -0
  20. package/dist/hooks/index.js +4 -0
  21. package/dist/hooks/index.js.map +1 -0
  22. package/dist/hooks/useCurrentPassage.d.ts +10 -0
  23. package/dist/hooks/useCurrentPassage.d.ts.map +1 -0
  24. package/dist/hooks/useCurrentPassage.js +17 -0
  25. package/dist/hooks/useCurrentPassage.js.map +1 -0
  26. package/dist/hooks/useGameEntity.d.ts +21 -0
  27. package/dist/hooks/useGameEntity.d.ts.map +1 -0
  28. package/dist/hooks/useGameEntity.js +70 -0
  29. package/dist/hooks/useGameEntity.js.map +1 -0
  30. package/dist/hooks/useGameIsStarted.d.ts +12 -0
  31. package/dist/hooks/useGameIsStarted.d.ts.map +1 -0
  32. package/dist/hooks/useGameIsStarted.js +18 -0
  33. package/dist/hooks/useGameIsStarted.js.map +1 -0
  34. package/dist/index.d.ts +12 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +10 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/logger.d.ts +8 -0
  39. package/dist/logger.d.ts.map +1 -0
  40. package/dist/logger.js +36 -0
  41. package/dist/logger.js.map +1 -0
  42. package/dist/options.d.ts +13 -0
  43. package/dist/options.d.ts.map +1 -0
  44. package/dist/options.js +15 -0
  45. package/dist/options.js.map +1 -0
  46. package/dist/passages/interactiveMap/fabric.d.ts +4 -0
  47. package/dist/passages/interactiveMap/fabric.d.ts.map +1 -0
  48. package/dist/passages/interactiveMap/fabric.js +3 -0
  49. package/dist/passages/interactiveMap/fabric.js.map +1 -0
  50. package/dist/passages/interactiveMap/index.d.ts +4 -0
  51. package/dist/passages/interactiveMap/index.d.ts.map +1 -0
  52. package/dist/passages/interactiveMap/index.js +4 -0
  53. package/dist/passages/interactiveMap/index.js.map +1 -0
  54. package/dist/passages/interactiveMap/interactiveMap.d.ts +89 -0
  55. package/dist/passages/interactiveMap/interactiveMap.d.ts.map +1 -0
  56. package/dist/passages/interactiveMap/interactiveMap.js +103 -0
  57. package/dist/passages/interactiveMap/interactiveMap.js.map +1 -0
  58. package/dist/passages/interactiveMap/types.d.ts +822 -0
  59. package/dist/passages/interactiveMap/types.d.ts.map +1 -0
  60. package/dist/passages/interactiveMap/types.js +2 -0
  61. package/dist/passages/interactiveMap/types.js.map +1 -0
  62. package/dist/passages/passage.d.ts +57 -0
  63. package/dist/passages/passage.d.ts.map +1 -0
  64. package/dist/passages/passage.js +64 -0
  65. package/dist/passages/passage.js.map +1 -0
  66. package/dist/passages/story/fabric.d.ts +4 -0
  67. package/dist/passages/story/fabric.d.ts.map +1 -0
  68. package/dist/passages/story/fabric.js +3 -0
  69. package/dist/passages/story/fabric.js.map +1 -0
  70. package/dist/passages/story/index.d.ts +5 -0
  71. package/dist/passages/story/index.d.ts.map +1 -0
  72. package/dist/passages/story/index.js +5 -0
  73. package/dist/passages/story/index.js.map +1 -0
  74. package/dist/passages/story/start.d.ts +14 -0
  75. package/dist/passages/story/start.d.ts.map +1 -0
  76. package/dist/passages/story/start.js +22 -0
  77. package/dist/passages/story/start.js.map +1 -0
  78. package/dist/passages/story/story.d.ts +84 -0
  79. package/dist/passages/story/story.d.ts.map +1 -0
  80. package/dist/passages/story/story.js +88 -0
  81. package/dist/passages/story/story.js.map +1 -0
  82. package/dist/passages/story/types.d.ts +911 -0
  83. package/dist/passages/story/types.d.ts.map +1 -0
  84. package/dist/passages/story/types.js +2 -0
  85. package/dist/passages/story/types.js.map +1 -0
  86. package/dist/passages/types/index.d.ts +3 -0
  87. package/dist/passages/types/index.d.ts.map +1 -0
  88. package/dist/passages/types/index.js +2 -0
  89. package/dist/passages/types/index.js.map +1 -0
  90. package/dist/passages/widget.d.ts +62 -0
  91. package/dist/passages/widget.d.ts.map +1 -0
  92. package/dist/passages/widget.js +66 -0
  93. package/dist/passages/widget.js.map +1 -0
  94. package/dist/saves/constants.d.ts +17 -0
  95. package/dist/saves/constants.d.ts.map +1 -0
  96. package/dist/saves/constants.js +17 -0
  97. package/dist/saves/constants.js.map +1 -0
  98. package/dist/saves/db.d.ts +119 -0
  99. package/dist/saves/db.d.ts.map +1 -0
  100. package/dist/saves/db.js +231 -0
  101. package/dist/saves/db.js.map +1 -0
  102. package/dist/saves/helpers.d.ts +28 -0
  103. package/dist/saves/helpers.d.ts.map +1 -0
  104. package/dist/saves/helpers.js +84 -0
  105. package/dist/saves/helpers.js.map +1 -0
  106. package/dist/saves/hooks/index.d.ts +10 -0
  107. package/dist/saves/hooks/index.d.ts.map +1 -0
  108. package/dist/saves/hooks/index.js +10 -0
  109. package/dist/saves/hooks/index.js.map +1 -0
  110. package/dist/saves/hooks/useDeleteAllSlots.d.ts +18 -0
  111. package/dist/saves/hooks/useDeleteAllSlots.d.ts.map +1 -0
  112. package/dist/saves/hooks/useDeleteAllSlots.js +18 -0
  113. package/dist/saves/hooks/useDeleteAllSlots.js.map +1 -0
  114. package/dist/saves/hooks/useDeleteGame.d.ts +22 -0
  115. package/dist/saves/hooks/useDeleteGame.d.ts.map +1 -0
  116. package/dist/saves/hooks/useDeleteGame.js +33 -0
  117. package/dist/saves/hooks/useDeleteGame.js.map +1 -0
  118. package/dist/saves/hooks/useExportSaves.d.ts +27 -0
  119. package/dist/saves/hooks/useExportSaves.d.ts.map +1 -0
  120. package/dist/saves/hooks/useExportSaves.js +54 -0
  121. package/dist/saves/hooks/useExportSaves.js.map +1 -0
  122. package/dist/saves/hooks/useImportSaves.d.ts +29 -0
  123. package/dist/saves/hooks/useImportSaves.d.ts.map +1 -0
  124. package/dist/saves/hooks/useImportSaves.js +108 -0
  125. package/dist/saves/hooks/useImportSaves.js.map +1 -0
  126. package/dist/saves/hooks/useLastLoadGame.d.ts +39 -0
  127. package/dist/saves/hooks/useLastLoadGame.d.ts.map +1 -0
  128. package/dist/saves/hooks/useLastLoadGame.js +72 -0
  129. package/dist/saves/hooks/useLastLoadGame.js.map +1 -0
  130. package/dist/saves/hooks/useLoadGame.d.ts +22 -0
  131. package/dist/saves/hooks/useLoadGame.d.ts.map +1 -0
  132. package/dist/saves/hooks/useLoadGame.js +40 -0
  133. package/dist/saves/hooks/useLoadGame.js.map +1 -0
  134. package/dist/saves/hooks/useRestartGame.d.ts +20 -0
  135. package/dist/saves/hooks/useRestartGame.d.ts.map +1 -0
  136. package/dist/saves/hooks/useRestartGame.js +29 -0
  137. package/dist/saves/hooks/useRestartGame.js.map +1 -0
  138. package/dist/saves/hooks/useSaveGame.d.ts +22 -0
  139. package/dist/saves/hooks/useSaveGame.d.ts.map +1 -0
  140. package/dist/saves/hooks/useSaveGame.js +34 -0
  141. package/dist/saves/hooks/useSaveGame.js.map +1 -0
  142. package/dist/saves/hooks/useSaveSlots.d.ts +45 -0
  143. package/dist/saves/hooks/useSaveSlots.d.ts.map +1 -0
  144. package/dist/saves/hooks/useSaveSlots.js +42 -0
  145. package/dist/saves/hooks/useSaveSlots.js.map +1 -0
  146. package/dist/saves/index.d.ts +4 -0
  147. package/dist/saves/index.d.ts.map +1 -0
  148. package/dist/saves/index.js +3 -0
  149. package/dist/saves/index.js.map +1 -0
  150. package/dist/saves/types.d.ts +52 -0
  151. package/dist/saves/types.d.ts.map +1 -0
  152. package/dist/saves/types.js +2 -0
  153. package/dist/saves/types.js.map +1 -0
  154. package/dist/storage.d.ts +124 -0
  155. package/dist/storage.d.ts.map +1 -0
  156. package/dist/storage.js +229 -0
  157. package/dist/storage.js.map +1 -0
  158. package/dist/tests/game.test.d.ts +2 -0
  159. package/dist/tests/game.test.d.ts.map +1 -0
  160. package/dist/tests/game.test.js +602 -0
  161. package/dist/tests/game.test.js.map +1 -0
  162. package/dist/tests/interactiveMap.test.d.ts +2 -0
  163. package/dist/tests/interactiveMap.test.d.ts.map +1 -0
  164. package/dist/tests/interactiveMap.test.js +1003 -0
  165. package/dist/tests/interactiveMap.test.js.map +1 -0
  166. package/dist/tests/storage.test.d.ts +2 -0
  167. package/dist/tests/storage.test.d.ts.map +1 -0
  168. package/dist/tests/storage.test.js +328 -0
  169. package/dist/tests/storage.test.js.map +1 -0
  170. package/dist/tests/story.test.d.ts +2 -0
  171. package/dist/tests/story.test.d.ts.map +1 -0
  172. package/dist/tests/story.test.js +698 -0
  173. package/dist/tests/story.test.js.map +1 -0
  174. package/dist/types.d.ts +19 -0
  175. package/dist/types.d.ts.map +1 -0
  176. package/dist/types.js +2 -0
  177. package/dist/types.js.map +1 -0
  178. package/package.json +60 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/passages/interactiveMap/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEnE;;;GAGG;AACH,UAAU,WAAW;IACjB;;;;;;;;;OASG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IAEvC;;;OAG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AC;KACtB,CAAC;IAEF;;OAEG;IACH,UAAU,CAAC,EAAE;QACT;;;;;;;;WAQG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;;;;;;;WAQG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;;WAGG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB;;;WAGG;QACH,YAAY,CAAC,EAAE,MAAM,CAAC;QAEtB;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACjC,qBAAqB,EACrB,SAAS,GAAG,OAAO,GAAG,YAAY,CACrC,GAAG;IACA;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/passages/interactiveMap/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import { EmptyObject, InitVarsType, PassageType } from "../types";
2
+ /**
3
+ * Base class for all passage types in the text game engine.
4
+ *
5
+ * Passages represent different screens or scenes in the game. Each passage has a unique
6
+ * identifier and type, and is automatically registered with the Game when instantiated.
7
+ *
8
+ * Subclasses must implement the `display()` method to define how the passage renders.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * class CustomPassage extends Passage {
13
+ * constructor(id: string) {
14
+ * super(id, 'custom');
15
+ * }
16
+ *
17
+ * display(props) {
18
+ * return { content: 'Custom passage content' };
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @see Story - Text-based narrative passage implementation
24
+ * @see InteractiveMap - Map-based interactive passage implementation
25
+ * @see Widget - React component passage implementation
26
+ */
27
+ export declare class Passage {
28
+ /**
29
+ * Unique identifier for this passage.
30
+ * Used for navigation and registry lookup.
31
+ */
32
+ readonly id: string;
33
+ /**
34
+ * The type of this passage.
35
+ * Determines how the passage should be rendered in the UI.
36
+ */
37
+ readonly type: PassageType;
38
+ /**
39
+ * Creates a new passage and automatically registers it with the Game.
40
+ *
41
+ * @param id - Unique identifier for this passage
42
+ * @param type - The passage type (story, interactiveMap, or widget)
43
+ */
44
+ constructor(id: string, type: PassageType);
45
+ /**
46
+ * Renders the passage content with optional props.
47
+ *
48
+ * This method must be implemented by subclasses to define the passage behavior.
49
+ *
50
+ * @template T - Type of props passed to the display method
51
+ * @param _props - Optional properties for rendering the passage
52
+ * @returns The rendered passage content (type depends on passage implementation)
53
+ * @throws Error if not implemented by subclass
54
+ */
55
+ display<T extends InitVarsType = EmptyObject>(_props?: T): void;
56
+ }
57
+ //# sourceMappingURL=passage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passage.d.ts","sourceRoot":"","sources":["../../src/passages/passage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,OAAO;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAE3B;;;;;OAKG;gBACS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;IAMzC;;;;;;;;;OASG;IAEH,OAAO,CAAC,CAAC,SAAS,YAAY,GAAG,WAAW,EAAE,MAAM,GAAE,CAAW;CAKpE"}
@@ -0,0 +1,64 @@
1
+ import { Game } from "../game";
2
+ /**
3
+ * Base class for all passage types in the text game engine.
4
+ *
5
+ * Passages represent different screens or scenes in the game. Each passage has a unique
6
+ * identifier and type, and is automatically registered with the Game when instantiated.
7
+ *
8
+ * Subclasses must implement the `display()` method to define how the passage renders.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * class CustomPassage extends Passage {
13
+ * constructor(id: string) {
14
+ * super(id, 'custom');
15
+ * }
16
+ *
17
+ * display(props) {
18
+ * return { content: 'Custom passage content' };
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @see Story - Text-based narrative passage implementation
24
+ * @see InteractiveMap - Map-based interactive passage implementation
25
+ * @see Widget - React component passage implementation
26
+ */
27
+ export class Passage {
28
+ /**
29
+ * Unique identifier for this passage.
30
+ * Used for navigation and registry lookup.
31
+ */
32
+ id;
33
+ /**
34
+ * The type of this passage.
35
+ * Determines how the passage should be rendered in the UI.
36
+ */
37
+ type;
38
+ /**
39
+ * Creates a new passage and automatically registers it with the Game.
40
+ *
41
+ * @param id - Unique identifier for this passage
42
+ * @param type - The passage type (story, interactiveMap, or widget)
43
+ */
44
+ constructor(id, type) {
45
+ this.id = id;
46
+ this.type = type;
47
+ Game.registerPassage(this);
48
+ }
49
+ /**
50
+ * Renders the passage content with optional props.
51
+ *
52
+ * This method must be implemented by subclasses to define the passage behavior.
53
+ *
54
+ * @template T - Type of props passed to the display method
55
+ * @param _props - Optional properties for rendering the passage
56
+ * @returns The rendered passage content (type depends on passage implementation)
57
+ * @throws Error if not implemented by subclass
58
+ */
59
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
+ display(_props = {}) {
61
+ throw new Error(`Display method not implemented for passage: ${this.id}`);
62
+ }
63
+ }
64
+ //# sourceMappingURL=passage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passage.js","sourceRoot":"","sources":["../../src/passages/passage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,OAAO;IAChB;;;OAGG;IACM,EAAE,CAAS;IAEpB;;;OAGG;IACM,IAAI,CAAc;IAE3B;;;;;OAKG;IACH,YAAY,EAAU,EAAE,IAAiB;QACrC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;;;OASG;IACH,6DAA6D;IAC7D,OAAO,CAAuC,SAAY,EAAO;QAC7D,MAAM,IAAI,KAAK,CACX,+CAA+C,IAAI,CAAC,EAAE,EAAE,CAC3D,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ import { Story } from "./story";
2
+ import { StoryContent, StoryOptions } from "./types";
3
+ export declare const newStory: (id: string, content: StoryContent, options?: StoryOptions) => Story;
4
+ //# sourceMappingURL=fabric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabric.d.ts","sourceRoot":"","sources":["../../../src/passages/story/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,eAAO,MAAM,QAAQ,GACjB,IAAI,MAAM,EACV,SAAS,YAAY,EACrB,UAAU,YAAY,KACvB,KAAwC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Story } from "./story";
2
+ export const newStory = (id, content, options) => new Story(id, content, options);
3
+ //# sourceMappingURL=fabric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabric.js","sourceRoot":"","sources":["../../../src/passages/story/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACpB,EAAU,EACV,OAAqB,EACrB,OAAsB,EACjB,EAAE,CAAC,IAAI,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import "./start";
2
+ export * from "./fabric";
3
+ export * from "./story";
4
+ export * from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/passages/story/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,5 @@
1
+ import "./start";
2
+ export * from "./fabric";
3
+ export * from "./story";
4
+ export * from "./types";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/passages/story/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Represents the starting point of the system's story flow.
3
+ *
4
+ * This variable initializes a new story passage using the default system
5
+ * passage name `START_MENU`. It contains a header and a text content placeholder,
6
+ * which can be customized or replaced with a new story.
7
+ *
8
+ * The contents include:
9
+ * - A header element with the title "Start Story".
10
+ * - A text element explaining that this is a placeholder for the initial
11
+ * story passage and should be updated with a new story identified as `start-menu-passage`.
12
+ */
13
+ export declare const system_start: import("./story").Story;
14
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/passages/story/start.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,yBAOvB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { SYSTEM_PASSAGE_NAMES } from "../../constants";
2
+ import { newStory } from "./fabric";
3
+ /**
4
+ * Represents the starting point of the system's story flow.
5
+ *
6
+ * This variable initializes a new story passage using the default system
7
+ * passage name `START_MENU`. It contains a header and a text content placeholder,
8
+ * which can be customized or replaced with a new story.
9
+ *
10
+ * The contents include:
11
+ * - A header element with the title "Start Story".
12
+ * - A text element explaining that this is a placeholder for the initial
13
+ * story passage and should be updated with a new story identified as `start-menu-passage`.
14
+ */
15
+ export const system_start = newStory(SYSTEM_PASSAGE_NAMES.START_MENU, () => [
16
+ { type: "header", content: "Start Story" },
17
+ {
18
+ type: "text",
19
+ content: "This is a placeholder for the start passage, please, consider to replace it with new story with id `start-menu-passage`.",
20
+ },
21
+ ]);
22
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/passages/story/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,oBAAoB,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;IACxE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE;IAC1C;QACI,IAAI,EAAE,MAAM;QACZ,OAAO,EACH,0HAA0H;KACjI;CACJ,CAAC,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { Passage } from "../../passages/passage";
2
+ import { EmptyObject, InitVarsType } from "../../types";
3
+ import { Component, StoryContent, StoryOptions } from "./types";
4
+ /**
5
+ * Text-based narrative passage for displaying story content with rich components.
6
+ *
7
+ * Story passages support various component types including text, headers, images,
8
+ * videos, actions, conversations, and embedded stories. Content is defined via
9
+ * a function that receives props and returns an array of components.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { newStory } from '@react-text-game/core';
14
+ *
15
+ * const introStory = newStory('intro', (props) => [
16
+ * {
17
+ * type: 'header',
18
+ * content: 'Chapter 1',
19
+ * props: { level: 1 }
20
+ * },
21
+ * {
22
+ * type: 'text',
23
+ * content: 'Your journey begins...'
24
+ * },
25
+ * {
26
+ * type: 'actions',
27
+ * content: [
28
+ * {
29
+ * label: 'Continue',
30
+ * action: () => Game.jumpTo('chapter-1')
31
+ * }
32
+ * ]
33
+ * }
34
+ * ], {
35
+ * background: { image: '/bg.jpg' },
36
+ * classNames: { container: 'story-container' }
37
+ * });
38
+ * ```
39
+ *
40
+ * @see newStory - Factory function for creating Story instances
41
+ */
42
+ export declare class Story extends Passage {
43
+ /**
44
+ * Function that generates story components based on props.
45
+ */
46
+ private readonly content;
47
+ /**
48
+ * Optional configuration for story appearance and behavior.
49
+ */
50
+ private readonly options;
51
+ /**
52
+ * Creates a new Story passage.
53
+ *
54
+ * @param id - Unique identifier for this story
55
+ * @param content - Function that returns an array of story components
56
+ * @param options - Optional configuration for background, styling, etc.
57
+ */
58
+ constructor(id: string, content: StoryContent, options?: StoryOptions);
59
+ /**
60
+ * Renders the story by invoking the content function with props.
61
+ *
62
+ * The content function receives props and returns an array of components
63
+ * (text, headers, images, actions, etc.) that make up the story.
64
+ *
65
+ * @template T - Type of props to pass to the content function
66
+ * @param props - Properties used during rendering (e.g., player state, game flags)
67
+ * @returns Object containing story options and rendered components
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const story = newStory('test', () => [
72
+ * { type: 'text', content: 'Hello' }
73
+ * ]);
74
+ *
75
+ * const { components, options } = story.display();
76
+ * // components: [{ type: 'text', content: 'Hello' }]
77
+ * ```
78
+ */
79
+ display<T extends InitVarsType = EmptyObject>(props?: T): {
80
+ options?: StoryOptions;
81
+ components: Array<Component>;
82
+ };
83
+ }
84
+ //# sourceMappingURL=story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.d.ts","sourceRoot":"","sources":["../../../src/passages/story/story.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBAAa,KAAM,SAAQ,OAAO;IAC9B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC;;;;;;OAMG;gBACS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,YAAiB;IAMzE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,CAAC,SAAS,YAAY,GAAG,WAAW,EACxC,KAAK,GAAE,CAAW,GACnB;QAAE,OAAO,CAAC,EAAE,YAAY,CAAC;QAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;KAAE;CAM9D"}
@@ -0,0 +1,88 @@
1
+ import { Passage } from "../../passages/passage";
2
+ /**
3
+ * Text-based narrative passage for displaying story content with rich components.
4
+ *
5
+ * Story passages support various component types including text, headers, images,
6
+ * videos, actions, conversations, and embedded stories. Content is defined via
7
+ * a function that receives props and returns an array of components.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { newStory } from '@react-text-game/core';
12
+ *
13
+ * const introStory = newStory('intro', (props) => [
14
+ * {
15
+ * type: 'header',
16
+ * content: 'Chapter 1',
17
+ * props: { level: 1 }
18
+ * },
19
+ * {
20
+ * type: 'text',
21
+ * content: 'Your journey begins...'
22
+ * },
23
+ * {
24
+ * type: 'actions',
25
+ * content: [
26
+ * {
27
+ * label: 'Continue',
28
+ * action: () => Game.jumpTo('chapter-1')
29
+ * }
30
+ * ]
31
+ * }
32
+ * ], {
33
+ * background: { image: '/bg.jpg' },
34
+ * classNames: { container: 'story-container' }
35
+ * });
36
+ * ```
37
+ *
38
+ * @see newStory - Factory function for creating Story instances
39
+ */
40
+ export class Story extends Passage {
41
+ /**
42
+ * Function that generates story components based on props.
43
+ */
44
+ content;
45
+ /**
46
+ * Optional configuration for story appearance and behavior.
47
+ */
48
+ options;
49
+ /**
50
+ * Creates a new Story passage.
51
+ *
52
+ * @param id - Unique identifier for this story
53
+ * @param content - Function that returns an array of story components
54
+ * @param options - Optional configuration for background, styling, etc.
55
+ */
56
+ constructor(id, content, options = {}) {
57
+ super(id, "story");
58
+ this.content = content;
59
+ this.options = options;
60
+ }
61
+ /**
62
+ * Renders the story by invoking the content function with props.
63
+ *
64
+ * The content function receives props and returns an array of components
65
+ * (text, headers, images, actions, etc.) that make up the story.
66
+ *
67
+ * @template T - Type of props to pass to the content function
68
+ * @param props - Properties used during rendering (e.g., player state, game flags)
69
+ * @returns Object containing story options and rendered components
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const story = newStory('test', () => [
74
+ * { type: 'text', content: 'Hello' }
75
+ * ]);
76
+ *
77
+ * const { components, options } = story.display();
78
+ * // components: [{ type: 'text', content: 'Hello' }]
79
+ * ```
80
+ */
81
+ display(props = {}) {
82
+ return {
83
+ options: this.options,
84
+ components: this.content(props),
85
+ };
86
+ }
87
+ }
88
+ //# sourceMappingURL=story.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.js","sourceRoot":"","sources":["../../../src/passages/story/story.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,OAAO,KAAM,SAAQ,OAAO;IAC9B;;OAEG;IACc,OAAO,CAAe;IAEvC;;OAEG;IACc,OAAO,CAAe;IAEvC;;;;;;OAMG;IACH,YAAY,EAAU,EAAE,OAAqB,EAAE,UAAwB,EAAE;QACrE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CACH,QAAW,EAAO;QAElB,OAAO;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;SAClC,CAAC;IACN,CAAC;CACJ"}