@pixerate/editor 0.262.1 → 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 (89) hide show
  1. package/dist/animation-editor/index.cjs +60 -60
  2. package/dist/animation-editor/index.js +4 -4
  3. package/dist/brushes/index.cjs +158 -71
  4. package/dist/brushes/index.d.cts +3 -3
  5. package/dist/brushes/index.d.ts +3 -3
  6. package/dist/brushes/index.js +113 -26
  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-25Q5BEY6.js → brushstrokeRender-3MOI7PH4.js} +3 -3
  14. package/dist/{brushstrokeRender-N6UPZSQS.cjs → brushstrokeRender-SMMPIJF2.cjs} +13 -13
  15. package/dist/canvas/index.cjs +15 -14
  16. package/dist/canvas/index.js +3 -2
  17. package/dist/canvas/stickers.d.cts +5 -1
  18. package/dist/canvas/stickers.d.ts +5 -1
  19. package/dist/{chunk-X2EXYY4J.js → chunk-4OJC4MCD.js} +9 -8
  20. package/dist/{chunk-J5UQHWVL.js → chunk-6JL2D5SG.js} +27 -15
  21. package/dist/{chunk-APX63ILU.js → chunk-ACFSFUQH.js} +31 -0
  22. package/dist/{chunk-TZOX7KWV.cjs → chunk-BY5EBP26.cjs} +35 -14
  23. package/dist/{chunk-CQVTGBQI.js → chunk-CECCP2V7.js} +1 -1
  24. package/dist/{chunk-F7CPSRLN.js → chunk-DOZ6F2K2.js} +12 -4
  25. package/dist/{chunk-5IW65VQ6.js → chunk-EE7SAYBF.js} +24 -3
  26. package/dist/{chunk-PYTJBVW5.cjs → chunk-F3KKR6DD.cjs} +37 -36
  27. package/dist/{chunk-YLUIFXSL.cjs → chunk-FQC5TDB6.cjs} +35 -35
  28. package/dist/{chunk-UVZ7RQOE.cjs → chunk-G5ADO47G.cjs} +1 -1
  29. package/dist/{chunk-D4TE5JNW.js → chunk-HAUDEVMC.js} +1 -1
  30. package/dist/{chunk-EHALWBBD.js → chunk-JEML4FSA.js} +1 -1
  31. package/dist/{chunk-43NT242D.cjs → chunk-KXNZNOEF.cjs} +86 -86
  32. package/dist/{chunk-JSDND7DF.cjs → chunk-OTN6VB5S.cjs} +32 -1
  33. package/dist/{chunk-AVTPZO4Z.cjs → chunk-PE6YJMQT.cjs} +37 -25
  34. package/dist/{chunk-QAR2N7HZ.js → chunk-ROBSFJ6F.js} +1 -1
  35. package/dist/{chunk-7AUQ2UJ3.cjs → chunk-USJX5SW4.cjs} +10 -10
  36. package/dist/{chunk-3TQW5MPW.cjs → chunk-V7MJ4HIN.cjs} +23 -23
  37. package/dist/{chunk-6NZL24W4.js → chunk-WWI6FLH2.js} +1 -1
  38. package/dist/{chunk-RVGP2XLF.cjs → chunk-XORJ7UZO.cjs} +21 -13
  39. package/dist/image-editor/controller.d.cts +3 -0
  40. package/dist/image-editor/controller.d.ts +3 -0
  41. package/dist/image-editor/index.cjs +792 -788
  42. package/dist/image-editor/index.js +10 -6
  43. package/dist/image-editor/stickers.d.cts +7 -2
  44. package/dist/image-editor/stickers.d.ts +7 -2
  45. package/dist/image-editor/types.d.cts +7 -0
  46. package/dist/image-editor/types.d.ts +7 -0
  47. package/dist/paint-editor/brush-library-tools.d.cts +8 -1
  48. package/dist/paint-editor/brush-library-tools.d.ts +8 -1
  49. package/dist/paint-editor/controller.d.cts +7 -2
  50. package/dist/paint-editor/controller.d.ts +7 -2
  51. package/dist/paint-editor/index.cjs +581 -524
  52. package/dist/paint-editor/index.d.cts +1 -1
  53. package/dist/paint-editor/index.d.ts +1 -1
  54. package/dist/paint-editor/index.js +105 -48
  55. package/dist/paint-editor/sticker-art.d.cts +20 -10
  56. package/dist/paint-editor/sticker-art.d.ts +20 -10
  57. package/dist/paint-editor/stickers.d.cts +8 -1
  58. package/dist/paint-editor/stickers.d.ts +8 -1
  59. package/dist/paint-editor/stroke.d.cts +2 -0
  60. package/dist/paint-editor/stroke.d.ts +2 -0
  61. package/dist/stickers/browser.d.cts +10 -3
  62. package/dist/stickers/browser.d.ts +10 -3
  63. package/dist/stickers/combine.d.cts +2 -0
  64. package/dist/stickers/combine.d.ts +2 -0
  65. package/dist/stickers/conformance.d.cts +1 -1
  66. package/dist/stickers/conformance.d.ts +1 -1
  67. package/dist/stickers/errors.d.cts +1 -1
  68. package/dist/stickers/errors.d.ts +1 -1
  69. package/dist/stickers/fake.d.cts +4 -2
  70. package/dist/stickers/fake.d.ts +4 -2
  71. package/dist/stickers/helpers.d.cts +16 -2
  72. package/dist/stickers/helpers.d.ts +16 -2
  73. package/dist/stickers/index.cjs +116 -29
  74. package/dist/stickers/index.js +106 -19
  75. package/dist/stickers/tools.d.cts +9 -2
  76. package/dist/stickers/tools.d.ts +9 -2
  77. package/dist/stickers/types.d.cts +32 -5
  78. package/dist/stickers/types.d.ts +32 -5
  79. package/dist/vector/controller.d.cts +13 -0
  80. package/dist/vector/controller.d.ts +13 -0
  81. package/dist/vector/index.cjs +1218 -1207
  82. package/dist/vector/index.js +19 -8
  83. package/dist/vector/stickers.d.cts +7 -2
  84. package/dist/vector/stickers.d.ts +7 -2
  85. package/package.json +1 -1
  86. package/skills/pixerate-brushes/SKILL.md +11 -3
  87. package/skills/pixerate-brushes-design/SKILL.md +1 -0
  88. package/skills/pixerate-stickers/SKILL.md +20 -9
  89. package/skills/pixerate-vector/SKILL.md +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkJSDND7DFcjs = require('./chunk-JSDND7DF.cjs');
5
+ var _chunkOTN6VB5Scjs = require('./chunk-OTN6VB5S.cjs');
6
6
 
7
7
 
8
8
  var _chunkWOFXZ3XUcjs = require('./chunk-WOFXZ3XU.cjs');
@@ -31,7 +31,7 @@ var DEFAULT_STICKER = { stamps: ["editor:star"], density: 0.4, sizeJitter: 0.4,
31
31
  function normalizeStickerSettings(raw = {}, base = DEFAULT_STICKER) {
32
32
  const refs = (list2) => list2.flatMap((s) => {
33
33
  try {
34
- return [_chunkJSDND7DFcjs.normalizeStickerRef.call(void 0, s)];
34
+ return [_chunkOTN6VB5Scjs.normalizeStickerRef.call(void 0, s)];
35
35
  } catch (e2) {
36
36
  return [];
37
37
  }
@@ -78,7 +78,7 @@ function normalizeParticle(raw = {}, base = DEFAULT_PARTICLE) {
78
78
  const texture = (t) => {
79
79
  if (typeof t !== "string") return null;
80
80
  const bare = t.startsWith("editor:") ? t.slice(7) : t;
81
- if (_chunkJSDND7DFcjs.STAMP_KINDS.includes(bare)) return bare;
81
+ if (_chunkOTN6VB5Scjs.STAMP_KINDS.includes(bare)) return bare;
82
82
  return /^[^:\s]+:\S+$/.test(t) && t.length <= 200 ? t : null;
83
83
  };
84
84
  const textures = Array.isArray(raw.dotTextures) ? raw.dotTextures.map(texture).filter((t) => t !== null).slice(0, MAX_DOT_TEXTURES) : [..._nullishCoalesce(base.dotTextures, () => ( []))];
@@ -214,7 +214,7 @@ var DEFAULT_SPRAY = { density: 0.5, size: 0.12 };
214
214
  function readStamp(raw, base) {
215
215
  if (raw === null) return null;
216
216
  if (typeof raw !== "string") return base;
217
- if (_chunkJSDND7DFcjs.STAMP_KINDS.includes(raw)) return `editor:${raw}`;
217
+ if (_chunkOTN6VB5Scjs.STAMP_KINDS.includes(raw)) return `editor:${raw}`;
218
218
  return /^[^:\s]+:\S+$/.test(raw) && raw.length <= 200 ? raw : base;
219
219
  }
220
220
  function readSpray(raw, base) {
@@ -1068,7 +1068,7 @@ var NOT = { toEngine: (v) => !v, toFacet: (v) => !v };
1068
1068
  var EDITOR_STAMPS = {
1069
1069
  toEngine: (v) => v.flatMap((ref) => {
1070
1070
  try {
1071
- const stamp = _chunkJSDND7DFcjs.editorStampOf.call(void 0, ref);
1071
+ const stamp = _chunkOTN6VB5Scjs.editorStampOf.call(void 0, ref);
1072
1072
  return stamp ? [stamp] : ref.includes(":") ? [ref] : [];
1073
1073
  } catch (e3) {
1074
1074
  return [];
@@ -1296,11 +1296,11 @@ var object = (description, properties, required) => ({
1296
1296
  additionalProperties: false
1297
1297
  });
1298
1298
  var MIXING = oneOf2(["pigment", "rgb"], "How colours mix: pigment (Kubelka-Munk, blue and yellow make green) or rgb (straight averages). Default pigment; a Mixer Brush and the smudge tool default to rgb.");
1299
- var BRUSH_STAMP_PATTERN = `^(?:[^:\\s]+:\\S+|${_chunkJSDND7DFcjs.STAMP_KINDS.join("|")})$`;
1299
+ var BRUSH_STAMP_PATTERN = `^(?:[^:\\s]+:\\S+|${_chunkOTN6VB5Scjs.STAMP_KINDS.join("|")})$`;
1300
1300
  var STAMP = {
1301
1301
  type: "string",
1302
1302
  pattern: BRUSH_STAMP_PATTERN,
1303
- description: `A sticker ref provider:id (find_stickers lists them; the editor's own are ${_chunkJSDND7DFcjs.STAMP_KINDS.map((k) => `editor:${k}`).join(", ")}). A bare editor stamp (star) means editor:star.`
1303
+ description: `A sticker ref provider:id (find_stickers lists them; the editor's own are ${_chunkOTN6VB5Scjs.STAMP_KINDS.map((k) => `editor:${k}`).join(", ")}). A bare editor stamp (star) means editor:star.`
1304
1304
  };
1305
1305
  var BRISTLES = object("Bristle tips: the tuft. Missing fields take their defaults.", {
1306
1306
  count: int(3, 128, "Bristles in the tuft (default 32)."),
@@ -1711,7 +1711,7 @@ function normalizeBrushSpec(raw, problems = []) {
1711
1711
  delete brush.tip.stamps;
1712
1712
  }
1713
1713
  if (brush.tip.stamps) {
1714
- const stamps = brush.tip.stamps.map((s) => _chunkJSDND7DFcjs.normalizeStickerRef.call(void 0, s));
1714
+ const stamps = brush.tip.stamps.map((s) => _chunkOTN6VB5Scjs.normalizeStickerRef.call(void 0, s));
1715
1715
  if (stamps.length) brush.tip.stamps = stamps;
1716
1716
  else {
1717
1717
  drop("tip.stamps", "none of the stamps can be laid");
@@ -2605,11 +2605,20 @@ function checkBrush(brush, profile) {
2605
2605
  if (foreign.length) add("colour.palette", "warning", `${host} skips the palette's ${list(foreign)} colours.`, `Nothing to do; or keep to ${list(profile.colours)} colours.`);
2606
2606
  return { ok: !issues.some((i) => i.severity === "error"), issues };
2607
2607
  }
2608
+ function withKeptIssues(check, before) {
2609
+ const had = new Set((_nullishCoalesce(_optionalChain([before, 'optionalAccess', _55 => _55.issues]), () => ( []))).filter((i) => i.severity === "error").map((i) => i.facet));
2610
+ const kept = check.issues.filter((i) => i.severity === "error" && had.has(i.facet));
2611
+ const issues = check.issues.filter((i) => !kept.includes(i));
2612
+ return { ok: !issues.some((i) => i.severity === "error"), issues, kept };
2613
+ }
2614
+ function checkBrushEdit(original, brush, profile) {
2615
+ return withKeptIssues(checkBrush(brush, profile), original ? checkBrush(original, profile) : null);
2616
+ }
2608
2617
  function listPresets(profile, presets = BRUSH_PRESETS) {
2609
2618
  return presets.filter((b) => checkBrush(b, profile).ok);
2610
2619
  }
2611
- function degrade(brush, profile) {
2612
- const before = checkBrush(brush, profile).issues.filter((i) => i.severity === "error");
2620
+ function degrade(brush, profile, options = {}) {
2621
+ const before = checkBrush(brush, profile).issues.filter((i) => i.severity === "error" || options.ignored);
2613
2622
  const b = JSON.parse(JSON.stringify(brush));
2614
2623
  const dropped = [];
2615
2624
  for (const issue of before) {
@@ -2658,12 +2667,17 @@ function degrade(brush, profile) {
2658
2667
  case "colour.default":
2659
2668
  delete b.colour.default;
2660
2669
  break;
2670
+ case "colour.palette":
2671
+ b.colour.palette = b.colour.palette.filter((c) => profile.colours.includes(brushColourKind(c)));
2672
+ if (!b.colour.palette.length) delete b.colour.palette;
2673
+ break;
2661
2674
  default:
2662
2675
  continue;
2663
2676
  }
2664
2677
  dropped.push(issue);
2665
2678
  }
2666
- if (_optionalChain([b, 'access', _55 => _55.behaviour, 'optionalAccess', _56 => _56.exchange]) && !Object.keys(b.behaviour.exchange).length) delete b.behaviour.exchange;
2679
+ if (_optionalChain([b, 'access', _56 => _56.behaviour, 'optionalAccess', _57 => _57.exchange]) && !Object.keys(b.behaviour.exchange).length) delete b.behaviour.exchange;
2680
+ if (b.colour && !Object.keys(b.colour).length) delete b.colour;
2667
2681
  const after = checkBrush(b, profile).issues.filter((i) => i.severity === "error");
2668
2682
  return { brush: b, dropped, issues: after };
2669
2683
  }
@@ -2677,6 +2691,10 @@ var BrushLibraryError = class extends Error {
2677
2691
  }
2678
2692
 
2679
2693
  };
2694
+ function isBrushLibrary(library) {
2695
+ const l = library;
2696
+ return !!l && typeof l.list === "function" && typeof l.get === "function" && typeof l.save === "function" && typeof l.isBuiltin === "function" && typeof l.subscribe === "function";
2697
+ }
2680
2698
  var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
2681
2699
  var isV1 = (item) => "engine" in item || "category" in item || !("kind" in item);
2682
2700
  function parseBrushLibrary2(raw, problems = []) {
@@ -2693,7 +2711,7 @@ function parseBrushLibrary2(raw, problems = []) {
2693
2711
  if (file && file.version !== void 0 && file.version !== 1 && file.version !== 2) {
2694
2712
  throw new BrushLibraryError("invalid", `Brush library version ${JSON.stringify(file.version)} is not supported; this library reads versions 1 and 2.`);
2695
2713
  }
2696
- const v1File = _optionalChain([file, 'optionalAccess', _57 => _57.version]) === 1;
2714
+ const v1File = _optionalChain([file, 'optionalAccess', _58 => _58.version]) === 1;
2697
2715
  const out = [];
2698
2716
  items.forEach((item, i) => {
2699
2717
  const at = `brushes[${i}]`;
@@ -2876,7 +2894,7 @@ function snapshotBrushLibrary(library, onChange) {
2876
2894
  (list2) => {
2877
2895
  entries = list2;
2878
2896
  user = list2.filter((e) => !e.builtin).map((e) => e.brush);
2879
- _optionalChain([onChange, 'optionalCall', _58 => _58()]);
2897
+ _optionalChain([onChange, 'optionalCall', _59 => _59()]);
2880
2898
  },
2881
2899
  () => void 0
2882
2900
  );
@@ -2980,4 +2998,7 @@ function snapshotBrushLibrary(library, onChange) {
2980
2998
 
2981
2999
 
2982
3000
 
2983
- exports.MAX_STICKER_STAMPS = MAX_STICKER_STAMPS; exports.DEFAULT_STICKER = DEFAULT_STICKER; exports.normalizeStickerSettings = normalizeStickerSettings; exports.PARTICLE_KINDS = PARTICLE_KINDS; exports.PARTICLE_RENDERS = PARTICLE_RENDERS; exports.RIBBON_PAIRS = RIBBON_PAIRS; exports.DOT_TEXTURE_ORDERS = DOT_TEXTURE_ORDERS; exports.DOT_ROTATIONS = DOT_ROTATIONS; exports.MAX_DOT_TEXTURES = MAX_DOT_TEXTURES; exports.DEFAULT_PARTICLE = DEFAULT_PARTICLE; exports.normalizeParticle = normalizeParticle; exports.DEFAULT_BRISTLE = DEFAULT_BRISTLE; exports.normalizeBristle = normalizeBristle; exports.PAINT_BRUSH_ENGINES = PAINT_BRUSH_ENGINES; exports.PAINT_BRUSH_CATEGORIES = PAINT_BRUSH_CATEGORIES; exports.WET_TOOLS = WET_TOOLS; exports.WET_MEDIA = WET_MEDIA; exports.DEFAULT_WET_BRUSH = DEFAULT_WET_BRUSH; exports.normalizeWetBrush = normalizeWetBrush; exports.IMPASTO_TOOLS = IMPASTO_TOOLS; exports.DEFAULT_IMPASTO = DEFAULT_IMPASTO; exports.DEFAULT_LIGHT = DEFAULT_LIGHT; exports.normalizeLight = normalizeLight; exports.normalizeImpasto = normalizeImpasto; exports.MULTI_COLOR_MODES = MULTI_COLOR_MODES; exports.DEFAULT_MULTI_COLOR = DEFAULT_MULTI_COLOR; exports.DEFAULT_BEHAVIOR = DEFAULT_BEHAVIOR; exports.BRUSH_ROTATIONS = BRUSH_ROTATIONS; exports.DEFAULT_DYNAMICS = DEFAULT_DYNAMICS; exports.normalizeDynamics = normalizeDynamics; exports.BRUSH_ID = BRUSH_ID; exports.normalizeMultiColor = normalizeMultiColor; exports.normalizeBehavior = normalizeBehavior; exports.DEFAULT_SPRAY = DEFAULT_SPRAY; exports.isWetCapable = isWetCapable; exports.isWetBrush = isWetBrush; exports.usesPaintExchange = usesPaintExchange; exports.brushTakesPaint = brushTakesPaint; exports.paintToMultiColor = paintToMultiColor; exports.multiColorToPaint = multiColorToPaint; exports.normalizePaintBrush = normalizePaintBrush; exports.BUILTIN_BRUSHES = BUILTIN_BRUSHES; exports.DEFAULT_BRUSH_ID = DEFAULT_BRUSH_ID; exports.brushToJSON = brushToJSON; exports.parseBrushLibrary = parseBrushLibrary; exports.BRUSH_FIELDS = BRUSH_FIELDS; exports.getPath = getPath; exports.setPath = setPath; exports.resolveEngine = resolveEngine; exports.resolveWetMedium = resolveWetMedium; exports.resolveCategory = resolveCategory; exports.resolveBrush = resolveBrush; exports.migrateBrushV1 = migrateBrushV1; exports.BRUSH_KINDS = BRUSH_KINDS; exports.BRUSH_MEDIA = BRUSH_MEDIA; exports.BRUSH_TOOLS = BRUSH_TOOLS; exports.BRUSH_TIP_SHAPES = BRUSH_TIP_SHAPES; exports.BRUSH_MARKS_KINDS = BRUSH_MARKS_KINDS; exports.BRUSH_SURFACES = BRUSH_SURFACES; exports.MAX_BRUSH_PALETTE = MAX_BRUSH_PALETTE; exports.BRUSH_WORD = BRUSH_WORD; exports.BRUSH_JSON_SCHEMA = BRUSH_JSON_SCHEMA; exports.BRUSH_FACET_SCHEMAS = BRUSH_FACET_SCHEMAS; exports.WET_BRUSH_TOOLS = WET_BRUSH_TOOLS; exports.normalizeBrushSpec = normalizeBrushSpec; exports.BRUSH_PRESETS = BRUSH_PRESETS; exports.PAINT_PROFILE = PAINT_PROFILE; exports.IMAGE_PROFILE = IMAGE_PROFILE; exports.CANVAS_PROFILE = CANVAS_PROFILE; exports.VECTOR_PROFILE = VECTOR_PROFILE; exports.BRUSH_HOST_PROFILES = BRUSH_HOST_PROFILES; exports.brushColourKind = brushColourKind; exports.checkBrush = checkBrush; exports.listPresets = listPresets; exports.degrade = degrade; exports.BrushLibraryError = BrushLibraryError; exports.parseBrushLibrary2 = parseBrushLibrary2; exports.createBrushLibrary = createBrushLibrary; exports.closest = closest; exports.snapshotBrushLibrary = snapshotBrushLibrary;
3001
+
3002
+
3003
+
3004
+ exports.MAX_STICKER_STAMPS = MAX_STICKER_STAMPS; exports.DEFAULT_STICKER = DEFAULT_STICKER; exports.normalizeStickerSettings = normalizeStickerSettings; exports.PARTICLE_KINDS = PARTICLE_KINDS; exports.PARTICLE_RENDERS = PARTICLE_RENDERS; exports.RIBBON_PAIRS = RIBBON_PAIRS; exports.DOT_TEXTURE_ORDERS = DOT_TEXTURE_ORDERS; exports.DOT_ROTATIONS = DOT_ROTATIONS; exports.MAX_DOT_TEXTURES = MAX_DOT_TEXTURES; exports.DEFAULT_PARTICLE = DEFAULT_PARTICLE; exports.normalizeParticle = normalizeParticle; exports.DEFAULT_BRISTLE = DEFAULT_BRISTLE; exports.normalizeBristle = normalizeBristle; exports.PAINT_BRUSH_ENGINES = PAINT_BRUSH_ENGINES; exports.PAINT_BRUSH_CATEGORIES = PAINT_BRUSH_CATEGORIES; exports.WET_TOOLS = WET_TOOLS; exports.WET_MEDIA = WET_MEDIA; exports.DEFAULT_WET_BRUSH = DEFAULT_WET_BRUSH; exports.normalizeWetBrush = normalizeWetBrush; exports.IMPASTO_TOOLS = IMPASTO_TOOLS; exports.DEFAULT_IMPASTO = DEFAULT_IMPASTO; exports.DEFAULT_LIGHT = DEFAULT_LIGHT; exports.normalizeLight = normalizeLight; exports.normalizeImpasto = normalizeImpasto; exports.MULTI_COLOR_MODES = MULTI_COLOR_MODES; exports.DEFAULT_MULTI_COLOR = DEFAULT_MULTI_COLOR; exports.DEFAULT_BEHAVIOR = DEFAULT_BEHAVIOR; exports.BRUSH_ROTATIONS = BRUSH_ROTATIONS; exports.DEFAULT_DYNAMICS = DEFAULT_DYNAMICS; exports.normalizeDynamics = normalizeDynamics; exports.BRUSH_ID = BRUSH_ID; exports.normalizeMultiColor = normalizeMultiColor; exports.normalizeBehavior = normalizeBehavior; exports.DEFAULT_SPRAY = DEFAULT_SPRAY; exports.isWetCapable = isWetCapable; exports.isWetBrush = isWetBrush; exports.usesPaintExchange = usesPaintExchange; exports.brushTakesPaint = brushTakesPaint; exports.paintToMultiColor = paintToMultiColor; exports.multiColorToPaint = multiColorToPaint; exports.normalizePaintBrush = normalizePaintBrush; exports.BUILTIN_BRUSHES = BUILTIN_BRUSHES; exports.DEFAULT_BRUSH_ID = DEFAULT_BRUSH_ID; exports.brushToJSON = brushToJSON; exports.parseBrushLibrary = parseBrushLibrary; exports.BRUSH_FIELDS = BRUSH_FIELDS; exports.getPath = getPath; exports.setPath = setPath; exports.resolveEngine = resolveEngine; exports.resolveWetMedium = resolveWetMedium; exports.resolveCategory = resolveCategory; exports.resolveBrush = resolveBrush; exports.migrateBrushV1 = migrateBrushV1; exports.BRUSH_KINDS = BRUSH_KINDS; exports.BRUSH_MEDIA = BRUSH_MEDIA; exports.BRUSH_TOOLS = BRUSH_TOOLS; exports.BRUSH_TIP_SHAPES = BRUSH_TIP_SHAPES; exports.BRUSH_MARKS_KINDS = BRUSH_MARKS_KINDS; exports.BRUSH_SURFACES = BRUSH_SURFACES; exports.MAX_BRUSH_PALETTE = MAX_BRUSH_PALETTE; exports.BRUSH_WORD = BRUSH_WORD; exports.BRUSH_JSON_SCHEMA = BRUSH_JSON_SCHEMA; exports.BRUSH_FACET_SCHEMAS = BRUSH_FACET_SCHEMAS; exports.WET_BRUSH_TOOLS = WET_BRUSH_TOOLS; exports.normalizeBrushSpec = normalizeBrushSpec; exports.BRUSH_PRESETS = BRUSH_PRESETS; exports.PAINT_PROFILE = PAINT_PROFILE; exports.IMAGE_PROFILE = IMAGE_PROFILE; exports.CANVAS_PROFILE = CANVAS_PROFILE; exports.VECTOR_PROFILE = VECTOR_PROFILE; exports.BRUSH_HOST_PROFILES = BRUSH_HOST_PROFILES; exports.brushColourKind = brushColourKind; exports.checkBrush = checkBrush; exports.withKeptIssues = withKeptIssues; exports.checkBrushEdit = checkBrushEdit; exports.listPresets = listPresets; exports.degrade = degrade; exports.BrushLibraryError = BrushLibraryError; exports.isBrushLibrary = isBrushLibrary; exports.parseBrushLibrary2 = parseBrushLibrary2; exports.createBrushLibrary = createBrushLibrary; exports.closest = closest; exports.snapshotBrushLibrary = snapshotBrushLibrary;
@@ -5,7 +5,7 @@ import {
5
5
  moveAnchorHandle,
6
6
  subpathSegment,
7
7
  subpathSegmentCount
8
- } from "./chunk-6NZL24W4.js";
8
+ } from "./chunk-WWI6FLH2.js";
9
9
  import {
10
10
  segmentPoint
11
11
  } from "./chunk-WEIK3UYB.js";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  EDITOR_STICKERS_ID,
3
3
  STAMP_KINDS,
4
+ checkStickerVariant,
4
5
  stampCoverage,
5
6
  stickerPage,
6
7
  stickerRefOf
7
- } from "./chunk-APX63ILU.js";
8
+ } from "./chunk-ACFSFUQH.js";
8
9
  import {
9
10
  StickerError
10
11
  } from "./chunk-SZTI6EER.js";
@@ -209,6 +210,7 @@ function editorStickers() {
209
210
  categories: () => [...new Set(STAMP_KINDS.map((k) => META[k].category))].map((c) => ({ id: c, name: c[0].toUpperCase() + c.slice(1), count: STAMP_KINDS.filter((k) => META[k].category === c).length })),
210
211
  load(id, options = {}) {
211
212
  const k = kind(id);
213
+ checkStickerVariant({ id: k }, options.variant);
212
214
  const colour = options.colour ?? META[k].colour;
213
215
  if (!HEX.test(colour)) throw new StickerError("invalid_argument", `colour ${JSON.stringify(colour)} must be #rrggbb.`);
214
216
  if (options.format === "png") {
@@ -229,7 +231,7 @@ var StickerBrowser = class {
229
231
  constructor(provider, pageSize = 24) {
230
232
  this.provider = provider;
231
233
  this.pageSize = pageSize;
232
- this.s = { query: "", category: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], provider: provider().name };
234
+ this.s = { query: "", category: "", collection: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], collections: [], provider: provider().name };
233
235
  }
234
236
  provider;
235
237
  pageSize;
@@ -256,8 +258,9 @@ var StickerBrowser = class {
256
258
  this.set({ loading: true, error: null, items: [], total: 0, hasMore: false, provider: p.name });
257
259
  try {
258
260
  const categories = await p.categories?.() ?? [];
261
+ const collections = await p.listCollections?.() ?? [];
259
262
  if (run !== this.run) return;
260
- this.set({ categories });
263
+ this.set({ categories, collections, ...this.s.collection && !collections.some((c) => c.id === this.s.collection) ? { collection: "" } : {} });
261
264
  await this.page(run, p, true);
262
265
  } catch (e) {
263
266
  if (run === this.run) this.set({ loading: false, error: e instanceof Error ? e.message : String(e) });
@@ -273,6 +276,11 @@ var StickerBrowser = class {
273
276
  this.s = { ...this.s, category };
274
277
  return this.refresh();
275
278
  }
279
+ /** Shows one collection (`''` for all) from the first page. */
280
+ setCollection(collection) {
281
+ this.s = { ...this.s, collection };
282
+ return this.refresh();
283
+ }
276
284
  /** Loads the next page onto the list. */
277
285
  async more() {
278
286
  if (!this.next || this.s.loading) return;
@@ -285,7 +293,7 @@ var StickerBrowser = class {
285
293
  }
286
294
  }
287
295
  async page(run, p, first) {
288
- const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...!first && this.next ? { after: this.next } : {} };
296
+ const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...this.s.collection ? { collection: this.s.collection } : {}, ...!first && this.next ? { after: this.next } : {} };
289
297
  const q = this.s.query.trim();
290
298
  const res = q && p.capabilities.supportsSearch ? await p.search(q, options) : await p.list(options);
291
299
  if (run !== this.run) return;
@@ -2,7 +2,7 @@ import {
2
2
  STAMP_KINDS,
3
3
  editorStampOf,
4
4
  normalizeStickerRef
5
- } from "./chunk-APX63ILU.js";
5
+ } from "./chunk-ACFSFUQH.js";
6
6
  import {
7
7
  validateJsonSchema
8
8
  } from "./chunk-V2ZCJRDM.js";
@@ -2605,11 +2605,20 @@ function checkBrush(brush, profile) {
2605
2605
  if (foreign.length) add("colour.palette", "warning", `${host} skips the palette's ${list(foreign)} colours.`, `Nothing to do; or keep to ${list(profile.colours)} colours.`);
2606
2606
  return { ok: !issues.some((i) => i.severity === "error"), issues };
2607
2607
  }
2608
+ function withKeptIssues(check, before) {
2609
+ const had = new Set((before?.issues ?? []).filter((i) => i.severity === "error").map((i) => i.facet));
2610
+ const kept = check.issues.filter((i) => i.severity === "error" && had.has(i.facet));
2611
+ const issues = check.issues.filter((i) => !kept.includes(i));
2612
+ return { ok: !issues.some((i) => i.severity === "error"), issues, kept };
2613
+ }
2614
+ function checkBrushEdit(original, brush, profile) {
2615
+ return withKeptIssues(checkBrush(brush, profile), original ? checkBrush(original, profile) : null);
2616
+ }
2608
2617
  function listPresets(profile, presets = BRUSH_PRESETS) {
2609
2618
  return presets.filter((b) => checkBrush(b, profile).ok);
2610
2619
  }
2611
- function degrade(brush, profile) {
2612
- const before = checkBrush(brush, profile).issues.filter((i) => i.severity === "error");
2620
+ function degrade(brush, profile, options = {}) {
2621
+ const before = checkBrush(brush, profile).issues.filter((i) => i.severity === "error" || options.ignored);
2613
2622
  const b = JSON.parse(JSON.stringify(brush));
2614
2623
  const dropped = [];
2615
2624
  for (const issue of before) {
@@ -2658,12 +2667,17 @@ function degrade(brush, profile) {
2658
2667
  case "colour.default":
2659
2668
  delete b.colour.default;
2660
2669
  break;
2670
+ case "colour.palette":
2671
+ b.colour.palette = b.colour.palette.filter((c) => profile.colours.includes(brushColourKind(c)));
2672
+ if (!b.colour.palette.length) delete b.colour.palette;
2673
+ break;
2661
2674
  default:
2662
2675
  continue;
2663
2676
  }
2664
2677
  dropped.push(issue);
2665
2678
  }
2666
2679
  if (b.behaviour?.exchange && !Object.keys(b.behaviour.exchange).length) delete b.behaviour.exchange;
2680
+ if (b.colour && !Object.keys(b.colour).length) delete b.colour;
2667
2681
  const after = checkBrush(b, profile).issues.filter((i) => i.severity === "error");
2668
2682
  return { brush: b, dropped, issues: after };
2669
2683
  }
@@ -2677,6 +2691,10 @@ var BrushLibraryError = class extends Error {
2677
2691
  }
2678
2692
  code;
2679
2693
  };
2694
+ function isBrushLibrary(library) {
2695
+ const l = library;
2696
+ return !!l && typeof l.list === "function" && typeof l.get === "function" && typeof l.save === "function" && typeof l.isBuiltin === "function" && typeof l.subscribe === "function";
2697
+ }
2680
2698
  var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
2681
2699
  var isV1 = (item) => "engine" in item || "category" in item || !("kind" in item);
2682
2700
  function parseBrushLibrary2(raw, problems = []) {
@@ -2973,9 +2991,12 @@ export {
2973
2991
  BRUSH_HOST_PROFILES,
2974
2992
  brushColourKind,
2975
2993
  checkBrush,
2994
+ withKeptIssues,
2995
+ checkBrushEdit,
2976
2996
  listPresets,
2977
2997
  degrade,
2978
2998
  BrushLibraryError,
2999
+ isBrushLibrary,
2979
3000
  parseBrushLibrary2,
2980
3001
  createBrushLibrary,
2981
3002
  closest,
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkAVTPZO4Zcjs = require('./chunk-AVTPZO4Z.cjs');
3
+ var _chunkPE6YJMQTcjs = require('./chunk-PE6YJMQT.cjs');
4
4
 
5
5
 
6
6
 
@@ -15,12 +15,13 @@ var _chunkAVTPZO4Zcjs = require('./chunk-AVTPZO4Z.cjs');
15
15
 
16
16
 
17
17
 
18
- var _chunkTZOX7KWVcjs = require('./chunk-TZOX7KWV.cjs');
18
+
19
+ var _chunkBY5EBP26cjs = require('./chunk-BY5EBP26.cjs');
19
20
 
20
21
  // src/brushes/patch.ts
21
22
  var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
22
23
  var copy = (v) => JSON.parse(JSON.stringify(v));
23
- var FACETS = _chunkTZOX7KWVcjs.BRUSH_JSON_SCHEMA.properties;
24
+ var FACETS = _chunkBY5EBP26cjs.BRUSH_JSON_SCHEMA.properties;
24
25
  var BRUSH_PATCH_PROPERTIES = (() => {
25
26
  const { id: _id, name: _name, ...rest } = FACETS;
26
27
  const { required: _r, ...tip } = rest.tip;
@@ -52,17 +53,17 @@ function changedBrushPaths(a, b, path = "") {
52
53
  // src/brushes/tools.ts
53
54
  var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
54
55
  var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
55
- var FACETS2 = _chunkTZOX7KWVcjs.BRUSH_JSON_SCHEMA.properties;
56
+ var FACETS2 = _chunkBY5EBP26cjs.BRUSH_JSON_SCHEMA.properties;
56
57
  var ID = { type: "string", pattern: String(FACETS2.id.pattern), description: "Brush id from list_brush_presets (lowercase letters, digits and dashes)." };
57
58
  var FACET_PROPS = BRUSH_PATCH_PROPERTIES;
58
- var HOSTS = Object.keys(_chunkTZOX7KWVcjs.BRUSH_HOST_PROFILES);
59
+ var HOSTS = Object.keys(_chunkBY5EBP26cjs.BRUSH_HOST_PROFILES);
59
60
  var copy2 = (v) => JSON.parse(JSON.stringify(v));
60
61
  var merge = mergeBrushPatch;
61
62
  var changedPaths = changedBrushPaths;
62
63
  function summary(entry, profile, withCheck) {
63
64
  const b = entry.brush;
64
- const engine = _chunkTZOX7KWVcjs.resolveEngine.call(void 0, b);
65
- const check = withCheck ? _chunkTZOX7KWVcjs.checkBrush.call(void 0, b, profile) : null;
65
+ const engine = _chunkBY5EBP26cjs.resolveEngine.call(void 0, b);
66
+ const check = withCheck ? _chunkBY5EBP26cjs.checkBrush.call(void 0, b, profile) : null;
66
67
  return {
67
68
  id: b.id,
68
69
  name: b.name,
@@ -71,7 +72,7 @@ function summary(entry, profile, withCheck) {
71
72
  ...b.medium ? { medium: b.medium } : {},
72
73
  ...b.variety ? { variety: b.variety } : {},
73
74
  ...b.tool ? { tool: b.tool } : {},
74
- category: _chunkTZOX7KWVcjs.resolveCategory.call(void 0, b, engine),
75
+ category: _chunkBY5EBP26cjs.resolveCategory.call(void 0, b, engine),
75
76
  engine,
76
77
  tip: b.tip.shape,
77
78
  ...b.tip.size !== void 0 ? { size: b.tip.size } : {},
@@ -85,44 +86,44 @@ function summary(entry, profile, withCheck) {
85
86
  var refusal = (check, host) => `${host.name} can't use this brush: ${check.issues.filter((i) => i.severity === "error").map((i) => `${i.facet}: ${i.reason} ${i.fix}`).join(" ")} (check_brush lists every issue; nothing was saved.)`;
86
87
  var warnings = (check) => check.issues.filter((i) => i.severity === "warning");
87
88
  function createBrushLibraryTools(library, options = {}) {
88
- const profile = _nullishCoalesce(options.profile, () => ( _chunkTZOX7KWVcjs.PAINT_PROFILE));
89
+ const profile = _nullishCoalesce(options.profile, () => ( _chunkBY5EBP26cjs.PAINT_PROFILE));
89
90
  const hostOf = (id) => {
90
91
  if (id === void 0) return profile;
91
- const p = _chunkTZOX7KWVcjs.BRUSH_HOST_PROFILES[id];
92
- if (!p) throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("invalid", `No host "${id}"; use one of: ${HOSTS.join(", ")}.`);
92
+ const p = _chunkBY5EBP26cjs.BRUSH_HOST_PROFILES[id];
93
+ if (!p) throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("invalid", `No host "${id}"; use one of: ${HOSTS.join(", ")}.`);
93
94
  return p;
94
95
  };
95
96
  const entry = async (id) => {
96
97
  const found = await library.get(id);
97
98
  if (found) return found;
98
99
  const ids = (await library.list()).map((e) => e.brush.id);
99
- throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("unknown_brush", `No brush "${id}". ${_chunkTZOX7KWVcjs.closest.call(void 0, id, ids)}list_brush_presets lists them.`);
100
+ throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("unknown_brush", `No brush "${id}". ${_chunkBY5EBP26cjs.closest.call(void 0, id, ids)}list_brush_presets lists them.`);
100
101
  };
101
102
  const checkFor = async (brush, p) => {
102
- const check2 = _chunkTZOX7KWVcjs.checkBrush.call(void 0, brush, p);
103
+ const check2 = _chunkBY5EBP26cjs.checkBrush.call(void 0, brush, p);
103
104
  const provider = _optionalChain([options, 'access', _9 => _9.stickers, 'optionalCall', _10 => _10()]);
104
105
  if (!provider || brush.tip.shape !== "stamp") return check2;
105
106
  const issues = [...check2.issues];
106
107
  for (const ref of _nullishCoalesce(brush.tip.stamps, () => ( []))) {
107
108
  if (ref.startsWith("editor:")) continue;
108
109
  try {
109
- await _chunkAVTPZO4Zcjs.describeStickerRef.call(void 0, provider, ref);
110
+ await _chunkPE6YJMQTcjs.describeStickerRef.call(void 0, provider, ref);
110
111
  } catch (e) {
111
112
  issues.push({ facet: "tip.stamps", severity: "error", reason: `${p.name} can't load sticker "${ref}": ${e.message}`, fix: "Use a ref from find_stickers, or an editor stamp (editor:star, editor:dot\u2026)." });
112
113
  }
113
114
  }
114
115
  return { ok: !issues.some((i) => i.severity === "error"), issues };
115
116
  };
116
- const store = async (raw, overwrite) => {
117
+ const store = async (raw, overwrite, original) => {
117
118
  const problems = [];
118
119
  let brush;
119
120
  try {
120
- brush = _chunkTZOX7KWVcjs.normalizeBrushSpec.call(void 0, raw, problems);
121
+ brush = _chunkBY5EBP26cjs.normalizeBrushSpec.call(void 0, raw, problems);
121
122
  } catch (e) {
122
- throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("invalid", e.message);
123
+ throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("invalid", e.message);
123
124
  }
124
- const check2 = await checkFor(brush, profile);
125
- if (!check2.ok) throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("invalid", refusal(check2, profile));
125
+ const check2 = _chunkBY5EBP26cjs.withKeptIssues.call(void 0, await checkFor(brush, profile), original ? await checkFor(original, profile) : null);
126
+ if (!check2.ok) throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("invalid", refusal(check2, profile));
126
127
  const saved = await library.save(brush, { overwrite });
127
128
  return { ...saved, problems, check: check2 };
128
129
  };
@@ -133,10 +134,10 @@ function createBrushLibraryTools(library, options = {}) {
133
134
  inputSchema: {
134
135
  type: "object",
135
136
  properties: {
136
- kind: { type: "string", enum: [..._chunkTZOX7KWVcjs.BRUSH_KINDS], description: "mark (lays a material) or tool (works on paint already down)." },
137
- medium: { type: "string", enum: [..._chunkTZOX7KWVcjs.BRUSH_MEDIA], description: "Marks laying this medium." },
137
+ kind: { type: "string", enum: [..._chunkBY5EBP26cjs.BRUSH_KINDS], description: "mark (lays a material) or tool (works on paint already down)." },
138
+ medium: { type: "string", enum: [..._chunkBY5EBP26cjs.BRUSH_MEDIA], description: "Marks laying this medium." },
138
139
  variety: { type: "string", maxLength: 40, description: "This variety (oil, watercolor, pencil, highlighter\u2026)." },
139
- tool: { type: "string", enum: [..._chunkTZOX7KWVcjs.BRUSH_TOOLS], description: "Tools that do this." },
140
+ tool: { type: "string", enum: [..._chunkBY5EBP26cjs.BRUSH_TOOLS], description: "Tools that do this." },
140
141
  tag: { type: "string", maxLength: 40, description: "Brushes with this tag." },
141
142
  text: { type: "string", maxLength: 200, description: "Words in the id, name, description, variety or tags (each word must match the start of one)." },
142
143
  source: { type: "string", enum: ["all", "builtin", "user"], description: "all (default), builtin presets only, or user (saved) brushes only." },
@@ -163,8 +164,8 @@ function createBrushLibraryTools(library, options = {}) {
163
164
  annotations: { title: "Describe a brush", ...READ },
164
165
  handler: async ({ id }) => {
165
166
  const e = await entry(id);
166
- const engine = _chunkTZOX7KWVcjs.resolveEngine.call(void 0, e.brush);
167
- return { brush: e.brush, builtin: e.builtin, engine, category: _chunkTZOX7KWVcjs.resolveCategory.call(void 0, e.brush, engine), check: await checkFor(e.brush, profile) };
167
+ const engine = _chunkBY5EBP26cjs.resolveEngine.call(void 0, e.brush);
168
+ return { brush: e.brush, builtin: e.builtin, engine, category: _chunkBY5EBP26cjs.resolveCategory.call(void 0, e.brush, engine), check: await checkFor(e.brush, profile) };
168
169
  }
169
170
  };
170
171
  const check = {
@@ -182,20 +183,20 @@ function createBrushLibraryTools(library, options = {}) {
182
183
  },
183
184
  annotations: { title: "Check a brush for a host", ...READ },
184
185
  handler: async ({ id, brush, host }) => {
185
- if (id === void 0 === (brush === void 0)) throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("invalid", "Give either id (a library brush) or brush (a spec), not both or neither.");
186
+ if (id === void 0 === (brush === void 0)) throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("invalid", "Give either id (a library brush) or brush (a spec), not both or neither.");
186
187
  const p = hostOf(host);
187
188
  let b;
188
189
  const problems = [];
189
190
  if (id !== void 0) b = (await entry(id)).brush;
190
191
  else {
191
192
  try {
192
- b = _chunkTZOX7KWVcjs.normalizeBrushSpec.call(void 0, brush, problems);
193
+ b = _chunkBY5EBP26cjs.normalizeBrushSpec.call(void 0, brush, problems);
193
194
  } catch (e) {
194
- throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("invalid", e.message);
195
+ throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("invalid", e.message);
195
196
  }
196
197
  }
197
198
  const result = await checkFor(b, p);
198
- return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded: _chunkTZOX7KWVcjs.degrade.call(void 0, b, p) } : {} };
199
+ return { host: p.id, ...result, ...problems.length ? { problems } : {}, ...!result.ok ? { degraded: _chunkBY5EBP26cjs.degrade.call(void 0, b, p) } : {} };
199
200
  }
200
201
  };
201
202
  const exportTool = {
@@ -254,18 +255,18 @@ function createBrushLibraryTools(library, options = {}) {
254
255
  },
255
256
  annotations: { title: "Save a new brush", ...WRITE },
256
257
  handler: async ({ basedOn, ...spec }) => {
257
- if (library.isBuiltin(spec.id)) throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("builtin", `"${spec.id}" is a built-in brush id; pick another id (or basedOn "${spec.id}" with a new id).`);
258
- if (await library.get(spec.id)) throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("exists", `A brush "${spec.id}" exists already; pick another id, or change it with update_brush.`);
258
+ if (library.isBuiltin(spec.id)) throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("builtin", `"${spec.id}" is a built-in brush id; pick another id (or basedOn "${spec.id}" with a new id).`);
259
+ if (await library.get(spec.id)) throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("exists", `A brush "${spec.id}" exists already; pick another id, or change it with update_brush.`);
259
260
  const base = basedOn !== void 0 ? (await entry(basedOn)).brush : void 0;
260
261
  const raw = base ? merge(base, spec) : spec;
261
262
  const saved = await store(raw, false);
262
- return { id: saved.brush.id, brush: saved.brush, engine: _chunkTZOX7KWVcjs.resolveEngine.call(void 0, saved.brush), problems: saved.problems, warnings: warnings(saved.check) };
263
+ return { id: saved.brush.id, brush: saved.brush, engine: _chunkBY5EBP26cjs.resolveEngine.call(void 0, saved.brush), problems: saved.problems, warnings: warnings(saved.check) };
263
264
  }
264
265
  },
265
266
  {
266
267
  name: "update_brush",
267
268
  title: "Update a brush",
268
- description: `Changes a saved brush: the facets given are laid over its own (objects merge, lists and values replace; marks of another kind replace the marks), and unset removes whole facets back to their defaults. Built-in presets are refused (duplicate_brush first). Checked against this host like create_brush; a refused change saves nothing. One change. Returns the brush, the leaf paths changed, problems and warnings.`,
269
+ description: `Changes a saved brush: the facets given are laid over its own (objects merge, lists and values replace; marks of another kind replace the marks), and unset removes whole facets back to their defaults. Built-in presets are refused (duplicate_brush first). Checked against this host like create_brush: a change that adds what this host can't render is refused and saves nothing, while facets the brush already had for other hosts (a paint brush's light, in canvas) are kept as they are. One change. Returns the brush, the leaf paths changed, problems, warnings and, when there are any, kept: the facets this host can't use that the brush keeps.`,
269
270
  inputSchema: {
270
271
  type: "object",
271
272
  properties: {
@@ -280,11 +281,11 @@ function createBrushLibraryTools(library, options = {}) {
280
281
  annotations: { title: "Update a brush", ...WRITE, idempotentHint: true },
281
282
  handler: async ({ id, unset, ...patch }) => {
282
283
  const e = await entry(id);
283
- if (e.builtin) throw new (0, _chunkTZOX7KWVcjs.BrushLibraryError)("builtin", `"${id}" is a built-in brush and can't be changed; duplicate_brush makes a copy you can change.`);
284
+ if (e.builtin) throw new (0, _chunkBY5EBP26cjs.BrushLibraryError)("builtin", `"${id}" is a built-in brush and can't be changed; duplicate_brush makes a copy you can change.`);
284
285
  const base = copy2(e.brush);
285
286
  for (const k of _nullishCoalesce(unset, () => ( []))) delete base[k];
286
- const saved = await store(merge(base, { ...patch, id }), true);
287
- return { id, brush: saved.brush, changed: changedPaths(e.brush, saved.brush), problems: saved.problems, warnings: warnings(saved.check) };
287
+ const saved = await store(merge(base, { ...patch, id }), true, e.brush);
288
+ return { id, brush: saved.brush, changed: changedPaths(e.brush, saved.brush), problems: saved.problems, warnings: warnings(saved.check), ...saved.check.kept.length ? { kept: saved.check.kept } : {} };
288
289
  }
289
290
  },
290
291
  {
@@ -339,7 +340,7 @@ function createBrushLibraryTools(library, options = {}) {
339
340
  return tools;
340
341
  }
341
342
  function createBrushLibraryToolProvider(library, options = {}) {
342
- const profile = _nullishCoalesce(options.profile, () => ( _chunkTZOX7KWVcjs.PAINT_PROFILE));
343
+ const profile = _nullishCoalesce(options.profile, () => ( _chunkBY5EBP26cjs.PAINT_PROFILE));
343
344
  const tools = createBrushLibraryTools(library, options);
344
345
  return {
345
346
  id: _nullishCoalesce(options.id, () => ( "brushes")),