`flattenNodesToVectorProps` and `outlineStrokeNodesToVectorProps` are built and typed but not exported, so Flatten and Outline stroke cannot be implemented by an embedder

Author: royvillasanaCreated Sep 26, 2026Updated Sep 26, 2026

editor.flattenSelected(), editor.outlineStrokeSelected() and editor.outlineTextSelected() all delegate their geometry to two functions in src/canvas/flatten.ts:

javascript
// dist/editor/structure/flatten.js
import { flattenNodesToVectorProps, outlineStrokeNodesToVectorProps } from "../../canvas/flatten.js";

Both are compiled AND typed in the published package — dist/canvas/flatten.js and dist/canvas/flatten.d.ts both exist — but neither is reachable from outside it:

  • not re-exported from @open-pencil/core/canvas (absent from dist/canvas/index.d.ts);
  • not on the package barrel (absent from dist/index.d.ts);
  • and the exports map has 29 explicit subpaths and no wildcard, so every deep specifier is refused:
await import("@open-pencil/core/canvas/flatten");
// Missing "./canvas/flatten" specifier in "@open-pencil/core" package

await import("@open-pencil/core/dist/canvas/flatten.js");
// Missing "./dist/canvas/flatten.js" specifier in "@open-pencil/core" package

Why the editor methods are not a way round it. They mutate ctx.graph directly and push their own undo entries. An embedder that routes every document write through its own mutation layer (for guards, journalling and a single undo stack) cannot call them without losing all of it — that is the general shape of embedding this engine, not a VortSpec peculiarity.

So the only ways to offer Flatten or Outline stroke today are to reimplement CanvasKit path flattening, or to let a raw write bypass the embedder's own invariants. Both are worse than the feature being absent.

Suggested fix, in preference order:

  1. Re-export both from ./canvas — one line in src/canvas/index.ts; nothing else changes. Their signatures are already (renderer, graph, nodes) => VectorProps | null, pure with respect to the document, which is exactly the shape an embedder needs.
  2. Or add "./canvas/flatten" to the exports map.
  3. Or split each editor method into a planX() that returns props and an applyX() that writes — the most useful shape for embedders generally, and it would close U17-style questions for the other structure actions too.

Measured on 0.14.0 (commit a9bf1b3). Reported from an embedding project that routes every document write through its own mutation layer; happy to test a patch.