archy/neode-ui/src/composables/useMarketplaceApp.ts

59 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-01-24 22:59:20 +00:00
import { ref } from 'vue'
export interface MarketplaceAppInfo {
id: string
title: string
version: string
icon: string
category: string
description: string | { short: string; long: string }
author: string
source: string
manifestUrl: string
url: string
repoUrl: string
s9pkUrl: string
dockerImage: string
/** External web URL for iframe-based web apps (no container needed) */
webUrl?: string
}
2026-01-24 22:59:20 +00:00
// Simple in-memory store for the current marketplace app
const currentMarketplaceApp = ref<MarketplaceAppInfo | null>(null)
2026-01-24 22:59:20 +00:00
export function useMarketplaceApp() {
function setCurrentApp(app: Partial<MarketplaceAppInfo> & { id: string }) {
2026-01-24 22:59:20 +00:00
// Create a clean, serializable copy
currentMarketplaceApp.value = {
id: app.id,
title: app.title ?? '',
version: app.version ?? '',
icon: app.icon ?? '',
category: app.category ?? '',
description: app.description ?? '',
author: app.author ?? '',
source: app.source ?? '',
manifestUrl: app.manifestUrl || app.s9pkUrl || app.url || '',
url: app.url || app.s9pkUrl || app.manifestUrl || '',
repoUrl: app.repoUrl ?? '',
s9pkUrl: app.s9pkUrl ?? '',
dockerImage: app.dockerImage ?? '',
webUrl: (app as Record<string, unknown>).webUrl as string | undefined,
2026-01-24 22:59:20 +00:00
}
}
function getCurrentApp() {
return currentMarketplaceApp.value
}
function clearCurrentApp() {
currentMarketplaceApp.value = null
}
return {
setCurrentApp,
getCurrentApp,
clearCurrentApp
}
}