Commit e35a407
authored
* docs(plan): #4 embed API v1 implementation plan (Task 0)
* feat(embed): protocol envelope types + validator (Task 1)
* feat(embed): origin validator + allowedOrigins parser (Task 2)
* feat(embed): URL param parser (Task 3)
* feat(embed): chrome CSS-class application (Task 4)
* feat(embed): theme CSS-class application (Task 5)
* feat(embed): EmbedServer constructor + URL-param wire-up (Task 6)
- New EmbedServer class in src/embed/server.ts
- Detects embed mode from URL params or detectEmbedMode callback
- Applies chrome (menu/toolbox/etc visibility) and theme from URL params on init
- Attaches message listener only when embedMode is true
- Provides dispose() for cleanup + _allowedOriginsForTest getter for unit tests
- 4 passing tests covering constructor, listener attachment, chrome application, and theme application
* fix(embed): drop unused _server vars in embed-server tests (TS6133)
* feat(embed): EmbedServer call dispatch + Element-handle round-trip (Task 7)
* feat(embed): EmbedServer event emission + ready() helper (Task 8)
* feat(embed): EmbedServer dialog hook system (Task 9)
* fix(embed): cover src/embed in tsconfig + .js import extensions + lint cleanup (Tasks 1-9 plan defects)
* docs(plan): revise embed-api v1 plan with 6 defect fixes (.js imports, tsconfig include, lint patterns, exactOptional, unused vars, void-listener)
* feat(embed): EmbedServer control-message handlers (Task 10)
* feat(embed): wire EmbedServer into Editor.ts + svgCanvas event bridge (Task 11)
* feat(embed): SvgEditEmbed constructor + ready awaiter (Task 12)
* feat(embed): SvgEditEmbed Proxy + Promise correlation + queued-call flush (Task 13)
* feat(embed): SvgEditEmbed event subscription (on/off/once) (Task 14)
* feat(embed): SvgEditEmbed dialog handler API (Task 15)
* feat(embed): SvgEditEmbed convenience methods (setTheme/setChrome/setDialogTimeout) (Task 16)
* chore(build): emit dist/embed via tsc + package exports (Task 17)
* test(embed): e2e fixture + helpers (Task 18)
* test(embed): e2e init handshake (Task 19)
Three fixes required to get e2e passing:
1. embed-host.html: change default editorSrc from /src/editor/index.html to
/index.html so fixture resolves under vite preview (dist/editor as root)
2. scripts/copy-static.ts: copy tests/e2e/fixtures/embed-host.html and
dist/embed/ into dist/editor so vite preview can serve both
3. src/embed/server.ts: default allowedOrigins to [window.location.origin]
when no origins are configured, allowing same-origin host->editor calls
(getZoom round-trip was silently rejected with empty allowedOrigins)
* test(embed): e2e methods round-trip (Task 20)
* test(embed): e2e events suite (Task 21)
Also fix EditorStartup.ts: bind 'sourcechanged' alongside 'changed' so
loadFromString/loadFromURL triggers the embed change event (setSvgString
fires sourcechanged, not changed).
* test(embed): e2e element-handles round-trip (Task 22)
- Add getElem(id) method to svgCanvas that returns elements by ID
- Extend getId() to accept an optional Element parameter
- When called with an element, getId() returns its id or ELEMENT_NOT_FOUND if element is not in document
- Implement element handle serialization/deserialization round-trip tests
- Both tests pass on chromium and firefox (4 × 2 = 4 pass total)
* test(embed): e2e chrome control (Task 23)
* test(embed): e2e theme sync (Task 24)
* test(embed): e2e dialog hooks (Task 25)
* test(embed): e2e security model (Task 26)
* test(embed): e2e versioning (Task 27)
* docs(embed): EMBED_API.md + README quickstart (Task 28)
* docs(changelog): #4 embed API v1 (Task 29)
* fix(embed): chain to previous svgCanvas event handlers (Task 11 regression)
svgCanvas.bind() REPLACES the existing handler — it does NOT append.
The Task 11 wire-in clobbered the editor's own 'changed' + 'selected' bindings
from EditorStartup.ts:212-214 (this.svgCanvas.bind('selected', this.selectedChanged.bind(this)) /
this.svgCanvas.bind('changed', this.elementChanged.bind(this))). That broke
the editor's reactive UI updates and caused 8 standalone e2e regressions in
clipboard / group-transforms / text-tools.
Fix: capture the previous handler from bind()'s return value and chain to it
before scheduling the embed emit. Also fix the 'selected' handler's arg
signature (svgCanvas.call invokes handlers with (window, arg) — selection
array is args[1], not args[0]).
1 parent df69fae commit e35a407
37 files changed
Lines changed: 6105 additions & 6 deletions
File tree
- docs/superpowers/plans
- packages/svgcanvas
- scripts
- src
- editor
- embed
- tests
- e2e
- fixtures
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
10 | 25 | | |
11 | 26 | | |
12 | 27 | | |
| |||
0 commit comments