perf(desktop): cache store path resolution (#5747)
This commit is contained in:
parent
9693a82a87
commit
b3b609d0b4
8 changed files with 2189 additions and 1874 deletions
|
|
@ -235,7 +235,6 @@ declare module 'vue' {
|
|||
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
|
||||
IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default']
|
||||
IconLucideBrush: typeof import('~icons/lucide/brush')['default']
|
||||
IconLucideCheck: typeof import('~icons/lucide/check')['default']
|
||||
IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default']
|
||||
IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']
|
||||
IconLucideCircleCheck: typeof import('~icons/lucide/circle-check')['default']
|
||||
|
|
@ -252,13 +251,11 @@ declare module 'vue' {
|
|||
IconLucideLoader2: typeof import('~icons/lucide/loader2')['default']
|
||||
IconLucideLock: typeof import('~icons/lucide/lock')['default']
|
||||
IconLucideMinus: typeof import('~icons/lucide/minus')['default']
|
||||
IconLucidePauseCircle: typeof import('~icons/lucide/pause-circle')['default']
|
||||
IconLucidePlusCircle: typeof import('~icons/lucide/plus-circle')['default']
|
||||
IconLucideRss: typeof import('~icons/lucide/rss')['default']
|
||||
IconLucideSearch: typeof import('~icons/lucide/search')['default']
|
||||
IconLucideTerminal: typeof import('~icons/lucide/terminal')['default']
|
||||
IconLucideTriangleAlert: typeof import('~icons/lucide/triangle-alert')['default']
|
||||
IconLucideUser: typeof import('~icons/lucide/user')['default']
|
||||
IconLucideUsers: typeof import('~icons/lucide/users')['default']
|
||||
IconLucideVerified: typeof import('~icons/lucide/verified')['default']
|
||||
IconLucideX: typeof import('~icons/lucide/x')['default']
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import { getKernelMode } from "@hoppscotch/kernel"
|
|||
|
||||
const STORE_PATH = `${window.location.host}.hoppscotch.store`
|
||||
|
||||
let cachedStorePath: string | undefined
|
||||
|
||||
// These are only defined functions if in desktop mode.
|
||||
// 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.
|
||||
|
|
@ -70,20 +72,23 @@ export const getInstanceDir = async (): Promise<string> => {
|
|||
}
|
||||
|
||||
const getStorePath = async (): Promise<string> => {
|
||||
if (cachedStorePath) return cachedStorePath
|
||||
|
||||
if (getKernelMode() === "desktop") {
|
||||
await isInitd()
|
||||
if (join) {
|
||||
try {
|
||||
const storeDir = await getStoreDir()
|
||||
return await join(storeDir, STORE_PATH)
|
||||
cachedStorePath = await join(storeDir, STORE_PATH)
|
||||
return cachedStorePath
|
||||
} catch (error) {
|
||||
console.error("Failed to get store directory:", error)
|
||||
return STORE_PATH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return STORE_PATH
|
||||
cachedStorePath = STORE_PATH
|
||||
return cachedStorePath
|
||||
}
|
||||
|
||||
export const Store = (() => {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"@hoppscotch/common": "workspace:^",
|
||||
"@hoppscotch/kernel": "workspace:^",
|
||||
|
|
@ -29,35 +29,36 @@
|
|||
"@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.3.3",
|
||||
"@tauri-apps/plugin-store": "2.4.1",
|
||||
"@tauri-apps/plugin-updater": "2.9.0",
|
||||
"@tauri-apps/plugin-shell": "2.2.1",
|
||||
"@tauri-apps/plugin-store": "2.2.0",
|
||||
"@tauri-apps/plugin-updater": "2.5.1",
|
||||
"@vueuse/core": "13.7.0",
|
||||
"fp-ts": "2.16.11",
|
||||
"rxjs": "7.8.2",
|
||||
"vue": "3.5.26",
|
||||
"vue-router": "4.6.4",
|
||||
"vue": "3.5.22",
|
||||
"vue-router": "4.6.3",
|
||||
"vue-tippy": "6.7.1",
|
||||
"zod": "3.25.32"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify-json/lucide": "1.2.81",
|
||||
"@rushstack/eslint-patch": "1.15.0",
|
||||
"@tauri-apps/cli": "2.9.3",
|
||||
"@typescript-eslint/eslint-plugin": "8.50.0",
|
||||
"@typescript-eslint/parser": "8.50.0",
|
||||
"@vitejs/plugin-vue": "6.0.3",
|
||||
"@iconify-json/lucide": "1.2.68",
|
||||
"@rushstack/eslint-patch": "1.14.0",
|
||||
"@tauri-apps/cli": "^2",
|
||||
"@typescript-eslint/eslint-plugin": "8.44.1",
|
||||
"@typescript-eslint/parser": "8.44.1",
|
||||
"@vitejs/plugin-vue": "5.1.4",
|
||||
"@vue/eslint-config-typescript": "13.0.0",
|
||||
"autoprefixer": "10.4.23",
|
||||
"autoprefixer": "10.4.21",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-plugin-prettier": "5.5.4",
|
||||
"eslint-plugin-vue": "10.6.2",
|
||||
"eslint-plugin-vue": "10.5.1",
|
||||
"postcss": "8.5.6",
|
||||
"sass": "1.97.0",
|
||||
"sass": "1.93.2",
|
||||
"tailwindcss": "3.4.16",
|
||||
"typescript": "5.9.3",
|
||||
"unplugin-icons": "22.5.0",
|
||||
"unplugin-vue-components": "30.0.0",
|
||||
"vite": "7.3.0",
|
||||
"unplugin-icons": "22.2.0",
|
||||
"unplugin-vue-components": "29.0.0",
|
||||
"vite": "6.3.5",
|
||||
"vue-tsc": "2.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2531
packages/hoppscotch-desktop/src-tauri/Cargo.lock
generated
2531
packages/hoppscotch-desktop/src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -15,45 +15,45 @@ name = "hoppscotch_desktop_lib"
|
|||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.5.2", features = [] }
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2.9.3", features = ["devtools"] }
|
||||
tauri-plugin-shell = { version = "2.3.3", features = [] }
|
||||
tauri = { version = "2", features = ["devtools"] }
|
||||
tauri-plugin-shell = { version = "2.2.1", features = [] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = { version = "1", features = [] }
|
||||
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" }
|
||||
tauri-plugin-store = "2.4.1"
|
||||
tauri-plugin-dialog = "2.4.2"
|
||||
tauri-plugin-fs = "2.4.4"
|
||||
tauri-plugin-deep-link = "2.4.5"
|
||||
tauri-plugin-store = "2.2.0"
|
||||
tauri-plugin-dialog = "2.2.0"
|
||||
tauri-plugin-fs = "2.2.0"
|
||||
tauri-plugin-deep-link = "2.2.0"
|
||||
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" }
|
||||
axum = "0.8.7"
|
||||
tower-http = { version = "0.6.6", features = ["cors"] }
|
||||
axum = "0.8.1"
|
||||
tower-http = { version = "0.6.2", features = ["cors"] }
|
||||
random-port = "0.1.1"
|
||||
tokio = "1.48.0"
|
||||
tauri-plugin-process = "2.3.1"
|
||||
tokio = "1.43.0"
|
||||
tauri-plugin-process = "2.2.0"
|
||||
file-rotate = "0.8.0"
|
||||
dirs = "6.0.0"
|
||||
thiserror = "2.0.17"
|
||||
thiserror = "2.0.12"
|
||||
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"
|
||||
semver = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.23.0"
|
||||
tempfile = "3.20.0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
tempfile = { version = "3.23.0" }
|
||||
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.9.0"
|
||||
tauri-plugin-window-state = "2.4.1"
|
||||
tauri-plugin-updater = "2.3.1"
|
||||
tauri-plugin-window-state = "2.2.1"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
// biome-ignore lint: disable
|
||||
// oxlint-disable
|
||||
// ------
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
|
||||
/* prettier-ignore */
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import { getKernelMode } from "@hoppscotch/kernel"
|
|||
|
||||
const STORE_PATH = "hoppscotch-unified.store"
|
||||
|
||||
let cachedStorePath: string | undefined
|
||||
|
||||
// These are only defined functions if in desktop mode.
|
||||
// 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.
|
||||
|
|
@ -70,20 +72,23 @@ export const getInstanceDir = async (): Promise<string> => {
|
|||
}
|
||||
|
||||
const getStorePath = async (): Promise<string> => {
|
||||
if (cachedStorePath) return cachedStorePath
|
||||
|
||||
if (getKernelMode() === "desktop") {
|
||||
await isInitd()
|
||||
if (join) {
|
||||
try {
|
||||
const instanceDir = await getInstanceDir()
|
||||
return await join(instanceDir, STORE_PATH)
|
||||
const storeDir = await getStoreDir()
|
||||
cachedStorePath = await join(storeDir, STORE_PATH)
|
||||
return cachedStorePath
|
||||
} catch (error) {
|
||||
console.error("Failed to get instance directory:", error)
|
||||
return STORE_PATH
|
||||
console.error("Failed to get store directory:", error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return STORE_PATH
|
||||
cachedStorePath = STORE_PATH
|
||||
return cachedStorePath
|
||||
}
|
||||
|
||||
export const Store = (() => {
|
||||
|
|
|
|||
1425
pnpm-lock.yaml
1425
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue