diff --git a/apps/desktop/src/lib/components/main/CommandPalette.svelte b/apps/desktop/src/lib/components/main/CommandPalette.svelte index c9256f9..b7f97ae 100644 --- a/apps/desktop/src/lib/components/main/CommandPalette.svelte +++ b/apps/desktop/src/lib/components/main/CommandPalette.svelte @@ -5,6 +5,7 @@ passing everything through props will be very complicated and hard to maintain. + @@ -51,7 +65,7 @@ passing everything through props will be very complicated and hard to maintain. No results found. - {#if $appConfig.extensionPath && $devStoreExts.length > 0} + {#if $appConfig.extensionsInstallDir && $devStoreExts.length > 0} {/if} - {#if $appConfig.extensionPath && $installedStoreExts.length > 0} + {#if $appConfig.extensionsInstallDir && $installedStoreExts.length > 0} & AppConfigAPI { async function init() { debug("Initializing app config") - const appDataDir = await path.appDataDir() - // const appConfigPath = await path.join(appDataDir, "appConfig.json") - // debug(`appConfigPath: ${appConfigPath}`) const persistStore = await load("kk-config.json", { autoSave: true }) const loadedConfig = await persistStore.get("config") const parseRes = v.safeParse(PersistedAppConfig, loadedConfig) if (parseRes.success) { console.log("Parse Persisted App Config Success", parseRes.output) - const extensionPath = await path.join(appDataDir, "extensions") + const extensionsInstallDir = await getExtensionsFolder() update((config) => ({ ...config, ...parseRes.output, isInitialized: true, - extensionPath, + extensionsInstallDir, platform: os.platform() })) } else { diff --git a/apps/desktop/src/lib/stores/extensions.ts b/apps/desktop/src/lib/stores/extensions.ts index 0bcb1a4..0769078 100644 --- a/apps/desktop/src/lib/stores/extensions.ts +++ b/apps/desktop/src/lib/stores/extensions.ts @@ -25,7 +25,7 @@ function createExtensionsStore(): Writable & { } function getExtensionsFromStore() { - const extContainerPath = get(appConfig).extensionPath + const extContainerPath = get(appConfig).extensionsInstallDir if (!extContainerPath) return [] return get(extensions).filter((ext) => !extAPI.isExtPathInDev(extContainerPath, ext.extPath)) } @@ -83,7 +83,7 @@ function createExtensionsStore(): Writable & { identifier: string, tarballUrl: string ): Promise { - const extsDir = get(appConfig).extensionPath + const extsDir = get(appConfig).extensionsInstallDir if (!extsDir) throw new Error("Extension path not set") return uninstallStoreExtensionByIdentifier(identifier).then(() => installFromTarballUrl(tarballUrl, extsDir) @@ -109,7 +109,7 @@ export const extensions = createExtensionsStore() export const installedStoreExts: Readable = derived( extensions, ($extensionsStore) => { - const extContainerPath = get(appConfig).extensionPath + const extContainerPath = get(appConfig).extensionsInstallDir if (!extContainerPath) return [] return $extensionsStore.filter((ext) => !extAPI.isExtPathInDev(extContainerPath, ext.extPath)) } @@ -117,7 +117,7 @@ export const installedStoreExts: Readable = derived( export const devStoreExts: Readable = derived( extensions, ($extensionsStore) => { - const extContainerPath = get(appConfig).extensionPath + const extContainerPath = get(appConfig).extensionsInstallDir if (!extContainerPath) return [] return $extensionsStore.filter((ext) => extAPI.isExtPathInDev(extContainerPath, ext.extPath)) } diff --git a/apps/desktop/src/lib/utils/dom.ts b/apps/desktop/src/lib/utils/dom.ts new file mode 100644 index 0000000..36bcfa6 --- /dev/null +++ b/apps/desktop/src/lib/utils/dom.ts @@ -0,0 +1,3 @@ +export function getActiveElementNodeName(): string | undefined { + return document.activeElement?.nodeName +} diff --git a/apps/desktop/src/routes/+layout.ts b/apps/desktop/src/routes/+layout.ts index 8d7e6d2..028840b 100644 --- a/apps/desktop/src/routes/+layout.ts +++ b/apps/desktop/src/routes/+layout.ts @@ -1,5 +1,12 @@ +import { getExtensionsFolder } from "@/constants" +import type { LayoutLoad } from "./$types" + // Tauri doesn't have a Node.js server to do proper SSR // so we will use adapter-static to prerender the app (SSG) // See: https://v2.tauri.app/start/frontend/sveltekit/ for more info export const prerender = true export const ssr = false + +export const load: LayoutLoad = async () => { + return { extsInstallDir: await getExtensionsFolder() } +} diff --git a/apps/desktop/src/routes/extension/store/+page.svelte b/apps/desktop/src/routes/extension/store/+page.svelte index 7f53ef9..bb11470 100644 --- a/apps/desktop/src/routes/extension/store/+page.svelte +++ b/apps/desktop/src/routes/extension/store/+page.svelte @@ -65,7 +65,6 @@ - {#snippet leftSlot()} { showBtn = { - install: !installedExt, + install: !$installedExt, upgrade: isUpgradable, - uninstall: !!installedExt + uninstall: !!$installedExt } }) @@ -140,7 +140,6 @@ - export type AppConfig = PersistedAppConfig & { isInitialized: boolean - extensionPath?: string + extensionsInstallDir?: string platform: Platform } diff --git a/packages/ui/src/components/extension/StoreExtDetail.svelte b/packages/ui/src/components/extension/StoreExtDetail.svelte index 9ef7d0c..2c6fe18 100644 --- a/packages/ui/src/components/extension/StoreExtDetail.svelte +++ b/packages/ui/src/components/extension/StoreExtDetail.svelte @@ -125,8 +125,8 @@ data-flip-id={`${Constants.CLASSNAMES.EXT_LOGO}-${ext.identifier}`} /> - - + + {manifest?.name} {#if isInstalled}