(html: string)
| 17 | // Typically called once in useEffect(() => { createEditorSession(html).then(setComp) }, []) |
| 18 | |
| 19 | export async function createEditorSession(html: string): Promise<Composition> { |
| 20 | const persist = createMemoryAdapter(); |
| 21 | |
| 22 | const comp = await openComposition(html, { persist }); |
| 23 | |
| 24 | // Persist failures surface as events, never fatal exceptions. |
| 25 | comp.on("persist:error", ({ error }) => { |
| 26 | console.error(`Auto-save failed: ${error.message}`); |
| 27 | // In a real app: show a toast notification |
| 28 | }); |
| 29 | |
| 30 | return comp; |
| 31 | } |
| 32 | |
| 33 | // ── useSyncExternalStore integration ───────────────────────────────────────── |
| 34 | // React 18+ pattern: |
nothing calls this directly
no test coverage detected