Compare commits

..
Author SHA1 Message Date
ShareVB 83a78e989d fix: better display 2024-04-28 22:06:17 +02:00
sharevb e10beda5b0 feat(ui): add c-monaco-editor to ui lib 2024-04-28 21:40:46 +02:00
sharevb 9390435366 feat(new tool): JSON Linter
Fix part of #605
2024-04-28 21:40:43 +02:00
sharevb 75269c8cd7 feat(new tool): JSON Linter
Fix part of #605
2024-04-28 12:51:16 +02:00
sharevb 9eac9cb2a9 fix(integer base converter): support bigint (#872) 2024-04-22 08:45:51 +02:00
sharevb 23f82d956a fix(bcrypt tool): allow salt rounds up to 100 (#987)
* fix(bcrypt tool): allow salt rounds up to 100

Previously max salt rounds was 10

* chore(github workflows): ci and e2e tests: try updating to node 20
2024-04-15 09:43:12 +02:00
17 changed files with 289 additions and 408 deletions

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'pnpm'
- name: Install dependencies
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'pnpm'
- name: Get Playwright version
+6 -5
View File
@@ -50,6 +50,7 @@ declare module '@vue/runtime-core' {
'CModal.demo': typeof import('./src/ui/c-modal/c-modal.demo.vue')['default']
CModalValue: typeof import('./src/ui/c-modal-value/c-modal-value.vue')['default']
'CModalValue.demo': typeof import('./src/ui/c-modal-value/c-modal-value.demo.vue')['default']
CMonacoEditor: typeof import('./src/ui/c-monaco-editor/c-monaco-editor.vue')['default']
CollapsibleToolMenu: typeof import('./src/components/CollapsibleToolMenu.vue')['default']
ColorConverter: typeof import('./src/tools/color-converter/color-converter.vue')['default']
ColoredCard: typeof import('./src/components/ColoredCard.vue')['default']
@@ -107,6 +108,7 @@ declare module '@vue/runtime-core' {
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']
Ipv6UlaGenerator: typeof import('./src/tools/ipv6-ula-generator/ipv6-ula-generator.vue')['default']
JsonDiff: typeof import('./src/tools/json-diff/json-diff.vue')['default']
JsonLinter: typeof import('./src/tools/json-linter/json-linter.vue')['default']
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
JsonToToml: typeof import('./src/tools/json-to-toml/json-to-toml.vue')['default']
@@ -126,25 +128,23 @@ declare module '@vue/runtime-core' {
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NA: typeof import('naive-ui')['NA']
NAlert: typeof import('naive-ui')['NAlert']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
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']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpin: typeof import('naive-ui')['NSpin']
NSwitch: typeof import('naive-ui')['NSwitch']
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']
@@ -159,6 +159,7 @@ declare module '@vue/runtime-core' {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
+2 -3
View File
@@ -35,6 +35,7 @@
"release": "node ./scripts/release.mjs"
},
"dependencies": {
"@guolao/vue-monaco-editor": "^1.4.1",
"@it-tools/bip39": "^0.0.4",
"@it-tools/oggen": "^1.3.0",
"@sindresorhus/slugify": "^2.2.1",
@@ -42,7 +43,6 @@
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/figlet": "^1.5.8",
"@types/spdx-satisfies": "^0.1.2",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^10.3.0",
@@ -66,6 +66,7 @@
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"json5": "^2.2.3",
"jsonlint-mod": "^1.7.6",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
@@ -81,8 +82,6 @@
"pinia": "^2.0.34",
"plausible-tracker": "^0.3.8",
"qrcode": "^1.5.1",
"safe-license-list": "^0.1.2",
"spdx-satisfies": "^5.0.1",
"sql-formatter": "^13.0.0",
"ua-parser-js": "^1.0.35",
"ulid": "^2.3.0",
+2 -2
View File
@@ -9,7 +9,7 @@ const useWebServer = process.env.NO_WEB_SERVER !== 'true';
*/
export default defineConfig({
testDir: './src',
testMatch: /.*\.e2e\.(spec\.)?ts/,
testMatch: /\.e2e\.(spec\.)?ts$/,
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -57,7 +57,7 @@ export default defineConfig({
&& {
webServer: {
command: 'npm run preview',
url: 'http://127.0.0.1:5050',
url: 'http://localhost:5050',
reuseExistingServer: !isCI,
},
}
+57 -42
View File
@@ -5,6 +5,9 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@guolao/vue-monaco-editor':
specifier: ^1.4.1
version: 1.5.1(monaco-editor@0.43.0)(vue@3.3.4)
'@it-tools/bip39':
specifier: ^0.0.4
version: 0.0.4
@@ -26,9 +29,6 @@ dependencies:
'@types/figlet':
specifier: ^1.5.8
version: 1.5.8
'@types/spdx-satisfies':
specifier: ^0.1.2
version: 0.1.2
'@vicons/material':
specifier: ^0.12.0
version: 0.12.0
@@ -98,6 +98,9 @@ dependencies:
json5:
specifier: ^2.2.3
version: 2.2.3
jsonlint-mod:
specifier: ^1.7.6
version: 1.7.6
jwt-decode:
specifier: ^3.1.2
version: 3.1.2
@@ -143,12 +146,6 @@ dependencies:
qrcode:
specifier: ^1.5.1
version: 1.5.1
safe-license-list:
specifier: ^0.1.2
version: 0.1.2
spdx-satisfies:
specifier: ^5.0.1
version: 5.0.1
sql-formatter:
specifier: ^13.0.0
version: 13.0.0
@@ -2159,6 +2156,22 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
/@guolao/vue-monaco-editor@1.5.1(monaco-editor@0.43.0)(vue@3.3.4):
resolution: {integrity: sha512-nhbQHDAwsxrdH/yitcrBgAkN8Cae0IEiYe/M3LWK8bSJRfapkbMyfTHE6Gcxsxa/6efSUZAPDo8dJWBDx5GZyA==}
peerDependencies:
'@vue/composition-api': ^1.7.1
monaco-editor: '>=0.43.0'
vue: ^2.6.14 || >=3.0.0
peerDependenciesMeta:
'@vue/composition-api':
optional: true
dependencies:
'@monaco-editor/loader': 1.4.0(monaco-editor@0.43.0)
monaco-editor: 0.43.0
vue: 3.3.4
vue-demi: 0.14.7(vue@3.3.4)
dev: false
/@humanwhocodes/config-array@0.11.10:
resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==}
engines: {node: '>=10.10.0'}
@@ -2426,6 +2439,15 @@ packages:
resolution: {integrity: sha512-mrC4y8n88BYvgcgzq9bvTlDgFyi2zuvzmPilRvRc3Uz1iIvq8mDhxJ0rHKFUNzPEScpDvJdIujqiDrulMqiudA==}
dev: true
/@monaco-editor/loader@1.4.0(monaco-editor@0.43.0):
resolution: {integrity: sha512-00ioBig0x642hytVspPl7DbQyaSWRaolYie/UFNjoTdvoKPzo6xrXLhTk9ixgIKcLH5b5vDOjVNiGyY+uDCUlg==}
peerDependencies:
monaco-editor: '>= 0.21.0 < 1'
dependencies:
monaco-editor: 0.43.0
state-local: 1.0.7
dev: false
/@nodelib/fs.scandir@2.1.5:
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -3048,10 +3070,6 @@ packages:
resolution: {integrity: sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==}
dev: true
/@types/spdx-satisfies@0.1.2:
resolution: {integrity: sha512-v8OtFJhx4gHvOktcvP1cdeAXYhUq1O5XP+NTxyZoxDSaKYGf3BFWb0P4Ik/JfRxsscKn8fDe4w9Obv92bNQ26Q==}
dev: false
/@types/throttle-debounce@2.1.0:
resolution: {integrity: sha512-5eQEtSCoESnh2FsiLTxE121IiE60hnMqcb435fShf4bpLRjEu1Eoekht23y6zXS9Ts3l+Szu3TARnTsA0GkOkQ==}
dev: false
@@ -4019,6 +4037,10 @@ packages:
resolution: {integrity: sha512-P1A1vRGFBhITco8Iw4/hvnDYoE/SoVrd71dW1pBFdXJb3vP+pBtoOuhbEKy0ROJGOyzQuqvFibcwzyLlWMqNiQ==}
dev: false
/JSV@4.0.2:
resolution: {integrity: sha512-ZJ6wx9xaKJ3yFUhq5/sk82PJMuUyLk277I8mQeyDgCTjGdjWJIvPfaU5LIXaMuaN2UO1X3kZH4+lgphublZUHw==}
dev: false
/abab@2.0.6:
resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==}
dev: true
@@ -4130,11 +4152,6 @@ packages:
is-array-buffer: 3.0.2
dev: true
/array-find-index@1.0.2:
resolution: {integrity: sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw==}
engines: {node: '>=0.10.0'}
dev: false
/array-union@2.1.0:
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
@@ -6624,6 +6641,16 @@ packages:
graceful-fs: 4.2.11
dev: true
/jsonlint-mod@1.7.6:
resolution: {integrity: sha512-oGuk6E1ehmIpw0w9ttgb2KsDQQgGXBzZczREW8OfxEm9eCQYL9/LCexSnh++0z3AiYGcXpBgqDSx9AAgzl/Bvg==}
engines: {node: '>= 0.6'}
hasBin: true
dependencies:
JSV: 4.0.2
chalk: 2.4.2
underscore: 1.13.6
dev: false
/jsonpointer@5.0.1:
resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==}
engines: {node: '>=0.10.0'}
@@ -7954,10 +7981,6 @@ packages:
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
dev: true
/safe-license-list@0.1.2:
resolution: {integrity: sha512-iY3tWEU++GUFO5iyNQgKdyYaV5/7g0g9IR3e2RXIm8f9/uzrlSt2EHje19Q185636EYpsR7NoZOfzfARzIc0bQ==}
dev: false
/safe-regex-test@1.0.0:
resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==}
dependencies:
@@ -8170,14 +8193,6 @@ packages:
resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==}
dev: true
/spdx-compare@1.0.0:
resolution: {integrity: sha512-C1mDZOX0hnu0ep9dfmuoi03+eOdDoz2yvK79RxbcrVEG1NO1Ph35yW102DHWKN4pk80nwCgeMmSY5L25VE4D9A==}
dependencies:
array-find-index: 1.0.2
spdx-expression-parse: 3.0.1
spdx-ranges: 2.1.1
dev: false
/spdx-correct@3.2.0:
resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==}
dependencies:
@@ -8187,27 +8202,18 @@ packages:
/spdx-exceptions@2.3.0:
resolution: {integrity: sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==}
dev: true
/spdx-expression-parse@3.0.1:
resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==}
dependencies:
spdx-exceptions: 2.3.0
spdx-license-ids: 3.0.13
dev: true
/spdx-license-ids@3.0.13:
resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==}
/spdx-ranges@2.1.1:
resolution: {integrity: sha512-mcdpQFV7UDAgLpXEE/jOMqvK4LBoO0uTQg0uvXUewmEFhpiZx5yJSZITHB8w1ZahKdhfZqP5GPEOKLyEq5p8XA==}
dev: false
/spdx-satisfies@5.0.1:
resolution: {integrity: sha512-Nwor6W6gzFp8XX4neaKQ7ChV4wmpSh2sSDemMFSzHxpTw460jxFYeOn+jq4ybnSSw/5sc3pjka9MQPouksQNpw==}
dependencies:
spdx-compare: 1.0.0
spdx-expression-parse: 3.0.1
spdx-ranges: 2.1.1
dev: false
dev: true
/split@0.3.3:
resolution: {integrity: sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==}
@@ -8235,6 +8241,10 @@ packages:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
dev: true
/state-local@1.0.7:
resolution: {integrity: sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==}
dev: false
/std-env@3.3.3:
resolution: {integrity: sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==}
dev: true
@@ -8671,6 +8681,10 @@ packages:
mlly: 1.4.2
dev: true
/underscore@1.13.6:
resolution: {integrity: sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==}
dev: false
/undici-types@5.26.5:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
dev: true
@@ -9481,6 +9495,7 @@ packages:
/workbox-google-analytics@7.0.0:
resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==}
deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
dependencies:
workbox-background-sync: 7.0.0
workbox-core: 7.0.0
+7
View File
@@ -2,6 +2,9 @@ import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { createHead } from '@vueuse/head';
import { install as VueMonacoEditorPlugin, loader } from '@guolao/vue-monaco-editor';
import * as monaco from 'monaco-editor';
import { registerSW } from 'virtual:pwa-register';
import { plausible } from './plugins/plausible.plugin';
@@ -13,10 +16,14 @@ import App from './App.vue';
import router from './router';
import { i18nPlugin } from './plugins/i18n.plugin';
// loaded monaco-editor from `node_modules`
loader.config({ monaco });
registerSW();
const app = createApp(App);
app.use(VueMonacoEditorPlugin);
app.use(createPinia());
app.use(createHead());
app.use(i18nPlugin);
+1 -1
View File
@@ -28,7 +28,7 @@ const compareMatch = computed(() => compareSync(compareString.value, compareHash
mb-2
/>
<n-form-item label="Salt count: " label-placement="left" label-width="120">
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="10" :min="0" w-full />
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
</n-form-item>
<c-input-text :value="hashed" readonly text-center />
+2 -2
View File
@@ -5,8 +5,8 @@ import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as softwareLicenceCompatibility } from './software-licence-compatibility';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as jsonLinter } from './json-linter';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -128,7 +128,6 @@ export const toolsByCategory: ToolCategory[] = [
userAgentParser,
httpStatusCodes,
jsonDiff,
softwareLicenceCompatibility,
safelinkDecoder,
],
},
@@ -144,6 +143,7 @@ export const toolsByCategory: ToolCategory[] = [
crontabGenerator,
jsonViewer,
jsonMinify,
jsonLinter,
jsonToCsv,
sqlPrettify,
chmodCalculator,
@@ -11,6 +11,9 @@ 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');
});
});
});
@@ -5,16 +5,16 @@ export function convertBase({ value, fromBase, toBase }: { value: string; fromBa
let decValue = value
.split('')
.reverse()
.reduce((carry: number, digit: string, index: number) => {
.reduce((carry: bigint, digit: string, index: number) => {
if (!fromRange.includes(digit)) {
throw new Error(`Invalid digit "${digit}" for base ${fromBase}.`);
}
return (carry += fromRange.indexOf(digit) * fromBase ** index);
}, 0);
return (carry += BigInt(fromRange.indexOf(digit)) * BigInt(fromBase) ** BigInt(index));
}, 0n);
let newValue = '';
while (decValue > 0) {
newValue = toRange[decValue % toBase] + newValue;
decValue = (decValue - (decValue % toBase)) / toBase;
newValue = toRange[Number(decValue % BigInt(toBase))] + newValue;
decValue = (decValue - (decValue % BigInt(toBase))) / BigInt(toBase);
}
return newValue || '0';
}
+12
View File
@@ -0,0 +1,12 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'JSON Linter',
path: '/json-linter',
description: 'Check and lint JSON content',
keywords: ['json', 'linter', 'check'],
component: () => import('./json-linter.vue'),
icon: Braces,
createdAt: new Date('2024-03-20'),
});
+55
View File
@@ -0,0 +1,55 @@
<script setup lang="ts">
import linter from 'jsonlint-mod';
const jsonContent = ref(
`{
a: True;
b=5
}`,
);
const conversionError = computed(() => {
try {
linter.parse(jsonContent.value);
return null;
}
catch (e: any) {
return e.toString();
}
});
const MONACO_EDITOR_OPTIONS = {
automaticLayout: true,
formatOnType: true,
formatOnPaste: true,
};
</script>
<template>
<div>
<c-label label="Paste your JSON file content:">
<div relative w-full>
<c-monaco-editor
v-model:value="jsonContent"
theme="vs-dark"
language="yaml"
height="250px"
:options="MONACO_EDITOR_OPTIONS"
/>
</div>
</c-label>
<div v-if="conversionError">
<n-alert title="The following errors occured" type="error" mt-5>
<pre>
{{ conversionError }}
</pre>
</n-alert>
</div>
<div v-else>
<n-alert type="success" mt-5>
Validation successful!
</n-alert>
</div>
</div>
</template>
+11
View File
@@ -0,0 +1,11 @@
declare module 'jsonlint-mod'{
/**
* Parse a JSON string to Typescript Object. If there is an error will print it
* as human readible.
*
* Please use `import * as jsonlint from 'jsonlint';`. Instead of,
* `import {parse} from 'jsonlint';`. Otherwise, it cannot reference to the
* correct instance.
*/
export function parse(str: string): Record<string, unknown>;
}
@@ -1,12 +0,0 @@
import { License } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Software licence compatibility',
path: '/software-licence-compatibility',
description: 'Software Licence compatibility checker and information',
keywords: ['software', 'licence', 'compatibility'],
component: () => import('./software-licence-compatibility.vue'),
icon: License,
createdAt: new Date('2024-03-17'),
});
@@ -1,334 +0,0 @@
<script setup lang="ts">
import satisfies from 'spdx-satisfies';
import { type ConditionTag, type LimitationTag, type PermissionTag, getLicenseFromId, licenses } from 'safe-license-list';
import type { VNode } from 'vue';
import { h, ref } from 'vue';
import type { SelectOption } from 'naive-ui';
import { NTooltip } from 'naive-ui';
import { Check as CheckIcon, LetterX as CrossIcon } from '@vicons/tabler';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const firstLicence = ref('GPL-3.0');
const secondLicence = ref('MIT');
const compatibility = computed(() => {
try {
return satisfies(firstLicence.value.split(':')[0], secondLicence.value.split(':')[0]) ? 'ok' : 'nok';
}
catch (e: any) {
return e.toString();
}
});
const permissions = [
{ key: 'commercial-use', desc: 'This software and derivatives may be used for commercial purposes.' },
{ key: 'modifications', desc: 'This software may be modified.' },
{ key: 'distribution', desc: 'This software may be distributed.' },
{ key: 'private-use', desc: 'This software may be used and modified in private.' },
{ key: 'patent-use', desc: 'This license provides an express grant of patent rights from contributors.' },
];
const permissionsInfos = permissions.map((l) => {
return { value: l.key, label: l.key, desc: l.desc };
});
const conditions = [
{ key: 'include-copyright', desc: 'A copy of the license and copyright notice must be included with the software.' },
{ key: 'include-copyright--source', desc: 'A copy of the license and copyright notice must be included with the software in source form, but is not required for binaries.' },
{ key: 'document-changes', desc: 'Changes made to the code must be documented.' },
{ key: 'disclose-source', desc: 'Source code must be made available when the software is distributed.' },
{ key: 'network-use-disclose', desc: 'Users who interact with the software via network are given the right to receive a copy of the source code.' },
{ key: 'same-license', desc: 'Modifications must be released under the same license when distributing the software. In some cases a similar or related license may be used.' },
{ key: 'same-license--file', desc: 'Modifications of existing files must be released under the same license when distributing the software. In some cases a similar or related license may be used.' },
{ key: 'same-license--library', desc: 'Modifications must be released under the same license when distributing the software. In some cases a similar or related license may be used, or this condition may not apply to works that use the software as a library.' },
];
const conditionsInfos = conditions.map((l) => {
return { value: l.key, label: l.key, desc: l.desc };
});
const limitations = [
{ key: 'trademark-use', desc: 'This license explicitly states that it does NOT grant trademark rights, even though licenses without such a statement probably do not grant any implicit trademark rights.' },
{ key: 'liability', desc: 'This license includes a limitation of liability.' },
{ key: 'patent-use', desc: 'This license explicitly states that it does NOT grant any rights in the patents of contributors.' },
{ key: 'warranty', desc: 'The license explicitly states that it does NOT provide any warranty.' },
];
const limitationsInfos = limitations.map((l) => {
return { value: l.key, label: l.key, desc: l.desc };
});
function renderTooltips({ node, option }: { node: VNode; option: SelectOption }) {
return h(NTooltip, null, {
trigger: () => node,
default: () => option.desc,
});
}
const currentLicence = ref('MIT');
const currentLicenceInfo = computed(() => {
return getLicenseFromId(currentLicence.value, true);
});
const licenceInfos = computed(() => licenses.map((l) => {
return { value: l.id, label: `${l.id}: ${l.title}` };
}));
const filterAllowedPermissions = ref([]);
const filterDisallowedPermissions = ref([]);
const filterAllowedConditions = ref([]);
const filterDisallowedConditions = ref([]);
const filterAllowedLimitations = ref([]);
const filterDisallowedLimitations = ref([]);
function includesAll(filters: string | string[], elements: string[]) {
return filters === '' || (filters as string[])?.every(e => elements.includes(e));
}
function includesNone(filters: string | string[], elements: string[]) {
return filters === '' || (filters as string[])?.every(e => !elements.includes(e));
}
const filteredLicencesInfos = computed(() => licenses.filter(
(licence) => {
return includesAll(filterAllowedPermissions.value, licence.permissions)
&& includesNone(filterDisallowedPermissions.value, licence.permissions)
&& includesAll(filterAllowedConditions.value, licence.conditions)
&& includesNone(filterDisallowedConditions.value, licence.conditions)
&& includesAll(filterAllowedLimitations.value, licence.limitations)
&& includesNone(filterDisallowedLimitations.value, licence.limitations);
}).map((l) => {
return { value: l.id, label: `${l.id}: ${l.title}` };
}));
function handleLicenceFallback() {
const fallback = filteredLicencesInfos.value && filteredLicencesInfos.value.length > 0 ? filteredLicencesInfos.value[0] : { value: '', label: '' };
currentLicence.value = fallback.value;
return fallback;
}
</script>
<template>
<div style="max-width: 600px;">
<n-card title="Software licences compatibility" mb-5>
<n-form-item label="First License (SPDX):" label-placement="left" label-width="120">
<n-auto-complete
v-model:value="firstLicence"
:options="licenceInfos"
placeholder="Put your first licence SPDX licence..."
raw-text
mb-5
/>
</n-form-item>
<n-form-item label="Second License (SPDX):" label-placement="left" label-width="120">
<n-auto-complete
v-model:value="secondLicence"
:options="licenceInfos"
placeholder="Put your second licence SPDX licence..."
raw-text
mb-5
/>
</n-form-item>
<div v-if="firstLicence !== '' && secondLicence !== ''" flex justify-center>
<span v-if="compatibility === 'ok'">
<n-icon color="green">
<CheckIcon />
</n-icon>
Compatible
</span>
<span v-if="compatibility === 'nok'">
<n-icon color="red">
<CrossIcon />
</n-icon>
Not compatible
</span>
<n-alert v-if="compatibility !== 'nok' && compatibility !== 'ok'" type="error">
{{ compatibility }}
</n-alert>
</div>
</n-card>
<n-card label="Licence infos">
<n-grid x-gap="12" :cols="2">
<n-gi>
<n-form-item
label="Allowed permission(s):"
label-placement="top"
>
<n-select
v-model:value="filterAllowedPermissions"
filterable multiple
:options="permissionsInfos"
:render-option="renderTooltips"
/>
</n-form-item>
</n-gi>
<n-gi>
<n-form-item
label="Disallowed permission(s):"
label-placement="top"
>
<n-select
v-model:value="filterDisallowedPermissions"
multiple filterable
:options="permissionsInfos"
:render-option="renderTooltips"
/>
</n-form-item>
</n-gi>
</n-grid>
<n-grid x-gap="12" :cols="2">
<n-gi>
<n-form-item
label="Allowed condition(s):"
label-placement="top"
>
<n-select
v-model:value="filterAllowedConditions"
multiple filterable
:options="conditionsInfos"
:render-option="renderTooltips"
/>
</n-form-item>
</n-gi>
<n-gi>
<n-form-item
label="Disallowed condition(s):"
label-placement="top"
>
<n-select
v-model:value="filterDisallowedConditions"
multiple filterable
:options="conditionsInfos"
:render-option="renderTooltips"
/>
</n-form-item>
</n-gi>
</n-grid>
<n-grid x-gap="12" :cols="2">
<n-gi>
<n-form-item
label="Allowed limitation(s):"
label-placement="top"
>
<n-select
v-model:value="filterAllowedLimitations"
multiple filterable
:options="limitationsInfos"
:render-option="renderTooltips"
/>
</n-form-item>
</n-gi>
<n-gi>
<n-form-item
label="Disallowed limitation(s):"
label-placement="top"
>
<n-select
v-model:value="filterDisallowedLimitations"
multiple filterable
:options="limitationsInfos"
:render-option="renderTooltips"
/>
</n-form-item>
</n-gi>
</n-grid>
<n-divider />
<n-select
v-model:value="currentLicence"
filterable
label-position="left"
label="Select a licence:"
:options="filteredLicencesInfos"
placeholder="Select a licence"
:fallback-option="handleLicenceFallback"
/>
<n-p text-center>
Applicable licences: {{ filteredLicencesInfos.length }}
</n-p>
<n-divider />
<div v-if="filteredLicencesInfos.length > 0">
<n-form-item label="Id:" label-placement="left">
<n-input
:value="currentLicenceInfo?.id"
readonly mb-5
/>
</n-form-item>
<n-form-item label="Title:" label-placement="left">
<n-input
:value="currentLicenceInfo?.title"
readonly mb-5
/>
</n-form-item>
<n-form-item label="Description:">
<TextareaCopyable
:value="currentLicenceInfo?.description ?? ''"
readonly
word-wrap
mb-5
/>
</n-form-item>
<n-form-item label="How:">
<TextareaCopyable
:value="currentLicenceInfo?.how ?? ''"
word-wrap
readonly
mb-5
/>
</n-form-item>
<n-form-item label="Used by:">
<TextareaCopyable
:value="Object.keys(currentLicenceInfo?.using || []).join(', ')"
mb-5
/>
</n-form-item>
<n-card title="Permissions" mb-5>
<n-p v-for="{ key, desc } in permissions" :key="key" :title="desc">
<n-icon v-if="(currentLicenceInfo?.permissions || []).includes(key as PermissionTag)" color="green">
<CheckIcon />
</n-icon>
<n-icon v-else color="red">
<CrossIcon />
</n-icon>
{{ key }}
</n-p>
</n-card>
<n-card title="Conditions" mb-5>
<n-p v-for="{ key, desc } in conditions" :key="key" :title="desc">
<n-icon v-if="(currentLicenceInfo?.conditions || []).includes(key as ConditionTag)" color="green">
<CheckIcon />
</n-icon>
<n-icon v-else color="red">
<CrossIcon />
</n-icon>
{{ key }}
</n-p>
</n-card>
<n-card title="Limitations" mb-5>
<n-p v-for="{ key, desc } in limitations" :key="key" :title="desc">
<n-icon v-if="(currentLicenceInfo?.limitations || []).includes(key as LimitationTag)" color="green">
<CheckIcon />
</n-icon>
<n-icon v-else color="red">
<CrossIcon />
</n-icon>
{{ key }}
</n-p>
</n-card>
<n-form-item label="Content:">
<TextareaCopyable
:value="currentLicenceInfo?.body ?? ''"
word-wrap
readonly
mb-5
/>
</n-form-item>
</div>
</n-card>
</div>
</template>
+124
View File
@@ -0,0 +1,124 @@
<script setup lang="ts">
import * as monacoEditor from 'monaco-editor';
import type { MonacoEditor } from '@guolao/vue-monaco-editor';
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
import CssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
import HtmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
import TsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
import { useStyleStore } from '@/stores/style.store';
const props = withDefaults(defineProps<EditorProps>(), {
theme: 'vs',
options: () => ({}),
overrideServices: () => ({}),
saveViewState: true,
width: '100%',
height: '100%',
});
const emits = defineEmits<{
(e: 'update:value', value: string | undefined): void
(e: 'beforeMount', monaco: MonacoEditor): void
(e: 'mount', editor: monacoEditor.editor.IStandaloneCodeEditor, monaco: MonacoEditor): void
(e: 'change', value: string | undefined, event: monacoEditor.editor.IModelContentChangedEvent): void
(e: 'validate', markers: monacoEditor.editor.IMarker[]): void
}>();
interface MonacoEnvironment {
getWorker(_: any, label: string): Worker
}
// eslint-disable-next-line @typescript-eslint/no-namespace
declare module globalThis {
let MonacoEnvironment: MonacoEnvironment;
}
const value = useVModel(props, 'value', emits);
globalThis.MonacoEnvironment = {
getWorker(_: any, label: string) {
if (label === 'json') {
return new JsonWorker();
}
if (label === 'css' || label === 'scss' || label === 'less') {
return new CssWorker();
}
if (label === 'html' || label === 'handlebars' || label === 'razor') {
return new HtmlWorker();
}
if (label === 'typescript' || label === 'javascript') {
return new TsWorker();
}
return new EditorWorker();
},
};
export interface EditorProps {
defaultValue?: string
defaultPath?: string
defaultLanguage?: string
value?: string
language?: string
path?: string
/* === */
theme: 'vs' | string
line?: number
options?: monacoEditor.editor.IStandaloneEditorConstructionOptions
overrideServices?: monacoEditor.editor.IEditorOverrideServices
saveViewState?: boolean
/* === */
width?: number | string
height?: number | string
className?: string
}
monacoEditor.editor.defineTheme('it-tools-dark', {
base: 'vs-dark',
inherit: true,
rules: [],
colors: {
'editor.background': '#00000000',
},
});
monacoEditor.editor.defineTheme('it-tools-light', {
base: 'vs',
inherit: true,
rules: [],
colors: {
'editor.background': '#00000000',
},
});
const styleStore = useStyleStore();
watch(
() => styleStore.isDarkTheme,
isDarkTheme => monacoEditor.editor.setTheme(isDarkTheme ? 'it-tools-dark' : 'it-tools-light'),
{ immediate: true },
);
const attrs = useAttrs();
const inheritedAttrs = { ...attrs, ...props };
</script>
<script lang="ts">
export default {
inheritAttrs: false,
};
</script>
<template>
<vue-monaco-editor
v-bind="inheritedAttrs"
v-model:value="value"
@before-mount="(monaco: MonacoEditor) => emits('beforeMount', monaco)"
@mount="(editor: monacoEditor.editor.IStandaloneCodeEditor, monaco: MonacoEditor) => emits('mount', editor, monaco)"
@change="(value: string | undefined, event: monacoEditor.editor.IModelContentChangedEvent) => emits('change', value, event)"
@validate="(markers: monacoEditor.editor.IMarker[]) => emits('validate', markers)"
/>
</template>