removed haex-pass components

This commit is contained in:
2025-10-15 21:54:50 +02:00
parent 5d6acfef93
commit 033c9135c6
64 changed files with 2502 additions and 3659 deletions

View File

@ -1,6 +1,6 @@
import { invoke } from '@tauri-apps/api/core'
import { readFile } from '@tauri-apps/plugin-fs'
import { EXTENSION_PROTOCOL_PREFIX } from '~/config/constants'
import { getExtensionUrl } from '~/utils/extension'
import type {
IHaexHubExtension,
@ -55,30 +55,18 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
const extensionEntry = computed(() => {
if (
!currentExtension.value?.version ||
!currentExtension.value?.id ||
!currentExtension.value?.publicKey ||
!currentExtension.value?.name
)
return null
// Extract key_hash from full_extension_id (everything before first underscore)
const firstUnderscoreIndex = currentExtension.value.id.indexOf('_')
if (firstUnderscoreIndex === -1) {
console.error(
'Invalid full_extension_id format:',
currentExtension.value.id,
)
return null
}
const keyHash = currentExtension.value.id.substring(0, firstUnderscoreIndex)
const encodedInfo = encodeExtensionInfo(
keyHash,
return getExtensionUrl(
currentExtension.value.publicKey,
currentExtension.value.name,
currentExtension.value.version,
'index.html',
currentExtension.value.devServerUrl ?? undefined
)
return `${EXTENSION_PROTOCOL_PREFIX}localhost/${encodedInfo}/index.html`
})
/* const getExtensionPathAsync = async (
@ -116,16 +104,8 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
const extensions =
await invoke<ExtensionInfoResponse[]>('get_all_extensions')
availableExtensions.value = extensions.map((ext) => ({
id: ext.fullId,
name: ext.displayName || ext.name,
version: ext.version,
author: ext.namespace,
icon: ext.icon,
enabled: ext.enabled,
description: ext.description,
homepage: ext.homepage,
}))
// ExtensionInfoResponse is now directly compatible with IHaexHubExtension
availableExtensions.value = extensions
} catch (error) {
console.error('Fehler beim Laden der Extensions:', error)
throw error
@ -185,22 +165,16 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
}
}
const removeExtensionAsync = async (extensionId: string, version: string) => {
const removeExtensionAsync = async (
publicKey: string,
name: string,
version: string,
) => {
try {
await invoke('remove_extension', {
extensionId,
extensionVersion: version,
})
} catch (error) {
console.error('Fehler beim Entfernen der Extension:', error)
throw error
}
}
const removeExtensionByFullIdAsync = async (fullExtensionId: string) => {
try {
await invoke('remove_extension_by_full_id', {
fullExtensionId,
publicKey,
name,
version,
})
} catch (error) {
console.error('Fehler beim Entfernen der Extension:', error)
@ -219,15 +193,18 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
} */
const isExtensionInstalledAsync = async ({
id,
publicKey,
name,
version,
}: {
id: string
publicKey: string
name: string
version: string
}) => {
try {
return await invoke<boolean>('is_extension_installed', {
extensionId: id,
publicKey,
name,
extensionVersion: version,
})
} catch (error) {
@ -314,7 +291,6 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
loadExtensionsAsync,
previewManifestAsync,
removeExtensionAsync,
removeExtensionByFullIdAsync,
}
})
@ -370,20 +346,3 @@ export const useExtensionsStore = defineStore('extensionsStore', () => {
throw new Error(JSON.stringify(error))
}
} */
function encodeExtensionInfo(
keyHash: string,
name: string,
version: string,
): string {
const info = {
key_hash: keyHash,
name: name,
version: version,
}
const jsonString = JSON.stringify(info)
const bytes = new TextEncoder().encode(jsonString)
return Array.from(bytes)
.map((b) => b.toString(16).padStart(2, '0'))
.join('')
}

View File

@ -28,10 +28,10 @@ export const useExtensionTabsStore = defineStore('extensionTabsStore', () => {
)
})
const extensionsStore = useExtensionsStore()
// Actions
const openTab = (extensionId: string) => {
// Hole Extension-Info aus dem anderen Store
const extensionsStore = useExtensionsStore()
const extension = extensionsStore.availableExtensions.find(
(ext) => ext.id === extensionId,
)
@ -43,7 +43,9 @@ export const useExtensionTabsStore = defineStore('extensionTabsStore', () => {
// Check if extension is enabled
if (!extension.enabled) {
console.warn(`Extension ${extensionId} ist deaktiviert und kann nicht geöffnet werden`)
console.warn(
`Extension ${extensionId} ist deaktiviert und kann nicht geöffnet werden`,
)
return
}
@ -91,7 +93,9 @@ export const useExtensionTabsStore = defineStore('extensionTabsStore', () => {
// Reload iframe if inactive for more than 10 minutes
if (inactiveDuration > TEN_MINUTES && newTab.iframe) {
console.log(`[TabStore] Reloading extension ${extensionId} after ${Math.round(inactiveDuration / 1000)}s inactivity`)
console.log(
`[TabStore] Reloading extension ${extensionId} after ${Math.round(inactiveDuration / 1000)}s inactivity`,
)
const currentSrc = newTab.iframe.src
newTab.iframe.src = 'about:blank'
// Small delay to ensure reload