Compare commits

..
Author SHA1 Message Date
sharevb 8659024c9b feat(new tool): Integers to IP
Fix #1187
2024-08-25 10:33:19 +02:00
21 changed files with 181 additions and 1217 deletions

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

+1 -5
View File
@@ -1,8 +1,4 @@
<picture>
<source srcset="./.github/logo-dark.png" media="(prefers-color-scheme: light)">
<source srcset="./.github/logo-white.png" media="(prefers-color-scheme: dark)">
<img src="./.github/logo-dark.png" alt="logo">
</picture>
![logo](.github/logo.png)
Useful tools for developer and people working in IT. [Have a look !](https://it-tools.tech).
+4 -10
View File
@@ -73,7 +73,6 @@ declare module '@vue/runtime-core' {
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
EmailNormalizer: typeof import('./src/tools/email-normalizer/email-normalizer.vue')['default']
EmailParser: typeof import('./src/tools/email-parser/email-parser.vue')['default']
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
EmojiPicker: typeof import('./src/tools/emoji-picker/emoji-picker.vue')['default']
@@ -104,6 +103,7 @@ declare module '@vue/runtime-core' {
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
IntegersToIp: typeof import('./src/tools/integers-to-ip/integers-to-ip.vue')['default']
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default']
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']
@@ -122,7 +122,6 @@ declare module '@vue/runtime-core' {
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
MathEvaluator: typeof import('./src/tools/math-evaluator/math-evaluator.vue')['default']
MenuBar: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar.vue')['default']
MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default']
@@ -131,25 +130,20 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NRadio: typeof import('naive-ui')['NRadio']
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpace: typeof import('naive-ui')['NSpace']
NTable: typeof import('naive-ui')['NTable']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
OutlookParser: typeof import('./src/tools/outlook-parser/outlook-parser.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
+1 -8
View File
@@ -37,13 +37,10 @@
"dependencies": {
"@it-tools/bip39": "^0.0.4",
"@it-tools/oggen": "^1.3.0",
"@kenjiuno/decompressrtf": "^0.1.4",
"@kenjiuno/msgreader": "^1.22.0",
"@sindresorhus/slugify": "^2.2.1",
"@tiptap/pm": "2.1.6",
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/markdown-it": "^13.0.7",
"@types/figlet": "^1.5.8",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
@@ -68,13 +65,12 @@
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"iconv-lite": "^0.6.3",
"ip-bigint": "^8.2.0",
"js-base64": "^3.7.6",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
"markdown-it": "^14.0.0",
"marked": "^10.0.0",
"mathjs": "^11.9.1",
"mime-types": "^2.1.35",
@@ -86,9 +82,7 @@
"pdf-signature-reader": "^1.4.2",
"pinia": "^2.0.34",
"plausible-tracker": "^0.3.8",
"postal-mime": "^2.2.7",
"qrcode": "^1.5.1",
"rtf-stream-parser": "^3.8.0",
"sql-formatter": "^13.0.0",
"ua-parser-js": "^1.0.35",
"ulid": "^2.3.0",
@@ -141,7 +135,6 @@
"unplugin-icons": "^0.17.0",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.4.9",
"vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-pwa": "^0.16.0",
"vite-plugin-vue-markdown": "^0.23.5",
"vite-svg-loader": "^4.0.0",
+13 -705
View File
File diff suppressed because it is too large. Load diff
+4 -40
View File
@@ -7,15 +7,7 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
import xmlHljs from 'highlight.js/lib/languages/xml';
import yamlHljs from 'highlight.js/lib/languages/yaml';
import iniHljs from 'highlight.js/lib/languages/ini';
import bashHljs from 'highlight.js/lib/languages/bash';
import markdownHljs from 'highlight.js/lib/languages/markdown';
import jsHljs from 'highlight.js/lib/languages/javascript';
import cssHljs from 'highlight.js/lib/languages/css';
import goHljs from 'highlight.js/lib/languages/go';
import csharpHljs from 'highlight.js/lib/languages/csharp';
import { Base64 } from 'js-base64';
import { useCopy } from '@/composable/copy';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
const props = withDefaults(
defineProps<{
@@ -24,17 +16,12 @@ const props = withDefaults(
language?: string
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
copyMessage?: string
wordWrap?: boolean
downloadFileName?: string
downloadButtonText?: string
}>(),
{
followHeightOf: null,
language: 'txt',
copyPlacement: 'top-right',
copyMessage: 'Copy to clipboard',
downloadFileName: '',
downloadButtonText: 'Download',
},
);
hljs.registerLanguage('sql', sqlHljs);
@@ -43,25 +30,12 @@ hljs.registerLanguage('html', xmlHljs);
hljs.registerLanguage('xml', xmlHljs);
hljs.registerLanguage('yaml', yamlHljs);
hljs.registerLanguage('toml', iniHljs);
hljs.registerLanguage('bash', bashHljs);
hljs.registerLanguage('markdown', markdownHljs);
hljs.registerLanguage('css', cssHljs);
hljs.registerLanguage('javascript', jsHljs);
hljs.registerLanguage('go', goHljs);
hljs.registerLanguage('csharp', csharpHljs);
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value);
const valueBase64 = computed(() => Base64.encode(value.value));
const { download } = useDownloadFileFromBase64(
{
source: valueBase64,
filename: downloadFileName,
});
</script>
<template>
@@ -73,16 +47,11 @@ const { download } = useDownloadFileFromBase64(
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
>
<n-config-provider :hljs="hljs">
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
</n-config-provider>
</n-scrollbar>
<div
v-if="value && copyPlacement !== 'none'"
absolute right-10px
:top-10px="copyPlacement === 'top-right' ? '' : 'no'"
:bottom-10px="copyPlacement === 'bottom-right' ? '' : 'no'"
>
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
<div absolute right-10px top-10px>
<c-tooltip v-if="value" :tooltip="tooltipText" position="left">
<c-button circle important:h-10 important:w-10 @click="copy()">
<n-icon size="22" :component="Copy" />
</c-button>
@@ -94,11 +63,6 @@ const { download } = useDownloadFileFromBase64(
{{ tooltipText }}
</c-button>
</div>
<div v-if="downloadFileName !== '' && value !== ''" mt-5 flex justify-center>
<c-button secondary @click="download">
{{ downloadButtonText }}
</c-button>
</div>
</div>
</template>
+14 -15
View File
@@ -1,7 +1,6 @@
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
import type { MaybeRef, Ref } from 'vue';
import type { Ref } from 'vue';
import _ from 'lodash';
import { get } from '@vueuse/core';
export {
getMimeTypeFromBase64,
@@ -76,11 +75,21 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
}
function useDownloadFileFromBase64(
{ source, filename, extension }:
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
{ source, filename, extension, fileMimeType }:
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
return {
download() {
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
},
};
}
function useDownloadFileFromBase64Refs(
{ source, filename, extension }:
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
},
};
}
@@ -107,13 +116,3 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
return img;
}
function useDownloadFileFromBase64Refs(
{ source, filename, extension }:
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
},
};
}
-152
View File
@@ -1,152 +0,0 @@
<script setup lang="ts">
import PostalMime from 'postal-mime';
const inputType = ref<'file' | 'content'>('file');
const emailContent = ref('');
const fileInput = ref() as Ref<File | null>;
const error = ref('');
const parsedEmail = computedAsync(async () => {
const emailContentValue = emailContent.value;
const file = fileInput.value;
error.value = '';
try {
if (inputType.value === 'file' && file) {
return await PostalMime.parse(await file.arrayBuffer());
}
else if (inputType.value === 'content' && emailContentValue) {
return await PostalMime.parse(emailContentValue);
}
else {
return null;
}
}
catch (e: any) {
error.value = e.toString();
return null;
}
});
function downloadFile(data: ArrayBuffer, fileName: string, fileType: string) {
const blob = new Blob([data], { type: fileType || 'application/octet-stream' });
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = downloadUrl;
a.download = fileName;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(downloadUrl);
}
function onUpload(file: File) {
if (file) {
fileInput.value = file;
}
}
</script>
<template>
<div style="max-width: 600px;">
<c-card title="Input" mb-2>
<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 EML file here, or click to select a file"
@file-upload="onUpload"
/>
<c-input-text
v-if="inputType === 'content'"
v-model:value="emailContent"
label="Email Content"
multiline
placeholder="Put your eml/email content here..."
rows="15"
mb-2
/>
</c-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
<c-card v-if="!error && parsedEmail" title="Output">
<input-copyable v-if="fileInput?.name" label="File Name" :value="fileInput?.name" />
<input-copyable v-if="parsedEmail.date" label="Date" :value="parsedEmail.date" />
<input-copyable v-if="parsedEmail.from?.name" label="From (name)" :value="parsedEmail.from?.name" />
<input-copyable v-if="parsedEmail.from" label="From (address)" :value="parsedEmail.from?.address || parsedEmail.from" />
<input-copyable v-if="parsedEmail.to" label="To" :value="JSON.stringify(parsedEmail.to)" />
<input-copyable v-if="parsedEmail.cc" label="Cc" :value="JSON.stringify(parsedEmail.cc)" />
<input-copyable v-if="parsedEmail.bcc" label="Bcc" :value="JSON.stringify(parsedEmail.bcc)" />
<input-copyable v-if="parsedEmail.replyTo" label="Reply-To" :value="JSON.stringify(parsedEmail.replyTo)" />
<input-copyable v-if="parsedEmail.subject" label="Subject" :value="parsedEmail.subject" />
<c-card v-if="parsedEmail.text" title="Plain Content" mb-2>
<details>
<summary>See content</summary>
<textarea-copyable :value="parsedEmail.text" word-wrap />
</details>
</c-card>
<c-card v-if="parsedEmail.html" title="Html Content" mb-2>
<details>
<summary>See content</summary>
<textarea-copyable :value="parsedEmail.html" word-wrap />
</details>
</c-card>
<c-card v-if="parsedEmail?.attachments?.length" title="Attachments" mb-2>
<n-table>
<thead>
<tr>
<th scope="col">
Attachment
</th><th scope="col" />
</tr>
</thead>
<tbody>
<tr
v-for="(h, index) in parsedEmail.attachments || []"
:key="index"
>
<td>
{{ `${h.filename || h.contentId || 'noname'} (${h.mimeType}) / ${h.disposition}` }}
</td>
<td>
<c-button @click="downloadFile(h.content, h.filename || h.contentId || 'noname', h.mimeType)">
Download
</c-button>
</td>
</tr>
</tbody>
</n-table>
</c-card>
<input-copyable v-if="parsedEmail.messageId" label="Message Id" :value="parsedEmail.messageId" />
<input-copyable v-if="parsedEmail.inReplyTo" label="In Reply To" :value="parsedEmail.inReplyTo" />
<input-copyable v-if="parsedEmail.references" label="References" :value="parsedEmail.references" />
<input-copyable v-if="parsedEmail.deliveredTo" label="Delivered To" :value="parsedEmail.deliveredTo" />
<input-copyable v-if="parsedEmail.returnPath" label="Return Path" :value="parsedEmail.returnPath" />
<input-copyable v-if="parsedEmail.sender?.name" label="Sender (name)" :value="parsedEmail.sender?.name" />
<input-copyable v-if="parsedEmail.sender" label="Sender (address)" :value="parsedEmail.sender?.address || parsedEmail.sender" />
<c-card title="All Headers" mt-2>
<input-copyable
v-for="(h, index) in parsedEmail.headers || []"
:key="index"
:label="h.key"
:value="h.value"
/>
</c-card>
</c-card>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { Mail } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Email Parser',
path: '/email-parser',
description: 'Parse and extract information from raw Email content',
keywords: ['email', 'parser', 'header', 'rfc2822', 'rfc5322', 'rfc822'],
component: () => import('./email-parser.vue'),
icon: Mail,
createdAt: new Date('2024-08-15'),
});
+2 -6
View File
@@ -2,8 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as emailParser } from './email-parser';
import { tool as outlookParser } from './outlook-parser';
import { tool as integersToIp } from './integers-to-ip';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
@@ -11,7 +10,6 @@ import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as markdownToHtml } from './markdown-to-html';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -115,7 +113,6 @@ export const toolsByCategory: ToolCategory[] = [
tomlToYaml,
xmlToJson,
jsonToXml,
markdownToHtml,
],
},
{
@@ -169,8 +166,7 @@ export const toolsByCategory: ToolCategory[] = [
macAddressLookup,
macAddressGenerator,
ipv6UlaGenerator,
emailParser,
outlookParser,
integersToIp,
],
},
{
@@ -11,9 +11,21 @@ describe('integer-base-converter', () => {
expect(convertBase({ value: '10100101', fromBase: 2, toBase: 16 })).toEqual('a5');
expect(convertBase({ value: '192654', fromBase: 10, toBase: 8 })).toEqual('570216');
expect(convertBase({ value: 'zz', fromBase: 64, toBase: 10 })).toEqual('2275');
expect(convertBase({ value: '42540766411283223938465490632011909384', fromBase: 10, toBase: 10 })).toEqual('42540766411283223938465490632011909384');
expect(convertBase({ value: '42540766411283223938465490632011909384', fromBase: 10, toBase: 16 })).toEqual('20010db8000085a300000000ac1f8908');
expect(convertBase({ value: '20010db8000085a300000000ac1f8908', fromBase: 16, toBase: 10 })).toEqual('42540766411283223938465490632011909384');
expect(convertBase({ value: 'AA', fromBase: 16, toBase: 10 })).toEqual('170');
expect(convertBase({ value: 'aa', fromBase: 16, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '0xAA', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '&HAA', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '0xAAUL', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '0XAAUL', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '10UL', fromBase: 10, toBase: 10 })).toEqual('10');
expect(convertBase({ value: '10n', fromBase: 10, toBase: 10 })).toEqual('10');
expect(convertBase({ value: '0o252', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '&O252', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '192 654', fromBase: 10, toBase: 8 })).toEqual('570216');
expect(convertBase({ value: '192.654', fromBase: 10, toBase: 8 })).toEqual('570216');
expect(convertBase({ value: '0b10101010', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '0b_1010_1010', fromBase: -1, toBase: 10 })).toEqual('170');
expect(convertBase({ value: '192,654', fromBase: 10, toBase: 8 })).toEqual('570216');
});
});
});
@@ -1,20 +1,61 @@
export function convertBase({ value, fromBase, toBase }: { value: string; fromBase: number; toBase: number }) {
export function hasNumberPrefix(value: string) {
return (value ?? '').trim().match(/^(0[xob].|&[hob].)/i);
}
export function convertBase(
{
value, fromBase, toBase,
ignorePunctuationsRegexChars = ' \u00A0_\.,-',
handlePrefixSuffix = true,
ignoreCase = true,
}: {
value: string
fromBase: number
toBase: number
ignorePunctuationsRegexChars?: string
handlePrefixSuffix?: boolean
ignoreCase?: boolean
}) {
let cleanedValue = (value ?? '0').trim();
if (ignorePunctuationsRegexChars) {
cleanedValue = cleanedValue.replace(new RegExp(`[${ignorePunctuationsRegexChars}]`, 'g'), '');
}
let finalFromBase = fromBase;
if (handlePrefixSuffix) {
for (const regBase of [
{ base: 2, regex: /^(&b|0b)?([01]+)([IULZn]*)$/i },
{ base: 8, regex: /^(&o|0o)?([0-7]+)([IULZn]*)$/i },
{ base: 16, regex: /^(&h|0x)?([a-f0-9]+)([IULZn]*)$/i },
]) {
const match = cleanedValue.match(regBase.regex);
if (match) {
if (match[1]) {
finalFromBase = regBase.base;
}
cleanedValue = match[2];
break;
}
}
}
if (ignoreCase && finalFromBase <= 36) {
cleanedValue = cleanedValue.toLowerCase();
}
const range = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/'.split('');
const fromRange = range.slice(0, fromBase);
const fromRange = range.slice(0, finalFromBase);
const toRange = range.slice(0, toBase);
let decValue = value
let decValue = cleanedValue
.split('')
.reverse()
.reduce((carry: bigint, digit: string, index: number) => {
.reduce((carry: number, digit: string, index: number) => {
if (!fromRange.includes(digit)) {
throw new Error(`Invalid digit "${digit}" for base ${fromBase}.`);
throw new Error(`Invalid digit "${digit}" for base ${finalFromBase}.`);
}
return (carry += BigInt(fromRange.indexOf(digit)) * BigInt(fromBase) ** BigInt(index));
}, 0n);
return (carry += fromRange.indexOf(digit) * finalFromBase ** index);
}, 0);
let newValue = '';
while (decValue > 0) {
newValue = toRange[Number(decValue % BigInt(toBase))] + newValue;
decValue = (decValue - (decValue % BigInt(toBase))) / BigInt(toBase);
newValue = toRange[decValue % toBase] + newValue;
decValue = (decValue - (decValue % toBase)) / toBase;
}
return newValue || '0';
}
+12
View File
@@ -0,0 +1,12 @@
import { Binary } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Integers to IPv4/IPv6',
path: '/integers-to-ip',
description: 'Convert integers to IP',
keywords: ['integers', 'ip', 'ipv4', 'ipv6'],
component: () => import('./integers-to-ip.vue'),
icon: Binary,
createdAt: new Date('2024-07-14'),
});
@@ -0,0 +1,65 @@
<script setup lang="ts">
import { stringifyIp } from 'ip-bigint';
import InputCopyable from '../../components/InputCopyable.vue';
import { convertBase, hasNumberPrefix } from '../integer-base-converter/integer-base-converter.model';
const input = ref('3232235777');
const inputBase = ref(10);
const hasInputNumberPrefix = computed(() => hasNumberPrefix(input.value));
function convertToIP({ value, fromBase, version }: { value: string; fromBase: number; version: 6 | 4 }): string {
try {
return stringifyIp({
number: BigInt(convertBase({
value,
fromBase,
toBase: 10,
})),
version,
}) ?? 'Invalid IP';
}
catch (err) {
return err?.toString() ?? 'Invalid IP';
}
}
</script>
<template>
<div>
<c-card>
<c-input-text v-model:value="input" label="Input number" placeholder="Put your number here (ex: 3232235777)" label-position="left" label-width="110px" mb-2 label-align="right" />
<n-form-item v-if="!hasInputNumberPrefix" label="Input base" label-placement="left" label-width="110" :show-feedback="false">
<c-select
v-model:value="inputBase"
:options="[{ value: 2, label: 'Binary' }, { value: 8, label: 'Octal' }, { value: 10, label: 'Decimal' }, { value: 16, label: 'Hexadecimal' }]"
placeholder="Select a base"
w-100px
/>
</n-form-item>
<n-divider />
<InputCopyable
label="Formatted IPv4"
label-position="left" label-width="110px" mb-2 label-align="right"
:value="convertToIP({ value: input, fromBase: inputBase, version: 4 })"
placeholder="Formatted IPv4 will be here..."
/>
<InputCopyable
label="Formatted IPv6"
label-position="left" label-width="110px" mb-2 label-align="right"
:value="convertToIP({ value: input, fromBase: inputBase, version: 6 })"
placeholder="Formatted IPv6 will be here..."
/>
</c-card>
</div>
</template>
<style lang="less" scoped>
.n-input-group:not(:first-child) {
margin-top: 5px;
}
</style>
-12
View File
@@ -1,12 +0,0 @@
import { Markdown } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Markdown to HTML',
path: '/markdown-to-html',
description: 'Convert Markdown to Html and allow to print (as PDF)',
keywords: ['markdown', 'html', 'converter', 'pdf'],
component: () => import('./markdown-to-html.vue'),
icon: Markdown,
createdAt: new Date('2024-08-25'),
});
@@ -1,44 +0,0 @@
<script setup lang="ts">
import markdownit from 'markdown-it';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const inputMarkdown = ref('');
const outputHtml = computed(() => {
const md = markdownit();
return md.render(inputMarkdown.value);
});
function printHtml() {
const w = window.open();
if (w === null) {
return;
}
w.document.body.innerHTML = outputHtml.value;
w.print();
}
</script>
<template>
<div>
<c-input-text
v-model:value="inputMarkdown"
multiline raw-text
placeholder="Your Markdown content..."
rows="8"
autofocus
label="Your Markdown to convert:"
/>
<n-divider />
<n-form-item label="Output HTML:">
<TextareaCopyable :value="outputHtml" :word-wrap="true" language="html" />
</n-form-item>
<div flex justify-center>
<n-button @click="printHtml">
Print as PDF
</n-button>
</div>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { Mail } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Outlook MSG Parser',
path: '/outlook-parser',
description: 'Parse Outlook MSG Files',
keywords: ['outlook', 'email', 'msg', 'parser'],
component: () => import('./outlook-parser.vue'),
icon: Mail,
createdAt: new Date('2024-08-15'),
});
-182
View File
@@ -1,182 +0,0 @@
<script setup lang="ts">
import { Buffer } from 'node:buffer';
import MsgReader, { type FieldsData } from '@kenjiuno/msgreader';
import { getProps } from '@kenjiuno/msgreader/lib/Defs.js';
import { deEncapsulateSync } from 'rtf-stream-parser';
import { decompressRTF } from '@kenjiuno/decompressrtf';
import iconv from 'iconv-lite';
const fileInput = ref() as Ref<File | null>;
const error = ref('');
function getPropertyName(tag: string | undefined) {
if (!tag) {
return '';
}
const tagLower = tag.toLocaleLowerCase();
const prop = getProps().find(p => p.key?.toLocaleLowerCase() === tagLower);
if (!prop) {
return tag;
}
return `${prop.name} (${prop.area})`;
}
const parsedEmailRaw = computedAsync(async () => {
const file = fileInput.value;
error.value = '';
if (file == null) {
return null;
}
try {
const msg = new MsgReader(await file.arrayBuffer());
msg.parserConfig = {
includeRawProps: true,
};
return msg;
}
catch (e: any) {
error.value = e.toString();
return null;
}
});
const parsedEmail = computed(() => parsedEmailRaw.value?.getFileData());
const parsedRtf = computed(() => {
if (!parsedEmail.value?.compressedRtf) {
return { rtf: '', html: '' };
}
try {
const rtfBlob = decompressRTF(Array.from(parsedEmail.value?.compressedRtf));
const rtfText = iconv.decode(
Buffer.from(rtfBlob),
'latin1',
);
try {
return { rtf: rtfText, html: deEncapsulateSync(rtfText, { decode: iconv.decode })?.text };
}
catch (dex: any) {
return { rtf: rtfText, html: dex.toString() };
}
}
catch (ex: any) {
return { rtf: ex.toString(), html: '' };
}
});
function downloadFile(attachment: FieldsData) {
const attachmentData = parsedEmailRaw.value?.getAttachment(attachment);
if (!attachmentData) {
return;
}
const blob = new Blob([attachmentData.content], { type: 'application/octet-stream' });
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = downloadUrl;
a.download = attachmentData.fileName;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(downloadUrl);
}
function onUpload(file: File) {
if (file) {
fileInput.value = file;
}
}
</script>
<template>
<div style="max-width: 600px;">
<c-card title="Input" mb-2>
<c-file-upload
title="Drag and drop MSG file here, or click to select a file"
@file-upload="onUpload"
/>
</c-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
<c-card v-if="!error && parsedEmail" title="Output">
<input-copyable v-if="fileInput?.name" label="File Name" :value="fileInput?.name" />
<input-copyable v-if="parsedEmail.creationTime" label="Creation Date" :value="parsedEmail.creationTime" />
<input-copyable v-if="parsedEmail.clientSubmitTime" label="Submit Date" :value="parsedEmail.clientSubmitTime" />
<input-copyable v-if="parsedEmail.messageDeliveryTime" label="Delivery Date" :value="parsedEmail.messageDeliveryTime" />
<input-copyable v-if="parsedEmail.lastModificationTime" label="Last Mod. Date" :value="parsedEmail.lastModificationTime" />
<c-card title="Recipients" mt-2>
<input-copyable
v-for="(h, index) in parsedEmail.recipients || []"
:key="index"
:label="h.recipType || 'unk'"
:value="`${h.name}/${h.email}`"
/>
</c-card>
<input-copyable v-if="parsedEmail.subject" label="Subject" :value="parsedEmail.subject" />
<c-card v-if="parsedEmail.body" title="Plain Content" mb-2>
<details>
<summary>See content</summary>
<textarea-copyable :value="parsedEmail.body" />
</details>
</c-card>
<c-card v-if="parsedEmail.bodyHtml" title="Html Content" mb-2>
<details>
<summary>See content</summary>
<textarea-copyable :value="parsedEmail.bodyHtml" word-wrap />
</details>
</c-card>
<c-card v-if="parsedRtf.rtf || parsedRtf.html" title="RTF Content" mb-2>
<details>
<summary>See Raw RTF</summary>
<textarea-copyable :value="parsedRtf.rtf" word-wrap />
</details>
<details>
<summary>See RTF converted HTML</summary>
<textarea-copyable :value="parsedRtf.html" word-wrap />
</details>
</c-card>
<c-card v-if="parsedEmail?.attachments?.length" title="Attachments" mb-2>
<n-table>
<thead>
<tr>
<th scope="col">
Attachment
</th><th scope="col" />
</tr>
</thead>
<tbody>
<tr
v-for="(h, index) in parsedEmail.attachments || []"
:key="index"
>
<td>
{{ `${h.fileName || h.fileNameShort || 'noname'}` }}
</td>
<td>
<c-button @click="downloadFile(h)">
Download
</c-button>
</td>
</tr>
</tbody>
</n-table>
</c-card>
<input-copyable v-if="parsedEmail.messageId" label="Message Id" :value="parsedEmail.messageId" />
<input-copyable v-if="parsedEmail.senderName" label="Sender (name)" :value="parsedEmail.senderName" />
<input-copyable v-if="parsedEmail.senderEmail" label="Sender (email)" :value="parsedEmail.senderEmail" />
<c-card v-if="parsedEmail.headers" title="All Headers" mt-2>
<textarea-copyable :value="parsedEmail.headers" />
</c-card>
<c-card title="All RawProps" mt-2>
<input-copyable
v-for="(h, index) in parsedEmail.rawProps || []"
:key="index"
:label="h.propertyName || getPropertyName(h.propertyTag)"
:value="h.value"
/>
</c-card>
</c-card>
</div>
</template>
-2
View File
@@ -15,7 +15,6 @@ import { VitePWA } from 'vite-plugin-pwa';
import markdown from 'vite-plugin-vue-markdown';
import svgLoader from 'vite-svg-loader';
import { configDefaults } from 'vitest/config';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
const baseUrl = process.env.BASE_URL ?? '/';
@@ -98,7 +97,6 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {