webtalekit-alpha 0.2.11 → 0.2.13

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 (389) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.clinerules +65 -0
  3. package/.history/README_20240812174230.md +193 -0
  4. package/.history/README_20240812175424.md +185 -0
  5. package/.history/README_20240812191012.md +185 -0
  6. package/.history/README_20240812191155.md +185 -0
  7. package/.history/README_20240812191211.md +185 -0
  8. package/.history/README_20240812192035.md +185 -0
  9. package/.history/dist/src/core/index_20240815021552.js +474 -0
  10. package/.history/dist/src/core/index_20240815022042.js +476 -0
  11. package/.history/dist/src/core/index_20240815022206.js +476 -0
  12. package/.history/dist/src/core/index_20240815023104.js +478 -0
  13. package/.history/dist/src/core/index_20240817022019.js +494 -0
  14. package/.history/dist/src/core/index_20240818013827.js +493 -0
  15. package/.history/dist/src/core/index_20240820001418.js +502 -0
  16. package/.history/package_20240812174230.json +45 -0
  17. package/.history/package_20240825011731.json +45 -0
  18. package/.history/package_20240825011739.json +44 -0
  19. package/.history/parser/parser_20240812174230.js +50 -0
  20. package/.history/parser/parser_20240825012739.js +47 -0
  21. package/.history/parser/parser_20240825012835.js +52 -0
  22. package/.history/src/core/drawer_20240813091343.ts +262 -0
  23. package/.history/src/core/drawer_20240815232345.ts +262 -0
  24. package/.history/src/core/drawer_20240815232350.ts +262 -0
  25. package/.history/src/core/drawer_20240816025257.ts +357 -0
  26. package/.history/src/core/drawer_20240816025358.ts +357 -0
  27. package/.history/src/core/drawer_20240816030148.ts +365 -0
  28. package/.history/src/core/drawer_20240816231033.ts +294 -0
  29. package/.history/src/core/drawer_20240816231107.ts +262 -0
  30. package/.history/src/core/drawer_20240816231234.ts +268 -0
  31. package/.history/src/core/drawer_20240817013836.ts +290 -0
  32. package/.history/src/core/drawer_20240817015150.ts +289 -0
  33. package/.history/src/core/drawer_20240817015353.ts +290 -0
  34. package/.history/src/core/drawer_20240817021254.ts +291 -0
  35. package/.history/src/core/drawer_20240817023440.ts +295 -0
  36. package/.history/src/core/drawer_20240817023445.ts +295 -0
  37. package/.history/src/core/drawer_20240818015327.ts +295 -0
  38. package/.history/src/core/drawer_20240819231006.ts +318 -0
  39. package/.history/src/core/drawer_20240820002829.ts +317 -0
  40. package/.history/src/core/drawer_20240820003141.ts +295 -0
  41. package/.history/src/core/drawer_20240824010043.ts +295 -0
  42. package/.history/src/core/drawer_20240825013311.ts +293 -0
  43. package/.history/src/core/drawer_20240902235257.ts +295 -0
  44. package/.history/src/core/drawer_20240904002038.ts +262 -0
  45. package/.history/src/core/drawer_20240904004020.ts +262 -0
  46. package/.history/src/core/drawer_20240904004238.ts +262 -0
  47. package/.history/src/core/drawer_20240904005648.ts +262 -0
  48. package/.history/src/core/drawer_20240904005808.ts +262 -0
  49. package/.history/src/core/drawer_20240904010523.ts +262 -0
  50. package/.history/src/core/drawer_20240904011611.ts +262 -0
  51. package/.history/src/core/drawer_20240904011740.ts +262 -0
  52. package/.history/src/core/index_20240812190102.js +443 -0
  53. package/.history/src/core/index_20240812190105.js +443 -0
  54. package/.history/src/core/index_20240812205421.js +452 -0
  55. package/.history/src/core/index_20240812213441.js +452 -0
  56. package/.history/src/core/index_20240812214203.js +453 -0
  57. package/.history/src/core/index_20240813090823.js +453 -0
  58. package/.history/src/core/index_20240813230449.js +452 -0
  59. package/.history/src/core/index_20240813230539.js +452 -0
  60. package/.history/src/core/index_20240813231447.js +453 -0
  61. package/.history/src/core/index_20240813231449.js +453 -0
  62. package/.history/src/core/index_20240813231511.js +453 -0
  63. package/.history/src/core/index_20240813231531.js +453 -0
  64. package/.history/src/core/index_20240813231913.js +453 -0
  65. package/.history/src/core/index_20240813232356.js +453 -0
  66. package/.history/src/core/index_20240813232640.js +453 -0
  67. package/.history/src/core/index_20240813232900.js +453 -0
  68. package/.history/src/core/index_20240814221127.js +454 -0
  69. package/.history/src/core/index_20240814221322.js +454 -0
  70. package/.history/src/core/index_20240814221526.js +454 -0
  71. package/.history/src/core/index_20240814222048.js +454 -0
  72. package/.history/src/core/index_20240814222918.js +459 -0
  73. package/.history/src/core/index_20240814223136.js +459 -0
  74. package/.history/src/core/index_20240814223501.js +464 -0
  75. package/.history/src/core/index_20240814224347.js +468 -0
  76. package/.history/src/core/index_20240815013712.js +474 -0
  77. package/.history/src/core/index_20240815021534.js +474 -0
  78. package/.history/src/core/index_20240815023143.js +477 -0
  79. package/.history/src/core/index_20240815023207.js +479 -0
  80. package/.history/src/core/index_20240815023344.js +481 -0
  81. package/.history/src/core/index_20240815035600.js +479 -0
  82. package/.history/src/core/index_20240815041549.js +480 -0
  83. package/.history/src/core/index_20240815185515.js +481 -0
  84. package/.history/src/core/index_20240815192158.js +481 -0
  85. package/.history/src/core/index_20240815222912.js +482 -0
  86. package/.history/src/core/index_20240815224052.js +483 -0
  87. package/.history/src/core/index_20240815224843.js +484 -0
  88. package/.history/src/core/index_20240815224850.js +483 -0
  89. package/.history/src/core/index_20240815231706.js +479 -0
  90. package/.history/src/core/index_20240816025748.js +483 -0
  91. package/.history/src/core/index_20240816030102.js +484 -0
  92. package/.history/src/core/index_20240817013329.js +485 -0
  93. package/.history/src/core/index_20240817013526.js +485 -0
  94. package/.history/src/core/index_20240817013819.js +488 -0
  95. package/.history/src/core/index_20240817013829.js +488 -0
  96. package/.history/src/core/index_20240817014921.js +494 -0
  97. package/.history/src/core/index_20240817022057.js +494 -0
  98. package/.history/src/core/index_20240817023316.js +493 -0
  99. package/.history/src/core/index_20240818005637.js +493 -0
  100. package/.history/src/core/index_20240818005721.js +493 -0
  101. package/.history/src/core/index_20240818011804.js +493 -0
  102. package/.history/src/core/index_20240818013835.js +493 -0
  103. package/.history/src/core/index_20240818014310.js +493 -0
  104. package/.history/src/core/index_20240818014323.js +493 -0
  105. package/.history/src/core/index_20240818014333.js +493 -0
  106. package/.history/src/core/index_20240818020725.js +496 -0
  107. package/.history/src/core/index_20240819195504.js +497 -0
  108. package/.history/src/core/index_20240819202012.js +495 -0
  109. package/.history/src/core/index_20240819231228.js +501 -0
  110. package/.history/src/core/index_20240819232555.js +502 -0
  111. package/.history/src/core/index_20240819233404.js +502 -0
  112. package/.history/src/core/index_20240820003114.js +495 -0
  113. package/.history/src/core/index_20240820003120.js +495 -0
  114. package/.history/src/core/index_20240820003331.js +495 -0
  115. package/.history/src/core/index_20240820004126.js +498 -0
  116. package/.history/src/core/index_20240820004357.js +497 -0
  117. package/.history/src/core/index_20240820005103.js +498 -0
  118. package/.history/src/core/index_20240820005110.js +499 -0
  119. package/.history/src/core/index_20240820005206.js +497 -0
  120. package/.history/src/core/index_20240820005352.js +497 -0
  121. package/{src/core/index.js → .history/src/core/index_20240823224904.ts} +75 -231
  122. package/.history/src/core/index_20240823224905.js +505 -0
  123. package/.history/src/core/index_20240823231631.ts +530 -0
  124. package/.history/src/core/index_20240823231735.ts +530 -0
  125. package/.history/src/core/index_20240823232123.ts +539 -0
  126. package/.history/src/core/index_20240823232329.ts +539 -0
  127. package/.history/src/core/index_20240823233058.ts +539 -0
  128. package/.history/src/core/index_20240823234946.ts +539 -0
  129. package/.history/src/core/index_20240824005956.ts +534 -0
  130. package/.history/src/core/index_20240824010113.ts +534 -0
  131. package/.history/src/core/index_20240824010124.ts +534 -0
  132. package/.history/src/core/index_20240824010212.ts +534 -0
  133. package/.history/src/core/index_20240824010218.ts +534 -0
  134. package/.history/src/core/index_20240824010407.ts +534 -0
  135. package/.history/src/core/index_20240824010611.ts +534 -0
  136. package/.history/src/core/index_20240824010623.ts +534 -0
  137. package/.history/src/core/index_20240824010652.ts +534 -0
  138. package/.history/src/core/index_20240824011007.ts +534 -0
  139. package/.history/src/core/index_20240824210450.ts +534 -0
  140. package/.history/src/core/index_20240824210703.ts +534 -0
  141. package/.history/src/core/index_20240824210708.ts +534 -0
  142. package/.history/src/core/index_20240824211001.ts +537 -0
  143. package/.history/src/core/index_20240824211258.ts +537 -0
  144. package/.history/src/core/index_20240824211654.ts +537 -0
  145. package/.history/src/core/index_20240824211723.ts +537 -0
  146. package/.history/src/core/index_20240824211808.ts +538 -0
  147. package/.history/src/core/index_20240824214041.js +538 -0
  148. package/.history/src/core/index_20240824215312.ts +538 -0
  149. package/.history/src/core/index_20240824215341.ts +538 -0
  150. package/.history/src/core/index_20240824220703.ts +538 -0
  151. package/.history/src/core/index_20240824220709.ts +538 -0
  152. package/.history/src/core/index_20240825012244.ts +536 -0
  153. package/.history/src/core/index_20240825012435.ts +539 -0
  154. package/.history/src/core/index_20240825012440.ts +539 -0
  155. package/.history/src/core/index_20240826005054.ts +539 -0
  156. package/.history/src/core/index_20240826005321.ts +540 -0
  157. package/.history/src/core/index_20240826005410.ts +539 -0
  158. package/.history/src/core/index_20240826005418.ts +539 -0
  159. package/.history/src/core/index_20240830231825.ts +539 -0
  160. package/.history/src/core/index_20240831022416.ts +539 -0
  161. package/.history/src/core/index_20240901222314.js +459 -0
  162. package/.history/src/core/index_20240901222951.js +459 -0
  163. package/.history/src/core/index_20240901223824.js +471 -0
  164. package/.history/src/core/index_20240901223833.js +468 -0
  165. package/.history/src/core/index_20240902223954.js +447 -0
  166. package/.history/src/core/index_20240902224000.js +446 -0
  167. package/.history/src/core/index_20240902230345.js +448 -0
  168. package/.history/src/core/index_20240902231130.js +449 -0
  169. package/.history/src/core/index_20240902231559.js +449 -0
  170. package/.history/src/core/index_20240902232135.js +449 -0
  171. package/.history/src/core/index_20240902232809.js +452 -0
  172. package/.history/src/core/index_20240902232815.js +452 -0
  173. package/.history/src/core/index_20240903000104.js +467 -0
  174. package/.history/src/core/index_20240904001731.js +444 -0
  175. package/.history/src/core/index_20240904002038.ts +539 -0
  176. package/.history/src/core/index_20240904011848.js +444 -0
  177. package/.history/src/core/index_20240904012138.js +444 -0
  178. package/.history/src/core/index_20240904012743.js +444 -0
  179. package/.history/src/core/index_20240904013051.js +444 -0
  180. package/.history/src/core/resourceManager_20240403231531.ts +16 -0
  181. package/.history/src/core/resourceManager_20240823232627.ts +17 -0
  182. package/.history/src/core/resourceManager_20240824214014.js +16 -0
  183. package/.history/src/core/resourceManager_20240824214620.js +17 -0
  184. package/.history/src/core/scenarioManager_20240812203410.ts +86 -0
  185. package/.history/src/core/scenarioManager_20240812203839.ts +94 -0
  186. package/.history/src/core/scenarioManager_20240812213437.ts +85 -0
  187. package/.history/src/core/scenarioManager_20240813225852.ts +85 -0
  188. package/.history/src/core/scenarioManager_20240823235010.ts +85 -0
  189. package/.history/src/core/scenarioManager_20240904002038.ts +94 -0
  190. package/.history/src/core/scenarioManager_20240904012411.ts +94 -0
  191. package/.history/src/core/scenarioManager_20240904012519.ts +94 -0
  192. package/.history/src/index_20240403231531.js +6 -0
  193. package/.history/src/index_20240429233436.js +8 -0
  194. package/.history/src/index_20240429233926.js +8 -0
  195. package/.history/src/index_20240429234401.js +7 -0
  196. package/.history/src/index_20240429234404.js +6 -0
  197. package/.history/src/resource/soundObject_20240419004314.ts +71 -0
  198. package/.history/src/resource/soundObject_20240815034420.ts +66 -0
  199. package/.history/src/resource/soundObject_20240815034836.ts +79 -0
  200. package/.history/src/resource/soundObject_20240815034919.ts +87 -0
  201. package/.history/src/resource/soundObject_20240815040724.ts +81 -0
  202. package/.history/src/resource/soundObject_20240815041022.ts +87 -0
  203. package/.history/src/resource/soundObject_20240815042103.ts +87 -0
  204. package/.history/src/resource/soundObject_20240823235929.ts +91 -0
  205. package/.history/src/resource/soundObject_20240824213129.ts +99 -0
  206. package/.history/src/resource/soundObject_20240824213611.ts +101 -0
  207. package/.history/src/resource/soundObject_20240824215734.ts +101 -0
  208. package/.history/src/resource/soundObject_20240825004926.ts +101 -0
  209. package/.history/src/resource/soundObject_20240825004947.ts +101 -0
  210. package/.history/src/utils/logger_20240812174230.ts +13 -0
  211. package/.history/src/utils/logger_20240823232736.ts +14 -0
  212. package/.history/src/utils/logger_20240824214930.js +14 -0
  213. package/.history/src/utils/store_20240812174230.ts +17 -0
  214. package/.history/src/utils/store_20240823232948.ts +29 -0
  215. package/.history/src/utils/store_20240824214020.js +17 -0
  216. package/.history/src/utils/store_20240824214955.js +29 -0
  217. package/.history/src/utils/waitUtil_20240812174230.ts +4 -0
  218. package/.history/src/utils/waitUtil_20240823232739.ts +4 -0
  219. package/.history/src/utils/waitUtil_20240824214024.js +4 -0
  220. package/.history/src/utils/waitUtil_20240824215009.js +4 -0
  221. package/.history/test/js/title_20240428215305.js +254 -0
  222. package/.history/test/js/title_20240429221911.js +227 -0
  223. package/.history/test/js/title_20240429222806.js +243 -0
  224. package/.history/test/js/title_20240429222854.js +263 -0
  225. package/.history/test/js/title_20240429222906.js +263 -0
  226. package/.history/test/js/title_20240429235639.js +263 -0
  227. package/.history/test/js/title_20240429235840.js +263 -0
  228. package/.history/test/js/title_20240430014721.js +262 -0
  229. package/.history/test/js/title_20240430014759.js +254 -0
  230. package/.history/test/js/title_20240430134612.js +285 -0
  231. package/.history/test/js/title_20240430141051.js +285 -0
  232. package/.history/test/js/title_20240430173745.js +245 -0
  233. package/.history/tsconfig_20240812174230.json +22 -0
  234. package/.history/tsconfig_20240824010157.json +19 -0
  235. package/.history/tsconfig_20240824220700.json +20 -0
  236. package/.history/tsconfig_20240825011301.json +20 -0
  237. package/.history/webpack.config_20240423002825.js +37 -0
  238. package/.history/webpack.config_20240430001157.js +38 -0
  239. package/.history/webpack.config_20240430001309.js +37 -0
  240. package/.history/webpack.config_20240430002112.js +37 -0
  241. package/CLAUDE.md +96 -0
  242. package/LICENSE +21 -0
  243. package/README.md +108 -39
  244. package/coverage/lcov-report/base.css +224 -0
  245. package/coverage/lcov-report/block-navigation.js +87 -0
  246. package/coverage/lcov-report/core/drawer.ts.html +1264 -0
  247. package/coverage/lcov-report/core/index.html +146 -0
  248. package/coverage/lcov-report/core/resourceManager.ts.html +136 -0
  249. package/coverage/lcov-report/core/scenarioManager.ts.html +373 -0
  250. package/coverage/lcov-report/favicon.png +0 -0
  251. package/coverage/lcov-report/index.html +146 -0
  252. package/coverage/lcov-report/prettify.css +1 -0
  253. package/coverage/lcov-report/prettify.js +2 -0
  254. package/coverage/lcov-report/resource/ImageObject.ts.html +433 -0
  255. package/coverage/lcov-report/resource/index.html +131 -0
  256. package/coverage/lcov-report/resource/soundObject.ts.html +346 -0
  257. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  258. package/coverage/lcov-report/sorter.js +196 -0
  259. package/coverage/lcov-report/utils/TextMeasurer.ts.html +520 -0
  260. package/coverage/lcov-report/utils/index.html +161 -0
  261. package/coverage/lcov-report/utils/logger.ts.html +142 -0
  262. package/coverage/lcov-report/utils/store.ts.html +151 -0
  263. package/coverage/lcov-report/utils/waitUtil.ts.html +97 -0
  264. package/coverage/lcov.info +882 -0
  265. package/dist/README.md +294 -0
  266. package/dist/engineConfig.json +10 -0
  267. package/dist/package.json +51 -0
  268. package/dist/parser/cli.js +61 -0
  269. package/dist/parser/parser.js +53 -0
  270. package/{src → dist/src}/core/drawer.js +0 -9
  271. package/dist/src/core/drawer.js.map +1 -0
  272. package/dist/src/core/index.js +969 -0
  273. package/{src → dist/src}/core/scenarioManager.js +5 -6
  274. package/dist/src/core/scenarioManager.js.map +1 -0
  275. package/{src → dist/src}/resource/soundObject.js +4 -2
  276. package/dist/src/resource/soundObject.js.map +1 -0
  277. package/dist/src/utils/fallbackTemplate.js +13 -0
  278. package/dist/src/utils/fallbackTemplate.js.map +1 -0
  279. package/dist/webtalekit-alpha-0.2.13.tgz +0 -0
  280. package/docs/event-system-specification.md +493 -0
  281. package/docs/glossary.html +833 -0
  282. package/docs/index.html +296 -0
  283. package/docs/tag-reference.html +1317 -0
  284. package/docs/ui-template-guide.html +1068 -0
  285. package/example/README.md +29 -0
  286. package/example/engineConfig.json +10 -0
  287. package/example/package-lock.json +5145 -0
  288. package/example/package.json +26 -0
  289. package/example/src/index.js +13 -0
  290. package/example/src/resource/background/beach.jpg +0 -0
  291. package/example/src/resource/background/city.jpg +0 -0
  292. package/example/src/resource/background/crossroad.jpg +0 -0
  293. package/example/src/resource/background/forest.jpg +0 -0
  294. package/example/src/resource/background/laboratory.jpg +0 -0
  295. package/example/src/resource/background/library.jpg +0 -0
  296. package/example/src/resource/background/living_room.jpg +0 -0
  297. package/example/src/resource/background/music_room.jpg +0 -0
  298. package/example/src/resource/background/stage.jpg +0 -0
  299. package/example/src/resource/background/sunset.jpg +0 -0
  300. package/example/src/resource/background/title_bg.png +0 -0
  301. package/example/src/resource/bgm/calm_music.wav +0 -0
  302. package/example/src/resource/bgm/doorbell.mp3 +0 -0
  303. package/example/src/resource/bgm/nc366476_Virtual_Voyage.mp3 +0 -0
  304. package/example/src/resource/bgm/title_theme.mp3 +0 -0
  305. package/example/src/resource/chara/dancer.png +0 -0
  306. package/example/src/resource/chara/guest.png +0 -0
  307. package/example/src/resource/chara/guide.png +0 -0
  308. package/example/src/resource/chara/scientist.png +0 -0
  309. package/example/src/resource/config.js +0 -0
  310. package/example/src/resource/se/doorbell.mp3 +0 -0
  311. package/example/src/resource/system/systemPicture/01_message/message.png +0 -0
  312. package/example/src/resource/system/systemPicture/02_button/button.png +0 -0
  313. package/example/src/resource/system/systemPicture/02_button/button2.png +0 -0
  314. package/example/src/resource/system/systemPicture/02_button/button3.png +0 -0
  315. package/example/src/resource/system/systemPicture/03_system_button/auto.png +0 -0
  316. package/example/src/resource/system/systemPicture/03_system_button/auto2.png +0 -0
  317. package/example/src/resource/system/systemPicture/03_system_button/close.png +0 -0
  318. package/example/src/resource/system/systemPicture/03_system_button/close2.png +0 -0
  319. package/example/src/resource/system/systemPicture/03_system_button/config.png +0 -0
  320. package/example/src/resource/system/systemPicture/03_system_button/config2.png +0 -0
  321. package/example/src/resource/system/systemPicture/03_system_button/load.png +0 -0
  322. package/example/src/resource/system/systemPicture/03_system_button/load2.png +0 -0
  323. package/example/src/resource/system/systemPicture/03_system_button/log.png +0 -0
  324. package/example/src/resource/system/systemPicture/03_system_button/log2.png +0 -0
  325. package/example/src/resource/system/systemPicture/03_system_button/menu.png +0 -0
  326. package/example/src/resource/system/systemPicture/03_system_button/menu2.png +0 -0
  327. package/example/src/resource/system/systemPicture/03_system_button/qload.png +0 -0
  328. package/example/src/resource/system/systemPicture/03_system_button/qload2.png +0 -0
  329. package/example/src/resource/system/systemPicture/03_system_button/qsave.png +0 -0
  330. package/example/src/resource/system/systemPicture/03_system_button/qsave2.png +0 -0
  331. package/example/src/resource/system/systemPicture/03_system_button/save.png +0 -0
  332. package/example/src/resource/system/systemPicture/03_system_button/save2.png +0 -0
  333. package/example/src/resource/system/systemPicture/03_system_button/screen.png +0 -0
  334. package/example/src/resource/system/systemPicture/03_system_button/screen2.png +0 -0
  335. package/example/src/resource/system/systemPicture/03_system_button/skip.png +0 -0
  336. package/example/src/resource/system/systemPicture/03_system_button/skip2.png +0 -0
  337. package/example/src/resource/system/systemPicture/03_system_button/title.png +0 -0
  338. package/example/src/resource/system/systemPicture/03_system_button/title2.png +0 -0
  339. package/example/src/resource/system/systemPicture//345/210/251/347/224/250/350/246/217/347/264/204.txt +0 -0
  340. package/example/src/resource/system/wait.gif +0 -0
  341. package/example/src/scene/animation.scene +28 -0
  342. package/example/src/scene/background.scene +29 -0
  343. package/example/src/scene/character.scene +26 -0
  344. package/example/src/scene/choice.scene +97 -0
  345. package/example/src/scene/dialog.scene +105 -0
  346. package/example/src/scene/effects.scene +38 -0
  347. package/example/src/scene/en/animation.scene +28 -0
  348. package/example/src/scene/en/background.scene +26 -0
  349. package/example/src/scene/en/character.scene +26 -0
  350. package/example/src/scene/en/choice.scene +32 -0
  351. package/example/src/scene/en/effects.scene +37 -0
  352. package/example/src/scene/en/sound.scene +26 -0
  353. package/example/src/scene/en/text.scene +26 -0
  354. package/example/src/scene/en/title.scene +39 -0
  355. package/example/src/scene/if_test.scene +37 -0
  356. package/example/src/scene/resource-error-test.scene +15 -0
  357. package/example/src/scene/save-load-test.scene +48 -0
  358. package/example/src/scene/sound.scene +26 -0
  359. package/example/src/scene/test_error.scene +21 -0
  360. package/example/src/scene/text.scene +34 -0
  361. package/example/src/scene/title.scene +51 -0
  362. package/example/src/screen/incoming.html +474 -0
  363. package/example/src/screen/title.html +135 -0
  364. package/example/src/template.html +16 -0
  365. package/example/test-results/.last-run.json +4 -0
  366. package/example/webpack.config.js +69 -0
  367. package/image.png +0 -0
  368. package/package.json +3 -1
  369. package/playwright-report/index.html +71 -0
  370. package/s-plan1-5Light-s-1.jpg +0 -0
  371. package/test-results/.last-run.json +6 -0
  372. package/tests/e2e/if-global-attribute.spec.js +90 -0
  373. package/tests/e2e/resource-error-handling.spec.js +58 -0
  374. package/tests/e2e/screenshots/before-error-check.png +0 -0
  375. package/tests/e2e/screenshots/choices.png +0 -0
  376. package/tests/e2e/screenshots/message-window-click-wait.png +0 -0
  377. package/src/core/drawer.js.map +0 -1
  378. package/src/core/scenarioManager.js.map +0 -1
  379. package/src/resource/soundObject.js.map +0 -1
  380. /package/{src → dist/src}/core/resourceManager.js +0 -0
  381. /package/{src → dist/src}/core/resourceManager.js.map +0 -0
  382. /package/{src → dist/src}/resource/ImageObject.js +0 -0
  383. /package/{src → dist/src}/resource/ImageObject.js.map +0 -0
  384. /package/{src → dist/src}/utils/logger.js +0 -0
  385. /package/{src → dist/src}/utils/logger.js.map +0 -0
  386. /package/{src → dist/src}/utils/store.js +0 -0
  387. /package/{src → dist/src}/utils/store.js.map +0 -0
  388. /package/{src → dist/src}/utils/waitUtil.js +0 -0
  389. /package/{src → dist/src}/utils/waitUtil.js.map +0 -0
@@ -0,0 +1,262 @@
1
+ import { ImageObject } from '../resource/ImageObject'
2
+ import { outputLog } from '../utils/logger'
3
+ import { sleep } from '../utils/waitUtil'
4
+
5
+ /*
6
+ drawerの目的
7
+ UIのHTMLとcanvasを描画する。
8
+ */
9
+ export class Drawer {
10
+ private gameScreen: HTMLElement
11
+ private nameView!: HTMLElement
12
+ private messageText!: HTMLElement
13
+ private interactiveView!: HTMLElement
14
+ private ctx!: CanvasRenderingContext2D
15
+ private screenHtml!: HTMLElement
16
+ private config: any
17
+ isSkip: boolean = false
18
+ readySkip: boolean = false
19
+
20
+ constructor(gameContainer: HTMLElement) {
21
+ this.gameScreen = gameContainer
22
+ // ウィンドウのリサイズ時にスケールを調整
23
+ window.addEventListener('resize', () => this.adjustScale(this.gameScreen))
24
+ // 初期ロード時にもスケールを調整
25
+ this.adjustScale(this.gameScreen)
26
+ }
27
+
28
+ setScreen(screenHtml: HTMLElement, resolution: { width: number; height: number }) {
29
+ this.screenHtml = screenHtml
30
+ this.nameView = screenHtml.querySelector('#nameView') as HTMLElement
31
+ this.messageText = screenHtml.querySelector('#messageView') as HTMLElement
32
+ this.interactiveView = screenHtml.querySelector(
33
+ '#interactiveView',
34
+ ) as HTMLElement
35
+
36
+ // canvasをDOMに追加する
37
+ const canvas = document.createElement('canvas')
38
+ canvas.width = resolution.width || 1280
39
+ canvas.height = resolution.height || 720
40
+ // canvasのコンテキストを取得する
41
+ this.gameScreen.appendChild(canvas)
42
+ this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D
43
+ // 黒で塗りつぶす
44
+ this.ctx.fillStyle = 'black'
45
+ this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
46
+ // 初期ロード時にもスケールを調整
47
+ this.adjustScale(this.gameScreen)
48
+ }
49
+
50
+ drawName(name: string) {
51
+ this.nameView.innerHTML = name
52
+ }
53
+
54
+ async drawText(text: string, wait: number) {
55
+ this.messageText.innerHTML = ''
56
+ for (const char of text) {
57
+ //prettier-ignore
58
+ setTimeout(() => { this.readySkip = true, wait*500 });
59
+ // 100ミリ秒待ってから、スキップボタンが押されたら即座に表示
60
+ if (!this.isSkip) {
61
+ this.messageText.innerHTML += char
62
+ await sleep(wait)
63
+ } else {
64
+ if (this.readySkip) {
65
+ this.messageText.innerHTML = text
66
+ this.readySkip = false
67
+ this.isSkip = false
68
+ break
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ async drawChoices(choices: any) {
75
+ let isSelect = false
76
+ let selectId = 0
77
+ let onSelect = 0
78
+
79
+ // 選択肢ボタンの配置を設定する
80
+ const interactiveView = document.querySelector(
81
+ '#interactiveView',
82
+ ) as HTMLElement
83
+ if (choices.position == 'auto' || choices.position === undefined) {
84
+ interactiveView.className = 'auto'
85
+ } else {
86
+ interactiveView.className = 'manual'
87
+ }
88
+ // 選択肢を表示
89
+ for (const choice of choices.content) {
90
+ const defaultImage =
91
+ choice.default !== undefined
92
+ ? choice.default
93
+ : './src/resource/system/systemPicture/02_button/button.png'
94
+ const hoverImage =
95
+ choice.hover !== undefined
96
+ ? choice.hover
97
+ : './src/resource/system/systemPicture/02_button/button2.png'
98
+ const selectImage =
99
+ choice.select !== undefined
100
+ ? choice.select
101
+ : './src/resource/system/systemPicture/02_button/button3.png'
102
+ const button = document.createElement('div')
103
+ button.className = 'choice'
104
+ if (interactiveView.className == 'manual') {
105
+ button.style.position = 'absolute'
106
+ button.style.top = choice.position?.y || 0
107
+ button.style.left = choice.position?.x || 0
108
+ }
109
+ button.style.color =
110
+ choice.color !== undefined ? choice.color.default : 'black'
111
+ button.style.width = '100%'
112
+ button.style.height = '50px'
113
+ button.style.backgroundImage = `url(${defaultImage})`
114
+ button.style.textAlign = 'center'
115
+ button.style.backgroundRepeat = 'no-repeat'
116
+ button.style.backgroundPosition = 'center'
117
+ button.style.paddingTop = '20px'
118
+ button.addEventListener('mouseenter', function () {
119
+ // マウスが要素の上にあるときの背景色
120
+ this.style.backgroundImage = `url(${hoverImage})`
121
+ this.style.color =
122
+ choice.color !== undefined ? choice.color.hover : 'black'
123
+ })
124
+ button.addEventListener('mouseleave', function () {
125
+ // マウスが要素から離れたときの背景色
126
+ this.style.backgroundImage = `url(${defaultImage})`
127
+ this.style.color =
128
+ choice.color !== undefined ? choice.color.default : 'black'
129
+ })
130
+ button.addEventListener('mousedown', function () {
131
+ // マウスが要素を選択したときの背景色
132
+ this.style.backgroundImage = `url(${selectImage})`
133
+ this.style.color =
134
+ choice.color !== undefined ? choice.color.select : 'black'
135
+ })
136
+ button.innerHTML = choice.label
137
+ button.onclick = () => {
138
+ outputLog('click', 'debug', choice)
139
+ this.interactiveView.querySelectorAll('.choice').forEach((element) => {
140
+ element.parentNode?.removeChild(element)
141
+ })
142
+ selectId = choice.id
143
+ onSelect = choice.content.map((item: any) => ({ ...item, sub: true }))
144
+ isSelect = true
145
+ }
146
+ this.interactiveView.appendChild(button)
147
+ }
148
+
149
+ // 選択待ち
150
+ return new Promise((resolve) => {
151
+ const intervalId = setInterval(() => {
152
+ if (isSelect) {
153
+ clearInterval(intervalId)
154
+ resolve({ selectId, onSelect })
155
+ }
156
+ }, 100)
157
+ })
158
+ }
159
+
160
+ clear() {
161
+ this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
162
+ }
163
+
164
+ show(displayedImages: any) {
165
+ this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)
166
+ for (let key in displayedImages) {
167
+ const img: ImageObject = displayedImages[key].image
168
+ const pos: { x: number; y: number } = displayedImages[key].pos || {
169
+ x: 0,
170
+ y: 0,
171
+ }
172
+ const size: { width: number; height: number } = displayedImages[key].size
173
+ const reverse: boolean = displayedImages[key].look || false
174
+ const entry: { time: number; wait: boolean } = displayedImages[key]
175
+ .entry || { time: 1, wait: false }
176
+ if (entry.wait) {
177
+ // 表示開始までの遅延処理
178
+ setTimeout(() => {
179
+ this.drawCanvas(img, pos, size, reverse)
180
+ }, entry.time * 1000)
181
+ } else {
182
+ this.drawCanvas(img, pos, size, reverse)
183
+ }
184
+ }
185
+ }
186
+
187
+ moveTo(name: string, displayedImages: any, pos: { x: number; y: number }, durning: number) {
188
+ return new Promise((resolve) => {
189
+ const target = displayedImages[name];
190
+ const startPos = { x: target.pos.x, y: target.pos.y };
191
+ const dest = { x: startPos.x + Number(pos.x), y: startPos.y + Number(pos.y) };
192
+ const startTime = performance.now();
193
+
194
+ const move = (currentTime:any) => {
195
+ const elapsedTime = (currentTime - startTime) / 1000; // 秒単位の経過時間
196
+ const progress = Math.min(elapsedTime / durning, 1); // 0から1の進捗
197
+
198
+ target.pos.x = startPos.x + (dest.x - startPos.x) * progress;
199
+ target.pos.y = startPos.y + (dest.y - startPos.y) * progress;
200
+
201
+ this.show(displayedImages);
202
+
203
+ if (progress < 1) {
204
+ window.requestAnimationFrame(move);
205
+ } else {
206
+ // 最終位置を正確に設定
207
+ target.pos.x = dest.x;
208
+ target.pos.y = dest.y;
209
+ this.show(displayedImages);
210
+ resolve(null);
211
+ }
212
+ };
213
+
214
+ window.requestAnimationFrame(move);
215
+ });
216
+ }
217
+ drawCanvas(img: ImageObject, pos: any, size: any, reverse: any) {
218
+ outputLog('drawCanvas', 'debug', {img, pos, size, reverse})
219
+ const canvas = img.draw(reverse).getCanvas()
220
+ // canvasから画像を取得して、this.ctxに描画
221
+ const imageWidth = size !== undefined ? size.width : canvas.width
222
+ const imageHeight = size !== undefined ? size.height : canvas.height
223
+ this.ctx.drawImage(
224
+ canvas,
225
+ 0,
226
+ 0,
227
+ canvas.width,
228
+ canvas.height,
229
+ pos.x,
230
+ pos.y,
231
+ imageWidth,
232
+ imageHeight,
233
+ ) //CanvasRenderingContext2D.drawImage: Passed-in canvas is empty
234
+ }
235
+
236
+ adjustScale(targetElement: HTMLElement) {
237
+ // ターゲット要素の元の幅と高さ
238
+ const originalWidth = targetElement.scrollWidth // 例: 1280px
239
+ const originalHeight = targetElement.scrollHeight // 例: 720px
240
+
241
+ // ビューポートの幅と高さを取得
242
+ const viewportWidth = window.innerWidth
243
+ const viewportHeight = window.innerHeight
244
+
245
+ // 幅と高さのスケールを計算
246
+ const scaleX = viewportWidth / originalWidth
247
+ const scaleY = viewportHeight / originalHeight
248
+
249
+ // 幅と高さのうち、小さい方のスケールを選択(アスペクト比を維持)
250
+ const scale = Math.min(scaleX, scaleY)
251
+
252
+ // ターゲット要素にスケールを適用
253
+ targetElement.style.transform = `scale(${scale})`
254
+ }
255
+
256
+ setVisibility(name: string, isVisible: boolean) {
257
+ const target = this.screenHtml.querySelector(name) as HTMLElement
258
+ if (target) {
259
+ target.style.visibility = isVisible ? 'visible' : 'hidden'
260
+ }
261
+ }
262
+ }
@@ -0,0 +1,443 @@
1
+ import { Drawer } from './drawer'
2
+ import { ScenarioManager } from './scenarioManager'
3
+ import { ImageObject } from '../resource/ImageObject'
4
+ import { ResourceManager } from './resourceManager'
5
+ import { SoundObject } from '../resource/soundObject'
6
+ import engineConfig from '../../engineConfig.json'
7
+ import { outputLog } from '../utils/logger'
8
+ import { sleep } from '../utils/waitUtil'
9
+
10
+ export class Core {
11
+ isAuto = false
12
+ isNext = false
13
+ isSkip = false
14
+ onNextHandler = null
15
+ sceneFile = {}
16
+ sceneConfig = {}
17
+ commandList = {
18
+ text: this.textHandler,
19
+ choice: this.choiceHandler,
20
+ show: this.showHandler,
21
+ newpage: this.newpageHandler,
22
+ hide: this.hideHandler,
23
+ jump: this.jumpHandler,
24
+ sound: this.soundHandler,
25
+ say: this.sayHandler,
26
+ if: this.ifHandler,
27
+ call: this.callHandler,
28
+ moveto: this.moveToHandler,
29
+ route: this.routeHandler,
30
+ }
31
+
32
+ constructor() {
33
+ this.gameContainer = document.getElementById('gameContainer')
34
+ // Drawerの初期化(canvasタグのサイズを設定する)
35
+ this.drawer = new Drawer(this.gameContainer)
36
+ // ScenarioManagerの初期化(変数の初期値設定)
37
+ this.scenarioManager = new ScenarioManager()
38
+ // ResourceManagerの初期化(引数にconfigを渡して、リソース管理配列を作る)
39
+ this.resourceManager = new ResourceManager(import(/* webpackIgnore: true */ '/src/resource/config.js')) // webpackIgnoreでバンドルを無視する
40
+ this.displayedImages = {}
41
+ this.usedSounds = {}
42
+ }
43
+
44
+ async start() {
45
+ outputLog('call', 'debug')
46
+ // TODO: ブラウザ用のビルドの場合は、最初にクリックしてもらう
47
+ // titleタグの内容を書き換える
48
+ document.title = engineConfig.title
49
+ // sceneファイルを読み込む
50
+ await this.loadScene('title')
51
+ // 画面を表示する
52
+ await this.loadScreen(this.sceneConfig)
53
+ // 入力イベントを設定する
54
+ document.addEventListener('keydown', (e) => {
55
+ if (e.key === 'Enter') {
56
+ this.onNextHandler()
57
+ } else if (e.key === 'Control') {
58
+ this.drawer.isSkip = true
59
+ this.isNext = true
60
+ }
61
+ })
62
+ document.addEventListener('keyup', (e) => {
63
+ if (e.key === 'Control') {
64
+ this.drawer.isSkip = true
65
+ this.isNext = false
66
+ }
67
+ })
68
+ document.addEventListener('click', (e) => {
69
+ this.onNextHandler()
70
+ })
71
+
72
+ // シナリオを実行する
73
+ while (this.scenarioManager.hasNext()) {
74
+ await this.runScenario()
75
+ }
76
+ }
77
+
78
+ async loadScene(sceneFileName) {
79
+ outputLog('call', 'debug', sceneFileName)
80
+ // sceneファイルを読み込む
81
+ this.sceneFile = await import(/* webpackChunkName: "[request]" */ `/src/js/${sceneFileName}.js`)
82
+ this.scenarioManager.setScenario(this.sceneFile.scenario, sceneFileName)
83
+ this.sceneConfig = { ...this.sceneConfig, ...this.sceneFile.sceneConfig }
84
+ outputLog('sceneFile', 'debug', this.sceneFile)
85
+ }
86
+
87
+ async loadScreen(sceneConfig) {
88
+ outputLog('call', 'debug', sceneConfig)
89
+ // sceneConfig.templateを読み込んで、HTMLを表示する
90
+ const htmlString = await (await fetch(sceneConfig.template)).text()
91
+ // 読み込んだhtmlからIDにmainを持つdivタグとStyleタグ以下を取り出して、gameContainerに表示する
92
+ var parser = new DOMParser()
93
+ var doc = parser.parseFromString(htmlString, 'text/html')
94
+ this.gameContainer.innerHTML = doc.getElementById('main').innerHTML
95
+ // Styleタグを取り出して、headタグに追加する
96
+ const styleElement = doc.head.getElementsByTagName('style')[0]
97
+ document.head.appendChild(styleElement)
98
+ // ゲーム進行用に必要な情報をセットする
99
+ this.drawer.setScreen(this.gameContainer, engineConfig.resolution)
100
+ // シナリオの進行状況を保存
101
+ this.scenarioManager.progress.currentScene = sceneConfig.name
102
+ // 背景画像を表示する
103
+ const background = await new ImageObject().setImageAsync(sceneConfig.background)
104
+ this.displayedImages['background'] = {
105
+ image: background,
106
+ size: {
107
+ width: this.gameContainer.clientWidth,
108
+ height: this.gameContainer.clientHeight,
109
+ },
110
+ }
111
+ this.drawer.show(this.displayedImages)
112
+ this.scenarioManager.setBackground(background)
113
+ // BGMを再生する
114
+ const bgm = await new SoundObject().setAudioAsync(sceneConfig.bgm)
115
+ bgm.play(true)
116
+ }
117
+
118
+ async runScenario() {
119
+ outputLog('call index:', 'debug', this.scenarioManager.getIndex())
120
+ let scenarioObject = this.scenarioManager.next()
121
+ if (!scenarioObject) {
122
+ return
123
+ }
124
+ outputLog('scenarioObject', 'debug', scenarioObject)
125
+ // prettier-ignore
126
+ const boundFunction = this.commandList[scenarioObject.type || 'text'].bind(this)
127
+ // prettier-ignore
128
+ outputLog(`boundFunction:${boundFunction.name.split(' ')[1]}`,'debug',scenarioObject)
129
+ scenarioObject = await this.httpHandler(scenarioObject)
130
+ await boundFunction(scenarioObject)
131
+ }
132
+
133
+ async textHandler(scenarioObject) {
134
+ outputLog('textHandler:line', 'debug', scenarioObject)
135
+ // 文章だけの場合は、contentプロパティに配列として設定する
136
+ if (typeof scenarioObject === 'string') scenarioObject = { content: [scenarioObject] }
137
+ // httpレスポンスがある場合は、list.contentに追加して、表示対象に加える
138
+ if (scenarioObject.then || scenarioObject.error) {
139
+ scenarioObject.content = scenarioObject.content.concat(scenarioObject.then || scenarioObject.error)
140
+ }
141
+ outputLog('call', 'debug', scenarioObject)
142
+ // {{}}が含まれている場合は、変換処理を行う
143
+ scenarioObject.content = scenarioObject.content.map((text) =>
144
+ text.replace(/{{([^{}]+)}}/g, (match) => {
145
+ const expr = match.slice(2, -2)
146
+ const returnValue = this.executeCode(`return ${expr}`)
147
+ return typeof returnValue == 'object' ? JSON.stringify(returnValue) : returnValue
148
+ }),
149
+ )
150
+ // 名前が設定されている場合は、名前を表示する
151
+ if (scenarioObject.name) {
152
+ this.drawer.drawName(scenarioObject.name)
153
+ } else {
154
+ this.drawer.drawName('')
155
+ }
156
+
157
+ //prettier-ignore
158
+ this.onNextHandler = () => { this.drawer.isSkip = true }
159
+ // 表示する文章を1行ずつ表示する
160
+ for (const line of scenarioObject.content) {
161
+ await this.drawer.drawText(line, line.speed || 50)
162
+ //prettier-ignore
163
+ this.onNextHandler = () => { this.isNext = true }
164
+ if (typeof line.wait === 'number') {
165
+ if (line.wait > 0 || this.isAuto) {
166
+ const waitTime = line.wait || 1500
167
+ // 指定された時間だけ待機
168
+ await sleep(line.wait)
169
+ }
170
+ } else {
171
+ // 改行ごとに入力待ち
172
+ await this.clickWait()
173
+ }
174
+ }
175
+ this.drawer.isSkip = false
176
+ this.scenarioManager.setHistory(scenarioObject.content)
177
+ }
178
+
179
+ // クリック待ち処理
180
+ async clickWait() {
181
+ outputLog('call', 'debug')
182
+ this.drawer.setVisibility('#waitCircle', true)
183
+ return new Promise((resolve) => {
184
+ const intervalId = setInterval(() => {
185
+ if (this.isNext) {
186
+ this.drawer.setVisibility('#waitCircle', false)
187
+ clearInterval(intervalId)
188
+ this.isNext = false
189
+ resolve(null)
190
+ }
191
+ }, 500)
192
+ })
193
+ }
194
+
195
+ async sayHandler(line) {
196
+ outputLog('call', 'debug', line)
197
+ // say(name:string, pattern: string, voice: {playの引数}, ...text)
198
+ if (line.voice) await this.soundHandler({ path: line.voice, play: undefined })
199
+ await this.textHandler({ content: line.content, name: line.name })
200
+ this.scenarioManager.setHistory(line)
201
+ }
202
+
203
+ async choiceHandler(line) {
204
+ outputLog('call', 'debug', line)
205
+ if (line.prompt) this.textHandler(line.prompt)
206
+ const { selectId, onSelect: selectHandler } = await this.drawer.drawChoices(line)
207
+ if (selectHandler !== undefined) {
208
+ this.scenarioManager.addScenario(selectHandler)
209
+ }
210
+ this.scenarioManager.setHistory({ line, ...selectId })
211
+ }
212
+
213
+ jumpHandler(line) {
214
+ outputLog('call:', 'debug', line.index)
215
+ this.newpageHandler()
216
+ this.scenarioManager.setIndex(Number(line.index))
217
+ }
218
+
219
+ async showHandler(line) {
220
+ outputLog('line', 'debug', line)
221
+ // 表示する画像の情報を管理オブジェクトに追加
222
+ const key = line.name || line.src.split('/').pop()
223
+ const baseLine = engineConfig.resolution.height / 2
224
+ const centerPoint = {
225
+ left: { x: engineConfig.resolution.width * 0.25, y: baseLine },
226
+ center: { x: engineConfig.resolution.width * 0.5, y: baseLine },
227
+ right: { x: engineConfig.resolution.width * 0.75, y: baseLine },
228
+ }
229
+
230
+ const image = await this.getImageObject(line)
231
+ // 画像の表示位置を設定
232
+ const position = { x: line.x, y: line.y }
233
+ // prettier-ignore
234
+ const size = line.width && line.height ? { width: line.width, height: line.height } : { width: image.getSize().width, height: image.getSize().height }
235
+
236
+ if (line.pos) {
237
+ const pos = line.pos.split(':')
238
+ const baseLines = {
239
+ top: 0,
240
+ middle: engineConfig.resolution.height / 2,
241
+ bottom: engineConfig.resolution.height,
242
+ }
243
+ // エイリアスが設定されている場合、画像の中心点を求めて、画像の表示位置を設定する
244
+ position.x = centerPoint[pos[0]].x - size.width / 2
245
+ if (pos[1] === 'middle') {
246
+ position.y = baseLines[pos[1]] - size.width / 2
247
+ } else if (pos[1]) {
248
+ position.y = baseLines[pos[1]]
249
+ } else {
250
+ position.y = baseLine / 2
251
+ }
252
+ }
253
+ this.displayedImages[key] = {
254
+ image,
255
+ pos: position,
256
+ size: size,
257
+ look: line.look,
258
+ entry: line.entry,
259
+ }
260
+ outputLog('displayedImages', 'debug', this.displayedImages[key])
261
+ if (line.sepia) this.displayedImages[key].image.setSepia(line.sepia)
262
+ if (line.mono) this.displayedImages[key].image.setMonochrome(line.mono)
263
+ if (line.blur) this.displayedImages[key].image.setBlur(line.blur)
264
+ if (line.opacity) this.displayedImages[key].image.setOpacity(line.opacity)
265
+ this.drawer.show(this.displayedImages)
266
+ outputLog('this.displayedImages', 'debug', this.displayedImages)
267
+ }
268
+
269
+ hideHandler(line) {
270
+ outputLog('call', 'debug', line)
271
+ const key = line.name
272
+ delete this.displayedImages[key]
273
+ this.drawer.show(this.displayedImages)
274
+ }
275
+
276
+ async moveToHandler(line) {
277
+ outputLog('moveToHandler:line', 'debug', line)
278
+ const key = line.name
279
+ outputLog('moveToHandler:displayedImages', 'debug', this.displayedImages)
280
+ await this.drawer.moveTo(key, this.displayedImages, { x: line.x, y: line.y }, line.duration | 1)
281
+ }
282
+
283
+ async getImageObject(line) {
284
+ outputLog('call', 'debug', line)
285
+ let image
286
+ // 既にインスタンスがある場合は、それを使う
287
+ if (line.name) {
288
+ const targetImage = this.displayedImages[line.name]
289
+ const imageObject = targetImage ? targetImage.image : new ImageObject()
290
+ image = await imageObject.setImageAsync(line.src)
291
+ } else {
292
+ image = await new ImageObject().setImageAsync(line.src)
293
+ }
294
+ return image
295
+ }
296
+
297
+ async soundHandler(line) {
298
+ outputLog('call', 'debug', line)
299
+ // soundObjectを作成
300
+ const soundObject = await this.getSoundObject(line)
301
+ // playプロパティが存在する場合は、再生する
302
+ if ('play' in line) {
303
+ 'loop' in line ? soundObject.play(true) : soundObject.play()
304
+ } else if ('stop' in line) {
305
+ soundObject.stop()
306
+ } else if ('pause' in line) {
307
+ soundObject.pause()
308
+ }
309
+ // soundObjectを管理オブジェクトに追加
310
+ const key = line.name || line.src.split('/').pop()
311
+ this.usedSounds[key] = {
312
+ audio: soundObject,
313
+ }
314
+ }
315
+
316
+ async getSoundObject(line) {
317
+ outputLog('call', 'debug', line)
318
+ let resource
319
+ if (line.name) {
320
+ const targetResource = this.usedSounds[line.name]
321
+ const soundObject = targetResource ? targetResource.audio : new SoundObject()
322
+ resource = await soundObject.setAudioAsync(line.src)
323
+ } else {
324
+ resource = await new SoundObject().setAudioAsync(line.src)
325
+ }
326
+ return resource
327
+ }
328
+
329
+ newpageHandler() {
330
+ outputLog('call', 'debug')
331
+ this.displayedImages = {
332
+ background: {
333
+ image: this.scenarioManager.getBackground(),
334
+ size: {
335
+ width: this.gameContainer.clientWidth,
336
+ height: this.gameContainer.clientHeight,
337
+ },
338
+ },
339
+ }
340
+ this.drawer.clear()
341
+ this.drawer.show(this.displayedImages)
342
+ }
343
+
344
+ async ifHandler(line) {
345
+ outputLog('call', 'debug', line)
346
+ const isTrue = this.executeCode(`return ${line.condition}`)
347
+ outputLog(`${isTrue}`, 'debug')
348
+ if (isTrue) {
349
+ outputLog('', 'debug', line.content[0].content)
350
+ this.scenarioManager.addScenario(line.content[0].content)
351
+ } else {
352
+ outputLog('', 'debug', line.content[1].content)
353
+ this.scenarioManager.addScenario(line.content[1].content)
354
+ }
355
+ }
356
+
357
+ async routeHandler(line) {
358
+ outputLog('call', 'debug', line)
359
+ this.newpageHandler()
360
+ // sceneファイルを読み込む
361
+ await this.loadScene(line.to)
362
+ // 画面を表示する
363
+ await this.loadScreen(this.sceneConfig)
364
+ }
365
+
366
+ // Sceneファイルに、ビルド時に実行処理を追加して、そこに処理をお願いしたほうがいいかも?
367
+ callHandler(line) {
368
+ outputLog('call', 'debug', line)
369
+ this.executeCode(line.func)
370
+ }
371
+
372
+ async httpHandler(line) {
373
+ if (!(line.get || line.post || line.put || line.delete)) {
374
+ return line
375
+ }
376
+ outputLog('call', 'debug', line)
377
+ // progress属性を処理する
378
+ // prettier-ignore
379
+ const progressText = line.content.filter((content) => content.type === 'progress')[0]
380
+ if (progressText) {
381
+ await this.textHandler({ content: [progressText.content][0], wait: 0 })
382
+ }
383
+ // get,post,put,delete属性を処理する
384
+ const headers = line.content
385
+ .filter((content) => content.type === 'header')[0]
386
+ .content.reduce(
387
+ (acc, header) => ({
388
+ ...acc,
389
+ [header.type]: header.content,
390
+ }),
391
+ {},
392
+ )
393
+ const body = line.content
394
+ .filter((content) => content.type === 'data')[0]
395
+ .content.reduce(
396
+ (acc, header) => ({
397
+ ...acc,
398
+ [header.type]: header.content,
399
+ }),
400
+ {},
401
+ )
402
+ outputLog('headers', 'debug', headers)
403
+ outputLog('body', 'debug', body)
404
+ const response = await fetch(line.get || line.post || line.put || line.delete, {
405
+ method: line.get ? 'GET' : line.post ? 'POST' : line.put ? 'PUT' : 'DELETE',
406
+ headers: headers,
407
+ body: JSON.stringify(body),
408
+ })
409
+ if (response.ok) {
410
+ const json = await response.json()
411
+ this.sceneFile.res = json
412
+ outputLog('res', 'debug', json)
413
+ line.then = line.content.filter((content) => content.type === 'then')[0].content
414
+ } else {
415
+ this.sceneFile.res = json
416
+ line.error = line.content.filter((content) => content.type === 'error')[0].content
417
+ }
418
+ if (line.content) {
419
+ line.content = line.content.filter(
420
+ (content) =>
421
+ !(
422
+ content.type &&
423
+ (content.type === 'header' ||
424
+ content.type === 'data' ||
425
+ content.type === 'then' ||
426
+ content.type === 'error' ||
427
+ content.type === 'progress')
428
+ ),
429
+ )
430
+ }
431
+ return line
432
+ }
433
+
434
+ executeCode(code) {
435
+ try {
436
+ const context = { ...this.sceneFile }
437
+ const func = new Function(...Object.keys(context), code)
438
+ return func.apply(null, Object.values(context))
439
+ } catch (error) {
440
+ console.error('Error executing code:', error)
441
+ }
442
+ }
443
+ }