Compare commits

..
Author SHA1 Message Date
renovate[bot] a73ddfe455 chore(deps): update dependency javascript-obfuscator to v5.10.1 2026-11-20 23:29:22 +00:00
ShareVB d07563cf5e fix: update nginx for CVE
Fix #600
2026-11-19 09:59:15 +01:00
ShareVB cf6df4e9f3 ci: fix e2e 2026-11-15 23:06:50 +01:00
JoAdo07 91ee2ab7a8 fix(percentage-calculator): clear the result when an input is cleared
n-input-number emits null when its text is cleared, while the computeds only
treated undefined as a missing value. The arithmetic then coerced null to 0,
so emptying To showed -100 and emptying X showed 0.

The three formulas moved into a service that treats null and undefined alike,
with unit tests for the cleared cases and an e2e case that clears a filled
field.

Fixes #1906
2026-11-15 23:03:42 +01:00
34 changed files with 2009 additions and 3002 deletions

No files matched your search

-31
View File
@@ -2,37 +2,6 @@
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.
## Version 2026.11.22
### Features
- **xml-diff**: add XML diff tool (e8f0677)
- **new tool**: Paste Image (0295223)
- **new tool**: Whitespace cleaner tool (8974b30)
- **new tool**: CLI Banner Generator (6e021e9)
- **new tools**: 4-20 mA, 0-10 V and analog scaling converters (#596) (b5eace8)
- **new tool**: Fraction Decimal Converter (41297c8)
- **new tool**: Sound Tester (f122baf)
### Bug fixes
- update nginx for CVE (5bbc672)
- **percentage-calculator**: clear the result when an input is cleared (7632d99)
- **extract desc script**: handle formatting of long lines (83d7d33)
- **Fortune Wheel**: better color choosing and UI enhancement (8d13f0a)
- **hash-text**: refresh added hashes when digest encoding changes (#594) (e775893)
- keep the language dropdown scrollable within the viewport (#592) (324a6be)
- **Regex Memo**: fix Escaping table formatting (ec33d7d)
### Continuous integration
- fix e2e (d10b89b)
- disable deploy on renovate bot PR because it exceeds Vercel free plan limits (231930d)
### Chores
- **deps**: update nginxinc/nginx-unprivileged:stable-alpine docker digest to f5116ed (#590) (47943c7)
### I18n
- extract and translate remaining (1d77ed3)
- extract and translated remaining (8f94ed3)
## Version 2026.10.25
### Features
-13
View File
@@ -10163,19 +10163,6 @@ tools:
label-banner-text: "نص الشعار:"
placeholder-enter-motd-banner-text-here: أدخل نص شعار رسالة اليوم هنا...
title-generated-banner: تم إنشاء لافتة
xml-diff:
title: مقارنة XML
description: قارن بين مستندين من نوع XML واحصل على الاختلافات بينهما.
texts:
message-invalid-xml-format: تنسيق XML غير صالح
label-your-first-xml: أول ملف XML خاص بك
placeholder-paste-your-first-xml-here: ألصق ملف XML الأول هنا...
label-your-xml-to-compare: ملف XML الخاص بك للمقارنة
placeholder-paste-your-xml-to-compare-here: ألصق ملف XML الخاص بك للمقارنة هنا...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: ملفات XML المقدمة هي نفسها
only-show-differences: أظهر الاختلافات فقط
spanCopyable:
copy: نسخ إلى الحافظة
copied: تم النسخ!
-13
View File
@@ -10240,19 +10240,6 @@ tools:
label-banner-text: "Bannertekst:"
placeholder-enter-motd-banner-text-here: Indtast MOTD-bannertekst her...
title-generated-banner: Genereret banner
xml-diff:
title: XML-diff
description: Sammenlign to XML-dokumenter og find forskellene mellem dem.
texts:
message-invalid-xml-format: Ugyldigt XML-format
label-your-first-xml: Din første XML
placeholder-paste-your-first-xml-here: Indsæt din første XML her...
label-your-xml-to-compare: Din XML til sammenligning
placeholder-paste-your-xml-to-compare-here: Indsæt din XML for at sammenligne her...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: De angivne XML-filer er de samme
only-show-differences: Vis kun forskelle
about:
alltools-title: Alle {toolsCount} værktøjer
tools:
-13
View File
@@ -10570,19 +10570,6 @@ tools:
label-banner-text: "Bannertext:"
placeholder-enter-motd-banner-text-here: Hier den Text für das MOTD-Banner eingeben...
title-generated-banner: Generiertes Banner
xml-diff:
title: XML diff
description: Vergleiche zwei XML-Dokumente und ermittle die Unterschiede zwischen ihnen.
texts:
message-invalid-xml-format: Ungültiges XML-Format
label-your-first-xml: Ihr erstes XML
placeholder-paste-your-first-xml-here: Fügen Sie hier Ihre erste XML-Datei ein...
label-your-xml-to-compare: Ihr zu vergleichendes XML.
placeholder-paste-your-xml-to-compare-here: Fügen Sie hier Ihre XML-Datei zum Vergleich ein...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Die bereitgestellten XML-Dateien sind identisch.
only-show-differences: Nur Unterschiede anzeigen
locale-selector:
select-a-language: Wählen Sie eine Sprache
collapsibleToolMenu:
-13
View File
@@ -10616,19 +10616,6 @@ tools:
label-banner-text: "Κείμενο banner:"
placeholder-enter-motd-banner-text-here: Εισαγάγετε εδώ κείμενο banner MOTD...
title-generated-banner: Δημιουργημένο banner
xml-diff:
title: Διαφορά XML
description: Συγκρίνετε δύο έγγραφα XML και βρείτε τις διαφορές μεταξύ τους.
texts:
message-invalid-xml-format: Μη έγκυρη μορφή XML
label-your-first-xml: Το πρώτο σας XML
placeholder-paste-your-first-xml-here: Επικολλήστε εδώ το πρώτο σας XML...
label-your-xml-to-compare: Το XML σας για σύγκριση
placeholder-paste-your-xml-to-compare-here: Επικολλήστε το XML σας για σύγκριση εδώ...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Τα παρεχόμενα XML είναι τα ίδια
only-show-differences: Εμφάνιση μόνο διαφορών
collapsibleToolMenu:
text:
expanding: Επέκταση...
+1955 -2130
View File
File diff suppressed because it is too large. Load diff
-13
View File
@@ -10490,19 +10490,6 @@ tools:
label-banner-text: "Texto del banner:"
placeholder-enter-motd-banner-text-here: Introduzca aquí el texto del banner del mensaje del día...
title-generated-banner: Banner generado
xml-diff:
title: Diferencia XML
description: Compara dos documentos XML y obtén las diferencias entre ellos.
texts:
message-invalid-xml-format: Formato XML no válido
label-your-first-xml: Tu primer XML
placeholder-paste-your-first-xml-here: Pegue aquí su primer XML...
label-your-xml-to-compare: Su XML para comparar
placeholder-paste-your-xml-to-compare-here: Pegue aquí su código XML para compararlo...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Los XML proporcionados son los mismos
only-show-differences: Solo muestra las diferencias
spanCopyable:
copy: Copiar al portapapeles
copied: Copiado!
-13
View File
@@ -10685,19 +10685,6 @@ tools:
label-banner-text: "Texte de la bannière :"
placeholder-enter-motd-banner-text-here: Saisissez ici le texte de la bannière du message du jour...
title-generated-banner: Bannière générée
xml-diff:
title: Différence XML
description: Comparez deux documents XML et obtenez les différences entre eux.
texts:
message-invalid-xml-format: Format XML invalide
label-your-first-xml: Votre premier XML
placeholder-paste-your-first-xml-here: Collez votre premier code XML ici...
label-your-xml-to-compare: Votre XML à comparer
placeholder-paste-your-xml-to-compare-here: Collez votre code XML à comparer ici...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Les fichiers XML fournis sont identiques.
only-show-differences: Afficher uniquement les différences
favoriteButton:
add: Ajouter aux favoris
remove: Retirer des favoris
-14
View File
@@ -10444,20 +10444,6 @@ tools:
label-banner-text: "Téacs Meirge:"
placeholder-enter-motd-banner-text-here: Cuir isteach téacs meirge MOTD anseo...
title-generated-banner: Meirge Ginte
xml-diff:
title: Difríocht XML
description: Déan comparáid idir dhá dhoiciméad XML agus faigh amach na
difríochtaí eatarthu.
texts:
message-invalid-xml-format: Formáid XML neamhbhailí
label-your-first-xml: Do chéad XML
placeholder-paste-your-first-xml-here: Greamaigh do chéad XML anseo...
label-your-xml-to-compare: Do XML le comparáid a dhéanamh
placeholder-paste-your-xml-to-compare-here: Greamaigh do XML anseo le comparáid a dhéanamh...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Is ionann na XMLanna a cuireadh ar fáil
only-show-differences: Taispeáin difríochtaí amháin
locale-selector:
select-a-language: Roghnaigh teanga
collapsibleToolMenu:
-13
View File
@@ -10415,19 +10415,6 @@ tools:
label-banner-text: "बैनर टेक्स्ट:"
placeholder-enter-motd-banner-text-here: यहां MOTD बैनर का टेक्स्ट डालें...
title-generated-banner: जनरेट किया गया बैनर
xml-diff:
title: XML अंतर
description: दो XML दस्तावेज़ों की तुलना करें और उनके बीच के अंतर ज्ञात करें।
texts:
message-invalid-xml-format: अमान्य XML प्रारूप
label-your-first-xml: आपका पहला XML
placeholder-paste-your-first-xml-here: अपना पहला XML यहां पेस्ट करें...
label-your-xml-to-compare: तुलना करने के लिए आपका XML
placeholder-paste-your-xml-to-compare-here: तुलना करने के लिए अपना XML यहां पेस्ट करें...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: दिए गए XML समान हैं।
only-show-differences: केवल अंतर दिखाएँ
collapsibleToolMenu:
text:
expanding: विस्तार हो रहा है...
-13
View File
@@ -10356,19 +10356,6 @@ tools:
label-banner-text: "Testo del banner:"
placeholder-enter-motd-banner-text-here: Inserisci qui il testo del banner MOTD...
title-generated-banner: Banner generato
xml-diff:
title: Differenza XML
description: Confronta due documenti XML e individua le differenze tra di essi.
texts:
message-invalid-xml-format: Formato XML non valido
label-your-first-xml: Il tuo primo XML
placeholder-paste-your-first-xml-here: Incolla qui il tuo primo file XML...
label-your-xml-to-compare: Il tuo XML da confrontare
placeholder-paste-your-xml-to-compare-here: Incolla qui il tuo file XML da confrontare...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: I file XML forniti sono gli stessi
only-show-differences: Mostra solo le differenze
collapsibleToolMenu:
text:
expanding: Espansione in corso...
-13
View File
@@ -9815,19 +9815,6 @@ tools:
label-banner-text: "배너 텍스트:"
placeholder-enter-motd-banner-text-here: 오늘의 주요 뉴스 배너 문구를 여기에 입력하세요...
title-generated-banner: 생성된 배너
xml-diff:
title: XML 차이점
description: 두 XML 문서를 비교하고 그 차이점을 확인하세요.
texts:
message-invalid-xml-format: 잘못된 XML 형식입니다.
label-your-first-xml: 첫 번째 XML
placeholder-paste-your-first-xml-here: 여기에 첫 번째 XML을 붙여넣으세요...
label-your-xml-to-compare: 비교할 XML
placeholder-paste-your-xml-to-compare-here: 비교할 XML을 여기에 붙여넣으세요...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: 제공된 XML은 동일합니다.
only-show-differences: 차이점만 표시하세요.
about:
alltools-title: 모든 {toolsCount}개 도구
tools:
-13
View File
@@ -10342,19 +10342,6 @@ tools:
label-banner-text: "Bannertekst:"
placeholder-enter-motd-banner-text-here: Voer hier de tekst voor de MOTD-banner in...
title-generated-banner: Gegenereerde banner
xml-diff:
title: XML-verschil
description: Vergelijk twee XML-documenten en vind de verschillen ertussen.
texts:
message-invalid-xml-format: Ongeldig XML-formaat
label-your-first-xml: Je eerste XML-bestand
placeholder-paste-your-first-xml-here: Plak hier je eerste XML-bestand...
label-your-xml-to-compare: Uw XML-bestand ter vergelijking
placeholder-paste-your-xml-to-compare-here: Plak hier uw XML-bestand om te vergelijken...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: De aangeleverde XML-bestanden zijn hetzelfde.
only-show-differences: Toon alleen verschillen
about:
alltools-title: Alle {toolsCount}-hulpmiddelen
tools:
-13
View File
@@ -10294,19 +10294,6 @@ tools:
label-banner-text: "Bannertekst:"
placeholder-enter-motd-banner-text-here: Skriv inn MOTD-bannertekst her ...
title-generated-banner: Generert banner
xml-diff:
title: XML-forskjell
description: Sammenlign to XML-dokumenter og finn forskjellene mellom dem.
texts:
message-invalid-xml-format: Ugyldig XML-format
label-your-first-xml: Din første XML
placeholder-paste-your-first-xml-here: Lim inn din første XML-fil her...
label-your-xml-to-compare: XML-en din for å sammenligne
placeholder-paste-your-xml-to-compare-here: Lim inn XML-filen din for å sammenligne her...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: De oppgitte XML-filene er de samme
only-show-differences: Vis bare forskjeller
spanCopyable:
copy: Kopier til utklippstavlen
copied: Kopiert!
-13
View File
@@ -10353,19 +10353,6 @@ tools:
label-banner-text: "Tekst banera:"
placeholder-enter-motd-banner-text-here: Wpisz tutaj tekst banera MOTD...
title-generated-banner: Wygenerowany baner
xml-diff:
title: Różnica XML
description: Porównaj dwa dokumenty XML i znajdź różnice między nimi.
texts:
message-invalid-xml-format: Nieprawidłowy format XML
label-your-first-xml: Twój pierwszy XML
placeholder-paste-your-first-xml-here: Wklej tutaj swój pierwszy plik XML...
label-your-xml-to-compare: Twój XML do porównania
placeholder-paste-your-xml-to-compare-here: Wklej tutaj swój kod XML, aby porównać...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Dostarczone pliki XML są takie same
only-show-differences: Pokaż tylko różnice
favoriteButton:
remove: Usuń z ulubionych
add: Dodaj do ulubionych
-13
View File
@@ -10400,19 +10400,6 @@ tools:
label-banner-text: "Texto do banner:"
placeholder-enter-motd-banner-text-here: Insira aqui o texto do banner MOTD...
title-generated-banner: Banner gerado
xml-diff:
title: Diferença XML
description: Compare dois documentos XML e obtenha as diferenças entre eles.
texts:
message-invalid-xml-format: Formato XML inválido
label-your-first-xml: Seu primeiro XML
placeholder-paste-your-first-xml-here: Cole seu primeiro XML aqui...
label-your-xml-to-compare: Seu XML para comparação
placeholder-paste-your-xml-to-compare-here: Cole aqui o seu XML para comparação...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Os arquivos XML fornecidos são os mesmos.
only-show-differences: Mostrar apenas as diferenças
spanCopyable:
copy: Copiar para a área de transferência
copied: Copiado!
-13
View File
@@ -10393,19 +10393,6 @@ tools:
label-banner-text: "Текст баннера:"
placeholder-enter-motd-banner-text-here: Введите текст баннера дня здесь...
title-generated-banner: Сгенерированный баннер
xml-diff:
title: XML-разница
description: Сравните два XML-документа и выявите различия между ними.
texts:
message-invalid-xml-format: Неверный формат XML
label-your-first-xml: Ваш первый XML
placeholder-paste-your-first-xml-here: Вставьте сюда свой первый XML-файл...
label-your-xml-to-compare: Ваш XML-файл для сравнения
placeholder-paste-your-xml-to-compare-here: Вставьте сюда свой XML-код для сравнения...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Предоставленные XML-файлы идентичны.
only-show-differences: Покажите только различия.
spanCopyable:
copy: Копировать в буфер обмена
copied: Скопировано!
-13
View File
@@ -10338,19 +10338,6 @@ tools:
label-banner-text: "Banner Metni:"
placeholder-enter-motd-banner-text-here: MOTD (Günün Mesajı) başlık metnini buraya girin...
title-generated-banner: Oluşturulan Afiş
xml-diff:
title: XML farkı
description: İki XML belgesini karşılaştırın ve aralarındaki farkları bulun.
texts:
message-invalid-xml-format: Geçersiz XML formatı
label-your-first-xml: İlk XML dosyanız
placeholder-paste-your-first-xml-here: İlk XML dosyanızı buraya yapıştırın...
label-your-xml-to-compare: Karşılaştırılacak XML dosyanız
placeholder-paste-your-xml-to-compare-here: Karşılaştırmak istediğiniz XML dosyasını buraya yapıştırın...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Verilen XML dosyaları aynıdır.
only-show-differences: Yalnızca farklılıkları göster
about:
alltools-title: Tüm {toolsCount} Araç
tools:
-13
View File
@@ -10335,19 +10335,6 @@ tools:
label-banner-text: "Текст банера:"
placeholder-enter-motd-banner-text-here: Введіть тут текст банера MOTD...
title-generated-banner: Згенерований банер
xml-diff:
title: Різниця XML
description: Порівняйте два XML-документи та знайдіть відмінності між ними.
texts:
message-invalid-xml-format: Недійсний формат XML
label-your-first-xml: Ваш перший XML-файл
placeholder-paste-your-first-xml-here: Вставте сюди свій перший XML-файл...
label-your-xml-to-compare: Ваш XML для порівняння
placeholder-paste-your-xml-to-compare-here: Вставте сюди свій XML-файл для порівняння...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Надані XML-файли однакові
only-show-differences: Показати лише відмінності
spanCopyable:
copy: Копіювати в буфер обміну
copied: Скопійовано!
-13
View File
@@ -10303,19 +10303,6 @@ tools:
label-banner-text: "Văn bản trên biểu ngữ:"
placeholder-enter-motd-banner-text-here: Nhập nội dung banner MOTD vào đây...
title-generated-banner: Biểu ngữ được tạo
xml-diff:
title: So sánh XML
description: So sánh hai tài liệu XML và tìm ra điểm khác biệt giữa chúng.
texts:
message-invalid-xml-format: Định dạng XML không hợp lệ
label-your-first-xml: XML đầu tiên của bạn
placeholder-paste-your-first-xml-here: Dán đoạn mã XML đầu tiên của bạn vào đây...
label-your-xml-to-compare: Tệp XML của bạn để so sánh
placeholder-paste-your-xml-to-compare-here: Hãy dán mã XML của bạn vào đây để so sánh...
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: Các tệp XML được cung cấp đều giống nhau.
only-show-differences: Chỉ hiển thị sự khác biệt
spanCopyable:
copy: Sao chép vào bảng tạm
copied: Đã sao chép!
-13
View File
@@ -9885,19 +9885,6 @@ tools:
label-banner-text: 橫幅文字:
placeholder-enter-motd-banner-text-here: 在此輸入每日比賽橫幅文字…
title-generated-banner: 產生的橫幅
xml-diff:
title: XML差異
description: 比較兩個 XML 文檔,找出它們之間的差異。
texts:
message-invalid-xml-format: 無效的 XML 格式
label-your-first-xml: 你的第一個 XML
placeholder-paste-your-first-xml-here: 把你的第一個 XML 檔案貼到這裡…
label-your-xml-to-compare: 要比較的 XML
placeholder-paste-your-xml-to-compare-here: 請將要比較的 XML 檔案貼到這裡…
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: 提供的 XML 檔案相同
only-show-differences: 僅顯示差異
collapsibleToolMenu:
text:
expanding: 正在展開……
-13
View File
@@ -9893,19 +9893,6 @@ tools:
label-banner-text: 横幅文字:
placeholder-enter-motd-banner-text-here: 在此输入每日比赛横幅文字……
title-generated-banner: 生成的横幅
xml-diff:
title: XML差异
description: 比较两个 XML 文档,找出它们之间的差异。
texts:
message-invalid-xml-format: 无效的 XML 格式
label-your-first-xml: 你的第一个 XML
placeholder-paste-your-first-xml-here: 把你的第一个 XML 文件粘贴到这里……
label-your-xml-to-compare: 要比较的 XML
placeholder-paste-your-xml-to-compare-here: 请将要比较的 XML 文件粘贴到这里……
xml-diff-viewer:
texts:
the-provided-xmls-are-the-same: 提供的 XML 文件相同
only-show-differences: 仅显示差异
collapsibleToolMenu:
text:
expanding: 正在展开……
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "it-tools",
"version": "2026.11.22",
"version": "2026.10.25",
"description": "Collection of handy online tools for developers, with great UX. ",
"keywords": [
"converter",
@@ -285,7 +285,7 @@
"markdown-it-sub": "^2.0.0",
"markdown-it-sup": "^2.0.0",
"markdown-table-prettify": "^4.1.0",
"marked": "^18.0.0",
"marked": "^10.0.0",
"mathjs": "^15.2.0",
"md-editor-v3": "^7.0.0",
"mdt2json": "^1.1.0",
+37 -50
View File
@@ -808,7 +808,7 @@ importers:
version: 1.0.7
javascript-obfuscator:
specifier: ^5.4.7
version: 5.4.7
version: 5.10.1
javastack.js:
specifier: ^1.0.3
version: 1.0.3
@@ -933,8 +933,8 @@ importers:
specifier: ^4.1.0
version: 4.1.0
marked:
specifier: ^18.0.0
version: 18.2.1
specifier: ^10.0.0
version: 10.0.0
mathjs:
specifier: ^15.2.0
version: 15.2.0
@@ -2903,6 +2903,9 @@ packages:
resolution: {integrity: sha512-AokJm4tuBHillT+FpMtxQ60n8ObyXBatq7jD2/JA9dxbDDokKQm8KMht5ibGzLVU9IJDIKK4TPKgMHEYMn3lMg==}
engines: {node: '>=18'}
'@isaacs/nonrecursive-glob-match@1.1.0':
resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==}
'@it-tools/bip39@0.0.4':
resolution: {integrity: sha512-0PWO7VKi6VALiFcm8z2WgxzSZ5wAko0OctBZ0I5+jjtSIXm3t1d54yrrHfgFOZDTyMpCXi638oLpzqexcfRtbA==}
@@ -4854,9 +4857,6 @@ packages:
'@types/mime-types@3.0.1':
resolution: {integrity: sha512-xRMsfuQbnRq1Ef+C+RKaENOxXX87Ygl38W1vDfPHRku02TgQr+Qd8iivLtAMcR0KF5/29xlnFihkTlbqFrGOVQ==}
'@types/minimatch@3.0.5':
resolution: {integrity: sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==}
'@types/morsee@1.0.2':
resolution: {integrity: sha512-WANv1kCyQtmGZTiov9FzFdt1X4wRtXYZA6B4YR3CghKgx4ychU7d1gkOx7oD+ddVGI+SWmWOPccco7pAc6wXeA==}
@@ -5581,10 +5581,6 @@ packages:
resolution: {integrity: sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==}
engines: {node: '>= 0.4'}
array-differ@3.0.0:
resolution: {integrity: sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==}
engines: {node: '>=8'}
array-each@1.0.1:
resolution: {integrity: sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==}
engines: {node: '>=0.10.0'}
@@ -5601,10 +5597,6 @@ packages:
resolution: {integrity: sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==}
engines: {node: '>=0.10.0'}
array-union@2.1.0:
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
array-unique@0.3.2:
resolution: {integrity: sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==}
engines: {node: '>=0.10.0'}
@@ -5617,10 +5609,6 @@ packages:
resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==}
engines: {node: '>= 0.4'}
arrify@2.0.1:
resolution: {integrity: sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==}
engines: {node: '>=8'}
asmcrypto.js@2.3.2:
resolution: {integrity: sha512-3FgFARf7RupsZETQ1nHnhLUUvpcttcCq1iZCaVAbJZbCZ5VNRrNyvpDyHTOb0KC3llFcsyOT/a99NZcCbeiEsA==}
@@ -5818,6 +5806,10 @@ packages:
brace-expansion@2.1.1:
resolution: {integrity: sha512-WR1cURNjuvBLMZBMbqM0UoE+WAfdUcEV1ccD8PVBVOI+Z3ND4+SZbN8RsfT2bMuG1qwz5RFvPukSZm5fF2D5eA==}
brace-expansion@5.0.13:
resolution: {integrity: sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==}
engines: {node: 20 || >=22}
brace-expansion@5.0.7:
resolution: {integrity: sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==}
engines: {node: 18 || 20 || >=22}
@@ -8244,9 +8236,9 @@ packages:
javascript-natural-sort@0.7.1:
resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==}
javascript-obfuscator@5.4.7:
resolution: {integrity: sha512-QBgWD5ty+GlTZkvkKlKGdcYaeXCPP3JjtxFI61NZrcT8Je5Maq9cvBa6hENY4Pem+j3/89fekeNOfo486b2JEg==}
engines: {node: '>=18.0.0'}
javascript-obfuscator@5.10.1:
resolution: {integrity: sha512-3zIGwyuif4gqQM7Rm7ypkbWFrzTGVP/iaUdTwKPssY+t4J2ZmBGqgxy0c/Dsxl3ZUsJ7+l5gf9TtEl0CV49jIg==}
engines: {node: '>=20.0.0'}
hasBin: true
javastack.js@1.0.3:
@@ -8810,6 +8802,11 @@ packages:
engines: {vscode: ^1.115.0}
hasBin: true
marked@10.0.0:
resolution: {integrity: sha512-YiGcYcWj50YrwBgNzFoYhQ1hT6GmQbFG8SksnYJX1z4BXTHSOrz1GB5/Jm2yQvMg4nN1FHP4M6r03R10KrVUiA==}
engines: {node: '>= 18'}
hasBin: true
marked@14.0.0:
resolution: {integrity: sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==}
engines: {node: '>= 18'}
@@ -8825,11 +8822,6 @@ packages:
engines: {node: '>= 20'}
hasBin: true
marked@18.2.1:
resolution: {integrity: sha512-ii4bxCTCqqwpT86XZWgJNs+ZnAIZksmLGYMViWA7PDIXYIeNo1x6cDdX3JOip9NM/cI6p8z57FxliACboTruMA==}
engines: {node: '>= 20'}
hasBin: true
marks-pane@1.0.9:
resolution: {integrity: sha512-Ahs4oeG90tbdPWwAJkAAoHg2lRR8lAs9mZXETNPO9hYg3AkjUJBKi1NQ4aaIQZVGrig7c/3NUV1jANl8rFTeMg==}
@@ -8970,6 +8962,10 @@ packages:
resolution: {integrity: sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==}
engines: {node: 18 || 20 || >=22}
minimatch@11.0.4:
resolution: {integrity: sha512-/UJ1dEoVQTjPNDh6SGlUo+ueLMmoHTas4q+8yaAR/5t6nLAIiBDJtoYUh20IYleix7ehiQkgczb84PE3uzHkxg==}
engines: {node: 20 || >=22}
minimatch@3.1.5:
resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==}
@@ -9083,10 +9079,6 @@ packages:
muggle-string@0.4.1:
resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==}
multimatch@5.0.0:
resolution: {integrity: sha512-ypMKuglUrZUD99Tk2bUQ+xNQj43lPEfAeX2o9cTteAmShXy2VHDJpuwu1o0xqoKCt9jLVAvwyFKdLTPXKAfJyA==}
engines: {node: '>=10'}
mute-stdout@2.0.0:
resolution: {integrity: sha512-32GSKM3Wyc8dg/p39lWPKYu8zci9mJFzV1Np9Of0ZEpe6Fhssn/FbI7ywAMd40uX+p3ZKh3T5EeCFv81qS3HmQ==}
engines: {node: '>= 10.13.0'}
@@ -13607,6 +13599,8 @@ snapshots:
'@isaacs/cliui@9.0.0': {}
'@isaacs/nonrecursive-glob-match@1.1.0': {}
'@it-tools/bip39@0.0.4':
dependencies:
js-sha256: 0.11.1
@@ -15460,8 +15454,6 @@ snapshots:
'@types/mime-types@3.0.1': {}
'@types/minimatch@3.0.5': {}
'@types/morsee@1.0.2': {}
'@types/nanoid-dictionary@4.2.3': {}
@@ -16303,8 +16295,6 @@ snapshots:
call-bound: 1.0.4
is-array-buffer: 3.0.5
array-differ@3.0.0: {}
array-each@1.0.1: {}
array-find-index@1.0.2: {}
@@ -16322,8 +16312,6 @@ snapshots:
array-slice@1.1.0: {}
array-union@2.1.0: {}
array-unique@0.3.2: {}
array.prototype.reduce@1.0.8:
@@ -16347,8 +16335,6 @@ snapshots:
get-intrinsic: 1.3.0
is-array-buffer: 3.0.5
arrify@2.0.1: {}
asmcrypto.js@2.3.2: {}
asn1.js@4.10.1:
@@ -16542,6 +16528,10 @@ snapshots:
dependencies:
balanced-match: 1.0.2
brace-expansion@5.0.13:
dependencies:
balanced-match: 4.0.4
brace-expansion@5.0.7:
dependencies:
balanced-match: 4.0.4
@@ -19213,7 +19203,7 @@ snapshots:
javascript-natural-sort@0.7.1: {}
javascript-obfuscator@5.4.7:
javascript-obfuscator@5.10.1:
dependencies:
'@javascript-obfuscator/escodegen': 2.4.2
'@javascript-obfuscator/estraverse': 5.4.0
@@ -19232,7 +19222,7 @@ snapshots:
inversify: 7.11.0(reflect-metadata@0.2.2)
js-string-escape: 1.0.1
md5: 2.3.0
multimatch: 5.0.0
minimatch: 11.0.4
process: 0.11.10
reflect-metadata: 0.2.2
string-template: 1.0.0
@@ -19832,14 +19822,14 @@ snapshots:
markdown-table-prettify@4.1.0: {}
marked@10.0.0: {}
marked@14.0.0: {}
marked@15.0.12: {}
marked@16.4.2: {}
marked@18.2.1: {}
marks-pane@1.0.9: {}
math-intrinsics@1.1.0: {}
@@ -20036,6 +20026,11 @@ snapshots:
dependencies:
brace-expansion: 5.0.7
minimatch@11.0.4:
dependencies:
'@isaacs/nonrecursive-glob-match': 1.1.0
brace-expansion: 5.0.13
minimatch@3.1.5:
dependencies:
brace-expansion: 1.1.15
@@ -20133,14 +20128,6 @@ snapshots:
muggle-string@0.4.1: {}
multimatch@5.0.0:
dependencies:
'@types/minimatch': 3.0.5
array-differ: 3.0.0
array-union: 2.1.0
arrify: 2.0.1
minimatch: 3.1.5
mute-stdout@2.0.0: {}
naive-ui@2.44.1(vue@3.5.39(typescript@6.0.3)):
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import {
format,
formatISO,
formatISO9075,
formatRFC3339,
@@ -11,7 +10,6 @@ import {
getUnixTime,
isDate,
isValid,
parse,
parseISO,
} from 'date-fns';
import { ticksFromDate, ticksToDate } from 'tick-time';
@@ -131,12 +129,6 @@ const formats: DateFormat[] = [
toDate: (date) => lDAPTimestampToDate(date),
formatMatcher: isLDAPTimestamp,
},
{
name: 'Julian Date (YYYY/DDD)',
fromDate: (date) => format(date, 'yyyy/DDD'),
toDate: (date) => parse(date, 'yyyy/DDD', new Date()),
formatMatcher: (date) => /\d{4}\/\d{3}/.test(date || ''),
},
{
name: 'Win32 FileTime/LDAP 18 digits Timestamp',
fromDate: (date) => dateToWin32FileTime(date),
@@ -147,7 +139,7 @@ const formats: DateFormat[] = [
name: '.Net ticks',
fromDate: (date) => ticksFromDate(date),
toDate: (date) => ticksToDate(date) || new Date(),
formatMatcher: (date) => /^\d+$/.test(date || ''),
formatMatcher: (date) => /\d+/.test(date || ''),
},
];
@@ -18,71 +18,58 @@ const { t } = useI18n();
const input = useQueryParam({ tool: 'mac-conv', name: 'addr', defaultValue: 'AA:BB:CC:DD:EE:FF' });
const convertMulti = (value: string, converter: (mac: string) => string): string => {
const macs = value.split(/[\s,;]+/).filter((mac) => mac.trim() !== '');
return macs
.map((mac) => {
try {
return converter(mac);
} catch (error) {
return t('tools.mac-address-converter.texts.error-invalid-mac-address', [mac]);
}
})
.join('\n');
};
const formats = computed(() => [
{
label: t('tools.mac-address-converter.texts.label-canonical-ietf-format'),
value: convertMulti(input.value, convertMacCanonicalIETF),
value: convertMacCanonicalIETF(input.value),
},
{
label: t('tools.mac-address-converter.texts.label-canonical-format'),
value: convertMulti(input.value, convertMacCanonical),
value: convertMacCanonical(input.value),
},
{
label: t('tools.mac-address-converter.texts.label-canonical-ieee-format'),
value: convertMulti(input.value, convertMacCanonicalIEEE),
value: convertMacCanonicalIEEE(input.value),
},
{
label: t('tools.mac-address-converter.texts.label-cisco'),
value: convertMulti(input.value, convertMacCISCO),
value: convertMacCISCO(input.value),
},
{
label: t('tools.mac-address-converter.texts.label-hex'),
value: convertMulti(input.value, (mac) => convertMacToNumber(mac).toString(16)),
value: convertMacToNumber(input.value).toString(16),
},
{
label: t('tools.mac-address-converter.texts.label-decimal'),
value: convertMulti(input.value, (mac) => convertMacToNumber(mac).toString(10)),
value: convertMacToNumber(input.value).toString(10),
},
{
label: t('tools.mac-address-converter.texts.label-eui-64-canonical-ietf-format'),
value: convertMulti(input.value, (mac) => convertMacToEUI64CanonicalIETF(mac, false)),
value: convertMacToEUI64CanonicalIETF(input.value, false),
},
{
label: t('tools.mac-address-converter.texts.label-eui-64-canonical-ieee-format'),
value: convertMulti(input.value, (mac) => convertMacToEUI64CanonicalIEEE(mac, false)),
value: convertMacToEUI64CanonicalIEEE(input.value, false),
},
{
label: t('tools.mac-address-converter.texts.label-eui-64-cisco'),
value: convertMulti(input.value, (mac) => convertMacToEUI64CISCO(mac, false)),
value: convertMacToEUI64CISCO(input.value, false),
},
{
label: t('tools.mac-address-converter.texts.label-eui-64-ipv6-canonical-ietf-format'),
value: convertMulti(input.value, (mac) => convertMacToEUI64CanonicalIETF(mac, true)),
value: convertMacToEUI64CanonicalIETF(input.value, true),
},
{
label: t('tools.mac-address-converter.texts.label-eui-64-ipv6-canonical-ieee-format'),
value: convertMulti(input.value, (mac) => convertMacToEUI64CanonicalIEEE(mac, true)),
value: convertMacToEUI64CanonicalIEEE(input.value, true),
},
{
label: t('tools.mac-address-converter.texts.label-eui-64-ipv6-cisco'),
value: convertMulti(input.value, (mac) => convertMacToEUI64CISCO(mac, true)),
value: convertMacToEUI64CISCO(input.value, true),
},
{
label: t('tools.mac-address-converter.texts.label-link-local-ipv6'),
value: convertMulti(input.value, (mac) => convertMacToLinkLocalIPv6(mac)),
value: convertMacToLinkLocalIPv6(input.value),
},
]);
@@ -99,10 +86,8 @@ const inputLabelAlignmentConfig = {
v-model:value="input"
:label="t('tools.mac-address-converter.texts.label-mac-address')"
size="large"
:placeholder="t('tools.mac-address-converter.texts.placeholder-type-mac-address')"
:placeholder="t('tools.mac-address-converter.texts.placeholder-type-a-mac-address')"
clearable
multiline
rows="3"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
@@ -118,9 +103,6 @@ const inputLabelAlignmentConfig = {
:value="format.value"
:label="format.label"
v-bind="inputLabelAlignmentConfig"
multiline
autosize
rows="1"
mb-1
/>
</c-card>
@@ -1,114 +0,0 @@
<script lang="ts" setup>
import * as _ from 'es-toolkit/compat';
import { diff } from '../../json-diff/json-diff.models';
import { DiffRootViewer } from '../../json-diff/diff-viewer/diff-viewer.models';
import { reconcileArrayShapes } from '../xml-diff.reconcile';
import { useAppTheme } from '@/ui/theme/themes';
const props = defineProps<{ leftXml: unknown; rightXml: unknown }>();
const onlyShowDifferences = ref(false);
const { leftXml, rightXml } = toRefs(props);
const appTheme = useAppTheme();
const result = computed(() => {
const [reconciledLeftXml, reconciledRightXml] = reconcileArrayShapes(leftXml.value, rightXml.value);
return diff(reconciledLeftXml, reconciledRightXml, { onlyShowDifferences: onlyShowDifferences.value });
});
const xmlAreTheSame = computed(() => _.isEqual(leftXml.value, rightXml.value));
const showResults = computed(() => !_.isUndefined(leftXml.value) && !_.isUndefined(rightXml.value));
</script>
<template>
<div v-if="showResults">
<div flex justify-center>
<n-form-item :label="$t('tools.xml-diff-viewer.texts.only-show-differences')" label-placement="left">
<n-switch v-model:value="onlyShowDifferences" />
</n-form-item>
</div>
<c-card data-test-id="diff-result">
<div v-if="xmlAreTheSame" text-center op-70>
{{ $t('tools.xml-diff-viewer.texts.the-provided-xmls-are-the-same') }}
</div>
<DiffRootViewer v-else :diff="result" />
</c-card>
</div>
</template>
<style lang="less" scoped>
::v-deep(.diffs-viewer) {
color: v-bind('appTheme.text.mutedColor');
& > ul {
padding-left: 0 !important;
}
ul {
list-style: none;
padding-left: 20px;
margin: 0;
li {
.updated-line {
padding: 3px 0;
}
.result,
.array,
.object,
.value {
&:not(:last-child) {
margin-right: 4px;
}
&.added {
padding: 3px 5px;
border-radius: 4px;
background-color: v-bind('appTheme.success.colorFaded');
color: v-bind('appTheme.success.color');
.key {
color: inherit;
}
}
&.removed {
padding: 3px 5px;
border-radius: 4px;
background-color: v-bind('appTheme.error.colorFaded');
color: v-bind('appTheme.error.color');
.key {
color: inherit;
}
}
}
.value {
cursor: pointer;
border: 1px solid transparent;
transition: border-color 0.2s ease-in-out;
&.added:hover {
border-color: v-bind('appTheme.success.color');
}
&.removed:hover {
border-color: v-bind('appTheme.error.color');
}
}
.added .added,
.removed .removed {
background-color: transparent;
color: inherit;
}
.key {
font-weight: 500;
color: v-bind('appTheme.text.baseColor');
}
}
}
}
</style>
-13
View File
@@ -1,13 +0,0 @@
import { defineTool } from '../tool';
import { translate as t } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: t('tools.xml-diff.title'),
path: '/xml-diff',
description: t('tools.xml-diff.description'),
keywords: ['xml', 'diff', 'compare', 'difference'],
component: () => import('./xml-diff.vue'),
icon: defineAsyncComponent(() => import('@vicons/material/es/CompareArrowsRound')),
createdAt: new Date('2026-11-22'),
category: 'XML',
});
-51
View File
@@ -1,51 +0,0 @@
import { expect, test } from '@playwright/test';
test.describe('Tool - XML diff', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/xml-diff');
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('XML diff - IT Tools');
});
test('Identical XMLs have a custom result message', async ({ page }) => {
await page.getByTestId('leftXml').fill('<foo><bar>baz</bar></foo>');
await page.getByTestId('rightXml').fill('<foo>\n <bar>baz</bar>\n</foo>');
const result = await page.getByTestId('diff-result').innerText();
expect(result).toContain('The provided XMLs are the same');
});
test('Different XMLs have differences listed', async ({ page }) => {
await page.getByTestId('leftXml').fill('<root foo="bar"/>');
await page.getByTestId('rightXml').fill('<root foo="buz" baz="qux"/>');
const result = await page.getByTestId('diff-result').innerText();
expect(result).toContain('{\n@foo: "bar""buz",\n@baz: "qux",\n},');
});
test('Different XMLs have only differences listed when "Only show differences" is checked', async ({ page }) => {
await page.getByTestId('leftXml').fill('<root foo="bar"/>');
await page.getByTestId('rightXml').fill('<root foo="bar" baz="qux"/>');
await page.getByRole('switch').click();
const result = await page.getByTestId('diff-result').innerText();
expect(result).toContain('{\n@baz: "qux",\n},');
expect(result).not.toContain('foo');
});
test('An element going from a single occurrence to several is diffed cleanly, not as a type change', async ({
page,
}) => {
await page.getByTestId('leftXml').fill('<root><item>A</item></root>');
await page.getByTestId('rightXml').fill('<root><item>A</item><item>B</item></root>');
const result = await page.getByTestId('diff-result').innerText();
expect(result).toContain('item: [\n"A",\n"B",\n],');
});
});
@@ -1,65 +0,0 @@
// @vitest-environment jsdom
import { describe, expect, it } from 'vitest';
import { isValidXML, parseXml } from './xml-diff.parser';
describe('xml-diff parser', () => {
describe('parseXml', () => {
it('returns undefined for an empty string', () => {
expect(parseXml('')).toBeUndefined();
expect(parseXml(' ')).toBeUndefined();
});
it('returns undefined for invalid xml', () => {
expect(parseXml('<a><b></a>')).toBeUndefined();
});
it('parses a leaf element to its text content', () => {
expect(parseXml('<foo>bar</foo>')).toEqual('bar');
});
it('parses an empty element to an empty string', () => {
expect(parseXml('<foo/>')).toEqual('');
});
it('parses attributes with an "@" prefix', () => {
expect(parseXml('<foo a="1" b="2"/>')).toEqual({ '@a': '1', '@b': '2' });
});
it('parses a single child element as a plain value', () => {
expect(parseXml('<root><item>A</item></root>')).toEqual({ item: 'A' });
});
it('parses repeated child elements as an array', () => {
expect(parseXml('<root><item>A</item><item>B</item></root>')).toEqual({ item: ['A', 'B'] });
});
it('combines attributes, text and children', () => {
expect(parseXml('<root id="1">hello<child>world</child></root>')).toEqual({
'@id': '1',
'#text': 'hello',
child: 'world',
});
});
it('ignores insignificant whitespace between tags', () => {
const withoutWhitespace = parseXml('<foo><bar>baz</bar></foo>');
const withWhitespace = parseXml('<foo>\n <bar>baz</bar>\n</foo>');
expect(withWhitespace).toEqual(withoutWhitespace);
});
});
describe('isValidXML', () => {
it('accepts an empty string', () => {
expect(isValidXML('')).toBe(true);
});
it('accepts valid xml', () => {
expect(isValidXML('<foo>bar</foo>')).toBe(true);
});
it('rejects invalid xml', () => {
expect(isValidXML('<a><b></a>')).toBe(false);
});
});
});
-74
View File
@@ -1,74 +0,0 @@
export { isValidXML, parseXml };
function parseXml(rawXml: string): unknown {
const trimmed = rawXml.trim();
if (trimmed === '') {
return undefined;
}
const doc = parseXmlDocument(trimmed);
if (doc === undefined || doc.documentElement === null) {
return undefined;
}
return elementToValue(doc.documentElement);
}
function isValidXML(rawXml: string): boolean {
const trimmed = rawXml.trim();
if (trimmed === '') {
return true;
}
return parseXmlDocument(trimmed) !== undefined;
}
function parseXmlDocument(xml: string): Document | undefined {
const doc = new DOMParser().parseFromString(xml, 'application/xml');
if (doc.getElementsByTagName('parsererror').length > 0) {
return undefined;
}
return doc;
}
function elementToValue(element: Element): unknown {
const attributes = Array.from(element.attributes);
const childElements = Array.from(element.children);
const text = getDirectText(element);
if (attributes.length === 0 && childElements.length === 0) {
return text;
}
const value: Record<string, unknown> = {};
for (const attribute of attributes) {
value[`@${attribute.name}`] = attribute.value;
}
const tags = [...new Set(childElements.map((child) => child.tagName))];
for (const tag of tags) {
const sameTagChildren = childElements.filter((child) => child.tagName === tag);
value[tag] =
sameTagChildren.length === 1 ? elementToValue(sameTagChildren[0]) : sameTagChildren.map(elementToValue);
}
if (text !== '') {
value['#text'] = text;
}
return value;
}
function getDirectText(element: Element): string {
return Array.from(element.childNodes)
.filter((node) => node.nodeType === Node.TEXT_NODE || node.nodeType === Node.CDATA_SECTION_NODE)
.map((node) => node.textContent ?? '')
.join('')
.trim();
}
@@ -1,63 +0,0 @@
import { describe, expect, it } from 'vitest';
import { diff } from '../json-diff/json-diff.models';
import { reconcileArrayShapes } from './xml-diff.reconcile';
describe('xml-diff reconcile', () => {
describe('reconcileArrayShapes', () => {
it('leaves matching plain values untouched', () => {
expect(reconcileArrayShapes({ item: 'A' }, { item: 'B' })).toEqual([{ item: 'A' }, { item: 'B' }]);
});
it('pads the shorter side when both are arrays of different lengths', () => {
expect(reconcileArrayShapes({ item: ['A'] }, { item: ['A', 'B'] })).toEqual([
{ item: ['A', undefined] },
{ item: ['A', 'B'] },
]);
});
it('wraps a single value in an array when the other side has an array for the same key', () => {
const [left, right] = reconcileArrayShapes({ item: 'A' }, { item: ['A', 'B'] });
expect(left).toEqual({ item: ['A', undefined] });
expect(right).toEqual({ item: ['A', 'B'] });
});
it('recurses into nested objects', () => {
const [left, right] = reconcileArrayShapes({ root: { item: 'A' } }, { root: { item: ['A', 'B'] } });
expect(left).toEqual({ root: { item: ['A', undefined] } });
expect(right).toEqual({ root: { item: ['A', 'B'] } });
});
});
describe('diff after reconciliation', () => {
it('produces a clean diff when an element goes from single to repeated', () => {
const left = { item: 'A' };
const right = { item: ['A', 'B'] };
const [reconciledLeft, reconciledRight] = reconcileArrayShapes(left, right);
const result = diff(reconciledLeft, reconciledRight);
expect(result).toEqual({
key: '',
type: 'object',
oldValue: { item: ['A', undefined] },
value: { item: ['A', 'B'] },
status: 'children-updated',
children: [
{
key: 'item',
type: 'array',
oldValue: ['A', undefined],
value: ['A', 'B'],
status: 'children-updated',
children: [
{ key: 0, type: 'value', oldValue: 'A', value: 'A', status: 'unchanged' },
{ key: 1, type: 'value', oldValue: undefined, value: 'B', status: 'added' },
],
},
],
});
});
});
});
-60
View File
@@ -1,60 +0,0 @@
export { reconcileArrayShapes };
/**
* XML has no way to know, from a single document, whether a repeated element
* could also legitimately appear once. `xml-diff.parser` therefore represents
* a single occurrence as a plain value and 2+ occurrences as an array, which
* means the same element key can land on different shapes on each side of the
* diff (e.g. `item: {...}` on the left, `item: [{...}, {...}]` on the right).
* Diffing an object against an array directly produces nonsense, so before
* calling the generic diff we walk both trees together and wrap the
* non-array side in a single-element array wherever the two sides disagree.
*/
function reconcileArrayShapes(left: unknown, right: unknown): [unknown, unknown] {
if (Array.isArray(left) || Array.isArray(right)) {
return reconcileArrays(
Array.isArray(left) ? left : left === undefined ? [] : [left],
Array.isArray(right) ? right : right === undefined ? [] : [right],
);
}
if (isPlainObject(left) && isPlainObject(right)) {
return reconcileObjects(left, right);
}
return [left, right];
}
function reconcileArrays(left: unknown[], right: unknown[]): [unknown[], unknown[]] {
const maxLength = Math.max(left.length, right.length);
const reconciledLeft: unknown[] = [];
const reconciledRight: unknown[] = [];
for (let i = 0; i < maxLength; i++) {
const [reconciledLeftItem, reconciledRightItem] = reconcileArrayShapes(left[i], right[i]);
reconciledLeft.push(reconciledLeftItem);
reconciledRight.push(reconciledRightItem);
}
return [reconciledLeft, reconciledRight];
}
function reconcileObjects(
left: Record<string, unknown>,
right: Record<string, unknown>,
): [Record<string, unknown>, Record<string, unknown>] {
const reconciledLeft: Record<string, unknown> = { ...left };
const reconciledRight: Record<string, unknown> = { ...right };
for (const key of new Set([...Object.keys(left), ...Object.keys(right)])) {
const [reconciledLeftValue, reconciledRightValue] = reconcileArrayShapes(left[key], right[key]);
reconciledLeft[key] = reconciledLeftValue;
reconciledRight[key] = reconciledRightValue;
}
return [reconciledLeft, reconciledRight];
}
function isPlainObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null;
}
-47
View File
@@ -1,47 +0,0 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
import DiffsViewer from './diff-viewer/xml-diff-viewer.vue';
import { isValidXML, parseXml } from './xml-diff.parser';
const rawLeftXml = ref('');
const rawRightXml = ref('');
const leftXml = computed(() => parseXml(rawLeftXml.value));
const rightXml = computed(() => parseXml(rawRightXml.value));
const xmlValidationRules = [
{
validator: (value: string) => isValidXML(value),
message: t('tools.xml-diff.texts.message-invalid-xml-format'),
},
];
</script>
<template>
<c-input-text
v-model:value="rawLeftXml"
:validation-rules="xmlValidationRules"
:label="t('tools.xml-diff.texts.label-your-first-xml')"
:placeholder="t('tools.xml-diff.texts.placeholder-paste-your-first-xml-here')"
rows="20"
test-id="leftXml"
raw-text
multiline
monospace
/>
<c-input-text
v-model:value="rawRightXml"
:validation-rules="xmlValidationRules"
:label="t('tools.xml-diff.texts.label-your-xml-to-compare')"
:placeholder="t('tools.xml-diff.texts.placeholder-paste-your-xml-to-compare-here')"
rows="20"
multiline
test-id="rightXml"
raw-text
monospace
/>
<DiffsViewer :left-xml="leftXml" :right-xml="rightXml" />
</template>