@pixerate/editor 0.257.0 → 0.258.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.
@@ -178,3 +178,41 @@ export declare function paintProposalGhost(proposal: PaintProposal): {
178
178
  height: number;
179
179
  data: Uint8ClampedArray;
180
180
  } | null;
181
+ /** A stroke an agent is painting live, drawn over the canvas until it is painted for real. */
182
+ export interface PaintAgentStroke {
183
+ id: string;
184
+ /** Who paints it (`agent:<id>`). */
185
+ origin: string;
186
+ /** Path in document pixels. */
187
+ points: readonly {
188
+ x: number;
189
+ y: number;
190
+ }[];
191
+ /** #rrggbb */
192
+ color: string;
193
+ /** Line width in document pixels. */
194
+ size: number;
195
+ /** 0..1 (default 0.6). */
196
+ opacity?: number;
197
+ }
198
+ export interface PaintAgentStrokesState {
199
+ strokes: readonly PaintAgentStroke[];
200
+ }
201
+ /** Agent strokes in progress, for `PaintCanvas` (`agentStrokes`) to draw while the user's pen is down. */
202
+ export interface PaintAgentStrokes {
203
+ getState(): PaintAgentStrokesState;
204
+ subscribe(listener: (state: PaintAgentStrokesState) => void): () => void;
205
+ /** Adds or replaces a stroke (by id). */
206
+ set(stroke: PaintAgentStroke): void;
207
+ remove(id: string): void;
208
+ /** Removes every stroke (or those of one origin). */
209
+ clear(origin?: string): void;
210
+ }
211
+ /**
212
+ * Live agent strokes: an agent painting along with the user draws its companion strokes here
213
+ * while the user's stroke is in progress (the editor can't paint two strokes at once), then paints
214
+ * them for real when the user lifts the pen. `PaintCanvas` draws them as soft lines over the canvas.
215
+ */
216
+ export declare function createPaintAgentStrokes(): PaintAgentStrokes;
217
+ /** An SVG `points` attribute for a live agent stroke. */
218
+ export declare function paintAgentStrokePoints(stroke: PaintAgentStroke): string;
@@ -178,3 +178,41 @@ export declare function paintProposalGhost(proposal: PaintProposal): {
178
178
  height: number;
179
179
  data: Uint8ClampedArray;
180
180
  } | null;
181
+ /** A stroke an agent is painting live, drawn over the canvas until it is painted for real. */
182
+ export interface PaintAgentStroke {
183
+ id: string;
184
+ /** Who paints it (`agent:<id>`). */
185
+ origin: string;
186
+ /** Path in document pixels. */
187
+ points: readonly {
188
+ x: number;
189
+ y: number;
190
+ }[];
191
+ /** #rrggbb */
192
+ color: string;
193
+ /** Line width in document pixels. */
194
+ size: number;
195
+ /** 0..1 (default 0.6). */
196
+ opacity?: number;
197
+ }
198
+ export interface PaintAgentStrokesState {
199
+ strokes: readonly PaintAgentStroke[];
200
+ }
201
+ /** Agent strokes in progress, for `PaintCanvas` (`agentStrokes`) to draw while the user's pen is down. */
202
+ export interface PaintAgentStrokes {
203
+ getState(): PaintAgentStrokesState;
204
+ subscribe(listener: (state: PaintAgentStrokesState) => void): () => void;
205
+ /** Adds or replaces a stroke (by id). */
206
+ set(stroke: PaintAgentStroke): void;
207
+ remove(id: string): void;
208
+ /** Removes every stroke (or those of one origin). */
209
+ clear(origin?: string): void;
210
+ }
211
+ /**
212
+ * Live agent strokes: an agent painting along with the user draws its companion strokes here
213
+ * while the user's stroke is in progress (the editor can't paint two strokes at once), then paints
214
+ * them for real when the user lifts the pen. `PaintCanvas` draws them as soft lines over the canvas.
215
+ */
216
+ export declare function createPaintAgentStrokes(): PaintAgentStrokes;
217
+ /** An SVG `points` attribute for a live agent stroke. */
218
+ export declare function paintAgentStrokePoints(stroke: PaintAgentStroke): string;
@@ -204,6 +204,21 @@ export interface PaintLayerInfo {
204
204
  /** How many live layer effects (glows, shadows, strokes…) it has, when any (`getLayerEffects`). */
205
205
  effects?: number;
206
206
  }
207
+ /** A live stroke as it is painted (`onStrokeSample`), for agents that paint along with the user. */
208
+ export interface PaintStrokeSample {
209
+ /** `begin`: the pen went down. `points`: new samples. `end`: the stroke was recorded. `cancel`: it was abandoned. */
210
+ phase: 'begin' | 'points' | 'end' | 'cancel';
211
+ layerId: string;
212
+ brush: PaintBrush;
213
+ /** #rrggbb */
214
+ color: string;
215
+ /** Every raw sample so far (document pixels), in order. */
216
+ points: readonly PenPoint[];
217
+ /** The samples this event added (`points` only). */
218
+ added: readonly PenPoint[];
219
+ /** `end`: the recorded stroke's id, or `null` when it painted nothing. */
220
+ strokeId?: string | null;
221
+ }
207
222
  /** One change to the paint history, for hosts and change feeds (`onCommit`). */
208
223
  export interface PaintCommitEvent {
209
224
  /** `execute`: a new undo step. `merge`: folded into the last one (a slider drag). */
@@ -371,6 +386,7 @@ export declare class PaintEditorController {
371
386
  private readonly encodeImage;
372
387
  private listeners;
373
388
  private commitListeners;
389
+ private sampleListeners;
374
390
  /** Origins set by `withOrigin`, innermost last. */
375
391
  private origins;
376
392
  /** `group` in progress: commits fold into one step, recorded when it ends. */
@@ -433,6 +449,21 @@ export declare class PaintEditorController {
433
449
  private paperEffectNodeCache;
434
450
  constructor(options?: PaintEditorOptions);
435
451
  subscribe(listener: () => void): () => void;
452
+ /**
453
+ * Hears the user's live strokes as they are painted (`beginStroke` sessions, not strokes painted
454
+ * from data): when the pen goes down, each batch of samples, and the end or cancel. For agents
455
+ * that paint along in real time. Returns an unsubscribe function.
456
+ */
457
+ onStrokeSample(listener: (sample: PaintStrokeSample) => void): () => void;
458
+ private notifySample;
459
+ /** The stroke being painted now, or `null`: its layer, brush, colour and samples so far. */
460
+ getLiveStroke(): {
461
+ layerId: string;
462
+ brushId: string;
463
+ brushName: string;
464
+ color: string;
465
+ points: readonly PenPoint[];
466
+ } | null;
436
467
  /** Hears each undo step recorded, merged, undone or redone, with who made it. Returns an unsubscribe function. */
437
468
  onCommit(listener: (event: PaintCommitEvent) => void): () => void;
438
469
  private notifyCommit;
@@ -204,6 +204,21 @@ export interface PaintLayerInfo {
204
204
  /** How many live layer effects (glows, shadows, strokes…) it has, when any (`getLayerEffects`). */
205
205
  effects?: number;
206
206
  }
207
+ /** A live stroke as it is painted (`onStrokeSample`), for agents that paint along with the user. */
208
+ export interface PaintStrokeSample {
209
+ /** `begin`: the pen went down. `points`: new samples. `end`: the stroke was recorded. `cancel`: it was abandoned. */
210
+ phase: 'begin' | 'points' | 'end' | 'cancel';
211
+ layerId: string;
212
+ brush: PaintBrush;
213
+ /** #rrggbb */
214
+ color: string;
215
+ /** Every raw sample so far (document pixels), in order. */
216
+ points: readonly PenPoint[];
217
+ /** The samples this event added (`points` only). */
218
+ added: readonly PenPoint[];
219
+ /** `end`: the recorded stroke's id, or `null` when it painted nothing. */
220
+ strokeId?: string | null;
221
+ }
207
222
  /** One change to the paint history, for hosts and change feeds (`onCommit`). */
208
223
  export interface PaintCommitEvent {
209
224
  /** `execute`: a new undo step. `merge`: folded into the last one (a slider drag). */
@@ -371,6 +386,7 @@ export declare class PaintEditorController {
371
386
  private readonly encodeImage;
372
387
  private listeners;
373
388
  private commitListeners;
389
+ private sampleListeners;
374
390
  /** Origins set by `withOrigin`, innermost last. */
375
391
  private origins;
376
392
  /** `group` in progress: commits fold into one step, recorded when it ends. */
@@ -433,6 +449,21 @@ export declare class PaintEditorController {
433
449
  private paperEffectNodeCache;
434
450
  constructor(options?: PaintEditorOptions);
435
451
  subscribe(listener: () => void): () => void;
452
+ /**
453
+ * Hears the user's live strokes as they are painted (`beginStroke` sessions, not strokes painted
454
+ * from data): when the pen goes down, each batch of samples, and the end or cancel. For agents
455
+ * that paint along in real time. Returns an unsubscribe function.
456
+ */
457
+ onStrokeSample(listener: (sample: PaintStrokeSample) => void): () => void;
458
+ private notifySample;
459
+ /** The stroke being painted now, or `null`: its layer, brush, colour and samples so far. */
460
+ getLiveStroke(): {
461
+ layerId: string;
462
+ brushId: string;
463
+ brushName: string;
464
+ color: string;
465
+ points: readonly PenPoint[];
466
+ } | null;
436
467
  /** Hears each undo step recorded, merged, undone or redone, with who made it. Returns an unsubscribe function. */
437
468
  onCommit(listener: (event: PaintCommitEvent) => void): () => void;
438
469
  private notifyCommit;