tldraw/packages/tlschema/src/index.ts

169 lines
4.9 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, type SchemaShapeInfo, type TLSchema } from './createTLSchema'
2023-04-25 11:01:25 +00:00
export { CLIENT_FIXUP_SCRIPT, fixupRecord } from './fixup'
export {
TL_CANVAS_UI_COLOR_TYPES,
canvasUiColorTypeValidator,
type TLCanvasUiColor,
} from './misc/TLColor'
export { type TLCursor, type TLCursorType } from './misc/TLCursor'
export { type TLHandle, type TLHandleType } from './misc/TLHandle'
export { opacityValidator, type TLOpacityType } from './misc/TLOpacity'
export { scribbleValidator, type TLScribble } from './misc/TLScribble'
export {
box2dModelValidator,
vec2dModelValidator,
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 { TLINSTANCE_ID, type TLInstance, type TLInstanceId } 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,
getShapePropKeysByStyle,
2023-04-25 11:01:25 +00:00
isShape,
isShapeId,
rootShapeMigrations,
type TLDefaultShape,
2023-04-25 11:01:25 +00:00
type TLParentId,
type TLShape,
type TLShapeId,
type TLShapePartial,
type TLShapeProp,
type TLShapeProps,
type TLUnknownShape,
} from './records/TLShape'
export {
ArrowShapeArrowheadEndStyle,
ArrowShapeArrowheadStartStyle,
arrowShapeMigrations,
arrowShapeProps,
2023-04-25 11:01:25 +00:00
type TLArrowShape,
type TLArrowShapeArrowheadStyle,
2023-04-25 11:01:25 +00:00
type TLArrowShapeProps,
type TLArrowShapeTerminal,
2023-04-25 11:01:25 +00:00
} from './shapes/TLArrowShape'
export {
createShapeValidator,
parentIdValidator,
shapeIdValidator,
type ShapeProps,
type TLBaseShape,
} from './shapes/TLBaseShape'
export {
bookmarkShapeMigrations,
bookmarkShapeProps,
type TLBookmarkShape,
} from './shapes/TLBookmarkShape'
export {
drawShapeMigrations,
drawShapeProps,
type TLDrawShape,
type TLDrawShapeSegment,
} from './shapes/TLDrawShape'
2023-04-25 11:01:25 +00:00
export {
EMBED_DEFINITIONS,
embedShapeMigrations,
embedShapePermissionDefaults,
embedShapeProps,
2023-04-25 11:01:25 +00:00
type EmbedDefinition,
type TLEmbedShape,
type TLEmbedShapePermissions,
} from './shapes/TLEmbedShape'
export { frameShapeMigrations, frameShapeProps, type TLFrameShape } from './shapes/TLFrameShape'
export {
GeoShapeGeoStyle,
geoShapeMigrations,
geoShapeProps,
type TLGeoShape,
} from './shapes/TLGeoShape'
export { groupShapeMigrations, groupShapeProps, type TLGroupShape } from './shapes/TLGroupShape'
export {
highlightShapeMigrations,
highlightShapeProps,
type TLHighlightShape,
} from './shapes/TLHighlightShape'
export {
imageShapeMigrations,
imageShapeProps,
type TLImageShape,
type TLImageShapeCrop,
type TLImageShapeProps,
} from './shapes/TLImageShape'
export {
LineShapeSplineStyle,
lineShapeMigrations,
lineShapeProps,
type TLLineShape,
} from './shapes/TLLineShape'
export { noteShapeMigrations, noteShapeProps, type TLNoteShape } from './shapes/TLNoteShape'
export {
textShapeMigrations,
textShapeProps,
type TLTextShape,
type TLTextShapeProps,
} from './shapes/TLTextShape'
export { videoShapeMigrations, videoShapeProps, type TLVideoShape } from './shapes/TLVideoShape'
export { EnumStyleProp, StyleProp } from './styles/StyleProp'
export {
DefaultColorStyle,
DefaultColorThemePalette,
getDefaultColorTheme,
type TLDefaultColorStyle,
type TLDefaultColorTheme,
type TLDefaultColorThemeColor,
} from './styles/TLColorStyle'
export { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'
export { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'
export {
DefaultFontFamilies,
DefaultFontStyle,
type TLDefaultFontStyle,
} from './styles/TLFontStyle'
export {
DefaultHorizontalAlignStyle,
type TLDefaultHorizontalAlignStyle,
} from './styles/TLHorizontalAlignStyle'
export { DefaultSizeStyle, type TLDefaultSizeStyle } from './styles/TLSizeStyle'
export {
DefaultVerticalAlignStyle,
type TLDefaultVerticalAlignStyle,
} from './styles/TLVerticalAlignStyle'
export {
LANGUAGES,
getDefaultTranslationLocale,
type TLLanguage,
} from './translations/translations'