tldraw/packages
Steve Ruiz 910be6073f
[refactor] reduce dependencies on shape utils in editor (#1693)
We'd like to make the @tldraw/editor layer more independent of specific
shapes. Unfortunately there are many places where shape types and
certain shape behavior is deeply embedded in the Editor. This PR begins
to refactor out dependencies between the editor library and shape utils.

It does this in two ways:
- removing shape utils from the arguments of `isShapeOfType`, replacing
with a generic
- removing shape utils from the arguments of `getShapeUtil`, replacing
with a generic
- moving custom arrow info cache out of the util and into the editor
class
- changing the a tool's `shapeType` to be a string instead of a shape
util

We're here trading type safety based on inferred types—"hey editor, give
me your instance of this shape util class"—for knowledge at the point of
call—"hey editor, give me a shape util class of this type; and trust me
it'll be an instance this shape util class". Likewise for shapes.

### A note on style 

We haven't really established our conventions or style when it comes to
types, but I'm increasingly of the opinion that we should defer to the
point of call to narrow a type based on generics (keeping the types in
typescript land) rather than using arguments, which blur into JavaScript
land.

### Change Type

- [x] `major` — Breaking change

### Test Plan

- [x] Unit Tests

### Release Notes

- removes shape utils from the arguments of `isShapeOfType`, replacing
with a generic
- removes shape utils from the arguments of `getShapeUtil`, replacing
with a generic
- moves custom arrow info cache out of the util and into the editor
class
- changes the a tool's `shapeType` to be a string instead of a shape
util
2023-07-07 13:56:31 +00:00
..
assets Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
editor [refactor] reduce dependencies on shape utils in editor (#1693) 2023-07-07 13:56:31 +00:00
file-format [refactor] reduce dependencies on shape utils in editor (#1693) 2023-07-07 13:56:31 +00:00
indices Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
polyfills Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
primitives Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
state Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
store Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
tldraw Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
tlschema Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
ui [refactor] reduce dependencies on shape utils in editor (#1693) 2023-07-07 13:56:31 +00:00
utils Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
validate Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00