@pixerate/editor 0.252.0 → 0.254.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 (73) hide show
  1. package/dist/animation-editor/index.cjs +53 -53
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/brushes/index.cjs +229 -2014
  4. package/dist/brushes/index.d.cts +5 -1
  5. package/dist/brushes/index.d.ts +5 -1
  6. package/dist/brushes/index.js +236 -2021
  7. package/dist/brushes/patch.d.cts +23 -0
  8. package/dist/brushes/patch.d.ts +23 -0
  9. package/dist/brushes/ui.d.cts +105 -0
  10. package/dist/brushes/ui.d.ts +105 -0
  11. package/dist/canvas/index.cjs +7 -7
  12. package/dist/canvas/index.js +1 -1
  13. package/dist/{chunk-QKXO6JPP.cjs → chunk-2OQGPEHH.cjs} +14 -14
  14. package/dist/chunk-34KLWUH4.cjs +2284 -0
  15. package/dist/{chunk-Z3BRH4JK.cjs → chunk-557BDWKO.cjs} +6 -6
  16. package/dist/{chunk-ZBCT5MEA.cjs → chunk-CBVNCWJM.cjs} +7 -7
  17. package/dist/{chunk-226QDRO3.js → chunk-DHQPRKXF.js} +1 -1
  18. package/dist/{chunk-ABL7IWFZ.js → chunk-GBEF2D4P.js} +1 -1
  19. package/dist/{chunk-ISIO63Q5.cjs → chunk-L2JTLW6B.cjs} +150 -25
  20. package/dist/{chunk-JA57JIT5.js → chunk-MV7CYFMJ.js} +133 -8
  21. package/dist/{chunk-5E2Q7ZHI.js → chunk-MWUZCEFT.js} +1 -1
  22. package/dist/chunk-QPHNVZHO.js +2284 -0
  23. package/dist/effects/conformance.d.cts +1 -0
  24. package/dist/effects/conformance.d.ts +1 -0
  25. package/dist/effects/fake.d.cts +7 -1
  26. package/dist/effects/fake.d.ts +7 -1
  27. package/dist/effects/helpers.d.cts +36 -4
  28. package/dist/effects/helpers.d.ts +36 -4
  29. package/dist/effects/index.cjs +331 -102
  30. package/dist/effects/index.js +238 -9
  31. package/dist/effects/types.d.cts +84 -5
  32. package/dist/effects/types.d.ts +84 -5
  33. package/dist/image-editor/index.cjs +15 -15
  34. package/dist/image-editor/index.js +1 -1
  35. package/dist/paint-editor/brush-controls.d.cts +57 -0
  36. package/dist/paint-editor/brush-controls.d.ts +57 -0
  37. package/dist/paint-editor/brush-library-tools.d.cts +15 -0
  38. package/dist/paint-editor/brush-library-tools.d.ts +15 -0
  39. package/dist/paint-editor/brush-library.d.cts +29 -0
  40. package/dist/paint-editor/brush-library.d.ts +29 -0
  41. package/dist/paint-editor/controller.d.cts +76 -17
  42. package/dist/paint-editor/controller.d.ts +76 -17
  43. package/dist/paint-editor/index.cjs +543 -858
  44. package/dist/paint-editor/index.d.cts +1 -0
  45. package/dist/paint-editor/index.d.ts +1 -0
  46. package/dist/paint-editor/index.js +329 -644
  47. package/dist/paint-editor/serialize.d.cts +7 -4
  48. package/dist/paint-editor/serialize.d.ts +7 -4
  49. package/dist/paint-editor/sticker-tools.d.cts +1 -1
  50. package/dist/paint-editor/sticker-tools.d.ts +1 -1
  51. package/dist/paint-editor/strokes.d.cts +10 -1
  52. package/dist/paint-editor/strokes.d.ts +10 -1
  53. package/dist/paint-editor/tools.d.cts +1 -1
  54. package/dist/paint-editor/tools.d.ts +1 -1
  55. package/dist/paint-editor/ui.d.cts +3 -51
  56. package/dist/paint-editor/ui.d.ts +3 -51
  57. package/dist/paint-editor/wet-tools.d.cts +1 -1
  58. package/dist/paint-editor/wet-tools.d.ts +1 -1
  59. package/dist/vector/index.cjs +6 -6
  60. package/dist/vector/index.js +1 -1
  61. package/dist/video-editor/index.cjs +344 -344
  62. package/dist/video-editor/index.js +4 -4
  63. package/package.json +1 -1
  64. package/skills/pixerate-brushes/SKILL.md +5 -3
  65. package/skills/pixerate-paint-editor/SKILL.md +26 -24
  66. package/skills/pixerate-paint-editor/references/brush-facets.md +30 -0
  67. package/skills/pixerate-paint-editor/references/gradient-paint.md +1 -1
  68. package/skills/pixerate-paint-editor/references/light-paint.md +2 -2
  69. package/skills/pixerate-paint-editor/references/oils.md +1 -1
  70. package/skills/pixerate-paint-editor/references/particle-brushes.md +8 -5
  71. package/skills/pixerate-paint-oil-impasto/SKILL.md +1 -1
  72. package/skills/pixerate-stickers/SKILL.md +1 -1
  73. package/skills/pixerate-video-editor/SKILL.md +1 -1
@@ -18,7 +18,10 @@ import { type LayerLocks } from '../raster/layers.js';
18
18
  import { type LayerEffect, type LayerEffectKind, type LayerEffects } from '../raster/effects/model.js';
19
19
  import type { EffectPattern } from '../raster/effects/patterns.js';
20
20
  import { TiledSurface, type RasterRect, type Tile } from '../raster/surface.js';
21
- import { type PaintBrushInput, type BrushLibraryFile, type PaintBrush } from './brushes.js';
21
+ import { type PaintBrushInput, type PaintBrush } from './brushes.js';
22
+ import { type BrushLibrary, type BrushLibraryFile } from '../brushes/library.js';
23
+ import { type BrushPatch, type UnsettableBrushFacet } from '../brushes/patch.js';
24
+ import type { Brush } from '../brushes/types.js';
22
25
  import { type PaintCanvas, type PaintDocumentState, type PaintLayer } from './document.js';
23
26
  import { type ImageEncoder, type ImageFormat } from './encode.js';
24
27
  import type { PenPoint } from './engine.js';
@@ -57,7 +60,12 @@ export interface PaintEditorOptions extends Partial<PaintCanvas> {
57
60
  paper?: Partial<PaperSettings> | string;
58
61
  /** Active brush id (default `pencil-6b`). */
59
62
  brushId?: string;
60
- /** Saved user brushes to start the library with. */
63
+ /**
64
+ * The brush library: built-in presets plus saved brushes, on any storage. Pass one library to
65
+ * every editor so a brush saved in one shows in all of them (default: a library in memory).
66
+ */
67
+ brushLibrary?: BrushLibrary;
68
+ /** Saved user brushes to start the default library with (or to add to `brushLibrary`). */
61
69
  brushes?: readonly PaintBrush[];
62
70
  /** Paint colour #rrggbb (default #1f2937). */
63
71
  color?: string;
@@ -296,8 +304,17 @@ export declare class PaintEditorController {
296
304
  private undoStack;
297
305
  private redoStack;
298
306
  private readonly historyLimit;
307
+ /** The brush library this editor lists, saves into and paints from (shared with other editors when the host passes one). */
308
+ readonly brushLibrary: BrushLibrary;
299
309
  private brush;
300
- private userBrushes;
310
+ /** The active brush as facets (what `getBrushSpec` and saving use). */
311
+ private brushSpec;
312
+ /** The library's brushes as last read, each as stored (facets) and as the engine paints it. */
313
+ private brushEntries;
314
+ /** The brush id asked for at construction, while the library had not listed it yet. */
315
+ private pendingBrushId;
316
+ private brushesLoaded;
317
+ private readonly unsubscribeLibrary;
301
318
  /** The library list in the state (the same array until the user brushes change, so thumbnails are not redrawn). */
302
319
  private library;
303
320
  private color;
@@ -673,39 +690,81 @@ export declare class PaintEditorController {
673
690
  source: PaintEffectSource;
674
691
  amount: number;
675
692
  }>;
693
+ private findEntry;
676
694
  private findBrush;
677
- /** A library brush by id (`undefined` when unknown). */
678
- getBrush(id: string): PaintBrush | undefined;
695
+ private requireEntry;
679
696
  private requireBrush;
697
+ /** Reads the library again (after a change anywhere it is shared). */
698
+ private refreshBrushes;
699
+ /** Resolves once the brush library has been read (user brushes kept in storage are listed from then on). */
700
+ whenBrushesLoaded(): Promise<void>;
701
+ /** A library brush by id, as the engine paints it (`undefined` when unknown). */
702
+ getBrush(id: string): PaintBrush | undefined;
703
+ /** A library brush by id as stored (its facets), or without an id the active brush as edited. */
704
+ getBrushSpec(id?: string): Brush | undefined;
680
705
  /**
681
- * Chooses the active brush (`id`: a library brush) and / or changes its settings. Editor state,
682
- * not an undo step. Returns the active brush.
706
+ * Chooses the active brush (`id`: a library brush) and / or changes its engine settings. Editor
707
+ * state, not an undo step. Returns the active brush. `setBrushFacets` changes it by facets.
683
708
  */
684
709
  setBrush(update?: {
685
710
  id?: string;
686
711
  } & Omit<PaintBrushInput, 'id'>): PaintBrush;
687
- /** Saves the active brush (or `brush`) into the user library under `id` / `name`. */
712
+ /**
713
+ * Chooses the active brush (`id`: a library brush) and / or lays a facet patch over it (objects
714
+ * merge, lists and values replace, as the library's `update_brush` does). Editor state, not an
715
+ * undo step. `unset` removes whole facets first. Returns the active brush as the engine paints
716
+ * it, its facets, and what was clamped or dropped.
717
+ */
718
+ setBrushFacets(patch?: BrushPatch, id?: string, unset?: readonly UnsettableBrushFacet[]): {
719
+ brush: PaintBrush;
720
+ spec: Brush;
721
+ problems: string[];
722
+ };
723
+ /**
724
+ * Makes `spec` (a whole facet brush, as the brush editor edits it) the active brush, keeping the
725
+ * active brush's id. Editor state, not an undo step. Returns it as the engine paints it, its
726
+ * facets, and what was clamped or dropped.
727
+ */
728
+ setBrushSpec(spec: Brush): {
729
+ brush: PaintBrush;
730
+ spec: Brush;
731
+ problems: string[];
732
+ };
733
+ /**
734
+ * The engine settings a facet patch changes on a brush (`from`: a library brush id or a brush as
735
+ * painted; default the active brush), as `paintStroke`'s and `updateStroke`'s `brush` take them.
736
+ */
737
+ brushChanges(patch: BrushPatch, from?: string | PaintBrush): Omit<PaintBrushInput, 'id'>;
738
+ private readBrushPatch;
739
+ private useBrush;
740
+ /**
741
+ * Saves the active brush (or `brush`, engine settings on top of it) into the brush library under
742
+ * `id` / `name`, replacing a user brush with that id. Built-in ids are refused. Resolves with the
743
+ * saved brush.
744
+ */
688
745
  saveBrush(options: {
689
746
  id: string;
690
747
  name?: string;
691
748
  brush?: PaintBrushInput;
692
- }): PaintBrush;
693
- removeBrush(id: string): void;
694
- /** The user's saved brushes. */
749
+ }): Promise<PaintBrush>;
750
+ /** Removes a user brush from the brush library (built-in brushes can't be removed). */
751
+ removeBrush(id: string): Promise<void>;
752
+ /** The user's saved brushes, as the engine paints them. */
695
753
  getUserBrushes(): PaintBrush[];
696
- /** A brush library file of the given brushes (default: the user's brushes). */
697
- exportBrushes(ids?: readonly string[]): BrushLibraryFile;
754
+ /** A brush library file (version 2) of the given brushes (default: the user's brushes). */
755
+ exportBrushes(ids?: readonly string[]): Promise<BrushLibraryFile>;
698
756
  /**
699
- * Adds the brushes of a library file to the user library. A brush whose id is taken is skipped
700
- * unless `replace` (built-in ids are always skipped). Returns the ids added and the problems.
757
+ * Adds the brushes of a library file (version 1 or 2) to the brush library. A brush whose id is
758
+ * taken is skipped unless `replace` (built-in ids are always skipped). Resolves with the ids
759
+ * added or replaced, the ids skipped and the problems.
701
760
  */
702
761
  importBrushes(file: unknown, options?: {
703
762
  replace?: boolean;
704
- }): {
763
+ }): Promise<{
705
764
  added: string[];
706
765
  skipped: string[];
707
766
  problems: string[];
708
- };
767
+ }>;
709
768
  /** A thumbnail of a brush: a test stroke on the current paper. */
710
769
  brushThumbnail(id: string, options?: {
711
770
  width?: number;