@@ -23,6 +23,6 @@ export default function (
} else if (selected.type === "link") {
window.open(normalizeURL(selected.suggestion));
} else if (selected.type === "inpage-link") {
- location.href = normalizeURL(selected.suggestion);
+ location.href = normalizeURL(selected.suggestion, false);
}
}
diff --git a/lib/onesearch/keywordSuggestion.ts b/lib/onesearch/keywordSuggestion.ts
index c13cfc0..7c11e38 100644
--- a/lib/onesearch/keywordSuggestion.ts
+++ b/lib/onesearch/keywordSuggestion.ts
@@ -1,4 +1,4 @@
-import { suggestionItem } from "global";
+import { SuggestionItem } from "global";
interface keywordLinkDict {
[key: string]: string;
@@ -15,7 +15,7 @@ const dict_cn: keywordLinkDict = {
export function keywordSuggestion(query: string) {
for (const keyword in dict_cn) {
if (query.includes(keyword)) {
- const result: suggestionItem = {
+ const result: SuggestionItem = {
type: "inpage-link",
suggestion: dict_cn[keyword],
prompt: keyword,
@@ -26,7 +26,7 @@ export function keywordSuggestion(query: string) {
}
for (const keyword in dict_en) {
if (query.includes(keyword)) {
- const result: suggestionItem = {
+ const result: SuggestionItem = {
type: "inpage-link",
suggestion: dict_en[keyword],
prompt: keyword,
diff --git a/lib/state/suggestion.ts b/lib/state/suggestion.ts
index df90be4..7fccb90 100644
--- a/lib/state/suggestion.ts
+++ b/lib/state/suggestion.ts
@@ -1,6 +1,6 @@
-import { suggestionItem } from "global";
+import { SuggestionItem } from "global";
import { atom } from "jotai";
-const suggestionAtom = atom([] as suggestionItem[]);
+const suggestionAtom = atom([] as SuggestionItem[]);
export { suggestionAtom };
diff --git a/lib/url/tldList.ts b/lib/url/tldList.ts
index 950ae99..8fc1f8d 100644
--- a/lib/url/tldList.ts
+++ b/lib/url/tldList.ts
@@ -1,4 +1,4 @@
-import TLDtxt from "./tlds.txt?raw";
+import TLDtxt from "./tlds.txt";
export function getTLD() {
return TLDtxt.split("\r\n").filter((line) => line[0] !== "#");
diff --git a/lib/url/tlds.txt b/lib/url/tlds.txt
index 143dcdc..d28a03d 100644
--- a/lib/url/tlds.txt
+++ b/lib/url/tlds.txt
@@ -1,4 +1,4 @@
-# Version 2024071300, Last Updated Sat Jul 13 07:07:01 2024 UTC
+# Version 2025011900, Last Updated Sun Jan 19 07:07:01 2025 UTC
AAA
AARP
ABB
@@ -297,7 +297,6 @@ CY
CYMRU
CYOU
CZ
-DABUR
DAD
DANCE
DATA
@@ -1444,4 +1443,4 @@ ZIP
ZM
ZONE
ZUERICH
-ZW
+ZW
\ No newline at end of file
diff --git a/lib/url/validLink.ts b/lib/url/validLink.ts
index 851d676..b1e1afa 100644
--- a/lib/url/validLink.ts
+++ b/lib/url/validLink.ts
@@ -1,41 +1,33 @@
import { toASCII } from "tr46";
import { getTLD } from "./tldList";
+console.log(getTLD());
+
export default function validLink(link: string) {
let finalURL;
try {
- const url = new URL(link);
- finalURL = url;
+ new URL(link);
return true;
} catch (error) {
// if the URL is invalid, try to add the protocol
try {
- const urlWithHTTP = new URL("http://" + link);
- finalURL = urlWithHTTP;
+ finalURL = new URL("http://" + link);
} catch (error) {
return false;
}
}
if (finalURL.host.endsWith(".")) return false;
- if (
- validTLD(finalURL.host) ||
+ return validTLD(finalURL.host) ||
isValidIPv6(link.slice(1, finalURL.host.length - 1)) ||
- isValidIPv4(link)
- ) {
- return true;
- }
- return false;
+ isValidIPv4(link);
+
}
export function validTLD(domain: string): boolean {
if (!domain.includes(".")) return false;
const tld = toASCII(domain.split(".").reverse()[0]);
const tldList = getTLD();
- if (tldList.includes(tld.toUpperCase())) {
- return true;
- } else {
- return false;
- }
+ return !!tldList.includes(tld.toUpperCase());
}
export function isValidIPv6(ip: string): boolean {
@@ -69,10 +61,8 @@ export function isValidIPv6(ip: string): boolean {
return false;
}
}
- if (doubleColonCount === 0 && groups !== 8) {
- return false;
- }
- return true;
+ return !(doubleColonCount === 0 && groups !== 8);
+
}
export function isValidIPv4(ip: string): boolean {
diff --git a/lib/version.ts b/lib/version.ts
index 663e101..915fc20 100644
--- a/lib/version.ts
+++ b/lib/version.ts
@@ -1,8 +1,5 @@
import * as pjson from "package.json";
-export default function getVersion() {
- return pjson.version;
-}
+export const clientVersion = pjson.version;
-export const clientNLUVersion = 4;
export const apiVersion = 1;
diff --git a/package.json b/package.json
index 194d1e8..d5fe039 100644
--- a/package.json
+++ b/package.json
@@ -1,65 +1,67 @@
{
- "name": "sparkast",
- "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": {
- "@alikia/search-complete": "^0.4.4",
- "@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": "sparkast",
+ "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": {
+ "@alikia/search-complete": "^0.4.4",
+ "@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-helmet": "^6.1.0",
+ "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/react-helmet": "^6.1.11",
+ "@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"
+ }
}
diff --git a/pages/about/index.tsx b/pages/about/index.tsx
index 1ba9687..974522e 100644
--- a/pages/about/index.tsx
+++ b/pages/about/index.tsx
@@ -1,8 +1,38 @@
import useDarkMode from "lib/darkModeHook";
-import getVersion, { apiVersion, clientNLUVersion } from "lib/version";
+import { apiVersion, clientVersion } from "lib/version";
import AboutLayout from "./layout";
import { useTranslation } from "react-i18next";
+function License() {
+ const { t } = useTranslation();
+ return (
+ <>
+
+
+ {t("about.oss.title")}
+
+
+ {t("about.oss.view")}
+
+
+
+
+ {t("about.license.title")}
+
+
+ {t("about.license.text")}
+
+
+ >
+ );
+}
+
export default function AboutPage() {
const darkMode = useDarkMode();
const { t } = useTranslation();
@@ -26,47 +56,41 @@ export default function AboutPage() {
-
+
-
- License
-
- {t("about.license.view")}
-
-
- Presented By
+
+
+ {t("about.presented-by")}
{!darkMode && (
)}
{darkMode && (
-
+
)}
);
}
function Version(props: { title: string; version: string; versionClass?: string }) {
- document.title = "About SparkHome";
const { t } = useTranslation();
return (
-
- {t(props.title)}
+
+
+ {t(props.title)}
+
diff --git a/pages/about/layout.tsx b/pages/about/layout.tsx
index 1a697bb..09aa4c9 100644
--- a/pages/about/layout.tsx
+++ b/pages/about/layout.tsx
@@ -1,6 +1,14 @@
+import React from "react";
+import { useTranslation } from "react-i18next";
+import { Helmet } from "react-helmet";
+
export default function AboutLayout({ children }: { children: React.ReactNode }) {
+ const { t } = useTranslation();
return (
+
+ {t('about.title')}
+
+
+ {t("oss_license.title")}
+
- LICENSE
+ {t('oss_license.page-title')}
+ {t('oss_license.desc')}
{LICENSE}
diff --git a/pages/about/license/ThisProject.tsx b/pages/about/license/ThisProject.tsx
new file mode 100644
index 0000000..fc45951
--- /dev/null
+++ b/pages/about/license/ThisProject.tsx
@@ -0,0 +1,22 @@
+import LICENSE from "LICENSE?raw";
+import { useTranslation } from "react-i18next";
+import { Helmet } from "react-helmet";
+
+export default function ThisProjectLicensePage() {
+ const { t } = useTranslation();
+ return (
+
+
+ {t("license.title")}
+
+
+ {t('license.page-title')}
+ {t('license.desc')}
+ {LICENSE}
+
+
+ );
+}
diff --git a/pages/index.tsx b/pages/index.tsx
index a7e8bfe..3303ff0 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -13,6 +13,7 @@ export default function Homepage() {
return (
+
sparkast
},
{
- path: "about",
+ path: "/about",
element:
,
- children: [
- {
- path: "license",
- element:
- }
- ]
+ },
+ {
+ path: "/about/oss-licenses",
+ element:
+ },
+ {
+ path: "/about/license",
+ element:
}
]);
diff --git a/test/bytesToUnicode.test.ts b/test/bytesToUnicode.test.ts
deleted file mode 100644
index 18bfa8f..0000000
--- a/test/bytesToUnicode.test.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { expect, test } from "bun:test";
-import bytesToUnicodes from "../lib/nlp/tokenize/bytesToUnicode";
-
-test("bytesToUnicode: test", () => {
- expect(bytesToUnicodes("Hello 你好")).toEqual("HelloĠä½łå¥½");
-});
diff --git a/test/getEmbeddings.test.ts b/test/getEmbeddings.test.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/test/unicodeToBytes.test.ts b/test/unicodeToBytes.test.ts
deleted file mode 100644
index ab5be6f..0000000
--- a/test/unicodeToBytes.test.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { expect, test } from "bun:test";
-import unicodeToBytes from "../lib/nlp/tokenize/unicodeToBytes";
-
-test("unicodeToBytes: test", () => {
- expect(unicodeToBytes("HelloĠä½łå¥½")).toEqual("Hello 你好");
-});
diff --git a/test/validLink.test.ts b/test/validLink.test.ts
index 58e1aa1..a028f6b 100644
--- a/test/validLink.test.ts
+++ b/test/validLink.test.ts
@@ -60,6 +60,7 @@ describe("Check if the given TLD exist and assigned.", () => {
expect(validTLD("example.foo")).toBe(true);
expect(validTLD("example.bar")).toBe(true);
expect(validTLD("example.zip")).toBe(true);
+ expect(validTLD("xn--s8w913fdga.chn.moe")).toBe(true);
});
test("Exist but not assigned TLD", () => {
expect(validTLD("example.active")).toBe(false);