tldraw/packages/validate/api-report.md
Steve Ruiz b7d9c8684c
tldraw zero - package shuffle (#1710)
This PR moves code between our packages so that:
- @tldraw/editor is a “core” library with the engine and canvas but no
shapes, tools, or other things
- @tldraw/tldraw contains everything particular to the experience we’ve
built for tldraw

At first look, this might seem like a step away from customization and
configuration, however I believe it greatly increases the configuration
potential of the @tldraw/editor while also providing a more accurate
reflection of what configuration options actually exist for
@tldraw/tldraw.

## Library changes

@tldraw/editor re-exports its dependencies and @tldraw/tldraw re-exports
@tldraw/editor.

- users of @tldraw/editor WITHOUT @tldraw/tldraw should almost always
only import things from @tldraw/editor.
- users of @tldraw/tldraw should almost always only import things from
@tldraw/tldraw.

- @tldraw/polyfills is merged into @tldraw/editor
- @tldraw/indices is merged into @tldraw/editor
- @tldraw/primitives is merged mostly into @tldraw/editor, partially
into @tldraw/tldraw
- @tldraw/file-format is merged into @tldraw/tldraw
- @tldraw/ui is merged into @tldraw/tldraw

Many (many) utils and other code is moved from the editor to tldraw. For
example, embeds now are entirely an feature of @tldraw/tldraw. The only
big chunk of code left in core is related to arrow handling.

## API Changes

The editor can now be used without tldraw's assets. We load them in
@tldraw/tldraw instead, so feel free to use whatever fonts or images or
whatever that you like with the editor.

All tools and shapes (except for the `Group` shape) are moved to
@tldraw/tldraw. This includes the `select` tool.

You should use the editor with at least one tool, however, so you now
also need to send in an `initialState` prop to the Editor /
<TldrawEditor> component indicating which state the editor should begin
in.

The `components` prop now also accepts `SelectionForeground`.

The complex selection component that we use for tldraw is moved to
@tldraw/tldraw. The default component is quite basic but can easily be
replaced via the `components` prop. We pass down our tldraw-flavored
SelectionFg via `components`.

Likewise with the `Scribble` component: the `DefaultScribble` no longer
uses our freehand tech and is a simple path instead. We pass down the
tldraw-flavored scribble via `components`.

The `ExternalContentManager` (`Editor.externalContentManager`) is
removed and replaced with a mapping of types to handlers.

- Register new content handlers with
`Editor.registerExternalContentHandler`.
- Register new asset creation handlers (for files and URLs) with
`Editor.registerExternalAssetHandler`

### Change Type

- [x] `major` — Breaking change

### Test Plan

- [x] Unit Tests
- [x] End to end tests

### Release Notes

- [@tldraw/editor] lots, wip
- [@tldraw/ui] gone, merged to tldraw/tldraw
- [@tldraw/polyfills] gone, merged to tldraw/editor
- [@tldraw/primitives] gone, merged to tldraw/editor / tldraw/tldraw
- [@tldraw/indices] gone, merged to tldraw/editor
- [@tldraw/file-format] gone, merged to tldraw/tldraw

---------

Co-authored-by: alex <alex@dytry.ch>
2023-07-17 21:22:34 +00:00

5.6 KiB

API Report File for "@tldraw/validate"

Do not edit this file. It is a report generated by API Extractor.


import { JsonValue } from '@tldraw/utils';

// @public
const any: Validator<any>;

// @public
const array: Validator<unknown[]>;

// @public
function arrayOf<T>(itemValidator: Validatable<T>): ArrayOfValidator<T>;

// @public (undocumented)
class ArrayOfValidator<T> extends Validator<T[]> {
    constructor(itemValidator: Validatable<T>);
    // (undocumented)
    readonly itemValidator: Validatable<T>;
    // (undocumented)
    lengthGreaterThan1(): Validator<T[]>;
    // (undocumented)
    nonEmpty(): Validator<T[]>;
}

// @public
const bigint: Validator<bigint>;

// @public
const boolean: Validator<boolean>;

// @public
function dict<Key extends string, Value>(keyValidator: Validatable<Key>, valueValidator: Validatable<Value>): DictValidator<Key, Value>;

// @public (undocumented)
class DictValidator<Key extends string, Value> extends Validator<Record<Key, Value>> {
    constructor(keyValidator: Validatable<Key>, valueValidator: Validatable<Value>);
    // (undocumented)
    readonly keyValidator: Validatable<Key>;
    // (undocumented)
    readonly valueValidator: Validatable<Value>;
}

// @public
const integer: Validator<number>;

// @public
function jsonDict(): DictValidator<string, JsonValue>;

// @public
const jsonValue: Validator<JsonValue>;

// @public
function literal<T extends boolean | number | string>(expectedValue: T): Validator<T>;

// @public (undocumented)
function literalEnum<const Values extends readonly unknown[]>(...values: Values): Validator<Values[number]>;

// @public
function model<T extends {
    readonly id: string;
}>(name: string, validator: Validatable<T>): Validator<T>;

// @public
const nonZeroInteger: Validator<number>;

// @public
const nonZeroNumber: Validator<number>;

// @public (undocumented)
function nullable<T>(validator: Validatable<T>): Validator<null | T>;

// @public
const number: Validator<number>;

// @public
function object<Shape extends object>(config: {
    readonly [K in keyof Shape]: Validatable<Shape[K]>;
}): ObjectValidator<Shape>;

// @public (undocumented)
class ObjectValidator<Shape extends object> extends Validator<Shape> {
    constructor(config: {
        readonly [K in keyof Shape]: Validatable<Shape[K]>;
    }, shouldAllowUnknownProperties?: boolean);
    // (undocumented)
    allowUnknownProperties(): ObjectValidator<Shape>;
    // (undocumented)
    readonly config: {
        readonly [K in keyof Shape]: Validatable<Shape[K]>;
    };
    extend<Extension extends Record<string, unknown>>(extension: {
        readonly [K in keyof Extension]: Validatable<Extension[K]>;
    }): ObjectValidator<Shape & Extension>;
}

// @public (undocumented)
function optional<T>(validator: Validatable<T>): Validator<T | undefined>;

// @public
const positiveInteger: Validator<number>;

// @public
const positiveNumber: Validator<number>;

// @public (undocumented)
function setEnum<T>(values: ReadonlySet<T>): Validator<T>;

// @public
const string: Validator<string>;

declare namespace T {
    export {
        literal,
        arrayOf,
        object,
        jsonDict,
        dict,
        union,
        model,
        setEnum,
        optional,
        nullable,
        literalEnum,
        ValidatorFn,
        Validatable,
        ValidationError,
        TypeOf,
        Validator,
        ArrayOfValidator,
        ObjectValidator,
        UnionValidator,
        DictValidator,
        unknown,
        any,
        string,
        number,
        positiveNumber,
        nonZeroNumber,
        integer,
        positiveInteger,
        nonZeroInteger,
        boolean,
        bigint,
        array,
        unknownObject,
        jsonValue
    }
}
export { T }

// @public (undocumented)
type TypeOf<V extends Validatable<unknown>> = V extends Validatable<infer T> ? T : never;

// @public
function union<Key extends string, Config extends UnionValidatorConfig<Key, Config>>(key: Key, config: Config): UnionValidator<Key, Config>;

// @public (undocumented)
class UnionValidator<Key extends string, Config extends UnionValidatorConfig<Key, Config>, UnknownValue = never> extends Validator<TypeOf<Config[keyof Config]> | UnknownValue> {
    constructor(key: Key, config: Config, unknownValueValidation: (value: object, variant: string) => UnknownValue);
    // (undocumented)
    validateUnknownVariants<Unknown>(unknownValueValidation: (value: object, variant: string) => Unknown): UnionValidator<Key, Config, Unknown>;
}

// @public
const unknown: Validator<unknown>;

// @public (undocumented)
const unknownObject: Validator<Record<string, unknown>>;

// @public (undocumented)
type Validatable<T> = {
    validate: (value: unknown) => T;
};

// @public (undocumented)
class ValidationError extends Error {
    constructor(rawMessage: string, path?: ReadonlyArray<number | string>);
    // (undocumented)
    name: string;
    // (undocumented)
    readonly path: ReadonlyArray<number | string>;
    // (undocumented)
    readonly rawMessage: string;
}

// @public (undocumented)
export class Validator<T> implements Validatable<T> {
    constructor(validationFn: ValidatorFn<T>);
    check(name: string, checkFn: (value: T) => void): Validator<T>;
    // (undocumented)
    check(checkFn: (value: T) => void): Validator<T>;
    nullable(): Validator<null | T>;
    optional(): Validator<T | undefined>;
    refine<U>(otherValidationFn: (value: T) => U): Validator<U>;
    validate(value: unknown): T;
    // (undocumented)
    readonly validationFn: ValidatorFn<T>;
}

// @public (undocumented)
type ValidatorFn<T> = (value: unknown) => T;

// (No @packageDocumentation comment for this package)