@tldraw/tlschema 5.2.0-next.ee0fa4d6244f → 5.2.1
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/DOCS.md +682 -0
- package/README.md +9 -1
- package/dist-cjs/index.d.ts +85 -11
- package/dist-cjs/index.js +3 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/misc/b64Vecs.js +175 -10
- package/dist-cjs/misc/b64Vecs.js.map +2 -2
- package/dist-cjs/records/TLInstance.js +3 -2
- package/dist-cjs/records/TLInstance.js.map +2 -2
- package/dist-cjs/records/TLPageState.js +5 -1
- package/dist-cjs/records/TLPageState.js.map +2 -2
- package/dist-cjs/records/TLPresence.js +3 -2
- package/dist-cjs/records/TLPresence.js.map +2 -2
- package/dist-cjs/shapes/TLDrawShape.js +16 -2
- package/dist-cjs/shapes/TLDrawShape.js.map +2 -2
- package/dist-cjs/shapes/TLHighlightShape.js +14 -1
- package/dist-cjs/shapes/TLHighlightShape.js.map +2 -2
- package/dist-cjs/shapes/TLNoteShape.js +14 -2
- package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
- package/dist-esm/index.d.mts +85 -11
- package/dist-esm/index.mjs +4 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/misc/b64Vecs.mjs +175 -10
- package/dist-esm/misc/b64Vecs.mjs.map +2 -2
- package/dist-esm/records/TLInstance.mjs +3 -2
- package/dist-esm/records/TLInstance.mjs.map +2 -2
- package/dist-esm/records/TLPageState.mjs +5 -1
- package/dist-esm/records/TLPageState.mjs.map +2 -2
- package/dist-esm/records/TLPresence.mjs +3 -2
- package/dist-esm/records/TLPresence.mjs.map +2 -2
- package/dist-esm/shapes/TLDrawShape.mjs +17 -3
- package/dist-esm/shapes/TLDrawShape.mjs.map +2 -2
- package/dist-esm/shapes/TLHighlightShape.mjs +15 -2
- package/dist-esm/shapes/TLHighlightShape.mjs.map +2 -2
- package/dist-esm/shapes/TLNoteShape.mjs +14 -2
- package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
- package/package.json +11 -7
- package/src/index.ts +1 -1
- package/src/migrations.test.ts +136 -1
- package/src/misc/b64Vecs.test.ts +112 -0
- package/src/misc/b64Vecs.ts +230 -15
- package/src/records/TLInstance.ts +5 -4
- package/src/records/TLPageState.ts +5 -1
- package/src/records/TLPresence.ts +5 -4
- package/src/shapes/TLDrawShape.ts +30 -1
- package/src/shapes/TLHighlightShape.ts +19 -1
- package/src/shapes/TLNoteShape.ts +15 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -285,38 +285,100 @@ export declare class b64Vecs {
|
|
|
285
285
|
* - Delta points: 3 Float16 values each = 6 bytes = 8 base64 chars each
|
|
286
286
|
*
|
|
287
287
|
* @param points - An array of VecModel objects to encode
|
|
288
|
+
* @param dim - Encoding dimension; `2` routes through the 2D variant (drops z), `3` (default) keeps x, y, z
|
|
288
289
|
* @returns A base64-encoded string containing delta-encoded points
|
|
289
290
|
* @public
|
|
290
291
|
*/
|
|
291
|
-
static encodePoints(points: VecModel[]): string;
|
|
292
|
+
static encodePoints(points: VecModel[], dim?: 2 | 3): string;
|
|
292
293
|
/**
|
|
293
294
|
* Decode a delta-encoded base64 string back to an array of absolute VecModels.
|
|
294
295
|
* The first point is stored as Float32 (high precision), subsequent points are
|
|
295
296
|
* Float16 deltas that are accumulated to reconstruct absolute positions.
|
|
296
297
|
*
|
|
297
298
|
* @param base64 - The base64-encoded string containing delta-encoded point data
|
|
299
|
+
* @param dim - Encoding dimension; `2` expects x/y only (z supplied as 0.5), `3` (default) expects x/y/z
|
|
298
300
|
* @returns An array of VecModel objects with absolute coordinates
|
|
299
301
|
* @public
|
|
300
302
|
*/
|
|
301
|
-
static decodePoints(base64: string): VecModel[];
|
|
303
|
+
static decodePoints(base64: string, dim?: 2 | 3): VecModel[];
|
|
302
304
|
/**
|
|
303
305
|
* Get the first point from a delta-encoded base64 string.
|
|
304
306
|
* The first point is stored as Float32 for full precision.
|
|
305
307
|
*
|
|
306
308
|
* @param b64Points - The delta-encoded base64 string
|
|
309
|
+
* @param dim - Encoding dimension; `2` expects x/y only (z supplied as 0.5), `3` (default) expects x/y/z
|
|
307
310
|
* @returns The first point as a VecModel, or null if the string is too short
|
|
308
311
|
* @public
|
|
309
312
|
*/
|
|
310
|
-
static decodeFirstPoint(b64Points: string): null | VecModel;
|
|
313
|
+
static decodeFirstPoint(b64Points: string, dim?: 2 | 3): null | VecModel;
|
|
311
314
|
/**
|
|
312
315
|
* Get the last point from a delta-encoded base64 string.
|
|
313
316
|
* Requires decoding all points to accumulate deltas.
|
|
314
317
|
*
|
|
315
318
|
* @param b64Points - The delta-encoded base64 string
|
|
319
|
+
* @param dim - Encoding dimension; `2` expects x/y only (z supplied as 0.5), `3` (default) expects x/y/z
|
|
316
320
|
* @returns The last point as a VecModel, or null if the string is too short
|
|
317
321
|
* @public
|
|
318
322
|
*/
|
|
319
|
-
static decodeLastPoint(b64Points: string): null | VecModel;
|
|
323
|
+
static decodeLastPoint(b64Points: string, dim?: 2 | 3): null | VecModel;
|
|
324
|
+
/**
|
|
325
|
+
* Encode an array of VecModels as 2D delta-encoded points, dropping z entirely.
|
|
326
|
+
* Use for draw shapes from devices that don't report pressure, where z is a
|
|
327
|
+
* constant 0.5 and storing it wastes ~33% of per-point bytes.
|
|
328
|
+
*
|
|
329
|
+
* Format:
|
|
330
|
+
* - First point: 2 Float32 values (x, y) = 8 bytes
|
|
331
|
+
* - Delta points: 2 Float16 values (dx, dy) = 4 bytes each
|
|
332
|
+
*
|
|
333
|
+
* @param points - An array of VecModel objects to encode (z is discarded)
|
|
334
|
+
* @returns A base64-encoded string containing 2D delta-encoded points
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
static encodePoints2D(points: VecModel[]): string;
|
|
338
|
+
/**
|
|
339
|
+
* Decode a 2D delta-encoded base64 string back to an array of absolute VecModels.
|
|
340
|
+
* The z coordinate is always set to 0.5 (the default pressure value) so downstream
|
|
341
|
+
* consumers don't need a separate code path.
|
|
342
|
+
*
|
|
343
|
+
* @param base64 - The base64-encoded string containing 2D delta-encoded point data
|
|
344
|
+
* @returns An array of VecModel objects with absolute (x, y) and z = 0.5
|
|
345
|
+
* @public
|
|
346
|
+
*/
|
|
347
|
+
static decodePoints2D(base64: string): VecModel[];
|
|
348
|
+
/**
|
|
349
|
+
* Get the first point from a 2D delta-encoded base64 string.
|
|
350
|
+
*
|
|
351
|
+
* @param b64Points - The 2D delta-encoded base64 string
|
|
352
|
+
* @returns The first point with z = 0.5, or null if the string is too short
|
|
353
|
+
* @public
|
|
354
|
+
*/
|
|
355
|
+
static decodeFirstPoint2D(b64Points: string): null | VecModel;
|
|
356
|
+
/**
|
|
357
|
+
* Get the last point from a 2D delta-encoded base64 string.
|
|
358
|
+
* Requires decoding all points to accumulate deltas.
|
|
359
|
+
*
|
|
360
|
+
* @param b64Points - The 2D delta-encoded base64 string
|
|
361
|
+
* @returns The last point with z = 0.5, or null if the string is too short
|
|
362
|
+
* @public
|
|
363
|
+
*/
|
|
364
|
+
static decodeLastPoint2D(b64Points: string): null | VecModel;
|
|
365
|
+
/**
|
|
366
|
+
* Whether an encoded path contains only a single point (a "dot"), inferred from
|
|
367
|
+
* the encoded length without decoding — cheap enough for the render path.
|
|
368
|
+
*
|
|
369
|
+
* The single-point length depends on the encoding dimension, so this takes the
|
|
370
|
+
* segment's `dim`: a one-point path is `FIRST_POINT_B64_LENGTH` chars (3D) or
|
|
371
|
+
* `FIRST_POINT_2D_B64_LENGTH` chars (2D). Keeping this beside the layout constants
|
|
372
|
+
* is deliberate — it is the single source of truth for "how long is one point", so
|
|
373
|
+
* callers never hard-code a length threshold (which silently breaks when a new
|
|
374
|
+
* encoding is added).
|
|
375
|
+
*
|
|
376
|
+
* @param b64Points - The encoded path string
|
|
377
|
+
* @param dim - Encoding dimension; `2` for (x, y), `3` (default) for (x, y, z)
|
|
378
|
+
* @returns true if the path encodes exactly one point
|
|
379
|
+
* @public
|
|
380
|
+
*/
|
|
381
|
+
static isSinglePoint(b64Points: string, dim?: 2 | 3): boolean;
|
|
320
382
|
}
|
|
321
383
|
|
|
322
384
|
/**
|
|
@@ -1626,6 +1688,12 @@ export declare const DefaultTextAlignStyle: EnumStyleProp<"end" | "middle" | "st
|
|
|
1626
1688
|
*/
|
|
1627
1689
|
export declare const DefaultVerticalAlignStyle: EnumStyleProp<"end" | "middle" | "start">;
|
|
1628
1690
|
|
|
1691
|
+
/** Draw segment path encoded with 2 dimensions, XY — the constant pressure Z is dropped. @public */
|
|
1692
|
+
export declare const DIM_2D = 2;
|
|
1693
|
+
|
|
1694
|
+
/** Draw segment path encoded with 3 dimensions, XYZ. @public */
|
|
1695
|
+
export declare const DIM_3D = 3;
|
|
1696
|
+
|
|
1629
1697
|
/**
|
|
1630
1698
|
* Record type definition for TLDocument with validation and default properties.
|
|
1631
1699
|
* Configures the document as a document-scoped record that persists across sessions.
|
|
@@ -1924,7 +1992,7 @@ export declare function getDefaultUserPresence(store: TLStore, user: TLUser): {
|
|
|
1924
1992
|
x: number;
|
|
1925
1993
|
y: number;
|
|
1926
1994
|
};
|
|
1927
|
-
followingUserId:
|
|
1995
|
+
followingUserId: TLUserId | null;
|
|
1928
1996
|
lastActivityTimestamp: number;
|
|
1929
1997
|
meta: {};
|
|
1930
1998
|
screenBounds: BoxModel;
|
|
@@ -4466,6 +4534,12 @@ export declare interface TLDrawShapeSegment {
|
|
|
4466
4534
|
* First point stored as Float32 (12 bytes) for precision, subsequent points as Float16 deltas (6 bytes each).
|
|
4467
4535
|
*/
|
|
4468
4536
|
path: string;
|
|
4537
|
+
/**
|
|
4538
|
+
* Encoding dimension of `path`. `2` means (x, y) only — the constant 0.5 pressure
|
|
4539
|
+
* was omitted, for input from devices that don't report pressure. `3` or absent
|
|
4540
|
+
* (the legacy default) means (x, y, z). Added in the `OmitNonPressureZ` migration.
|
|
4541
|
+
*/
|
|
4542
|
+
dim?: 2 | 3;
|
|
4469
4543
|
}
|
|
4470
4544
|
|
|
4471
4545
|
/**
|
|
@@ -5101,8 +5175,8 @@ export declare interface TLInstance extends BaseRecord<'instance', TLInstanceId>
|
|
|
5101
5175
|
currentPageId: TLPageId;
|
|
5102
5176
|
opacityForNextShape: TLOpacityType;
|
|
5103
5177
|
stylesForNextShape: Record<string, unknown>;
|
|
5104
|
-
followingUserId: null |
|
|
5105
|
-
highlightedUserIds:
|
|
5178
|
+
followingUserId: null | TLUserId;
|
|
5179
|
+
highlightedUserIds: TLUserId[];
|
|
5106
5180
|
brush: BoxModel | null;
|
|
5107
5181
|
cursor: TLCursor;
|
|
5108
5182
|
scribbles: TLScribble[];
|
|
@@ -5250,7 +5324,7 @@ export declare type TLInstancePageStateId = RecordId<TLInstancePageState>;
|
|
|
5250
5324
|
* @public
|
|
5251
5325
|
*/
|
|
5252
5326
|
export declare interface TLInstancePresence extends BaseRecord<'instance_presence', TLInstancePresenceID> {
|
|
5253
|
-
userId:
|
|
5327
|
+
userId: TLUserId;
|
|
5254
5328
|
userName: string;
|
|
5255
5329
|
lastActivityTimestamp: null | number;
|
|
5256
5330
|
color: string;
|
|
@@ -5264,7 +5338,7 @@ export declare interface TLInstancePresence extends BaseRecord<'instance_presenc
|
|
|
5264
5338
|
brush: BoxModel | null;
|
|
5265
5339
|
scribbles: TLScribble[];
|
|
5266
5340
|
screenBounds: BoxModel | null;
|
|
5267
|
-
followingUserId: null |
|
|
5341
|
+
followingUserId: null | TLUserId;
|
|
5268
5342
|
cursor: {
|
|
5269
5343
|
rotation: number;
|
|
5270
5344
|
type: TLCursor['type'];
|
|
@@ -5502,8 +5576,8 @@ export declare interface TLNoteShapeProps {
|
|
|
5502
5576
|
richText: TLRichText;
|
|
5503
5577
|
/** Scale factor applied to the note shape for display */
|
|
5504
5578
|
scale: number;
|
|
5505
|
-
/** User ID of the person who
|
|
5506
|
-
|
|
5579
|
+
/** User ID of the person who last edited the note text */
|
|
5580
|
+
textLastEditedBy: null | string;
|
|
5507
5581
|
}
|
|
5508
5582
|
|
|
5509
5583
|
/**
|
package/dist-cjs/index.js
CHANGED
|
@@ -23,6 +23,8 @@ __export(index_exports, {
|
|
|
23
23
|
ArrowShapeKindStyle: () => import_TLArrowShape.ArrowShapeKindStyle,
|
|
24
24
|
AssetRecordType: () => import_TLAsset.AssetRecordType,
|
|
25
25
|
CameraRecordType: () => import_TLCamera.CameraRecordType,
|
|
26
|
+
DIM_2D: () => import_b64Vecs.DIM_2D,
|
|
27
|
+
DIM_3D: () => import_b64Vecs.DIM_3D,
|
|
26
28
|
DefaultColorStyle: () => import_TLColorStyle.DefaultColorStyle,
|
|
27
29
|
DefaultDashStyle: () => import_TLDashStyle.DefaultDashStyle,
|
|
28
30
|
DefaultFillStyle: () => import_TLFillStyle.DefaultFillStyle,
|
|
@@ -205,7 +207,7 @@ var import_translations = require("./translations/translations");
|
|
|
205
207
|
var import_b64Vecs = require("./misc/b64Vecs");
|
|
206
208
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
207
209
|
"@tldraw/tlschema",
|
|
208
|
-
"5.2.
|
|
210
|
+
"5.2.1",
|
|
209
211
|
"cjs"
|
|
210
212
|
);
|
|
211
213
|
//# 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 {\n\tbookmarkAssetMigrations,\n\tbookmarkAssetProps,\n\ttype TLBookmarkAsset,\n} from './assets/TLBookmarkAsset'\nexport { imageAssetMigrations, imageAssetProps, type TLImageAsset } from './assets/TLImageAsset'\nexport { videoAssetMigrations, videoAssetProps, 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 CreatePresenceStateDerivationOpts,\n\ttype TLPresenceStateInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\n\tdefaultAssetSchemas,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype TLSchema,\n\ttype UserSchemaInfo,\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\tcreateAssetPropsMigrationIds,\n\tcreateAssetPropsMigrationSequence,\n\tcreateAssetRecordType,\n\ttype TLAsset,\n\ttype TLAssetId,\n\ttype TLAssetPartial,\n\ttype TLAssetShape,\n\ttype TLDefaultAsset,\n\ttype TLGlobalAssetPropsMap,\n\ttype TLIndexedAssets,\n\ttype TLUnknownAsset,\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\tcreateCustomRecordId,\n\tcreateCustomRecordMigrationIds,\n\tcreateCustomRecordMigrationSequence,\n\tisCustomRecord,\n\tisCustomRecordId,\n\ttype CustomRecordInfo,\n} from './records/TLCustomRecord'\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 {\n\ttype TLCustomRecord,\n\ttype TLDefaultRecord,\n\ttype TLGlobalRecordPropsMap,\n\ttype TLIndexedRecords,\n\ttype TLRecord,\n} 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\tcreateUserId,\n\tcreateUserRecordType,\n\tisUserId,\n\tuserIdValidator,\n\tUserRecordType,\n\ttype TLUser,\n\ttype TLUserId,\n} from './records/TLUser'\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\tDefaultColorStyle,\n\tregisterColorsFromThemes,\n\ttype TLDefaultColorStyle,\n} from './styles/TLColorStyle'\nexport { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'\nexport { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'\nexport { type TLFontFace, type TLFontFaceSource } from './styles/TLFontFace'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\tisFontEntry,\n\tregisterFontsFromThemes,\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\ttype TLDefaultColor,\n\ttype TLRemovedDefaultThemeColors,\n\ttype TLTheme,\n\ttype TLThemeColors,\n\ttype TLThemeDefaultColors,\n\ttype TLThemeFont,\n\ttype TLThemeFonts,\n\ttype TLThemeId,\n\ttype TLThemes,\n\ttype TLThemeUiColorKeys,\n} from './styles/TLTheme'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype TLDefaultVerticalAlignStyle,\n} from './styles/TLVerticalAlignStyle'\nexport {\n\tcreateCachedUserResolve,\n\ttype TLAssetContext,\n\ttype TLAssetStore,\n\ttype TLSerializedStore,\n\ttype TLStore,\n\ttype TLStoreProps,\n\ttype TLStoreSchema,\n\ttype TLStoreSnapshot,\n\ttype TLUserStore,\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCA,mBAA6C;AAC7C,yBAAyE;AACzE,6BAIO;AACP,0BAAyE;AACzE,0BAAyE;AACzE,4BAOO;AACP,2BAIO;AACP,2CAKO;AACP,4BAQO;AACP,4BAKO;AACP,0BAA4B;AAC5B,qBAIO;AACP,sBAAkE;AAClE,sBAAkE;AAClE,uBAAqD;AACrD,wBAA+D;AAC/D,wBAAuE;AACvE,qBAcO;AACP,uBAeO;AACP,sBAAiE;AACjE,4BAOO;AACP,wBAKO;AACP,wBAKO;AACP,oBAMO;AACP,yBAIO;AACP,uBAKO;AACP,wBAIO;AAQP,qBAkBO;AACP,oBAQO;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,0BAIO;AACP,yBAA0D;AAC1D,yBAA0D;AAE1D,yBAMO;AACP,oCAGO;AACP,yBAA0D;AAC1D,8BAAoE;AAapE,kCAGO;AACP,qBAUO;AACP,0BAIO;AASP,
|
|
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 {\n\tbookmarkAssetMigrations,\n\tbookmarkAssetProps,\n\ttype TLBookmarkAsset,\n} from './assets/TLBookmarkAsset'\nexport { imageAssetMigrations, imageAssetProps, type TLImageAsset } from './assets/TLImageAsset'\nexport { videoAssetMigrations, videoAssetProps, 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 CreatePresenceStateDerivationOpts,\n\ttype TLPresenceStateInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\n\tdefaultAssetSchemas,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype TLSchema,\n\ttype UserSchemaInfo,\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\tcreateAssetPropsMigrationIds,\n\tcreateAssetPropsMigrationSequence,\n\tcreateAssetRecordType,\n\ttype TLAsset,\n\ttype TLAssetId,\n\ttype TLAssetPartial,\n\ttype TLAssetShape,\n\ttype TLDefaultAsset,\n\ttype TLGlobalAssetPropsMap,\n\ttype TLIndexedAssets,\n\ttype TLUnknownAsset,\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\tcreateCustomRecordId,\n\tcreateCustomRecordMigrationIds,\n\tcreateCustomRecordMigrationSequence,\n\tisCustomRecord,\n\tisCustomRecordId,\n\ttype CustomRecordInfo,\n} from './records/TLCustomRecord'\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 {\n\ttype TLCustomRecord,\n\ttype TLDefaultRecord,\n\ttype TLGlobalRecordPropsMap,\n\ttype TLIndexedRecords,\n\ttype TLRecord,\n} 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\tcreateUserId,\n\tcreateUserRecordType,\n\tisUserId,\n\tuserIdValidator,\n\tUserRecordType,\n\ttype TLUser,\n\ttype TLUserId,\n} from './records/TLUser'\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\tDefaultColorStyle,\n\tregisterColorsFromThemes,\n\ttype TLDefaultColorStyle,\n} from './styles/TLColorStyle'\nexport { DefaultDashStyle, type TLDefaultDashStyle } from './styles/TLDashStyle'\nexport { DefaultFillStyle, type TLDefaultFillStyle } from './styles/TLFillStyle'\nexport { type TLFontFace, type TLFontFaceSource } from './styles/TLFontFace'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\tisFontEntry,\n\tregisterFontsFromThemes,\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\ttype TLDefaultColor,\n\ttype TLRemovedDefaultThemeColors,\n\ttype TLTheme,\n\ttype TLThemeColors,\n\ttype TLThemeDefaultColors,\n\ttype TLThemeFont,\n\ttype TLThemeFonts,\n\ttype TLThemeId,\n\ttype TLThemes,\n\ttype TLThemeUiColorKeys,\n} from './styles/TLTheme'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype TLDefaultVerticalAlignStyle,\n} from './styles/TLVerticalAlignStyle'\nexport {\n\tcreateCachedUserResolve,\n\ttype TLAssetContext,\n\ttype TLAssetStore,\n\ttype TLSerializedStore,\n\ttype TLStore,\n\ttype TLStoreProps,\n\ttype TLStoreSchema,\n\ttype TLStoreSnapshot,\n\ttype TLUserStore,\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 { DIM_2D, DIM_3D, 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCA,mBAA6C;AAC7C,yBAAyE;AACzE,6BAIO;AACP,0BAAyE;AACzE,0BAAyE;AACzE,4BAOO;AACP,2BAIO;AACP,2CAKO;AACP,4BAQO;AACP,4BAKO;AACP,0BAA4B;AAC5B,qBAIO;AACP,sBAAkE;AAClE,sBAAkE;AAClE,uBAAqD;AACrD,wBAA+D;AAC/D,wBAAuE;AACvE,qBAcO;AACP,uBAeO;AACP,sBAAiE;AACjE,4BAOO;AACP,wBAKO;AACP,wBAKO;AACP,oBAMO;AACP,yBAIO;AACP,uBAKO;AACP,wBAIO;AAQP,qBAkBO;AACP,oBAQO;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,0BAIO;AACP,yBAA0D;AAC1D,yBAA0D;AAE1D,yBAMO;AACP,oCAGO;AACP,yBAA0D;AAC1D,8BAAoE;AAapE,kCAGO;AACP,qBAUO;AACP,0BAIO;AASP,qBAAwC;AAAA,IANxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-cjs/misc/b64Vecs.js
CHANGED
|
@@ -18,6 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var b64Vecs_exports = {};
|
|
20
20
|
__export(b64Vecs_exports, {
|
|
21
|
+
DIM_2D: () => DIM_2D,
|
|
22
|
+
DIM_3D: () => DIM_3D,
|
|
21
23
|
b64Vecs: () => b64Vecs,
|
|
22
24
|
fallbackBase64ToUint8Array: () => fallbackBase64ToUint8Array,
|
|
23
25
|
fallbackUint8ArrayToBase64: () => fallbackUint8ArrayToBase64,
|
|
@@ -25,14 +27,19 @@ __export(b64Vecs_exports, {
|
|
|
25
27
|
numberToFloat16Bits: () => numberToFloat16Bits
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(b64Vecs_exports);
|
|
28
|
-
var import_utils = require("@tldraw/utils");
|
|
29
30
|
const _POINT_B64_LENGTH = 8;
|
|
30
31
|
const FIRST_POINT_B64_LENGTH = 16;
|
|
32
|
+
const FIRST_POINT_2D_B64_LENGTH = 12;
|
|
33
|
+
const DEFAULT_PRESSURE = 0.5;
|
|
34
|
+
const DIM_2D = 2;
|
|
35
|
+
const DIM_3D = 3;
|
|
31
36
|
const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
32
37
|
const B64_LOOKUP = new Uint8Array(128);
|
|
33
38
|
for (let i = 0; i < 64; i++) {
|
|
34
39
|
B64_LOOKUP[BASE64_CHARS.charCodeAt(i)] = i;
|
|
35
40
|
}
|
|
41
|
+
const SIX_BIT_MASK = 63;
|
|
42
|
+
const PADDING_CHAR_CODE = "=".charCodeAt(0);
|
|
36
43
|
const POW2 = new Float64Array(31);
|
|
37
44
|
for (let i = 0; i < 31; i++) {
|
|
38
45
|
POW2[i] = Math.pow(2, i - 15);
|
|
@@ -61,10 +68,19 @@ function nativeBase64ToUint8Array(base64) {
|
|
|
61
68
|
return Uint8Array.fromBase64(base64);
|
|
62
69
|
}
|
|
63
70
|
function fallbackBase64ToUint8Array(base64) {
|
|
64
|
-
const
|
|
71
|
+
const paddedLength = base64.length;
|
|
72
|
+
let padding = 0;
|
|
73
|
+
if (paddedLength > 0 && base64.charCodeAt(paddedLength - 1) === PADDING_CHAR_CODE) {
|
|
74
|
+
padding++;
|
|
75
|
+
if (paddedLength > 1 && base64.charCodeAt(paddedLength - 2) === PADDING_CHAR_CODE) {
|
|
76
|
+
padding++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const numBytes = Math.floor(paddedLength * 3 / 4) - padding;
|
|
65
80
|
const bytes = new Uint8Array(numBytes);
|
|
66
81
|
let byteIndex = 0;
|
|
67
|
-
|
|
82
|
+
const fullGroups = Math.floor((paddedLength - padding) / 4) * 4;
|
|
83
|
+
for (let i = 0; i < fullGroups; i += 4) {
|
|
68
84
|
const c0 = B64_LOOKUP[base64.charCodeAt(i)];
|
|
69
85
|
const c1 = B64_LOOKUP[base64.charCodeAt(i + 1)];
|
|
70
86
|
const c2 = B64_LOOKUP[base64.charCodeAt(i + 2)];
|
|
@@ -74,20 +90,45 @@ function fallbackBase64ToUint8Array(base64) {
|
|
|
74
90
|
bytes[byteIndex++] = bitmap >> 8 & 255;
|
|
75
91
|
bytes[byteIndex++] = bitmap & 255;
|
|
76
92
|
}
|
|
93
|
+
if (padding === 1) {
|
|
94
|
+
const c0 = B64_LOOKUP[base64.charCodeAt(fullGroups)];
|
|
95
|
+
const c1 = B64_LOOKUP[base64.charCodeAt(fullGroups + 1)];
|
|
96
|
+
const c2 = B64_LOOKUP[base64.charCodeAt(fullGroups + 2)];
|
|
97
|
+
const bitmap = c0 << 18 | c1 << 12 | c2 << 6;
|
|
98
|
+
bytes[byteIndex++] = bitmap >> 16 & 255;
|
|
99
|
+
bytes[byteIndex++] = bitmap >> 8 & 255;
|
|
100
|
+
} else if (padding === 2) {
|
|
101
|
+
const c0 = B64_LOOKUP[base64.charCodeAt(fullGroups)];
|
|
102
|
+
const c1 = B64_LOOKUP[base64.charCodeAt(fullGroups + 1)];
|
|
103
|
+
const bitmap = c0 << 18 | c1 << 12;
|
|
104
|
+
bytes[byteIndex++] = bitmap >> 16 & 255;
|
|
105
|
+
}
|
|
77
106
|
return bytes;
|
|
78
107
|
}
|
|
79
108
|
function nativeUint8ArrayToBase64(uint8Array) {
|
|
80
109
|
return uint8Array.toBase64();
|
|
81
110
|
}
|
|
82
111
|
function fallbackUint8ArrayToBase64(uint8Array) {
|
|
83
|
-
|
|
112
|
+
const len = uint8Array.length;
|
|
113
|
+
const fullGroups = Math.floor(len / 3) * 3;
|
|
84
114
|
let result = "";
|
|
85
|
-
for (let i = 0; i <
|
|
115
|
+
for (let i = 0; i < fullGroups; i += 3) {
|
|
86
116
|
const byte1 = uint8Array[i];
|
|
87
117
|
const byte2 = uint8Array[i + 1];
|
|
88
118
|
const byte3 = uint8Array[i + 2];
|
|
89
119
|
const bitmap = byte1 << 16 | byte2 << 8 | byte3;
|
|
90
|
-
result += BASE64_CHARS[bitmap >> 18 &
|
|
120
|
+
result += BASE64_CHARS[bitmap >> 18 & SIX_BIT_MASK] + // bits 23–18 (top sextet)
|
|
121
|
+
BASE64_CHARS[bitmap >> 12 & SIX_BIT_MASK] + // bits 17–12
|
|
122
|
+
BASE64_CHARS[bitmap >> 6 & SIX_BIT_MASK] + // bits 11–6
|
|
123
|
+
BASE64_CHARS[bitmap & SIX_BIT_MASK];
|
|
124
|
+
}
|
|
125
|
+
const remaining = len - fullGroups;
|
|
126
|
+
if (remaining === 1) {
|
|
127
|
+
const bitmap = uint8Array[fullGroups] << 16;
|
|
128
|
+
result += BASE64_CHARS[bitmap >> 18 & SIX_BIT_MASK] + BASE64_CHARS[bitmap >> 12 & SIX_BIT_MASK] + "==";
|
|
129
|
+
} else if (remaining === 2) {
|
|
130
|
+
const bitmap = uint8Array[fullGroups] << 16 | uint8Array[fullGroups + 1] << 8;
|
|
131
|
+
result += BASE64_CHARS[bitmap >> 18 & SIX_BIT_MASK] + BASE64_CHARS[bitmap >> 12 & SIX_BIT_MASK] + BASE64_CHARS[bitmap >> 6 & SIX_BIT_MASK] + "=";
|
|
91
132
|
}
|
|
92
133
|
return result;
|
|
93
134
|
}
|
|
@@ -208,10 +249,12 @@ class b64Vecs {
|
|
|
208
249
|
* - Delta points: 3 Float16 values each = 6 bytes = 8 base64 chars each
|
|
209
250
|
*
|
|
210
251
|
* @param points - An array of VecModel objects to encode
|
|
252
|
+
* @param dim - Encoding dimension; `2` routes through the 2D variant (drops z), `3` (default) keeps x, y, z
|
|
211
253
|
* @returns A base64-encoded string containing delta-encoded points
|
|
212
254
|
* @public
|
|
213
255
|
*/
|
|
214
|
-
static encodePoints(points) {
|
|
256
|
+
static encodePoints(points, dim) {
|
|
257
|
+
if (dim === DIM_2D) return b64Vecs.encodePoints2D(points);
|
|
215
258
|
if (points.length === 0) return "";
|
|
216
259
|
const firstPointBytes = 12;
|
|
217
260
|
const deltaBytes = (points.length - 1) * 6;
|
|
@@ -244,10 +287,12 @@ class b64Vecs {
|
|
|
244
287
|
* Float16 deltas that are accumulated to reconstruct absolute positions.
|
|
245
288
|
*
|
|
246
289
|
* @param base64 - The base64-encoded string containing delta-encoded point data
|
|
290
|
+
* @param dim - Encoding dimension; `2` expects x/y only (z supplied as 0.5), `3` (default) expects x/y/z
|
|
247
291
|
* @returns An array of VecModel objects with absolute coordinates
|
|
248
292
|
* @public
|
|
249
293
|
*/
|
|
250
|
-
static decodePoints(base64) {
|
|
294
|
+
static decodePoints(base64, dim) {
|
|
295
|
+
if (dim === DIM_2D) return b64Vecs.decodePoints2D(base64);
|
|
251
296
|
if (base64.length === 0) return [];
|
|
252
297
|
const bytes = base64ToUint8Array(base64);
|
|
253
298
|
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
@@ -270,10 +315,12 @@ class b64Vecs {
|
|
|
270
315
|
* The first point is stored as Float32 for full precision.
|
|
271
316
|
*
|
|
272
317
|
* @param b64Points - The delta-encoded base64 string
|
|
318
|
+
* @param dim - Encoding dimension; `2` expects x/y only (z supplied as 0.5), `3` (default) expects x/y/z
|
|
273
319
|
* @returns The first point as a VecModel, or null if the string is too short
|
|
274
320
|
* @public
|
|
275
321
|
*/
|
|
276
|
-
static decodeFirstPoint(b64Points) {
|
|
322
|
+
static decodeFirstPoint(b64Points, dim) {
|
|
323
|
+
if (dim === DIM_2D) return b64Vecs.decodeFirstPoint2D(b64Points);
|
|
277
324
|
if (b64Points.length < FIRST_POINT_B64_LENGTH) return null;
|
|
278
325
|
const bytes = base64ToUint8Array(b64Points.slice(0, FIRST_POINT_B64_LENGTH));
|
|
279
326
|
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
@@ -288,10 +335,12 @@ class b64Vecs {
|
|
|
288
335
|
* Requires decoding all points to accumulate deltas.
|
|
289
336
|
*
|
|
290
337
|
* @param b64Points - The delta-encoded base64 string
|
|
338
|
+
* @param dim - Encoding dimension; `2` expects x/y only (z supplied as 0.5), `3` (default) expects x/y/z
|
|
291
339
|
* @returns The last point as a VecModel, or null if the string is too short
|
|
292
340
|
* @public
|
|
293
341
|
*/
|
|
294
|
-
static decodeLastPoint(b64Points) {
|
|
342
|
+
static decodeLastPoint(b64Points, dim) {
|
|
343
|
+
if (dim === DIM_2D) return b64Vecs.decodeLastPoint2D(b64Points);
|
|
295
344
|
if (b64Points.length < FIRST_POINT_B64_LENGTH) return null;
|
|
296
345
|
const bytes = base64ToUint8Array(b64Points);
|
|
297
346
|
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
@@ -306,5 +355,121 @@ class b64Vecs {
|
|
|
306
355
|
}
|
|
307
356
|
return { x, y, z };
|
|
308
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Encode an array of VecModels as 2D delta-encoded points, dropping z entirely.
|
|
360
|
+
* Use for draw shapes from devices that don't report pressure, where z is a
|
|
361
|
+
* constant 0.5 and storing it wastes ~33% of per-point bytes.
|
|
362
|
+
*
|
|
363
|
+
* Format:
|
|
364
|
+
* - First point: 2 Float32 values (x, y) = 8 bytes
|
|
365
|
+
* - Delta points: 2 Float16 values (dx, dy) = 4 bytes each
|
|
366
|
+
*
|
|
367
|
+
* @param points - An array of VecModel objects to encode (z is discarded)
|
|
368
|
+
* @returns A base64-encoded string containing 2D delta-encoded points
|
|
369
|
+
* @public
|
|
370
|
+
*/
|
|
371
|
+
static encodePoints2D(points) {
|
|
372
|
+
if (points.length === 0) return "";
|
|
373
|
+
const firstPointBytes = 8;
|
|
374
|
+
const deltaBytes = (points.length - 1) * 4;
|
|
375
|
+
const buffer = new Uint8Array(firstPointBytes + deltaBytes);
|
|
376
|
+
const dataView = new DataView(buffer.buffer);
|
|
377
|
+
const first = points[0];
|
|
378
|
+
dataView.setFloat32(0, first.x, true);
|
|
379
|
+
dataView.setFloat32(4, first.y, true);
|
|
380
|
+
let prevX = first.x;
|
|
381
|
+
let prevY = first.y;
|
|
382
|
+
for (let i = 1; i < points.length; i++) {
|
|
383
|
+
const p = points[i];
|
|
384
|
+
const offset = firstPointBytes + (i - 1) * 4;
|
|
385
|
+
setFloat16(dataView, offset, p.x - prevX);
|
|
386
|
+
setFloat16(dataView, offset + 2, p.y - prevY);
|
|
387
|
+
prevX = p.x;
|
|
388
|
+
prevY = p.y;
|
|
389
|
+
}
|
|
390
|
+
return uint8ArrayToBase64(buffer);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Decode a 2D delta-encoded base64 string back to an array of absolute VecModels.
|
|
394
|
+
* The z coordinate is always set to 0.5 (the default pressure value) so downstream
|
|
395
|
+
* consumers don't need a separate code path.
|
|
396
|
+
*
|
|
397
|
+
* @param base64 - The base64-encoded string containing 2D delta-encoded point data
|
|
398
|
+
* @returns An array of VecModel objects with absolute (x, y) and z = 0.5
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
401
|
+
static decodePoints2D(base64) {
|
|
402
|
+
if (base64.length === 0) return [];
|
|
403
|
+
const bytes = base64ToUint8Array(base64);
|
|
404
|
+
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
405
|
+
const result = [];
|
|
406
|
+
let x = dataView.getFloat32(0, true);
|
|
407
|
+
let y = dataView.getFloat32(4, true);
|
|
408
|
+
result.push({ x, y, z: DEFAULT_PRESSURE });
|
|
409
|
+
const firstPointBytes = 8;
|
|
410
|
+
for (let offset = firstPointBytes; offset < bytes.length; offset += 4) {
|
|
411
|
+
x += getFloat16(dataView, offset);
|
|
412
|
+
y += getFloat16(dataView, offset + 2);
|
|
413
|
+
result.push({ x, y, z: DEFAULT_PRESSURE });
|
|
414
|
+
}
|
|
415
|
+
return result;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Get the first point from a 2D delta-encoded base64 string.
|
|
419
|
+
*
|
|
420
|
+
* @param b64Points - The 2D delta-encoded base64 string
|
|
421
|
+
* @returns The first point with z = 0.5, or null if the string is too short
|
|
422
|
+
* @public
|
|
423
|
+
*/
|
|
424
|
+
static decodeFirstPoint2D(b64Points) {
|
|
425
|
+
if (b64Points.length < FIRST_POINT_2D_B64_LENGTH) return null;
|
|
426
|
+
const bytes = base64ToUint8Array(b64Points.slice(0, FIRST_POINT_2D_B64_LENGTH));
|
|
427
|
+
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
428
|
+
return {
|
|
429
|
+
x: dataView.getFloat32(0, true),
|
|
430
|
+
y: dataView.getFloat32(4, true),
|
|
431
|
+
z: DEFAULT_PRESSURE
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Get the last point from a 2D delta-encoded base64 string.
|
|
436
|
+
* Requires decoding all points to accumulate deltas.
|
|
437
|
+
*
|
|
438
|
+
* @param b64Points - The 2D delta-encoded base64 string
|
|
439
|
+
* @returns The last point with z = 0.5, or null if the string is too short
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
static decodeLastPoint2D(b64Points) {
|
|
443
|
+
if (b64Points.length < FIRST_POINT_2D_B64_LENGTH) return null;
|
|
444
|
+
const bytes = base64ToUint8Array(b64Points);
|
|
445
|
+
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
446
|
+
let x = dataView.getFloat32(0, true);
|
|
447
|
+
let y = dataView.getFloat32(4, true);
|
|
448
|
+
const firstPointBytes = 8;
|
|
449
|
+
for (let offset = firstPointBytes; offset < bytes.length; offset += 4) {
|
|
450
|
+
x += getFloat16(dataView, offset);
|
|
451
|
+
y += getFloat16(dataView, offset + 2);
|
|
452
|
+
}
|
|
453
|
+
return { x, y, z: DEFAULT_PRESSURE };
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Whether an encoded path contains only a single point (a "dot"), inferred from
|
|
457
|
+
* the encoded length without decoding — cheap enough for the render path.
|
|
458
|
+
*
|
|
459
|
+
* The single-point length depends on the encoding dimension, so this takes the
|
|
460
|
+
* segment's `dim`: a one-point path is `FIRST_POINT_B64_LENGTH` chars (3D) or
|
|
461
|
+
* `FIRST_POINT_2D_B64_LENGTH` chars (2D). Keeping this beside the layout constants
|
|
462
|
+
* is deliberate — it is the single source of truth for "how long is one point", so
|
|
463
|
+
* callers never hard-code a length threshold (which silently breaks when a new
|
|
464
|
+
* encoding is added).
|
|
465
|
+
*
|
|
466
|
+
* @param b64Points - The encoded path string
|
|
467
|
+
* @param dim - Encoding dimension; `2` for (x, y), `3` (default) for (x, y, z)
|
|
468
|
+
* @returns true if the path encodes exactly one point
|
|
469
|
+
* @public
|
|
470
|
+
*/
|
|
471
|
+
static isSinglePoint(b64Points, dim) {
|
|
472
|
+
return b64Points.length <= (dim === DIM_2D ? FIRST_POINT_2D_B64_LENGTH : FIRST_POINT_B64_LENGTH);
|
|
473
|
+
}
|
|
309
474
|
}
|
|
310
475
|
//# sourceMappingURL=b64Vecs.js.map
|