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