@lvl99dotcom/paintcanvas 0.3.1 → 0.5.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/README.md +30 -15
- package/dist/lib/brushes/StrokeEngine/index.d.ts +2 -2
- package/dist/lib/brushes/StrokeEngine/index.js +26 -28
- package/dist/lib/brushes/presets/round/index.d.ts +1 -1
- package/dist/lib/brushes/presets/round/index.js +12 -7
- package/dist/lib/brushes/presets/square/index.d.ts +1 -1
- package/dist/lib/brushes/presets/square/index.js +7 -3
- package/dist/lib/brushes/shapeImage/index.d.ts +7 -3
- package/dist/lib/brushes/shapeImage/index.js +15 -9
- package/dist/lib/brushes/shapes/index.d.ts +18 -0
- package/dist/lib/brushes/shapes/index.js +86 -0
- package/dist/lib/classes/BrushSettings/index.d.ts +53 -2
- package/dist/lib/classes/BrushSettings/index.js +85 -14
- package/dist/lib/classes/KeyboardShortcuts/index.d.ts +47 -7
- package/dist/lib/classes/KeyboardShortcuts/index.js +145 -20
- package/dist/lib/classes/PaintCanvas/index.d.ts +123 -27
- package/dist/lib/classes/PaintCanvas/index.js +208 -41
- package/dist/lib/classes/PaintCanvas/tool.d.ts +15 -0
- package/dist/lib/classes/PaintCanvas/tool.js +18 -0
- package/dist/lib/classes/Palette/index.d.ts +58 -0
- package/dist/lib/classes/Palette/index.js +92 -0
- package/dist/lib/classes/SettingsAutosave/index.d.ts +53 -0
- package/dist/lib/classes/SettingsAutosave/index.js +98 -0
- package/dist/lib/classes/ShortcutSettings/index.d.ts +63 -0
- package/dist/lib/classes/ShortcutSettings/index.js +110 -0
- package/dist/lib/classes/UiSettings/index.d.ts +68 -0
- package/dist/lib/classes/UiSettings/index.js +82 -0
- package/dist/lib/palette/index.d.ts +49 -0
- package/dist/lib/palette/index.js +82 -0
- package/dist/lib/palette/schema.d.ts +45 -0
- package/dist/lib/palette/schema.js +41 -0
- package/dist/lib/rendering/cursors/index.d.ts +2 -0
- package/dist/lib/rendering/cursors/index.js +3 -1
- package/dist/lib/rendering/sample/index.js +3 -2
- package/dist/lib/settings/index.d.ts +63 -0
- package/dist/lib/settings/index.js +93 -0
- package/dist/lib/settings/schema.d.ts +168 -0
- package/dist/lib/settings/schema.js +116 -0
- package/dist/lib/storage/index.d.ts +36 -5
- package/dist/lib/storage/index.js +87 -29
- package/dist/lib/utils/colour/index.d.ts +72 -0
- package/dist/lib/utils/colour/index.js +154 -0
- package/dist/lib/utils/shortcuts/index.d.ts +174 -11
- package/dist/lib/utils/shortcuts/index.js +391 -145
- package/dist/lib/validation/validators.generated.d.ts +5 -0
- package/dist/lib/validation/validators.generated.js +1040 -1
- package/dist/locales/en-GB.js +96 -3
- package/dist/locales/en-US.js +96 -3
- package/dist/locales/fr.js +96 -3
- package/dist/locales/ja.js +96 -3
- package/dist/locales/ko.js +96 -3
- package/dist/locales/zh-Hans.js +96 -3
- package/dist/locales/zh-Hant.js +96 -3
- package/dist/package.js +1 -1
- package/dist/testing/recordingCanvas.js +2 -1
- package/dist/ui/base/index.d.ts +2 -2
- package/dist/ui/dismiss/index.d.ts +21 -0
- package/dist/ui/dismiss/index.js +27 -0
- package/dist/ui/drag/index.d.ts +51 -0
- package/dist/ui/drag/index.js +81 -0
- package/dist/ui/elements/PaintCanvas/index.d.ts +57 -50
- package/dist/ui/elements/PaintCanvas/index.js +141 -174
- package/dist/ui/elements/PaintCanvas/style.js +1 -1
- package/dist/ui/elements/PcAppSettings/index.d.ts +59 -0
- package/dist/ui/elements/PcAppSettings/index.js +222 -0
- package/dist/ui/elements/PcBrushConfig/index.d.ts +9 -2
- package/dist/ui/elements/PcBrushConfig/index.js +47 -7
- package/dist/ui/elements/PcBrushConfig/style.js +1 -1
- package/dist/ui/elements/PcBrushSize/index.d.ts +53 -0
- package/dist/ui/elements/PcBrushSize/index.js +66 -0
- package/dist/ui/elements/PcBrushTest/index.d.ts +26 -0
- package/dist/ui/elements/PcBrushTest/index.js +73 -5
- package/dist/ui/elements/PcBrushTest/style.js +1 -1
- package/dist/ui/elements/PcCanvas/index.d.ts +22 -2
- package/dist/ui/elements/PcCanvas/index.js +60 -15
- package/dist/ui/elements/PcCanvasMap/style.js +1 -1
- package/dist/ui/elements/PcClipboardTools/index.d.ts +48 -0
- package/dist/ui/elements/PcClipboardTools/index.js +118 -0
- package/dist/ui/elements/PcColourPair/index.d.ts +43 -0
- package/dist/ui/elements/PcColourPair/index.js +125 -0
- package/dist/ui/elements/PcContextMenu/index.d.ts +71 -34
- package/dist/ui/elements/PcContextMenu/index.js +128 -97
- package/dist/ui/elements/PcInputSettings/index.d.ts +13 -0
- package/dist/ui/elements/PcInputSettings/index.js +16 -1
- package/dist/ui/elements/PcLayerItem/index.d.ts +13 -34
- package/dist/ui/elements/PcLayerItem/index.js +39 -91
- package/dist/ui/elements/PcLayerItem/style.js +1 -1
- package/dist/ui/elements/PcMenu/index.d.ts +138 -0
- package/dist/ui/elements/PcMenu/index.js +296 -0
- package/dist/ui/elements/PcNumberSlider/index.d.ts +137 -0
- package/dist/ui/elements/PcNumberSlider/index.js +247 -0
- package/dist/ui/elements/PcPane/index.d.ts +120 -0
- package/dist/ui/elements/PcPane/index.js +394 -0
- package/dist/ui/elements/PcPanel/index.d.ts +26 -8
- package/dist/ui/elements/PcPanel/index.js +76 -8
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.d.ts +22 -21
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.js +24 -57
- package/dist/ui/elements/PcPanelBrushes/style.js +3 -0
- package/dist/ui/elements/PcPanelColours/index.d.ts +171 -0
- package/dist/ui/elements/PcPanelColours/index.js +650 -0
- package/dist/ui/elements/PcPanelColours/style.js +3 -0
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.d.ts +17 -4
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.js +17 -10
- package/dist/ui/elements/PcPanelLayers/style.js +3 -0
- package/dist/ui/elements/PcPopover/index.d.ts +39 -1
- package/dist/ui/elements/PcPopover/index.js +72 -4
- package/dist/ui/elements/PcShortcutSettings/index.d.ts +69 -0
- package/dist/ui/elements/PcShortcutSettings/index.js +273 -0
- package/dist/ui/elements/PcThemePicker/index.d.ts +17 -15
- package/dist/ui/elements/PcThemePicker/index.js +22 -21
- package/dist/ui/elements/PcToolSettings/index.d.ts +48 -9
- package/dist/ui/elements/PcToolSettings/index.js +384 -319
- package/dist/ui/elements/PcToolSettings/style.js +1 -1
- package/dist/ui/elements/PcToolbar/index.d.ts +62 -12
- package/dist/ui/elements/PcToolbar/index.js +119 -57
- package/dist/ui/elements/PcToolbar/style.js +1 -1
- package/dist/ui/icons/images/icon-brush@2x.js +3 -0
- package/dist/ui/icons/images/icon-circle-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-clipboard@2x.js +3 -0
- package/dist/ui/icons/images/icon-cog@2x.js +3 -0
- package/dist/ui/icons/images/icon-cursor@2x.js +3 -0
- package/dist/ui/icons/images/icon-diagonal-tlbr-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-diagonal-trbl-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-eraser@2x.js +3 -0
- package/dist/ui/icons/images/icon-eyedropper@2x.js +3 -0
- package/dist/ui/icons/images/icon-flip-horizontal@2x.js +3 -0
- package/dist/ui/icons/images/icon-flip-vertical@2x.js +3 -0
- package/dist/ui/icons/images/icon-focus-pen@2x.js +3 -0
- package/dist/ui/icons/images/icon-freehand-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-hidden@2x.js +3 -0
- package/dist/ui/icons/images/icon-horizontal-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-layers@2x.js +3 -0
- package/dist/ui/icons/images/icon-linked@2x.js +3 -0
- package/dist/ui/icons/images/icon-locked@2x.js +3 -0
- package/dist/ui/icons/images/icon-moon@2x.js +3 -0
- package/dist/ui/icons/images/icon-pan@2x.js +3 -0
- package/dist/ui/icons/images/icon-polygon-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-pressure@2x.js +3 -0
- package/dist/ui/icons/images/icon-randomise@2x.js +3 -0
- package/dist/ui/icons/images/icon-rectangle-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-redo@2x.js +3 -0
- package/dist/ui/icons/images/icon-rotate-90-left@2x.js +3 -0
- package/dist/ui/icons/images/icon-rotate-90-right@2x.js +3 -0
- package/dist/ui/icons/images/icon-rotate@2x.js +3 -0
- package/dist/ui/icons/images/icon-smoothing-bezier-cubic@2x.js +3 -0
- package/dist/ui/icons/images/icon-smoothing-bezier-quad@2x.js +3 -0
- package/dist/ui/icons/images/icon-smoothing-linear@2x.js +3 -0
- package/dist/ui/icons/images/icon-star@2x.js +3 -0
- package/dist/ui/icons/images/icon-sun@2x.js +3 -0
- package/dist/ui/icons/images/icon-tilt@2x.js +3 -0
- package/dist/ui/icons/images/icon-undo@2x.js +3 -0
- package/dist/ui/icons/images/icon-unlinked@2x.js +3 -0
- package/dist/ui/icons/images/icon-unlocked@2x.js +3 -0
- package/dist/ui/icons/images/icon-vertical-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-visible@2x.js +3 -0
- package/dist/ui/icons/images/icon-zoom-in@2x.js +3 -0
- package/dist/ui/icons/images/icon-zoom-out@2x.js +3 -0
- package/dist/ui/icons/images/icon-zoom@2x.js +3 -0
- package/dist/ui/icons/index.d.ts +1 -1
- package/dist/ui/icons/index.js +84 -72
- package/dist/ui/index.d.ts +13 -2
- package/dist/ui/index.js +16 -4
- package/dist/ui/layout/index.d.ts +9 -1
- package/dist/ui/layout/index.js +11 -2
- package/dist/ui/tokens/index.d.ts +5 -4
- package/dist/ui/tokens/index.js +15 -8
- package/locales/en-GB.json +96 -3
- package/locales/en-US.json +96 -3
- package/locales/fr.json +96 -3
- package/locales/ja.json +96 -3
- package/locales/ko.json +96 -3
- package/locales/zh-Hans.json +96 -3
- package/locales/zh-Hant.json +96 -3
- package/package.json +11 -4
- package/dist/ui/elements/PcBrushMenu/style.js +0 -3
- package/dist/ui/elements/PcLayersMenu/style.js +0 -3
- package/dist/ui/icons/images/brush.js +0 -3
- package/dist/ui/icons/images/circle-mask.js +0 -3
- package/dist/ui/icons/images/clipboard.js +0 -3
- package/dist/ui/icons/images/cursor.js +0 -3
- package/dist/ui/icons/images/eraser.js +0 -3
- package/dist/ui/icons/images/eyedropper.js +0 -3
- package/dist/ui/icons/images/flip-horizontal.js +0 -3
- package/dist/ui/icons/images/flip-vertical.js +0 -3
- package/dist/ui/icons/images/focus-pen.js +0 -3
- package/dist/ui/icons/images/freehand-mask.js +0 -3
- package/dist/ui/icons/images/hidden.js +0 -3
- package/dist/ui/icons/images/layers.js +0 -3
- package/dist/ui/icons/images/linked.js +0 -3
- package/dist/ui/icons/images/locked.js +0 -3
- package/dist/ui/icons/images/moon.js +0 -3
- package/dist/ui/icons/images/pan.js +0 -3
- package/dist/ui/icons/images/polygon-mask.js +0 -3
- package/dist/ui/icons/images/pressure.js +0 -3
- package/dist/ui/icons/images/randomise.js +0 -3
- package/dist/ui/icons/images/rectangle-mask.js +0 -3
- package/dist/ui/icons/images/redo.js +0 -3
- package/dist/ui/icons/images/rotate-90-left.js +0 -3
- package/dist/ui/icons/images/rotate-90-right.js +0 -3
- package/dist/ui/icons/images/smoothing-bezier-cubic.js +0 -3
- package/dist/ui/icons/images/smoothing-bezier-quad.js +0 -3
- package/dist/ui/icons/images/smoothing-linear.js +0 -3
- package/dist/ui/icons/images/star.js +0 -3
- package/dist/ui/icons/images/sun.js +0 -3
- package/dist/ui/icons/images/tilt.js +0 -3
- package/dist/ui/icons/images/undo.js +0 -3
- package/dist/ui/icons/images/unlinked.js +0 -3
- package/dist/ui/icons/images/unlocked.js +0 -3
- package/dist/ui/icons/images/visible.js +0 -3
- package/dist/ui/icons/images/zoom-in.js +0 -3
- package/dist/ui/icons/images/zoom-out.js +0 -3
- package/dist/ui/icons/images/zoom.js +0 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type PaletteFile } from "./schema";
|
|
2
|
+
export * from "./schema";
|
|
3
|
+
/** The colours a palette starts with */
|
|
4
|
+
export declare const DEFAULT_PALETTE: readonly string[];
|
|
5
|
+
/** Messages shown when importing or exporting a palette fails */
|
|
6
|
+
export declare const PALETTE_FILE_ERRORS: {
|
|
7
|
+
readonly incompatible: "Colour palette JSON file not compatible";
|
|
8
|
+
readonly read: "Failed to read colour palette JSON file";
|
|
9
|
+
};
|
|
10
|
+
/** Importing a palette failed, with a message for the user */
|
|
11
|
+
export declare class PaletteFileError extends Error {
|
|
12
|
+
}
|
|
13
|
+
/** Result of checking a palette file */
|
|
14
|
+
export type PaletteValidationResult = {
|
|
15
|
+
valid: true;
|
|
16
|
+
value: PaletteFile;
|
|
17
|
+
} | {
|
|
18
|
+
valid: false;
|
|
19
|
+
errors: string[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Check a colour palette file against `paletteFileSchema`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* isValidPaletteFile({ format: "paintcanvas-palette", version: 1, colours: ["#ff0000"] }).valid; // true
|
|
26
|
+
*/
|
|
27
|
+
export declare const isValidPaletteFile: (input: unknown) => PaletteValidationResult;
|
|
28
|
+
/**
|
|
29
|
+
* The file name a palette is exported to on a day, starting with a prefix (see `PaintCanvasNames.filePrefix`).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* paletteFileName(new Date(2026, 10, 4)); // "paintcanvas-palette-2026-11-04.json"
|
|
33
|
+
*/
|
|
34
|
+
export declare const paletteFileName: (date?: Date, prefix?: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Write colours to a colour palette file (JSON) of a format (see `PaintCanvasNames.paletteFileFormat`).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* exportPaletteFile(["#ff0000"]); // '{ "format": "paintcanvas-palette", "version": 1, "colours": ["#ff0000"] }'
|
|
40
|
+
*/
|
|
41
|
+
export declare const exportPaletteFile: (colours: readonly string[], format?: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Read the colours (as lowercase `#rrggbb`) in a colour palette file of one of the given formats (PaintCanvas's by
|
|
44
|
+
* default). Throws a `PaletteFileError` if it isn't valid JSON or a compatible file.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* parsePaletteFile('{ "format": "paintcanvas-palette", "version": 1, "colours": ["#FF0000"] }'); // ["#ff0000"]
|
|
48
|
+
*/
|
|
49
|
+
export declare const parsePaletteFile: (text: string, formats?: readonly string[]) => string[];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { formatErrors } from "../presets/index.js";
|
|
2
|
+
import { validatePaletteFile } from "../validation/validators.generated.js";
|
|
3
|
+
import { HEX_COLOUR_PATTERN, MAX_PALETTE_COLOURS, MAX_PALETTE_FILE_FORMAT_LENGTH, PALETTE_FILE_FORMAT, PALETTE_FILE_FORMATS, PALETTE_FILE_VERSION, paletteFileSchema } from "./schema.js";
|
|
4
|
+
// src/lib/palette/index.ts
|
|
5
|
+
/** The colours a palette starts with */
|
|
6
|
+
var DEFAULT_PALETTE = [
|
|
7
|
+
"#2c6bff",
|
|
8
|
+
"#8f3de8",
|
|
9
|
+
"#f40f95",
|
|
10
|
+
"#fb234a",
|
|
11
|
+
"#fe7e07",
|
|
12
|
+
"#ffd52c",
|
|
13
|
+
"#6dc905",
|
|
14
|
+
"#21e887",
|
|
15
|
+
"#13c3f4",
|
|
16
|
+
"#000000",
|
|
17
|
+
"#333333",
|
|
18
|
+
"#666666",
|
|
19
|
+
"#999999",
|
|
20
|
+
"#cccccc",
|
|
21
|
+
"#ffffff"
|
|
22
|
+
];
|
|
23
|
+
/** Messages shown when importing or exporting a palette fails */
|
|
24
|
+
var PALETTE_FILE_ERRORS = {
|
|
25
|
+
incompatible: "Colour palette JSON file not compatible",
|
|
26
|
+
read: "Failed to read colour palette JSON file"
|
|
27
|
+
};
|
|
28
|
+
/** Importing a palette failed, with a message for the user */
|
|
29
|
+
var PaletteFileError = class extends Error {};
|
|
30
|
+
/**
|
|
31
|
+
* Check a colour palette file against `paletteFileSchema`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* isValidPaletteFile({ format: "paintcanvas-palette", version: 1, colours: ["#ff0000"] }).valid; // true
|
|
35
|
+
*/
|
|
36
|
+
var isValidPaletteFile = (input) => validatePaletteFile(input) ? {
|
|
37
|
+
valid: true,
|
|
38
|
+
value: input
|
|
39
|
+
} : {
|
|
40
|
+
valid: false,
|
|
41
|
+
errors: formatErrors(validatePaletteFile.errors)
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The file name a palette is exported to on a day, starting with a prefix (see `PaintCanvasNames.filePrefix`).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* paletteFileName(new Date(2026, 10, 4)); // "paintcanvas-palette-2026-11-04.json"
|
|
48
|
+
*/
|
|
49
|
+
var paletteFileName = (date = /* @__PURE__ */ new Date(), prefix = "paintcanvas") => {
|
|
50
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
51
|
+
return `${prefix}-palette-${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}.json`;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Write colours to a colour palette file (JSON) of a format (see `PaintCanvasNames.paletteFileFormat`).
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* exportPaletteFile(["#ff0000"]); // '{ "format": "paintcanvas-palette", "version": 1, "colours": ["#ff0000"] }'
|
|
58
|
+
*/
|
|
59
|
+
var exportPaletteFile = (colours, format = PALETTE_FILE_FORMAT) => JSON.stringify({
|
|
60
|
+
format,
|
|
61
|
+
version: 1,
|
|
62
|
+
colours
|
|
63
|
+
}, null, 2);
|
|
64
|
+
/**
|
|
65
|
+
* Read the colours (as lowercase `#rrggbb`) in a colour palette file of one of the given formats (PaintCanvas's by
|
|
66
|
+
* default). Throws a `PaletteFileError` if it isn't valid JSON or a compatible file.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* parsePaletteFile('{ "format": "paintcanvas-palette", "version": 1, "colours": ["#FF0000"] }'); // ["#ff0000"]
|
|
70
|
+
*/
|
|
71
|
+
var parsePaletteFile = (text, formats = PALETTE_FILE_FORMATS) => {
|
|
72
|
+
let data;
|
|
73
|
+
try {
|
|
74
|
+
data = JSON.parse(text);
|
|
75
|
+
} catch {
|
|
76
|
+
throw new PaletteFileError(PALETTE_FILE_ERRORS.incompatible);
|
|
77
|
+
}
|
|
78
|
+
const result = isValidPaletteFile(data);
|
|
79
|
+
if (!result.valid || !formats.includes(result.value.format)) throw new PaletteFileError(PALETTE_FILE_ERRORS.incompatible);
|
|
80
|
+
return result.value.colours.map((colour) => colour.toLowerCase());
|
|
81
|
+
};
|
|
82
|
+
export { DEFAULT_PALETTE, HEX_COLOUR_PATTERN, MAX_PALETTE_COLOURS, MAX_PALETTE_FILE_FORMAT_LENGTH, PALETTE_FILE_ERRORS, PALETTE_FILE_FORMAT, PALETTE_FILE_FORMATS, PALETTE_FILE_VERSION, PaletteFileError, exportPaletteFile, isValidPaletteFile, paletteFileName, paletteFileSchema, parsePaletteFile };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The `format` of a colour palette file, unless the implementer names their own (see `PaintCanvasNames`) */
|
|
2
|
+
export declare const PALETTE_FILE_FORMAT = "paintcanvas-palette";
|
|
3
|
+
/** Formats of colour palette files that are imported by default */
|
|
4
|
+
export declare const PALETTE_FILE_FORMATS: readonly string[];
|
|
5
|
+
/** The version of the colour palette file format */
|
|
6
|
+
export declare const PALETTE_FILE_VERSION = 1;
|
|
7
|
+
/** Most colours in a palette (and in one file) */
|
|
8
|
+
export declare const MAX_PALETTE_COLOURS = 1000;
|
|
9
|
+
/** Longest palette file format name (characters) */
|
|
10
|
+
export declare const MAX_PALETTE_FILE_FORMAT_LENGTH = 100;
|
|
11
|
+
/** Matches a `#rrggbb` colour in any case */
|
|
12
|
+
export declare const HEX_COLOUR_PATTERN = "^#[0-9a-fA-F]{6}$";
|
|
13
|
+
/** A colour palette file: what users export and import */
|
|
14
|
+
export interface PaletteFile {
|
|
15
|
+
/** Names the app or kind of file, e.g. `PALETTE_FILE_FORMAT` */
|
|
16
|
+
format: string;
|
|
17
|
+
version: typeof PALETTE_FILE_VERSION;
|
|
18
|
+
/** Colours as `#rrggbb`, in palette order */
|
|
19
|
+
colours: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Schema of a colour palette file */
|
|
22
|
+
export declare const paletteFileSchema: {
|
|
23
|
+
readonly $id: "paintcanvas/palette-file";
|
|
24
|
+
readonly type: "object";
|
|
25
|
+
readonly additionalProperties: false;
|
|
26
|
+
readonly required: readonly ["format", "version", "colours"];
|
|
27
|
+
readonly properties: {
|
|
28
|
+
readonly format: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly minLength: 1;
|
|
31
|
+
readonly maxLength: 100;
|
|
32
|
+
};
|
|
33
|
+
readonly version: {
|
|
34
|
+
readonly const: 1;
|
|
35
|
+
};
|
|
36
|
+
readonly colours: {
|
|
37
|
+
readonly type: "array";
|
|
38
|
+
readonly maxItems: 1000;
|
|
39
|
+
readonly items: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly pattern: "^#[0-9a-fA-F]{6}$";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/lib/palette/schema.ts
|
|
2
|
+
/** The `format` of a colour palette file, unless the implementer names their own (see `PaintCanvasNames`) */
|
|
3
|
+
var PALETTE_FILE_FORMAT = "paintcanvas-palette";
|
|
4
|
+
/** Formats of colour palette files that are imported by default */
|
|
5
|
+
var PALETTE_FILE_FORMATS = [PALETTE_FILE_FORMAT];
|
|
6
|
+
/** The version of the colour palette file format */
|
|
7
|
+
var PALETTE_FILE_VERSION = 1;
|
|
8
|
+
/** Most colours in a palette (and in one file) */
|
|
9
|
+
var MAX_PALETTE_COLOURS = 1e3;
|
|
10
|
+
/** Longest palette file format name (characters) */
|
|
11
|
+
var MAX_PALETTE_FILE_FORMAT_LENGTH = 100;
|
|
12
|
+
/** Matches a `#rrggbb` colour in any case */
|
|
13
|
+
var HEX_COLOUR_PATTERN = "^#[0-9a-fA-F]{6}$";
|
|
14
|
+
/** Schema of a colour palette file */
|
|
15
|
+
var paletteFileSchema = {
|
|
16
|
+
$id: "paintcanvas/palette-file",
|
|
17
|
+
type: "object",
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
required: [
|
|
20
|
+
"format",
|
|
21
|
+
"version",
|
|
22
|
+
"colours"
|
|
23
|
+
],
|
|
24
|
+
properties: {
|
|
25
|
+
format: {
|
|
26
|
+
type: "string",
|
|
27
|
+
minLength: 1,
|
|
28
|
+
maxLength: 100
|
|
29
|
+
},
|
|
30
|
+
version: { const: 1 },
|
|
31
|
+
colours: {
|
|
32
|
+
type: "array",
|
|
33
|
+
maxItems: MAX_PALETTE_COLOURS,
|
|
34
|
+
items: {
|
|
35
|
+
type: "string",
|
|
36
|
+
pattern: HEX_COLOUR_PATTERN
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export { HEX_COLOUR_PATTERN, MAX_PALETTE_COLOURS, MAX_PALETTE_FILE_FORMAT_LENGTH, PALETTE_FILE_FORMAT, PALETTE_FILE_FORMATS, PALETTE_FILE_VERSION, paletteFileSchema };
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* svgCursor("M4 4 L20 20", [4, 4], "crosshair"); // 'url("data:image/svg+xml,...") 4 4, crosshair'
|
|
9
9
|
*/
|
|
10
10
|
export declare const svgCursor: (path: string, hotspot: [number, number], fallback: string) => string;
|
|
11
|
+
/** Deleting: an "X", e.g. over a brush preset or saved colour that a click deletes (Alt/Option held); the point is its middle */
|
|
12
|
+
export declare const DELETE_CURSOR: string;
|
|
11
13
|
/** Colour sample (eyedropper): a pipette pointing down to the left; the point is at its tip */
|
|
12
14
|
export declare const EYEDROPPER_CURSOR: string;
|
|
13
15
|
/** Polygon lasso: a straight-edged loop with a tail; the point is at the tail's end */
|
|
@@ -12,6 +12,8 @@ var svgCursor = (path, hotspot, fallback) => {
|
|
|
12
12
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="${path}" stroke="#ffffff" stroke-width="3.5"/><path d="${path}" stroke="#000000" stroke-width="1.5"/></svg>`;
|
|
13
13
|
return `url("data:image/svg+xml,${encodeURIComponent(svg)}") ${hotspot[0]} ${hotspot[1]}, ${fallback}`;
|
|
14
14
|
};
|
|
15
|
+
/** Deleting: an "X", e.g. over a brush preset or saved colour that a click deletes (Alt/Option held); the point is its middle */
|
|
16
|
+
var DELETE_CURSOR = svgCursor("M6 6 L18 18 M18 6 L6 18", [12, 12], "not-allowed");
|
|
15
17
|
/** Colour sample (eyedropper): a pipette pointing down to the left; the point is at its tip */
|
|
16
18
|
var EYEDROPPER_CURSOR = svgCursor("M2 22 L3 18 L12 9 L15 12 L6 21 Z M10 7 L17 14 M14 10 L18 6 C19 5 20 4 21 5 C22 6 21 7 20 8 L16 12", [2, 22], "crosshair");
|
|
17
19
|
/** Polygon lasso: a straight-edged loop with a tail; the point is at the tail's end */
|
|
@@ -20,4 +22,4 @@ var POLYGON_LASSO_CURSOR = svgCursor("M3 21 L7 15 M7 15 L5 6 L13 2 L21 7 L17 15
|
|
|
20
22
|
var FREEFORM_LASSO_CURSOR = svgCursor("M3 21 C3 19 5 18 7 17 C7 17 5 16 4 14 C2 10 4 6 8 5 C11 4 12 6 15 4 C18 3 22 6 20 10 C19 13 21 15 18 16 C15 17 11 15 9 16 C8 16.5 7.5 17 7 17", [3, 21], "crosshair");
|
|
21
23
|
/** Rotate: the browser's grab cursor, as browsers have no standard rotate cursor */
|
|
22
24
|
var ROTATE_CURSOR = "grab";
|
|
23
|
-
export { EYEDROPPER_CURSOR, FREEFORM_LASSO_CURSOR, POLYGON_LASSO_CURSOR, ROTATE_CURSOR, svgCursor };
|
|
25
|
+
export { DELETE_CURSOR, EYEDROPPER_CURSOR, FREEFORM_LASSO_CURSOR, POLYGON_LASSO_CURSOR, ROTATE_CURSOR, svgCursor };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rgbToHex } from "../../utils/colour/index.js";
|
|
1
2
|
import { CANVAS_BACKGROUND, drawLayers } from "../compositing/index.js";
|
|
2
3
|
// src/lib/rendering/sample/index.ts
|
|
3
4
|
/** How many canvas pixels across the sampling window enlarges */
|
|
@@ -12,11 +13,11 @@ var PREVIEW_MAX_PIXELS = 100;
|
|
|
12
13
|
* @example
|
|
13
14
|
* toHex(255, 0, 128); // "#ff0080"
|
|
14
15
|
*/
|
|
15
|
-
var toHex = (r, g, b) =>
|
|
16
|
+
var toHex = (r, g, b) => rgbToHex({
|
|
16
17
|
r,
|
|
17
18
|
g,
|
|
18
19
|
b
|
|
19
|
-
|
|
20
|
+
});
|
|
20
21
|
/**
|
|
21
22
|
* The average colour of RGBA pixels, counting every pixel that isn't fully transparent (transparent pixels are outside
|
|
22
23
|
* the canvas). Undefined if all are transparent.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type PaintCanvas from "../classes/PaintCanvas";
|
|
2
|
+
import { type AppSettings } from "./schema";
|
|
3
|
+
export * from "./schema";
|
|
4
|
+
/** Messages shown when importing settings fails */
|
|
5
|
+
export declare const SETTINGS_FILE_ERRORS: {
|
|
6
|
+
readonly incompatible: "Settings JSON file not compatible";
|
|
7
|
+
readonly read: "Failed to read settings JSON file";
|
|
8
|
+
};
|
|
9
|
+
/** Importing settings failed, with a message for the user */
|
|
10
|
+
export declare class SettingsFileError extends Error {
|
|
11
|
+
}
|
|
12
|
+
/** Result of checking settings */
|
|
13
|
+
export type SettingsValidationResult = {
|
|
14
|
+
valid: true;
|
|
15
|
+
value: AppSettings;
|
|
16
|
+
} | {
|
|
17
|
+
valid: false;
|
|
18
|
+
errors: string[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Check app settings (e.g. kept in the browser) against `settingsSchema`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* isValidSettings({ palette: ["#ff0000"] }).valid; // true
|
|
25
|
+
*/
|
|
26
|
+
export declare const isValidSettings: (input: unknown) => SettingsValidationResult;
|
|
27
|
+
/**
|
|
28
|
+
* The app settings of a canvas: its input settings, keyboard shortcuts, colour palette, colours, theme and language.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* collectSettings(canvas).palette; // ["#2c6bff", ...]
|
|
32
|
+
*/
|
|
33
|
+
export declare const collectSettings: (app: PaintCanvas) => AppSettings;
|
|
34
|
+
/**
|
|
35
|
+
* Use app settings on a canvas, e.g. ones kept in the browser or imported. Parts left out stay as they are; invalid
|
|
36
|
+
* values within a part are left out (see each part's sanitising).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* applySettings(canvas, { colours: { foreground: "#ff0000", background: "#ffffff" } });
|
|
40
|
+
*/
|
|
41
|
+
export declare const applySettings: (app: PaintCanvas, settings: AppSettings) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The file name settings are exported to on a day, starting with a prefix (see `PaintCanvasNames.filePrefix`).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* settingsFileName(new Date(2026, 10, 4)); // "paintcanvas-settings-2026-11-04.json"
|
|
47
|
+
*/
|
|
48
|
+
export declare const settingsFileName: (date?: Date, prefix?: string) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Write app settings to a settings file (JSON) of a format (see `PaintCanvasNames.settingsFileFormat`).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* exportSettingsFile(collectSettings(canvas)); // '{ "format": "paintcanvas-settings", "version": 1, "settings": {...} }'
|
|
54
|
+
*/
|
|
55
|
+
export declare const exportSettingsFile: (settings: AppSettings, format?: string) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Read the app settings in a settings file of one of the given formats (PaintCanvas's by default). Throws a
|
|
58
|
+
* `SettingsFileError` if it isn't valid JSON or a compatible file.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* applySettings(canvas, parseSettingsFile(text));
|
|
62
|
+
*/
|
|
63
|
+
export declare const parseSettingsFile: (text: string, formats?: readonly string[]) => AppSettings;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { formatErrors } from "../presets/index.js";
|
|
2
|
+
import { validateSettings, validateSettingsFile } from "../validation/validators.generated.js";
|
|
3
|
+
import { MAX_SAVED_SHORTCUTS, MAX_SETTINGS_FILE_FORMAT_LENGTH, SETTINGS_FILE_FORMAT, SETTINGS_FILE_FORMATS, SETTINGS_FILE_VERSION, keyComboSchema, settingsFileSchema, settingsSchema } from "./schema.js";
|
|
4
|
+
// src/lib/settings/index.ts
|
|
5
|
+
/** Messages shown when importing settings fails */
|
|
6
|
+
var SETTINGS_FILE_ERRORS = {
|
|
7
|
+
incompatible: "Settings JSON file not compatible",
|
|
8
|
+
read: "Failed to read settings JSON file"
|
|
9
|
+
};
|
|
10
|
+
/** Importing settings failed, with a message for the user */
|
|
11
|
+
var SettingsFileError = class extends Error {};
|
|
12
|
+
/**
|
|
13
|
+
* Check app settings (e.g. kept in the browser) against `settingsSchema`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* isValidSettings({ palette: ["#ff0000"] }).valid; // true
|
|
17
|
+
*/
|
|
18
|
+
var isValidSettings = (input) => validateSettings(input) ? {
|
|
19
|
+
valid: true,
|
|
20
|
+
value: input
|
|
21
|
+
} : {
|
|
22
|
+
valid: false,
|
|
23
|
+
errors: formatErrors(validateSettings.errors)
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The app settings of a canvas: its input settings, keyboard shortcuts, colour palette, colours, theme and language.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* collectSettings(canvas).palette; // ["#2c6bff", ...]
|
|
30
|
+
*/
|
|
31
|
+
var collectSettings = (app) => ({
|
|
32
|
+
input: structuredClone(app.input.data),
|
|
33
|
+
shortcuts: structuredClone(app.shortcuts.bindings),
|
|
34
|
+
palette: [...app.palette.colours],
|
|
35
|
+
colours: { ...app.colours },
|
|
36
|
+
ui: { ...app.ui.data }
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Use app settings on a canvas, e.g. ones kept in the browser or imported. Parts left out stay as they are; invalid
|
|
40
|
+
* values within a part are left out (see each part's sanitising).
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* applySettings(canvas, { colours: { foreground: "#ff0000", background: "#ffffff" } });
|
|
44
|
+
*/
|
|
45
|
+
var applySettings = (app, settings) => {
|
|
46
|
+
if (settings.input) app.input.update(settings.input);
|
|
47
|
+
if (settings.shortcuts) app.shortcuts.load(settings.shortcuts);
|
|
48
|
+
if (settings.palette) app.palette.set(settings.palette);
|
|
49
|
+
if (settings.colours) {
|
|
50
|
+
app.setColour(settings.colours.foreground, "foreground");
|
|
51
|
+
app.setColour(settings.colours.background, "background");
|
|
52
|
+
}
|
|
53
|
+
if (settings.ui) app.ui.update(settings.ui);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The file name settings are exported to on a day, starting with a prefix (see `PaintCanvasNames.filePrefix`).
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* settingsFileName(new Date(2026, 10, 4)); // "paintcanvas-settings-2026-11-04.json"
|
|
60
|
+
*/
|
|
61
|
+
var settingsFileName = (date = /* @__PURE__ */ new Date(), prefix = "paintcanvas") => {
|
|
62
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
63
|
+
return `${prefix}-settings-${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}.json`;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Write app settings to a settings file (JSON) of a format (see `PaintCanvasNames.settingsFileFormat`).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* exportSettingsFile(collectSettings(canvas)); // '{ "format": "paintcanvas-settings", "version": 1, "settings": {...} }'
|
|
70
|
+
*/
|
|
71
|
+
var exportSettingsFile = (settings, format = SETTINGS_FILE_FORMAT) => JSON.stringify({
|
|
72
|
+
format,
|
|
73
|
+
version: 1,
|
|
74
|
+
settings
|
|
75
|
+
}, null, 2);
|
|
76
|
+
/**
|
|
77
|
+
* Read the app settings in a settings file of one of the given formats (PaintCanvas's by default). Throws a
|
|
78
|
+
* `SettingsFileError` if it isn't valid JSON or a compatible file.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* applySettings(canvas, parseSettingsFile(text));
|
|
82
|
+
*/
|
|
83
|
+
var parseSettingsFile = (text, formats = SETTINGS_FILE_FORMATS) => {
|
|
84
|
+
let data;
|
|
85
|
+
try {
|
|
86
|
+
data = JSON.parse(text);
|
|
87
|
+
} catch {
|
|
88
|
+
throw new SettingsFileError(SETTINGS_FILE_ERRORS.incompatible);
|
|
89
|
+
}
|
|
90
|
+
if (!validateSettingsFile(data) || !formats.includes(data.format)) throw new SettingsFileError(SETTINGS_FILE_ERRORS.incompatible);
|
|
91
|
+
return data.settings;
|
|
92
|
+
};
|
|
93
|
+
export { MAX_SAVED_SHORTCUTS, MAX_SETTINGS_FILE_FORMAT_LENGTH, SETTINGS_FILE_ERRORS, SETTINGS_FILE_FORMAT, SETTINGS_FILE_FORMATS, SETTINGS_FILE_VERSION, SettingsFileError, applySettings, collectSettings, exportSettingsFile, isValidSettings, keyComboSchema, parseSettingsFile, settingsFileName, settingsFileSchema, settingsSchema };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { InputSettingsData } from "../classes/InputSettings";
|
|
2
|
+
import { type UiSettingsData } from "../classes/UiSettings/index.ts";
|
|
3
|
+
import type { KeyCombo } from "../utils/shortcuts";
|
|
4
|
+
/** The `format` of a settings file, unless the implementer names their own (see `PaintCanvasNames`) */
|
|
5
|
+
export declare const SETTINGS_FILE_FORMAT = "paintcanvas-settings";
|
|
6
|
+
/** Formats of settings files that are imported by default */
|
|
7
|
+
export declare const SETTINGS_FILE_FORMATS: readonly string[];
|
|
8
|
+
/** The version of the settings file format */
|
|
9
|
+
export declare const SETTINGS_FILE_VERSION = 1;
|
|
10
|
+
/** Longest settings file format name (characters) */
|
|
11
|
+
export declare const MAX_SETTINGS_FILE_FORMAT_LENGTH = 100;
|
|
12
|
+
/** Most keyboard shortcuts in saved settings */
|
|
13
|
+
export declare const MAX_SAVED_SHORTCUTS = 200;
|
|
14
|
+
/** The user's app settings. Each part is optional, so a file can hold only some of them. */
|
|
15
|
+
export interface AppSettings {
|
|
16
|
+
/** How input devices control the canvas */
|
|
17
|
+
input?: Partial<InputSettingsData>;
|
|
18
|
+
/** Each configurable keyboard shortcut action's key combination, by ID (null when it has none) */
|
|
19
|
+
shortcuts?: Record<string, KeyCombo | null>;
|
|
20
|
+
/** The colour palette's colours, as `#rrggbb` */
|
|
21
|
+
palette?: string[];
|
|
22
|
+
/** The foreground and background colours, as `#rrggbb` */
|
|
23
|
+
colours?: {
|
|
24
|
+
foreground: string;
|
|
25
|
+
background: string;
|
|
26
|
+
};
|
|
27
|
+
/** The theme and language */
|
|
28
|
+
ui?: Partial<UiSettingsData>;
|
|
29
|
+
}
|
|
30
|
+
/** A settings file: what users export and import */
|
|
31
|
+
export interface SettingsFile {
|
|
32
|
+
/** Names the app or kind of file, e.g. `SETTINGS_FILE_FORMAT` */
|
|
33
|
+
format: string;
|
|
34
|
+
version: typeof SETTINGS_FILE_VERSION;
|
|
35
|
+
settings: AppSettings;
|
|
36
|
+
}
|
|
37
|
+
/** Schema of a key combination */
|
|
38
|
+
export declare const keyComboSchema: {
|
|
39
|
+
readonly $id: "paintcanvas/key-combo";
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
readonly additionalProperties: false;
|
|
42
|
+
readonly required: readonly ["key"];
|
|
43
|
+
readonly properties: {
|
|
44
|
+
readonly key: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly minLength: 1;
|
|
47
|
+
readonly maxLength: 32;
|
|
48
|
+
};
|
|
49
|
+
readonly cmd: {
|
|
50
|
+
readonly type: "boolean";
|
|
51
|
+
};
|
|
52
|
+
readonly ctrl: {
|
|
53
|
+
readonly type: "boolean";
|
|
54
|
+
};
|
|
55
|
+
readonly shift: {
|
|
56
|
+
readonly type: "boolean";
|
|
57
|
+
};
|
|
58
|
+
readonly alt: {
|
|
59
|
+
readonly type: "boolean";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/** Schema of the user's app settings */
|
|
64
|
+
export declare const settingsSchema: {
|
|
65
|
+
readonly $id: "paintcanvas/settings";
|
|
66
|
+
readonly type: "object";
|
|
67
|
+
readonly additionalProperties: false;
|
|
68
|
+
readonly properties: {
|
|
69
|
+
readonly input: {
|
|
70
|
+
readonly type: "object";
|
|
71
|
+
readonly additionalProperties: false;
|
|
72
|
+
readonly properties: {
|
|
73
|
+
readonly scrollPan: {
|
|
74
|
+
readonly type: "boolean";
|
|
75
|
+
};
|
|
76
|
+
readonly pinchZoom: {
|
|
77
|
+
readonly type: "boolean";
|
|
78
|
+
};
|
|
79
|
+
readonly modifierScrollZoom: {
|
|
80
|
+
readonly type: "boolean";
|
|
81
|
+
};
|
|
82
|
+
readonly focusPen: {
|
|
83
|
+
readonly type: "boolean";
|
|
84
|
+
};
|
|
85
|
+
readonly gestures: {
|
|
86
|
+
readonly type: "object";
|
|
87
|
+
readonly maxProperties: 20;
|
|
88
|
+
readonly additionalProperties: {
|
|
89
|
+
readonly type: "string";
|
|
90
|
+
readonly maxLength: 50;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
readonly shortcuts: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly maxProperties: 200;
|
|
98
|
+
readonly propertyNames: {
|
|
99
|
+
readonly maxLength: 64;
|
|
100
|
+
};
|
|
101
|
+
readonly additionalProperties: {
|
|
102
|
+
readonly anyOf: readonly [{
|
|
103
|
+
readonly type: "null";
|
|
104
|
+
}, {
|
|
105
|
+
readonly $ref: "key-combo";
|
|
106
|
+
}];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
readonly palette: {
|
|
110
|
+
readonly type: "array";
|
|
111
|
+
readonly maxItems: 1000;
|
|
112
|
+
readonly items: {
|
|
113
|
+
readonly type: "string";
|
|
114
|
+
readonly pattern: "^#[0-9a-fA-F]{6}$";
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
readonly colours: {
|
|
118
|
+
readonly type: "object";
|
|
119
|
+
readonly additionalProperties: false;
|
|
120
|
+
readonly required: readonly ["foreground", "background"];
|
|
121
|
+
readonly properties: {
|
|
122
|
+
readonly foreground: {
|
|
123
|
+
readonly type: "string";
|
|
124
|
+
readonly pattern: "^#[0-9a-fA-F]{6}$";
|
|
125
|
+
};
|
|
126
|
+
readonly background: {
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
readonly pattern: "^#[0-9a-fA-F]{6}$";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
readonly ui: {
|
|
133
|
+
readonly type: "object";
|
|
134
|
+
readonly additionalProperties: false;
|
|
135
|
+
readonly properties: {
|
|
136
|
+
readonly theme: {
|
|
137
|
+
readonly enum: readonly ["light", "dark", "system"];
|
|
138
|
+
};
|
|
139
|
+
readonly locale: {
|
|
140
|
+
readonly type: "string";
|
|
141
|
+
readonly minLength: 1;
|
|
142
|
+
readonly maxLength: 35;
|
|
143
|
+
readonly pattern: "^[A-Za-z0-9-]+$";
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
/** Schema of a settings file */
|
|
150
|
+
export declare const settingsFileSchema: {
|
|
151
|
+
readonly $id: "paintcanvas/settings-file";
|
|
152
|
+
readonly type: "object";
|
|
153
|
+
readonly additionalProperties: false;
|
|
154
|
+
readonly required: readonly ["format", "version", "settings"];
|
|
155
|
+
readonly properties: {
|
|
156
|
+
readonly format: {
|
|
157
|
+
readonly type: "string";
|
|
158
|
+
readonly minLength: 1;
|
|
159
|
+
readonly maxLength: 100;
|
|
160
|
+
};
|
|
161
|
+
readonly version: {
|
|
162
|
+
readonly const: 1;
|
|
163
|
+
};
|
|
164
|
+
readonly settings: {
|
|
165
|
+
readonly $ref: "settings";
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
};
|