Skip to content

Commit

Permalink
Merge branch 'developing/2.0.0' of https://github.com/sunnydanu/godev…
Browse files Browse the repository at this point in the history
….run into feat(yaml-viewer)--add-parsing-validation

Merge branch 'developing/2.0.0' of https://github.com/sunnydanu/godev.run into feat(yaml-viewer)--add-parsing-validation
  • Loading branch information
sunnydanu committed Nov 3, 2024
2 parents 8912ea0 + db4d1be commit a9b6e82
Show file tree
Hide file tree
Showing 8 changed files with 786 additions and 15 deletions.
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ declare module '@vue/runtime-core' {
RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default']
'RegexMemo.content': typeof import('./src/tools/regex-memo/regex-memo.content.md')['default']
RegexTester: typeof import('./src/tools/regex-tester/regex-tester.vue')['default']
RemoveExif: typeof import('./src/tools/remove-exif/remove-exif.vue')['default']
ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default']
RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@tiptap/vue-3": "2.0.3",
"@types/figlet": "^1.5.8",
"@types/markdown-it": "^13.0.7",
"@types/memorystream": "^0.3.4",
"@types/pdfjs-dist": "^2.10.378",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
Expand All @@ -69,6 +70,7 @@
"dompurify": "^3.0.6",
"email-normalizer": "^1.0.0",
"emojilib": "^3.0.10",
"exif-be-gone": "^1.5.1",
"exifreader": "^4.20.0",
"fflate": "^0.8.2",
"figlet": "^1.7.0",
Expand All @@ -95,6 +97,7 @@
"markdown-it": "^14.0.0",
"marked": "^10.0.0",
"mathjs": "^11.9.1",
"memorystream": "^0.3.1",
"mime-types": "^2.1.35",
"monaco-editor": "^0.43.0",
"naive-ui": "^2.35.0",
Expand Down Expand Up @@ -165,6 +168,7 @@
"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",
Expand Down
685 changes: 683 additions & 2 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions src/composable/downloadBase64.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
import type { Ref } from 'vue';
import type { MaybeRef, Ref } from 'vue';
import _ from 'lodash';
import { get } from '@vueuse/core';

export {
getMimeTypeFromBase64,
Expand Down Expand Up @@ -75,21 +76,11 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
}

function useDownloadFileFromBase64(
{ source, filename, extension, fileMimeType }:
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
},
};
}

function useDownloadFileFromBase64Refs(
{ source, filename, extension }:
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
return {
download() {
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
},
};
}
Expand All @@ -116,3 +107,13 @@ 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 });
},
};
}
2 changes: 2 additions & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { tool as gzipConverter } from './gzip-converter';
import { tool as ocrImage } from './ocr-image';
import { tool as ipGeoLocation } from './ip-geo-location';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as removeExif } from './remove-exif';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as regexTester } from './regex-tester';
Expand Down Expand Up @@ -186,6 +187,7 @@ export const toolsByCategory: ToolCategory[] = [
imageResizer,
ocrImage,
imageExifReader,
removeExif,
],
},
{
Expand Down
12 changes: 12 additions & 0 deletions src/tools/remove-exif/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PictureInPictureOff } from '@vicons/tabler';
import { defineTool } from '../tool';

export const tool = defineTool({
name: 'Remove EXIF',
path: '/remove-exif',
description: 'Remove Exif from JPEG Files',
keywords: ['remove', 'exif', 'jpeg'],
component: () => import('./remove-exif.vue'),
icon: PictureInPictureOff,
createdAt: new Date('2024-07-14'),
});
68 changes: 68 additions & 0 deletions src/tools/remove-exif/remove-exif.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<script setup lang="ts">
import { Buffer } from 'node:buffer';
import { Base64 } from 'js-base64';
import ExifTransformer from 'exif-be-gone';
import MemoryStream from 'memorystream';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
const file = ref<File | null>(null);
interface ToBufferMemoryStream extends MemoryStream {
toBuffer(): Buffer
}
const base64OutputFile = ref('');
const fileName = ref('');
const { download } = useDownloadFileFromBase64(
{
source: base64OutputFile,
filename: fileName,
extension: 'jpg',
});
async function onFileUploaded(uploadedFile: File) {
file.value = uploadedFile;
const fileBuffer = await uploadedFile.arrayBuffer();
fileName.value = `noexif_${uploadedFile.name}`;
status.value = 'processing';
try {
const inStream = MemoryStream.createReadStream(Buffer.from(fileBuffer));
const outStream = MemoryStream.createWriteStream();
const trans = new ExifTransformer();
await new Promise((resolve, _reject) => {
inStream.pipe(trans).pipe(outStream).on('finish', () => resolve(true));
});
const outFileBuffer = (outStream as ToBufferMemoryStream).toBuffer();
base64OutputFile.value = `data:image/File;base64,${Base64.fromUint8Array(outFileBuffer)}`;
status.value = 'done';
download();
}
catch (e) {
status.value = 'error';
}
}
</script>

<template>
<div>
<div style="flex: 0 0 100%">
<div mx-auto max-w-600px>
<c-file-upload title="Drag and drop a Image file here, or click to select a file" accept="image/*" @file-upload="onFileUploaded" />
</div>
</div>

<div mt-3 flex justify-center>
<c-alert v-if="status === 'error'" type="error">
An error occured processing {{ fileName }}
</c-alert>
<n-spin
v-if="status === 'processing'"
size="small"
/>
</div>
</div>
</template>
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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 ?? '/';

Expand Down Expand Up @@ -101,6 +102,7 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {
Expand Down

0 comments on commit a9b6e82

Please sign in to comment.