Merge branch 'feat/torrent-to-magnet' into chore/all-my-stuffs

# Conflicts:
#	components.d.ts
#	package.json
#	pnpm-lock.yaml
#	src/tools/index.ts
#	vite.config.ts
This commit is contained in:
ShareVB committed 2024-11-03 21:38:02 +01:00
commit ee341e0034
6 files changed
+224 -6

No files matched your search

+1
View File
@@ -195,6 +195,7 @@
"oui-data": "^1.0.10",
"parse-duration": "^1.1.0",
"path2d-polyfill": "^3.0.1",
"parse-torrent": "^11.0.17",
"pdf-signature-reader": "^1.4.2",
"pdfjs-dist": "^4.0.379",
"pinia": "^2.0.34",
+90 -6
View File
@@ -410,6 +410,9 @@ dependencies:
parse-duration:
specifier: ^1.1.0
version: 1.1.0
parse-torrent:
specifier: ^11.0.17
version: 11.0.17
path2d-polyfill:
specifier: ^3.0.1
version: 3.1.2
@@ -4756,6 +4759,13 @@ packages:
resolution: {integrity: sha512-nXSeUzsCOxX/Of+kdUVQfxL9bG+ck8XCWNf9dGSpE+nhVexRwk/4HiDQDxFDysfT7vfgSut6GXnrZsU5M5dSlA==}
dev: false
/@thaunknown/thirty-two@1.0.5:
resolution: {integrity: sha512-Q53KyCXweV1CS62EfqtPDqfpksn5keQ59PGqzzkK+g8Vif1jB4inoBCcs/BUSdsqddhE3G+2Fn+4RX3S6RqT0A==}
engines: {node: '>=0.2.6'}
dependencies:
uint8-util: 2.2.5
dev: false
/@tiptap/core@2.1.12(@tiptap/pm@2.1.6):
resolution: {integrity: sha512-ZGc3xrBJA9KY8kln5AYTj8y+GDrKxi7u95xIl2eccrqTY5CQeRu6HRNM1yT4mAjuSaG9jmazyjGRlQuhyxCKxQ==}
peerDependencies:
@@ -6299,7 +6309,7 @@ packages:
/@vueuse/shared@10.0.0(vue@3.3.4):
resolution: {integrity: sha512-Zh3LgJqvUBWVY3SiMvXanTcfAneGbt63QPczBRDNgQ6jd/ehodO9a1lCFzaA6SWJJoI+ugVTjHFYJdoR656DVQ==}
dependencies:
vue-demi: 0.14.5(vue@3.3.4)
vue-demi: 0.14.10(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
@@ -6350,6 +6360,13 @@ packages:
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
dev: true
/abort-controller@3.0.0:
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
engines: {node: '>=6.5'}
dependencies:
event-target-shim: 5.0.1
dev: false
/acorn-jsx@5.3.2(acorn@8.10.0):
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
@@ -6674,6 +6691,11 @@ packages:
dev: false
optional: true
/base64-arraybuffer@1.0.2:
resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==}
engines: {node: '>= 0.6.0'}
dev: false
/base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
@@ -6687,6 +6709,18 @@ packages:
resolution: {integrity: sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==}
dev: false
/bencode@4.0.0:
resolution: {integrity: sha512-AERXw18df0pF3ziGOCyUjqKZBVNH8HV3lBxnx5w0qtgMIk4a1wb9BkcCQbkp9Zstfrn/dzRwl7MmUHHocX3sRQ==}
engines: {node: '>=12.20.0'}
dependencies:
uint8-util: 2.2.5
dev: false
/bep53-range@2.0.0:
resolution: {integrity: sha512-sMm2sV5PRs0YOVk0LTKtjuIprVzxgTQUsrGX/7Yph2Rm4FO2Fqqtq7hNjsOB5xezM4v4+5rljCgK++UeQJZguA==}
engines: {node: '>=12.20.0'}
dev: false
/big.js@6.2.2:
resolution: {integrity: sha512-y/ie+Faknx7sZA5MfGA2xKlu0GDv8RWrXGsmlteyJQ2lvoKv9GBK/fpRMc2qlSoBAgNxrixICFCBefIq8WCQpQ==}
dev: false
@@ -7515,6 +7549,13 @@ packages:
resolution: {integrity: sha512-M1VdV3hpBAsd1Zzvqcvf63wgDpcwCuS4WiNEVFpJ0s33MGO2sVDTfswYq0EPypCmESrCzmgL8h68DTzJuSDbVA==}
dev: false
/cross-fetch-ponyfill@1.0.3:
resolution: {integrity: sha512-uOBkDhUAGAbx/FEzNKkOfx3w57H8xReBBXoZvUnOKTI0FW0Xvrj3GrYv2iZXUqlffC1LMGfQzhmBM/ke+6eTDA==}
dependencies:
abort-controller: 3.0.0
node-fetch: 3.3.2
dev: false
/cross-fetch@3.1.8:
resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==}
dependencies:
@@ -7686,7 +7727,6 @@ packages:
/data-uri-to-buffer@4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
dev: true
/data-urls@4.0.0:
resolution: {integrity: sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g==}
@@ -8747,6 +8787,11 @@ packages:
through: 2.3.8
dev: true
/event-target-shim@5.0.1:
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
engines: {node: '>=6'}
dev: false
/events@3.3.0:
resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}
engines: {node: '>=0.8.x'}
@@ -8891,7 +8936,6 @@ packages:
dependencies:
node-domexception: 1.0.0
web-streams-polyfill: 3.2.1
dev: true
/figlet@1.7.0:
resolution: {integrity: sha512-gO8l3wvqo0V7wEFLXPbkX83b7MVjRrk1oRLfYlZXol8nEpb/ON9pcKLI4qpBv5YtOTfrINtqb7b40iYY2FTWFg==}
@@ -9063,7 +9107,6 @@ packages:
engines: {node: '>=12.20.0'}
dependencies:
fetch-blob: 3.2.0
dev: true
/fraction.js@4.2.0:
resolution: {integrity: sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==}
@@ -9220,6 +9263,11 @@ packages:
engines: {node: '>=10'}
dev: false
/get-stdin@9.0.0:
resolution: {integrity: sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==}
engines: {node: '>=12'}
dev: false
/get-stream@6.0.1:
resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
engines: {node: '>=10'}
@@ -10932,6 +10980,15 @@ packages:
dependencies:
'@jridgewell/sourcemap-codec': 1.4.15
/magnet-uri@7.0.5:
resolution: {integrity: sha512-Ke+dDiYHK1Rq/ZyGUAgk7NIkoypivxolTj/A0qr60ypP0FjeP+NTUNEhr965HsRan0zGxKEBK73+SsjRyJWkXg==}
engines: {node: '>=12.20.0'}
dependencies:
'@thaunknown/thirty-two': 1.0.5
bep53-range: 2.0.0
uint8-util: 2.2.5
dev: false
/make-dir@2.1.0:
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
engines: {node: '>=6'}
@@ -11418,7 +11475,6 @@ packages:
/node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
dev: true
/node-fetch-native@1.4.1:
resolution: {integrity: sha512-NsXBU0UgBxo2rQLOeWNZqS3fvflWePMECr8CoSWoSTqCqGbVVsvl9vZu1HfQicYN0g5piV9Gh8RTEvo/uP752w==}
@@ -11445,6 +11501,15 @@ packages:
formdata-polyfill: 4.0.10
dev: true
/node-fetch@3.3.2:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
data-uri-to-buffer: 4.0.1
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
dev: false
/node-forge@1.3.1:
resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==}
engines: {node: '>= 6.13.0'}
@@ -11893,6 +11958,19 @@ packages:
engines: {node: '>=0.10.0'}
dev: false
/parse-torrent@11.0.17:
resolution: {integrity: sha512-bkfEtrqIMT4+bSWs+m7+Ktd7LSJsDefA9qfJQ3UFwOeBqipiQ+347guu79zX++nRwMnrdvRecLmgaRcdiYjE4w==}
engines: {node: '>=12.20.0'}
hasBin: true
dependencies:
bencode: 4.0.0
cross-fetch-ponyfill: 1.0.3
get-stdin: 9.0.0
magnet-uri: 7.0.5
queue-microtask: 1.2.3
uint8-util: 2.2.5
dev: false
/parse5@7.1.2:
resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==}
dependencies:
@@ -14139,6 +14217,12 @@ packages:
/ufo@1.3.1:
resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==}
/uint8-util@2.2.5:
resolution: {integrity: sha512-/QxVQD7CttWpVUKVPz9znO+3Dd4BdTSnFQ7pv/4drVhC9m4BaL2LFHTkJn6EsYoxT79VDq/2Gg8L0H22PrzyMw==}
dependencies:
base64-arraybuffer: 1.0.2
dev: false
/ulid@2.3.0:
resolution: {integrity: sha512-keqHubrlpvT6G2wH0OEfSW4mquYRcbe/J8NMmveoQOjUqmo+hXtO+ORCpWhdbZ7k72UtY61BL7haGxW6enBnjw==}
hasBin: true
@@ -15085,7 +15169,6 @@ packages:
/web-streams-polyfill@3.2.1:
resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==}
engines: {node: '>= 8'}
dev: true
/web-tree-sitter@0.24.3:
resolution: {integrity: sha512-uR9YNewr1S2EzPKE+y39nAwaTyobBaZRG/IsfkB/OT4v0lXtNj5WjtHKgn2h7eOYUWIZh5rK9Px7tI6S9CRKdA==}
@@ -15534,6 +15617,7 @@ packages:
/yamljs@0.3.0:
resolution: {integrity: sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==}
hasBin: true
dependencies:
argparse: 1.0.10
glob: 7.2.3
+2
View File
@@ -86,6 +86,7 @@ import { tool as potrace } from './potrace';
import { tool as rmbNumbers } from './rmb-numbers';
import { tool as sensitiveDataMasker } from './sensitive-data-masker';
import { tool as textToUnicodeNames } from './text-to-unicode-names';
import { tool as torrentToMagnet } from './torrent-to-magnet';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -273,6 +274,7 @@ export const toolsByCategory: ToolCategory[] = [
jsonToPhpArray,
phpArrayToJson,
maliciousLinksTester,
torrentToMagnet,
],
},
{
+12
View File
@@ -0,0 +1,12 @@
import { Bookmarks } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Torrent to Magnet',
path: '/torrent-to-magnet',
description: 'Convert a torrent file to a Magnet url',
keywords: ['torrent', 'magnet', 'url', 'link'],
component: () => import('./torrent-to-magnet.vue'),
icon: Bookmarks,
createdAt: new Date('2024-04-20'),
});
+4
View File
@@ -0,0 +1,4 @@
declare module 'parse-torrent'{
export default function parseTorrent(content: string | ArrayBufferView): Promise<object>;
export function toMagnetURI(parsedTorrent: object): string;
}
@@ -0,0 +1,115 @@
<script setup lang="ts">
import type { Ref } from 'vue';
import parseTorrent, { toMagnetURI } from 'parse-torrent';
import { withDefaultOnError } from '@/utils/defaults';
import { useValidation } from '@/composable/validation';
const inputType = ref<'file' | 'content'>('file');
const torrentContent = ref('');
const fileInput = ref() as Ref<File | null>;
const torrentInfosRaw = computedAsync(async () => {
const file = fileInput.value;
const content = torrentContent.value;
try {
if (inputType.value === 'file' && file) {
return await parseTorrent(new Uint8Array(await file.arrayBuffer()));
}
else {
return await parseTorrent(content);
}
}
catch (e: any) {
return {
error: e.toString(),
};
}
});
const torrentInfos = computed(() => withDefaultOnError(() => {
return Object.entries(torrentInfosRaw.value).map(([k, v]) => {
return {
label: k?.toString() || '',
value: JSON.stringify(v),
};
});
}, []));
const magnetURI = computed(() => withDefaultOnError(() => toMagnetURI(torrentInfosRaw.value), []));
async function onUpload(file: File) {
if (file) {
fileInput.value = file;
}
}
watch(torrentContent, (_, newValue) => {
if (newValue !== '') {
fileInput.value = null;
}
});
const { attrs: validationAttrs } = useValidation({
source: torrentInfos,
rules: [{ message: 'Invalid torrent content', validator: torrent => torrent?.length > 0 }],
});
</script>
<template>
<div>
<n-radio-group v-model:value="inputType" name="radiogroup" mb-2 flex justify-center>
<n-space>
<n-radio
value="file"
label="File"
/>
<n-radio
value="content"
label="Content"
/>
</n-space>
</n-radio-group>
<c-file-upload
v-if="inputType === 'file'"
title="Drag and drop torrent file here, or click to select a file"
@file-upload="onUpload"
/>
<c-input-text
v-if="inputType === 'content'"
v-model:value="torrentContent"
label="Torrent/Magnet Content"
placeholder="Paste your Torrent/Magnet content here"
multiline
mb-2
/>
<n-divider />
<input-copyable
label="Magnet URI"
label-position="left"
label-width="100px"
label-align="right"
mb-2
:value="validationAttrs.validationStatus === 'error' ? '' : magnetURI"
placeholder="Please use a correct torrent"
/>
<input-copyable
v-for="{ label, value } of torrentInfos"
:key="label"
:label="label"
label-position="left"
label-width="100px"
label-align="right"
mb-2
:value="validationAttrs.validationStatus === 'error' ? '' : value"
placeholder="Please use a correct torrent"
/>
</div>
</template>
<style lang="less" scoped>
::v-deep(.n-upload-trigger) {
width: 100%;
}
</style>