From 899db05ab8c5ae33e0b8d842a92cf11fdb494a63 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Thu, 24 Jul 2025 15:45:48 +0530 Subject: [PATCH] feat(desktop): portable phase-1 foundational: infra & build (#5259) --- packages/hoppscotch-data/package.json | 2 +- packages/hoppscotch-desktop/.eslintrc.cjs | 67 ++ packages/hoppscotch-desktop/package.json | 24 +- .../hoppscotch-desktop/src-tauri/Cargo.lock | 609 ++++++++++++++++-- .../hoppscotch-desktop/src-tauri/Cargo.toml | 13 + .../hoppscotch-desktop/src-tauri/build.rs | 17 + .../src-tauri/tauri.conf.json | 2 +- .../src-tauri/tauri.portable.macos.conf.json | 62 ++ .../tauri.portable.windows.conf.json | 60 ++ .../hoppscotch-desktop/src/kernel/index.ts | 13 + packages/hoppscotch-desktop/src/kernel/io.ts | 34 + .../hoppscotch-desktop/src/kernel/relay.ts | 26 + .../hoppscotch-desktop/src/kernel/store.ts | 114 ++++ .../hoppscotch-desktop/src/types/kernel.d.ts | 9 + packages/hoppscotch-desktop/tsconfig.json | 7 +- packages/hoppscotch-desktop/vite.config.ts | 35 +- packages/hoppscotch-kernel/package.json | 2 +- pnpm-lock.yaml | 134 ++-- 18 files changed, 1091 insertions(+), 139 deletions(-) create mode 100644 packages/hoppscotch-desktop/.eslintrc.cjs create mode 100644 packages/hoppscotch-desktop/src-tauri/tauri.portable.macos.conf.json create mode 100644 packages/hoppscotch-desktop/src-tauri/tauri.portable.windows.conf.json create mode 100644 packages/hoppscotch-desktop/src/kernel/index.ts create mode 100644 packages/hoppscotch-desktop/src/kernel/io.ts create mode 100644 packages/hoppscotch-desktop/src/kernel/relay.ts create mode 100644 packages/hoppscotch-desktop/src/kernel/store.ts create mode 100644 packages/hoppscotch-desktop/src/types/kernel.d.ts diff --git a/packages/hoppscotch-data/package.json b/packages/hoppscotch-data/package.json index b82c9481..03242c18 100644 --- a/packages/hoppscotch-data/package.json +++ b/packages/hoppscotch-data/package.json @@ -19,7 +19,7 @@ }, "exports": { ".": { - "type": "./dist/index.d.ts", + "types": "./dist/index.d.ts", "import": "./dist/hoppscotch-data.js", "require": "./dist/hoppscotch-data.cjs" } diff --git a/packages/hoppscotch-desktop/.eslintrc.cjs b/packages/hoppscotch-desktop/.eslintrc.cjs new file mode 100644 index 00000000..2988b395 --- /dev/null +++ b/packages/hoppscotch-desktop/.eslintrc.cjs @@ -0,0 +1,67 @@ +/* eslint-env node */ +require("@rushstack/eslint-patch/modern-module-resolution") + +module.exports = { + root: true, + env: { + browser: true, + node: true, + jest: true, + }, + parserOptions: { + sourceType: "module", + requireConfigFile: false, + ecmaFeatures: { + jsx: false, + }, + }, + extends: [ + "@vue/typescript/recommended", + "plugin:vue/vue3-recommended", + "plugin:prettier/recommended", + ], + ignorePatterns: [ + "static/**/*", + "./helpers/backend/graphql.ts", + "**/*.d.ts", + "types/**/*", + ], + plugins: ["vue", "prettier"], + // add your custom rules here + rules: { + semi: [2, "never"], + "import/named": "off", // because, named import issue with typescript see: https://github.com/typescript-eslint/typescript-eslint/issues/154 + "no-console": "off", + "no-debugger": process.env.HOPP_LINT_FOR_PROD === "true" ? "error" : "warn", + "prettier/prettier": + process.env.HOPP_LINT_FOR_PROD === "true" ? "error" : "warn", + "vue/multi-word-component-names": "off", + "vue/no-side-effects-in-computed-properties": "off", + "import/no-named-as-default": "off", + "import/no-named-as-default-member": "off", + "@typescript-eslint/no-unused-vars": + process.env.HOPP_LINT_FOR_PROD === "true" ? "error" : "warn", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-explicit-any": "off", + "import/default": "off", + "no-undef": "off", + // localStorage block + "no-restricted-globals": [ + "error", + { + name: "localStorage", + message: + "Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores", + }, + ], + // window.localStorage block + "no-restricted-syntax": [ + "error", + { + selector: "CallExpression[callee.object.property.name='localStorage']", + message: + "Do not use 'localStorage' directly. Please use localpersistence.ts functions or stores", + }, + ], + }, +} diff --git a/packages/hoppscotch-desktop/package.json b/packages/hoppscotch-desktop/package.json index 418f5939..6c067f28 100644 --- a/packages/hoppscotch-desktop/package.json +++ b/packages/hoppscotch-desktop/package.json @@ -8,32 +8,50 @@ "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", "tauri": "tauri", - "dev:full": "(cd ../hoppscotch-selfhost-web && pnpm install && pnpm generate) && (cd crates/webapp-bundler && cargo build --release && cd target/release && ./webapp-bundler --input ../../../../../hoppscotch-selfhost-web/dist --output ../../../../bundle.zip --manifest ../../../../manifest.json) && (cd src-tauri && pnpm tauri dev)", - "build:full": "(cd ../hoppscotch-selfhost-web && pnpm install && pnpm generate) && (cd crates/webapp-bundler && cargo build --release && cd target/release && ./webapp-bundler --input ../../../../../hoppscotch-selfhost-web/dist --output ../../../../bundle.zip --manifest ../../../../manifest.json) && (cd src-tauri && pnpm tauri build)" + "lint": "eslint src --ext .ts,.js,.vue --ignore-path .gitignore .", + "lint:ts": "vue-tsc --noEmit", + "lintfix": "eslint --fix src --ext .ts,.js,.vue --ignore-path .gitignore .", + "prod-lint": "cross-env HOPP_LINT_FOR_PROD=true pnpm run lint", + "prepare-web": "(cd ../hoppscotch-selfhost-web && pnpm install && pnpm generate) && (cd crates/webapp-bundler && cargo build --release && cd target/release && ./webapp-bundler --input ../../../../../hoppscotch-selfhost-web/dist --output ../../../../bundle.zip --manifest ../../../../manifest.json)", + "dev:full": "pnpm tauri dev", + "build:full": "pnpm tauri build", + "dev:portable": "pnpm tauri dev -- --no-default-features --features portable", + "build:portable": "pnpm tauri build -- --no-default-features --features portable" }, "dependencies": { "@fontsource-variable/inter": "5.1.0", "@fontsource-variable/material-symbols-rounded": "5.1.3", "@fontsource-variable/roboto-mono": "5.1.0", + "@hoppscotch/common": "workspace:^", "@hoppscotch/kernel": "workspace:^", "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#1b52e49d881926135838cf6cfebdc1643a9bec31", "@hoppscotch/ui": "0.2.1", "@tauri-apps/api": "2.1.1", + "@tauri-apps/plugin-fs": "2.0.2", "@tauri-apps/plugin-process": "2.2.0", "@tauri-apps/plugin-shell": "2.0.1", "@tauri-apps/plugin-store": "2.2.0", "@tauri-apps/plugin-updater": "2.5.1", "@vueuse/core": "11.1.0", "fp-ts": "2.16.9", + "rxjs": "7.8.1", "vue": "^3.3.4", "vue-router": "4.4.5", - "vue-tippy": "6.5.0" + "vue-tippy": "6.5.0", + "zod": "3.23.8" }, "devDependencies": { "@iconify-json/lucide": "1.2.10", + "@rushstack/eslint-patch": "1.10.4", "@tauri-apps/cli": "^2", + "@typescript-eslint/eslint-plugin": "8.9.0", + "@typescript-eslint/parser": "8.9.0", "@vitejs/plugin-vue": "^5.0.5", + "@vue/eslint-config-typescript": "13.0.0", "autoprefixer": "10.4.20", + "eslint": "8.57.0", + "eslint-plugin-prettier": "5.2.1", + "eslint-plugin-vue": "9.29.0", "postcss": "8.4.49", "sass": "1.80.3", "tailwindcss": "3.4.14", diff --git a/packages/hoppscotch-desktop/src-tauri/Cargo.lock b/packages/hoppscotch-desktop/src-tauri/Cargo.lock index 9533c038..135c0748 100644 --- a/packages/hoppscotch-desktop/src-tauri/Cargo.lock +++ b/packages/hoppscotch-desktop/src-tauri/Cargo.lock @@ -149,6 +149,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + [[package]] name = "ashpd" version = "0.9.2" @@ -159,7 +165,7 @@ dependencies = [ "futures-channel", "futures-util", "rand 0.8.5", - "raw-window-handle", + "raw-window-handle 0.6.2", "serde", "serde_repr", "tokio", @@ -167,7 +173,7 @@ dependencies = [ "wayland-backend", "wayland-client", "wayland-protocols", - "zbus", + "zbus 4.0.1", ] [[package]] @@ -194,6 +200,44 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-compression" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddb939d66e4ae03cee6091612804ba446b12878410cfa17f785f4dd67d4014e8" +dependencies = [ + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-executor" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb812ffb58524bdd10860d7d974e2f01cc0950c2438a74ee5ec2e2280c6c4ffa" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f7e37c0ed80b2a977691c47dae8625cfb21e205827106c64f7c588766b2e50" +dependencies = [ + "async-lock", + "blocking", + "futures-lite", +] + [[package]] name = "async-io" version = "2.4.0" @@ -688,6 +732,22 @@ dependencies = [ "inout", ] +[[package]] +name = "cocoa" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" +dependencies = [ + "bitflags 1.3.2", + "block", + "cocoa-foundation 0.1.2", + "core-foundation 0.9.4", + "core-graphics 0.23.2", + "foreign-types 0.5.0", + "libc", + "objc", +] + [[package]] name = "cocoa" version = "0.26.0" @@ -696,14 +756,28 @@ checksum = "f79398230a6e2c08f5c9760610eb6924b52aa9e7950a619602baba59dcbbdbb2" dependencies = [ "bitflags 2.6.0", "block", - "cocoa-foundation", + "cocoa-foundation 0.2.0", "core-foundation 0.10.0", - "core-graphics", + "core-graphics 0.24.0", "foreign-types 0.5.0", "libc", "objc", ] +[[package]] +name = "cocoa-foundation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" +dependencies = [ + "bitflags 1.3.2", + "block", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "libc", + "objc", +] + [[package]] name = "cocoa-foundation" version = "0.2.0" @@ -713,7 +787,7 @@ dependencies = [ "bitflags 2.6.0", "block", "core-foundation 0.10.0", - "core-graphics-types", + "core-graphics-types 0.2.0", "libc", "objc", ] @@ -787,10 +861,29 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ddef33a339a91ea89fb53151bd0a4689cfce27055c291dfa69945475d22c747" dependencies = [ + "percent-encoding", "time", "version_check", ] +[[package]] +name = "cookie_store" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eac901828f88a5241ee0600950ab981148a18f2f756900ffba1b125ca6a3ef9" +dependencies = [ + "cookie", + "document-features", + "idna", + "log", + "publicsuffix", + "serde", + "serde_derive", + "serde_json", + "time", + "url", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -817,6 +910,19 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "foreign-types 0.5.0", + "libc", +] + [[package]] name = "core-graphics" version = "0.24.0" @@ -825,11 +931,22 @@ checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ "bitflags 2.6.0", "core-foundation 0.10.0", - "core-graphics-types", + "core-graphics-types 0.2.0", "foreign-types 0.5.0", "libc", ] +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "libc", +] + [[package]] name = "core-graphics-types" version = "0.2.0" @@ -1062,6 +1179,12 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "data-url" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" + [[package]] name = "deflate64" version = "0.1.9" @@ -1152,6 +1275,16 @@ dependencies = [ "dirs-sys 0.5.0", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + [[package]] name = "dirs-sys" version = "0.4.1" @@ -1176,6 +1309,17 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users 0.4.6", + "winapi", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1234,6 +1378,15 @@ dependencies = [ "const-random", ] +[[package]] +name = "document-features" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +dependencies = [ + "litrs", +] + [[package]] name = "downcast-rs" version = "1.2.1" @@ -1882,7 +2035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" dependencies = [ "heck 0.4.1", - "proc-macro-crate 2.0.2", + "proc-macro-crate 2.0.0", "proc-macro-error", "proc-macro2", "quote", @@ -2052,6 +2205,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "hoppscotch-desktop" version = "25.6.1" @@ -2059,7 +2221,9 @@ dependencies = [ "axum", "dirs 6.0.0", "file-rotate", + "native-dialog", "portpicker", + "semver", "serde", "serde_json", "tauri", @@ -2068,17 +2232,22 @@ dependencies = [ "tauri-plugin-deep-link", "tauri-plugin-dialog", "tauri-plugin-fs", + "tauri-plugin-http", + "tauri-plugin-opener", "tauri-plugin-process", "tauri-plugin-relay", "tauri-plugin-shell", "tauri-plugin-store", "tauri-plugin-updater", "tauri-plugin-window-state", + "tempfile", + "thiserror 2.0.12", "tokio", "tower-http", "tracing", "tracing-appender", "tracing-subscriber", + "winreg", ] [[package]] @@ -2499,6 +2668,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -2712,6 +2890,12 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "lock_api" version = "0.4.12" @@ -2844,6 +3028,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "minisign-verify" version = "0.2.3" @@ -2891,6 +3081,29 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "native-dialog" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e7038885d2aeab236bd60da9e159a5967b47cde3292da3b15ff1bec27c039f" +dependencies = [ + "ascii", + "block", + "cocoa 0.25.0", + "core-foundation 0.9.4", + "dirs-next", + "objc", + "objc-foundation", + "objc_id", + "once_cell", + "raw-window-handle 0.5.2", + "thiserror 1.0.69", + "versions", + "wfd", + "which", + "winapi", +] + [[package]] name = "native-tls" version = "0.2.12" @@ -2919,7 +3132,7 @@ dependencies = [ "log", "ndk-sys", "num_enum", - "raw-window-handle", + "raw-window-handle 0.6.2", "thiserror 1.0.69", ] @@ -2956,12 +3169,35 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "cfg_aliases", + "libc", + "memoffset", +] + [[package]] name = "nodrop" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "ntapi" version = "0.4.1" @@ -3011,7 +3247,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 2.0.2", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 2.0.90", @@ -3026,6 +3262,17 @@ dependencies = [ "malloc_buf", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc-sys" version = "0.3.5" @@ -3254,6 +3501,15 @@ dependencies = [ "objc2-foundation", ] +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "object" version = "0.36.5" @@ -3708,14 +3964,22 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_datetime", "toml_edit 0.20.2", ] +[[package]] +name = "proc-macro-crate" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +dependencies = [ + "toml_edit 0.22.27", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3755,6 +4019,22 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "psl-types" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" + +[[package]] +name = "publicsuffix" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42ea446cab60335f76979ec15e12619a2165b5ae2c12166bef27d283a9fadf" +dependencies = [ + "idna", + "psl-types", +] + [[package]] name = "quick-xml" version = "0.32.0" @@ -3786,7 +4066,7 @@ dependencies = [ "rustc-hash", "rustls", "socket2", - "thiserror 2.0.7", + "thiserror 2.0.12", "tokio", "tracing", ] @@ -3805,7 +4085,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.7", + "thiserror 2.0.12", "tinyvec", "tracing", "web-time", @@ -3915,6 +4195,12 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + [[package]] name = "raw-window-handle" version = "0.6.2" @@ -3969,7 +4255,7 @@ checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ "getrandom 0.2.15", "libredox", - "thiserror 2.0.7", + "thiserror 2.0.12", ] [[package]] @@ -4051,8 +4337,11 @@ version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ + "async-compression", "base64 0.22.1", "bytes", + "cookie", + "cookie_store", "encoding_rs", "futures-core", "futures-util", @@ -4111,7 +4400,7 @@ dependencies = [ "objc2", "objc2-app-kit", "objc2-foundation", - "raw-window-handle", + "raw-window-handle 0.6.2", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -4610,14 +4899,14 @@ checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08" dependencies = [ "bytemuck", "cfg_aliases", - "core-graphics", + "core-graphics 0.24.0", "foreign-types 0.5.0", "js-sys", "log", "objc2", "objc2-foundation", "objc2-quartz-core", - "raw-window-handle", + "raw-window-handle 0.6.2", "redox_syscall", "wasm-bindgen", "web-sys", @@ -4845,9 +5134,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6682a07cf5bab0b8a2bd20d0a542917ab928b5edb75ebd4eda6b05cbaab872da" dependencies = [ "bitflags 2.6.0", - "cocoa", + "cocoa 0.26.0", "core-foundation 0.10.0", - "core-graphics", + "core-graphics 0.24.0", "crossbeam-channel", "dispatch", "dlopen2", @@ -4866,7 +5155,7 @@ dependencies = [ "objc", "once_cell", "parking_lot", - "raw-window-handle", + "raw-window-handle 0.6.2", "scopeguard", "tao-macros", "unicode-segmentation", @@ -4932,7 +5221,7 @@ dependencies = [ "objc2-foundation", "percent-encoding", "plist", - "raw-window-handle", + "raw-window-handle 0.6.2", "reqwest", "serde", "serde_json", @@ -4944,7 +5233,7 @@ dependencies = [ "tauri-runtime", "tauri-runtime-wry", "tauri-utils", - "thiserror 2.0.7", + "thiserror 2.0.12", "tokio", "tray-icon", "url", @@ -4997,7 +5286,7 @@ dependencies = [ "sha2", "syn 2.0.90", "tauri-utils", - "thiserror 2.0.7", + "thiserror 2.0.12", "time", "url", "uuid", @@ -5043,7 +5332,7 @@ dependencies = [ "base64 0.22.1", "blake3", "chrono", - "cocoa", + "cocoa 0.26.0", "dashmap", "dunce", "ed25519-dalek", @@ -5065,7 +5354,7 @@ dependencies = [ "sysinfo", "tauri", "tauri-plugin", - "thiserror 2.0.7", + "thiserror 2.0.12", "tokio", "tracing", "url", @@ -5087,7 +5376,7 @@ dependencies = [ "tauri", "tauri-plugin", "tauri-utils", - "thiserror 2.0.7", + "thiserror 2.0.12", "tracing", "url", "windows-registry 0.3.0", @@ -5101,14 +5390,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b59fd750551b1066744ab956a1cd6b1ea3e1b3763b0b9153ac27a044d596426" dependencies = [ "log", - "raw-window-handle", + "raw-window-handle 0.6.2", "rfd", "serde", "serde_json", "tauri", "tauri-plugin", "tauri-plugin-fs", - "thiserror 2.0.7", + "thiserror 2.0.12", "url", ] @@ -5129,12 +5418,56 @@ dependencies = [ "tauri", "tauri-plugin", "tauri-utils", - "thiserror 2.0.7", + "thiserror 2.0.12", "toml 0.8.2", "url", "uuid", ] +[[package]] +name = "tauri-plugin-http" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "696ef548befeee6c6c17b80ef73e7c41205b6c2204e87ef78ccc231212389a5c" +dependencies = [ + "data-url", + "http", + "regex", + "reqwest", + "schemars", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror 2.0.12", + "tokio", + "url", + "urlpattern", +] + +[[package]] +name = "tauri-plugin-opener" +version = "2.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "635ed7c580dc3cdc61c94097d38ef517d749ffc0141c806d904e68e4b0cf1c2a" +dependencies = [ + "dunce", + "glob", + "objc2-app-kit", + "objc2-foundation", + "open", + "schemars", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror 2.0.12", + "url", + "windows 0.58.0", + "zbus 5.4.0", +] + [[package]] name = "tauri-plugin-process" version = "2.2.0" @@ -5154,7 +5487,7 @@ dependencies = [ "serde", "tauri", "tauri-plugin", - "thiserror 2.0.7", + "thiserror 2.0.12", "tracing", ] @@ -5175,7 +5508,7 @@ dependencies = [ "shared_child", "tauri", "tauri-plugin", - "thiserror 2.0.7", + "thiserror 2.0.12", "tokio", ] @@ -5190,7 +5523,7 @@ dependencies = [ "serde_json", "tauri", "tauri-plugin", - "thiserror 2.0.7", + "thiserror 2.0.12", "tokio", "tracing", ] @@ -5217,7 +5550,7 @@ dependencies = [ "tauri", "tauri-plugin", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.12", "time", "tokio", "url", @@ -5237,7 +5570,7 @@ dependencies = [ "serde_json", "tauri", "tauri-plugin", - "thiserror 2.0.7", + "thiserror 2.0.12", ] [[package]] @@ -5250,11 +5583,11 @@ dependencies = [ "gtk", "http", "jni", - "raw-window-handle", + "raw-window-handle 0.6.2", "serde", "serde_json", "tauri-utils", - "thiserror 2.0.7", + "thiserror 2.0.12", "url", "windows 0.58.0", ] @@ -5273,7 +5606,7 @@ dependencies = [ "objc2-app-kit", "objc2-foundation", "percent-encoding", - "raw-window-handle", + "raw-window-handle 0.6.2", "softbuffer", "tao", "tauri-runtime", @@ -5314,7 +5647,7 @@ dependencies = [ "serde_json", "serde_with", "swift-rs", - "thiserror 2.0.7", + "thiserror 2.0.12", "toml 0.8.2", "url", "urlpattern", @@ -5373,11 +5706,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.7" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93605438cbd668185516ab499d589afb7ee1859ea3d5fc8f6b0755e1c7443767" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.7", + "thiserror-impl 2.0.12", ] [[package]] @@ -5393,9 +5726,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.7" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d8749b4531af2117677a5fcd12b1348a3fe2b81e36e61ffeac5c4aa3273e36" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", @@ -5565,9 +5898,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] @@ -5582,7 +5915,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -5595,7 +5928,18 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap 2.7.0", + "toml_datetime", + "winnow 0.7.12", ] [[package]] @@ -5720,7 +6064,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d48a05076dd272615d03033bf04f480199f7d1b66a8ac64d75c625fc4a70c06b" dependencies = [ - "core-graphics", + "core-graphics 0.24.0", "crossbeam-channel", "dirs 5.0.1", "libappindicator", @@ -5932,6 +6276,16 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "versions" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c73a36bc44e3039f51fbee93e39f41225f6b17b380eb70cc2aab942df06b34dd" +dependencies = [ + "itertools", + "nom", +] + [[package]] name = "vswhom" version = "0.1.0" @@ -6232,6 +6586,28 @@ dependencies = [ "windows-core 0.58.0", ] +[[package]] +name = "wfd" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e713040b67aae5bf1a0ae3e1ebba8cc29ab2b90da9aa1bff6e09031a8a41d7a8" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" @@ -6272,7 +6648,7 @@ dependencies = [ "objc2", "objc2-app-kit", "objc2-foundation", - "raw-window-handle", + "raw-window-handle 0.6.2", "windows-sys 0.59.0", "windows-version", ] @@ -6675,6 +7051,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.52.0" @@ -6734,7 +7119,7 @@ dependencies = [ "objc2-web-kit", "once_cell", "percent-encoding", - "raw-window-handle", + "raw-window-handle 0.6.2", "sha2", "soup3", "tao-macros", @@ -6832,7 +7217,7 @@ dependencies = [ "futures-sink", "futures-util", "hex", - "nix", + "nix 0.27.1", "ordered-stream", "rand 0.8.5", "serde", @@ -6844,9 +7229,45 @@ dependencies = [ "uds_windows", "windows-sys 0.52.0", "xdg-home", - "zbus_macros", - "zbus_names", - "zvariant", + "zbus_macros 4.0.1", + "zbus_names 3.0.0", + "zvariant 4.0.0", +] + +[[package]] +name = "zbus" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbddd8b6cb25d5d8ec1b23277b45299a98bfb220f1761ca11e186d5c702507f8" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-util", + "hex", + "nix 0.29.0", + "ordered-stream", + "serde", + "serde_repr", + "static_assertions", + "tracing", + "uds_windows", + "windows-sys 0.59.0", + "winnow 0.7.12", + "xdg-home", + "zbus_macros 5.4.0", + "zbus_names 4.2.0", + "zvariant 5.6.0", ] [[package]] @@ -6860,7 +7281,22 @@ dependencies = [ "quote", "regex", "syn 1.0.109", - "zvariant_utils", + "zvariant_utils 1.1.0", +] + +[[package]] +name = "zbus_macros" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac404d48b4e9cf193c8b49589f3280ceca5ff63519e7e64f55b4cf9c47ce146" +dependencies = [ + "proc-macro-crate 3.3.0", + "proc-macro2", + "quote", + "syn 2.0.90", + "zbus_names 4.2.0", + "zvariant 5.6.0", + "zvariant_utils 3.2.0", ] [[package]] @@ -6871,7 +7307,19 @@ checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" dependencies = [ "serde", "static_assertions", - "zvariant", + "zvariant 4.0.0", +] + +[[package]] +name = "zbus_names" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" +dependencies = [ + "serde", + "static_assertions", + "winnow 0.7.12", + "zvariant 5.6.0", ] [[package]] @@ -6980,7 +7428,7 @@ dependencies = [ "pbkdf2", "rand 0.8.5", "sha1", - "thiserror 2.0.7", + "thiserror 2.0.12", "time", "zeroize", "zopfli", @@ -7040,7 +7488,21 @@ dependencies = [ "serde", "static_assertions", "url", - "zvariant_derive", + "zvariant_derive 4.0.0", +] + +[[package]] +name = "zvariant" +version = "5.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91b3680bb339216abd84714172b5138a4edac677e641ef17e1d8cb1b3ca6e6f" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow 0.7.12", + "zvariant_derive 5.6.0", + "zvariant_utils 3.2.0", ] [[package]] @@ -7053,7 +7515,20 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "zvariant_utils", + "zvariant_utils 1.1.0", +] + +[[package]] +name = "zvariant_derive" +version = "5.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8c68501be459a8dbfffbe5d792acdd23b4959940fc87785fb013b32edbc208" +dependencies = [ + "proc-macro-crate 3.3.0", + "proc-macro2", + "quote", + "syn 2.0.90", + "zvariant_utils 3.2.0", ] [[package]] @@ -7066,3 +7541,17 @@ dependencies = [ "quote", "syn 1.0.109", ] + +[[package]] +name = "zvariant_utils" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16edfee43e5d7b553b77872d99bc36afdda75c223ca7ad5e3fbecd82ca5fc34" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "static_assertions", + "syn 2.0.90", + "winnow 0.7.12", +] diff --git a/packages/hoppscotch-desktop/src-tauri/Cargo.toml b/packages/hoppscotch-desktop/src-tauri/Cargo.toml index 6fefe6ce..49d4507a 100644 --- a/packages/hoppscotch-desktop/src-tauri/Cargo.toml +++ b/packages/hoppscotch-desktop/src-tauri/Cargo.toml @@ -38,7 +38,20 @@ tokio = "1.43.0" tauri-plugin-process = "2.2.0" file-rotate = "0.8.0" dirs = "6.0.0" +thiserror = "2.0.12" +native-dialog = { version = "0.7.0" } +tauri-plugin-http = { version = "2.0.1", features = ["gzip"] } +tauri-plugin-opener = "2" +semver = "1.0" + +[target.'cfg(windows)'.dependencies] +tempfile = { version = "3.13.0" } +winreg = { version = "0.52.0" } [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-updater = "2.3.1" tauri-plugin-window-state = "2.2.1" + +[features] +default = [] +portable = [] diff --git a/packages/hoppscotch-desktop/src-tauri/build.rs b/packages/hoppscotch-desktop/src-tauri/build.rs index d860e1e6..0d2e5906 100644 --- a/packages/hoppscotch-desktop/src-tauri/build.rs +++ b/packages/hoppscotch-desktop/src-tauri/build.rs @@ -1,3 +1,20 @@ fn main() { + #[cfg(all(feature = "portable", target_os = "windows"))] + { + println!("cargo:rerun-if-changed=tauri.portable.windows.conf.json"); + println!("cargo:rustc-env=TAURI_CONFIG_FILE=tauri.portable.windows.conf.json"); + } + + #[cfg(all(feature = "portable", target_os = "macos"))] + { + println!("cargo:rerun-if-changed=tauri.portable.macos.conf.json"); + println!("cargo:rustc-env=TAURI_CONFIG_FILE=tauri.portable.macos.conf.json"); + } + + #[cfg(not(feature = "portable"))] + { + println!("cargo:rerun-if-changed=tauri.conf.json"); + } + tauri_build::build() } diff --git a/packages/hoppscotch-desktop/src-tauri/tauri.conf.json b/packages/hoppscotch-desktop/src-tauri/tauri.conf.json index 2913e1d1..637194b0 100644 --- a/packages/hoppscotch-desktop/src-tauri/tauri.conf.json +++ b/packages/hoppscotch-desktop/src-tauri/tauri.conf.json @@ -14,7 +14,7 @@ { "title": "main", "width": 500, - "height": 600, + "height": 700, "decorations": false, "alwaysOnTop": true, "resizable": false diff --git a/packages/hoppscotch-desktop/src-tauri/tauri.portable.macos.conf.json b/packages/hoppscotch-desktop/src-tauri/tauri.portable.macos.conf.json new file mode 100644 index 00000000..62e7345a --- /dev/null +++ b/packages/hoppscotch-desktop/src-tauri/tauri.portable.macos.conf.json @@ -0,0 +1,62 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Hoppscotch", + "version": "25.6.1", + "identifier": "io.hoppscotch.desktop", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://127.0.0.1:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "main", + "width": 500, + "height": 700, + "decorations": false, + "alwaysOnTop": true, + "resizable": false + } + ], + "security": { + "csp": { + "default-src": "blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' customprotocol: asset:", + "script-src": "* 'self' 'unsafe-eval' 'wasm-unsafe-eval' 'unsafe-inline'", + "connect-src": "ipc: http://ipc.localhost https://api.hoppscotch.io data: *", + "font-src": "https://fonts.gstatic.com data: 'self' *", + "img-src": "'self' asset: http://asset.localhost blob: data: customprotocol: *", + "style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com data: asset: *", + "worker-src": "* 'self' data: 'unsafe-eval' blob:" + } + } + }, + "bundle": { + "active": true, + "targets": "all", + "createUpdaterArtifacts": false, + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + }, + "plugins": { + "deep-link": { + "desktop": { + "schemes": ["io.hoppscotch.desktop"] + } + }, + "updater": { + "active": true, + "endpoints": [ + "https://releases.hoppscotch.com/hoppscotch-selfhost-desktop.json" + ], + "dialog": false, + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDYwOURFNEY4RDRGMDQxNTgKUldSWVFmRFUrT1NkWUc1RDM0Z2ZjTHE2dG52Q3ZlYzg3ZXVpZU9KaENPWTBMd3MwY0hWa1lreDcK" + } + } +} diff --git a/packages/hoppscotch-desktop/src-tauri/tauri.portable.windows.conf.json b/packages/hoppscotch-desktop/src-tauri/tauri.portable.windows.conf.json new file mode 100644 index 00000000..c66a08ae --- /dev/null +++ b/packages/hoppscotch-desktop/src-tauri/tauri.portable.windows.conf.json @@ -0,0 +1,60 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "Hoppscotch", + "version": "25.6.1", + "identifier": "io.hoppscotch.desktop", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://127.0.0.1:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "main", + "width": 500, + "height": 700, + "decorations": false, + "alwaysOnTop": true, + "resizable": false + } + ], + "security": { + "csp": { + "default-src": "blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' customprotocol: asset:", + "script-src": "* 'self' 'unsafe-eval' 'wasm-unsafe-eval' 'unsafe-inline'", + "connect-src": "ipc: http://ipc.localhost https://api.hoppscotch.io data: *", + "font-src": "https://fonts.gstatic.com data: 'self' *", + "img-src": "'self' asset: http://asset.localhost blob: data: customprotocol: *", + "style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com data: asset: *", + "worker-src": "* 'self' data: 'unsafe-eval' blob:" + } + } + }, + "bundle": { + "active": false, + "targets": "all", + "windows": { + "webviewInstallMode": { + "type": "skip" + } + }, + "createUpdaterArtifacts": false + }, + "plugins": { + "deep-link": { + "desktop": { + "schemes": ["io.hoppscotch.desktop"] + } + }, + "updater": { + "active": true, + "endpoints": [ + "https://releases.hoppscotch.com/hoppscotch-selfhost-desktop.json" + ], + "dialog": false, + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDYwOURFNEY4RDRGMDQxNTgKUldSWVFmRFUrT1NkWUc1RDM0Z2ZjTHE2dG52Q3ZlYzg3ZXVpZU9KaENPWTBMd3MwY0hWa1lreDcK" + } + } +} diff --git a/packages/hoppscotch-desktop/src/kernel/index.ts b/packages/hoppscotch-desktop/src/kernel/index.ts new file mode 100644 index 00000000..5d75abbc --- /dev/null +++ b/packages/hoppscotch-desktop/src/kernel/index.ts @@ -0,0 +1,13 @@ +import { KernelAPI } from "@hoppscotch/kernel" + +export { Io } from "./io" +export { Relay } from "./relay" +export { Store } from "./store" + +export const getModule = ( + name: K +): NonNullable => { + const kernel = window.__KERNEL__ + if (!kernel?.[name]) throw new Error(`Kernel ${String(name)} not initialized`) + return kernel[name] +} diff --git a/packages/hoppscotch-desktop/src/kernel/io.ts b/packages/hoppscotch-desktop/src/kernel/io.ts new file mode 100644 index 00000000..bf55cf8d --- /dev/null +++ b/packages/hoppscotch-desktop/src/kernel/io.ts @@ -0,0 +1,34 @@ +import type { + SaveFileWithDialogOptions, + OpenExternalLinkOptions, + SaveFileResponse, + OpenExternalLinkResponse, + EventCallback, + UnlistenFn, +} from "@hoppscotch/kernel" +import { getModule } from "." + +export const Io = (() => { + const module = () => getModule("io") + + return { + saveFileWithDialog: ( + opts: SaveFileWithDialogOptions + ): Promise => module().saveFileWithDialog(opts), + + openExternalLink: ( + opts: OpenExternalLinkOptions + ): Promise => module().openExternalLink(opts), + + listen: ( + event: string, + handler: EventCallback + ): Promise => module().listen(event, handler), + + once: (event: string, handler: EventCallback): Promise => + module().once(event, handler), + + emit: (event: string, payload?: unknown): Promise => + module().emit(event, payload), + } as const +})() diff --git a/packages/hoppscotch-desktop/src/kernel/relay.ts b/packages/hoppscotch-desktop/src/kernel/relay.ts new file mode 100644 index 00000000..46a8d4ea --- /dev/null +++ b/packages/hoppscotch-desktop/src/kernel/relay.ts @@ -0,0 +1,26 @@ +import type { + RelayRequest, + RelayRequestEvents, + RelayError, + RelayResponse, + RelayEventEmitter, +} from "@hoppscotch/kernel" +import * as E from "fp-ts/Either" +import { getModule } from "." + +export const Relay = (() => { + const module = () => getModule("relay") + + return { + capabilities: () => module().capabilities, + canHandle: (request: RelayRequest): E.Either => + module().canHandle(request), + execute: ( + request: RelayRequest + ): { + cancel: () => Promise + emitter: RelayEventEmitter + response: Promise> + } => module().execute(request), + } as const +})() diff --git a/packages/hoppscotch-desktop/src/kernel/store.ts b/packages/hoppscotch-desktop/src/kernel/store.ts new file mode 100644 index 00000000..9badf6d2 --- /dev/null +++ b/packages/hoppscotch-desktop/src/kernel/store.ts @@ -0,0 +1,114 @@ +import type { + StorageOptions, + StoreError, + StoreEvents, + StoreEventEmitter, +} from "@hoppscotch/kernel" +import * as E from "fp-ts/Either" +import { getModule } from "." +import { invoke } from "@tauri-apps/api/core" +import { join } from "@tauri-apps/api/path" + +const STORE_PATH = "hoppscotch-unified.store" + +export const getConfigDir = async (): Promise => { + return invoke("get_config_dir") +} + +export const getBackupDir = async (): Promise => { + return invoke("get_backup_dir") +} + +export const getLatestDir = async (): Promise => { + return invoke("get_latest_dir") +} + +export const getStoreDir = async (): Promise => { + return invoke("get_store_dir") +} + +export const getInstanceDir = async (): Promise => { + return invoke("get_instance_dir") +} + +const getStorePath = async (): Promise => { + try { + const instanceDir = await getInstanceDir() + return join(instanceDir, STORE_PATH) + } catch (error) { + console.error("Failed to get instance directory:", error) + return "hoppscotch-unified.store" + } +} + +export const Store = (() => { + const module = () => getModule("store") + + return { + capabilities: () => module().capabilities, + + init: async () => { + const storePath = await getStorePath() + return module().init(storePath) + }, + + set: async ( + namespace: string, + key: string, + value: unknown, + options?: StorageOptions + ): Promise> => { + const storePath = await getStorePath() + return module().set(storePath, namespace, key, value, options) + }, + + get: async ( + namespace: string, + key: string + ): Promise> => { + const storePath = await getStorePath() + return module().get(storePath, namespace, key) + }, + + remove: async ( + namespace: string, + key: string + ): Promise> => { + const storePath = await getStorePath() + return module().remove(storePath, namespace, key) + }, + + clear: async (namespace?: string): Promise> => { + const storePath = await getStorePath() + return module().clear(storePath, namespace) + }, + + has: async ( + namespace: string, + key: string + ): Promise> => { + const storePath = await getStorePath() + return module().has(storePath, namespace, key) + }, + + listNamespaces: async (): Promise> => { + const storePath = await getStorePath() + return module().listNamespaces(storePath) + }, + + listKeys: async ( + namespace: string + ): Promise> => { + const storePath = await getStorePath() + return module().listKeys(storePath, namespace) + }, + + watch: async ( + namespace: string, + key: string + ): Promise> => { + const storePath = await getStorePath() + return module().watch(storePath, namespace, key) + }, + } as const +})() diff --git a/packages/hoppscotch-desktop/src/types/kernel.d.ts b/packages/hoppscotch-desktop/src/types/kernel.d.ts new file mode 100644 index 00000000..a4c43a34 --- /dev/null +++ b/packages/hoppscotch-desktop/src/types/kernel.d.ts @@ -0,0 +1,9 @@ +import type { KernelAPI } from "@hoppscotch/kernel" + +declare global { + interface Window { + __KERNEL__?: KernelAPI + } +} + +export {} diff --git a/packages/hoppscotch-desktop/tsconfig.json b/packages/hoppscotch-desktop/tsconfig.json index cfb13a56..1a0e5977 100644 --- a/packages/hoppscotch-desktop/tsconfig.json +++ b/packages/hoppscotch-desktop/tsconfig.json @@ -21,16 +21,21 @@ "noFallthroughCasesInSwitch": true, "paths": { "~/*": ["./src/*"], + "@hoppscotch/common": ["../hoppscotch-common/src/index.ts"], + "@hoppscotch/common/*": ["../hoppscotch-common/src/*"], "@composables/*": ["./src/composables/*"], "@components/*": ["./src/components/*"], "@helpers/*": ["./src/helpers/*"], + "@kernel/*": ["./src/kernel/*"], "@modules/*": ["./src/modules/*"], + "@services/*": ["./src/services/*"], "@workers/*": ["./src/workers/*"], "@functional/*": ["./src/helpers/functional/*"] }, "types": [ "vite/client", - "unplugin-icons/types/vue" + "unplugin-icons/types/vue", + "./src/types/kernel.d.ts" ] }, "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], diff --git a/packages/hoppscotch-desktop/vite.config.ts b/packages/hoppscotch-desktop/vite.config.ts index f9473471..9bdafeac 100644 --- a/packages/hoppscotch-desktop/vite.config.ts +++ b/packages/hoppscotch-desktop/vite.config.ts @@ -1,9 +1,9 @@ import { defineConfig } from "vite" import vue from "@vitejs/plugin-vue" -import Icons from 'unplugin-icons/vite' -import IconResolver from 'unplugin-icons/resolver' -import Components from 'unplugin-vue-components/vite' -import path from 'path' +import Icons from "unplugin-icons/vite" +import IconResolver from "unplugin-icons/resolver" +import Components from "unplugin-vue-components/vite" +import path from "path" // @ts-expect-error process is a nodejs global const host = process.env.TAURI_DEV_HOST @@ -12,28 +12,28 @@ export default defineConfig(async () => ({ plugins: [ vue(), Components({ - dts: './src/components.d.ts', + dts: "./src/components.d.ts", resolvers: [ IconResolver({ - prefix: 'icon', + prefix: "icon", }), (compName: string) => { - if (compName.startsWith('Hopp')) - return { name: compName, from: '@hoppscotch/ui' } + if (compName.startsWith("Hopp")) + return { name: compName, from: "@hoppscotch/ui" } return undefined }, ], types: [ { - from: 'vue-tippy', - names: ['Tippy'], + from: "vue-tippy", + names: ["Tippy"], }, ], include: [/\.vue$/, /\.vue\?vue/], - dirs: ['src/components'], + dirs: ["src/components"], }), Icons({ - compiler: 'vue3', + compiler: "vue3", }), ], @@ -41,6 +41,7 @@ export default defineConfig(async () => ({ alias: { "~": path.resolve(__dirname, "src"), "~/": path.resolve(__dirname, "src/"), + "@hoppscotch/common": "@hoppscotch/common/src", }, dedupe: ["vue"], }, @@ -65,13 +66,13 @@ export default defineConfig(async () => ({ server: { port: 1420, strictPort: true, - host: '127.0.0.1', + host: "127.0.0.1", hmr: host ? { - protocol: "ws", - host, - port: 1421, - } + protocol: "ws", + host, + port: 1421, + } : undefined, watch: { ignored: ["**/src-tauri/**"], diff --git a/packages/hoppscotch-kernel/package.json b/packages/hoppscotch-kernel/package.json index 1acf4524..0b439ee1 100644 --- a/packages/hoppscotch-kernel/package.json +++ b/packages/hoppscotch-kernel/package.json @@ -19,7 +19,7 @@ }, "exports": { ".": { - "type": "./dist/index.d.ts", + "types": "./dist/index.d.ts", "import": "./dist/hoppscotch-kernel.js", "require": "./dist/hoppscotch-kernel.cjs" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6050d941..bfd71a47 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -994,6 +994,9 @@ importers: '@fontsource-variable/roboto-mono': specifier: 5.1.0 version: 5.1.0 + '@hoppscotch/common': + specifier: workspace:^ + version: link:../hoppscotch-common '@hoppscotch/kernel': specifier: workspace:^ version: link:../hoppscotch-kernel @@ -1002,10 +1005,13 @@ importers: version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/1b52e49d881926135838cf6cfebdc1643a9bec31' '@hoppscotch/ui': specifier: 0.2.1 - version: 0.2.1(eslint@9.27.0(jiti@2.4.2))(terser@5.39.2)(typescript@5.8.3)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3)) + version: 0.2.1(eslint@8.57.0)(terser@5.39.2)(typescript@5.8.3)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3)) '@tauri-apps/api': specifier: 2.1.1 version: 2.1.1 + '@tauri-apps/plugin-fs': + specifier: 2.0.2 + version: 2.0.2 '@tauri-apps/plugin-process': specifier: 2.2.0 version: 2.2.0 @@ -1024,6 +1030,9 @@ importers: fp-ts: specifier: 2.16.9 version: 2.16.9 + rxjs: + specifier: 7.8.1 + version: 7.8.1 vue: specifier: 3.5.12 version: 3.5.12(typescript@5.8.3) @@ -1033,19 +1042,43 @@ importers: vue-tippy: specifier: 6.5.0 version: 6.5.0(vue@3.5.12(typescript@5.8.3)) + zod: + specifier: 3.23.8 + version: 3.23.8 devDependencies: '@iconify-json/lucide': specifier: 1.2.10 version: 1.2.10 + '@rushstack/eslint-patch': + specifier: 1.10.4 + version: 1.10.4 '@tauri-apps/cli': specifier: ^2 version: 2.0.4 + '@typescript-eslint/eslint-plugin': + specifier: 8.9.0 + version: 8.9.0(@typescript-eslint/parser@8.9.0(eslint@8.57.0)(typescript@5.8.3))(eslint@8.57.0)(typescript@5.8.3) + '@typescript-eslint/parser': + specifier: 8.9.0 + version: 8.9.0(eslint@8.57.0)(typescript@5.8.3) '@vitejs/plugin-vue': specifier: ^5.0.5 version: 5.1.4(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3)) + '@vue/eslint-config-typescript': + specifier: 13.0.0 + version: 13.0.0(eslint-plugin-vue@9.29.0(eslint@8.57.0))(eslint@8.57.0)(typescript@5.8.3) autoprefixer: specifier: 10.4.20 version: 10.4.20(postcss@8.4.49) + eslint: + specifier: 8.57.0 + version: 8.57.0 + eslint-plugin-prettier: + specifier: 5.2.1 + version: 5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@10.1.5(eslint@8.57.0))(eslint@8.57.0)(prettier@3.5.3) + eslint-plugin-vue: + specifier: 9.29.0 + version: 9.29.0(eslint@8.57.0) postcss: specifier: 8.4.49 version: 8.4.49 @@ -13043,12 +13076,6 @@ packages: resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} hasBin: true - ts-api-utils@1.3.0: - resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} - engines: {node: '>=16'} - peerDependencies: - typescript: '>=4.2.0' - ts-api-utils@1.4.3: resolution: {integrity: sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==} engines: {node: '>=16'} @@ -14511,6 +14538,9 @@ packages: zod@3.22.4: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} + zod@3.23.8: + resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} + zod@3.25.32: resolution: {integrity: sha512-OSm2xTIRfW8CV5/QKgngwmQW/8aPfGdaQFlrGoErlgg/Epm7cjb6K6VEyExfe65a3VybUOnu381edLb0dfJl0g==} @@ -18493,6 +18523,30 @@ snapshots: stringify-object: 3.3.0 yargs: 17.7.2 + '@hoppscotch/ui@0.2.1(eslint@8.57.0)(terser@5.39.2)(typescript@5.8.3)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3))': + dependencies: + '@boringer-avatars/vue3': 0.2.1(vue@3.5.12(typescript@5.8.3)) + '@fontsource-variable/inter': 5.1.0 + '@fontsource-variable/material-symbols-rounded': 5.1.3 + '@fontsource-variable/roboto-mono': 5.1.0 + '@hoppscotch/vue-sonner': 1.2.3 + '@hoppscotch/vue-toasted': 0.1.0(vue@3.5.12(typescript@5.8.3)) + '@vitejs/plugin-legacy': 2.3.0(terser@5.39.2)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2)) + '@vueuse/core': 8.9.4(vue@3.5.12(typescript@5.8.3)) + fp-ts: 2.16.9 + lodash-es: 4.17.21 + path: 0.12.7 + vite-plugin-eslint: 1.8.1(eslint@8.57.0)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2)) + vue: 3.5.12(typescript@5.8.3) + vue-promise-modals: 0.1.0(typescript@5.8.3) + vuedraggable-es: 4.1.1(vue@3.5.12(typescript@5.8.3)) + transitivePeerDependencies: + - '@vue/composition-api' + - eslint + - terser + - typescript + - vite + '@hoppscotch/ui@0.2.1(eslint@8.57.0)(terser@5.39.2)(typescript@5.8.3)(vite@5.4.9(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3))': dependencies: '@boringer-avatars/vue3': 0.2.1(vue@3.5.12(typescript@5.8.3)) @@ -18517,30 +18571,6 @@ snapshots: - typescript - vite - '@hoppscotch/ui@0.2.1(eslint@9.27.0(jiti@2.4.2))(terser@5.39.2)(typescript@5.8.3)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3))': - dependencies: - '@boringer-avatars/vue3': 0.2.1(vue@3.5.12(typescript@5.8.3)) - '@fontsource-variable/inter': 5.1.0 - '@fontsource-variable/material-symbols-rounded': 5.1.3 - '@fontsource-variable/roboto-mono': 5.1.0 - '@hoppscotch/vue-sonner': 1.2.3 - '@hoppscotch/vue-toasted': 0.1.0(vue@3.5.12(typescript@5.8.3)) - '@vitejs/plugin-legacy': 2.3.0(terser@5.39.2)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2)) - '@vueuse/core': 8.9.4(vue@3.5.12(typescript@5.8.3)) - fp-ts: 2.16.9 - lodash-es: 4.17.21 - path: 0.12.7 - vite-plugin-eslint: 1.8.1(eslint@9.27.0(jiti@2.4.2))(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2)) - vue: 3.5.12(typescript@5.8.3) - vue-promise-modals: 0.1.0(typescript@5.8.3) - vuedraggable-es: 4.1.1(vue@3.5.12(typescript@5.8.3)) - transitivePeerDependencies: - - '@vue/composition-api' - - eslint - - terser - - typescript - - vite - '@hoppscotch/ui@0.2.1(eslint@9.27.0(jiti@2.4.2))(terser@5.39.2)(typescript@5.8.3)(vite@5.4.9(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2))(vue@3.5.12(typescript@5.8.3))': dependencies: '@boringer-avatars/vue3': 0.2.1(vue@3.5.12(typescript@5.8.3)) @@ -20567,7 +20597,7 @@ snapshots: '@typescript-eslint/eslint-plugin@8.9.0(@typescript-eslint/parser@8.9.0(eslint@8.57.0)(typescript@5.8.3))(eslint@8.57.0)(typescript@5.8.3)': dependencies: - '@eslint-community/regexpp': 4.11.1 + '@eslint-community/regexpp': 4.12.1 '@typescript-eslint/parser': 8.9.0(eslint@8.57.0)(typescript@5.8.3) '@typescript-eslint/scope-manager': 8.9.0 '@typescript-eslint/type-utils': 8.9.0(eslint@8.57.0)(typescript@5.8.3) @@ -20577,7 +20607,7 @@ snapshots: graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.8.3) + ts-api-utils: 1.4.3(typescript@5.8.3) optionalDependencies: typescript: 5.8.3 transitivePeerDependencies: @@ -20626,7 +20656,7 @@ snapshots: '@typescript-eslint/types': 8.9.0 '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.8.3) '@typescript-eslint/visitor-keys': 8.9.0 - debug: 4.3.7 + debug: 4.4.1 eslint: 8.57.0 optionalDependencies: typescript: 5.8.3 @@ -20698,7 +20728,7 @@ snapshots: '@typescript-eslint/typescript-estree': 8.9.0(typescript@5.8.3) '@typescript-eslint/utils': 8.9.0(eslint@8.57.0)(typescript@5.8.3) debug: 4.4.1 - ts-api-utils: 1.3.0(typescript@5.8.3) + ts-api-utils: 1.4.3(typescript@5.8.3) optionalDependencies: typescript: 5.8.3 transitivePeerDependencies: @@ -20780,7 +20810,7 @@ snapshots: fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 - semver: 7.7.2 + semver: 7.6.3 ts-api-utils: 1.4.3(typescript@5.8.3) optionalDependencies: typescript: 5.8.3 @@ -21532,10 +21562,6 @@ snapshots: mime-types: 3.0.1 negotiator: 1.0.0 - acorn-jsx@5.3.2(acorn@8.12.1): - dependencies: - acorn: 8.12.1 - acorn-jsx@5.3.2(acorn@8.14.1): dependencies: acorn: 8.14.1 @@ -23634,7 +23660,7 @@ snapshots: eslint-plugin-vue@9.29.0(eslint@8.57.0): dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) + '@eslint-community/eslint-utils': 4.7.0(eslint@8.57.0) eslint: 8.57.0 globals: 13.24.0 natural-compare: 1.4.0 @@ -23800,8 +23826,8 @@ snapshots: espree@9.6.1: dependencies: - acorn: 8.12.1 - acorn-jsx: 5.3.2(acorn@8.12.1) + acorn: 8.14.1 + acorn-jsx: 5.3.2(acorn@8.14.1) eslint-visitor-keys: 3.4.3 esprima-extract-comments@1.1.0: @@ -29412,10 +29438,6 @@ snapshots: tree-kill@1.2.2: {} - ts-api-utils@1.3.0(typescript@5.8.3): - dependencies: - typescript: 5.8.3 - ts-api-utils@1.4.3(typescript@5.8.3): dependencies: typescript: 5.8.3 @@ -30114,6 +30136,14 @@ snapshots: typescript: 5.8.3 vue-tsc: 1.8.24(typescript@5.8.3) + vite-plugin-eslint@1.8.1(eslint@8.57.0)(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2)): + dependencies: + '@rollup/pluginutils': 4.2.1 + '@types/eslint': 8.56.10 + eslint: 8.57.0 + rollup: 2.79.2 + vite: 5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2) + vite-plugin-eslint@1.8.1(eslint@8.57.0)(vite@5.4.9(@types/node@22.15.19)(sass@1.79.5)(terser@5.39.2)): dependencies: '@rollup/pluginutils': 4.2.1 @@ -30130,14 +30160,6 @@ snapshots: rollup: 2.79.2 vite: 5.4.9(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2) - vite-plugin-eslint@1.8.1(eslint@9.27.0(jiti@2.4.2))(vite@5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2)): - dependencies: - '@rollup/pluginutils': 4.2.1 - '@types/eslint': 8.56.10 - eslint: 9.27.0(jiti@2.4.2) - rollup: 2.79.2 - vite: 5.4.11(@types/node@22.15.19)(sass@1.80.3)(terser@5.39.2) - vite-plugin-eslint@1.8.1(eslint@9.27.0(jiti@2.4.2))(vite@5.4.11(@types/node@22.7.6)(sass@1.80.3)(terser@5.39.2)): dependencies: '@rollup/pluginutils': 4.2.1 @@ -31269,4 +31291,6 @@ snapshots: zod@3.22.4: {} + zod@3.23.8: {} + zod@3.25.32: {}