tldraw/apps/examples/src
David Sheldrick f15a8797f0
Independent instance state persistence (#1493)
This PR 

- Removes UserDocumentRecordType
  - moving isSnapMode to user preferences
  - moving isGridMode and isPenMode to InstanceRecordType
  - deleting the other properties which are no longer needed.
 
- Creates a separate pipeline for persisting instance state.
  
Previously the instance state records were stored alongside the document
state records, and in order to load the state for a particular instance
(in our case, a particular tab) you needed to pass the 'instanceId'
prop. This prop ended up totally pervading the public API and people ran
into all kinds of issues with it, e.g. using the same instance id in
multiple editor instances.

There was also an issue whereby it was hard for us to clean up old
instance state so the idb table ended up bloating over time.
  
This PR makes it so that rather than passing an instanceId, you load the
instance state yourself while creating the store. It provides tools to
make that easy.

- Undoes the assumption that we might have more than one instance's
state in the store.

- Like `document`, `instance` now has a singleton id
`instance:instance`.
- Page state ids and camera ids are no longer random, but rather derive
from the page they belong to. This is like having a foreign primary key
in SQL databases. It's something i'd love to support fully as part of
the RecordType/Store api.

Tests to do

- [x] Test Migrations
- [x] Test Store.listen filtering
- [x] Make type sets in Store public and readonly
- [x] Test RecordType.createId
- [x] Test Instance state snapshot loading/exporting
- [x] Manual test File I/O
- [x] Manual test Vscode extension with multiple tabs
- [x] Audit usages of store.query
- [x] Audit usages of changed types: InstanceRecordType, 'instance',
InstancePageStateRecordType, 'instance_page_state', 'user_document',
'camera', CameraRecordType, InstancePresenceRecordType,
'instance_presence'
- [x] Test user preferences
- [x] Manual test isSnapMode and isGridMode and isPenMode
- [ ] Test indexedDb functions
- [x] Add instanceId stuff back


### Change Type

- [x] `major` — Breaking Change


### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Add a brief release note for your PR here.
2023-06-05 14:11:07 +00:00
..
1-basic Independent instance state persistence (#1493) 2023-06-05 14:11:07 +00:00
2-api tlschema cleanup (#1509) 2023-06-03 20:46:53 +00:00
3-custom-config Renaming types, shape utils, tools (#1513) 2023-06-04 10:38:53 +00:00
4-custom-ui rename app to editor (#1503) 2023-06-02 15:21:45 +00:00
5-exploded [refactor] User-facing APIs (#1478) 2023-06-01 15:47:34 +00:00
6-scroll remove svg layer, html all the things, rs to tl (#1227) 2023-05-05 14:14:42 +00:00
7-multiple [refactor] User-facing APIs (#1478) 2023-06-01 15:47:34 +00:00
8-error-boundary Renaming types, shape utils, tools (#1513) 2023-06-04 10:38:53 +00:00
9-hide-ui remove svg layer, html all the things, rs to tl (#1227) 2023-05-05 14:14:42 +00:00
10-custom-components remove svg layer, html all the things, rs to tl (#1227) 2023-05-05 14:14:42 +00:00
11-user-presence Independent instance state persistence (#1493) 2023-06-05 14:11:07 +00:00
12-ui-events [improvement] rename onEvent to onUiEvent (#1358) 2023-05-12 09:05:56 +00:00
13-store-events rename app to editor (#1503) 2023-06-02 15:21:45 +00:00
14-persistence Independent instance state persistence (#1493) 2023-06-05 14:11:07 +00:00
15-custom-zones Add support for project names (#1340) 2023-06-01 18:46:26 +00:00
end-to-end rename app to editor (#1503) 2023-06-02 15:21:45 +00:00
icons New vite-based examples app (#1226) 2023-05-05 13:10:36 +00:00
index.html New vite-based examples app (#1226) 2023-05-05 13:10:36 +00:00
index.tsx Add support for project names (#1340) 2023-06-01 18:46:26 +00:00
styles.css New vite-based examples app (#1226) 2023-05-05 13:10:36 +00:00