@tldraw/tlstore
Advanced tools
Comparing version 0.0.1-alpha.0 to 0.0.1-alpha.1
@@ -1,671 +0,2 @@ | ||
import { Atom, Computed } from '@tldraw/tlstate'; | ||
type ID<R extends BaseRecord = BaseRecord> = string & { | ||
__type__: R; | ||
}; | ||
/** | ||
* The base record that all records must extend. | ||
*/ | ||
interface BaseRecord<TypeName extends string = string> { | ||
readonly id: ID<this>; | ||
readonly typeName: TypeName; | ||
} | ||
type OmitMeta<R extends BaseRecord> = R extends R ? Omit<R, 'id' | 'typeName'> : R; | ||
declare function defineMigrations<FirstVersion extends number, CurrentVersion extends number>({ firstVersion, currentVersion, migrators, subTypeKey, subTypeMigrations, }: { | ||
firstVersion: FirstVersion; | ||
currentVersion: CurrentVersion; | ||
migrators: { | ||
[version in Exclude<Range<FirstVersion, CurrentVersion>, FirstVersion>]: Migration; | ||
}; | ||
subTypeKey?: string; | ||
subTypeMigrations?: Record<string, BaseMigrationsInfo>; | ||
}): Migrations; | ||
type Migration<T = any> = { | ||
up: (oldState: T) => T; | ||
down: (newState: T) => T; | ||
}; | ||
interface BaseMigrationsInfo { | ||
firstVersion: number; | ||
currentVersion: number; | ||
migrators: { | ||
[version: number]: Migration; | ||
}; | ||
} | ||
interface Migrations extends BaseMigrationsInfo { | ||
subTypeKey?: string; | ||
subTypeMigrations?: Record<string, BaseMigrationsInfo>; | ||
} | ||
type MigrationResult<T> = { | ||
type: 'success'; | ||
value: T; | ||
} | { | ||
type: 'error'; | ||
reason: MigrationFailureReason; | ||
}; | ||
declare enum MigrationFailureReason { | ||
IncompatibleSubtype = "incompatible-subtype", | ||
UnknownType = "unknown-type", | ||
TargetVersionTooNew = "target-version-too-new", | ||
TargetVersionTooOld = "target-version-too-old", | ||
MigrationError = "migration-error", | ||
UnrecognizedSubtype = "unrecognized-subtype" | ||
} | ||
type RecordVersion = { | ||
rootVersion: number; | ||
subTypeVersion?: number; | ||
}; | ||
declare function getRecordVersion(record: BaseRecord, serializedSchema: SerializedSchema): RecordVersion; | ||
declare function compareRecordVersions(a: RecordVersion, b: RecordVersion): 0 | 1 | -1; | ||
declare function migrateRecord<R extends BaseRecord>({ record, migrations, fromVersion, toVersion, }: { | ||
record: unknown; | ||
migrations: Migrations; | ||
fromVersion: number; | ||
toVersion: number; | ||
}): MigrationResult<R>; | ||
declare function migrate<T>({ value, migrations, fromVersion, toVersion, }: { | ||
value: unknown; | ||
migrations: Migrations; | ||
fromVersion: number; | ||
toVersion: number; | ||
}): MigrationResult<T>; | ||
type Range<From extends number, To extends number> = To extends From ? From : To | Range<From, Decrement<To>>; | ||
type Decrement<n extends number> = n extends 0 ? never : n extends 1 ? 0 : n extends 2 ? 1 : n extends 3 ? 2 : n extends 4 ? 3 : n extends 5 ? 4 : n extends 6 ? 5 : n extends 7 ? 6 : n extends 8 ? 7 : n extends 9 ? 8 : n extends 10 ? 9 : n extends 11 ? 10 : n extends 12 ? 11 : n extends 13 ? 12 : n extends 14 ? 13 : n extends 15 ? 14 : n extends 16 ? 15 : n extends 17 ? 16 : n extends 18 ? 17 : n extends 19 ? 18 : n extends 20 ? 19 : n extends 21 ? 20 : n extends 22 ? 21 : n extends 23 ? 22 : n extends 24 ? 23 : n extends 25 ? 24 : n extends 26 ? 25 : n extends 27 ? 26 : n extends 28 ? 27 : n extends 29 ? 28 : n extends 30 ? 29 : n extends 31 ? 30 : n extends 32 ? 31 : n extends 33 ? 32 : n extends 34 ? 33 : n extends 35 ? 34 : n extends 36 ? 35 : n extends 37 ? 36 : n extends 38 ? 37 : n extends 39 ? 38 : n extends 40 ? 39 : n extends 41 ? 40 : n extends 42 ? 41 : n extends 43 ? 42 : n extends 44 ? 43 : n extends 45 ? 44 : n extends 46 ? 45 : n extends 47 ? 46 : n extends 48 ? 47 : n extends 49 ? 48 : n extends 50 ? 49 : n extends 51 ? 50 : never; | ||
/** | ||
* A record type is a type that can be stored in a record store. It is created with | ||
* `createRecordType`. | ||
*/ | ||
declare class RecordType<R extends BaseRecord, RequiredProperties extends keyof Omit<R, 'id' | 'typeName'>> { | ||
/** | ||
* The unique type associated with this record. | ||
* | ||
* @public | ||
* @readonly | ||
*/ | ||
readonly typeName: R['typeName']; | ||
readonly config: { | ||
readonly createDefaultProperties: () => Exclude<OmitMeta<R>, RequiredProperties>; | ||
readonly migrations: Migrations; | ||
}; | ||
constructor( | ||
/** | ||
* The unique type associated with this record. | ||
* | ||
* @public | ||
* @readonly | ||
*/ | ||
typeName: R['typeName'], config: { | ||
readonly createDefaultProperties: () => Exclude<OmitMeta<R>, RequiredProperties>; | ||
readonly migrations: Migrations; | ||
}); | ||
/** | ||
* Create a new record of this type. | ||
* | ||
* @param properties The properties of the record. | ||
* | ||
* @returns The new record. | ||
*/ | ||
create(properties: Pick<R, RequiredProperties> & Omit<Partial<R>, RequiredProperties>): R; | ||
/** | ||
* Clone a record of this type. | ||
* | ||
* @param record The record to clone. | ||
* @public | ||
* @returns The cloned record. | ||
*/ | ||
clone(record: R): R; | ||
/** | ||
* Create a new ID for this record type. | ||
* | ||
* @example | ||
* const id = recordType.createId() | ||
* | ||
* @public | ||
* @returns The new ID. | ||
*/ | ||
createId(): ID<R>; | ||
/** | ||
* Create a new ID for this record type based on the given ID. | ||
* | ||
* @example | ||
* const id = recordType.createCustomId("myId") | ||
* | ||
* @param id The ID to base the new ID on. | ||
* @returns The new ID. | ||
*/ | ||
createCustomId(id: string): ID<R>; | ||
/** | ||
* Check whether a record is an instance of this record type. | ||
* | ||
* @example | ||
* const result = recordType.isInstance(someRecord) | ||
* | ||
* @param record The record to check. | ||
* @returns Whether the record is an instance of this record type. | ||
*/ | ||
isInstance: (record?: BaseRecord) => record is R; | ||
/** | ||
* Check whether an id is an id of this type. | ||
* | ||
* @example | ||
* const result = recordType.isIn("someId") | ||
* | ||
* @param id The id to check. | ||
* @returns Whether the id is an id of this type. | ||
*/ | ||
isId(id?: string): id is ID<R>; | ||
/** | ||
* Create a new RecordType that has the same type name as this RecordType and includes the given default properties. | ||
* | ||
* @example | ||
* const authorType = createRecordType('author', () => ({ living: true })) | ||
* const deadAuthorType = authorType.withDefaultProperties({ living: false }) | ||
* | ||
* @param fn A function that returns the default properties of the new RecordType. | ||
* | ||
* @returns The new RecordType. | ||
*/ | ||
withDefaultProperties<DefaultProps extends Omit<Partial<R>, 'typeName' | 'id'>>(createDefaultProperties: () => DefaultProps): RecordType<R, Exclude<RequiredProperties, keyof DefaultProps>>; | ||
} | ||
/** | ||
* Create a record type. | ||
* | ||
* @example | ||
* const Book = createRecordType<Book>('book') | ||
* | ||
* @param typeName The name of the type to create. | ||
*/ | ||
declare function createRecordType<R extends BaseRecord>(typeName: R['typeName'], config?: Omit<Partial<ConstructorParameters<typeof RecordType>[1]>, 'defaultProperties' | 'onLoad'>): RecordType<R, keyof Omit<R, 'id' | 'typeName'>>; | ||
/** | ||
* Assert whether an id correspond to a record type. | ||
* | ||
* @example | ||
* assertIdType(myId, ID<MyRecord>) | ||
* | ||
* @param id The id to check. | ||
* @param type The type of the record. | ||
*/ | ||
declare function assertIdType<R extends BaseRecord>(id: string | undefined, type: RecordType<R, any>): asserts id is ID<R>; | ||
type ValueMatcher<T> = { | ||
eq: T; | ||
} | { | ||
neq: T; | ||
}; | ||
type QueryExpression<R extends object> = { | ||
[k in keyof R & string]?: ValueMatcher<R[k]>; | ||
}; | ||
type RSIndexDiff<R extends BaseRecord = BaseRecord, Property extends string & keyof R = string & keyof R> = Map<R[Property], CollectionDiff<ID<R>>>; | ||
type RSIndex<R extends BaseRecord = BaseRecord, Property extends string & keyof R = string & keyof R> = Computed<Map<R[Property], Set<ID<R>>>, RSIndexDiff<R, Property>>; | ||
/** | ||
* A class that provides a 'namespace' for the various kinds of indexes | ||
* one may wish to derive from the record store. | ||
*/ | ||
declare class StoreQueries<R extends BaseRecord = BaseRecord> { | ||
private readonly atoms; | ||
private readonly history; | ||
constructor(atoms: Atom<Record<ID<R>, Atom<R>>>, history: Atom<number, RecordsDiff<R>>); | ||
/** | ||
* A cache of derivations (indexes). | ||
* | ||
* @private | ||
*/ | ||
private indexCache; | ||
/** | ||
* A cache of derivations (filtered histories). | ||
* | ||
* @private | ||
*/ | ||
private historyCache; | ||
/** | ||
* Create a derivation that contains the hisotry for a given type | ||
* | ||
* @param typeName The name of the type to filter by. | ||
* | ||
* @returns A derivation that returns the ids of all records of the given type. | ||
* @public | ||
*/ | ||
filterHistory<TypeName extends R['typeName']>(typeName: TypeName): Computed<number, RecordsDiff<Extract<R, { | ||
typeName: TypeName; | ||
}>>>; | ||
/** | ||
* Create a derivation that returns an index on a property for the given type. | ||
* | ||
* @param typeName The name of the type. | ||
* @param property The name of the property. | ||
* | ||
* @public | ||
*/ | ||
index<TypeName extends R['typeName'], Property extends string & keyof Extract<R, { | ||
typeName: TypeName; | ||
}>>(typeName: TypeName, property: Property): RSIndex<Extract<R, { | ||
typeName: TypeName; | ||
}>, Property>; | ||
/** | ||
* Create a derivation that returns an index on a property for the given type. | ||
* | ||
* @param typeName The name of the type?. | ||
* @param property The name of the property?. | ||
* | ||
* @private | ||
*/ | ||
__uncached_createIndex<TypeName extends R['typeName'], Property extends string & keyof Extract<R, { | ||
typeName: TypeName; | ||
}>>(typeName: TypeName, property: Property): RSIndex<Extract<R, { | ||
typeName: TypeName; | ||
}>, Property>; | ||
/** | ||
* Create a derivation that will return a signle record matching the given query. | ||
* | ||
* It will return undefined if there is no matching record | ||
* | ||
* @param typeName The name of the type? | ||
* @param queryCreator A function that returns the query expression. | ||
* @param name (optinal) The name of the query. | ||
*/ | ||
record<TypeName extends R['typeName']>(typeName: TypeName, queryCreator?: () => QueryExpression<Extract<R, { | ||
typeName: TypeName; | ||
}>>, name?: string): Computed<Extract<R, { | ||
typeName: TypeName; | ||
}> | undefined>; | ||
/** | ||
* Create a derivation that will return an array of records matching the given query | ||
* | ||
* @param typeName The name of the type? | ||
* @param queryCreator A function that returns the query expression. | ||
* @param name (optinal) The name of the query. | ||
*/ | ||
records<TypeName extends R['typeName']>(typeName: TypeName, queryCreator?: () => QueryExpression<Extract<R, { | ||
typeName: TypeName; | ||
}>>, name?: string): Computed<Array<Extract<R, { | ||
typeName: TypeName; | ||
}>>>; | ||
/** | ||
* Create a derivation that will return the ids of all records of the given type. | ||
* | ||
* @param typeName The name of the type. | ||
* @param queryCreator A function that returns the query expression. | ||
* @param name (optinal) The name of the query. | ||
*/ | ||
ids<TypeName extends R['typeName']>(typeName: TypeName, queryCreator?: () => QueryExpression<Extract<R, { | ||
typeName: TypeName; | ||
}>>, name?: string): Computed<Set<ID<Extract<R, { | ||
typeName: TypeName; | ||
}>>>, CollectionDiff<ID<Extract<R, { | ||
typeName: TypeName; | ||
}>>>>; | ||
exec<TypeName extends R['typeName']>(typeName: TypeName, query: QueryExpression<Extract<R, { | ||
typeName: TypeName; | ||
}>>): Array<Extract<R, { | ||
typeName: TypeName; | ||
}>>; | ||
} | ||
type RecFromId<K extends ID> = K extends ID<infer R> ? R : never; | ||
/** A diff describing the changes to a record. */ | ||
type RecordsDiff<R extends BaseRecord> = { | ||
added: Record<string, R>; | ||
updated: Record<string, [from: R, to: R]>; | ||
removed: Record<string, R>; | ||
}; | ||
/** A diff describing the changes to a collection. */ | ||
type CollectionDiff<T> = { | ||
added?: Set<T>; | ||
removed?: Set<T>; | ||
}; | ||
/** An entry containing changes that originated either by user actions or remote changes. */ | ||
type HistoryEntry<R extends BaseRecord = BaseRecord> = { | ||
changes: RecordsDiff<R>; | ||
source: 'user' | 'remote'; | ||
}; | ||
/** A function that will be called when the history changes. */ | ||
type StoreListener<R extends BaseRecord> = (entry: HistoryEntry<R>) => void; | ||
/** A record store is a collection of records of different types. */ | ||
type ComputedCache<Data, R extends BaseRecord> = { | ||
get(id: ID<R>): Data | undefined; | ||
}; | ||
/** A serialized snapshot of the record store's values. */ | ||
type StoreSnapshot<R extends BaseRecord> = { | ||
[id: string]: R; | ||
}; | ||
type StoreValidator<R extends BaseRecord> = { | ||
validate: (record: unknown) => R; | ||
}; | ||
type StoreValidators<R extends BaseRecord> = { | ||
[K in R['typeName']]: StoreValidator<Extract<R, { | ||
typeName: K; | ||
}>>; | ||
}; | ||
/** A store of records. */ | ||
declare class Store<R extends BaseRecord = BaseRecord> { | ||
/** | ||
* An atom containing the store's atoms. | ||
* | ||
* @private | ||
* @readonly | ||
*/ | ||
private readonly atoms; | ||
/** | ||
* An atom containing the store's history. | ||
* | ||
* @public | ||
* @readonly | ||
*/ | ||
readonly history: Atom<number, RecordsDiff<R>>; | ||
/** | ||
* A StoreQueries instance for this store. | ||
* | ||
* @public | ||
* @readonly | ||
*/ | ||
readonly query: StoreQueries<R>; | ||
/** | ||
* A set containing listeners that have been added to this store. | ||
* | ||
* @private | ||
*/ | ||
private listeners; | ||
/** | ||
* An array of history entries that have not yet been flushed. | ||
* | ||
* @private | ||
*/ | ||
private historyAccumulator; | ||
/** | ||
* A reactor that responds to changes to the history by squashing the | ||
* accumulated history and notifying listeners of the changes. | ||
* | ||
* @private | ||
*/ | ||
private historyReactor; | ||
private onError?; | ||
validators: StoreValidators<R>; | ||
constructor(config: { | ||
/** | ||
* The store's initial data. | ||
*/ | ||
initialData?: StoreSnapshot<R>; | ||
/** | ||
* A map of validators for each record type. A record's validator will be | ||
* called when the record is created or updated. It should throw an error if the record is invalid. | ||
*/ | ||
validators: StoreValidators<R>; | ||
UNSAFE_SKIP_INITIAL_VALIDATION?: boolean; | ||
onError?: (error: Error) => void; | ||
}); | ||
_flushHistory(): void; | ||
private validateRecord; | ||
/** | ||
* Update the history with a diff of changes. | ||
* | ||
* @param changes The changes to add to the history. | ||
*/ | ||
private updateHistory; | ||
validate(): void; | ||
/** | ||
* A callback fired after a record is created. Use this to perform | ||
* related updates to other records in the store. | ||
* | ||
* @param record The record to be created | ||
*/ | ||
onAfterCreate?: (record: R) => void; | ||
/** | ||
* A callback fired after each record's change. | ||
* | ||
* @param prev The previous value, if any. | ||
* @param next The next value. | ||
*/ | ||
onAfterChange?: (prev: R, next: R) => void; | ||
/** | ||
* A callback fired before a record is deleted. | ||
* | ||
* @param prev The record that will be deleted. | ||
*/ | ||
onBeforeDelete?: (prev: R) => void; | ||
/** | ||
* A callback fired after a record is deleted. | ||
* | ||
* @param prev The record that will be deleted. | ||
*/ | ||
onAfterDelete?: (prev: R) => void; | ||
private _runCallbacks; | ||
/** | ||
* Add some records to the store. It's an error if they already exist. | ||
* | ||
* @param records The records to add. | ||
* @public | ||
*/ | ||
put: (records: R[]) => void; | ||
/** | ||
* Remove some records from the store via their ids. | ||
* | ||
* @param ids The ids of the records to remove. | ||
* @public | ||
*/ | ||
remove: (ids: ID<R>[]) => void; | ||
/** | ||
* Get the value of a store record by its id. | ||
* | ||
* @param id The id of the record to get. | ||
* @public | ||
*/ | ||
get: <K extends ID<R>>(id: K) => RecFromId<K> | undefined; | ||
/** | ||
* Opposite of `deserialize`. Creates a JSON payload from the record store. | ||
* | ||
* @param filter (optional) A function to filter structs that do not satisfy the predicate. | ||
* @returns The record store snapshot as a JSON payload. | ||
*/ | ||
serialize: (filter?: ((record: R) => boolean) | undefined) => StoreSnapshot<R>; | ||
/** | ||
* Opposite of `serialize`. Replace the store's current records with records as defined by a simple JSON structure into the stores. | ||
* | ||
* @param snapshot The JSON snapshot to deserialize. | ||
* @public | ||
*/ | ||
deserialize: (snapshot: StoreSnapshot<R>) => void; | ||
/** | ||
* Get an array of all values in the store. | ||
* | ||
* @public | ||
* @returns An array of all values in the store. | ||
*/ | ||
allRecords: () => R[]; | ||
/** | ||
* Removes all records from the store. | ||
* | ||
* @public | ||
*/ | ||
clear: () => void; | ||
/** | ||
* Update a record. To update multiple records at once, use the `update` method of the `TypedStore` class. | ||
* | ||
* @param id The id of the record to update. | ||
* @param updater A function that updates the record. | ||
*/ | ||
update: <K extends ID<R>>(id: K, updater: (record: RecFromId<K>) => RecFromId<K>) => void; | ||
/** | ||
* Get whether the record store has a id. | ||
* | ||
* @param id The id of the record to check. | ||
* @public | ||
*/ | ||
has: <K extends ID<R>>(id: K) => boolean; | ||
/** | ||
* Add a new listener to the store. | ||
* | ||
* @param listener The listener to call when the store updates. | ||
* @returns A function to remove the listener. | ||
*/ | ||
listen: (listener: StoreListener<R>) => () => void; | ||
private isMergingRemoteChanges; | ||
/** | ||
* Merge changes from a remote source without triggering listeners. | ||
* | ||
* @param fn A function that merges the external changes. | ||
* @public | ||
*/ | ||
mergeRemoteChanges: (fn: () => void) => void; | ||
extractingChanges(fn: () => void): RecordsDiff<R>; | ||
applyDiff(diff: RecordsDiff<R>, runCallbacks?: boolean): void; | ||
/** | ||
* Create a computed cache. | ||
* | ||
* @param name The name of the derivation cache. | ||
* @param derive A function used to derive the value of the cache. | ||
* @public | ||
*/ | ||
createComputedCache: <T, V extends R = R>(name: string, derive: (record: V) => T | undefined) => ComputedCache<T, V>; | ||
/** | ||
* Create a computed cache from a selector | ||
* | ||
* @param name The name of the derivation cache. | ||
* @param selector A function that returns a subset of the original shape | ||
* @param derive A function used to derive the value of the cache. | ||
* @public | ||
*/ | ||
createSelectedComputedCache: <T, J, V extends R = R>(name: string, selector: (record: V) => T | undefined, derive: (input: T) => J | undefined) => ComputedCache<J, V>; | ||
} | ||
/** | ||
* Squash a collection of diffs into a single diff. | ||
* | ||
* @param diffs An array of diffs to squash. | ||
* | ||
* @returns A single diff that represents the squashed diffs. | ||
*/ | ||
declare function squashRecordDiffs<T extends BaseRecord>(diffs: RecordsDiff<T>[]): RecordsDiff<T>; | ||
declare function reverseRecordsDiff(diff: RecordsDiff<any>): RecordsDiff<any>; | ||
interface SerializedSchema { | ||
/** | ||
* Schema version is the version for this type you're looking at right now | ||
*/ | ||
schemaVersion: number; | ||
/** | ||
* Store version is the version for the structure of the store. e.g. higher level | ||
* structure like removing or renaming a record type. | ||
*/ | ||
storeVersion: number; | ||
/** | ||
* Record versions are the versions for each record type. e.g. adding a new field to a record | ||
*/ | ||
recordVersions: Record<string, { | ||
version: number; | ||
} | { | ||
version: number; | ||
subTypeVersions: Record<string, number>; | ||
subTypeKey: string; | ||
}>; | ||
} | ||
declare class StoreSchema<R extends BaseRecord> { | ||
readonly typeArray: RecordType<R, any>[]; | ||
readonly storeMigrations: Migrations; | ||
types: Record<string, RecordType<R, any>>; | ||
constructor(typeArray: RecordType<R, any>[], storeMigrations: Migrations); | ||
migratePersistedRecord(record: R, persistedSchema: SerializedSchema, direction?: 'up' | 'down'): MigrationResult<R>; | ||
migrateStore(store: Store<R>, persistedSchema: SerializedSchema): MigrationResult<void>; | ||
serialize(): SerializedSchema; | ||
serializeEarliestVersion(): SerializedSchema; | ||
} | ||
declare const compareSchemas: (a: SerializedSchema, b: SerializedSchema) => number; | ||
/** | ||
* Freeze an object when in development mode. | ||
* Copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze | ||
* | ||
* @example | ||
* const frozen = devFreeze({ a: 1 }) | ||
* | ||
* @param object The object to freeze. | ||
* | ||
* @returns The frozen object when in development mode, or else the object when in other modes. | ||
*/ | ||
declare function devFreeze<T>(object: T): T; | ||
/** | ||
* A class that can be used to incrementally construct a set of records. | ||
*/ | ||
declare class IncrementalSetConstructor<T> { | ||
/** | ||
* The previous value of the set. | ||
* | ||
* @private | ||
* @readonly | ||
*/ | ||
private readonly previousValue; | ||
/** | ||
* The next value of the set. | ||
* | ||
* @private | ||
*/ | ||
private nextValue?; | ||
/** | ||
* The diff of the set. | ||
* | ||
* @private | ||
*/ | ||
private diff?; | ||
constructor( | ||
/** | ||
* The previous value of the set. | ||
* | ||
* @private | ||
* @readonly | ||
*/ | ||
previousValue: Set<T>); | ||
/** | ||
* Get the next value of the set. | ||
* | ||
* @public | ||
*/ | ||
get(): { | ||
value: Set<T>; | ||
diff: CollectionDiff<T>; | ||
} | undefined; | ||
/** | ||
* Add an item to the set. | ||
* | ||
* @param item The item to add. | ||
* @param wasAlreadyPresent Whether the item was already present in the set. | ||
* | ||
* @private | ||
*/ | ||
private _add; | ||
/** | ||
* Add an item to the set. | ||
* | ||
* @param item The item to add. | ||
* | ||
* @public | ||
*/ | ||
add(item: T): void; | ||
/** | ||
* Remove an item from the set. | ||
* | ||
* @param item The item to remove. | ||
* @param wasAlreadyPresent Whether the item was already present in the set. | ||
* | ||
* @private | ||
*/ | ||
private _remove; | ||
/** | ||
* Remove an item from the set. | ||
* | ||
* @param item The item to remove. | ||
* | ||
* @public | ||
*/ | ||
remove(item: T): void; | ||
} | ||
type ExtractRecordType<T extends Store<any>> = T extends Store<infer R> ? R : never; | ||
type ExtractR<T extends RecordType<any, any>> = T extends RecordType<infer S, any> ? S : never; | ||
/** | ||
* Get the type of all records in a record store. | ||
*/ | ||
type AllRecords<T extends Store<any>> = ExtractR<ExtractRecordType<T>>; | ||
export { AllRecords, BaseRecord, CollectionDiff, ComputedCache, HistoryEntry, ID, IncrementalSetConstructor, Migration, MigrationFailureReason, MigrationResult, Migrations, RecordType, RecordVersion, RecordsDiff, SerializedSchema, Store, StoreListener, StoreSchema, StoreSnapshot, assertIdType, compareRecordVersions, compareSchemas, createRecordType, defineMigrations, devFreeze, getRecordVersion, migrate, migrateRecord, reverseRecordsDiff, squashRecordDiffs }; | ||
export * from './lib'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,3 +5,3 @@ { | ||
"description": "A tiny little drawing app (store).", | ||
"version": "0.0.1-alpha.0", | ||
"version": "0.0.1-alpha.1", | ||
"author": "tldraw GB Ltd.", | ||
@@ -17,2 +17,5 @@ "homepage": "https://tldraw.dev", | ||
"main": "./src/index.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
@@ -25,7 +28,4 @@ "test": "jest", | ||
}, | ||
"files": [ | ||
"dist/**" | ||
], | ||
"dependencies": { | ||
"@tldraw/tlstate": "0.0.1-alpha.0", | ||
"@tldraw/tlstate": "0.0.1-alpha.1", | ||
"lodash.isequal": "^4.5.0", | ||
@@ -32,0 +32,0 @@ "nanoid": "^3.0.0" |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
282047
54
946