Skip to content

Commit 3ad648d

Browse files
committed
feat(new tool): GZIP String converter
Fix CorentinTh#892
1 parent fe349ad commit 3ad648d

File tree

6 files changed

+117
-13
lines changed

6 files changed

+117
-13
lines changed

components.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ declare module '@vue/runtime-core' {
8181
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
8282
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
8383
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
84+
GzipConverter: typeof import('./src/tools/gzip-converter/gzip-converter.vue')['default']
8485
HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default']
8586
HmacGenerator: typeof import('./src/tools/hmac-generator/hmac-generator.vue')['default']
8687
'Home.page': typeof import('./src/pages/Home.page.vue')['default']
@@ -130,21 +131,14 @@ declare module '@vue/runtime-core' {
130131
NCode: typeof import('naive-ui')['NCode']
131132
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
132133
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
133-
NDivider: typeof import('naive-ui')['NDivider']
134134
NEllipsis: typeof import('naive-ui')['NEllipsis']
135-
NFormItem: typeof import('naive-ui')['NFormItem']
136-
NGi: typeof import('naive-ui')['NGi']
137-
NGrid: typeof import('naive-ui')['NGrid']
138135
NH1: typeof import('naive-ui')['NH1']
139136
NH3: typeof import('naive-ui')['NH3']
140137
NIcon: typeof import('naive-ui')['NIcon']
141-
NInputNumber: typeof import('naive-ui')['NInputNumber']
142-
NLabel: typeof import('naive-ui')['NLabel']
143138
NLayout: typeof import('naive-ui')['NLayout']
144139
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
145140
NMenu: typeof import('naive-ui')['NMenu']
146141
NScrollbar: typeof import('naive-ui')['NScrollbar']
147-
NSpin: typeof import('naive-ui')['NSpin']
148142
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
149143
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
150144
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@
5858
"date-fns": "^2.29.3",
5959
"dompurify": "^3.0.6",
6060
"emojilib": "^3.0.10",
61+
"fflate": "^0.8.2",
6162
"figlet": "^1.7.0",
6263
"figue": "^1.2.0",
6364
"fuse.js": "^6.6.2",
6465
"highlight.js": "^11.7.0",
6566
"iarna-toml-esm": "^3.0.5",
6667
"ibantools": "^4.3.3",
68+
"js-base64": "^3.7.7",
6769
"json5": "^2.2.3",
6870
"jwt-decode": "^3.1.2",
6971
"libphonenumber-js": "^1.10.28",

pnpm-lock.yaml

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<script setup lang="ts">
2+
import * as fflate from 'fflate';
3+
import { Base64 } from 'js-base64';
4+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
5+
import { withDefaultOnError } from '@/utils/defaults';
6+
7+
const compressedInput = ref('');
8+
const decompressedOutput = computed(() => withDefaultOnError(() => {
9+
const compressedBuf = Base64.toUint8Array(compressedInput.value);
10+
return fflate.strFromU8(fflate.decompressSync(compressedBuf));
11+
}, '# invalid compressed base64 string'));
12+
13+
const rawInput = ref('');
14+
const compressedGzipOutput = computed(() => withDefaultOnError(() => Base64.fromUint8Array(fflate.gzipSync(fflate.strToU8(rawInput.value))), ''));
15+
const compressedDeflateOutput = computed(() => withDefaultOnError(() => Base64.fromUint8Array(fflate.deflateSync(fflate.strToU8(rawInput.value))), ''));
16+
const compressedZlibOutput = computed(() => withDefaultOnError(() => Base64.fromUint8Array(fflate.zlibSync(fflate.strToU8(rawInput.value))), ''));
17+
</script>
18+
19+
<template>
20+
<div style="max-width: 600px;">
21+
<c-card title="Compress string" mb-5>
22+
<c-input-text
23+
v-model:value="rawInput"
24+
multiline
25+
placeholder="Put your string here..."
26+
rows="5"
27+
label="String to compress"
28+
raw-text
29+
mb-5
30+
/>
31+
32+
<div>
33+
<h3>GZIP compressed string</h3>
34+
<TextareaCopyable
35+
:value="compressedGzipOutput"
36+
placeholder="The GZip compressed version of your string will be here"
37+
mb-5
38+
/>
39+
</div>
40+
41+
<div>
42+
<h3>Zlib compressed string</h3>
43+
<TextareaCopyable
44+
:value="compressedZlibOutput"
45+
placeholder="The Zlib compressed version of your string will be here"
46+
mb-5
47+
/>
48+
</div>
49+
50+
<div>
51+
<h3>Deflate compressed string</h3>
52+
<TextareaCopyable
53+
:value="compressedDeflateOutput"
54+
placeholder="The Deflate compressed version of your string will be here"
55+
mb-5
56+
/>
57+
</div>
58+
</c-card>
59+
60+
<c-card title="Decompress string">
61+
<c-input-text
62+
v-model:value="compressedInput"
63+
multiline
64+
placeholder="Your compressed string..."
65+
rows="5"
66+
label="Compressed string to decompress"
67+
mb-5
68+
/>
69+
70+
<div>
71+
<h3>Decompressed string</h3>
72+
<TextareaCopyable
73+
v-model:value="decompressedOutput"
74+
placeholder="The decompressed string will be here"
75+
mb-5
76+
/>
77+
</div>
78+
</c-card>
79+
</div>
80+
</template>

src/tools/gzip-converter/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { FileZip } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'GZip/Deflate converter',
6+
path: '/gzip-converter',
7+
description: 'Convert text from/to gzip/deflate',
8+
keywords: ['gzip', 'deflate', 'converter'],
9+
component: () => import('./gzip-converter.vue'),
10+
icon: FileZip,
11+
createdAt: new Date('2024-03-09'),
12+
});

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
66

77
import { tool as textToUnicode } from './text-to-unicode';
88

9+
import { tool as gzipConverter } from './gzip-converter';
910
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
1011
import { tool as numeronymGenerator } from './numeronym-generator';
1112
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -107,6 +108,7 @@ export const toolsByCategory: ToolCategory[] = [
107108
listConverter,
108109
tomlToJson,
109110
tomlToYaml,
111+
gzipConverter,
110112
],
111113
},
112114
{

0 commit comments

Comments
 (0)