@drincs/pixi-vn 0.4.7 → 0.4.8

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 (513) hide show
  1. package/dist/TickerBase-CFEJHstJ.d.mts +73 -0
  2. package/dist/TickerBase-CjfyD6j5.d.ts +73 -0
  3. package/dist/classes/CanvasEvent.d.mts +24 -0
  4. package/dist/classes/CanvasEvent.d.ts +24 -0
  5. package/dist/classes/CanvasEvent.js +12 -0
  6. package/dist/classes/CanvasEvent.js.map +1 -0
  7. package/dist/classes/CanvasEvent.mjs +10 -0
  8. package/dist/classes/CanvasEvent.mjs.map +1 -0
  9. package/dist/classes/CharacterBaseModel.d.mts +90 -0
  10. package/dist/classes/CharacterBaseModel.d.ts +90 -0
  11. package/dist/classes/CharacterBaseModel.js +1529 -0
  12. package/dist/classes/CharacterBaseModel.js.map +1 -0
  13. package/dist/classes/CharacterBaseModel.mjs +1527 -0
  14. package/dist/classes/CharacterBaseModel.mjs.map +1 -0
  15. package/dist/classes/ChoiceMenuOptionLabel.d.mts +42 -0
  16. package/dist/classes/ChoiceMenuOptionLabel.d.ts +42 -0
  17. package/dist/classes/ChoiceMenuOptionLabel.js +19 -0
  18. package/dist/classes/ChoiceMenuOptionLabel.js.map +1 -0
  19. package/dist/classes/ChoiceMenuOptionLabel.mjs +17 -0
  20. package/dist/classes/ChoiceMenuOptionLabel.mjs.map +1 -0
  21. package/dist/classes/DialogueBaseModel.d.mts +58 -0
  22. package/dist/classes/DialogueBaseModel.d.ts +58 -0
  23. package/dist/classes/DialogueBaseModel.js +51 -0
  24. package/dist/classes/DialogueBaseModel.js.map +1 -0
  25. package/dist/classes/DialogueBaseModel.mjs +49 -0
  26. package/dist/classes/DialogueBaseModel.mjs.map +1 -0
  27. package/dist/classes/Label.d.mts +46 -0
  28. package/dist/classes/Label.d.ts +46 -0
  29. package/dist/classes/Label.js +41 -0
  30. package/dist/classes/Label.js.map +1 -0
  31. package/dist/classes/Label.mjs +39 -0
  32. package/dist/classes/Label.mjs.map +1 -0
  33. package/dist/classes/StoredClassModel.d.mts +55 -0
  34. package/dist/classes/StoredClassModel.d.ts +55 -0
  35. package/dist/classes/StoredClassModel.js +1470 -0
  36. package/dist/classes/StoredClassModel.js.map +1 -0
  37. package/dist/classes/StoredClassModel.mjs +1468 -0
  38. package/dist/classes/StoredClassModel.mjs.map +1 -0
  39. package/dist/classes/canvas/CanvasBase.d.mts +37 -0
  40. package/dist/classes/canvas/CanvasBase.d.ts +37 -0
  41. package/dist/classes/canvas/CanvasBase.js +23 -0
  42. package/dist/classes/canvas/CanvasBase.js.map +1 -0
  43. package/dist/classes/canvas/CanvasBase.mjs +21 -0
  44. package/dist/classes/canvas/CanvasBase.mjs.map +1 -0
  45. package/dist/classes/canvas/CanvasContainer.d.mts +30 -0
  46. package/dist/classes/canvas/CanvasContainer.d.ts +30 -0
  47. package/dist/classes/canvas/CanvasContainer.js +514 -0
  48. package/dist/classes/canvas/CanvasContainer.js.map +1 -0
  49. package/dist/classes/canvas/CanvasContainer.mjs +508 -0
  50. package/dist/classes/canvas/CanvasContainer.mjs.map +1 -0
  51. package/dist/classes/canvas/CanvasImage.d.mts +50 -0
  52. package/dist/classes/canvas/CanvasImage.d.ts +50 -0
  53. package/dist/classes/canvas/CanvasImage.js +326 -0
  54. package/dist/classes/canvas/CanvasImage.js.map +1 -0
  55. package/dist/classes/canvas/CanvasImage.mjs +324 -0
  56. package/dist/classes/canvas/CanvasImage.mjs.map +1 -0
  57. package/dist/classes/canvas/CanvasSprite.d.mts +90 -0
  58. package/dist/classes/canvas/CanvasSprite.d.ts +90 -0
  59. package/dist/classes/canvas/CanvasSprite.js +285 -0
  60. package/dist/classes/canvas/CanvasSprite.js.map +1 -0
  61. package/dist/classes/canvas/CanvasSprite.mjs +279 -0
  62. package/dist/classes/canvas/CanvasSprite.mjs.map +1 -0
  63. package/dist/classes/canvas/CanvasText.d.mts +79 -0
  64. package/dist/classes/canvas/CanvasText.d.ts +79 -0
  65. package/dist/classes/canvas/CanvasText.js +259 -0
  66. package/dist/classes/canvas/CanvasText.js.map +1 -0
  67. package/dist/classes/canvas/CanvasText.mjs +253 -0
  68. package/dist/classes/canvas/CanvasText.mjs.map +1 -0
  69. package/dist/classes/canvas/index.d.mts +15 -0
  70. package/dist/classes/canvas/index.d.ts +15 -0
  71. package/dist/classes/canvas/index.js +528 -0
  72. package/dist/classes/canvas/index.js.map +1 -0
  73. package/dist/classes/canvas/index.mjs +522 -0
  74. package/dist/classes/canvas/index.mjs.map +1 -0
  75. package/dist/classes/index.d.mts +14 -0
  76. package/dist/classes/index.d.ts +14 -0
  77. package/dist/classes/index.js +1633 -0
  78. package/dist/classes/index.js.map +1 -0
  79. package/dist/classes/index.mjs +1626 -0
  80. package/dist/classes/index.mjs.map +1 -0
  81. package/dist/classes/ticker/TickerBase.d.mts +3 -0
  82. package/dist/classes/ticker/TickerBase.d.ts +3 -0
  83. package/dist/classes/ticker/TickerBase.js +29 -0
  84. package/dist/classes/ticker/TickerBase.js.map +1 -0
  85. package/dist/classes/ticker/TickerBase.mjs +27 -0
  86. package/dist/classes/ticker/TickerBase.mjs.map +1 -0
  87. package/dist/classes/ticker/TickerFadeAlpha.d.mts +31 -0
  88. package/dist/classes/ticker/TickerFadeAlpha.d.ts +31 -0
  89. package/dist/classes/ticker/TickerFadeAlpha.js +1330 -0
  90. package/dist/classes/ticker/TickerFadeAlpha.js.map +1 -0
  91. package/dist/classes/ticker/TickerFadeAlpha.mjs +1328 -0
  92. package/dist/classes/ticker/TickerFadeAlpha.mjs.map +1 -0
  93. package/dist/classes/ticker/TickerMove.d.mts +29 -0
  94. package/dist/classes/ticker/TickerMove.d.ts +29 -0
  95. package/dist/classes/ticker/TickerMove.js +1328 -0
  96. package/dist/classes/ticker/TickerMove.js.map +1 -0
  97. package/dist/classes/ticker/TickerMove.mjs +1326 -0
  98. package/dist/classes/ticker/TickerMove.mjs.map +1 -0
  99. package/dist/classes/ticker/TickerRotate.d.mts +30 -0
  100. package/dist/classes/ticker/TickerRotate.d.ts +30 -0
  101. package/dist/classes/ticker/TickerRotate.js +1328 -0
  102. package/dist/classes/ticker/TickerRotate.js.map +1 -0
  103. package/dist/classes/ticker/TickerRotate.mjs +1326 -0
  104. package/dist/classes/ticker/TickerRotate.mjs.map +1 -0
  105. package/dist/classes/ticker/index.d.mts +10 -0
  106. package/dist/classes/ticker/index.d.ts +10 -0
  107. package/dist/classes/ticker/index.js +1330 -0
  108. package/dist/classes/ticker/index.js.map +1 -0
  109. package/dist/classes/ticker/index.mjs +1328 -0
  110. package/dist/classes/ticker/index.mjs.map +1 -0
  111. package/dist/constants.d.mts +3 -0
  112. package/dist/constants.d.ts +3 -0
  113. package/dist/constants.js +8 -0
  114. package/dist/constants.js.map +1 -0
  115. package/dist/constants.mjs +6 -0
  116. package/dist/constants.mjs.map +1 -0
  117. package/dist/decorators/CanvasElementDecorator.d.mts +18 -0
  118. package/dist/decorators/CanvasElementDecorator.d.ts +18 -0
  119. package/dist/decorators/CanvasElementDecorator.js +540 -0
  120. package/dist/decorators/CanvasElementDecorator.js.map +1 -0
  121. package/dist/decorators/CanvasElementDecorator.mjs +533 -0
  122. package/dist/decorators/CanvasElementDecorator.mjs.map +1 -0
  123. package/dist/decorators/CharacterDecorator.d.mts +39 -0
  124. package/dist/decorators/CharacterDecorator.d.ts +39 -0
  125. package/dist/decorators/CharacterDecorator.js +37 -0
  126. package/dist/decorators/CharacterDecorator.js.map +1 -0
  127. package/dist/decorators/CharacterDecorator.mjs +32 -0
  128. package/dist/decorators/CharacterDecorator.mjs.map +1 -0
  129. package/dist/decorators/EventDecorator.d.mts +35 -0
  130. package/dist/decorators/EventDecorator.d.ts +35 -0
  131. package/dist/decorators/EventDecorator.js +52 -0
  132. package/dist/decorators/EventDecorator.js.map +1 -0
  133. package/dist/decorators/EventDecorator.mjs +45 -0
  134. package/dist/decorators/EventDecorator.mjs.map +1 -0
  135. package/dist/decorators/LabelDecorator.d.mts +32 -0
  136. package/dist/decorators/LabelDecorator.d.ts +32 -0
  137. package/dist/decorators/LabelDecorator.js +56 -0
  138. package/dist/decorators/LabelDecorator.js.map +1 -0
  139. package/dist/decorators/LabelDecorator.mjs +49 -0
  140. package/dist/decorators/LabelDecorator.mjs.map +1 -0
  141. package/dist/decorators/TickerDecorator.d.mts +27 -0
  142. package/dist/decorators/TickerDecorator.d.ts +27 -0
  143. package/dist/decorators/TickerDecorator.js +36 -0
  144. package/dist/decorators/TickerDecorator.js.map +1 -0
  145. package/dist/decorators/TickerDecorator.mjs +30 -0
  146. package/dist/decorators/TickerDecorator.mjs.map +1 -0
  147. package/dist/decorators/index.d.mts +23 -0
  148. package/dist/decorators/index.d.ts +23 -0
  149. package/dist/decorators/index.js +100 -0
  150. package/dist/decorators/index.js.map +1 -0
  151. package/dist/decorators/index.mjs +92 -0
  152. package/dist/decorators/index.mjs.map +1 -0
  153. package/dist/enums/LabelRunModeEnum.d.mts +9 -0
  154. package/dist/enums/LabelRunModeEnum.d.ts +9 -0
  155. package/dist/enums/LabelRunModeEnum.js +12 -0
  156. package/dist/enums/LabelRunModeEnum.js.map +1 -0
  157. package/dist/enums/LabelRunModeEnum.mjs +10 -0
  158. package/dist/enums/LabelRunModeEnum.mjs.map +1 -0
  159. package/dist/enums/index.d.mts +1 -0
  160. package/dist/enums/index.d.ts +1 -0
  161. package/dist/enums/index.js +12 -0
  162. package/dist/enums/index.js.map +1 -0
  163. package/dist/enums/index.mjs +10 -0
  164. package/dist/enums/index.mjs.map +1 -0
  165. package/dist/functions/CanvasUtility.d.mts +25 -0
  166. package/dist/functions/CanvasUtility.d.ts +25 -0
  167. package/dist/functions/CanvasUtility.js +510 -0
  168. package/dist/functions/CanvasUtility.js.map +1 -0
  169. package/dist/functions/CanvasUtility.mjs +506 -0
  170. package/dist/functions/CanvasUtility.mjs.map +1 -0
  171. package/dist/functions/DialogueUtility.d.mts +72 -0
  172. package/dist/functions/DialogueUtility.d.ts +72 -0
  173. package/dist/functions/DialogueUtility.js +2189 -0
  174. package/dist/functions/DialogueUtility.js.map +1 -0
  175. package/dist/functions/DialogueUtility.mjs +2177 -0
  176. package/dist/functions/DialogueUtility.mjs.map +1 -0
  177. package/dist/functions/DiffUtility.d.mts +5 -0
  178. package/dist/functions/DiffUtility.d.ts +5 -0
  179. package/dist/functions/DiffUtility.js +57 -0
  180. package/dist/functions/DiffUtility.js.map +1 -0
  181. package/dist/functions/DiffUtility.mjs +55 -0
  182. package/dist/functions/DiffUtility.mjs.map +1 -0
  183. package/dist/functions/EasterEgg.d.mts +3 -0
  184. package/dist/functions/EasterEgg.d.ts +3 -0
  185. package/dist/functions/EasterEgg.js +16 -0
  186. package/dist/functions/EasterEgg.js.map +1 -0
  187. package/dist/functions/EasterEgg.mjs +14 -0
  188. package/dist/functions/EasterEgg.mjs.map +1 -0
  189. package/dist/functions/ErrorUtility.d.mts +24 -0
  190. package/dist/functions/ErrorUtility.d.ts +24 -0
  191. package/dist/functions/ErrorUtility.js +261 -0
  192. package/dist/functions/ErrorUtility.js.map +1 -0
  193. package/dist/functions/ErrorUtility.mjs +258 -0
  194. package/dist/functions/ErrorUtility.mjs.map +1 -0
  195. package/dist/functions/ExportUtility.d.mts +8 -0
  196. package/dist/functions/ExportUtility.d.ts +8 -0
  197. package/dist/functions/ExportUtility.js +16 -0
  198. package/dist/functions/ExportUtility.js.map +1 -0
  199. package/dist/functions/ExportUtility.mjs +14 -0
  200. package/dist/functions/ExportUtility.mjs.map +1 -0
  201. package/dist/functions/FlagsUtility.d.mts +14 -0
  202. package/dist/functions/FlagsUtility.d.ts +14 -0
  203. package/dist/functions/FlagsUtility.js +1436 -0
  204. package/dist/functions/FlagsUtility.js.map +1 -0
  205. package/dist/functions/FlagsUtility.mjs +1433 -0
  206. package/dist/functions/FlagsUtility.mjs.map +1 -0
  207. package/dist/functions/GameUtility.d.mts +6 -0
  208. package/dist/functions/GameUtility.d.ts +6 -0
  209. package/dist/functions/GameUtility.js +1335 -0
  210. package/dist/functions/GameUtility.js.map +1 -0
  211. package/dist/functions/GameUtility.mjs +1333 -0
  212. package/dist/functions/GameUtility.mjs.map +1 -0
  213. package/dist/functions/ImageUtility.d.mts +51 -0
  214. package/dist/functions/ImageUtility.d.ts +51 -0
  215. package/dist/functions/ImageUtility.js +1392 -0
  216. package/dist/functions/ImageUtility.js.map +1 -0
  217. package/dist/functions/ImageUtility.mjs +1387 -0
  218. package/dist/functions/ImageUtility.mjs.map +1 -0
  219. package/dist/functions/SavesUtility.d.mts +90 -0
  220. package/dist/functions/SavesUtility.d.ts +90 -0
  221. package/dist/functions/SavesUtility.js +2081 -0
  222. package/dist/functions/SavesUtility.js.map +1 -0
  223. package/dist/functions/SavesUtility.mjs +2071 -0
  224. package/dist/functions/SavesUtility.mjs.map +1 -0
  225. package/dist/functions/StepLabelUtility.d.mts +20 -0
  226. package/dist/functions/StepLabelUtility.d.ts +20 -0
  227. package/dist/functions/StepLabelUtility.js +21 -0
  228. package/dist/functions/StepLabelUtility.js.map +1 -0
  229. package/dist/functions/StepLabelUtility.mjs +14 -0
  230. package/dist/functions/StepLabelUtility.mjs.map +1 -0
  231. package/dist/functions/TextureUtility.d.mts +11 -0
  232. package/dist/functions/TextureUtility.d.ts +11 -0
  233. package/dist/functions/TextureUtility.js +78 -0
  234. package/dist/functions/TextureUtility.js.map +1 -0
  235. package/dist/functions/TextureUtility.mjs +75 -0
  236. package/dist/functions/TextureUtility.mjs.map +1 -0
  237. package/dist/functions/TickerUtility.d.mts +13 -0
  238. package/dist/functions/TickerUtility.d.ts +13 -0
  239. package/dist/functions/TickerUtility.js +33 -0
  240. package/dist/functions/TickerUtility.js.map +1 -0
  241. package/dist/functions/TickerUtility.mjs +31 -0
  242. package/dist/functions/TickerUtility.mjs.map +1 -0
  243. package/dist/functions/index.d.mts +41 -0
  244. package/dist/functions/index.d.ts +41 -0
  245. package/dist/functions/index.js +2313 -0
  246. package/dist/functions/index.js.map +1 -0
  247. package/dist/functions/index.mjs +2289 -0
  248. package/dist/functions/index.mjs.map +1 -0
  249. package/dist/index.d.mts +63 -1773
  250. package/dist/index.d.ts +63 -1773
  251. package/dist/index.js +89 -197
  252. package/dist/index.js.map +1 -1
  253. package/dist/index.mjs +16 -98
  254. package/dist/index.mjs.map +1 -1
  255. package/dist/interface/IClassWithArgsHistory.d.mts +25 -0
  256. package/dist/interface/IClassWithArgsHistory.d.ts +25 -0
  257. package/dist/interface/IClassWithArgsHistory.js +4 -0
  258. package/dist/interface/IClassWithArgsHistory.js.map +1 -0
  259. package/dist/interface/IClassWithArgsHistory.mjs +3 -0
  260. package/dist/interface/IClassWithArgsHistory.mjs.map +1 -0
  261. package/dist/interface/IDialogueHistory.d.mts +33 -0
  262. package/dist/interface/IDialogueHistory.d.ts +33 -0
  263. package/dist/interface/IDialogueHistory.js +4 -0
  264. package/dist/interface/IDialogueHistory.js.map +1 -0
  265. package/dist/interface/IDialogueHistory.mjs +3 -0
  266. package/dist/interface/IDialogueHistory.mjs.map +1 -0
  267. package/dist/interface/IHistoryStep.d.mts +75 -0
  268. package/dist/interface/IHistoryStep.d.ts +75 -0
  269. package/dist/interface/IHistoryStep.js +4 -0
  270. package/dist/interface/IHistoryStep.js.map +1 -0
  271. package/dist/interface/IHistoryStep.mjs +3 -0
  272. package/dist/interface/IHistoryStep.mjs.map +1 -0
  273. package/dist/interface/IOpenedLabel.d.mts +8 -0
  274. package/dist/interface/IOpenedLabel.d.ts +8 -0
  275. package/dist/interface/IOpenedLabel.js +4 -0
  276. package/dist/interface/IOpenedLabel.js.map +1 -0
  277. package/dist/interface/IOpenedLabel.mjs +3 -0
  278. package/dist/interface/IOpenedLabel.mjs.map +1 -0
  279. package/dist/interface/ISaveData.d.mts +33 -0
  280. package/dist/interface/ISaveData.d.ts +33 -0
  281. package/dist/interface/ISaveData.js +4 -0
  282. package/dist/interface/ISaveData.js.map +1 -0
  283. package/dist/interface/ISaveData.mjs +3 -0
  284. package/dist/interface/ISaveData.mjs.map +1 -0
  285. package/dist/interface/ITicker.d.mts +3 -0
  286. package/dist/interface/ITicker.d.ts +3 -0
  287. package/dist/interface/ITicker.js +4 -0
  288. package/dist/interface/ITicker.js.map +1 -0
  289. package/dist/interface/ITicker.mjs +3 -0
  290. package/dist/interface/ITicker.mjs.map +1 -0
  291. package/dist/interface/ITickersSteps.d.mts +31 -0
  292. package/dist/interface/ITickersSteps.d.ts +31 -0
  293. package/dist/interface/ITickersSteps.js +4 -0
  294. package/dist/interface/ITickersSteps.js.map +1 -0
  295. package/dist/interface/ITickersSteps.mjs +3 -0
  296. package/dist/interface/ITickersSteps.mjs.map +1 -0
  297. package/dist/interface/TickerProgrationType.d.mts +13 -0
  298. package/dist/interface/TickerProgrationType.d.ts +13 -0
  299. package/dist/interface/TickerProgrationType.js +4 -0
  300. package/dist/interface/TickerProgrationType.js.map +1 -0
  301. package/dist/interface/TickerProgrationType.mjs +3 -0
  302. package/dist/interface/TickerProgrationType.mjs.map +1 -0
  303. package/dist/interface/canvas/ICanvasBaseMemory.d.mts +8 -0
  304. package/dist/interface/canvas/ICanvasBaseMemory.d.ts +8 -0
  305. package/dist/interface/canvas/ICanvasBaseMemory.js +4 -0
  306. package/dist/interface/canvas/ICanvasBaseMemory.js.map +1 -0
  307. package/dist/interface/canvas/ICanvasBaseMemory.mjs +3 -0
  308. package/dist/interface/canvas/ICanvasBaseMemory.mjs.map +1 -0
  309. package/dist/interface/canvas/ICanvasContainerMemory.d.mts +11 -0
  310. package/dist/interface/canvas/ICanvasContainerMemory.d.ts +11 -0
  311. package/dist/interface/canvas/ICanvasContainerMemory.js +4 -0
  312. package/dist/interface/canvas/ICanvasContainerMemory.js.map +1 -0
  313. package/dist/interface/canvas/ICanvasContainerMemory.mjs +3 -0
  314. package/dist/interface/canvas/ICanvasContainerMemory.mjs.map +1 -0
  315. package/dist/interface/canvas/ICanvasImageMemory.d.mts +14 -0
  316. package/dist/interface/canvas/ICanvasImageMemory.d.ts +14 -0
  317. package/dist/interface/canvas/ICanvasImageMemory.js +4 -0
  318. package/dist/interface/canvas/ICanvasImageMemory.js.map +1 -0
  319. package/dist/interface/canvas/ICanvasImageMemory.mjs +3 -0
  320. package/dist/interface/canvas/ICanvasImageMemory.mjs.map +1 -0
  321. package/dist/interface/canvas/ICanvasSpriteMemory.d.mts +19 -0
  322. package/dist/interface/canvas/ICanvasSpriteMemory.d.ts +19 -0
  323. package/dist/interface/canvas/ICanvasSpriteMemory.js +4 -0
  324. package/dist/interface/canvas/ICanvasSpriteMemory.js.map +1 -0
  325. package/dist/interface/canvas/ICanvasSpriteMemory.mjs +3 -0
  326. package/dist/interface/canvas/ICanvasSpriteMemory.mjs.map +1 -0
  327. package/dist/interface/canvas/ICanvasTextTextMemory.d.mts +15 -0
  328. package/dist/interface/canvas/ICanvasTextTextMemory.d.ts +15 -0
  329. package/dist/interface/canvas/ICanvasTextTextMemory.js +4 -0
  330. package/dist/interface/canvas/ICanvasTextTextMemory.js.map +1 -0
  331. package/dist/interface/canvas/ICanvasTextTextMemory.mjs +3 -0
  332. package/dist/interface/canvas/ICanvasTextTextMemory.mjs.map +1 -0
  333. package/dist/interface/canvas/ITextureMemory.d.mts +8 -0
  334. package/dist/interface/canvas/ITextureMemory.d.ts +8 -0
  335. package/dist/interface/canvas/ITextureMemory.js +4 -0
  336. package/dist/interface/canvas/ITextureMemory.js.map +1 -0
  337. package/dist/interface/canvas/ITextureMemory.mjs +3 -0
  338. package/dist/interface/canvas/ITextureMemory.mjs.map +1 -0
  339. package/dist/interface/canvas/index.d.mts +8 -0
  340. package/dist/interface/canvas/index.d.ts +8 -0
  341. package/dist/interface/canvas/index.js +4 -0
  342. package/dist/interface/canvas/index.js.map +1 -0
  343. package/dist/interface/canvas/index.mjs +3 -0
  344. package/dist/interface/canvas/index.mjs.map +1 -0
  345. package/dist/interface/export/ExportedCanvas.d.mts +19 -0
  346. package/dist/interface/export/ExportedCanvas.d.ts +19 -0
  347. package/dist/interface/export/ExportedCanvas.js +4 -0
  348. package/dist/interface/export/ExportedCanvas.js.map +1 -0
  349. package/dist/interface/export/ExportedCanvas.mjs +3 -0
  350. package/dist/interface/export/ExportedCanvas.mjs.map +1 -0
  351. package/dist/interface/export/ExportedStep.d.mts +34 -0
  352. package/dist/interface/export/ExportedStep.d.ts +34 -0
  353. package/dist/interface/export/ExportedStep.js +4 -0
  354. package/dist/interface/export/ExportedStep.js.map +1 -0
  355. package/dist/interface/export/ExportedStep.mjs +3 -0
  356. package/dist/interface/export/ExportedStep.mjs.map +1 -0
  357. package/dist/interface/export/ExportedStorage.d.mts +10 -0
  358. package/dist/interface/export/ExportedStorage.d.ts +10 -0
  359. package/dist/interface/export/ExportedStorage.js +4 -0
  360. package/dist/interface/export/ExportedStorage.js.map +1 -0
  361. package/dist/interface/export/ExportedStorage.mjs +3 -0
  362. package/dist/interface/export/ExportedStorage.mjs.map +1 -0
  363. package/dist/interface/export/index.d.mts +23 -0
  364. package/dist/interface/export/index.d.ts +23 -0
  365. package/dist/interface/export/index.js +4 -0
  366. package/dist/interface/export/index.js.map +1 -0
  367. package/dist/interface/export/index.mjs +3 -0
  368. package/dist/interface/export/index.mjs.map +1 -0
  369. package/dist/interface/index.d.mts +29 -0
  370. package/dist/interface/index.d.ts +29 -0
  371. package/dist/interface/index.js +4 -0
  372. package/dist/interface/index.js.map +1 -0
  373. package/dist/interface/index.mjs +3 -0
  374. package/dist/interface/index.mjs.map +1 -0
  375. package/dist/managers/StepManager.d.mts +210 -0
  376. package/dist/managers/StepManager.d.ts +210 -0
  377. package/dist/managers/StepManager.js +2043 -0
  378. package/dist/managers/StepManager.js.map +1 -0
  379. package/dist/managers/StepManager.mjs +2037 -0
  380. package/dist/managers/StepManager.mjs.map +1 -0
  381. package/dist/managers/StorageManager.d.mts +45 -0
  382. package/dist/managers/StorageManager.d.ts +45 -0
  383. package/dist/managers/StorageManager.js +101 -0
  384. package/dist/managers/StorageManager.js.map +1 -0
  385. package/dist/managers/StorageManager.mjs +99 -0
  386. package/dist/managers/StorageManager.mjs.map +1 -0
  387. package/dist/managers/WindowManager.d.mts +265 -0
  388. package/dist/managers/WindowManager.d.ts +265 -0
  389. package/dist/managers/WindowManager.js +1142 -0
  390. package/dist/managers/WindowManager.js.map +1 -0
  391. package/dist/managers/WindowManager.mjs +1140 -0
  392. package/dist/managers/WindowManager.mjs.map +1 -0
  393. package/dist/managers/index.d.mts +30 -0
  394. package/dist/managers/index.d.ts +30 -0
  395. package/dist/managers/index.js +2049 -0
  396. package/dist/managers/index.js.map +1 -0
  397. package/dist/managers/index.mjs +2041 -0
  398. package/dist/managers/index.mjs.map +1 -0
  399. package/dist/override/StepLabelProps.d.mts +18 -0
  400. package/dist/override/StepLabelProps.d.ts +18 -0
  401. package/dist/override/StepLabelProps.js +4 -0
  402. package/dist/override/StepLabelProps.js.map +1 -0
  403. package/dist/override/StepLabelProps.mjs +3 -0
  404. package/dist/override/StepLabelProps.mjs.map +1 -0
  405. package/dist/override/StepLabelResult.d.mts +19 -0
  406. package/dist/override/StepLabelResult.d.ts +19 -0
  407. package/dist/override/StepLabelResult.js +4 -0
  408. package/dist/override/StepLabelResult.js.map +1 -0
  409. package/dist/override/StepLabelResult.mjs +3 -0
  410. package/dist/override/StepLabelResult.mjs.map +1 -0
  411. package/dist/override/index.d.mts +2 -0
  412. package/dist/override/index.d.ts +2 -0
  413. package/dist/override/index.js +4 -0
  414. package/dist/override/index.js.map +1 -0
  415. package/dist/override/index.mjs +3 -0
  416. package/dist/override/index.mjs.map +1 -0
  417. package/dist/types/CanvasElementTagType.d.mts +3 -0
  418. package/dist/types/CanvasElementTagType.d.ts +3 -0
  419. package/dist/types/CanvasElementTagType.js +4 -0
  420. package/dist/types/CanvasElementTagType.js.map +1 -0
  421. package/dist/types/CanvasElementTagType.mjs +3 -0
  422. package/dist/types/CanvasElementTagType.mjs.map +1 -0
  423. package/dist/types/CanvasEventNamesType.d.mts +6 -0
  424. package/dist/types/CanvasEventNamesType.d.ts +6 -0
  425. package/dist/types/CanvasEventNamesType.js +4 -0
  426. package/dist/types/CanvasEventNamesType.js.map +1 -0
  427. package/dist/types/CanvasEventNamesType.mjs +3 -0
  428. package/dist/types/CanvasEventNamesType.mjs.map +1 -0
  429. package/dist/types/ChoiceMenuOptionsType.d.mts +16 -0
  430. package/dist/types/ChoiceMenuOptionsType.d.ts +16 -0
  431. package/dist/types/ChoiceMenuOptionsType.js +4 -0
  432. package/dist/types/ChoiceMenuOptionsType.js.map +1 -0
  433. package/dist/types/ChoiceMenuOptionsType.mjs +3 -0
  434. package/dist/types/ChoiceMenuOptionsType.mjs.map +1 -0
  435. package/dist/types/EventIdType.d.mts +3 -0
  436. package/dist/types/EventIdType.d.ts +3 -0
  437. package/dist/types/EventIdType.js +4 -0
  438. package/dist/types/EventIdType.js.map +1 -0
  439. package/dist/types/EventIdType.mjs +3 -0
  440. package/dist/types/EventIdType.mjs.map +1 -0
  441. package/dist/types/LabelIdType.d.mts +7 -0
  442. package/dist/types/LabelIdType.d.ts +7 -0
  443. package/dist/types/LabelIdType.js +4 -0
  444. package/dist/types/LabelIdType.js.map +1 -0
  445. package/dist/types/LabelIdType.mjs +3 -0
  446. package/dist/types/LabelIdType.mjs.map +1 -0
  447. package/dist/types/PauseType.d.mts +8 -0
  448. package/dist/types/PauseType.d.ts +8 -0
  449. package/dist/types/PauseType.js +15 -0
  450. package/dist/types/PauseType.js.map +1 -0
  451. package/dist/types/PauseType.mjs +12 -0
  452. package/dist/types/PauseType.mjs.map +1 -0
  453. package/dist/types/RepeatType.d.mts +4 -0
  454. package/dist/types/RepeatType.d.ts +4 -0
  455. package/dist/types/RepeatType.js +8 -0
  456. package/dist/types/RepeatType.js.map +1 -0
  457. package/dist/types/RepeatType.mjs +6 -0
  458. package/dist/types/RepeatType.mjs.map +1 -0
  459. package/dist/types/StepHistoryDataType.d.mts +8 -0
  460. package/dist/types/StepHistoryDataType.d.ts +8 -0
  461. package/dist/types/StepHistoryDataType.js +4 -0
  462. package/dist/types/StepHistoryDataType.js.map +1 -0
  463. package/dist/types/StepHistoryDataType.mjs +3 -0
  464. package/dist/types/StepHistoryDataType.mjs.map +1 -0
  465. package/dist/types/StepLabelType.d.mts +11 -0
  466. package/dist/types/StepLabelType.d.ts +11 -0
  467. package/dist/types/StepLabelType.js +4 -0
  468. package/dist/types/StepLabelType.js.map +1 -0
  469. package/dist/types/StepLabelType.mjs +3 -0
  470. package/dist/types/StepLabelType.mjs.map +1 -0
  471. package/dist/types/StorageElementType.d.mts +10 -0
  472. package/dist/types/StorageElementType.d.ts +10 -0
  473. package/dist/types/StorageElementType.js +4 -0
  474. package/dist/types/StorageElementType.js.map +1 -0
  475. package/dist/types/StorageElementType.mjs +3 -0
  476. package/dist/types/StorageElementType.mjs.map +1 -0
  477. package/dist/types/TickerIdType.d.mts +7 -0
  478. package/dist/types/TickerIdType.d.ts +7 -0
  479. package/dist/types/TickerIdType.js +4 -0
  480. package/dist/types/TickerIdType.js.map +1 -0
  481. package/dist/types/TickerIdType.mjs +3 -0
  482. package/dist/types/TickerIdType.mjs.map +1 -0
  483. package/dist/types/index.d.mts +13 -0
  484. package/dist/types/index.d.ts +13 -0
  485. package/dist/types/index.js +19 -0
  486. package/dist/types/index.js.map +1 -0
  487. package/dist/types/index.mjs +15 -0
  488. package/dist/types/index.mjs.map +1 -0
  489. package/dist/types/ticker/TickerFadeAlphaProps.d.mts +26 -0
  490. package/dist/types/ticker/TickerFadeAlphaProps.d.ts +26 -0
  491. package/dist/types/ticker/TickerFadeAlphaProps.js +4 -0
  492. package/dist/types/ticker/TickerFadeAlphaProps.js.map +1 -0
  493. package/dist/types/ticker/TickerFadeAlphaProps.mjs +3 -0
  494. package/dist/types/ticker/TickerFadeAlphaProps.mjs.map +1 -0
  495. package/dist/types/ticker/TickerMoveProps.d.mts +26 -0
  496. package/dist/types/ticker/TickerMoveProps.d.ts +26 -0
  497. package/dist/types/ticker/TickerMoveProps.js +4 -0
  498. package/dist/types/ticker/TickerMoveProps.js.map +1 -0
  499. package/dist/types/ticker/TickerMoveProps.mjs +3 -0
  500. package/dist/types/ticker/TickerMoveProps.mjs.map +1 -0
  501. package/dist/types/ticker/TickerRotateProps.d.mts +24 -0
  502. package/dist/types/ticker/TickerRotateProps.d.ts +24 -0
  503. package/dist/types/ticker/TickerRotateProps.js +4 -0
  504. package/dist/types/ticker/TickerRotateProps.js.map +1 -0
  505. package/dist/types/ticker/TickerRotateProps.mjs +3 -0
  506. package/dist/types/ticker/TickerRotateProps.mjs.map +1 -0
  507. package/dist/types/ticker/index.d.mts +3 -0
  508. package/dist/types/ticker/index.d.ts +3 -0
  509. package/dist/types/ticker/index.js +4 -0
  510. package/dist/types/ticker/index.js.map +1 -0
  511. package/dist/types/ticker/index.mjs +3 -0
  512. package/dist/types/ticker/index.mjs.map +1 -0
  513. package/package.json +2 -1
@@ -0,0 +1,2289 @@
1
+ import { diff } from 'deep-diff';
2
+ import sha1 from 'crypto-js/sha1';
3
+ import { Assets, Texture, Sprite, Container, Application, Text } from 'pixi.js';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __defProps = Object.defineProperties;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __decorateClass = (decorators, target, key, kind) => {
26
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
27
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
28
+ if (decorator = decorators[i])
29
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
30
+ if (kind && result)
31
+ __defProp(target, key, result);
32
+ return result;
33
+ };
34
+ var __async = (__this, __arguments, generator) => {
35
+ return new Promise((resolve, reject) => {
36
+ var fulfilled = (value) => {
37
+ try {
38
+ step(generator.next(value));
39
+ } catch (e) {
40
+ reject(e);
41
+ }
42
+ };
43
+ var rejected = (value) => {
44
+ try {
45
+ step(generator.throw(value));
46
+ } catch (e) {
47
+ reject(e);
48
+ }
49
+ };
50
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
51
+ step((generator = generator.apply(__this, __arguments)).next());
52
+ });
53
+ };
54
+
55
+ // src/decorators/LabelDecorator.ts
56
+ var registeredLabels = {};
57
+ function getLabelTypeByClassName(labelName) {
58
+ try {
59
+ let labelType = registeredLabels[labelName];
60
+ if (!labelType) {
61
+ console.error(`[Pixi'VN] Label ${labelName} not found`);
62
+ return;
63
+ }
64
+ new labelType();
65
+ return labelType;
66
+ } catch (e) {
67
+ console.error(`[Pixi'VN] Error while getting Label ${labelName}`, e);
68
+ return;
69
+ }
70
+ }
71
+ function getLabelInstanceByClassName(labelName) {
72
+ try {
73
+ let labelType = registeredLabels[labelName];
74
+ if (!labelType) {
75
+ console.error(`[Pixi'VN] Label ${labelName} not found`);
76
+ return;
77
+ }
78
+ let label = new labelType();
79
+ let step = label.steps;
80
+ if (step.length = 0) {
81
+ console.warn(`[Pixi'VN] Label ${labelName} has no steps`);
82
+ }
83
+ return label;
84
+ } catch (e) {
85
+ console.error(`[Pixi'VN] Error while getting Label ${labelName}`, e);
86
+ return;
87
+ }
88
+ }
89
+
90
+ // src/functions/ExportUtility.ts
91
+ function createExportableElement(element) {
92
+ try {
93
+ let elementString = JSON.stringify(element);
94
+ return JSON.parse(elementString);
95
+ } catch (e) {
96
+ console.error("[Pixi'VN] Error creating exportable element", e);
97
+ throw new Error("[Pixi'VN] Error creating exportable element");
98
+ }
99
+ }
100
+
101
+ // src/functions/DiffUtility.ts
102
+ function restoreDeepDiffChanges(data, differences) {
103
+ let result = createExportableElement(data);
104
+ differences.forEach((diff2) => {
105
+ let dataToEdit = result;
106
+ if (diff2.path && diff2.path.length > 0) {
107
+ diff2.path.forEach((path, index) => {
108
+ if (diff2.path && index === diff2.path.length - 1) {
109
+ if (diff2.kind === "E" || diff2.kind === "D") {
110
+ dataToEdit[path] = diff2.lhs;
111
+ } else if (diff2.kind === "N") {
112
+ if (Number.isInteger(path)) {
113
+ if (Array.isArray(dataToEdit)) {
114
+ dataToEdit.splice(path, 1);
115
+ }
116
+ } else if (typeof path === "string") {
117
+ delete dataToEdit[path];
118
+ }
119
+ } else if (diff2.kind === "A") {
120
+ let index2 = diff2.index;
121
+ if (diff2.item.kind === "N") {
122
+ dataToEdit[path].splice(index2, 1);
123
+ } else if (diff2.item.kind === "E" || diff2.item.kind === "D") {
124
+ dataToEdit[path][index2] = diff2.item.lhs;
125
+ } else if (diff2.item.kind === "A") {
126
+ console.warn("[Pixi'VN] Nested array found, skipping diff", diff2);
127
+ } else {
128
+ console.warn("[Pixi'VN] No array found, skipping diff", diff2);
129
+ }
130
+ }
131
+ } else {
132
+ dataToEdit = dataToEdit[path];
133
+ }
134
+ });
135
+ } else {
136
+ console.warn("[Pixi'VN] No path found, skipping diff", diff2);
137
+ }
138
+ });
139
+ return result;
140
+ }
141
+ function getStepSha1(step) {
142
+ let sha1String = sha1(step.toString().toLocaleLowerCase());
143
+ return sha1String.toString();
144
+ }
145
+ function checkIfStepsIsEqual(step1, step2) {
146
+ return step1 === step2;
147
+ }
148
+
149
+ // src/managers/StorageManager.ts
150
+ var _GameStorageManager = class _GameStorageManager {
151
+ constructor() {
152
+ }
153
+ static get keysSystem() {
154
+ return {
155
+ CURRENT_DIALOGUE_MEMORY_KEY: "___current_dialogue_memory___",
156
+ LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: "___last_dialogue_added_in_step_memory___",
157
+ CURRENT_MENU_OPTIONS_MEMORY_KEY: "___current_menu_options_memory___",
158
+ LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: "___last_menu_options_added_in_step_memory___",
159
+ CHARACTER_CATEGORY_KEY: "___character___",
160
+ FLAGS_CATEGORY_KEY: "___flags___"
161
+ };
162
+ }
163
+ /**
164
+ * Set a variable in the storage
165
+ * @param key The key of the variable
166
+ * @param value The value of the variable. If undefined, the variable will be removed
167
+ * @returns
168
+ */
169
+ static setVariable(key, value) {
170
+ key = key.toLowerCase();
171
+ if (value === void 0 || value === null) {
172
+ if (_GameStorageManager.storage.hasOwnProperty(key)) {
173
+ delete _GameStorageManager.storage[key];
174
+ }
175
+ return;
176
+ }
177
+ _GameStorageManager.storage[key] = value;
178
+ }
179
+ /**
180
+ * Get a variable from the storage
181
+ * @param key The key of the variable
182
+ * @returns The value of the variable. If the variable does not exist, it will return undefined
183
+ */
184
+ static getVariable(key) {
185
+ key = key.toLowerCase();
186
+ if (_GameStorageManager.storage.hasOwnProperty(key)) {
187
+ return _GameStorageManager.storage[key];
188
+ }
189
+ return void 0;
190
+ }
191
+ /**
192
+ * Remove a variable from the storage
193
+ * @param key The key of the variable
194
+ * @returns
195
+ */
196
+ static removeVariable(key) {
197
+ key = key.toLowerCase();
198
+ if (_GameStorageManager.storage.hasOwnProperty(key)) {
199
+ delete _GameStorageManager.storage[key];
200
+ }
201
+ }
202
+ /**
203
+ * Clear the storage and the oidsUsed
204
+ * @returns
205
+ */
206
+ static clear() {
207
+ _GameStorageManager.storage = {};
208
+ }
209
+ static exportJson() {
210
+ return JSON.stringify(this.export());
211
+ }
212
+ static export() {
213
+ return createExportableElement(_GameStorageManager.storage);
214
+ }
215
+ static importJson(dataString) {
216
+ _GameStorageManager.import(JSON.parse(dataString));
217
+ }
218
+ static import(data) {
219
+ _GameStorageManager.clear();
220
+ try {
221
+ if (data) {
222
+ _GameStorageManager.storage = data;
223
+ } else {
224
+ console.warn("[Pixi'VN] No storage data found");
225
+ }
226
+ } catch (e) {
227
+ console.error("[Pixi'VN] Error importing data", e);
228
+ }
229
+ }
230
+ };
231
+ _GameStorageManager.storage = {};
232
+ var GameStorageManager = _GameStorageManager;
233
+
234
+ // src/classes/ticker/TickerBase.ts
235
+ var TickerBase = class {
236
+ /**
237
+ * @param args The arguments that you want to pass to the ticker.
238
+ * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
239
+ * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
240
+ */
241
+ constructor(args, duration, priority) {
242
+ this.args = args;
243
+ this.duration = duration;
244
+ this.priority = priority;
245
+ }
246
+ /**
247
+ * The method that will be called every frame.
248
+ * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.
249
+ * @param t The ticker that is calling this method
250
+ * @param args The arguments that you passed when you added the ticker
251
+ * @param tags The tags of the canvas elements that are connected to this ticker
252
+ */
253
+ fn(_t, _args, _tags) {
254
+ throw new Error("[Pixi'VN] The method TickerBase.fn() must be overridden");
255
+ }
256
+ };
257
+
258
+ // src/decorators/TickerDecorator.ts
259
+ var registeredTickers = {};
260
+ function tickerDecorator(name) {
261
+ return function(target) {
262
+ if (!name) {
263
+ name = target.name;
264
+ }
265
+ if (registeredTickers[name]) {
266
+ console.warn(`[Pixi'VN] Ticker ${name} already exists, it will be overwritten`);
267
+ }
268
+ registeredTickers[name] = target;
269
+ };
270
+ }
271
+ function geTickerInstanceByClassName(tickerName, args, duration, priority) {
272
+ try {
273
+ let ticker = registeredTickers[tickerName];
274
+ if (!ticker) {
275
+ console.error(`[Pixi'VN] Ticker ${tickerName} not found`);
276
+ return;
277
+ }
278
+ return new ticker(args, duration, priority);
279
+ } catch (e) {
280
+ console.error(`[Pixi'VN] Error while getting Ticker ${tickerName}`, e);
281
+ return;
282
+ }
283
+ }
284
+ var CanvasContainer = class extends Container {
285
+ get memory() {
286
+ let memory = getMemoryContainer(this);
287
+ this.children.forEach((child) => {
288
+ memory.elements.push(exportCanvasElement(child));
289
+ });
290
+ return memory;
291
+ }
292
+ set memory(value) {
293
+ setMemoryContainer(this, value);
294
+ value.elements.forEach((child) => {
295
+ this.addChild(importCanvasElement(child));
296
+ });
297
+ }
298
+ };
299
+ function getMemoryContainer(element) {
300
+ return {
301
+ className: "CanvasContainer",
302
+ elements: [],
303
+ width: element.width,
304
+ height: element.height,
305
+ isRenderGroup: element.isRenderGroup,
306
+ blendMode: element.blendMode,
307
+ tint: element.tint,
308
+ alpha: element.alpha,
309
+ angle: element.angle,
310
+ renderable: element.renderable,
311
+ rotation: element.rotation,
312
+ scale: { x: element.scale.x, y: element.scale.y },
313
+ pivot: { x: element.pivot.x, y: element.pivot.y },
314
+ position: { x: element.position.x, y: element.position.y },
315
+ skew: { x: element.skew.x, y: element.skew.y },
316
+ visible: element.visible,
317
+ culled: element.culled,
318
+ x: element.x,
319
+ y: element.y,
320
+ boundsArea: element.boundsArea,
321
+ cursor: element.cursor,
322
+ eventMode: element.eventMode,
323
+ interactive: element.interactive,
324
+ interactiveChildren: element.interactiveChildren,
325
+ hitArea: element.hitArea
326
+ };
327
+ }
328
+ function setMemoryContainer(element, memory) {
329
+ memory.width && (element.width = memory.width);
330
+ memory.height && (element.height = memory.height);
331
+ memory.isRenderGroup && (element.isRenderGroup = memory.isRenderGroup);
332
+ memory.blendMode && (element.blendMode = memory.blendMode);
333
+ memory.tint && (element.tint = memory.tint);
334
+ memory.alpha && (element.alpha = memory.alpha);
335
+ memory.angle && (element.angle = memory.angle);
336
+ memory.renderable && (element.renderable = memory.renderable);
337
+ memory.rotation && (element.rotation = memory.rotation);
338
+ if (memory.scale) {
339
+ if (typeof memory.scale === "number") {
340
+ element.scale.set(memory.scale, memory.scale);
341
+ } else {
342
+ element.scale.set(memory.scale.x, memory.scale.y);
343
+ }
344
+ }
345
+ if (memory.pivot) {
346
+ if (typeof memory.pivot === "number") {
347
+ element.pivot.set(memory.pivot, memory.pivot);
348
+ } else {
349
+ element.pivot.set(memory.pivot.x, memory.pivot.y);
350
+ }
351
+ }
352
+ memory.position && element.position.set(memory.position.x, memory.position.y);
353
+ memory.skew && element.skew.set(memory.skew.x, memory.skew.y);
354
+ memory.visible && (element.visible = memory.visible);
355
+ memory.culled && (element.culled = memory.culled);
356
+ memory.x && (element.x = memory.x);
357
+ memory.y && (element.y = memory.y);
358
+ memory.boundsArea && (element.boundsArea = memory.boundsArea);
359
+ memory.cursor && (element.cursor = memory.cursor);
360
+ memory.eventMode && (element.eventMode = memory.eventMode);
361
+ memory.interactive && (element.interactive = memory.interactive);
362
+ memory.interactiveChildren && (element.interactiveChildren = memory.interactiveChildren);
363
+ memory.hitArea && (element.hitArea = memory.hitArea);
364
+ }
365
+ function getTexture(imageUrl) {
366
+ return __async(this, null, function* () {
367
+ if (Assets.cache.has(imageUrl)) {
368
+ return Assets.get(imageUrl);
369
+ }
370
+ return Assets.load(imageUrl).then((texture) => {
371
+ if (!texture) {
372
+ console.error("[Pixi'VN] Texture not found", imageUrl);
373
+ return;
374
+ }
375
+ if (!(texture instanceof Texture)) {
376
+ console.error("[Pixi'VN] File not is a image", imageUrl);
377
+ return;
378
+ }
379
+ return texture;
380
+ }).catch((e) => {
381
+ console.error("[Pixi'VN] Error loading image", e);
382
+ return;
383
+ });
384
+ });
385
+ }
386
+ function getTextStyle(style) {
387
+ let fill = style.fill;
388
+ if (fill instanceof Object) {
389
+ console.warn("[Pixi'VN] CanvasText.style.fill is a FillGradient or FillPattern, this is not supported yet.", fill);
390
+ fill = "#00FF00";
391
+ }
392
+ return {
393
+ align: style.align,
394
+ breakWords: style.breakWords,
395
+ dropShadow: style.dropShadow,
396
+ fill,
397
+ fontFamily: style.fontFamily,
398
+ fontSize: style.fontSize,
399
+ fontStyle: style.fontStyle,
400
+ fontVariant: style.fontVariant,
401
+ fontWeight: style.fontWeight,
402
+ leading: style.leading,
403
+ letterSpacing: style.letterSpacing,
404
+ lineHeight: style.lineHeight,
405
+ padding: style.padding,
406
+ stroke: style.stroke,
407
+ textBaseline: style.textBaseline,
408
+ trim: style.trim,
409
+ whiteSpace: style.whiteSpace,
410
+ wordWrap: style.wordWrap,
411
+ wordWrapWidth: style.wordWrapWidth
412
+ };
413
+ }
414
+
415
+ // src/decorators/EventDecorator.ts
416
+ var registeredEvents = {};
417
+ function getEventTypeByClassName(eventName) {
418
+ try {
419
+ let eventType = registeredEvents[eventName];
420
+ if (!eventType) {
421
+ console.error(`[Pixi'VN] Event ${eventName} not found`);
422
+ return;
423
+ }
424
+ new eventType();
425
+ return eventType;
426
+ } catch (e) {
427
+ console.error(`[Pixi'VN] Error while getting Event ${eventName}`, e);
428
+ return;
429
+ }
430
+ }
431
+ function getEventInstanceByClassName(eventName) {
432
+ try {
433
+ let eventType = registeredEvents[eventName];
434
+ if (!eventType) {
435
+ console.error(`[Pixi'VN] Event ${eventName} not found`);
436
+ return;
437
+ }
438
+ let event = new eventType();
439
+ return event;
440
+ } catch (e) {
441
+ console.error(`[Pixi'VN] Error while getting Event ${eventName}`, e);
442
+ return;
443
+ }
444
+ }
445
+
446
+ // src/classes/canvas/CanvasSprite.ts
447
+ var CanvasSprite = class _CanvasSprite extends Sprite {
448
+ constructor() {
449
+ super(...arguments);
450
+ this._onEvents = {};
451
+ }
452
+ get memory() {
453
+ return getMemorySprite(this);
454
+ }
455
+ set memory(value) {
456
+ setMemorySprite(this, value);
457
+ }
458
+ get onEvents() {
459
+ return this._onEvents;
460
+ }
461
+ /**
462
+ * is same function as on(), but it keeps in memory the children.
463
+ * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
464
+ * @param eventClass The class that extends CanvasEvent.
465
+ * @returns
466
+ * @example
467
+ * ```typescript
468
+ * \@eventDecorator()
469
+ * export class EventTest extends CanvasEvent<CanvasSprite> {
470
+ * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void {
471
+ * if (event === 'pointerdown') {
472
+ * sprite.scale.x *= 1.25;
473
+ * sprite.scale.y *= 1.25;
474
+ * }
475
+ * }
476
+ * }
477
+ * ```
478
+ *
479
+ * ```typescript
480
+ * let sprite = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
481
+ * await sprite.load()
482
+ *
483
+ * sprite.eventMode = 'static';
484
+ * sprite.cursor = 'pointer';
485
+ * sprite.onEvent('pointerdown', EventTest);
486
+ *
487
+ * GameWindowManager.addCanvasElement("bunny", sprite);
488
+ * ```
489
+ */
490
+ onEvent(event, eventClass) {
491
+ let className = eventClass.name;
492
+ let instance = getEventInstanceByClassName(className);
493
+ this._onEvents[event] = className;
494
+ if (instance) {
495
+ super.on(event, () => {
496
+ instance.fn(event, this);
497
+ });
498
+ }
499
+ return this;
500
+ }
501
+ /**
502
+ * on() does not keep in memory the event class, use onEvent() instead
503
+ * @deprecated
504
+ * @private
505
+ * @param event
506
+ * @param fn
507
+ * @param context
508
+ */
509
+ on(event, fn, context) {
510
+ return super.on(event, fn, context);
511
+ }
512
+ static from(source, skipCache) {
513
+ let sprite = Sprite.from(source, skipCache);
514
+ let mySprite = new _CanvasSprite();
515
+ mySprite.texture = sprite.texture;
516
+ return mySprite;
517
+ }
518
+ };
519
+ function getMemorySprite(element) {
520
+ let temp = getMemoryContainer(element);
521
+ return __spreadProps(__spreadValues({}, temp), {
522
+ className: "CanvasSprite",
523
+ textureImage: getTextureMemory(element.texture),
524
+ anchor: { x: element.anchor.x, y: element.anchor.y },
525
+ roundPixels: element.roundPixels,
526
+ onEvents: element.onEvents
527
+ });
528
+ }
529
+ function setMemorySprite(element, memory) {
530
+ setMemoryContainer(element, memory);
531
+ getTexture(memory.textureImage.image).then((texture) => {
532
+ if (texture) {
533
+ element.texture = texture;
534
+ }
535
+ });
536
+ if (memory.anchor) {
537
+ if (typeof memory.anchor === "number") {
538
+ element.anchor.set(memory.anchor, memory.anchor);
539
+ } else {
540
+ element.anchor.set(memory.anchor.x, memory.anchor.y);
541
+ }
542
+ }
543
+ memory.roundPixels && (element.roundPixels = memory.roundPixels);
544
+ for (let event in memory.onEvents) {
545
+ let className = memory.onEvents[event];
546
+ let instance = getEventTypeByClassName(className);
547
+ if (instance) {
548
+ element.onEvent(event, instance);
549
+ }
550
+ }
551
+ }
552
+
553
+ // src/classes/canvas/CanvasImage.ts
554
+ var CanvasImage = class _CanvasImage extends CanvasSprite {
555
+ constructor(options, imageLink) {
556
+ super(options);
557
+ this.imageLink = "";
558
+ if (imageLink) {
559
+ this.imageLink = imageLink;
560
+ }
561
+ }
562
+ get memory() {
563
+ return __spreadProps(__spreadValues({}, getMemorySprite(this)), {
564
+ className: "CanvasImage",
565
+ textureImage: { image: this.imageLink }
566
+ });
567
+ }
568
+ set memory(memory) {
569
+ setMemorySprite(this, memory);
570
+ }
571
+ static from(source, skipCache) {
572
+ let sprite = Sprite.from(source, skipCache);
573
+ let mySprite = new _CanvasImage();
574
+ mySprite.texture = sprite.texture;
575
+ return mySprite;
576
+ }
577
+ /**
578
+ * Load the image from the link and set the texture of the sprite.
579
+ * @param image The link of the image. If it is not set, it will use the imageLink property.
580
+ * @returns A promise that resolves when the image is loaded.
581
+ */
582
+ load(image) {
583
+ return __async(this, null, function* () {
584
+ if (!image) {
585
+ image = this.imageLink;
586
+ }
587
+ return getTexture(this.imageLink).then((texture) => {
588
+ if (texture) {
589
+ this.texture = texture;
590
+ }
591
+ }).catch((e) => {
592
+ console.error("[Pixi'VN] Error into CanvasImage.load()", e);
593
+ });
594
+ });
595
+ }
596
+ };
597
+ var CanvasText = class extends Text {
598
+ constructor() {
599
+ super(...arguments);
600
+ this._onEvents = {};
601
+ }
602
+ get memory() {
603
+ return getMemoryText(this);
604
+ }
605
+ set memory(value) {
606
+ setMemoryText(this, value);
607
+ }
608
+ get onEvents() {
609
+ return this._onEvents;
610
+ }
611
+ /**
612
+ * is same function as on(), but it keeps in memory the children.
613
+ * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
614
+ * @param eventClass The class that extends CanvasEvent.
615
+ * @returns
616
+ * @example
617
+ * ```typescript
618
+ * \@eventDecorator()
619
+ * export class EventTest extends CanvasEvent<CanvasText> {
620
+ * override fn(event: CanvasEventNamesType, text: CanvasText): void {
621
+ * if (event === 'pointerdown') {
622
+ * text.scale.x *= 1.25;
623
+ * text.scale.y *= 1.25;
624
+ * }
625
+ * }
626
+ * }
627
+ * ```
628
+ *
629
+ * ```typescript
630
+ * const text = new CanvasText();
631
+ * text.text = "Hello World"
632
+ *
633
+ * text.eventMode = 'static';
634
+ * text.cursor = 'pointer';
635
+ * text.onEvent('pointerdown', EventTest);
636
+ *
637
+ * GameWindowManager.addCanvasElement("text", text);
638
+ * ```
639
+ */
640
+ onEvent(event, eventClass) {
641
+ let className = eventClass.name;
642
+ let instance = getEventInstanceByClassName(className);
643
+ this._onEvents[event] = className;
644
+ if (instance) {
645
+ super.on(event, () => {
646
+ instance.fn(event, this);
647
+ });
648
+ }
649
+ return this;
650
+ }
651
+ /**
652
+ * on() does not keep in memory the event class, use onEvent() instead
653
+ * @deprecated
654
+ * @private
655
+ * @param event
656
+ * @param fn
657
+ * @param context
658
+ */
659
+ on(event, fn, context) {
660
+ return super.on(event, fn, context);
661
+ }
662
+ };
663
+ function getMemoryText(element) {
664
+ let temp = getMemoryContainer(element);
665
+ return __spreadProps(__spreadValues({}, temp), {
666
+ className: "CanvasText",
667
+ anchor: { x: element.anchor.x, y: element.anchor.y },
668
+ text: element.text,
669
+ resolution: element.resolution,
670
+ style: getTextStyle(element.style),
671
+ roundPixels: element.roundPixels,
672
+ onEvents: element.onEvents
673
+ });
674
+ }
675
+ function setMemoryText(element, memory) {
676
+ setMemoryContainer(element, memory);
677
+ if (memory.anchor) {
678
+ if (typeof memory.anchor === "number") {
679
+ element.anchor.set(memory.anchor, memory.anchor);
680
+ } else {
681
+ element.anchor.set(memory.anchor.x, memory.anchor.y);
682
+ }
683
+ }
684
+ memory.text && (element.text = memory.text);
685
+ memory.resolution && (element.resolution = memory.resolution);
686
+ memory.style && (element.style = memory.style);
687
+ memory.roundPixels && (element.roundPixels = memory.roundPixels);
688
+ for (let event in memory.onEvents) {
689
+ let className = memory.onEvents[event];
690
+ let instance = getEventTypeByClassName(className);
691
+ if (instance) {
692
+ element.onEvent(event, instance);
693
+ }
694
+ }
695
+ }
696
+
697
+ // src/decorators/CanvasElementDecorator.ts
698
+ var registeredCanvasElement = {};
699
+ function getCanvasElementInstanceByClassName(canvasName) {
700
+ try {
701
+ let eventType = registeredCanvasElement[canvasName];
702
+ if (!eventType) {
703
+ if (canvasName === "CanvasContainer") {
704
+ eventType = CanvasContainer;
705
+ } else if (canvasName === "CanvasImage") {
706
+ eventType = CanvasImage;
707
+ } else if (canvasName === "CanvasSprite") {
708
+ eventType = CanvasSprite;
709
+ } else if (canvasName === "CanvasText") {
710
+ eventType = CanvasText;
711
+ }
712
+ }
713
+ if (!eventType) {
714
+ console.error(`[Pixi'VN] CanvasElement ${canvasName} not found`);
715
+ return;
716
+ }
717
+ let canvasElement = new eventType();
718
+ return canvasElement;
719
+ } catch (e) {
720
+ console.error(`[Pixi'VN] Error while getting CanvasElement ${canvasName}`, e);
721
+ return;
722
+ }
723
+ }
724
+
725
+ // src/functions/CanvasUtility.ts
726
+ function getTextureMemory(texture) {
727
+ let sourceTexture = texture.source;
728
+ let textureMemory = {
729
+ image: sourceTexture.label
730
+ };
731
+ return textureMemory;
732
+ }
733
+ function exportCanvasElement(element) {
734
+ return element.memory;
735
+ }
736
+ function importCanvasElement(memory) {
737
+ let element = getCanvasElementInstanceByClassName(memory.className);
738
+ if (element) {
739
+ element.memory = memory;
740
+ } else {
741
+ throw new Error("[Pixi'VN] The element " + memory.className + " could not be created");
742
+ }
743
+ return element;
744
+ }
745
+
746
+ // src/functions/EasterEgg.ts
747
+ function asciiArtLog() {
748
+ console.info(`
749
+ ____ _ _ ___ ___ _
750
+ | _ \\(_)_ _(_| ) \\ / / \\ | |
751
+ | |_) | \\ \\/ / |/ \\ \\ / /| \\| |
752
+ | __/| |> <| | \\ V / | |\\ |
753
+ |_| |_/_/\\_\\_| \\_/ |_| \\_|
754
+ `);
755
+ }
756
+
757
+ // src/types/PauseType.ts
758
+ var PauseValueType = "Pause";
759
+
760
+ // src/types/RepeatType.ts
761
+ var Repeat = "Repeat";
762
+
763
+ // src/managers/WindowManager.ts
764
+ var _GameWindowManager = class _GameWindowManager {
765
+ constructor() {
766
+ }
767
+ /**
768
+ * The PIXI Application instance.
769
+ * It not recommended to use this property directly.
770
+ */
771
+ static get app() {
772
+ if (!_GameWindowManager._app) {
773
+ throw new Error("[Pixi'VN] GameWindowManager.app is undefined");
774
+ }
775
+ return _GameWindowManager._app;
776
+ }
777
+ /**
778
+ * If the manager is initialized.
779
+ */
780
+ static get isInitialized() {
781
+ return _GameWindowManager._isInitialized;
782
+ }
783
+ static get screen() {
784
+ return _GameWindowManager.app.screen;
785
+ }
786
+ /**
787
+ * Initialize the PIXI Application and the interface div.
788
+ * This method should be called before any other method.
789
+ * @param element The html element where I will put the canvas. Example: document.body
790
+ * @param width The width of the canvas
791
+ * @param height The height of the canvas
792
+ * @param options The options of PIXI Application
793
+ * @example
794
+ * ```typescript
795
+ * const body = document.body
796
+ * if (!body) {
797
+ * throw new Error('body element not found')
798
+ * }
799
+ * await GameWindowManager.initialize(body, 1920, 1080, {
800
+ * backgroundColor: "#303030"
801
+ * })
802
+ * ```
803
+ */
804
+ static initialize(element, width, height, options) {
805
+ return __async(this, null, function* () {
806
+ _GameWindowManager.canvasWidth = width;
807
+ _GameWindowManager.canvasHeight = height;
808
+ _GameWindowManager._app = new Application();
809
+ return _GameWindowManager.app.init(__spreadValues({
810
+ resolution: window.devicePixelRatio || 1,
811
+ autoDensity: true,
812
+ width,
813
+ height
814
+ }, options)).then(() => {
815
+ _GameWindowManager._isInitialized = true;
816
+ this.addCanvasIntoElement(element);
817
+ window.addEventListener("resize", _GameWindowManager.resize);
818
+ _GameWindowManager.resize();
819
+ asciiArtLog();
820
+ });
821
+ });
822
+ }
823
+ /**
824
+ * Add the canvas into a html element.
825
+ * @param element it is the html element where I will put the canvas. Example: document.body
826
+ */
827
+ static addCanvasIntoElement(element) {
828
+ if (_GameWindowManager.isInitialized) {
829
+ element.appendChild(_GameWindowManager.app.canvas);
830
+ } else {
831
+ console.error("[Pixi'VN] GameWindowManager is not initialized");
832
+ }
833
+ }
834
+ /**
835
+ * Initialize the interface div and add it into a html element.
836
+ * @param element it is the html element where I will put the interface div. Example: document.getElementById('root')
837
+ * @example
838
+ * ```typescript
839
+ * const root = document.getElementById('root')
840
+ * if (!root) {
841
+ * throw new Error('root element not found')
842
+ * }
843
+ * GameWindowManager.initializeHTMLLayout(root)
844
+ * const reactRoot = createRoot(GameWindowManager.htmlLayout)
845
+ * reactRoot.render(
846
+ * <App />
847
+ * )
848
+ * ```
849
+ */
850
+ static initializeHTMLLayout(element) {
851
+ let div = document.createElement("div");
852
+ div.style.position = "absolute";
853
+ div.style.pointerEvents = "none";
854
+ element.appendChild(div);
855
+ _GameWindowManager.htmlLayout = div;
856
+ _GameWindowManager.resize();
857
+ }
858
+ /* Resize Metods */
859
+ /**
860
+ * This method returns the scale of the screen.
861
+ */
862
+ static get screenScale() {
863
+ let screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
864
+ let screenHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
865
+ return Math.min(screenWidth / _GameWindowManager.canvasWidth, screenHeight / _GameWindowManager.canvasHeight);
866
+ }
867
+ /**
868
+ * This method returns the width of the screen enlarged by the scale.
869
+ */
870
+ static get screenWidth() {
871
+ return Math.floor(_GameWindowManager.screenScale * _GameWindowManager.canvasWidth);
872
+ }
873
+ /**
874
+ * This method returns the height of the screen enlarged by the scale.
875
+ */
876
+ static get screenHeight() {
877
+ return Math.floor(_GameWindowManager.screenScale * _GameWindowManager.canvasHeight);
878
+ }
879
+ /**
880
+ * This method returns the horizontal margin of the screen.
881
+ */
882
+ static get horizontalMargin() {
883
+ let screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
884
+ return (screenWidth - _GameWindowManager.screenWidth) / 2;
885
+ }
886
+ /**
887
+ * This method returns the vertical margin of the screen.
888
+ */
889
+ static get verticalMargin() {
890
+ let screenHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
891
+ return (screenHeight - _GameWindowManager.screenHeight) / 2;
892
+ }
893
+ /**
894
+ * This method is called when the screen is resized.
895
+ */
896
+ static resize() {
897
+ if (_GameWindowManager.isInitialized) {
898
+ let style = _GameWindowManager.app.canvas.style;
899
+ style.width = `${_GameWindowManager.screenWidth}px`;
900
+ style.height = `${_GameWindowManager.screenHeight}px`;
901
+ style.marginLeft = `${_GameWindowManager.horizontalMargin}px`;
902
+ style.marginRight = `${_GameWindowManager.horizontalMargin}px`;
903
+ style.marginTop = `${_GameWindowManager.verticalMargin}px`;
904
+ style.marginBottom = `${_GameWindowManager.verticalMargin}px`;
905
+ }
906
+ if (_GameWindowManager.htmlLayout) {
907
+ _GameWindowManager.htmlLayout.style.width = `${_GameWindowManager.screenWidth}px`;
908
+ _GameWindowManager.htmlLayout.style.height = `${_GameWindowManager.screenHeight}px`;
909
+ _GameWindowManager.htmlLayout.style.marginLeft = `${_GameWindowManager.horizontalMargin}px`;
910
+ _GameWindowManager.htmlLayout.style.marginRight = `${_GameWindowManager.horizontalMargin}px`;
911
+ _GameWindowManager.htmlLayout.style.marginTop = `${_GameWindowManager.verticalMargin}px`;
912
+ _GameWindowManager.htmlLayout.style.marginBottom = `${_GameWindowManager.verticalMargin}px`;
913
+ }
914
+ }
915
+ /* Edit Canvas Elements Methods */
916
+ /**
917
+ * This is a dictionary that contains all Canvas Elements of Canvas, currently.
918
+ */
919
+ static get currentCanvasElements() {
920
+ return _GameWindowManager._children;
921
+ }
922
+ /**
923
+ * Add a canvas element to the canvas.
924
+ * If there is a canvas element with the same tag, it will be removed.
925
+ * @param tag The tag of the canvas element.
926
+ * @param canvasElement The canvas elements to be added.
927
+ * @example
928
+ * ```typescript
929
+ * const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
930
+ * const sprite = CanvasSprite.from(texture);
931
+ * GameWindowManager.addCanvasElement("bunny", sprite);
932
+ * ```
933
+ */
934
+ static addCanvasElement(tag, canvasElement) {
935
+ if (_GameWindowManager._children[tag]) {
936
+ _GameWindowManager.removeCanvasElement(tag);
937
+ }
938
+ _GameWindowManager.app.stage.addChild(canvasElement);
939
+ _GameWindowManager._children[tag] = canvasElement;
940
+ _GameWindowManager.childrenTagsOrder.push(tag);
941
+ }
942
+ /**
943
+ * Remove a canvas element from the canvas.
944
+ * And remove all tickers that are not connected to any canvas element.
945
+ * @param tag The tag of the canvas element to be removed.
946
+ * @returns
947
+ * @example
948
+ * ```typescript
949
+ * GameWindowManager.removeCanvasElement("bunny");
950
+ * ```
951
+ */
952
+ static removeCanvasElement(tag) {
953
+ if (typeof tag === "string") {
954
+ tag = [tag];
955
+ }
956
+ tag.forEach((t) => {
957
+ if (_GameWindowManager._children[t]) {
958
+ _GameWindowManager.app.stage.removeChild(_GameWindowManager._children[t]);
959
+ delete _GameWindowManager._children[t];
960
+ }
961
+ });
962
+ _GameWindowManager.removeTickersWithoutAssociatedCanvasElement();
963
+ _GameWindowManager.childrenTagsOrder = _GameWindowManager.childrenTagsOrder.filter((t) => !tag.includes(t));
964
+ }
965
+ /**
966
+ * Get a canvas element by the tag.
967
+ * @param tag The tag of the canvas element.
968
+ * @returns The canvas element.
969
+ * @example
970
+ * ```typescript
971
+ * const sprite = GameWindowManager.getCanvasElement<CanvasSprite>("bunny");
972
+ * ```
973
+ */
974
+ static getCanvasElement(tag) {
975
+ return _GameWindowManager._children[tag];
976
+ }
977
+ /**
978
+ * Check if a DisplayObject is on the canvas.
979
+ * @param pixiElement The DisplayObject to be checked.
980
+ * @returns If the DisplayObject is on the canvas.
981
+ */
982
+ static canvasElementIsOnCanvas(pixiElement) {
983
+ return _GameWindowManager.app.stage.children.includes(pixiElement);
984
+ }
985
+ /**
986
+ * Remove all canvas elements from the canvas.
987
+ * And remove all tickers that are not connected to any canvas element.
988
+ */
989
+ static removeCanvasElements() {
990
+ _GameWindowManager.app.stage.removeChildren();
991
+ _GameWindowManager._children = {};
992
+ _GameWindowManager.childrenTagsOrder = [];
993
+ _GameWindowManager.removeTickers();
994
+ }
995
+ /**
996
+ * Edit the tag of a canvas element.
997
+ * @param oldTag The old tag of the canvas element.
998
+ * @param newTag The new tag of the canvas element.
999
+ */
1000
+ static editTagCanvasElement(oldTag, newTag) {
1001
+ if (_GameWindowManager._children[oldTag]) {
1002
+ _GameWindowManager._children[newTag] = _GameWindowManager._children[oldTag];
1003
+ delete _GameWindowManager._children[oldTag];
1004
+ }
1005
+ }
1006
+ /** Edit Tickers Methods */
1007
+ /**
1008
+ * Currently tickers that are running.
1009
+ */
1010
+ static get currentTickers() {
1011
+ return _GameWindowManager._currentTickers;
1012
+ }
1013
+ /**
1014
+ * The steps of the tickers
1015
+ */
1016
+ static get currentTickersSteps() {
1017
+ return _GameWindowManager._currentTickersSteps;
1018
+ }
1019
+ /**
1020
+ * Run a ticker.
1021
+ * @param canvasEslementTag The tag of the canvas element that will use the ticker.
1022
+ * @param ticker The ticker class to be run.
1023
+ * @param args The arguments to be used in the ticker.
1024
+ * @param duration The time to be used in the ticker. This number is in milliseconds. If it is undefined, the ticker will run forever.
1025
+ * @param priority The priority to be used in the ticker.
1026
+ * @returns
1027
+ * @example
1028
+ * ```typescript
1029
+ * GameWindowManager.addTicker("alien", new TickerRotate({ speed: 0.2 }))
1030
+ * ```
1031
+ */
1032
+ static addTicker(canvasElementTag, ticker) {
1033
+ let tickerName = ticker.constructor.name;
1034
+ if (typeof canvasElementTag === "string") {
1035
+ canvasElementTag = [canvasElementTag];
1036
+ }
1037
+ let t = geTickerInstanceByClassName(tickerName, ticker.args, ticker.duration, ticker.priority);
1038
+ if (!t) {
1039
+ console.error(`[Pixi'VN] Ticker ${tickerName} not found`);
1040
+ return;
1041
+ }
1042
+ _GameWindowManager.removeAssociationBetweenTickerCanvasElement(canvasElementTag, ticker);
1043
+ let tickerHistory = {
1044
+ fn: () => {
1045
+ },
1046
+ className: tickerName,
1047
+ args: ticker.args,
1048
+ canvasElementTags: canvasElementTag,
1049
+ priority: ticker.priority,
1050
+ duration: ticker.duration
1051
+ };
1052
+ _GameWindowManager.pushTicker(tickerHistory, t);
1053
+ _GameWindowManager.removeTickersWithoutAssociatedCanvasElement();
1054
+ if (ticker.duration) {
1055
+ let timeout = setTimeout(() => {
1056
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
1057
+ _GameWindowManager.nextTickerStep(canvasElementTag);
1058
+ }, ticker.duration);
1059
+ _GameWindowManager.addTickerTimeoutInfo(canvasElementTag, tickerName, timeout.toString());
1060
+ }
1061
+ }
1062
+ static pushTicker(tickerData, ticker) {
1063
+ _GameWindowManager.removeAssociationBetweenTickerCanvasElement(tickerData.canvasElementTags, tickerData);
1064
+ _GameWindowManager._currentTickers.push(tickerData);
1065
+ tickerData.fn = (t) => {
1066
+ ticker == null ? void 0 : ticker.fn(t, tickerData.args, tickerData.canvasElementTags);
1067
+ };
1068
+ _GameWindowManager.app.ticker.add(tickerData.fn, void 0, tickerData.priority);
1069
+ }
1070
+ /**
1071
+ * Run a sequence of tickers.
1072
+ * @param tag The tag of canvas element that will use the tickers.
1073
+ * @param steps The steps of the tickers.
1074
+ * @returns
1075
+ * @example
1076
+ * ```typescript
1077
+ * GameWindowManager.addTickersSteps("alien", [
1078
+ * new TickerRotate({ speed: 0.1, clockwise: true }, 2000),
1079
+ * Pause(500),
1080
+ * new TickerRotate({ speed: 0.2, clockwise: false }, 2000),
1081
+ * Repeat,
1082
+ * ])
1083
+ * ```
1084
+ */
1085
+ static addTickersSteps(tag, steps) {
1086
+ if (steps.length == 0) {
1087
+ console.warn("[Pixi'VN] The steps of the tickers is empty");
1088
+ return;
1089
+ }
1090
+ let alredyExists = _GameWindowManager._currentTickersSteps[tag] !== void 0;
1091
+ _GameWindowManager._currentTickersSteps[tag] = {
1092
+ currentStepNumber: 0,
1093
+ steps: steps.map((s) => {
1094
+ if (s === Repeat) {
1095
+ return s;
1096
+ }
1097
+ if (!s.duration) {
1098
+ console.warn("[Pixi'VN] Duration is not defined, so it will be set to 1000");
1099
+ s.duration = 1e3;
1100
+ }
1101
+ if (s.hasOwnProperty("type") && s.type === PauseValueType) {
1102
+ return s;
1103
+ }
1104
+ let tickerName = s.constructor.name;
1105
+ return {
1106
+ ticker: tickerName,
1107
+ args: s.args,
1108
+ duration: s.duration
1109
+ };
1110
+ })
1111
+ };
1112
+ if (!alredyExists) {
1113
+ _GameWindowManager.runTickersSteps(tag);
1114
+ }
1115
+ }
1116
+ static runTickersSteps(tag) {
1117
+ let step = _GameWindowManager._currentTickersSteps[tag].steps[_GameWindowManager._currentTickersSteps[tag].currentStepNumber];
1118
+ if (step === Repeat) {
1119
+ step = _GameWindowManager._currentTickersSteps[tag].steps[0];
1120
+ _GameWindowManager._currentTickersSteps[tag].currentStepNumber = 0;
1121
+ if (step === Repeat) {
1122
+ console.error("[Pixi'VN] TikersSteps has a RepeatType in the first step");
1123
+ return;
1124
+ }
1125
+ }
1126
+ if (step.hasOwnProperty("type") && step.type === PauseValueType) {
1127
+ let timeout = setTimeout(() => {
1128
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
1129
+ _GameWindowManager.nextTickerStep(tag);
1130
+ }, step.duration);
1131
+ _GameWindowManager.addTickerTimeoutInfo(tag, "steps", timeout.toString());
1132
+ return;
1133
+ }
1134
+ let ticker = geTickerInstanceByClassName(step.ticker, step.args, step.duration, step.priority);
1135
+ if (!ticker) {
1136
+ console.error(`[Pixi'VN] Ticker ${step.ticker} not found`);
1137
+ return;
1138
+ }
1139
+ _GameWindowManager.addTicker(tag, ticker);
1140
+ }
1141
+ static nextTickerStep(tag) {
1142
+ if (typeof tag === "string") {
1143
+ tag = [tag];
1144
+ }
1145
+ tag.forEach((tag2) => {
1146
+ if (_GameWindowManager._currentTickersSteps[tag2]) {
1147
+ let steps = _GameWindowManager._currentTickersSteps[tag2];
1148
+ if (steps.currentStepNumber + 1 < steps.steps.length) {
1149
+ steps.currentStepNumber++;
1150
+ _GameWindowManager._currentTickersSteps[tag2] = steps;
1151
+ _GameWindowManager.runTickersSteps(tag2);
1152
+ } else {
1153
+ delete _GameWindowManager._currentTickersSteps[tag2];
1154
+ }
1155
+ }
1156
+ });
1157
+ }
1158
+ /**
1159
+ * Remove a connection between a canvas element and a ticker.
1160
+ * And remove the ticker if there is no canvas element connected to it.
1161
+ * @param tag The tag of the canvas element that will use the ticker.
1162
+ * @param ticker The ticker class to be removed.
1163
+ * @example
1164
+ * ```typescript
1165
+ * GameWindowManager.removeAssociationBetweenTickerCanvasElement("alien", TickerRotate)
1166
+ * ```
1167
+ */
1168
+ static removeAssociationBetweenTickerCanvasElement(tag, ticker) {
1169
+ let tickerName;
1170
+ if (ticker instanceof TickerBase) {
1171
+ tickerName = ticker.constructor.name;
1172
+ } else {
1173
+ tickerName = ticker.name;
1174
+ }
1175
+ if (typeof tag === "string") {
1176
+ tag = [tag];
1177
+ }
1178
+ _GameWindowManager._currentTickers = _GameWindowManager._currentTickers.map((t) => {
1179
+ if (t.className === tickerName) {
1180
+ t.canvasElementTags = t.canvasElementTags.filter((e) => !tag.includes(e));
1181
+ }
1182
+ return t;
1183
+ });
1184
+ for (let timeout in _GameWindowManager.currentTickersTimeouts) {
1185
+ let t = _GameWindowManager.currentTickersTimeouts[timeout].tags.filter((e) => !tag.includes(e));
1186
+ if (t.length == 0) {
1187
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
1188
+ } else {
1189
+ _GameWindowManager.currentTickersTimeouts[timeout].tags = t;
1190
+ }
1191
+ }
1192
+ _GameWindowManager.removeTickersWithoutAssociatedCanvasElement();
1193
+ }
1194
+ /**
1195
+ * Remove all tickers that are not connected to any existing canvas element.
1196
+ */
1197
+ static removeTickersWithoutAssociatedCanvasElement() {
1198
+ let currentTickers = _GameWindowManager._currentTickers.map((t) => {
1199
+ t.canvasElementTags = t.canvasElementTags.filter((e) => _GameWindowManager._children[e]);
1200
+ return t;
1201
+ });
1202
+ currentTickers.filter((t) => t.canvasElementTags.length === 0).forEach((t) => {
1203
+ _GameWindowManager.app.ticker.remove(t.fn);
1204
+ });
1205
+ currentTickers = currentTickers.filter((t) => t.canvasElementTags.length > 0);
1206
+ _GameWindowManager._currentTickers = currentTickers;
1207
+ for (let tag in _GameWindowManager._currentTickersSteps) {
1208
+ if (_GameWindowManager._children[tag] === void 0) {
1209
+ delete _GameWindowManager._currentTickersSteps[tag];
1210
+ }
1211
+ }
1212
+ }
1213
+ static addTickerTimeoutInfo(tags, ticker, timeout) {
1214
+ if (typeof tags === "string") {
1215
+ tags = [tags];
1216
+ }
1217
+ _GameWindowManager.currentTickersTimeouts[timeout] = {
1218
+ tags,
1219
+ ticker
1220
+ };
1221
+ }
1222
+ static removeTickerTimeoutInfo(timeout) {
1223
+ if (typeof timeout !== "string") {
1224
+ timeout = timeout.toString();
1225
+ }
1226
+ if (_GameWindowManager.currentTickersTimeouts[timeout]) {
1227
+ delete _GameWindowManager.currentTickersTimeouts[timeout];
1228
+ }
1229
+ }
1230
+ /**
1231
+ * Remove all tickers from the canvas.
1232
+ */
1233
+ static removeTickers() {
1234
+ _GameWindowManager._currentTickersSteps = {};
1235
+ _GameWindowManager._currentTickers.forEach((t) => {
1236
+ _GameWindowManager.app.ticker.remove(t.fn);
1237
+ });
1238
+ _GameWindowManager._currentTickers = [];
1239
+ for (let timeout in _GameWindowManager.currentTickersTimeouts) {
1240
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
1241
+ }
1242
+ }
1243
+ /**
1244
+ * Clear the canvas and the tickers.
1245
+ */
1246
+ static clear() {
1247
+ _GameWindowManager.removeCanvasElements();
1248
+ }
1249
+ /* Export and Import Methods */
1250
+ /**
1251
+ * Export the canvas and the tickers to a JSON string.
1252
+ * @returns The JSON string.
1253
+ */
1254
+ static exportJson() {
1255
+ return JSON.stringify(this.export());
1256
+ }
1257
+ /**
1258
+ * Export the canvas and the tickers to an object.
1259
+ * @returns The object.
1260
+ */
1261
+ static export() {
1262
+ let currentElements = {};
1263
+ for (let tag in _GameWindowManager._children) {
1264
+ currentElements[tag] = exportCanvasElement(_GameWindowManager._children[tag]);
1265
+ }
1266
+ return {
1267
+ currentTickers: createExportableElement(_GameWindowManager._currentTickers),
1268
+ currentElements: createExportableElement(currentElements),
1269
+ childrenTagsOrder: createExportableElement(_GameWindowManager.childrenTagsOrder)
1270
+ };
1271
+ }
1272
+ /**
1273
+ * Import the canvas and the tickers from a JSON string.
1274
+ * @param dataString The JSON string.
1275
+ */
1276
+ static importJson(dataString) {
1277
+ _GameWindowManager.import(JSON.parse(dataString));
1278
+ }
1279
+ /**
1280
+ * Import the canvas and the tickers from an object.
1281
+ * @param data The object.
1282
+ */
1283
+ static import(data) {
1284
+ _GameWindowManager.clear();
1285
+ try {
1286
+ if (data.hasOwnProperty("childrenTagsOrder") && data.hasOwnProperty("currentElements")) {
1287
+ let currentElements = data["currentElements"];
1288
+ let childrenTagsOrder = data["childrenTagsOrder"];
1289
+ childrenTagsOrder.forEach((tag) => {
1290
+ if (currentElements[tag]) {
1291
+ let element = importCanvasElement(currentElements[tag]);
1292
+ _GameWindowManager.addCanvasElement(tag, element);
1293
+ _GameWindowManager.childrenTagsOrder.push(tag);
1294
+ }
1295
+ });
1296
+ } else {
1297
+ console.error("[Pixi'VN] The data does not have the properties childrenTagsOrder and currentElements");
1298
+ return;
1299
+ }
1300
+ if (data.hasOwnProperty("currentTickers")) {
1301
+ let currentTickers = data["currentTickers"];
1302
+ currentTickers.forEach((t) => {
1303
+ let tags = t.canvasElementTags;
1304
+ let ticker = geTickerInstanceByClassName(t.className, t.args, t.duration, t.priority);
1305
+ if (ticker) {
1306
+ _GameWindowManager.addTicker(tags, ticker);
1307
+ } else {
1308
+ console.error(`[Pixi'VN] Ticker ${t.className} not found`);
1309
+ }
1310
+ });
1311
+ }
1312
+ } catch (e) {
1313
+ console.error("[Pixi'VN] Error importing data", e);
1314
+ }
1315
+ }
1316
+ };
1317
+ _GameWindowManager._app = void 0;
1318
+ _GameWindowManager._isInitialized = false;
1319
+ _GameWindowManager._children = {};
1320
+ /**
1321
+ * The order of the children tags.
1322
+ */
1323
+ _GameWindowManager.childrenTagsOrder = [];
1324
+ _GameWindowManager._currentTickers = [];
1325
+ _GameWindowManager._currentTickersSteps = {};
1326
+ _GameWindowManager.currentTickersTimeouts = {};
1327
+ var GameWindowManager = _GameWindowManager;
1328
+
1329
+ // src/managers/StepManager.ts
1330
+ var _GameStepManager = class _GameStepManager {
1331
+ constructor() {
1332
+ }
1333
+ static get stepsHistory() {
1334
+ return _GameStepManager._stepsHistory;
1335
+ }
1336
+ /**
1337
+ * lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
1338
+ */
1339
+ static get lastStepIndex() {
1340
+ return _GameStepManager._lastStepIndex;
1341
+ }
1342
+ /**
1343
+ * Increase the last step index that occurred during the progression of the steps.
1344
+ */
1345
+ static increaseLastStepIndex() {
1346
+ _GameStepManager._lastStepIndex++;
1347
+ }
1348
+ static get openedLabels() {
1349
+ return _GameStepManager._openedLabels;
1350
+ }
1351
+ /**
1352
+ * currentLabelId is the current label id that occurred during the progression of the steps.
1353
+ */
1354
+ static get currentLabelId() {
1355
+ if (_GameStepManager._openedLabels.length > 0) {
1356
+ let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
1357
+ return item.label;
1358
+ }
1359
+ return void 0;
1360
+ }
1361
+ /**
1362
+ * currentLabel is the current label that occurred during the progression of the steps.
1363
+ */
1364
+ static get currentLabel() {
1365
+ if (_GameStepManager.currentLabelId) {
1366
+ return getLabelInstanceByClassName(_GameStepManager.currentLabelId);
1367
+ }
1368
+ }
1369
+ static get currentLabelStepIndex() {
1370
+ if (_GameStepManager._openedLabels.length > 0) {
1371
+ let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
1372
+ return item.currentStepIndex;
1373
+ }
1374
+ return null;
1375
+ }
1376
+ /**
1377
+ * currentLabelStep is the current step that occurred during the progression of the steps. It can used to determine the game end.
1378
+ */
1379
+ static get isLastGameStep() {
1380
+ var _a;
1381
+ let stepLabel = (_a = _GameStepManager.currentLabel) == null ? void 0 : _a.steps;
1382
+ if (stepLabel && _GameStepManager.currentLabelStepIndex === stepLabel.length) {
1383
+ if (this.openedLabels.length <= 1) {
1384
+ return true;
1385
+ } else {
1386
+ this.openedLabels.forEach((item) => {
1387
+ let label = getLabelInstanceByClassName(item.label);
1388
+ if (label && label.steps.length > item.currentStepIndex) {
1389
+ return false;
1390
+ }
1391
+ });
1392
+ return true;
1393
+ }
1394
+ }
1395
+ return false;
1396
+ }
1397
+ /**
1398
+ * lastHistoryStep is the last history step that occurred during the progression of the steps.
1399
+ */
1400
+ static get lastHistoryStep() {
1401
+ if (_GameStepManager._stepsHistory.length > 0) {
1402
+ return _GameStepManager._stepsHistory[_GameStepManager._stepsHistory.length - 1];
1403
+ }
1404
+ return null;
1405
+ }
1406
+ static get originalStepData() {
1407
+ if (!_GameStepManager._originalStepData) {
1408
+ return {
1409
+ path: "",
1410
+ storage: {},
1411
+ canvas: {
1412
+ childrenTagsOrder: [],
1413
+ currentElements: {},
1414
+ currentTickers: []
1415
+ },
1416
+ labelIndex: -1,
1417
+ openedLabels: []
1418
+ };
1419
+ }
1420
+ return createExportableElement(_GameStepManager._originalStepData);
1421
+ }
1422
+ static set originalStepData(value) {
1423
+ _GameStepManager._originalStepData = createExportableElement(value);
1424
+ }
1425
+ /* Edit History Methods */
1426
+ /**
1427
+ * Add a label to the history.
1428
+ * @param label The label to add to the history.
1429
+ */
1430
+ static addStepHistory(step) {
1431
+ let stepHistory = getStepSha1(step);
1432
+ let historyStep = {
1433
+ path: window.location.pathname,
1434
+ storage: GameStorageManager.export(),
1435
+ canvas: GameWindowManager.export(),
1436
+ labelIndex: _GameStepManager.currentLabelStepIndex || 0,
1437
+ openedLabels: createExportableElement(_GameStepManager._openedLabels)
1438
+ };
1439
+ if (_GameStepManager.originalStepData) {
1440
+ if (_GameStepManager.originalStepData.openedLabels.length === historyStep.openedLabels.length) {
1441
+ try {
1442
+ let lastStepDataOpenedLabelsString = JSON.stringify(_GameStepManager.originalStepData.openedLabels);
1443
+ let historyStepOpenedLabelsString = JSON.stringify(historyStep.openedLabels);
1444
+ if (lastStepDataOpenedLabelsString === historyStepOpenedLabelsString) {
1445
+ return;
1446
+ }
1447
+ } catch (e) {
1448
+ console.error("[Pixi'VN] Error comparing openedLabels", e);
1449
+ }
1450
+ }
1451
+ }
1452
+ let data = diff(_GameStepManager.originalStepData, historyStep);
1453
+ if (data) {
1454
+ let dialoge = void 0;
1455
+ let requiredChoices = void 0;
1456
+ if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
1457
+ dialoge = getDialogue();
1458
+ }
1459
+ if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
1460
+ requiredChoices = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
1461
+ }
1462
+ _GameStepManager._stepsHistory.push({
1463
+ diff: data,
1464
+ currentLabel: _GameStepManager.currentLabelId,
1465
+ dialoge,
1466
+ choices: requiredChoices,
1467
+ stepSha1: stepHistory,
1468
+ index: _GameStepManager.lastStepIndex
1469
+ });
1470
+ _GameStepManager.originalStepData = historyStep;
1471
+ }
1472
+ _GameStepManager.increaseLastStepIndex();
1473
+ }
1474
+ /**
1475
+ * Add a label to the history.
1476
+ * @param label The label to add to the history.
1477
+ */
1478
+ static pushNewLabel(label) {
1479
+ let currentLabel = getLabelInstanceByClassName(label);
1480
+ if (!currentLabel) {
1481
+ throw new Error("[Pixi'VN] Label not found");
1482
+ }
1483
+ _GameStepManager._openedLabels.push({
1484
+ label,
1485
+ currentStepIndex: 0
1486
+ });
1487
+ }
1488
+ /**
1489
+ * Close the current label and add it to the history.
1490
+ * @returns
1491
+ */
1492
+ static closeCurrentLabel() {
1493
+ if (!_GameStepManager.currentLabelId) {
1494
+ console.warn("[Pixi'VN] No label to close");
1495
+ return;
1496
+ }
1497
+ if (!_GameStepManager.currentLabel) {
1498
+ console.error("[Pixi'VN] Label not found");
1499
+ return;
1500
+ }
1501
+ _GameStepManager._openedLabels.pop();
1502
+ }
1503
+ /**
1504
+ * Close all labels and add them to the history.
1505
+ */
1506
+ static closeAllLabels() {
1507
+ while (_GameStepManager._openedLabels.length > 0) {
1508
+ _GameStepManager.closeCurrentLabel();
1509
+ }
1510
+ }
1511
+ /**
1512
+ * Increase the current step index of the current label.
1513
+ */
1514
+ static increaseCurrentStepIndex() {
1515
+ let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
1516
+ _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1] = __spreadProps(__spreadValues({}, item), {
1517
+ currentStepIndex: item.currentStepIndex + 1
1518
+ });
1519
+ }
1520
+ /* Run Methods */
1521
+ /**
1522
+ * Execute the next step and add it to the history.
1523
+ * @param props The props to pass to the step.
1524
+ * @returns StepLabelResultType or undefined.
1525
+ * @example
1526
+ * ```typescript
1527
+ * function nextOnClick() {
1528
+ * setLoading(true)
1529
+ * GameStepManager.runNextStep(yourParams)
1530
+ * .then((result) => {
1531
+ * setUpdate((p) => p + 1)
1532
+ * setLoading(false)
1533
+ * if (result) {
1534
+ * // your code
1535
+ * }
1536
+ * })
1537
+ * .catch((e) => {
1538
+ * setLoading(false)
1539
+ * console.error(e)
1540
+ * })
1541
+ * }
1542
+ * ```
1543
+ */
1544
+ static runNextStep(props) {
1545
+ return __async(this, null, function* () {
1546
+ if (_GameStepManager._openedLabels.length === 0) {
1547
+ console.warn("[Pixi'VN] There are no labels to run");
1548
+ return;
1549
+ }
1550
+ _GameStepManager.increaseCurrentStepIndex();
1551
+ return yield _GameStepManager.runCurrentStep(props);
1552
+ });
1553
+ }
1554
+ /**
1555
+ * Execute the current step and add it to the history.
1556
+ * @param props The props to pass to the step.
1557
+ * @returns StepLabelResultType or undefined.
1558
+ */
1559
+ static runCurrentStep(props) {
1560
+ return __async(this, null, function* () {
1561
+ if (_GameStepManager.currentLabelId) {
1562
+ let lasteStepsLength = _GameStepManager.currentLabelStepIndex;
1563
+ if (lasteStepsLength === null) {
1564
+ console.error("[Pixi'VN] currentLabelStepIndex is null");
1565
+ return;
1566
+ }
1567
+ let currentLabel = _GameStepManager.currentLabel;
1568
+ if (!currentLabel) {
1569
+ console.error("[Pixi'VN] Label not found");
1570
+ return;
1571
+ }
1572
+ let n = currentLabel.steps.length;
1573
+ if (n > lasteStepsLength) {
1574
+ let nextStep = currentLabel.steps[lasteStepsLength];
1575
+ let result = yield nextStep(props);
1576
+ _GameStepManager.addStepHistory(nextStep);
1577
+ return result;
1578
+ } else if (n === lasteStepsLength) {
1579
+ _GameStepManager.closeCurrentLabel();
1580
+ return yield _GameStepManager.runNextStep(props);
1581
+ } else {
1582
+ console.warn("[Pixi'VN] There are no steps to run");
1583
+ }
1584
+ }
1585
+ });
1586
+ }
1587
+ /**
1588
+ * Execute the label and add it to the history.
1589
+ * Is a call function in Ren'Py.
1590
+ * @param label The label to execute.
1591
+ * @param props The props to pass to the label.
1592
+ * @returns StepLabelResultType or undefined.
1593
+ * @example
1594
+ * ```typescript
1595
+ * GameStepManager.callLabel(StartLabel, yourParams).then((result) => {
1596
+ * if (result) {
1597
+ * // your code
1598
+ * }
1599
+ * })
1600
+ * ```
1601
+ * @example
1602
+ * ```typescript
1603
+ * // if you use it in a step label you should return the result.
1604
+ * return GameStepManager.callLabel(StartLabel).then((result) => {
1605
+ * return result
1606
+ * })
1607
+ * ```
1608
+ */
1609
+ static callLabel(label, props) {
1610
+ return __async(this, null, function* () {
1611
+ try {
1612
+ if (label instanceof Label) {
1613
+ label = label.constructor;
1614
+ }
1615
+ let labelName = label.name;
1616
+ _GameStepManager.pushNewLabel(labelName);
1617
+ } catch (e) {
1618
+ console.error("[Pixi'VN] Error calling label", e);
1619
+ return;
1620
+ }
1621
+ return yield _GameStepManager.runCurrentStep(props);
1622
+ });
1623
+ }
1624
+ /**
1625
+ * Execute the label, close all labels and add them to the history.
1626
+ * Is a jump function in Ren'Py.
1627
+ * @param label The label to execute.
1628
+ * @param props The props to pass to the label.
1629
+ * @returns StepLabelResultType or undefined.
1630
+ * @example
1631
+ * ```typescript
1632
+ * GameStepManager.jumpLabel(StartLabel, yourParams).then((result) => {
1633
+ * if (result) {
1634
+ * // your code
1635
+ * }
1636
+ * })
1637
+ * ```
1638
+ * @example
1639
+ * ```typescript
1640
+ * // if you use it in a step label you should return the result.
1641
+ * return GameStepManager.jumpLabel(StartLabel).then((result) => {
1642
+ * return result
1643
+ * })
1644
+ * ```
1645
+ */
1646
+ static jumpLabel(label, props) {
1647
+ return __async(this, null, function* () {
1648
+ _GameStepManager.closeAllLabels();
1649
+ try {
1650
+ if (label instanceof Label) {
1651
+ label = label.constructor;
1652
+ }
1653
+ let labelName = label.name;
1654
+ _GameStepManager.pushNewLabel(labelName);
1655
+ } catch (e) {
1656
+ console.error("[Pixi'VN] Error jumping label", e);
1657
+ return;
1658
+ }
1659
+ return yield _GameStepManager.runCurrentStep(props);
1660
+ });
1661
+ }
1662
+ /* After Update Methods */
1663
+ // /**
1664
+ // * After the update or code edit, some steps or labels may no longer match.
1665
+ // * - In case of step mismatch, the game will be updated to the last matching step.
1666
+ // * - In case of label mismatch, the game gives an error.
1667
+ // * @returns
1668
+ // */
1669
+ // private static afterUpdate() {
1670
+ // // TODO: implement
1671
+ // if (!GameStepManager.currentLabel) {
1672
+ // // TODO: implement
1673
+ // return
1674
+ // }
1675
+ // let currentLabel = getLabelInstanceByClassName(GameStepManager.currentLabel)
1676
+ // if (!currentLabel) {
1677
+ // console.error("Label not found")
1678
+ // return
1679
+ // }
1680
+ // let oldSteps = GameStepManager.stepsAfterLastHistoryLabel
1681
+ // let currentStepIndex = currentLabel.getCorrespondingStepsNumber(oldSteps)
1682
+ // let stepToRemove = oldSteps.length - currentStepIndex
1683
+ // GameStepManager.removeLastHistoryNodes(stepToRemove)
1684
+ // GameStepManager.loadLastStep()
1685
+ // }
1686
+ // private static loadLastStep() {
1687
+ // // TODO: implement
1688
+ // }
1689
+ // /**
1690
+ // * Remove a number of items from the last of the history.
1691
+ // * @param itemNumber The number of items to remove from the last of the history.
1692
+ // */
1693
+ // private static removeLastHistoryNodes(itemNumber: number) {
1694
+ // // TODO: implement
1695
+ // for (let i = 0; i < itemNumber; i++) {
1696
+ // GameStepManager._stepsHistory.pop()
1697
+ // }
1698
+ // }
1699
+ // /**
1700
+ // * stepsAfterLastHistoryLabel is a list of steps that occurred after the last history label.
1701
+ // */
1702
+ // private static get stepsAfterLastHistoryLabel(): StepHistoryDataType[] {
1703
+ // let length = GameStepManager._stepsHistory.length
1704
+ // let steps: StepHistoryDataType[] = []
1705
+ // for (let i = length - 1; i >= 0; i--) {
1706
+ // let element = GameStepManager._stepsHistory[i]
1707
+ // if (typeof element === "object" && "stepSha1" in element) {
1708
+ // steps.push(element.stepSha1)
1709
+ // }
1710
+ // else {
1711
+ // break
1712
+ // }
1713
+ // }
1714
+ // steps = steps.reverse()
1715
+ // return steps
1716
+ // }
1717
+ /* Go Back & Refresh Methods */
1718
+ /**
1719
+ * Go back to the last step and add it to the history.
1720
+ * @param navigate The navigate function.
1721
+ * @param steps The number of steps to go back.
1722
+ * @returns
1723
+ * @example
1724
+ * ```typescript
1725
+ * export function goBack(navigate: (path: string) => void, afterBack?: () => void) {
1726
+ * GameStepManager.goBack(navigate)
1727
+ * afterBack && afterBack()
1728
+ * }
1729
+ * ```
1730
+ */
1731
+ static goBack(navigate, steps = 1) {
1732
+ if (steps <= 0) {
1733
+ console.warn("[Pixi'VN] Steps must be greater than 0");
1734
+ return;
1735
+ }
1736
+ if (_GameStepManager._stepsHistory.length <= 1) {
1737
+ console.warn("[Pixi'VN] No steps to go back");
1738
+ return;
1739
+ }
1740
+ let restoredStep = _GameStepManager.goBackInternal(steps, _GameStepManager.originalStepData);
1741
+ if (restoredStep) {
1742
+ _GameStepManager._originalStepData = restoredStep;
1743
+ _GameStepManager._openedLabels = createExportableElement(restoredStep.openedLabels);
1744
+ GameStorageManager.import(createExportableElement(restoredStep.storage));
1745
+ GameWindowManager.import(createExportableElement(restoredStep.canvas));
1746
+ navigate(restoredStep.path);
1747
+ } else {
1748
+ console.error("[Pixi'VN] Error going back");
1749
+ }
1750
+ }
1751
+ static goBackInternal(steps, restoredStep) {
1752
+ if (steps <= 0) {
1753
+ return restoredStep;
1754
+ }
1755
+ if (_GameStepManager._stepsHistory.length == 0) {
1756
+ return restoredStep;
1757
+ }
1758
+ let lastHistoryStep = _GameStepManager.lastHistoryStep;
1759
+ if (lastHistoryStep) {
1760
+ try {
1761
+ let result = restoreDeepDiffChanges(restoredStep, lastHistoryStep.diff);
1762
+ _GameStepManager._lastStepIndex = lastHistoryStep.index;
1763
+ _GameStepManager._stepsHistory.pop();
1764
+ return _GameStepManager.goBackInternal(steps - 1, result);
1765
+ } catch (e) {
1766
+ console.error("[Pixi'VN] Error applying diff", e);
1767
+ return restoredStep;
1768
+ }
1769
+ } else {
1770
+ return restoredStep;
1771
+ }
1772
+ }
1773
+ /**
1774
+ * Return true if it is possible to go back.
1775
+ */
1776
+ static get canGoBack() {
1777
+ return _GameStepManager._stepsHistory.length > 1;
1778
+ }
1779
+ /**
1780
+ * Add a label to the history.
1781
+ */
1782
+ static clear() {
1783
+ _GameStepManager._stepsHistory = [];
1784
+ _GameStepManager._openedLabels = [];
1785
+ }
1786
+ /* Export and Import Methods */
1787
+ /**
1788
+ * Export the history to a JSON string.
1789
+ * @returns The history in a JSON string.
1790
+ */
1791
+ static exportJson() {
1792
+ return JSON.stringify(this.export());
1793
+ }
1794
+ /**
1795
+ * Export the history to an object.
1796
+ * @returns The history in an object.
1797
+ */
1798
+ static export() {
1799
+ return {
1800
+ stepsHistory: _GameStepManager._stepsHistory,
1801
+ openedLabels: _GameStepManager._openedLabels,
1802
+ lastStepIndex: _GameStepManager._lastStepIndex,
1803
+ originalStepData: _GameStepManager._originalStepData
1804
+ };
1805
+ }
1806
+ /**
1807
+ * Import the history from a JSON string.
1808
+ * @param dataString The history in a JSON string.
1809
+ */
1810
+ static importJson(dataString) {
1811
+ _GameStepManager.import(JSON.parse(dataString));
1812
+ }
1813
+ /**
1814
+ * Import the history from an object.
1815
+ * @param data The history in an object.
1816
+ */
1817
+ static import(data) {
1818
+ _GameStepManager.clear();
1819
+ try {
1820
+ if (data.hasOwnProperty("stepsHistory")) {
1821
+ _GameStepManager._stepsHistory = data["stepsHistory"];
1822
+ } else {
1823
+ console.warn("[Pixi'VN] No stepsHistory data found");
1824
+ }
1825
+ if (data.hasOwnProperty("openedLabels")) {
1826
+ _GameStepManager._openedLabels = data["openedLabels"];
1827
+ } else {
1828
+ console.warn("[Pixi'VN] No openedLabels data found");
1829
+ }
1830
+ if (data.hasOwnProperty("lastStepIndex")) {
1831
+ _GameStepManager._lastStepIndex = data["lastStepIndex"];
1832
+ } else {
1833
+ console.warn("[Pixi'VN] No lastStepIndex data found");
1834
+ }
1835
+ if (data.hasOwnProperty("originalStepData")) {
1836
+ _GameStepManager._originalStepData = data["originalStepData"];
1837
+ } else {
1838
+ console.warn("[Pixi'VN] No originalStepData data found");
1839
+ }
1840
+ } catch (e) {
1841
+ console.error("[Pixi'VN] Error importing data", e);
1842
+ }
1843
+ }
1844
+ };
1845
+ /**
1846
+ * stepHistory is a list of label events and steps that occurred during the progression of the steps.
1847
+ */
1848
+ _GameStepManager._stepsHistory = [];
1849
+ _GameStepManager._lastStepIndex = 0;
1850
+ _GameStepManager._openedLabels = [];
1851
+ _GameStepManager._originalStepData = void 0;
1852
+ var GameStepManager = _GameStepManager;
1853
+
1854
+ // src/classes/DialogueBaseModel.ts
1855
+ var DialogueBaseModel2 = class {
1856
+ /**
1857
+ * @param text The text of the dialogue.
1858
+ * @param character The id of the character that is speaking.
1859
+ * @param oltherParams Other parameters that can be stored in the dialogue.
1860
+ */
1861
+ constructor(text, character, oltherParams = {}) {
1862
+ /**
1863
+ * The text of the dialogue.
1864
+ */
1865
+ this.text = "";
1866
+ /**
1867
+ * Other parameters that can be stored in the dialogue.
1868
+ */
1869
+ this.oltherParams = {};
1870
+ if (typeof text === "string") {
1871
+ this.text = text;
1872
+ if (typeof character === "string") {
1873
+ this.characterId = character;
1874
+ } else {
1875
+ this.characterId = character == null ? void 0 : character.id;
1876
+ }
1877
+ this.oltherParams = oltherParams;
1878
+ } else {
1879
+ this.text = text.text;
1880
+ if (text.characterId) {
1881
+ this.characterId = text.characterId;
1882
+ }
1883
+ this.oltherParams = text.oltherParams || {};
1884
+ }
1885
+ }
1886
+ /**
1887
+ * Export the dialogue to a DialogueBaseData object.
1888
+ *
1889
+ * @returns The data of the dialogue.
1890
+ */
1891
+ export() {
1892
+ return {
1893
+ text: this.text,
1894
+ characterId: this.characterId,
1895
+ oltherParams: this.oltherParams
1896
+ };
1897
+ }
1898
+ };
1899
+
1900
+ // src/classes/Label.ts
1901
+ var Label = class {
1902
+ /**
1903
+ * Get the steps of the label.
1904
+ * This class should be extended and the steps method should be overridden.
1905
+ * Every time you update this list will also be updated when the other game versions load.
1906
+ */
1907
+ get steps() {
1908
+ throw new Error("[Pixi'VN] The method Label.steps must be overridden");
1909
+ }
1910
+ /**
1911
+ * Get the corresponding steps number
1912
+ * @param externalSteps
1913
+ * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1
1914
+ */
1915
+ getCorrespondingStepsNumber(externalSteps) {
1916
+ if (externalSteps.length === 0) {
1917
+ return 0;
1918
+ }
1919
+ let res = 0;
1920
+ externalSteps.forEach((step, index) => {
1921
+ if (checkIfStepsIsEqual(step, this.steps[index])) {
1922
+ res = index;
1923
+ }
1924
+ });
1925
+ return res;
1926
+ }
1927
+ };
1928
+
1929
+ // src/functions/DialogueUtility.ts
1930
+ function setDialogue(props) {
1931
+ let text = "";
1932
+ let characterId = void 0;
1933
+ let dialogue;
1934
+ if (typeof props === "string") {
1935
+ text = props;
1936
+ dialogue = new DialogueBaseModel2(text, characterId);
1937
+ } else if (!(props instanceof DialogueBaseModel2)) {
1938
+ text = props.text;
1939
+ if (props.character) {
1940
+ if (typeof props.character === "string") {
1941
+ characterId = props.character;
1942
+ } else {
1943
+ characterId = props.character.id;
1944
+ }
1945
+ }
1946
+ dialogue = new DialogueBaseModel2(text, characterId);
1947
+ } else {
1948
+ dialogue = props;
1949
+ }
1950
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, dialogue);
1951
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
1952
+ }
1953
+ function getDialogue() {
1954
+ return GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY);
1955
+ }
1956
+ function clearDialogue() {
1957
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, void 0);
1958
+ }
1959
+ function setChoiceMenuOptions(options) {
1960
+ let value = options.map((option) => {
1961
+ return __spreadProps(__spreadValues({}, option), {
1962
+ label: option.label.name
1963
+ });
1964
+ });
1965
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY, value);
1966
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
1967
+ }
1968
+ function getChoiceMenuOptions() {
1969
+ let d = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
1970
+ if (d) {
1971
+ let options = [];
1972
+ d.forEach((option) => {
1973
+ let label = getLabelTypeByClassName(option.label);
1974
+ if (label) {
1975
+ options.push(__spreadProps(__spreadValues({}, option), {
1976
+ label
1977
+ }));
1978
+ }
1979
+ });
1980
+ return options;
1981
+ }
1982
+ return void 0;
1983
+ }
1984
+ function clearChoiceMenuOptions() {
1985
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY, void 0);
1986
+ }
1987
+ function getDialogueHistory() {
1988
+ let list = [];
1989
+ GameStepManager.stepsHistory.forEach((step) => {
1990
+ let dialoge = step.dialoge;
1991
+ let requiredChoices = step.choices;
1992
+ if (list.length > 0 && list[list.length - 1].choices && !list[list.length - 1].choiceMade && step.currentLabel) {
1993
+ let oldChoices = list[list.length - 1].choices;
1994
+ if (oldChoices) {
1995
+ list[list.length - 1].choiceMade = oldChoices.find((choice) => choice.label === step.currentLabel);
1996
+ }
1997
+ }
1998
+ if (dialoge || requiredChoices) {
1999
+ list.push({
2000
+ dialoge,
2001
+ choiceMade: void 0,
2002
+ choices: requiredChoices,
2003
+ stepIndex: step.index
2004
+ });
2005
+ }
2006
+ });
2007
+ return list;
2008
+ }
2009
+
2010
+ // src/functions/FlagsUtility.ts
2011
+ function setFlag(name, value) {
2012
+ let flags = GameStorageManager.getVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY) || [];
2013
+ if (value) {
2014
+ if (!flags.includes(name)) {
2015
+ flags.push(name);
2016
+ }
2017
+ } else {
2018
+ let index = flags.indexOf(name);
2019
+ if (index > -1) {
2020
+ flags.splice(index, 1);
2021
+ }
2022
+ }
2023
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY, flags);
2024
+ }
2025
+ function getFlag(name) {
2026
+ let flags = GameStorageManager.getVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY) || [];
2027
+ return flags.includes(name);
2028
+ }
2029
+
2030
+ // src/functions/GameUtility.ts
2031
+ function clearAllGameDatas() {
2032
+ GameStorageManager.clear();
2033
+ GameWindowManager.clear();
2034
+ GameStepManager.clear();
2035
+ }
2036
+ var TickerFadeAlpha = class extends TickerBase {
2037
+ /**
2038
+ * The method that will be called every frame to fade the alpha of the canvas element of the canvas.
2039
+ * @param delta The delta time
2040
+ * @param args The arguments that are passed to the ticker
2041
+ * @param tags The tags of the canvas element that are connected to this ticker
2042
+ */
2043
+ fn(t, args, tags) {
2044
+ let type = args.type === void 0 ? "hide" : args.type;
2045
+ let speed = args.speed === void 0 ? 0.1 : args.speed;
2046
+ let limit = args.limit === void 0 ? type === "hide" ? 0 : 1 : args.limit;
2047
+ let removeElementAfter = args.tagToRemoveAfter || [];
2048
+ if (typeof removeElementAfter === "string") {
2049
+ removeElementAfter = [removeElementAfter];
2050
+ }
2051
+ if (type === "hide" && limit < 0) {
2052
+ limit = 0;
2053
+ }
2054
+ if (type === "show" && limit > 1) {
2055
+ limit = 1;
2056
+ }
2057
+ tags.filter((tag) => {
2058
+ var _a;
2059
+ let element = GameWindowManager.getCanvasElement(tag);
2060
+ if (args.startOnlyIfHaveTexture) {
2061
+ if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
2062
+ return false;
2063
+ }
2064
+ }
2065
+ return true;
2066
+ }).forEach((tag) => {
2067
+ let element = GameWindowManager.getCanvasElement(tag);
2068
+ if (element && element instanceof Container) {
2069
+ if (type === "show" && element.alpha < limit) {
2070
+ element.alpha += speed * t.deltaTime;
2071
+ } else if (type === "hide" && element.alpha > limit) {
2072
+ element.alpha -= speed * t.deltaTime;
2073
+ } else {
2074
+ element.alpha = limit;
2075
+ GameWindowManager.removeAssociationBetweenTickerCanvasElement(tag, this);
2076
+ GameWindowManager.removeCanvasElement(removeElementAfter);
2077
+ }
2078
+ }
2079
+ });
2080
+ }
2081
+ };
2082
+ TickerFadeAlpha = __decorateClass([
2083
+ tickerDecorator()
2084
+ ], TickerFadeAlpha);
2085
+
2086
+ // src/functions/TickerUtility.ts
2087
+ function updateTickerProgression(args, propertyName, progression) {
2088
+ if (args.hasOwnProperty(propertyName) && typeof args[propertyName] !== "number") {
2089
+ return;
2090
+ }
2091
+ if (args[propertyName] !== void 0 && progression && args[propertyName] !== progression.limit) {
2092
+ if (progression.type === "linear") {
2093
+ args[propertyName] += progression.amt;
2094
+ if (progression.limit !== void 0) {
2095
+ if (args[propertyName] > progression.limit && progression.amt > 0) {
2096
+ args[propertyName] = progression.limit;
2097
+ } else if (args[propertyName] < progression.limit && progression.amt < 0) {
2098
+ args[propertyName] = progression.limit;
2099
+ }
2100
+ }
2101
+ } else if (progression.type === "exponential") {
2102
+ args[propertyName] += args[propertyName] * progression.percentage;
2103
+ if (progression.limit !== void 0) {
2104
+ if (args[propertyName] > progression.limit && progression.percentage > 0) {
2105
+ args[propertyName] = progression.limit;
2106
+ } else if (args[propertyName] < progression.limit && progression.percentage < 0) {
2107
+ args[propertyName] = progression.limit;
2108
+ }
2109
+ }
2110
+ }
2111
+ }
2112
+ }
2113
+
2114
+ // src/classes/ticker/TickerMove.ts
2115
+ var TickerMove = class extends TickerBase {
2116
+ /**
2117
+ * The method that will be called every frame to move the canvas element of the canvas.
2118
+ * @param t The ticker that is calling this method
2119
+ * @param args The arguments that are passed to the ticker
2120
+ * @param tags The tags of the canvas element that are connected to this ticker
2121
+ */
2122
+ fn(t, args, tags) {
2123
+ let speed = args.speed === void 0 ? 0.1 : args.speed;
2124
+ let destination = args.destination;
2125
+ tags.filter((tag) => {
2126
+ var _a;
2127
+ let element = GameWindowManager.getCanvasElement(tag);
2128
+ if (args.startOnlyIfHaveTexture) {
2129
+ if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
2130
+ return false;
2131
+ }
2132
+ }
2133
+ return true;
2134
+ }).forEach((tag) => {
2135
+ let element = GameWindowManager.getCanvasElement(tag);
2136
+ if (element && element instanceof Container) {
2137
+ let xDistance = destination.x - element.x;
2138
+ if (xDistance != 0) {
2139
+ element.x += xDistance / speed * t.deltaTime;
2140
+ let newDistance = destination.x - element.x;
2141
+ if (xDistance < 0 && newDistance > 0 || xDistance > 0 && newDistance < 0) {
2142
+ element.x = destination.x;
2143
+ }
2144
+ }
2145
+ let yDistance = destination.y - element.y;
2146
+ if (yDistance != 0) {
2147
+ element.y += yDistance / speed * t.deltaTime;
2148
+ let newDistance = destination.y - element.y;
2149
+ if (yDistance < 0 && newDistance > 0 || yDistance > 0 && newDistance < 0) {
2150
+ element.y = destination.y;
2151
+ }
2152
+ }
2153
+ }
2154
+ });
2155
+ if (args.speedProgression)
2156
+ updateTickerProgression(args, "speed", args.speedProgression);
2157
+ }
2158
+ };
2159
+ TickerMove = __decorateClass([
2160
+ tickerDecorator()
2161
+ ], TickerMove);
2162
+ var TickerRotate = class extends TickerBase {
2163
+ /**
2164
+ * The method that will be called every frame to rotate the canvas element of the canvas.
2165
+ * @param delta The delta time
2166
+ * @param args The arguments that are passed to the ticker
2167
+ * @param tags The tags of the canvas element that are connected to this ticker
2168
+ */
2169
+ fn(t, args, tags) {
2170
+ let speed = args.speed === void 0 ? 0.1 : args.speed;
2171
+ let clockwise = args.clockwise === void 0 ? true : args.clockwise;
2172
+ tags.filter((tag) => {
2173
+ var _a;
2174
+ let element = GameWindowManager.getCanvasElement(tag);
2175
+ if (args.startOnlyIfHaveTexture) {
2176
+ if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
2177
+ return false;
2178
+ }
2179
+ }
2180
+ return true;
2181
+ }).forEach((tag) => {
2182
+ let element = GameWindowManager.getCanvasElement(tag);
2183
+ if (element && element instanceof Container) {
2184
+ if (clockwise)
2185
+ element.rotation += speed * t.deltaTime;
2186
+ else
2187
+ element.rotation -= speed * t.deltaTime;
2188
+ }
2189
+ });
2190
+ if (args.speedProgression)
2191
+ updateTickerProgression(args, "speed", args.speedProgression);
2192
+ }
2193
+ };
2194
+ TickerRotate = __decorateClass([
2195
+ tickerDecorator()
2196
+ ], TickerRotate);
2197
+
2198
+ // src/functions/ImageUtility.ts
2199
+ function addImage(tag, imageUrl) {
2200
+ let image = new CanvasImage();
2201
+ image.imageLink = imageUrl;
2202
+ GameWindowManager.addCanvasElement(tag, image);
2203
+ return image;
2204
+ }
2205
+ function loadImages(canvasImages) {
2206
+ return __async(this, null, function* () {
2207
+ if (!Array.isArray(canvasImages)) {
2208
+ return [canvasImages];
2209
+ }
2210
+ let promises = Array(canvasImages.length);
2211
+ for (let i = 0; i < canvasImages.length; i++) {
2212
+ promises[i] = getTexture(canvasImages[i].imageLink);
2213
+ }
2214
+ return Promise.all(promises).then((textures) => {
2215
+ return textures.map((texture, index) => {
2216
+ if (texture) {
2217
+ canvasImages[index].texture = texture;
2218
+ return canvasImages[index];
2219
+ }
2220
+ canvasImages[index].load();
2221
+ return canvasImages[index];
2222
+ });
2223
+ });
2224
+ });
2225
+ }
2226
+ function removeCanvasElement(tag) {
2227
+ GameWindowManager.removeCanvasElement(tag);
2228
+ }
2229
+ function showWithDissolveTransition(tag, image, speed, priority) {
2230
+ return __async(this, null, function* () {
2231
+ let specialTag = void 0;
2232
+ if (GameWindowManager.getCanvasElement(tag)) {
2233
+ specialTag = tag + "_temp_disolve";
2234
+ GameWindowManager.editTagCanvasElement(tag, specialTag);
2235
+ }
2236
+ let canvasElement;
2237
+ if (typeof image === "string") {
2238
+ canvasElement = addImage(tag, image);
2239
+ } else {
2240
+ canvasElement = image;
2241
+ }
2242
+ image.alpha = 0;
2243
+ let effect = new TickerFadeAlpha({
2244
+ speed,
2245
+ type: "show",
2246
+ tagToRemoveAfter: specialTag,
2247
+ startOnlyIfHaveTexture: true
2248
+ }, 1e4, priority);
2249
+ GameWindowManager.addTicker(tag, effect);
2250
+ if (canvasElement instanceof CanvasImage) {
2251
+ return canvasElement.load();
2252
+ }
2253
+ return;
2254
+ });
2255
+ }
2256
+
2257
+ // src/constants.ts
2258
+ var PIXIVN_VERSION = "0.4.6";
2259
+
2260
+ // src/functions/SavesUtility.ts
2261
+ function getSaveData() {
2262
+ return {
2263
+ pixivn_version: PIXIVN_VERSION,
2264
+ stepData: GameStepManager.export(),
2265
+ storageData: GameStorageManager.export(),
2266
+ canvasData: GameWindowManager.export(),
2267
+ path: window.location.pathname
2268
+ };
2269
+ }
2270
+ function getSaveJson() {
2271
+ const saveData = getSaveData();
2272
+ return JSON.stringify(saveData);
2273
+ }
2274
+ function loadSaveData(data, navigate) {
2275
+ GameStepManager.import(data.stepData);
2276
+ GameStorageManager.import(data.storageData);
2277
+ GameWindowManager.import(data.canvasData);
2278
+ navigate(data.path);
2279
+ }
2280
+ function loadSaveJson(dataString, navigate) {
2281
+ loadSaveData(jsonToSaveData(dataString), navigate);
2282
+ }
2283
+ function jsonToSaveData(json) {
2284
+ return JSON.parse(json);
2285
+ }
2286
+
2287
+ export { addImage, clearAllGameDatas, clearChoiceMenuOptions, clearDialogue, getChoiceMenuOptions, getDialogue, getDialogueHistory, getFlag, getSaveData, getSaveJson, getTexture, loadImages, loadSaveData, loadSaveJson, removeCanvasElement, setChoiceMenuOptions, setDialogue, setFlag, showWithDissolveTransition };
2288
+ //# sourceMappingURL=out.js.map
2289
+ //# sourceMappingURL=index.mjs.map