Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: implement omniget scheme URL handling and deep link configuration

Tonho905e23f653d3
diff --git a/browser-extension/chrome/src/send-via-scheme.js b/browser-extension/chrome/src/send-via-scheme.js
new file mode 100644
index 00000000..8547820c
--- /dev/null
+++ b/browser-extension/chrome/src/send-via-scheme.js
@@ -0,0 +1,42 @@
+export const OMNIGET_SCHEME = "omniget://";
+
+export function buildOmnigetSchemeUrl(url) {
+ if (typeof url !== "string") {
+ return null;
+ }
+ const trimmed = url.trim();
+ if (!trimmed) {
+ return null;
+ }
+ if (trimmed.startsWith(OMNIGET_SCHEME)) {
+ return trimmed;
+ }
+ if (trimmed.startsWith("magnet:") || trimmed.startsWith("p2p:")) {
+ return `omniget:${trimmed}`;
+ }
+ const withoutProtocol = trimmed.replace(/^https?:\/\//i, "");
+ if (!withoutProtocol) {
+ return null;
+ }
+ return `${OMNIGET_SCHEME}${withoutProtocol}`;
+}
+
+export async function openOmnigetScheme(url, { tabs } = { tabs: chrome?.tabs }) {
+ const schemeUrl = buildOmnigetSchemeUrl(url);
+ if (!schemeUrl) {
+ return { ok: false, reason: "invalid-url" };
+ }
+ if (!tabs?.update) {
+ return { ok: false, reason: "tabs-api-unavailable" };
+ }
+ try {
+ await tabs.update({ url: schemeUrl });
+ return { ok: true, schemeUrl };
+ } catch (error) {
+ return {
+ ok: false,
+ reason: "tabs-update-failed",
+ message: error instanceof Error ? error.message : String(error),
+ };
+ }
+}
diff --git a/browser-extension/firefox/src/send-via-scheme.js b/browser-extension/firefox/src/send-via-scheme.js
new file mode 100644
index 00000000..8547820c
--- /dev/null
+++ b/browser-extension/firefox/src/send-via-scheme.js
@@ -0,0 +1,42 @@
+export const OMNIGET_SCHEME = "omniget://";
+
+export function buildOmnigetSchemeUrl(url) {
+ if (typeof url !== "string") {
+ return null;
+ }
+ const trimmed = url.trim();
+ if (!trimmed) {
+ return null;
+ }
+ if (trimmed.startsWith(OMNIGET_SCHEME)) {
+ return trimmed;
+ }
+ if (trimmed.startsWith("magnet:") || trimmed.startsWith("p2p:")) {
+ return `omniget:${trimmed}`;
+ }
+ const withoutProtocol = trimmed.replace(/^https?:\/\//i, "");
+ if (!withoutProtocol) {
+ return null;
+ }
+ return `${OMNIGET_SCHEME}${withoutProtocol}`;
+}
+
+export async function openOmnigetScheme(url, { tabs } = { tabs: chrome?.tabs }) {
+ const schemeUrl = buildOmnigetSchemeUrl(url);
+ if (!schemeUrl) {
+ return { ok: false, reason: "invalid-url" };
+ }
+ if (!tabs?.update) {
+ return { ok: false, reason: "tabs-api-unavailable" };
+ }
+ try {
+ await tabs.update({ url: schemeUrl });
+ return { ok: true, schemeUrl };
+ } catch (error) {
+ return {
+ ok: false,
+ reason: "tabs-update-failed",
+ message: error instanceof Error ? error.message : String(error),
+ };
+ }
+}
diff --git a/browser-extension/sync.mjs b/browser-extension/sync.mjs
index 226ecb2b..5f4e3084 100644
--- a/browser-extension/sync.mjs
+++ b/browser-extension/sync.mjs
@@ -18,6 +18,7 @@ const SHARED = [
"src/detect.js",
"src/media-sniffer.js",
"src/open-app-toggle.js",
+ "src/send-via-scheme.js",
"src/sniffer-toggle.js",
"popup/popup.js",
"popup/popup.css",
diff --git a/flatpak/wtf.tonho.omniget.metainfo.xml b/flatpak/wtf.tonho.omniget.metainfo.xml
index 33af36ac..397f8cf2 100644
--- a/flatpak/wtf.tonho.omniget.metainfo.xml
+++ b/flatpak/wtf.tonho.omniget.metainfo.xml
@@ -33,7 +33,7 @@
<screenshots>
<screenshot type="default">
<caption>Main download interface</caption>
- <image>https://raw.githubusercontent.com/tonhowtf/omniget/v0.4.0/flatpak/screenshots/main.png</image>
+ <image>https://raw.githubusercontent.com/tonhowtf/omniget/main/flatpak/screenshots/main.png</image>
</screenshot>
</screenshots>
<branding>
diff --git a/scripts/bump-version.js b/scripts/bump-version.js
index ae40adbe..684660c2 100644
--- a/scripts/bump-version.js
+++ b/scripts/bump-version.js
@@ -132,15 +132,6 @@ writeJson(tauriConfPath, (conf) => {
conf.version = version;
});
-const metainfoPath = path.join(root, "flatpak", "wtf.tonho.omniget.metainfo.xml");
-writeText(metainfoPath, (content) => {
- let updated = content.replace(
- /(raw\.githubusercontent\.com\/tonhowtf\/omniget\/v)(\d+\.\d+\.\d+(?:-[\w.]+)?)(\/)/g,
- (_, a, _b, c) => `${a}${version}${c}`
- );
- return updated;
-});
-
const changelogStorePath = path.join(root, "src", "lib", "stores", "changelog-store.svelte.ts");
if (fs.existsSync(changelogStorePath)) {
writeText(changelogStorePath, (content) =>
diff --git a/scripts/generate-i18n-keys.js b/scripts/generate-i18n-keys.js
index 8d7d9b32..a38ff722 100644
--- a/scripts/generate-i18n-keys.js
+++ b/scripts/generate-i18n-keys.js
@@ -9,6 +9,9 @@ const i18nDir = path.join(__dirname, "..", "src", "lib", "i18n");
const enPath = path.join(i18nDir, "en.json");
const outputFile = path.join(i18nDir, "keys.ts");
+const STRICT =
+ process.argv.includes("--strict") || process.env.GENERATE_I18N_KEYS_STRICT === "1";
+
function extractKeys(obj, prefix = "") {
const keys = [];
for (const [key, value] of Object.entries(obj)) {
@@ -105,6 +108,9 @@ export type TranslationKeys =\n`;
}
if (!hadMismatch) {
console.log(`All ${otherLocales.length} other locales in sync with en.json`);
+ } else if (STRICT) {
+ console.error("i18n strict mode: locales out of sync with en.json — aborting.");
+ process.exit(1);
}
}
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index d2fe2fca..c9e09a4b 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -720,6 +720,26 @@ dependencies = [
"crossbeam-utils",
]
+[[package]]
+name = "const-random"
+version = "0.1.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
+dependencies = [
+ "const-random-macro",
+]
+
+[[package]]
+name = "const-random-macro"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
+dependencies = [
+ "getrandom 0.2.17",
+ "once_cell",
+ "tiny-keccak",
+]
+
[[package]]
name = "const_panic"
version = "0.2.15"
@@ -1093,6 +1113,15 @@ dependencies = [
"syn 2.0.117",
]
+[[package]]
+name = "dlv-list"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
+dependencies = [
+ "const-random",
+]
+
[[package]]
name = "document-features"
version = "0.2.12"
@@ -3484,6 +3513,7 @@ dependencies = [
"tauri",
"tauri-build",
"tauri-plugin-clipboard-manager",
+ "tauri-plugin-deep-link",
"tauri-plugin-dialog",
"tauri-plugin-fs",
"tauri-plugin-global-shortcut",
@@ -3620,6 +3650,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
+[[package]]
+name = "ordered-multimap"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79"
+dependencies = [
+ "dlv-list",
+ "hashbrown 0.14.5",
+]
+
[[package]]
name = "ordered-stream"
version = "0.2.0"
@@ -4555,6 +4595,16 @@ dependencies = [
"libc",
]
+[[package]]
+name = "rust-ini"
+version = "0.21.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "796e8d2b6696392a43bea58116b667fb4c29727dc5abd27d6acf338bb4f688c7"
+dependencies = [
+ "cfg-if",
+ "ordered-multimap",
+]
+
[[package]]
name = "rustc-hash"
version = "2.1.1"
@@ -5478,6 +5528,27 @@ dependencies = [
"thiserror 2.0.18",
]
+[[package]]
+name = "tauri-plugin-deep-link"
+version = "2.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3db49816aee496a9b200d55b55ab6ae73fd50847c79f2fabc7ee20871fa75c95"
+dependencies = [
+ "dunce",
+ "plist",
+ "rust-ini",
+ "serde",
+ "serde_json",
+ "tauri",
+ "tauri-plugin",
+ "tauri-utils",
+ "thiserror 2.0.18",
+ "tracing",
+ "url",
+ "windows-registry",
+ "windows-result 0.3.4",
+]
+
[[package]]
name = "tauri-plugin-dialog"
version = "2.6.0"
@@ -5878,6 +5949,15 @@ dependencies = [
"time-core",
]
+[[package]]
+name = "tiny-keccak"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
+dependencies = [
+ "crunchy",
+]
+
[[package]]
name = "tinystr"
version = "0.8.2"
@@ -6974,6 +7054,17 @@ dependencies = [
"windows-link 0.1.3",
]
+[[package]]
+name = "windows-registry"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e"
+dependencies = [
+ "windows-link 0.1.3",
+ "windows-result 0.3.4",
+ "windows-strings 0.4.2",
+]
+
[[package]]
name = "windows-result"
version = "0.3.4"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 90b748db..9b35d377 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -68,6 +68,7 @@ tauri-plugin-updater = "2.10.0"
tauri-plugin-global-shortcut = "2"
tauri-plugin-clipboard-manager = "2"
tauri-plugin-single-instance = "2"
+tauri-plugin-deep-link = "2"
[profile.dev]
debug = 0
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 6cf4492d..2df0ac43 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -28,6 +28,11 @@
"endpoints": [
"https://github.com/tonhowtf/omniget/releases/latest/download/latest.json"
]
+ },
+ "deep-link": {
+ "desktop": {
+ "schemes": ["omniget"]
+ }
}
},
"bundle": {
diff --git a/vite.config.js b/vite.config.js
index 3120b2ff..fe14cb9d 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1,9 +1,12 @@
import { defineConfig } from "vite";
import { sveltekit } from "@sveltejs/kit/vite";
-import { execSync } from "child_process";
-import { readFileSync } from "fs";
+import { execSync, spawnSync } from "child_process";
+import { readFileSync, existsSync } from "fs";
+import path from "path";
+import { fileURLToPath } from "url";
const host = process.env.TAURI_DEV_HOST;
+const configDir = path.dirname(fileURLToPath(import.meta.url));
function getGitInfo() {
try {
@@ -24,12 +27,36 @@ function getVersion() {
}
}
+function i18nKeysPlugin() {
+ return {
+ name: "omniget-i18n-keys",
+ buildStart() {
+ const script = path.join(configDir, "scripts", "generate-i18n-keys.js");
+ if (!existsSync(script)) {
+ return;
+ }
+ const strict = process.env.OMNIGET_I18N_STRICT !== "0";
+ const args = strict ? [script, "--strict"] : [script];
+ const result = spawnSync(process.execPath, args, {
+ cwd: configDir,
+ stdio: "inherit",
+ });
+ if (result.status !== 0) {
+ this.error(
+ `generate-i18n-keys.js exited with code ${result.status}. ` +
+ `Fix locale keys or set OMNIGET_I18N_STRICT=0 to bypass.`,
+ );
+ }
+ },
+ };
+}
+
// https://vite.dev/config/
export default defineConfig(async () => {
const gitInfo = getGitInfo();
return {
- plugins: [sveltekit()],
+ plugins: [i18nKeysPlugin(), sveltekit()],
define: {
__COMMIT_HASH__: JSON.stringify(gitInfo.hash),