@tin.so/core 0.1.0 → 0.3.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.
@@ -1,101 +1,5 @@
1
1
  import * as v from "valibot";
2
2
  import { InitInput } from "@resvg/resvg-wasm";
3
- type FontFace = {
4
- weight: number;
5
- italic: boolean;
6
- /** Path relative to the fonts directory of this package */
7
- file: string;
8
- /** Family name inside the font file, which resvg uses to match the face */
9
- family: string;
10
- };
11
- type FontMetrics = {
12
- unitsPerEm: number;
13
- ascender: number;
14
- descender: number;
15
- lineGap: number;
16
- };
17
- type CodeFont = {
18
- id: string;
19
- name: string;
20
- kind: "code";
21
- faces: Array<FontFace>;
22
- metrics: FontMetrics & {
23
- advance: number;
24
- };
25
- };
26
- type UiFont = {
27
- id: string;
28
- name: string;
29
- kind: "ui";
30
- faces: Array<FontFace>;
31
- metrics: FontMetrics & {
32
- advances: Record<string, number>;
33
- };
34
- };
35
- type Font = CodeFont | UiFont;
36
- /** Reads a font file by its path relative to the fonts directory */
37
- type FontLoader = (file: string) => Promise<Uint8Array>;
38
- declare const CODE_FONTS: CodeFont[];
39
- declare const CODE_FONT_IDS: string[];
40
- declare const DEFAULT_CODE_FONT = "jetbrains-mono";
41
- declare const UI_FONT: UiFont;
42
- declare function getCodeFont(id: string): CodeFont;
43
- /** Picks the face that matches the style best: the exact face, then the regular face of the same style */
44
- declare function getFace(font: Font, style?: {
45
- bold?: boolean;
46
- italic?: boolean;
47
- }): FontFace;
48
- /**
49
- * The CSS font family of a face. The first name is for browsers, which load the faces with @font-face
50
- * rules under that name. The second name is the family inside the file, for resvg. The names stay
51
- * unquoted, because resvg does not match a quoted name that follows another name.
52
- */
53
- declare function cssFontFamily(font: Font, face: FontFace): string;
54
- /** Width of a text in the UI font, for title layout. Characters outside of ASCII count as an "M". */
55
- declare function measureUiText(text: string, fontSize: number): number;
56
- /** An icon on a 24px grid, drawn either filled or as a 2px stroke */
57
- type Icon = {
58
- id: string;
59
- title: string;
60
- /** SVG elements of the icon, without the root element */
61
- body: string;
62
- style: "fill" | "stroke";
63
- };
64
- /** The icon of the language, from its id in the language list */
65
- declare const AUTO_ICON = "auto";
66
- declare const FILE_ICON = "file";
67
- declare const NO_ICON = "none";
68
- /** Icon ids that a pane can name, besides "auto" and "none" */
69
- declare const ICON_IDS: string[];
70
- declare function getIcon(id: string): Icon | undefined;
71
- /** Resolves the icon setting of a pane. Returns undefined for "none". */
72
- declare function resolveIcon(setting: string, language: string): Icon | undefined;
73
- /** The URL of the JSON Schema of the latest spec version, on the hosted app */
74
- declare const SPEC_SCHEMA_URL: string;
75
- /**
76
- * The spec as a JSON Schema, for editors and agents. JSON Schema cannot express the custom checks of
77
- * the spec, such as line ranges, so their rules are only in the descriptions.
78
- */
79
- declare function specJsonSchema(): Record<string, unknown>;
80
- /**
81
- * The hosted web app. The CLI takes another app from its TIN_APP_URL environment variable,
82
- * for example the local editor during development.
83
- */
84
- declare const DEFAULT_APP_URL = "https://code-image.zirkelc.workers.dev/";
85
- /**
86
- * Compresses a spec into a URL-safe string. A spec without a version gets version 1, so that the
87
- * link keeps its meaning when a later version changes the format.
88
- */
89
- declare function encodeSpec(spec: unknown): Promise<string>;
90
- /** Reads a spec from a string of the encoder, with the fields of older links changed */
91
- declare function decodeSpec(encoded: string): Promise<unknown>;
92
- /**
93
- * A link that opens the spec in the web app. The spec is in the fragment, so it never goes to a
94
- * server and has no length limit of a request line.
95
- */
96
- declare function createLink(spec: unknown, appUrl?: string): Promise<string>;
97
- /** Reads the spec from the fragment of a link, or returns undefined when the fragment has none */
98
- declare function readLink(link: string): Promise<unknown>;
99
3
  type Mode = "light" | "dark";
100
4
  /** Token colors of a theme. Keys that are missing use the foreground color. */
101
5
  type Syntax = {
@@ -125,16 +29,24 @@ type Theme = {
125
29
  from: string;
126
30
  to: string;
127
31
  };
128
- font?: string;
129
- partner?: boolean;
130
- hidden?: boolean;
131
- lineNumbers?: boolean;
32
+ /** The colors of the window by mode, as in the editor of the theme. The background is opaque. */
33
+ window?: Partial<Record<Mode, EditorWindow>>;
34
+ /** The Shiki theme by mode that colors the code, in place of the token colors of the syntax */
35
+ textmate: Partial<Record<Mode, string>>;
132
36
  syntax: {
133
37
  light?: Syntax;
134
38
  dark?: Syntax;
135
39
  };
136
40
  };
137
- /** Colors of the window around the code, from the ray.so default frame */
41
+ /** The colors of the window of an editor theme */
42
+ type EditorWindow = {
43
+ background: string;
44
+ /** The text of the title bar and the tabs */
45
+ title?: string;
46
+ lineNumber?: string;
47
+ divider?: string;
48
+ };
49
+ /** Colors of the window around the code, from the default frame of ray.so */
138
50
  type FrameColors = {
139
51
  /** The gradient behind the windows */
140
52
  backdrop: {
@@ -153,7 +65,7 @@ type FrameColors = {
153
65
  };
154
66
  declare const THEMES: Array<Theme>;
155
67
  declare const THEME_IDS: string[];
156
- declare const DEFAULT_THEME = "candy";
68
+ declare const DEFAULT_THEME = "github";
157
69
  declare function getTheme(id: string): Theme;
158
70
  /** A theme with only one mode always uses that mode */
159
71
  declare function resolveMode(theme: Theme, mode: Mode): Mode;
@@ -183,6 +95,101 @@ declare function resolveLanguage(language: string): string;
183
95
  declare function inferLanguage(fileName: string | undefined): string;
184
96
  /** Splits code into lines of colored tokens with the colors of the theme */
185
97
  declare function highlight(code: string, language: string, theme: Theme, mode: Mode, syntax: Syntax): Promise<Array<HighlightedLine>>;
98
+ /**
99
+ * Backgrounds that the renderer makes from the colors of the image:
100
+ * - ambient-blur: a blurred and larger copy of the code behind the window
101
+ * - ambient-code: a mesh of the colors that the code uses most
102
+ * - ambient-theme: a mesh of the keyword, string, function and constant colors of the theme
103
+ */
104
+ declare const AMBIENT_BACKGROUNDS: readonly ["ambient-blur", "ambient-code", "ambient-theme"];
105
+ declare const AMBIENT_ENABLED = false;
106
+ type AmbientBackground = (typeof AMBIENT_BACKGROUNDS)[number];
107
+ declare function isAmbientBackground(css: string): css is AmbientBackground;
108
+ /** The theme mesh of a theme in a mode, as a preview of the ambient backgrounds before the code is known */
109
+ declare function ambientPreviewCss(theme: Theme, mode: Mode): string;
110
+ /** A background preset of the editor: a gradient, a color or a mesh of radial gradients */
111
+ type BackgroundPreset = {
112
+ id: string;
113
+ name: string;
114
+ kind: "gradient" | "color" | "mesh";
115
+ /** The CSS background, as the background field of a spec takes it */
116
+ css: string;
117
+ };
118
+ declare const BACKGROUNDS: Array<BackgroundPreset>;
119
+ /** The background preset of a theme in a mode, or undefined when the theme has none */
120
+ declare function themeBackground(theme: Theme, mode: Mode): BackgroundPreset | undefined;
121
+ type FontFace = {
122
+ weight: number;
123
+ italic: boolean;
124
+ /** Path relative to the fonts directory of this package */
125
+ file: string;
126
+ /** Family name inside the font file, which resvg uses to match the face */
127
+ family: string;
128
+ };
129
+ type FontMetrics = {
130
+ unitsPerEm: number;
131
+ ascender: number;
132
+ descender: number;
133
+ lineGap: number;
134
+ };
135
+ type CodeFont = {
136
+ id: string;
137
+ name: string;
138
+ kind: "code";
139
+ faces: Array<FontFace>;
140
+ metrics: FontMetrics & {
141
+ advance: number;
142
+ };
143
+ };
144
+ type UiFont = {
145
+ id: string;
146
+ name: string;
147
+ kind: "ui";
148
+ faces: Array<FontFace>;
149
+ metrics: FontMetrics & {
150
+ advances: Record<string, number>;
151
+ };
152
+ };
153
+ type Font = CodeFont | UiFont;
154
+ /** Reads a font file by its path relative to the fonts directory */
155
+ type FontLoader = (file: string) => Promise<Uint8Array>;
156
+ declare const CODE_FONTS: CodeFont[];
157
+ declare const CODE_FONT_IDS: string[];
158
+ declare const DEFAULT_CODE_FONT = "jetbrains-mono";
159
+ declare const UI_FONT: UiFont;
160
+ declare function getCodeFont(id: string): CodeFont;
161
+ /** Picks the face that matches the style best: the exact face, then the regular face of the same style */
162
+ declare function getFace(font: Font, style?: {
163
+ bold?: boolean;
164
+ italic?: boolean;
165
+ }): FontFace;
166
+ /**
167
+ * The CSS font family of a face. The first name is for browsers, which load the faces with @font-face
168
+ * rules under that name. The second name is the family inside the file, for resvg. The names stay
169
+ * unquoted, because resvg does not match a quoted name that follows another name.
170
+ */
171
+ declare function cssFontFamily(font: Font, face: FontFace): string;
172
+ /** Width of a text in the UI font, for title layout. Characters outside of ASCII count as an "M". */
173
+ /** The width of text in a code font, which gives each character the same advance */
174
+ declare function measureCodeText(text: string, fontSize: number, font: CodeFont): number;
175
+ declare function measureUiText(text: string, fontSize: number): number;
176
+ /** An icon on a 24px grid, drawn either filled or as a 2px stroke */
177
+ type Icon = {
178
+ id: string;
179
+ title: string;
180
+ /** SVG elements of the icon, without the root element */
181
+ body: string;
182
+ style: "fill" | "stroke";
183
+ };
184
+ /** The icon of the language, from its id in the language list */
185
+ declare const AUTO_ICON = "auto";
186
+ declare const FILE_ICON = "file";
187
+ declare const NO_ICON = "none";
188
+ /** Icon ids that a pane can name, besides "auto" and "none" */
189
+ declare const ICON_IDS: string[];
190
+ declare function getIcon(id: string): Icon | undefined;
191
+ /** Resolves the icon setting of a pane. Returns undefined for "none". */
192
+ declare function resolveIcon(setting: string, language: string): Icon | undefined;
186
193
  declare const MAC_HEADER: {
187
194
  paddingTop: number;
188
195
  height: number;
@@ -234,6 +241,8 @@ type AnnotationBox = {
234
241
  lines: Array<HighlightedLine>;
235
242
  /** true when the popover is smaller than its code, so that it must cut the code off */
236
243
  clipped: boolean;
244
+ /** The background of the popover from the spec */
245
+ background?: string;
237
246
  };
238
247
  type PaneBox = Rect & {
239
248
  title?: string;
@@ -279,6 +288,8 @@ type WindowBox = Rect & {
279
288
  radius: number;
280
289
  title?: string;
281
290
  controls: "gray" | "color";
291
+ /** The background of the window from the spec, in place of the theme color */
292
+ background?: string;
282
293
  /** The size that fits the panes. The layout can make a window larger to fill the image. */
283
294
  natural: {
284
295
  width: number;
@@ -302,7 +313,14 @@ type Scene = {
302
313
  mode: Mode;
303
314
  syntax: Syntax;
304
315
  frame: FrameColors;
316
+ /** false for a transparent image */
305
317
  background: boolean;
318
+ /** The opacity of the background, from 0 to 1 */
319
+ backgroundOpacity: number;
320
+ /** The color or gradient of the image: the one of the spec, or the background preset of the theme */
321
+ customBackground: CssBackground | undefined;
322
+ /** Draw a blurred copy of the code of each window behind it, over the background color */
323
+ ambientBlur: boolean;
306
324
  font: CodeFont;
307
325
  text: TextMetrics;
308
326
  popoverText: TextMetrics;
@@ -321,6 +339,99 @@ type LayoutOptions = {
321
339
  declare function normalizeCode(code: string, options?: LayoutOptions): string;
322
340
  /** Validates the spec, highlights the code and places every element of the image */
323
341
  declare function layout(input: unknown, options?: LayoutOptions): Promise<Scene>;
342
+ /**
343
+ * The CSS backgrounds that a spec can use: a color, or layers of linear-gradient and
344
+ * radial-gradient with an optional color as the last layer. Colors are hex, rgb(), rgba() and
345
+ * transparent.
346
+ */
347
+ type Rgba = {
348
+ r: number;
349
+ g: number;
350
+ b: number;
351
+ a: number;
352
+ };
353
+ type Length = {
354
+ value: number;
355
+ unit: "%" | "px";
356
+ };
357
+ type ColorStop = {
358
+ color: Rgba;
359
+ position?: Length;
360
+ };
361
+ type Extent = "closest-side" | "closest-corner" | "farthest-side" | "farthest-corner";
362
+ type LinearLayer = {
363
+ type: "linear";
364
+ /** An angle in degrees, or the corner or side of a "to" keyword as -1, 0 or 1 on each axis */
365
+ direction: {
366
+ angle: number;
367
+ } | {
368
+ to: {
369
+ x: number;
370
+ y: number;
371
+ };
372
+ };
373
+ stops: Array<ColorStop>;
374
+ };
375
+ type RadialLayer = {
376
+ type: "radial";
377
+ shape: "circle" | "ellipse";
378
+ size: Extent | {
379
+ x: Length;
380
+ y: Length;
381
+ };
382
+ at: {
383
+ x: Length;
384
+ y: Length;
385
+ };
386
+ stops: Array<ColorStop>;
387
+ };
388
+ type ColorLayer = {
389
+ type: "color";
390
+ color: Rgba;
391
+ };
392
+ type Layer = LinearLayer | RadialLayer | ColorLayer;
393
+ /** A parsed CSS background, with the top layer first as in CSS */
394
+ type CssBackground = Array<Layer>;
395
+ declare function isCssBackground(css: string): boolean;
396
+ /** The URL of the JSON Schema of the latest spec version, on the hosted app */
397
+ declare const SPEC_SCHEMA_URL: string;
398
+ /**
399
+ * The spec as a JSON Schema, for editors and agents. JSON Schema cannot express the custom checks of
400
+ * the spec, such as line ranges, so their rules are only in the descriptions.
401
+ */
402
+ declare function specJsonSchema(): Record<string, unknown>;
403
+ /**
404
+ * True when the value is the URL of a tin.so spec schema: a path that ends with
405
+ * /schema/v<number>.json on the host of the hosted app, on an earlier host of the app, or on the
406
+ * host of the given app URL (for example a local editor).
407
+ */
408
+ declare function isSpecSchemaUrl(value: unknown, appUrl?: string): boolean;
409
+ /**
410
+ * The hosted web app. The CLI takes another app from its TIN_APP_URL environment variable,
411
+ * for example the local editor during development.
412
+ */
413
+ declare const DEFAULT_APP_URL = "https://tin.so/";
414
+ type DecodeOptions = {
415
+ /** The largest size of the inflated spec in bytes, so that a hostile input cannot use much memory */
416
+ maxBytes?: number;
417
+ };
418
+ /**
419
+ * Compresses a spec into a URL-safe string. A spec without a version gets version 1, so that the
420
+ * link keeps its meaning when a later version changes the format.
421
+ */
422
+ declare function encodeSpec(spec: unknown): Promise<string>;
423
+ /**
424
+ * Reads a spec from a string of the encoder, with the fields of older links changed. Throws for
425
+ * bad data and for a spec larger than the limit.
426
+ */
427
+ declare function decodeSpec(encoded: string, options?: DecodeOptions): Promise<unknown>;
428
+ /**
429
+ * A link that opens the spec in the web app. The spec is in the fragment, so it never goes to a
430
+ * server and has no length limit of a request line.
431
+ */
432
+ declare function createLink(spec: unknown, appUrl?: string): Promise<string>;
433
+ /** Reads the spec from the fragment of a link, or returns undefined when the fragment has none */
434
+ declare function readLink(link: string, options?: DecodeOptions): Promise<unknown>;
324
435
  /**
325
436
  * Whether a render writes the metadata when the caller does not say. This is the one place to
326
437
  * change the default.
@@ -332,14 +443,16 @@ declare const SOFTWARE = "tin.so";
332
443
  declare const PNG_KEYWORDS: {
333
444
  readonly software: "Software";
334
445
  readonly source: "Source";
335
- readonly link: "code-image:link";
336
- readonly spec: "code-image:spec";
446
+ readonly link: "tin.so:link";
337
447
  };
338
448
  /** The namespace of the metadata element in an SVG */
339
- declare const SVG_NAMESPACE = "urn:code-image:metadata:1";
340
- /** The data that an exported image carries, so that the editor can open the image again */
449
+ declare const SVG_NAMESPACE = "urn:tin.so:metadata:1";
450
+ /**
451
+ * The data that an exported image carries, so that the editor can open the image again. The image
452
+ * stores only the link, because the link holds the whole spec.
453
+ */
341
454
  type ImageMetadata = {
342
- /** The spec input, as the user wrote it */
455
+ /** The spec input, as the user wrote it, with its version */
343
456
  spec: unknown;
344
457
  /** A link that opens the spec in the editor */
345
458
  link: string;
@@ -350,8 +463,8 @@ type ImageMetadata = {
350
463
  */
351
464
  declare function createImageMetadata(spec: unknown, appUrl?: string): Promise<ImageMetadata>;
352
465
  /**
353
- * Adds text chunks after the header of a PNG: the program, the app URL, the editor link and the
354
- * compressed spec. A PNG without the expected header comes back unchanged.
466
+ * Adds text chunks after the header of a PNG: the program, the app URL and the editor link. A PNG
467
+ * without the expected header comes back unchanged.
355
468
  */
356
469
  declare function addPngMetadata(png: Uint8Array, metadata: ImageMetadata): Promise<Uint8Array>;
357
470
  /**
@@ -362,14 +475,19 @@ declare function addPngMetadata(png: Uint8Array, metadata: ImageMetadata): Promi
362
475
  declare function readImageSpec(input: Uint8Array | ArrayBuffer | Blob | string): Promise<unknown>;
363
476
  declare const IMPLICIT_SPEC_VERSION = 1;
364
477
  /**
365
- * Changes the fields of older specs from before the v field to the current fields, so that old
366
- * links, files and images stay valid. Input that is not a spec stays as it is, so that the spec
367
- * validation reports it.
478
+ * The version that the $schema URL of a spec names, or undefined when the spec has no such URL.
479
+ * Only the path counts, so that the URL of each host that serves the schema gives the version.
368
480
  */
369
- declare function migrateLegacySpec(spec: unknown): unknown;
481
+ declare function schemaVersion(spec: unknown): number | undefined;
482
+ /**
483
+ * Keys with this prefix hold data of other tools, such as an editor state. The renderer ignores
484
+ * them in each object of a spec, so that a spec with such keys stays valid in all versions.
485
+ */
486
+ declare const EXTENSION_PREFIX = "x-";
370
487
  /**
371
488
  * Adds the version to a spec without one, so that a stored spec keeps its meaning when a later
372
- * version changes the format. A spec with a version stays as it is.
489
+ * version changes the format. The version comes from the $schema URL, or is version 1 without it.
490
+ * A spec with a version stays as it is.
373
491
  */
374
492
  declare function stampSpecVersion(spec: unknown): unknown;
375
493
  type PngOptions = {
@@ -400,12 +518,19 @@ declare const SPEC_LIMITS: {
400
518
  readonly size: 8192;
401
519
  };
402
520
  declare const MARK_STYLES: readonly ["strong", "emphasis", "underline", "strikethrough"];
521
+ declare const ANNOTATION_TYPES: readonly ["popover"];
403
522
  /**
404
523
  * Versions of the spec format.
405
524
  *
406
525
  * - Increase v only for a breaking change: a field that changes its meaning, gets a new name or
407
- * goes away. A new optional field does not increase v, because older specs stay valid.
408
- * - A spec without v is version 1, now and in all later versions, because older specs have no v.
526
+ * goes away, a changed default, a value that a list no longer has (a theme, font, icon or
527
+ * language id), or a smaller limit. Specs leave out the defaults, so a new default changes old
528
+ * images. A new optional field, a new value or a larger limit does not increase v, because older
529
+ * specs stay valid.
530
+ * - The version is v, or the version of the $schema URL (/schema/v<number>.json) without v. When
531
+ * both are there, they must be the same. A spec without both is version 1, now and in all later
532
+ * versions, because older specs have neither.
533
+ * - Keys that start with "x-" are for other tools. The renderer ignores them in every object.
409
534
  * - For a new version, add its schema (with v as a required literal of the new number) to
410
535
  * SPEC_SCHEMAS, a function that changes a parsed spec of the version before into the new
411
536
  * version to MIGRATIONS, and increase LATEST_SPEC_VERSION. The schema of the latest version is
@@ -416,9 +541,10 @@ declare const LATEST_SPEC_VERSION = 1;
416
541
  declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
417
542
  readonly $schema: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>, undefined>, v.DescriptionAction<string | undefined, string>]>;
418
543
  readonly v: v.SchemaWithPipe<readonly [v.OptionalSchema<v.LiteralSchema<1, undefined>, 1>, v.DescriptionAction<1, string>]>;
419
- readonly theme: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<string[], undefined>, "candy">, v.DescriptionAction<string, string>]>;
544
+ readonly theme: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<string[], undefined>, "github">, v.DescriptionAction<string, string>]>;
420
545
  readonly mode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<["dark", "light"], undefined>, "dark">, v.DescriptionAction<"dark" | "light", string>]>;
421
- readonly background: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BooleanSchema<undefined>, true>, v.DescriptionAction<boolean, string>]>;
546
+ readonly background: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Use a hex color such as \"#1e1e2e\", or a CSS gradient such as \"linear-gradient(135deg, #2e1065, #a78bfa)\". Gradients are linear-gradient and radial-gradient, with hex, rgb(), rgba() or transparent colors, several layers separated by commas, and a color as the last layer">]>, undefined>, v.DescriptionAction<string | undefined, string>]>;
547
+ readonly backgroundOpacity: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 1, undefined>]>, 1>, v.DescriptionAction<number, string>]>;
422
548
  readonly padding: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 256, undefined>]>, 64>, v.DescriptionAction<number, string>]>;
423
549
  readonly font: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<string[], undefined>, undefined>, v.DescriptionAction<string | undefined, string>]>;
424
550
  readonly lineNumbers: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BooleanSchema<undefined>, undefined>, v.DescriptionAction<boolean | undefined, string>]>;
@@ -431,6 +557,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
431
557
  readonly frame: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BooleanSchema<undefined>, true>, v.DescriptionAction<boolean, string>]>;
432
558
  readonly titleBar: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BooleanSchema<undefined>, true>, v.DescriptionAction<boolean, string>]>;
433
559
  readonly tabs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BooleanSchema<undefined>, false>, v.DescriptionAction<boolean, string>]>;
560
+ readonly background: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Use a hex color such as \"#ff5c57\"">]>, undefined>, v.DescriptionAction<string | undefined, string>]>;
434
561
  readonly controls: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<["gray", "color"], undefined>, "gray">, v.DescriptionAction<"color" | "gray", string>]>;
435
562
  readonly title: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 200, undefined>]>, undefined>, v.DescriptionAction<string | undefined, string>]>;
436
563
  readonly split: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<["row", "column"], undefined>, "row">, v.DescriptionAction<"column" | "row", string>]>;
@@ -446,6 +573,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
446
573
  readonly icon: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<["auto", "none", ...string[]], undefined>, "auto">, v.DescriptionAction<string, string>]>;
447
574
  readonly lineNumbers: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BooleanSchema<undefined>, undefined>, v.DescriptionAction<boolean | undefined, string>]>;
448
575
  readonly annotations: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
576
+ readonly type: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["popover"], undefined>, "popover">, v.DescriptionAction<"popover", string>]>;
449
577
  readonly line: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, v.DescriptionAction<number, string>]>;
450
578
  readonly match: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.DescriptionAction<string, string>]>;
451
579
  readonly occurrence: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, 1>, v.DescriptionAction<number, string>]>;
@@ -491,7 +619,9 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
491
619
  color?: string | undefined;
492
620
  background?: string | undefined;
493
621
  }[], string>]>;
622
+ readonly background: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "Use a hex color such as \"#ff5c57\"">]>, undefined>, v.DescriptionAction<string | undefined, string>]>;
494
623
  }, undefined>, undefined>, v.MaxLengthAction<{
624
+ type: "popover";
495
625
  line: number;
496
626
  match: string;
497
627
  occurrence: number;
@@ -509,7 +639,9 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
509
639
  color?: string | undefined;
510
640
  background?: string | undefined;
511
641
  }[];
642
+ background?: string | undefined;
512
643
  }[], number, (issue: v.MaxLengthIssue<{
644
+ type: "popover";
513
645
  line: number;
514
646
  match: string;
515
647
  occurrence: number;
@@ -527,7 +659,9 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
527
659
  color?: string | undefined;
528
660
  background?: string | undefined;
529
661
  }[];
662
+ background?: string | undefined;
530
663
  }[], number>) => string>]>, readonly []>, v.DescriptionAction<{
664
+ type: "popover";
531
665
  line: number;
532
666
  match: string;
533
667
  occurrence: number;
@@ -545,6 +679,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
545
679
  color?: string | undefined;
546
680
  background?: string | undefined;
547
681
  }[];
682
+ background?: string | undefined;
548
683
  }[], string>]>;
549
684
  readonly marks: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
550
685
  readonly line: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, v.DescriptionAction<number, string>]>;
@@ -591,6 +726,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
591
726
  icon: string;
592
727
  lineNumbers?: boolean | undefined;
593
728
  annotations: {
729
+ type: "popover";
594
730
  line: number;
595
731
  match: string;
596
732
  occurrence: number;
@@ -608,6 +744,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
608
744
  color?: string | undefined;
609
745
  background?: string | undefined;
610
746
  }[];
747
+ background?: string | undefined;
611
748
  }[];
612
749
  marks: {
613
750
  line: number;
@@ -626,6 +763,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
626
763
  icon: string;
627
764
  lineNumbers?: boolean | undefined;
628
765
  annotations: {
766
+ type: "popover";
629
767
  line: number;
630
768
  match: string;
631
769
  occurrence: number;
@@ -643,6 +781,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
643
781
  color?: string | undefined;
644
782
  background?: string | undefined;
645
783
  }[];
784
+ background?: string | undefined;
646
785
  }[];
647
786
  marks: {
648
787
  line: number;
@@ -661,6 +800,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
661
800
  icon: string;
662
801
  lineNumbers?: boolean | undefined;
663
802
  annotations: {
803
+ type: "popover";
664
804
  line: number;
665
805
  match: string;
666
806
  occurrence: number;
@@ -678,6 +818,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
678
818
  color?: string | undefined;
679
819
  background?: string | undefined;
680
820
  }[];
821
+ background?: string | undefined;
681
822
  }[];
682
823
  marks: {
683
824
  line: number;
@@ -696,6 +837,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
696
837
  icon: string;
697
838
  lineNumbers?: boolean | undefined;
698
839
  annotations: {
840
+ type: "popover";
699
841
  line: number;
700
842
  match: string;
701
843
  occurrence: number;
@@ -713,6 +855,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
713
855
  color?: string | undefined;
714
856
  background?: string | undefined;
715
857
  }[];
858
+ background?: string | undefined;
716
859
  }[];
717
860
  marks: {
718
861
  line: number;
@@ -728,6 +871,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
728
871
  frame: boolean;
729
872
  titleBar: boolean;
730
873
  tabs: boolean;
874
+ background?: string | undefined;
731
875
  controls: "color" | "gray";
732
876
  title?: string | undefined;
733
877
  split: "column" | "row";
@@ -743,6 +887,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
743
887
  icon: string;
744
888
  lineNumbers?: boolean | undefined;
745
889
  annotations: {
890
+ type: "popover";
746
891
  line: number;
747
892
  match: string;
748
893
  occurrence: number;
@@ -760,6 +905,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
760
905
  color?: string | undefined;
761
906
  background?: string | undefined;
762
907
  }[];
908
+ background?: string | undefined;
763
909
  }[];
764
910
  marks: {
765
911
  line: number;
@@ -775,6 +921,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
775
921
  frame: boolean;
776
922
  titleBar: boolean;
777
923
  tabs: boolean;
924
+ background?: string | undefined;
778
925
  controls: "color" | "gray";
779
926
  title?: string | undefined;
780
927
  split: "column" | "row";
@@ -790,6 +937,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
790
937
  icon: string;
791
938
  lineNumbers?: boolean | undefined;
792
939
  annotations: {
940
+ type: "popover";
793
941
  line: number;
794
942
  match: string;
795
943
  occurrence: number;
@@ -807,6 +955,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
807
955
  color?: string | undefined;
808
956
  background?: string | undefined;
809
957
  }[];
958
+ background?: string | undefined;
810
959
  }[];
811
960
  marks: {
812
961
  line: number;
@@ -822,6 +971,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
822
971
  frame: boolean;
823
972
  titleBar: boolean;
824
973
  tabs: boolean;
974
+ background?: string | undefined;
825
975
  controls: "color" | "gray";
826
976
  title?: string | undefined;
827
977
  split: "column" | "row";
@@ -837,6 +987,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
837
987
  icon: string;
838
988
  lineNumbers?: boolean | undefined;
839
989
  annotations: {
990
+ type: "popover";
840
991
  line: number;
841
992
  match: string;
842
993
  occurrence: number;
@@ -854,6 +1005,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
854
1005
  color?: string | undefined;
855
1006
  background?: string | undefined;
856
1007
  }[];
1008
+ background?: string | undefined;
857
1009
  }[];
858
1010
  marks: {
859
1011
  line: number;
@@ -869,6 +1021,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
869
1021
  frame: boolean;
870
1022
  titleBar: boolean;
871
1023
  tabs: boolean;
1024
+ background?: string | undefined;
872
1025
  controls: "color" | "gray";
873
1026
  title?: string | undefined;
874
1027
  split: "column" | "row";
@@ -884,6 +1037,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
884
1037
  icon: string;
885
1038
  lineNumbers?: boolean | undefined;
886
1039
  annotations: {
1040
+ type: "popover";
887
1041
  line: number;
888
1042
  match: string;
889
1043
  occurrence: number;
@@ -901,6 +1055,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
901
1055
  color?: string | undefined;
902
1056
  background?: string | undefined;
903
1057
  }[];
1058
+ background?: string | undefined;
904
1059
  }[];
905
1060
  marks: {
906
1061
  line: number;
@@ -918,7 +1073,8 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
918
1073
  v: 1;
919
1074
  theme: string;
920
1075
  mode: "dark" | "light";
921
- background: boolean;
1076
+ background?: string | undefined;
1077
+ backgroundOpacity: number;
922
1078
  padding: number;
923
1079
  font?: string | undefined;
924
1080
  lineNumbers?: boolean | undefined;
@@ -931,6 +1087,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
931
1087
  frame: boolean;
932
1088
  titleBar: boolean;
933
1089
  tabs: boolean;
1090
+ background?: string | undefined;
934
1091
  controls: "color" | "gray";
935
1092
  title?: string | undefined;
936
1093
  split: "column" | "row";
@@ -946,6 +1103,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
946
1103
  icon: string;
947
1104
  lineNumbers?: boolean | undefined;
948
1105
  annotations: {
1106
+ type: "popover";
949
1107
  line: number;
950
1108
  match: string;
951
1109
  occurrence: number;
@@ -963,6 +1121,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
963
1121
  color?: string | undefined;
964
1122
  background?: string | undefined;
965
1123
  }[];
1124
+ background?: string | undefined;
966
1125
  }[];
967
1126
  marks: {
968
1127
  line: number;
@@ -980,7 +1139,8 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
980
1139
  v: 1;
981
1140
  theme: string;
982
1141
  mode: "dark" | "light";
983
- background: boolean;
1142
+ background?: string | undefined;
1143
+ backgroundOpacity: number;
984
1144
  padding: number;
985
1145
  font?: string | undefined;
986
1146
  lineNumbers?: boolean | undefined;
@@ -993,6 +1153,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
993
1153
  frame: boolean;
994
1154
  titleBar: boolean;
995
1155
  tabs: boolean;
1156
+ background?: string | undefined;
996
1157
  controls: "color" | "gray";
997
1158
  title?: string | undefined;
998
1159
  split: "column" | "row";
@@ -1008,6 +1169,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
1008
1169
  icon: string;
1009
1170
  lineNumbers?: boolean | undefined;
1010
1171
  annotations: {
1172
+ type: "popover";
1011
1173
  line: number;
1012
1174
  match: string;
1013
1175
  occurrence: number;
@@ -1025,6 +1187,7 @@ declare const SpecSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
1025
1187
  color?: string | undefined;
1026
1188
  background?: string | undefined;
1027
1189
  }[];
1190
+ background?: string | undefined;
1028
1191
  }[];
1029
1192
  marks: {
1030
1193
  line: number;
@@ -1055,9 +1218,9 @@ declare class SpecError extends Error {
1055
1218
  constructor(issues: Array<string>);
1056
1219
  }
1057
1220
  /**
1058
- * Validates a spec and applies the defaults. It first changes the fields of older specs, then
1059
- * validates the spec with the schema of its version and changes it to the latest version. Throws
1060
- * a SpecError that lists every issue.
1221
+ * Validates a spec and applies the defaults. It first removes the keys of other tools, then
1222
+ * validates the spec with the schema of its version and changes it to the latest version. Throws a
1223
+ * SpecError that lists every issue.
1061
1224
  */
1062
1225
  declare function parseSpec(input: unknown): Spec;
1063
1226
  /** Expands highlight entries such as [2, "4-6"] to a set of line numbers, up to the last line */
@@ -1073,4 +1236,4 @@ type SvgOptions = {
1073
1236
  };
1074
1237
  /** Writes the scene as a standalone SVG document */
1075
1238
  declare function toSvg(scene: Scene, options?: SvgOptions): string;
1076
- export { resolveLanguage as $, readImageSpec as A, FontFace as At, WINDOW_RADIUS as B, ImageMetadata as C, getIcon as Ct, SVG_NAMESPACE as D, CodeFont as Dt, SOFTWARE as E, CODE_FONT_IDS as Et, PaneBox as F, cssFontFamily as Ft, MAC_HEADER as G, cellCount as H, Rect as I, getCodeFont as It, PLAIN_TEXT as J, HighlightedLine as K, Scene as L, getFace as Lt, LINE_HEIGHT as M, FontMetrics as Mt, LayoutOptions as N, UI_FONT as Nt, addPngMetadata as O, DEFAULT_CODE_FONT as Ot, POPOVER as P, UiFont as Pt, isKnownLanguage as Q, TAB_HEADER as R, measureUiText as Rt, stampSpecVersion as S, NO_ICON as St, PNG_KEYWORDS as T, CODE_FONTS as Tt, layout as U, WindowBox as V, normalizeCode as W, highlight as X, Token as Y, inferLanguage as Z, loadSceneFonts as _, specJsonSchema as _t, MarkStyle as a, THEME_IDS as at, IMPLICIT_SPEC_VERSION as b, ICON_IDS as bt, Spec as c, getSyntax as ct, SpecSchema as d, DEFAULT_APP_URL as dt, DEFAULT_THEME as et, WindowSpec as f, createLink as ft, initPng as g, SPEC_SCHEMA_URL as gt, PngOptions as h, readLink as ht, MARK_STYLES as i, THEMES as it, FONT_SIZE as j, FontLoader as jt, createImageMetadata as k, Font as kt, SpecError as l, getTheme as lt, parseSpec as m, encodeSpec as mt, toSvg as n, Mode as nt, PaneSpec as o, Theme as ot, expandLineRanges as p, decodeSpec as pt, LANGUAGE_IDS as q, LATEST_SPEC_VERSION as r, Syntax as rt, SPEC_LIMITS as s, getFrameColors as st, SvgOptions as t, FrameColors as tt, SpecInput as u, resolveMode as ut, sceneFontFiles as v, AUTO_ICON as vt, METADATA_BY_DEFAULT as w, resolveIcon as wt, migrateLegacySpec as x, Icon as xt, svgToPng as y, FILE_ICON as yt, TextMetrics as z };
1239
+ export { WindowBox as $, resolveMode as $t, addPngMetadata as A, AMBIENT_ENABLED as At, isSpecSchemaUrl as B, isKnownLanguage as Bt, schemaVersion as C, getFace as Ct, PNG_KEYWORDS as D, BackgroundPreset as Dt, METADATA_BY_DEFAULT as E, BACKGROUNDS as Et, createLink as F, LANGUAGE_IDS as Ft, LayoutOptions as G, Mode as Gt, isCssBackground as H, DEFAULT_THEME as Ht, decodeSpec as I, PLAIN_TEXT as It, Rect as J, THEME_IDS as Jt, POPOVER as K, Syntax as Kt, encodeSpec as L, Token as Lt, readImageSpec as M, ambientPreviewCss as Mt, DEFAULT_APP_URL as N, isAmbientBackground as Nt, SOFTWARE as O, themeBackground as Ot, DecodeOptions as P, HighlightedLine as Pt, WINDOW_RADIUS as Q, getTheme as Qt, readLink as R, highlight as Rt, IMPLICIT_SPEC_VERSION as S, getCodeFont as St, ImageMetadata as T, measureUiText as Tt, FONT_SIZE as U, EditorWindow as Ut, specJsonSchema as V, resolveLanguage as Vt, LINE_HEIGHT as W, FrameColors as Wt, TAB_HEADER as X, getFrameColors as Xt, Scene as Y, Theme as Yt, TextMetrics as Z, getSyntax as Zt, initPng as _, FontLoader as _t, MARK_STYLES as a, FILE_ICON as at, svgToPng as b, UiFont as bt, SPEC_LIMITS as c, NO_ICON as ct, SpecInput as d, CODE_FONTS as dt, cellCount as et, SpecSchema as f, CODE_FONT_IDS as ft, PngOptions as g, FontFace as gt, parseSpec as h, Font as ht, LATEST_SPEC_VERSION as i, AUTO_ICON as it, createImageMetadata as j, AmbientBackground as jt, SVG_NAMESPACE as k, AMBIENT_BACKGROUNDS as kt, Spec as l, getIcon as lt, expandLineRanges as m, DEFAULT_CODE_FONT as mt, toSvg as n, normalizeCode as nt, MarkStyle as o, ICON_IDS as ot, WindowSpec as p, CodeFont as pt, PaneBox as q, THEMES as qt, ANNOTATION_TYPES as r, MAC_HEADER as rt, PaneSpec as s, Icon as st, SvgOptions as t, layout as tt, SpecError as u, resolveIcon as ut, loadSceneFonts as v, FontMetrics as vt, stampSpecVersion as w, measureCodeText as wt, EXTENSION_PREFIX as x, cssFontFamily as xt, sceneFontFiles as y, UI_FONT as yt, SPEC_SCHEMA_URL as z, inferLanguage as zt };