ref: format

This commit is contained in:
alikia2x (寒寒) 2024-10-07 01:41:21 +08:00
parent 76c4472de1
commit ea8b503653
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
11 changed files with 4326 additions and 371 deletions

View File

@ -12,7 +12,7 @@ import { settingsAtom } from "lib/state/settings";
import PlainText from "./plainText";
import { sendError } from "lib/telemetering/sendError";
import { handleNLUResult } from "./handleNLUResult";
import * as ort from 'onnxruntime-web';
import * as ort from "onnxruntime-web";
import { useAtom, useAtomValue } from "jotai";
import i18next from "i18next";
import { useTranslation } from "react-i18next";
@ -100,16 +100,15 @@ export default function OneSearch() {
const embeddingDict = getEmbeddingLayer(arrBuf);
setEmbeddingLayer(embeddingDict);
await loadModel("/models/NLU.onnx");
await loadModel("/models/NLU.onnx");
// if (!modelLoaded) {
// console.error("NLU model was not correctly loaded.")
// }
})();
}, []);
async function loadModel(modelPath: string) {
ort.env.wasm.wasmPaths = "/onnx/"
ort.env.wasm.wasmPaths = "/onnx/";
const session = await ort.InferenceSession.create(modelPath);
setNLUsession(session);
}

View File

@ -1,10 +1,10 @@
{
"search": {
"placeholder": "ابحث أو اكتب عنوان URL"
},
"about": {
"license": {
"view": "← عرض"
}
}
"search": {
"placeholder": "ابحث أو اكتب عنوان URL"
},
"about": {
"license": {
"view": "← عرض"
}
}
}

View File

@ -1,39 +1,39 @@
{
"404": {
"title": "Page not found"
},
"search": {
"placeholder": "Search or type a URL",
"engine-aria": "Switch search engine",
"engine": {
"google": "Google",
"baidu": "Baidu",
"bing": "Bing",
"duckduckgo": "DuckDuckGo",
"yandex": "Yandex",
"yahoo": "Yahoo",
"ecosia": "Ecosia"
},
"search-help-text": "Search {engine}"
},
"notfound": {
"title": "page not found",
"desc": "Please check if there is a typo in the URL. <br/>If SparkHome brought you to this page,<br/> please <a style=\"text-decoration:underline;\" href=\"mailto:contact@alikia2x.com\">contact us.</a>"
},
"tools": {
"base64": {
"title": "Base64 tools - LuminaraUtils",
"decode": "Decode",
"encode": "Encode",
"result": "Result: ",
"copy": "Copy",
"copied": "Copied"
}
},
"about": {
"title": "About sparkast",
"license": {
"view": "→ view"
}
}
"404": {
"title": "Page not found"
},
"search": {
"placeholder": "Search or type a URL",
"engine-aria": "Switch search engine",
"engine": {
"google": "Google",
"baidu": "Baidu",
"bing": "Bing",
"duckduckgo": "DuckDuckGo",
"yandex": "Yandex",
"yahoo": "Yahoo",
"ecosia": "Ecosia"
},
"search-help-text": "Search {engine}"
},
"notfound": {
"title": "page not found",
"desc": "Please check if there is a typo in the URL. <br/>If SparkHome brought you to this page,<br/> please <a style=\"text-decoration:underline;\" href=\"mailto:contact@alikia2x.com\">contact us.</a>"
},
"tools": {
"base64": {
"title": "Base64 tools - LuminaraUtils",
"decode": "Decode",
"encode": "Encode",
"result": "Result: ",
"copy": "Copy",
"copied": "Copied"
}
},
"about": {
"title": "About sparkast",
"license": {
"view": "→ view"
}
}
}

View File

@ -1,14 +1,14 @@
{
"search": {
"engine-aria": "検索エンジンを切り替える",
"engine": {
"google": "Google"
},
"placeholder": "検索またはURLを入力"
},
"about": {
"license": {
"view": "→ 見る"
}
}
"search": {
"engine-aria": "検索エンジンを切り替える",
"engine": {
"google": "Google"
},
"placeholder": "検索またはURLを入力"
},
"about": {
"license": {
"view": "→ 見る"
}
}
}

View File

@ -1,39 +1,39 @@
{
"404": {
"title": "页面未找到"
},
"search": {
"placeholder": "搜索或输入网址",
"engine-aria": "切换搜索引擎",
"engine": {
"google": "谷歌",
"baidu": "百度",
"bing": "必应",
"duckduckgo": "DuckDuckGo",
"yandex": "Yandex",
"yahoo": "雅虎",
"ecosia": "Ecosia"
},
"search-help-text": "用 {engine} 搜索"
},
"tools": {
"base64": {
"title": "Base64 工具",
"decode": "解码",
"encode": "编码",
"result": "结果: ",
"copy": "复制",
"copied": "已复制"
}
},
"notfound": {
"desc": "请检查网址是否出错。 <br/>如果你从星火主页跳转到这里,<br/> 请 <a style=\"text-decoration:underline;\" href=\"mailto:contact@alikia2x.com\">联系我们</a>",
"title": "网页不存在"
},
"about": {
"title": "关于 sparkast",
"license": {
"view": "→ 查看"
}
}
"404": {
"title": "页面未找到"
},
"search": {
"placeholder": "搜索或输入网址",
"engine-aria": "切换搜索引擎",
"engine": {
"google": "谷歌",
"baidu": "百度",
"bing": "必应",
"duckduckgo": "DuckDuckGo",
"yandex": "Yandex",
"yahoo": "雅虎",
"ecosia": "Ecosia"
},
"search-help-text": "用 {engine} 搜索"
},
"tools": {
"base64": {
"title": "Base64 工具",
"decode": "解码",
"encode": "编码",
"result": "结果: ",
"copy": "复制",
"copied": "已复制"
}
},
"notfound": {
"desc": "请检查网址是否出错。 <br/>如果你从星火主页跳转到这里,<br/> 请 <a style=\"text-decoration:underline;\" href=\"mailto:contact@alikia2x.com\">联系我们</a>",
"title": "网页不存在"
},
"about": {
"title": "关于 sparkast",
"license": {
"view": "→ 查看"
}
}
}

View File

@ -1,64 +1,64 @@
{
"name": "sparkhome",
"private": false,
"version": "5.8.1",
"type": "module",
"scripts": {
"dev": "bun server.ts",
"build": "bun license-gen && tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "NODE_ENV=production bun server.ts",
"license-gen": "bunx generate-license-file --input package.json --output lib/license.txt --overwrite",
"format": "prettier --write ."
},
"dependencies": {
"@iconify/react": "^5.0.1",
"@nextui-org/react": "^2.4.2",
"@types/bun": "^1.1.6",
"@types/express": "^4.17.21",
"@types/tr46": "^5.0.0",
"@xenova/transformers": "^2.17.2",
"cac": "^6.7.14",
"chalk": "^5.3.0",
"express": "^4.19.2",
"fflate": "^0.8.2",
"framer-motion": "^11.2.12",
"generate-license-file": "^3.5.1",
"i18next": "^23.11.5",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-icu": "^2.3.0",
"jest": "^29.7.0",
"jotai": "^2.8.3",
"node-nlp": "^4.27.0",
"onnxruntime-web": "^1.20.0-dev.20240925-a47254eaef",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^14.1.2",
"react-router": "^6.23.1",
"react-router-dom": "^6.23.1",
"tr46": "^5.0.0",
"valid-url": "^1.0.9",
"validate-color": "^2.2.4",
"vite-express": "^0.17.0"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/valid-url": "^1.0.7",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"postcss": "^8.4.38",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.4",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vite-plugin-chunk-split": "^0.5.0",
"vite-plugin-pages": "^0.32.2",
"vite-tsconfig-paths": "^4.3.2"
}
"name": "sparkhome",
"private": false,
"version": "5.8.1",
"type": "module",
"scripts": {
"dev": "bun server.ts",
"build": "bun license-gen && tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "NODE_ENV=production bun server.ts",
"license-gen": "bunx generate-license-file --input package.json --output lib/license.txt --overwrite",
"format": "prettier --write ."
},
"dependencies": {
"@iconify/react": "^5.0.1",
"@nextui-org/react": "^2.4.2",
"@types/bun": "^1.1.6",
"@types/express": "^4.17.21",
"@types/tr46": "^5.0.0",
"@xenova/transformers": "^2.17.2",
"cac": "^6.7.14",
"chalk": "^5.3.0",
"express": "^4.19.2",
"fflate": "^0.8.2",
"framer-motion": "^11.2.12",
"generate-license-file": "^3.5.1",
"i18next": "^23.11.5",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-icu": "^2.3.0",
"jest": "^29.7.0",
"jotai": "^2.8.3",
"node-nlp": "^4.27.0",
"onnxruntime-web": "^1.20.0-dev.20240925-a47254eaef",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^14.1.2",
"react-router": "^6.23.1",
"react-router-dom": "^6.23.1",
"tr46": "^5.0.0",
"valid-url": "^1.0.9",
"validate-color": "^2.2.4",
"vite-express": "^0.17.0"
},
"devDependencies": {
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/valid-url": "^1.0.7",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"postcss": "^8.4.38",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.4",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vite-plugin-chunk-split": "^0.5.0",
"vite-plugin-pages": "^0.32.2",
"vite-tsconfig-paths": "^4.3.2"
}
}

View File

@ -15,7 +15,10 @@ export default function AboutPage() {
<span className="leading-7 md:leading-9 text-3xl font-bold">sparkast</span>
<p className="mt-2 leading-5 text-base md:text-xl">
Made with <span className="text-red-500"></span> by
<a className="underline decoration-dotted text-red-500 mx-1" href="https://alikia2x.com">
<a
className="underline decoration-dotted text-red-500 mx-1"
href="https://alikia2x.com"
>
alikia2x
</a>
from Luminara Studio
@ -40,7 +43,7 @@ export default function AboutPage() {
className="relative px-2 py-1 text-sm font-bold rounded-md text-nowrap underline
bg-green-600 text-white"
>
<a href="/about/license">{t('about.license.view')}</a>
<a href="/about/license">{t("about.license.view")}</a>
</span>
</p>

View File

@ -1 +1,13 @@
{"idx_to_class": {"0": "weather", "1": "base64", "2": "url-encode", "3": "html-encode", "4": "ai.command", "5": "knowledge", "6": "ai.question", "7": "datetime"}, "threshold": 1.7}
{
"idx_to_class": {
"0": "weather",
"1": "base64",
"2": "url-encode",
"3": "html-encode",
"4": "ai.command",
"5": "knowledge",
"6": "ai.question",
"7": "datetime"
},
"threshold": 1.7
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,59 +1,59 @@
import { describe, expect, test } from "bun:test";
import { isValidIPv4, } from "../lib/url/validLink";
import { isValidIPv4 } from "../lib/url/validLink";
describe("Check if a string is a valid IPv4", () => {
test("Invalid IPv4 addresses - Missing part", () => {
expect(isValidIPv4("192.168.1")).toBe(false);
expect(isValidIPv4("1")).toBe(false);
});
test("Invalid IPv4 addresses - Contains non-digit characters", () => {
expect(isValidIPv4("192.168.1.a")).toBe(false);
expect(isValidIPv4("192.168.1.1a")).toBe(false);
expect(isValidIPv4("192.168.1.1.1")).toBe(false);
});
test("Invalid IPv4 addresses - Contains empty parts", () => {
expect(isValidIPv4("192.168.1.")).toBe(false);
expect(isValidIPv4("192..168.1")).toBe(false);
});
test("Invalid IPv4 addresses - Contains negative numbers", () => {
expect(isValidIPv4("192.168.-1.1")).toBe(false);
});
test("Invalid IPv4 addresses - Contains out-of-range numbers", () => {
expect(isValidIPv4("192.168.256.1")).toBe(false);
expect(isValidIPv4("192.168.1.256")).toBe(false);
});
test("Invalid IPv4 addresses - Contains multiple dots", () => {
expect(isValidIPv4("192.168..1.1")).toBe(false);
expect(isValidIPv4("192.168.1..1")).toBe(false);
});
test("Invalid IPv4 addresses - Empty string", () => {
expect(isValidIPv4("")).toBe(false);
});
test("Invalid IPv4 addresses - Contains special characters", () => {
expect(isValidIPv4("192.168.1.1!")).toBe(false);
expect(isValidIPv4("192.168.1.1 ")).toBe(false);
expect(isValidIPv4("192.168.1.1\t")).toBe(false);
});
test("Invalid IPv4 addresses - Contains non-ASCII characters", () => {
expect(isValidIPv4("192.168.1.1©")).toBe(false);
});
test("Invalid IPv4 addresses - Contains newline character", () => {
expect(isValidIPv4("192.168.1.1\n")).toBe(false);
});
test("Invalid IPv4 addresses - Contains multiple IP addresses", () => {
expect(isValidIPv4("192.168.1.1 192.168.1.2")).toBe(false);
});
test("Invalid IPv4 addresses - Contains IPv6 address", () => {
expect(isValidIPv4("2001:0db8:85a3:0000:0000:8a2e:0370:7334")).toBe(false);
});
@ -61,19 +61,19 @@ describe("Check if a string is a valid IPv4", () => {
test("Valid IPv4 addresses - Standard IP", () => {
expect(isValidIPv4("192.168.1.1")).toBe(true);
});
test("Valid IPv4 addresses - All zeros", () => {
expect(isValidIPv4("0.0.0.0")).toBe(true);
});
test("Valid IPv4 addresses - Maximum value", () => {
expect(isValidIPv4("255.255.255.255")).toBe(true);
});
test("Valid IPv4 addresses - Leading zero but valid", () => {
expect(isValidIPv4("192.000.001.001")).toBe(true);
});
test("Valid IPv4 addresses - Single digit parts", () => {
expect(isValidIPv4("1.2.3.4")).toBe(true);
});