Reference · 132 exports · mocanvas 4.11.2
The reactive record store, its schema and its migrations.
Read out of the type declarations inside the published package, so a name here is a name in the version above — and its description is the one written next to the code.
132 of 132
class
Describes one kind of record in the store: how to make ids, defaults, validation, and where the record lives (its scope).
class
A reactive, transactional collection of records.
class
class
The set of record types a store holds plus the migrations that bring persisted data up to date.
class
Hooks that run around record writes.
function
Record that `id` went from `before` to `after` in `target`, collapsing with any change already recorded for the same id:
function
Apply a {@link CollectionDiff} to a set, in place.
function
Apply one migration (record- or store-scoped) to a whole store in place.
function
Apply one record migration to a single record, honoring its filter.
function
Assert that `id` belongs to `type`, narrowing it to that type's id.
function
Shallow-copy a diff (entries are shared).
function
Compare two keys: negative, zero, or positive.
function
Compare two zkeys as unsigned 64-bit integers.
function
Declare a per-record memo, keyed by record id, recomputed only when that record changes.
function
function
A {@link SynchronousStorage} backed by a plain `Map`.
function
Build the ids of a sequence's migrations from friendly names:
function
Create a validated migration sequence.
function
Convenience for the common case: a sequence of record-scoped migrations that all apply to one record type (optionally narrowed further by `filter`).
function
Define a record type.
function
Deep-freeze `object` in development builds, and hand it straight back in production.
function
Freeze a record and its `props` / `meta` bags (one level).
function
How many grapheme clusters `str` has — its length as a reader would count it.
function
The grapheme clusters of `str`, as an array.
function
The property this query can be answered from an index on, or `undefined` when none of it is indexable.
function
Generate a key strictly above `below` (or a first key when omitted).
function
Generate a key strictly below `above` (or a first key when omitted).
function
Generate a key strictly between `below` and `above`; either may be omitted.
function
`start`, followed by `n` freshly generated keys above it.
function
Generate `n` sorted keys strictly above `below`.
function
Generate `n` sorted keys strictly below `above`.
function
Generate `n` sorted keys strictly between `below` and `above`.
function
function
Whether a {@link CollectionDiff} describes no change at all.
function
Whether jitter is on right now.
function
Non-throwing variant of `validateIndexKey`.
function
Assert that `value` looks like a record: an object with string `id` and `typeName`.
function
function
Records are considered unchanged when every top-level value is identical, with `props` and `meta` compared one level deeper.
function
Whether a persisted schema is in the pre-sequence format.
function
Iterate the grapheme clusters of `str`.
function
Whether `record` satisfies every entry of `query`.
function
Whether `value` satisfies `matcher`.
function
function
Split any `${typeName}:${unique}` id into its parts.
function
Parse a `.tldr` file.
function
Produce the diff that undoes `diff`.
function
Serialize records and their schema into the `.tldr` envelope (pretty-printed, stable key order).
function
Turn jitter on or off for the rest of this process; `null` restores the default resolution above.
function
Return a sorted copy of `items` ordered by their `index` (stable).
function
Squash a sequence of diffs into one equivalent diff (does not mutate inputs).
function
Merge `diff` into `target` in place (see `applyChangeToDiff` for the rules).
function
Convert a `{ store, schema }` snapshot into `.tldr` text.
function
Convert a parsed file into a `{ store, schema }` snapshot.
function
Generate a URL-safe unique id (21 chars by default).
function
Throws if `key` is not a well-formed fractional index key: a head marker, enough base-62 integer digits for that head, then an optional fraction of base-62 digits that does not end in `0`.
function
Recombine a zkey into a BigInt (mostly for tests and debugging).
interface
Every record has an id and a type name.
interface
What changed in a set: the members added and the members removed.
interface
The handle returned by {@link createComputedCache}.
interface
Options for {@link createComputedCache}.
interface
interface
The version bounds every legacy migration table declares.
interface
One numbered step of a {@link LegacyMigrations} table.
interface
A legacy migration table: the version range it covers, the numbered steps, and optionally the sub-type split a record type used (a shape's `type`, say, each with its own version line).
interface
interface
interface
A set of changes to a store's records.
interface
interface
The persisted schema shape used before migration sequences: a version number per record type, and one for the store as a whole.
interface
Persisted description of a schema: for each migration sequence, how many migrations had been applied when the data was saved.
interface
A dependency declared by a standalone migration sequence: it must run after (or before) another sequence's numbered migration, even though neither owns the other.
interface
A record that failed validation, with enough context to say what was being done to it at the time.
interface
interface
interface
interface
interface
interface
interface
interface
interface
Somewhere records can be read from and written to, one at a time, without awaiting.
interface
Record storage that also remembers the schema its records were written against, so they can be migrated when they are read back.
interface
interface
type
A context a computed cache can read a store from: a store itself, or anything holding one (an `Editor`).
Options for {@link createComputedCache}, including the record-level equality that decides when a derivation is worth re-running at all.
type
type
type
A fractional index: an order key that sorts lexicographically (plain string comparison) and between which new keys can always be generated.
type
type
type
type
A query over the records of one type: property name to matcher, every entry of which must hold (they are ANDed).
How one property of a record is matched.
Properties the caller must pass to `create()`: the record's data keys minus whatever `withDefaultProperties` provides.
type
Keys of `R` that hold data (everything except `id` and `typeName`).
type
Extract the record type an id refers to.
type
A branded string id.
type
Where a record lives: - `document`: persisted, shared between collaborators (shapes, pages, ...) - `session`: persisted locally only (camera, current page, ...) - `presence`: shared but never persisted (cursors, ...)
type
type
A live index over one property, as a diff-carrying signal.
type
How an {@link RSIndexMap} changed: per property value, which ids joined and left.
type
An index over one property of one record type: for each value that property takes, the ids of the records that hold it.
type
A persisted schema, in either format mocanvas can read.
type
Serialized records keyed by id.
Return `false` to veto the deletion.
type
type
Anything that owns a store: a `Store` itself, or an object holding one (an `Editor`).
The record union of whatever store a {@link StoreObject} carries.
type
How the records of one type are narrowed: a predicate, or a declarative {@link QueryExpression} the store can answer from an index.
type
type
A validator per record type, as `StoreSchema` collects them from the record types.
type
type
constant
Why loading a persisted snapshot failed.
constant
The key a run of indices starts from when the caller names none.
constant
`.tldr` file envelope.
constant
Length of the unique part of a generated record id.
constant
The conventional first key.
constant
Number of base-62 digits (after the head marker) that affect the zkey.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.