@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":"useGameEntity.js","sourceRoot":"","sources":["../../src/hooks/useGameEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,MAAM,eAAe,GAAG,CAAC,EAAU,EAAE,EAAE,CACnC;IACI,EAAE;IACF,0DAA0D;IAC1D,+BAA+B;IAC/B,0DAA0D;IAC1D,EAAE;IACF,WAAW,EAAE,2CAA2C;IACxD,EAAE;IACF,oBAAoB;IACpB,qEAAqE;IACrE,iEAAiE;IACjE,EAAE;IACF,aAAa;IACb,2DAA2D;IAC3D,+BAA+B;IAC/B,EAAE;IACF,SAAS,EAAE,8CAA8C;IACzD,2EAA2E;IAC3E,EAAE;IACF,YAAY;IACZ,0BAA0B;IAC1B,kDAAkD;IAClD,OAAO;IACP,EAAE;IACF,kBAAkB;IAClB,kBAAkB,EAAE,0BAA0B;IAC9C,sDAAsD;IACtD,kEAAkE;IAClE,EAAE;IACF,0DAA0D;IAC1D,EAAE;CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa,CAA2B,UAAa;IACjE,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAEzD,IAAI,CAAC;QACD,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,iEAAiE;QACjE,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACJ,MAAM,KAAK,CAAC,CAAC,gCAAgC;QACjD,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Determines whether the game has started.
3
+ *
4
+ * @function
5
+ * @returns {boolean} True if the game has started; false otherwise.
6
+ *
7
+ * This function checks the current passage ID within the game's reactive state to infer
8
+ * whether the game has progressed beyond the starting point. If the current passage ID
9
+ * does not match the system-defined starting passage ID, the game is considered to have started.
10
+ */
11
+ export declare const useGameIsStarted: () => boolean;
12
+ //# sourceMappingURL=useGameIsStarted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameIsStarted.d.ts","sourceRoot":"","sources":["../../src/hooks/useGameIsStarted.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,QAAO,OAInC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { useProxy } from "valtio/utils";
2
+ import { SYSTEM_PASSAGE_NAMES } from "../constants";
3
+ import { Game } from "../game";
4
+ /**
5
+ * Determines whether the game has started.
6
+ *
7
+ * @function
8
+ * @returns {boolean} True if the game has started; false otherwise.
9
+ *
10
+ * This function checks the current passage ID within the game's reactive state to infer
11
+ * whether the game has progressed beyond the starting point. If the current passage ID
12
+ * does not match the system-defined starting passage ID, the game is considered to have started.
13
+ */
14
+ export const useGameIsStarted = () => {
15
+ const reactiveGameState = useProxy(Game.selfState);
16
+ return reactiveGameState.currentPassageId !== SYSTEM_PASSAGE_NAMES.START_MENU;
17
+ };
18
+ //# sourceMappingURL=useGameIsStarted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameIsStarted.js","sourceRoot":"","sources":["../../src/hooks/useGameIsStarted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAY,EAAE;IAC1C,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEnD,OAAO,iBAAiB,CAAC,gBAAgB,KAAK,oBAAoB,CAAC,UAAU,CAAC;AAClF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { BaseGameObject } from "./baseGameObject";
2
+ import { Game } from "./game";
3
+ import type { NewOptions, Options } from "./options";
4
+ import { InteractiveMap, newInteractiveMap } from "./passages/interactiveMap";
5
+ import { Passage } from "./passages/passage";
6
+ import { newStory, Story } from "./passages/story";
7
+ import { newWidget, Widget } from "./passages/widget";
8
+ export * from "./constants";
9
+ export * from "./hooks";
10
+ export type * from "./types";
11
+ export { BaseGameObject, Game, InteractiveMap, newInteractiveMap, NewOptions, newStory, newWidget, Options, Passage, Story, Widget, };
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,mBAAmB,QAAQ,CAAC;AAE5B,OAAO,EACH,cAAc,EACd,IAAI,EACJ,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,GACT,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { BaseGameObject } from "./baseGameObject";
2
+ import { Game } from "./game";
3
+ import { InteractiveMap, newInteractiveMap } from "./passages/interactiveMap";
4
+ import { Passage } from "./passages/passage";
5
+ import { newStory, Story } from "./passages/story";
6
+ import { newWidget, Widget } from "./passages/widget";
7
+ export * from "./constants";
8
+ export * from "./hooks";
9
+ export { BaseGameObject, Game, InteractiveMap, newInteractiveMap, newStory, newWidget, Passage, Story, Widget, };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAGxB,OAAO,EACH,cAAc,EACd,IAAI,EACJ,cAAc,EACd,iBAAiB,EAEjB,QAAQ,EACR,SAAS,EAET,OAAO,EACP,KAAK,EACL,MAAM,GACT,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const logger: {
2
+ readonly level: 0 | 2;
3
+ debug(...what: unknown[]): void;
4
+ log(...what: unknown[]): void;
5
+ warn(...what: unknown[]): void;
6
+ error(...what: unknown[]): void;
7
+ };
8
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,MAAM;;mBAKA,OAAO,EAAE;iBAKX,OAAO,EAAE;kBAKR,OAAO,EAAE;mBAKR,OAAO,EAAE;CAK3B,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,36 @@
1
+ import { consola } from "consola/browser";
2
+ import { colors } from 'consola/utils';
3
+ import { _getOptions } from "./options";
4
+ const LEVELS = {
5
+ DEBUG: 0,
6
+ INFO: 1,
7
+ WARN: 2,
8
+ ERROR: 3,
9
+ };
10
+ export const logger = {
11
+ get level() {
12
+ const { isDevMode } = _getOptions();
13
+ return isDevMode ? LEVELS.DEBUG : LEVELS.WARN;
14
+ },
15
+ debug(...what) {
16
+ if (this.level <= LEVELS.DEBUG) {
17
+ consola.debug(colors.green("[DEBUG]"), ...what);
18
+ }
19
+ },
20
+ log(...what) {
21
+ if (this.level <= LEVELS.INFO) {
22
+ consola.log(colors.blue("[INFO]"), ...what);
23
+ }
24
+ },
25
+ warn(...what) {
26
+ if (this.level <= LEVELS.WARN) {
27
+ consola.warn(colors.yellow("[WARN]"), ...what);
28
+ }
29
+ },
30
+ error(...what) {
31
+ if (this.level <= LEVELS.ERROR) {
32
+ consola.error(colors.red("[ERROR]"), ...what);
33
+ }
34
+ },
35
+ };
36
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,GAAG;IACX,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACF,CAAC;AAEX,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,IAAI,KAAK;QACL,MAAM,EAAE,SAAS,EAAE,GAAG,WAAW,EAAE,CAAC;QACpC,OAAO,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IAClD,CAAC;IACD,KAAK,CAAC,GAAG,IAAe;QACpB,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IACD,GAAG,CAAC,GAAG,IAAe;QAClB,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QAChD,CAAC;IACL,CAAC;IACD,IAAI,CAAC,GAAG,IAAe;QACnB,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QACnD,CAAC;IACL,CAAC;IACD,KAAK,CAAC,GAAG,IAAe;QACpB,IAAI,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;CACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ export type Options = {
2
+ gameName: string;
3
+ gameId: string;
4
+ description: string;
5
+ gameVersion: string;
6
+ startPassage: string;
7
+ author: string;
8
+ isDevMode: boolean;
9
+ };
10
+ export type NewOptions = Pick<Options, "gameName"> & Partial<Omit<Options, "gameName">>;
11
+ export declare const newOptions: (opts: NewOptions) => void;
12
+ export declare const _getOptions: () => Options;
13
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAYxF,eAAO,MAAM,UAAU,GAAI,MAAM,UAAU,SAE1C,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { SYSTEM_PASSAGE_NAMES } from "./constants";
2
+ const options = {
3
+ gameName: "",
4
+ gameId: "",
5
+ description: "",
6
+ startPassage: SYSTEM_PASSAGE_NAMES.START,
7
+ gameVersion: "1.0.0",
8
+ author: "",
9
+ isDevMode: false,
10
+ };
11
+ export const newOptions = (opts) => {
12
+ Object.assign(options, opts);
13
+ };
14
+ export const _getOptions = () => options;
15
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAclD,MAAM,OAAO,GAAY;IACrB,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE;IACV,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,oBAAoB,CAAC,KAAK;IACxC,WAAW,EAAE,OAAO;IACpB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,KAAK;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAgB,EAAE,EAAE;IAC3C,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { InteractiveMap } from "./interactiveMap";
2
+ import { InteractiveMapOptions } from "./types";
3
+ export declare const newInteractiveMap: (id: string, options: InteractiveMapOptions) => InteractiveMap;
4
+ //# sourceMappingURL=fabric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabric.d.ts","sourceRoot":"","sources":["../../../src/passages/interactiveMap/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,iBAAiB,GAC1B,IAAI,MAAM,EACV,SAAS,qBAAqB,KAC/B,cAAiD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { InteractiveMap } from "./interactiveMap";
2
+ export const newInteractiveMap = (id, options) => new InteractiveMap(id, options);
3
+ //# sourceMappingURL=fabric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fabric.js","sourceRoot":"","sources":["../../../src/passages/interactiveMap/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,EAAU,EACV,OAA8B,EAChB,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./fabric";
2
+ export * from "./interactiveMap";
3
+ export * from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/passages/interactiveMap/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./fabric";
2
+ export * from "./interactiveMap";
3
+ export * from "./types";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/passages/interactiveMap/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { Passage } from "../../passages/passage";
2
+ import { EmptyObject, InitVarsType } from "../../types";
3
+ import { InteractiveMapOptions, InteractiveMapType } from "./types";
4
+ /**
5
+ * Map-based interactive passage with clickable hotspots.
6
+ *
7
+ * Interactive maps display an image with interactive hotspots (buttons/images) that
8
+ * can be positioned on the map or on its sides. Hotspots can be labels, images, or menus.
9
+ * Both the map image and hotspots can be dynamic based on game state.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { newInteractiveMap } from '@react-text-game/core';
14
+ *
15
+ * const worldMap = newInteractiveMap('world-map', {
16
+ * image: '/maps/world.jpg',
17
+ * bgImage: '/maps/world-bg.jpg',
18
+ * hotspots: [
19
+ * {
20
+ * type: 'label',
21
+ * content: 'Village',
22
+ * position: { x: 30, y: 40 },
23
+ * action: () => Game.jumpTo('village')
24
+ * },
25
+ * {
26
+ * type: 'image',
27
+ * content: {
28
+ * idle: '/icons/chest.png',
29
+ * hover: '/icons/chest-glow.png'
30
+ * },
31
+ * position: { x: 60, y: 70 },
32
+ * action: () => openChest()
33
+ * },
34
+ * () => player.hasKey ? {
35
+ * type: 'label',
36
+ * content: 'Secret Door',
37
+ * position: 'top',
38
+ * action: () => Game.jumpTo('secret')
39
+ * } : undefined
40
+ * ]
41
+ * });
42
+ * ```
43
+ *
44
+ * @see newInteractiveMap - Factory function for creating InteractiveMap instances
45
+ */
46
+ export declare class InteractiveMap extends Passage {
47
+ /**
48
+ * Configuration for the interactive map including images and hotspots.
49
+ */
50
+ private readonly options;
51
+ /**
52
+ * Creates a new InteractiveMap passage.
53
+ *
54
+ * @param id - Unique identifier for this map
55
+ * @param options - Configuration including image, hotspots, and styling
56
+ */
57
+ constructor(id: string, options: InteractiveMapOptions);
58
+ /**
59
+ * Renders the interactive map by resolving dynamic values and filtering hotspots.
60
+ *
61
+ * Processes all hotspots by:
62
+ * 1. Calling hotspot functions with props (if they are functions)
63
+ * 2. Filtering out undefined hotspots (useful for conditional hotspots)
64
+ * 3. Resolving image URLs (if they are functions)
65
+ *
66
+ * @template T - Type of props to pass when resolving dynamic content
67
+ * @param props - Properties used when evaluating dynamic hotspots/images
68
+ * @returns Processed map configuration ready for rendering
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const map = newInteractiveMap('map', {
73
+ * image: () => `/maps/${currentSeason}.jpg`,
74
+ * hotspots: [
75
+ * () => isNight ? undefined : {
76
+ * type: 'label',
77
+ * content: 'Shop',
78
+ * position: { x: 50, y: 50 },
79
+ * action: () => openShop()
80
+ * }
81
+ * ]
82
+ * });
83
+ *
84
+ * const { image, hotspots } = map.display({ currentSeason: 'winter', isNight: false });
85
+ * ```
86
+ */
87
+ display<T extends InitVarsType = EmptyObject>(props?: T): InteractiveMapType;
88
+ }
89
+ //# sourceMappingURL=interactiveMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactiveMap.d.ts","sourceRoot":"","sources":["../../../src/passages/interactiveMap/interactiveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,cAAe,SAAQ,OAAO;IACvC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAEhD;;;;;OAKG;gBACS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB;IAKtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,CAAC,SAAS,YAAY,GAAG,WAAW,EACxC,KAAK,GAAE,CAAW,GACnB,kBAAkB;CAgBxB"}
@@ -0,0 +1,103 @@
1
+ import { callIfFunction } from "../../helpers";
2
+ import { Passage } from "../../passages/passage";
3
+ /**
4
+ * Map-based interactive passage with clickable hotspots.
5
+ *
6
+ * Interactive maps display an image with interactive hotspots (buttons/images) that
7
+ * can be positioned on the map or on its sides. Hotspots can be labels, images, or menus.
8
+ * Both the map image and hotspots can be dynamic based on game state.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { newInteractiveMap } from '@react-text-game/core';
13
+ *
14
+ * const worldMap = newInteractiveMap('world-map', {
15
+ * image: '/maps/world.jpg',
16
+ * bgImage: '/maps/world-bg.jpg',
17
+ * hotspots: [
18
+ * {
19
+ * type: 'label',
20
+ * content: 'Village',
21
+ * position: { x: 30, y: 40 },
22
+ * action: () => Game.jumpTo('village')
23
+ * },
24
+ * {
25
+ * type: 'image',
26
+ * content: {
27
+ * idle: '/icons/chest.png',
28
+ * hover: '/icons/chest-glow.png'
29
+ * },
30
+ * position: { x: 60, y: 70 },
31
+ * action: () => openChest()
32
+ * },
33
+ * () => player.hasKey ? {
34
+ * type: 'label',
35
+ * content: 'Secret Door',
36
+ * position: 'top',
37
+ * action: () => Game.jumpTo('secret')
38
+ * } : undefined
39
+ * ]
40
+ * });
41
+ * ```
42
+ *
43
+ * @see newInteractiveMap - Factory function for creating InteractiveMap instances
44
+ */
45
+ export class InteractiveMap extends Passage {
46
+ /**
47
+ * Configuration for the interactive map including images and hotspots.
48
+ */
49
+ options;
50
+ /**
51
+ * Creates a new InteractiveMap passage.
52
+ *
53
+ * @param id - Unique identifier for this map
54
+ * @param options - Configuration including image, hotspots, and styling
55
+ */
56
+ constructor(id, options) {
57
+ super(id, "interactiveMap");
58
+ this.options = options;
59
+ }
60
+ /**
61
+ * Renders the interactive map by resolving dynamic values and filtering hotspots.
62
+ *
63
+ * Processes all hotspots by:
64
+ * 1. Calling hotspot functions with props (if they are functions)
65
+ * 2. Filtering out undefined hotspots (useful for conditional hotspots)
66
+ * 3. Resolving image URLs (if they are functions)
67
+ *
68
+ * @template T - Type of props to pass when resolving dynamic content
69
+ * @param props - Properties used when evaluating dynamic hotspots/images
70
+ * @returns Processed map configuration ready for rendering
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const map = newInteractiveMap('map', {
75
+ * image: () => `/maps/${currentSeason}.jpg`,
76
+ * hotspots: [
77
+ * () => isNight ? undefined : {
78
+ * type: 'label',
79
+ * content: 'Shop',
80
+ * position: { x: 50, y: 50 },
81
+ * action: () => openShop()
82
+ * }
83
+ * ]
84
+ * });
85
+ *
86
+ * const { image, hotspots } = map.display({ currentSeason: 'winter', isNight: false });
87
+ * ```
88
+ */
89
+ display(props = {}) {
90
+ const hotspots = this.options.hotspots
91
+ .map((callback) => callIfFunction(callback, props))
92
+ .filter((hotspot) => hotspot !== undefined);
93
+ const image = callIfFunction(this.options.image);
94
+ const bgImage = callIfFunction(this.options.bgImage);
95
+ return {
96
+ ...this.options,
97
+ image,
98
+ bgImage,
99
+ hotspots,
100
+ };
101
+ }
102
+ }
103
+ //# sourceMappingURL=interactiveMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactiveMap.js","sourceRoot":"","sources":["../../../src/passages/interactiveMap/interactiveMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,cAAe,SAAQ,OAAO;IACvC;;OAEG;IACc,OAAO,CAAwB;IAEhD;;;;;OAKG;IACH,YAAY,EAAU,EAAE,OAA8B;QAClD,KAAK,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CACH,QAAW,EAAO;QAElB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ;aACjC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;aAClD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC;QAEhD,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEjD,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC;QAEtD,OAAO;YACH,GAAG,IAAI,CAAC,OAAO;YACf,KAAK;YACL,OAAO;YACP,QAAQ;SACX,CAAC;IACN,CAAC;CACJ"}