-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
11,178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
module.exports = { | ||
'root': true, | ||
'env': { | ||
'es2021': true, | ||
'node': true | ||
}, | ||
'extends': [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended' | ||
], | ||
'overrides': [ | ||
{ | ||
'env': { | ||
'node': true | ||
}, | ||
'files': [ | ||
'.eslintrc.{js,cjs}' | ||
], | ||
'parserOptions': { | ||
'sourceType': 'script' | ||
} | ||
} | ||
], | ||
'parser': '@typescript-eslint/parser', | ||
'parserOptions': { | ||
'ecmaVersion': 'latest', | ||
'sourceType': 'module' | ||
}, | ||
'plugins': [ | ||
'@typescript-eslint', | ||
'import' | ||
], | ||
'settings': { | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts'] | ||
}, | ||
'import/resolver': { | ||
'typescript': { | ||
'alwaysTryTypes': true | ||
} | ||
} | ||
}, | ||
'rules': { | ||
'indent': [ | ||
'error', | ||
2 | ||
], | ||
'linebreak-style': [ | ||
'error', | ||
'unix' | ||
], | ||
'quotes': [ | ||
'error', | ||
'single' | ||
], | ||
'semi': [ | ||
'error', | ||
'always' | ||
], | ||
'no-unused-vars': 'off', | ||
'no-async-promise-executor': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'object-curly-spacing': ['error', 'always'], | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ | ||
node_modules/ | ||
dist/ | ||
lib/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @napneko/core | ||
|
||
此仓库目前只用于隐藏源码,目前无法进行单独打包,只是作为 NapCatQQ 的 git submodule 引用。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const swc = require("@swc/core"); | ||
const glob = require('glob'); | ||
const fs = require('fs-extra'); | ||
|
||
const files = glob.sync('src/**/*.ts'); | ||
|
||
function transfrom(file) { | ||
return swc | ||
.transformFile(file, { | ||
// Some options cannot be specified in .swcrc | ||
sourceMaps: false, | ||
// Input files are treated as module by default. | ||
// isModule: false, | ||
module: { | ||
type: 'commonjs' | ||
}, | ||
|
||
// All options below can be configured via .swcrc | ||
jsc: { | ||
parser: { | ||
syntax: "typescript", | ||
decorators: true, | ||
}, | ||
transform: { | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true | ||
}, | ||
target: 'es2017' | ||
}, | ||
// "keepClassNames": true, | ||
// "loose": true | ||
}) | ||
.then((output) => { | ||
// console.log(output.code); // transformed code | ||
return { | ||
file, | ||
output | ||
} | ||
}); | ||
} | ||
|
||
(async () => { | ||
const result = await Promise.all(files.map((file) => { | ||
return transfrom(file) | ||
})); | ||
|
||
await Promise.all(result.map((item) => { | ||
return fs.outputFile(item.file.replace('src', 'dist').replace('.ts', '.js'), item.output.code) | ||
})); | ||
//console.timeEnd('swc build'); | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "@napneko/core", | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"main": "./lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"scripts": { | ||
"lint": "eslint --fix ./src/**/*.ts", | ||
"build": "npx tsc --target es2022 --experimentalDecorators && node ./scripts/obfuscator.cjs" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/NapNeko/core.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/NapNeko/core/issues" | ||
}, | ||
"homepage": "https://github.com/NapNeko/core#readme", | ||
"devDependencies": { | ||
"@babel/core": "^7.24.7", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/plugin-proposal-decorators": "^7.24.7", | ||
"@babel/preset-typescript": "^7.24.7", | ||
"@swc/core": "^1.6.1", | ||
"@types/node": "^20.12.7", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-standard-with-typescript": "^43.0.1", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-n": "^16.6.2", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"typescript": "^5.4.5", | ||
"vite": "^5.2.8", | ||
"vite-plugin-babel": "^1.2.0", | ||
"vite-plugin-dts": "^3.8.1" | ||
}, | ||
"dependencies": { | ||
"@log4js-node/log4js-api": "^1.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@napneko/core", | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"main": "./index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"scripts": { | ||
"lint": "eslint --fix ./src/**/*.ts", | ||
"build:dev": "vite build --mode development", | ||
"build:prod": "vite build --mode production", | ||
"build": "npm run build:dev" | ||
}, | ||
"author": "NapNeko", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/NapNeko/NapCatQQ/issues" | ||
}, | ||
"homepage": "https://github.com/NapNeko/NapCatQQ#readme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
let fs = require('fs'); | ||
let path = require('path'); | ||
let JavaScriptObfuscator = require('javascript-obfuscator'); | ||
|
||
const dirPath = path.join(__dirname, '../dist/core'); | ||
const outputPath = dirPath; | ||
|
||
if (!fs.existsSync(outputPath)) { | ||
fs.mkdirSync(outputPath, {recursive: true}); | ||
} | ||
|
||
function obfuscateDir(currentPath, outputDir) { | ||
fs.readdir(currentPath, {withFileTypes: true}, (err, entries) => { | ||
if (err) throw err; | ||
|
||
entries.forEach(entry => { | ||
const localBasePath = path.join(currentPath, entry.name); | ||
const outputLocalBasePath = path.join(outputDir, entry.name); | ||
|
||
if (entry.isDirectory()) { | ||
// 如果是目录,递归调用 | ||
if (!fs.existsSync(outputLocalBasePath)) { | ||
fs.mkdirSync(outputLocalBasePath, {recursive: true}); | ||
} | ||
obfuscateDir(localBasePath, outputLocalBasePath); | ||
} else if (entry.isFile() && path.extname(entry.name) === '.js') { | ||
// 如果是文件且为 .js,进行混淆 | ||
fs.readFile(localBasePath, (err, content)=>{ | ||
// console.log('read file', localBasePath); | ||
const obfuscated = JavaScriptObfuscator.obfuscate(content.toString(), { | ||
compact: true, | ||
controlFlowFlattening: true | ||
}); | ||
// console.log('obfuscate file', localBasePath); | ||
fs.writeFile(outputLocalBasePath, obfuscated.getObfuscatedCode(), ()=>{ | ||
// console.log(`[NapCat] [Obfuscator] ${localBasePath} => ${outputLocalBasePath}`); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// 开始混淆 | ||
obfuscateDir(dirPath, outputPath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { log } from "@/common/utils/log"; | ||
|
||
interface IDependsAdapter { | ||
onMSFStatusChange(arg1: number, arg2: number): void; | ||
|
||
onMSFSsoError(args: unknown): void; | ||
|
||
getGroupCode(args: unknown): void; | ||
} | ||
|
||
export interface NodeIDependsAdapter extends IDependsAdapter { | ||
// eslint-disable-next-line @typescript-eslint/no-misused-new | ||
new(adapter: IDependsAdapter): NodeIDependsAdapter; | ||
} | ||
|
||
export class DependsAdapter implements IDependsAdapter { | ||
onMSFStatusChange(arg1: number, arg2: number) { | ||
// console.log(arg1, arg2); | ||
// if (arg1 == 2 && arg2 == 2) { | ||
// log("NapCat丢失网络连接,请检查网络") | ||
// } | ||
} | ||
|
||
onMSFSsoError(args: unknown) { | ||
} | ||
|
||
getGroupCode(args: unknown) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
interface IDispatcherAdapter { | ||
dispatchRequest(arg: unknown): void; | ||
|
||
dispatchCall(arg: unknown): void; | ||
|
||
dispatchCallWithJson(arg: unknown): void; | ||
} | ||
|
||
export interface NodeIDispatcherAdapter extends IDispatcherAdapter { | ||
// eslint-disable-next-line @typescript-eslint/no-misused-new | ||
new(adapter: IDispatcherAdapter): NodeIDispatcherAdapter; | ||
} | ||
|
||
export class DispatcherAdapter implements IDispatcherAdapter { | ||
dispatchRequest(arg: unknown) { | ||
} | ||
|
||
dispatchCall(arg: unknown) { | ||
} | ||
|
||
dispatchCallWithJson(arg: unknown) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
interface IGlobalAdapter { | ||
onLog(...args: unknown[]): void; | ||
|
||
onGetSrvCalTime(...args: unknown[]): void; | ||
|
||
onShowErrUITips(...args: unknown[]): void; | ||
|
||
fixPicImgType(...args: unknown[]): void; | ||
|
||
getAppSetting(...args: unknown[]): void; | ||
|
||
onInstallFinished(...args: unknown[]): void; | ||
|
||
onUpdateGeneralFlag(...args: unknown[]): void; | ||
|
||
onGetOfflineMsg(...args: unknown[]): void; | ||
} | ||
|
||
export interface NodeIGlobalAdapter extends IGlobalAdapter { | ||
// eslint-disable-next-line @typescript-eslint/no-misused-new | ||
new(adapter: IGlobalAdapter): NodeIGlobalAdapter; | ||
} | ||
|
||
export class GlobalAdapter implements IGlobalAdapter { | ||
onLog(...args: unknown[]) { | ||
} | ||
|
||
onGetSrvCalTime(...args: unknown[]) { | ||
} | ||
|
||
onShowErrUITips(...args: unknown[]) { | ||
} | ||
|
||
fixPicImgType(...args: unknown[]) { | ||
} | ||
|
||
getAppSetting(...args: unknown[]) { | ||
} | ||
|
||
onInstallFinished(...args: unknown[]) { | ||
} | ||
|
||
onUpdateGeneralFlag(...args: unknown[]) { | ||
} | ||
|
||
onGetOfflineMsg(...args: unknown[]) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './NodeIDependsAdapter'; | ||
export * from './NodeIDispatcherAdapter'; | ||
export * from './NodeIGlobalAdapter'; |
Oops, something went wrong.