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
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { check } from '../parser/checker'
|
|
2
|
+
|
|
3
|
+
describe('checker', () => {
|
|
4
|
+
describe('valid scenarios', () => {
|
|
5
|
+
test('empty scenario passes without errors', () => {
|
|
6
|
+
expect(check([])).toEqual([])
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('top-level commands pass without errors', () => {
|
|
10
|
+
const scenario = [
|
|
11
|
+
{ type: 'text', content: ['Hello'] },
|
|
12
|
+
{ type: 'say', name: 'Narrator', content: ['World'] },
|
|
13
|
+
{ type: 'show', src: './bg.jpg', content: [] },
|
|
14
|
+
{ type: 'route', to: 'title', content: [] },
|
|
15
|
+
]
|
|
16
|
+
expect(check(scenario)).toEqual([])
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('item inside choice passes without errors', () => {
|
|
20
|
+
const scenario = [
|
|
21
|
+
{
|
|
22
|
+
type: 'choice',
|
|
23
|
+
prompt: 'Choose',
|
|
24
|
+
content: [
|
|
25
|
+
{ type: 'item', label: 'A', content: [] },
|
|
26
|
+
{ type: 'item', label: 'B', content: [] },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
expect(check(scenario)).toEqual([])
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('action inside actions inside dialog passes without errors', () => {
|
|
34
|
+
const scenario = [
|
|
35
|
+
{
|
|
36
|
+
type: 'dialog',
|
|
37
|
+
name: 'test',
|
|
38
|
+
content: [
|
|
39
|
+
{ type: 'prompt', content: ['Question?'] },
|
|
40
|
+
{
|
|
41
|
+
type: 'actions',
|
|
42
|
+
content: [
|
|
43
|
+
{ type: 'action', value: 'yes', label: 'Yes', content: [] },
|
|
44
|
+
{ type: 'action', value: 'no', label: 'No', content: [] },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
expect(check(scenario)).toEqual([])
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('then and else inside if passes without errors', () => {
|
|
54
|
+
const scenario = [
|
|
55
|
+
{
|
|
56
|
+
type: 'if',
|
|
57
|
+
condition: 'x === 1',
|
|
58
|
+
content: [
|
|
59
|
+
{ type: 'then', content: [{ type: 'text', content: ['yes'] }] },
|
|
60
|
+
{ type: 'else', content: [{ type: 'text', content: ['no'] }] },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
expect(check(scenario)).toEqual([])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('nested choice inside item passes without errors', () => {
|
|
68
|
+
const scenario = [
|
|
69
|
+
{
|
|
70
|
+
type: 'choice',
|
|
71
|
+
prompt: 'Outer',
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: 'item',
|
|
75
|
+
label: 'Pick',
|
|
76
|
+
content: [
|
|
77
|
+
{
|
|
78
|
+
type: 'choice',
|
|
79
|
+
prompt: 'Inner',
|
|
80
|
+
content: [{ type: 'item', label: 'Sub', content: [] }],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
expect(check(scenario)).toEqual([])
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test('inline text decoration tags inside text pass without errors', () => {
|
|
91
|
+
const scenario = [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
content: [
|
|
95
|
+
{ type: 'color', value: 'red', content: ['Red text'] },
|
|
96
|
+
{ type: 'ruby', text: 'ルビ', content: ['漢字'] },
|
|
97
|
+
{ type: 'b', content: ['Bold'] },
|
|
98
|
+
{ type: 'i', content: ['Italic'] },
|
|
99
|
+
{ type: 'br', content: [] },
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
]
|
|
103
|
+
expect(check(scenario)).toEqual([])
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('inline text decoration tags inside say pass without errors', () => {
|
|
107
|
+
const scenario = [
|
|
108
|
+
{
|
|
109
|
+
type: 'say',
|
|
110
|
+
name: 'Narrator',
|
|
111
|
+
content: [
|
|
112
|
+
{ type: 'color', value: 'blue', content: ['Blue'] },
|
|
113
|
+
{ type: 'b', content: ['Bold'] },
|
|
114
|
+
{ type: 'br', content: [] },
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
]
|
|
118
|
+
expect(check(scenario)).toEqual([])
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test('then inside text (HTTP response) passes without errors', () => {
|
|
122
|
+
const scenario = [
|
|
123
|
+
{
|
|
124
|
+
type: 'text',
|
|
125
|
+
get: 'https://api.example.com/data',
|
|
126
|
+
content: [
|
|
127
|
+
{ type: 'progress', content: ['Loading...'] },
|
|
128
|
+
{ type: 'header', content: [] },
|
|
129
|
+
{ type: 'data', content: [] },
|
|
130
|
+
{ type: 'then', content: ['Success'] },
|
|
131
|
+
{ type: 'error', content: ['Error'] },
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
]
|
|
135
|
+
expect(check(scenario)).toEqual([])
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
test('HTTP sub-tags inside call pass without errors', () => {
|
|
139
|
+
const scenario = [
|
|
140
|
+
{
|
|
141
|
+
type: 'call',
|
|
142
|
+
post: 'https://api.example.com/action',
|
|
143
|
+
content: [
|
|
144
|
+
{ type: 'header', content: [] },
|
|
145
|
+
{ type: 'data', content: [] },
|
|
146
|
+
{ type: 'then', content: ['Done'] },
|
|
147
|
+
{ type: 'error', content: ['Failed'] },
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
]
|
|
151
|
+
expect(check(scenario)).toEqual([])
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
test('all known show attributes pass without warnings', () => {
|
|
155
|
+
const scenario = [
|
|
156
|
+
{
|
|
157
|
+
type: 'show',
|
|
158
|
+
src: './chara.png',
|
|
159
|
+
name: 'hero',
|
|
160
|
+
mode: 'chara',
|
|
161
|
+
x: 100,
|
|
162
|
+
y: 200,
|
|
163
|
+
width: 300,
|
|
164
|
+
height: 400,
|
|
165
|
+
pos: 'center:middle',
|
|
166
|
+
look: false,
|
|
167
|
+
entry: { time: 1, wait: false },
|
|
168
|
+
sepia: 0.5,
|
|
169
|
+
mono: false,
|
|
170
|
+
blur: 0,
|
|
171
|
+
opacity: 1,
|
|
172
|
+
transition: 'fade',
|
|
173
|
+
duration: 1000,
|
|
174
|
+
content: [],
|
|
175
|
+
},
|
|
176
|
+
]
|
|
177
|
+
expect(check(scenario)).toEqual([])
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
test('all known sound attributes pass without warnings', () => {
|
|
181
|
+
const scenario = [
|
|
182
|
+
{
|
|
183
|
+
type: 'sound',
|
|
184
|
+
src: './bgm.mp3',
|
|
185
|
+
name: 'main',
|
|
186
|
+
mode: 'bgm',
|
|
187
|
+
play: true,
|
|
188
|
+
loop: true,
|
|
189
|
+
content: [],
|
|
190
|
+
},
|
|
191
|
+
]
|
|
192
|
+
expect(check(scenario)).toEqual([])
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
test('save and load with known attributes pass without warnings', () => {
|
|
196
|
+
const scenario = [
|
|
197
|
+
{ type: 'save', slot: '1', name: 'chapter1', message: true, content: [] },
|
|
198
|
+
{ type: 'load', slot: '1', message: false, content: [] },
|
|
199
|
+
]
|
|
200
|
+
expect(check(scenario)).toEqual([])
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
test('global attributes (if, get, post, put, delete) do not produce warnings', () => {
|
|
204
|
+
const scenario = [
|
|
205
|
+
{ type: 'text', if: 'flag', get: 'https://api.example.com', content: ['ok'] },
|
|
206
|
+
{ type: 'call', if: 'x > 0', method: 'doSomething()', content: [] },
|
|
207
|
+
]
|
|
208
|
+
expect(check(scenario)).toEqual([])
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
test('item with all known attributes passes without warnings', () => {
|
|
212
|
+
const scenario = [
|
|
213
|
+
{
|
|
214
|
+
type: 'choice',
|
|
215
|
+
content: [
|
|
216
|
+
{
|
|
217
|
+
type: 'item',
|
|
218
|
+
label: 'Option A',
|
|
219
|
+
id: 1,
|
|
220
|
+
default: './btn.png',
|
|
221
|
+
hover: './btn_hover.png',
|
|
222
|
+
select: './btn_select.png',
|
|
223
|
+
color: { default: 'black', hover: 'white', select: 'red' },
|
|
224
|
+
position: { x: 100, y: 200 },
|
|
225
|
+
content: [],
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
]
|
|
230
|
+
expect(check(scenario)).toEqual([])
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
describe('invalid parent-child relationships', () => {
|
|
235
|
+
test('item at scenario root produces an error', () => {
|
|
236
|
+
const scenario = [{ type: 'item', label: 'Option', content: [] }]
|
|
237
|
+
const errors = check(scenario)
|
|
238
|
+
expect(errors).toHaveLength(1)
|
|
239
|
+
expect(errors[0].type).toBe('invalid_parent')
|
|
240
|
+
expect(errors[0].node).toBe('item')
|
|
241
|
+
expect(errors[0].parent).toBeNull()
|
|
242
|
+
expect(errors[0].message).toContain('<item>')
|
|
243
|
+
expect(errors[0].message).toContain('<choice>')
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
test('item inside if (not choice) produces an error', () => {
|
|
247
|
+
const scenario = [
|
|
248
|
+
{
|
|
249
|
+
type: 'if',
|
|
250
|
+
condition: 'x',
|
|
251
|
+
content: [
|
|
252
|
+
{
|
|
253
|
+
type: 'then',
|
|
254
|
+
content: [{ type: 'item', label: 'Option', content: [] }],
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
]
|
|
259
|
+
const errors = check(scenario)
|
|
260
|
+
expect(errors.some((e) => e.node === 'item')).toBe(true)
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
test('action at scenario root produces an error', () => {
|
|
264
|
+
const scenario = [{ type: 'action', value: 'yes', label: 'Yes', content: [] }]
|
|
265
|
+
const errors = check(scenario)
|
|
266
|
+
expect(errors).toHaveLength(1)
|
|
267
|
+
expect(errors[0].type).toBe('invalid_parent')
|
|
268
|
+
expect(errors[0].node).toBe('action')
|
|
269
|
+
expect(errors[0].message).toContain('<actions>')
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
test('then at scenario root produces an error', () => {
|
|
273
|
+
const scenario = [{ type: 'then', content: [] }]
|
|
274
|
+
const errors = check(scenario)
|
|
275
|
+
expect(errors).toHaveLength(1)
|
|
276
|
+
expect(errors[0].node).toBe('then')
|
|
277
|
+
expect(errors[0].message).toContain('<if>')
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
test('else at scenario root produces an error', () => {
|
|
281
|
+
const scenario = [{ type: 'else', content: [] }]
|
|
282
|
+
const errors = check(scenario)
|
|
283
|
+
expect(errors).toHaveLength(1)
|
|
284
|
+
expect(errors[0].node).toBe('else')
|
|
285
|
+
expect(errors[0].message).toContain('<if>')
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
test('prompt at scenario root produces an error', () => {
|
|
289
|
+
const scenario = [{ type: 'prompt', content: ['Question?'] }]
|
|
290
|
+
const errors = check(scenario)
|
|
291
|
+
expect(errors).toHaveLength(1)
|
|
292
|
+
expect(errors[0].node).toBe('prompt')
|
|
293
|
+
expect(errors[0].message).toContain('<dialog>')
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
test('actions at scenario root produces an error', () => {
|
|
297
|
+
const scenario = [{ type: 'actions', content: [] }]
|
|
298
|
+
const errors = check(scenario)
|
|
299
|
+
expect(errors).toHaveLength(1)
|
|
300
|
+
expect(errors[0].node).toBe('actions')
|
|
301
|
+
expect(errors[0].message).toContain('<dialog>')
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
test('multiple errors are all reported', () => {
|
|
305
|
+
const scenario = [
|
|
306
|
+
{ type: 'item', label: 'A', content: [] },
|
|
307
|
+
{ type: 'item', label: 'B', content: [] },
|
|
308
|
+
{ type: 'action', value: 'x', label: 'X', content: [] },
|
|
309
|
+
]
|
|
310
|
+
const errors = check(scenario)
|
|
311
|
+
expect(errors).toHaveLength(3)
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
test('color at scenario root produces an error', () => {
|
|
315
|
+
const scenario = [{ type: 'color', value: 'red', content: ['Red'] }]
|
|
316
|
+
const errors = check(scenario)
|
|
317
|
+
expect(errors).toHaveLength(1)
|
|
318
|
+
expect(errors[0].node).toBe('color')
|
|
319
|
+
expect(errors[0].message).toContain('<text>')
|
|
320
|
+
expect(errors[0].message).toContain('<say>')
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
test('ruby at scenario root produces an error', () => {
|
|
324
|
+
const scenario = [{ type: 'ruby', text: 'ルビ', content: ['漢字'] }]
|
|
325
|
+
const errors = check(scenario)
|
|
326
|
+
expect(errors).toHaveLength(1)
|
|
327
|
+
expect(errors[0].node).toBe('ruby')
|
|
328
|
+
expect(errors[0].message).toContain('<text>')
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
test('b and i at scenario root produce errors', () => {
|
|
332
|
+
const scenario = [
|
|
333
|
+
{ type: 'b', content: ['Bold'] },
|
|
334
|
+
{ type: 'i', content: ['Italic'] },
|
|
335
|
+
]
|
|
336
|
+
const errors = check(scenario)
|
|
337
|
+
expect(errors).toHaveLength(2)
|
|
338
|
+
expect(errors[0].node).toBe('b')
|
|
339
|
+
expect(errors[1].node).toBe('i')
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
test('br at scenario root produces an error', () => {
|
|
343
|
+
const scenario = [{ type: 'br', content: [] }]
|
|
344
|
+
const errors = check(scenario)
|
|
345
|
+
expect(errors).toHaveLength(1)
|
|
346
|
+
expect(errors[0].node).toBe('br')
|
|
347
|
+
expect(errors[0].message).toContain('<text>')
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
test('color inside choice (not text/say) produces an error', () => {
|
|
351
|
+
const scenario = [
|
|
352
|
+
{
|
|
353
|
+
type: 'choice',
|
|
354
|
+
content: [{ type: 'color', value: 'red', content: ['Red'] }],
|
|
355
|
+
},
|
|
356
|
+
]
|
|
357
|
+
const errors = check(scenario)
|
|
358
|
+
expect(errors.some((e) => e.node === 'color')).toBe(true)
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
test('HTTP sub-tags at scenario root produce errors', () => {
|
|
362
|
+
const scenario = [
|
|
363
|
+
{ type: 'header', content: [] },
|
|
364
|
+
{ type: 'data', content: [] },
|
|
365
|
+
{ type: 'error', content: ['Error'] },
|
|
366
|
+
{ type: 'progress', content: ['Loading'] },
|
|
367
|
+
]
|
|
368
|
+
const errors = check(scenario)
|
|
369
|
+
expect(errors).toHaveLength(4)
|
|
370
|
+
expect(errors.map((e) => e.node)).toEqual(['header', 'data', 'error', 'progress'])
|
|
371
|
+
})
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
describe('unknown attribute warnings', () => {
|
|
375
|
+
test('unknown attribute on text produces a warning', () => {
|
|
376
|
+
const scenario = [{ type: 'text', content: ['Hello'], unknownAttr: 'value' }]
|
|
377
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
378
|
+
expect(warnings).toHaveLength(1)
|
|
379
|
+
expect(warnings[0].node).toBe('text')
|
|
380
|
+
expect(warnings[0].attribute).toBe('unknownAttr')
|
|
381
|
+
expect(warnings[0].message).toContain('"unknownAttr"')
|
|
382
|
+
expect(warnings[0].message).toContain('will be ignored')
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
test('unknown attribute on show produces a warning', () => {
|
|
386
|
+
const scenario = [{ type: 'show', src: './bg.jpg', content: [], typo: 'yes' }]
|
|
387
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
388
|
+
expect(warnings).toHaveLength(1)
|
|
389
|
+
expect(warnings[0].node).toBe('show')
|
|
390
|
+
expect(warnings[0].attribute).toBe('typo')
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
test('unknown attribute on jump produces a warning', () => {
|
|
394
|
+
const scenario = [{ type: 'jump', index: 5, content: [], badAttr: true }]
|
|
395
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
396
|
+
expect(warnings).toHaveLength(1)
|
|
397
|
+
expect(warnings[0].node).toBe('jump')
|
|
398
|
+
expect(warnings[0].attribute).toBe('badAttr')
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
test('any attribute on newpage produces a warning', () => {
|
|
402
|
+
const scenario = [{ type: 'newpage', content: [], extra: 'ignored' }]
|
|
403
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
404
|
+
expect(warnings).toHaveLength(1)
|
|
405
|
+
expect(warnings[0].node).toBe('newpage')
|
|
406
|
+
expect(warnings[0].attribute).toBe('extra')
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
test('unknown attribute on item produces a warning', () => {
|
|
410
|
+
const scenario = [
|
|
411
|
+
{
|
|
412
|
+
type: 'choice',
|
|
413
|
+
content: [{ type: 'item', label: 'A', content: [], ghost: true }],
|
|
414
|
+
},
|
|
415
|
+
]
|
|
416
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
417
|
+
expect(warnings).toHaveLength(1)
|
|
418
|
+
expect(warnings[0].node).toBe('item')
|
|
419
|
+
expect(warnings[0].attribute).toBe('ghost')
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
test('multiple unknown attributes on one node produce multiple warnings', () => {
|
|
423
|
+
const scenario = [{ type: 'route', to: 'next', content: [], foo: 1, bar: 2 }]
|
|
424
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
425
|
+
expect(warnings).toHaveLength(2)
|
|
426
|
+
expect(warnings.map((w) => w.attribute).sort()).toEqual(['bar', 'foo'])
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
test('unknown attribute on inline color tag produces a warning', () => {
|
|
430
|
+
const scenario = [
|
|
431
|
+
{
|
|
432
|
+
type: 'text',
|
|
433
|
+
content: [{ type: 'color', value: 'red', content: ['Red'], extra: true }],
|
|
434
|
+
},
|
|
435
|
+
]
|
|
436
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
437
|
+
expect(warnings).toHaveLength(1)
|
|
438
|
+
expect(warnings[0].node).toBe('color')
|
|
439
|
+
expect(warnings[0].attribute).toBe('extra')
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
test('unknown attribute on HTTP sub-tag produces a warning', () => {
|
|
443
|
+
const scenario = [
|
|
444
|
+
{
|
|
445
|
+
type: 'text',
|
|
446
|
+
get: 'https://api.example.com',
|
|
447
|
+
content: [{ type: 'error', content: ['Fail'], retries: 3 }],
|
|
448
|
+
},
|
|
449
|
+
]
|
|
450
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
451
|
+
expect(warnings).toHaveLength(1)
|
|
452
|
+
expect(warnings[0].node).toBe('error')
|
|
453
|
+
expect(warnings[0].attribute).toBe('retries')
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
test('global attributes never produce warnings', () => {
|
|
457
|
+
const scenario = [
|
|
458
|
+
{
|
|
459
|
+
type: 'say',
|
|
460
|
+
name: 'Alice',
|
|
461
|
+
if: 'flag',
|
|
462
|
+
get: 'https://api.example.com',
|
|
463
|
+
post: 'https://api.example.com',
|
|
464
|
+
put: 'https://api.example.com',
|
|
465
|
+
delete: 'https://api.example.com',
|
|
466
|
+
content: ['Hello'],
|
|
467
|
+
},
|
|
468
|
+
]
|
|
469
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
470
|
+
expect(warnings).toHaveLength(0)
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
test('unknown node types do not produce attribute warnings', () => {
|
|
474
|
+
// Custom/unknown tag types should not be flagged
|
|
475
|
+
const scenario = [{ type: 'custom-tag', anything: 'value', content: [] }]
|
|
476
|
+
const warnings = check(scenario).filter((r) => r.type === 'unknown_attribute')
|
|
477
|
+
expect(warnings).toHaveLength(0)
|
|
478
|
+
})
|
|
479
|
+
|
|
480
|
+
test('warnings and errors can occur together', () => {
|
|
481
|
+
// item at root (error) with an unknown attribute (warning)
|
|
482
|
+
const scenario = [{ type: 'item', label: 'A', content: [], badAttr: true }]
|
|
483
|
+
const results = check(scenario)
|
|
484
|
+
const errors = results.filter((r) => r.type === 'invalid_parent')
|
|
485
|
+
const warnings = results.filter((r) => r.type === 'unknown_attribute')
|
|
486
|
+
expect(errors).toHaveLength(1)
|
|
487
|
+
expect(warnings).toHaveLength(1)
|
|
488
|
+
expect(warnings[0].attribute).toBe('badAttr')
|
|
489
|
+
})
|
|
490
|
+
})
|
|
491
|
+
})
|
package/parser/cli.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
const { HTMLToJSON } = require('html-to-json-parser')
|
|
3
|
+
const { minify } = require('html-minifier')
|
|
2
4
|
const parse = require('./parser.js')
|
|
3
5
|
const fs = require('fs')
|
|
4
6
|
const path = require('path')
|
|
7
|
+
|
|
8
|
+
const minifyOptions = {
|
|
9
|
+
removeTagWhitespace: true,
|
|
10
|
+
collapseWhitespace: true,
|
|
11
|
+
removeComments: true,
|
|
12
|
+
minifyJS: true,
|
|
13
|
+
minifyCSS: true,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Node.js 向け HTMLParserAdapter(minify + HTMLToJSON)
|
|
18
|
+
* @param {string} data
|
|
19
|
+
* @returns {Promise<object>}
|
|
20
|
+
*/
|
|
21
|
+
const nodeHtmlParser = async (data) => {
|
|
22
|
+
const html = minify(data, minifyOptions)
|
|
23
|
+
return HTMLToJSON(html)
|
|
24
|
+
}
|
|
5
25
|
/**
|
|
6
|
-
* WebTaleScript
|
|
26
|
+
* WebTaleScript パーサー CLI
|
|
7
27
|
*/
|
|
8
28
|
|
|
9
29
|
const exec = (targetScript) => {
|
|
@@ -24,7 +44,19 @@ const exec = (targetScript) => {
|
|
|
24
44
|
return
|
|
25
45
|
}
|
|
26
46
|
// パーサーを呼び出す。
|
|
27
|
-
const { scenario, script, lang } = await parse(data)
|
|
47
|
+
const { scenario, script, lang, errors } = await parse(data, nodeHtmlParser)
|
|
48
|
+
// 構文エラーと属性警告を分ける
|
|
49
|
+
const syntaxErrors = errors ? errors.filter((e) => e.type !== 'unknown_attribute') : []
|
|
50
|
+
const attrWarnings = errors ? errors.filter((e) => e.type === 'unknown_attribute') : []
|
|
51
|
+
// 属性警告を標準エラー出力へ
|
|
52
|
+
if (attrWarnings.length > 0) {
|
|
53
|
+
attrWarnings.forEach((w) => console.warn(`Attribute Warning in ${targetScript}: ${w.message}`))
|
|
54
|
+
}
|
|
55
|
+
// 構文エラーがある場合、エラーを出力して終了する
|
|
56
|
+
if (syntaxErrors.length > 0) {
|
|
57
|
+
syntaxErrors.forEach((err) => console.error(`Syntax Error in ${targetScript}: ${err.message}`))
|
|
58
|
+
process.exit(1)
|
|
59
|
+
}
|
|
28
60
|
// jsディレクトリがない場合、作成する
|
|
29
61
|
if (!fs.existsSync(outputPath)) {
|
|
30
62
|
fs.mkdirSync(outputPath)
|
package/parser/parser.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const { minify } = require('html-minifier')
|
|
1
|
+
const { check } = require('./checker')
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* WebTaleScript パーサー(環境非依存)
|
|
5
|
+
* @param {string} data - WTSファイルの文字列
|
|
6
|
+
* @param {Function} htmlParser - HTMLをParsedNode形式に変換する関数
|
|
7
|
+
* @returns {Promise<{scenario: Array, script: Array, lang: string, errors: Array}>}
|
|
8
|
+
*/
|
|
9
|
+
module.exports = async (data, htmlParser) => {
|
|
5
10
|
let scenario = []
|
|
6
11
|
let script = []
|
|
7
12
|
let lang = 'js'
|
|
13
|
+
const errors = []
|
|
8
14
|
|
|
9
15
|
/**
|
|
10
16
|
* 渡されたオブジェクトを展開する
|
|
@@ -27,27 +33,28 @@ module.exports = async (data) => {
|
|
|
27
33
|
return rest
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
/** HTMLを読み込む */
|
|
35
|
-
const html = minify(data, {
|
|
36
|
-
removeTagWhitespace: true,
|
|
37
|
-
collapseWhitespace: true,
|
|
38
|
-
removeComments: true,
|
|
39
|
-
minifyJS: true,
|
|
40
|
-
minifyCSS: true,
|
|
41
|
-
})
|
|
42
|
-
// HTMLをJSONに変換
|
|
43
|
-
const parseJson = await HTMLToJSON(html)
|
|
36
|
+
// 外から注入されたパーサーを使用
|
|
37
|
+
const parseJson = await htmlParser(data)
|
|
38
|
+
let scenarioCount = 0
|
|
44
39
|
parseJson.content.forEach((element) => {
|
|
45
40
|
if (element.type === 'scenario') {
|
|
41
|
+
scenarioCount++
|
|
42
|
+
if (scenarioCount > 1) {
|
|
43
|
+
errors.push({
|
|
44
|
+
type: 'duplicate_scenario',
|
|
45
|
+
message: 'Multiple <scenario> sections found. Only one <scenario> is allowed per scene file.',
|
|
46
|
+
})
|
|
47
|
+
}
|
|
46
48
|
scenario = flattenAttributes(element.content)
|
|
47
49
|
} else {
|
|
48
50
|
script = element.content
|
|
49
51
|
lang = element.attributes?.type
|
|
50
52
|
}
|
|
51
53
|
})
|
|
52
|
-
|
|
54
|
+
|
|
55
|
+
// パース済みシナリオに対して構文チェッカーを実行する
|
|
56
|
+
const checkerErrors = check(scenario)
|
|
57
|
+
errors.push(...checkerErrors)
|
|
58
|
+
|
|
59
|
+
return { scenario, script, lang, errors }
|
|
53
60
|
}
|