From 6adeb770bf9f3465693d3e6372aa7fcaf1a70616 Mon Sep 17 00:00:00 2001 From: jlightner Date: Thu, 26 Mar 2026 07:03:02 +0000 Subject: [PATCH] =?UTF-8?q?test:=20Added=20embed=20demo=20page=20with=20st?= =?UTF-8?q?yle-isolation=20proof,=206=20setEngineBase=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - "examples/embed-demo.html" - "app/src/api/__tests__/engine.test.ts" - "vite.embed.config.ts" - ".gitignore" GSD-Task: S03/T02 --- .gitignore | 1 + .gsd/event-log.jsonl | 1 + .gsd/milestones/M003/slices/S03/S03-PLAN.md | 2 +- .../M003/slices/S03/tasks/T01-VERIFY.json | 42 ++++++++ .../M003/slices/S03/tasks/T02-SUMMARY.md | 85 ++++++++++++++++ .gsd/state-manifest.json | 97 ++++++++++++++++--- app/src/api/__tests__/engine.test.ts | 74 +++++++++++++- examples/embed-demo.html | 80 +++++++++++++++ vite.embed.config.ts | 40 ++++++++ 9 files changed, 408 insertions(+), 14 deletions(-) create mode 100644 .gsd/milestones/M003/slices/S03/tasks/T01-VERIFY.json create mode 100644 .gsd/milestones/M003/slices/S03/tasks/T02-SUMMARY.md create mode 100644 examples/embed-demo.html create mode 100644 vite.embed.config.ts diff --git a/.gitignore b/.gitignore index 295b77e..6c95176 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ Thumbs.db node_modules/ .next/ dist/ +dist-embed/ build/ __pycache__/ *.pyc diff --git a/.gsd/event-log.jsonl b/.gsd/event-log.jsonl index dafb7fe..2533470 100644 --- a/.gsd/event-log.jsonl +++ b/.gsd/event-log.jsonl @@ -42,3 +42,4 @@ {"cmd":"complete-slice","params":{"milestoneId":"M003","sliceId":"S02"},"ts":"2026-03-26T06:48:34.805Z","actor":"agent","hash":"b305679ef7f0a27b","session_id":"49f8e0fe-34a0-4608-b519-eca93850ed7c"} {"cmd":"plan-slice","params":{"milestoneId":"M003","sliceId":"S03"},"ts":"2026-03-26T06:54:15.756Z","actor":"agent","hash":"eaf42bd487467df8","session_id":"49f8e0fe-34a0-4608-b519-eca93850ed7c"} {"cmd":"complete-task","params":{"milestoneId":"M003","sliceId":"S03","taskId":"T01"},"ts":"2026-03-26T06:59:26.868Z","actor":"agent","hash":"a47a8fb4b4e7bb97","session_id":"49f8e0fe-34a0-4608-b519-eca93850ed7c"} +{"cmd":"complete-task","params":{"milestoneId":"M003","sliceId":"S03","taskId":"T02"},"ts":"2026-03-26T07:02:59.395Z","actor":"agent","hash":"3e4362f2d0a5550b","session_id":"49f8e0fe-34a0-4608-b519-eca93850ed7c"} diff --git a/.gsd/milestones/M003/slices/S03/S03-PLAN.md b/.gsd/milestones/M003/slices/S03/S03-PLAN.md index 9106011..1675d57 100644 --- a/.gsd/milestones/M003/slices/S03/S03-PLAN.md +++ b/.gsd/milestones/M003/slices/S03/S03-PLAN.md @@ -22,7 +22,7 @@ The Vite library config must: - Estimate: 1h30m - Files: app/src/api/engine.ts, app/src/embed.tsx, app/vite.embed.config.ts, app/tsconfig.node.json - Verify: cd app && npx vite build --config vite.embed.config.ts && test -f dist-embed/kerf-embed.js && test -f dist-embed/style.css && echo 'Build OK' -- [ ] **T02: Add demo page, unit tests for API configurability, and verify full build** — Create the embed demo HTML page and unit tests, then run full verification. +- [x] **T02: Added embed demo page with style-isolation proof, 6 setEngineBaseUrl unit tests, and root-level vite.embed.config.ts so embed build works from project root** — Create the embed demo HTML page and unit tests, then run full verification. 1. Create `examples/embed-demo.html` — a plain HTML page that loads the embed bundle via ` + + + diff --git a/vite.embed.config.ts b/vite.embed.config.ts new file mode 100644 index 0000000..109bb19 --- /dev/null +++ b/vite.embed.config.ts @@ -0,0 +1,40 @@ +/// +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; +import { resolve } from 'path'; + +/** + * Root-level Vite library-mode config for the Web Component. + * + * Mirrors app/vite.embed.config.ts but resolves paths relative to the + * monorepo root so `npx vite build --config vite.embed.config.ts` works + * from the project root directory. + */ +export default defineConfig({ + root: resolve(__dirname, 'app'), + plugins: [react()], + build: { + outDir: resolve(__dirname, 'dist-embed'), + emptyOutDir: true, + lib: { + entry: resolve(__dirname, 'app/src/embed.tsx'), + name: 'KerfEmbed', + formats: ['es', 'iife'], + fileName: (format) => { + if (format === 'es') return 'kerf-embed.js'; + return 'kerf-embed.iife.js'; + }, + }, + cssCodeSplit: false, + rollupOptions: { + external: [], + output: { + codeSplitting: false, + assetFileNames: (assetInfo) => { + if (assetInfo.names?.[0]?.endsWith('.css')) return 'style.css'; + return assetInfo.names?.[0] ?? '[name][extname]'; + }, + }, + }, + }, +});