@pixerate/editor 0.104.0 → 0.106.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 (31) hide show
  1. package/dist/{chunk-NQLQ2JOI.js → chunk-4X5MIVCE.js} +1155 -295
  2. package/dist/chunk-4X5MIVCE.js.map +1 -0
  3. package/dist/{chunk-VSMM7B3P.cjs → chunk-ZID226ZG.cjs} +1169 -309
  4. package/dist/chunk-ZID226ZG.cjs.map +1 -0
  5. package/dist/{compositor-CTMU-B1t.d.cts → compositor-Bc3PNP3C.d.cts} +1 -1
  6. package/dist/{compositor-B1ZrKR89.d.ts → compositor-BsYYllvR.d.ts} +1 -1
  7. package/dist/{export-X9rY79p0.d.cts → export-_m3Es4ru.d.cts} +19 -4
  8. package/dist/{export-BLpMyCYg.d.ts → export-iMrop3Jm.d.ts} +19 -4
  9. package/dist/image-editor/index.cjs +714 -539
  10. package/dist/image-editor/index.cjs.map +1 -1
  11. package/dist/image-editor/index.d.cts +50 -9
  12. package/dist/image-editor/index.d.ts +50 -9
  13. package/dist/image-editor/index.js +228 -53
  14. package/dist/image-editor/index.js.map +1 -1
  15. package/dist/{mixer-DGcH6HLu.d.cts → mixer-C1M1Nua_.d.cts} +1 -1
  16. package/dist/{mixer-DG_9Yu2W.d.ts → mixer-Cu5a9Bzd.d.ts} +1 -1
  17. package/dist/paint/index.d.cts +2 -2
  18. package/dist/paint/index.d.ts +2 -2
  19. package/dist/paint-editor/index.cjs +348 -32
  20. package/dist/paint-editor/index.cjs.map +1 -1
  21. package/dist/paint-editor/index.d.cts +154 -13
  22. package/dist/paint-editor/index.d.ts +154 -13
  23. package/dist/paint-editor/index.js +317 -1
  24. package/dist/paint-editor/index.js.map +1 -1
  25. package/dist/raster/index.d.cts +4 -4
  26. package/dist/raster/index.d.ts +4 -4
  27. package/dist/{surface-AfHCH7BR.d.cts → surface-BBJN9wxg.d.cts} +1 -1
  28. package/dist/{surface-AfHCH7BR.d.ts → surface-BBJN9wxg.d.ts} +1 -1
  29. package/package.json +1 -1
  30. package/dist/chunk-NQLQ2JOI.js.map +0 -1
  31. package/dist/chunk-VSMM7B3P.cjs.map +0 -1
@@ -1,9 +1,9 @@
1
- import { R as RasterLayer, a as RasterGroupLayer, b as RasterPixelLayer, C as CompositorLayer, c as RasterCompositor, d as RasterSources, L as LayerLocks } from '../compositor-CTMU-B1t.cjs';
2
- import { B as BrushSettings, M as MixerSettings, C as CoverageMap, D as Dab, S as StrokePoint, a as MixerLoad } from '../mixer-DGcH6HLu.cjs';
3
- export { b as MAX_BRUSH_SIZE } from '../mixer-DGcH6HLu.cjs';
4
- import { R as RasterRect, a as TiledSurface, B as BlendMode } from '../surface-AfHCH7BR.cjs';
5
- export { b as Tile } from '../surface-AfHCH7BR.cjs';
6
- import { I as ImageEditorAssetStore, S as SerializedLayer, P as PsdExportResult } from '../export-X9rY79p0.cjs';
1
+ import { R as RasterLayer, a as RasterGroupLayer, b as RasterPixelLayer, C as CompositorLayer, c as RasterCompositor, d as RasterSources, L as LayerLocks } from '../compositor-Bc3PNP3C.cjs';
2
+ import { B as BrushSettings, M as MixerSettings, C as CoverageMap, D as Dab, S as StrokePoint, a as MixerLoad } from '../mixer-C1M1Nua_.cjs';
3
+ export { b as MAX_BRUSH_SIZE } from '../mixer-C1M1Nua_.cjs';
4
+ import { R as RasterRect, a as TiledSurface, B as BlendMode } from '../surface-BBJN9wxg.cjs';
5
+ export { b as BLEND_MODES, c as Tile, i as isBlendMode } from '../surface-BBJN9wxg.cjs';
6
+ import { I as ImageEditorAssetStore, S as SerializedLayer, P as PsdExportResult } from '../export-_m3Es4ru.cjs';
7
7
  import { a as AgentToolProvider } from '../registry-BqA1AZt0.cjs';
8
8
  import '../types-CwMPoRMU.cjs';
9
9
  import '../warp-D5jz_tN7.cjs';
@@ -203,12 +203,14 @@ interface PaintBrush {
203
203
  }
204
204
  declare function normalizeDynamics(raw?: Partial<BrushDynamics>, base?: BrushDynamics): BrushDynamics;
205
205
  declare const BRUSH_ID: RegExp;
206
- /** A brush with every field in range; missing fields come from `base` (default: a plain round dab brush). */
207
- declare function normalizePaintBrush(raw?: Partial<Omit<PaintBrush, 'tip' | 'dynamics' | 'mixer'>> & {
206
+ /** Brush settings to change or read: any subset of a brush, its tip, dynamics and mixer. */
207
+ type PaintBrushInput = Partial<Omit<PaintBrush, 'tip' | 'dynamics' | 'mixer'>> & {
208
208
  tip?: Partial<BrushSettings>;
209
209
  dynamics?: Partial<BrushDynamics>;
210
210
  mixer?: Partial<MixerSettings>;
211
- }, base?: PaintBrush): PaintBrush;
211
+ };
212
+ /** A brush with every field in range; missing fields come from `base` (default: a plain round dab brush). */
213
+ declare function normalizePaintBrush(raw?: PaintBrushInput, base?: PaintBrush): PaintBrush;
212
214
  /** The built-in brush library. */
213
215
  declare const BUILTIN_BRUSHES: readonly PaintBrush[];
214
216
  declare const DEFAULT_BRUSH_ID = "pencil-6b";
@@ -823,6 +825,17 @@ type ImageEncoder = (image: {
823
825
  }, format: 'image/jpeg' | 'image/webp', quality: number) => Promise<Uint8Array>;
824
826
  /** An encoder through `OffscreenCanvas`, or `null` where there is none (Node, tests). */
825
827
  declare function defaultImageEncoder(): ImageEncoder | null;
828
+ /**
829
+ * Decodes an image file (PNG, JPEG, WebP, … whatever the browser reads) into RGBA pixels through
830
+ * `createImageBitmap` and an `OffscreenCanvas`. Browser and Worker only.
831
+ */
832
+ declare function decodeImageBlob(blob: Blob): Promise<{
833
+ width: number;
834
+ height: number;
835
+ data: Uint8ClampedArray;
836
+ }>;
837
+ /** Saves bytes as a file through a temporary link. Browser only. */
838
+ declare function downloadBytes(bytes: Uint8Array | string, fileName: string, mimeType: string): void;
826
839
 
827
840
  /**
828
841
  * Brush thumbnails: a test stroke (an S-curve with pressure swelling and fading, at a steady
@@ -1137,7 +1150,7 @@ interface PaintStrokeInit {
1137
1150
  /** Default the active brush. */
1138
1151
  brushId?: string;
1139
1152
  /** Changes to the brush for this stroke only. */
1140
- brush?: Parameters<typeof normalizePaintBrush>[0];
1153
+ brush?: PaintBrushInput;
1141
1154
  /** Jitter seed (default: a new one per stroke). */
1142
1155
  seed?: number;
1143
1156
  /** Extra copies of the stroke as affine maps (default: the symmetry guide's). */
@@ -1307,12 +1320,12 @@ declare class PaintEditorController {
1307
1320
  */
1308
1321
  setBrush(update?: {
1309
1322
  id?: string;
1310
- } & Omit<Parameters<typeof normalizePaintBrush>[0], 'id'>): PaintBrush;
1323
+ } & Omit<PaintBrushInput, 'id'>): PaintBrush;
1311
1324
  /** Saves the active brush (or `brush`) into the user library under `id` / `name`. */
1312
1325
  saveBrush(options: {
1313
1326
  id: string;
1314
1327
  name?: string;
1315
- brush?: Parameters<typeof normalizePaintBrush>[0];
1328
+ brush?: PaintBrushInput;
1316
1329
  }): PaintBrush;
1317
1330
  removeBrush(id: string): void;
1318
1331
  /** The user's saved brushes. */
@@ -1536,4 +1549,132 @@ interface PaintEditorToolProviderOptions {
1536
1549
  /** Agent tools for one paint editor. */
1537
1550
  declare function createPaintEditorToolProvider(controller: PaintEditorController, options?: PaintEditorToolProviderOptions): AgentToolProvider;
1538
1551
 
1539
- export { type Affine, BRUSH_ID, BRUSH_ROTATIONS, BUILTIN_BRUSHES, type BrushDynamics, type BrushLibraryFile, type BrushRotation, type BrushThumbnail, type ColorWheel, DEFAULT_BRUSH_ID, DEFAULT_DPI, DEFAULT_DYNAMICS, DEFAULT_PAPER, DEFAULT_SWATCHES, DEFAULT_VIEW, DryStroke, type DryStrokeOptions, type FillLayerOptions, GRAIN_PATTERNS, GRAIN_TILE, type GrainPattern, type GrainTuning, HARMONY_KINDS, type Hand, type HarmonyColor, type HarmonyKind, IDENTITY_AFFINE, IDENTITY_COPY, type ImageEncoder, type ImageFormat, type ImageNode, type LayerUpdate, type Linear2, type LoadedPaintDocument, MAX_CANVAS_SIDE, MAX_COORDINATE, MAX_IMAGE_SIDE, MAX_ZOOM, MIN_CANVAS_SIDE, MIN_ZOOM, MIXING_PAD_HEIGHT, MIXING_PAD_WIDTH, MixingPad, type MixingPadTool, PAINT_BRUSH_CATEGORIES, PAINT_BRUSH_ENGINES, PAINT_FORMAT, PAINT_SCHEMA_VERSION, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_NODE_ID, type PaintAssetStore, type PaintBrush, type PaintBrushCategory, type PaintBrushEngine, type PaintCanvas, PaintDocumentError, type PaintDocumentExtensions, type PaintDocumentState, PaintEditorController, PaintEditorError, type PaintEditorOptions, type PaintEditorState, type PaintEditorToolProviderOptions, type PaintGroupLayer, type PaintGuides, type PaintLayer, type PaintLayerInfo, type PaintPixelLayer, type PaintStrokeInit, type PaintStrokeResult, PaintStrokeSession, type PaintView, type PaperFamily, PaperGrain, type PaperNode, type PaperSettings, type PaperTiling, type PenDab, PenDabWalker, type PenPoint, PenSmoother, type PerspectiveGuide, PerspectiveSnapper, type PixelImage, type Point2, type PointerSample, type RecordedStroke, type ReferenceImage, type RenderOptions, type ReplayOptions, type Rgb255, SNAP_DECIDE_DISTANCE, SYMMETRY_MODES, type SerializeOptions, type SerializedPaintDocument, type StrokeCopy, type StrokeSessionHost, type StrokeSessionInit, type StrokeVariation, type Swatch, type SymmetryGuide, type SymmetryMode, TRACING_NODE_ID, TileableNoise, type TracingImage, type ViewLayer, affineCopy, applyAffine, brushToJSON, clonePaper, colorHarmony, composeAffine, createPaintCompositor, createPaintDocument, createPaintEditorToolProvider, createPaintLayer, defaultGuides, defaultImageEncoder, deserializePaintDocument, deserializePaintDocumentAsync, documentExtensions, documentToScreen, downsampleRgba, fitZoom, grainCatch, grainHeights, hash2, hexToRgb8, hslToRgb, hsvToRgb, hueToWheel, invertAffine, isPalmTouch, mapPenPoint, mix32, mixerLoadForStroke, mixerTip, newPaintLayerId, normalizeBrushStroke, normalizeCanvas, normalizeDynamics, normalizePaintBrush, normalizePaper, normalizePerspective, normalizeRotation, normalizeSymmetry, normalizeView, paperGrain, paperKey, paperNode, paperPreset, parseBrushLibrary, parseHexColor, penOrientation, perspectiveDirections, perspectiveGuideLines, pointerToPenPoint, rand01, randSigned, renderBrushThumbnail, renderPaper, rgbToHexColor, rgbToHsl, rgbToHsv, samplePressure, screenToDocument, seedFromString, serializePaintDocument, serializePaintDocumentExternal, strokeBounds, symmetryAxisAngles, symmetryAxisSegments, symmetryCopies, thumbnailStroke, tiltToOrientation, toStrokePoint, variationAffine, varyStroke, viewCssTransform, viewMatrix, viewPenToDocument, wheelToHue };
1552
+ /**
1553
+ * Framework-free UI logic shared by the React and Svelte paint editors, so both behave the same:
1554
+ *
1555
+ * - `PaintGesture` turns pointer events (structurally typed, no DOM import) into strokes (with
1556
+ * coalesced samples and a predicted tail), colour picks, pans, view rotation and zoom, with palm
1557
+ * rejection while a pen is down.
1558
+ * - `PaintCanvasPresenter` keeps a document-sized 2D canvas up to date from the compositor,
1559
+ * uploading only the tiles that changed.
1560
+ * - Guide overlays as line segments, and the slider tables of the brush and paper panels.
1561
+ */
1562
+
1563
+ /** The Pointer Event fields the gesture reads. */
1564
+ interface PaintPointerEvent extends PointerSample {
1565
+ pointerId: number;
1566
+ clientX: number;
1567
+ clientY: number;
1568
+ button?: number;
1569
+ buttons?: number;
1570
+ shiftKey?: boolean;
1571
+ altKey?: boolean;
1572
+ ctrlKey?: boolean;
1573
+ metaKey?: boolean;
1574
+ getCoalescedEvents?(): PaintPointerEvent[];
1575
+ getPredictedEvents?(): PaintPointerEvent[];
1576
+ }
1577
+ type PaintTool = 'brush' | 'eyedropper' | 'pan' | 'rotate';
1578
+ declare const PAINT_TOOLS: ReadonlyArray<{
1579
+ id: PaintTool;
1580
+ label: string;
1581
+ key: string;
1582
+ }>;
1583
+ /** Where the viewport element is on screen and how big it is (CSS pixels). */
1584
+ interface ViewportBox {
1585
+ left: number;
1586
+ top: number;
1587
+ width: number;
1588
+ height: number;
1589
+ }
1590
+ declare class PaintGesture {
1591
+ private readonly controller;
1592
+ private readonly box;
1593
+ tool: PaintTool;
1594
+ /** The last refusal (a hidden or locked layer), for the editor to show. */
1595
+ error: string | null;
1596
+ /** The predicted tail of the current stroke in document pixels (draw it as a thin preview). */
1597
+ predicted: PenPoint[];
1598
+ private mode;
1599
+ private penAt;
1600
+ private penDown;
1601
+ constructor(controller: PaintEditorController, box: () => ViewportBox);
1602
+ private doc;
1603
+ private pen;
1604
+ /** Pointer down; returns true when the gesture took the pointer (capture it). */
1605
+ down(e: PaintPointerEvent): boolean;
1606
+ private pick;
1607
+ move(e: PaintPointerEvent): void;
1608
+ up(e: PaintPointerEvent): void;
1609
+ cancel(): void;
1610
+ get active(): boolean;
1611
+ /** Wheel: zoom about the pointer (Ctrl / pinch or plain wheel), Shift+wheel rotates the view. */
1612
+ wheel(e: {
1613
+ clientX: number;
1614
+ clientY: number;
1615
+ deltaY: number;
1616
+ shiftKey?: boolean;
1617
+ }): void;
1618
+ }
1619
+ /** Keyboard shortcuts shared by both editors; returns true when it handled the key. */
1620
+ declare function handlePaintShortcut(controller: PaintEditorController, gesture: PaintGesture, e: {
1621
+ key: string;
1622
+ ctrlKey?: boolean;
1623
+ metaKey?: boolean;
1624
+ shiftKey?: boolean;
1625
+ target?: unknown;
1626
+ }): boolean;
1627
+ /** The 2D context methods the presenter uses (a `CanvasRenderingContext2D`). */
1628
+ interface Paint2DContext {
1629
+ createImageData(width: number, height: number): {
1630
+ data: Uint8ClampedArray;
1631
+ };
1632
+ putImageData(image: never, dx: number, dy: number, sx?: number, sy?: number, sw?: number, sh?: number): void;
1633
+ }
1634
+ /** Keeps a document-sized canvas in step with the controller, tile by tile. */
1635
+ declare class PaintCanvasPresenter {
1636
+ private readonly controller;
1637
+ private readonly uploaded;
1638
+ private scratch;
1639
+ private size;
1640
+ constructor(controller: PaintEditorController);
1641
+ /** Draws what changed into `ctx` (a canvas the size of the document); returns the tiles drawn. */
1642
+ render(ctx: Paint2DContext): number;
1643
+ }
1644
+ /** Lines to draw over the canvas for the guides, in document pixels, with a style key. */
1645
+ declare function guideOverlay(controller: PaintEditorController): Array<{
1646
+ from: Point2;
1647
+ to: Point2;
1648
+ kind: 'symmetry' | 'perspective' | 'snap';
1649
+ }>;
1650
+ /** One slider of a panel: a path into the brush (or paper) settings. */
1651
+ interface SliderControl {
1652
+ path: string;
1653
+ label: string;
1654
+ min: number;
1655
+ max: number;
1656
+ step: number;
1657
+ }
1658
+ declare const BRUSH_SLIDERS: readonly SliderControl[];
1659
+ declare const PAPER_SLIDERS: readonly SliderControl[];
1660
+ /** Reads `a.b` from an object. */
1661
+ declare function readPath(obj: unknown, path: string): number;
1662
+ /** `{a: {b: value}}` for `a.b`, keeping the rest of `obj`'s `a`. */
1663
+ declare function patchPath(obj: Record<string, unknown>, path: string, value: number): Record<string, unknown>;
1664
+ /** The point on a colour wheel of `radius` (centre 0, 0) for a wheel angle in degrees, red at the top. */
1665
+ declare function wheelPoint(angle: number, radius: number): Point2;
1666
+ /** The wheel angle (degrees, red at the top, clockwise) of a point relative to the wheel centre. */
1667
+ declare function wheelAngle(x: number, y: number): number;
1668
+ /**
1669
+ * A hue ring for a colour wheel, `size × size` RGBA: hues at full saturation and value between
1670
+ * `inner` and 1 of the radius, red at the top, laid out on the RYB or RGB wheel.
1671
+ */
1672
+ declare function renderColorWheel(size: number, wheel: ColorWheel, inner?: number): {
1673
+ width: number;
1674
+ height: number;
1675
+ data: Uint8ClampedArray;
1676
+ };
1677
+ /** The colour for a click on the wheel ring at (dx, dy) from its centre, keeping `color`'s saturation and value. */
1678
+ declare function wheelPick(dx: number, dy: number, wheel: ColorWheel, color: string): string;
1679
+
1680
+ export { type Affine, BRUSH_ID, BRUSH_ROTATIONS, BRUSH_SLIDERS, BUILTIN_BRUSHES, BlendMode, type BrushDynamics, type BrushLibraryFile, type BrushRotation, type BrushThumbnail, type ColorWheel, DEFAULT_BRUSH_ID, DEFAULT_DPI, DEFAULT_DYNAMICS, DEFAULT_PAPER, DEFAULT_SWATCHES, DEFAULT_VIEW, DryStroke, type DryStrokeOptions, type FillLayerOptions, GRAIN_PATTERNS, GRAIN_TILE, type GrainPattern, type GrainTuning, HARMONY_KINDS, type Hand, type HarmonyColor, type HarmonyKind, IDENTITY_AFFINE, IDENTITY_COPY, type ImageEncoder, type ImageFormat, type ImageNode, type LayerUpdate, type Linear2, type LoadedPaintDocument, MAX_CANVAS_SIDE, MAX_COORDINATE, MAX_IMAGE_SIDE, MAX_ZOOM, MIN_CANVAS_SIDE, MIN_ZOOM, MIXING_PAD_HEIGHT, MIXING_PAD_WIDTH, MixingPad, type MixingPadTool, PAINT_BRUSH_CATEGORIES, PAINT_BRUSH_ENGINES, PAINT_FORMAT, PAINT_SCHEMA_VERSION, PAINT_TOOLS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_NODE_ID, PAPER_SLIDERS, type Paint2DContext, type PaintAssetStore, type PaintBrush, type PaintBrushCategory, type PaintBrushEngine, type PaintBrushInput, type PaintCanvas, PaintCanvasPresenter, PaintDocumentError, type PaintDocumentExtensions, type PaintDocumentState, PaintEditorController, PaintEditorError, type PaintEditorOptions, type PaintEditorState, type PaintEditorToolProviderOptions, PaintGesture, type PaintGroupLayer, type PaintGuides, type PaintLayer, type PaintLayerInfo, type PaintPixelLayer, type PaintPointerEvent, type PaintStrokeInit, type PaintStrokeResult, PaintStrokeSession, type PaintTool, type PaintView, type PaperFamily, PaperGrain, type PaperNode, type PaperSettings, type PaperTiling, type PenDab, PenDabWalker, type PenPoint, PenSmoother, type PerspectiveGuide, PerspectiveSnapper, type PixelImage, type Point2, type PointerSample, type RecordedStroke, type ReferenceImage, type RenderOptions, type ReplayOptions, type Rgb255, SNAP_DECIDE_DISTANCE, SYMMETRY_MODES, type SerializeOptions, type SerializedPaintDocument, type SliderControl, type StrokeCopy, type StrokeSessionHost, type StrokeSessionInit, type StrokeVariation, type Swatch, type SymmetryGuide, type SymmetryMode, TRACING_NODE_ID, TileableNoise, type TracingImage, type ViewLayer, type ViewportBox, affineCopy, applyAffine, brushToJSON, clonePaper, colorHarmony, composeAffine, createPaintCompositor, createPaintDocument, createPaintEditorToolProvider, createPaintLayer, decodeImageBlob, defaultGuides, defaultImageEncoder, deserializePaintDocument, deserializePaintDocumentAsync, documentExtensions, documentToScreen, downloadBytes, downsampleRgba, fitZoom, grainCatch, grainHeights, guideOverlay, handlePaintShortcut, hash2, hexToRgb8, hslToRgb, hsvToRgb, hueToWheel, invertAffine, isPalmTouch, mapPenPoint, mix32, mixerLoadForStroke, mixerTip, newPaintLayerId, normalizeBrushStroke, normalizeCanvas, normalizeDynamics, normalizePaintBrush, normalizePaper, normalizePerspective, normalizeRotation, normalizeSymmetry, normalizeView, paperGrain, paperKey, paperNode, paperPreset, parseBrushLibrary, parseHexColor, patchPath, penOrientation, perspectiveDirections, perspectiveGuideLines, pointerToPenPoint, rand01, randSigned, readPath, renderBrushThumbnail, renderColorWheel, renderPaper, rgbToHexColor, rgbToHsl, rgbToHsv, samplePressure, screenToDocument, seedFromString, serializePaintDocument, serializePaintDocumentExternal, strokeBounds, symmetryAxisAngles, symmetryAxisSegments, symmetryCopies, thumbnailStroke, tiltToOrientation, toStrokePoint, variationAffine, varyStroke, viewCssTransform, viewMatrix, viewPenToDocument, wheelAngle, wheelPick, wheelPoint, wheelToHue };
@@ -1,9 +1,9 @@
1
- import { R as RasterLayer, a as RasterGroupLayer, b as RasterPixelLayer, C as CompositorLayer, c as RasterCompositor, d as RasterSources, L as LayerLocks } from '../compositor-B1ZrKR89.js';
2
- import { B as BrushSettings, M as MixerSettings, C as CoverageMap, D as Dab, S as StrokePoint, a as MixerLoad } from '../mixer-DG_9Yu2W.js';
3
- export { b as MAX_BRUSH_SIZE } from '../mixer-DG_9Yu2W.js';
4
- import { R as RasterRect, a as TiledSurface, B as BlendMode } from '../surface-AfHCH7BR.js';
5
- export { b as Tile } from '../surface-AfHCH7BR.js';
6
- import { I as ImageEditorAssetStore, S as SerializedLayer, P as PsdExportResult } from '../export-BLpMyCYg.js';
1
+ import { R as RasterLayer, a as RasterGroupLayer, b as RasterPixelLayer, C as CompositorLayer, c as RasterCompositor, d as RasterSources, L as LayerLocks } from '../compositor-BsYYllvR.js';
2
+ import { B as BrushSettings, M as MixerSettings, C as CoverageMap, D as Dab, S as StrokePoint, a as MixerLoad } from '../mixer-Cu5a9Bzd.js';
3
+ export { b as MAX_BRUSH_SIZE } from '../mixer-Cu5a9Bzd.js';
4
+ import { R as RasterRect, a as TiledSurface, B as BlendMode } from '../surface-BBJN9wxg.js';
5
+ export { b as BLEND_MODES, c as Tile, i as isBlendMode } from '../surface-BBJN9wxg.js';
6
+ import { I as ImageEditorAssetStore, S as SerializedLayer, P as PsdExportResult } from '../export-iMrop3Jm.js';
7
7
  import { a as AgentToolProvider } from '../registry-D-4fit9C.js';
8
8
  import '../types-CwMPoRMU.js';
9
9
  import '../warp-CWHZzE3x.js';
@@ -203,12 +203,14 @@ interface PaintBrush {
203
203
  }
204
204
  declare function normalizeDynamics(raw?: Partial<BrushDynamics>, base?: BrushDynamics): BrushDynamics;
205
205
  declare const BRUSH_ID: RegExp;
206
- /** A brush with every field in range; missing fields come from `base` (default: a plain round dab brush). */
207
- declare function normalizePaintBrush(raw?: Partial<Omit<PaintBrush, 'tip' | 'dynamics' | 'mixer'>> & {
206
+ /** Brush settings to change or read: any subset of a brush, its tip, dynamics and mixer. */
207
+ type PaintBrushInput = Partial<Omit<PaintBrush, 'tip' | 'dynamics' | 'mixer'>> & {
208
208
  tip?: Partial<BrushSettings>;
209
209
  dynamics?: Partial<BrushDynamics>;
210
210
  mixer?: Partial<MixerSettings>;
211
- }, base?: PaintBrush): PaintBrush;
211
+ };
212
+ /** A brush with every field in range; missing fields come from `base` (default: a plain round dab brush). */
213
+ declare function normalizePaintBrush(raw?: PaintBrushInput, base?: PaintBrush): PaintBrush;
212
214
  /** The built-in brush library. */
213
215
  declare const BUILTIN_BRUSHES: readonly PaintBrush[];
214
216
  declare const DEFAULT_BRUSH_ID = "pencil-6b";
@@ -823,6 +825,17 @@ type ImageEncoder = (image: {
823
825
  }, format: 'image/jpeg' | 'image/webp', quality: number) => Promise<Uint8Array>;
824
826
  /** An encoder through `OffscreenCanvas`, or `null` where there is none (Node, tests). */
825
827
  declare function defaultImageEncoder(): ImageEncoder | null;
828
+ /**
829
+ * Decodes an image file (PNG, JPEG, WebP, … whatever the browser reads) into RGBA pixels through
830
+ * `createImageBitmap` and an `OffscreenCanvas`. Browser and Worker only.
831
+ */
832
+ declare function decodeImageBlob(blob: Blob): Promise<{
833
+ width: number;
834
+ height: number;
835
+ data: Uint8ClampedArray;
836
+ }>;
837
+ /** Saves bytes as a file through a temporary link. Browser only. */
838
+ declare function downloadBytes(bytes: Uint8Array | string, fileName: string, mimeType: string): void;
826
839
 
827
840
  /**
828
841
  * Brush thumbnails: a test stroke (an S-curve with pressure swelling and fading, at a steady
@@ -1137,7 +1150,7 @@ interface PaintStrokeInit {
1137
1150
  /** Default the active brush. */
1138
1151
  brushId?: string;
1139
1152
  /** Changes to the brush for this stroke only. */
1140
- brush?: Parameters<typeof normalizePaintBrush>[0];
1153
+ brush?: PaintBrushInput;
1141
1154
  /** Jitter seed (default: a new one per stroke). */
1142
1155
  seed?: number;
1143
1156
  /** Extra copies of the stroke as affine maps (default: the symmetry guide's). */
@@ -1307,12 +1320,12 @@ declare class PaintEditorController {
1307
1320
  */
1308
1321
  setBrush(update?: {
1309
1322
  id?: string;
1310
- } & Omit<Parameters<typeof normalizePaintBrush>[0], 'id'>): PaintBrush;
1323
+ } & Omit<PaintBrushInput, 'id'>): PaintBrush;
1311
1324
  /** Saves the active brush (or `brush`) into the user library under `id` / `name`. */
1312
1325
  saveBrush(options: {
1313
1326
  id: string;
1314
1327
  name?: string;
1315
- brush?: Parameters<typeof normalizePaintBrush>[0];
1328
+ brush?: PaintBrushInput;
1316
1329
  }): PaintBrush;
1317
1330
  removeBrush(id: string): void;
1318
1331
  /** The user's saved brushes. */
@@ -1536,4 +1549,132 @@ interface PaintEditorToolProviderOptions {
1536
1549
  /** Agent tools for one paint editor. */
1537
1550
  declare function createPaintEditorToolProvider(controller: PaintEditorController, options?: PaintEditorToolProviderOptions): AgentToolProvider;
1538
1551
 
1539
- export { type Affine, BRUSH_ID, BRUSH_ROTATIONS, BUILTIN_BRUSHES, type BrushDynamics, type BrushLibraryFile, type BrushRotation, type BrushThumbnail, type ColorWheel, DEFAULT_BRUSH_ID, DEFAULT_DPI, DEFAULT_DYNAMICS, DEFAULT_PAPER, DEFAULT_SWATCHES, DEFAULT_VIEW, DryStroke, type DryStrokeOptions, type FillLayerOptions, GRAIN_PATTERNS, GRAIN_TILE, type GrainPattern, type GrainTuning, HARMONY_KINDS, type Hand, type HarmonyColor, type HarmonyKind, IDENTITY_AFFINE, IDENTITY_COPY, type ImageEncoder, type ImageFormat, type ImageNode, type LayerUpdate, type Linear2, type LoadedPaintDocument, MAX_CANVAS_SIDE, MAX_COORDINATE, MAX_IMAGE_SIDE, MAX_ZOOM, MIN_CANVAS_SIDE, MIN_ZOOM, MIXING_PAD_HEIGHT, MIXING_PAD_WIDTH, MixingPad, type MixingPadTool, PAINT_BRUSH_CATEGORIES, PAINT_BRUSH_ENGINES, PAINT_FORMAT, PAINT_SCHEMA_VERSION, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_NODE_ID, type PaintAssetStore, type PaintBrush, type PaintBrushCategory, type PaintBrushEngine, type PaintCanvas, PaintDocumentError, type PaintDocumentExtensions, type PaintDocumentState, PaintEditorController, PaintEditorError, type PaintEditorOptions, type PaintEditorState, type PaintEditorToolProviderOptions, type PaintGroupLayer, type PaintGuides, type PaintLayer, type PaintLayerInfo, type PaintPixelLayer, type PaintStrokeInit, type PaintStrokeResult, PaintStrokeSession, type PaintView, type PaperFamily, PaperGrain, type PaperNode, type PaperSettings, type PaperTiling, type PenDab, PenDabWalker, type PenPoint, PenSmoother, type PerspectiveGuide, PerspectiveSnapper, type PixelImage, type Point2, type PointerSample, type RecordedStroke, type ReferenceImage, type RenderOptions, type ReplayOptions, type Rgb255, SNAP_DECIDE_DISTANCE, SYMMETRY_MODES, type SerializeOptions, type SerializedPaintDocument, type StrokeCopy, type StrokeSessionHost, type StrokeSessionInit, type StrokeVariation, type Swatch, type SymmetryGuide, type SymmetryMode, TRACING_NODE_ID, TileableNoise, type TracingImage, type ViewLayer, affineCopy, applyAffine, brushToJSON, clonePaper, colorHarmony, composeAffine, createPaintCompositor, createPaintDocument, createPaintEditorToolProvider, createPaintLayer, defaultGuides, defaultImageEncoder, deserializePaintDocument, deserializePaintDocumentAsync, documentExtensions, documentToScreen, downsampleRgba, fitZoom, grainCatch, grainHeights, hash2, hexToRgb8, hslToRgb, hsvToRgb, hueToWheel, invertAffine, isPalmTouch, mapPenPoint, mix32, mixerLoadForStroke, mixerTip, newPaintLayerId, normalizeBrushStroke, normalizeCanvas, normalizeDynamics, normalizePaintBrush, normalizePaper, normalizePerspective, normalizeRotation, normalizeSymmetry, normalizeView, paperGrain, paperKey, paperNode, paperPreset, parseBrushLibrary, parseHexColor, penOrientation, perspectiveDirections, perspectiveGuideLines, pointerToPenPoint, rand01, randSigned, renderBrushThumbnail, renderPaper, rgbToHexColor, rgbToHsl, rgbToHsv, samplePressure, screenToDocument, seedFromString, serializePaintDocument, serializePaintDocumentExternal, strokeBounds, symmetryAxisAngles, symmetryAxisSegments, symmetryCopies, thumbnailStroke, tiltToOrientation, toStrokePoint, variationAffine, varyStroke, viewCssTransform, viewMatrix, viewPenToDocument, wheelToHue };
1552
+ /**
1553
+ * Framework-free UI logic shared by the React and Svelte paint editors, so both behave the same:
1554
+ *
1555
+ * - `PaintGesture` turns pointer events (structurally typed, no DOM import) into strokes (with
1556
+ * coalesced samples and a predicted tail), colour picks, pans, view rotation and zoom, with palm
1557
+ * rejection while a pen is down.
1558
+ * - `PaintCanvasPresenter` keeps a document-sized 2D canvas up to date from the compositor,
1559
+ * uploading only the tiles that changed.
1560
+ * - Guide overlays as line segments, and the slider tables of the brush and paper panels.
1561
+ */
1562
+
1563
+ /** The Pointer Event fields the gesture reads. */
1564
+ interface PaintPointerEvent extends PointerSample {
1565
+ pointerId: number;
1566
+ clientX: number;
1567
+ clientY: number;
1568
+ button?: number;
1569
+ buttons?: number;
1570
+ shiftKey?: boolean;
1571
+ altKey?: boolean;
1572
+ ctrlKey?: boolean;
1573
+ metaKey?: boolean;
1574
+ getCoalescedEvents?(): PaintPointerEvent[];
1575
+ getPredictedEvents?(): PaintPointerEvent[];
1576
+ }
1577
+ type PaintTool = 'brush' | 'eyedropper' | 'pan' | 'rotate';
1578
+ declare const PAINT_TOOLS: ReadonlyArray<{
1579
+ id: PaintTool;
1580
+ label: string;
1581
+ key: string;
1582
+ }>;
1583
+ /** Where the viewport element is on screen and how big it is (CSS pixels). */
1584
+ interface ViewportBox {
1585
+ left: number;
1586
+ top: number;
1587
+ width: number;
1588
+ height: number;
1589
+ }
1590
+ declare class PaintGesture {
1591
+ private readonly controller;
1592
+ private readonly box;
1593
+ tool: PaintTool;
1594
+ /** The last refusal (a hidden or locked layer), for the editor to show. */
1595
+ error: string | null;
1596
+ /** The predicted tail of the current stroke in document pixels (draw it as a thin preview). */
1597
+ predicted: PenPoint[];
1598
+ private mode;
1599
+ private penAt;
1600
+ private penDown;
1601
+ constructor(controller: PaintEditorController, box: () => ViewportBox);
1602
+ private doc;
1603
+ private pen;
1604
+ /** Pointer down; returns true when the gesture took the pointer (capture it). */
1605
+ down(e: PaintPointerEvent): boolean;
1606
+ private pick;
1607
+ move(e: PaintPointerEvent): void;
1608
+ up(e: PaintPointerEvent): void;
1609
+ cancel(): void;
1610
+ get active(): boolean;
1611
+ /** Wheel: zoom about the pointer (Ctrl / pinch or plain wheel), Shift+wheel rotates the view. */
1612
+ wheel(e: {
1613
+ clientX: number;
1614
+ clientY: number;
1615
+ deltaY: number;
1616
+ shiftKey?: boolean;
1617
+ }): void;
1618
+ }
1619
+ /** Keyboard shortcuts shared by both editors; returns true when it handled the key. */
1620
+ declare function handlePaintShortcut(controller: PaintEditorController, gesture: PaintGesture, e: {
1621
+ key: string;
1622
+ ctrlKey?: boolean;
1623
+ metaKey?: boolean;
1624
+ shiftKey?: boolean;
1625
+ target?: unknown;
1626
+ }): boolean;
1627
+ /** The 2D context methods the presenter uses (a `CanvasRenderingContext2D`). */
1628
+ interface Paint2DContext {
1629
+ createImageData(width: number, height: number): {
1630
+ data: Uint8ClampedArray;
1631
+ };
1632
+ putImageData(image: never, dx: number, dy: number, sx?: number, sy?: number, sw?: number, sh?: number): void;
1633
+ }
1634
+ /** Keeps a document-sized canvas in step with the controller, tile by tile. */
1635
+ declare class PaintCanvasPresenter {
1636
+ private readonly controller;
1637
+ private readonly uploaded;
1638
+ private scratch;
1639
+ private size;
1640
+ constructor(controller: PaintEditorController);
1641
+ /** Draws what changed into `ctx` (a canvas the size of the document); returns the tiles drawn. */
1642
+ render(ctx: Paint2DContext): number;
1643
+ }
1644
+ /** Lines to draw over the canvas for the guides, in document pixels, with a style key. */
1645
+ declare function guideOverlay(controller: PaintEditorController): Array<{
1646
+ from: Point2;
1647
+ to: Point2;
1648
+ kind: 'symmetry' | 'perspective' | 'snap';
1649
+ }>;
1650
+ /** One slider of a panel: a path into the brush (or paper) settings. */
1651
+ interface SliderControl {
1652
+ path: string;
1653
+ label: string;
1654
+ min: number;
1655
+ max: number;
1656
+ step: number;
1657
+ }
1658
+ declare const BRUSH_SLIDERS: readonly SliderControl[];
1659
+ declare const PAPER_SLIDERS: readonly SliderControl[];
1660
+ /** Reads `a.b` from an object. */
1661
+ declare function readPath(obj: unknown, path: string): number;
1662
+ /** `{a: {b: value}}` for `a.b`, keeping the rest of `obj`'s `a`. */
1663
+ declare function patchPath(obj: Record<string, unknown>, path: string, value: number): Record<string, unknown>;
1664
+ /** The point on a colour wheel of `radius` (centre 0, 0) for a wheel angle in degrees, red at the top. */
1665
+ declare function wheelPoint(angle: number, radius: number): Point2;
1666
+ /** The wheel angle (degrees, red at the top, clockwise) of a point relative to the wheel centre. */
1667
+ declare function wheelAngle(x: number, y: number): number;
1668
+ /**
1669
+ * A hue ring for a colour wheel, `size × size` RGBA: hues at full saturation and value between
1670
+ * `inner` and 1 of the radius, red at the top, laid out on the RYB or RGB wheel.
1671
+ */
1672
+ declare function renderColorWheel(size: number, wheel: ColorWheel, inner?: number): {
1673
+ width: number;
1674
+ height: number;
1675
+ data: Uint8ClampedArray;
1676
+ };
1677
+ /** The colour for a click on the wheel ring at (dx, dy) from its centre, keeping `color`'s saturation and value. */
1678
+ declare function wheelPick(dx: number, dy: number, wheel: ColorWheel, color: string): string;
1679
+
1680
+ export { type Affine, BRUSH_ID, BRUSH_ROTATIONS, BRUSH_SLIDERS, BUILTIN_BRUSHES, BlendMode, type BrushDynamics, type BrushLibraryFile, type BrushRotation, type BrushThumbnail, type ColorWheel, DEFAULT_BRUSH_ID, DEFAULT_DPI, DEFAULT_DYNAMICS, DEFAULT_PAPER, DEFAULT_SWATCHES, DEFAULT_VIEW, DryStroke, type DryStrokeOptions, type FillLayerOptions, GRAIN_PATTERNS, GRAIN_TILE, type GrainPattern, type GrainTuning, HARMONY_KINDS, type Hand, type HarmonyColor, type HarmonyKind, IDENTITY_AFFINE, IDENTITY_COPY, type ImageEncoder, type ImageFormat, type ImageNode, type LayerUpdate, type Linear2, type LoadedPaintDocument, MAX_CANVAS_SIDE, MAX_COORDINATE, MAX_IMAGE_SIDE, MAX_ZOOM, MIN_CANVAS_SIDE, MIN_ZOOM, MIXING_PAD_HEIGHT, MIXING_PAD_WIDTH, MixingPad, type MixingPadTool, PAINT_BRUSH_CATEGORIES, PAINT_BRUSH_ENGINES, PAINT_FORMAT, PAINT_SCHEMA_VERSION, PAINT_TOOLS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_NODE_ID, PAPER_SLIDERS, type Paint2DContext, type PaintAssetStore, type PaintBrush, type PaintBrushCategory, type PaintBrushEngine, type PaintBrushInput, type PaintCanvas, PaintCanvasPresenter, PaintDocumentError, type PaintDocumentExtensions, type PaintDocumentState, PaintEditorController, PaintEditorError, type PaintEditorOptions, type PaintEditorState, type PaintEditorToolProviderOptions, PaintGesture, type PaintGroupLayer, type PaintGuides, type PaintLayer, type PaintLayerInfo, type PaintPixelLayer, type PaintPointerEvent, type PaintStrokeInit, type PaintStrokeResult, PaintStrokeSession, type PaintTool, type PaintView, type PaperFamily, PaperGrain, type PaperNode, type PaperSettings, type PaperTiling, type PenDab, PenDabWalker, type PenPoint, PenSmoother, type PerspectiveGuide, PerspectiveSnapper, type PixelImage, type Point2, type PointerSample, type RecordedStroke, type ReferenceImage, type RenderOptions, type ReplayOptions, type Rgb255, SNAP_DECIDE_DISTANCE, SYMMETRY_MODES, type SerializeOptions, type SerializedPaintDocument, type SliderControl, type StrokeCopy, type StrokeSessionHost, type StrokeSessionInit, type StrokeVariation, type Swatch, type SymmetryGuide, type SymmetryMode, TRACING_NODE_ID, TileableNoise, type TracingImage, type ViewLayer, type ViewportBox, affineCopy, applyAffine, brushToJSON, clonePaper, colorHarmony, composeAffine, createPaintCompositor, createPaintDocument, createPaintEditorToolProvider, createPaintLayer, decodeImageBlob, defaultGuides, defaultImageEncoder, deserializePaintDocument, deserializePaintDocumentAsync, documentExtensions, documentToScreen, downloadBytes, downsampleRgba, fitZoom, grainCatch, grainHeights, guideOverlay, handlePaintShortcut, hash2, hexToRgb8, hslToRgb, hsvToRgb, hueToWheel, invertAffine, isPalmTouch, mapPenPoint, mix32, mixerLoadForStroke, mixerTip, newPaintLayerId, normalizeBrushStroke, normalizeCanvas, normalizeDynamics, normalizePaintBrush, normalizePaper, normalizePerspective, normalizeRotation, normalizeSymmetry, normalizeView, paperGrain, paperKey, paperNode, paperPreset, parseBrushLibrary, parseHexColor, patchPath, penOrientation, perspectiveDirections, perspectiveGuideLines, pointerToPenPoint, rand01, randSigned, readPath, renderBrushThumbnail, renderColorWheel, renderPaper, rgbToHexColor, rgbToHsl, rgbToHsv, samplePressure, screenToDocument, seedFromString, serializePaintDocument, serializePaintDocumentExternal, strokeBounds, symmetryAxisAngles, symmetryAxisSegments, symmetryCopies, thumbnailStroke, tiltToOrientation, toStrokePoint, variationAffine, varyStroke, viewCssTransform, viewMatrix, viewPenToDocument, wheelAngle, wheelPick, wheelPoint, wheelToHue };