alpha2 0.3.0 → 0.4.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.
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Layout generators for authors: boxes laid out by CSS flexbox or grid around their text and
3
+ * shapes, as a project's `{ "type": "layout" }` generator holds them.
4
+ *
5
+ * {@link measureLayout} answers, in wasm and with the fonts the engine draws with, where every box
6
+ * of a layout lies on a picture and whether anything overflows, before anything is rendered. The
7
+ * builder ({@link box}, {@link text}, {@link shape}, {@link layout}) writes the document from
8
+ * CSS-like props: a value that is not animated becomes a constant, a `[top, right, bottom, left]`
9
+ * tuple the sides object, an `[x, y]` tuple a vector. Lengths are written as the document writes
10
+ * them: a number is a fraction of the picture's shorter side, `"12px"` pixels of the project
11
+ * canvas, `"50%"` a percent of the parent's content box. Text style (`font_family`, `font_size`,
12
+ * `color`, `line_height`, `text_align`, `outline`) may be set on any box and is inherited. Its
13
+ * output is a plain document that `validateProject` accepts; a CSS value string it cannot read
14
+ * throws, with the parser's message.
15
+ */
16
+ import type { PictureSize } from "./geometry.js";
17
+ import type { AlignContent, AlignItems, Animated, Display, FlexDirection, FlexWrap, Generator, GridAutoFlow, JustifyContent, LayoutNode, Overflow, Paint, Position, Rgba, ShapeItem, TextAlign, TextOutline, Ticks, Vec2 } from "./project.js";
18
+ /** The part of `alpha2/wasm`'s `WasmTextMeasurer` {@link measureLayout} uses. */
19
+ export interface LayoutBinding {
20
+ measureLayout(generatorJson: string, width: number, height: number, time: number, canvasWidth?: number, canvasHeight?: number): string;
21
+ }
22
+ /** A rectangle as fractions of the picture, `(0, 0)` top-left to `(1, 1)` bottom-right. */
23
+ export interface LayoutRect {
24
+ readonly left: number;
25
+ readonly top: number;
26
+ readonly right: number;
27
+ readonly bottom: number;
28
+ }
29
+ /** Where one node lies: its layout boxes, before its clip's transform and node visuals. */
30
+ export interface NodeBounds {
31
+ /** Its path from the root, like `root.children[1]`. */
32
+ readonly at: string;
33
+ /** The border box. */
34
+ readonly border: LayoutRect;
35
+ /** The content box. */
36
+ readonly content: LayoutRect;
37
+ /**
38
+ * Whether it overflows: its text is taller than its content box or splits a word, or an
39
+ * in-flow child reaches past its padding box. Rendering draws it anyway.
40
+ */
41
+ readonly overflow: boolean;
42
+ /** A text node's line count; `null` for other nodes. */
43
+ readonly lineCount: number | null;
44
+ }
45
+ /** Where every node of a layout lies, the root first, in document order. */
46
+ export interface LayoutBounds {
47
+ readonly nodes: readonly NodeBounds[];
48
+ }
49
+ /**
50
+ * Where every node of `generator` (a layout generator, or its root) lies on `picture` at picture
51
+ * time `time`, laid out with `binding`'s fonts as a frame lays it out. Measure at the size the
52
+ * picture is drawn at: at another size, lines can break elsewhere. The layout's `"<n>px"` lengths
53
+ * are pixels of `canvas`, the project canvas: `picture` itself by default, so a preview measured
54
+ * at half size passes the project's own size here.
55
+ *
56
+ * @throws An `INVALID_INPUT` error for a layout the model rejects (on that canvas), a picture or
57
+ * canvas outside 1 to 16384 pixels a side, or a time that is not whole ticks; a text error for a
58
+ * measurer without fonts when the layout has text.
59
+ */
60
+ export declare function measureLayout(binding: LayoutBinding, generator: Generator | LayoutNode, picture: PictureSize, time?: Ticks, canvas?: PictureSize): LayoutBounds;
61
+ /** A value, or the document's animated form of it. */
62
+ export type Value<T> = T | Animated<T>;
63
+ /** A length that may not be a percent: a fraction of the picture's shorter side, or `"12px"`. */
64
+ export type Size = number | `${number}px`;
65
+ /** A size or inset: a {@link Size}, or `"50%"` of the parent's content box. */
66
+ export type Length = Size | `${number}%`;
67
+ /**
68
+ * The sides of a box: one size for all, the CSS shorthand (`"8px 16px"`), a
69
+ * `[top, right, bottom, left]` tuple, or the sides object (missing sides 0).
70
+ */
71
+ export type Sides = number | string | readonly [Size, Size, Size, Size] | {
72
+ readonly top?: Size;
73
+ readonly right?: Size;
74
+ readonly bottom?: Size;
75
+ readonly left?: Size;
76
+ };
77
+ /** A color: the components object, or CSS hex (`"#1e2230"`) as `Rgba` allows. */
78
+ export type Color = Rgba;
79
+ /** A paint, or a color painted solid. */
80
+ export type Fill = Paint | Color;
81
+ /** An offset: the CSS `translate` string (`"10px 20px"`), an `[x, y]` tuple, or `{ x, y }`. */
82
+ export type Offset = string | readonly [Size, Size] | {
83
+ readonly x: Size;
84
+ readonly y: Size;
85
+ };
86
+ /** The style a box gives its text and the boxes in it, inherited as CSS inherits it. */
87
+ export interface TextStyleProps {
88
+ readonly font_family?: string;
89
+ readonly font_size?: Value<Size>;
90
+ readonly color?: Color;
91
+ readonly line_height?: number;
92
+ readonly text_align?: TextAlign;
93
+ readonly outline?: TextOutline;
94
+ }
95
+ /** A box's CSS fields, with shorthands. */
96
+ export interface BoxProps extends TextStyleProps {
97
+ readonly display?: Display;
98
+ readonly flex_direction?: FlexDirection;
99
+ readonly flex_wrap?: FlexWrap;
100
+ /** A grid's columns, as CSS writes them: `"1fr 2fr"`, `"repeat(3, minmax(100px, 1fr))"`. */
101
+ readonly grid_template_columns?: string;
102
+ readonly grid_template_rows?: string;
103
+ readonly grid_auto_columns?: string;
104
+ readonly grid_auto_rows?: string;
105
+ readonly grid_auto_flow?: GridAutoFlow;
106
+ readonly gap?: Value<Size>;
107
+ readonly row_gap?: Value<Size>;
108
+ readonly column_gap?: Value<Size>;
109
+ readonly justify_content?: JustifyContent;
110
+ readonly align_items?: AlignItems;
111
+ readonly align_content?: AlignContent;
112
+ readonly justify_items?: AlignItems;
113
+ readonly padding?: Value<Sides>;
114
+ readonly background?: Value<Fill>;
115
+ readonly border?: {
116
+ readonly width: Value<Size>;
117
+ readonly paint: Value<Fill>;
118
+ };
119
+ readonly border_radius?: Value<Size>;
120
+ readonly overflow?: Overflow;
121
+ readonly width?: Value<Length>;
122
+ readonly height?: Value<Length>;
123
+ readonly min_width?: Value<Length>;
124
+ readonly min_height?: Value<Length>;
125
+ readonly max_width?: Value<Length>;
126
+ readonly max_height?: Value<Length>;
127
+ readonly aspect_ratio?: number;
128
+ readonly margin?: Value<Sides>;
129
+ readonly flex_grow?: Value<number>;
130
+ readonly flex_shrink?: Value<number>;
131
+ readonly flex_basis?: Value<Length>;
132
+ readonly align_self?: AlignItems;
133
+ readonly justify_self?: AlignItems;
134
+ /** The box's grid columns, as CSS writes them: `2`, `"1 / 3"`, `"span 2"`. */
135
+ readonly grid_column?: number | string;
136
+ readonly grid_row?: number | string;
137
+ readonly position?: Position;
138
+ readonly inset?: {
139
+ readonly left?: Value<Length>;
140
+ readonly top?: Value<Length>;
141
+ readonly right?: Value<Length>;
142
+ readonly bottom?: Value<Length>;
143
+ };
144
+ readonly opacity?: Value<number>;
145
+ readonly translate?: Value<Offset>;
146
+ /** One number scales both axes. */
147
+ readonly scale?: Value<Vec2> | number | readonly [number, number];
148
+ readonly rotation_degrees?: Value<number>;
149
+ }
150
+ /** A layout generator whose root is `root`: the whole picture. */
151
+ export declare function layout(root: LayoutNode): Generator;
152
+ /** A box: a container holding `children`, or empty without them. */
153
+ export declare function box(props?: BoxProps, ...children: LayoutNode[]): LayoutNode;
154
+ /**
155
+ * A box holding one paragraph of text, wrapped at its content width and drawn in the style it
156
+ * sets or inherits.
157
+ */
158
+ export declare function text(content: Value<string>, props?: Omit<BoxProps, ContainerField>): LayoutNode;
159
+ /**
160
+ * A box holding shapes, drawn on a picture the size of its content box: positions normalized to
161
+ * it, lengths fractions of its shorter side. It has no size of its own: give it `width` and
162
+ * `height`, an `aspect_ratio`, or `flex_grow`.
163
+ */
164
+ export declare function shape(items: readonly ShapeItem[], props?: Omit<BoxProps, ContainerField>): LayoutNode;
165
+ /** The container fields a text or shape node may not take. */
166
+ type ContainerField = "display" | "flex_direction" | "flex_wrap" | "grid_template_columns" | "grid_template_rows" | "grid_auto_columns" | "grid_auto_rows" | "grid_auto_flow" | "gap" | "row_gap" | "column_gap" | "justify_content" | "align_items" | "align_content" | "justify_items";
167
+ export {};
package/dist/layout.js ADDED
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Layout generators for authors: boxes laid out by CSS flexbox or grid around their text and
3
+ * shapes, as a project's `{ "type": "layout" }` generator holds them.
4
+ *
5
+ * {@link measureLayout} answers, in wasm and with the fonts the engine draws with, where every box
6
+ * of a layout lies on a picture and whether anything overflows, before anything is rendered. The
7
+ * builder ({@link box}, {@link text}, {@link shape}, {@link layout}) writes the document from
8
+ * CSS-like props: a value that is not animated becomes a constant, a `[top, right, bottom, left]`
9
+ * tuple the sides object, an `[x, y]` tuple a vector. Lengths are written as the document writes
10
+ * them: a number is a fraction of the picture's shorter side, `"12px"` pixels of the project
11
+ * canvas, `"50%"` a percent of the parent's content box. Text style (`font_family`, `font_size`,
12
+ * `color`, `line_height`, `text_align`, `outline`) may be set on any box and is inherited. Its
13
+ * output is a plain document that `validateProject` accepts; a CSS value string it cannot read
14
+ * throws, with the parser's message.
15
+ */
16
+ import { parseHex, parseInsets, parseLength, parseOffset, parsePlacement, parseSize, parseTrackList, } from "./layout-values.js";
17
+ /**
18
+ * Where every node of `generator` (a layout generator, or its root) lies on `picture` at picture
19
+ * time `time`, laid out with `binding`'s fonts as a frame lays it out. Measure at the size the
20
+ * picture is drawn at: at another size, lines can break elsewhere. The layout's `"<n>px"` lengths
21
+ * are pixels of `canvas`, the project canvas: `picture` itself by default, so a preview measured
22
+ * at half size passes the project's own size here.
23
+ *
24
+ * @throws An `INVALID_INPUT` error for a layout the model rejects (on that canvas), a picture or
25
+ * canvas outside 1 to 16384 pixels a side, or a time that is not whole ticks; a text error for a
26
+ * measurer without fonts when the layout has text.
27
+ */
28
+ export function measureLayout(binding, generator, picture, time = 0, canvas = picture) {
29
+ const document = "type" in generator && generator.type === "layout"
30
+ ? generator
31
+ : layout(generator);
32
+ return JSON.parse(binding.measureLayout(JSON.stringify(document), picture.width, picture.height, time, canvas.width, canvas.height));
33
+ }
34
+ /** A layout generator whose root is `root`: the whole picture. */
35
+ export function layout(root) {
36
+ return { type: "layout", root };
37
+ }
38
+ /** A box: a container holding `children`, or empty without them. */
39
+ export function box(props = {}, ...children) {
40
+ return children.length > 0
41
+ ? { ...boxFields(props), children }
42
+ : boxFields(props);
43
+ }
44
+ /**
45
+ * A box holding one paragraph of text, wrapped at its content width and drawn in the style it
46
+ * sets or inherits.
47
+ */
48
+ export function text(content, props = {}) {
49
+ return { ...boxFields(props), text: animated(content) };
50
+ }
51
+ /**
52
+ * A box holding shapes, drawn on a picture the size of its content box: positions normalized to
53
+ * it, lengths fractions of its shorter side. It has no size of its own: give it `width` and
54
+ * `height`, an `aspect_ratio`, or `flex_grow`.
55
+ */
56
+ export function shape(items, props = {}) {
57
+ return { ...boxFields(props), shape: { items } };
58
+ }
59
+ function isAnimated(value) {
60
+ return (typeof value === "object" &&
61
+ value !== null &&
62
+ "mode" in value &&
63
+ (value.mode === "constant" || value.mode === "keyframes"));
64
+ }
65
+ function animated(value) {
66
+ return isAnimated(value) ? value : { mode: "constant", value };
67
+ }
68
+ /** `value` when `parse` reads it; otherwise the parser's message, thrown. */
69
+ function checked(value, parsed) {
70
+ if (!parsed.ok)
71
+ throw new TypeError(parsed.error);
72
+ return value;
73
+ }
74
+ /** A length's or size's string checked as the engine reads it; numbers as they are. */
75
+ function lengthValue(value, percent) {
76
+ if (typeof value !== "string")
77
+ return value;
78
+ return checked(value, percent ? parseLength(value) : parseSize(value));
79
+ }
80
+ function sidesValue(value) {
81
+ if (typeof value === "number")
82
+ return value;
83
+ if (typeof value === "string")
84
+ return checked(value, parseInsets(value));
85
+ if (Array.isArray(value)) {
86
+ const [top, right, bottom, left] = value.map((side) => lengthValue(side, false));
87
+ return { top, right, bottom, left };
88
+ }
89
+ return Object.fromEntries(Object.entries(value).map(([side, size]) => [
90
+ side,
91
+ lengthValue(size, false),
92
+ ]));
93
+ }
94
+ function fillValue(value) {
95
+ return typeof value === "string" ? checked(value, parseHex(value)) : value;
96
+ }
97
+ function offsetValue(value) {
98
+ if (typeof value === "string")
99
+ return checked(value, parseOffset(value));
100
+ if (Array.isArray(value)) {
101
+ const [x, y] = value;
102
+ return { x: lengthValue(x, false), y: lengthValue(y, false) };
103
+ }
104
+ const { x, y } = value;
105
+ return { x: lengthValue(x, false), y: lengthValue(y, false) };
106
+ }
107
+ /** `value` as an animated field, each of its values mapped by `map` when it is not animated. */
108
+ function field(value, map) {
109
+ return isAnimated(value) ? value : { mode: "constant", value: map(value) };
110
+ }
111
+ function scaleField(value) {
112
+ if (typeof value === "number") {
113
+ return { mode: "constant", value: { x: value, y: value } };
114
+ }
115
+ if (Array.isArray(value)) {
116
+ const [x, y] = value;
117
+ return { mode: "constant", value: { x, y } };
118
+ }
119
+ return animated(value);
120
+ }
121
+ /** `props` as the document's fields, each shorthand written out; absent fields stay absent. */
122
+ function boxFields(props) {
123
+ const fields = {};
124
+ for (const [name, value] of Object.entries(props)) {
125
+ if (value === undefined)
126
+ continue;
127
+ switch (name) {
128
+ case "flex_grow":
129
+ case "flex_shrink":
130
+ case "opacity":
131
+ case "rotation_degrees":
132
+ fields[name] = animated(value);
133
+ break;
134
+ case "gap":
135
+ case "row_gap":
136
+ case "column_gap":
137
+ case "border_radius":
138
+ case "font_size":
139
+ fields[name] = field(value, (size) => lengthValue(size, false));
140
+ break;
141
+ case "padding":
142
+ case "margin":
143
+ fields[name] = field(value, sidesValue);
144
+ break;
145
+ case "background":
146
+ fields[name] = field(value, fillValue);
147
+ break;
148
+ case "border": {
149
+ const border = value;
150
+ fields[name] = {
151
+ width: field(border.width, (size) => lengthValue(size, false)),
152
+ paint: field(border.paint, fillValue),
153
+ };
154
+ break;
155
+ }
156
+ case "width":
157
+ case "height":
158
+ case "min_width":
159
+ case "min_height":
160
+ case "max_width":
161
+ case "max_height":
162
+ case "flex_basis":
163
+ fields[name] = field(value, (length) => lengthValue(length, true));
164
+ break;
165
+ case "inset":
166
+ fields[name] = Object.fromEntries(Object.entries(value)
167
+ .filter(([, side]) => side !== undefined)
168
+ .map(([side, length]) => [
169
+ side,
170
+ field(length, (inset) => lengthValue(inset, true)),
171
+ ]));
172
+ break;
173
+ case "grid_template_columns":
174
+ case "grid_template_rows":
175
+ case "grid_auto_columns":
176
+ case "grid_auto_rows":
177
+ fields[name] = checked(value, parseTrackList(value));
178
+ break;
179
+ case "grid_column":
180
+ case "grid_row":
181
+ fields[name] = checked(value, parsePlacement(value));
182
+ break;
183
+ case "color":
184
+ fields[name] = fillValue(value);
185
+ break;
186
+ case "translate":
187
+ fields[name] = field(value, offsetValue);
188
+ break;
189
+ case "scale":
190
+ fields[name] = scaleField(value);
191
+ break;
192
+ default:
193
+ // CSS keywords, the aspect ratio and the plain style values are written as they are;
194
+ // anything else the model refuses by name.
195
+ fields[name] = value;
196
+ }
197
+ }
198
+ return fields;
199
+ }
@@ -40,7 +40,9 @@ export declare class MediabunnyVideoDecoder implements BrowserVideoDecoder {
40
40
  private constructor();
41
41
  /**
42
42
  * Opens `resource`'s primary video track. Rejects when it has none, or when this browser cannot
43
- * decode it, so a host can fall back before the first request.
43
+ * decode it, so a host can fall back before the first request. With `hardwareAcceleration:
44
+ * "prefer-software"`, a track the browser has no software decoder for rejects with `code:
45
+ * "software_decode_unavailable"`.
44
46
  */
45
47
  static open(sourceId: string, resource: MediabunnyInput, options?: MediabunnyVideoDecoderOptions): Promise<MediabunnyVideoDecoder>;
46
48
  /** Bytes both windows hold: decoder frames and reverse copies. */
@@ -113,7 +113,9 @@ export class MediabunnyVideoDecoder {
113
113
  }
114
114
  /**
115
115
  * Opens `resource`'s primary video track. Rejects when it has none, or when this browser cannot
116
- * decode it, so a host can fall back before the first request.
116
+ * decode it, so a host can fall back before the first request. With `hardwareAcceleration:
117
+ * "prefer-software"`, a track the browser has no software decoder for rejects with `code:
118
+ * "software_decode_unavailable"`.
117
119
  */
118
120
  static async open(sourceId, resource, options = {}) {
119
121
  const limits = {
@@ -139,6 +141,20 @@ export class MediabunnyVideoDecoder {
139
141
  throw new Error("mediabunny input has no video track");
140
142
  if (!(await track.canDecode()))
141
143
  throw new Error("this browser cannot decode the video track");
144
+ // `canDecode` does not ask for a software decoder: a codec only hardware decodes would open
145
+ // and fail on its first read. Without WebCodecs only mediabunny's own decoders decode.
146
+ if (options.hardwareAcceleration === "prefer-software" &&
147
+ typeof VideoDecoder !== "undefined") {
148
+ const config = await track.getDecoderConfig();
149
+ const support = config === null
150
+ ? { supported: false }
151
+ : await VideoDecoder.isConfigSupported({
152
+ ...config,
153
+ hardwareAcceleration: "prefer-software",
154
+ });
155
+ if (support.supported !== true)
156
+ throw Object.assign(new Error(`this browser has no software decoder for ${config?.codec ?? track.codec ?? "the video track"}`), { code: "software_decode_unavailable" });
157
+ }
142
158
  // mediabunny reports a turn but not a mirror, and reads a mirroring matrix's angle otherwise
143
159
  // than native decoding does.
144
160
  const orientation = (await readVideoOrientation(resource, track.id)) ?? {
package/dist/project.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * Timeline values are integer ticks at {@link TICKS_PER_SECOND}. Ranges are
15
15
  * half-open: `[start, end)`.
16
16
  */
17
- import type { Animated, Easing, FrameRate, Interpolation, MediaTime, Project } from "./generated/project-schema.js";
17
+ import type { Animated, Easing, FrameRate, Insets, Interpolation, LayoutOffset, LayoutSize, MediaTime, Paint, Project, Rgba } from "./generated/project-schema.js";
18
18
  import { MAX_JSON_DEPTH } from "./json-text.js";
19
19
  export * from "./generated/project-schema.js";
20
20
  /** The deepest nesting of arrays and objects the engine reads in a project (serde_json's limit). */
@@ -136,6 +136,61 @@ export declare function validateProjectJson(json: string): string[];
136
136
  * {@link TICKS_PER_SECOND} frames per second).
137
137
  */
138
138
  export declare function validFrameRate(rate: unknown): rate is FrameRate;
139
+ /** A color as the engine writes it: the `{ red, green, blue, alpha }` object, never hex. */
140
+ export type RgbaObject = Exclude<Rgba, string>;
141
+ /** A paint as the engine writes it: tagged, its colors objects. */
142
+ export type CanonicalPaint = CanonicalPart<Exclude<Paint, Rgba>>;
143
+ /** Padding or margin sides as the engine writes them: all four, each a length. */
144
+ export interface CanonicalInsets {
145
+ readonly top: LayoutSize;
146
+ readonly right: LayoutSize;
147
+ readonly bottom: LayoutSize;
148
+ readonly left: LayoutSize;
149
+ }
150
+ /** An offset (a layout node's `translate`) as the engine writes it: `{ x, y }`. */
151
+ export type CanonicalOffset = Exclude<LayoutOffset, string>;
152
+ type Same<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : false;
153
+ /**
154
+ * `T`, a part of a project document, in the forms the engine writes: each color an
155
+ * {@link RgbaObject}, each paint a {@link CanonicalPaint}, each padding or margin
156
+ * {@link CanonicalInsets}, each offset a {@link CanonicalOffset}. What {@link canonicalProject}
157
+ * returns for a `Project`. Lengths and grid values keep the CSS spelling they were written in.
158
+ */
159
+ export type Canonical<T> = CanonicalValue<Exclude<T, null | undefined>> | Extract<T, null | undefined>;
160
+ type CanonicalValue<T> = [T] extends [never] ? never : Same<T, Rgba> extends true ? RgbaObject : Same<T, Paint> extends true ? CanonicalPaint : Same<T, Insets> extends true ? CanonicalInsets : Same<T, LayoutOffset> extends true ? CanonicalOffset : CanonicalPart<T>;
161
+ type CanonicalPart<T> = T extends string | number | boolean | bigint ? T : {
162
+ readonly [K in keyof T]: Canonical<T[K]>;
163
+ };
164
+ /** A project document in the forms the engine writes ({@link Canonical}). */
165
+ export type CanonicalProject = Canonical<Project>;
166
+ /**
167
+ * `color` as the engine writes it: a CSS hex string becomes the components object, each
168
+ * component the 32-bit value the engine reads, spelled shortest.
169
+ *
170
+ * @throws A `TypeError` for a string that is not CSS hex.
171
+ */
172
+ export declare function canonicalRgba(color: Rgba): RgbaObject;
173
+ /**
174
+ * `paint` as the engine writes it: a color (hex or object) becomes a solid paint of it, and
175
+ * every color in it the components object.
176
+ *
177
+ * @throws A `TypeError` for a color string that is not CSS hex.
178
+ */
179
+ export declare function canonicalPaint(paint: Paint): CanonicalPaint;
180
+ /**
181
+ * `project` in the forms the engine writes it back ({@link Canonical}): every color the
182
+ * components object, every paint tagged, every padding and margin the four sides, every offset
183
+ * `{ x, y }`. The forms the engine reads but never writes (CSS hex, a color as a paint, the
184
+ * sides shorthand, a `translate` string) are gone, so code that reads the document can take the
185
+ * one form. A value it cannot read (a string that is not hex, say) stays as it is, for
186
+ * {@link validateProject} to report: give it a document that validates to get a document in
187
+ * canonical form.
188
+ *
189
+ * The input is not changed. A part that is already canonical comes back as the same object, so
190
+ * a document in canonical form is returned itself, and a frozen part met before is not walked
191
+ * again: run on a changed copy of a document read before, it costs the parts that changed.
192
+ */
193
+ export declare function canonicalProject(project: Project): CanonicalProject;
139
194
  /** What a {@link LintIssue} is about. */
140
195
  export type LintOwner = {
141
196
  readonly type: "clip";