Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031import { openDB } from 'idb'import type { PluginManifest } from '../types'
export interface CatalogBundle { waitForMetadata?: boolean manifest: PluginManifest mainJs: string stylesCss?: string sourceUrl: string installedAt: number}
const database = () => openDB('reams-plugin-catalog', 1, { upgrade(db) { db.createObjectStore('bundles', { keyPath: 'manifest.id' }) },})
export async function saveCatalogBundle(bundle: CatalogBundle): Promise<void> { const db = await database() try { await db.add('bundles', bundle) } finally { db.close() }}
export async function readCatalogBundles(): Promise<CatalogBundle[]> { const db = await database() try { return await db.getAll('bundles') } finally { db.close() }}
export async function deleteCatalogBundle(id: string): Promise<void> { const db = await database() try { await db.delete('bundles', id) } finally { db.close() }}