From d79254ab6c27f5780013cb8be24301f22294f499 Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Wed, 14 Aug 2024 22:09:02 +0000 Subject: [PATCH] chore: remove useless depedency --- package.json | 7 +- pnpm-lock.yaml | 147 ------------------------------------- src/api/api.ts | 12 +-- src/api/utils/constants.ts | 5 -- src/client/httpclient.ts | 24 +----- 5 files changed, 4 insertions(+), 191 deletions(-) diff --git a/package.json b/package.json index bc5788b..054b299 100644 --- a/package.json +++ b/package.json @@ -10,20 +10,16 @@ "deps/**" ], "scripts": { - "build": "npm run clean && tsc --outDir ./lib", + "build": "tsc --outDir ./lib", "prepublishOnly": "npm run build", "prepare": "npm run build && husky", "lint": "biome lint --write ./src", "format": "biome format --write ./src", - "clean": "rimraf ./lib", "check-h": "biome check --write ./src", "check": "biome check --write --no-errors-on-unmatched ./src" }, "author": "MARCROCK22", "license": "Apache-2.0", - "dependencies": { - "magic-bytes.js": "^1.10.0" - }, "lint-staged": { "*.ts": [ "biome check --write" @@ -36,7 +32,6 @@ "@types/node": "^20.14.11", "husky": "^9.1.1", "lint-staged": "^15.2.7", - "rimraf": "5.0.9", "typescript": "^5.5.3" }, "optionalDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81d7718..e305838 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,10 +7,6 @@ settings: importers: .: - dependencies: - magic-bytes.js: - specifier: ^1.10.0 - version: 1.10.0 optionalDependencies: chokidar: specifier: ^3.6.0 @@ -43,9 +39,6 @@ importers: lint-staged: specifier: ^15.2.7 version: 15.2.7 - rimraf: - specifier: 5.0.9 - version: 5.0.9 typescript: specifier: ^5.5.3 version: 5.5.3 @@ -189,14 +182,6 @@ packages: '@ioredis/commands@1.2.0': resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} - '@isaacs/cliui@8.0.2': - resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} - engines: {node: '>=12'} - - '@pkgjs/parseargs@0.11.0': - resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} - engines: {node: '>=14'} - '@types/conventional-commits-parser@5.0.0': resolution: {integrity: sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ==} @@ -244,16 +229,10 @@ packages: array-ify@1.0.0: resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==} - balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} - brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} @@ -368,18 +347,12 @@ packages: resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} engines: {node: '>=8'} - eastasianwidth@0.2.0: - resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - emoji-regex@10.3.0: resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - emoji-regex@9.2.2: - resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - env-paths@2.2.1: resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} engines: {node: '>=6'} @@ -416,10 +389,6 @@ packages: resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==} engines: {node: '>=18'} - foreground-child@3.2.1: - resolution: {integrity: sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==} - engines: {node: '>=14'} - fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -446,10 +415,6 @@ packages: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} - glob@10.4.5: - resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} - hasBin: true - global-directory@4.0.1: resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} engines: {node: '>=18'} @@ -528,9 +493,6 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - jackspeak@3.4.3: - resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} - jiti@1.21.6: resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==} hasBin: true @@ -609,12 +571,6 @@ packages: resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==} engines: {node: '>=18'} - lru-cache@10.4.3: - resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} - - magic-bytes.js@1.10.0: - resolution: {integrity: sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==} - meow@12.1.1: resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} engines: {node: '>=16.10'} @@ -634,17 +590,9 @@ packages: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} - minimatch@9.0.5: - resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} - engines: {node: '>=16 || 14 >=14.17'} - minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - minipass@7.1.2: - resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} - engines: {node: '>=16 || 14 >=14.17'} - ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} @@ -672,9 +620,6 @@ packages: resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - package-json-from-dist@1.0.0: - resolution: {integrity: sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==} - parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -695,10 +640,6 @@ packages: resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} engines: {node: '>=12'} - path-scurry@1.11.1: - resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} - engines: {node: '>=16 || 14 >=14.18'} - picocolors@1.0.1: resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==} @@ -746,11 +687,6 @@ packages: rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} - rimraf@5.0.9: - resolution: {integrity: sha512-3i7b8OcswU6CpU8Ej89quJD4O98id7TtVM5U4Mybh84zQXdrFmDLouWBEEaD/QfO3gDDfH+AGFCGsR7kngzQnA==} - engines: {node: 14 >=14.20 || 16 >=16.20 || >=18} - hasBin: true - semver@7.6.3: resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} engines: {node: '>=10'} @@ -794,10 +730,6 @@ packages: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} - string-width@5.1.2: - resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} - engines: {node: '>=12'} - string-width@7.2.0: resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==} engines: {node: '>=18'} @@ -857,10 +789,6 @@ packages: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} - wrap-ansi@8.1.0: - resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} - engines: {node: '>=12'} - wrap-ansi@9.0.0: resolution: {integrity: sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==} engines: {node: '>=18'} @@ -1051,18 +979,6 @@ snapshots: '@ioredis/commands@1.2.0': optional: true - '@isaacs/cliui@8.0.2': - dependencies: - string-width: 5.1.2 - string-width-cjs: string-width@4.2.3 - strip-ansi: 7.1.0 - strip-ansi-cjs: strip-ansi@6.0.1 - wrap-ansi: 8.1.0 - wrap-ansi-cjs: wrap-ansi@7.0.0 - - '@pkgjs/parseargs@0.11.0': - optional: true - '@types/conventional-commits-parser@5.0.0': dependencies: '@types/node': 20.14.11 @@ -1109,15 +1025,9 @@ snapshots: array-ify@1.0.0: {} - balanced-match@1.0.2: {} - binary-extensions@2.3.0: optional: true - brace-expansion@2.0.1: - dependencies: - balanced-match: 1.0.2 - braces@3.0.3: dependencies: fill-range: 7.1.1 @@ -1234,14 +1144,10 @@ snapshots: dependencies: is-obj: 2.0.0 - eastasianwidth@0.2.0: {} - emoji-regex@10.3.0: {} emoji-regex@8.0.0: {} - emoji-regex@9.2.2: {} - env-paths@2.2.1: {} error-ex@1.3.2: @@ -1280,11 +1186,6 @@ snapshots: path-exists: 5.0.0 unicorn-magic: 0.1.0 - foreground-child@3.2.1: - dependencies: - cross-spawn: 7.0.3 - signal-exit: 4.1.0 - fsevents@2.3.3: optional: true @@ -1305,15 +1206,6 @@ snapshots: is-glob: 4.0.3 optional: true - glob@10.4.5: - dependencies: - foreground-child: 3.2.1 - jackspeak: 3.4.3 - minimatch: 9.0.5 - minipass: 7.1.2 - package-json-from-dist: 1.0.0 - path-scurry: 1.11.1 - global-directory@4.0.1: dependencies: ini: 4.1.1 @@ -1383,12 +1275,6 @@ snapshots: isexe@2.0.0: {} - jackspeak@3.4.3: - dependencies: - '@isaacs/cliui': 8.0.2 - optionalDependencies: - '@pkgjs/parseargs': 0.11.0 - jiti@1.21.6: {} js-tokens@4.0.0: {} @@ -1467,10 +1353,6 @@ snapshots: strip-ansi: 7.1.0 wrap-ansi: 9.0.0 - lru-cache@10.4.3: {} - - magic-bytes.js@1.10.0: {} - meow@12.1.1: {} merge-stream@2.0.0: {} @@ -1484,14 +1366,8 @@ snapshots: mimic-fn@4.0.0: {} - minimatch@9.0.5: - dependencies: - brace-expansion: 2.0.1 - minimist@1.2.8: {} - minipass@7.1.2: {} - ms@2.1.2: {} normalize-path@3.0.0: @@ -1517,8 +1393,6 @@ snapshots: dependencies: p-limit: 4.0.0 - package-json-from-dist@1.0.0: {} - parent-module@1.0.1: dependencies: callsites: 3.1.0 @@ -1536,11 +1410,6 @@ snapshots: path-key@4.0.0: {} - path-scurry@1.11.1: - dependencies: - lru-cache: 10.4.3 - minipass: 7.1.2 - picocolors@1.0.1: {} picomatch@2.3.1: {} @@ -1575,10 +1444,6 @@ snapshots: rfdc@1.4.1: {} - rimraf@5.0.9: - dependencies: - glob: 10.4.5 - semver@7.6.3: {} shebang-command@2.0.0: @@ -1614,12 +1479,6 @@ snapshots: is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - string-width@5.1.2: - dependencies: - eastasianwidth: 0.2.0 - emoji-regex: 9.2.2 - strip-ansi: 7.1.0 - string-width@7.2.0: dependencies: emoji-regex: 10.3.0 @@ -1670,12 +1529,6 @@ snapshots: string-width: 4.2.3 strip-ansi: 6.0.1 - wrap-ansi@8.1.0: - dependencies: - ansi-styles: 6.2.1 - string-width: 5.1.2 - strip-ansi: 7.1.0 - wrap-ansi@9.0.0: dependencies: ansi-styles: 6.2.1 diff --git a/src/api/api.ts b/src/api/api.ts index 710b267..1942df5 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,4 +1,3 @@ -import { filetypemime } from 'magic-bytes.js'; import { randomUUID } from 'node:crypto'; import { Logger, delay, lazyLoadPackage } from '../common'; import { snowflakeToTimestamp } from '../structures/extra/functions'; @@ -8,7 +7,6 @@ import { CDNRouter, type ProxyRequestMethod } from './Router'; import { Bucket } from './bucket'; import { DefaultUserAgent, - OverwrittenMimeTypes, type ApiHandlerInternalOptions, type ApiHandlerOptions, type ApiRequestOptions, @@ -350,15 +348,7 @@ export class ApiHandler { const fileKey = file.key ?? `files[${index}]`; if (isBufferLike(file.data)) { - let contentType = file.contentType; - - if (!contentType) { - const mime = filetypemime(Buffer.from(file.data))[0]; - - contentType = - OverwrittenMimeTypes[mime as keyof typeof OverwrittenMimeTypes] ?? mime ?? 'application/octet-stream'; - } - + const contentType = file.contentType; formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name); } else { formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name); diff --git a/src/api/utils/constants.ts b/src/api/utils/constants.ts index 2b2dd20..d6b146d 100644 --- a/src/api/utils/constants.ts +++ b/src/api/utils/constants.ts @@ -6,8 +6,3 @@ export const ALLOWED_SIZES = [16, 32, 64, 100, 128, 256, 512, 1_024, 2_048, 4_09 export type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number]; export type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number]; export type ImageSize = (typeof ALLOWED_SIZES)[number]; - -export const OverwrittenMimeTypes = { - // https://github.com/discordjs/discord.js/issues/8557 - 'image/apng': 'image/png', -} as const satisfies Readonly>; diff --git a/src/client/httpclient.ts b/src/client/httpclient.ts index a1cd9ac..25645c2 100644 --- a/src/client/httpclient.ts +++ b/src/client/httpclient.ts @@ -1,7 +1,5 @@ import { type APIInteractionResponse, InteractionResponseType, InteractionType, type APIInteraction } from '../types'; -import { filetypemime } from 'magic-bytes.js'; import type { HttpRequest, HttpResponse } from 'uWebSockets.js'; -import { OverwrittenMimeTypes } from '../api'; import { isBufferLike } from '../api/utils/utils'; import { MergeOptions, isCloudfareWorker, type DeepPartial } from '../common'; import type { BaseClientOptions, InternalRuntimeConfigHTTP, StartOptions } from './base'; @@ -171,16 +169,7 @@ export class HttpClient extends BaseClient { for (const [index, file] of files.entries()) { const fileKey = file.key ?? `files[${index}]`; if (isBufferLike(file.data)) { - let contentType = file.contentType; - - if (!contentType) { - const mime = filetypemime(Buffer.from(file.data))[0]; - - contentType = - OverwrittenMimeTypes[mime as keyof typeof OverwrittenMimeTypes] ?? - mime ?? - 'application/octet-stream'; - } + const contentType = file.contentType; response.append(fileKey, new Blob([file.data], { type: contentType }), file.name); } else { response.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name); @@ -227,16 +216,7 @@ export class HttpClient extends BaseClient { for (const [index, file] of files.entries()) { const fileKey = file.key ?? `files[${index}]`; if (isBufferLike(file.data)) { - let contentType = file.contentType; - - if (!contentType) { - const mime = filetypemime(Buffer.from(file.data))[0]; - - contentType = - OverwrittenMimeTypes[mime as keyof typeof OverwrittenMimeTypes] ?? - mime ?? - 'application/octet-stream'; - } + const contentType = file.contentType; response.append(fileKey, new Blob([file.data], { type: contentType }), file.name); } else { response.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);