Force interface instead of type for better docs (#3815)

Typescript's type aliases (`type X = thing`) can refer to basically
anything, which makes it hard to write an automatic document formatter
for them. Interfaces on the other hand are only object, so they play
much nicer with docs. Currently, object-flavoured type aliases don't
really get expanded at all on our docs site, which means we have a bunch
of docs content that's not shown on the site.

This diff introduces a lint rule that forces `interface X {foo: bar}`s
instead of `type X = {foo: bar}` where possible, as it results in a much
better documentation experience:

Before:
<img width="437" alt="Screenshot 2024-05-22 at 15 24 13"
src="https://github.com/tldraw/tldraw/assets/1489520/32606fd1-6832-4a1e-aa5f-f0534d160c92">

After:
<img width="431" alt="Screenshot 2024-05-22 at 15 33 01"
src="https://github.com/tldraw/tldraw/assets/1489520/4e0d59ee-c38e-4056-b9fd-6a7f15d28f0f">


### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `docs` — Changes to the documentation, examples, or templates.
- [x] `improvement` — Improving existing features
This commit is contained in:
alex 2024-05-22 16:55:49 +01:00 committed by GitHub
parent abc8521a71
commit f9ed1bf2c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
131 changed files with 731 additions and 434 deletions

View file

@ -70,6 +70,7 @@ module.exports = {
'error', 'error',
{ name: 'structuredClone', message: 'Use structuredClone from @tldraw/util instead' }, { name: 'structuredClone', message: 'Use structuredClone from @tldraw/util instead' },
], ],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
}, },
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { parserOptions: {

View file

@ -1,7 +1,7 @@
import { Article } from '@/types/content-types' import { Article } from '@/types/content-types'
import { Icon } from './Icon' import { Icon } from './Icon'
type ArticleDetailsProps = { interface ArticleDetailsProps {
article: Article article: Article
} }

View file

@ -2,7 +2,7 @@ import { ArticleLinks } from '@/types/content-types'
import Link from 'next/link' import Link from 'next/link'
import { Icon } from './Icon' import { Icon } from './Icon'
type ArticleNavLinksProps = { interface ArticleNavLinksProps {
links: ArticleLinks links: ArticleLinks
} }

View file

@ -13,13 +13,13 @@ import './Autocomplete.css'
import { Icon } from './Icon' import { Icon } from './Icon'
import { Spinner } from './Spinner' import { Spinner } from './Spinner'
export type DropdownOption = { export interface DropdownOption {
label: string label: string
value: string value: string
group?: string group?: string
} }
type AutocompleteProps = { interface AutocompleteProps {
customUI?: React.ReactNode customUI?: React.ReactNode
groups?: string[] groups?: string[]
groupsToIcon?: { groupsToIcon?: {

View file

@ -24,7 +24,10 @@ import {
} from '@microsoft/api-extractor-model' } from '@microsoft/api-extractor-model'
import { MarkdownWriter, formatWithPrettier, getPath, getSlug } from '../utils' import { MarkdownWriter, formatWithPrettier, getPath, getSlug } from '../utils'
type Result = { markdown: string; keywords: string[] } interface Result {
markdown: string
keywords: string[]
}
const REPO_URL = 'https://github.com/tldraw/tldraw/blob/main/' const REPO_URL = 'https://github.com/tldraw/tldraw/blob/main/'

View file

@ -1,4 +1,4 @@
export type InputCategory = { export interface InputCategory {
id: string id: string
title: string title: string
description: string description: string
@ -6,7 +6,7 @@ export type InputCategory = {
hero: string | null hero: string | null
} }
export type InputSection = { export interface InputSection {
id: string id: string
title: string title: string
description: string description: string
@ -15,7 +15,7 @@ export type InputSection = {
sidebar_behavior: 'show-links' | 'show-title' | 'hidden' | 'reference' sidebar_behavior: 'show-links' | 'show-title' | 'hidden' | 'reference'
} }
export type InputGroup = { export interface InputGroup {
id: string id: string
} }
@ -150,7 +150,7 @@ export type ArticleLink = Pick<
'id' | 'title' | 'description' | 'categoryId' | 'sectionId' | 'path' 'id' | 'title' | 'description' | 'categoryId' | 'sectionId' | 'path'
> >
export type ArticleLinks = { export interface ArticleLinks {
prev: ArticleLink | null prev: ArticleLink | null
next: ArticleLink | null next: ArticleLink | null
} }
@ -184,7 +184,7 @@ export type SidebarContentLink =
| SidebarContentCategoryLink | SidebarContentCategoryLink
| SidebarContentArticleLink | SidebarContentArticleLink
export type SidebarContentList = { export interface SidebarContentList {
sectionId: string | null sectionId: string | null
categoryId: string | null categoryId: string | null
articleId: string | null articleId: string | null
@ -197,4 +197,7 @@ export type SidebarContentList = {
/** A table keyed by slug of articles. */ /** A table keyed by slug of articles. */
export type Articles = Record<string, Article> export type Articles = Record<string, Article>
export type GeneratedContent = { sections: Section[]; articles: Articles } export interface GeneratedContent {
sections: Section[]
articles: Articles
}

View file

@ -1,4 +1,4 @@
export type SearchResult = { export interface SearchResult {
type: 'article' | 'category' | 'section' | 'heading' type: 'article' | 'category' | 'section' | 'heading'
id: string id: string
subtitle: string subtitle: string

View file

@ -1,6 +1,6 @@
import { exhaustiveSwitchError, hasOwnProperty } from '@tldraw/utils' import { exhaustiveSwitchError, hasOwnProperty } from '@tldraw/utils'
type AlarmOpts = { interface AlarmOpts {
overwrite: 'always' | 'if-sooner' overwrite: 'always' | 'if-sooner'
} }

View file

@ -35,7 +35,7 @@ const MAX_CONNECTIONS = 50
// increment this any time you make a change to this type // increment this any time you make a change to this type
const CURRENT_DOCUMENT_INFO_VERSION = 0 const CURRENT_DOCUMENT_INFO_VERSION = 0
type DocumentInfo = { interface DocumentInfo {
version: number version: number
slug: string slug: string
} }

View file

@ -6,7 +6,7 @@ import { getR2KeyForSnapshot } from '../r2'
import { Environment } from '../types' import { Environment } from '../types'
import { validateSnapshot } from '../utils/validateSnapshot' import { validateSnapshot } from '../utils/validateSnapshot'
export type R2Snapshot = { export interface R2Snapshot {
parent_slug: CreateSnapshotRequestBody['parent_slug'] parent_slug: CreateSnapshotRequestBody['parent_slug']
drawing: RoomSnapshot drawing: RoomSnapshot
} }

View file

@ -1,7 +1,7 @@
// https://developers.cloudflare.com/analytics/analytics-engine/ // https://developers.cloudflare.com/analytics/analytics-engine/
// This type isn't available in @cloudflare/workers-types yet // This type isn't available in @cloudflare/workers-types yet
export type Analytics = { export interface Analytics {
writeDataPoint(data: { writeDataPoint(data: {
blobs?: string[] blobs?: string[]
doubles?: number[] doubles?: number[]

View file

@ -3,7 +3,7 @@ import { TLRecord } from '@tldraw/tlschema'
import { schema } from '@tldraw/tlsync' import { schema } from '@tldraw/tlsync'
import { Result, objectMapEntries } from '@tldraw/utils' import { Result, objectMapEntries } from '@tldraw/utils'
type SnapshotRequestBody = { interface SnapshotRequestBody {
schema: SerializedSchema schema: SerializedSchema
snapshot: SerializedStore<TLRecord> snapshot: SerializedStore<TLRecord>
} }

View file

@ -32,7 +32,7 @@ import { FORK_PROJECT_ACTION } from '../../utils/sharing'
import { SAVE_FILE_COPY_ACTION } from '../../utils/useFileSystem' import { SAVE_FILE_COPY_ACTION } from '../../utils/useFileSystem'
import { getShareUrl } from '../ShareMenu' import { getShareUrl } from '../ShareMenu'
type NameState = { interface NameState {
readonly name: string | null readonly name: string | null
readonly isEditing: boolean readonly isEditing: boolean
} }

View file

@ -28,7 +28,7 @@ const SHARE_CURRENT_STATE = {
} as const } as const
type ShareCurrentState = (typeof SHARE_CURRENT_STATE)[keyof typeof SHARE_CURRENT_STATE] type ShareCurrentState = (typeof SHARE_CURRENT_STATE)[keyof typeof SHARE_CURRENT_STATE]
type ShareState = { interface ShareState {
state: ShareCurrentState state: ShareCurrentState
qrCodeDataUrl: string qrCodeDataUrl: string
url: string url: string

View file

@ -63,7 +63,7 @@ const components: TLComponents = {
}, },
} }
type SnapshotEditorProps = { interface SnapshotEditorProps {
schema: SerializedSchema schema: SerializedSchema
records: TLRecord[] records: TLRecord[]
} }

View file

@ -10,7 +10,7 @@ export class RemoteSyncError extends Error {
} }
/** @public */ /** @public */
export type UseSyncClientConfig = { export interface UseSyncClientConfig {
uri: string uri: string
roomId?: string roomId?: string
userPreferences?: Signal<TLUserPreferences> userPreferences?: Signal<TLUserPreferences>

View file

@ -8,7 +8,7 @@ import { PageMenu } from './menus/PageMenu'
import { StylePanel } from './menus/StylePanel' import { StylePanel } from './menus/StylePanel'
import { Toolbar } from './menus/Toolbar' import { Toolbar } from './menus/Toolbar'
type Fixtures = { interface Fixtures {
toolbar: Toolbar toolbar: Toolbar
stylePanel: StylePanel stylePanel: StylePanel
actionsMenu: ActionsMenu actionsMenu: ActionsMenu

View file

@ -1,6 +1,6 @@
import { ComponentType } from 'react' import { ComponentType } from 'react'
export type Example = { export interface Example {
title: string title: string
description: string description: string
details: string details: string

View file

@ -2,14 +2,14 @@ import { useState } from 'react'
import { AssetRecordType, Box, TLAssetId, TLShapeId, createShapeId } from 'tldraw' import { AssetRecordType, Box, TLAssetId, TLShapeId, createShapeId } from 'tldraw'
import tldrawPdf from './assets/tldraw.pdf' import tldrawPdf from './assets/tldraw.pdf'
export type PdfPage = { export interface PdfPage {
src: string src: string
bounds: Box bounds: Box
assetId: TLAssetId assetId: TLAssetId
shapeId: TLShapeId shapeId: TLShapeId
} }
export type Pdf = { export interface Pdf {
name: string name: string
pages: PdfPage[] pages: PdfPage[]
source: string | ArrayBuffer source: string | ArrayBuffer

View file

@ -4,7 +4,7 @@ import { atom, computed, structuredClone, uniqueId } from 'tldraw'
export const SLIDE_SIZE = { x: 0, y: 0, w: 1600, h: 900 } export const SLIDE_SIZE = { x: 0, y: 0, w: 1600, h: 900 }
export const SLIDE_MARGIN = 100 export const SLIDE_MARGIN = 100
type Slide = { interface Slide {
id: string id: string
index: number index: number
name: string name: string

View file

@ -8,7 +8,7 @@ const RED = 14692657
const ORANGE = 16213767 const ORANGE = 16213767
// docs: https://birdie0.github.io/discord-webhooks-guide/index.html // docs: https://birdie0.github.io/discord-webhooks-guide/index.html
export type DiscordPayload = { export interface DiscordPayload {
username: string username: string
content: string content: string
embeds: APIEmbed[] embeds: APIEmbed[]

View file

@ -3,7 +3,7 @@ import { GetServerSideProps } from 'next'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { getAppOctokit } from '../src/octokit' import { getAppOctokit } from '../src/octokit'
type Props = { interface Props {
deliveries: { deliveries: {
id: number id: number
guid: string guid: string
@ -39,7 +39,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
return { props: { deliveries: deliveries.data, cursor } } return { props: { deliveries: deliveries.data, cursor } }
} }
type SelectedDelivery = { interface SelectedDelivery {
id: number id: number
data?: unknown data?: unknown
} }

View file

@ -1,6 +1,6 @@
import { App, Octokit } from 'octokit' import { App, Octokit } from 'octokit'
export type Ctx = { export interface Ctx {
app: App app: App
octokit: Octokit octokit: Octokit
installationToken: string installationToken: string

View file

@ -14,13 +14,13 @@ const CLA_SIGNATURES_BRANCH = 'cla-signees'
const pullRequestActionsToCheck = ['opened', 'synchronize', 'reopened', 'edited'] const pullRequestActionsToCheck = ['opened', 'synchronize', 'reopened', 'edited']
type Signing = { interface Signing {
githubId: number githubId: number
signedAt: string signedAt: string
signedVersion: 1 signedVersion: 1
signingComment: string signingComment: string
} }
type SigneeInfo = { interface SigneeInfo {
unsigned: Set<string> unsigned: Set<string>
signees: Map<string, { signing: Signing; fileSha: string }> signees: Map<string, { signing: Signing; fileSha: string }>
total: number total: number

View file

@ -96,7 +96,7 @@ export const TldrawWrapper = () => {
) )
} }
export type TLDrawInnerProps = { export interface TLDrawInnerProps {
assetSrc: string assetSrc: string
fileContents: string fileContents: string
uri: string uri: string

View file

@ -2,7 +2,7 @@ import { uniqueId } from 'tldraw'
import type { VscodeMessagePairs } from '../../../messages' import type { VscodeMessagePairs } from '../../../messages'
import { vscode } from './vscode' import { vscode } from './vscode'
type SimpleRpcOpts = { interface SimpleRpcOpts {
timeout: number timeout: number
} }
class SimpleRpcError extends Error { class SimpleRpcError extends Error {

View file

@ -1,16 +1,16 @@
import { SerializedSchema, SerializedStore, TLRecord } from 'tldraw' import { SerializedSchema, SerializedStore, TLRecord } from 'tldraw'
export type Snapshot = { export interface Snapshot {
schema: SerializedSchema schema: SerializedSchema
snapshot: SerializedStore<TLRecord> snapshot: SerializedStore<TLRecord>
} }
export type CreateRoomRequestBody = { export interface CreateRoomRequestBody {
origin: string origin: string
snapshot: Snapshot snapshot: Snapshot
} }
export type CreateSnapshotRequestBody = { export interface CreateSnapshotRequestBody {
schema: SerializedSchema schema: SerializedSchema
snapshot: SerializedStore<TLRecord> snapshot: SerializedStore<TLRecord>
parent_slug?: string | undefined parent_slug?: string | undefined
@ -26,4 +26,7 @@ export type CreateSnapshotResponseBody =
message: string message: string
} }
export type GetReadonlySlugResponseBody = { slug: string; isLegacy: boolean } export interface GetReadonlySlugResponseBody {
slug: string
isLegacy: boolean
}

View file

@ -1131,15 +1131,19 @@ export function extractSessionStateFromLegacySnapshot(store: Record<string, Unkn
export const featureFlags: Record<string, DebugFlag<boolean>>; export const featureFlags: Record<string, DebugFlag<boolean>>;
// @public (undocumented) // @public (undocumented)
export type GapsSnapIndicator = { export interface GapsSnapIndicator {
// (undocumented)
direction: 'horizontal' | 'vertical'; direction: 'horizontal' | 'vertical';
// (undocumented)
gaps: Array<{ gaps: Array<{
endEdge: [VecLike, VecLike]; endEdge: [VecLike, VecLike];
startEdge: [VecLike, VecLike]; startEdge: [VecLike, VecLike];
}>; }>;
// (undocumented)
id: string; id: string;
// (undocumented)
type: 'gaps'; type: 'gaps';
}; }
// @public (undocumented) // @public (undocumented)
export abstract class Geometry2d { export abstract class Geometry2d {
@ -1593,11 +1597,14 @@ export class Point2d extends Geometry2d {
export function pointInPolygon(A: VecLike, points: VecLike[]): boolean; export function pointInPolygon(A: VecLike, points: VecLike[]): boolean;
// @public (undocumented) // @public (undocumented)
export type PointsSnapIndicator = { export interface PointsSnapIndicator {
// (undocumented)
id: string; id: string;
// (undocumented)
points: VecLike[]; points: VecLike[];
// (undocumented)
type: 'points'; type: 'points';
}; }
// @public (undocumented) // @public (undocumented)
export class Polygon2d extends Polyline2d { export class Polygon2d extends Polyline2d {
@ -2057,12 +2064,29 @@ export interface TLBindingUtilConstructor<T extends TLUnknownBinding, U extends
} }
// @public (undocumented) // @public (undocumented)
export type TLBrushProps = { export interface TLBrushProps {
// (undocumented)
brush: BoxModel; brush: BoxModel;
// (undocumented)
className?: string; className?: string;
// (undocumented)
color?: string; color?: string;
// (undocumented)
opacity?: number; opacity?: number;
}
// @public (undocumented)
export interface TLCameraConstraints {
baseZoom: 'default' | 'fit-max-100' | 'fit-max' | 'fit-min-100' | 'fit-min' | 'fit-x-100' | 'fit-x' | 'fit-y-100' | 'fit-y';
behavior: 'contain' | 'fixed' | 'free' | 'inside' | 'outside' | {
x: 'contain' | 'fixed' | 'free' | 'inside' | 'outside';
y: 'contain' | 'fixed' | 'free' | 'inside' | 'outside';
}; };
bounds: BoxModel;
initialZoom: 'default' | 'fit-max-100' | 'fit-max' | 'fit-min-100' | 'fit-min' | 'fit-x-100' | 'fit-x' | 'fit-y-100' | 'fit-y';
origin: VecLike;
padding: VecLike;
}
// @public (undocumented) // @public (undocumented)
export type TLCameraMoveOptions = Partial<{ export type TLCameraMoveOptions = Partial<{
@ -2076,33 +2100,25 @@ export type TLCameraMoveOptions = Partial<{
}>; }>;
// @public (undocumented) // @public (undocumented)
export type TLCameraOptions = { export interface TLCameraOptions {
wheelBehavior: 'none' | 'pan' | 'zoom'; constraints?: TLCameraConstraints;
constraints?: { isLocked: boolean;
behavior: 'contain' | 'fixed' | 'free' | 'inside' | 'outside' | {
x: 'contain' | 'fixed' | 'free' | 'inside' | 'outside';
y: 'contain' | 'fixed' | 'free' | 'inside' | 'outside';
};
bounds: BoxModel;
baseZoom: 'default' | 'fit-max-100' | 'fit-max' | 'fit-min-100' | 'fit-min' | 'fit-x-100' | 'fit-x' | 'fit-y-100' | 'fit-y';
initialZoom: 'default' | 'fit-max-100' | 'fit-max' | 'fit-min-100' | 'fit-min' | 'fit-x-100' | 'fit-x' | 'fit-y-100' | 'fit-y';
origin: VecLike;
padding: VecLike;
};
panSpeed: number; panSpeed: number;
wheelBehavior: 'none' | 'pan' | 'zoom';
zoomSpeed: number; zoomSpeed: number;
zoomSteps: number[]; zoomSteps: number[];
isLocked: boolean; }
};
// @public (undocumented) // @public (undocumented)
export type TLCancelEvent = (info: TLCancelEventInfo) => void; export type TLCancelEvent = (info: TLCancelEventInfo) => void;
// @public (undocumented) // @public (undocumented)
export type TLCancelEventInfo = { export interface TLCancelEventInfo {
// (undocumented)
name: 'cancel'; name: 'cancel';
// (undocumented)
type: 'misc'; type: 'misc';
}; }
// @public (undocumented) // @public (undocumented)
export type TLClickEvent = (info: TLClickEventInfo) => void; export type TLClickEvent = (info: TLClickEventInfo) => void;
@ -2121,23 +2137,31 @@ export type TLClickEventInfo = TLBaseEventInfo & {
export type TLCLickEventName = 'double_click' | 'quadruple_click' | 'triple_click'; export type TLCLickEventName = 'double_click' | 'quadruple_click' | 'triple_click';
// @public (undocumented) // @public (undocumented)
export type TLCollaboratorHintProps = { export interface TLCollaboratorHintProps {
// (undocumented)
className?: string; className?: string;
// (undocumented)
color: string; color: string;
// (undocumented)
opacity?: number; opacity?: number;
// (undocumented)
point: VecModel; point: VecModel;
// (undocumented)
viewport: Box; viewport: Box;
// (undocumented)
zoom: number; zoom: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLCompleteEvent = (info: TLCompleteEventInfo) => void; export type TLCompleteEvent = (info: TLCompleteEventInfo) => void;
// @public (undocumented) // @public (undocumented)
export type TLCompleteEventInfo = { export interface TLCompleteEventInfo {
// (undocumented)
name: 'complete'; name: 'complete';
// (undocumented)
type: 'misc'; type: 'misc';
}; }
// @public (undocumented) // @public (undocumented)
export interface TLContent { export interface TLContent {
@ -2154,14 +2178,20 @@ export interface TLContent {
} }
// @public (undocumented) // @public (undocumented)
export type TLCursorProps = { export interface TLCursorProps {
// (undocumented)
chatMessage: string; chatMessage: string;
// (undocumented)
className?: string; className?: string;
// (undocumented)
color?: string; color?: string;
// (undocumented)
name: null | string; name: null | string;
// (undocumented)
point: null | VecModel; point: null | VecModel;
// (undocumented)
zoom: number; zoom: number;
}; }
// @public (undocumented) // @public (undocumented)
export const TldrawEditor: React_2.NamedExoticComponent<TldrawEditorProps>; export const TldrawEditor: React_2.NamedExoticComponent<TldrawEditorProps>;
@ -2361,35 +2391,47 @@ export type TLExternalContentSource = {
}; };
// @public (undocumented) // @public (undocumented)
export type TLGridProps = { export interface TLGridProps {
// (undocumented)
size: number; size: number;
// (undocumented)
x: number; x: number;
// (undocumented)
y: number; y: number;
// (undocumented)
z: number; z: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLHandleProps = { export interface TLHandleProps {
// (undocumented)
className?: string; className?: string;
// (undocumented)
handle: TLHandle; handle: TLHandle;
// (undocumented)
isCoarse: boolean; isCoarse: boolean;
// (undocumented)
shapeId: TLShapeId; shapeId: TLShapeId;
// (undocumented)
zoom: number; zoom: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLHandlesProps = { export interface TLHandlesProps {
// (undocumented)
children: ReactNode; children: ReactNode;
}; }
// @public (undocumented) // @public (undocumented)
export type TLInterruptEvent = (info: TLInterruptEventInfo) => void; export type TLInterruptEvent = (info: TLInterruptEventInfo) => void;
// @public (undocumented) // @public (undocumented)
export type TLInterruptEventInfo = { export interface TLInterruptEventInfo {
// (undocumented)
name: 'interrupt'; name: 'interrupt';
// (undocumented)
type: 'misc'; type: 'misc';
}; }
// @public (undocumented) // @public (undocumented)
export type TLKeyboardEvent = (info: TLKeyboardEventInfo) => void; export type TLKeyboardEvent = (info: TLKeyboardEventInfo) => void;
@ -2520,15 +2562,22 @@ export type TLPointerEventTarget = {
export type TLResizeHandle = SelectionCorner | SelectionEdge; export type TLResizeHandle = SelectionCorner | SelectionEdge;
// @public // @public
export type TLResizeInfo<T extends TLShape> = { export interface TLResizeInfo<T extends TLShape> {
// (undocumented)
handle: TLResizeHandle; handle: TLResizeHandle;
// (undocumented)
initialBounds: Box; initialBounds: Box;
// (undocumented)
initialShape: T; initialShape: T;
// (undocumented)
mode: TLResizeMode; mode: TLResizeMode;
// (undocumented)
newPoint: Vec; newPoint: Vec;
// (undocumented)
scaleX: number; scaleX: number;
// (undocumented)
scaleY: number; scaleY: number;
}; }
// @public // @public
export type TLResizeMode = 'resize_bounds' | 'scale_shape'; export type TLResizeMode = 'resize_bounds' | 'scale_shape';
@ -2547,36 +2596,49 @@ export type TLResizeShapeOptions = Partial<{
}>; }>;
// @public // @public
export type TLRotationSnapshot = { export interface TLRotationSnapshot {
// (undocumented)
initialCursorAngle: number; initialCursorAngle: number;
// (undocumented)
initialSelectionRotation: number; initialSelectionRotation: number;
// (undocumented)
selectionPageCenter: Vec; selectionPageCenter: Vec;
// (undocumented)
shapeSnapshots: { shapeSnapshots: {
initialPagePoint: Vec; initialPagePoint: Vec;
shape: TLShape; shape: TLShape;
}[]; }[];
}; }
// @public (undocumented) // @public (undocumented)
export type TLScribbleProps = { export interface TLScribbleProps {
// (undocumented)
className?: string; className?: string;
// (undocumented)
color?: string; color?: string;
// (undocumented)
opacity?: number; opacity?: number;
// (undocumented)
scribble: TLScribble; scribble: TLScribble;
// (undocumented)
zoom: number; zoom: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLSelectionBackgroundProps = { export interface TLSelectionBackgroundProps {
// (undocumented)
bounds: Box; bounds: Box;
// (undocumented)
rotation: number; rotation: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLSelectionForegroundProps = { export interface TLSelectionForegroundProps {
// (undocumented)
bounds: Box; bounds: Box;
// (undocumented)
rotation: number; rotation: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLSelectionHandle = RotateCorner | SelectionCorner | SelectionEdge; export type TLSelectionHandle = RotateCorner | SelectionCorner | SelectionEdge;
@ -2611,13 +2673,18 @@ export interface TLSessionStateSnapshot {
} }
// @public (undocumented) // @public (undocumented)
export type TLShapeIndicatorProps = { export interface TLShapeIndicatorProps {
// (undocumented)
className?: string; className?: string;
// (undocumented)
color?: string | undefined; color?: string | undefined;
// (undocumented)
hidden?: boolean; hidden?: boolean;
// (undocumented)
opacity?: number; opacity?: number;
// (undocumented)
shapeId: TLShapeId; shapeId: TLShapeId;
}; }
// @public (undocumented) // @public (undocumented)
export interface TLShapeUtilCanvasSvgDef { export interface TLShapeUtilCanvasSvgDef {
@ -2643,11 +2710,14 @@ export interface TLShapeUtilConstructor<T extends TLUnknownShape, U extends Shap
export type TLShapeUtilFlag<T> = (shape: T) => boolean; export type TLShapeUtilFlag<T> = (shape: T) => boolean;
// @public (undocumented) // @public (undocumented)
export type TLSnapIndicatorProps = { export interface TLSnapIndicatorProps {
// (undocumented)
className?: string; className?: string;
// (undocumented)
line: SnapIndicator; line: SnapIndicator;
// (undocumented)
zoom: number; zoom: number;
}; }
// @public (undocumented) // @public (undocumented)
export interface TLStateNodeConstructor { export interface TLStateNodeConstructor {
@ -2702,14 +2772,20 @@ export type TLStoreWithStatus = {
}; };
// @public (undocumented) // @public (undocumented)
export type TLSvgOptions = { export interface TLSvgOptions {
// (undocumented)
background: boolean; background: boolean;
// (undocumented)
bounds: Box; bounds: Box;
// (undocumented)
darkMode?: boolean; darkMode?: boolean;
// (undocumented)
padding: number; padding: number;
// (undocumented)
preserveAspectRatio: React.SVGAttributes<SVGSVGElement>['preserveAspectRatio']; preserveAspectRatio: React.SVGAttributes<SVGSVGElement>['preserveAspectRatio'];
// (undocumented)
scale: number; scale: number;
}; }
// @public (undocumented) // @public (undocumented)
export type TLTickEvent = (info: TLTickEventInfo) => void; export type TLTickEvent = (info: TLTickEventInfo) => void;

View file

@ -223,6 +223,7 @@ export {
} from './lib/editor/types/external-content' } from './lib/editor/types/external-content'
export { export {
type RequiredKeys, type RequiredKeys,
type TLCameraConstraints,
type TLCameraMoveOptions, type TLCameraMoveOptions,
type TLCameraOptions, type TLCameraOptions,
type TLSvgOptions, type TLSvgOptions,

View file

@ -8,7 +8,9 @@ export interface TLErrorBoundaryProps {
fallback: TLErrorFallbackComponent fallback: TLErrorFallbackComponent
} }
type TLErrorBoundaryState = { error: Error | null } interface TLErrorBoundaryState {
error: Error | null
}
const initialState: TLErrorBoundaryState = { error: null } const initialState: TLErrorBoundaryState = { error: null }

View file

@ -4,7 +4,7 @@ import { useTransform } from '../../hooks/useTransform'
import { toDomPrecision } from '../../primitives/utils' import { toDomPrecision } from '../../primitives/utils'
/** @public */ /** @public */
export type TLBrushProps = { export interface TLBrushProps {
brush: BoxModel brush: BoxModel
color?: string color?: string
opacity?: number opacity?: number

View file

@ -26,7 +26,9 @@ import { LiveCollaborators } from '../LiveCollaborators'
import { Shape } from '../Shape' import { Shape } from '../Shape'
/** @public */ /** @public */
export type TLCanvasComponentProps = { className?: string } export interface TLCanvasComponentProps {
className?: string
}
/** @public */ /** @public */
export function DefaultCanvas({ className }: TLCanvasComponentProps) { export function DefaultCanvas({ className }: TLCanvasComponentProps) {

View file

@ -7,7 +7,7 @@ import { Vec } from '../../primitives/Vec'
import { clamp } from '../../primitives/utils' import { clamp } from '../../primitives/utils'
/** @public */ /** @public */
export type TLCollaboratorHintProps = { export interface TLCollaboratorHintProps {
className?: string className?: string
point: VecModel point: VecModel
viewport: Box viewport: Box

View file

@ -4,7 +4,7 @@ import { memo, useRef } from 'react'
import { useTransform } from '../../hooks/useTransform' import { useTransform } from '../../hooks/useTransform'
/** @public */ /** @public */
export type TLCursorProps = { export interface TLCursorProps {
className?: string className?: string
point: VecModel | null point: VecModel | null
zoom: number zoom: number

View file

@ -2,7 +2,7 @@ import { modulate } from '@tldraw/utils'
import { GRID_STEPS } from '../../constants' import { GRID_STEPS } from '../../constants'
/** @public */ /** @public */
export type TLGridProps = { export interface TLGridProps {
x: number x: number
y: number y: number
z: number z: number

View file

@ -3,7 +3,7 @@ import classNames from 'classnames'
import { COARSE_HANDLE_RADIUS, HANDLE_RADIUS, SIDES } from '../../constants' import { COARSE_HANDLE_RADIUS, HANDLE_RADIUS, SIDES } from '../../constants'
/** @public */ /** @public */
export type TLHandleProps = { export interface TLHandleProps {
shapeId: TLShapeId shapeId: TLShapeId
handle: TLHandle handle: TLHandle
zoom: number zoom: number

View file

@ -1,7 +1,7 @@
import { ReactNode } from 'react' import { ReactNode } from 'react'
/** @public */ /** @public */
export type TLHandlesProps = { export interface TLHandlesProps {
children: ReactNode children: ReactNode
} }

View file

@ -3,7 +3,7 @@ import classNames from 'classnames'
import { getSvgPathFromPoints } from '../../utils/getSvgPathFromPoints' import { getSvgPathFromPoints } from '../../utils/getSvgPathFromPoints'
/** @public */ /** @public */
export type TLScribbleProps = { export interface TLScribbleProps {
scribble: TLScribble scribble: TLScribble
zoom: number zoom: number
color?: string color?: string

View file

@ -4,7 +4,7 @@ import { Box } from '../../primitives/Box'
import { toDomPrecision } from '../../primitives/utils' import { toDomPrecision } from '../../primitives/utils'
/** @public */ /** @public */
export type TLSelectionBackgroundProps = { export interface TLSelectionBackgroundProps {
bounds: Box bounds: Box
rotation: number rotation: number
} }

View file

@ -7,7 +7,7 @@ import { Box } from '../../primitives/Box'
import { toDomPrecision } from '../../primitives/utils' import { toDomPrecision } from '../../primitives/utils'
/** @public */ /** @public */
export type TLSelectionForegroundProps = { export interface TLSelectionForegroundProps {
bounds: Box bounds: Box
rotation: number rotation: number
} }

View file

@ -33,7 +33,7 @@ const InnerIndicator = ({ editor, id }: { editor: Editor; id: TLShapeId }) => {
} }
/** @public */ /** @public */
export type TLShapeIndicatorProps = { export interface TLShapeIndicatorProps {
shapeId: TLShapeId shapeId: TLShapeId
color?: string | undefined color?: string | undefined
opacity?: number opacity?: number

View file

@ -154,7 +154,7 @@ function GapsSnapIndicator({ gaps, direction, zoom }: { zoom: number } & GapsSna
} }
/** @public */ /** @public */
export type TLSnapIndicatorProps = { export interface TLSnapIndicatorProps {
className?: string className?: string
line: SnapIndicator line: SnapIndicator
zoom: number zoom: number

View file

@ -6771,7 +6771,7 @@ export class Editor extends EventEmitter<TLEventMap> {
let remaining = duration let remaining = duration
let t: number let t: number
type ShapeAnimation = { interface ShapeAnimation {
partial: TLShapePartial partial: TLShapePartial
values: { prop: string; from: number; to: number }[] values: { prop: string; from: number; to: number }[]
} }

View file

@ -3,7 +3,7 @@ import { Vec } from '../../primitives/Vec'
import { uniqueId } from '../../utils/uniqueId' import { uniqueId } from '../../utils/uniqueId'
import { Editor } from '../Editor' import { Editor } from '../Editor'
type ScribbleItem = { interface ScribbleItem {
id: string id: string
scribble: TLScribble scribble: TLScribble
timeoutMs: number timeoutMs: number

View file

@ -44,9 +44,12 @@ export interface BoundsSnapPoint {
handle?: SelectionCorner handle?: SelectionCorner
} }
type SnapPair = { thisPoint: BoundsSnapPoint; otherPoint: BoundsSnapPoint } interface SnapPair {
thisPoint: BoundsSnapPoint
otherPoint: BoundsSnapPoint
}
type NearestPointsSnap = { interface NearestPointsSnap {
// selection snaps to a nearby snap point // selection snaps to a nearby snap point
type: 'points' type: 'points'
points: SnapPair points: SnapPair
@ -70,12 +73,12 @@ type NearestSnap =
nudge: number nudge: number
} }
type GapNode = { interface GapNode {
id: TLShapeId id: TLShapeId
pageBounds: Box pageBounds: Box
} }
type Gap = { interface Gap {
// e.g. // e.g.
// start // start
// edge │ breadth // edge │ breadth

View file

@ -6,14 +6,14 @@ import { BoundsSnaps } from './BoundsSnaps'
import { HandleSnaps } from './HandleSnaps' import { HandleSnaps } from './HandleSnaps'
/** @public */ /** @public */
export type PointsSnapIndicator = { export interface PointsSnapIndicator {
id: string id: string
type: 'points' type: 'points'
points: VecLike[] points: VecLike[]
} }
/** @public */ /** @public */
export type GapsSnapIndicator = { export interface GapsSnapIndicator {
id: string id: string
type: 'gaps' type: 'gaps'
direction: 'horizontal' | 'vertical' direction: 'horizontal' | 'vertical'

View file

@ -21,7 +21,7 @@ const textAlignmentsForLtr = {
} }
type TLOverflowMode = 'wrap' | 'truncate-ellipsis' | 'truncate-clip' type TLOverflowMode = 'wrap' | 'truncate-ellipsis' | 'truncate-clip'
type TLMeasureTextSpanOpts = { interface TLMeasureTextSpanOpts {
overflow: TLOverflowMode overflow: TLOverflowMode
width: number width: number
height: number height: number

View file

@ -562,7 +562,7 @@ export type TLResizeMode = 'scale_shape' | 'resize_bounds'
* @param initialShape - The shape at the start of the resize. * @param initialShape - The shape at the start of the resize.
* @public * @public
*/ */
export type TLResizeInfo<T extends TLShape> = { export interface TLResizeInfo<T extends TLShape> {
newPoint: Vec newPoint: Vec
handle: TLResizeHandle handle: TLResizeHandle
mode: TLResizeMode mode: TLResizeMode

View file

@ -96,13 +96,26 @@ export type TLWheelEventInfo = TLBaseEventInfo & {
} }
/** @public */ /** @public */
export type TLCancelEventInfo = { type: 'misc'; name: 'cancel' } export interface TLCancelEventInfo {
type: 'misc'
name: 'cancel'
}
/** @public */ /** @public */
export type TLCompleteEventInfo = { type: 'misc'; name: 'complete' } export interface TLCompleteEventInfo {
type: 'misc'
name: 'complete'
}
/** @public */ /** @public */
export type TLInterruptEventInfo = { type: 'misc'; name: 'interrupt' } export interface TLInterruptEventInfo {
type: 'misc'
name: 'interrupt'
}
/** @public */ /** @public */
export type TLTickEventInfo = { type: 'misc'; name: 'tick'; elapsed: number } export interface TLTickEventInfo {
type: 'misc'
name: 'tick'
elapsed: number
}
/** @public */ /** @public */
export type TLEventInfo = export type TLEventInfo =

View file

@ -8,7 +8,7 @@ export type RequiredKeys<T, K extends keyof T> = Partial<Omit<T, K>> & Pick<T, K
export type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> export type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
/** @public */ /** @public */
export type TLSvgOptions = { export interface TLSvgOptions {
bounds: Box bounds: Box
scale: number scale: number
background: boolean background: boolean
@ -35,7 +35,7 @@ export type TLCameraMoveOptions = Partial<{
}> }>
/** @public */ /** @public */
export type TLCameraOptions = { export interface TLCameraOptions {
/** Whether the camera is locked. */ /** Whether the camera is locked. */
isLocked: boolean isLocked: boolean
/** The speed of a scroll wheel / trackpad pan. Default is 1. */ /** The speed of a scroll wheel / trackpad pan. Default is 1. */
@ -52,7 +52,11 @@ export type TLCameraOptions = {
*/ */
wheelBehavior: 'zoom' | 'pan' | 'none' wheelBehavior: 'zoom' | 'pan' | 'none'
/** The camera constraints. */ /** The camera constraints. */
constraints?: { constraints?: TLCameraConstraints
}
/** @public */
export interface TLCameraConstraints {
/** The bounds (in page space) of the constrained space */ /** The bounds (in page space) of the constrained space */
bounds: BoxModel bounds: BoxModel
/** The padding inside of the viewport (in screen space) */ /** The padding inside of the viewport (in screen space) */
@ -122,4 +126,3 @@ export type TLCameraOptions = {
y: 'free' | 'fixed' | 'inside' | 'outside' | 'contain' y: 'free' | 'fixed' | 'inside' | 'outside' | 'contain'
} }
} }
}

View file

@ -73,7 +73,7 @@ export interface BaseEditorComponents {
} }
// These will always have defaults // These will always have defaults
type ErrorComponents = { interface ErrorComponents {
ErrorFallback: TLErrorFallbackComponent ErrorFallback: TLErrorFallbackComponent
ShapeErrorFallback: TLShapeErrorFallbackComponent ShapeErrorFallback: TLShapeErrorFallbackComponent
ShapeIndicatorErrorFallback: TLShapeIndicatorErrorFallbackComponent ShapeIndicatorErrorFallback: TLShapeIndicatorErrorFallbackComponent
@ -88,7 +88,7 @@ export type TLEditorComponents = Partial<
const EditorComponentsContext = createContext<null | (TLEditorComponents & ErrorComponents)>(null) const EditorComponentsContext = createContext<null | (TLEditorComponents & ErrorComponents)>(null)
type ComponentsContextProviderProps = { interface ComponentsContextProviderProps {
overrides?: TLEditorComponents overrides?: TLEditorComponents
children: ReactNode children: ReactNode
} }

View file

@ -48,7 +48,7 @@ export function getRotationSnapshot({ editor }: { editor: Editor }): TLRotationS
* *
* @public * @public
**/ **/
export type TLRotationSnapshot = { export interface TLRotationSnapshot {
selectionPageCenter: Vec selectionPageCenter: Vec
initialCursorAngle: number initialCursorAngle: number
initialSelectionRotation: number initialSelectionRotation: number

View file

@ -26,7 +26,7 @@ const UPDATE_INSTANCE_STATE = Symbol('UPDATE_INSTANCE_STATE')
* once it has the db integrated * once it has the db integrated
*/ */
type SyncMessage = { interface SyncMessage {
type: 'diff' type: 'diff'
storeId: string storeId: string
changes: RecordsDiff<UnknownRecord> changes: RecordsDiff<UnknownRecord>
@ -36,7 +36,7 @@ type SyncMessage = {
// Sent by new clients when they connect // Sent by new clients when they connect
// If another client is on the channel with a newer schema version // If another client is on the channel with a newer schema version
// It will // It will
type AnnounceMessage = { interface AnnounceMessage {
type: 'announce' type: 'announce'
schema: SerializedSchema schema: SerializedSchema
} }

View file

@ -38,13 +38,13 @@ async function withDb<T>(storeId: string, cb: (db: IDBPDatabase<StoreName>) => P
} }
} }
type LoadResult = { interface LoadResult {
records: TLRecord[] records: TLRecord[]
schema?: SerializedSchema schema?: SerializedSchema
sessionStateSnapshot?: TLSessionStateSnapshot | null sessionStateSnapshot?: TLSessionStateSnapshot | null
} }
type SessionStateSnapshotRow = { interface SessionStateSnapshotRow {
id: string id: string
snapshot: TLSessionStateSnapshot snapshot: TLSessionStateSnapshot
updatedAt: number updatedAt: number

View file

@ -53,7 +53,10 @@ export const WithDiff = singleton(
) {} ) {}
} }
) )
export type WithDiff<Value, Diff> = { value: Value; diff: Diff } export interface WithDiff<Value, Diff> {
value: Value
diff: Diff
}
/** /**
* When writing incrementally-computed signals it is convenient (and usually more performant) to incrementally compute the diff too. * When writing incrementally-computed signals it is convenient (and usually more performant) to incrementally compute the diff too.

View file

@ -72,7 +72,7 @@ const unpack = (value: unknown): Letter => {
return value as Letter return value as Letter
} }
type FuzzSystemState = { interface FuzzSystemState {
atoms: Record<string, Atom<Letter>> atoms: Record<string, Atom<Letter>>
atomsInAtoms: Record<string, Atom<Atom<Letter>>> atomsInAtoms: Record<string, Atom<Atom<Letter>>>
derivations: Record<string, { derivation: Computed<Letter>; sneakyGet: () => Letter }> derivations: Record<string, { derivation: Computed<Letter>; sneakyGet: () => Letter }>

View file

@ -49,7 +49,7 @@ export interface Signal<Value, Diff = unknown> {
} }
/** @internal */ /** @internal */
export type Child = { export interface Child {
lastTraversedEpoch: number lastTraversedEpoch: number
readonly parentSet: ArraySet<Signal<any, any>> readonly parentSet: ArraySet<Signal<any, any>>
readonly parents: Signal<any, any>[] readonly parents: Signal<any, any>[]

View file

@ -23,15 +23,18 @@ export interface BaseRecord<TypeName extends string, Id extends RecordId<Unknown
} }
// @public // @public
export type CollectionDiff<T> = { export interface CollectionDiff<T> {
// (undocumented)
added?: Set<T>; added?: Set<T>;
// (undocumented)
removed?: Set<T>; removed?: Set<T>;
}; }
// @public // @public
export type ComputedCache<Data, R extends UnknownRecord> = { export interface ComputedCache<Data, R extends UnknownRecord> {
// (undocumented)
get(id: IdOf<R>): Data | undefined; get(id: IdOf<R>): Data | undefined;
}; }
// @public // @public
export function createComputedCache<Context extends StoreContext<any>, Result, Record extends ContextRecordType<Context> = ContextRecordType<Context>>(name: string, derive: (context: Context, record: Record) => Result | undefined, isEqual?: (a: Record, b: Record) => boolean): { export function createComputedCache<Context extends StoreContext<any>, Result, Record extends ContextRecordType<Context> = ContextRecordType<Context>>(name: string, derive: (context: Context, record: Record) => Result | undefined, isEqual?: (a: Record, b: Record) => boolean): {
@ -86,10 +89,12 @@ export function defineMigrations(opts: {
export function devFreeze<T>(object: T): T; export function devFreeze<T>(object: T): T;
// @public // @public
export type HistoryEntry<R extends UnknownRecord = UnknownRecord> = { export interface HistoryEntry<R extends UnknownRecord = UnknownRecord> {
// (undocumented)
changes: RecordsDiff<R>; changes: RecordsDiff<R>;
// (undocumented)
source: ChangeSource; source: ChangeSource;
}; }
// @public (undocumented) // @public (undocumented)
export type IdOf<R extends UnknownRecord> = R['id']; export type IdOf<R extends UnknownRecord> = R['id'];
@ -113,10 +118,12 @@ export class IncrementalSetConstructor<T> {
export function isRecordsDiffEmpty<T extends UnknownRecord>(diff: RecordsDiff<T>): boolean; export function isRecordsDiffEmpty<T extends UnknownRecord>(diff: RecordsDiff<T>): boolean;
// @public (undocumented) // @public (undocumented)
export type LegacyMigration<Before = any, After = any> = { export interface LegacyMigration<Before = any, After = any> {
// (undocumented)
down: (newState: After) => Before; down: (newState: After) => Before;
// (undocumented)
up: (oldState: Before) => After; up: (oldState: Before) => After;
}; }
// @public (undocumented) // @public (undocumented)
export interface LegacyMigrations extends LegacyBaseMigrationsInfo { export interface LegacyMigrations extends LegacyBaseMigrationsInfo {
@ -190,11 +197,14 @@ export type RecordId<R extends UnknownRecord> = string & {
}; };
// @public // @public
export type RecordsDiff<R extends UnknownRecord> = { export interface RecordsDiff<R extends UnknownRecord> {
// (undocumented)
added: Record<IdOf<R>, R>; added: Record<IdOf<R>, R>;
// (undocumented)
removed: Record<IdOf<R>, R>; removed: Record<IdOf<R>, R>;
// (undocumented)
updated: Record<IdOf<R>, [from: R, to: R]>; updated: Record<IdOf<R>, [from: R, to: R]>;
}; }
// @public // @public
export class RecordType<R extends UnknownRecord, RequiredProperties extends keyof Omit<R, 'id' | 'typeName'>> { export class RecordType<R extends UnknownRecord, RequiredProperties extends keyof Omit<R, 'id' | 'typeName'>> {
@ -271,9 +281,10 @@ export function squashRecordDiffs<T extends UnknownRecord>(diffs: RecordsDiff<T>
export function squashRecordDiffsMutable<T extends UnknownRecord>(target: RecordsDiff<T>, diffs: RecordsDiff<T>[]): void; export function squashRecordDiffsMutable<T extends UnknownRecord>(target: RecordsDiff<T>, diffs: RecordsDiff<T>[]): void;
// @public (undocumented) // @public (undocumented)
export type StandaloneDependsOn = { export interface StandaloneDependsOn {
// (undocumented)
readonly dependsOn: readonly MigrationId[]; readonly dependsOn: readonly MigrationId[];
}; }
// @public // @public
export class Store<R extends UnknownRecord = UnknownRecord, Props = unknown> { export class Store<R extends UnknownRecord = UnknownRecord, Props = unknown> {
@ -358,13 +369,18 @@ export type StoreBeforeCreateHandler<R extends UnknownRecord> = (record: R, sour
export type StoreBeforeDeleteHandler<R extends UnknownRecord> = (record: R, source: 'remote' | 'user') => false | void; export type StoreBeforeDeleteHandler<R extends UnknownRecord> = (record: R, source: 'remote' | 'user') => false | void;
// @public (undocumented) // @public (undocumented)
export type StoreError = { export interface StoreError {
// (undocumented)
error: Error; error: Error;
// (undocumented)
isExistingValidationIssue: boolean; isExistingValidationIssue: boolean;
// (undocumented)
phase: 'createRecord' | 'initialize' | 'tests' | 'updateRecord'; phase: 'createRecord' | 'initialize' | 'tests' | 'updateRecord';
// (undocumented)
recordAfter: unknown; recordAfter: unknown;
// (undocumented)
recordBefore?: unknown; recordBefore?: unknown;
}; }
// @public // @public
export type StoreListener<R extends UnknownRecord> = (entry: HistoryEntry<R>) => void; export type StoreListener<R extends UnknownRecord> = (entry: HistoryEntry<R>) => void;
@ -407,8 +423,12 @@ export class StoreSchema<R extends UnknownRecord, P = unknown> {
} }
// @public (undocumented) // @public (undocumented)
export type StoreSchemaOptions<R extends UnknownRecord, P> = { export interface StoreSchemaOptions<R extends UnknownRecord, P> {
// @internal (undocumented)
createIntegrityChecker?: (store: Store<R, P>) => void; createIntegrityChecker?: (store: Store<R, P>) => void;
// (undocumented)
migrations?: MigrationSequence[];
// (undocumented)
onValidationFailure?: (data: { onValidationFailure?: (data: {
error: unknown; error: unknown;
phase: 'createRecord' | 'initialize' | 'tests' | 'updateRecord'; phase: 'createRecord' | 'initialize' | 'tests' | 'updateRecord';
@ -416,8 +436,7 @@ export type StoreSchemaOptions<R extends UnknownRecord, P> = {
recordBefore: null | R; recordBefore: null | R;
store: Store<R>; store: Store<R>;
}) => R; }) => R;
migrations?: MigrationSequence[]; }
};
// @public // @public
export class StoreSideEffects<R extends UnknownRecord> { export class StoreSideEffects<R extends UnknownRecord> {
@ -473,16 +492,20 @@ export class StoreSideEffects<R extends UnknownRecord> {
} }
// @public (undocumented) // @public (undocumented)
export type StoreSnapshot<R extends UnknownRecord> = { export interface StoreSnapshot<R extends UnknownRecord> {
// (undocumented)
schema: SerializedSchema; schema: SerializedSchema;
// (undocumented)
store: SerializedStore<R>; store: SerializedStore<R>;
}; }
// @public (undocumented) // @public (undocumented)
export type StoreValidator<R extends UnknownRecord> = { export interface StoreValidator<R extends UnknownRecord> {
// (undocumented)
validate: (record: unknown) => R; validate: (record: unknown) => R;
// (undocumented)
validateUsingKnownGoodVersion?: (knownGoodVersion: R, record: unknown) => R; validateUsingKnownGoodVersion?: (knownGoodVersion: R, record: unknown) => R;
}; }
// @public (undocumented) // @public (undocumented)
export type StoreValidators<R extends UnknownRecord> = { export type StoreValidators<R extends UnknownRecord> = {

View file

@ -6,7 +6,7 @@ import { IdOf, UnknownRecord } from './BaseRecord'
* *
* @public * @public
*/ */
export type RecordsDiff<R extends UnknownRecord> = { export interface RecordsDiff<R extends UnknownRecord> {
added: Record<IdOf<R>, R> added: Record<IdOf<R>, R>
updated: Record<IdOf<R>, [from: R, to: R]> updated: Record<IdOf<R>, [from: R, to: R]>
removed: Record<IdOf<R>, R> removed: Record<IdOf<R>, R>

View file

@ -26,11 +26,14 @@ type RecFromId<K extends RecordId<UnknownRecord>> = K extends RecordId<infer R>
* *
* @public * @public
*/ */
export type CollectionDiff<T> = { added?: Set<T>; removed?: Set<T> } export interface CollectionDiff<T> {
added?: Set<T>
removed?: Set<T>
}
export type ChangeSource = 'user' | 'remote' export type ChangeSource = 'user' | 'remote'
export type StoreListenerFilters = { export interface StoreListenerFilters {
source: ChangeSource | 'all' source: ChangeSource | 'all'
scope: RecordScope | 'all' scope: RecordScope | 'all'
} }
@ -40,7 +43,7 @@ export type StoreListenerFilters = {
* *
* @public * @public
*/ */
export type HistoryEntry<R extends UnknownRecord = UnknownRecord> = { export interface HistoryEntry<R extends UnknownRecord = UnknownRecord> {
changes: RecordsDiff<R> changes: RecordsDiff<R>
source: ChangeSource source: ChangeSource
} }
@ -57,7 +60,7 @@ export type StoreListener<R extends UnknownRecord> = (entry: HistoryEntry<R>) =>
* *
* @public * @public
*/ */
export type ComputedCache<Data, R extends UnknownRecord> = { export interface ComputedCache<Data, R extends UnknownRecord> {
get(id: IdOf<R>): Data | undefined get(id: IdOf<R>): Data | undefined
} }
@ -69,13 +72,13 @@ export type ComputedCache<Data, R extends UnknownRecord> = {
export type SerializedStore<R extends UnknownRecord> = Record<IdOf<R>, R> export type SerializedStore<R extends UnknownRecord> = Record<IdOf<R>, R>
/** @public */ /** @public */
export type StoreSnapshot<R extends UnknownRecord> = { export interface StoreSnapshot<R extends UnknownRecord> {
store: SerializedStore<R> store: SerializedStore<R>
schema: SerializedSchema schema: SerializedSchema
} }
/** @public */ /** @public */
export type StoreValidator<R extends UnknownRecord> = { export interface StoreValidator<R extends UnknownRecord> {
validate: (record: unknown) => R validate: (record: unknown) => R
validateUsingKnownGoodVersion?: (knownGoodVersion: R, record: unknown) => R validateUsingKnownGoodVersion?: (knownGoodVersion: R, record: unknown) => R
} }
@ -86,7 +89,7 @@ export type StoreValidators<R extends UnknownRecord> = {
} }
/** @public */ /** @public */
export type StoreError = { export interface StoreError {
error: Error error: Error
phase: 'initialize' | 'createRecord' | 'updateRecord' | 'tests' phase: 'initialize' | 'createRecord' | 'updateRecord' | 'tests'
recordBefore?: unknown recordBefore?: unknown

View file

@ -74,7 +74,7 @@ export function upgradeSchema(schema: SerializedSchema): Result<SerializedSchema
} }
/** @public */ /** @public */
export type StoreSchemaOptions<R extends UnknownRecord, P> = { export interface StoreSchemaOptions<R extends UnknownRecord, P> {
migrations?: MigrationSequence[] migrations?: MigrationSequence[]
/** @public */ /** @public */
onValidationFailure?: (data: { onValidationFailure?: (data: {

View file

@ -128,7 +128,7 @@ export function createRecordMigrationSequence(opts: {
} }
/** @public */ /** @public */
export type LegacyMigration<Before = any, After = any> = { export interface LegacyMigration<Before = any, After = any> {
up: (oldState: Before) => After up: (oldState: Before) => After
down: (newState: After) => Before down: (newState: After) => Before
} }
@ -137,7 +137,7 @@ export type LegacyMigration<Before = any, After = any> = {
export type MigrationId = `${string}/${number}` export type MigrationId = `${string}/${number}`
/** @public */ /** @public */
export type StandaloneDependsOn = { export interface StandaloneDependsOn {
readonly dependsOn: readonly MigrationId[] readonly dependsOn: readonly MigrationId[]
} }

File diff suppressed because one or more lines are too long

View file

@ -27,7 +27,7 @@ import { getEmbedInfo } from './utils/embeds/embeds'
import { cleanupText, isRightToLeftLanguage, truncateStringWithEllipsis } from './utils/text/text' import { cleanupText, isRightToLeftLanguage, truncateStringWithEllipsis } from './utils/text/text'
/** @public */ /** @public */
export type TLExternalContentProps = { export interface TLExternalContentProps {
// The maximum dimension (width or height) of an image. Images larger than this will be rescaled to fit. Defaults to infinity. // The maximum dimension (width or height) of an image. Images larger than this will be rescaled to fit. Defaults to infinity.
maxImageDimension: number maxImageDimension: number
// The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults to 10mb (10 * 1024 * 1024). // The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults to 10mb (10 * 1024 * 1024).

View file

@ -2,7 +2,7 @@ import { TLArrowShapeArrowheadStyle, VecLike } from '@tldraw/editor'
import { TLArrowBindings } from './shared' import { TLArrowBindings } from './shared'
/** @public */ /** @public */
export type TLArrowPoint = { export interface TLArrowPoint {
handle: VecLike handle: VecLike
point: VecLike point: VecLike
arrowhead: TLArrowShapeArrowheadStyle arrowhead: TLArrowShapeArrowheadStyle

View file

@ -1,7 +1,7 @@
import { HALF_PI, PI, Vec, VecLike, intersectCircleCircle } from '@tldraw/editor' import { HALF_PI, PI, Vec, VecLike, intersectCircleCircle } from '@tldraw/editor'
import { TLArrowInfo } from './arrow-types' import { TLArrowInfo } from './arrow-types'
type TLArrowPointsInfo = { interface TLArrowPointsInfo {
point: VecLike point: VecLike
int: VecLike int: VecLike
} }

View file

@ -17,7 +17,7 @@ export function getIsArrowStraight(shape: TLArrowShape) {
return Math.abs(shape.props.bend) < 8 // snap to +-8px return Math.abs(shape.props.bend) < 8 // snap to +-8px
} }
export type BoundShapeInfo<T extends TLShape = TLShape> = { export interface BoundShapeInfo<T extends TLShape = TLShape> {
shape: T shape: T
didIntersect: boolean didIntersect: boolean
isExact: boolean isExact: boolean

View file

@ -215,7 +215,7 @@ export function getCloudArcs(
return arcs return arcs
} }
type Arc = { interface Arc {
leftPoint: Vec leftPoint: Vec
rightPoint: Vec rightPoint: Vec
arcPoint: Vec arcPoint: Vec

View file

@ -12,7 +12,7 @@ import { TextHelpers } from './TextHelpers'
import { isLegacyAlign } from './legacyProps' import { isLegacyAlign } from './legacyProps'
import { useEditableText } from './useEditableText' import { useEditableText } from './useEditableText'
type TextLabelProps = { interface TextLabelProps {
id: TLShapeId id: TLShapeId
type: string type: string
font: TLDefaultFontStyle font: TLDefaultFontStyle

View file

@ -147,7 +147,11 @@ const canvasBlob = (size: [number, number], fn: (ctx: CanvasRenderingContext2D)
fn(ctx) fn(ctx)
return canvas.toDataURL() return canvas.toDataURL()
} }
type PatternDef = { zoom: number; url: string; theme: 'light' | 'dark' } interface PatternDef {
zoom: number
url: string
theme: 'light' | 'dark'
}
let defaultPixels: { white: string; black: string } | null = null let defaultPixels: { white: string; black: string } | null = null
function getDefaultPixels() { function getDefaultPixels() {

View file

@ -1,6 +1,6 @@
import canvasSize from 'canvas-size' import canvasSize from 'canvas-size'
export type CanvasMaxSize = { export interface CanvasMaxSize {
maxWidth: number maxWidth: number
maxHeight: number maxHeight: number
maxArea: number maxArea: number

View file

@ -1,7 +1,7 @@
import { preventDefault, stopEventPropagation } from '@tldraw/editor' import { preventDefault, stopEventPropagation } from '@tldraw/editor'
import { forwardRef } from 'react' import { forwardRef } from 'react'
type TextAreaProps = { interface TextAreaProps {
isEditing: boolean isEditing: boolean
text: string text: string
handleFocus: () => void handleFocus: () => void

View file

@ -77,7 +77,7 @@ export const TldrawUi = React.memo(function TldrawUi({
) )
}) })
type TldrawUiContentProps = { interface TldrawUiContentProps {
hideUi?: boolean hideUi?: boolean
shareZone?: ReactNode shareZone?: ReactNode
topZone?: ReactNode topZone?: ReactNode

View file

@ -15,7 +15,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultActionsMenuContent } from './DefaultActionsMenuContent' import { DefaultActionsMenuContent } from './DefaultActionsMenuContent'
/** @public */ /** @public */
export type TLUiActionsMenuProps = { export interface TLUiActionsMenuProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -10,7 +10,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultDebugMenuContent } from './DefaultDebugMenuContent' import { DefaultDebugMenuContent } from './DefaultDebugMenuContent'
/** @public */ /** @public */
export type TLUiDebugMenuProps = { export interface TLUiDebugMenuProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -13,7 +13,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultHelpMenuContent } from './DefaultHelpMenuContent' import { DefaultHelpMenuContent } from './DefaultHelpMenuContent'
/** @public */ /** @public */
export type TLUiHelpMenuProps = { export interface TLUiHelpMenuProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -3,7 +3,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultHelperButtonsContent } from './DefaultHelperButtonsContent' import { DefaultHelperButtonsContent } from './DefaultHelperButtonsContent'
/** @public */ /** @public */
export type TLUiHelperButtonsProps = { export interface TLUiHelperButtonsProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -9,7 +9,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultMainMenuContent } from './DefaultMainMenuContent' import { DefaultMainMenuContent } from './DefaultMainMenuContent'
/** @public */ /** @public */
export type TLUiMainMenuProps = { export interface TLUiMainMenuProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -3,7 +3,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultQuickActionsContent } from './DefaultQuickActionsContent' import { DefaultQuickActionsContent } from './DefaultQuickActionsContent'
/** @public */ /** @public */
export type TLUiQuickActionsProps = { export interface TLUiQuickActionsProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -35,7 +35,7 @@ import { DoubleDropdownPicker } from './DoubleDropdownPicker'
import { DropdownPicker } from './DropdownPicker' import { DropdownPicker } from './DropdownPicker'
/** @public */ /** @public */
export type TLUiStylePanelContentProps = { export interface TLUiStylePanelContentProps {
styles: ReturnType<typeof useRelevantStyles> styles: ReturnType<typeof useRelevantStyles>
} }

View file

@ -10,7 +10,7 @@ import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuCon
import { DefaultZoomMenuContent } from './DefaultZoomMenuContent' import { DefaultZoomMenuContent } from './DefaultZoomMenuContent'
/** @public */ /** @public */
export type TLUiZoomMenuProps = { export interface TLUiZoomMenuProps {
children?: ReactNode children?: ReactNode
} }

View file

@ -1,7 +1,9 @@
import { TldrawUiIcon } from '../TldrawUiIcon' import { TldrawUiIcon } from '../TldrawUiIcon'
/** @public */ /** @public */
export type TLUiButtonCheckProps = { checked: boolean } export interface TLUiButtonCheckProps {
checked: boolean
}
/** @public */ /** @public */
export function TldrawUiButtonCheck({ checked }: TLUiButtonCheckProps) { export function TldrawUiButtonCheck({ checked }: TLUiButtonCheckProps) {

View file

@ -1,7 +1,7 @@
import { TldrawUiIcon } from '../TldrawUiIcon' import { TldrawUiIcon } from '../TldrawUiIcon'
/** @public */ /** @public */
export type TLUiButtonIconProps = { export interface TLUiButtonIconProps {
icon: string icon: string
small?: boolean small?: boolean
invertIcon?: boolean invertIcon?: boolean

View file

@ -1,7 +1,9 @@
import { ReactNode } from 'react' import { ReactNode } from 'react'
/** @public */ /** @public */
export type TLUiButtonLabelProps = { children?: ReactNode } export interface TLUiButtonLabelProps {
children?: ReactNode
}
/** @public */ /** @public */
export function TldrawUiButtonLabel({ children }: TLUiButtonLabelProps) { export function TldrawUiButtonLabel({ children }: TLUiButtonLabelProps) {

View file

@ -5,7 +5,7 @@ import { TldrawUiButton } from './Button/TldrawUiButton'
import { TldrawUiButtonIcon } from './Button/TldrawUiButtonIcon' import { TldrawUiButtonIcon } from './Button/TldrawUiButtonIcon'
/** @public */ /** @public */
export type TLUiDialogHeaderProps = { export interface TLUiDialogHeaderProps {
className?: string className?: string
children: ReactNode children: ReactNode
} }
@ -16,7 +16,7 @@ export function TldrawUiDialogHeader({ className, children }: TLUiDialogHeaderPr
} }
/** @public */ /** @public */
export type TLUiDialogTitleProps = { export interface TLUiDialogTitleProps {
className?: string className?: string
children: ReactNode children: ReactNode
} }
@ -48,7 +48,7 @@ export function TldrawUiDialogCloseButton() {
} }
/** @public */ /** @public */
export type TLUiDialogBodyProps = { export interface TLUiDialogBodyProps {
className?: string className?: string
children: ReactNode children: ReactNode
style?: React.CSSProperties style?: React.CSSProperties
@ -64,7 +64,7 @@ export function TldrawUiDialogBody({ className, children, style }: TLUiDialogBod
} }
/** @public */ /** @public */
export type TLUiDialogFooterProps = { export interface TLUiDialogFooterProps {
className?: string className?: string
children: ReactNode children: ReactNode
} }

View file

@ -8,7 +8,7 @@ import { TldrawUiButtonLabel } from './Button/TldrawUiButtonLabel'
import { TldrawUiIcon } from './TldrawUiIcon' import { TldrawUiIcon } from './TldrawUiIcon'
/** @public */ /** @public */
export type TLUiDropdownMenuRootProps = { export interface TLUiDropdownMenuRootProps {
id: string id: string
children: ReactNode children: ReactNode
modal?: boolean modal?: boolean
@ -57,7 +57,7 @@ export function TldrawUiDropdownMenuTrigger({ children, ...rest }: TLUiDropdownM
} }
/** @public */ /** @public */
export type TLUiDropdownMenuContentProps = { export interface TLUiDropdownMenuContentProps {
id?: string id?: string
children: ReactNode children: ReactNode
alignOffset?: number alignOffset?: number
@ -93,7 +93,10 @@ export function TldrawUiDropdownMenuContent({
} }
/** @public */ /** @public */
export type TLUiDropdownMenuSubProps = { id: string; children: ReactNode } export interface TLUiDropdownMenuSubProps {
id: string
children: ReactNode
}
/** @public */ /** @public */
export function TldrawUiDropdownMenuSub({ id, children }: TLUiDropdownMenuSubProps) { export function TldrawUiDropdownMenuSub({ id, children }: TLUiDropdownMenuSubProps) {
@ -107,7 +110,7 @@ export function TldrawUiDropdownMenuSub({ id, children }: TLUiDropdownMenuSubPro
} }
/** @public */ /** @public */
export type TLUiDropdownMenuSubTriggerProps = { export interface TLUiDropdownMenuSubTriggerProps {
label: string label: string
id?: string id?: string
title?: string title?: string
@ -138,7 +141,7 @@ export function TldrawUiDropdownMenuSubTrigger({
} }
/** @public */ /** @public */
export type TLUiDropdownMenuSubContentProps = { export interface TLUiDropdownMenuSubContentProps {
id?: string id?: string
alignOffset?: number alignOffset?: number
sideOffset?: number sideOffset?: number
@ -172,7 +175,7 @@ export function TldrawUiDropdownMenuSubContent({
} }
/** @public */ /** @public */
export type TLUiDropdownMenuGroupProps = { export interface TLUiDropdownMenuGroupProps {
children: ReactNode children: ReactNode
} }

View file

@ -4,7 +4,7 @@ import React from 'react'
import { useMenuIsOpen } from '../../hooks/useMenuIsOpen' import { useMenuIsOpen } from '../../hooks/useMenuIsOpen'
/** @public */ /** @public */
export type TLUiPopoverProps = { export interface TLUiPopoverProps {
id: string id: string
open?: boolean open?: boolean
children: React.ReactNode children: React.ReactNode
@ -40,7 +40,7 @@ export function TldrawUiPopoverTrigger({ children }: TLUiPopoverTriggerProps) {
} }
/** @public */ /** @public */
export type TLUiPopoverContentProps = { export interface TLUiPopoverContentProps {
children: React.ReactNode children: React.ReactNode
side: 'top' | 'bottom' | 'left' | 'right' side: 'top' | 'bottom' | 'left' | 'right'
align?: 'start' | 'center' | 'end' align?: 'start' | 'center' | 'end'

View file

@ -11,10 +11,10 @@ import { TldrawUiKbd } from '../TldrawUiKbd'
import { useTldrawUiMenuContext } from './TldrawUiMenuContext' import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
/** @public */ /** @public */
export type TLUiMenuCheckboxItemProps< export interface TLUiMenuCheckboxItemProps<
TranslationKey extends string = string, TranslationKey extends string = string,
IconType extends string = string, IconType extends string = string,
> = { > {
icon?: IconType icon?: IconType
id: string id: string
kbd?: string kbd?: string

View file

@ -28,7 +28,7 @@ export function useTldrawUiMenuContext() {
} }
/** @public */ /** @public */
export type TLUiMenuContextProviderProps = { export interface TLUiMenuContextProviderProps {
type: TldrawUiMenuContextType type: TldrawUiMenuContextType
sourceId: TLUiEventSource sourceId: TLUiEventSource
children: React.ReactNode children: React.ReactNode

View file

@ -7,7 +7,7 @@ import { TldrawUiDropdownMenuGroup } from '../TldrawUiDropdownMenu'
import { useTldrawUiMenuContext } from './TldrawUiMenuContext' import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
/** @public */ /** @public */
export type TLUiMenuGroupProps<TranslationKey extends string = string> = { export interface TLUiMenuGroupProps<TranslationKey extends string = string> {
id: string id: string
/** /**
* The label to display on the item. If it's a string, it will be translated. If it's an object, the keys will be used as the language keys and the values will be translated. * The label to display on the item. If it's a string, it will be translated. If it's an object, the keys will be used as the language keys and the values will be translated.

View file

@ -16,10 +16,10 @@ import { TldrawUiKbd } from '../TldrawUiKbd'
import { useTldrawUiMenuContext } from './TldrawUiMenuContext' import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
/** @public */ /** @public */
export type TLUiMenuItemProps< export interface TLUiMenuItemProps<
TranslationKey extends string = string, TranslationKey extends string = string,
IconType extends string = string, IconType extends string = string,
> = { > {
id: string id: string
/** /**
* The icon to display on the item. * The icon to display on the item.

View file

@ -20,7 +20,7 @@ import {
import { useTldrawUiMenuContext } from './TldrawUiMenuContext' import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
/** @public */ /** @public */
export type TLUiMenuSubmenuProps<Translation extends string = string> = { export interface TLUiMenuSubmenuProps<Translation extends string = string> {
id: string id: string
label?: Translation | { [key: string]: Translation } label?: Translation | { [key: string]: Translation }
disabled?: boolean disabled?: boolean
@ -103,7 +103,10 @@ export function TldrawUiMenuSubmenu<Translation extends string = string>({
} }
/** @private */ /** @private */
export type TLUiContextMenuSubProps = { id: string; children: ReactNode } export interface TLUiContextMenuSubProps {
id: string
children: ReactNode
}
/** @private */ /** @private */
export function ContextMenuSubWithMenu({ id, children }: TLUiContextMenuSubProps) { export function ContextMenuSubWithMenu({ id, children }: TLUiContextMenuSubProps) {

View file

@ -59,7 +59,7 @@ export type TLUiActionsContextType = Record<string, TLUiActionItem>
export const ActionsContext = React.createContext<TLUiActionsContextType | null>(null) export const ActionsContext = React.createContext<TLUiActionsContextType | null>(null)
/** @public */ /** @public */
export type ActionsProviderProps = { export interface ActionsProviderProps {
overrides?: ( overrides?: (
editor: Editor, editor: Editor,
actions: TLUiActionsContextType, actions: TLUiActionsContextType,

View file

@ -61,7 +61,7 @@ export type TLUiComponents = Partial<{
const TldrawUiComponentsContext = createContext<TLUiComponents | null>(null) const TldrawUiComponentsContext = createContext<TLUiComponents | null>(null)
/** @public */ /** @public */
export type TLUiComponentsProviderProps = { export interface TLUiComponentsProviderProps {
overrides?: TLUiComponents overrides?: TLUiComponents
children: ReactNode children: ReactNode
} }

View file

@ -15,7 +15,7 @@ export interface TLUiDialog {
} }
/** @public */ /** @public */
export type TLUiDialogsContextType = { export interface TLUiDialogsContextType {
addDialog: (dialog: Omit<TLUiDialog, 'id'> & { id?: string }) => string addDialog: (dialog: Omit<TLUiDialog, 'id'> & { id?: string }) => string
removeDialog: (id: string) => string removeDialog: (id: string) => string
updateDialog: (id: string, newDialogData: Partial<TLUiDialog>) => string updateDialog: (id: string, newDialogData: Partial<TLUiDialog>) => string
@ -27,7 +27,7 @@ export type TLUiDialogsContextType = {
export const DialogsContext = createContext<TLUiDialogsContextType | null>(null) export const DialogsContext = createContext<TLUiDialogsContextType | null>(null)
/** @internal */ /** @internal */
export type DialogsProviderProps = { export interface DialogsProviderProps {
overrides?: (editor: Editor) => TLUiDialogsContextType overrides?: (editor: Editor) => TLUiDialogsContextType
children: ReactNode children: ReactNode
} }

View file

@ -118,7 +118,7 @@ export type TLUiEventContextType = TLUiEventHandler<keyof TLUiEventMap>
export const EventsContext = React.createContext<TLUiEventContextType | null>(null) export const EventsContext = React.createContext<TLUiEventContextType | null>(null)
/** @public */ /** @public */
export type EventsProviderProps = { export interface EventsProviderProps {
onEvent?: TLUiEventHandler onEvent?: TLUiEventHandler
children: React.ReactNode children: React.ReactNode
} }

View file

@ -26,7 +26,7 @@ export interface TLUiToastAction {
} }
/** @public */ /** @public */
export type TLUiToastsContextType = { export interface TLUiToastsContextType {
addToast: (toast: Omit<TLUiToast, 'id'> & { id?: string }) => string addToast: (toast: Omit<TLUiToast, 'id'> & { id?: string }) => string
removeToast: (id: TLUiToast['id']) => string removeToast: (id: TLUiToast['id']) => string
clearToasts: () => void clearToasts: () => void
@ -37,7 +37,7 @@ export type TLUiToastsContextType = {
export const ToastsContext = createContext<TLUiToastsContextType | null>(null) export const ToastsContext = createContext<TLUiToastsContextType | null>(null)
/** @internal */ /** @internal */
export type ToastsProviderProps = { export interface ToastsProviderProps {
overrides?: (editor: Editor) => TLUiToastsContextType overrides?: (editor: Editor) => TLUiToastsContextType
children: ReactNode children: ReactNode
} }

View file

@ -31,7 +31,7 @@ export type TLUiToolsContextType = Record<string, TLUiToolItem>
export const ToolsContext = React.createContext<null | TLUiToolsContextType>(null) export const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)
/** @public */ /** @public */
export type TLUiToolsProviderProps = { export interface TLUiToolsProviderProps {
overrides?: ( overrides?: (
editor: Editor, editor: Editor,
tools: TLUiToolsContextType, tools: TLUiToolsContextType,

View file

@ -13,7 +13,7 @@ import { DEFAULT_TRANSLATION } from './defaultTranslation'
export const RTL_LANGUAGES = new Set(['ar', 'fa', 'he', 'ur', 'ku']) export const RTL_LANGUAGES = new Set(['ar', 'fa', 'he', 'ur', 'ku'])
/** @public */ /** @public */
export type TLUiTranslation = { export interface TLUiTranslation {
readonly locale: string readonly locale: string
readonly label: string readonly label: string
readonly messages: Record<TLUiTranslationKey, string> readonly messages: Record<TLUiTranslationKey, string>

View file

@ -1,7 +1,7 @@
import { MediaHelpers, assertExists } from '@tldraw/editor' import { MediaHelpers, assertExists } from '@tldraw/editor'
import { clampToBrowserMaxCanvasSize } from '../../shapes/shared/getBrowserCanvasMaxSize' import { clampToBrowserMaxCanvasSize } from '../../shapes/shared/getBrowserCanvasMaxSize'
type BoxWidthHeight = { interface BoxWidthHeight {
w: number w: number
h: number h: number
} }

Some files were not shown because too many files have changed in this diff Show more