Update to 0.7.6 (#25)
This commit is contained in:
5
server/proxy/package.json
Normal file
5
server/proxy/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"cors-anywhere": "^0.4.4"
|
||||
}
|
||||
}
|
||||
68
server/proxy/pnpm-lock.yaml
generated
Normal file
68
server/proxy/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,68 @@
|
||||
lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
cors-anywhere: ^0.4.4
|
||||
http-proxy: ^1.18.1
|
||||
|
||||
dependencies:
|
||||
cors-anywhere: 0.4.4
|
||||
http-proxy: 1.18.1
|
||||
|
||||
packages:
|
||||
|
||||
/cors-anywhere/0.4.4:
|
||||
resolution: {integrity: sha512-8OBFwnzMgR4mNrAeAyOLB2EruS2z7u02of2bOu7i9kKYlZG+niS7CTHLPgEXKWW2NAOJWRry9RRCaL9lJRjNqg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dependencies:
|
||||
http-proxy: 1.11.1
|
||||
proxy-from-env: 0.0.1
|
||||
dev: false
|
||||
|
||||
/eventemitter3/1.2.0:
|
||||
resolution: {integrity: sha512-DOFqA1MF46fmZl2xtzXR3MPCRsXqgoFqdXcrCVYM3JNnfUeHTm/fh/v/iU7gBFpwkuBmoJPAm5GuhdDfSEJMJA==}
|
||||
dev: false
|
||||
|
||||
/eventemitter3/4.0.7:
|
||||
resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
|
||||
dev: false
|
||||
|
||||
/follow-redirects/1.15.2:
|
||||
resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
|
||||
engines: {node: '>=4.0'}
|
||||
peerDependencies:
|
||||
debug: '*'
|
||||
peerDependenciesMeta:
|
||||
debug:
|
||||
optional: true
|
||||
dev: false
|
||||
|
||||
/http-proxy/1.11.1:
|
||||
resolution: {integrity: sha512-qz7jZarkVG3G6GMq+4VRJPSN4NkIjL4VMTNhKGd8jc25BumeJjWWvnY3A7OkCGa8W1TTxbaK3dcE0ijFalITVA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dependencies:
|
||||
eventemitter3: 1.2.0
|
||||
requires-port: 0.0.1
|
||||
dev: false
|
||||
|
||||
/http-proxy/1.18.1:
|
||||
resolution: {integrity: sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
dependencies:
|
||||
eventemitter3: 4.0.7
|
||||
follow-redirects: 1.15.2
|
||||
requires-port: 1.0.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
dev: false
|
||||
|
||||
/proxy-from-env/0.0.1:
|
||||
resolution: {integrity: sha512-B9Hnta3CATuMS0q6kt5hEezOPM+V3dgaRewkFtFoaRQYTVNsHqUvFXmndH06z3QO1ZdDnRELv5vfY6zAj/gG7A==}
|
||||
dev: false
|
||||
|
||||
/requires-port/0.0.1:
|
||||
resolution: {integrity: sha512-AzPDCliPoWDSvEVYRQmpzuPhGGEnPrQz9YiOEvn+UdB9ixBpw+4IOZWtwctmpzySLZTy7ynpn47V14H4yaowtA==}
|
||||
dev: false
|
||||
|
||||
/requires-port/1.0.0:
|
||||
resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
|
||||
dev: false
|
||||
6
server/proxy/server.js
Normal file
6
server/proxy/server.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const cors_proxy = require('cors-anywhere');
|
||||
|
||||
const host = process.env.HOST || 'localhost';
|
||||
const port = process.env.PORT || 8080;
|
||||
|
||||
cors_proxy.createServer({originWhitelist: []}).listen(port, host, function() {console.log('Running Proxy on ' + host + ':' + port);});
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "RisuAI",
|
||||
"version": "0.7.5"
|
||||
"version": "0.7.6"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
@@ -476,9 +476,19 @@
|
||||
<span class="text-neutral-200">{language.requestretrys}</span>
|
||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" type="number" min={0} max="20" bind:value={$DataBase.requestRetrys}>
|
||||
|
||||
<span class="text-neutral-200">Request Method</span>
|
||||
<select class="bg-transparent input-text text-gray-200 appearance-none text-sm mb-4" bind:value={$DataBase.requestmet}>
|
||||
<option value="normal" class="bg-darkbg appearance-none">Normal</option>
|
||||
<option value="proxy" class="bg-darkbg appearance-none">Proxy</option>
|
||||
<option value="plain" class="bg-darkbg appearance-none">Plain Fetch</option>
|
||||
</select>
|
||||
|
||||
{#if isTauri}
|
||||
<span class="text-neutral-200 mt-2">Request Lib</span>
|
||||
{#if $DataBase.requestmet === 'proxy'}
|
||||
<span class="text-neutral-200">Request Proxy URL</span>
|
||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" bind:value={$DataBase.requestproxy}>
|
||||
{/if}
|
||||
{#if isTauri && $DataBase.requestmet === 'normal'}
|
||||
<span class="text-neutral-200">Request Lib</span>
|
||||
<select class="bg-transparent input-text text-gray-200 appearance-none text-sm" bind:value={$DataBase.requester}>
|
||||
<option value="new" class="bg-darkbg appearance-none">Reqwest</option>
|
||||
<option value="old" class="bg-darkbg appearance-none">Tauri</option>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { cloneDeep } from 'lodash';
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = '0.7.5'
|
||||
export let appVer = '0.7.6'
|
||||
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
@@ -172,6 +172,12 @@ export function setDatabase(data:Database){
|
||||
if(checkNullish(data.bias)){
|
||||
data.bias = []
|
||||
}
|
||||
if(checkNullish(data.requestmet)){
|
||||
data.requestmet = 'normal'
|
||||
}
|
||||
if(checkNullish(data.requestproxy)){
|
||||
data.requestproxy = ''
|
||||
}
|
||||
if(checkNullish(data.sdConfig)){
|
||||
data.sdConfig = {
|
||||
width:512,
|
||||
@@ -340,6 +346,8 @@ export interface Database{
|
||||
emotionPrompt2:string
|
||||
useSayNothing:boolean
|
||||
didFirstSetup: boolean
|
||||
requestmet: string
|
||||
requestproxy: string
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -310,8 +310,84 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
||||
}
|
||||
}
|
||||
|
||||
if(isTauri){
|
||||
if(db.requestmet === 'proxy'){
|
||||
try {
|
||||
let headers = arg.headers ?? {}
|
||||
if(!headers["Content-Type"]){
|
||||
headers["Content-Type"] = `application/json`
|
||||
}
|
||||
const furl = new URL(db.requestproxy)
|
||||
furl.pathname = url
|
||||
|
||||
const da = await fetch(furl, {
|
||||
body: JSON.stringify(arg.body),
|
||||
headers: arg.headers,
|
||||
method: method
|
||||
})
|
||||
|
||||
if(arg.rawResponse){
|
||||
addFetchLog("Uint8Array Response", da.ok)
|
||||
return {
|
||||
ok: da.ok,
|
||||
data: new Uint8Array(await da.arrayBuffer())
|
||||
}
|
||||
}
|
||||
else{
|
||||
const dat = await da.json()
|
||||
addFetchLog(dat, da.ok)
|
||||
return {
|
||||
ok: da.ok,
|
||||
data: dat
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
ok: false,
|
||||
data: `${error}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
if(db.requestmet === 'plain'){
|
||||
try {
|
||||
let headers = arg.headers ?? {}
|
||||
if(!headers["Content-Type"]){
|
||||
headers["Content-Type"] = `application/json`
|
||||
}
|
||||
const furl = new URL(url)
|
||||
|
||||
const da = await fetch(furl, {
|
||||
body: JSON.stringify(arg.body),
|
||||
headers: arg.headers,
|
||||
method: method
|
||||
})
|
||||
|
||||
if(arg.rawResponse){
|
||||
addFetchLog("Uint8Array Response", da.ok)
|
||||
return {
|
||||
ok: da.ok,
|
||||
data: new Uint8Array(await da.arrayBuffer())
|
||||
}
|
||||
}
|
||||
else{
|
||||
const dat = await da.json()
|
||||
addFetchLog(dat, da.ok)
|
||||
return {
|
||||
ok: da.ok,
|
||||
data: dat
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
ok: false,
|
||||
data: `${error}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isTauri){
|
||||
if(db.requester === 'new'){
|
||||
try {
|
||||
let preHeader = arg.headers ?? {}
|
||||
|
||||
Reference in New Issue
Block a user