Modify some parts of PR
This commit is contained in:
@@ -98,6 +98,7 @@
|
|||||||
"@tsconfig/svelte": "^3.0.0",
|
"@tsconfig/svelte": "^3.0.0",
|
||||||
"@types/blueimp-md5": "^2.18.2",
|
"@types/blueimp-md5": "^2.18.2",
|
||||||
"@types/codemirror": "^5.60.15",
|
"@types/codemirror": "^5.60.15",
|
||||||
|
"@types/diff": "^6.0.0",
|
||||||
"@types/dompurify": "^3.0.5",
|
"@types/dompurify": "^3.0.5",
|
||||||
"@types/libsodium-wrappers-sumo": "^0.7.8",
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|
||||||
"@types/lodash": "^4.14.202",
|
"@types/lodash": "^4.14.202",
|
||||||
|
|||||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -249,6 +249,9 @@ importers:
|
|||||||
'@types/codemirror':
|
'@types/codemirror':
|
||||||
specifier: ^5.60.15
|
specifier: ^5.60.15
|
||||||
version: 5.60.15
|
version: 5.60.15
|
||||||
|
'@types/diff':
|
||||||
|
specifier: ^6.0.0
|
||||||
|
version: 6.0.0
|
||||||
'@types/dompurify':
|
'@types/dompurify':
|
||||||
specifier: ^3.0.5
|
specifier: ^3.0.5
|
||||||
version: 3.0.5
|
version: 3.0.5
|
||||||
@@ -1211,6 +1214,9 @@ packages:
|
|||||||
'@types/codemirror@5.60.15':
|
'@types/codemirror@5.60.15':
|
||||||
resolution: {integrity: sha512-dTOvwEQ+ouKJ/rE9LT1Ue2hmP6H1mZv5+CCnNWu2qtiOe2LQa9lCprEY20HxiDmV/Bxh+dXjywmy5aKvoGjULA==}
|
resolution: {integrity: sha512-dTOvwEQ+ouKJ/rE9LT1Ue2hmP6H1mZv5+CCnNWu2qtiOe2LQa9lCprEY20HxiDmV/Bxh+dXjywmy5aKvoGjULA==}
|
||||||
|
|
||||||
|
'@types/diff@6.0.0':
|
||||||
|
resolution: {integrity: sha512-dhVCYGv3ZSbzmQaBSagrv1WJ6rXCdkyTcDyoNu1MD8JohI7pR7k8wdZEm+mvdxRKXyHVwckFzWU1vJc+Z29MlA==}
|
||||||
|
|
||||||
'@types/dompurify@3.0.5':
|
'@types/dompurify@3.0.5':
|
||||||
resolution: {integrity: sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==}
|
resolution: {integrity: sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==}
|
||||||
|
|
||||||
@@ -4865,6 +4871,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/tern': 0.23.9
|
'@types/tern': 0.23.9
|
||||||
|
|
||||||
|
'@types/diff@6.0.0': {}
|
||||||
|
|
||||||
'@types/dompurify@3.0.5':
|
'@types/dompurify@3.0.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/trusted-types': 2.0.7
|
'@types/trusted-types': 2.0.7
|
||||||
|
|||||||
@@ -838,5 +838,7 @@ export const languageEnglish = {
|
|||||||
showSavingIcon: "Show Saving Icon",
|
showSavingIcon: "Show Saving Icon",
|
||||||
pluginVersionWarn: "This is {{plugin_version}} version of the plugin. which is not compatible with this version of RisuAI. please update the plugin to {{required_version}} version.",
|
pluginVersionWarn: "This is {{plugin_version}} version of the plugin. which is not compatible with this version of RisuAI. please update the plugin to {{required_version}} version.",
|
||||||
imageTranslation: "Image Translation",
|
imageTranslation: "Image Translation",
|
||||||
banCharacterset: 'Auto Regenerate On Characterset'
|
banCharacterset: 'Auto Regenerate On Characterset',
|
||||||
|
checkCorruption: "Check Corruption",
|
||||||
|
showPromptComparison: "Show Prompt Comparison",
|
||||||
}
|
}
|
||||||
@@ -192,6 +192,10 @@
|
|||||||
<Help key="dynamicAssets"/>
|
<Help key="dynamicAssets"/>
|
||||||
</Check>
|
</Check>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center mt-4">
|
||||||
|
<Check bind:check={DBState.db.checkCorruption} name={language.checkCorruption}>
|
||||||
|
</Check>
|
||||||
|
</div>
|
||||||
{#if DBState.db?.account?.useSync}
|
{#if DBState.db?.account?.useSync}
|
||||||
<div class="flex items-center mt-4">
|
<div class="flex items-center mt-4">
|
||||||
<Check bind:check={DBState.db.lightningRealmImport} name={"Lightning Realm Import"}>
|
<Check bind:check={DBState.db.lightningRealmImport} name={"Lightning Realm Import"}>
|
||||||
|
|||||||
@@ -304,6 +304,10 @@
|
|||||||
<Check bind:check={DBState.db.showSavingIcon} name={language.showSavingIcon}/>
|
<Check bind:check={DBState.db.showSavingIcon} name={language.showSavingIcon}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center mt-2">
|
||||||
|
<Check bind:check={DBState.db.showPromptComparison} name={language.showPromptComparison}/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if DBState.db.textScreenBorder}
|
{#if DBState.db.textScreenBorder}
|
||||||
<div class="flex items-center mt-2">
|
<div class="flex items-center mt-2">
|
||||||
<Check check={true} onChange={() => {
|
<Check check={true} onChange={() => {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
import { prebuiltPresets } from "src/ts/process/templates/templates";
|
import { prebuiltPresets } from "src/ts/process/templates/templates";
|
||||||
import { ShowRealmFrameStore } from "src/ts/stores.svelte";
|
import { ShowRealmFrameStore } from "src/ts/stores.svelte";
|
||||||
import type { PromptItem, PromptItemPlain, PromptItemChatML, PromptItemTyped, PromptItemAuthorNote, PromptItemChat } from "src/ts/process/prompt.ts";
|
import type { PromptItem, PromptItemPlain, PromptItemChatML, PromptItemTyped, PromptItemAuthorNote, PromptItemChat } from "src/ts/process/prompt.ts";
|
||||||
import { diffWordsWithSpace, diffLines } from 'diff';
|
|
||||||
|
|
||||||
let editMode = $state(false)
|
let editMode = $state(false)
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -112,7 +111,8 @@
|
|||||||
return prompt
|
return prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkDiff(prompt1: string, prompt2: string): string {
|
async function checkDiff(prompt1: string, prompt2: string): Promise<string> {
|
||||||
|
const { diffLines } = await import('diff')
|
||||||
const lineDiffs = diffLines(prompt1, prompt2)
|
const lineDiffs = diffLines(prompt1, prompt2)
|
||||||
|
|
||||||
let resultHtml = '';
|
let resultHtml = '';
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
if(linePart.removed){
|
if(linePart.removed){
|
||||||
const nextPart = lineDiffs[i + 1]
|
const nextPart = lineDiffs[i + 1]
|
||||||
if(nextPart?.added){
|
if(nextPart?.added){
|
||||||
resultHtml += `<div style="border-left: 4px solid blue; padding-left: 8px;">${highlightChanges(linePart.value, nextPart.value)}</div>`
|
resultHtml += `<div style="border-left: 4px solid blue; padding-left: 8px;">${await highlightChanges(linePart.value, nextPart.value)}</div>`
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -148,7 +148,8 @@
|
|||||||
return resultHtml
|
return resultHtml
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightChanges(string1: string, string2: string) {
|
async function highlightChanges(string1: string, string2: string) {
|
||||||
|
const { diffWordsWithSpace } = await import('diff')
|
||||||
const charDiffs = diffWordsWithSpace(string1, string2)
|
const charDiffs = diffWordsWithSpace(string1, string2)
|
||||||
|
|
||||||
return charDiffs
|
return charDiffs
|
||||||
@@ -169,7 +170,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleDiffMode(id: number) {
|
async function handleDiffMode(id: number) {
|
||||||
if (selectedDiffPreset === id) {
|
if (selectedDiffPreset === id) {
|
||||||
selectedDiffPreset = -1
|
selectedDiffPreset = -1
|
||||||
selectedPrompts = []
|
selectedPrompts = []
|
||||||
@@ -193,7 +194,7 @@
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
alertWait("Loading...")
|
alertWait("Loading...")
|
||||||
const result = checkDiff(selectedPrompts[0], prompt)
|
const result = await checkDiff(selectedPrompts[0], prompt)
|
||||||
alertMd(result)
|
alertMd(result)
|
||||||
selectedDiffPreset = -1
|
selectedDiffPreset = -1
|
||||||
selectedPrompts = []
|
selectedPrompts = []
|
||||||
@@ -234,6 +235,7 @@
|
|||||||
<span>{preset.name}</span>
|
<span>{preset.name}</span>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex-grow flex justify-end">
|
<div class="flex-grow flex justify-end">
|
||||||
|
{#if DBState.db.showPromptComparison}
|
||||||
<div class="{selectedDiffPreset === i ? 'text-green-500' : 'text-textcolor2 hover:text-green-500'} cursor-pointer mr-2" role="button" tabindex="0" onclick={(e) => {
|
<div class="{selectedDiffPreset === i ? 'text-green-500' : 'text-textcolor2 hover:text-green-500'} cursor-pointer mr-2" role="button" tabindex="0" onclick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
handleDiffMode(i)
|
handleDiffMode(i)
|
||||||
@@ -244,6 +246,7 @@
|
|||||||
}}>
|
}}>
|
||||||
<GitCompare size={18}/>
|
<GitCompare size={18}/>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="text-textcolor2 hover:text-green-500 cursor-pointer mr-2" role="button" tabindex="0" onclick={(e) => {
|
<div class="text-textcolor2 hover:text-green-500 cursor-pointer mr-2" role="button" tabindex="0" onclick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
copyPreset(i)
|
copyPreset(i)
|
||||||
|
|||||||
@@ -468,6 +468,8 @@ export function setDatabase(data:Database){
|
|||||||
data.assetMaxDifference ??= 4
|
data.assetMaxDifference ??= 4
|
||||||
data.showSavingIcon ??= false
|
data.showSavingIcon ??= false
|
||||||
data.banCharacterset ??= []
|
data.banCharacterset ??= []
|
||||||
|
data.showPromptComparison ??= false
|
||||||
|
data.checkCorruption ??= true
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
setDatabaseLite(data)
|
setDatabaseLite(data)
|
||||||
}
|
}
|
||||||
@@ -868,6 +870,8 @@ export interface Database{
|
|||||||
showSavingIcon:boolean
|
showSavingIcon:boolean
|
||||||
presetRegex: customscript[]
|
presetRegex: customscript[]
|
||||||
banCharacterset:string[]
|
banCharacterset:string[]
|
||||||
|
showPromptComparison:boolean
|
||||||
|
checkCorruption:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SeparateParameters{
|
interface SeparateParameters{
|
||||||
|
|||||||
Reference in New Issue
Block a user