// Universal Nuxt plugin syncing `app.config.ts` (`journal.embeds`) into the // active Journal embed registry on both SSR and client before page components // render, so `htmlGate.ts`, `embeds.ts`, and `useJournalEmbedHydration.ts` // agree on the exact same provider set. import { defineJournalEmbedProviders, type JournalEmbedProvider } from '../utils/embedRegistry.ts' const syncedEmbedMaps = new WeakSet() export default defineNuxtPlugin({ name: 'journal-embeds', enforce: 'pre', setup() { const appConfig = useAppConfig() as { journal?: { embeds?: Record } } const embeds = appConfig?.journal?.embeds if (embeds && typeof embeds === 'object' && !syncedEmbedMaps.has(embeds)) { defineJournalEmbedProviders(embeds) syncedEmbedMaps.add(embeds) } }, })