From 3c4cd3743fab5a94633538722f0029324beaaf51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 8 Aug 2024 20:57:10 +0800 Subject: [PATCH] build: liteloader Co-Authored-By: Wesley F. Young <25684570+Wesley-Young@users.noreply.github.com> --- .env.liteloader | 3 ++- .env.shell | 3 ++- manifest.json | 33 +++++++++++++++++++++++++++++++++ vite.config.ts | 37 ++++++++++++++++++++++++++++++------- 4 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 manifest.json diff --git a/.env.liteloader b/.env.liteloader index 4642c3e8..bd8b9bdf 100644 --- a/.env.liteloader +++ b/.env.liteloader @@ -1 +1,2 @@ -VITE_BUILD_TYPE = Development \ No newline at end of file +VITE_BUILD_TYPE = Production +VITE_BUILD_PLATFORM = LiteLoader \ No newline at end of file diff --git a/.env.shell b/.env.shell index 458dab00..a4b71e71 100644 --- a/.env.shell +++ b/.env.shell @@ -1 +1,2 @@ -VITE_BUILD_TYPE = Production \ No newline at end of file +VITE_BUILD_TYPE = Production +VITE_BUILD_PLATFORM = Shell \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 00000000..a76e72c3 --- /dev/null +++ b/manifest.json @@ -0,0 +1,33 @@ +{ + "manifest_version": 4, + "type": "extension", + "name": "NapCat", + "slug": "NapCat", + "description": "OneBot v11 protocol implementation with NapCat logic", + "version": "1.8.4", + "icon": "./logo.png", + "authors": [ + { + "name": "MliKiowa", + "link": "https://github.com/MliKiowa" + }, + { + "name": "Young", + "link": "https://github.com/Wesley-Young" + } + ], + "repository": { + "repo": "NapNeko/NapCatQQ", + "branch": "main" + }, + "platform": [ + "win32", + "linux", + "darwin" + ], + "injects": { + "renderer": "./renderer.cjs", + "main": "./napcat.cjs", + "preload": "./preload.cjs" + } +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 9f7632bd..13659bfb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -28,8 +28,33 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') { } else { startScripts = ['./script/BootWay05.bat', './script/BootWay05.utf8.bat', './script/dbghelp.dll', './script/BootWay05.ps1', './script/napcat.sh', './script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1', './script/napcat-9912.ps1', './script/napcat-9912-utf8.ps1', './script/napcat-9912.bat', './script/napcat-9912-utf8.bat']; } - -const baseConfigPlugin: PluginOption[] = [ +const LLBaseConfigPlugin: PluginOption[] = [ + // PreprocessorDirectives(), + babel({ + filter: /.*\.(ts|js)$/, + babelConfig: { + babelrc: false, + configFile: false, + presets: ["@babel/preset-typescript"], + plugins: [ + //'2018-09', decoratorsBeforeExport: true + ['@babel/plugin-proposal-decorators', { legacy: true }], + '@babel/plugin-proposal-class-properties', + ], + }, + }), + cp({ + targets: [ + { src: './manifest.json', dest: 'dist' }, + { src: './src/liteloader/napcat.cjs', dest: 'dist' }, + { src: './src/liteloader/preload.cjs', dest: 'dist' }, + { src: './src/liteloader/renderer.cjs', dest: 'dist' }, + { src: './logo.png', dest: 'dist' }, + ] + }), + nodeResolve(), +]; +const ShellBaseConfigPlugin: PluginOption[] = [ // PreprocessorDirectives(), babel({ filter: /.*\.(ts|js)$/, @@ -99,7 +124,7 @@ const LLBaseConfig = () => defineConfig({ target: 'esnext', minify: false, lib: { - entry: "src/liteloader/napcat.ts", + entry: "src/liteloader/napcat.ts", formats: ['es'], fileName: () => 'napcat.mjs', }, @@ -113,14 +138,12 @@ export default defineConfig(({ mode }): UserConfig => { if (mode === 'shell') { return { ...ShellBaseConfig(), - plugins: [ - ...baseConfigPlugin - ] + plugins: [...ShellBaseConfigPlugin] }; } else { return { ...LLBaseConfig(), - plugins: baseConfigPlugin, + plugins: [...LLBaseConfigPlugin], }; } });