tldraw/packages/tlschema/src/index.ts

150 lines
4.8 KiB
TypeScript
Raw Normal View History

2023-04-25 11:01:25 +00:00
export {
type TLStore,
type TLStoreProps,
type TLStoreSchema,
type TLStoreSnapshot,
} from './TLStore'
export { assetIdValidator, createAssetValidator, type TLBaseAsset } from './assets/TLBaseAsset'
export { type TLBookmarkAsset } from './assets/TLBookmarkAsset'
export { type TLImageAsset } from './assets/TLImageAsset'
export { type TLVideoAsset } from './assets/TLVideoAsset'
export { createPresenceStateDerivation } from './createPresenceStateDerivation'
export { createTLSchema } from './createTLSchema'
2023-04-25 11:01:25 +00:00
export { CLIENT_FIXUP_SCRIPT, fixupRecord } from './fixup'
export { TL_COLOR_TYPES, colorTypeValidator, type TLColor } from './misc/TLColor'
export { type TLCursor, type TLCursorType } from './misc/TLCursor'
export { type TLHandle, type TLHandleType } from './misc/TLHandle'
export { scribbleValidator, type TLScribble } from './misc/TLScribble'
export { type Box2dModel, type Vec2dModel } from './misc/geometry-types'
export { idValidator } from './misc/id-validator'
2023-04-25 11:01:25 +00:00
export {
AssetRecordType,
assetMigrations,
assetValidator,
type TLAsset,
2023-04-25 11:01:25 +00:00
type TLAssetId,
type TLAssetPartial,
type TLAssetShape,
} from './records/TLAsset'
export { CameraRecordType, type TLCamera, type TLCameraId } from './records/TLCamera'
export { DocumentRecordType, TLDOCUMENT_ID, type TLDocument } from './records/TLDocument'
export {
InstanceRecordType,
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
TLINSTANCE_ID,
2023-04-25 11:01:25 +00:00
instanceTypeValidator,
type TLInstance,
2023-04-25 11:01:25 +00:00
type TLInstanceId,
type TLInstancePropsForNextShape,
} from './records/TLInstance'
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
export {
PageRecordType,
isPageId,
pageIdValidator,
type TLPage,
type TLPageId,
} from './records/TLPage'
export { InstancePageStateRecordType, type TLInstancePageState } from './records/TLPageState'
export { PointerRecordType, TLPOINTER_ID } from './records/TLPointer'
export { InstancePresenceRecordType, type TLInstancePresence } from './records/TLPresence'
export { type TLRecord } from './records/TLRecord'
2023-04-25 11:01:25 +00:00
export {
createShapeId,
isShape,
isShapeId,
rootShapeMigrations,
type TLDefaultShape,
2023-04-25 11:01:25 +00:00
type TLNullableShapeProps,
type TLParentId,
type TLShape,
type TLShapeId,
type TLShapePartial,
type TLShapeProp,
type TLShapeProps,
type TLUnknownShape,
} from './records/TLShape'
export {
type TLArrowShape,
type TLArrowShapeProps,
type TLArrowTerminal,
type TLArrowTerminalType,
} from './shapes/TLArrowShape'
export {
createShapeValidator,
parentIdValidator,
shapeIdValidator,
type TLBaseShape,
} from './shapes/TLBaseShape'
export { type TLBookmarkShape } from './shapes/TLBookmarkShape'
export { type TLDrawShape, type TLDrawShapeSegment } from './shapes/TLDrawShape'
2023-04-25 11:01:25 +00:00
export {
EMBED_DEFINITIONS,
embedShapePermissionDefaults,
2023-04-25 11:01:25 +00:00
type EmbedDefinition,
type TLEmbedShape,
type TLEmbedShapePermissions,
} from './shapes/TLEmbedShape'
export { type TLFrameShape } from './shapes/TLFrameShape'
export { type TLGeoShape } from './shapes/TLGeoShape'
export { type TLGroupShape } from './shapes/TLGroupShape'
export { type TLHighlightShape } from './shapes/TLHighlightShape'
export { type TLIconShape } from './shapes/TLIconShape'
export { type TLImageCrop, type TLImageShape, type TLImageShapeProps } from './shapes/TLImageShape'
export { type TLLineShape } from './shapes/TLLineShape'
export { type TLNoteShape } from './shapes/TLNoteShape'
export { type TLTextShape, type TLTextShapeProps } from './shapes/TLTextShape'
export { type TLVideoShape } from './shapes/TLVideoShape'
2023-04-25 11:01:25 +00:00
export {
TL_ALIGN_TYPES,
alignValidator,
type TLAlignStyle,
type TLAlignType,
} from './styles/TLAlignStyle'
export {
TL_ARROWHEAD_TYPES,
2023-04-25 11:01:25 +00:00
type TLArrowheadEndStyle,
type TLArrowheadStartStyle,
type TLArrowheadType,
} from './styles/TLArrowheadStyle'
export { TL_STYLE_TYPES, type TLStyleType } from './styles/TLBaseStyle'
export { colorValidator, type TLColorStyle, type TLColorType } from './styles/TLColorStyle'
export {
TL_DASH_TYPES,
dashValidator,
type TLDashStyle,
type TLDashType,
} from './styles/TLDashStyle'
export {
TL_FILL_TYPES,
fillValidator,
type TLFillStyle,
type TLFillType,
} from './styles/TLFillStyle'
export {
TL_FONT_TYPES,
fontValidator,
type TLFontStyle,
type TLFontType,
} from './styles/TLFontStyle'
export { TL_GEO_TYPES, geoValidator, type TLGeoStyle, type TLGeoType } from './styles/TLGeoStyle'
export { iconValidator, type TLIconStyle, type TLIconType } from './styles/TLIconStyle'
export { opacityValidator, type TLOpacityType } from './styles/TLOpacityStyle'
export {
TL_SIZE_TYPES,
sizeValidator,
type TLSizeStyle,
type TLSizeType,
} from './styles/TLSizeStyle'
export {
TL_SPLINE_TYPES,
splineValidator,
type TLSplineStyle,
type TLSplineType,
} from './styles/TLSplineStyle'
export { verticalAlignValidator, type TLVerticalAlignType } from './styles/TLVerticalAlignStyle'
export { type TLStyleCollections, type TLStyleItem, type TLStyleProps } from './styles/style-types'
export {
LANGUAGES,
getDefaultTranslationLocale,
type TLLanguage,
} from './translations/translations'