tldraw/apps
Mime Čuvalo 735161c4a8
assets: store in indexedDB, not as base64 (#3836)
this is take #2 of this PR https://github.com/tldraw/tldraw/pull/3745

As I look at LOD holistically and whether we have multiple sources when
working locally, I learned that our system used base64 encoding of
assets directly. Issue https://github.com/tldraw/tldraw/issues/3728

<img width="1350" alt="assetstore"
src="https://github.com/tldraw/tldraw/assets/469604/e7b41e29-6656-4d9b-b462-72d43b98f3f7">


The motivations and benefits are:
- store size: not having a huge base64 blobs injected in room data
- perf on loading snapshot: this helps with loading the room data more
quickly
- multiple sources: furthermore, if we do decide to have multiple
sources locally (for each asset), then we won't get a multiplicative
effect of even larger JSON blobs that have lots of base64 data in them
- encoding/decoding perf: this also saves the (slow) step of having to
base64 encode/decode our assets, we can just strictly with work with
blobs.


Todo:
- [x] decodes video and images
- [x] make sure it syncs to other tabs
- [x] make sure it syncs to other multiplayer room
- [x] fix tests


### Change Type

<!--  Please select a 'Scope' label ️ -->

- [x] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [x] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know


### Test Plan

1. Test the shit out of uploading/downloading video/image assets,
locally+multiplayer.

- [ ] Need to fix current tests and write new ones

### Release Notes

- Assets: store as reference to blob in indexedDB instead of storing
directly as base64 in the snapshot.
2024-06-14 10:23:52 +00:00
..
apps-script google meet: add hardware whiteboard integration (#3765) 2024-05-20 14:52:05 +00:00
docs Generated docs cleanup (#3935) 2024-06-13 16:04:12 +00:00
dotcom assets: store in indexedDB, not as base64 (#3836) 2024-06-14 10:23:52 +00:00
dotcom-asset-upload cloudflare: dont cache no-cache headers (#3849) 2024-06-03 08:32:40 +00:00
dotcom-bookmark-extractor bookmarks: resolve relative urls (#3914) 2024-06-11 11:04:29 +00:00
dotcom-worker Force interface instead of type for better docs (#3815) 2024-05-22 15:55:49 +00:00
examples assets: make option to transform urls dynamically / LOD (#3827) 2024-06-11 14:17:09 +00:00
health-worker Force interface instead of type for better docs (#3815) 2024-05-22 15:55:49 +00:00
huppy Force interface instead of type for better docs (#3815) 2024-05-22 15:55:49 +00:00
vscode assets: store in indexedDB, not as base64 (#3836) 2024-06-14 10:23:52 +00:00