@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,249 @@
|
|
|
1
|
+
|
|
2
|
+
import YAML from 'yaml'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import YamlReader from './YamlReader.js'
|
|
6
|
+
import fileWatcherRegistry from './FileWatcherRegistry.js'
|
|
7
|
+
import { pluginRoot } from '../model/filesystem/path.js'
|
|
8
|
+
import logger from './Logger.js'
|
|
9
|
+
import platform from './platform/index.js'
|
|
10
|
+
|
|
11
|
+
const Plugin_Name = 'phi-plugin'
|
|
12
|
+
const Plugin_Path = pluginRoot
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Koishi 移植专用:用户可写配置目录。
|
|
16
|
+
* 非 Koishi 环境与原本一致(插件根目录/config/config),
|
|
17
|
+
* Koishi 环境指向 `<ctx.baseDir>/data/<plugin>/config/config`。
|
|
18
|
+
*/
|
|
19
|
+
const koishiRoot = process.env.PHI_PLUGIN_KOISHI_ROOT
|
|
20
|
+
? path.resolve(process.env.PHI_PLUGIN_KOISHI_ROOT)
|
|
21
|
+
: null
|
|
22
|
+
|
|
23
|
+
/** 默认配置(随包分发,只读来源) */
|
|
24
|
+
const DefaultConfigDir = path.join(Plugin_Path, 'config', 'default_config')
|
|
25
|
+
|
|
26
|
+
/** 用户可写配置目录 */
|
|
27
|
+
const UserConfigDir = koishiRoot
|
|
28
|
+
? path.join(koishiRoot, 'config', 'config')
|
|
29
|
+
: path.join(Plugin_Path, 'config', 'config')
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 根据配置类别返回 yaml 文件路径
|
|
33
|
+
* @param {'config'|'default_config'} type
|
|
34
|
+
* @param {string} name
|
|
35
|
+
* @returns {string}
|
|
36
|
+
*/
|
|
37
|
+
function configFile(type, name) {
|
|
38
|
+
if (type === 'default_config') return path.join(DefaultConfigDir, `${name}.yaml`)
|
|
39
|
+
return path.join(UserConfigDir, `${name}.yaml`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class Config {
|
|
43
|
+
constructor() {
|
|
44
|
+
/** @type {Record<string, any>} */
|
|
45
|
+
this.config = {}
|
|
46
|
+
|
|
47
|
+
/** 监听文件 */
|
|
48
|
+
/** @type {Record<string, any>} */
|
|
49
|
+
this.watcher = {}
|
|
50
|
+
|
|
51
|
+
this.initCfg()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 初始化配置 */
|
|
55
|
+
initCfg() {
|
|
56
|
+
fs.mkdirSync(UserConfigDir, { recursive: true })
|
|
57
|
+
const files = fs.readdirSync(DefaultConfigDir).filter(file => file.endsWith('.yaml'))
|
|
58
|
+
for (let file of files) {
|
|
59
|
+
if (!fs.existsSync(path.join(UserConfigDir, file))) {
|
|
60
|
+
fs.copyFileSync(path.join(DefaultConfigDir, file), path.join(UserConfigDir, file))
|
|
61
|
+
}
|
|
62
|
+
this.watch(path.join(UserConfigDir, file), file.replace('.yaml', ''), 'config')
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 群配置 */
|
|
67
|
+
getGroup(groupId = '') {
|
|
68
|
+
let config = this.getConfig('whole')
|
|
69
|
+
let group = this.getConfig('group')
|
|
70
|
+
let defCfg = this.getdefSet('whole')
|
|
71
|
+
|
|
72
|
+
if (group[groupId]) {
|
|
73
|
+
return { ...defCfg, ...config, ...group[groupId] }
|
|
74
|
+
}
|
|
75
|
+
return { ...defCfg, ...config }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @overload
|
|
80
|
+
* @param {'config'} name 文件名
|
|
81
|
+
* @param {configName} style key值
|
|
82
|
+
* @returns {any} 配置值
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* @overload
|
|
86
|
+
* @param {'nickconfig'} name 文件名
|
|
87
|
+
* @param {string} mic 别名
|
|
88
|
+
* @returns {idString[]} 原曲id
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* @overload
|
|
92
|
+
* @param {'nickconfig'} name 文件名
|
|
93
|
+
* @returns {Record<string, idString[]>} <别名: 原曲id[]>
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* @overload
|
|
97
|
+
* @param {'otherinfo'} name 文件名
|
|
98
|
+
* @returns {any} 其他信息
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* @param {'config'|'nickconfig'|'otherinfo'} name 文件名
|
|
102
|
+
* @param {any} [style] key值
|
|
103
|
+
* @description 默认配置和用户配置
|
|
104
|
+
*/
|
|
105
|
+
getUserCfg(name, style = undefined) {
|
|
106
|
+
let def = this.getdefSet(name)
|
|
107
|
+
let config = this.getConfig(name)
|
|
108
|
+
if (name == 'otherinfo' && config) {
|
|
109
|
+
for (let i in config) {
|
|
110
|
+
config[i].sp_vis = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (style) {
|
|
114
|
+
if (typeof config[style] != 'undefined') {
|
|
115
|
+
return config[style]
|
|
116
|
+
} else {
|
|
117
|
+
/**对设置进行补全 */
|
|
118
|
+
if (name == 'config') {
|
|
119
|
+
this.modify(name, style, def[style])
|
|
120
|
+
}
|
|
121
|
+
return def[style]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else
|
|
125
|
+
return (config ? config : def)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** 默认配置 */
|
|
129
|
+
/**
|
|
130
|
+
* @param {string} name
|
|
131
|
+
* @returns {Record<string, any>}
|
|
132
|
+
*/
|
|
133
|
+
getdefSet(name) {
|
|
134
|
+
return this.getYaml('default_config', name)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** 用户配置 */
|
|
138
|
+
/**
|
|
139
|
+
* @param {string} name
|
|
140
|
+
* @returns {Record<string, any>}
|
|
141
|
+
*/
|
|
142
|
+
getConfig(name) {
|
|
143
|
+
return this.getYaml('config', name)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 获取配置yaml
|
|
148
|
+
* @param {'config'|'default_config'} type 默认配置-defSet,用户配置-config
|
|
149
|
+
* @param {string} name 名称
|
|
150
|
+
* @returns {Record<string, any>}
|
|
151
|
+
*/
|
|
152
|
+
getYaml(type, name) {
|
|
153
|
+
let file = configFile(type, name)
|
|
154
|
+
let key = `${type}.${name}`
|
|
155
|
+
|
|
156
|
+
if (this.config[key]) return this.config[key]
|
|
157
|
+
|
|
158
|
+
this.config[key] = YAML.parse(
|
|
159
|
+
fs.readFileSync(file, 'utf8')
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
this.watch(file, name, type)
|
|
163
|
+
|
|
164
|
+
return this.config[key]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** 监听配置文件 */
|
|
168
|
+
/**
|
|
169
|
+
* @param {string} file
|
|
170
|
+
* @param {string} name
|
|
171
|
+
* @param {'config'|'default_config'} [type]
|
|
172
|
+
*/
|
|
173
|
+
watch(file, name, type = 'default_config') {
|
|
174
|
+
let key = `${type}.${name}`
|
|
175
|
+
|
|
176
|
+
if (this.watcher[key]) return
|
|
177
|
+
|
|
178
|
+
const watcherKey = `config:${key}`
|
|
179
|
+
const watcher = fileWatcherRegistry.watch(watcherKey, file, path => {
|
|
180
|
+
delete this.config[key]
|
|
181
|
+
if (!platform.isBotReady()) return
|
|
182
|
+
logger.mark(`[phi修改配置文件][${type}][${name}]`)
|
|
183
|
+
const changeHandler = /** @type {Record<string, any>} */ (this)[`change_${name}`]
|
|
184
|
+
if (typeof changeHandler === 'function') {
|
|
185
|
+
changeHandler.call(this)
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
this.watcher[key] = watcher
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** 关闭当前配置实例创建的全部监听器。 */
|
|
193
|
+
async close() {
|
|
194
|
+
const entries = Object.entries(this.watcher)
|
|
195
|
+
this.watcher = {}
|
|
196
|
+
await Promise.allSettled(entries.map(([, lease]) => lease.close()))
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @overload
|
|
201
|
+
* @param {'config'} name 文件名
|
|
202
|
+
* @param {configName} key 修改的key值
|
|
203
|
+
* @param {String|Number|boolean} value 修改的value值
|
|
204
|
+
* @param {'config'|'default_config'} [type] 配置或默认,默认为配置
|
|
205
|
+
* @returns {void}
|
|
206
|
+
*/
|
|
207
|
+
/**
|
|
208
|
+
* @overload
|
|
209
|
+
* @param {'nickconfig'} name 文件名
|
|
210
|
+
* @param {any} key 别名
|
|
211
|
+
* @param {String|Number|any[]} value 修改的value值
|
|
212
|
+
* @param {'config'|'default_config'} [type] 配置或默认,默认为配置
|
|
213
|
+
* @returns {void}
|
|
214
|
+
*/
|
|
215
|
+
/**
|
|
216
|
+
* @description: 修改设置
|
|
217
|
+
* @param {'config'|'nickconfig'} name 文件名
|
|
218
|
+
* @param {any} key 修改的key值
|
|
219
|
+
* @param {String|Number|boolean|any[]} value 修改的value值
|
|
220
|
+
* @param {'config'|'default_config'} [type] 配置或默认
|
|
221
|
+
*/
|
|
222
|
+
modify(name, key, value, type = 'config') {
|
|
223
|
+
let file = configFile(type, name)
|
|
224
|
+
new YamlReader(file).set(key, value)
|
|
225
|
+
delete this.config[`${type}.${name}`]
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @description: 修改配置数组
|
|
230
|
+
* @param {'config'|'nickconfig'} name 文件名
|
|
231
|
+
* @param {string | number} key key值
|
|
232
|
+
* @param {String|Number} value value
|
|
233
|
+
* @param {'add'|'del'} category 类别 add or del
|
|
234
|
+
* @param {'config'|'default_config'} type 配置或默认
|
|
235
|
+
*/
|
|
236
|
+
modifyarr(name, key, value, category = 'add', type = 'config') {
|
|
237
|
+
let file = configFile(type, name)
|
|
238
|
+
let yaml = new YamlReader(file)
|
|
239
|
+
const keyPath = String(key)
|
|
240
|
+
if (category == 'add') {
|
|
241
|
+
yaml.addIn(keyPath, value)
|
|
242
|
+
} else {
|
|
243
|
+
let index = yaml.jsonData[keyPath].indexOf(value)
|
|
244
|
+
yaml.delete(`${keyPath}.${index}`)
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export default new Config()
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import lodash from 'lodash'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import { pluginRoot } from '../model/filesystem/path.js'
|
|
4
|
+
import logger from './Logger.js'
|
|
5
|
+
import { redis } from './platform/index.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} [root]
|
|
9
|
+
* @returns {string}
|
|
10
|
+
*/
|
|
11
|
+
const getRoot = (root = '') => {
|
|
12
|
+
if (root === 'root' || root === 'yunzai') {
|
|
13
|
+
root = `${process.cwd()}/`
|
|
14
|
+
} else if (!root) {
|
|
15
|
+
root = `${pluginRoot}/`
|
|
16
|
+
}
|
|
17
|
+
return root
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {object} DataPickOptions
|
|
22
|
+
* @property {Record<string, any>} [defaultData]
|
|
23
|
+
* @property {boolean} [lowerFirstKey]
|
|
24
|
+
* @property {string} [keyPrefix]
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** @type {Record<string, any>} */
|
|
28
|
+
let Data = {
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* 根据指定的path依次检查与创建目录
|
|
32
|
+
* */
|
|
33
|
+
createDir(path = '', root = '', includeFile = false) {
|
|
34
|
+
root = getRoot(root)
|
|
35
|
+
let pathList = path.split('/')
|
|
36
|
+
let nowPath = root
|
|
37
|
+
pathList.forEach((name, idx) => {
|
|
38
|
+
name = name.trim()
|
|
39
|
+
if (!includeFile && idx <= pathList.length - 1) {
|
|
40
|
+
nowPath += name + '/'
|
|
41
|
+
if (name) {
|
|
42
|
+
if (!fs.existsSync(nowPath)) {
|
|
43
|
+
fs.mkdirSync(nowPath)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/** 读取json */
|
|
51
|
+
readJSON(file = '', root = '') {
|
|
52
|
+
root = getRoot(root)
|
|
53
|
+
if (fs.existsSync(`${root}/${file}`)) {
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(fs.readFileSync(`${root}/${file}`, 'utf8'))
|
|
56
|
+
} catch (e) {
|
|
57
|
+
logger.error(e)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/** 写JSON */
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} file
|
|
66
|
+
* @param {unknown} data
|
|
67
|
+
* @param {string} [root]
|
|
68
|
+
* @param {string | number} [space]
|
|
69
|
+
*/
|
|
70
|
+
writeJSON(file, data, root = '', space = '\t') {
|
|
71
|
+
// 检查并创建目录
|
|
72
|
+
Data.createDir(file, root, true)
|
|
73
|
+
root = getRoot(root)
|
|
74
|
+
// delete data._res
|
|
75
|
+
try {
|
|
76
|
+
fs.writeFileSync(`${root}/${file}`, JSON.stringify(data, null, space))
|
|
77
|
+
return true
|
|
78
|
+
} catch (err) {
|
|
79
|
+
logger.error(err)
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {string} key
|
|
86
|
+
*/
|
|
87
|
+
async getCacheJSON(key) {
|
|
88
|
+
try {
|
|
89
|
+
let txt = await redis.get(key)
|
|
90
|
+
if (txt) {
|
|
91
|
+
return JSON.parse(txt)
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
logger.error(e)
|
|
95
|
+
}
|
|
96
|
+
return {}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} key
|
|
101
|
+
* @param {unknown} data
|
|
102
|
+
* @param {number} [EX]
|
|
103
|
+
*/
|
|
104
|
+
async setCacheJSON(key, data, EX = 3600 * 24 * 90) {
|
|
105
|
+
await redis.set(key, JSON.stringify(data), { EX })
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {string} file
|
|
110
|
+
* @param {string} [root]
|
|
111
|
+
*/
|
|
112
|
+
async importModule(file, root = '') {
|
|
113
|
+
root = getRoot(root)
|
|
114
|
+
if (!/\.js$/.test(file)) {
|
|
115
|
+
file = file + '.js'
|
|
116
|
+
}
|
|
117
|
+
if (fs.existsSync(`${root}/${file}`)) {
|
|
118
|
+
try {
|
|
119
|
+
let data = await import(`file://${root}/${file}?t=${Date.now()}`)
|
|
120
|
+
return data || {}
|
|
121
|
+
} catch (e) {
|
|
122
|
+
logger.error(e)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return {}
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {string} file
|
|
130
|
+
* @param {string} [root]
|
|
131
|
+
*/
|
|
132
|
+
async importDefault(file, root) {
|
|
133
|
+
let ret = await Data.importModule(file, root)
|
|
134
|
+
return ret.default || {}
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {string} name
|
|
139
|
+
*/
|
|
140
|
+
async import(name) {
|
|
141
|
+
return await Data.importModule(`components/optional-lib/${name}.js`)
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {string} key
|
|
146
|
+
*/
|
|
147
|
+
async importCfg(key) {
|
|
148
|
+
let sysCfg = await Data.importModule(`config/system/${key}_system.js`)
|
|
149
|
+
let diyCfg = await Data.importModule(`config/${key}.js`)
|
|
150
|
+
if (diyCfg.isSys) {
|
|
151
|
+
logger.error(`phi-plugin: config/${key}.js无效,已忽略`)
|
|
152
|
+
logger.error(`如需配置请复制config/${key}_default.js为config/${key}.js,请勿复制config/system下的系统文件`)
|
|
153
|
+
diyCfg = {}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
sysCfg,
|
|
157
|
+
diyCfg
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
/*
|
|
162
|
+
* 返回一个从 target 中选中的属性的对象
|
|
163
|
+
*
|
|
164
|
+
* keyList : 获取字段列表,逗号分割字符串
|
|
165
|
+
* key1, key2, toKey1:fromKey1, toKey2:fromObj.key
|
|
166
|
+
*
|
|
167
|
+
* defaultData: 当某个字段为空时会选取defaultData的对应内容
|
|
168
|
+
* toKeyPrefix:返回数据的字段前缀,默认为空。defaultData中的键值无需包含toKeyPrefix
|
|
169
|
+
*
|
|
170
|
+
* */
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @param {Record<string, any>} target
|
|
174
|
+
* @param {string | string[]} [keyList]
|
|
175
|
+
* @param {DataPickOptions} [cfg]
|
|
176
|
+
*/
|
|
177
|
+
getData(target, keyList = '', cfg = {}) {
|
|
178
|
+
target = target || {}
|
|
179
|
+
let defaultData = cfg.defaultData || {}
|
|
180
|
+
/** @type {Record<string, any>} */
|
|
181
|
+
let ret = {}
|
|
182
|
+
// 分割逗号
|
|
183
|
+
if (typeof (keyList) === 'string') {
|
|
184
|
+
keyList = keyList.split(',')
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
lodash.forEach(keyList, (keyCfg) => {
|
|
188
|
+
// 处理通过:指定 toKey & fromKey
|
|
189
|
+
let _keyCfg = keyCfg.split(':')
|
|
190
|
+
let keyTo = _keyCfg[0].trim()
|
|
191
|
+
let keyFrom = (_keyCfg[1] || _keyCfg[0]).trim()
|
|
192
|
+
let keyRet = keyTo
|
|
193
|
+
if (cfg.lowerFirstKey) {
|
|
194
|
+
keyRet = lodash.lowerFirst(keyRet)
|
|
195
|
+
}
|
|
196
|
+
if (cfg.keyPrefix) {
|
|
197
|
+
keyRet = cfg.keyPrefix + keyRet
|
|
198
|
+
}
|
|
199
|
+
// 通过Data.getVal获取数据
|
|
200
|
+
ret[keyRet] = Data.getVal(target, keyFrom, defaultData[keyTo], cfg)
|
|
201
|
+
})
|
|
202
|
+
return ret
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @param {Record<string, any>} target
|
|
207
|
+
* @param {string} keyFrom
|
|
208
|
+
* @param {unknown} defaultValue
|
|
209
|
+
*/
|
|
210
|
+
getVal(target, keyFrom, defaultValue) {
|
|
211
|
+
return lodash.get(target, keyFrom, defaultValue)
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
// 异步池,聚合请求
|
|
215
|
+
/**
|
|
216
|
+
* @template T, R
|
|
217
|
+
* @param {number} poolLimit
|
|
218
|
+
* @param {T[]} array
|
|
219
|
+
* @param {(item: T, array: T[]) => R | Promise<R>} iteratorFn
|
|
220
|
+
* @returns {Promise<R[]>}
|
|
221
|
+
*/
|
|
222
|
+
async asyncPool(poolLimit, array, iteratorFn) {
|
|
223
|
+
/** @type {Promise<R>[]} */
|
|
224
|
+
const ret = [] // 存储所有的异步任务
|
|
225
|
+
/** @type {Promise<void>[]} */
|
|
226
|
+
const executing = [] // 存储正在执行的异步任务
|
|
227
|
+
for (const item of array) {
|
|
228
|
+
// 调用iteratorFn函数创建异步任务
|
|
229
|
+
const p = Promise.resolve().then(() => iteratorFn(item, array))
|
|
230
|
+
// 保存新的异步任务
|
|
231
|
+
ret.push(p)
|
|
232
|
+
|
|
233
|
+
// 当poolLimit值小于或等于总任务个数时,进行并发控制
|
|
234
|
+
if (poolLimit <= array.length) {
|
|
235
|
+
// 当任务完成后,从正在执行的任务数组中移除已完成的任务
|
|
236
|
+
const e = p.then(() => undefined)
|
|
237
|
+
executing.push(e) // 保存正在执行的异步任务
|
|
238
|
+
void e.then(() => {
|
|
239
|
+
const index = executing.indexOf(e)
|
|
240
|
+
if (index >= 0) executing.splice(index, 1)
|
|
241
|
+
})
|
|
242
|
+
if (executing.length >= poolLimit) {
|
|
243
|
+
// 等待较快的任务执行完成
|
|
244
|
+
await Promise.race(executing)
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return Promise.all(ret)
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// sleep
|
|
252
|
+
/**
|
|
253
|
+
* @param {number} ms
|
|
254
|
+
*/
|
|
255
|
+
sleep(ms) {
|
|
256
|
+
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
// 获取默认值
|
|
260
|
+
def() {
|
|
261
|
+
for (let idx in arguments) {
|
|
262
|
+
if (!lodash.isUndefined(arguments[idx])) {
|
|
263
|
+
return arguments[idx]
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
// 循环字符串回调
|
|
269
|
+
/**
|
|
270
|
+
* @param {string | number | Array<string | number>} arr
|
|
271
|
+
* @param {(value: string | number, index: number | string) => void} fn
|
|
272
|
+
*/
|
|
273
|
+
eachStr: (arr, fn) => {
|
|
274
|
+
if (lodash.isString(arr)) {
|
|
275
|
+
arr = arr.replace(/\s*(;|;|、|,)\s*/, ',')
|
|
276
|
+
arr = arr.split(',')
|
|
277
|
+
} else if (lodash.isNumber(arr)) {
|
|
278
|
+
arr = [arr.toString()]
|
|
279
|
+
}
|
|
280
|
+
lodash.forEach(arr, (str, idx) => {
|
|
281
|
+
if (!lodash.isUndefined(str)) {
|
|
282
|
+
const value = typeof str === 'string' ? str.trim() : str
|
|
283
|
+
fn(value, idx)
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {RegExp} reg
|
|
290
|
+
* @param {string} txt
|
|
291
|
+
* @param {number} idx
|
|
292
|
+
*/
|
|
293
|
+
regRet(reg, txt, idx) {
|
|
294
|
+
if (reg && txt) {
|
|
295
|
+
let ret = reg.exec(txt)
|
|
296
|
+
if (ret && ret[idx]) {
|
|
297
|
+
return ret[idx]
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return false
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export default Data
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import chokidar from 'chokidar'
|
|
3
|
+
|
|
4
|
+
const registrySymbol = Symbol.for('phi-plugin.fileWatcherRegistry')
|
|
5
|
+
const globalStore = /** @type {Record<symbol, any>} */ (globalThis)
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} FileWatcherLease
|
|
9
|
+
* @property {import('chokidar').FSWatcher} watcher
|
|
10
|
+
* @property {Promise<void>} ready
|
|
11
|
+
* @property {() => Promise<void>} close
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export class FileWatcherRegistry {
|
|
15
|
+
constructor() {
|
|
16
|
+
/** @type {Map<string, {file: string, watcher: import('chokidar').FSWatcher, ready: Promise<void>, onChange: (...args: any[]) => void, lease: FileWatcherLease}>} */
|
|
17
|
+
this.entries = new Map()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 同一个 key 在热重载后复用 watcher,只替换回调以释放旧模块引用。
|
|
22
|
+
* @param {string} key
|
|
23
|
+
* @param {string} file
|
|
24
|
+
* @param {(...args: any[]) => void} onChange
|
|
25
|
+
* @param {string[]} [events=['change']] 需要监听的 chokidar 事件(change/add/unlink/addDir/unlinkDir…)
|
|
26
|
+
* @param {import('chokidar').ChokidarOptions} [watchOptions]
|
|
27
|
+
* @returns {FileWatcherLease}
|
|
28
|
+
*/
|
|
29
|
+
watch(key, file, onChange, events = ['change'], watchOptions = {}) {
|
|
30
|
+
const normalizedFile = path.resolve(file)
|
|
31
|
+
const current = this.entries.get(key)
|
|
32
|
+
if (current?.file === normalizedFile) {
|
|
33
|
+
current.onChange = onChange
|
|
34
|
+
current.lease = this.createLease(key, current.watcher, current.ready)
|
|
35
|
+
return current.lease
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (current) {
|
|
39
|
+
this.entries.delete(key)
|
|
40
|
+
void current.watcher.close()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @type {{file: string, watcher: import('chokidar').FSWatcher, ready: Promise<void>, onChange: (...args: any[]) => void, lease: FileWatcherLease}} */
|
|
44
|
+
const entry = {
|
|
45
|
+
file: normalizedFile,
|
|
46
|
+
watcher: /** @type {any} */ (null),
|
|
47
|
+
ready: /** @type {any} */ (null),
|
|
48
|
+
onChange,
|
|
49
|
+
lease: /** @type {any} */ (null),
|
|
50
|
+
}
|
|
51
|
+
entry.watcher = chokidar.watch(normalizedFile, watchOptions)
|
|
52
|
+
entry.ready = new Promise(resolve => entry.watcher.once('ready', () => resolve()))
|
|
53
|
+
const watcher = /** @type {any} */ (entry.watcher)
|
|
54
|
+
for (const event of events) {
|
|
55
|
+
watcher.on(event, /** @type {(...args: any[]) => void} */ ((...args) => entry.onChange(...args)))
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
entry.lease = this.createLease(key, entry.watcher, entry.ready)
|
|
59
|
+
this.entries.set(key, entry)
|
|
60
|
+
return entry.lease
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {string} key
|
|
65
|
+
* @param {import('chokidar').FSWatcher} watcher
|
|
66
|
+
* @param {Promise<void>} ready
|
|
67
|
+
* @returns {FileWatcherLease}
|
|
68
|
+
*/
|
|
69
|
+
createLease(key, watcher, ready) {
|
|
70
|
+
/** @type {FileWatcherLease} */
|
|
71
|
+
const lease = {
|
|
72
|
+
watcher,
|
|
73
|
+
ready,
|
|
74
|
+
close: () => this.close(key, lease),
|
|
75
|
+
}
|
|
76
|
+
return lease
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} key
|
|
81
|
+
* @param {FileWatcherLease} [expectedLease]
|
|
82
|
+
*/
|
|
83
|
+
async close(key, expectedLease) {
|
|
84
|
+
const entry = this.entries.get(key)
|
|
85
|
+
if (!entry) return
|
|
86
|
+
if (expectedLease && entry.lease !== expectedLease) return
|
|
87
|
+
this.entries.delete(key)
|
|
88
|
+
await entry.watcher.close()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async closeAll() {
|
|
92
|
+
const entries = [...this.entries.values()]
|
|
93
|
+
this.entries.clear()
|
|
94
|
+
await Promise.allSettled(entries.map(entry => entry.watcher.close()))
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const fileWatcherRegistry = /** @type {FileWatcherRegistry} */ (
|
|
99
|
+
globalStore[registrySymbol] ||= new FileWatcherRegistry()
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
export default fileWatcherRegistry
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import platform from './platform/index.js'
|
|
2
|
+
|
|
3
|
+
const logger = /** @type {import('./platform/types.js').PlatformLogger} */ (new Proxy({}, {
|
|
4
|
+
get(_target, prop) {
|
|
5
|
+
if (typeof prop === 'symbol') return undefined
|
|
6
|
+
const value = platform.logger?.[prop]
|
|
7
|
+
return typeof value === 'function' ? value.bind(platform.logger) : value
|
|
8
|
+
},
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
export default logger
|