@pixerate/editor 0.263.0 → 0.264.1

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 (52) hide show
  1. package/dist/animation-editor/index.cjs +59 -59
  2. package/dist/animation-editor/index.js +3 -3
  3. package/dist/brushes/index.cjs +155 -68
  4. package/dist/brushes/index.d.cts +3 -3
  5. package/dist/brushes/index.d.ts +3 -3
  6. package/dist/brushes/index.js +111 -24
  7. package/dist/brushes/library.d.cts +2 -0
  8. package/dist/brushes/library.d.ts +2 -0
  9. package/dist/brushes/profiles.d.cts +21 -2
  10. package/dist/brushes/profiles.d.ts +21 -2
  11. package/dist/brushes/ui.d.cts +57 -4
  12. package/dist/brushes/ui.d.ts +57 -4
  13. package/dist/{brushstrokeRender-S5DABANG.js → brushstrokeRender-3MOI7PH4.js} +2 -2
  14. package/dist/{brushstrokeRender-2GBME4XD.cjs → brushstrokeRender-SMMPIJF2.cjs} +12 -12
  15. package/dist/canvas/index.cjs +13 -13
  16. package/dist/canvas/index.js +1 -1
  17. package/dist/{chunk-CNLO6E2K.js → chunk-4OJC4MCD.js} +8 -7
  18. package/dist/{chunk-ZBACQHW3.cjs → chunk-BY5EBP26.cjs} +27 -6
  19. package/dist/{chunk-JGI4PZWO.js → chunk-CECCP2V7.js} +1 -1
  20. package/dist/{chunk-P5343XZO.js → chunk-EE7SAYBF.js} +23 -2
  21. package/dist/{chunk-TILEUVRO.cjs → chunk-F3KKR6DD.cjs} +35 -34
  22. package/dist/{chunk-TIHW7CUY.cjs → chunk-FQC5TDB6.cjs} +35 -35
  23. package/dist/{chunk-4E6BGHWN.cjs → chunk-G5ADO47G.cjs} +1 -1
  24. package/dist/{chunk-QW7LKWKE.js → chunk-HAUDEVMC.js} +1 -1
  25. package/dist/{chunk-LG6MEEV7.js → chunk-JEML4FSA.js} +1 -1
  26. package/dist/{chunk-XQW6R7VW.cjs → chunk-KXNZNOEF.cjs} +86 -86
  27. package/dist/{chunk-6XX7E7O2.js → chunk-ROBSFJ6F.js} +1 -1
  28. package/dist/{chunk-LWHUU6A6.cjs → chunk-USJX5SW4.cjs} +10 -10
  29. package/dist/{chunk-73QFSPDG.cjs → chunk-V7MJ4HIN.cjs} +23 -23
  30. package/dist/{chunk-34HIZXFX.js → chunk-WWI6FLH2.js} +1 -1
  31. package/dist/image-editor/controller.d.cts +3 -0
  32. package/dist/image-editor/controller.d.ts +3 -0
  33. package/dist/image-editor/index.cjs +789 -786
  34. package/dist/image-editor/index.js +7 -4
  35. package/dist/image-editor/types.d.cts +7 -0
  36. package/dist/image-editor/types.d.ts +7 -0
  37. package/dist/paint-editor/brush-library-tools.d.cts +8 -1
  38. package/dist/paint-editor/brush-library-tools.d.ts +8 -1
  39. package/dist/paint-editor/controller.d.cts +1 -1
  40. package/dist/paint-editor/controller.d.ts +1 -1
  41. package/dist/paint-editor/index.cjs +88 -83
  42. package/dist/paint-editor/index.d.cts +1 -1
  43. package/dist/paint-editor/index.d.ts +1 -1
  44. package/dist/paint-editor/index.js +16 -11
  45. package/dist/vector/controller.d.cts +13 -0
  46. package/dist/vector/controller.d.ts +13 -0
  47. package/dist/vector/index.cjs +1215 -1205
  48. package/dist/vector/index.js +16 -6
  49. package/package.json +1 -1
  50. package/skills/pixerate-brushes/SKILL.md +11 -3
  51. package/skills/pixerate-brushes-design/SKILL.md +1 -0
  52. package/skills/pixerate-vector/SKILL.md +1 -1
@@ -26,7 +26,7 @@ export * from './mixing-pad.cjs';
26
26
  export * from './controller.cjs';
27
27
  export * from './presence.cjs';
28
28
  export * from './tools.cjs';
29
- export { createPaintBrushLibraryToolProvider, type PaintBrushLibraryToolProviderOptions } from './brush-library-tools.cjs';
29
+ export { createPaintBrushLibraryToolProvider, paintBrushPreviewRenderer, type PaintBrushLibraryToolProviderOptions } from './brush-library-tools.cjs';
30
30
  export type { PaintAgentTool, PaintOrigin, PaintToolCoordinates } from './hosted.cjs';
31
31
  export * from './ui.cjs';
32
32
  export { BLEND_MODES, PAINTERLY_BLEND_MODES, isBlendMode, isPainterlyBlendMode, standardBlendMode, type BlendMode, type BlendModeInfo } from '../raster/blend.cjs';
@@ -26,7 +26,7 @@ export * from './mixing-pad.js';
26
26
  export * from './controller.js';
27
27
  export * from './presence.js';
28
28
  export * from './tools.js';
29
- export { createPaintBrushLibraryToolProvider, type PaintBrushLibraryToolProviderOptions } from './brush-library-tools.js';
29
+ export { createPaintBrushLibraryToolProvider, paintBrushPreviewRenderer, type PaintBrushLibraryToolProviderOptions } from './brush-library-tools.js';
30
30
  export type { PaintAgentTool, PaintOrigin, PaintToolCoordinates } from './hosted.js';
31
31
  export * from './ui.js';
32
32
  export { BLEND_MODES, PAINTERLY_BLEND_MODES, isBlendMode, isPainterlyBlendMode, standardBlendMode, type BlendMode, type BlendModeInfo } from '../raster/blend.js';
@@ -11,7 +11,7 @@ import {
11
11
  mergeBrushPatch,
12
12
  multiColorSliders,
13
13
  patchBrushValue
14
- } from "../chunk-CNLO6E2K.js";
14
+ } from "../chunk-4OJC4MCD.js";
15
15
  import {
16
16
  createStickerTools,
17
17
  describeStickerRef
@@ -30,7 +30,7 @@ import {
30
30
  resolveExternalAssets,
31
31
  serializeLayers,
32
32
  serializeLayersExternal
33
- } from "../chunk-QW7LKWKE.js";
33
+ } from "../chunk-HAUDEVMC.js";
34
34
  import "../chunk-WJ4WQJCC.js";
35
35
  import {
36
36
  LAYER_EFFECT_KINDS,
@@ -88,7 +88,7 @@ import {
88
88
  realPresenceClock,
89
89
  tweenPresenceCursor
90
90
  } from "../chunk-IVSWRVB4.js";
91
- import "../chunk-34HIZXFX.js";
91
+ import "../chunk-WWI6FLH2.js";
92
92
  import {
93
93
  BRUSH_ID,
94
94
  BRUSH_PRESETS,
@@ -143,7 +143,7 @@ import {
143
143
  parseBrushLibrary,
144
144
  resolveBrush,
145
145
  usesPaintExchange
146
- } from "../chunk-P5343XZO.js";
146
+ } from "../chunk-EE7SAYBF.js";
147
147
  import {
148
148
  STAMP_KINDS,
149
149
  StickersSlot,
@@ -5579,7 +5579,8 @@ async function replayPainting(source, target, options = {}) {
5579
5579
  const maxStrokes = options.strokes ?? source.strokes.length;
5580
5580
  const chunk = Math.max(1, options.wetChunk ?? 0) || Infinity;
5581
5581
  let strokes = 0;
5582
- await target.prepareEffectPaints(source.strokes.slice(0, maxStrokes).flatMap((st) => st.paint?.type === "effect" ? [st.paint] : []));
5582
+ const scaled = source.strokes.slice(0, maxStrokes).map((st) => s === 1 ? st : varyStroke(st, scaleM, { scale: s }));
5583
+ await target.prepareEffectPaints(scaled.flatMap((st) => st.paint?.type === "effect" ? [st.paint] : []));
5583
5584
  const advanceTo = async (clock) => {
5584
5585
  const now = target.getState().wet.clock;
5585
5586
  let left = clock - now;
@@ -9588,11 +9589,11 @@ var PaintEditorController = class _PaintEditorController {
9588
9589
  if (!layers.length) return null;
9589
9590
  return { layerIds: layers.map((x) => x.layer.id), strokes: layers.reduce((n, x) => n + x.strokes.filter(isLiveEffect).length, 0), sources: sources.length };
9590
9591
  }
9591
- /** Plays or pauses live effect paint, and caps its frame rate (1..60). Editor state, not an undo step. */
9592
+ /** Plays or pauses live effect paint, and caps its frame rate (1..60); a setting left out keeps its value. Editor state, not an undo step. */
9592
9593
  setEffectPlayback(update) {
9593
9594
  if (update.playing !== void 0 && typeof update.playing !== "boolean") throw new PaintEditorError("playing must be true or false.");
9594
9595
  if (update.fps !== void 0 && !(Number.isInteger(update.fps) && update.fps >= 1 && update.fps <= 60)) throw new PaintEditorError(`fps ${update.fps} is out of range; use a whole number 1..60.`);
9595
- this.effectPlaybackState = { ...this.effectPlaybackState, ...update };
9596
+ this.effectPlaybackState = { playing: update.playing ?? this.effectPlaybackState.playing, fps: update.fps ?? this.effectPlaybackState.fps };
9596
9597
  this.emit([]);
9597
9598
  return { ...this.effectPlaybackState, time: this.effectTime };
9598
9599
  }
@@ -12150,15 +12151,18 @@ function strokeSummary(s, withPoints, live) {
12150
12151
  }
12151
12152
 
12152
12153
  // src/paint-editor/brush-library-tools.ts
12154
+ function paintBrushPreviewRenderer(paper = () => DEFAULT_PAPER) {
12155
+ return (brush, { width, height, color }) => {
12156
+ const t = renderBrushThumbnail(resolveBrush(brush), { paper: paper(), width, height, color: color.toLowerCase() });
12157
+ return { data: bytesToBase64(encodePng(t.width, t.height, t.data)), mimeType: "image/png" };
12158
+ };
12159
+ }
12153
12160
  function createPaintBrushLibraryToolProvider(controller, options = {}) {
12154
12161
  return createBrushLibraryToolProvider(controller.brushLibrary, {
12155
12162
  profile: PAINT_PROFILE,
12156
12163
  stickers: () => controller.stickers.provider,
12157
12164
  ...options,
12158
- renderPreview: (brush, { width, height, color }) => {
12159
- const t = renderBrushThumbnail(resolveBrush(brush), { paper: controller.getState().document.paper, width, height, color: color.toLowerCase() });
12160
- return { data: bytesToBase64(encodePng(t.width, t.height, t.data)), mimeType: "image/png" };
12161
- }
12165
+ renderPreview: paintBrushPreviewRenderer(() => controller.getState().document.paper)
12162
12166
  });
12163
12167
  }
12164
12168
 
@@ -13780,6 +13784,7 @@ export {
13780
13784
  overPixels,
13781
13785
  padSampleRadius,
13782
13786
  paintAgentStrokePoints,
13787
+ paintBrushPreviewRenderer,
13783
13788
  paintContracts,
13784
13789
  paintGradientMappingFor,
13785
13790
  paintPlaybackPanel,
@@ -1,4 +1,5 @@
1
1
  import { type BrushLibrary } from '../brushes/library.cjs';
2
+ import type { BrushPreviewRenderer } from '../brushes/tools.cjs';
2
3
  import type { PaintBrush } from '../paint-editor/brushes.cjs';
3
4
  import { type VectorStylizeOptions, type VectorStylizeStyle } from './stylize.cjs';
4
5
  import { type VectorDistortBrushMode } from './distortBrush.cjs';
@@ -104,6 +105,12 @@ export interface VectorEditorOptions {
104
105
  * profile decides which). Share one with the paint editor so a brush saved there paints here.
105
106
  */
106
107
  brushLibrary?: Pick<BrushLibrary, 'list' | 'subscribe'>;
108
+ /**
109
+ * Draws a brush's preview stroke for the brush editor ("Edit brush…"), e.g.
110
+ * `renderCanvasBrushPreview` from `@pixerate/editor/canvas` (the renderer brushstrokes paint
111
+ * with; not bundled here). Without it the brush editor has no preview.
112
+ */
113
+ brushPreview?: BrushPreviewRenderer;
107
114
  /** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
108
115
  colorScheme?: 'light' | 'dark';
109
116
  /** History to record into, e.g. one shared with the rest of the app (default: a new one). */
@@ -802,6 +809,12 @@ export declare class VectorEditorController {
802
809
  */
803
810
  /** The saved brushes of the brush library as last read (empty without one). */
804
811
  private brushes;
812
+ /** The brush library brushstrokes use (`brushLibrary` option), or `null`. A full `BrushLibrary` lets the UI edit brushes (`isBrushLibrary`). */
813
+ readonly brushLibrary: Pick<BrushLibrary, 'list' | 'subscribe'> | null;
814
+ /** The `brushPreview` option: draws the brush editor's preview stroke, or `null`. */
815
+ readonly brushPreview: BrushPreviewRenderer | null;
816
+ /** Reads the brush library again now (it is also read after every change to it); resolves once read. */
817
+ refreshBrushes(): Promise<void>;
805
818
  /** The brushes a brushstroke can use: the presets, then the brush library's saved brushes the vector profile admits. */
806
819
  listBrushstrokeBrushes(): PaintBrush[];
807
820
  /** Resolves once the brush library has been read (its saved brushes can be used from then on). */
@@ -1,4 +1,5 @@
1
1
  import { type BrushLibrary } from '../brushes/library.js';
2
+ import type { BrushPreviewRenderer } from '../brushes/tools.js';
2
3
  import type { PaintBrush } from '../paint-editor/brushes.js';
3
4
  import { type VectorStylizeOptions, type VectorStylizeStyle } from './stylize.js';
4
5
  import { type VectorDistortBrushMode } from './distortBrush.js';
@@ -104,6 +105,12 @@ export interface VectorEditorOptions {
104
105
  * profile decides which). Share one with the paint editor so a brush saved there paints here.
105
106
  */
106
107
  brushLibrary?: Pick<BrushLibrary, 'list' | 'subscribe'>;
108
+ /**
109
+ * Draws a brush's preview stroke for the brush editor ("Edit brush…"), e.g.
110
+ * `renderCanvasBrushPreview` from `@pixerate/editor/canvas` (the renderer brushstrokes paint
111
+ * with; not bundled here). Without it the brush editor has no preview.
112
+ */
113
+ brushPreview?: BrushPreviewRenderer;
107
114
  /** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
108
115
  colorScheme?: 'light' | 'dark';
109
116
  /** History to record into, e.g. one shared with the rest of the app (default: a new one). */
@@ -802,6 +809,12 @@ export declare class VectorEditorController {
802
809
  */
803
810
  /** The saved brushes of the brush library as last read (empty without one). */
804
811
  private brushes;
812
+ /** The brush library brushstrokes use (`brushLibrary` option), or `null`. A full `BrushLibrary` lets the UI edit brushes (`isBrushLibrary`). */
813
+ readonly brushLibrary: Pick<BrushLibrary, 'list' | 'subscribe'> | null;
814
+ /** The `brushPreview` option: draws the brush editor's preview stroke, or `null`. */
815
+ readonly brushPreview: BrushPreviewRenderer | null;
816
+ /** Reads the brush library again now (it is also read after every change to it); resolves once read. */
817
+ refreshBrushes(): Promise<void>;
805
818
  /** The brushes a brushstroke can use: the presets, then the brush library's saved brushes the vector profile admits. */
806
819
  listBrushstrokeBrushes(): PaintBrush[];
807
820
  /** Resolves once the brush library has been read (its saved brushes can be used from then on). */