@zsherman/canvas 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +373 -0
- package/README.md +15 -2
- package/THIRD_PARTY_NOTICES.md +117 -0
- package/dist/dom/canvas/assets.js +89 -0
- package/dist/dom/canvas/board-store.js +56 -0
- package/dist/dom/canvas/canvas-actions.js +78 -0
- package/dist/dom/canvas/canvas-board.js +557 -0
- package/dist/dom/canvas/canvas-board.styles.js +110 -0
- package/dist/dom/canvas/canvas-chrome.js +1167 -0
- package/dist/dom/canvas/canvas-chrome.styles.js +220 -0
- package/dist/dom/canvas/canvas-comments.js +950 -0
- package/dist/dom/canvas/canvas-comments.styles.js +231 -0
- package/dist/dom/canvas/canvas-context.js +196 -0
- package/dist/dom/canvas/canvas-controller.js +697 -0
- package/dist/dom/canvas/canvas-cursor-chat.js +120 -0
- package/dist/dom/canvas/canvas-cursor-chat.styles.js +55 -0
- package/dist/dom/canvas/canvas-menus.js +276 -0
- package/dist/dom/canvas/canvas-menus.styles.js +7 -0
- package/dist/dom/canvas/canvas-style-bar.js +930 -0
- package/dist/dom/canvas/canvas-style-bar.styles.js +52 -0
- package/dist/dom/canvas/canvas-surface.js +1353 -0
- package/dist/dom/canvas/canvas-surface.styles.js +345 -0
- package/dist/dom/canvas/canvas-tool-rail.js +406 -0
- package/dist/dom/canvas/canvas-tool-rail.styles.js +20 -0
- package/dist/dom/canvas/comments.js +58 -0
- package/dist/dom/canvas/equality.js +13 -0
- package/dist/dom/canvas/export-png.js +496 -0
- package/dist/dom/canvas/gesture-machine.js +91 -0
- package/dist/dom/canvas/handlers.js +18 -0
- package/dist/dom/canvas/index.js +9 -0
- package/dist/dom/canvas/input.js +85 -0
- package/dist/dom/canvas/instant.js +28 -0
- package/dist/dom/canvas/kernel.js +39 -0
- package/dist/dom/canvas/motion.js +686 -0
- package/dist/dom/canvas/palette.js +165 -0
- package/dist/dom/canvas/random-id.js +15 -0
- package/dist/dom/canvas/scene-renderer.js +559 -0
- package/dist/dom/canvas/scene.styles.js +7 -0
- package/dist/dom/canvas/surface-model.js +324 -0
- package/dist/dom/canvas/uploads.js +294 -0
- package/dist/dom/index.js +9 -0
- package/dist/dom/kernel/actions.js +455 -0
- package/dist/dom/kernel/board.js +856 -0
- package/dist/dom/kernel/claims.js +40 -0
- package/dist/dom/kernel/clipboard.js +30 -0
- package/dist/dom/kernel/constants.js +210 -0
- package/dist/dom/kernel/contract.js +0 -0
- package/dist/dom/kernel/decode.js +85 -0
- package/dist/dom/kernel/editor.js +2077 -0
- package/dist/dom/kernel/errors.js +82 -0
- package/dist/dom/kernel/fonts/inter.js +7924 -0
- package/dist/dom/kernel/fractional-index.js +54 -0
- package/dist/dom/kernel/geometry.js +123 -0
- package/dist/dom/kernel/hit-test.js +156 -0
- package/dist/dom/kernel/index.js +22 -0
- package/dist/dom/kernel/inspect.js +116 -0
- package/dist/dom/kernel/kernel.js +251 -0
- package/dist/dom/kernel/outline.js +64 -0
- package/dist/dom/kernel/plan.js +1370 -0
- package/dist/dom/kernel/rev.js +173 -0
- package/dist/dom/kernel/scene.js +580 -0
- package/dist/dom/kernel/schema.js +1109 -0
- package/dist/dom/kernel/snap.js +258 -0
- package/dist/dom/kernel/svg.js +148 -0
- package/dist/dom/kernel/text.js +142 -0
- package/dist/solid/canvas/assets.jsx +89 -0
- package/dist/solid/canvas/board-store.jsx +56 -0
- package/dist/solid/canvas/canvas-actions.jsx +78 -0
- package/dist/solid/canvas/canvas-board.jsx +326 -0
- package/dist/solid/canvas/canvas-board.styles.jsx +110 -0
- package/dist/solid/canvas/canvas-chrome.jsx +612 -0
- package/dist/solid/canvas/canvas-chrome.styles.jsx +220 -0
- package/dist/solid/canvas/canvas-comments.jsx +435 -0
- package/dist/solid/canvas/canvas-comments.styles.jsx +231 -0
- package/dist/solid/canvas/canvas-context.jsx +174 -0
- package/dist/solid/canvas/canvas-controller.jsx +697 -0
- package/dist/solid/canvas/canvas-cursor-chat.jsx +87 -0
- package/dist/solid/canvas/canvas-cursor-chat.styles.jsx +55 -0
- package/dist/solid/canvas/canvas-menus.jsx +223 -0
- package/dist/solid/canvas/canvas-menus.styles.jsx +7 -0
- package/dist/solid/canvas/canvas-style-bar.jsx +486 -0
- package/dist/solid/canvas/canvas-style-bar.styles.jsx +52 -0
- package/dist/solid/canvas/canvas-surface.jsx +681 -0
- package/dist/solid/canvas/canvas-surface.styles.jsx +345 -0
- package/dist/solid/canvas/canvas-tool-rail.jsx +195 -0
- package/dist/solid/canvas/canvas-tool-rail.styles.jsx +20 -0
- package/dist/solid/canvas/comments.jsx +58 -0
- package/dist/solid/canvas/equality.jsx +13 -0
- package/dist/solid/canvas/export-png.jsx +496 -0
- package/dist/solid/canvas/gesture-machine.jsx +91 -0
- package/dist/solid/canvas/handlers.jsx +18 -0
- package/dist/solid/canvas/index.jsx +9 -0
- package/dist/solid/canvas/input.jsx +85 -0
- package/dist/solid/canvas/instant.jsx +28 -0
- package/dist/solid/canvas/kernel.jsx +39 -0
- package/dist/solid/canvas/motion.jsx +686 -0
- package/dist/solid/canvas/palette.jsx +165 -0
- package/dist/solid/canvas/random-id.jsx +15 -0
- package/dist/solid/canvas/scene-renderer.jsx +559 -0
- package/dist/solid/canvas/scene.styles.jsx +7 -0
- package/dist/solid/canvas/surface-model.jsx +324 -0
- package/dist/solid/canvas/uploads.jsx +294 -0
- package/dist/solid/index.jsx +9 -0
- package/dist/solid/kernel/actions.jsx +455 -0
- package/dist/solid/kernel/board.jsx +856 -0
- package/dist/solid/kernel/claims.jsx +40 -0
- package/dist/solid/kernel/clipboard.jsx +30 -0
- package/dist/solid/kernel/constants.jsx +210 -0
- package/dist/solid/kernel/contract.jsx +0 -0
- package/dist/solid/kernel/decode.jsx +85 -0
- package/dist/solid/kernel/editor.jsx +2077 -0
- package/dist/solid/kernel/errors.jsx +82 -0
- package/dist/solid/kernel/fonts/inter.jsx +7924 -0
- package/dist/solid/kernel/fractional-index.jsx +54 -0
- package/dist/solid/kernel/geometry.jsx +123 -0
- package/dist/solid/kernel/hit-test.jsx +156 -0
- package/dist/solid/kernel/index.jsx +22 -0
- package/dist/solid/kernel/inspect.jsx +116 -0
- package/dist/solid/kernel/kernel.jsx +251 -0
- package/dist/solid/kernel/outline.jsx +64 -0
- package/dist/solid/kernel/plan.jsx +1370 -0
- package/dist/solid/kernel/rev.jsx +173 -0
- package/dist/solid/kernel/scene.jsx +580 -0
- package/dist/solid/kernel/schema.jsx +1109 -0
- package/dist/solid/kernel/snap.jsx +258 -0
- package/dist/solid/kernel/svg.jsx +148 -0
- package/dist/solid/kernel/text.jsx +142 -0
- package/dist/styles.css +1 -0
- package/dist/types/canvas/assets.d.ts +111 -0
- package/dist/types/canvas/board-store.d.ts +86 -0
- package/dist/types/canvas/canvas-actions.d.ts +21 -0
- package/dist/types/canvas/canvas-board.d.ts +53 -0
- package/dist/types/canvas/canvas-board.styles.d.ts +94 -0
- package/dist/types/canvas/canvas-chrome.d.ts +109 -0
- package/dist/types/canvas/canvas-chrome.styles.d.ts +193 -0
- package/dist/types/canvas/canvas-comments.d.ts +20 -0
- package/dist/types/canvas/canvas-comments.styles.d.ts +208 -0
- package/dist/types/canvas/canvas-context.d.ts +104 -0
- package/dist/types/canvas/canvas-controller.d.ts +159 -0
- package/dist/types/canvas/canvas-cursor-chat.d.ts +13 -0
- package/dist/types/canvas/canvas-cursor-chat.styles.d.ts +54 -0
- package/dist/types/canvas/canvas-menus.d.ts +21 -0
- package/dist/types/canvas/canvas-menus.styles.d.ts +6 -0
- package/dist/types/canvas/canvas-style-bar.d.ts +19 -0
- package/dist/types/canvas/canvas-style-bar.styles.d.ts +43 -0
- package/dist/types/canvas/canvas-surface.d.ts +15 -0
- package/dist/types/canvas/canvas-surface.styles.d.ts +313 -0
- package/dist/types/canvas/canvas-tool-rail.d.ts +41 -0
- package/dist/types/canvas/canvas-tool-rail.styles.d.ts +15 -0
- package/dist/types/canvas/comments.d.ts +106 -0
- package/dist/types/canvas/equality.d.ts +4 -0
- package/dist/types/canvas/export-png.d.ts +77 -0
- package/dist/types/canvas/gesture-machine.d.ts +46 -0
- package/dist/types/canvas/handlers.d.ts +7 -0
- package/dist/types/canvas/index.d.ts +18 -0
- package/dist/types/canvas/input.d.ts +63 -0
- package/dist/types/canvas/instant.d.ts +13 -0
- package/dist/types/canvas/kernel.d.ts +27 -0
- package/dist/types/canvas/motion.d.ts +72 -0
- package/dist/types/canvas/palette.d.ts +46 -0
- package/dist/types/canvas/random-id.d.ts +6 -0
- package/dist/types/canvas/scene-renderer.d.ts +27 -0
- package/dist/types/canvas/scene.styles.d.ts +4 -0
- package/dist/types/canvas/surface-model.d.ts +113 -0
- package/dist/types/canvas/uploads.d.ts +58 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/kernel/actions.d.ts +19 -0
- package/dist/types/kernel/board.d.ts +137 -0
- package/dist/types/kernel/claims.d.ts +29 -0
- package/dist/types/kernel/clipboard.d.ts +10 -0
- package/dist/types/kernel/constants.d.ts +195 -0
- package/dist/types/kernel/contract.d.ts +1533 -0
- package/dist/types/kernel/decode.d.ts +60 -0
- package/dist/types/kernel/editor.d.ts +12 -0
- package/dist/types/kernel/errors.d.ts +11 -0
- package/dist/types/kernel/fractional-index.d.ts +7 -0
- package/dist/types/kernel/geometry.d.ts +42 -0
- package/dist/types/kernel/hit-test.d.ts +16 -0
- package/dist/types/kernel/index.d.ts +8 -0
- package/dist/types/kernel/inspect.d.ts +6 -0
- package/dist/types/kernel/kernel.d.ts +6 -0
- package/dist/types/kernel/outline.d.ts +4 -0
- package/dist/types/kernel/plan.d.ts +20 -0
- package/dist/types/kernel/rev.d.ts +21 -0
- package/dist/types/kernel/scene.d.ts +16 -0
- package/dist/types/kernel/schema.d.ts +3436 -0
- package/dist/types/kernel/snap.d.ts +41 -0
- package/dist/types/kernel/svg.d.ts +3 -0
- package/dist/types/kernel/text.d.ts +21 -0
- package/docs/api.json +207 -0
- package/docs/canvas.md +444 -0
- package/docs/kernel.md +108 -0
- package/docs/llms.txt +41 -0
- package/docs/search-index.json +52 -0
- package/package.json +55 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural checks for values arriving from outside the kernel. A guard
|
|
3
|
+
* accepts exactly the JSON shape of its type: plain objects with no unknown
|
|
4
|
+
* keys, arrays, finite numbers, well-formed strings, booleans and `null`.
|
|
5
|
+
* Anything else (undefined, NaN, class instances, Maps, Dates, lone
|
|
6
|
+
* surrogates) fails with the path to the bad value and what it accepts.
|
|
7
|
+
*/
|
|
8
|
+
import type { PathJson } from "./contract.js";
|
|
9
|
+
export interface Issue {
|
|
10
|
+
readonly path: PathJson;
|
|
11
|
+
readonly expected: string;
|
|
12
|
+
}
|
|
13
|
+
/** Collects the first issue a guard finds. */
|
|
14
|
+
interface Checker {
|
|
15
|
+
issue: Issue | null;
|
|
16
|
+
}
|
|
17
|
+
export type Guard<T> = (value: unknown, checker: Checker, path: PathJson) => value is T;
|
|
18
|
+
export type Guarded<G> = G extends Guard<infer T> ? T : never;
|
|
19
|
+
type Simplify<T> = {
|
|
20
|
+
[K in keyof T]: T[K];
|
|
21
|
+
} & {};
|
|
22
|
+
export declare const LONE_SURROGATE: RegExp;
|
|
23
|
+
/** A well-formed string of at most `max` UTF-16 code units. */
|
|
24
|
+
export declare const string: (max: number, expected?: string) => Guard<string>;
|
|
25
|
+
export declare const pattern: (regex: RegExp, expected: string) => Guard<string>;
|
|
26
|
+
/** Shape, transaction and actor ids. */
|
|
27
|
+
export declare const id: Guard<string>;
|
|
28
|
+
export declare const boolean: Guard<boolean>;
|
|
29
|
+
/** A finite number within `[min, max]`. */
|
|
30
|
+
export declare const number: (min: number, max: number, expected?: string) => Guard<number>;
|
|
31
|
+
export declare const integer: (min: number, max: number) => Guard<number>;
|
|
32
|
+
export declare const literal: <const L extends ReadonlyArray<string | number | boolean>>(...values: L) => Guard<L[number]>;
|
|
33
|
+
export declare const nullable: <T>(guard: Guard<T>) => Guard<T | null>;
|
|
34
|
+
export declare const array: <T>(guard: Guard<T>, max: number) => Guard<ReadonlyArray<T>>;
|
|
35
|
+
/** A plain object of at most `max` entries whose keys and values pass the guards. */
|
|
36
|
+
export declare const dictionary: <T>(key: Guard<string>, guard: Guard<T>, max: number) => Guard<Readonly<Record<string, T>>>;
|
|
37
|
+
type Fields = {
|
|
38
|
+
readonly [key: string]: Guard<unknown>;
|
|
39
|
+
};
|
|
40
|
+
export type Struct<R extends Fields, O extends Fields> = Simplify<{
|
|
41
|
+
readonly [K in keyof R]: Guarded<R[K]>;
|
|
42
|
+
} & {
|
|
43
|
+
readonly [K in keyof O]?: Guarded<O[K]>;
|
|
44
|
+
}>;
|
|
45
|
+
/** A plain object with exactly the `required` keys and any of the `optional` keys. */
|
|
46
|
+
export declare const struct: <R extends Fields, O extends Fields = {}>(required: R, optional?: O) => Guard<Struct<R, O>>;
|
|
47
|
+
type Members = {
|
|
48
|
+
readonly [tag: string]: Guard<unknown>;
|
|
49
|
+
};
|
|
50
|
+
/** A union whose members are told apart by the string at `key`. */
|
|
51
|
+
export declare const tagged: <M extends Members>(key: string, members: M) => Guard<Guarded<M[keyof M]>>;
|
|
52
|
+
/** Runs a guard: the value, typed, or the first issue it found. */
|
|
53
|
+
export declare const run: <T>(guard: Guard<T>, value: unknown, path: PathJson) => {
|
|
54
|
+
readonly ok: T;
|
|
55
|
+
} | {
|
|
56
|
+
readonly issue: Issue;
|
|
57
|
+
};
|
|
58
|
+
/** Compile-time proof that a guard accepts exactly a contract type. */
|
|
59
|
+
export type Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type BoardIndex } from "./board.js";
|
|
2
|
+
import type { BoardJson, EditorInputJson, EditorStateJson, EditorStepJson, PresenceJson, Outcome, ViewportJson } from "./contract.js";
|
|
3
|
+
import type { Fonts } from "./text.js";
|
|
4
|
+
export declare const initialState: (session: string, view: ViewportJson) => EditorStateJson;
|
|
5
|
+
/**
|
|
6
|
+
* Shapes another connection holds (see `claims.ts`), each with the sentence
|
|
7
|
+
* that says so. This editor's claims are its mode's, so when it and another
|
|
8
|
+
* connection both claim a shape (each started before seeing the other),
|
|
9
|
+
* exactly one side stops.
|
|
10
|
+
*/
|
|
11
|
+
export declare const heldBy: (state: EditorStateJson, presence: ReadonlyArray<PresenceJson>) => ReadonlyMap<string, string>;
|
|
12
|
+
export declare const step: (fonts: Fonts, state: EditorStateJson, board: BoardJson, index: BoardIndex, input: EditorInputJson, presence: ReadonlyArray<PresenceJson>) => Outcome<EditorStepJson>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Error values. Each message names the fix. */
|
|
2
|
+
import type { CommandErrorJson, PathJson } from "./contract.js";
|
|
3
|
+
export declare const invalid: (path: PathJson, expected: string, fix: string) => CommandErrorJson;
|
|
4
|
+
export declare const shapeNotFound: (path: PathJson, id: string, candidates: Iterable<string>) => CommandErrorJson;
|
|
5
|
+
export declare const transactionNotFound: (path: PathJson, id: string, candidates: Iterable<string>) => CommandErrorJson;
|
|
6
|
+
/** `id` is not among the board's records, and records before `oldest` were dropped. */
|
|
7
|
+
export declare const historyExpired: (path: PathJson, id: string, oldest: number) => CommandErrorJson;
|
|
8
|
+
/** `actor` is the planner: its own name in `by` means another of its connections. */
|
|
9
|
+
export declare const claimed: (path: PathJson, id: string, by: ReadonlyArray<string>, actor: string) => CommandErrorJson;
|
|
10
|
+
export declare const tooLarge: (path: PathJson, what: string, limit: number, size: number, fix?: string) => CommandErrorJson;
|
|
11
|
+
export declare const locked: (path: PathJson, id: string) => CommandErrorJson;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const isKey: (key: string) => boolean;
|
|
2
|
+
/** A key after `a`, or "V" when `a` is null. */
|
|
3
|
+
export declare const keyAfter: (a: string | null) => string;
|
|
4
|
+
/** A key before `b`, or "V" when `b` is null. */
|
|
5
|
+
export declare const keyBefore: (b: string | null) => string;
|
|
6
|
+
/** A key strictly between `a` and `b`; null stands for the start or the end. Requires `a < b`. */
|
|
7
|
+
export declare const keyBetween: (a: string | null, b: string | null) => string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plane geometry. Only `+ - * /` and `Math.sqrt` are used, which IEEE 754
|
|
3
|
+
* rounds the same on every host, so results match bit for bit across kernels.
|
|
4
|
+
*/
|
|
5
|
+
import type { BoxJson, PointJson } from "./contract.js";
|
|
6
|
+
/**
|
|
7
|
+
* Rounds to hundredths, halves toward +∞ (`Math.round`). Every coordinate the
|
|
8
|
+
* kernel stores or draws passes through this.
|
|
9
|
+
*/
|
|
10
|
+
export declare const round: (value: number) => number;
|
|
11
|
+
/**
|
|
12
|
+
* Rounds up to hundredths, so a stored size never falls short of what it must
|
|
13
|
+
* hold: an auto-width text rounded down would be narrower than its own line
|
|
14
|
+
* and wrap.
|
|
15
|
+
*/
|
|
16
|
+
export declare const roundUp: (value: number) => number;
|
|
17
|
+
/** Formats a number for text output: rounded, no exponent, no trailing zeros. */
|
|
18
|
+
export declare const formatNumber: (value: number) => string;
|
|
19
|
+
/**
|
|
20
|
+
* An instant (integer epoch milliseconds, 0 to 8.64e15) as ISO 8601 in UTC,
|
|
21
|
+
* such as `2026-11-20T15:04:00.000Z`; years past 9999 take the `+275760`
|
|
22
|
+
* form. Never a local time zone.
|
|
23
|
+
*/
|
|
24
|
+
export declare const isoInstant: (epochMs: number) => string;
|
|
25
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
26
|
+
export declare const center: (b: BoxJson) => PointJson;
|
|
27
|
+
/** The box spanned by two corners. */
|
|
28
|
+
export declare const boxFromPoints: (a: PointJson, b: PointJson) => BoxJson;
|
|
29
|
+
export declare const roundBox: (b: BoxJson) => BoxJson;
|
|
30
|
+
export declare const roundPoint: (p: PointJson) => PointJson;
|
|
31
|
+
export declare const inflate: (b: BoxJson, by: number) => BoxJson;
|
|
32
|
+
export declare const union: (boxes: ReadonlyArray<BoxJson>) => BoxJson | null;
|
|
33
|
+
/** Whether two boxes share area or touch. */
|
|
34
|
+
export declare const intersects: (a: BoxJson, b: BoxJson) => boolean;
|
|
35
|
+
/** Whether two boxes share area; touching edges do not overlap. */
|
|
36
|
+
export declare const overlaps: (a: BoxJson, b: BoxJson) => boolean;
|
|
37
|
+
export declare const distanceToSegment: (p: PointJson, a: PointJson, b: PointJson) => number;
|
|
38
|
+
export declare const distance: (a: PointJson, b: PointJson) => number;
|
|
39
|
+
/** Where a ray from the center of `b` toward `toward` leaves the rectangle `b`. */
|
|
40
|
+
export declare const rectExit: (b: BoxJson, toward: PointJson) => PointJson;
|
|
41
|
+
/** Where a ray from the center of `b` toward `toward` leaves the ellipse inscribed in `b`. */
|
|
42
|
+
export declare const ellipseExit: (b: BoxJson, toward: PointJson) => PointJson;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BoxJson, HitJson, HitProbeJson, PointJson, PointerKindJson, ResizeHandleJson, ShapeJson } from "./contract.js";
|
|
2
|
+
import { type BoardIndex, type Shapes } from "./board.js";
|
|
3
|
+
export declare const RESIZE_HANDLES: readonly ["nw", "n", "ne", "e", "se", "s", "sw", "w"];
|
|
4
|
+
/** Where a resize handle sits on a box. */
|
|
5
|
+
export declare const handlePoint: (b: BoxJson, handle: ResizeHandleJson) => PointJson;
|
|
6
|
+
/** The shapes a selection's handles act on: unlocked, existing, not only connectors. */
|
|
7
|
+
export declare const resizable: (shapes: Shapes, selection: ReadonlyArray<string>) => ReadonlyArray<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Whether segment a→b (a point when `b` is left out) hits `shape`, exactly:
|
|
10
|
+
* no sampling, so one long eraser move costs one test per shape.
|
|
11
|
+
* `tolerance` is in board units.
|
|
12
|
+
*/
|
|
13
|
+
export declare const hitsShape: (shapes: Shapes, shape: ShapeJson, a: PointJson, tolerance: number, selected: boolean, b?: PointJson) => boolean;
|
|
14
|
+
export declare const hitTestIndex: (index: BoardIndex, probe: HitProbeJson) => HitJson;
|
|
15
|
+
/** Shapes whose geometry passes within `reach` of the segment a→b (the eraser). */
|
|
16
|
+
export declare const touchedBySegment: (index: BoardIndex, a: PointJson, b: PointJson, reach: number, pointer: PointerKindJson, zoom: number) => ReadonlyArray<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BoardHistoryJson, BoardJson } from "./contract.js";
|
|
2
|
+
export type * from "./contract.js";
|
|
3
|
+
export { decodeClipboard } from "./clipboard.js";
|
|
4
|
+
export { loadKernel } from "./kernel.js";
|
|
5
|
+
/** A board with no shapes and no history: where every new board starts. */
|
|
6
|
+
export declare const EMPTY_BOARD: BoardJson;
|
|
7
|
+
/** The bound on every board's history, which `apply` keeps. */
|
|
8
|
+
export declare const BOARD_HISTORY: BoardHistoryJson;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Read-only views of a board for UI chrome: style inspection, descriptions, proposals. */
|
|
2
|
+
import type { BoardJson, InspectionJson, ProposalJson, ShapeJson } from "./contract.js";
|
|
3
|
+
import { type BoardIndex } from "./board.js";
|
|
4
|
+
export declare const inspectShapes: (index: BoardIndex, ids: ReadonlyArray<string>) => InspectionJson;
|
|
5
|
+
export declare const describeShape: (index: BoardIndex, shape: ShapeJson) => string;
|
|
6
|
+
export declare const listProposals: (board: BoardJson, index: BoardIndex) => ReadonlyArray<ProposalJson>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FontDataJson, Kernel, Outcome } from "./contract.js";
|
|
2
|
+
/**
|
|
3
|
+
* Loads a kernel with the font advance tables text is measured with. The
|
|
4
|
+
* one asynchronous call, so a WebAssembly kernel can load the same way.
|
|
5
|
+
*/
|
|
6
|
+
export declare const loadKernel: (fontData: FontDataJson) => Promise<Outcome<Kernel>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A plain-text description of a board for agents: shapes back to front, proposals and people. */
|
|
2
|
+
import type { BoardJson, PresenceJson } from "./contract.js";
|
|
3
|
+
import { type BoardIndex } from "./board.js";
|
|
4
|
+
export declare const outlineBoard: (board: BoardJson, index: BoardIndex, presence: ReadonlyArray<PresenceJson>) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BoardJson, BoxJson, Outcome, PlanJson, PresenceJson, ShapeJson, TransactionJson, TransactionRecordJson } from "./contract.js";
|
|
2
|
+
import type { Fonts } from "./text.js";
|
|
3
|
+
/** The shape moved by (dx, dy). A connector moves its free ends; bound ends follow their shapes. */
|
|
4
|
+
export declare const translate: (shape: ShapeJson, dx: number, dy: number) => ShapeJson;
|
|
5
|
+
/** The shape scaled from box `from` to box `to`. */
|
|
6
|
+
export declare const scale: (fonts: Fonts, shape: ShapeJson, from: BoxJson, to: BoxJson) => ShapeJson;
|
|
7
|
+
/**
|
|
8
|
+
* `source` copied by (dx, dy), its connector ends bound to the copies in
|
|
9
|
+
* `ids` (original id → copy id); an end bound to a shape not copied stays
|
|
10
|
+
* bound only when the copy does not move, and is a free point otherwise.
|
|
11
|
+
*/
|
|
12
|
+
export declare const copyShape: (shapes: ReadonlyMap<string, ShapeJson>, source: ShapeJson, ids: ReadonlyMap<string, string>, dx: number, dy: number) => ShapeJson;
|
|
13
|
+
/**
|
|
14
|
+
* Shapes a revert of `record` leaves as they are, as a fresh edit would:
|
|
15
|
+
* those `held` (claimed by another connection) and those locked, unless the
|
|
16
|
+
* revert only locks or unlocks them.
|
|
17
|
+
*/
|
|
18
|
+
export declare const revertSkips: (shapes: ReadonlyMap<string, ShapeJson>, record: TransactionRecordJson, held: (id: string) => boolean) => ReadonlySet<string>;
|
|
19
|
+
export declare const planTransaction: (fonts: Fonts, board: BoardJson, transaction: TransactionJson, actor: string, presence: ReadonlyArray<PresenceJson>, connection: string | null) => Outcome<PlanJson>;
|
|
20
|
+
export declare const applyPlan: (board: BoardJson, plan: PlanJson) => Outcome<BoardJson>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene item revs: a 53-bit hash (cyrb53's two 32-bit lanes) of everything
|
|
3
|
+
* an item is drawn from, so equal revs mean equal items. A shape's items
|
|
4
|
+
* hash their sources (the fields of the shape that drawing reads, the shapes
|
|
5
|
+
* its connector ends follow, its ghost) rather than their own path data and
|
|
6
|
+
* text lines, which those sources determine and which cost more to hash;
|
|
7
|
+
* every other item hashes itself. Nothing is remembered between calls.
|
|
8
|
+
*/
|
|
9
|
+
import type { ShapeJson } from "./contract.js";
|
|
10
|
+
/** The two lanes, in a typed array so mixing allocates nothing. */
|
|
11
|
+
type Hash = Int32Array;
|
|
12
|
+
/** The hash a shape's items share: its ghost, the shape and its ends' shapes. */
|
|
13
|
+
export declare const shapeHash: (ghost: unknown, drawn: ShapeJson, from: ShapeJson | null, to: ShapeJson | null) => Hash;
|
|
14
|
+
/**
|
|
15
|
+
* The rev of an item: `h` with `tag` mixed in, as 53 bits in eleven base-32
|
|
16
|
+
* digits, least significant first.
|
|
17
|
+
*/
|
|
18
|
+
export declare const finish: (h: Hash, tag: string) => string;
|
|
19
|
+
/** The rev of an item drawn from nothing but its own fields. */
|
|
20
|
+
export declare const revOf: (item: object) => string;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ActivityJson, BoardJson, DraftKindJson, EditorStateJson, PresenceJson, SceneJson, ShapeJson, ViewportJson } from "./contract.js";
|
|
2
|
+
import { type BoardIndex, type Shapes } from "./board.js";
|
|
3
|
+
import type { Fonts } from "./text.js";
|
|
4
|
+
export declare const draftKind: (draft: DraftKindJson) => ShapeJson["kind"];
|
|
5
|
+
/** The id of the next transaction the editor sends. */
|
|
6
|
+
export declare const nextTransaction: (state: EditorStateJson) => string;
|
|
7
|
+
/** The id the transaction `transaction` gives the `n`th shape it creates. */
|
|
8
|
+
export declare const createdId: (transaction: string, kind: ShapeJson["kind"], n?: number) => string;
|
|
9
|
+
/** The id the editor gives the `n`th shape its next transaction creates. */
|
|
10
|
+
export declare const newId: (state: EditorStateJson, kind: ShapeJson["kind"], n?: number) => string;
|
|
11
|
+
/**
|
|
12
|
+
* The activity the viewer's editor mode shows to others, which the scene
|
|
13
|
+
* also previews locally: targets, not offsets (see `ActivityJson`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const activityOf: (state: EditorStateJson, shapes: Shapes) => ActivityJson;
|
|
16
|
+
export declare const buildScene: (fonts: Fonts, board: BoardJson, index: BoardIndex, view: ViewportJson, presence: ReadonlyArray<PresenceJson>, editor: EditorStateJson | null) => SceneJson;
|