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