@lvl99dotcom/paintcanvas 0.7.0 → 0.8.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.
Files changed (89) hide show
  1. package/README.md +1 -0
  2. package/dist/lib/assets/index.d.ts +92 -0
  3. package/dist/lib/assets/index.js +106 -0
  4. package/dist/lib/assets/schema.d.ts +151 -0
  5. package/dist/lib/assets/schema.js +76 -0
  6. package/dist/lib/brushes/presetFile/index.d.ts +6 -27
  7. package/dist/lib/brushes/presetFile/index.js +34 -47
  8. package/dist/lib/brushes/types/index.d.ts +2 -11
  9. package/dist/lib/classes/AssetSync/index.d.ts +45 -0
  10. package/dist/lib/classes/AssetSync/index.js +80 -0
  11. package/dist/lib/classes/ColourPalettes/index.d.ts +83 -0
  12. package/dist/lib/classes/ColourPalettes/index.js +165 -0
  13. package/dist/lib/classes/CustomPresets/index.d.ts +14 -15
  14. package/dist/lib/classes/CustomPresets/index.js +25 -10
  15. package/dist/lib/classes/LayerAutosave/index.d.ts +9 -2
  16. package/dist/lib/classes/LayerAutosave/index.js +16 -6
  17. package/dist/lib/classes/PaintCanvas/index.d.ts +111 -23
  18. package/dist/lib/classes/PaintCanvas/index.js +219 -58
  19. package/dist/lib/classes/Palette/index.d.ts +3 -2
  20. package/dist/lib/classes/Palette/index.js +3 -2
  21. package/dist/lib/classes/ProfileGraphs/index.d.ts +13 -2
  22. package/dist/lib/classes/ProfileGraphs/index.js +22 -2
  23. package/dist/lib/classes/RemoteDocumentAutosave/index.d.ts +73 -0
  24. package/dist/lib/classes/RemoteDocumentAutosave/index.js +119 -0
  25. package/dist/lib/classes/SettingsAutosave/index.d.ts +7 -3
  26. package/dist/lib/classes/SettingsAutosave/index.js +28 -7
  27. package/dist/lib/classes/SettingsExtensions/index.d.ts +67 -0
  28. package/dist/lib/classes/SettingsExtensions/index.js +88 -0
  29. package/dist/lib/document/index.d.ts +61 -4
  30. package/dist/lib/document/index.js +173 -4
  31. package/dist/lib/document/schema.d.ts +154 -39
  32. package/dist/lib/document/schema.js +91 -25
  33. package/dist/lib/messages/schema.d.ts +176 -74
  34. package/dist/lib/messages/schema.js +2 -1
  35. package/dist/lib/palette/index.d.ts +8 -42
  36. package/dist/lib/palette/index.js +26 -59
  37. package/dist/lib/palette/schema.d.ts +111 -22
  38. package/dist/lib/palette/schema.js +51 -26
  39. package/dist/lib/presets/index.d.ts +1 -9
  40. package/dist/lib/presets/index.js +4 -10
  41. package/dist/lib/presets/schema.d.ts +118 -73
  42. package/dist/lib/presets/schema.js +28 -60
  43. package/dist/lib/profiles/profileFile/index.d.ts +10 -0
  44. package/dist/lib/profiles/profileFile/index.js +19 -0
  45. package/dist/lib/profiles/schema.d.ts +96 -3
  46. package/dist/lib/profiles/schema.js +31 -7
  47. package/dist/lib/schemas/index.d.ts +42 -0
  48. package/dist/lib/schemas/index.js +60 -0
  49. package/dist/lib/settings/index.d.ts +37 -22
  50. package/dist/lib/settings/index.js +78 -37
  51. package/dist/lib/settings/schema.d.ts +198 -76
  52. package/dist/lib/settings/schema.js +92 -86
  53. package/dist/lib/storage/index.d.ts +82 -3
  54. package/dist/lib/storage/index.js +82 -5
  55. package/dist/lib/validation/validators.generated.d.ts +19 -8
  56. package/dist/lib/validation/validators.generated.js +44716 -18900
  57. package/dist/lib/version/index.js +1 -1
  58. package/dist/locales/en-GB.js +23 -5
  59. package/dist/locales/en-US.js +23 -5
  60. package/dist/locales/fr.js +23 -5
  61. package/dist/locales/ja.js +23 -5
  62. package/dist/locales/ko.js +23 -5
  63. package/dist/locales/zh-Hans.js +23 -5
  64. package/dist/locales/zh-Hant.js +23 -5
  65. package/dist/package.js +1 -1
  66. package/dist/testing/app.d.ts +6 -2
  67. package/dist/testing/app.js +7 -2
  68. package/dist/testing/documentStore.d.ts +26 -0
  69. package/dist/testing/documentStore.js +31 -0
  70. package/dist/ui/elements/PaintCanvas/index.d.ts +6 -2
  71. package/dist/ui/elements/PaintCanvas/index.js +20 -6
  72. package/dist/ui/elements/PcAppSettings/index.d.ts +5 -6
  73. package/dist/ui/elements/PcAppSettings/index.js +17 -27
  74. package/dist/ui/elements/PcPanelBrushes/index.d.ts +1 -1
  75. package/dist/ui/elements/PcPanelBrushes/index.js +22 -28
  76. package/dist/ui/elements/PcPanelBrushes/style.js +1 -1
  77. package/dist/ui/elements/PcPanelColours/index.d.ts +56 -19
  78. package/dist/ui/elements/PcPanelColours/index.js +251 -104
  79. package/dist/ui/elements/PcPanelColours/style.js +1 -1
  80. package/dist/ui/elements/PcStats/index.d.ts +8 -4
  81. package/dist/ui/elements/PcStats/index.js +39 -5
  82. package/locales/en-GB.json +23 -5
  83. package/locales/en-US.json +23 -5
  84. package/locales/fr.json +23 -5
  85. package/locales/ja.json +23 -5
  86. package/locales/ko.json +23 -5
  87. package/locales/zh-Hans.json +23 -5
  88. package/locales/zh-Hant.json +23 -5
  89. package/package.json +2 -1
@@ -80,6 +80,14 @@ export declare const strokePresetSchema: {
80
80
  readonly minLength: 1;
81
81
  readonly maxLength: 100;
82
82
  };
83
+ readonly $schema: {
84
+ readonly type: "string";
85
+ readonly minLength: 1;
86
+ readonly maxLength: 2048;
87
+ };
88
+ readonly "@type": {
89
+ readonly const: "PaintCanvas/BrushConfig";
90
+ };
83
91
  readonly name: {
84
92
  readonly type: "string";
85
93
  readonly minLength: 1;
@@ -104,6 +112,11 @@ export declare const strokePresetSchema: {
104
112
  readonly additionalProperties: false;
105
113
  readonly required: readonly ["name"];
106
114
  readonly properties: {
115
+ readonly did: {
116
+ readonly type: "string";
117
+ readonly maxLength: 2048;
118
+ readonly pattern: "^did:[a-z]+:[a-zA-Z0-9._:%-]+$";
119
+ };
107
120
  readonly name: {
108
121
  readonly type: "string";
109
122
  readonly minLength: 1;
@@ -118,7 +131,7 @@ export declare const strokePresetSchema: {
118
131
  readonly type: "string";
119
132
  readonly maxLength: 254;
120
133
  };
121
- readonly website: {
134
+ readonly homepage: {
122
135
  readonly type: "string";
123
136
  readonly maxLength: 2048;
124
137
  };
@@ -210,9 +223,12 @@ export declare const strokePresetSchema: {
210
223
  };
211
224
  };
212
225
  readonly profileId: {
213
- readonly type: "string";
214
- readonly minLength: 1;
215
- readonly maxLength: 100;
226
+ readonly anyOf: readonly [{
227
+ readonly type: "string";
228
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
229
+ }, {
230
+ readonly enum: string[];
231
+ }];
216
232
  };
217
233
  };
218
234
  };
@@ -293,9 +309,12 @@ export declare const strokePresetSchema: {
293
309
  };
294
310
  };
295
311
  readonly profileId: {
296
- readonly type: "string";
297
- readonly minLength: 1;
298
- readonly maxLength: 100;
312
+ readonly anyOf: readonly [{
313
+ readonly type: "string";
314
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
315
+ }, {
316
+ readonly enum: string[];
317
+ }];
299
318
  };
300
319
  };
301
320
  };
@@ -376,9 +395,12 @@ export declare const strokePresetSchema: {
376
395
  };
377
396
  };
378
397
  readonly profileId: {
379
- readonly type: "string";
380
- readonly minLength: 1;
381
- readonly maxLength: 100;
398
+ readonly anyOf: readonly [{
399
+ readonly type: "string";
400
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
401
+ }, {
402
+ readonly enum: string[];
403
+ }];
382
404
  };
383
405
  };
384
406
  };
@@ -459,9 +481,12 @@ export declare const strokePresetSchema: {
459
481
  };
460
482
  };
461
483
  readonly profileId: {
462
- readonly type: "string";
463
- readonly minLength: 1;
464
- readonly maxLength: 100;
484
+ readonly anyOf: readonly [{
485
+ readonly type: "string";
486
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
487
+ }, {
488
+ readonly enum: string[];
489
+ }];
465
490
  };
466
491
  };
467
492
  };
@@ -542,9 +567,12 @@ export declare const strokePresetSchema: {
542
567
  };
543
568
  };
544
569
  readonly profileId: {
545
- readonly type: "string";
546
- readonly minLength: 1;
547
- readonly maxLength: 100;
570
+ readonly anyOf: readonly [{
571
+ readonly type: "string";
572
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
573
+ }, {
574
+ readonly enum: string[];
575
+ }];
548
576
  };
549
577
  };
550
578
  };
@@ -625,9 +653,12 @@ export declare const strokePresetSchema: {
625
653
  };
626
654
  };
627
655
  readonly profileId: {
628
- readonly type: "string";
629
- readonly minLength: 1;
630
- readonly maxLength: 100;
656
+ readonly anyOf: readonly [{
657
+ readonly type: "string";
658
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
659
+ }, {
660
+ readonly enum: string[];
661
+ }];
631
662
  };
632
663
  };
633
664
  };
@@ -705,9 +736,12 @@ export declare const strokePresetSchema: {
705
736
  };
706
737
  };
707
738
  readonly profileId: {
708
- readonly type: "string";
709
- readonly minLength: 1;
710
- readonly maxLength: 100;
739
+ readonly anyOf: readonly [{
740
+ readonly type: "string";
741
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
742
+ }, {
743
+ readonly enum: string[];
744
+ }];
711
745
  };
712
746
  };
713
747
  };
@@ -785,9 +819,12 @@ export declare const strokePresetSchema: {
785
819
  };
786
820
  };
787
821
  readonly profileId: {
788
- readonly type: "string";
789
- readonly minLength: 1;
790
- readonly maxLength: 100;
822
+ readonly anyOf: readonly [{
823
+ readonly type: "string";
824
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
825
+ }, {
826
+ readonly enum: string[];
827
+ }];
791
828
  };
792
829
  };
793
830
  };
@@ -865,9 +902,12 @@ export declare const strokePresetSchema: {
865
902
  };
866
903
  };
867
904
  readonly profileId: {
868
- readonly type: "string";
869
- readonly minLength: 1;
870
- readonly maxLength: 100;
905
+ readonly anyOf: readonly [{
906
+ readonly type: "string";
907
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
908
+ }, {
909
+ readonly enum: string[];
910
+ }];
871
911
  };
872
912
  };
873
913
  };
@@ -948,9 +988,12 @@ export declare const strokePresetSchema: {
948
988
  };
949
989
  };
950
990
  readonly profileId: {
951
- readonly type: "string";
952
- readonly minLength: 1;
953
- readonly maxLength: 100;
991
+ readonly anyOf: readonly [{
992
+ readonly type: "string";
993
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
994
+ }, {
995
+ readonly enum: string[];
996
+ }];
954
997
  };
955
998
  };
956
999
  };
@@ -1028,9 +1071,12 @@ export declare const strokePresetSchema: {
1028
1071
  };
1029
1072
  };
1030
1073
  readonly profileId: {
1031
- readonly type: "string";
1032
- readonly minLength: 1;
1033
- readonly maxLength: 100;
1074
+ readonly anyOf: readonly [{
1075
+ readonly type: "string";
1076
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1077
+ }, {
1078
+ readonly enum: string[];
1079
+ }];
1034
1080
  };
1035
1081
  };
1036
1082
  };
@@ -1108,9 +1154,12 @@ export declare const strokePresetSchema: {
1108
1154
  };
1109
1155
  };
1110
1156
  readonly profileId: {
1111
- readonly type: "string";
1112
- readonly minLength: 1;
1113
- readonly maxLength: 100;
1157
+ readonly anyOf: readonly [{
1158
+ readonly type: "string";
1159
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1160
+ }, {
1161
+ readonly enum: string[];
1162
+ }];
1114
1163
  };
1115
1164
  };
1116
1165
  };
@@ -1131,6 +1180,8 @@ export declare const strokePresetSchema: {
1131
1180
  readonly type: "boolean";
1132
1181
  };
1133
1182
  };
1183
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
1184
+ readonly "@type": "PaintCanvas/BrushConfig";
1134
1185
  readonly type: "object";
1135
1186
  readonly additionalProperties: false;
1136
1187
  readonly required: readonly ["id"];
@@ -1293,6 +1344,14 @@ export declare const messageSchemas: readonly [{
1293
1344
  readonly minLength: 1;
1294
1345
  readonly maxLength: 100;
1295
1346
  };
1347
+ readonly $schema: {
1348
+ readonly type: "string";
1349
+ readonly minLength: 1;
1350
+ readonly maxLength: 2048;
1351
+ };
1352
+ readonly "@type": {
1353
+ readonly const: "PaintCanvas/BrushConfig";
1354
+ };
1296
1355
  readonly name: {
1297
1356
  readonly type: "string";
1298
1357
  readonly minLength: 1;
@@ -1317,6 +1376,11 @@ export declare const messageSchemas: readonly [{
1317
1376
  readonly additionalProperties: false;
1318
1377
  readonly required: readonly ["name"];
1319
1378
  readonly properties: {
1379
+ readonly did: {
1380
+ readonly type: "string";
1381
+ readonly maxLength: 2048;
1382
+ readonly pattern: "^did:[a-z]+:[a-zA-Z0-9._:%-]+$";
1383
+ };
1320
1384
  readonly name: {
1321
1385
  readonly type: "string";
1322
1386
  readonly minLength: 1;
@@ -1331,7 +1395,7 @@ export declare const messageSchemas: readonly [{
1331
1395
  readonly type: "string";
1332
1396
  readonly maxLength: 254;
1333
1397
  };
1334
- readonly website: {
1398
+ readonly homepage: {
1335
1399
  readonly type: "string";
1336
1400
  readonly maxLength: 2048;
1337
1401
  };
@@ -1423,9 +1487,12 @@ export declare const messageSchemas: readonly [{
1423
1487
  };
1424
1488
  };
1425
1489
  readonly profileId: {
1426
- readonly type: "string";
1427
- readonly minLength: 1;
1428
- readonly maxLength: 100;
1490
+ readonly anyOf: readonly [{
1491
+ readonly type: "string";
1492
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1493
+ }, {
1494
+ readonly enum: string[];
1495
+ }];
1429
1496
  };
1430
1497
  };
1431
1498
  };
@@ -1506,9 +1573,12 @@ export declare const messageSchemas: readonly [{
1506
1573
  };
1507
1574
  };
1508
1575
  readonly profileId: {
1509
- readonly type: "string";
1510
- readonly minLength: 1;
1511
- readonly maxLength: 100;
1576
+ readonly anyOf: readonly [{
1577
+ readonly type: "string";
1578
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1579
+ }, {
1580
+ readonly enum: string[];
1581
+ }];
1512
1582
  };
1513
1583
  };
1514
1584
  };
@@ -1589,9 +1659,12 @@ export declare const messageSchemas: readonly [{
1589
1659
  };
1590
1660
  };
1591
1661
  readonly profileId: {
1592
- readonly type: "string";
1593
- readonly minLength: 1;
1594
- readonly maxLength: 100;
1662
+ readonly anyOf: readonly [{
1663
+ readonly type: "string";
1664
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1665
+ }, {
1666
+ readonly enum: string[];
1667
+ }];
1595
1668
  };
1596
1669
  };
1597
1670
  };
@@ -1672,9 +1745,12 @@ export declare const messageSchemas: readonly [{
1672
1745
  };
1673
1746
  };
1674
1747
  readonly profileId: {
1675
- readonly type: "string";
1676
- readonly minLength: 1;
1677
- readonly maxLength: 100;
1748
+ readonly anyOf: readonly [{
1749
+ readonly type: "string";
1750
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1751
+ }, {
1752
+ readonly enum: string[];
1753
+ }];
1678
1754
  };
1679
1755
  };
1680
1756
  };
@@ -1755,9 +1831,12 @@ export declare const messageSchemas: readonly [{
1755
1831
  };
1756
1832
  };
1757
1833
  readonly profileId: {
1758
- readonly type: "string";
1759
- readonly minLength: 1;
1760
- readonly maxLength: 100;
1834
+ readonly anyOf: readonly [{
1835
+ readonly type: "string";
1836
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1837
+ }, {
1838
+ readonly enum: string[];
1839
+ }];
1761
1840
  };
1762
1841
  };
1763
1842
  };
@@ -1838,9 +1917,12 @@ export declare const messageSchemas: readonly [{
1838
1917
  };
1839
1918
  };
1840
1919
  readonly profileId: {
1841
- readonly type: "string";
1842
- readonly minLength: 1;
1843
- readonly maxLength: 100;
1920
+ readonly anyOf: readonly [{
1921
+ readonly type: "string";
1922
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
1923
+ }, {
1924
+ readonly enum: string[];
1925
+ }];
1844
1926
  };
1845
1927
  };
1846
1928
  };
@@ -1918,9 +2000,12 @@ export declare const messageSchemas: readonly [{
1918
2000
  };
1919
2001
  };
1920
2002
  readonly profileId: {
1921
- readonly type: "string";
1922
- readonly minLength: 1;
1923
- readonly maxLength: 100;
2003
+ readonly anyOf: readonly [{
2004
+ readonly type: "string";
2005
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
2006
+ }, {
2007
+ readonly enum: string[];
2008
+ }];
1924
2009
  };
1925
2010
  };
1926
2011
  };
@@ -1998,9 +2083,12 @@ export declare const messageSchemas: readonly [{
1998
2083
  };
1999
2084
  };
2000
2085
  readonly profileId: {
2001
- readonly type: "string";
2002
- readonly minLength: 1;
2003
- readonly maxLength: 100;
2086
+ readonly anyOf: readonly [{
2087
+ readonly type: "string";
2088
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
2089
+ }, {
2090
+ readonly enum: string[];
2091
+ }];
2004
2092
  };
2005
2093
  };
2006
2094
  };
@@ -2078,9 +2166,12 @@ export declare const messageSchemas: readonly [{
2078
2166
  };
2079
2167
  };
2080
2168
  readonly profileId: {
2081
- readonly type: "string";
2082
- readonly minLength: 1;
2083
- readonly maxLength: 100;
2169
+ readonly anyOf: readonly [{
2170
+ readonly type: "string";
2171
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
2172
+ }, {
2173
+ readonly enum: string[];
2174
+ }];
2084
2175
  };
2085
2176
  };
2086
2177
  };
@@ -2161,9 +2252,12 @@ export declare const messageSchemas: readonly [{
2161
2252
  };
2162
2253
  };
2163
2254
  readonly profileId: {
2164
- readonly type: "string";
2165
- readonly minLength: 1;
2166
- readonly maxLength: 100;
2255
+ readonly anyOf: readonly [{
2256
+ readonly type: "string";
2257
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
2258
+ }, {
2259
+ readonly enum: string[];
2260
+ }];
2167
2261
  };
2168
2262
  };
2169
2263
  };
@@ -2241,9 +2335,12 @@ export declare const messageSchemas: readonly [{
2241
2335
  };
2242
2336
  };
2243
2337
  readonly profileId: {
2244
- readonly type: "string";
2245
- readonly minLength: 1;
2246
- readonly maxLength: 100;
2338
+ readonly anyOf: readonly [{
2339
+ readonly type: "string";
2340
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
2341
+ }, {
2342
+ readonly enum: string[];
2343
+ }];
2247
2344
  };
2248
2345
  };
2249
2346
  };
@@ -2321,9 +2418,12 @@ export declare const messageSchemas: readonly [{
2321
2418
  };
2322
2419
  };
2323
2420
  readonly profileId: {
2324
- readonly type: "string";
2325
- readonly minLength: 1;
2326
- readonly maxLength: 100;
2421
+ readonly anyOf: readonly [{
2422
+ readonly type: "string";
2423
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
2424
+ }, {
2425
+ readonly enum: string[];
2426
+ }];
2327
2427
  };
2328
2428
  };
2329
2429
  };
@@ -2344,6 +2444,8 @@ export declare const messageSchemas: readonly [{
2344
2444
  readonly type: "boolean";
2345
2445
  };
2346
2446
  };
2447
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
2448
+ readonly "@type": "PaintCanvas/BrushConfig";
2347
2449
  readonly type: "object";
2348
2450
  readonly additionalProperties: false;
2349
2451
  readonly required: readonly ["id"];
@@ -1,5 +1,6 @@
1
+ import { UUID_PATTERN } from "../assets/schema.js";
1
2
  import { ImageEncoding } from "../image/index.js";
2
- import { UUID_PATTERN, brushPresetSchema } from "../presets/schema.js";
3
+ import { brushPresetSchema } from "../presets/schema.js";
3
4
  // src/lib/messages/schema.ts
4
5
  /** Version of the drawing message protocol, sent in every message */
5
6
  var PROTOCOL_VERSION = 1;
@@ -1,49 +1,15 @@
1
- import { type PaletteFile } from "./schema";
1
+ import AssetFile from "../assets";
2
+ import { type ColourPalette } from "./schema";
2
3
  export * from "./schema";
3
4
  /** The colours a palette starts with */
4
5
  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
- };
6
+ /** Name given to the palette in a colour palette file from before versioned schemas */
7
+ export declare const LEGACY_PALETTE_NAME = "Imported palette";
21
8
  /**
22
- * Check a colour palette file against `paletteFileSchema`.
9
+ * Reads and writes colour palette collection files. Files from before versioned schemas (`format` and `version: 1`,
10
+ * holding one list of colours) are read as one palette named `LEGACY_PALETTE_NAME`.
23
11
  *
24
12
  * @example
25
- * isValidPaletteFile({ format: "paintcanvas-palette", version: 1, colours: ["#ff0000"] }).valid; // true
13
+ * const palettes = colourPaletteFile.parse(await file.text());
26
14
  */
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[];
15
+ export declare const colourPaletteFile: AssetFile<ColourPalette>;
@@ -1,6 +1,6 @@
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";
1
+ import AssetFile from "../assets/index.js";
2
+ import { validateColourPaletteCollection } from "../validation/validators.generated.js";
3
+ import { COLOUR_PALETTE_COLLECTION_SCHEMA_VERSION, COLOUR_PALETTE_COLLECTION_TYPE, COLOUR_PALETTE_SCHEMA_VERSION, COLOUR_PALETTE_TYPE, HEX_COLOUR_PATTERN, MAX_PALETTES_PER_FILE, MAX_PALETTE_COLOURS, MAX_PALETTE_NAME_LENGTH, colourPaletteCollectionSchema, colourPaletteSchema, paletteColoursSchema } from "./schema.js";
4
4
  // src/lib/palette/index.ts
5
5
  /** The colours a palette starts with */
6
6
  var DEFAULT_PALETTE = [
@@ -20,63 +20,30 @@ var DEFAULT_PALETTE = [
20
20
  "#cccccc",
21
21
  "#ffffff"
22
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 {};
23
+ /** Name given to the palette in a colour palette file from before versioned schemas */
24
+ var LEGACY_PALETTE_NAME = "Imported palette";
30
25
  /**
31
- * Check a colour palette file against `paletteFileSchema`.
26
+ * Reads and writes colour palette collection files. Files from before versioned schemas (`format` and `version: 1`,
27
+ * holding one list of colours) are read as one palette named `LEGACY_PALETTE_NAME`.
32
28
  *
33
29
  * @example
34
- * isValidPaletteFile({ format: "paintcanvas-palette", version: 1, colours: ["#ff0000"] }).valid; // true
30
+ * const palettes = colourPaletteFile.parse(await file.text());
35
31
  */
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 };
32
+ var colourPaletteFile = new AssetFile({
33
+ schema: "colour-palette-collection",
34
+ version: COLOUR_PALETTE_COLLECTION_SCHEMA_VERSION,
35
+ type: COLOUR_PALETTE_COLLECTION_TYPE,
36
+ validate: validateColourPaletteCollection,
37
+ fileName: "colour-palettes",
38
+ legacyVersion: (data) => typeof data.format === "string" && data.version === 1 ? "legacy-1" : void 0,
39
+ migrations: [{
40
+ from: "legacy-1",
41
+ to: "1.0.0",
42
+ migrate: (data) => ({ items: [{
43
+ id: crypto.randomUUID(),
44
+ name: LEGACY_PALETTE_NAME,
45
+ colours: data.colours
46
+ }] })
47
+ }]
48
+ });
49
+ export { COLOUR_PALETTE_COLLECTION_SCHEMA_VERSION, COLOUR_PALETTE_COLLECTION_TYPE, COLOUR_PALETTE_SCHEMA_VERSION, COLOUR_PALETTE_TYPE, DEFAULT_PALETTE, HEX_COLOUR_PATTERN, LEGACY_PALETTE_NAME, MAX_PALETTES_PER_FILE, MAX_PALETTE_COLOURS, MAX_PALETTE_NAME_LENGTH, colourPaletteCollectionSchema, colourPaletteFile, colourPaletteSchema, paletteColoursSchema };