mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-10-24 08:33:48 +00:00
Compare commits
17 Commits
landing-pa
...
v2.19.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
072083832d | ||
|
|
c934c4e50c | ||
|
|
4a5734d4a3 | ||
|
|
f708f5091e | ||
|
|
db817a2459 | ||
|
|
119041c185 | ||
|
|
4607837f9a | ||
|
|
f52f7a845c | ||
|
|
acc7f0a586 | ||
|
|
ebb7301a98 | ||
|
|
def60e7248 | ||
|
|
bf88836dbe | ||
|
|
bfc2e24bbf | ||
|
|
40872859a5 | ||
|
|
cf723f144e | ||
|
|
7f964941d3 | ||
|
|
af075dcccc |
50
CHANGELOG.md
50
CHANGELOG.md
@@ -2,6 +2,56 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [2.19.0](https://github.com/CorentinTh/it-tools/compare/v2.18.0...v2.19.0) (2023-02-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **new-tool:** keycode info ([c934c4e](https://github.com/CorentinTh/it-tools/commit/c934c4e50ca1a129b80b786a5d9a7dbc33ad9ba3))
|
||||
|
||||
## [2.18.0](https://github.com/CorentinTh/it-tools/compare/v2.17.0...v2.18.0) (2023-02-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **new-tool:** json minify ([#265](https://github.com/CorentinTh/it-tools/issues/265)) ([f708f50](https://github.com/CorentinTh/it-tools/commit/f708f5091e2182fc88e7cf3e7d23b3d05edc04da))
|
||||
|
||||
|
||||
### Refactors
|
||||
|
||||
* **tools:** config in query params ([db817a2](https://github.com/CorentinTh/it-tools/commit/db817a2459e23bd096274a7f91815d613d5f7ff4))
|
||||
|
||||
## [2.17.0](https://github.com/CorentinTh/it-tools/compare/v2.16.0...v2.17.0) (2023-01-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **new-tool:** jwt parser ([#262](https://github.com/CorentinTh/it-tools/issues/262)) ([acc7f0a](https://github.com/CorentinTh/it-tools/commit/acc7f0a586c64500c5f720e70cdbccf9bffe76d9))
|
||||
* **new-tool:** temperature converter ([4607837](https://github.com/CorentinTh/it-tools/commit/4607837f9a398440e0098f2ba862e8d7422ce94f))
|
||||
|
||||
|
||||
### Refactors
|
||||
|
||||
* **jwt-parser:** simplified code ([f52f7a8](https://github.com/CorentinTh/it-tools/commit/f52f7a845c34ce7da57b11c17d261733be89554f))
|
||||
|
||||
## [2.16.0](https://github.com/CorentinTh/it-tools/compare/v2.15.0...v2.16.0) (2022-12-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **search-bar:** use cmd + k to focus on mac ([bf88836](https://github.com/CorentinTh/it-tools/commit/bf88836dbe4037019e9545deaae1db06e5768cfb))
|
||||
* **tool:** improved favorite tool management ([af075dc](https://github.com/CorentinTh/it-tools/commit/af075dccccec959a0863e6d11516206860bed91f))
|
||||
* **tools:** added favorite tool handling ([4cd809b](https://github.com/CorentinTh/it-tools/commit/4cd809bd0c94836532f58a2ec6aa131694cce10d))
|
||||
* **tracker:** added actions monitoring ([bfc2e24](https://github.com/CorentinTh/it-tools/commit/bfc2e24bbfc08f67ed9c9b1d93474029bc01dc8b))
|
||||
|
||||
|
||||
### Refactors
|
||||
|
||||
* **clean:** removed empty style tag ([cf723f1](https://github.com/CorentinTh/it-tools/commit/cf723f144ee865b6de7323d3be58eb7a9586fa56))
|
||||
* **clean:** removed unused import ([4087285](https://github.com/CorentinTh/it-tools/commit/40872859a580a20bb838b79db2b3c88c00995e37))
|
||||
* **menu:** improve support button ([679dd1c](https://github.com/CorentinTh/it-tools/commit/679dd1c1f6265227cc9db60c55d83f8eaf8f72b4))
|
||||
* **tracker:** better tracker injection ([def60e7](https://github.com/CorentinTh/it-tools/commit/def60e7248003e74ed67e9ff116b438bab410a92))
|
||||
|
||||
## [2.15.0](https://github.com/CorentinTh/it-tools/compare/v2.14.1...v2.15.0) (2022-12-16)
|
||||
|
||||
|
||||
|
||||
48
README.md
48
README.md
@@ -10,46 +10,53 @@ You have an idea of a tool? Submit a [feature request](https://github.com/Corent
|
||||
|
||||
## Contribute
|
||||
|
||||
### Recommended IDE Setup
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin).
|
||||
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
||||
|
||||
### Node version
|
||||
## Type Support for `.vue` Imports in TS
|
||||
|
||||
Ensure you have the correct node/npm version
|
||||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
||||
|
||||
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
||||
|
||||
1. Disable the built-in TypeScript Extension
|
||||
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
||||
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
||||
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
||||
|
||||
## Customize configuration
|
||||
|
||||
See [Vite Configuration Reference](https://vitejs.dev/config/).
|
||||
|
||||
## Project Setup
|
||||
|
||||
```sh
|
||||
nvm use
|
||||
pnpm install
|
||||
```
|
||||
|
||||
### Project Setup
|
||||
### Compile and Hot-Reload for Development
|
||||
|
||||
```sh
|
||||
npm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
#### Compile and Hot-Reload for Development
|
||||
### Type-Check, Compile and Minify for Production
|
||||
|
||||
```sh
|
||||
npm run dev
|
||||
pnpm build
|
||||
```
|
||||
|
||||
#### Type-Check, Compile and Minify for Production
|
||||
### Run Unit Tests with [Vitest](https://vitest.dev/)
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
pnpm test
|
||||
```
|
||||
|
||||
#### Run Unit Tests with [Vitest](https://vitest.dev/)
|
||||
### Lint with [ESLint](https://eslint.org/)
|
||||
|
||||
```sh
|
||||
npm run test
|
||||
```
|
||||
|
||||
#### Lint with [ESLint](https://eslint.org/)
|
||||
|
||||
```sh
|
||||
npm run lint
|
||||
pnpm lint
|
||||
```
|
||||
|
||||
### Create a new tool
|
||||
@@ -68,12 +75,9 @@ Coded with ❤️ by [Corentin Thomasset](//corentin-thomasset.fr).
|
||||
|
||||
This project is continuously deployed using [vercel.com](https://vercel.com).
|
||||
|
||||
|
||||
|
||||
<a href="https://www.producthunt.com/posts/it-tools?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-it-tools" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=345793&theme=light" alt="IT Tools - Collection of handy online tools for devs, with great UX | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
<a href="https://www.producthunt.com/posts/it-tools?utm_source=badge-top-post-badge&utm_medium=badge&utm_souce=badge-it-tools" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=345793&theme=light&period=daily" alt="IT Tools - Collection of handy online tools for devs, with great UX | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This project is under the [GNU GPLv3](LICENSE).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "it-tools",
|
||||
"version": "2.15.0",
|
||||
"version": "2.19.0",
|
||||
"description": "Collection of handy online tools for developers, with great UX. ",
|
||||
"keywords": [
|
||||
"productivity",
|
||||
@@ -37,6 +37,7 @@
|
||||
"@vicons/tabler": "^0.12.0",
|
||||
"@vueuse/core": "^8.9.4",
|
||||
"@vueuse/head": "^0.7.13",
|
||||
"@vueuse/router": "^9.11.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"change-case": "^4.1.2",
|
||||
"colord": "^2.9.3",
|
||||
@@ -48,6 +49,7 @@
|
||||
"fuse.js": "^6.6.2",
|
||||
"highlight.js": "^11.6.0",
|
||||
"json5": "^2.2.1",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"lodash": "^4.17.21",
|
||||
"mathjs": "^10.6.4",
|
||||
"mime-types": "^2.1.35",
|
||||
@@ -57,6 +59,7 @@
|
||||
"qrcode": "^1.5.1",
|
||||
"randombytes": "^2.1.0",
|
||||
"sql-formatter": "^8.2.0",
|
||||
"ts-pattern": "^4.1.3",
|
||||
"uuid": "^8.3.2",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.1.6"
|
||||
|
||||
36
pnpm-lock.yaml
generated
36
pnpm-lock.yaml
generated
@@ -24,6 +24,7 @@ specifiers:
|
||||
'@vue/tsconfig': ^0.1.3
|
||||
'@vueuse/core': ^8.9.4
|
||||
'@vueuse/head': ^0.7.13
|
||||
'@vueuse/router': ^9.11.0
|
||||
bcryptjs: ^2.4.3
|
||||
c8: ^7.12.0
|
||||
change-case: ^4.1.2
|
||||
@@ -42,6 +43,7 @@ specifiers:
|
||||
highlight.js: ^11.6.0
|
||||
jsdom: ^19.0.0
|
||||
json5: ^2.2.1
|
||||
jwt-decode: ^3.1.2
|
||||
less: ^4.1.3
|
||||
lodash: ^4.17.21
|
||||
mathjs: ^10.6.4
|
||||
@@ -55,6 +57,7 @@ specifiers:
|
||||
sql-formatter: ^8.2.0
|
||||
standard-version: ^9.5.0
|
||||
start-server-and-test: ^1.14.0
|
||||
ts-pattern: ^4.1.3
|
||||
typescript: ~4.5.5
|
||||
uuid: ^8.3.2
|
||||
vite: ^2.9.15
|
||||
@@ -74,6 +77,7 @@ dependencies:
|
||||
'@vicons/tabler': 0.12.0
|
||||
'@vueuse/core': 8.9.4_vue@3.2.45
|
||||
'@vueuse/head': 0.7.13_vue@3.2.45
|
||||
'@vueuse/router': 9.11.0_xsxatmlnmmg5bcuv3xdnj6fj7y
|
||||
bcryptjs: 2.4.3
|
||||
change-case: 4.1.2
|
||||
colord: 2.9.3
|
||||
@@ -85,6 +89,7 @@ dependencies:
|
||||
fuse.js: 6.6.2
|
||||
highlight.js: 11.6.0
|
||||
json5: 2.2.1
|
||||
jwt-decode: 3.1.2
|
||||
lodash: 4.17.21
|
||||
mathjs: 10.6.4
|
||||
mime-types: 2.1.35
|
||||
@@ -94,6 +99,7 @@ dependencies:
|
||||
qrcode: 1.5.1
|
||||
randombytes: 2.1.0
|
||||
sql-formatter: 8.2.0
|
||||
ts-pattern: 4.1.3
|
||||
uuid: 8.3.2
|
||||
vue: 3.2.45
|
||||
vue-router: 4.1.6_vue@3.2.45
|
||||
@@ -2170,6 +2176,19 @@ packages:
|
||||
resolution: {integrity: sha512-IwSfzH80bnJMzqhaapqJl9JRIiyQU0zsRGEgnxN6jhq7992cPUJIRfV+JHRIZXjYqbwt07E1gTEp0R0zPJ1aqw==}
|
||||
dev: false
|
||||
|
||||
/@vueuse/router/9.11.0_xsxatmlnmmg5bcuv3xdnj6fj7y:
|
||||
resolution: {integrity: sha512-AlaQzbUy3XeqeoIapQxLvJjPzbdiO/Dt1thQhebP4iFUjc61a7WrboULxNBY+jEH0XipwK/T/b9mBnmn/jEStA==}
|
||||
peerDependencies:
|
||||
vue-router: '>=4.0.0-rc.1'
|
||||
dependencies:
|
||||
'@vueuse/shared': 9.11.0_vue@3.2.45
|
||||
vue-demi: 0.13.11_vue@3.2.45
|
||||
vue-router: 4.1.6_vue@3.2.45
|
||||
transitivePeerDependencies:
|
||||
- '@vue/composition-api'
|
||||
- vue
|
||||
dev: false
|
||||
|
||||
/@vueuse/shared/8.9.4_vue@3.2.45:
|
||||
resolution: {integrity: sha512-wt+T30c4K6dGRMVqPddexEVLa28YwxW5OFIPmzUHICjphfAuBFTTdDoyqREZNDOFJZ44ARH1WWQNCUK8koJ+Ag==}
|
||||
peerDependencies:
|
||||
@@ -2185,6 +2204,15 @@ packages:
|
||||
vue-demi: 0.13.11_vue@3.2.45
|
||||
dev: false
|
||||
|
||||
/@vueuse/shared/9.11.0_vue@3.2.45:
|
||||
resolution: {integrity: sha512-8lO7wD5abYxupKy2KynH1pSgP715ky6iCrWYb8aX2AuAVi9uHXj7qE1dw6BnmArSaLHci4x9iuzWPCpAzUkC/A==}
|
||||
dependencies:
|
||||
vue-demi: 0.13.11_vue@3.2.45
|
||||
transitivePeerDependencies:
|
||||
- '@vue/composition-api'
|
||||
- vue
|
||||
dev: false
|
||||
|
||||
/@vueuse/shared/9.5.0_vue@3.2.45:
|
||||
resolution: {integrity: sha512-HnnCWU1Vg9CVWRCcI8ohDKDRB2Sc4bTgT1XAIaoLSfVHHn+TKbrox6pd3klCSw4UDxkhDfOk8cAdcK+Z5KleCA==}
|
||||
dependencies:
|
||||
@@ -4838,6 +4866,10 @@ packages:
|
||||
promise: 7.3.1
|
||||
dev: true
|
||||
|
||||
/jwt-decode/3.1.2:
|
||||
resolution: {integrity: sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==}
|
||||
dev: false
|
||||
|
||||
/kind-of/6.0.3:
|
||||
resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -6489,6 +6521,10 @@ packages:
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/ts-pattern/4.1.3:
|
||||
resolution: {integrity: sha512-8beXMWTGEv1JfDjSxfNhe4uT5jKYdhmEUKzt4gZW9dmHlquq3b+IbEyA7vX9LjBfzHmvKnM4HiomAUCyaW2Pew==}
|
||||
dev: false
|
||||
|
||||
/tsconfig-paths/3.14.1:
|
||||
resolution: {integrity: sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==}
|
||||
dependencies:
|
||||
|
||||
@@ -36,5 +36,3 @@ function toggleFavorite(event: MouseEvent) {
|
||||
toolStore.addToolToFavorites({ tool });
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
import { useFuzzySearch } from '@/composable/fuzzySearch';
|
||||
import { useTracker } from '@/modules/tracker/tracker.services';
|
||||
import { tools } from '@/tools';
|
||||
import type { Tool } from '@/tools/tools.types';
|
||||
import { SearchRound } from '@vicons/material';
|
||||
import { useMagicKeys, whenever } from '@vueuse/core';
|
||||
import type { NInput } from 'naive-ui';
|
||||
import { computed, h, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import SearchBarItem from './SearchBarItem.vue';
|
||||
|
||||
const router = useRouter();
|
||||
const queryString = ref('');
|
||||
|
||||
const { searchResult } = useFuzzySearch({
|
||||
search: queryString,
|
||||
data: tools,
|
||||
options: { keys: [{ name: 'name', weight: 2 }, 'description', 'keywords'] },
|
||||
});
|
||||
|
||||
const toolToOption = (tool: Tool) => ({ label: tool.name, value: tool.path, tool });
|
||||
|
||||
const router = useRouter();
|
||||
const { tracker } = useTracker();
|
||||
|
||||
const queryString = ref('');
|
||||
const inputEl = ref<HTMLElement>();
|
||||
const displayDropDown = ref(true);
|
||||
const isMac = computed(() => window.navigator.userAgent.toLowerCase().includes('mac'));
|
||||
|
||||
const options = computed(() => {
|
||||
if (queryString.value === '') {
|
||||
return tools.map(toolToOption);
|
||||
@@ -27,12 +28,11 @@ const options = computed(() => {
|
||||
return searchResult.value.map(toolToOption);
|
||||
});
|
||||
|
||||
function onSelect(path: string) {
|
||||
router.push(path);
|
||||
queryString.value = '';
|
||||
}
|
||||
|
||||
const focusTarget = ref();
|
||||
const { searchResult } = useFuzzySearch({
|
||||
search: queryString,
|
||||
data: tools,
|
||||
options: { keys: [{ name: 'name', weight: 2 }, 'description', 'keywords'] },
|
||||
});
|
||||
|
||||
const keys = useMagicKeys({
|
||||
passive: false,
|
||||
@@ -40,16 +40,40 @@ const keys = useMagicKeys({
|
||||
if (e.ctrlKey && e.key === 'k' && e.type === 'keydown') {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (e.metaKey && e.key === 'k' && e.type === 'keydown') {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
whenever(keys.ctrl_k, () => {
|
||||
focusTarget.value.focus();
|
||||
});
|
||||
whenever(keys.ctrl_k, claimFocus);
|
||||
whenever(keys.meta_k, claimFocus);
|
||||
whenever(keys.escape, releaseFocus);
|
||||
|
||||
function renderOption({ tool }: { tool: Tool }) {
|
||||
return h(SearchBarItem, { tool });
|
||||
}
|
||||
|
||||
function onSelect(path: string) {
|
||||
router.push(path);
|
||||
queryString.value = '';
|
||||
}
|
||||
|
||||
function claimFocus() {
|
||||
displayDropDown.value = true;
|
||||
|
||||
inputEl.value?.focus();
|
||||
}
|
||||
|
||||
function releaseFocus() {
|
||||
displayDropDown.value = false;
|
||||
}
|
||||
|
||||
function onFocus() {
|
||||
tracker.trackEvent({ eventName: 'Search-bar focused' });
|
||||
displayDropDown.value = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -60,14 +84,16 @@ function renderOption({ tool }: { tool: Tool }) {
|
||||
:on-select="(value) => onSelect(String(value))"
|
||||
:render-label="renderOption"
|
||||
:default-value="'aa'"
|
||||
:get-show="() => true"
|
||||
:get-show="() => displayDropDown"
|
||||
:on-focus="onFocus"
|
||||
@update:value="() => (displayDropDown = true)"
|
||||
>
|
||||
<template #default="{ handleInput, handleBlur, handleFocus, value: slotValue }">
|
||||
<n-input
|
||||
ref="focusTarget"
|
||||
ref="inputEl"
|
||||
round
|
||||
clearable
|
||||
placeholder="Search a tool... [Ctrl + K]"
|
||||
:placeholder="`Search a tool (use ${isMac ? 'Cmd' : 'Ctrl'} + K to focus)`"
|
||||
:value="slotValue"
|
||||
:input-props="{ autocomplete: 'disabled' }"
|
||||
@input="handleInput"
|
||||
@@ -82,5 +108,3 @@ function renderOption({ tool }: { tool: Tool }) {
|
||||
</n-auto-complete>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
35
src/composable/queryParams.ts
Normal file
35
src/composable/queryParams.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { useRouteQuery } from '@vueuse/router';
|
||||
import { computed } from 'vue';
|
||||
|
||||
export { useQueryParam };
|
||||
|
||||
const transformers = {
|
||||
number: {
|
||||
fromQuery: (value: string) => Number(value),
|
||||
toQuery: (value: number) => String(value),
|
||||
},
|
||||
string: {
|
||||
fromQuery: (value: string) => value,
|
||||
toQuery: (value: string) => value,
|
||||
},
|
||||
boolean: {
|
||||
fromQuery: (value: string) => value.toLowerCase() === 'true',
|
||||
toQuery: (value: boolean) => (value ? 'true' : 'false'),
|
||||
},
|
||||
};
|
||||
|
||||
function useQueryParam<T>({ name, defaultValue }: { name: string; defaultValue: T }) {
|
||||
const type = typeof defaultValue;
|
||||
const transformer = transformers[type as keyof typeof transformers] ?? transformers.string;
|
||||
|
||||
const proxy = useRouteQuery(name, transformer.toQuery(defaultValue as never));
|
||||
|
||||
return computed<T>({
|
||||
get() {
|
||||
return transformer.fromQuery(proxy.value) as T;
|
||||
},
|
||||
set(value) {
|
||||
proxy.value = transformer.toQuery(value as never);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { NIcon, useThemeVars, type MenuGroupOption } from 'naive-ui';
|
||||
import { h } from 'vue';
|
||||
import { computed, h } from 'vue';
|
||||
import { RouterLink, useRoute } from 'vue-router';
|
||||
import { Heart, Menu2, Home2 } from '@vicons/tabler';
|
||||
import { toolsByCategory } from '@/tools';
|
||||
@@ -8,6 +8,8 @@ import { useStyleStore } from '@/stores/style.store';
|
||||
import { config } from '@/config';
|
||||
import MenuIconItem from '@/components/MenuIconItem.vue';
|
||||
import type { Tool } from '@/tools/tools.types';
|
||||
import { useToolStore } from '@/tools/tools.store';
|
||||
import { useTracker } from '@/modules/tracker/tracker.services';
|
||||
import SearchBar from '../components/SearchBar.vue';
|
||||
import HeroGradient from '../assets/hero-gradient.svg?component';
|
||||
import MenuLayout from '../components/MenuLayout.vue';
|
||||
@@ -22,7 +24,17 @@ const commitSha = config.app.lastCommitSha.slice(0, 7);
|
||||
const makeLabel = (tool: Tool) => () => h(RouterLink, { to: tool.path }, { default: () => tool.name });
|
||||
const makeIcon = (tool: Tool) => () => h(MenuIconItem, { tool });
|
||||
|
||||
const menuOptions: MenuGroupOption[] = toolsByCategory.map((category) => ({
|
||||
const { tracker } = useTracker();
|
||||
|
||||
const toolStore = useToolStore();
|
||||
|
||||
const menuOptions = computed<MenuGroupOption[]>(() =>
|
||||
[
|
||||
...(toolStore.favoriteTools.length > 0
|
||||
? [{ name: 'Your favorite tools', components: toolStore.favoriteTools }]
|
||||
: []),
|
||||
...toolsByCategory,
|
||||
].map((category) => ({
|
||||
label: category.name,
|
||||
key: category.name,
|
||||
type: 'group',
|
||||
@@ -31,7 +43,8 @@ const menuOptions: MenuGroupOption[] = toolsByCategory.map((category) => ({
|
||||
icon: makeIcon(tool),
|
||||
key: tool.name,
|
||||
})),
|
||||
}));
|
||||
})),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -147,10 +160,10 @@ const menuOptions: MenuGroupOption[] = toolsByCategory.map((category) => ({
|
||||
target="_blank"
|
||||
class="support-button"
|
||||
:bordered="false"
|
||||
@click="() => tracker.trackEvent({ eventName: 'Support button clicked' })"
|
||||
>
|
||||
Buy me a coffee
|
||||
|
||||
<n-icon v-if="!styleStore.isSmallScreen" :component="Heart" style="margin-left: 8px" size="20px" />
|
||||
<n-icon v-if="!styleStore.isSmallScreen" :component="Heart" style="margin-left: 5px" />
|
||||
</n-button>
|
||||
</template>
|
||||
❤ Support IT Tools development !
|
||||
|
||||
@@ -3,22 +3,22 @@ import { useRoute } from 'vue-router';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import type { HeadObject } from '@vueuse/head';
|
||||
import { computed } from 'vue';
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import FavoriteButton from '@/components/FavoriteButton.vue';
|
||||
import type { Tool } from '@/tools/tools.types';
|
||||
import BaseLayout from './base.layout.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const theme = useThemeVars();
|
||||
|
||||
const head = computed<HeadObject>(() => ({
|
||||
title: `${route.meta.name} - IT Tools`,
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content: route.meta.description,
|
||||
content: route.meta?.description as string,
|
||||
},
|
||||
{
|
||||
name: 'keywords',
|
||||
content: route.meta.keywords,
|
||||
content: ((route.meta.keywords ?? []) as string[]).join(','),
|
||||
},
|
||||
],
|
||||
}));
|
||||
@@ -29,22 +29,18 @@ useHead(head);
|
||||
<base-layout>
|
||||
<div class="tool-layout">
|
||||
<div class="tool-header">
|
||||
<n-space align="center" justify="space-between" :wrap="false">
|
||||
<n-h1>
|
||||
{{ route.meta.name }}
|
||||
|
||||
<n-tag
|
||||
v-if="route.meta.isNew"
|
||||
round
|
||||
type="success"
|
||||
:bordered="false"
|
||||
:color="{ color: theme.primaryColor, textColor: theme.tagColor }"
|
||||
>
|
||||
New tool
|
||||
</n-tag>
|
||||
<!-- <span class="new-tool-badge">New !</span> -->
|
||||
</n-h1>
|
||||
|
||||
<div>
|
||||
<favorite-button :tool="{name: route.meta.name} as Tool" />
|
||||
</div>
|
||||
</n-space>
|
||||
|
||||
<div class="separator" />
|
||||
|
||||
<div class="description">
|
||||
{{ route.meta.description }}
|
||||
</div>
|
||||
@@ -92,6 +88,7 @@ useHead(head);
|
||||
width: 200px;
|
||||
height: 2px;
|
||||
background: rgb(161, 161, 161);
|
||||
opacity: 0.2;
|
||||
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
27
src/modules/tracker/tracker.services.ts
Normal file
27
src/modules/tracker/tracker.services.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import _ from 'lodash';
|
||||
import type Plausible from 'plausible-tracker';
|
||||
import { inject } from 'vue';
|
||||
|
||||
export { createTrackerService, useTracker };
|
||||
|
||||
function createTrackerService({ plausible }: { plausible: ReturnType<typeof Plausible> }) {
|
||||
return {
|
||||
trackEvent({ eventName }: { eventName: string }) {
|
||||
plausible.trackEvent(eventName);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function useTracker() {
|
||||
const plausible: ReturnType<typeof Plausible> | undefined = inject('plausible');
|
||||
|
||||
if (_.isNil(plausible)) {
|
||||
throw new Error('Plausible must be instantiated');
|
||||
}
|
||||
|
||||
const tracker = createTrackerService({ plausible });
|
||||
|
||||
return {
|
||||
tracker,
|
||||
};
|
||||
}
|
||||
3
src/modules/tracker/tracker.types.ts
Normal file
3
src/modules/tracker/tracker.types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { createTrackerService } from './tracker.services';
|
||||
|
||||
export type TrackerService = ReturnType<typeof createTrackerService>;
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { useTracker } from '@/modules/tracker/tracker.services';
|
||||
import { useHead } from '@vueuse/head';
|
||||
|
||||
useHead({ title: 'About - IT Tools' });
|
||||
const { tracker } = useTracker();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -25,6 +27,7 @@ useHead({ title: 'About - IT Tools' });
|
||||
href="https://github.com/sponsors/CorentinTh"
|
||||
rel="noopener"
|
||||
target="_blank"
|
||||
@click="() => tracker.trackEvent({ eventName: 'Support button clicked' })"
|
||||
>
|
||||
sponsoring me </n-button
|
||||
>.
|
||||
|
||||
@@ -12,6 +12,7 @@ useHead({ title: 'IT Tools - Handy online tools for developers' });
|
||||
|
||||
<template>
|
||||
<div class="home-page">
|
||||
<div class="grid-wrapper">
|
||||
<n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8">
|
||||
<n-gi>
|
||||
<colored-card title="You like it-tools?" :icon="Heart">
|
||||
@@ -65,6 +66,7 @@ useHead({ title: 'IT Tools - Handy online tools for developers' });
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="less">
|
||||
@@ -72,8 +74,12 @@ useHead({ title: 'IT Tools - Handy online tools for developers' });
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.n-h3 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
::v-deep(.n-grid) {
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.height-enter-active,
|
||||
|
||||
@@ -53,6 +53,7 @@ import {
|
||||
NTooltip,
|
||||
NUpload,
|
||||
NUploadDragger,
|
||||
NPopover,
|
||||
NCheckbox,
|
||||
} from 'naive-ui';
|
||||
|
||||
@@ -111,6 +112,7 @@ const components = [
|
||||
NIcon,
|
||||
NSwitch,
|
||||
NCollapseTransition,
|
||||
NPopover,
|
||||
];
|
||||
|
||||
export const naive = create({ components });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { config } from '@/config';
|
||||
|
||||
import Plausible from 'plausible-tracker';
|
||||
import type { App } from 'vue';
|
||||
|
||||
@@ -7,6 +8,6 @@ export const plausible = {
|
||||
const plausible = Plausible(config.plausible);
|
||||
plausible.enableAutoPageviews();
|
||||
|
||||
app.config.globalProperties.$plausible = plausible;
|
||||
app.provide('plausible', plausible);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -53,5 +53,3 @@ const b64Validation = useValidation({
|
||||
rules: [{ message: 'Invalid base64 string', validator: (value) => isValidBase64(value.trim()) }],
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useQueryParam } from '@/composable/queryParams';
|
||||
import { enc, lib, MD5, RIPEMD160, SHA1, SHA224, SHA256, SHA3, SHA384, SHA512 } from 'crypto-js';
|
||||
import { ref } from 'vue';
|
||||
import InputCopyable from '../../components/InputCopyable.vue';
|
||||
@@ -59,7 +60,7 @@ const algos = {
|
||||
type AlgoNames = keyof typeof algos;
|
||||
type Encoding = keyof typeof enc | 'Bin';
|
||||
const algoNames = Object.keys(algos) as AlgoNames[];
|
||||
const encoding = ref<Encoding>('Hex');
|
||||
const encoding = useQueryParam<Encoding>({ defaultValue: 'Hex', name: 'encoding' });
|
||||
const clearText = ref('');
|
||||
|
||||
function formatWithEncoding(words: lib.WordArray, encoding: Encoding) {
|
||||
|
||||
@@ -94,5 +94,3 @@ const hmac = computed(() =>
|
||||
);
|
||||
const { copy } = useCopy({ source: hmac });
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { LockOpen } from '@vicons/tabler';
|
||||
|
||||
import { tool as chmodCalculator } from './chmod-calculator';
|
||||
import { tool as mimeTypes } from './mime-types';
|
||||
import { tool as otpCodeGeneratorAndValidator } from './otp-code-generator-and-validator';
|
||||
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 keycodeInfo } from './keycode-info';
|
||||
import { tool as jsonMinify } from './json-minify';
|
||||
import { tool as bcrypt } from './bcrypt';
|
||||
import { tool as bip39 } from './bip39-generator';
|
||||
import { tool as caseConverter } from './case-converter';
|
||||
import { tool as chmodCalculator } from './chmod-calculator';
|
||||
import { tool as chronometer } from './chronometer';
|
||||
import { tool as colorConverter } from './color-converter';
|
||||
import { tool as crontabGenerator } from './crontab-generator';
|
||||
@@ -22,20 +20,24 @@ import { tool as hmacGenerator } from './hmac-generator';
|
||||
import { tool as htmlEntities } from './html-entities';
|
||||
import { tool as baseConverter } from './integer-base-converter';
|
||||
import { tool as jsonViewer } from './json-viewer';
|
||||
import { tool as jwtParser } from './jwt-parser';
|
||||
import { tool as loremIpsumGenerator } from './lorem-ipsum-generator';
|
||||
import { tool as mathEvaluator } from './math-evaluator';
|
||||
import { tool as metaTagGenerator } from './meta-tag-generator';
|
||||
import { tool as mimeTypes } from './mime-types';
|
||||
import { tool as otpCodeGeneratorAndValidator } from './otp-code-generator-and-validator';
|
||||
import { tool as qrCodeGenerator } from './qr-code-generator';
|
||||
import { tool as randomPortGenerator } from './random-port-generator';
|
||||
import { tool as romanNumeralConverter } from './roman-numeral-converter';
|
||||
import { tool as sqlPrettify } from './sql-prettify';
|
||||
import { tool as svgPlaceholderGenerator } from './svg-placeholder-generator';
|
||||
import { tool as temperatureConverter } from './temperature-converter';
|
||||
import { tool as textStatistics } from './text-statistics';
|
||||
import { tool as tokenGenerator } from './token-generator';
|
||||
import type { ToolCategory } from './tools.types';
|
||||
import { tool as urlEncoder } from './url-encoder';
|
||||
import { tool as urlParser } from './url-parser';
|
||||
import { tool as uuidGenerator } from './uuid-generator';
|
||||
import type { ToolCategory } from './tools.types';
|
||||
|
||||
export const toolsByCategory: ToolCategory[] = [
|
||||
{
|
||||
@@ -65,6 +67,8 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
metaTagGenerator,
|
||||
otpCodeGeneratorAndValidator,
|
||||
mimeTypes,
|
||||
jwtParser,
|
||||
keycodeInfo,
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -73,7 +77,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Development',
|
||||
components: [gitMemo, randomPortGenerator, crontabGenerator, jsonViewer, sqlPrettify, chmodCalculator],
|
||||
components: [gitMemo, randomPortGenerator, crontabGenerator, jsonViewer, jsonMinify, sqlPrettify, chmodCalculator],
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
@@ -81,7 +85,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Measurement',
|
||||
components: [chronometer],
|
||||
components: [chronometer, temperatureConverter],
|
||||
},
|
||||
{
|
||||
name: 'Text',
|
||||
|
||||
11
src/tools/json-minify/index.ts
Normal file
11
src/tools/json-minify/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Braces } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'JSON minify',
|
||||
path: '/json-minify',
|
||||
description: 'Minify and compress your JSON by removing unnecessary white spaces.',
|
||||
keywords: ['json', 'minify', 'format'],
|
||||
component: () => import('./json-minify.vue'),
|
||||
icon: Braces,
|
||||
});
|
||||
57
src/tools/json-minify/json-minify.vue
Normal file
57
src/tools/json-minify/json-minify.vue
Normal file
@@ -0,0 +1,57 @@
|
||||
<template>
|
||||
<n-form-item
|
||||
label="Your raw json"
|
||||
:feedback="rawJsonValidation.message"
|
||||
:validation-status="rawJsonValidation.status"
|
||||
>
|
||||
<n-input
|
||||
ref="inputElement"
|
||||
v-model:value="rawJson"
|
||||
placeholder="Paste your raw json here..."
|
||||
type="textarea"
|
||||
rows="20"
|
||||
autocomplete="off"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="Minify version of your JSON">
|
||||
<textarea-copyable :value="cleanJson" language="json" :follow-height-of="inputElement" />
|
||||
</n-form-item>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import JSON5 from 'json5';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
const inputElement = ref<HTMLElement>();
|
||||
|
||||
const rawJson = ref('{\n\t"hello": [\n\t\t"world"\n\t]\n}');
|
||||
const cleanJson = computed(() => withDefaultOnError(() => JSON.stringify(JSON5.parse(rawJson.value), null, 0), ''));
|
||||
|
||||
const rawJsonValidation = useValidation({
|
||||
source: rawJson,
|
||||
rules: [
|
||||
{
|
||||
validator: (v) => v === '' || JSON5.parse(v),
|
||||
message: 'Provided JSON is not valid.',
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.result-card {
|
||||
position: relative;
|
||||
|
||||
.copy-button {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
27
src/tools/jwt-parser/index.ts
Normal file
27
src/tools/jwt-parser/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Key } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'JWT parser',
|
||||
path: '/jwt-parser',
|
||||
description: 'Parse and decode your JSON Web Token (jwt) and display its content.',
|
||||
keywords: [
|
||||
'jwt',
|
||||
'parser',
|
||||
'decode',
|
||||
'typ',
|
||||
'alg',
|
||||
'iss',
|
||||
'sub',
|
||||
'aud',
|
||||
'exp',
|
||||
'nbf',
|
||||
'iat',
|
||||
'jti',
|
||||
'json',
|
||||
'web',
|
||||
'token',
|
||||
],
|
||||
component: () => import('./jwt-parser.vue'),
|
||||
icon: Key,
|
||||
});
|
||||
92
src/tools/jwt-parser/jwt-parser.constants.ts
Normal file
92
src/tools/jwt-parser/jwt-parser.constants.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
// From https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
|
||||
export const ALGORITHM_DESCRIPTIONS: { [k: string]: string } = {
|
||||
HS256: 'HMAC using SHA-256',
|
||||
HS384: 'HMAC using SHA-384',
|
||||
HS512: 'HMAC using SHA-512',
|
||||
RS256: 'RSASSA-PKCS1-v1_5 using SHA-256',
|
||||
RS384: 'RSASSA-PKCS1-v1_5 using SHA-384',
|
||||
RS512: 'RSASSA-PKCS1-v1_5 using SHA-512',
|
||||
ES256: 'ECDSA using P-256 and SHA-256',
|
||||
ES384: 'ECDSA using P-384 and SHA-384',
|
||||
ES512: 'ECDSA using P-521 and SHA-512',
|
||||
PS256: 'RSASSA-PSS using SHA-256 and MGF1 with SHA-256',
|
||||
PS384: 'RSASSA-PSS using SHA-384 and MGF1 with SHA-384',
|
||||
PS512: 'RSASSA-PSS using SHA-512 and MGF1 with SHA-512',
|
||||
none: 'No digital signature or MAC performed',
|
||||
};
|
||||
|
||||
// List extracted from IANA: https://www.iana.org/assignments/jwt/jwt.xhtml
|
||||
export const CLAIM_DESCRIPTIONS: Record<string, string> = {
|
||||
typ: 'Type',
|
||||
alg: 'Algorithm',
|
||||
iss: 'Issuer',
|
||||
sub: 'Subject',
|
||||
aud: 'Audience',
|
||||
exp: 'Expiration Time',
|
||||
nbf: 'Not Before',
|
||||
iat: 'Issued At',
|
||||
jti: 'JWT ID',
|
||||
name: 'Full name',
|
||||
given_name: 'Given name(s) or first name(s)',
|
||||
family_name: 'Surname(s) or last name(s)',
|
||||
middle_name: 'Middle name(s)',
|
||||
nickname: 'Casual name',
|
||||
preferred_username: 'Shorthand name by which the End-User wishes to be referred to',
|
||||
profile: 'Profile page URL',
|
||||
picture: 'Profile picture URL',
|
||||
website: 'Web page or blog URL',
|
||||
email: 'Preferred e-mail address',
|
||||
email_verified: 'True if the e-mail address has been verified; otherwise false',
|
||||
gender: 'Gender',
|
||||
birthdate: 'Birthday',
|
||||
zoneinfo: 'Time zone',
|
||||
locale: 'Locale',
|
||||
phone_number: 'Preferred telephone number',
|
||||
phone_number_verified: 'True if the phone number has been verified; otherwise false',
|
||||
address: 'Preferred postal address',
|
||||
updated_at: 'Time the information was last updated',
|
||||
azp: 'Authorized party - the party to which the ID Token was issued',
|
||||
nonce: 'Value used to associate a Client session with an ID Token',
|
||||
auth_time: 'Time when the authentication occurred',
|
||||
at_hash: 'Access Token hash value',
|
||||
c_hash: 'Code hash value',
|
||||
acr: 'Authentication Context Class Reference',
|
||||
amr: 'Authentication Methods References',
|
||||
sub_jwk: 'Public key used to check the signature of an ID Token',
|
||||
cnf: 'Confirmation',
|
||||
sip_from_tag: 'SIP From tag header field parameter value',
|
||||
sip_date: 'SIP Date header field value',
|
||||
sip_callid: 'SIP Call-Id header field value',
|
||||
sip_cseq_num: 'SIP CSeq numeric header field parameter value',
|
||||
sip_via_branch: 'SIP Via branch header field parameter value',
|
||||
orig: 'Originating Identity String',
|
||||
dest: 'Destination Identity String',
|
||||
mky: 'Media Key Fingerprint String',
|
||||
events: 'Security Events',
|
||||
toe: 'Time of Event',
|
||||
txn: 'Transaction Identifier',
|
||||
rph: 'Resource Priority Header Authorization',
|
||||
sid: 'Session ID',
|
||||
vot: 'Vector of Trust value',
|
||||
vtm: 'Vector of Trust trustmark URL',
|
||||
attest: 'Attestation level as defined in SHAKEN framework',
|
||||
origid: 'Originating Identifier as defined in SHAKEN framework',
|
||||
act: 'Actor',
|
||||
scope: 'Scope Values',
|
||||
client_id: 'Client Identifier',
|
||||
may_act: 'Authorized Actor - the party that is authorized to become the actor',
|
||||
jcard: 'jCard data',
|
||||
at_use_nbr: 'Number of API requests for which the access token can be used',
|
||||
div: 'Diverted Target of a Call',
|
||||
opt: 'Original PASSporT (in Full Form)',
|
||||
vc: 'Verifiable Credential as specified in the W3C Recommendation',
|
||||
vp: 'Verifiable Presentation as specified in the W3C Recommendation',
|
||||
sph: 'SIP Priority header field',
|
||||
ace_profile: 'ACE profile a token is supposed to be used with.',
|
||||
cnonce: 'Client nonce',
|
||||
exi: 'Expires in',
|
||||
roles: 'Roles',
|
||||
groups: 'Groups',
|
||||
entitlements: 'Entitlements',
|
||||
token_introspection: 'Token introspection response',
|
||||
};
|
||||
46
src/tools/jwt-parser/jwt-parser.service.ts
Normal file
46
src/tools/jwt-parser/jwt-parser.service.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import jwtDecode, { type JwtHeader, type JwtPayload } from 'jwt-decode';
|
||||
import _ from 'lodash';
|
||||
import { match } from 'ts-pattern';
|
||||
import { ALGORITHM_DESCRIPTIONS, CLAIM_DESCRIPTIONS } from './jwt-parser.constants';
|
||||
|
||||
export { decodeJwt };
|
||||
|
||||
function decodeJwt({ jwt }: { jwt: string }) {
|
||||
const rawHeader = jwtDecode<JwtHeader>(jwt, { header: true });
|
||||
const rawPayload = jwtDecode<JwtPayload>(jwt);
|
||||
|
||||
const header = _.map(rawHeader, (value, claim) => parseClaims({ claim, value }));
|
||||
const payload = _.map(rawPayload, (value, claim) => parseClaims({ claim, value }));
|
||||
|
||||
return {
|
||||
header,
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
function parseClaims({ claim, value }: { claim: string; value: unknown }) {
|
||||
const claimDescription = CLAIM_DESCRIPTIONS[claim];
|
||||
const formattedValue = _.toString(value);
|
||||
const friendlyValue = getFriendlyValue({ claim, value });
|
||||
|
||||
return {
|
||||
value: formattedValue,
|
||||
friendlyValue,
|
||||
claim,
|
||||
claimDescription,
|
||||
};
|
||||
}
|
||||
|
||||
function getFriendlyValue({ claim, value }: { claim: string; value: unknown }) {
|
||||
return match(claim)
|
||||
.with('exp', 'nbf', 'iat', () => dateFormatter(value))
|
||||
.with('alg', () => (_.isString(value) ? ALGORITHM_DESCRIPTIONS[value] : undefined))
|
||||
.otherwise(() => undefined);
|
||||
}
|
||||
|
||||
const dateFormatter = (value: unknown) => {
|
||||
if (_.isNil(value)) return undefined;
|
||||
|
||||
const date = new Date(Number(value) * 1000);
|
||||
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
||||
};
|
||||
70
src/tools/jwt-parser/jwt-parser.vue
Normal file
70
src/tools/jwt-parser/jwt-parser.vue
Normal file
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<n-card>
|
||||
<n-form-item label="JWT to decode" :feedback="validation.message" :validation-status="validation.status">
|
||||
<n-input v-model:value="rawJwt" type="textarea" placeholder="Put your token here..." rows="5" />
|
||||
</n-form-item>
|
||||
|
||||
<n-table v-if="validation.isValid">
|
||||
<tbody>
|
||||
<template v-for="section of sections" :key="section.key">
|
||||
<th colspan="2" class="table-header">{{ section.title }}</th>
|
||||
<tr v-for="{ claim, claimDescription, friendlyValue, value } in decodedJWT[section.key]" :key="claim + value">
|
||||
<td class="claims">
|
||||
<n-space>
|
||||
<n-text strong>{{ claim }}</n-text>
|
||||
<template v-if="claimDescription">
|
||||
<n-text depth="3">({{ claimDescription }})</n-text>
|
||||
</template>
|
||||
</n-space>
|
||||
</td>
|
||||
<td>
|
||||
<n-space>
|
||||
<n-text>{{ value }}</n-text>
|
||||
<template v-if="friendlyValue">
|
||||
<n-text depth="3">({{ friendlyValue }})</n-text>
|
||||
</template>
|
||||
</n-space>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</n-table>
|
||||
</n-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
import { computed, ref } from 'vue';
|
||||
import { decodeJwt } from './jwt-parser.service';
|
||||
|
||||
const rawJwt = ref(
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
|
||||
);
|
||||
|
||||
const decodedJWT = computed(() =>
|
||||
withDefaultOnError(() => decodeJwt({ jwt: rawJwt.value }), { header: [], payload: [] }),
|
||||
);
|
||||
|
||||
const sections = [
|
||||
{ key: 'header', title: 'Header' },
|
||||
{ key: 'payload', title: 'Payload' },
|
||||
] as const;
|
||||
|
||||
const validation = useValidation({
|
||||
source: rawJwt,
|
||||
rules: [
|
||||
{
|
||||
validator: (value) => value.length > 0 && isNotThrowing(() => decodeJwt({ jwt: rawJwt.value })),
|
||||
message: 'Invalid JWT',
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.table-header {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
26
src/tools/keycode-info/index.ts
Normal file
26
src/tools/keycode-info/index.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Keyboard } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Keycode info',
|
||||
path: '/keycode-info',
|
||||
description: 'Find the javascript keycode, code, location and modifiers of any pressed key.',
|
||||
keywords: [
|
||||
'keycode',
|
||||
'info',
|
||||
'code',
|
||||
'javascript',
|
||||
'event',
|
||||
'keycodes',
|
||||
'which',
|
||||
'keyboard',
|
||||
'press',
|
||||
'modifier',
|
||||
'alt',
|
||||
'ctrl',
|
||||
'meta',
|
||||
'shift',
|
||||
],
|
||||
component: () => import('./keycode-info.vue'),
|
||||
icon: Keyboard,
|
||||
});
|
||||
67
src/tools/keycode-info/keycode-info.vue
Normal file
67
src/tools/keycode-info/keycode-info.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-card style="text-align: center; padding: 40px 0; margin-bottom: 26px">
|
||||
<n-h2 v-if="event">{{ event.key }}</n-h2>
|
||||
<n-text strong depth="3">Press the key on your keyboard you want to now stuff</n-text>
|
||||
</n-card>
|
||||
|
||||
<n-input-group v-for="({ label, value, placeholder }, i) of fields" :key="i" style="margin-bottom: 5px">
|
||||
<n-input-group-label style="flex: 0 0 150px"> {{ label }} </n-input-group-label>
|
||||
<input-copyable :value="value" readonly :placeholder="placeholder" />
|
||||
</n-input-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useEventListener } from '@vueuse/core';
|
||||
import { computed, ref } from 'vue';
|
||||
import InputCopyable from '../../components/InputCopyable.vue';
|
||||
|
||||
const event = ref<KeyboardEvent>();
|
||||
|
||||
useEventListener(document, 'keydown', (e) => {
|
||||
event.value = e;
|
||||
});
|
||||
|
||||
const fields = computed(() => {
|
||||
if (!event.value) return [];
|
||||
|
||||
return [
|
||||
{
|
||||
label: 'Key :',
|
||||
value: event.value.key,
|
||||
placeholder: 'Key name...',
|
||||
},
|
||||
{
|
||||
label: 'Keycode :',
|
||||
value: String(event.value.keyCode),
|
||||
placeholder: 'Keycode...',
|
||||
},
|
||||
{
|
||||
label: 'Code :',
|
||||
value: event.value.code,
|
||||
placeholder: 'Code...',
|
||||
},
|
||||
{
|
||||
label: 'Location :',
|
||||
value: String(event.value.location),
|
||||
placeholder: 'Code...',
|
||||
},
|
||||
|
||||
{
|
||||
label: 'Modifiers :',
|
||||
value: [
|
||||
event.value.metaKey && 'Meta',
|
||||
event.value.shiftKey && 'Shift',
|
||||
event.value.ctrlKey && 'Ctrl',
|
||||
event.value.altKey && 'Alt',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' + '),
|
||||
placeholder: 'None',
|
||||
},
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@@ -29,5 +29,3 @@ const expression = ref('');
|
||||
|
||||
const result = computed(() => withDefaultOnError(() => evaluate(expression.value) ?? '', ''));
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
@@ -95,5 +95,3 @@ const selectedExtension = ref(undefined);
|
||||
|
||||
const mimeTypeFound = computed(() => (selectedExtension.value ? extensionToMimeType[selectedExtension.value] : []));
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
24
src/tools/temperature-converter/index.ts
Normal file
24
src/tools/temperature-converter/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Temperature } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Temperature converter',
|
||||
path: '/temperature-converter',
|
||||
description:
|
||||
'Temperature degrees conversions for Kelvin, Celsius, Fahrenheit, Rankine, Delisle, Newton, Réaumur and Rømer.',
|
||||
keywords: [
|
||||
'temperature',
|
||||
'converter',
|
||||
'degree',
|
||||
'Kelvin',
|
||||
'Celsius',
|
||||
'Fahrenheit',
|
||||
'Rankine',
|
||||
'Delisle',
|
||||
'Newton',
|
||||
'Réaumur',
|
||||
'Rømer',
|
||||
],
|
||||
component: () => import('./temperature-converter.vue'),
|
||||
icon: Temperature,
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
export const convertCelsiusToKelvin = (temperature: number) => temperature + 273.15;
|
||||
export const convertKelvinToCelsius = (temperature: number) => temperature - 273.15;
|
||||
|
||||
export const convertFahrenheitToKelvin = (temperature: number) => (temperature + 459.67) * (5 / 9);
|
||||
export const convertKelvinToFahrenheit = (temperature: number) => temperature * (9 / 5) - 459.67;
|
||||
|
||||
export const convertRankineToKelvin = (temperature: number) => temperature * (5 / 9);
|
||||
export const convertKelvinToRankine = (temperature: number) => temperature * (9 / 5);
|
||||
|
||||
export const convertDelisleToKelvin = (temperature: number) => 373.15 - (2 / 3) * temperature;
|
||||
export const convertKelvinToDelisle = (temperature: number) => (3 / 2) * (373.15 - temperature);
|
||||
|
||||
export const convertNewtonToKelvin = (temperature: number) => temperature * (100 / 33) + 273.15;
|
||||
export const convertKelvinToNewton = (temperature: number) => (temperature - 273.15) * (33 / 100);
|
||||
|
||||
export const convertReaumurToKelvin = (temperature: number) => temperature * (5 / 4) + 273.15;
|
||||
export const convertKelvinToReaumur = (temperature: number) => (temperature - 273.15) * (4 / 5);
|
||||
|
||||
export const convertRomerToKelvin = (temperature: number) => (temperature - 7.5) * (40 / 21) + 273.15;
|
||||
export const convertKelvinToRomer = (temperature: number) => (temperature - 273.15) * (21 / 40) + 7.5;
|
||||
127
src/tools/temperature-converter/temperature-converter.vue
Normal file
127
src/tools/temperature-converter/temperature-converter.vue
Normal file
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-input-group
|
||||
v-for="[key, { title, unit }] in Object.entries(units)"
|
||||
:key="key"
|
||||
style="width: 100%; margin-bottom: 15px"
|
||||
>
|
||||
<n-input-group-label style="width: 100px">
|
||||
{{ title }}
|
||||
</n-input-group-label>
|
||||
|
||||
<n-input-number
|
||||
v-model:value="units[key].ref"
|
||||
style="flex: 1"
|
||||
@update:value="() => update(key as TemperatureScale)"
|
||||
/>
|
||||
|
||||
<n-input-group-label style="width: 50px">
|
||||
{{ unit }}
|
||||
</n-input-group-label>
|
||||
</n-input-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import _ from 'lodash';
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
convertCelsiusToKelvin,
|
||||
convertDelisleToKelvin,
|
||||
convertFahrenheitToKelvin,
|
||||
convertKelvinToCelsius,
|
||||
convertKelvinToDelisle,
|
||||
convertKelvinToFahrenheit,
|
||||
convertKelvinToNewton,
|
||||
convertKelvinToRankine,
|
||||
convertKelvinToReaumur,
|
||||
convertKelvinToRomer,
|
||||
convertNewtonToKelvin,
|
||||
convertRankineToKelvin,
|
||||
convertReaumurToKelvin,
|
||||
convertRomerToKelvin,
|
||||
} from './temperature-converter.models';
|
||||
|
||||
type TemperatureScale = 'kelvin' | 'celsius' | 'fahrenheit' | 'rankine' | 'delisle' | 'newton' | 'reaumur' | 'romer';
|
||||
|
||||
const units = reactive<
|
||||
Record<
|
||||
string | TemperatureScale,
|
||||
{ title: string; unit: string; ref: number; toKelvin: (v: number) => number; fromKelvin: (v: number) => number }
|
||||
>
|
||||
>({
|
||||
kelvin: {
|
||||
title: 'Kelvin',
|
||||
unit: 'K',
|
||||
ref: 0,
|
||||
toKelvin: _.identity,
|
||||
fromKelvin: _.identity,
|
||||
},
|
||||
celsius: {
|
||||
title: 'Celsius',
|
||||
unit: '°C',
|
||||
ref: 0,
|
||||
toKelvin: convertCelsiusToKelvin,
|
||||
fromKelvin: convertKelvinToCelsius,
|
||||
},
|
||||
fahrenheit: {
|
||||
title: 'Fahrenheit',
|
||||
unit: '°F',
|
||||
ref: 0,
|
||||
toKelvin: convertFahrenheitToKelvin,
|
||||
fromKelvin: convertKelvinToFahrenheit,
|
||||
},
|
||||
rankine: {
|
||||
title: 'Rankine',
|
||||
unit: '°R',
|
||||
ref: 0,
|
||||
toKelvin: convertRankineToKelvin,
|
||||
fromKelvin: convertKelvinToRankine,
|
||||
},
|
||||
delisle: {
|
||||
title: 'Delisle',
|
||||
unit: '°De',
|
||||
ref: 0,
|
||||
toKelvin: convertDelisleToKelvin,
|
||||
fromKelvin: convertKelvinToDelisle,
|
||||
},
|
||||
newton: {
|
||||
title: 'Newton',
|
||||
unit: '°N',
|
||||
ref: 0,
|
||||
toKelvin: convertNewtonToKelvin,
|
||||
fromKelvin: convertKelvinToNewton,
|
||||
},
|
||||
reaumur: {
|
||||
title: 'Réaumur',
|
||||
unit: '°Ré',
|
||||
ref: 0,
|
||||
toKelvin: convertReaumurToKelvin,
|
||||
fromKelvin: convertKelvinToReaumur,
|
||||
},
|
||||
romer: {
|
||||
title: 'Rømer',
|
||||
unit: '°Rø',
|
||||
ref: 0,
|
||||
toKelvin: convertRomerToKelvin,
|
||||
fromKelvin: convertKelvinToRomer,
|
||||
},
|
||||
});
|
||||
|
||||
function update(key: TemperatureScale) {
|
||||
const { ref: value, toKelvin } = units[key];
|
||||
|
||||
const kelvins = toKelvin(value) ?? 0;
|
||||
|
||||
_.chain(units)
|
||||
.omit(key)
|
||||
.forEach(({ fromKelvin }, index) => {
|
||||
units[index].ref = Math.floor((fromKelvin(kelvins) ?? 0) * 100) / 100;
|
||||
})
|
||||
.value();
|
||||
}
|
||||
|
||||
update('kelvin');
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@@ -54,18 +54,19 @@
|
||||
<script setup lang="ts">
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useQueryParam } from '@/composable/queryParams';
|
||||
import { createToken } from './token-generator.service';
|
||||
|
||||
const token = ref('');
|
||||
const length = ref(64);
|
||||
const length = useQueryParam({ name: 'length', defaultValue: 64 });
|
||||
const { copy } = useCopy({ source: token, text: 'Token copied to the clipboard' });
|
||||
|
||||
const withUppercase = ref(true);
|
||||
const withLowercase = ref(true);
|
||||
const withNumbers = ref(true);
|
||||
const withSymbols = ref(false);
|
||||
const withUppercase = useQueryParam({ name: 'uppercase', defaultValue: true });
|
||||
const withLowercase = useQueryParam({ name: 'lowercase', defaultValue: true });
|
||||
const withNumbers = useQueryParam({ name: 'numbers', defaultValue: true });
|
||||
const withSymbols = useQueryParam({ name: 'symbols', defaultValue: false });
|
||||
|
||||
watch([withUppercase, withLowercase, withNumbers, withSymbols, length], refreshToken);
|
||||
watch([withUppercase, withLowercase, withNumbers, withSymbols, length], refreshToken, { immediate: true });
|
||||
|
||||
function refreshToken() {
|
||||
token.value = createToken({
|
||||
@@ -76,6 +77,4 @@ function refreshToken() {
|
||||
withSymbols: withSymbols.value,
|
||||
});
|
||||
}
|
||||
|
||||
refreshToken();
|
||||
</script>
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { ref, watch } from 'vue';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
import { useQueryParam } from '@/composable/queryParams';
|
||||
|
||||
const count = ref(1);
|
||||
const count = useQueryParam({ defaultValue: 1, name: 'count' });
|
||||
|
||||
const uuids = ref('');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user