Skip to content

Core seam for server-side and export embedders #37

Open

Description

@calumk

Today

Everything renderable goes through drawShape, but its browser dependencies are hardcoded: the global Path2D class, OffscreenCanvas/document canvases for measurement and hatch tiles, and the browser Image loader with its warming cache. Any server-side renderer (see #36) must fork or monkey-patch globals to reuse the engine. The paint order (Editor.shapesSorted()) and several geometry/layout helpers are likewise unreachable behind the exports map.

Proposal

A small, dependency-free, behavior-preserving seam:

  • setShapePlatform({ Path2D, measureCtx, tileCanvas }) — explicit backend injection (never global monkey-patching; the browser never calls it).
  • drawShape accepts per-render opts.images (pre-decoded bitmaps, bypassing the loader), opts.patternCache and opts.Path2D — no cross-request shared state.
  • Export the shared paint order as sortShapesForRender() (used by Editor.shapesSorted(), identical behavior), plus the textLayout / noteLayout / boundsUnion helpers embedders need.
  • Full type declarations. No new dependencies, no DOM touched, full suite green.

Follow-up to #33 territory (font stacks) but independent of it; together they are everything an out-of-tree headless renderer imports from core.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions