Switch to libcurl for omnibox

This commit is contained in:
MotorTruck1221 2024-10-02 19:28:28 -06:00
parent ac3154e334
commit 22b0c1ebf9
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
4 changed files with 17 additions and 27 deletions

View file

@ -8,15 +8,9 @@ import { baremuxPath } from '@mercuryworkshop/bare-mux';
import { epoxyPath } from '@mercuryworkshop/epoxy-transport'; import { epoxyPath } from '@mercuryworkshop/epoxy-transport';
import { libcurlPath } from '@mercuryworkshop/libcurl-transport'; import { libcurlPath } from '@mercuryworkshop/libcurl-transport';
import { uvPath } from '@titaniumnetwork-dev/ultraviolet'; import { uvPath } from '@titaniumnetwork-dev/ultraviolet';
export default defineConfig({ export default defineConfig({
integrations: [tailwind(), icon(), svelte()], integrations: [tailwind(), icon(), svelte()],
vite: { vite: {
build: {
rollupOptions: {
external: ['@mercuryworkshop/epoxy-tls-new']
}
},
plugins: [ plugins: [
viteStaticCopy({ viteStaticCopy({
targets: [ targets: [

View file

@ -20,9 +20,9 @@
"@iconify-json/ph": "^1.2.0", "@iconify-json/ph": "^1.2.0",
"@mercuryworkshop/bare-mux": "1.1.1", "@mercuryworkshop/bare-mux": "1.1.1",
"@mercuryworkshop/epoxy-tls": "2.0.0-3", "@mercuryworkshop/epoxy-tls": "2.0.0-3",
"@mercuryworkshop/libcurl-transport": "1.3.2", "libcurl.js-new": "npm:libcurl.js@^0.6.16",
"@mercuryworkshop/epoxy-tls-new": "npm:@mercuryworkshop/epoxy-tls@^2.1.4-1",
"@mercuryworkshop/epoxy-transport": "2.0.1", "@mercuryworkshop/epoxy-transport": "2.0.1",
"@mercuryworkshop/libcurl-transport": "1.3.2",
"@titaniumnetwork-dev/ultraviolet": "3.1.2", "@titaniumnetwork-dev/ultraviolet": "3.1.2",
"astro": "^4.15.9", "astro": "^4.15.9",
"astro-icon": "^1.1.1", "astro-icon": "^1.1.1",

16
pnpm-lock.yaml generated
View file

@ -35,9 +35,6 @@ importers:
'@mercuryworkshop/epoxy-tls': '@mercuryworkshop/epoxy-tls':
specifier: 2.0.0-3 specifier: 2.0.0-3
version: 2.0.0-3 version: 2.0.0-3
'@mercuryworkshop/epoxy-tls-new':
specifier: npm:@mercuryworkshop/epoxy-tls@^2.1.4-1
version: '@mercuryworkshop/epoxy-tls@2.1.4-1'
'@mercuryworkshop/epoxy-transport': '@mercuryworkshop/epoxy-transport':
specifier: 2.0.1 specifier: 2.0.1
version: 2.0.1(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4) version: 2.0.1(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4)
@ -68,6 +65,9 @@ importers:
formdata-node: formdata-node:
specifier: ^6.0.3 specifier: ^6.0.3
version: 6.0.3 version: 6.0.3
libcurl.js-new:
specifier: npm:libcurl.js@^0.6.16
version: libcurl.js@0.6.16
multer: multer:
specifier: 1.4.5-lts.1 specifier: 1.4.5-lts.1
version: 1.4.5-lts.1 version: 1.4.5-lts.1
@ -606,9 +606,6 @@ packages:
'@mercuryworkshop/epoxy-tls@2.0.0-3': '@mercuryworkshop/epoxy-tls@2.0.0-3':
resolution: {integrity: sha512-iC5CViTh2xn44xtjvDW4YW9qoeoJcCBOqcNmffBx3RHdK7FAzAWFHLTUBtdlnMVv6cjYZtV+eUTzxyreqlgOVA==} resolution: {integrity: sha512-iC5CViTh2xn44xtjvDW4YW9qoeoJcCBOqcNmffBx3RHdK7FAzAWFHLTUBtdlnMVv6cjYZtV+eUTzxyreqlgOVA==}
'@mercuryworkshop/epoxy-tls@2.1.4-1':
resolution: {integrity: sha512-kRbW12tU4TAf9GuoLfyFYvUATqFZq6n9ScRSfwAECceOBWDlr+bACnSH45lLDXvjBKwxZotTyYE5aNc+Ow+M3Q==}
'@mercuryworkshop/epoxy-transport@2.0.1': '@mercuryworkshop/epoxy-transport@2.0.1':
resolution: {integrity: sha512-iGuH/CT5hCVRYBa+5ZrlTG0DWII9VOCMHnmv9CPFLM17obE84y9EUXpTp9hXdfENnuAcNzQVPizjwVas7HiYQA==} resolution: {integrity: sha512-iGuH/CT5hCVRYBa+5ZrlTG0DWII9VOCMHnmv9CPFLM17obE84y9EUXpTp9hXdfENnuAcNzQVPizjwVas7HiYQA==}
@ -1996,6 +1993,9 @@ packages:
libcurl.js@0.6.15: libcurl.js@0.6.15:
resolution: {integrity: sha512-rKcGhvJiju/V6RoH0mYW0l/w9GnTRFtidp8qC+3cMliHXHEHnbqwpOPzauMeOd2CtcEW5ZPZ29PpXLJ1bdHbyQ==} resolution: {integrity: sha512-rKcGhvJiju/V6RoH0mYW0l/w9GnTRFtidp8qC+3cMliHXHEHnbqwpOPzauMeOd2CtcEW5ZPZ29PpXLJ1bdHbyQ==}
libcurl.js@0.6.16:
resolution: {integrity: sha512-aR56ZgHjzUVRVU3l+XQIBIuZwTc7k6CUrwbH0v6GAyXreL5rluWjLOc3GtDAgK9JEBZi1aVSrNdBtqE669NGCw==}
light-my-request@5.13.0: light-my-request@5.13.0:
resolution: {integrity: sha512-9IjUN9ZyCS9pTG+KqTDEQo68Sui2lHsYBrfMyVUTTZ3XhH8PMZq7xO94Kr+eP9dhi/kcKsx4N41p2IXEBil1pQ==} resolution: {integrity: sha512-9IjUN9ZyCS9pTG+KqTDEQo68Sui2lHsYBrfMyVUTTZ3XhH8PMZq7xO94Kr+eP9dhi/kcKsx4N41p2IXEBil1pQ==}
@ -4172,8 +4172,6 @@ snapshots:
'@mercuryworkshop/epoxy-tls@2.0.0-3': {} '@mercuryworkshop/epoxy-tls@2.0.0-3': {}
'@mercuryworkshop/epoxy-tls@2.1.4-1': {}
'@mercuryworkshop/epoxy-transport@2.0.1(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4)': '@mercuryworkshop/epoxy-transport@2.0.1(bufferutil@4.0.8)(typescript@5.6.2)(utf-8-validate@6.0.4)':
dependencies: dependencies:
'@mercuryworkshop/epoxy-tls': 2.0.0-3 '@mercuryworkshop/epoxy-tls': 2.0.0-3
@ -5813,6 +5811,8 @@ snapshots:
libcurl.js@0.6.15: {} libcurl.js@0.6.15: {}
libcurl.js@0.6.16: {}
light-my-request@5.13.0: light-my-request@5.13.0:
dependencies: dependencies:
cookie: 0.6.0 cookie: 0.6.0

View file

@ -44,7 +44,7 @@ const t = useTranslations(lang);
import { initSw, setTransport } from "@utils/registerSW.ts"; //../../utils/registerSW.ts import { initSw, setTransport } from "@utils/registerSW.ts"; //../../utils/registerSW.ts
import { WispServerURLS, SearchEngines, Settings, cloak } from "@utils/settings"; import { WispServerURLS, SearchEngines, Settings, cloak } from "@utils/settings";
import { search } from "@utils/search.ts"; //../../utils/search.ts import { search } from "@utils/search.ts"; //../../utils/search.ts
import initEpoxy, { EpoxyClient, EpoxyClientOptions } from "@mercuryworkshop/epoxy-tls-new"; import { libcurl } from "libcurl.js-new/bundled";
type Suggestion = { type Suggestion = {
phrase: string phrase: string
} }
@ -70,9 +70,9 @@ const t = useTranslations(lang);
const input = document.getElementById("nebula-input") as HTMLInputElement; const input = document.getElementById("nebula-input") as HTMLInputElement;
const iframe = document.getElementById("neb-iframe") as HTMLIFrameElement; const iframe = document.getElementById("neb-iframe") as HTMLIFrameElement;
const omnibox = document.getElementById("omnibox") as HTMLDivElement; const omnibox = document.getElementById("omnibox") as HTMLDivElement;
let epoxyClientOptions: any = null; await libcurl.load_wasm();
let epoxyClient: any = null; libcurl.set_websocket(WispServerURLS.default);
await initEpoxy(); //This ONLY runs once console.debug("Libucurl ready?", libcurl.ready);
input?.addEventListener("keypress", function (event: any) { input?.addEventListener("keypress", function (event: any) {
if (event.key === "Enter") { if (event.key === "Enter") {
initSw().then(() => { initSw().then(() => {
@ -87,11 +87,6 @@ const t = useTranslations(lang);
} }
}) })
input?.addEventListener("input", async function() { input?.addEventListener("input", async function() {
if (!epoxyClient) {
console.debug("Creating epoxy client");
epoxyClientOptions = new EpoxyClientOptions();
epoxyClient = new EpoxyClient(WispServerURLS.default, epoxyClientOptions);
}
const value = input?.value; const value = input?.value;
input.classList.remove("rounded-b-2xl"); input.classList.remove("rounded-b-2xl");
omnibox.classList.remove("hidden"); omnibox.classList.remove("hidden");
@ -100,7 +95,7 @@ const t = useTranslations(lang);
omnibox.classList.add("hidden"); omnibox.classList.add("hidden");
} }
if (value.length >= 3) { if (value.length >= 3) {
const resp = await epoxyClient.fetch(`https://api.duckduckgo.com/ac?q=${encodeURIComponent(value)}&format=json`); const resp = await libcurl.fetch(`https://api.duckduckgo.com/ac?q=${encodeURIComponent(value)}&format=json`);
const data = await resp.json(); const data = await resp.json();
if (data) { if (data) {
omnibox.innerHTML = ""; omnibox.innerHTML = "";
@ -130,6 +125,7 @@ const t = useTranslations(lang);
} }
catch (_) { catch (_) {
//we purposely don't return anything //we purposely don't return anything
//console.debug(err);
} }
}); });
</script> </script>