@lf_maple/koishi-plugin-phi-plugin-full 0.1.80
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/LICENSE +22 -0
- package/core/.github/ISSUE_TEMPLATE/bug.yaml +133 -0
- package/core/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/core/.github/ISSUE_TEMPLATE/enhancement.yml +44 -0
- package/core/.vscode/c_cpp_properties.json +18 -0
- package/core/.vscode/launch.json +24 -0
- package/core/.vscode/settings.json +59 -0
- package/core/CHANGELOG.md +184 -0
- package/core/LICENSE +674 -0
- package/core/README.md +330 -0
- package/core/README_en.md +285 -0
- package/core/apps/Dan.js +129 -0
- package/core/apps/RankList.js +322 -0
- package/core/apps/aliasProposal.js +223 -0
- package/core/apps/apiSetting.js +592 -0
- package/core/apps/b19.js +1329 -0
- package/core/apps/botClient.js +64 -0
- package/core/apps/chart.js +692 -0
- package/core/apps/guessGame/guessIll.js +821 -0
- package/core/apps/guessGame/guessLetter.js +831 -0
- package/core/apps/guessGame/guessTips.js +254 -0
- package/core/apps/guessGame/letterGameUtils.js +74 -0
- package/core/apps/guessGame.js +214 -0
- package/core/apps/help.js +117 -0
- package/core/apps/manage.js +288 -0
- package/core/apps/market.js +243 -0
- package/core/apps/money.js +1064 -0
- package/core/apps/phisong.js +1418 -0
- package/core/apps/session.js +664 -0
- package/core/apps/setting.js +468 -0
- package/core/apps/update.js +541 -0
- package/core/apps/user.js +968 -0
- package/core/components/Config.js +249 -0
- package/core/components/Data.js +304 -0
- package/core/components/FileWatcherRegistry.js +102 -0
- package/core/components/Logger.js +11 -0
- package/core/components/ProcessCleanup.js +113 -0
- package/core/components/Version.js +56 -0
- package/core/components/YamlReader.js +157 -0
- package/core/components/baseClass.js +287 -0
- package/core/components/common.js +47 -0
- package/core/components/index.js +13 -0
- package/core/components/platform/index.js +79 -0
- package/core/components/platform/koishi.js +800 -0
- package/core/components/platform/koishiDatabaseRedis.js +391 -0
- package/core/components/platform/memoryRedis.js +209 -0
- package/core/components/platform/types.d.ts +272 -0
- package/core/components/platform/yunzai.js +604 -0
- package/core/components/segment.js +4 -0
- package/core/config/config//350/277/231/351/207/214/346/230/257/351/205/215/347/275/256/346/226/207/344/273/266/347/233/256/345/275/225.txt +0 -0
- package/core/config/default_config/banGroup.yaml +14 -0
- package/core/config/default_config/config.yaml +159 -0
- package/core/config/default_config/nickconfig.yaml +6 -0
- package/core/config/default_config/otherinfo.yaml +51 -0
- package/core/guoba.support.js +597 -0
- package/core/index.js +85 -0
- package/core/lib/AES.js +40 -0
- package/core/lib/Base64.js +22 -0
- package/core/lib/ByteReader.js +168 -0
- package/core/lib/GameProgress.js +37 -0
- package/core/lib/GameRecord.js +47 -0
- package/core/lib/GameSettings.js +24 -0
- package/core/lib/GameUser.js +19 -0
- package/core/lib/Level.js +6 -0
- package/core/lib/LevelRecord.js +9 -0
- package/core/lib/PhigrosUser.js +135 -0
- package/core/lib/SaveManager.js +117 -0
- package/core/lib/Summary.js +47 -0
- package/core/lib/TapTap/CompleteQRCodeData.js +27 -0
- package/core/lib/TapTap/LCHelper.js +81 -0
- package/core/lib/TapTap/TapTapHelper.js +170 -0
- package/core/lib/TapTap/getQRcode.js +61 -0
- package/core/lib/Util.js +30 -0
- package/core/lib/getQRcode.js +73 -0
- package/core/lib/http.js +105 -0
- package/core/model/README.md +3 -0
- package/core/model/api/aliasProposalService.js +151 -0
- package/core/model/api/apiVersion.js +67 -0
- package/core/model/api/autoSeekApi.js +165 -0
- package/core/model/api/botApiAuth.js +208 -0
- package/core/model/api/botSyncService.js +78 -0
- package/core/model/api/gameRecordPayload.js +24 -0
- package/core/model/api/makeRequest.js +1004 -0
- package/core/model/api/makeRequestFnc.js +17 -0
- package/core/model/api/phiApiClient.js +53 -0
- package/core/model/api/phiApiErrors.js +121 -0
- package/core/model/filesystem/getFile.js +256 -0
- package/core/model/filesystem/path.js +84 -0
- package/core/model/game/Chart.js +57 -0
- package/core/model/game/LevelRecordInfo.js +109 -0
- package/core/model/game/SongsInfo.js +46 -0
- package/core/model/game/b30Analysis.js +93 -0
- package/core/model/game/chartParser/Chart.js +23 -0
- package/core/model/game/chartParser/JudgeLine.js +38 -0
- package/core/model/game/chartParser/base/JudgeLineEvent.js +99 -0
- package/core/model/game/chartParser/base/Note.js +44 -0
- package/core/model/game/chartParser/base/SpeedEvent.js +25 -0
- package/core/model/game/chartParser/base/baseType.js +2 -0
- package/core/model/game/constNum.js +215 -0
- package/core/model/game/fCompute.js +711 -0
- package/core/model/game/getChartTag.js +140 -0
- package/core/model/game/getComment.js +132 -0
- package/core/model/game/getInfo.js +1069 -0
- package/core/model/game/getRksRank.js +77 -0
- package/core/model/game/markdown.js +77 -0
- package/core/model/integrations/Vika.js +103 -0
- package/core/model/integrations/getInfoFromTap.js +80 -0
- package/core/model/render/getPic.js +79 -0
- package/core/model/render/picmodle.js +496 -0
- package/core/model/render/progress-bar.js +44 -0
- package/core/model/render/puppeteer.js +431 -0
- package/core/model/render/renderPressureHistory.js +71 -0
- package/core/model/render/send.js +94 -0
- package/core/model/save/Save.js +953 -0
- package/core/model/save/analyzeSaveHistory.js +413 -0
- package/core/model/save/getBackup.js +328 -0
- package/core/model/save/getSave.js +90 -0
- package/core/model/save/getSaveFromApi.js +46 -0
- package/core/model/save/saveHistory.js +586 -0
- package/core/model/save/scoreHistory.js +101 -0
- package/core/model/theme/catalog.js +192 -0
- package/core/model/theme/installGuard.js +275 -0
- package/core/model/theme/installLock.js +174 -0
- package/core/model/theme/installer.js +398 -0
- package/core/model/theme/manager.js +408 -0
- package/core/model/theme/marketClient.js +294 -0
- package/core/model/theme/paths.js +42 -0
- package/core/model/theme/policy.js +54 -0
- package/core/model/theme/recovery.js +167 -0
- package/core/model/theme/useService.js +187 -0
- package/core/model/type/aliasProposal.d.ts +45 -0
- package/core/model/type/type.js +420 -0
- package/core/model/user/apiPermission.js +62 -0
- package/core/model/user/getBanGroup.js +120 -0
- package/core/model/user/getNotes.js +48 -0
- package/core/model/user/pluginData.js +101 -0
- package/core/model/user/userCredentialStore.js +154 -0
- package/core/model/user/userCredentials.js +860 -0
- package/core/package.json +60 -0
- package/core/resources/0608badSave/save.json +1 -0
- package/core/resources/LICENSE +201 -0
- package/core/resources/html/analyzeSaveHistory/analyzeSaveHistory.art +220 -0
- package/core/resources/html/analyzeSaveHistory/analyzeSaveHistory.css +345 -0
- package/core/resources/html/analyzeSaveHistory/analyzeSaveHistory.html +434 -0
- package/core/resources/html/arcgrosB19/arcgros.png +0 -0
- package/core/resources/html/arcgrosB19/arcgrosB19-orz.html +276 -0
- package/core/resources/html/arcgrosB19/arcgrosB19.art +168 -0
- package/core/resources/html/arcgrosB19/arcgrosB19.css +637 -0
- package/core/resources/html/atlas/atlas-orz.html +313 -0
- package/core/resources/html/atlas/atlas.art +194 -0
- package/core/resources/html/atlas/atlas.css +695 -0
- package/core/resources/html/avatar/-SURREALISM-.png +0 -0
- package/core/resources/html/avatar/Alkaid.png +0 -0
- package/core/resources/html/avatar/Aphasia.png +0 -0
- package/core/resources/html/avatar/Artificial Existence.png +0 -0
- package/core/resources/html/avatar/Bonus Time.png +0 -0
- package/core/resources/html/avatar/Burn.png +0 -0
- package/core/resources/html/avatar/Cereris1.png +0 -0
- package/core/resources/html/avatar/Cereris2.png +0 -0
- package/core/resources/html/avatar/Cereris3.png +0 -0
- package/core/resources/html/avatar/Christmas -2019.png +0 -0
- package/core/resources/html/avatar/Cipher1.png +0 -0
- package/core/resources/html/avatar/Class Memories.png +0 -0
- package/core/resources/html/avatar/Credits.png +0 -0
- package/core/resources/html/avatar/Dash.png +0 -0
- package/core/resources/html/avatar/Dlyrotz.png +0 -0
- package/core/resources/html/avatar/Doppelganger1.png +0 -0
- package/core/resources/html/avatar/Doppelganger2.png +0 -0
- package/core/resources/html/avatar/Drop it.png +0 -0
- package/core/resources/html/avatar/Energy Synergy Matrix1.png +0 -0
- package/core/resources/html/avatar/Energy Synergy Matrix2.png +0 -0
- package/core/resources/html/avatar/Energy Synergy Matrix3.png +0 -0
- package/core/resources/html/avatar/Engine x Start!! (melody mix).png +0 -0
- package/core/resources/html/avatar/Engine x Start!! extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/Eradication Catastrophe.png +0 -0
- package/core/resources/html/avatar/FULi AUTO SHOOTER extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/FULi AUTO SHOOTER.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/264-Special1.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/264-Special2.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2641.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2642.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2643.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2644.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2645.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2646.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2647.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2648.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2649.png +0 -0
- package/core/resources/html/avatar/Find_Me.png +0 -0
- package/core/resources/html/avatar/Geopelia 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/Geopelia 2 -by cycats.png +0 -0
- package/core/resources/html/avatar/Geopelia 3 -by /344/275/225/345/221/265.png +0 -0
- package/core/resources/html/avatar/Geopelia in WEPLAY -by /346/265/267/344/272/247.png +0 -0
- package/core/resources/html/avatar/Gino-AprilFool.png +0 -0
- package/core/resources/html/avatar/Glaciaxion.png +0 -0
- package/core/resources/html/avatar/HumaN.png +0 -0
- package/core/resources/html/avatar/Indelible Scar.png +0 -0
- package/core/resources/html/avatar/Introduction.png +0 -0
- package/core/resources/html/avatar/Khronostasis Katharsis.png +0 -0
- package/core/resources/html/avatar/MARENOL.png +0 -0
- package/core/resources/html/avatar/Marenol extra 1 -by /345/226/265n/350/221/265.png +0 -0
- package/core/resources/html/avatar/Non-Melodic Ragez (MUG Edit).png +0 -0
- package/core/resources/html/avatar/Non-Melodic Ragez extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/Oblivion +0 -0
- package/core/resources/html/avatar/OblivionPHIN.png +0 -0
- package/core/resources/html/avatar/Para.png +0 -0
- package/core/resources/html/avatar/Pixel Rebelz1.png +0 -0
- package/core/resources/html/avatar/Pixel Rebelz2.png +0 -0
- package/core/resources/html/avatar/Pixel Rebelz3.png +0 -0
- package/core/resources/html/avatar/RIPPER extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/RIPPER extra 2 -by /344/275/225/345/221/265.png +0 -0
- package/core/resources/html/avatar/Sein.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-Special.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-Special2.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-/346/231/256/351/200/232.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-/346/233/262/347/273/230Ver.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240-Special.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240-/346/231/256/351/200/232.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240-/346/233/262/347/273/230Ver.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240/345/222/214/346/260/264/351/235/222-Special.png +0 -0
- package/core/resources/html/avatar/Snow Desert.png +0 -0
- package/core/resources/html/avatar/Sparkle New Life.png +0 -0
- package/core/resources/html/avatar/Sultan Rage.png +0 -0
- package/core/resources/html/avatar/Winter /342/206/221cube/342/206/223.png +0 -0
- package/core/resources/html/avatar/Xenolith.png +0 -0
- package/core/resources/html/avatar/[PRAW].png +0 -0
- package/core/resources/html/avatar/dB doll.png +0 -0
- package/core/resources/html/avatar/ripper.png +0 -0
- package/core/resources/html/avatar//343/202/202/343/201/272/343/202/202/343/201/2721.png +0 -0
- package/core/resources/html/avatar//343/202/202/343/201/272/343/202/202/343/201/2722.png +0 -0
- package/core/resources/html/avatar//344/270/207/345/220/250/345/214/277/345/220/215/344/277/241.png +0 -0
- package/core/resources/html/avatar//344/272/221/345/245/263/345/255/251 extra 1 -by /345/276/241/345/235/202/346/236/234/345/255/220.png +0 -0
- package/core/resources/html/avatar//344/272/221/345/245/263/345/255/251.png +0 -0
- package/core/resources/html/avatar//345/205/211.png +0 -0
- package/core/resources/html/avatar//345/274/200/345/277/203/347/227/2051.png +0 -0
- package/core/resources/html/avatar//345/274/200/345/277/203/347/227/2052.png +0 -0
- package/core/resources/html/avatar//346/260/264/351/235/222-/344/270/200/345/221/250/345/271/264/347/233/270/350/201/232.png +0 -0
- package/core/resources/html/avatar//346/267/267/344/271/261-Confusion.png +0 -0
- package/core/resources/html/avatar//347/213/202/345/226/234/350/230/255/350/210/2361.png +0 -0
- package/core/resources/html/avatar//347/213/202/345/226/234/350/230/255/350/210/2362.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/201-Special.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2011.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2012.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2013.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2014.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2015.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2016.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2017.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/227-Special.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/2271.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/2272.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/2273.png +0 -0
- package/core/resources/html/avatar//350/217/257/347/201/257/347/210/2611.png +0 -0
- package/core/resources/html/avatar//350/217/257/347/201/257/347/210/2612.png +0 -0
- package/core/resources/html/avatar//350/220/244/347/201/253/350/231/253/343/201/256/346/200/2501.png +0 -0
- package/core/resources/html/avatar//350/220/244/347/201/253/350/231/253/343/201/256/346/200/2502.png +0 -0
- package/core/resources/html/avatar//351/235/222/350/212/275-Special.png +0 -0
- package/core/resources/html/avatar//351/235/222/350/212/275.png +0 -0
- package/core/resources/html/avatar//351/243/216/345/261/277.png +0 -0
- package/core/resources/html/avatar//351/270/240-AprilFool.png +0 -0
- package/core/resources/html/avatar//351/270/240-/344/270/200/345/221/250/345/271/264/347/233/270/350/201/232.png +0 -0
- package/core/resources/html/b19/b19.art +490 -0
- package/core/resources/html/b19/b19.css +1261 -0
- package/core/resources/html/b19/b19666.art +350 -0
- package/core/resources/html/b19/b19666.css +1409 -0
- package/core/resources/html/b19/b19666.html +481 -0
- package/core/resources/html/b19/b19title.css +120 -0
- package/core/resources/html/b19/best19.html +853 -0
- package/core/resources/html/b19/dss2-orz.html +428 -0
- package/core/resources/html/b19/dss2.art +298 -0
- package/core/resources/html/b19/dss2.css +776 -0
- package/core/resources/html/b19/res/666.jpeg +0 -0
- package/core/resources/html/chap/chap-orz.html +93 -0
- package/core/resources/html/chap/chap.art +87 -0
- package/core/resources/html/chap/chap.css +365 -0
- package/core/resources/html/chartImg/chartImg.art +169 -0
- package/core/resources/html/chartImg/chartImg.css +439 -0
- package/core/resources/html/chartImg/echarts-wordcloud.min.js +3 -0
- package/core/resources/html/chartImg/echarts.js +85796 -0
- package/core/resources/html/chartImg/img/Drag.png +0 -0
- package/core/resources/html/chartImg/img/DragHL.png +0 -0
- package/core/resources/html/chartImg/img/Flick.png +0 -0
- package/core/resources/html/chartImg/img/FlickHL.png +0 -0
- package/core/resources/html/chartImg/img/Hold.png +0 -0
- package/core/resources/html/chartImg/img/HoldHL.png +0 -0
- package/core/resources/html/chartImg/img/Hold_End.png +0 -0
- package/core/resources/html/chartImg/img/Hold_Head.png +0 -0
- package/core/resources/html/chartImg/img/Hold_HeadHL.png +0 -0
- package/core/resources/html/chartImg/img/Tap.png +0 -0
- package/core/resources/html/chartImg/img/TapHL.png +0 -0
- package/core/resources/html/chartInfo/chartInfo-orz.html +250 -0
- package/core/resources/html/chartInfo/chartInfo.art +222 -0
- package/core/resources/html/chartInfo/chartInfo.css +265 -0
- package/core/resources/html/chartInfo/echarts-wordcloud.min.js +3 -0
- package/core/resources/html/chartInfo/echarts.js +85796 -0
- package/core/resources/html/clg/clg-orz.html +218 -0
- package/core/resources/html/clg/clg.art +88 -0
- package/core/resources/html/clg/clg.css +230 -0
- package/core/resources/html/clg/demo.jpg +0 -0
- package/core/resources/html/common/common.css +319 -0
- package/core/resources/html/common/css/playerInfo.css +136 -0
- package/core/resources/html/common/font/Aldrich-Regular.ttf +0 -0
- package/core/resources/html/common/font/HIMALAYA.TTF +0 -0
- package/core/resources/html/common/font/NotoColorEmoji-Regular.ttf +0 -0
- package/core/resources/html/common/font/NotoSans-Regular.ttf +0 -0
- package/core/resources/html/common/font/NotoSansArabic.ttf +0 -0
- package/core/resources/html/common/font/NotoSansCanadianAboriginal.ttf +0 -0
- package/core/resources/html/common/font/NotoSansJP.ttf +0 -0
- package/core/resources/html/common/font/NotoSansKannada.ttf +0 -0
- package/core/resources/html/common/font/NotoSansMath-Regular.ttf +0 -0
- package/core/resources/html/common/font/NotoSansSymbols2.ttf +0 -0
- package/core/resources/html/common/font/phi.ttf +0 -0
- package/core/resources/html/common/font//345/220/236/345/274/245/346/201/260/344/277/212.ttf +0 -0
- package/core/resources/html/common/layout/default.art +324 -0
- package/core/resources/html/common/layout/elem.art +21 -0
- package/core/resources/html/common/theme/snow/snow.css +17 -0
- package/core/resources/html/common/theme/snow/snow.js +19 -0
- package/core/resources/html/common/theme/star/star.js +201 -0
- package/core/resources/html/common/theme/topText/topText.css +15 -0
- package/core/resources/html/common/theme/topText/topText.js +30 -0
- package/core/resources/html/difficultyHistory/difficultyHistory-orz.html +361 -0
- package/core/resources/html/difficultyHistory/difficultyHistory.art +102 -0
- package/core/resources/html/difficultyHistory/difficultyHistory.css +205 -0
- package/core/resources/html/guess/guess-orz.html +50 -0
- package/core/resources/html/guess/guess.art +51 -0
- package/core/resources/html/guess/guess.css +33 -0
- package/core/resources/html/help/help-orz.html +73 -0
- package/core/resources/html/help/help.art +84 -0
- package/core/resources/html/help/help.css +266 -0
- package/core/resources/html/historyB30/historyB30-orz.html +168 -0
- package/core/resources/html/historyB30/historyB30.art +143 -0
- package/core/resources/html/historyB30/historyB30.css +270 -0
- package/core/resources/html/ill/ill-orz.html +21 -0
- package/core/resources/html/ill/ill.art +23 -0
- package/core/resources/html/ill/ill.css +79 -0
- package/core/resources/html/jrrp/ShineAfter.removebg.png +0 -0
- package/core/resources/html/jrrp/jrrp-orz.html +68 -0
- package/core/resources/html/jrrp/jrrp.art +58 -0
- package/core/resources/html/jrrp/jrrp.css +251 -0
- package/core/resources/html/list/list-orz.html +35 -0
- package/core/resources/html/list/list.art +67 -0
- package/core/resources/html/list/list.css +259 -0
- package/core/resources/html/lvsco/demo.jpg +0 -0
- package/core/resources/html/lvsco/lvsco-orz.html +334 -0
- package/core/resources/html/lvsco/lvsco.art +314 -0
- package/core/resources/html/lvsco/lvsco.css +706 -0
- package/core/resources/html/market/detail.art +44 -0
- package/core/resources/html/market/market.art +86 -0
- package/core/resources/html/market/market.css +64 -0
- package/core/resources/html/newSong/newSong.art +34 -0
- package/core/resources/html/newSong/newSong.css +48 -0
- package/core/resources/html/newSong/newSong.html +23 -0
- package/core/resources/html/newnotice/newnotice.art +47 -0
- package/core/resources/html/newnotice/newnotice.css +83 -0
- package/core/resources/html/otherimg/0.png +0 -0
- package/core/resources/html/otherimg/1.png +0 -0
- package/core/resources/html/otherimg/2.png +0 -0
- package/core/resources/html/otherimg/3.png +0 -0
- package/core/resources/html/otherimg/4.png +0 -0
- package/core/resources/html/otherimg/5.png +0 -0
- package/core/resources/html/otherimg/A.png +0 -0
- package/core/resources/html/otherimg/B.png +0 -0
- package/core/resources/html/otherimg/C.png +0 -0
- package/core/resources/html/otherimg/F.png +0 -0
- package/core/resources/html/otherimg/FC.png +0 -0
- package/core/resources/html/otherimg/NEW.png +0 -0
- package/core/resources/html/otherimg/Phigros_Icon_3.0.0.png +0 -0
- package/core/resources/html/otherimg/S.png +0 -0
- package/core/resources/html/otherimg/Star1.png +0 -0
- package/core/resources/html/otherimg/Star2.png +0 -0
- package/core/resources/html/otherimg/V.png +0 -0
- package/core/resources/html/otherimg/callback.png +0 -0
- package/core/resources/html/otherimg/chapHelp.png +0 -0
- package/core/resources/html/otherimg/dan_code.png +0 -0
- package/core/resources/html/otherimg/data.png +0 -0
- package/core/resources/html/otherimg/helpDoc.png +0 -0
- package/core/resources/html/otherimg/nickSuggest.png +0 -0
- package/core/resources/html/otherimg/phi.png +0 -0
- package/core/resources/html/otherimg/phigros.png +0 -0
- package/core/resources/html/otherimg/snow1.png +0 -0
- package/core/resources/html/otherimg/snow2.png +0 -0
- package/core/resources/html/otherimg/snow3.png +0 -0
- package/core/resources/html/otherimg/snow4.png +0 -0
- package/core/resources/html/otherimg/title.png +0 -0
- package/core/resources/html/rand/rand-orz.html +62 -0
- package/core/resources/html/rand/rand.art +59 -0
- package/core/resources/html/rand/rand.css +257 -0
- package/core/resources/html/rankingList/rankingList-orz.html +456 -0
- package/core/resources/html/rankingList/rankingList.art +171 -0
- package/core/resources/html/rankingList/rankingList.css +570 -0
- package/core/resources/html/rankingList-old/rankingList-orz.html +300 -0
- package/core/resources/html/rankingList-old/rankingList.art +89 -0
- package/core/resources/html/rankingList-old/rankingList.css +265 -0
- package/core/resources/html/score/score-orz.html +625 -0
- package/core/resources/html/score/score.art +249 -0
- package/core/resources/html/score/score.css +435 -0
- package/core/resources/html/score/scoreOld-orz.html +128 -0
- package/core/resources/html/score/scoreOld.art +230 -0
- package/core/resources/html/score/scoreOld.css +475 -0
- package/core/resources/html/score/scoreRankList-orz.html +613 -0
- package/core/resources/html/score/scoreRankList.art +231 -0
- package/core/resources/html/score/scoreRankList.css +197 -0
- package/core/resources/html/setting/setting-orz.html +123 -0
- package/core/resources/html/setting/setting.art +72 -0
- package/core/resources/html/setting/setting.css +170 -0
- package/core/resources/html/setting/userSetting-orz.html +132 -0
- package/core/resources/html/setting/userSetting.art +48 -0
- package/core/resources/html/setting/userSetting.css +160 -0
- package/core/resources/html/sign/sign-orz.html +262 -0
- package/core/resources/html/sign/sign.art +163 -0
- package/core/resources/html/sign/sign.css +706 -0
- package/core/resources/html/suggest/suggest.art +271 -0
- package/core/resources/html/suggest/suggest.css +300 -0
- package/core/resources/html/table/table-orz.html +228 -0
- package/core/resources/html/table/table.art +163 -0
- package/core/resources/html/table/table.css +401 -0
- package/core/resources/html/tasks/tasks-orz.html +83 -0
- package/core/resources/html/tasks/tasks.art +118 -0
- package/core/resources/html/tasks/tasks.css +334 -0
- package/core/resources/html/update/update-orz.html +735 -0
- package/core/resources/html/update/update.art +259 -0
- package/core/resources/html/update/update.css +676 -0
- package/core/resources/html/userinfo/userinfo-old-orz.html +408 -0
- package/core/resources/html/userinfo/userinfo-old.art +233 -0
- package/core/resources/html/userinfo/userinfo-old.css +466 -0
- package/core/resources/html/userinfo/userinfo-orz.html +543 -0
- package/core/resources/html/userinfo/userinfo.art +288 -0
- package/core/resources/html/userinfo/userinfo.css +757 -0
- package/core/resources/info/DLC/arc.json +412 -0
- package/core/resources/info/DLC/chunithm.json +1172 -0
- package/core/resources/info/DLC/dynamix.json +455 -0
- package/core/resources/info/DLC/fanshi.json +132 -0
- package/core/resources/info/DLC/lanota.json +412 -0
- package/core/resources/info/DLC/maimai.json +1110 -0
- package/core/resources/info/DLC/orz.json +158 -0
- package/core/resources/info/DLC/rizline.json +40 -0
- package/core/resources/info/DLC/rotaeno.json +159 -0
- package/core/resources/info/DLC/ryceam.json +53 -0
- package/core/resources/info/avatar.txt +109 -0
- package/core/resources/info/chaplist.yaml +102 -0
- package/core/resources/info/help/api.json +83 -0
- package/core/resources/info/help.json +436 -0
- package/core/resources/info/info.csv +315 -0
- package/core/resources/info/infolist.json +1758 -0
- package/core/resources/info/jrrp.json +92 -0
- package/core/resources/info/nicklist.yaml +2373 -0
- package/core/resources/info/notesInfo.json +1 -0
- package/core/resources/info/notice.json +11 -0
- package/core/resources/info/oldInfo/100/change.csv +218 -0
- package/core/resources/info/oldInfo/100/info.json +7 -0
- package/core/resources/info/oldInfo/101/change.csv +218 -0
- package/core/resources/info/oldInfo/101/info.json +7 -0
- package/core/resources/info/oldInfo/102/change.csv +223 -0
- package/core/resources/info/oldInfo/102/info.json +7 -0
- package/core/resources/info/oldInfo/103/change.csv +224 -0
- package/core/resources/info/oldInfo/103/info.json +7 -0
- package/core/resources/info/oldInfo/104/change.csv +225 -0
- package/core/resources/info/oldInfo/104/info.json +7 -0
- package/core/resources/info/oldInfo/105/change.csv +228 -0
- package/core/resources/info/oldInfo/105/info.json +7 -0
- package/core/resources/info/oldInfo/106/change.csv +229 -0
- package/core/resources/info/oldInfo/106/info.json +7 -0
- package/core/resources/info/oldInfo/108/change.csv +233 -0
- package/core/resources/info/oldInfo/108/info.json +7 -0
- package/core/resources/info/oldInfo/109/change.csv +235 -0
- package/core/resources/info/oldInfo/109/info.json +7 -0
- package/core/resources/info/oldInfo/110/change.csv +235 -0
- package/core/resources/info/oldInfo/110/info.json +7 -0
- package/core/resources/info/oldInfo/111/change.csv +242 -0
- package/core/resources/info/oldInfo/111/info.json +7 -0
- package/core/resources/info/oldInfo/112/change.csv +242 -0
- package/core/resources/info/oldInfo/112/info.json +7 -0
- package/core/resources/info/oldInfo/113/change.csv +244 -0
- package/core/resources/info/oldInfo/113/info.json +7 -0
- package/core/resources/info/oldInfo/115/change.csv +247 -0
- package/core/resources/info/oldInfo/115/info.json +7 -0
- package/core/resources/info/oldInfo/116/change.csv +249 -0
- package/core/resources/info/oldInfo/116/info.json +7 -0
- package/core/resources/info/oldInfo/118/change.csv +252 -0
- package/core/resources/info/oldInfo/118/info.json +7 -0
- package/core/resources/info/oldInfo/119/change.csv +255 -0
- package/core/resources/info/oldInfo/119/info.json +7 -0
- package/core/resources/info/oldInfo/120/change.csv +255 -0
- package/core/resources/info/oldInfo/120/info.json +7 -0
- package/core/resources/info/oldInfo/121/change.csv +257 -0
- package/core/resources/info/oldInfo/121/info.json +7 -0
- package/core/resources/info/oldInfo/122/change.csv +260 -0
- package/core/resources/info/oldInfo/122/info.json +7 -0
- package/core/resources/info/oldInfo/123/change.csv +260 -0
- package/core/resources/info/oldInfo/123/info.json +7 -0
- package/core/resources/info/oldInfo/124/change.csv +262 -0
- package/core/resources/info/oldInfo/124/info.json +7 -0
- package/core/resources/info/oldInfo/125/change.csv +266 -0
- package/core/resources/info/oldInfo/125/info.json +7 -0
- package/core/resources/info/oldInfo/126/change.csv +269 -0
- package/core/resources/info/oldInfo/126/info.json +7 -0
- package/core/resources/info/oldInfo/127/change.csv +270 -0
- package/core/resources/info/oldInfo/127/info.json +7 -0
- package/core/resources/info/oldInfo/128/change.csv +273 -0
- package/core/resources/info/oldInfo/128/info.json +7 -0
- package/core/resources/info/oldInfo/129/change.csv +274 -0
- package/core/resources/info/oldInfo/129/info.json +7 -0
- package/core/resources/info/oldInfo/130/change.csv +275 -0
- package/core/resources/info/oldInfo/130/info.json +7 -0
- package/core/resources/info/oldInfo/131/change.csv +278 -0
- package/core/resources/info/oldInfo/131/info.json +7 -0
- package/core/resources/info/oldInfo/132/change.csv +280 -0
- package/core/resources/info/oldInfo/132/info.json +7 -0
- package/core/resources/info/oldInfo/133/change.csv +284 -0
- package/core/resources/info/oldInfo/133/info.json +7 -0
- package/core/resources/info/oldInfo/134/change.csv +286 -0
- package/core/resources/info/oldInfo/134/info.json +7 -0
- package/core/resources/info/oldInfo/135/change.csv +290 -0
- package/core/resources/info/oldInfo/135/info.json +7 -0
- package/core/resources/info/oldInfo/136/change.csv +290 -0
- package/core/resources/info/oldInfo/136/info.json +7 -0
- package/core/resources/info/oldInfo/137/change.csv +293 -0
- package/core/resources/info/oldInfo/137/info.json +7 -0
- package/core/resources/info/oldInfo/138/change.csv +295 -0
- package/core/resources/info/oldInfo/138/info.json +7 -0
- package/core/resources/info/oldInfo/139/change.csv +295 -0
- package/core/resources/info/oldInfo/139/info.json +7 -0
- package/core/resources/info/oldInfo/140/change.csv +298 -0
- package/core/resources/info/oldInfo/140/info.json +7 -0
- package/core/resources/info/oldInfo/141/change.csv +300 -0
- package/core/resources/info/oldInfo/141/info.json +7 -0
- package/core/resources/info/oldInfo/142/change.csv +302 -0
- package/core/resources/info/oldInfo/142/info.json +7 -0
- package/core/resources/info/oldInfo/143/change.csv +303 -0
- package/core/resources/info/oldInfo/143/info.json +7 -0
- package/core/resources/info/oldInfo/144/change.csv +303 -0
- package/core/resources/info/oldInfo/144/info.json +7 -0
- package/core/resources/info/oldInfo/145/change.csv +305 -0
- package/core/resources/info/oldInfo/145/info.json +7 -0
- package/core/resources/info/oldInfo/146/change.csv +305 -0
- package/core/resources/info/oldInfo/146/info.json +7 -0
- package/core/resources/info/oldInfo/148/change.csv +307 -0
- package/core/resources/info/oldInfo/148/info.json +7 -0
- package/core/resources/info/oldInfo/149/change.csv +307 -0
- package/core/resources/info/oldInfo/149/info.json +7 -0
- package/core/resources/info/oldInfo/151/change.csv +309 -0
- package/core/resources/info/oldInfo/151/info.json +7 -0
- package/core/resources/info/oldInfo/152/change.csv +312 -0
- package/core/resources/info/oldInfo/152/info.json +7 -0
- package/core/resources/info/oldInfo/153/change.csv +313 -0
- package/core/resources/info/oldInfo/153/info.json +7 -0
- package/core/resources/info/oldInfo/154/change.csv +315 -0
- package/core/resources/info/oldInfo/154/info.json +7 -0
- package/core/resources/info/oldInfo/92/change.csv +204 -0
- package/core/resources/info/oldInfo/92/info.json +7 -0
- package/core/resources/info/oldInfo/93/change.csv +206 -0
- package/core/resources/info/oldInfo/93/info.json +7 -0
- package/core/resources/info/oldInfo/94/change.csv +209 -0
- package/core/resources/info/oldInfo/94/info.json +7 -0
- package/core/resources/info/oldInfo/95/change.csv +211 -0
- package/core/resources/info/oldInfo/95/info.json +7 -0
- package/core/resources/info/oldInfo/96/change.csv +216 -0
- package/core/resources/info/oldInfo/96/info.json +7 -0
- package/core/resources/info/oldInfo/98/change.csv +216 -0
- package/core/resources/info/oldInfo/98/info.json +7 -0
- package/core/resources/info/oldInfo/99/change.csv +217 -0
- package/core/resources/info/oldInfo/99/info.json +7 -0
- package/core/resources/info/oldNotesInfo.json +1 -0
- package/core/resources/info/sentences.json +1 -0
- package/core/resources/info/spinfo.json +362 -0
- package/core/resources/info/tips.txt +278 -0
- package/core/resources/otherill//351/233/252/351/231/215SP.png +0 -0
- package/core/resources/song-select.html +535 -0
- package/core/resources/themes/README.md +24 -0
- package/core/resources/themes/milthm/A.png +0 -0
- package/core/resources/themes/milthm/B.png +0 -0
- package/core/resources/themes/milthm/C.png +0 -0
- package/core/resources/themes/milthm/F.png +0 -0
- package/core/resources/themes/milthm/FC.png +0 -0
- package/core/resources/themes/milthm/S.png +0 -0
- package/core/resources/themes/milthm/V.png +0 -0
- package/core/resources/themes/milthm/arcgrosB19.css +36 -0
- package/core/resources/themes/milthm/b19.art +464 -0
- package/core/resources/themes/milthm/b19.css +1314 -0
- package/core/resources/themes/milthm/bg.png +0 -0
- package/core/resources/themes/milthm/clg.css +37 -0
- package/core/resources/themes/milthm/difficultyHistory.css +42 -0
- package/core/resources/themes/milthm/font.ttf +0 -0
- package/core/resources/themes/milthm/help.css +36 -0
- package/core/resources/themes/milthm/historyB30.css +48 -0
- package/core/resources/themes/milthm/info.yaml +45 -0
- package/core/resources/themes/milthm/list.css +39 -0
- package/core/resources/themes/milthm/phi.png +0 -0
- package/core/resources/themes/milthm/setting.css +37 -0
- package/core/resources/themes/milthm/sign.css +81 -0
- package/core/resources/themes/milthm/suggest.css +40 -0
- package/core/resources/themes/milthm/table.css +54 -0
- package/core/resources/themes/milthm/update.css +68 -0
- package/core/tests/aliasProposalService.test.js +82 -0
- package/core/tests/apiAccountDeletion.test.js +125 -0
- package/core/tests/apiPermission.test.js +44 -0
- package/core/tests/apiVersion.test.js +55 -0
- package/core/tests/b30Analysis.test.js +38 -0
- package/core/tests/backgroundIllustration.test.js +21 -0
- package/core/tests/botApiAuthRecovery.test.js +148 -0
- package/core/tests/botSyncService.test.js +42 -0
- package/core/tests/fileWatcherRegistry.test.js +44 -0
- package/core/tests/gameRecordPayload.test.js +34 -0
- package/core/tests/guessLetter.test.js +79 -0
- package/core/tests/makeRequestHandling.test.js +118 -0
- package/core/tests/marketOverflow.test.js +31 -0
- package/core/tests/platformTemplateCache.test.js +92 -0
- package/core/tests/pluginDataThemePreference.test.js +36 -0
- package/core/tests/processCleanup.test.js +58 -0
- package/core/tests/puppeteerShutdown.test.js +17 -0
- package/core/tests/renderPressureHistory.test.js +59 -0
- package/core/tests/saveStats.test.js +26 -0
- package/core/tests/themeInstallGuard.test.js +289 -0
- package/core/tests/themeManager.test.js +625 -0
- package/core/tests/themeManagerInit.test.js +11 -0
- package/core/tests/themeMarket.test.js +855 -0
- package/core/tests/themePageRouting.test.js +431 -0
- package/core/tests/themePolicy.test.js +28 -0
- package/core/tests/themeStorageRecovery.test.js +192 -0
- package/core/tests/userCredentialModuleBoundaries.test.js +41 -0
- package/core/tests/userCredentials.test.js +285 -0
- package/core/tsconfig.json +32 -0
- package/core/types/vendor.d.ts +14 -0
- package/lib/index.cjs +358 -0
- package/lib/index.d.cts +182 -0
- package/lib/index.d.ts +182 -0
- package/lib/index.js +320 -0
- package/package.json +74 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import JSZip from "jszip";
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Readable } from 'node:stream';
|
|
5
|
+
import getFile from "../filesystem/getFile.js";
|
|
6
|
+
import { backupPath, pluginDataPath, savePath, dataPath } from "../filesystem/path.js";
|
|
7
|
+
import saveHistory from "./saveHistory.js";
|
|
8
|
+
import ProgressBar from "../render/progress-bar.js";
|
|
9
|
+
import fCompute from '../game/fCompute.js'
|
|
10
|
+
import send from "../render/send.js";
|
|
11
|
+
import logger from "../../components/Logger.js";
|
|
12
|
+
import Save from "./Save.js";
|
|
13
|
+
import userCredentialStore from '../user/userCredentialStore.js';
|
|
14
|
+
import { themesDir } from '../theme/paths.js';
|
|
15
|
+
import { withMarketInstallLock } from '../theme/installLock.js';
|
|
16
|
+
|
|
17
|
+
const MaxNum = 1e4
|
|
18
|
+
const THEME_DIR_RE = /^[a-zA-Z0-9_-]+$/
|
|
19
|
+
const WINDOWS_RESERVED = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i
|
|
20
|
+
|
|
21
|
+
class LazyFileReadStream extends Readable {
|
|
22
|
+
/** @param {string} file */
|
|
23
|
+
constructor(file) {
|
|
24
|
+
super()
|
|
25
|
+
this.file = file
|
|
26
|
+
/** @type {fs.ReadStream|null} */
|
|
27
|
+
this.source = null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_read() {
|
|
31
|
+
if (this.source) {
|
|
32
|
+
this.source.resume()
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
const source = fs.createReadStream(this.file)
|
|
36
|
+
this.source = source
|
|
37
|
+
source.on('data', chunk => {
|
|
38
|
+
if (!this.push(chunk)) source.pause()
|
|
39
|
+
})
|
|
40
|
+
source.on('end', () => this.push(null))
|
|
41
|
+
source.on('error', error => this.destroy(error))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @param {Error|null} error @param {(error?:Error|null)=>void} callback */
|
|
45
|
+
_destroy(error, callback) {
|
|
46
|
+
this.source?.destroy()
|
|
47
|
+
callback(error)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @param {JSZip} zip @param {string} source @param {string} relative */
|
|
52
|
+
function addThemeDirectory(zip, source, relative) {
|
|
53
|
+
let files = 0
|
|
54
|
+
for (const entry of fs.readdirSync(source, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
55
|
+
const fullPath = path.join(source, entry.name)
|
|
56
|
+
const archivePath = `${relative}/${entry.name}`
|
|
57
|
+
const stat = fs.lstatSync(fullPath)
|
|
58
|
+
if (stat.isSymbolicLink()) {
|
|
59
|
+
logger.warn(`[phi-plugin][backup] 跳过主题中的符号链接:${fullPath}`)
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
if (stat.isDirectory()) {
|
|
63
|
+
zip.folder(archivePath)
|
|
64
|
+
files += addThemeDirectory(zip, fullPath, archivePath)
|
|
65
|
+
} else if (stat.isFile()) {
|
|
66
|
+
zip.file(archivePath, new LazyFileReadStream(fullPath))
|
|
67
|
+
files++
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return files
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @param {JSZip} zip Add installed/local themes, excluding transaction directories. */
|
|
74
|
+
export function addThemesToBackup(zip) {
|
|
75
|
+
if (!fs.existsSync(themesDir)) return { themes: 0, files: 0 }
|
|
76
|
+
let themes = 0
|
|
77
|
+
let files = 0
|
|
78
|
+
for (const entry of fs.readdirSync(themesDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
79
|
+
if (!entry.isDirectory() || entry.name.startsWith('.phi-market-') || !THEME_DIR_RE.test(entry.name)) continue
|
|
80
|
+
zip.folder(`themes/${entry.name}`)
|
|
81
|
+
files += addThemeDirectory(zip, path.join(themesDir, entry.name), `themes/${entry.name}`)
|
|
82
|
+
themes++
|
|
83
|
+
}
|
|
84
|
+
return { themes, files }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** @param {string} name @param {boolean} directory */
|
|
88
|
+
function parseThemeArchivePath(name, directory) {
|
|
89
|
+
if (!name.startsWith('themes/') || name.includes('\u0000')) return null
|
|
90
|
+
if (process.platform === 'win32' && /[\\\u0001-\u001f\u007f]/.test(name)) return null
|
|
91
|
+
const relative = name.slice('themes/'.length)
|
|
92
|
+
const segments = relative.split('/')
|
|
93
|
+
if (directory && segments.at(-1) === '') segments.pop()
|
|
94
|
+
if (segments.length < (directory ? 1 : 2)
|
|
95
|
+
|| !THEME_DIR_RE.test(segments[0])
|
|
96
|
+
|| segments.some(segment => !segment || segment === '.' || segment === '..'
|
|
97
|
+
|| (process.platform === 'win32'
|
|
98
|
+
&& (segment.includes(':') || /[. ]$/.test(segment) || WINDOWS_RESERVED.test(segment))))) return null
|
|
99
|
+
return segments
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** @param {JSZip} zip Restore missing themes atomically; existing themes are preserved. */
|
|
103
|
+
async function restoreThemesFromBackupUnlocked(zip) {
|
|
104
|
+
const entries = Object.values(zip.files).filter(file => file.name.startsWith('themes/') && file.name !== 'themes/')
|
|
105
|
+
if (!entries.length) return { restored: 0, skipped: 0 }
|
|
106
|
+
|
|
107
|
+
/** @type {{file:import('jszip').JSZipObject,segments:string[],directory:boolean}[]} */
|
|
108
|
+
const parsed = []
|
|
109
|
+
for (const file of entries) {
|
|
110
|
+
const originalName = /** @type {any} */ (file).unsafeOriginalName ?? file.name
|
|
111
|
+
const segments = parseThemeArchivePath(originalName, file.dir)
|
|
112
|
+
if (!segments) throw new Error(`备份中的主题路径不安全:${originalName}`)
|
|
113
|
+
parsed.push({ file, segments, directory: file.dir })
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
fs.mkdirSync(themesDir, { recursive: true, mode: 0o700 })
|
|
117
|
+
const stage = await fs.promises.mkdtemp(path.join(themesDir, '.phi-market-restore-'))
|
|
118
|
+
const themeNames = new Set(parsed.map(item => item.segments[0]))
|
|
119
|
+
let restored = 0
|
|
120
|
+
let skipped = 0
|
|
121
|
+
try {
|
|
122
|
+
for (const item of parsed) {
|
|
123
|
+
const output = path.join(stage, ...item.segments)
|
|
124
|
+
const relative = path.relative(stage, output)
|
|
125
|
+
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
126
|
+
throw new Error(`备份中的主题路径越界:${item.file.name}`)
|
|
127
|
+
}
|
|
128
|
+
if (item.directory) {
|
|
129
|
+
await fs.promises.mkdir(output, { recursive: true, mode: 0o700 })
|
|
130
|
+
} else {
|
|
131
|
+
await fs.promises.mkdir(path.dirname(output), { recursive: true, mode: 0o700 })
|
|
132
|
+
await fs.promises.writeFile(output, await item.file.async('nodebuffer'), { mode: 0o600, flag: 'wx' })
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const themeName of [...themeNames].sort()) {
|
|
136
|
+
const source = path.join(stage, themeName)
|
|
137
|
+
const target = path.join(themesDir, themeName)
|
|
138
|
+
const exists = await fs.promises.lstat(target).then(() => true, () => false)
|
|
139
|
+
if (exists) {
|
|
140
|
+
skipped++
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
await fs.promises.rename(source, target)
|
|
144
|
+
restored++
|
|
145
|
+
}
|
|
146
|
+
} finally {
|
|
147
|
+
await fs.promises.rm(stage, { recursive: true, force: true })
|
|
148
|
+
}
|
|
149
|
+
return { restored, skipped }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** @param {JSZip} zip Restore themes under the same lock used by market installs. */
|
|
153
|
+
export function restoreThemesFromBackup(zip) {
|
|
154
|
+
return withMarketInstallLock(() => restoreThemesFromBackupUnlocked(zip))
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**@import {botEvent} from "../../components/baseClass.js" */
|
|
158
|
+
export default class getBackup {
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 备份
|
|
162
|
+
* @param {botEvent} e
|
|
163
|
+
*/
|
|
164
|
+
static async backup(e) {
|
|
165
|
+
let zip = new JSZip()
|
|
166
|
+
/**data目录下存档 */
|
|
167
|
+
/**@type {ProgressBar|undefined} */
|
|
168
|
+
let bar = undefined
|
|
169
|
+
let list = fs.readdirSync(savePath)
|
|
170
|
+
if (list.length >= MaxNum) {
|
|
171
|
+
send.send_with_At(e, `存档数量过多,请手动备份 /data/saveData/ 目录!`)
|
|
172
|
+
console.error('[phi-plugin] 存档数量过多,请手动备份 /data/saveData/ 目录!')
|
|
173
|
+
} else {
|
|
174
|
+
send.send_with_At(e, '开始备份存档,请稍等...')
|
|
175
|
+
console.info('[phi-plugin][backup] 开始备份存档...')
|
|
176
|
+
bar = new ProgressBar('[phi-plugin] 存档备份中', 20)
|
|
177
|
+
list.forEach((folderName, index, array) => {
|
|
178
|
+
let folderPath = path.join(savePath, folderName)
|
|
179
|
+
fs.readdirSync(folderPath).forEach((fileName) => { //遍历检测目录中的文件
|
|
180
|
+
let filePath = path.join(folderPath, fileName);
|
|
181
|
+
let file = fs.statSync(filePath); //获取一个文件
|
|
182
|
+
if (file.isDirectory()) {
|
|
183
|
+
logger.error(filePath, '[phi-plugin] 备份错误:意料之外的文件夹');
|
|
184
|
+
} else {
|
|
185
|
+
zip.folder('saveData')?.folder(folderName)?.file(fileName, fs.readFileSync(filePath)); //压缩目录添加文件
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
bar?.render({ completed: index + 1, total: array.length });
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**data目录下plugin数据 */
|
|
192
|
+
list = fs.readdirSync(pluginDataPath)
|
|
193
|
+
if (list.length >= MaxNum) {
|
|
194
|
+
send.send_with_At(e, `插件数据数量过多,请手动备份 /data/pluginData/ 目录!`)
|
|
195
|
+
console.error('[phi-plugin] 插件数据数量过多,请手动备份 /data/pluginData/ 目录!')
|
|
196
|
+
} else {
|
|
197
|
+
send.send_with_At(e, '开始备份插件数据,请稍等...')
|
|
198
|
+
console.info('\n[phi-plugin][backup] 开始备份插件数据...')
|
|
199
|
+
bar = new ProgressBar('[phi-plugin] 插件数据备份中', 20)
|
|
200
|
+
list.forEach((fileName, index, array) => { //遍历检测目录中的文件
|
|
201
|
+
let filePath = path.join(pluginDataPath, fileName);
|
|
202
|
+
let file = fs.statSync(filePath); //获取一个文件
|
|
203
|
+
if (file.isDirectory()) {
|
|
204
|
+
logger.error(filePath, '[phi-plugin] 备份错误:意料之外的文件夹');
|
|
205
|
+
} else {
|
|
206
|
+
zip?.folder('pluginData')?.file(fileName, fs.readFileSync(filePath)); //压缩目录添加文件
|
|
207
|
+
}
|
|
208
|
+
bar?.render({ completed: index + 1, total: array.length });
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**提取redis中user_id数据 */
|
|
212
|
+
send.send_with_At(e, '开始备份user_token,请稍等...')
|
|
213
|
+
console.info('\n[phi-plugin][backup] 开始备份user_token数据...')
|
|
214
|
+
/**
|
|
215
|
+
* 获取user_token
|
|
216
|
+
* @type {Record<string, string>}
|
|
217
|
+
*/
|
|
218
|
+
let user_token = {}
|
|
219
|
+
console.info('[phi-plugin] 获取user_token列表...')
|
|
220
|
+
const credentialEntries = await userCredentialStore.listSessionCredentials()
|
|
221
|
+
for (const [userId, sessionToken] of credentialEntries) user_token[userId] = sessionToken
|
|
222
|
+
logger.info(`[phi-plugin] 已获取 ${credentialEntries.size} 个 user_token`)
|
|
223
|
+
zip.file('user_token.json', JSON.stringify(user_token))
|
|
224
|
+
/**压缩 */
|
|
225
|
+
let zipName = `${(new Date()).toISOString().replace(/[\:\.]/g, '-')}.zip`
|
|
226
|
+
if (!fs.existsSync(backupPath)) {
|
|
227
|
+
// 递归创建目录
|
|
228
|
+
fs.mkdirSync(backupPath, { recursive: true });
|
|
229
|
+
}
|
|
230
|
+
send.send_with_At(e, '开始压缩备份数据,请稍等...')
|
|
231
|
+
console.info('\n[phi-plugin][backup] 开始压缩备份数据...')
|
|
232
|
+
const outputPath = path.join(backupPath, zipName)
|
|
233
|
+
try {
|
|
234
|
+
await withMarketInstallLock(async () => {
|
|
235
|
+
const themeBackup = addThemesToBackup(zip)
|
|
236
|
+
if (themeBackup.themes) {
|
|
237
|
+
send.send_with_At(e, `已加入 ${themeBackup.themes} 个主题到备份`)
|
|
238
|
+
logger.info(`[phi-plugin][backup] 已加入 ${themeBackup.themes} 个主题、${themeBackup.files} 个文件`)
|
|
239
|
+
}
|
|
240
|
+
await new Promise((resolve, reject) => {
|
|
241
|
+
const archive = zip.generateNodeStream({ streamFiles: true })
|
|
242
|
+
const output = fs.createWriteStream(outputPath)
|
|
243
|
+
archive.once('error', reject)
|
|
244
|
+
output.once('error', reject)
|
|
245
|
+
output.once('finish', () => resolve(undefined))
|
|
246
|
+
archive.pipe(output)
|
|
247
|
+
})
|
|
248
|
+
})
|
|
249
|
+
} catch (error) {
|
|
250
|
+
await fs.promises.rm(outputPath, { force: true }).catch(() => {})
|
|
251
|
+
throw error
|
|
252
|
+
}
|
|
253
|
+
console.info('[phi-plugin]备份完成' + outputPath)
|
|
254
|
+
send.send_with_At(e, `${zipName.replace(".zip", '')} 成功备份到 ./backup 目录下`)
|
|
255
|
+
if (e.msg.replace(/^[#/].*backup/, '').includes('back')) {
|
|
256
|
+
await fCompute.sendFile(e, outputPath, zipName)
|
|
257
|
+
}
|
|
258
|
+
return { zipName: zipName, zip: zip }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 从zip中恢复
|
|
263
|
+
* @param {string} zipPath
|
|
264
|
+
*/
|
|
265
|
+
static async restore(zipPath) {
|
|
266
|
+
let zip = await JSZip.loadAsync(fs.readFileSync(zipPath))
|
|
267
|
+
const themeRestore = await restoreThemesFromBackup(zip)
|
|
268
|
+
if (themeRestore.restored || themeRestore.skipped) {
|
|
269
|
+
logger.info(`[phi-plugin][backup] 主题恢复完成:恢复 ${themeRestore.restored} 个,保留现有 ${themeRestore.skipped} 个`)
|
|
270
|
+
}
|
|
271
|
+
/**存档相关 */
|
|
272
|
+
zip.folder('saveData')?.forEach((session) => {
|
|
273
|
+
try {
|
|
274
|
+
/**阻止遍历文件user_token.json */
|
|
275
|
+
if (!session.includes('.json')) {
|
|
276
|
+
/**history */
|
|
277
|
+
getFile.FileReader(path.join(savePath, session, 'history.json')).then((/** @type {saveHistoryObject & { version?: number; }} */ old) => {
|
|
278
|
+
zip.folder('saveData')?.folder(session)?.file('history.json')?.async('string').then((history) => {
|
|
279
|
+
/**格式化为 JSON */
|
|
280
|
+
let now = new saveHistory(JSON.parse(history))
|
|
281
|
+
/**有本地记录,合并;无本地记录,直接覆盖 */
|
|
282
|
+
now.add(new saveHistory(old))
|
|
283
|
+
getFile.SetFile(path.join(savePath, session, 'history.json'), now)
|
|
284
|
+
})
|
|
285
|
+
})
|
|
286
|
+
/**save */
|
|
287
|
+
getFile.FileReader(path.join(savePath, session, 'save.json')).then((/** @type {Save} */ old) => {
|
|
288
|
+
zip.folder('saveData')?.folder(session)?.file('save.json')?.async('string').then((save) => {
|
|
289
|
+
/**格式化为 JSON */
|
|
290
|
+
let now = JSON.parse(save)
|
|
291
|
+
/**有本地记录,保留最新记录;无本地记录,直接覆盖 */
|
|
292
|
+
if (new Date(old?.saveInfo?.modifiedAt?.iso) > new Date(now?.saveInfo?.modifiedAt?.iso)) { now = old }
|
|
293
|
+
getFile.SetFile(path.join(savePath, session, 'save.json'), now)
|
|
294
|
+
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
}
|
|
298
|
+
} catch (e) {
|
|
299
|
+
logger.error(`恢复存档 ${session} 错误:` + e);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
/**插件数据相关 */
|
|
303
|
+
zip.folder('pluginData')?.forEach((fileName, file) => {
|
|
304
|
+
try {
|
|
305
|
+
file.async('string').then((data) => {
|
|
306
|
+
getFile.SetFile(path.join(pluginDataPath, fileName), JSON.parse(data))
|
|
307
|
+
})
|
|
308
|
+
} catch (e) {
|
|
309
|
+
logger.error(`恢复插件数据 ${fileName} 错误:` + e);
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
/**user_id->tk */
|
|
313
|
+
zip.file('user_token.json')?.async('text').then((data) => {
|
|
314
|
+
try {
|
|
315
|
+
let now = JSON.parse(data)
|
|
316
|
+
for (let user_id in now) {
|
|
317
|
+
try {
|
|
318
|
+
userCredentialStore.setSessionToken(user_id, now[user_id])
|
|
319
|
+
} catch (e) {
|
|
320
|
+
logger.error(`恢复 user_token 对照 [${user_id}]:${now[user_id]} 错误:` + e);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
} catch (e) {
|
|
324
|
+
logger.error(`恢复 user_token 对照错误:` + e);
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import PhigrosUser from '../../lib/PhigrosUser.js'
|
|
4
|
+
import Save from './Save.js'
|
|
5
|
+
import saveHistory from './saveHistory.js'
|
|
6
|
+
import readFile from '../filesystem/getFile.js'
|
|
7
|
+
import getRksRank from '../game/getRksRank.js'
|
|
8
|
+
import { savePath } from '../filesystem/path.js'
|
|
9
|
+
import userCredentialStore from '../user/userCredentialStore.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SSTK 本地存档仓库。
|
|
13
|
+
* 只处理以 sessionToken 为键的文件,不负责平台用户与凭证的映射。
|
|
14
|
+
*/
|
|
15
|
+
export default class LocalSaveRepository {
|
|
16
|
+
/**
|
|
17
|
+
* 检查 sessionToken 是否允许访问本地存档。
|
|
18
|
+
* @param {phigrosToken} sessionToken Phigros sessionToken
|
|
19
|
+
*/
|
|
20
|
+
static async assertSessionTokenAllowed(sessionToken) {
|
|
21
|
+
if (await userCredentialStore.isSessionTokenBanned(sessionToken)) {
|
|
22
|
+
throw new Error(`${sessionToken} 已被禁用`)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 读取 sessionToken 对应的本地存档。
|
|
28
|
+
* @param {phigrosToken | null | undefined} sessionToken Phigros sessionToken
|
|
29
|
+
* @returns {Promise<Save | undefined>} 已初始化的存档
|
|
30
|
+
*/
|
|
31
|
+
static async getSaveBySessionToken(sessionToken) {
|
|
32
|
+
if (!sessionToken) return undefined
|
|
33
|
+
await this.assertSessionTokenAllowed(sessionToken)
|
|
34
|
+
const data = await readFile.FileReader(path.join(savePath, sessionToken, 'save.json'))
|
|
35
|
+
if (!data?.saveInfo) return undefined
|
|
36
|
+
const save = new Save(data)
|
|
37
|
+
await save.init()
|
|
38
|
+
return save
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 保存 sessionToken 对应的本地存档并更新 RKS 索引。
|
|
43
|
+
* @param {Save | PhigrosUser} data 包含 sessionToken 的存档
|
|
44
|
+
*/
|
|
45
|
+
static async putSaveBySessionToken(data) {
|
|
46
|
+
const sessionToken = data.session
|
|
47
|
+
if (!sessionToken) throw new Error('sessionToken is undefined')
|
|
48
|
+
await this.assertSessionTokenAllowed(sessionToken)
|
|
49
|
+
await getRksRank.addUserRks(sessionToken, data.saveInfo.summary.rankingScore)
|
|
50
|
+
return readFile.SetFile(path.join(savePath, sessionToken, 'save.json'), data)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 读取 sessionToken 对应的本地历史。
|
|
55
|
+
* @param {phigrosToken | null | undefined} sessionToken Phigros sessionToken
|
|
56
|
+
* @returns {Promise<saveHistory>} 历史记录对象
|
|
57
|
+
*/
|
|
58
|
+
static async getHistoryBySessionToken(sessionToken) {
|
|
59
|
+
if (!sessionToken) return new saveHistory(/** @type {any} */ (null))
|
|
60
|
+
await this.assertSessionTokenAllowed(sessionToken)
|
|
61
|
+
const data = await readFile.FileReader(path.join(savePath, sessionToken, 'history.json'))
|
|
62
|
+
return new saveHistory(data)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 保存 sessionToken 对应的本地历史。
|
|
67
|
+
* @param {phigrosToken} sessionToken Phigros sessionToken
|
|
68
|
+
* @param {saveHistory | saveHistoryObject | object} data 历史记录
|
|
69
|
+
*/
|
|
70
|
+
static async putHistoryBySessionToken(sessionToken, data) {
|
|
71
|
+
if (!sessionToken) throw new Error('sessionToken is undefined')
|
|
72
|
+
await this.assertSessionTokenAllowed(sessionToken)
|
|
73
|
+
return readFile.SetFile(path.join(savePath, sessionToken, 'history.json'), data)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 删除 sessionToken 对应的本地存档、历史和 RKS 索引。
|
|
78
|
+
* @param {phigrosToken | null | undefined} sessionToken Phigros sessionToken
|
|
79
|
+
* @returns {Promise<boolean>} 是否执行了删除
|
|
80
|
+
*/
|
|
81
|
+
static async deleteSaveBySessionToken(sessionToken) {
|
|
82
|
+
if (!sessionToken) return false
|
|
83
|
+
const directory = path.join(savePath, sessionToken)
|
|
84
|
+
await readFile.DelFile(path.join(directory, 'save.json'))
|
|
85
|
+
await readFile.DelFile(path.join(directory, 'history.json'))
|
|
86
|
+
await getRksRank.delUserRks(sessionToken)
|
|
87
|
+
fs.rmSync(directory, { recursive: true, force: true })
|
|
88
|
+
return true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import Save from './Save.js'
|
|
4
|
+
import readFile from '../filesystem/getFile.js'
|
|
5
|
+
import { apiSavePath } from '../filesystem/path.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* API ID 本地存档缓存仓库。
|
|
9
|
+
* 只处理文件,不读取用户凭证,也不发起 API 请求。
|
|
10
|
+
*/
|
|
11
|
+
export default class ApiSaveCacheRepository {
|
|
12
|
+
/**
|
|
13
|
+
* 读取 API ID对应的本地存档缓存。
|
|
14
|
+
* @param {apiUserId | null | undefined} apiId API 用户 ID
|
|
15
|
+
* @returns {Promise<Save | undefined>} 已初始化的缓存存档
|
|
16
|
+
*/
|
|
17
|
+
static async getSaveByApiId(apiId) {
|
|
18
|
+
if (!apiId) return undefined
|
|
19
|
+
const data = await readFile.FileReader(path.join(apiSavePath, apiId, 'save.json'))
|
|
20
|
+
if (!data?.saveInfo) return undefined
|
|
21
|
+
const save = new Save(data)
|
|
22
|
+
await save.init()
|
|
23
|
+
return save
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 保存 API ID对应的本地存档缓存。
|
|
28
|
+
* @param {apiUserId} apiId API 用户 ID
|
|
29
|
+
* @param {Partial<oriSave | Save>} data 存档数据
|
|
30
|
+
*/
|
|
31
|
+
static async putSaveByApiId(apiId, data) {
|
|
32
|
+
if (!apiId) throw new Error('apiId is undefined')
|
|
33
|
+
return readFile.SetFile(path.join(apiSavePath, apiId, 'save.json'), data)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 删除 API ID对应的本地存档缓存。
|
|
38
|
+
* @param {apiUserId | null | undefined} apiId API 用户 ID
|
|
39
|
+
* @returns {boolean} 是否执行了删除
|
|
40
|
+
*/
|
|
41
|
+
static deleteSaveByApiId(apiId) {
|
|
42
|
+
if (!apiId) return false
|
|
43
|
+
fs.rmSync(path.join(apiSavePath, apiId), { recursive: true, force: true })
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
}
|