feat: use more compact diff for activatable skill parameters

Uses HTML syntax.
This commit is contained in:
Lukas Obermann
2026-03-13 19:38:39 +01:00
parent fecbae5bbb
commit 70d70823c2
3 changed files with 35 additions and 11 deletions
+17 -7
View File
@@ -9,9 +9,10 @@
"version": "0.4.0",
"license": "MPL-2.0",
"dependencies": {
"@elyukai/utils": "^0.3.1",
"@elyukai/utils": "^0.3.2",
"@optolith/adventure-points": "^0.1.1",
"@optolith/helpers": "^0.2.2",
"diff": "^8.0.3",
"messageformat": "^4.0.0",
"tsondb": "^0.20.0"
},
@@ -82,9 +83,9 @@
}
},
"node_modules/@elyukai/utils": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@elyukai/utils/-/utils-0.3.1.tgz",
"integrity": "sha512-OzfEkxVu8uYbPfrrUPaYLMVMh27dyx0VqK9gwULjDnZdMb9egtFSPeMQandGXDjEXGfb+USa4iWP8zSudh0QwQ==",
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@elyukai/utils/-/utils-0.3.2.tgz",
"integrity": "sha512-COD5Yisf29xQAFIkFmNamf6wrd9O4eQGX9aQgkLUkGsENVRTm2uOBPA1wlmo6prjQ4zVCePeeGNc6Q3Kzqpejg==",
"license": "MPL-2.0"
},
"node_modules/@es-joy/jsdoccomment": {
@@ -1948,6 +1949,15 @@
"node": ">=8"
}
},
"node_modules/diff": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/diff/-/diff-8.0.3.tgz",
"integrity": "sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/dot-prop": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
@@ -2681,9 +2691,9 @@
}
},
"node_modules/flatted": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz",
"integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==",
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.1.tgz",
"integrity": "sha512-IxfVbRFVlV8V/yRaGzk0UVIcsKKHMSfYw66T/u4nTwlWteQePsxe//LjudR1AMX4tZW3WFCh3Zqa/sjlqpbURQ==",
"dev": true,
"license": "ISC",
"peer": true
+2 -1
View File
@@ -33,9 +33,10 @@
},
"homepage": "https://github.com/Optolith/entity-descriptions#readme",
"dependencies": {
"@elyukai/utils": "^0.3.1",
"@elyukai/utils": "^0.3.2",
"@optolith/adventure-points": "^0.1.1",
"@optolith/helpers": "^0.2.2",
"diff": "^8.0.3",
"messageformat": "^4.0.0",
"tsondb": "^0.20.0"
},
+16 -3
View File
@@ -7,6 +7,7 @@ import { romanize } from "@elyukai/utils/roman"
import { numAsc, type Compare } from "@optolith/helpers/compare"
import { isNotNullish, mapNullable } from "@optolith/helpers/nullable"
import { assertExhaustive } from "@optolith/helpers/typeSafety"
import { diffWordsWithSpace } from "diff"
import {
type ActivatableSkillEffect,
type AnimistPowerImprovementCost,
@@ -102,13 +103,25 @@ const combineGeneratedTextWithStaticTranslation = (
}
const normalizedStaticText = typeof staticText === "string" ? staticText : staticText?.full
const diff =
normalizedStaticText === undefined
? undefined
: diffWordsWithSpace(normalizedStaticText, generatedText)
return {
label,
value:
normalizedStaticText !== undefined && generatedText !== normalizedStaticText
? `***${generatedText}*** (${normalizedStaticText})`
: generatedText,
diff === undefined
? generatedText
: diff
.map(part =>
part.added
? `<ins>${part.value}</ins>`
: part.removed
? `<del>${part.value}</del>`
: part.value,
)
.join(""),
}
}