Merge branch 'kwaroran:main' into main
This commit is contained in:
@@ -8,7 +8,7 @@ android {
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 2
|
||||
versionName "114.2.0"
|
||||
versionName "114.2.2"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 2,
|
||||
"versionName": "114.2.0",
|
||||
"versionName": "114.2.2",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "RisuAI",
|
||||
"version": "114.2.0"
|
||||
"version": "114.2.2"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import { DataBase, setDatabase, type character } from "src/ts/storage/database";
|
||||
import PlaygroundImageGen from "./PlaygroundImageGen.svelte";
|
||||
import PlaygroundParser from "./PlaygroundParser.svelte";
|
||||
|
||||
const playgroundChat = () => {
|
||||
let db = get(DataBase)
|
||||
@@ -75,6 +76,11 @@
|
||||
}}>
|
||||
<h1 class="text-2xl font-bold text-start">{language.imageGeneration}</h1>
|
||||
</button>
|
||||
<button class="bg-darkbg rounded-md p-6 flex flex-col transition-shadow hover:ring-1" on:click={() => {
|
||||
PlaygroundStore.set(8)
|
||||
}}>
|
||||
<h1 class="text-2xl font-bold text-start">Parser</h1>
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
{#if $SizeStore.w < 1024}
|
||||
@@ -105,6 +111,9 @@
|
||||
{#if $PlaygroundStore === 7}
|
||||
<PlaygroundImageGen/>
|
||||
{/if}
|
||||
{#if $PlaygroundStore === 8}
|
||||
<PlaygroundParser/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
23
src/lib/Playground/PlaygroundParser.svelte
Normal file
23
src/lib/Playground/PlaygroundParser.svelte
Normal file
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { ParseMarkdown } from "src/ts/parser";
|
||||
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
|
||||
let input = "";
|
||||
let output = "";
|
||||
const onInput = async () => {
|
||||
try {
|
||||
output = await ParseMarkdown(input)
|
||||
} catch (e) {
|
||||
output = `Error: ${e}`
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<h2 class="text-4xl text-textcolor my-6 font-black relative">Full Parser</h2>
|
||||
|
||||
<span class="text-textcolor text-lg">Input</span>
|
||||
|
||||
<TextAreaInput onInput={onInput} bind:value={input} optimaizedInput={false} />
|
||||
|
||||
<span class="text-textcolor text-lg">Output HTML</span>
|
||||
|
||||
<TextAreaInput value={output} />
|
||||
@@ -187,8 +187,10 @@ export async function ParseMarkdown(data:string, charArg:(character|simpleCharac
|
||||
data = await parseInlayImages(data)
|
||||
|
||||
data = encodeStyle(data)
|
||||
if(mode !== 'back'){
|
||||
data = risuFormater(data)
|
||||
data = mconverted.parse(data)
|
||||
}
|
||||
return decodeStyle(DOMPurify.sanitize(data, {
|
||||
ADD_TAGS: ["iframe", "style", "risu-style", "x-em"],
|
||||
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling", "risu-btn", 'risu-trigger', 'risu-mark'],
|
||||
@@ -761,9 +763,6 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
case 'prefill_supported':{
|
||||
return db.aiModel.startsWith('claude') ? '1' : '0'
|
||||
}
|
||||
case 'unixtime':{
|
||||
return (Date.now() / 1000).toFixed(2)
|
||||
}
|
||||
case 'screen_width':{
|
||||
return get(SizeStore).w.toString()
|
||||
}
|
||||
@@ -1056,9 +1055,9 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
if(p1.startsWith('pick')){
|
||||
const selchar = db.characters[get(selectedCharID)]
|
||||
const selChat = selchar.chats[selchar.chatPage]
|
||||
const cid = (chatID < 0) ? selChat.message.length : chatID
|
||||
const cid = selChat.message.length
|
||||
if(p1.startsWith('pick::')){
|
||||
const randomIndex = Math.floor(pickHashRand(cid, selchar.chaId) * (arra.length - 1)) + 1
|
||||
const randomIndex = Math.floor(pickHashRand(cid, selchar.chaId + (selChat.id ?? '')) * (arra.length - 1)) + 1
|
||||
if(matcherArg.tokenizeAccurate){
|
||||
return arra[0]
|
||||
}
|
||||
@@ -1066,7 +1065,7 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
}
|
||||
else{
|
||||
const arr = p1.replace(/\\,/g, '§X').split(/\:|\,/g)
|
||||
const randomIndex = Math.floor(pickHashRand(cid, selchar.chaId) * (arr.length - 1)) + 1
|
||||
const randomIndex = Math.floor(pickHashRand(cid, selchar.chaId + (selChat.id ?? '')) * (arr.length - 1)) + 1
|
||||
if(matcherArg.tokenizeAccurate){
|
||||
return arra[0]
|
||||
}
|
||||
@@ -1089,8 +1088,8 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
if(p){
|
||||
const selchar = db.characters[get(selectedCharID)]
|
||||
const selChat = selchar.chats[selchar.chatPage]
|
||||
const cid = (chatID < 0) ? selChat.message.length : chatID
|
||||
return (Math.floor(pickHashRand(cid, selchar.chaId) * maxRoll) + 1).toString()
|
||||
const cid = selChat.message.length
|
||||
return (Math.floor(pickHashRand(cid, selchar.chaId + (selChat.id ?? '')) * maxRoll) + 1).toString()
|
||||
}
|
||||
return (Math.floor(Math.random() * maxRoll) + 1).toString()
|
||||
}
|
||||
@@ -1127,7 +1126,7 @@ const matcher = (p1:string,matcherArg:matcherArg) => {
|
||||
}
|
||||
|
||||
function pickHashRand(cid:number,word:string) {
|
||||
let hashAddress = cid * 23515
|
||||
let hashAddress = 5515
|
||||
const rand = (word:string) => {
|
||||
for (let counter = 0; counter<word.length; counter++){
|
||||
hashAddress = ((hashAddress << 5) + hashAddress) + word.charCodeAt(counter)
|
||||
@@ -1135,6 +1134,10 @@ function pickHashRand(cid:number,word:string) {
|
||||
return hashAddress
|
||||
}
|
||||
const randF = sfc32(rand(word), rand(word), rand(word), rand(word))
|
||||
const v = cid % 1000
|
||||
for (let i = 0; i < v; i++){
|
||||
randF()
|
||||
}
|
||||
return randF()
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = "114.2.0"
|
||||
export let appVer = "114.2.2"
|
||||
export let webAppSubVer = ''
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
|
||||
@@ -371,7 +371,7 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
|
||||
node instanceof HTMLElement
|
||||
) {
|
||||
const children = Array.from(node.childNodes);
|
||||
const blacklist = ["img", "iframe", "script", "style", "div"];
|
||||
const blacklist = ["img", "iframe", "script", "style", "div", "button"];
|
||||
const hasBlacklistChild = children.some((child) =>
|
||||
blacklist.includes(child.nodeName.toLowerCase())
|
||||
);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":"114.2.0"}
|
||||
{"version":"114.2.2"}
|
||||
Reference in New Issue
Block a user