@pixerate/editor 0.263.0 → 0.264.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 (50) 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/index.cjs +84 -80
  40. package/dist/paint-editor/index.d.cts +1 -1
  41. package/dist/paint-editor/index.d.ts +1 -1
  42. package/dist/paint-editor/index.js +12 -8
  43. package/dist/vector/controller.d.cts +13 -0
  44. package/dist/vector/controller.d.ts +13 -0
  45. package/dist/vector/index.cjs +1215 -1205
  46. package/dist/vector/index.js +16 -6
  47. package/package.json +1 -1
  48. package/skills/pixerate-brushes/SKILL.md +11 -3
  49. package/skills/pixerate-brushes-design/SKILL.md +1 -0
  50. package/skills/pixerate-vector/SKILL.md +1 -1
@@ -26,7 +26,7 @@ import {
26
26
  traceField,
27
27
  traceVectorImage,
28
28
  vectorTraceContours
29
- } from "../chunk-JGI4PZWO.js";
29
+ } from "../chunk-CECCP2V7.js";
30
30
  import {
31
31
  applyHomography,
32
32
  homographyFromPoints,
@@ -53,7 +53,7 @@ import {
53
53
  reverseMorphContour,
54
54
  subpathToMorphContour,
55
55
  turnMorphContour
56
- } from "../chunk-6XX7E7O2.js";
56
+ } from "../chunk-ROBSFJ6F.js";
57
57
  import {
58
58
  DEFAULT_VECTOR_FONT,
59
59
  IDENTITY_MATRIX,
@@ -529,10 +529,10 @@ import {
529
529
  withVectorStrokes,
530
530
  withVectorTargetPaint,
531
531
  zigzagPaths
532
- } from "../chunk-34HIZXFX.js";
532
+ } from "../chunk-WWI6FLH2.js";
533
533
  import {
534
534
  snapshotBrushLibrary
535
- } from "../chunk-P5343XZO.js";
535
+ } from "../chunk-EE7SAYBF.js";
536
536
  import "../chunk-ACFSFUQH.js";
537
537
  import {
538
538
  createProvenance
@@ -6829,6 +6829,8 @@ var VectorEditorController = class _VectorEditorController {
6829
6829
  colorScheme;
6830
6830
  constructor(options = {}) {
6831
6831
  this.colorScheme = options.colorScheme ?? "light";
6832
+ this.brushLibrary = options.brushLibrary ?? null;
6833
+ this.brushPreview = options.brushPreview ?? null;
6832
6834
  this.brushes = options.brushLibrary ? snapshotBrushLibrary(options.brushLibrary, () => this.notify()) : null;
6833
6835
  this.history = options.history ?? new HistoryManager();
6834
6836
  this.doc = options.document ? loadedDocument(options.document) : { width: 800, height: 600, nodes: [] };
@@ -6867,6 +6869,14 @@ var VectorEditorController = class _VectorEditorController {
6867
6869
  */
6868
6870
  /** The saved brushes of the brush library as last read (empty without one). */
6869
6871
  brushes;
6872
+ /** The brush library brushstrokes use (`brushLibrary` option), or `null`. A full `BrushLibrary` lets the UI edit brushes (`isBrushLibrary`). */
6873
+ brushLibrary;
6874
+ /** The `brushPreview` option: draws the brush editor's preview stroke, or `null`. */
6875
+ brushPreview;
6876
+ /** Reads the brush library again now (it is also read after every change to it); resolves once read. */
6877
+ refreshBrushes() {
6878
+ return this.brushes?.refresh() ?? Promise.resolve();
6879
+ }
6870
6880
  /** The brushes a brushstroke can use: the presets, then the brush library's saved brushes the vector profile admits. */
6871
6881
  listBrushstrokeBrushes() {
6872
6882
  return vectorBrushstrokeBrushes(this.brushes?.user ?? []);
@@ -8236,7 +8246,7 @@ var VectorEditorController = class _VectorEditorController {
8236
8246
  (stack, path) => {
8237
8247
  const layer = stack[index];
8238
8248
  if (!layer || layer.kind !== "brushstroke" || !layer.brush) return `Path "${path.id}" has no brushstroke at stroke ${index} (vector.getAppearance lists its strokes; 0 is the bottom).`;
8239
- const brush = patch.brushId && patch.brushId !== layer.brush.brushId ? { ...layer.brush, brushId: patch.brushId, spec: void 0 } : { ...layer.brush };
8249
+ const brush = patch.brushId ? { ...layer.brush, brushId: patch.brushId, spec: void 0 } : { ...layer.brush };
8240
8250
  if (patch.size === null) delete brush.size;
8241
8251
  else if (patch.size !== void 0) brush.size = patch.size;
8242
8252
  if (patch.pressure === null) delete brush.pressure;
@@ -15985,7 +15995,7 @@ function createVectorCommands(controller, options = {}) {
15985
15995
  id: `${prefix}setBrushstroke`,
15986
15996
  label: "Edit Brushstroke\u2026",
15987
15997
  keywords: ["brushstroke", "brush", "size", "pressure", "taper"],
15988
- description: "Changes the brushstroke at stroke layer `index` of path `id` (vector.getAppearance lists strokes; 0 is the bottom): `brushId`, `size` (null: the brush's own), `pressure` (null: full pressure), `color`, `opacity`, `seed` (turns the brush's character on; null: plain dabs) and `paper` (replaced whole; null: no grain; {}: the default paper). Pass at least one. One undo step. Returns { id, strokes }.",
15998
+ description: "Changes the brushstroke at stroke layer `index` of path `id` (vector.getAppearance lists strokes; 0 is the bottom): `brushId` (the same id again takes that saved brush as the library has it now), `size` (null: the brush's own), `pressure` (null: full pressure), `color`, `opacity`, `seed` (turns the brush's character on; null: plain dabs) and `paper` (replaced whole; null: no grain; {}: the default paper). Pass at least one. One undo step. Returns { id, strokes }.",
15989
15999
  params: {
15990
16000
  type: "object",
15991
16001
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.263.0",
3
+ "version": "0.264.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -47,6 +47,9 @@ paints without (warnings), each with a fix; lists and writes use the current hos
47
47
 
48
48
  Every host lists the presets its profile admits and the library's saved brushes it admits, and
49
49
  each registers these tools with its own profile, so `list_brush_presets` shows that host's brushes.
50
+ People edit brushes in every host with the same brush editor, scoped the same way: it shows only
51
+ the controls the host uses (no velocity on canvas, no grain in the image editor), and what the
52
+ brush has for other hosts is kept on save. The tools follow the same rule (see Pitfalls).
50
53
  A saved brush used in canvas or vector strokes is copied into the stroke, so the document renders
51
54
  where the library is not; changing the brush in the library later doesn't change strokes already
52
55
  drawn.
@@ -87,8 +90,13 @@ drawn.
87
90
 
88
91
  ## Pitfalls
89
92
 
90
- - **A facet the host refuses.** `create_brush` and `update_brush` refuse it with the facet and
91
- fix; `check_brush` returns `degraded`, the brush with those facets stripped, to start from.
93
+ - **A facet the host refuses.** `create_brush` refuses it, and `update_brush` refuses a change
94
+ that adds it, with the facet and fix; `check_brush` returns `degraded`, the brush with those
95
+ facets stripped, to start from.
96
+ - **Tuning a brush in a host that can't paint all of it.** `update_brush` keeps what the brush
97
+ already has for other hosts (a paint brush's light, changed from canvas) and lists it in
98
+ `kept`; it is not stripped. To make a copy for this host only, `create_brush` from
99
+ `check_brush`'s `degraded` brush instead.
92
100
  - **Ids.** Built-in ids can't be reused or changed; a taken id is refused (update it instead).
93
101
  - **Stamps.** Any marks take any sticker ref from `find_stickers`, or an editor stamp
94
102
  (`editor:star`…). A ref the host's sticker library can't load is refused with the closest
@@ -113,7 +121,7 @@ drawn.
113
121
  | `list_brush_presets` | Find brushes this host renders: `kind`, `medium`, `variety`, `tool`, `tag`, `text`, `source` (all, builtin, user), `all`, `offset`, `limit`. Returns `brushes` (id, name, builtin, kind, medium, variety or tool, category, engine, tip, size, marks, surface, light) and `total`. Call first. |
114
122
  | `describe_brush` | One brush by `id`: its full facet `brush` (with its `colour`: default, palette, own), `builtin`, `engine`, `category` and `check` for this host (stamp stickers included). Unknown ids are refused with the closest ones. |
115
123
  | `create_brush` | Save a new brush: `id`, `name`, optional `basedOn`, and the facets, `colour` included (to keep an editor's current brush, pass the `brush` its `get_brush` returns). Normalised and checked for this host (and its sticker library, for stamp tips); refused brushes save nothing. Returns `id`, `brush`, `engine`, `problems`, `warnings`. |
116
- | `update_brush` | Change a saved brush: facets to merge in, `unset` facets to drop. Refuses built-ins (duplicate first) and changes the host can't render. Returns `brush`, `changed` paths, `problems`, `warnings`. |
124
+ | `update_brush` | Change a saved brush: facets to merge in, `unset` facets to drop. Refuses built-ins (duplicate first) and changes that add what the host can't render; keeps what the brush already had for other hosts. Returns `brush`, `changed` paths, `problems`, `warnings` and, when there are any, `kept` (facets this host can't use, left as they were). |
117
125
  | `duplicate_brush` | Copy any brush, built-ins included, to a saved brush (`newId` default `<id>-copy`, `name`). Returns the new `id` and `brush`; then `update_brush` it. |
118
126
  | `remove_brush` | Delete a saved brush for good (export it first to keep a copy). Built-ins are refused. Returns `removed`. |
119
127
  | `check_brush` | Check a brush (`id`, or an unsaved `brush` spec) for a `host` (paint, image, canvas, vector). Returns `ok`, `issues` (facet, severity, reason, fix) and, when refused, `degraded`. |
@@ -61,6 +61,7 @@ Ask when you cannot tell from the request; say what you assumed when you can.
61
61
  | A shape as the tip (stars, leaves, a logo) | `tip.shape` stamp with `stamps` (an editor stamp or a ref from `find_stickers`), continuous marks; it paints in the user's colour. Keep the sticker's colours with `marks` objects. Paint editor only. |
62
62
  | A spray can or mist | `basedOn` `spray-can`, or `medium` spray with `marks` scatter (`density`, `size`). Paint editor only. |
63
63
  | A change to a built-in | `duplicate_brush`, then `update_brush` the copy. |
64
+ | Tune a brush from a host that can't paint all of it | `update_brush` there: what the host can't use is kept (`kept`), not stripped; refused only if the change adds it. |
64
65
 
65
66
  ## Recipes
66
67
 
@@ -375,7 +375,7 @@ contents whole while you work, without losing the mask.
375
375
  | --- | --- |
376
376
  | `vector.listBrushes` | List the brushes a brushstroke can use: the dry presets (pencils, pastels, charcoal, crayon, chalk, markers, inks, ballpoint, gel pen, fineliner), then saved brushes from the brush library the vector profile admits, with their sizes and `builtin`. Brushes it refuses (wet, thick, particles, stickers, tools) are refused by `vector.addBrushstroke` with the reason. A saved brush is kept in the layer, so the document renders without the library. |
377
377
  | `vector.addBrushstroke` | Paint paths with a brush along their outline (`brushId`, `size`, `pressure` profile such as [0.2, 1, 0.2] for a taper, `color`, default the brush's default colour (ballpoint blue, chalk), else the path's stroke; `keepColour` keeps the path's colour): sketchy, hand-drawn or inked lines that stay editable. Pass a `seed` (any integer) so the brush gets its character, the seeded jitter and paper grain that make pencil, pastel and charcoal look real; `paper` picks the grain (`{ pattern, seed, scale, depth }`) or `null` turns it off. Returns the stroke stacks. |
378
- | `vector.setBrushstroke` | Change brushstroke layer `index` of path `id`: brush (another brush without `color` takes its default colour, unless `keepColour`), size, pressure, colour, opacity, `seed` (a new seed is a new take on the same stroke; null: plain dabs) and `paper` (replaced whole; null: no grain; {}: the default sanded paper). Remove it with `vector.removeStroke`. |
378
+ | `vector.setBrushstroke` | Change brushstroke layer `index` of path `id`: brush (another brush without `color` takes its default colour, unless `keepColour`; giving the same `brushId` again takes that saved brush as the library has it now), size, pressure, colour, opacity, `seed` (a new seed is a new take on the same stroke; null: plain dabs) and `paper` (replaced whole; null: no grain; {}: the default sanded paper). Remove it with `vector.removeStroke`. |
379
379
 
380
380
  Give brushstrokes a `seed` unless you want flat, even dabs: without one a charcoal or pastel line looks like a felt pen. Use different seeds on neighbouring strokes so they do not repeat each other, and `paper: null` for clean ink or marker lines that should not catch grain. The grain is laid in each path's own space, so it moves with the path.
381
381