tldraw/packages/editor
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
..
src [refactor] reduce dependencies on shape utils in editor (#1693) 2023-07-07 13:56:31 +00:00
api-extractor.json transfer-out: transfer out 2023-04-25 12:01:25 +01:00
api-report.md [refactor] reduce dependencies on shape utils in editor (#1693) 2023-07-07 13:56:31 +00:00
CHANGELOG.md Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
editor.css [improvement] add box sizing border box (#1674) 2023-06-29 14:23:18 +00:00
LICENSE transfer-out: transfer out 2023-04-25 12:01:25 +01:00
package.json Update CHANGELOG.md [skip ci] 2023-07-04 14:21:37 +00:00
README.md transfer-out: transfer out 2023-04-25 12:01:25 +01:00
setupTests.js Styles API follow-ups (#1636) 2023-06-24 13:46:04 +00:00
tsconfig.json Incorporate signia as @tldraw/state (#1620) 2023-06-20 13:31:26 +00:00

tldraw/tldraw

Benchmark

To run the benchmarks

yarn workspace @tldraw/tldraw benchmark

Or

yarn workspace @tldraw/tldraw benchmark "file_search_string"