From b7299ea2ccc5beb349921ab6b3bc58e71472f125 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 19 Apr 2023 20:18:42 +0200 Subject: [PATCH] npm types package --- packages/vencord-types/.gitignore | 2 + packages/vencord-types/.npmignore | 2 + packages/vencord-types/README.md | 11 ++ packages/vencord-types/index.d.ts | 5 + packages/vencord-types/package.json | 26 ++++ packages/vencord-types/prepare.ts | 31 ++++ pnpm-lock.yaml | 232 +++++++++++++++------------- pnpm-workspace.yaml | 2 + src/modules.d.ts | 2 +- src/plugins/highResAvatars.ts | 37 +++++ 10 files changed, 242 insertions(+), 108 deletions(-) create mode 100644 packages/vencord-types/.gitignore create mode 100644 packages/vencord-types/.npmignore create mode 100644 packages/vencord-types/README.md create mode 100644 packages/vencord-types/index.d.ts create mode 100644 packages/vencord-types/package.json create mode 100644 packages/vencord-types/prepare.ts create mode 100644 pnpm-workspace.yaml create mode 100644 src/plugins/highResAvatars.ts diff --git a/packages/vencord-types/.gitignore b/packages/vencord-types/.gitignore new file mode 100644 index 00000000..de4d1f00 --- /dev/null +++ b/packages/vencord-types/.gitignore @@ -0,0 +1,2 @@ +dist +node_modules diff --git a/packages/vencord-types/.npmignore b/packages/vencord-types/.npmignore new file mode 100644 index 00000000..ff179ca7 --- /dev/null +++ b/packages/vencord-types/.npmignore @@ -0,0 +1,2 @@ +node_modules +prepare.ts diff --git a/packages/vencord-types/README.md b/packages/vencord-types/README.md new file mode 100644 index 00000000..0513f870 --- /dev/null +++ b/packages/vencord-types/README.md @@ -0,0 +1,11 @@ +# Vencord Types + +Typings for Vencord's api, published to npm + +```sh +npm i @vencord/types + +yarn add @vencord/types + +pnpm add @vencord/types +``` diff --git a/packages/vencord-types/index.d.ts b/packages/vencord-types/index.d.ts new file mode 100644 index 00000000..dcb52546 --- /dev/null +++ b/packages/vencord-types/index.d.ts @@ -0,0 +1,5 @@ +/* eslint-disable */ + +/// +/// +/// diff --git a/packages/vencord-types/package.json b/packages/vencord-types/package.json new file mode 100644 index 00000000..547d5d31 --- /dev/null +++ b/packages/vencord-types/package.json @@ -0,0 +1,26 @@ +{ + "name": "@vencord/types", + "private": false, + "version": "0.1.0", + "description": "", + "types": "index.d.ts", + "scripts": { + "prepublishOnly": "tsx ./prepare.ts", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "Vencord", + "license": "GPL-3.0", + "devDependencies": { + "tsx": "^3.12.6" + }, + "dependencies": { + "@types/lodash": "^4.14.191", + "@types/node": "^18.11.18", + "@types/react": "^18.0.27", + "@types/react-dom": "^18.0.10", + "discord-types": "^1.3.26", + "standalone-electron-types": "^1.0.0", + "type-fest": "^3.5.3" + } +} diff --git a/packages/vencord-types/prepare.ts b/packages/vencord-types/prepare.ts new file mode 100644 index 00000000..f278204d --- /dev/null +++ b/packages/vencord-types/prepare.ts @@ -0,0 +1,31 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { cpSync, rmSync } from "fs"; +import { join } from "path"; + +for (const file of ["preload.d.ts", "userplugins", "main", "debug"]) { + rmSync(join(__dirname, "dist", file), { recursive: true, force: true }); +} + +for (const file of ["globals.d.ts", "modules.d.ts"]) { + cpSync( + join(__dirname, "..", "..", "src", file), + join(__dirname, "dist", file) + ); +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73d29a53..148de6c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,102 +8,132 @@ patchedDependencies: hash: 7wc6icvgtg3uswirb5tpsbjnbe path: patches/eslint@8.28.0.patch -dependencies: - '@vap/core': - specifier: 0.0.12 - version: 0.0.12 - '@vap/shiki': - specifier: 0.10.3 - version: 0.10.3 - fflate: - specifier: ^0.7.4 - version: 0.7.4 - nanoid: - specifier: ^4.0.2 - version: 4.0.2 - virtual-merge: - specifier: ^1.0.1 - version: 1.0.1 +importers: -devDependencies: - '@types/diff': - specifier: ^5.0.2 - version: 5.0.2 - '@types/lodash': - specifier: ^4.14.191 - version: 4.14.191 - '@types/node': - specifier: ^18.11.18 - version: 18.11.18 - '@types/react': - specifier: ^18.0.27 - version: 18.0.27 - '@types/react-dom': - specifier: ^18.0.10 - version: 18.0.10 - '@types/yazl': - specifier: ^2.4.2 - version: 2.4.2 - '@typescript-eslint/eslint-plugin': - specifier: ^5.49.0 - version: 5.49.0(@typescript-eslint/parser@5.49.0)(eslint@8.28.0)(typescript@4.9.4) - '@typescript-eslint/parser': - specifier: ^5.49.0 - version: 5.49.0(eslint@8.28.0)(typescript@4.9.4) - diff: - specifier: ^5.1.0 - version: 5.1.0 - discord-types: - specifier: ^1.3.26 - version: 1.3.26 - esbuild: - specifier: ^0.15.18 - version: 0.15.18 - eslint: - specifier: ^8.28.0 - version: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) - eslint-import-resolver-alias: - specifier: ^1.1.2 - version: 1.1.2 - eslint-plugin-header: - specifier: ^3.1.1 - version: 3.1.1(eslint@8.28.0) - eslint-plugin-path-alias: - specifier: ^1.0.0 - version: 1.0.0(patch_hash=m6sma4g6bh67km3q6igf6uxaja)(eslint@8.28.0) - eslint-plugin-simple-import-sort: - specifier: ^8.0.0 - version: 8.0.0(eslint@8.28.0) - eslint-plugin-unused-imports: - specifier: ^2.0.0 - version: 2.0.0(@typescript-eslint/eslint-plugin@5.49.0)(eslint@8.28.0) - highlight.js: - specifier: 10.6.0 - version: 10.6.0 - moment: - specifier: ^2.29.4 - version: 2.29.4 - puppeteer-core: - specifier: ^19.6.0 - version: 19.6.0 - standalone-electron-types: - specifier: ^1.0.0 - version: 1.0.0 - stylelint: - specifier: ^14.16.1 - version: 14.16.1 - stylelint-config-standard: - specifier: ^29.0.0 - version: 29.0.0(stylelint@14.16.1) - tsx: - specifier: ^3.12.6 - version: 3.12.6 - type-fest: - specifier: ^3.5.3 - version: 3.5.3 - typescript: - specifier: ^4.9.4 - version: 4.9.4 + .: + dependencies: + '@vap/core': + specifier: 0.0.12 + version: 0.0.12 + '@vap/shiki': + specifier: 0.10.3 + version: 0.10.3 + fflate: + specifier: ^0.7.4 + version: 0.7.4 + nanoid: + specifier: ^4.0.2 + version: 4.0.2 + virtual-merge: + specifier: ^1.0.1 + version: 1.0.1 + devDependencies: + '@types/diff': + specifier: ^5.0.2 + version: 5.0.2 + '@types/lodash': + specifier: ^4.14.191 + version: 4.14.191 + '@types/node': + specifier: ^18.11.18 + version: 18.11.18 + '@types/react': + specifier: ^18.0.27 + version: 18.0.27 + '@types/react-dom': + specifier: ^18.0.10 + version: 18.0.10 + '@types/yazl': + specifier: ^2.4.2 + version: 2.4.2 + '@typescript-eslint/eslint-plugin': + specifier: ^5.49.0 + version: 5.49.0(@typescript-eslint/parser@5.49.0)(eslint@8.28.0)(typescript@4.9.4) + '@typescript-eslint/parser': + specifier: ^5.49.0 + version: 5.49.0(eslint@8.28.0)(typescript@4.9.4) + diff: + specifier: ^5.1.0 + version: 5.1.0 + discord-types: + specifier: ^1.3.26 + version: 1.3.26 + esbuild: + specifier: ^0.15.18 + version: 0.15.18 + eslint: + specifier: ^8.28.0 + version: 8.28.0(patch_hash=7wc6icvgtg3uswirb5tpsbjnbe) + eslint-import-resolver-alias: + specifier: ^1.1.2 + version: 1.1.2 + eslint-plugin-header: + specifier: ^3.1.1 + version: 3.1.1(eslint@8.28.0) + eslint-plugin-path-alias: + specifier: ^1.0.0 + version: 1.0.0(patch_hash=m6sma4g6bh67km3q6igf6uxaja)(eslint@8.28.0) + eslint-plugin-simple-import-sort: + specifier: ^8.0.0 + version: 8.0.0(eslint@8.28.0) + eslint-plugin-unused-imports: + specifier: ^2.0.0 + version: 2.0.0(@typescript-eslint/eslint-plugin@5.49.0)(eslint@8.28.0) + highlight.js: + specifier: 10.6.0 + version: 10.6.0 + moment: + specifier: ^2.29.4 + version: 2.29.4 + puppeteer-core: + specifier: ^19.6.0 + version: 19.6.0 + standalone-electron-types: + specifier: ^1.0.0 + version: 1.0.0 + stylelint: + specifier: ^14.16.1 + version: 14.16.1 + stylelint-config-standard: + specifier: ^29.0.0 + version: 29.0.0(stylelint@14.16.1) + tsx: + specifier: ^3.12.6 + version: 3.12.6 + type-fest: + specifier: ^3.5.3 + version: 3.5.3 + typescript: + specifier: ^4.9.4 + version: 4.9.4 + + packages/vencord-types: + dependencies: + '@types/lodash': + specifier: ^4.14.191 + version: 4.14.191 + '@types/node': + specifier: ^18.11.18 + version: 18.11.18 + '@types/react': + specifier: ^18.0.27 + version: 18.0.27 + '@types/react-dom': + specifier: ^18.0.10 + version: 18.0.10 + discord-types: + specifier: ^1.3.26 + version: 1.3.26 + standalone-electron-types: + specifier: ^1.0.0 + version: 1.0.0 + type-fest: + specifier: ^3.5.3 + version: 3.5.3 + devDependencies: + tsx: + specifier: ^3.12.6 + version: 3.12.6 packages: @@ -444,7 +474,6 @@ packages: /@types/lodash@4.14.191: resolution: {integrity: sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==} - dev: true /@types/minimist@1.2.2: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} @@ -452,7 +481,6 @@ packages: /@types/node@18.11.18: resolution: {integrity: sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==} - dev: true /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} @@ -464,20 +492,17 @@ packages: /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} - dev: true /@types/react-dom@18.0.10: resolution: {integrity: sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==} dependencies: '@types/react': 18.0.27 - dev: true /@types/react@17.0.2: resolution: {integrity: sha512-Xt40xQsrkdvjn1EyWe1Bc0dJLcil/9x2vAuW7ya+PuQip4UYUaXyhzWmAbwRsdMgwOFHpfp7/FFZebDU6Y8VHA==} dependencies: '@types/prop-types': 15.7.5 csstype: 3.1.0 - dev: true /@types/react@18.0.27: resolution: {integrity: sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==} @@ -485,11 +510,9 @@ packages: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.2 csstype: 3.1.0 - dev: true /@types/scheduler@0.16.2: resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} - dev: true /@types/semver@7.3.13: resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==} @@ -980,7 +1003,6 @@ packages: /csstype@3.1.0: resolution: {integrity: sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==} - dev: true /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} @@ -1070,7 +1092,6 @@ packages: dependencies: '@types/react': 17.0.2 moment: 2.29.4 - dev: true /doctrine@3.0.0: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} @@ -2262,7 +2283,6 @@ packages: /moment@2.29.4: resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} - dev: true /ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} @@ -2828,7 +2848,6 @@ packages: resolution: {integrity: sha512-0HOi/tlTz3mjWhsAz4uRbpQcHMZ+ifj1JzWW9nugykOHClBBG77ps8QinrzX1eow4Iw2pnC+RFaSYRgufF4BOg==} dependencies: '@types/node': 18.11.18 - dev: true /static-extend@0.1.2: resolution: {integrity: sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==} @@ -3098,7 +3117,6 @@ packages: /type-fest@3.5.3: resolution: {integrity: sha512-V2+og4j/rWReWvaFrse3s9g2xvUv/K9Azm/xo6CjIuq7oeGqsoimC7+9/A3tfvNcbQf8RPSVj/HV81fB4DJrjA==} engines: {node: '>=14.16'} - dev: true /typescript@4.9.4: resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 00000000..9bec5ba5 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - packages/* diff --git a/src/modules.d.ts b/src/modules.d.ts index d75a84f7..dee20cbe 100644 --- a/src/modules.d.ts +++ b/src/modules.d.ts @@ -20,7 +20,7 @@ /// declare module "~plugins" { - const plugins: Record; + const plugins: Record; export default plugins; } diff --git a/src/plugins/highResAvatars.ts b/src/plugins/highResAvatars.ts new file mode 100644 index 00000000..5687466e --- /dev/null +++ b/src/plugins/highResAvatars.ts @@ -0,0 +1,37 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "HighResImages", + description: "Makes Discord use higher resolution versions of images (pfps, emotes, etc)", + authors: [Devs.Ven], + + patches: [ + { + find: 'command:"tenor"', + replacement: { + // resolution list. Simply removes everything smaller than 512 + match: /=\[16,20,22.+?,(512,.+?3072,4096)\]/, + replace: "=[$1]" + } + } + ] +});