Compare commits

...

12 Commits

Author SHA1 Message Date
手瓜一十雪
5dc33e78ad Add napiloader scripts and binaries, update Vite config
Introduces napiloader batch scripts and binaries (napiloader.dll, napimain.exe) for Windows integration. Updates vite.config.ts to include napiloader files in the Framework build output and refactors plugin target lists for improved distribution packaging.
2025-11-09 12:54:15 +08:00
Mlikiowa
d76a2170a0 release: v4.9.32 2025-11-08 04:26:49 +00:00
手瓜一十雪
ec2af3120c Refactor FFmpeg file conversion logic and API
Unified file conversion in FFmpegAddonAdapter to use decodeAudioToFmt for all formats, updated FFmpeg interface and service to support new conversion method, and added adapter name checks in GetRecord and DownloadFileRecordStream for optimized conversion flow. Updated native addon binaries to support these changes.
2025-11-08 12:22:51 +08:00
Mlikiowa
8de49a3109 release: v4.9.30 2025-11-08 02:30:01 +00:00
手瓜一十雪
dbb5a0022e Update ffmpeg native binaries for all platforms
Replaces ffmpegAddon binaries for Darwin ARM64, Linux ARM64, Linux x64, and Windows x64 with new versions. Ensures compatibility and includes latest native changes.
2025-11-08 10:28:59 +08:00
Mlikiowa
cb8c8d6b57 release: v4.9.29 2025-11-07 12:01:08 +00:00
手瓜一十雪
93c140ed4e Improve error message for group notice image upload
Enhanced the error message when group notice image upload fails to include the error details from the upload API response.
2025-11-07 20:00:17 +08:00
手瓜一十雪
457b072f0e Update NTQQ build version check to 41679
Changed the minimum NTQQ build version required for buddy list operations from 40990 to 41679 in NTQQFriendApi. Ensures compatibility with newer NTQQ builds.
2025-11-07 19:57:07 +08:00
手瓜一十雪
1869493473 Update getBuddyV2ExWithCate for NTQQ build compatibility
Modified getBuddyV2ExWithCate to conditionally call getBuddyListV2 with an extra boolean argument for NTQQ builds >= 40990, ensuring compatibility with different API signatures.
2025-11-07 19:50:11 +08:00
Mlikiowa
f33c66ce15 release: v4.9.28 2025-11-07 11:35:58 +00:00
手瓜一十雪
e8d6f86458 feat: 修复一些问题 2025-11-07 19:35:35 +08:00
手瓜一十雪
a000ffdf0d fix: buddylist 2025-11-07 19:29:39 +08:00
25 changed files with 355 additions and 258 deletions

4
.gitignore vendored
View File

@@ -14,4 +14,6 @@ devconfig/*
*.db
checkVersion.sh
bun.lockb
tests/run/
tests/run/
guild1.db-wal
guild1.db-shm

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.9.27",
"version": "4.9.32",
"icon": "./logo.png",
"authors": [
{

View File

@@ -0,0 +1,30 @@
@echo off
chcp 65001
set NAPCAT_INJECT_PATH=%cd%\napiloader.dll
set NAPCAT_LAUNCHER_PATH=%cd%\napimain.exe
set NAPCAT_MAIN_PATH=%cd%\nativeLoader.cjs
set NAPCAT_DEBUG_CONSOLE=1
:loop_read
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do (
set "RetString=%%~b"
goto :napcat_boot
)
:napcat_boot
for %%a in ("%RetString%") do (
set "pathWithoutUninstall=%%~dpa"
)
set "QQPath=%pathWithoutUninstall%QQ.exe"
if not exist "%QQpath%" (
echo provided QQ path is invalid
pause
exit /b
)
set NAPCAT_MAIN_PATH=%NAPCAT_MAIN_PATH:\=/%
"%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%" "%NAPCAT_MAIN_PATH%"
pause

27
napiloader/napiLoader.bat Normal file
View File

@@ -0,0 +1,27 @@
@echo off
chcp 65001
set NAPCAT_INJECT_PATH=%cd%\napiloader.dll
set NAPCAT_LAUNCHER_PATH=%cd%\napimain.exe
set NAPCAT_MAIN_PATH=%cd%\nativeLoader.cjs
:loop_read
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do (
set "RetString=%%~b"
goto :napcat_boot
)
:napcat_boot
for %%a in ("%RetString%") do (
set "pathWithoutUninstall=%%~dpa"
)
set "QQPath=%pathWithoutUninstall%QQ.exe"
if not exist "%QQpath%" (
echo provided QQ path is invalid
pause
exit /b
)
set NAPCAT_MAIN_PATH=%NAPCAT_MAIN_PATH:\=/%
start "" "%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%" "%NAPCAT_MAIN_PATH%"

BIN
napiloader/napiloader.dll Normal file

Binary file not shown.

BIN
napiloader/napimain.exe Normal file

Binary file not shown.

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.9.27",
"version": "4.9.32",
"scripts": {
"build:universal": "npm run build:webui && npm run dev:universal || exit 1",
"build:framework": "npm run build:webui && npm run dev:framework || exit 1",

View File

@@ -68,11 +68,13 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
const addon = this.ensureAddon();
const info = await addon.getVideoInfo(videoPath, 'bmp24');
let format = info.format.includes(',') ? info.format.split(',')[0] ?? info.format : info.format;
console.log('[FFmpegAddonAdapter] Detected format:', format);
return {
width: info.width,
height: info.height,
duration: info.duration,
format: info.format,
format: format,
thumbnail: info.image,
};
}
@@ -88,7 +90,7 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
/**
* 转换为 PCM
*/
async convertToPCM (filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
async convertToPCM (filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number; }> {
const addon = this.ensureAddon();
const result = await addon.decodeAudioToPCM(filePath, pcmPath, 24000);
@@ -100,13 +102,8 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
*/
async convertFile (inputFile: string, outputFile: string, format: string): Promise<void> {
const addon = this.ensureAddon();
if (format === 'silk' || format === 'ntsilk') {
// 使用 Addon 的 NTSILK 转换
await addon.convertToNTSilkTct(inputFile, outputFile);
} else {
throw new Error(`Format '${format}' is not supported by FFmpeg Addon`);
}
console.log('[FFmpegAddonAdapter] Converting file:', inputFile, 'to', outputFile, 'as', format);
await addon.decodeAudioToFmt(inputFile, outputFile, format);
}
/**

View File

@@ -49,23 +49,25 @@ export interface AudioPCMResult {
* FFmpeg interface providing all audio/video processing methods
*/
export interface FFmpeg {
convertFile (inputFile: string, outputFile: string, format: string): Promise<{ success: boolean; }>;
/**
* Get video information including resolution, duration, format, codec and first frame thumbnail
*/
getVideoInfo(filePath: string, format?: 'bmp' | 'bmp24'): Promise<VideoInfo>;
getVideoInfo (filePath: string, format?: 'bmp' | 'bmp24'): Promise<VideoInfo>;
/**
* Get duration of audio or video file in seconds
*/
getDuration(filePath: string): Promise<number>;
getDuration (filePath: string): Promise<number>;
/**
* Convert audio file to NTSILK format (WeChat voice message format)
*/
convertToNTSilkTct(inputPath: string, outputPath: string): Promise<void>;
convertToNTSilkTct (inputPath: string, outputPath: string): Promise<void>;
/**
* Decode audio file to raw PCM data
*/
decodeAudioToPCM(filePath: string, pcmPath: string, sampleRate?: number): Promise<{ result: boolean, sampleRate: number }>;
decodeAudioToPCM (filePath: string, pcmPath: string, sampleRate?: number): Promise<{ result: boolean, sampleRate: number; }>;
decodeAudioToFmt (filePath: string, pcmPath: string, format: string): Promise<{ channels: number; sampleRate: number; format: string; }>;
}

View File

@@ -48,6 +48,14 @@ export class FFmpegService {
this.initialized = true;
}
public static getAdapterName (): string {
if (!this.adapter) {
throw new Error('FFmpeg service not initialized. Please call FFmpegService.init() first.');
}
return this.adapter.name;
}
/**
* 获取 FFmpeg 适配器
*/

View File

@@ -1 +1 @@
export const napCatVersion = '4.9.27';
export const napCatVersion = '4.9.32';

View File

@@ -17,8 +17,14 @@ export class NTQQFriendApi {
async getBuddyV2SimpleInfoMap () {
const buddyService = this.context.session.getBuddyService();
const buddyListV2 = await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
const uids = buddyListV2.data.flatMap(item => item.buddyUids);
let uids: string[] = [];
if (this.core.context.basicInfoWrapper.requireMinNTQQBuild('41679')) {
const buddyListV2NT = await buddyService.getBuddyListV2('0', true, BuddyListReqType.KNOMAL);
uids = buddyListV2NT.data.flatMap(item => item.buddyUids);
} else {
const buddyListV2 = await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
uids = buddyListV2.data.flatMap(item => item.buddyUids);
}
return await this.core.eventWrapper.callNoListenerEvent(
'NodeIKernelProfileService/getCoreAndBaseInfo',
'nodeStore',
@@ -47,10 +53,15 @@ export class NTQQFriendApi {
async getBuddyV2ExWithCate () {
const buddyService = this.context.session.getBuddyService();
const buddyListV2 = (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
const uids = buddyListV2.flatMap(item => {
return item.buddyUids;
});
let uids: string[] = [];
let buddyListV2: Awaited<ReturnType<typeof buddyService.getBuddyListV2>>['data'];
if (this.core.context.basicInfoWrapper.requireMinNTQQBuild('41679')) {
buddyListV2 = (await buddyService.getBuddyListV2('0', true, BuddyListReqType.KNOMAL)).data;
uids = buddyListV2.flatMap(item => item.buddyUids);
} else {
buddyListV2 = (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
uids = buddyListV2.flatMap(item => item.buddyUids);
}
const data = await this.core.eventWrapper.callNoListenerEvent(
'NodeIKernelProfileService/getCoreAndBaseInfo',
'nodeStore',

View File

@@ -3,122 +3,133 @@ import { NodeIKernelBuddyListener } from '@/core/listeners';
import { BuddyListReqType } from '@/core/types/user';
export interface NodeIKernelBuddyService {
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
getBuddyListV2 (callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
data: Array<{
categoryId: number,
categorySortId: number,
categroyName: string,
categroyMbCount: number,
onlineCount: number,
buddyUids: Array<string>
}>
buddyUids: Array<string>;
}>;
}>;
getBuddyListV2 (callFrom: string, isPullRefresh: boolean, reqType: BuddyListReqType): Promise<GeneralCallResult & {
data: Array<{
categoryId: number,
categorySortId: number,
categroyName: string,
categroyMbCount: number,
onlineCount: number,
buddyUids: Array<string>;
}>;
}>;
getBuddyListFromCache(reqType: BuddyListReqType): Promise<Array<
{
categoryId: number, // 9999为特别关心
categorySortId: number, // 排序方式
categroyName: string, // 分类名
categroyMbCount: number, // 不懂
onlineCount: number, // 在线数目
buddyUids: Array<string>// Uids
}>>;
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
getBuddyListFromCache (reqType: BuddyListReqType): Promise<Array<
{
categoryId: number, // 9999为特别关心
categorySortId: number, // 排序方式
categroyName: string, // 分类名
categroyMbCount: number, // 不懂
onlineCount: number, // 在线数目
buddyUids: Array<string>;// Uids
}>>;
getAllBuddyCount(): number;
addKernelBuddyListener (listener: NodeIKernelBuddyListener): number;
removeKernelBuddyListener(listenerId: number): void;
getAllBuddyCount (): number;
removeKernelBuddyListener (listenerId: number): void;
// getBuddyList(nocache: boolean): Promise<GeneralCallResult>;
getBuddyNick(uid: number): string;
getBuddyNick (uid: number): string;
getBuddyRemark(uid: number): string;
getBuddyRemark (uid: number): string;
setBuddyRemark(param: { uid: string, remark: string, signInfo?: unknown }): void;
setBuddyRemark (param: { uid: string, remark: string, signInfo?: unknown; }): void;
getAvatarUrl(uid: number): string;
getAvatarUrl (uid: number): string;
isBuddy(uid: string): boolean;
isBuddy (uid: string): boolean;
getCategoryNameWithUid(uid: number): string;
getCategoryNameWithUid (uid: number): string;
getTargetBuddySetting(uid: number): unknown;
getTargetBuddySetting (uid: number): unknown;
getTargetBuddySettingByType(uid: number, type: number): unknown;
getTargetBuddySettingByType (uid: number, type: number): unknown;
getBuddyReqUnreadCnt(): number;
getBuddyReqUnreadCnt (): number;
getBuddyReq(): Promise<GeneralCallResult>;
getBuddyReq (): Promise<GeneralCallResult>;
delBuddyReq(uid: number): void;
delBuddyReq (uid: number): void;
clearBuddyReqUnreadCnt(): Promise<GeneralCallResult>;
clearBuddyReqUnreadCnt (): Promise<GeneralCallResult>;
reqToAddFriends(uid: number, msg: string): void;
reqToAddFriends (uid: number, msg: string): void;
setSpacePermission(uid: number, permission: number): void;
setSpacePermission (uid: number, permission: number): void;
approvalFriendRequest(arg: {
approvalFriendRequest (arg: {
friendUid: string;
reqTime: string;
accept: boolean;
}): Promise<void>;
delBuddy(param: {
delBuddy (param: {
friendUid: string;
tempBlock: boolean;
tempBothDel: boolean;
}): Promise<unknown>;
delBatchBuddy(uids: number[]): void;
delBatchBuddy (uids: number[]): void;
getSmartInfos(uid: number): unknown;
getSmartInfos (uid: number): unknown;
setBuddyCategory(uid: number, category: number): void;
setBuddyCategory (uid: number, category: number): void;
setBatchBuddyCategory(uids: number[], category: number): void;
setBatchBuddyCategory (uids: number[], category: number): void;
addCategory(category: string): void;
addCategory (category: string): void;
delCategory(category: string): void;
delCategory (category: string): void;
renameCategory(oldCategory: string, newCategory: string): void;
renameCategory (oldCategory: string, newCategory: string): void;
resortCategory(categorys: string[]): void;
resortCategory (categorys: string[]): void;
pullCategory(uid: number, category: string): void;
pullCategory (uid: number, category: string): void;
setTop(uid: number, isTop: boolean): void;
setTop (uid: number, isTop: boolean): void;
SetSpecialCare(uid: number, isSpecialCare: boolean): void;
SetSpecialCare (uid: number, isSpecialCare: boolean): void;
setMsgNotify(uid: number, isNotify: boolean): void;
setMsgNotify (uid: number, isNotify: boolean): void;
hasBuddyList(): boolean;
hasBuddyList (): boolean;
setBlock(uid: number, isBlock: boolean): void;
setBlock (uid: number, isBlock: boolean): void;
isBlocked(uid: number): boolean;
isBlocked (uid: number): boolean;
modifyAddMeSetting(setting: unknown): void;
modifyAddMeSetting (setting: unknown): void;
getAddMeSetting(): unknown;
getAddMeSetting (): unknown;
getDoubtBuddyReq(reqId: string, num: number, uk:string): Promise<GeneralCallResult>;
getDoubtBuddyReq (reqId: string, num: number, uk: string): Promise<GeneralCallResult>;
getDoubtBuddyUnreadNum(): number;
getDoubtBuddyUnreadNum (): number;
approvalDoubtBuddyReq(uid: string, str1: string, str2: string): void;
approvalDoubtBuddyReq (uid: string, str1: string, str2: string): void;
delDoubtBuddyReq(uid: number): void;
delDoubtBuddyReq (uid: number): void;
delAllDoubtBuddyReq(): Promise<GeneralCallResult>;
delAllDoubtBuddyReq (): Promise<GeneralCallResult>;
reportDoubtBuddyReqUnread(): void;
reportDoubtBuddyReqUnread (): void;
getBuddyRecommendContactArkJson(uid: string, phoneNumber: string): Promise<GeneralCallResult & { arkMsg: string }>;
getBuddyRecommendContactArkJson (uid: string, phoneNumber: string): Promise<GeneralCallResult & { arkMsg: string; }>;
isNull(): boolean;
isNull (): boolean;
}

View File

@@ -7,7 +7,7 @@ import { FFmpegService } from '@/common/ffmpeg';
const out_format = ['mp3', 'amr', 'wma', 'm4a', 'spx', 'ogg', 'wav', 'flac'];
type Payload = {
out_format: string
out_format: string;
} & GetFilePayload;
export default class GetRecord extends GetFileBase {
@@ -28,8 +28,12 @@ export default class GetRecord extends GetFileBase {
try {
await fs.access(outputFile);
} catch {
await this.decodeFile(inputFile, pcmFile);
await FFmpegService.convertFile(pcmFile, outputFile, payload.out_format);
if (FFmpegService.getAdapterName() === 'FFmpegAddon') {
await FFmpegService.convertFile(inputFile, outputFile, payload.out_format);
} else {
await this.decodeFile(inputFile, pcmFile);
await FFmpegService.convertFile(pcmFile, outputFile, payload.out_format);
}
}
const base64Data = await fs.readFile(outputFile, { encoding: 'base64' });
res.file = outputFile;

View File

@@ -37,7 +37,7 @@ export class SendGroupNotice extends OneBotAction<Payload, null> {
await checkFileExist(path, 5000);
const ImageUploadResult = await this.core.apis.GroupApi.uploadGroupBulletinPic(payload.group_id.toString(), path);
if (ImageUploadResult.errCode !== 0) {
throw new Error(`群公告${payload.image}设置失败,图片上传失败`);
throw new Error(`群公告${payload.image}设置失败,图片上传失败 错误信息:${ImageUploadResult.errMsg}`);
}
unlink(path).catch(() => { });

View File

@@ -47,8 +47,12 @@ export class DownloadFileRecordStream extends BaseDownloadStream<Payload, Downlo
streamPath = outputFile;
} catch {
// 尝试解码 silk 到 pcm 再用 ffmpeg 转换
await this.decodeFile(downloadPath, pcmFile);
await FFmpegService.convertFile(pcmFile, outputFile, payload.out_format);
if (FFmpegService.getAdapterName() === 'FFmpegAddon') {
await FFmpegService.convertFile(downloadPath, outputFile, payload.out_format);
} else {
await this.decodeFile(downloadPath, pcmFile);
await FFmpegService.convertFile(pcmFile, outputFile, payload.out_format);
}
streamPath = outputFile;
}
}

Binary file not shown.

View File

@@ -6,204 +6,205 @@ import { builtinModules } from 'module';
import { performanceMonitorPlugin } from './vite-plugin-performance-monitor';
//依赖排除
const external = [
'silk-wasm',
'ws',
'express'
'silk-wasm',
'ws',
'express'
];
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
let startScripts: string[] | undefined = undefined;
if (process.env.NAPCAT_BUILDSYS == 'linux') {
startScripts = [];
startScripts = [];
} else if (process.env.NAPCAT_BUILDSYS == 'win32') {
startScripts = ['./script/KillQQ.bat'];
startScripts = ['./script/KillQQ.bat'];
} else {
startScripts = ['./script/KillQQ.bat'];
startScripts = ['./script/KillQQ.bat'];
}
const UniversalBaseConfigPlugin: PluginOption[] = [
// performanceMonitorPlugin({
// enabled: process.env.NODE_ENV !== 'production',
// exclude: [/node_modules/, /\.min\./, /performance-monitor/],
// include: [/\.ts$/, /\.js$/]
// }),
cp({
targets: [
{ src: './manifest.json', dest: 'dist' },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './src/native/', dest: 'dist/native', flatten: false },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
{ src: './src/framework/liteloader.cjs', dest: 'dist' },
{ src: './src/framework/napcat.cjs', dest: 'dist' },
{ src: './src/framework/preload.cjs', dest: 'dist' },
{ src: './src/framework/renderer.js', dest: 'dist' },
{ src: './package.json', dest: 'dist' },
{ src: './logo.png', dest: 'dist' },
{ src: './launcher/', dest: 'dist', flatten: true },
...startScripts.map((startScript) => {
return { src: startScript, dest: 'dist' };
}),
],
}),
nodeResolve(),
// performanceMonitorPlugin({
// enabled: process.env.NODE_ENV !== 'production',
// exclude: [/node_modules/, /\.min\./, /performance-monitor/],
// include: [/\.ts$/, /\.js$/]
// }),
cp({
targets: [
{ src: './manifest.json', dest: 'dist' },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './src/native/', dest: 'dist/native', flatten: false },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
{ src: './src/framework/liteloader.cjs', dest: 'dist' },
{ src: './src/framework/napcat.cjs', dest: 'dist' },
{ src: './src/framework/preload.cjs', dest: 'dist' },
{ src: './src/framework/renderer.js', dest: 'dist' },
{ src: './package.json', dest: 'dist' },
{ src: './logo.png', dest: 'dist' },
{ src: './launcher/', dest: 'dist', flatten: true },
...startScripts.map((startScript) => {
return { src: startScript, dest: 'dist' };
}),
],
}),
nodeResolve(),
];
const FrameworkBaseConfigPlugin: PluginOption[] = [
// performanceMonitorPlugin({
// enabled: process.env.NODE_ENV !== 'production',
// exclude: [/node_modules/, /\.min\./, /performance-monitor/],
// include: [/\.ts$/, /\.js$/]
// }),
cp({
targets: [
{ src: './src/native/', dest: 'dist/native', flatten: false },
{ src: './manifest.json', dest: 'dist' },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
{ src: './src/framework/liteloader.cjs', dest: 'dist' },
{ src: './src/framework/napcat.cjs', dest: 'dist' },
{ src: './src/framework/nativeLoader.cjs', dest: 'dist' },
{ src: './src/framework/preload.cjs', dest: 'dist' },
{ src: './src/framework/renderer.js', dest: 'dist' },
{ src: './package.json', dest: 'dist' },
{ src: './logo.png', dest: 'dist' },
],
}),
nodeResolve(),
// performanceMonitorPlugin({
// enabled: process.env.NODE_ENV !== 'production',
// exclude: [/node_modules/, /\.min\./, /performance-monitor/],
// include: [/\.ts$/, /\.js$/]
// }),
cp({
targets: [
{ src: './napiloader/', dest: 'dist', flatten: true },
{ src: './src/native/', dest: 'dist/native', flatten: false },
{ src: './manifest.json', dest: 'dist' },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
{ src: './src/framework/liteloader.cjs', dest: 'dist' },
{ src: './src/framework/napcat.cjs', dest: 'dist' },
{ src: './src/framework/nativeLoader.cjs', dest: 'dist' },
{ src: './src/framework/preload.cjs', dest: 'dist' },
{ src: './src/framework/renderer.js', dest: 'dist' },
{ src: './package.json', dest: 'dist' },
{ src: './logo.png', dest: 'dist' },
],
}),
nodeResolve(),
];
const ShellBaseConfigPlugin: PluginOption[] = [
// performanceMonitorPlugin({
// enabled: process.env.NODE_ENV !== 'production',
// exclude: [/node_modules/, /\.min\./, /performance-monitor/],
// include: [/\.ts$/, /\.js$/]
// }),
cp({
targets: [
{ src: './src/native/', dest: 'dist/native', flatten: false },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './package.json', dest: 'dist' },
{ src: './launcher/', dest: 'dist', flatten: true },
...startScripts.map((startScript) => {
return { src: startScript, dest: 'dist' };
}),
],
}),
nodeResolve(),
// performanceMonitorPlugin({
// enabled: process.env.NODE_ENV !== 'production',
// exclude: [/node_modules/, /\.min\./, /performance-monitor/],
// include: [/\.ts$/, /\.js$/]
// }),
cp({
targets: [
{ src: './src/native/', dest: 'dist/native', flatten: false },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './package.json', dest: 'dist' },
{ src: './launcher/', dest: 'dist', flatten: true },
...startScripts.map((startScript) => {
return { src: startScript, dest: 'dist' };
}),
],
}),
nodeResolve(),
];
const UniversalBaseConfig = () =>
defineConfig({
resolve: {
conditions: ['node', 'default'],
alias: {
'@/core': resolve(__dirname, './src/core'),
'@': resolve(__dirname, './src'),
'@webapi': resolve(__dirname, './src/webui/src'),
},
defineConfig({
resolve: {
conditions: ['node', 'default'],
alias: {
'@/core': resolve(__dirname, './src/core'),
'@': resolve(__dirname, './src'),
'@webapi': resolve(__dirname, './src/webui/src'),
},
},
build: {
sourcemap: false,
target: 'esnext',
minify: false,
lib: {
entry: {
napcat: 'src/universal/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
'worker/conoutSocketWorker': 'src/pty/worker/conoutSocketWorker.ts',
},
build: {
sourcemap: false,
target: 'esnext',
minify: false,
lib: {
entry: {
napcat: 'src/universal/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
'worker/conoutSocketWorker': 'src/pty/worker/conoutSocketWorker.ts',
},
formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
},
},
});
formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
},
},
});
const ShellBaseConfig = () =>
defineConfig({
resolve: {
conditions: ['node', 'default'],
alias: {
'@/core': resolve(__dirname, './src/core'),
'@': resolve(__dirname, './src'),
'@webapi': resolve(__dirname, './src/webui/src'),
},
defineConfig({
resolve: {
conditions: ['node', 'default'],
alias: {
'@/core': resolve(__dirname, './src/core'),
'@': resolve(__dirname, './src'),
'@webapi': resolve(__dirname, './src/webui/src'),
},
},
build: {
sourcemap: false,
target: 'esnext',
minify: false,
lib: {
entry: {
napcat: 'src/shell/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
'worker/conoutSocketWorker': 'src/pty/worker/conoutSocketWorker.ts',
},
build: {
sourcemap: false,
target: 'esnext',
minify: false,
lib: {
entry: {
napcat: 'src/shell/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
'worker/conoutSocketWorker': 'src/pty/worker/conoutSocketWorker.ts',
},
formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
},
},
});
formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
},
},
});
const FrameworkBaseConfig = () =>
defineConfig({
resolve: {
conditions: ['node', 'default'],
alias: {
'@/core': resolve(__dirname, './src/core'),
'@': resolve(__dirname, './src'),
'@webapi': resolve(__dirname, './src/webui/src'),
},
defineConfig({
resolve: {
conditions: ['node', 'default'],
alias: {
'@/core': resolve(__dirname, './src/core'),
'@': resolve(__dirname, './src'),
'@webapi': resolve(__dirname, './src/webui/src'),
},
},
build: {
sourcemap: false,
target: 'esnext',
minify: false,
lib: {
entry: {
napcat: 'src/framework/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
'worker/conoutSocketWorker': 'src/pty/worker/conoutSocketWorker.ts',
},
build: {
sourcemap: false,
target: 'esnext',
minify: false,
lib: {
entry: {
napcat: 'src/framework/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
'worker/conoutSocketWorker': 'src/pty/worker/conoutSocketWorker.ts',
},
formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
},
},
});
formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
},
},
});
export default defineConfig(({ mode }): UserConfig => {
if (mode === 'shell') {
return {
...ShellBaseConfig(),
plugins: [...ShellBaseConfigPlugin],
};
} else if (mode == 'universal') {
return {
...UniversalBaseConfig(),
plugins: [...UniversalBaseConfigPlugin],
};
} else if (mode == 'shell-analysis') {
return {
...ShellBaseConfig(),
plugins: [
performanceMonitorPlugin({
exclude: [/node_modules/, /\.min\./, /performance-monitor\.ts$/, /packet/],
include: [/\.ts$/, /\.js$/]
}),
...ShellBaseConfigPlugin
],
};
} else
return {
...FrameworkBaseConfig(),
plugins: [...FrameworkBaseConfigPlugin],
};
if (mode === 'shell') {
return {
...ShellBaseConfig(),
plugins: [...ShellBaseConfigPlugin],
};
} else if (mode == 'universal') {
return {
...UniversalBaseConfig(),
plugins: [...UniversalBaseConfigPlugin],
};
} else if (mode == 'shell-analysis') {
return {
...ShellBaseConfig(),
plugins: [
performanceMonitorPlugin({
exclude: [/node_modules/, /\.min\./, /performance-monitor\.ts$/, /packet/],
include: [/\.ts$/, /\.js$/]
}),
...ShellBaseConfigPlugin
],
};
} else
return {
...FrameworkBaseConfig(),
plugins: [...FrameworkBaseConfigPlugin],
};
});