perf(desktop): cache store path resolution (#5747)

This commit is contained in:
Shreyas 2026-01-06 14:08:29 +05:30 committed by GitHub
parent 9693a82a87
commit b3b609d0b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 2189 additions and 1874 deletions

View file

@ -235,7 +235,6 @@ declare module 'vue' {
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'] IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default'] IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default']
IconLucideBrush: typeof import('~icons/lucide/brush')['default'] IconLucideBrush: typeof import('~icons/lucide/brush')['default']
IconLucideCheck: typeof import('~icons/lucide/check')['default']
IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default'] IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default']
IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default'] IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']
IconLucideCircleCheck: typeof import('~icons/lucide/circle-check')['default'] IconLucideCircleCheck: typeof import('~icons/lucide/circle-check')['default']
@ -252,13 +251,11 @@ declare module 'vue' {
IconLucideLoader2: typeof import('~icons/lucide/loader2')['default'] IconLucideLoader2: typeof import('~icons/lucide/loader2')['default']
IconLucideLock: typeof import('~icons/lucide/lock')['default'] IconLucideLock: typeof import('~icons/lucide/lock')['default']
IconLucideMinus: typeof import('~icons/lucide/minus')['default'] IconLucideMinus: typeof import('~icons/lucide/minus')['default']
IconLucidePauseCircle: typeof import('~icons/lucide/pause-circle')['default']
IconLucidePlusCircle: typeof import('~icons/lucide/plus-circle')['default'] IconLucidePlusCircle: typeof import('~icons/lucide/plus-circle')['default']
IconLucideRss: typeof import('~icons/lucide/rss')['default'] IconLucideRss: typeof import('~icons/lucide/rss')['default']
IconLucideSearch: typeof import('~icons/lucide/search')['default'] IconLucideSearch: typeof import('~icons/lucide/search')['default']
IconLucideTerminal: typeof import('~icons/lucide/terminal')['default'] IconLucideTerminal: typeof import('~icons/lucide/terminal')['default']
IconLucideTriangleAlert: typeof import('~icons/lucide/triangle-alert')['default'] IconLucideTriangleAlert: typeof import('~icons/lucide/triangle-alert')['default']
IconLucideUser: typeof import('~icons/lucide/user')['default']
IconLucideUsers: typeof import('~icons/lucide/users')['default'] IconLucideUsers: typeof import('~icons/lucide/users')['default']
IconLucideVerified: typeof import('~icons/lucide/verified')['default'] IconLucideVerified: typeof import('~icons/lucide/verified')['default']
IconLucideX: typeof import('~icons/lucide/x')['default'] IconLucideX: typeof import('~icons/lucide/x')['default']

View file

@ -10,6 +10,8 @@ import { getKernelMode } from "@hoppscotch/kernel"
const STORE_PATH = `${window.location.host}.hoppscotch.store` const STORE_PATH = `${window.location.host}.hoppscotch.store`
let cachedStorePath: string | undefined
// These are only defined functions if in desktop mode. // These are only defined functions if in desktop mode.
// For more context, take a look at how `hoppscotch-kernel/.../store/v1/` works // For more context, take a look at how `hoppscotch-kernel/.../store/v1/` works
// and how the `web` mode store kernel ignores the first file directory input. // and how the `web` mode store kernel ignores the first file directory input.
@ -70,20 +72,23 @@ export const getInstanceDir = async (): Promise<string> => {
} }
const getStorePath = async (): Promise<string> => { const getStorePath = async (): Promise<string> => {
if (cachedStorePath) return cachedStorePath
if (getKernelMode() === "desktop") { if (getKernelMode() === "desktop") {
await isInitd() await isInitd()
if (join) { if (join) {
try { try {
const storeDir = await getStoreDir() const storeDir = await getStoreDir()
return await join(storeDir, STORE_PATH) cachedStorePath = await join(storeDir, STORE_PATH)
return cachedStorePath
} catch (error) { } catch (error) {
console.error("Failed to get store directory:", error) console.error("Failed to get store directory:", error)
return STORE_PATH
} }
} }
} }
return STORE_PATH cachedStorePath = STORE_PATH
return cachedStorePath
} }
export const Store = (() => { export const Store = (() => {

View file

@ -20,7 +20,7 @@
}, },
"dependencies": { "dependencies": {
"@fontsource-variable/inter": "5.2.8", "@fontsource-variable/inter": "5.2.8",
"@fontsource-variable/material-symbols-rounded": "5.2.30", "@fontsource-variable/material-symbols-rounded": "5.2.24",
"@fontsource-variable/roboto-mono": "5.2.8", "@fontsource-variable/roboto-mono": "5.2.8",
"@hoppscotch/common": "workspace:^", "@hoppscotch/common": "workspace:^",
"@hoppscotch/kernel": "workspace:^", "@hoppscotch/kernel": "workspace:^",
@ -29,35 +29,36 @@
"@tauri-apps/api": "2.1.1", "@tauri-apps/api": "2.1.1",
"@tauri-apps/plugin-fs": "2.0.2", "@tauri-apps/plugin-fs": "2.0.2",
"@tauri-apps/plugin-process": "2.2.0", "@tauri-apps/plugin-process": "2.2.0",
"@tauri-apps/plugin-shell": "2.3.3", "@tauri-apps/plugin-shell": "2.2.1",
"@tauri-apps/plugin-store": "2.4.1", "@tauri-apps/plugin-store": "2.2.0",
"@tauri-apps/plugin-updater": "2.9.0", "@tauri-apps/plugin-updater": "2.5.1",
"@vueuse/core": "13.7.0",
"fp-ts": "2.16.11", "fp-ts": "2.16.11",
"rxjs": "7.8.2", "rxjs": "7.8.2",
"vue": "3.5.26", "vue": "3.5.22",
"vue-router": "4.6.4", "vue-router": "4.6.3",
"vue-tippy": "6.7.1", "vue-tippy": "6.7.1",
"zod": "3.25.32" "zod": "3.25.32"
}, },
"devDependencies": { "devDependencies": {
"@iconify-json/lucide": "1.2.81", "@iconify-json/lucide": "1.2.68",
"@rushstack/eslint-patch": "1.15.0", "@rushstack/eslint-patch": "1.14.0",
"@tauri-apps/cli": "2.9.3", "@tauri-apps/cli": "^2",
"@typescript-eslint/eslint-plugin": "8.50.0", "@typescript-eslint/eslint-plugin": "8.44.1",
"@typescript-eslint/parser": "8.50.0", "@typescript-eslint/parser": "8.44.1",
"@vitejs/plugin-vue": "6.0.3", "@vitejs/plugin-vue": "5.1.4",
"@vue/eslint-config-typescript": "13.0.0", "@vue/eslint-config-typescript": "13.0.0",
"autoprefixer": "10.4.23", "autoprefixer": "10.4.21",
"eslint": "8.57.0", "eslint": "8.57.0",
"eslint-plugin-prettier": "5.5.4", "eslint-plugin-prettier": "5.5.4",
"eslint-plugin-vue": "10.6.2", "eslint-plugin-vue": "10.5.1",
"postcss": "8.5.6", "postcss": "8.5.6",
"sass": "1.97.0", "sass": "1.93.2",
"tailwindcss": "3.4.16", "tailwindcss": "3.4.16",
"typescript": "5.9.3", "typescript": "5.9.3",
"unplugin-icons": "22.5.0", "unplugin-icons": "22.2.0",
"unplugin-vue-components": "30.0.0", "unplugin-vue-components": "29.0.0",
"vite": "7.3.0", "vite": "6.3.5",
"vue-tsc": "2.2.0" "vue-tsc": "2.2.0"
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -15,45 +15,45 @@ name = "hoppscotch_desktop_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.5.2", features = [] } tauri-build = { version = "2", features = [] }
[dependencies] [dependencies]
tauri = { version = "2.9.3", features = ["devtools"] } tauri = { version = "2", features = ["devtools"] }
tauri-plugin-shell = { version = "2.3.3", features = [] } tauri-plugin-shell = { version = "2.2.1", features = [] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = [] } serde_json = { version = "1", features = [] }
tracing = "0.1.41" tracing = "0.1.41"
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-appender = { version = "0.2.3" } tracing-appender = { version = "0.2.3" }
tauri-plugin-store = "2.4.1" tauri-plugin-store = "2.2.0"
tauri-plugin-dialog = "2.4.2" tauri-plugin-dialog = "2.2.0"
tauri-plugin-fs = "2.4.4" tauri-plugin-fs = "2.2.0"
tauri-plugin-deep-link = "2.4.5" tauri-plugin-deep-link = "2.2.0"
tauri-plugin-appload = { git = "https://github.com/CuriousCorrelation/tauri-plugin-appload", rev = "52744a8f35bf81b039410522efd4168bd06d4f35" } tauri-plugin-appload = { git = "https://github.com/CuriousCorrelation/tauri-plugin-appload", rev = "52744a8f35bf81b039410522efd4168bd06d4f35" }
tauri-plugin-relay = { git = "https://github.com/CuriousCorrelation/tauri-plugin-relay", rev = "7cf09c1ad31e228758738c2f4e1c8fe9cc141291" } tauri-plugin-relay = { git = "https://github.com/CuriousCorrelation/tauri-plugin-relay", rev = "7cf09c1ad31e228758738c2f4e1c8fe9cc141291" }
axum = "0.8.7" axum = "0.8.1"
tower-http = { version = "0.6.6", features = ["cors"] } tower-http = { version = "0.6.2", features = ["cors"] }
random-port = "0.1.1" random-port = "0.1.1"
tokio = "1.48.0" tokio = "1.43.0"
tauri-plugin-process = "2.3.1" tauri-plugin-process = "2.2.0"
file-rotate = "0.8.0" file-rotate = "0.8.0"
dirs = "6.0.0" dirs = "6.0.0"
thiserror = "2.0.17" thiserror = "2.0.12"
native-dialog = { version = "0.7.0" } native-dialog = { version = "0.7.0" }
tauri-plugin-http = { version = "2.5.4", features = ["gzip"] } tauri-plugin-http = { version = "2.0.1", features = ["gzip"] }
tauri-plugin-opener = "2" tauri-plugin-opener = "2"
semver = "1.0" semver = "1.0"
[dev-dependencies] [dev-dependencies]
tempfile = "3.23.0" tempfile = "3.20.0"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
tempfile = { version = "3.23.0" } tempfile = { version = "3.13.0" }
winreg = { version = "0.52.0" } winreg = { version = "0.52.0" }
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-updater = "2.9.0" tauri-plugin-updater = "2.3.1"
tauri-plugin-window-state = "2.4.1" tauri-plugin-window-state = "2.2.1"
[features] [features]
default = [] default = []

View file

@ -1,11 +1,8 @@
/* eslint-disable */ /* eslint-disable */
// @ts-nocheck // @ts-nocheck
// biome-ignore lint: disable
// oxlint-disable
// ------
// Generated by unplugin-vue-components // Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399 // Read more: https://github.com/vuejs/core/pull/3399
// biome-ignore lint: disable
export {} export {}
/* prettier-ignore */ /* prettier-ignore */

View file

@ -10,6 +10,8 @@ import { getKernelMode } from "@hoppscotch/kernel"
const STORE_PATH = "hoppscotch-unified.store" const STORE_PATH = "hoppscotch-unified.store"
let cachedStorePath: string | undefined
// These are only defined functions if in desktop mode. // These are only defined functions if in desktop mode.
// For more context, take a look at how `hoppscotch-kernel/.../store/v1/` works // For more context, take a look at how `hoppscotch-kernel/.../store/v1/` works
// and how the `web` mode store kernel ignores the first file directory input. // and how the `web` mode store kernel ignores the first file directory input.
@ -70,20 +72,23 @@ export const getInstanceDir = async (): Promise<string> => {
} }
const getStorePath = async (): Promise<string> => { const getStorePath = async (): Promise<string> => {
if (cachedStorePath) return cachedStorePath
if (getKernelMode() === "desktop") { if (getKernelMode() === "desktop") {
await isInitd() await isInitd()
if (join) { if (join) {
try { try {
const instanceDir = await getInstanceDir() const storeDir = await getStoreDir()
return await join(instanceDir, STORE_PATH) cachedStorePath = await join(storeDir, STORE_PATH)
return cachedStorePath
} catch (error) { } catch (error) {
console.error("Failed to get instance directory:", error) console.error("Failed to get store directory:", error)
return STORE_PATH
} }
} }
} }
return STORE_PATH cachedStorePath = STORE_PATH
return cachedStorePath
} }
export const Store = (() => { export const Store = (() => {

File diff suppressed because it is too large Load diff