@tldraw/tlschema 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/bindings/TLBaseBinding.js.map +2 -2
- package/dist-cjs/createTLSchema.js.map +2 -2
- package/dist-cjs/index.d.ts +242 -71
- package/dist-cjs/index.js +4 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/misc/TLOpacity.js +1 -5
- package/dist-cjs/misc/TLOpacity.js.map +2 -2
- package/dist-cjs/misc/TLRichText.js +5 -1
- package/dist-cjs/misc/TLRichText.js.map +2 -2
- package/dist-cjs/misc/b64Vecs.js +224 -0
- package/dist-cjs/misc/b64Vecs.js.map +7 -0
- package/dist-cjs/records/TLAsset.js.map +1 -1
- package/dist-cjs/records/TLBinding.js.map +2 -2
- package/dist-cjs/records/TLShape.js.map +2 -2
- package/dist-cjs/shapes/ShapeWithCrop.js.map +1 -1
- package/dist-cjs/shapes/TLArrowShape.js +26 -13
- package/dist-cjs/shapes/TLArrowShape.js.map +2 -2
- package/dist-cjs/shapes/TLBaseShape.js.map +2 -2
- package/dist-cjs/shapes/TLDrawShape.js +37 -4
- package/dist-cjs/shapes/TLDrawShape.js.map +2 -2
- package/dist-cjs/shapes/TLEmbedShape.js +17 -0
- package/dist-cjs/shapes/TLEmbedShape.js.map +2 -2
- package/dist-cjs/shapes/TLGeoShape.js +12 -1
- package/dist-cjs/shapes/TLGeoShape.js.map +2 -2
- package/dist-cjs/shapes/TLHighlightShape.js +29 -2
- package/dist-cjs/shapes/TLHighlightShape.js.map +2 -2
- package/dist-cjs/shapes/TLNoteShape.js +12 -1
- package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
- package/dist-cjs/shapes/TLTextShape.js +12 -1
- package/dist-cjs/shapes/TLTextShape.js.map +2 -2
- package/dist-cjs/store-migrations.js +15 -15
- package/dist-cjs/store-migrations.js.map +2 -2
- package/dist-esm/bindings/TLBaseBinding.mjs.map +2 -2
- package/dist-esm/createTLSchema.mjs.map +2 -2
- package/dist-esm/index.d.mts +242 -71
- package/dist-esm/index.mjs +5 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/misc/TLOpacity.mjs +1 -5
- package/dist-esm/misc/TLOpacity.mjs.map +2 -2
- package/dist-esm/misc/TLRichText.mjs +5 -1
- package/dist-esm/misc/TLRichText.mjs.map +2 -2
- package/dist-esm/misc/b64Vecs.mjs +204 -0
- package/dist-esm/misc/b64Vecs.mjs.map +7 -0
- package/dist-esm/records/TLAsset.mjs.map +1 -1
- package/dist-esm/records/TLBinding.mjs.map +2 -2
- package/dist-esm/records/TLShape.mjs.map +2 -2
- package/dist-esm/shapes/TLArrowShape.mjs +26 -13
- package/dist-esm/shapes/TLArrowShape.mjs.map +2 -2
- package/dist-esm/shapes/TLBaseShape.mjs.map +2 -2
- package/dist-esm/shapes/TLDrawShape.mjs +37 -4
- package/dist-esm/shapes/TLDrawShape.mjs.map +2 -2
- package/dist-esm/shapes/TLEmbedShape.mjs +17 -0
- package/dist-esm/shapes/TLEmbedShape.mjs.map +2 -2
- package/dist-esm/shapes/TLGeoShape.mjs +12 -1
- package/dist-esm/shapes/TLGeoShape.mjs.map +2 -2
- package/dist-esm/shapes/TLHighlightShape.mjs +29 -2
- package/dist-esm/shapes/TLHighlightShape.mjs.map +2 -2
- package/dist-esm/shapes/TLNoteShape.mjs +12 -1
- package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
- package/dist-esm/shapes/TLTextShape.mjs +12 -1
- package/dist-esm/shapes/TLTextShape.mjs.map +2 -2
- package/dist-esm/store-migrations.mjs +15 -15
- package/dist-esm/store-migrations.mjs.map +2 -2
- package/package.json +8 -8
- package/src/__tests__/migrationTestUtils.ts +9 -3
- package/src/bindings/TLBaseBinding.ts +25 -14
- package/src/createTLSchema.ts +8 -2
- package/src/index.ts +9 -0
- package/src/migrations.test.ts +149 -1
- package/src/misc/TLOpacity.ts +1 -5
- package/src/misc/TLRichText.ts +6 -1
- package/src/misc/b64Vecs.ts +308 -0
- package/src/records/TLAsset.ts +2 -2
- package/src/records/TLBinding.ts +65 -23
- package/src/records/TLShape.ts +100 -5
- package/src/shapes/ShapeWithCrop.ts +2 -2
- package/src/shapes/TLArrowShape.ts +28 -14
- package/src/shapes/TLBaseShape.ts +34 -10
- package/src/shapes/TLDrawShape.ts +59 -12
- package/src/shapes/TLEmbedShape.ts +17 -0
- package/src/shapes/TLGeoShape.ts +14 -1
- package/src/shapes/TLHighlightShape.ts +37 -0
- package/src/shapes/TLNoteShape.ts +15 -1
- package/src/shapes/TLTextShape.ts +16 -2
- package/src/store-migrations.ts +17 -16
- package/src/assets/TLBookmarkAsset.test.ts +0 -96
- package/src/assets/TLImageAsset.test.ts +0 -213
- package/src/assets/TLVideoAsset.test.ts +0 -105
- package/src/bindings/TLArrowBinding.test.ts +0 -55
- package/src/misc/id-validator.test.ts +0 -50
- package/src/records/TLAsset.test.ts +0 -234
- package/src/records/TLBinding.test.ts +0 -22
- package/src/records/TLCamera.test.ts +0 -19
- package/src/records/TLDocument.test.ts +0 -35
- package/src/records/TLInstance.test.ts +0 -201
- package/src/records/TLPage.test.ts +0 -110
- package/src/records/TLPageState.test.ts +0 -228
- package/src/records/TLPointer.test.ts +0 -63
- package/src/records/TLPresence.test.ts +0 -190
- package/src/records/TLRecord.test.ts +0 -70
- package/src/records/TLShape.test.ts +0 -232
- package/src/shapes/ShapeWithCrop.test.ts +0 -18
- package/src/shapes/TLArrowShape.test.ts +0 -505
- package/src/shapes/TLBaseShape.test.ts +0 -142
- package/src/shapes/TLBookmarkShape.test.ts +0 -122
- package/src/shapes/TLDrawShape.test.ts +0 -177
- package/src/shapes/TLEmbedShape.test.ts +0 -286
- package/src/shapes/TLFrameShape.test.ts +0 -71
- package/src/shapes/TLGeoShape.test.ts +0 -247
- package/src/shapes/TLGroupShape.test.ts +0 -59
- package/src/shapes/TLHighlightShape.test.ts +0 -325
- package/src/shapes/TLImageShape.test.ts +0 -534
- package/src/shapes/TLLineShape.test.ts +0 -269
- package/src/shapes/TLNoteShape.test.ts +0 -1568
- package/src/shapes/TLTextShape.test.ts +0 -407
- package/src/shapes/TLVideoShape.test.ts +0 -112
- package/src/styles/TLColorStyle.test.ts +0 -439
package/dist-cjs/index.d.ts
CHANGED
|
@@ -210,6 +210,7 @@ export declare const arrowShapeVersions: {
|
|
|
210
210
|
readonly AddLabelColor: "com.tldraw.shape.arrow/1";
|
|
211
211
|
readonly AddLabelPosition: "com.tldraw.shape.arrow/3";
|
|
212
212
|
readonly AddRichText: "com.tldraw.shape.arrow/7";
|
|
213
|
+
readonly AddRichTextAttrs: "com.tldraw.shape.arrow/8";
|
|
213
214
|
readonly AddScale: "com.tldraw.shape.arrow/5";
|
|
214
215
|
readonly ExtractBindings: "com.tldraw.shape.arrow/4";
|
|
215
216
|
};
|
|
@@ -299,6 +300,59 @@ export declare const AssetRecordType: RecordType<TLAsset, "props" | "type">;
|
|
|
299
300
|
*/
|
|
300
301
|
export declare const assetValidator: T.Validator<TLAsset>;
|
|
301
302
|
|
|
303
|
+
/**
|
|
304
|
+
* Utilities for encoding and decoding points using base64 and Float16 encoding.
|
|
305
|
+
* Provides functions for converting between VecModel arrays and compact base64 strings,
|
|
306
|
+
* as well as individual point encoding/decoding operations.
|
|
307
|
+
*
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
export declare class b64Vecs {
|
|
311
|
+
/**
|
|
312
|
+
* Encode a single point (x, y, z) to 8 base64 characters.
|
|
313
|
+
* Each coordinate is encoded as a Float16 value, resulting in 6 bytes total.
|
|
314
|
+
*
|
|
315
|
+
* @param x - The x coordinate
|
|
316
|
+
* @param y - The y coordinate
|
|
317
|
+
* @param z - The z coordinate
|
|
318
|
+
* @returns An 8-character base64 string representing the point
|
|
319
|
+
*/
|
|
320
|
+
static encodePoint(x: number, y: number, z: number): string;
|
|
321
|
+
/**
|
|
322
|
+
* Convert an array of VecModels to a base64 string for compact storage.
|
|
323
|
+
* Uses Float16 encoding for each coordinate (x, y, z). If a point's z value is
|
|
324
|
+
* undefined, it defaults to 0.5.
|
|
325
|
+
*
|
|
326
|
+
* @param points - An array of VecModel objects to encode
|
|
327
|
+
* @returns A base64-encoded string containing all points
|
|
328
|
+
*/
|
|
329
|
+
static encodePoints(points: VecModel[]): string;
|
|
330
|
+
/**
|
|
331
|
+
* Convert a base64 string back to an array of VecModels.
|
|
332
|
+
* Decodes Float16-encoded coordinates (x, y, z) from the base64 string.
|
|
333
|
+
*
|
|
334
|
+
* @param base64 - The base64-encoded string containing point data
|
|
335
|
+
* @returns An array of VecModel objects decoded from the string
|
|
336
|
+
*/
|
|
337
|
+
static decodePoints(base64: string): VecModel[];
|
|
338
|
+
/* Excluded from this release type: decodePointAt */
|
|
339
|
+
/**
|
|
340
|
+
* Get the first point from a base64-encoded string of points.
|
|
341
|
+
*
|
|
342
|
+
* @param b64Points - The base64-encoded string containing point data
|
|
343
|
+
* @returns The first point as a VecModel, or null if the string is too short
|
|
344
|
+
* @public
|
|
345
|
+
*/
|
|
346
|
+
static decodeFirstPoint(b64Points: string): null | VecModel;
|
|
347
|
+
/**
|
|
348
|
+
* Get the last point from a base64-encoded string of points.
|
|
349
|
+
*
|
|
350
|
+
* @param b64Points - The base64-encoded string containing point data
|
|
351
|
+
* @returns The last point as a VecModel, or null if the string is too short
|
|
352
|
+
*/
|
|
353
|
+
static decodeLastPoint(b64Points: string): null | VecModel;
|
|
354
|
+
}
|
|
355
|
+
|
|
302
356
|
/**
|
|
303
357
|
* Validator for binding IDs. Ensures that binding identifiers follow the correct
|
|
304
358
|
* format and type constraints required by the tldraw schema system.
|
|
@@ -426,6 +480,17 @@ export declare const CameraRecordType: RecordType<TLCamera, never>;
|
|
|
426
480
|
*/
|
|
427
481
|
export declare const canvasUiColorTypeValidator: T.Validator<"accent" | "black" | "laser" | "muted-1" | "selection-fill" | "selection-stroke" | "white">;
|
|
428
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Compress legacy draw shape segments by converting VecModel[] points to base64 format.
|
|
485
|
+
* This function is useful for converting old draw shape data to the new compressed format.
|
|
486
|
+
*
|
|
487
|
+
* @public
|
|
488
|
+
*/
|
|
489
|
+
export declare function compressLegacySegments(segments: {
|
|
490
|
+
points: VecModel[];
|
|
491
|
+
type: 'free' | 'straight';
|
|
492
|
+
}[]): TLDrawShapeSegment[];
|
|
493
|
+
|
|
429
494
|
/**
|
|
430
495
|
* Creates a validator for a specific asset record type. This factory function generates
|
|
431
496
|
* a complete validator that validates the entire asset record structure including the
|
|
@@ -1398,22 +1463,7 @@ export declare const DocumentRecordType: RecordType<TLDocument, never>;
|
|
|
1398
1463
|
*/
|
|
1399
1464
|
export declare const drawShapeMigrations: TLPropsMigrations;
|
|
1400
1465
|
|
|
1401
|
-
/**
|
|
1402
|
-
* Validation schema for draw shape properties.
|
|
1403
|
-
*
|
|
1404
|
-
* @public
|
|
1405
|
-
* @example
|
|
1406
|
-
* ```ts
|
|
1407
|
-
* // Validate draw shape properties
|
|
1408
|
-
* const props = {
|
|
1409
|
-
* color: 'red',
|
|
1410
|
-
* fill: 'solid',
|
|
1411
|
-
* segments: [{ type: 'free', points: [] }],
|
|
1412
|
-
* isComplete: true
|
|
1413
|
-
* }
|
|
1414
|
-
* const isValid = drawShapeProps.color.isValid(props.color)
|
|
1415
|
-
* ```
|
|
1416
|
-
*/
|
|
1466
|
+
/** @public */
|
|
1417
1467
|
export declare const drawShapeProps: RecordProps<TLDrawShape>;
|
|
1418
1468
|
|
|
1419
1469
|
/**
|
|
@@ -1478,6 +1528,24 @@ export declare class EnumStyleProp<T> extends StyleProp<T> {
|
|
|
1478
1528
|
/* Excluded from this release type: __constructor */
|
|
1479
1529
|
}
|
|
1480
1530
|
|
|
1531
|
+
/**
|
|
1532
|
+
* Extract a shape type by its props.
|
|
1533
|
+
*
|
|
1534
|
+
* This utility type takes a props object type and returns the corresponding shape type
|
|
1535
|
+
* from the TLShape union whose props match the given type.
|
|
1536
|
+
*
|
|
1537
|
+
* @example
|
|
1538
|
+
* ```ts
|
|
1539
|
+
* type MyShape = ExtractShapeByProps<{ w: number; h: number }>
|
|
1540
|
+
* // MyShape is now the type of shape(s) that have props with w and h as numbers
|
|
1541
|
+
* ```
|
|
1542
|
+
*
|
|
1543
|
+
* @public
|
|
1544
|
+
*/
|
|
1545
|
+
export declare type ExtractShapeByProps<P> = Extract<TLShape, {
|
|
1546
|
+
props: P;
|
|
1547
|
+
}>;
|
|
1548
|
+
|
|
1481
1549
|
/**
|
|
1482
1550
|
* Migration sequence for frame shape properties across different schema versions.
|
|
1483
1551
|
* Handles adding color properties to existing frame shapes.
|
|
@@ -1519,7 +1587,7 @@ export declare const GeoShapeGeoStyle: EnumStyleProp<"arrow-down" | "arrow-left"
|
|
|
1519
1587
|
/**
|
|
1520
1588
|
* Migration sequence for geo shape properties across different schema versions.
|
|
1521
1589
|
* Handles evolution of geo shapes including URL support, label colors, alignment changes,
|
|
1522
|
-
*
|
|
1590
|
+
* the transition from plain text to rich text, and support for attrs property on richText.
|
|
1523
1591
|
*
|
|
1524
1592
|
* @public
|
|
1525
1593
|
*/
|
|
@@ -1735,20 +1803,7 @@ export declare const groupShapeProps: RecordProps<TLGroupShape>;
|
|
|
1735
1803
|
*/
|
|
1736
1804
|
export declare const highlightShapeMigrations: TLPropsMigrations;
|
|
1737
1805
|
|
|
1738
|
-
/**
|
|
1739
|
-
* Validation schema for highlight shape properties. Defines the runtime validation rules
|
|
1740
|
-
* for all properties of highlight shapes.
|
|
1741
|
-
*
|
|
1742
|
-
* @public
|
|
1743
|
-
* @example
|
|
1744
|
-
* ```ts
|
|
1745
|
-
* import { highlightShapeProps } from '@tldraw/tlschema'
|
|
1746
|
-
*
|
|
1747
|
-
* // Used internally by the validation system
|
|
1748
|
-
* const validator = T.object(highlightShapeProps)
|
|
1749
|
-
* const validatedProps = validator.validate(someHighlightProps)
|
|
1750
|
-
* ```
|
|
1751
|
-
*/
|
|
1806
|
+
/** @public */
|
|
1752
1807
|
export declare const highlightShapeProps: RecordProps<TLHighlightShape>;
|
|
1753
1808
|
|
|
1754
1809
|
/**
|
|
@@ -2197,7 +2252,8 @@ export declare const LineShapeSplineStyle: EnumStyleProp<"cubic" | "line">;
|
|
|
2197
2252
|
* Migration sequence for note shapes. Handles schema evolution over time by defining
|
|
2198
2253
|
* how to upgrade and downgrade note shape data between different versions. Includes
|
|
2199
2254
|
* migrations for URL properties, text alignment changes, vertical alignment addition,
|
|
2200
|
-
* font size adjustments, scaling support, label color,
|
|
2255
|
+
* font size adjustments, scaling support, label color, the transition from plain text to rich text,
|
|
2256
|
+
* and support for attrs property on richText.
|
|
2201
2257
|
*
|
|
2202
2258
|
* @public
|
|
2203
2259
|
*/
|
|
@@ -2394,6 +2450,7 @@ export declare type RecordPropsType<Config extends Record<string, T.Validatable<
|
|
|
2394
2450
|
* ```
|
|
2395
2451
|
*/
|
|
2396
2452
|
export declare const richTextValidator: T.ObjectValidator<{
|
|
2453
|
+
attrs?: any;
|
|
2397
2454
|
content: unknown[];
|
|
2398
2455
|
type: string;
|
|
2399
2456
|
}>;
|
|
@@ -2599,7 +2656,7 @@ export declare const shapeIdValidator: T.Validator<TLShapeId>;
|
|
|
2599
2656
|
*
|
|
2600
2657
|
* @public
|
|
2601
2658
|
*/
|
|
2602
|
-
export declare type ShapeWithCrop =
|
|
2659
|
+
export declare type ShapeWithCrop = ExtractShapeByProps<{
|
|
2603
2660
|
crop: null | TLShapeCrop;
|
|
2604
2661
|
h: number;
|
|
2605
2662
|
w: number;
|
|
@@ -2699,6 +2756,7 @@ export declare type StylePropValue<T extends StyleProp<any>> = T extends StylePr
|
|
|
2699
2756
|
* - RemoveJustify: Replaced 'justify' alignment with 'start'
|
|
2700
2757
|
* - AddTextAlign: Migrated from 'align' to 'textAlign' property
|
|
2701
2758
|
* - AddRichText: Converted plain text to rich text format
|
|
2759
|
+
* - AddRichTextAttrs: Added support for attrs property on richText
|
|
2702
2760
|
*
|
|
2703
2761
|
* @public
|
|
2704
2762
|
*/
|
|
@@ -3140,10 +3198,8 @@ export declare type TLAssetPartial<T extends TLAsset = TLAsset> = T extends T ?
|
|
|
3140
3198
|
*
|
|
3141
3199
|
* @public
|
|
3142
3200
|
*/
|
|
3143
|
-
export declare type TLAssetShape =
|
|
3144
|
-
|
|
3145
|
-
assetId: TLAssetId;
|
|
3146
|
-
};
|
|
3201
|
+
export declare type TLAssetShape = ExtractShapeByProps<{
|
|
3202
|
+
assetId: TLAssetId;
|
|
3147
3203
|
}>;
|
|
3148
3204
|
|
|
3149
3205
|
/**
|
|
@@ -3253,33 +3309,41 @@ export declare interface TLBaseAsset<Type extends string, Props> extends BaseRec
|
|
|
3253
3309
|
* Base interface for all binding types in tldraw. Bindings represent relationships
|
|
3254
3310
|
* between shapes, such as arrows connecting to other shapes or organizational connections.
|
|
3255
3311
|
*
|
|
3256
|
-
* All bindings extend this base interface with specific type and property definitions.
|
|
3312
|
+
* All default bindings extend this base interface with specific type and property definitions.
|
|
3257
3313
|
* The binding system enables shapes to maintain relationships that persist through
|
|
3258
3314
|
* transformations, movements, and other operations.
|
|
3259
3315
|
*
|
|
3316
|
+
* Custom bindings should be defined by augmenting the TLGlobalBindingPropsMap type and getting the binding type from the TLBinding type.
|
|
3317
|
+
*
|
|
3260
3318
|
* @param Type - String literal type identifying the specific binding type (e.g., 'arrow')
|
|
3261
3319
|
* @param Props - Object containing binding-specific properties and configuration
|
|
3262
3320
|
*
|
|
3263
3321
|
* @example
|
|
3264
3322
|
* ```ts
|
|
3265
|
-
* // Define a
|
|
3266
|
-
* interface
|
|
3323
|
+
* // Define a default binding type
|
|
3324
|
+
* interface TLArrowBinding extends TLBaseBinding<'arrow', TLArrowBindingProps> {}
|
|
3267
3325
|
*
|
|
3268
|
-
* interface
|
|
3269
|
-
*
|
|
3270
|
-
*
|
|
3326
|
+
* interface TLArrowBindingProps {
|
|
3327
|
+
* terminal: 'start' | 'end'
|
|
3328
|
+
* normalizedAnchor: VecModel
|
|
3329
|
+
* isExact: boolean
|
|
3330
|
+
* isPrecise: boolean
|
|
3331
|
+
* snap: ElbowArrowSnap
|
|
3271
3332
|
* }
|
|
3272
3333
|
*
|
|
3273
3334
|
* // Create a binding instance
|
|
3274
|
-
* const
|
|
3335
|
+
* const arrowBinding: TLArrowBinding = {
|
|
3275
3336
|
* id: 'binding:abc123',
|
|
3276
3337
|
* typeName: 'binding',
|
|
3277
|
-
* type: '
|
|
3338
|
+
* type: 'arrow',
|
|
3278
3339
|
* fromId: 'shape:source1',
|
|
3279
3340
|
* toId: 'shape:target1',
|
|
3280
3341
|
* props: {
|
|
3281
|
-
*
|
|
3282
|
-
*
|
|
3342
|
+
* terminal: 'end',
|
|
3343
|
+
* normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
3344
|
+
* isExact: false,
|
|
3345
|
+
* isPrecise: true,
|
|
3346
|
+
* snap: 'edge'
|
|
3283
3347
|
* },
|
|
3284
3348
|
* meta: {}
|
|
3285
3349
|
* }
|
|
@@ -3287,7 +3351,9 @@ export declare interface TLBaseAsset<Type extends string, Props> extends BaseRec
|
|
|
3287
3351
|
*
|
|
3288
3352
|
* @public
|
|
3289
3353
|
*/
|
|
3290
|
-
export declare interface TLBaseBinding<Type extends string, Props extends object>
|
|
3354
|
+
export declare interface TLBaseBinding<Type extends string, Props extends object> {
|
|
3355
|
+
readonly id: TLBindingId;
|
|
3356
|
+
readonly typeName: 'binding';
|
|
3291
3357
|
/** The specific type of this binding (e.g., 'arrow', 'custom') */
|
|
3292
3358
|
type: Type;
|
|
3293
3359
|
/** ID of the source shape in this binding relationship */
|
|
@@ -3304,18 +3370,37 @@ export declare interface TLBaseBinding<Type extends string, Props extends object
|
|
|
3304
3370
|
* Base interface for all shapes in tldraw.
|
|
3305
3371
|
*
|
|
3306
3372
|
* This interface defines the common properties that all shapes share, regardless of their
|
|
3307
|
-
* specific type. Every shape extends this base with additional type-specific properties.
|
|
3308
|
-
*
|
|
3309
|
-
*
|
|
3310
|
-
*
|
|
3311
|
-
*
|
|
3312
|
-
*
|
|
3373
|
+
* specific type. Every default shape extends this base with additional type-specific properties.
|
|
3374
|
+
*
|
|
3375
|
+
* Custom shapes should be defined by augmenting the TLGlobalShapePropsMap type and getting the shape type from the TLShape type.
|
|
3376
|
+
*
|
|
3377
|
+
* @example
|
|
3378
|
+
* ```ts
|
|
3379
|
+
* // Define a default shape type
|
|
3380
|
+
* interface TLArrowShape extends TLBaseShape<'arrow', {
|
|
3381
|
+
* kind: TLArrowShapeKind
|
|
3382
|
+
* labelColor: TLDefaultColorStyle
|
|
3383
|
+
* color: TLDefaultColorStyle
|
|
3384
|
+
* fill: TLDefaultFillStyle
|
|
3385
|
+
* dash: TLDefaultDashStyle
|
|
3386
|
+
* size: TLDefaultSizeStyle
|
|
3387
|
+
* arrowheadStart: TLArrowShapeArrowheadStyle
|
|
3388
|
+
* arrowheadEnd: TLArrowShapeArrowheadStyle
|
|
3389
|
+
* font: TLDefaultFontStyle
|
|
3390
|
+
* start: VecModel
|
|
3391
|
+
* end: VecModel
|
|
3392
|
+
* bend: number
|
|
3393
|
+
* richText: TLRichText
|
|
3394
|
+
* labelPosition: number
|
|
3395
|
+
* scale: number
|
|
3396
|
+
* elbowMidPoint: number
|
|
3397
|
+
* }> {}
|
|
3313
3398
|
*
|
|
3314
3399
|
* // Create a shape instance
|
|
3315
|
-
* const
|
|
3400
|
+
* const arrowShape: TLArrowShape = {
|
|
3316
3401
|
* id: 'shape:abc123',
|
|
3317
3402
|
* typeName: 'shape',
|
|
3318
|
-
* type: '
|
|
3403
|
+
* type: 'arrow',
|
|
3319
3404
|
* x: 100,
|
|
3320
3405
|
* y: 200,
|
|
3321
3406
|
* rotation: 0,
|
|
@@ -3324,8 +3409,10 @@ export declare interface TLBaseBinding<Type extends string, Props extends object
|
|
|
3324
3409
|
* isLocked: false,
|
|
3325
3410
|
* opacity: 1,
|
|
3326
3411
|
* props: {
|
|
3327
|
-
*
|
|
3328
|
-
*
|
|
3412
|
+
* kind: 'arc',
|
|
3413
|
+
* start: { x: 0, y: 0 },
|
|
3414
|
+
* end: { x: 100, y: 100 },
|
|
3415
|
+
* // ... other props
|
|
3329
3416
|
* },
|
|
3330
3417
|
* meta: {}
|
|
3331
3418
|
* }
|
|
@@ -3333,7 +3420,9 @@ export declare interface TLBaseBinding<Type extends string, Props extends object
|
|
|
3333
3420
|
*
|
|
3334
3421
|
* @public
|
|
3335
3422
|
*/
|
|
3336
|
-
export declare interface TLBaseShape<Type extends string, Props extends object>
|
|
3423
|
+
export declare interface TLBaseShape<Type extends string, Props extends object> {
|
|
3424
|
+
readonly id: TLShapeId;
|
|
3425
|
+
readonly typeName: 'shape';
|
|
3337
3426
|
type: Type;
|
|
3338
3427
|
x: number;
|
|
3339
3428
|
y: number;
|
|
@@ -3347,9 +3436,12 @@ export declare interface TLBaseShape<Type extends string, Props extends object>
|
|
|
3347
3436
|
}
|
|
3348
3437
|
|
|
3349
3438
|
/**
|
|
3350
|
-
* The set of all bindings that are available in the editor
|
|
3439
|
+
* The set of all bindings that are available in the editor.
|
|
3351
3440
|
* Bindings represent relationships between shapes, such as arrows connecting to other shapes.
|
|
3352
3441
|
*
|
|
3442
|
+
* You can use this type without a type argument to work with any binding, or pass
|
|
3443
|
+
* a specific binding type string (e.g., `'arrow'`) to narrow down to that specific binding type.
|
|
3444
|
+
*
|
|
3353
3445
|
* @example
|
|
3354
3446
|
* ```ts
|
|
3355
3447
|
* // Check binding type and handle accordingly
|
|
@@ -3363,11 +3455,16 @@ export declare interface TLBaseShape<Type extends string, Props extends object>
|
|
|
3363
3455
|
* break
|
|
3364
3456
|
* }
|
|
3365
3457
|
* }
|
|
3458
|
+
*
|
|
3459
|
+
* // Narrow to a specific binding type by passing the type as a generic argument
|
|
3460
|
+
* function getArrowSourceId(binding: TLBinding<'arrow'>) {
|
|
3461
|
+
* return binding.fromId // TypeScript knows this is a TLArrowBinding
|
|
3462
|
+
* }
|
|
3366
3463
|
* ```
|
|
3367
3464
|
*
|
|
3368
3465
|
* @public
|
|
3369
3466
|
*/
|
|
3370
|
-
export declare type TLBinding =
|
|
3467
|
+
export declare type TLBinding<K extends keyof TLIndexedBindings = keyof TLIndexedBindings> = TLIndexedBindings[K];
|
|
3371
3468
|
|
|
3372
3469
|
/**
|
|
3373
3470
|
* Type for creating new bindings with required fromId and toId.
|
|
@@ -3393,7 +3490,7 @@ export declare type TLBinding = TLDefaultBinding | TLUnknownBinding;
|
|
|
3393
3490
|
*
|
|
3394
3491
|
* @public
|
|
3395
3492
|
*/
|
|
3396
|
-
export declare type TLBindingCreate<T extends TLBinding = TLBinding> =
|
|
3493
|
+
export declare type TLBindingCreate<T extends TLBinding = TLBinding> = T extends T ? {
|
|
3397
3494
|
fromId: T['fromId'];
|
|
3398
3495
|
id?: TLBindingId;
|
|
3399
3496
|
meta?: Partial<T['meta']>;
|
|
@@ -3401,7 +3498,7 @@ export declare type TLBindingCreate<T extends TLBinding = TLBinding> = Expand<{
|
|
|
3401
3498
|
toId: T['toId'];
|
|
3402
3499
|
type: T['type'];
|
|
3403
3500
|
typeName?: T['typeName'];
|
|
3404
|
-
}
|
|
3501
|
+
} : never;
|
|
3405
3502
|
|
|
3406
3503
|
/**
|
|
3407
3504
|
* Branded string type for binding record identifiers.
|
|
@@ -3426,7 +3523,7 @@ export declare type TLBindingCreate<T extends TLBinding = TLBinding> = Expand<{
|
|
|
3426
3523
|
*
|
|
3427
3524
|
* @public
|
|
3428
3525
|
*/
|
|
3429
|
-
export declare type TLBindingId = RecordId<
|
|
3526
|
+
export declare type TLBindingId = RecordId<TLBinding>;
|
|
3430
3527
|
|
|
3431
3528
|
/**
|
|
3432
3529
|
* Type for updating existing bindings with partial properties.
|
|
@@ -3448,7 +3545,7 @@ export declare type TLBindingId = RecordId<TLUnknownBinding>;
|
|
|
3448
3545
|
*
|
|
3449
3546
|
* @public
|
|
3450
3547
|
*/
|
|
3451
|
-
export declare type TLBindingUpdate<T extends TLBinding = TLBinding> =
|
|
3548
|
+
export declare type TLBindingUpdate<T extends TLBinding = TLBinding> = T extends T ? {
|
|
3452
3549
|
fromId?: T['fromId'];
|
|
3453
3550
|
id: TLBindingId;
|
|
3454
3551
|
meta?: Partial<T['meta']>;
|
|
@@ -3456,7 +3553,7 @@ export declare type TLBindingUpdate<T extends TLBinding = TLBinding> = Expand<{
|
|
|
3456
3553
|
toId?: T['toId'];
|
|
3457
3554
|
type: T['type'];
|
|
3458
3555
|
typeName?: T['typeName'];
|
|
3459
|
-
}
|
|
3556
|
+
} : never;
|
|
3460
3557
|
|
|
3461
3558
|
/**
|
|
3462
3559
|
* An asset used for URL bookmarks, used by the TLBookmarkShape.
|
|
@@ -3596,6 +3693,39 @@ export declare type TLCameraId = RecordId<TLCamera>;
|
|
|
3596
3693
|
*/
|
|
3597
3694
|
export declare type TLCanvasUiColor = SetValue<typeof TL_CANVAS_UI_COLOR_TYPES>;
|
|
3598
3695
|
|
|
3696
|
+
/**
|
|
3697
|
+
* A partial version of a shape, useful for creating shapes.
|
|
3698
|
+
*
|
|
3699
|
+
* This type represents a shape where all properties except `type` are optional.
|
|
3700
|
+
* It's commonly used when creating shapes.
|
|
3701
|
+
*
|
|
3702
|
+
* @example
|
|
3703
|
+
* ```ts
|
|
3704
|
+
* // Create a shape
|
|
3705
|
+
* const shapeCreate: TLCreateShapePartial = {
|
|
3706
|
+
* type: 'geo',
|
|
3707
|
+
* x: 100,
|
|
3708
|
+
* y: 200
|
|
3709
|
+
* }
|
|
3710
|
+
*
|
|
3711
|
+
* // Create shape properties
|
|
3712
|
+
* const propsCreate: TLCreateShapePartial<TLGeoShape> = {
|
|
3713
|
+
* type: 'geo',
|
|
3714
|
+
* props: {
|
|
3715
|
+
* w: 150,
|
|
3716
|
+
* h: 100
|
|
3717
|
+
* }
|
|
3718
|
+
* }
|
|
3719
|
+
* ```
|
|
3720
|
+
*
|
|
3721
|
+
* @public
|
|
3722
|
+
*/
|
|
3723
|
+
export declare type TLCreateShapePartial<T extends TLShape = TLShape> = T extends T ? {
|
|
3724
|
+
meta?: Partial<T['meta']>;
|
|
3725
|
+
props?: Partial<T['props']>;
|
|
3726
|
+
type: T['type'];
|
|
3727
|
+
} & Partial<Omit<T, 'meta' | 'props' | 'type'>> : never;
|
|
3728
|
+
|
|
3599
3729
|
/**
|
|
3600
3730
|
* A cursor object used throughout the tldraw editor.
|
|
3601
3731
|
*
|
|
@@ -4071,6 +4201,10 @@ export declare interface TLDrawShapeProps {
|
|
|
4071
4201
|
isPen: boolean;
|
|
4072
4202
|
/** Scale factor applied to the drawing */
|
|
4073
4203
|
scale: number;
|
|
4204
|
+
/** Horizontal scale factor for lazy resize */
|
|
4205
|
+
scaleX: number;
|
|
4206
|
+
/** Vertical scale factor for lazy resize */
|
|
4207
|
+
scaleY: number;
|
|
4074
4208
|
}
|
|
4075
4209
|
|
|
4076
4210
|
/**
|
|
@@ -4081,8 +4215,8 @@ export declare interface TLDrawShapeProps {
|
|
|
4081
4215
|
export declare interface TLDrawShapeSegment {
|
|
4082
4216
|
/** Type of drawing segment - 'free' for freehand curves, 'straight' for line segments */
|
|
4083
4217
|
type: 'free' | 'straight';
|
|
4084
|
-
/**
|
|
4085
|
-
points:
|
|
4218
|
+
/** Base64-encoded points (x, y, z triplets stored as Float16) */
|
|
4219
|
+
points: string;
|
|
4086
4220
|
}
|
|
4087
4221
|
|
|
4088
4222
|
/**
|
|
@@ -4260,6 +4394,14 @@ export declare interface TLGeoShapeProps {
|
|
|
4260
4394
|
richText: TLRichText;
|
|
4261
4395
|
}
|
|
4262
4396
|
|
|
4397
|
+
/** @public */
|
|
4398
|
+
export declare interface TLGlobalBindingPropsMap {
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4401
|
+
/** @public */
|
|
4402
|
+
export declare interface TLGlobalShapePropsMap {
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4263
4405
|
/**
|
|
4264
4406
|
* A group shape that acts as a container for organizing multiple shapes into a single logical unit.
|
|
4265
4407
|
* Groups enable users to move, transform, and manage collections of shapes together while maintaining
|
|
@@ -4445,6 +4587,10 @@ export declare interface TLHighlightShapeProps {
|
|
|
4445
4587
|
isPen: boolean;
|
|
4446
4588
|
/** Scale factor applied to the highlight shape for display */
|
|
4447
4589
|
scale: number;
|
|
4590
|
+
/** Horizontal scale factor for lazy resize */
|
|
4591
|
+
scaleX: number;
|
|
4592
|
+
/** Vertical scale factor for lazy resize */
|
|
4593
|
+
scaleY: number;
|
|
4448
4594
|
}
|
|
4449
4595
|
|
|
4450
4596
|
/**
|
|
@@ -4537,6 +4683,22 @@ export declare interface TLImageShapeProps {
|
|
|
4537
4683
|
altText: string;
|
|
4538
4684
|
}
|
|
4539
4685
|
|
|
4686
|
+
/** @public */
|
|
4687
|
+
export declare type TLIndexedBindings = {
|
|
4688
|
+
[K in keyof TLGlobalBindingPropsMap | TLDefaultBinding['type'] as K extends TLDefaultBinding['type'] ? K extends keyof TLGlobalBindingPropsMap ? TLGlobalBindingPropsMap[K] extends null | undefined ? never : K : K : K]: K extends TLDefaultBinding['type'] ? K extends keyof TLGlobalBindingPropsMap ? TLBaseBinding<K, TLGlobalBindingPropsMap[K]> : Extract<TLDefaultBinding, {
|
|
4689
|
+
type: K;
|
|
4690
|
+
}> : TLBaseBinding<K, TLGlobalBindingPropsMap[K & keyof TLGlobalBindingPropsMap]>;
|
|
4691
|
+
};
|
|
4692
|
+
|
|
4693
|
+
/** @public */
|
|
4694
|
+
export declare type TLIndexedShapes = {
|
|
4695
|
+
[K in keyof TLGlobalShapePropsMap | TLDefaultShape['type'] as K extends TLDefaultShape['type'] ? K extends 'group' ? K : K extends keyof TLGlobalShapePropsMap ? TLGlobalShapePropsMap[K] extends null | undefined ? never : K : K : K]: K extends 'group' ? Extract<TLDefaultShape, {
|
|
4696
|
+
type: K;
|
|
4697
|
+
}> : K extends TLDefaultShape['type'] ? K extends keyof TLGlobalShapePropsMap ? TLBaseShape<K, TLGlobalShapePropsMap[K]> : Extract<TLDefaultShape, {
|
|
4698
|
+
type: K;
|
|
4699
|
+
}> : TLBaseShape<K, TLGlobalShapePropsMap[K & keyof TLGlobalShapePropsMap]>;
|
|
4700
|
+
};
|
|
4701
|
+
|
|
4540
4702
|
/**
|
|
4541
4703
|
* State that is particular to a single browser tab. The TLInstance record stores
|
|
4542
4704
|
* all session-specific state including cursor position, selected tools, UI preferences,
|
|
@@ -5372,11 +5534,15 @@ export declare interface TLScribble {
|
|
|
5372
5534
|
export declare type TLSerializedStore = SerializedStore<TLRecord>;
|
|
5373
5535
|
|
|
5374
5536
|
/**
|
|
5375
|
-
* The set of all shapes that are available in the editor
|
|
5537
|
+
* The set of all shapes that are available in the editor.
|
|
5376
5538
|
*
|
|
5377
5539
|
* This is the primary shape type used throughout tldraw. It includes both the
|
|
5378
5540
|
* built-in default shapes and any custom shapes that might be added.
|
|
5379
5541
|
*
|
|
5542
|
+
* You can use this type without a type argument to work with any shape, or pass
|
|
5543
|
+
* a specific shape type string (e.g., `'geo'`, `'arrow'`, `'text'`) to narrow
|
|
5544
|
+
* down to that specific shape type.
|
|
5545
|
+
*
|
|
5380
5546
|
* @example
|
|
5381
5547
|
* ```ts
|
|
5382
5548
|
* // Work with any shape in the editor
|
|
@@ -5387,11 +5553,16 @@ export declare type TLSerializedStore = SerializedStore<TLRecord>;
|
|
|
5387
5553
|
* y: shape.y + deltaY
|
|
5388
5554
|
* }
|
|
5389
5555
|
* }
|
|
5556
|
+
*
|
|
5557
|
+
* // Narrow to a specific shape type by passing the type as a generic argument
|
|
5558
|
+
* function getArrowLabel(shape: TLShape<'arrow'>): string {
|
|
5559
|
+
* return shape.props.text // TypeScript knows this is a TLArrowShape
|
|
5560
|
+
* }
|
|
5390
5561
|
* ```
|
|
5391
5562
|
*
|
|
5392
5563
|
* @public
|
|
5393
5564
|
*/
|
|
5394
|
-
export declare type TLShape =
|
|
5565
|
+
export declare type TLShape<K extends keyof TLIndexedShapes = keyof TLIndexedShapes> = TLIndexedShapes[K];
|
|
5395
5566
|
|
|
5396
5567
|
/**
|
|
5397
5568
|
* Defines cropping parameters for shapes that support cropping.
|
|
@@ -5438,7 +5609,7 @@ export declare interface TLShapeCrop {
|
|
|
5438
5609
|
*
|
|
5439
5610
|
* @public
|
|
5440
5611
|
*/
|
|
5441
|
-
export declare type TLShapeId = RecordId<
|
|
5612
|
+
export declare type TLShapeId = RecordId<TLShape>;
|
|
5442
5613
|
|
|
5443
5614
|
/**
|
|
5444
5615
|
* A partial version of a shape, useful for updates and patches.
|
package/dist-cjs/index.js
CHANGED
|
@@ -62,11 +62,13 @@ __export(index_exports, {
|
|
|
62
62
|
assetIdValidator: () => import_TLBaseAsset.assetIdValidator,
|
|
63
63
|
assetMigrations: () => import_TLAsset.assetMigrations,
|
|
64
64
|
assetValidator: () => import_TLAsset.assetValidator,
|
|
65
|
+
b64Vecs: () => import_b64Vecs.b64Vecs,
|
|
65
66
|
bindingIdValidator: () => import_TLBaseBinding.bindingIdValidator,
|
|
66
67
|
bookmarkShapeMigrations: () => import_TLBookmarkShape.bookmarkShapeMigrations,
|
|
67
68
|
bookmarkShapeProps: () => import_TLBookmarkShape.bookmarkShapeProps,
|
|
68
69
|
boxModelValidator: () => import_geometry_types.boxModelValidator,
|
|
69
70
|
canvasUiColorTypeValidator: () => import_TLColor.canvasUiColorTypeValidator,
|
|
71
|
+
compressLegacySegments: () => import_TLDrawShape.compressLegacySegments,
|
|
70
72
|
createAssetValidator: () => import_TLBaseAsset.createAssetValidator,
|
|
71
73
|
createBindingId: () => import_TLBinding.createBindingId,
|
|
72
74
|
createBindingPropsMigrationIds: () => import_TLBinding.createBindingPropsMigrationIds,
|
|
@@ -176,9 +178,10 @@ var import_TLSizeStyle = require("./styles/TLSizeStyle");
|
|
|
176
178
|
var import_TLTextAlignStyle = require("./styles/TLTextAlignStyle");
|
|
177
179
|
var import_TLVerticalAlignStyle = require("./styles/TLVerticalAlignStyle");
|
|
178
180
|
var import_translations = require("./translations/translations");
|
|
181
|
+
var import_b64Vecs = require("./misc/b64Vecs");
|
|
179
182
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
180
183
|
"@tldraw/tlschema",
|
|
181
|
-
"4.2.
|
|
184
|
+
"4.2.2",
|
|
182
185
|
"cjs"
|
|
183
186
|
);
|
|
184
187
|
//# sourceMappingURL=index.js.map
|
package/dist-cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview\n * Main entry point for the tldraw schema package. Exports the complete type system,\n * data structures, validation, and migrations for tldraw's persisted data.\n *\n * This package provides:\n * - Schema creation utilities (createTLSchema, defaultShapeSchemas, defaultBindingSchemas)\n * - All built-in shape types (TLGeoShape, TLTextShape, TLArrowShape, etc.)\n * - Asset management types and validators (TLImageAsset, TLVideoAsset, TLBookmarkAsset)\n * - Binding system for shape relationships (TLArrowBinding)\n * - Store integration types (TLStore, TLStoreProps, TLStoreSnapshot)\n * - Style properties for consistent styling (DefaultColorStyle, DefaultSizeStyle, etc.)\n * - Validation utilities and type guards\n * - Migration systems for schema evolution\n * - Geometry and utility types\n *\n * @example\n * ```ts\n * import { createTLSchema, defaultShapeSchemas, TLStore } from '@tldraw/tlschema'\n *\n * // Create a schema with default shapes\n * const schema = createTLSchema({\n * shapes: defaultShapeSchemas\n * })\n *\n * // Use with a store\n * const store = new Store({ schema })\n * ```\n *\n * @public\n */\n\nimport { registerTldrawLibraryVersion } from '@tldraw/utils'\nexport { assetIdValidator, createAssetValidator, type TLBaseAsset } from './assets/TLBaseAsset'\nexport { type TLBookmarkAsset } from './assets/TLBookmarkAsset'\nexport { type TLImageAsset } from './assets/TLImageAsset'\nexport { type TLVideoAsset } from './assets/TLVideoAsset'\nexport {\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tarrowBindingVersions,\n\tElbowArrowSnap,\n\ttype TLArrowBinding,\n\ttype TLArrowBindingProps,\n} from './bindings/TLArrowBinding'\nexport {\n\tbindingIdValidator,\n\tcreateBindingValidator,\n\ttype TLBaseBinding,\n} from './bindings/TLBaseBinding'\nexport {\n\tcreatePresenceStateDerivation,\n\tgetDefaultUserPresence,\n\ttype TLPresenceStateInfo,\n\ttype TLPresenceUserInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype TLSchema,\n} from './createTLSchema'\nexport {\n\tboxModelValidator,\n\tvecModelValidator,\n\ttype BoxModel,\n\ttype VecModel,\n} from './misc/geometry-types'\nexport { idValidator } from './misc/id-validator'\nexport {\n\tcanvasUiColorTypeValidator,\n\tTL_CANVAS_UI_COLOR_TYPES,\n\ttype TLCanvasUiColor,\n} from './misc/TLColor'\nexport { TL_CURSOR_TYPES, type TLCursor, type TLCursorType } from './misc/TLCursor'\nexport { TL_HANDLE_TYPES, type TLHandle, type TLHandleType } from './misc/TLHandle'\nexport { opacityValidator, type TLOpacityType } from './misc/TLOpacity'\nexport { richTextValidator, toRichText, type TLRichText } from './misc/TLRichText'\nexport { scribbleValidator, TL_SCRIBBLE_STATES, type TLScribble } from './misc/TLScribble'\nexport {\n\tassetMigrations,\n\tAssetRecordType,\n\tassetValidator,\n\ttype TLAsset,\n\ttype TLAssetId,\n\ttype TLAssetPartial,\n\ttype TLAssetShape,\n} from './records/TLAsset'\nexport {\n\tcreateBindingId,\n\tcreateBindingPropsMigrationIds,\n\tcreateBindingPropsMigrationSequence,\n\tisBinding,\n\tisBindingId,\n\trootBindingMigrations,\n\ttype TLBinding,\n\ttype TLBindingCreate,\n\ttype TLBindingId,\n\ttype TLBindingUpdate,\n\ttype TLDefaultBinding,\n\ttype TLUnknownBinding,\n} from './records/TLBinding'\nexport { CameraRecordType, type TLCamera, type TLCameraId } from './records/TLCamera'\nexport {\n\tDocumentRecordType,\n\tisDocument,\n\tTLDOCUMENT_ID,\n\ttype TLDocument,\n} from './records/TLDocument'\nexport {\n\tpluckPreservingValues,\n\tTLINSTANCE_ID,\n\ttype TLInstance,\n\ttype TLInstanceId,\n} from './records/TLInstance'\nexport {\n\tisPageId,\n\tpageIdValidator,\n\tPageRecordType,\n\ttype TLPage,\n\ttype TLPageId,\n} from './records/TLPage'\nexport {\n\tInstancePageStateRecordType,\n\ttype TLInstancePageState,\n\ttype TLInstancePageStateId,\n} from './records/TLPageState'\nexport {\n\tPointerRecordType,\n\tTLPOINTER_ID,\n\ttype TLPointer,\n\ttype TLPointerId,\n} from './records/TLPointer'\nexport {\n\tInstancePresenceRecordType,\n\ttype TLInstancePresence,\n\ttype TLInstancePresenceID,\n} from './records/TLPresence'\nexport { type TLRecord } from './records/TLRecord'\nexport {\n\tcreateShapeId,\n\tcreateShapePropsMigrationIds,\n\tcreateShapePropsMigrationSequence,\n\tgetShapePropKeysByStyle,\n\tisShape,\n\tisShapeId,\n\trootShapeMigrations,\n\ttype TLDefaultShape,\n\ttype TLParentId,\n\ttype TLShape,\n\ttype TLShapeId,\n\ttype TLShapePartial,\n\ttype TLUnknownShape,\n} from './records/TLShape'\nexport {\n\ttype RecordProps,\n\ttype RecordPropsType,\n\ttype TLPropsMigration,\n\ttype TLPropsMigrations,\n} from './recordsWithProps'\nexport { type ShapeWithCrop, type TLShapeCrop } from './shapes/ShapeWithCrop'\nexport {\n\tArrowShapeArrowheadEndStyle,\n\tArrowShapeArrowheadStartStyle,\n\tArrowShapeKindStyle,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tarrowShapeVersions,\n\ttype TLArrowShape,\n\ttype TLArrowShapeArrowheadStyle,\n\ttype TLArrowShapeKind,\n\ttype TLArrowShapeProps,\n} from './shapes/TLArrowShape'\nexport {\n\tcreateShapeValidator,\n\tparentIdValidator,\n\tshapeIdValidator,\n\ttype TLBaseShape,\n} from './shapes/TLBaseShape'\nexport {\n\tbookmarkShapeMigrations,\n\tbookmarkShapeProps,\n\ttype TLBookmarkShape,\n\ttype TLBookmarkShapeProps,\n} from './shapes/TLBookmarkShape'\nexport {\n\tdrawShapeMigrations,\n\tdrawShapeProps,\n\ttype TLDrawShape,\n\ttype TLDrawShapeProps,\n\ttype TLDrawShapeSegment,\n} from './shapes/TLDrawShape'\nexport {\n\tembedShapeMigrations,\n\tembedShapeProps,\n\ttype TLEmbedShape,\n\ttype TLEmbedShapeProps,\n} from './shapes/TLEmbedShape'\nexport {\n\tframeShapeMigrations,\n\tframeShapeProps,\n\ttype TLFrameShape,\n\ttype TLFrameShapeProps,\n} from './shapes/TLFrameShape'\nexport {\n\tGeoShapeGeoStyle,\n\tgeoShapeMigrations,\n\tgeoShapeProps,\n\ttype TLGeoShape,\n\ttype TLGeoShapeGeoStyle,\n\ttype TLGeoShapeProps,\n} from './shapes/TLGeoShape'\nexport {\n\tgroupShapeMigrations,\n\tgroupShapeProps,\n\ttype TLGroupShape,\n\ttype TLGroupShapeProps,\n} from './shapes/TLGroupShape'\nexport {\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\ttype TLHighlightShape,\n\ttype TLHighlightShapeProps,\n} from './shapes/TLHighlightShape'\nexport {\n\tImageShapeCrop,\n\timageShapeMigrations,\n\timageShapeProps,\n\ttype TLImageShape,\n\ttype TLImageShapeProps,\n} from './shapes/TLImageShape'\nexport {\n\tlineShapeMigrations,\n\tlineShapeProps,\n\tLineShapeSplineStyle,\n\ttype TLLineShape,\n\ttype TLLineShapePoint,\n\ttype TLLineShapeProps,\n\ttype TLLineShapeSplineStyle,\n} from './shapes/TLLineShape'\nexport {\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\ttype TLNoteShape,\n\ttype TLNoteShapeProps,\n} from './shapes/TLNoteShape'\nexport {\n\ttextShapeMigrations,\n\ttextShapeProps,\n\ttype TLTextShape,\n\ttype TLTextShapeProps,\n} from './shapes/TLTextShape'\nexport {\n\tvideoShapeMigrations,\n\tvideoShapeProps,\n\ttype TLVideoShape,\n\ttype TLVideoShapeProps,\n} from './shapes/TLVideoShape'\nexport { EnumStyleProp, StyleProp, type StylePropValue } from './styles/StyleProp'\nexport {\n\tdefaultColorNames,\n\tDefaultColorStyle,\n\tDefaultColorThemePalette,\n\tDefaultLabelColorStyle,\n\tgetColorValue,\n\tgetDefaultColorTheme,\n\ttype TLDefaultColorStyle,\n\ttype TLDefaultColorTheme,\n\ttype TLDefaultColorThemeColor,\n} from './styles/TLColorStyle'\nexport { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'\nexport { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\ttype TLDefaultFontStyle,\n} from './styles/TLFontStyle'\nexport {\n\tDefaultHorizontalAlignStyle,\n\ttype TLDefaultHorizontalAlignStyle,\n} from './styles/TLHorizontalAlignStyle'\nexport { DefaultSizeStyle, type TLDefaultSizeStyle } from './styles/TLSizeStyle'\nexport { DefaultTextAlignStyle, type TLDefaultTextAlignStyle } from './styles/TLTextAlignStyle'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype TLDefaultVerticalAlignStyle,\n} from './styles/TLVerticalAlignStyle'\nexport {\n\ttype TLAssetContext,\n\ttype TLAssetStore,\n\ttype TLSerializedStore,\n\ttype TLStore,\n\ttype TLStoreProps,\n\ttype TLStoreSchema,\n\ttype TLStoreSnapshot,\n} from './TLStore'\nexport {\n\tgetDefaultTranslationLocale,\n\tLANGUAGES,\n\ttype TLLanguage,\n} from './translations/translations'\nexport { type SetValue } from './util-types'\n\nregisterTldrawLibraryVersion(\n\t(globalThis as any).TLDRAW_LIBRARY_NAME,\n\t(globalThis as any).TLDRAW_LIBRARY_VERSION,\n\t(globalThis as any).TLDRAW_LIBRARY_MODULES\n)\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCA,mBAA6C;AAC7C,yBAAyE;AAIzE,4BAOO;AACP,2BAIO;AACP,2CAKO;AACP,4BAMO;AACP,4BAKO;AACP,0BAA4B;AAC5B,qBAIO;AACP,sBAAkE;AAClE,sBAAkE;AAClE,uBAAqD;AACrD,wBAA+D;AAC/D,wBAAuE;AACvE,qBAQO;AACP,
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview\n * Main entry point for the tldraw schema package. Exports the complete type system,\n * data structures, validation, and migrations for tldraw's persisted data.\n *\n * This package provides:\n * - Schema creation utilities (createTLSchema, defaultShapeSchemas, defaultBindingSchemas)\n * - All built-in shape types (TLGeoShape, TLTextShape, TLArrowShape, etc.)\n * - Asset management types and validators (TLImageAsset, TLVideoAsset, TLBookmarkAsset)\n * - Binding system for shape relationships (TLArrowBinding)\n * - Store integration types (TLStore, TLStoreProps, TLStoreSnapshot)\n * - Style properties for consistent styling (DefaultColorStyle, DefaultSizeStyle, etc.)\n * - Validation utilities and type guards\n * - Migration systems for schema evolution\n * - Geometry and utility types\n *\n * @example\n * ```ts\n * import { createTLSchema, defaultShapeSchemas, TLStore } from '@tldraw/tlschema'\n *\n * // Create a schema with default shapes\n * const schema = createTLSchema({\n * shapes: defaultShapeSchemas\n * })\n *\n * // Use with a store\n * const store = new Store({ schema })\n * ```\n *\n * @public\n */\n\nimport { registerTldrawLibraryVersion } from '@tldraw/utils'\nexport { assetIdValidator, createAssetValidator, type TLBaseAsset } from './assets/TLBaseAsset'\nexport { type TLBookmarkAsset } from './assets/TLBookmarkAsset'\nexport { type TLImageAsset } from './assets/TLImageAsset'\nexport { type TLVideoAsset } from './assets/TLVideoAsset'\nexport {\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tarrowBindingVersions,\n\tElbowArrowSnap,\n\ttype TLArrowBinding,\n\ttype TLArrowBindingProps,\n} from './bindings/TLArrowBinding'\nexport {\n\tbindingIdValidator,\n\tcreateBindingValidator,\n\ttype TLBaseBinding,\n} from './bindings/TLBaseBinding'\nexport {\n\tcreatePresenceStateDerivation,\n\tgetDefaultUserPresence,\n\ttype TLPresenceStateInfo,\n\ttype TLPresenceUserInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype TLSchema,\n} from './createTLSchema'\nexport {\n\tboxModelValidator,\n\tvecModelValidator,\n\ttype BoxModel,\n\ttype VecModel,\n} from './misc/geometry-types'\nexport { idValidator } from './misc/id-validator'\nexport {\n\tcanvasUiColorTypeValidator,\n\tTL_CANVAS_UI_COLOR_TYPES,\n\ttype TLCanvasUiColor,\n} from './misc/TLColor'\nexport { TL_CURSOR_TYPES, type TLCursor, type TLCursorType } from './misc/TLCursor'\nexport { TL_HANDLE_TYPES, type TLHandle, type TLHandleType } from './misc/TLHandle'\nexport { opacityValidator, type TLOpacityType } from './misc/TLOpacity'\nexport { richTextValidator, toRichText, type TLRichText } from './misc/TLRichText'\nexport { scribbleValidator, TL_SCRIBBLE_STATES, type TLScribble } from './misc/TLScribble'\nexport {\n\tassetMigrations,\n\tAssetRecordType,\n\tassetValidator,\n\ttype TLAsset,\n\ttype TLAssetId,\n\ttype TLAssetPartial,\n\ttype TLAssetShape,\n} from './records/TLAsset'\nexport {\n\tcreateBindingId,\n\tcreateBindingPropsMigrationIds,\n\tcreateBindingPropsMigrationSequence,\n\tisBinding,\n\tisBindingId,\n\trootBindingMigrations,\n\ttype TLBinding,\n\ttype TLBindingCreate,\n\ttype TLBindingId,\n\ttype TLBindingUpdate,\n\ttype TLDefaultBinding,\n\ttype TLGlobalBindingPropsMap,\n\ttype TLIndexedBindings,\n\ttype TLUnknownBinding,\n} from './records/TLBinding'\nexport { CameraRecordType, type TLCamera, type TLCameraId } from './records/TLCamera'\nexport {\n\tDocumentRecordType,\n\tisDocument,\n\tTLDOCUMENT_ID,\n\ttype TLDocument,\n} from './records/TLDocument'\nexport {\n\tpluckPreservingValues,\n\tTLINSTANCE_ID,\n\ttype TLInstance,\n\ttype TLInstanceId,\n} from './records/TLInstance'\nexport {\n\tisPageId,\n\tpageIdValidator,\n\tPageRecordType,\n\ttype TLPage,\n\ttype TLPageId,\n} from './records/TLPage'\nexport {\n\tInstancePageStateRecordType,\n\ttype TLInstancePageState,\n\ttype TLInstancePageStateId,\n} from './records/TLPageState'\nexport {\n\tPointerRecordType,\n\tTLPOINTER_ID,\n\ttype TLPointer,\n\ttype TLPointerId,\n} from './records/TLPointer'\nexport {\n\tInstancePresenceRecordType,\n\ttype TLInstancePresence,\n\ttype TLInstancePresenceID,\n} from './records/TLPresence'\nexport { type TLRecord } from './records/TLRecord'\nexport {\n\tcreateShapeId,\n\tcreateShapePropsMigrationIds,\n\tcreateShapePropsMigrationSequence,\n\tgetShapePropKeysByStyle,\n\tisShape,\n\tisShapeId,\n\trootShapeMigrations,\n\ttype ExtractShapeByProps,\n\ttype TLCreateShapePartial,\n\ttype TLDefaultShape,\n\ttype TLGlobalShapePropsMap,\n\ttype TLIndexedShapes,\n\ttype TLParentId,\n\ttype TLShape,\n\ttype TLShapeId,\n\ttype TLShapePartial,\n\ttype TLUnknownShape,\n} from './records/TLShape'\nexport {\n\ttype RecordProps,\n\ttype RecordPropsType,\n\ttype TLPropsMigration,\n\ttype TLPropsMigrations,\n} from './recordsWithProps'\nexport { type ShapeWithCrop, type TLShapeCrop } from './shapes/ShapeWithCrop'\nexport {\n\tArrowShapeArrowheadEndStyle,\n\tArrowShapeArrowheadStartStyle,\n\tArrowShapeKindStyle,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tarrowShapeVersions,\n\ttype TLArrowShape,\n\ttype TLArrowShapeArrowheadStyle,\n\ttype TLArrowShapeKind,\n\ttype TLArrowShapeProps,\n} from './shapes/TLArrowShape'\nexport {\n\tcreateShapeValidator,\n\tparentIdValidator,\n\tshapeIdValidator,\n\ttype TLBaseShape,\n} from './shapes/TLBaseShape'\nexport {\n\tbookmarkShapeMigrations,\n\tbookmarkShapeProps,\n\ttype TLBookmarkShape,\n\ttype TLBookmarkShapeProps,\n} from './shapes/TLBookmarkShape'\nexport {\n\tcompressLegacySegments,\n\tdrawShapeMigrations,\n\tdrawShapeProps,\n\ttype TLDrawShape,\n\ttype TLDrawShapeProps,\n\ttype TLDrawShapeSegment,\n} from './shapes/TLDrawShape'\nexport {\n\tembedShapeMigrations,\n\tembedShapeProps,\n\ttype TLEmbedShape,\n\ttype TLEmbedShapeProps,\n} from './shapes/TLEmbedShape'\nexport {\n\tframeShapeMigrations,\n\tframeShapeProps,\n\ttype TLFrameShape,\n\ttype TLFrameShapeProps,\n} from './shapes/TLFrameShape'\nexport {\n\tGeoShapeGeoStyle,\n\tgeoShapeMigrations,\n\tgeoShapeProps,\n\ttype TLGeoShape,\n\ttype TLGeoShapeGeoStyle,\n\ttype TLGeoShapeProps,\n} from './shapes/TLGeoShape'\nexport {\n\tgroupShapeMigrations,\n\tgroupShapeProps,\n\ttype TLGroupShape,\n\ttype TLGroupShapeProps,\n} from './shapes/TLGroupShape'\nexport {\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\ttype TLHighlightShape,\n\ttype TLHighlightShapeProps,\n} from './shapes/TLHighlightShape'\nexport {\n\tImageShapeCrop,\n\timageShapeMigrations,\n\timageShapeProps,\n\ttype TLImageShape,\n\ttype TLImageShapeProps,\n} from './shapes/TLImageShape'\nexport {\n\tlineShapeMigrations,\n\tlineShapeProps,\n\tLineShapeSplineStyle,\n\ttype TLLineShape,\n\ttype TLLineShapePoint,\n\ttype TLLineShapeProps,\n\ttype TLLineShapeSplineStyle,\n} from './shapes/TLLineShape'\nexport {\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\ttype TLNoteShape,\n\ttype TLNoteShapeProps,\n} from './shapes/TLNoteShape'\nexport {\n\ttextShapeMigrations,\n\ttextShapeProps,\n\ttype TLTextShape,\n\ttype TLTextShapeProps,\n} from './shapes/TLTextShape'\nexport {\n\tvideoShapeMigrations,\n\tvideoShapeProps,\n\ttype TLVideoShape,\n\ttype TLVideoShapeProps,\n} from './shapes/TLVideoShape'\nexport { EnumStyleProp, StyleProp, type StylePropValue } from './styles/StyleProp'\nexport {\n\tdefaultColorNames,\n\tDefaultColorStyle,\n\tDefaultColorThemePalette,\n\tDefaultLabelColorStyle,\n\tgetColorValue,\n\tgetDefaultColorTheme,\n\ttype TLDefaultColorStyle,\n\ttype TLDefaultColorTheme,\n\ttype TLDefaultColorThemeColor,\n} from './styles/TLColorStyle'\nexport { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'\nexport { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\ttype TLDefaultFontStyle,\n} from './styles/TLFontStyle'\nexport {\n\tDefaultHorizontalAlignStyle,\n\ttype TLDefaultHorizontalAlignStyle,\n} from './styles/TLHorizontalAlignStyle'\nexport { DefaultSizeStyle, type TLDefaultSizeStyle } from './styles/TLSizeStyle'\nexport { DefaultTextAlignStyle, type TLDefaultTextAlignStyle } from './styles/TLTextAlignStyle'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype TLDefaultVerticalAlignStyle,\n} from './styles/TLVerticalAlignStyle'\nexport {\n\ttype TLAssetContext,\n\ttype TLAssetStore,\n\ttype TLSerializedStore,\n\ttype TLStore,\n\ttype TLStoreProps,\n\ttype TLStoreSchema,\n\ttype TLStoreSnapshot,\n} from './TLStore'\nexport {\n\tgetDefaultTranslationLocale,\n\tLANGUAGES,\n\ttype TLLanguage,\n} from './translations/translations'\nexport { type SetValue } from './util-types'\n\nregisterTldrawLibraryVersion(\n\t(globalThis as any).TLDRAW_LIBRARY_NAME,\n\t(globalThis as any).TLDRAW_LIBRARY_VERSION,\n\t(globalThis as any).TLDRAW_LIBRARY_MODULES\n)\n\nexport { b64Vecs } from './misc/b64Vecs'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCA,mBAA6C;AAC7C,yBAAyE;AAIzE,4BAOO;AACP,2BAIO;AACP,2CAKO;AACP,4BAMO;AACP,4BAKO;AACP,0BAA4B;AAC5B,qBAIO;AACP,sBAAkE;AAClE,sBAAkE;AAClE,uBAAqD;AACrD,wBAA+D;AAC/D,wBAAuE;AACvE,qBAQO;AACP,uBAeO;AACP,sBAAiE;AACjE,wBAKO;AACP,wBAKO;AACP,oBAMO;AACP,yBAIO;AACP,uBAKO;AACP,wBAIO;AAEP,qBAkBO;AAQP,0BAWO;AACP,yBAKO;AACP,6BAKO;AACP,yBAOO;AACP,0BAKO;AACP,0BAKO;AACP,wBAOO;AACP,0BAKO;AACP,8BAKO;AACP,0BAMO;AACP,yBAQO;AACP,yBAKO;AACP,yBAKO;AACP,0BAKO;AACP,uBAA8D;AAC9D,0BAUO;AACP,yBAA0D;AAC1D,yBAA0D;AAC1D,yBAIO;AACP,oCAGO;AACP,yBAA0D;AAC1D,8BAAoE;AACpE,kCAGO;AAUP,0BAIO;AASP,qBAAwB;AAAA,IANxB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,9 +22,5 @@ __export(TLOpacity_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(TLOpacity_exports);
|
|
24
24
|
var import_validate = require("@tldraw/validate");
|
|
25
|
-
const opacityValidator = import_validate.T.
|
|
26
|
-
if (n < 0 || n > 1) {
|
|
27
|
-
throw new import_validate.T.ValidationError("Opacity must be between 0 and 1");
|
|
28
|
-
}
|
|
29
|
-
});
|
|
25
|
+
const opacityValidator = import_validate.T.unitInterval;
|
|
30
26
|
//# sourceMappingURL=TLOpacity.js.map
|