mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 23:00:19 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55b4a8ce57 |
No files matched your search
@@ -286,9 +286,6 @@
|
||||
"watchTriggerable": true,
|
||||
"watchWithFilter": true,
|
||||
"whenever": true,
|
||||
"toValue": true,
|
||||
"injectLocal": true,
|
||||
"provideLocal": true,
|
||||
"useClipboardItems": true
|
||||
"toValue": true
|
||||
}
|
||||
}
|
||||
Vendored
-9
@@ -36,7 +36,6 @@ declare global {
|
||||
const h: typeof import('vue')['h']
|
||||
const ignorableWatch: typeof import('@vueuse/core')['ignorableWatch']
|
||||
const inject: typeof import('vue')['inject']
|
||||
const injectLocal: typeof import('@vueuse/core')['injectLocal']
|
||||
const isDefined: typeof import('@vueuse/core')['isDefined']
|
||||
const isProxy: typeof import('vue')['isProxy']
|
||||
const isReactive: typeof import('vue')['isReactive']
|
||||
@@ -66,7 +65,6 @@ declare global {
|
||||
const onUpdated: typeof import('vue')['onUpdated']
|
||||
const pausableWatch: typeof import('@vueuse/core')['pausableWatch']
|
||||
const provide: typeof import('vue')['provide']
|
||||
const provideLocal: typeof import('@vueuse/core')['provideLocal']
|
||||
const reactify: typeof import('@vueuse/core')['reactify']
|
||||
const reactifyObject: typeof import('@vueuse/core')['reactifyObject']
|
||||
const reactive: typeof import('vue')['reactive']
|
||||
@@ -130,7 +128,6 @@ declare global {
|
||||
const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation']
|
||||
const useCached: typeof import('@vueuse/core')['useCached']
|
||||
const useClipboard: typeof import('@vueuse/core')['useClipboard']
|
||||
const useClipboardItems: typeof import('@vueuse/core')['useClipboardItems']
|
||||
const useCloned: typeof import('@vueuse/core')['useCloned']
|
||||
const useColorMode: typeof import('@vueuse/core')['useColorMode']
|
||||
const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog']
|
||||
@@ -329,7 +326,6 @@ declare module 'vue' {
|
||||
readonly h: UnwrapRef<typeof import('vue')['h']>
|
||||
readonly ignorableWatch: UnwrapRef<typeof import('@vueuse/core')['ignorableWatch']>
|
||||
readonly inject: UnwrapRef<typeof import('vue')['inject']>
|
||||
readonly injectLocal: UnwrapRef<typeof import('@vueuse/core')['injectLocal']>
|
||||
readonly isDefined: UnwrapRef<typeof import('@vueuse/core')['isDefined']>
|
||||
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
|
||||
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
|
||||
@@ -359,7 +355,6 @@ declare module 'vue' {
|
||||
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
|
||||
readonly pausableWatch: UnwrapRef<typeof import('@vueuse/core')['pausableWatch']>
|
||||
readonly provide: UnwrapRef<typeof import('vue')['provide']>
|
||||
readonly provideLocal: UnwrapRef<typeof import('@vueuse/core')['provideLocal']>
|
||||
readonly reactify: UnwrapRef<typeof import('@vueuse/core')['reactify']>
|
||||
readonly reactifyObject: UnwrapRef<typeof import('@vueuse/core')['reactifyObject']>
|
||||
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
|
||||
@@ -423,7 +418,6 @@ declare module 'vue' {
|
||||
readonly useBrowserLocation: UnwrapRef<typeof import('@vueuse/core')['useBrowserLocation']>
|
||||
readonly useCached: UnwrapRef<typeof import('@vueuse/core')['useCached']>
|
||||
readonly useClipboard: UnwrapRef<typeof import('@vueuse/core')['useClipboard']>
|
||||
readonly useClipboardItems: UnwrapRef<typeof import('@vueuse/core')['useClipboardItems']>
|
||||
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
|
||||
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
|
||||
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
|
||||
@@ -616,7 +610,6 @@ declare module '@vue/runtime-core' {
|
||||
readonly h: UnwrapRef<typeof import('vue')['h']>
|
||||
readonly ignorableWatch: UnwrapRef<typeof import('@vueuse/core')['ignorableWatch']>
|
||||
readonly inject: UnwrapRef<typeof import('vue')['inject']>
|
||||
readonly injectLocal: UnwrapRef<typeof import('@vueuse/core')['injectLocal']>
|
||||
readonly isDefined: UnwrapRef<typeof import('@vueuse/core')['isDefined']>
|
||||
readonly isProxy: UnwrapRef<typeof import('vue')['isProxy']>
|
||||
readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
|
||||
@@ -646,7 +639,6 @@ declare module '@vue/runtime-core' {
|
||||
readonly onUpdated: UnwrapRef<typeof import('vue')['onUpdated']>
|
||||
readonly pausableWatch: UnwrapRef<typeof import('@vueuse/core')['pausableWatch']>
|
||||
readonly provide: UnwrapRef<typeof import('vue')['provide']>
|
||||
readonly provideLocal: UnwrapRef<typeof import('@vueuse/core')['provideLocal']>
|
||||
readonly reactify: UnwrapRef<typeof import('@vueuse/core')['reactify']>
|
||||
readonly reactifyObject: UnwrapRef<typeof import('@vueuse/core')['reactifyObject']>
|
||||
readonly reactive: UnwrapRef<typeof import('vue')['reactive']>
|
||||
@@ -710,7 +702,6 @@ declare module '@vue/runtime-core' {
|
||||
readonly useBrowserLocation: UnwrapRef<typeof import('@vueuse/core')['useBrowserLocation']>
|
||||
readonly useCached: UnwrapRef<typeof import('@vueuse/core')['useCached']>
|
||||
readonly useClipboard: UnwrapRef<typeof import('@vueuse/core')['useClipboard']>
|
||||
readonly useClipboardItems: UnwrapRef<typeof import('@vueuse/core')['useClipboardItems']>
|
||||
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
|
||||
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
|
||||
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
|
||||
|
||||
Vendored
+2
-4
@@ -82,7 +82,6 @@ declare module '@vue/runtime-core' {
|
||||
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
|
||||
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
|
||||
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
|
||||
GptTokenEstimator: typeof import('./src/tools/gpt-token-estimator/gpt-token-estimator.vue')['default']
|
||||
HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default']
|
||||
HmacGenerator: typeof import('./src/tools/hmac-generator/hmac-generator.vue')['default']
|
||||
'Home.page': typeof import('./src/pages/Home.page.vue')['default']
|
||||
@@ -132,19 +131,18 @@ declare module '@vue/runtime-core' {
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
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']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
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']
|
||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
"figlet": "^1.7.0",
|
||||
"figue": "^1.2.0",
|
||||
"fuse.js": "^6.6.2",
|
||||
"gpt-tokens": "^1.3.13",
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
|
||||
Generated
+1712
-1945
File diff suppressed because it is too large.
Load diff
@@ -1,170 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { GPTTokens } from 'gpt-tokens';
|
||||
import JSON5 from 'json5';
|
||||
import type { supportModelType } from 'gpt-tokens';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
const models = GPTTokens.supportModels;
|
||||
|
||||
const model = useQueryParamOrStorage({ name: 'model', storageName: 'gpt-counter:model', defaultValue: 'gpt-3.5-turbo-1106' });
|
||||
const systemPrompt = ref('');
|
||||
const userPrompt = ref('');
|
||||
|
||||
const isAdvancedMode = ref(false);
|
||||
const messagesJsonArray = ref('');
|
||||
const toolsJsonArray = ref('');
|
||||
|
||||
const messagesValidation = useValidation({
|
||||
source: messagesJsonArray,
|
||||
rules: [
|
||||
{
|
||||
message: 'Invalid "messages" array',
|
||||
validator: value => value && JSON5.parse(value.trim()),
|
||||
},
|
||||
],
|
||||
});
|
||||
const toolsValidation = useValidation({
|
||||
source: toolsJsonArray,
|
||||
rules: [
|
||||
{
|
||||
message: 'Invalid "tools" array',
|
||||
validator: value => value && JSON5.parse(value.trim()),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const outputTokenCosts = computed(() => {
|
||||
try {
|
||||
let messagesArray = [];
|
||||
let toolsArray = [];
|
||||
|
||||
if (isAdvancedMode.value) {
|
||||
messagesArray = messagesJsonArray.value ? JSON5.parse(messagesJsonArray.value.trim()) : [];
|
||||
toolsArray = toolsJsonArray.value ? JSON5.parse(toolsJsonArray.value.trim()) : [];
|
||||
}
|
||||
else {
|
||||
if (systemPrompt.value) {
|
||||
messagesArray.push({ role: 'system', content: systemPrompt.value });
|
||||
}
|
||||
if (userPrompt.value) {
|
||||
messagesArray.push({ role: 'user', content: userPrompt.value });
|
||||
}
|
||||
}
|
||||
|
||||
if (!messagesArray.length) {
|
||||
return {
|
||||
error: '',
|
||||
usedTokens: '0',
|
||||
usedUSD: '0',
|
||||
promptUsedTokens: '0',
|
||||
completionUsedTokens: '0',
|
||||
};
|
||||
}
|
||||
|
||||
const tokens = new GPTTokens({
|
||||
model: model.value as supportModelType,
|
||||
messages: messagesArray,
|
||||
tools: toolsArray,
|
||||
});
|
||||
return {
|
||||
error: '',
|
||||
usedTokens: tokens.usedTokens.toString(),
|
||||
usedUSD: tokens.usedUSD.toString(),
|
||||
promptUsedTokens: tokens.promptUsedTokens.toString(),
|
||||
completionUsedTokens: tokens.completionUsedTokens.toString(),
|
||||
};
|
||||
}
|
||||
catch (e: any) {
|
||||
return {
|
||||
error: e.toString(),
|
||||
usedTokens: '',
|
||||
usedUSD: '',
|
||||
promptUsedTokens: '',
|
||||
completionUsedTokens: '',
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-select
|
||||
v-model:value="model"
|
||||
label-position="left"
|
||||
label="Model:"
|
||||
:options="models"
|
||||
placeholder="Select GPT model"
|
||||
mb-2
|
||||
/>
|
||||
|
||||
<div flex justify-center>
|
||||
<n-form-item label="Advanded JSON Mode" label-placement="left">
|
||||
<n-checkbox v-model:checked="isAdvancedMode" mr-2 />
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<c-card v-if="isAdvancedMode" title="Prompts">
|
||||
<c-input-text
|
||||
v-model:value="messagesJsonArray"
|
||||
multiline raw-text
|
||||
placeholder="Your 'messages' JSON array..."
|
||||
rows="5"
|
||||
autofocus
|
||||
label="Your 'messages' JSON array:"
|
||||
:validation="messagesValidation"
|
||||
/>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="toolsJsonArray"
|
||||
multiline raw-text
|
||||
placeholder="Your 'tools' JSON array..."
|
||||
rows="5"
|
||||
autofocus
|
||||
label="Your 'tools' JSON array:"
|
||||
:validation="toolsValidation"
|
||||
/>
|
||||
</c-card>
|
||||
<c-card v-else title="Input JSON(s)">
|
||||
<c-input-text
|
||||
v-model:value="systemPrompt"
|
||||
multiline raw-text
|
||||
placeholder="Your System Prompt content..."
|
||||
rows="2"
|
||||
autofocus
|
||||
label="Your System Prompt content:"
|
||||
/>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="userPrompt"
|
||||
multiline raw-text
|
||||
placeholder="Your User Prompt content..."
|
||||
rows="6"
|
||||
autofocus
|
||||
label="Your User Prompt content:"
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-alert v-if="outputTokenCosts.error">
|
||||
{{ outputTokenCosts.error }}
|
||||
</c-alert>
|
||||
|
||||
<div v-if="!outputTokenCosts.error">
|
||||
<n-form-item label="Used Tokens:">
|
||||
<TextareaCopyable :value="outputTokenCosts.usedTokens" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Prompt Tokens:">
|
||||
<TextareaCopyable :value="outputTokenCosts.promptUsedTokens" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Completion Tokens:">
|
||||
<TextareaCopyable :value="outputTokenCosts.completionUsedTokens" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Used USD:">
|
||||
<TextareaCopyable :value="outputTokenCosts.usedUSD" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { CurrencyDollar } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'GPT Token Estimator',
|
||||
path: '/gpt-token-estimator',
|
||||
description: 'OpenAI GPT Token Estimator',
|
||||
keywords: ['gpt', 'token', 'estimator'],
|
||||
component: () => import('./gpt-token-estimator.vue'),
|
||||
icon: CurrencyDollar,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -2,7 +2,6 @@ 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 gptTokenEstimator } from './gpt-token-estimator';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
@@ -161,7 +160,6 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
emailNormalizer,
|
||||
regexTester,
|
||||
regexMemo,
|
||||
gptTokenEstimator,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Link } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.url-encoder.title'),
|
||||
name: 'Encode/decode url formatted strings',
|
||||
path: '/url-encoder',
|
||||
description: translate('tools.url-encoder.description'),
|
||||
description: 'Encode to url-encoded format (also known as "percent-encoded") or decode from it.',
|
||||
keywords: ['url', 'encode', 'decode', 'percent', '%20', 'format'],
|
||||
component: () => import('./url-encoder.vue'),
|
||||
icon: Link,
|
||||
|
||||
@@ -1,17 +1,82 @@
|
||||
<script setup lang="ts">
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
const encodings = [
|
||||
{ value: 'URIComponent', label: 'URIComponent' },
|
||||
{ value: 'RFC3986URIComponent', label: 'RFC3986 - URIComponent' },
|
||||
{ value: 'RFC5987', label: 'RFC5987 (Link - Content-Disposition)' },
|
||||
{ value: 'URI', label: 'URI' },
|
||||
{ value: 'RFC3986URI', label: 'RFC3986 - URI' },
|
||||
];
|
||||
const encoding = useQueryParamOrStorage({ name: 'enc', storageName: 'url-encode:enc', defaultValue: 'URIComponent' });
|
||||
|
||||
function encodeRFC3986URIComponent(str: string) {
|
||||
return encodeURIComponent(str).replace(
|
||||
/[!'()*]/g,
|
||||
(c: string) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
|
||||
);
|
||||
}
|
||||
|
||||
function encodeRFC5987ValueChars(str: string) {
|
||||
return (
|
||||
encodeURIComponent(str)
|
||||
// The following creates the sequences %27 %28 %29 %2A (Note that
|
||||
// the valid encoding of "*" is %2A, which necessitates calling
|
||||
// toUpperCase() to properly encode). Although RFC3986 reserves "!",
|
||||
// RFC5987 does not, so we do not need to escape it.
|
||||
.replace(
|
||||
/['()*]/g,
|
||||
c => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
|
||||
)
|
||||
// The following are not required for percent-encoding per RFC5987,
|
||||
// so we can allow for a little better readability over the wire: |`^
|
||||
.replace(/%(7C|60|5E)/g, (str, hex) =>
|
||||
String.fromCharCode(Number.parseInt(hex, 16)),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function encodeRFC3986URI(str: string) {
|
||||
return encodeURI(str)
|
||||
.replace(/%5B/g, '[')
|
||||
.replace(/%5D/g, ']')
|
||||
.replace(
|
||||
/[!'()*]/g,
|
||||
c => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
|
||||
);
|
||||
}
|
||||
|
||||
function encode(str: string) {
|
||||
if (encoding.value === 'URIComponent') {
|
||||
return encodeURIComponent(str);
|
||||
}
|
||||
if (encoding.value === 'RFC3986URIComponent') {
|
||||
return encodeRFC3986URIComponent(str);
|
||||
}
|
||||
if (encoding.value === 'RFC5987') {
|
||||
return encodeRFC5987ValueChars(str);
|
||||
}
|
||||
if (encoding.value === 'URI') {
|
||||
return encodeURI(str);
|
||||
}
|
||||
if (encoding.value === 'RFC3986URI') {
|
||||
return encodeRFC3986URI(str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const encodeInput = ref('Hello world :)');
|
||||
const encodeOutput = computed(() => withDefaultOnError(() => encodeURIComponent(encodeInput.value), ''));
|
||||
const encodeOutput = computed(() => withDefaultOnError(() => encode(encodeInput.value), ''));
|
||||
|
||||
const encodedValidation = useValidation({
|
||||
source: encodeInput,
|
||||
rules: [
|
||||
{
|
||||
validator: value => isNotThrowing(() => encodeURIComponent(value)),
|
||||
validator: value => isNotThrowing(() => encode(value)),
|
||||
message: 'Impossible to parse this string',
|
||||
},
|
||||
],
|
||||
@@ -23,7 +88,7 @@ const decodeInput = ref('Hello%20world%20%3A)');
|
||||
const decodeOutput = computed(() => withDefaultOnError(() => decodeURIComponent(decodeInput.value), ''));
|
||||
|
||||
const decodeValidation = useValidation({
|
||||
source: decodeInput,
|
||||
source: encodeInput,
|
||||
rules: [
|
||||
{
|
||||
validator: value => isNotThrowing(() => decodeURIComponent(value)),
|
||||
@@ -37,6 +102,15 @@ const { copy: copyDecoded } = useCopy({ source: decodeOutput, text: 'Decoded str
|
||||
|
||||
<template>
|
||||
<c-card title="Encode">
|
||||
<c-select
|
||||
v-model:value="encoding"
|
||||
label="Encoding Kind:"
|
||||
label-position="left"
|
||||
:options="encodings"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-input-text
|
||||
v-model:value="encodeInput"
|
||||
label="Your string :"
|
||||
|
||||
Reference in new issue
Block a user