`flattenNodesToVectorProps` and `outlineStrokeNodesToVectorProps` are built and typed but not exported, so Flatten and Outline stroke cannot be implemented by an embedder
editor.flattenSelected(), editor.outlineStrokeSelected() and editor.outlineTextSelected()
all delegate their geometry to two functions in src/canvas/flatten.ts:
// 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 fromdist/canvas/index.d.ts); - not on the package barrel (absent from
dist/index.d.ts); - and the
exportsmap 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" packageWhy 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:
- Re-export both from
./canvas— one line insrc/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. - Or add
"./canvas/flatten"to theexportsmap. - Or split each editor method into a
planX()that returns props and anapplyX()that writes — the most useful shape for embedders generally, and it would closeU17-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.
Source: open-pencil/open-pencil