tldraw/packages
Steve Ruiz 57bb341593
ShapeUtil refactor, Editor cleanup (#1611)
This PR improves the ergonomics of `ShapeUtil` classes.

### Cached methods

First, I've remove the cached methods (such as `bounds`) from the
`ShapeUtil` class and lifted this to the `Editor` class.

Previously, calling `ShapeUtil.getBounds` would return the un-cached
bounds of a shape, while calling `ShapeUtil.bounds` would return the
cached bounds of a shape. We also had `Editor.getBounds`, which would
call `ShapeUtil.bounds`. It was confusing. The cached methods like
`outline` were also marked with "please don't override", which suggested
the architecture was just wrong.

The only weirdness from this is that utils sometimes reach out to the
editor for cached versions of data rather than calling their own cached
methods. It's still an easier story to tell than what we had before.

### More defaults

We now have three and only three `abstract` methods for a `ShapeUtil`:
- `getDefaultProps` (renamed from `defaultProps`)
- `getBounds`,
- `component`
-  `indicator`

Previously, we also had `getCenter` as an abstract method, though this
was usually just the middle of the bounds anyway.

### Editing bounds

This PR removes the concept of editingBounds. The viewport will no
longer animate to editing shapes.

### Active area manager

This PR also removes the active area manager, which was not being used
in the way we expected it to be.

### Dpr manager

This PR removes the dpr manager and uses a hook instead to update it
from React. This is one less runtime browser dependency in the app, one
less thing to document.

### Moving things around

This PR also continues to try to organize related methods and properties
in the editor.

### Change Type

- [x] `major` — Breaking change

### Release Notes

- [editor] renames `defaultProps` to `getDefaultProps`
- [editor] removes `outline`, `outlineSegments`, `handles`, `bounds`
- [editor] renames `renderBackground` to `backgroundComponent`
2023-06-19 14:01:18 +00:00
..
assets Revert "Update dependencies (#1613)" (#1617) 2023-06-19 09:49:44 +00:00
editor ShapeUtil refactor, Editor cleanup (#1611) 2023-06-19 14:01:18 +00:00
file-format ShapeUtil refactor, Editor cleanup (#1611) 2023-06-19 14:01:18 +00:00
indices update lazyrepo 2023-06-05 18:32:32 +01:00
polyfills Revert "Update dependencies (#1613)" (#1617) 2023-06-19 09:49:44 +00:00
primitives [refactor] snapping (#1589) 2023-06-15 14:36:46 +00:00
store update lazyrepo 2023-06-05 18:32:32 +01:00
tldraw ShapeUtil refactor, Editor cleanup (#1611) 2023-06-19 14:01:18 +00:00
tlschema ShapeUtil refactor, Editor cleanup (#1611) 2023-06-19 14:01:18 +00:00
ui Revert "Update dependencies (#1613)" (#1617) 2023-06-19 09:49:44 +00:00
utils Styles API (#1580) 2023-06-16 10:33:47 +00:00
validate Styles API (#1580) 2023-06-16 10:33:47 +00:00