diff --git a/.planning/phases/38-extensible-journal-embed-providers/38-02-SUMMARY.md b/.planning/phases/38-extensible-journal-embed-providers/38-02-SUMMARY.md new file mode 100644 index 00000000..23e6c3bf --- /dev/null +++ b/.planning/phases/38-extensible-journal-embed-providers/38-02-SUMMARY.md @@ -0,0 +1,72 @@ +--- +phase: 38-extensible-journal-embed-providers +plan: 02 +subsystem: vue-journal-layer +tags: [journal, embeds, sanitizer, nuxt, hydration, cls, reduced-motion] +requires: ["38-01"] +provides: + - "Pure TS `JournalEmbedRegistry` (`app/utils/embedRegistry.ts`) with prototype-safe `Map` storage, built-in `YOUTUBE_EMBED_PROVIDER`, and singleton helpers" + - "Universal Nuxt plugin (`app/plugins/journal-embeds.ts`) syncing `app.config.ts` (`journal.embeds`) into the active registry on SSR and client" + - "Registry-driven pair-aware `(data-embed, data-id)` sanitizer (`app/utils/htmlGate.ts`) allowing validated `data-aspect`/`data-height` and UGC fallback children" + - "Generalized `expandEmbeds` (`app/utils/embeds.ts`) preserving byte-identical YouTube SSR iframes and SSR fallback DOM + CLS reservation for client-hydrated providers" + - "Lazy `IntersectionObserver` hydration composable (`app/composables/useJournalEmbedHydration.ts`) wired into `PostBody.vue` and `CategoryHeader.vue`, plus neutral `.journal-embed` CSS" +affects: + - "../vue-journal-layer" + - "Plan 38-03 (unit tests, corpus cross-check, docs)" +tech-stack: + added: [] + patterns: + - "Dual provider registration (`app.config.ts` `journal.embeds` + `registerJournalEmbedProvider` / `defineJournalEmbedProviders`) feeding both SSR sanitizer and client hydration" + - "Zero-CLS height reservation before fallback swap (`min-height` from measured box + validated `data-aspect`/`data-height`)" + - "Dual client mount interface: Vue async `component` (`createVNode` + `render` inheriting `nuxtApp.vueApp._context`) and plain DOM `mount(el, ctx)` with reactive `prefers-reduced-motion` and error fallback" +key-files: + created: + - "../vue-journal-layer/app/utils/embedRegistry.ts" + - "../vue-journal-layer/app/plugins/journal-embeds.ts" + - "../vue-journal-layer/app/composables/useJournalEmbedHydration.ts" + modified: + - "../vue-journal-layer/app/utils/htmlGate.ts" + - "../vue-journal-layer/app/utils/embeds.ts" + - "../vue-journal-layer/app/components/Journal/PostBody.vue" + - "../vue-journal-layer/app/components/Journal/CategoryHeader.vue" + - "../vue-journal-layer/app/assets/css/journal-base.css" + - "../vue-journal-layer/tests/embeds.test.ts" + - "../vue-journal-layer/tests/htmlGate.test.ts" +key-decisions: + - "Kept `embedRegistry.ts` pure TypeScript with zero Nuxt imports and avoided re-exporting symbols across `app/utils` / `app/composables` so both `node --test` and `tests/autoImports.test.ts` pass cleanly." + - "Aligned malformed-placeholder stripping expectations in `tests/embeds.test.ts` and `tests/htmlGate.test.ts` from orphan single-attribute `
` / `
` to `
` to match Wave 1's D-03 pair-aware stripping." + - "Scoped the default 16/9 `aspect-ratio` rule in `journal-base.css` to `.journal-embed--youtube` and `.journal-embed:has(> iframe)` so custom fallback images and interactive widgets are not cropped to 16/9." +duration: 6m +completed: 2026-11-28 +--- + +# Phase 38 Plan 02: Extensible Embed Registry & Lazy Hydration Runtime (`vue-journal-layer`) Summary + +Implemented the app-extensible embed provider registry, universal Nuxt config sync plugin, registry-driven pair-aware sanitizer, generalized SSR embed expander, and lazy `IntersectionObserver` client hydration runtime in `vue-journal-layer`. + +## Commits + +- **`vue-journal-layer` `babd3a9`** — `feat(embeds): add extensible embed registry, universal plugin, and pair-aware sanitizer` + - Created `app/utils/embedRegistry.ts` (`EMBED_PROVIDER_KEY`, `EMBED_ASPECT`, `EMBED_HEIGHT`, `JournalEmbedRegistry`, `YOUTUBE_EMBED_PROVIDER`, `createJournalEmbedRegistry`, `getJournalEmbedRegistry`, `registerJournalEmbedProvider`, `defineJournalEmbedProviders`, `resetJournalEmbedRegistry`). + - Created universal `app/plugins/journal-embeds.ts` (`enforce: 'pre'`) syncing `useAppConfig().journal?.embeds` into the active registry on SSR and client. + - Updated `app/utils/htmlGate.ts` to read the active (or `options.embedRegistry`) registry inside `makeFilterAttributeValues`, enforce pair-aware `(data-embed, data-id)` matching, allow validated `data-aspect`/`data-height` only on validated `
` elements, and strip all four attributes on mismatch. + - Generalized `app/utils/embeds.ts` (`expandEmbeds(html, registry?)`) to preserve byte-identical YouTube SSR `