From f2575c2207838eede0e949e2bdda8b7c35e76a7c Mon Sep 17 00:00:00 2001 From: yuki Date: Fri, 16 Dec 2022 16:33:26 +0900 Subject: [PATCH] feat: refactor --- .gitignore | 1 - README.md | 41 ++++++- package.json | 17 +-- pnpm-lock.yaml | 305 +++++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 74 ++++++++---- src/service.ts | 70 +++++++----- src/types.ts | 9 -- tsconfig.json | 114 +++--------------- 8 files changed, 463 insertions(+), 168 deletions(-) create mode 100644 pnpm-lock.yaml delete mode 100644 src/types.ts diff --git a/.gitignore b/.gitignore index 3e83bc8..3b4e8dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ lib/ node_modules/ -package-lock.json diff --git a/README.md b/README.md index e2fa62c..ad1e79d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ # kokkoro-plugin-saucenao -Locating image sources + +> SauceNAO 图片搜索 + +## 安装 + +```shell +# 切换至 bot 目录 +cd bot + +# 安装 npm 包 +npm i kokkoro-plugin-saucenao +``` + +## 配置项 + +```typescript +interface SaucenaoOption extends Option { + /** 结果返回数 */ + results: number; + /** 数据库索引数组,例如只搜索 Pixiv [5] */ + mask: number[]; + /** 数据库索引(结果排除) */ + excludeMask: number[]; + /** 测试模式 */ + testMode: boolean; + /** 搜索特定数据库索引而不必生成掩码 */ + db: number; + /** 最低相似度,低于该数值的略缩图将会和谐 */ + similarity: number; +} +``` + +## 环境变量 + +你可以在项目根目录下创建 `.env` 文件 + +```ini +# API key +SAUCENAO_API_KEY=3d14159265358979323846264338327950288419 +``` diff --git a/package.json b/package.json index 619afd7..d5cb136 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "kokkoro-plugin-saucenao", - "version": "0.0.1", - "description": "Locating image sources", - "main": "./lib/index.js", + "version": "1.0.0", + "description": "SauceNAO 图片搜索", + "main": "lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -13,18 +13,21 @@ "keywords": [ "kokkoro" ], - "author": "yuki", + "author": "yuki ", "license": "MIT", "bugs": { "url": "https://github.com/kokkorojs/kokkoro-plugin-saucenao/issues" }, "homepage": "https://github.com/kokkorojs/kokkoro-plugin-saucenao#readme", "devDependencies": { - "@types/node": "^17.0.23", - "kokkoro": "^0.3.0" + "@types/node": "^18.11.15", + "kokkoro": "^1.2.9" }, "files": [ "lib", "images" - ] + ], + "dependencies": { + "sagiri": "^3.2.4" + } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..a19336f --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,305 @@ +lockfileVersion: 5.4 + +specifiers: + '@types/node': ^18.11.15 + kokkoro: ^1.2.9 + sagiri: ^3.2.4 + +dependencies: + sagiri: 3.2.4 + +devDependencies: + '@types/node': 18.11.15 + kokkoro: 1.2.9 + +packages: + + /@types/node/18.11.15: + resolution: {integrity: sha512-VkhBbVo2+2oozlkdHXLrb3zjsRkpdnaU2bXmX8Wgle3PUi569eLRaHGlgETQHR7lLL1w7GiG3h9SnePhxNDecw==} + dev: true + + /asynckit/0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + + /axios/0.27.2: + resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} + dependencies: + follow-redirects: 1.15.2 + form-data: 4.0.0 + transitivePeerDependencies: + - debug + dev: true + + /bent/7.3.12: + resolution: {integrity: sha512-T3yrKnVGB63zRuoco/7Ybl7BwwGZR0lceoVG5XmQyMIH9s19SV5m+a8qam4if0zQuAmOQTyPTPmsQBdAorGK3w==} + dependencies: + bytesish: 0.4.4 + caseless: 0.12.0 + is-stream: 2.0.1 + dev: false + + /bytesish/0.4.4: + resolution: {integrity: sha512-i4uu6M4zuMUiyfZN4RU2+i9+peJh//pXhd9x1oSe1LBkZ3LEbCoygu8W0bXTukU1Jme2txKuotpCZRaC3FLxcQ==} + dev: false + + /caseless/0.12.0: + resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==} + dev: false + + /combined-stream/1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + dependencies: + delayed-stream: 1.0.0 + + /cron/2.1.0: + resolution: {integrity: sha512-Hq7u3P8y7UWYvsZbSKHHJDVG0VO9O7tp2qljxzTScelcTODBfCme8AIhnZsFwmQ9NchZ3hr2uNr+s3DSms7q6w==} + dependencies: + luxon: 1.28.0 + dev: true + + /date-format/4.0.14: + resolution: {integrity: sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==} + engines: {node: '>=4.0'} + dev: true + + /debug/2.6.9: + resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.0.0 + dev: true + + /debug/3.2.7: + resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.3 + dev: true + + /debug/4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + + /delayed-stream/1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + + /dotenv/16.0.3: + resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + engines: {node: '>=12'} + dev: true + + /flatted/3.2.7: + resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} + dev: true + + /follow-redirects/1.15.2: + resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: true + + /form-data/4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + + /fs-extra/8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + dependencies: + graceful-fs: 4.2.10 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: true + + /graceful-fs/4.2.10: + resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} + dev: true + + /iconv-lite/0.4.24: + resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} + engines: {node: '>=0.10.0'} + dependencies: + safer-buffer: 2.1.2 + dev: true + + /is-stream/2.0.1: + resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} + engines: {node: '>=8'} + dev: false + + /jsonfile/4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + optionalDependencies: + graceful-fs: 4.2.10 + dev: true + + /kokkoro/1.2.9: + resolution: {integrity: sha512-RiCnC/rT9+DUpqMZ4pQQHQQ3nVKQuYPPnv/FqsEkL8e9jMbL9BbHa00k5n1VgNfSpD3AFtSA4/KWDOztBr+8mg==} + engines: {node: '>= v15'} + dependencies: + cron: 2.1.0 + dotenv: 16.0.3 + oicq: 2.3.1 + transitivePeerDependencies: + - debug + - supports-color + dev: true + + /lodash.merge/4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + dev: true + + /log4js/6.7.1: + resolution: {integrity: sha512-lzbd0Eq1HRdWM2abSD7mk6YIVY0AogGJzb/z+lqzRk+8+XJP+M6L1MS5FUSc3jjGru4dbKjEMJmqlsoYYpuivQ==} + engines: {node: '>=8.0'} + dependencies: + date-format: 4.0.14 + debug: 4.3.4 + flatted: 3.2.7 + rfdc: 1.3.0 + streamroller: 3.1.3 + transitivePeerDependencies: + - supports-color + dev: true + + /long/4.0.0: + resolution: {integrity: sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==} + dev: true + + /luxon/1.28.0: + resolution: {integrity: sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==} + dev: true + + /mime-db/1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + + /mime-types/2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + + /ms/2.0.0: + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} + dev: true + + /ms/2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + + /ms/2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + dev: true + + /needle/2.9.1: + resolution: {integrity: sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==} + engines: {node: '>= 4.4.x'} + hasBin: true + dependencies: + debug: 3.2.7 + iconv-lite: 0.4.24 + sax: 1.2.4 + transitivePeerDependencies: + - supports-color + dev: true + + /oicq/2.3.1: + resolution: {integrity: sha512-mRw/GgdRKFMylnrlnnywzCIwvad6fF5E4WZfIlval070wEc3w9yMV49i9epFltWkU/JGNMDS4t5wWdZEYzW0EQ==} + engines: {node: '>= v14'} + dependencies: + axios: 0.27.2 + log4js: 6.7.1 + long: 4.0.0 + pngjs: 6.0.0 + probe-image-size: 7.2.3 + transitivePeerDependencies: + - debug + - supports-color + dev: true + + /pngjs/6.0.0: + resolution: {integrity: sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==} + engines: {node: '>=12.13.0'} + dev: true + + /probe-image-size/7.2.3: + resolution: {integrity: sha512-HubhG4Rb2UH8YtV4ba0Vp5bQ7L78RTONYu/ujmCu5nBI8wGv24s4E9xSKBi0N1MowRpxk76pFCpJtW0KPzOK0w==} + dependencies: + lodash.merge: 4.6.2 + needle: 2.9.1 + stream-parser: 0.3.1 + transitivePeerDependencies: + - supports-color + dev: true + + /rfdc/1.3.0: + resolution: {integrity: sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==} + dev: true + + /safer-buffer/2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + dev: true + + /sagiri/3.2.4: + resolution: {integrity: sha512-5e3xZZ/GYXTBpUyTaQ0avUKnwG64CQk3TNUhr+2EX7X1S+45zLCBUF6AJsV4+RS7j8o9xk9f9YMp16lCv+yfNA==} + engines: {node: '>=12'} + dependencies: + bent: 7.3.12 + debug: 4.3.4 + form-data: 4.0.0 + transitivePeerDependencies: + - supports-color + dev: false + + /sax/1.2.4: + resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + dev: true + + /stream-parser/0.3.1: + resolution: {integrity: sha512-bJ/HgKq41nlKvlhccD5kaCr/P+Hu0wPNKPJOH7en+YrJu/9EgqUF+88w5Jb6KNcjOFMhfX4B2asfeAtIGuHObQ==} + dependencies: + debug: 2.6.9 + transitivePeerDependencies: + - supports-color + dev: true + + /streamroller/3.1.3: + resolution: {integrity: sha512-CphIJyFx2SALGHeINanjFRKQ4l7x2c+rXYJ4BMq0gd+ZK0gi4VT8b+eHe2wi58x4UayBAKx4xtHpXT/ea1cz8w==} + engines: {node: '>=8.0'} + dependencies: + date-format: 4.0.14 + debug: 4.3.4 + fs-extra: 8.1.0 + transitivePeerDependencies: + - supports-color + dev: true + + /universalify/0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + dev: true diff --git a/src/index.ts b/src/index.ts index afe7c95..0850542 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,32 +1,64 @@ -import { Plugin } from 'kokkoro'; -import { searchImage } from './service'; -import { SaucenaoOption } from './types'; +import { Plugin, Option, Scanner, segment, ImageElem } from 'kokkoro'; +import { SaucenaoService } from './service'; + +export interface SaucenaoOption extends Option { + /** 结果返回数 */ + results: number; + /** 数据库索引数组,例如只搜索 Pixiv [5] */ + mask: number[]; + /** 数据库索引(结果排除) */ + excludeMask: number[]; + /** 测试模式 */ + testMode: boolean; + /** 搜索特定数据库索引而不必生成掩码 */ + db: number; + /** 最低相似度,低于该数值的略缩图将会和谐 */ + similarity: number; +} const option: SaucenaoOption = { apply: true, lock: false, + results: 5, + mask: [], + excludeMask: [], + testMode: false, db: 999, - output_type: 2, - testmode: 1, - numres: 3, - minSimilarity: 50, + similarity: 50, }; -export const plugin = new Plugin('saucenao', option).version(require('../package.json').version); +const { version } = require('../package.json'); + +const plugin = new Plugin('saucenao', option); +const service = new SaucenaoService(plugin.logger, process.env.SAUCENAO_API_KEY); + +plugin + .version(version) plugin .command('search', 'group') .sugar(/^搜图$/) - .action(function () { - const scanner = this.createScanner(); - - this.reply(`请发送你要搜索的图片 (●'◡'●)`); - scanner.nextImage(this.event.sender.user_id, (image) => { - searchImage(image.url!, this.option as SaucenaoOption) - .then((search_info) => { - this.reply(search_info); - }) - .catch(error => { - this.reply(error.message); - }) - }) + .action(async (ctx) => { + const { bot, option } = ctx; + const scanner = new Scanner(bot); + + await ctx.reply(`请发送你要搜索的图片 (●'◡'●)`); + + const { url } = await scanner.nextImage(ctx.sender.user_id) as ImageElem; + const results = await service.searchImage(url!, option as SaucenaoOption); + const results_length = results.length; + const forwardMessage = []; + + for (let i = 0; i < results_length; i++) { + const result = results[i]; + const { site, similarity, thumbnail, authorName, url } = result; + const message = { + message: [`平台:${site}\n封面:`, '\n', segment.image(thumbnail), `相似度:${similarity}\n作者:${authorName}\n来源:${url}`], + user_id: ctx.self_id, + nickname: bot.nickname, + }; + forwardMessage.push(message); + } + await bot + .makeForwardMsg(forwardMessage) + .then(xml => ctx.reply(xml)) }) diff --git a/src/service.ts b/src/service.ts index 03029a9..b25ff81 100644 --- a/src/service.ts +++ b/src/service.ts @@ -1,39 +1,51 @@ -import axios from 'axios'; import { join } from 'path'; -import { getApiKey } from 'kokkoro'; -import { segment } from 'kokkoro/lib/util'; -import { SaucenaoOption } from './types'; +import { Logger } from 'kokkoro'; +import { Readable } from 'stream'; +import sagiri, { SagiriResult, Options } from 'sagiri'; -const key = getApiKey('saucenao'); -const api = 'https://saucenao.com/search.php'; -const images_path = join(__dirname, '../images'); +import { SaucenaoOption } from '.'; -export async function searchImage(url: string, option: SaucenaoOption) { - if (!key) { - throw new Error('你没有添加 apikey ,saucenao 服务将无法使用'); - } - url = url.indexOf('?') > -1 ? url.match(/.+(?=\?)/g)![0] : url; +type File = string | Buffer | Readable; +const xcw = join(__dirname, '../images/h.jpg'); - const { db, output_type, testmode, numres, minSimilarity } = option; - const params = `?db=${db}&output_type=${output_type}&testmode=${testmode}&numres=${numres}&api_key=${key}&url=${url}`; +export class SaucenaoService { + /** API */ + api: string; + client?: (file: File, optionOverrides?: Options) => Promise; - try { - const response = await axios.get(api + params); - const { results } = response.data; - const search_message: any[] = []; + constructor( + /** 日志 */ + private logger: Logger, + /** API key */ + private api_key?: string, + ) { + this.api = 'https://saucenao.com/search.php'; + this.client = this.api_key ? sagiri(this.api_key) : undefined; - for (const result of results) { - const { header: { similarity, thumbnail, index_name }, data } = result; - const cover = similarity > minSimilarity - ? segment.image(thumbnail) - : segment.image(join(images_path, 'h.jpg')); + if (!this.api_key) { + this.logger.warn('你没有添加 api key ,saucenao 服务将无法正常使用'); + } + } - search_message.push(`平台:${index_name.match(/(?<=: ).*(?=\ -)/g)}\n封面:`); - search_message.push(cover); - search_message.push(`\n相似:${similarity}%\n${data.ext_urls ? `地址:${data.ext_urls.join('\n')}` : `日文:${data.jp_name}\n英语:${data.eng_name}`}\n\n`); + async searchImage(url: string, option: SaucenaoOption) { + if (!this.client) { + throw new Error('你没有添加 api key ,saucenao 服务将无法正常使用'); } - return search_message; - } catch (error) { - throw error; + const options: Options = { + results: (option).results, + mask: (option).mask, + excludeMask: (option).excludeMask, + testMode: (option).testMode, + db: (option).db, + }; + const results = await this.client(url, options); + + results.map((result) => { + if (result.similarity < option.similarity) { + result.thumbnail = xcw; + } + return result; + }); + return results; } } diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index 50370af..0000000 --- a/src/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Option } from 'kokkoro'; - -export interface SaucenaoOption extends Option { - db: number; - output_type: number; - testmode: number; - numres: number; - minSimilarity: number; -} diff --git a/tsconfig.json b/tsconfig.json index 916037c..c02c134 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,102 +1,16 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - "rootDir": "./src", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "resolveJsonModule": true, /* Enable importing .json files */ - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./lib", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - "include": ["src"] -} + "target": "ES2022", + "lib": [ + "ES2022" + ], + "module": "commonjs", + "rootDir": "src", + "moduleResolution": "node", + "outDir": "lib", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } +} \ No newline at end of file