@tldraw/tlschema 4.6.0-next.1f489710ee41 → 4.6.0-next.4dde09fa17ab

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.
Files changed (38) hide show
  1. package/dist-cjs/TLStore.js +13 -0
  2. package/dist-cjs/TLStore.js.map +2 -2
  3. package/dist-cjs/createPresenceStateDerivation.js +6 -4
  4. package/dist-cjs/createPresenceStateDerivation.js.map +2 -2
  5. package/dist-cjs/createTLSchema.js +8 -1
  6. package/dist-cjs/createTLSchema.js.map +2 -2
  7. package/dist-cjs/index.d.ts +211 -28
  8. package/dist-cjs/index.js +9 -1
  9. package/dist-cjs/index.js.map +2 -2
  10. package/dist-cjs/records/TLRecord.js.map +1 -1
  11. package/dist-cjs/records/TLUser.js +101 -0
  12. package/dist-cjs/records/TLUser.js.map +7 -0
  13. package/dist-cjs/shapes/TLNoteShape.js +13 -2
  14. package/dist-cjs/shapes/TLNoteShape.js.map +2 -2
  15. package/dist-esm/TLStore.mjs +13 -0
  16. package/dist-esm/TLStore.mjs.map +2 -2
  17. package/dist-esm/createPresenceStateDerivation.mjs +6 -4
  18. package/dist-esm/createPresenceStateDerivation.mjs.map +2 -2
  19. package/dist-esm/createTLSchema.mjs +8 -1
  20. package/dist-esm/createTLSchema.mjs.map +2 -2
  21. package/dist-esm/index.d.mts +211 -28
  22. package/dist-esm/index.mjs +17 -1
  23. package/dist-esm/index.mjs.map +2 -2
  24. package/dist-esm/records/TLUser.mjs +85 -0
  25. package/dist-esm/records/TLUser.mjs.map +7 -0
  26. package/dist-esm/shapes/TLNoteShape.mjs +13 -2
  27. package/dist-esm/shapes/TLNoteShape.mjs.map +2 -2
  28. package/package.json +6 -6
  29. package/src/TLStore.test.ts +5 -0
  30. package/src/TLStore.ts +95 -1
  31. package/src/createPresenceStateDerivation.test.ts +33 -20
  32. package/src/createPresenceStateDerivation.ts +20 -25
  33. package/src/createTLSchema.ts +52 -0
  34. package/src/index.ts +13 -1
  35. package/src/migrations.test.ts +22 -0
  36. package/src/records/TLRecord.ts +2 -0
  37. package/src/records/TLUser.ts +148 -0
  38. package/src/shapes/TLNoteShape.ts +13 -0
@@ -718,6 +718,32 @@ export declare function createBindingValidator<Type extends string, Props extend
718
718
  [K in keyof Meta]: T.Validatable<Meta[K]>;
719
719
  }): T.ObjectValidator<Expand< { [P in "fromId" | "id" | "meta" | "toId" | "typeName" | (undefined extends Props ? never : "props") | (undefined extends Type ? never : "type")]: TLBaseBinding<Type, Props>[P]; } & { [P in (undefined extends Props ? "props" : never) | (undefined extends Type ? "type" : never)]?: TLBaseBinding<Type, Props>[P] | undefined; }>>;
720
720
 
721
+ /**
722
+ * Create a cached {@link TLUserStore.resolve} implementation.
723
+ *
724
+ * Wraps a reactive lookup function so that each `userId` gets a single
725
+ * stable {@link @tldraw/state#Signal | Signal} that is reused across calls.
726
+ * The `resolveFn` is evaluated inside a `computed`, so any `.get()` calls
727
+ * it makes are automatically tracked.
728
+ *
729
+ * @param resolveFn - A function that resolves a raw user-ID string to a
730
+ * {@link TLUser} or `null`. Called reactively inside a `computed`.
731
+ * @returns A function suitable for use as `TLUserStore.resolve`.
732
+ *
733
+ * @example
734
+ * ```ts
735
+ * const users: TLUserStore = {
736
+ * currentUser: currentUserSignal,
737
+ * resolve: createCachedUserResolve(
738
+ * (userId) => usersAtom.get()[createUserId(userId)] ?? null
739
+ * ),
740
+ * }
741
+ * ```
742
+ *
743
+ * @public
744
+ */
745
+ export declare function createCachedUserResolve(resolveFn: (userId: string) => null | TLUser): (userId: string) => Signal<null | TLUser>;
746
+
721
747
  /**
722
748
  * Creates a unique ID for a custom record type.
723
749
  *
@@ -802,8 +828,8 @@ export declare function createCustomRecordMigrationSequence(migrations: TLPropsM
802
828
  * position, selected shapes, camera position, and user metadata that gets synchronized in
803
829
  * multiplayer scenarios.
804
830
  *
805
- * @param $user - A reactive signal containing the user information
806
- * @param instanceId - Optional custom instance ID. If not provided, one will be generated based on the store ID
831
+ * @param $user - A reactive signal containing the user information, or `null` when anonymous
832
+ * @param opts - Optional configuration for instance ID and presence derivation
807
833
  * @returns A function that takes a store and returns a computed signal of the user's presence state
808
834
  *
809
835
  * @example
@@ -811,7 +837,7 @@ export declare function createCustomRecordMigrationSequence(migrations: TLPropsM
811
837
  * import { createPresenceStateDerivation } from '@tldraw/tlschema'
812
838
  * import { atom } from '@tldraw/state'
813
839
  *
814
- * const userSignal = atom('user', { id: 'user-123', name: 'Alice', color: '#ff0000' })
840
+ * const userSignal = atom('user', { id: 'user-123', name: 'Alice', color: '#ff0000', meta: {} })
815
841
  * const presenceDerivation = createPresenceStateDerivation(userSignal)
816
842
  *
817
843
  * // Use with a store to get reactive presence state
@@ -821,7 +847,18 @@ export declare function createCustomRecordMigrationSequence(migrations: TLPropsM
821
847
  *
822
848
  * @public
823
849
  */
824
- export declare function createPresenceStateDerivation($user: Signal<TLPresenceUserInfo>, instanceId?: TLInstancePresence['id']): (store: TLStore) => Signal<null | TLInstancePresence, unknown>;
850
+ export declare function createPresenceStateDerivation($user: Signal<null | TLUser>, opts?: CreatePresenceStateDerivationOpts): (store: TLStore) => Signal<null | TLInstancePresence, unknown>;
851
+
852
+ /** @public */
853
+ export declare interface CreatePresenceStateDerivationOpts {
854
+ /** Custom instance ID. If not provided, one is generated from the store ID. */
855
+ instanceId?: TLInstancePresence['id'];
856
+ /**
857
+ * Override how presence state is built from the store and current user.
858
+ * Defaults to {@link getDefaultUserPresence}.
859
+ */
860
+ getUserPresence?(store: TLStore, user: TLUser): null | TLPresenceStateInfo;
861
+ }
825
862
 
826
863
  /**
827
864
  * Creates a new shape ID.
@@ -965,6 +1002,7 @@ export declare function createShapeValidator<Type extends string, Props extends
965
1002
  * @param options - Configuration options for the schema
966
1003
  * - shapes - Shape schema configurations. Defaults to defaultShapeSchemas if not provided
967
1004
  * - bindings - Binding schema configurations. Defaults to defaultBindingSchemas if not provided
1005
+ * - user - Custom user record configuration with meta validators and migrations
968
1006
  * - records - Custom record type configurations. These are additional record types beyond
969
1007
  * the built-in shapes, bindings, assets, etc.
970
1008
  * - migrations - Additional migration sequences to include in the schema
@@ -990,6 +1028,16 @@ export declare function createShapeValidator<Type extends string, Props extends
990
1028
  * },
991
1029
  * })
992
1030
  *
1031
+ * // Create schema with custom user metadata
1032
+ * const schemaWithCustomUser = createTLSchema({
1033
+ * user: {
1034
+ * meta: {
1035
+ * isAdmin: T.boolean,
1036
+ * department: T.string,
1037
+ * },
1038
+ * },
1039
+ * })
1040
+ *
993
1041
  * // Create schema with custom record types
994
1042
  * const schemaWithCustomRecords = createTLSchema({
995
1043
  * records: {
@@ -1014,13 +1062,47 @@ export declare function createShapeValidator<Type extends string, Props extends
1014
1062
  * })
1015
1063
  * ```
1016
1064
  */
1017
- export declare function createTLSchema({ shapes, bindings, records, migrations }?: {
1065
+ export declare function createTLSchema({ shapes, bindings, user, records, migrations }?: {
1018
1066
  bindings?: Record<string, SchemaPropsInfo>;
1019
1067
  migrations?: readonly MigrationSequence[];
1020
1068
  records?: Record<string, CustomRecordInfo>;
1021
1069
  shapes?: Record<string, SchemaPropsInfo>;
1070
+ user?: UserSchemaInfo;
1022
1071
  }): TLSchema;
1023
1072
 
1073
+ /** @public */
1074
+ export declare function createUserId(id: string): TLUserId;
1075
+
1076
+ /**
1077
+ * Creates a user record type with optional custom meta validation.
1078
+ *
1079
+ * When `meta` validators are provided, the user record's `meta` field will
1080
+ * validate those specific fields (when present) while still allowing
1081
+ * arbitrary additional JSON properties. Custom meta fields are treated as
1082
+ * optional so that user records created without them remain valid.
1083
+ *
1084
+ * @param config - Optional configuration for custom meta validators
1085
+ * @returns A configured user record type
1086
+ *
1087
+ * @example
1088
+ * ```ts
1089
+ * import { createUserRecordType } from '@tldraw/tlschema'
1090
+ * import { T } from '@tldraw/validate'
1091
+ *
1092
+ * const CustomUserRecordType = createUserRecordType({
1093
+ * meta: {
1094
+ * isAdmin: T.boolean,
1095
+ * department: T.string,
1096
+ * },
1097
+ * })
1098
+ * ```
1099
+ *
1100
+ * @public
1101
+ */
1102
+ export declare function createUserRecordType(config?: {
1103
+ meta?: Record<string, T.Validatable<any>>;
1104
+ }): RecordType<TLUser, never>;
1105
+
1024
1106
  /**
1025
1107
  * Configuration for a custom record type in the schema.
1026
1108
  *
@@ -1873,7 +1955,7 @@ export declare function getDefaultTranslationLocale(): TLLanguage['locale'];
1873
1955
  * ```ts
1874
1956
  * import { getDefaultUserPresence } from '@tldraw/tlschema'
1875
1957
  *
1876
- * const user = { id: 'user-123', name: 'Alice', color: '#ff0000' }
1958
+ * const user = { id: 'user-123', name: 'Alice', color: '#ff0000', meta: {} }
1877
1959
  * const presenceInfo = getDefaultUserPresence(store, user)
1878
1960
  *
1879
1961
  * if (presenceInfo) {
@@ -1897,7 +1979,7 @@ export declare function getDefaultTranslationLocale(): TLLanguage['locale'];
1897
1979
  *
1898
1980
  * @public
1899
1981
  */
1900
- export declare function getDefaultUserPresence(store: TLStore, user: TLPresenceUserInfo): {
1982
+ export declare function getDefaultUserPresence(store: TLStore, user: TLUser): {
1901
1983
  brush: BoxModel | null;
1902
1984
  camera: {
1903
1985
  x: number;
@@ -1919,7 +2001,7 @@ export declare function getDefaultUserPresence(store: TLStore, user: TLPresenceU
1919
2001
  screenBounds: BoxModel;
1920
2002
  scribbles: TLScribble[];
1921
2003
  selectedShapeIds: TLShapeId[];
1922
- userId: string;
2004
+ userId: TLUserId;
1923
2005
  userName: string;
1924
2006
  } | null;
1925
2007
 
@@ -2249,6 +2331,9 @@ export declare function isShape(record?: UnknownRecord): record is TLShape;
2249
2331
  */
2250
2332
  export declare function isShapeId(id?: string): id is TLShapeId;
2251
2333
 
2334
+ /** @public */
2335
+ export declare function isUserId(id: string): id is TLUserId;
2336
+
2252
2337
  /** @public */
2253
2338
  export declare const LANGUAGES: readonly [{
2254
2339
  readonly label: "Bahasa Indonesia";
@@ -4197,7 +4282,7 @@ export declare type TLDefaultHorizontalAlignStyle = T.TypeOf<typeof DefaultHoriz
4197
4282
  *
4198
4283
  * @public
4199
4284
  */
4200
- export declare type TLDefaultRecord = TLAsset | TLBinding | TLCamera | TLDocument | TLInstance | TLInstancePageState | TLInstancePresence | TLPage | TLPointer | TLShape;
4285
+ export declare type TLDefaultRecord = TLAsset | TLBinding | TLCamera | TLDocument | TLInstance | TLInstancePageState | TLInstancePresence | TLPage | TLPointer | TLShape | TLUser;
4201
4286
 
4202
4287
  /**
4203
4288
  * The default set of shapes that are available in the editor.
@@ -5390,6 +5475,8 @@ export declare interface TLNoteShapeProps {
5390
5475
  richText: TLRichText;
5391
5476
  /** Scale factor applied to the note shape for display */
5392
5477
  scale: number;
5478
+ /** User ID of the person who first edited the note text */
5479
+ textFirstEditedBy: null | string;
5393
5480
  }
5394
5481
 
5395
5482
  /**
@@ -5546,25 +5633,6 @@ export declare type TLPointerId = RecordId<TLPointer>;
5546
5633
  */
5547
5634
  export declare type TLPresenceStateInfo = Parameters<(typeof InstancePresenceRecordType)['create']>[0];
5548
5635
 
5549
- /**
5550
- * The information about a user which is used for multiplayer features.
5551
- * @public
5552
- */
5553
- export declare interface TLPresenceUserInfo {
5554
- /**
5555
- * id - A unique identifier for the user. This should be the same across all devices and sessions.
5556
- */
5557
- id: string;
5558
- /**
5559
- * The user's display name.
5560
- */
5561
- name?: null | string;
5562
- /**
5563
- * The user's color. If not given, a random color will be assigned.
5564
- */
5565
- color?: null | string;
5566
- }
5567
-
5568
5636
  /**
5569
5637
  * A migration definition for shape or record properties.
5570
5638
  *
@@ -5968,6 +6036,8 @@ export declare interface TLStoreProps {
5968
6036
  defaultName: string;
5969
6037
  /** Asset store implementation for handling file uploads and storage */
5970
6038
  assets: Required<TLAssetStore>;
6039
+ /** User store implementation for user resolution and attribution */
6040
+ users: Required<TLUserStore>;
5971
6041
  /**
5972
6042
  * Called when an {@link @tldraw/editor#Editor} connected to this store is mounted.
5973
6043
  * Can optionally return a cleanup function that will be called when unmounted.
@@ -6119,6 +6189,82 @@ export declare type TLUnknownBinding = TLBaseBinding<string, object>;
6119
6189
  */
6120
6190
  export declare type TLUnknownShape = TLBaseShape<string, object>;
6121
6191
 
6192
+ /**
6193
+ * A user record in a tldraw store. User records are document-scoped and
6194
+ * persist alongside shapes, assets, and pages. They are automatically
6195
+ * included in snapshots, clipboard content, and `.tldr` files so that
6196
+ * attribution display names survive across boards and sessions.
6197
+ *
6198
+ * User records are populated from the {@link @tldraw/tlschema#TLUserStore}
6199
+ * when the editor stamps attribution metadata onto shapes.
6200
+ *
6201
+ * Extend user records with custom metadata by passing validators to
6202
+ * {@link @tldraw/tlschema#createTLSchema} or {@link createUserRecordType}.
6203
+ *
6204
+ * @public
6205
+ */
6206
+ export declare interface TLUser extends BaseRecord<'user', TLUserId> {
6207
+ name: string;
6208
+ color: string;
6209
+ imageUrl: string;
6210
+ meta: JsonObject;
6211
+ }
6212
+
6213
+ /** @public */
6214
+ export declare type TLUserId = RecordId<TLUser>;
6215
+
6216
+ /**
6217
+ * Interface for resolving user information in tldraw.
6218
+ *
6219
+ * A `TLUserStore` sits alongside the main {@link TLStore} and provides user
6220
+ * resolution for attribution labels and display names. Implement this interface
6221
+ * to connect tldraw to your auth/user system.
6222
+ *
6223
+ * `currentUser` and `resolve` are reactive {@link @tldraw/state#Signal | Signals}
6224
+ * so that the editor can automatically track changes to user data and
6225
+ * re-render when a user's name, color, or avatar updates.
6226
+ *
6227
+ * Implementations should cache signals returned by `resolve` — e.g. return the
6228
+ * same `Signal` for repeated calls with the same `userId` — to avoid
6229
+ * unnecessary re-computation.
6230
+ *
6231
+ * @public
6232
+ * @example
6233
+ * ```ts
6234
+ * const currentUser = computed('currentUser', () =>
6235
+ * UserRecordType.create({
6236
+ * id: createUserId(myAuth.userId),
6237
+ * name: myAuth.displayName,
6238
+ * color: myAuth.color,
6239
+ * })
6240
+ * )
6241
+ *
6242
+ * const userStore: TLUserStore = {
6243
+ * currentUser,
6244
+ * resolve(userId) {
6245
+ * return computed('resolve-' + userId, () =>
6246
+ * myUserCache.get(userId) ?? null
6247
+ * )
6248
+ * },
6249
+ * }
6250
+ * ```
6251
+ */
6252
+ export declare interface TLUserStore {
6253
+ /**
6254
+ * A signal resolving to the currently authenticated user,
6255
+ * or `null` for anonymous / unknown.
6256
+ * Read when stamping attribution on shape create/update.
6257
+ */
6258
+ currentUser: Signal<null | TLUser>;
6259
+ /**
6260
+ * Return a signal resolving an arbitrary user ID to display info.
6261
+ * Called when rendering attribution labels for shapes that may have been
6262
+ * created or edited by someone else.
6263
+ * The signal's value should be `null` if the user cannot be resolved.
6264
+ */
6265
+ resolve?(userId: string): Signal<null | TLUser>;
6266
+ }
6267
+
6122
6268
  /**
6123
6269
  * An asset record representing video files that can be displayed in video shapes.
6124
6270
  * Video assets store metadata about video files including dimensions, MIME type,
@@ -6257,6 +6403,43 @@ export declare interface TLVideoShapeProps {
6257
6403
  */
6258
6404
  export declare function toRichText(text: string): TLRichText;
6259
6405
 
6406
+ /** @public */
6407
+ export declare const userIdValidator: T.Validator<TLUserId>;
6408
+
6409
+ /** @public */
6410
+ export declare const UserRecordType: RecordType<TLUser, never>;
6411
+
6412
+ /**
6413
+ * Configuration for extending the user record type with custom metadata
6414
+ * validators and migration sequences.
6415
+ *
6416
+ * @example
6417
+ * ```ts
6418
+ * import { T } from '@tldraw/validate'
6419
+ *
6420
+ * const userSchema: UserSchemaInfo = {
6421
+ * meta: {
6422
+ * isAdmin: T.boolean,
6423
+ * department: T.string,
6424
+ * },
6425
+ * }
6426
+ * ```
6427
+ *
6428
+ * @public
6429
+ */
6430
+ export declare interface UserSchemaInfo {
6431
+ /**
6432
+ * Validators for custom metadata fields on user records. Each field is
6433
+ * treated as optional — user records without these fields remain valid,
6434
+ * but when present, values are validated against the provided validators.
6435
+ */
6436
+ meta?: Record<string, T.Validatable<any>>;
6437
+ /**
6438
+ * Additional migration sequences for evolving custom user data over time.
6439
+ */
6440
+ migrations?: readonly MigrationSequence[];
6441
+ }
6442
+
6260
6443
  /**
6261
6444
  * A serializable model for 2D vectors.
6262
6445
  *
@@ -87,6 +87,13 @@ import {
87
87
  isShapeId,
88
88
  rootShapeMigrations
89
89
  } from "./records/TLShape.mjs";
90
+ import {
91
+ createUserId,
92
+ createUserRecordType,
93
+ isUserId,
94
+ userIdValidator,
95
+ UserRecordType
96
+ } from "./records/TLUser.mjs";
90
97
  import {
91
98
  ArrowShapeArrowheadEndStyle,
92
99
  ArrowShapeArrowheadStartStyle,
@@ -175,13 +182,16 @@ import { DefaultTextAlignStyle } from "./styles/TLTextAlignStyle.mjs";
175
182
  import {
176
183
  DefaultVerticalAlignStyle
177
184
  } from "./styles/TLVerticalAlignStyle.mjs";
185
+ import {
186
+ createCachedUserResolve
187
+ } from "./TLStore.mjs";
178
188
  import {
179
189
  getDefaultTranslationLocale,
180
190
  LANGUAGES
181
191
  } from "./translations/translations.mjs";
182
192
  registerTldrawLibraryVersion(
183
193
  "@tldraw/tlschema",
184
- "4.6.0-next.1f489710ee41",
194
+ "4.6.0-next.4dde09fa17ab",
185
195
  "esm"
186
196
  );
187
197
  import { b64Vecs } from "./misc/b64Vecs.mjs";
@@ -221,6 +231,7 @@ export {
221
231
  TL_CURSOR_TYPES,
222
232
  TL_HANDLE_TYPES,
223
233
  TL_SCRIBBLE_STATES,
234
+ UserRecordType,
224
235
  arrowBindingMigrations,
225
236
  arrowBindingProps,
226
237
  arrowBindingVersions,
@@ -242,6 +253,7 @@ export {
242
253
  createBindingPropsMigrationIds,
243
254
  createBindingPropsMigrationSequence,
244
255
  createBindingValidator,
256
+ createCachedUserResolve,
245
257
  createCustomRecordId,
246
258
  createCustomRecordMigrationIds,
247
259
  createCustomRecordMigrationSequence,
@@ -251,6 +263,8 @@ export {
251
263
  createShapePropsMigrationSequence,
252
264
  createShapeValidator,
253
265
  createTLSchema,
266
+ createUserId,
267
+ createUserRecordType,
254
268
  defaultBindingSchemas,
255
269
  defaultColorNames,
256
270
  defaultShapeSchemas,
@@ -282,6 +296,7 @@ export {
282
296
  isPageId,
283
297
  isShape,
284
298
  isShapeId,
299
+ isUserId,
285
300
  lineShapeMigrations,
286
301
  lineShapeProps,
287
302
  noteShapeMigrations,
@@ -298,6 +313,7 @@ export {
298
313
  textShapeMigrations,
299
314
  textShapeProps,
300
315
  toRichText,
316
+ userIdValidator,
301
317
  vecModelValidator,
302
318
  videoShapeMigrations,
303
319
  videoShapeProps
@@ -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 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\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": "AAgCA,SAAS,oCAAoC;AAC7C,SAAS,kBAAkB,4BAA8C;AAIzE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,uBAAyD;AAClE,SAAS,uBAAyD;AAClE,SAAS,wBAA4C;AACrD,SAAS,mBAAmB,kBAAmC;AAC/D,SAAS,mBAAmB,0BAA2C;AACvE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASM;AACP,SAAS,wBAAwD;AACjE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,OAGM;AAQP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWM;AAQP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,eAAe,iBAAsC;AAC9D;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP,SAAS,wBAAiD;AAC1D,SAAS,wBAAiD;AAC1D;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,OAEM;AACP,SAAS,wBAAiD;AAC1D,SAAS,6BAA2D;AACpE;AAAA,EACC;AAAA,OAEM;AAUP;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,eAAe;",
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 CreatePresenceStateDerivationOpts,\n\ttype TLPresenceStateInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateTLSchema,\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\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\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\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\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": "AAgCA,SAAS,oCAAoC;AAC7C,SAAS,kBAAkB,4BAA8C;AAIzE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP,SAAS,uBAAyD;AAClE,SAAS,uBAAyD;AAClE,SAAS,wBAA4C;AACrD,SAAS,mBAAmB,kBAAmC;AAC/D,SAAS,mBAAmB,0BAA2C;AACvE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASM;AACP,SAAS,wBAAwD;AACjE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,OAGM;AAQP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAQP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAKM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,eAAe,iBAAsC;AAC9D;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIM;AACP,SAAS,wBAAiD;AAC1D,SAAS,wBAAiD;AAC1D;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,OAEM;AACP,SAAS,wBAAiD;AAC1D,SAAS,6BAA2D;AACpE;AAAA,EACC;AAAA,OAEM;AACP;AAAA,EACC;AAAA,OASM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OAEM;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,eAAe;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,85 @@
1
+ import {
2
+ createMigrationIds,
3
+ createRecordMigrationSequence,
4
+ createRecordType
5
+ } from "@tldraw/store";
6
+ import { T } from "@tldraw/validate";
7
+ import { idValidator } from "../misc/id-validator.mjs";
8
+ const userIdValidator = idValidator("user");
9
+ const userVersions = createMigrationIds("com.tldraw.user", {
10
+ Initial: 1
11
+ });
12
+ const userMigrations = createRecordMigrationSequence({
13
+ sequenceId: "com.tldraw.user",
14
+ recordType: "user",
15
+ sequence: [
16
+ {
17
+ id: userVersions.Initial,
18
+ up: (_record) => {
19
+ }
20
+ }
21
+ ]
22
+ });
23
+ function createUserRecordType(config) {
24
+ const metaConfig = config?.meta;
25
+ const metaValidator = metaConfig ? T.object(
26
+ Object.fromEntries(
27
+ Object.entries(metaConfig).map(([key, v]) => [
28
+ key,
29
+ new T.Validator((value) => {
30
+ if (value === void 0) return void 0;
31
+ return v.validate(value);
32
+ })
33
+ ])
34
+ )
35
+ ).allowUnknownProperties() : T.jsonValue;
36
+ const validator = T.model(
37
+ "user",
38
+ T.object({
39
+ typeName: T.literal("user"),
40
+ id: userIdValidator,
41
+ name: T.string,
42
+ color: T.string,
43
+ imageUrl: T.string,
44
+ meta: metaValidator
45
+ })
46
+ );
47
+ return createRecordType("user", {
48
+ validator,
49
+ scope: "document"
50
+ }).withDefaultProperties(() => ({
51
+ name: "",
52
+ color: "",
53
+ imageUrl: "",
54
+ meta: {}
55
+ }));
56
+ }
57
+ const userValidator = T.model(
58
+ "user",
59
+ T.object({
60
+ typeName: T.literal("user"),
61
+ id: userIdValidator,
62
+ name: T.string,
63
+ color: T.string,
64
+ imageUrl: T.string,
65
+ meta: T.jsonValue
66
+ })
67
+ );
68
+ const UserRecordType = createUserRecordType();
69
+ function isUserId(id) {
70
+ return UserRecordType.isId(id);
71
+ }
72
+ function createUserId(id) {
73
+ return UserRecordType.createId(id);
74
+ }
75
+ export {
76
+ UserRecordType,
77
+ createUserId,
78
+ createUserRecordType,
79
+ isUserId,
80
+ userIdValidator,
81
+ userMigrations,
82
+ userValidator,
83
+ userVersions
84
+ };
85
+ //# sourceMappingURL=TLUser.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/records/TLUser.ts"],
4
+ "sourcesContent": ["import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@tldraw/store'\nimport { JsonObject } from '@tldraw/utils'\nimport { T } from '@tldraw/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * A user record in a tldraw store. User records are document-scoped and\n * persist alongside shapes, assets, and pages. They are automatically\n * included in snapshots, clipboard content, and `.tldr` files so that\n * attribution display names survive across boards and sessions.\n *\n * User records are populated from the {@link @tldraw/tlschema#TLUserStore}\n * when the editor stamps attribution metadata onto shapes.\n *\n * Extend user records with custom metadata by passing validators to\n * {@link @tldraw/tlschema#createTLSchema} or {@link createUserRecordType}.\n *\n * @public\n */\nexport interface TLUser extends BaseRecord<'user', TLUserId> {\n\tname: string\n\tcolor: string\n\timageUrl: string\n\tmeta: JsonObject\n}\n\n/** @public */\nexport type TLUserId = RecordId<TLUser>\n\n/** @public */\nexport const userIdValidator = idValidator<TLUserId>('user')\n\n/** @public */\nexport const userVersions = createMigrationIds('com.tldraw.user', {\n\tInitial: 1,\n})\n\n/** @public */\nexport const userMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.tldraw.user',\n\trecordType: 'user',\n\tsequence: [\n\t\t{\n\t\t\tid: userVersions.Initial,\n\t\t\tup: (_record: any) => {\n\t\t\t\t// initial version \u2014 nothing to migrate\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Creates a user record type with optional custom meta validation.\n *\n * When `meta` validators are provided, the user record's `meta` field will\n * validate those specific fields (when present) while still allowing\n * arbitrary additional JSON properties. Custom meta fields are treated as\n * optional so that user records created without them remain valid.\n *\n * @param config - Optional configuration for custom meta validators\n * @returns A configured user record type\n *\n * @example\n * ```ts\n * import { createUserRecordType } from '@tldraw/tlschema'\n * import { T } from '@tldraw/validate'\n *\n * const CustomUserRecordType = createUserRecordType({\n * meta: {\n * isAdmin: T.boolean,\n * department: T.string,\n * },\n * })\n * ```\n *\n * @public\n */\nexport function createUserRecordType(config?: { meta?: Record<string, T.Validatable<any>> }) {\n\tconst metaConfig = config?.meta\n\n\tconst metaValidator = metaConfig\n\t\t? T.object(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries(metaConfig).map(([key, v]) => [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tnew T.Validator((value) => {\n\t\t\t\t\t\t\tif (value === undefined) return undefined\n\t\t\t\t\t\t\treturn (v as T.Validator<unknown>).validate(value)\n\t\t\t\t\t\t}),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t).allowUnknownProperties()\n\t\t: (T.jsonValue as T.ObjectValidator<JsonObject>)\n\n\tconst validator: T.Validator<TLUser> = T.model(\n\t\t'user',\n\t\tT.object({\n\t\t\ttypeName: T.literal('user'),\n\t\t\tid: userIdValidator,\n\t\t\tname: T.string,\n\t\t\tcolor: T.string,\n\t\t\timageUrl: T.string,\n\t\t\tmeta: metaValidator as T.ObjectValidator<JsonObject>,\n\t\t})\n\t)\n\n\treturn createRecordType<TLUser>('user', {\n\t\tvalidator,\n\t\tscope: 'document',\n\t}).withDefaultProperties(() => ({\n\t\tname: '',\n\t\tcolor: '',\n\t\timageUrl: '',\n\t\tmeta: {},\n\t}))\n}\n\n/** @public */\nexport const userValidator: T.Validator<TLUser> = T.model(\n\t'user',\n\tT.object({\n\t\ttypeName: T.literal('user'),\n\t\tid: userIdValidator,\n\t\tname: T.string,\n\t\tcolor: T.string,\n\t\timageUrl: T.string,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/** @public */\nexport const UserRecordType = createUserRecordType()\n\n/** @public */\nexport function isUserId(id: string): id is TLUserId {\n\treturn UserRecordType.isId(id)\n}\n\n/** @public */\nexport function createUserId(id: string): TLUserId {\n\treturn UserRecordType.createId(id)\n}\n"],
5
+ "mappings": "AAAA;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAEP,SAAS,SAAS;AAClB,SAAS,mBAAmB;AA2BrB,MAAM,kBAAkB,YAAsB,MAAM;AAGpD,MAAM,eAAe,mBAAmB,mBAAmB;AAAA,EACjE,SAAS;AACV,CAAC;AAGM,MAAM,iBAAiB,8BAA8B;AAAA,EAC3D,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,IACT;AAAA,MACC,IAAI,aAAa;AAAA,MACjB,IAAI,CAAC,YAAiB;AAAA,MAEtB;AAAA,IACD;AAAA,EACD;AACD,CAAC;AA4BM,SAAS,qBAAqB,QAAwD;AAC5F,QAAM,aAAa,QAAQ;AAE3B,QAAM,gBAAgB,aACnB,EAAE;AAAA,IACF,OAAO;AAAA,MACN,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM;AAAA,QAC5C;AAAA,QACA,IAAI,EAAE,UAAU,CAAC,UAAU;AAC1B,cAAI,UAAU,OAAW,QAAO;AAChC,iBAAQ,EAA2B,SAAS,KAAK;AAAA,QAClD,CAAC;AAAA,MACF,CAAC;AAAA,IACF;AAAA,EACD,EAAE,uBAAuB,IACvB,EAAE;AAEN,QAAM,YAAiC,EAAE;AAAA,IACxC;AAAA,IACA,EAAE,OAAO;AAAA,MACR,UAAU,EAAE,QAAQ,MAAM;AAAA,MAC1B,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,OAAO,EAAE;AAAA,MACT,UAAU,EAAE;AAAA,MACZ,MAAM;AAAA,IACP,CAAC;AAAA,EACF;AAEA,SAAO,iBAAyB,QAAQ;AAAA,IACvC;AAAA,IACA,OAAO;AAAA,EACR,CAAC,EAAE,sBAAsB,OAAO;AAAA,IAC/B,MAAM;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM,CAAC;AAAA,EACR,EAAE;AACH;AAGO,MAAM,gBAAqC,EAAE;AAAA,EACnD;AAAA,EACA,EAAE,OAAO;AAAA,IACR,UAAU,EAAE,QAAQ,MAAM;AAAA,IAC1B,IAAI;AAAA,IACJ,MAAM,EAAE;AAAA,IACR,OAAO,EAAE;AAAA,IACT,UAAU,EAAE;AAAA,IACZ,MAAM,EAAE;AAAA,EACT,CAAC;AACF;AAGO,MAAM,iBAAiB,qBAAqB;AAG5C,SAAS,SAAS,IAA4B;AACpD,SAAO,eAAe,KAAK,EAAE;AAC9B;AAGO,SAAS,aAAa,IAAsB;AAClD,SAAO,eAAe,SAAS,EAAE;AAClC;",
6
+ "names": []
7
+ }
@@ -24,7 +24,8 @@ const noteShapeProps = {
24
24
  growY: T.positiveNumber,
25
25
  url: T.linkUrl,
26
26
  richText: richTextValidator,
27
- scale: T.nonZeroNumber
27
+ scale: T.nonZeroNumber,
28
+ textFirstEditedBy: T.string.nullable()
28
29
  };
29
30
  const Versions = createShapePropsMigrationIds("note", {
30
31
  AddUrlProp: 1,
@@ -36,7 +37,8 @@ const Versions = createShapePropsMigrationIds("note", {
36
37
  AddScale: 7,
37
38
  AddLabelColor: 8,
38
39
  AddRichText: 9,
39
- AddRichTextAttrs: 10
40
+ AddRichTextAttrs: 10,
41
+ AddFirstEditedBy: 11
40
42
  });
41
43
  const noteShapeMigrations = createShapePropsMigrationSequence({
42
44
  sequence: [
@@ -137,6 +139,15 @@ const noteShapeMigrations = createShapePropsMigrationSequence({
137
139
  delete props.richText.attrs;
138
140
  }
139
141
  }
142
+ },
143
+ {
144
+ id: Versions.AddFirstEditedBy,
145
+ up: (props) => {
146
+ props.textFirstEditedBy = null;
147
+ },
148
+ down: (props) => {
149
+ delete props.textFirstEditedBy;
150
+ }
140
151
  }
141
152
  ]
142
153
  });