@overtone-art/canvas-editor-core 0.2.7 → 0.3.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.
- package/dist/chunk-MCBRZQ4M.mjs +261 -0
- package/dist/chunk-MCBRZQ4M.mjs.map +1 -0
- package/dist/index.d.mts +326 -5
- package/dist/index.d.ts +326 -5
- package/dist/index.global.js +71 -71
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1350 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1136 -35
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +51 -2
- package/dist/node.d.ts +51 -2
- package/dist/node.js +546 -13
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +446 -4
- package/dist/node.mjs.map +1 -1
- package/dist/{types-bOY7oYVq.d.mts → types-Dh1unrzT.d.mts} +107 -2
- package/dist/{types-bOY7oYVq.d.ts → types-Dh1unrzT.d.ts} +107 -2
- package/package.json +42 -5
- package/dist/chunk-NINRTPOJ.mjs +0 -104
- package/dist/chunk-NINRTPOJ.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Canvas, FabricObject, ImageFormat } from 'fabric';
|
|
2
|
-
import { b as EditorEvents,
|
|
3
|
-
export { D as DEFAULT_PATTERN_CONFIG, d as ExportFormat, f as ImageAttribution,
|
|
2
|
+
import { b as EditorEvents, m as LayerType, k as LayerMeta, L as LayerData, W as SerializedLayer, J as PatternSourceResolver, P as PatternConfig, H as PatternLocks, a0 as TextCurveConfig, r as MaskPresetId, X as ShapeMaskPresetId, a1 as TextureMaskPresetId, a3 as Unit, G as MockupPrintArea, x as MockupConfig, e as FontDefinition, n as LicenseConfig, p as LicenseStatus, S as ProjectState, M as MaskBrushOptions, q as MaskPoint, t as MaskRefinementProvider, s as MaskRefinementPrompt, v as MaskRefinementResult, E as EditorConfig, Y as ShapePlugin, _ as TemplateDefinition, I as ImageAdjustments, c as EditorState, U as SemanticExportOptions, Z as SvgExportOptions, Q as PrintifyPositioning, N as NormalizedLayerPosition, O as PositioningAdapter, h as ImageProviderResult, i as ImageSearchOptions, j as ImageSearchResult, F as FileAdapter, g as ImageProvider, V as SerializedBackgroundImageOptions, B as BackgroundImageOptions, T as ResizeOptions, a as DpiIssue, l as LayerShadowConfig, C as CanvasSizePreset, y as MockupDisplacement } from './types-Dh1unrzT.mjs';
|
|
3
|
+
export { D as DEFAULT_PATTERN_CONFIG, d as ExportFormat, f as ImageAttribution, o as LicensePayload, u as MaskRefinementRequest, w as MockupBlendMode, z as MockupDisplacementChannel, A as MockupOverlay, K as PatternState, R as ProjectPage, $ as TemplateParameter, a2 as TileMode } from './types-Dh1unrzT.mjs';
|
|
4
4
|
|
|
5
5
|
type EventHandler<T> = (data: T) => void;
|
|
6
6
|
declare class EventEmitter<TEvents extends {} = Record<string, unknown>> {
|
|
@@ -53,8 +53,12 @@ declare class LayerManager {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
declare class HistoryManager {
|
|
56
|
+
private static readonly ASSET_KEY;
|
|
56
57
|
private undoStack;
|
|
57
58
|
private redoStack;
|
|
59
|
+
private assets;
|
|
60
|
+
private assetIds;
|
|
61
|
+
private nextAssetId;
|
|
58
62
|
private maxSize;
|
|
59
63
|
private maxBytes;
|
|
60
64
|
private paused;
|
|
@@ -94,6 +98,21 @@ declare class HistoryManager {
|
|
|
94
98
|
private emitChanged;
|
|
95
99
|
private snapshotBytes;
|
|
96
100
|
private trimToBudget;
|
|
101
|
+
/**
|
|
102
|
+
* History is internal and can content-address large raster strings without
|
|
103
|
+
* changing the public EditorState wire format. Unchanged images are retained
|
|
104
|
+
* once even when dozens of snapshots reference them.
|
|
105
|
+
*/
|
|
106
|
+
private compactState;
|
|
107
|
+
private expandState;
|
|
108
|
+
/**
|
|
109
|
+
* Runs on every commit, so it scans for the serialized reference marker
|
|
110
|
+
* instead of re-parsing every snapshot — parsing multi-megabyte raster states
|
|
111
|
+
* per save would cost more than the retention it reclaims. `JSON.stringify`
|
|
112
|
+
* emits the marker verbatim; the same text inside user data is escaped and
|
|
113
|
+
* therefore cannot match.
|
|
114
|
+
*/
|
|
115
|
+
private pruneAssets;
|
|
97
116
|
}
|
|
98
117
|
|
|
99
118
|
/**
|
|
@@ -227,6 +246,107 @@ interface CanvasRenderingProtocol {
|
|
|
227
246
|
drawImage(image: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void;
|
|
228
247
|
}
|
|
229
248
|
|
|
249
|
+
/** Straight text — the state every text layer starts in. */
|
|
250
|
+
declare const DEFAULT_TEXT_CURVE: TextCurveConfig;
|
|
251
|
+
interface CurvePath {
|
|
252
|
+
/** SVG path data the text is laid out along. */
|
|
253
|
+
data: string;
|
|
254
|
+
/** Length of that path, used to centre the run on it. */
|
|
255
|
+
length: number;
|
|
256
|
+
}
|
|
257
|
+
/** Path the given curve traces for a text run of `width` px, or null when straight. */
|
|
258
|
+
declare function buildCurvePathData(config: TextCurveConfig, width: number, fontSize: number): CurvePath | null;
|
|
259
|
+
/**
|
|
260
|
+
* Bends a text layer's baseline along a generated path.
|
|
261
|
+
*
|
|
262
|
+
* The curve lives on the fabric object as a real text path, so it survives
|
|
263
|
+
* export and serialization with no extra machinery. The parameters that
|
|
264
|
+
* produced it are kept in `layer.meta.curve` so the UI can show them and so the
|
|
265
|
+
* path can be rebuilt when the text, font or size changes.
|
|
266
|
+
*/
|
|
267
|
+
declare class TextCurveManager {
|
|
268
|
+
private canvas;
|
|
269
|
+
private layers;
|
|
270
|
+
private history;
|
|
271
|
+
private events;
|
|
272
|
+
constructor(canvas: Canvas, layers: LayerManager, history: HistoryManager, events: EventEmitter<EditorEvents>);
|
|
273
|
+
/** Curve parameters for a layer, or null when it is not curved text. */
|
|
274
|
+
get(layerId: string): TextCurveConfig | null;
|
|
275
|
+
isCurved(layerId: string): boolean;
|
|
276
|
+
/** Apply (or update) the curve on a text layer. Zeroed config clears it. */
|
|
277
|
+
apply(layerId: string, config: Partial<TextCurveConfig>, save?: boolean): boolean;
|
|
278
|
+
/** Remove the curve, restoring the authored text box width. */
|
|
279
|
+
clear(layerId: string, save?: boolean): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Rebuild the path from the stored parameters. Text content, font family and
|
|
282
|
+
* font size all change the run's width, and the path is sized to that width —
|
|
283
|
+
* without this the curve keeps the geometry of the text it was created from.
|
|
284
|
+
*/
|
|
285
|
+
refresh(layerId: string, save?: boolean): boolean;
|
|
286
|
+
/** Rebuild every curved layer — used after a state restore. */
|
|
287
|
+
refreshAll(): void;
|
|
288
|
+
private detach;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
declare function isMaskPresetId(value: unknown): value is MaskPresetId;
|
|
292
|
+
/**
|
|
293
|
+
* Clips a layer to a preset silhouette or soft texture.
|
|
294
|
+
*
|
|
295
|
+
* The preset is installed as the fabric object's `clipPath`, so it renders,
|
|
296
|
+
* exports and serializes through the same path fabric already uses. The chosen
|
|
297
|
+
* id is kept in `layer.meta.maskPreset` so the UI can show the active preset
|
|
298
|
+
* and so the clip can be rebuilt when the layer is resized.
|
|
299
|
+
*
|
|
300
|
+
* A pattern strips and restores the layer's clip while it is enabled (see
|
|
301
|
+
* `PatternManager`), so a mask preset is suspended for the duration of one.
|
|
302
|
+
*/
|
|
303
|
+
declare class MaskPresetManager {
|
|
304
|
+
private canvas;
|
|
305
|
+
private layers;
|
|
306
|
+
private history;
|
|
307
|
+
private events;
|
|
308
|
+
constructor(canvas: Canvas, layers: LayerManager, history: HistoryManager, events: EventEmitter<EditorEvents>);
|
|
309
|
+
get(layerId: string): MaskPresetId | null;
|
|
310
|
+
/** Clip the layer to `id`. Passing null (or an unknown id) clears the clip. */
|
|
311
|
+
apply(layerId: string, id: MaskPresetId | null, save?: boolean): boolean;
|
|
312
|
+
clear(layerId: string, save?: boolean): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Re-fit the clip to the layer's current size. The clip is built for the
|
|
315
|
+
* object's dimensions at the time it was applied; editing text or replacing an
|
|
316
|
+
* image changes them, and a stale clip would crop the wrong region.
|
|
317
|
+
*/
|
|
318
|
+
refresh(layerId: string, save?: boolean): boolean;
|
|
319
|
+
/** Re-fit every masked layer — used after a state restore. */
|
|
320
|
+
refreshAll(): void;
|
|
321
|
+
private buildClip;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** Silhouette masks, authored on a 0–100 square so they scale to any layer. */
|
|
325
|
+
declare const SHAPE_MASK_IDS: readonly ["circle", "square", "triangle", "star", "heart", "octagram", "arch", "zigzag"];
|
|
326
|
+
type ShapeMaskId = ShapeMaskPresetId;
|
|
327
|
+
declare function isShapeMaskId(value: unknown): value is ShapeMaskId;
|
|
328
|
+
/** SVG path data for a shape mask, on a 100×100 box. */
|
|
329
|
+
declare function shapeMaskPathData(id: ShapeMaskId): string;
|
|
330
|
+
/** Nominal authoring box every shape mask path is drawn in. */
|
|
331
|
+
declare const SHAPE_MASK_BOX = 100;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Procedural alpha textures used as soft layer masks.
|
|
335
|
+
*
|
|
336
|
+
* Each renders white-on-transparent at a fixed resolution; the opaque parts are
|
|
337
|
+
* what survives masking. They are deterministic (seeded PRNG, no `Math.random`)
|
|
338
|
+
* so a design renders identically on every load and in every export.
|
|
339
|
+
*/
|
|
340
|
+
declare const TEXTURE_MASK_IDS: readonly ["vignette", "halftone", "spray", "grunge", "torn", "band"];
|
|
341
|
+
type TextureMaskId = TextureMaskPresetId;
|
|
342
|
+
declare function isTextureMaskId(value: unknown): value is TextureMaskId;
|
|
343
|
+
/** Square resolution every texture is rendered at before being scaled to fit. */
|
|
344
|
+
declare const TEXTURE_MASK_SIZE = 320;
|
|
345
|
+
/** Render (and memoize) a texture mask. Browser-only: needs a 2D canvas. */
|
|
346
|
+
declare function renderTextureMask(id: TextureMaskId): HTMLCanvasElement;
|
|
347
|
+
/** Drop memoized textures — used by tests and by long-lived editors on dispose. */
|
|
348
|
+
declare function clearTextureMaskCache(): void;
|
|
349
|
+
|
|
230
350
|
declare class UnitConverter {
|
|
231
351
|
private unit;
|
|
232
352
|
private dpi;
|
|
@@ -254,6 +374,14 @@ declare function computePrintAreaClip(area: MockupPrintArea, scaleX: number, sca
|
|
|
254
374
|
/** Object-fit: cover geometry, exported for deterministic preview/composite tests. */
|
|
255
375
|
declare function computeCoverPlacement(sourceWidth: number, sourceHeight: number, targetWidth: number, targetHeight: number): CoverPlacement;
|
|
256
376
|
declare function exportPNG(canvas: Canvas, options?: PngExportOptions): Promise<Blob>;
|
|
377
|
+
/**
|
|
378
|
+
* Render just the print-area rectangle, on transparency.
|
|
379
|
+
*
|
|
380
|
+
* This is the file a print provider receives: the design alone, cropped to the
|
|
381
|
+
* printable rectangle, with no garment behind it and no canvas background baked
|
|
382
|
+
* in — so it is rendered from cloned objects rather than off the live canvas.
|
|
383
|
+
*/
|
|
384
|
+
declare function exportPrintArea(source: Canvas, area: MockupPrintArea, options?: PngExportOptions): Promise<Blob>;
|
|
257
385
|
/** Rasterize the browser mockup preview together with the transparent design. */
|
|
258
386
|
declare function exportMockup(canvas: Canvas, mockup: MockupConfig, options?: PngExportOptions): Promise<Blob>;
|
|
259
387
|
declare function exportSVG(canvas: Canvas): string;
|
|
@@ -308,6 +436,60 @@ declare class ProjectManager {
|
|
|
308
436
|
private emitChanged;
|
|
309
437
|
}
|
|
310
438
|
|
|
439
|
+
type MaskRefinementErrorCode = 'not-found' | 'cancelled' | 'provider' | 'invalid-result';
|
|
440
|
+
declare class MaskRefinementError extends Error {
|
|
441
|
+
readonly code: MaskRefinementErrorCode;
|
|
442
|
+
readonly cause?: unknown | undefined;
|
|
443
|
+
constructor(code: MaskRefinementErrorCode, message: string, cause?: unknown | undefined);
|
|
444
|
+
}
|
|
445
|
+
interface MaskPerformanceSample {
|
|
446
|
+
width: number;
|
|
447
|
+
height: number;
|
|
448
|
+
backingBytes: number;
|
|
449
|
+
strokeBackupBytes: number;
|
|
450
|
+
estimatedPeakBytes: number;
|
|
451
|
+
historyBytes: number;
|
|
452
|
+
interactionLatencyMs: number;
|
|
453
|
+
usedJsHeapBytes?: number;
|
|
454
|
+
elapsedMs: number;
|
|
455
|
+
}
|
|
456
|
+
/** Raster-mask editing without exposing Fabric brush classes in the public contract. */
|
|
457
|
+
declare class MaskController {
|
|
458
|
+
private readonly editor;
|
|
459
|
+
private backing;
|
|
460
|
+
private context;
|
|
461
|
+
private layerId;
|
|
462
|
+
private brush;
|
|
463
|
+
private previousPoint;
|
|
464
|
+
private strokeBackup;
|
|
465
|
+
private strokeStartedAt;
|
|
466
|
+
private lastInteractionLatencyMs;
|
|
467
|
+
private refinement;
|
|
468
|
+
private disposed;
|
|
469
|
+
constructor(editor: CanvasEditor);
|
|
470
|
+
create(width?: number, height?: number): Promise<Layer>;
|
|
471
|
+
attach(layerId: string): void;
|
|
472
|
+
beginStroke(options: MaskBrushOptions): void;
|
|
473
|
+
addPoint(point: MaskPoint): void;
|
|
474
|
+
endStroke(): Promise<void>;
|
|
475
|
+
cancelStroke(): void;
|
|
476
|
+
isStrokeActive(): boolean;
|
|
477
|
+
activeLayerId(): string | null;
|
|
478
|
+
detach(layerId?: string): void;
|
|
479
|
+
refine(layerId: string, provider: MaskRefinementProvider, prompts: MaskRefinementPrompt[], options?: {
|
|
480
|
+
signal?: AbortSignal;
|
|
481
|
+
onProgress?: (progress: number) => void;
|
|
482
|
+
}): Promise<MaskRefinementResult>;
|
|
483
|
+
cancelRefinement(): void;
|
|
484
|
+
measure(): MaskPerformanceSample | null;
|
|
485
|
+
dispose(): void;
|
|
486
|
+
private drawDot;
|
|
487
|
+
private makeCanvas;
|
|
488
|
+
private attachBacking;
|
|
489
|
+
private requireMask;
|
|
490
|
+
private assertActive;
|
|
491
|
+
}
|
|
492
|
+
|
|
311
493
|
declare class CanvasEditor {
|
|
312
494
|
readonly canvas: Canvas;
|
|
313
495
|
readonly layers: LayerManager;
|
|
@@ -317,15 +499,19 @@ declare class CanvasEditor {
|
|
|
317
499
|
readonly snapping: SnapManager;
|
|
318
500
|
readonly crop: CropController;
|
|
319
501
|
readonly patterns: PatternManager;
|
|
502
|
+
readonly curves: TextCurveManager;
|
|
503
|
+
readonly maskPresets: MaskPresetManager;
|
|
320
504
|
readonly fonts: FontRegistry;
|
|
321
505
|
readonly licensing: LicenseManager;
|
|
322
506
|
readonly pages: ProjectManager;
|
|
507
|
+
readonly masks: MaskController;
|
|
323
508
|
private fileAdapter?;
|
|
324
509
|
private imageProvider?;
|
|
325
510
|
private zoomLevel;
|
|
326
511
|
private mockup;
|
|
327
512
|
private designBackground;
|
|
328
513
|
private designBackgroundImage;
|
|
514
|
+
private backgroundImageOptions;
|
|
329
515
|
constructor(canvasElement: HTMLCanvasElement, config: EditorConfig);
|
|
330
516
|
addImage(url: string, options?: Partial<Record<string, unknown>>): Promise<Layer>;
|
|
331
517
|
/** Replace an image source without changing its layer identity or visual transform. */
|
|
@@ -350,10 +536,20 @@ declare class CanvasEditor {
|
|
|
350
536
|
toPNG(options?: PngExportOptions): Promise<Blob>;
|
|
351
537
|
toJPEG(options?: Omit<PngExportOptions, 'format'>): Promise<Blob>;
|
|
352
538
|
toWebP(options?: Omit<PngExportOptions, 'format'>): Promise<Blob>;
|
|
539
|
+
/** Export one layer in document coordinates or at its native image resolution. */
|
|
540
|
+
exportLayer(id: string, options?: SemanticExportOptions): Promise<Blob>;
|
|
541
|
+
/** Export only the configured document background, excluding design layers. */
|
|
542
|
+
exportBackground(options?: SemanticExportOptions): Promise<Blob>;
|
|
353
543
|
private toRaster;
|
|
354
544
|
toSVG(): string;
|
|
355
545
|
toSVGAsync(options?: SvgExportOptions): Promise<string>;
|
|
356
546
|
toDataURL(format?: ImageFormat, multiplier?: number): string;
|
|
547
|
+
/**
|
|
548
|
+
* Export the print file: the design cropped to the mockup's print area, on
|
|
549
|
+
* transparency. Without a print area this is the whole canvas, still
|
|
550
|
+
* transparent — a print file never carries the design background.
|
|
551
|
+
*/
|
|
552
|
+
toPrintFile(options?: PngExportOptions): Promise<Blob>;
|
|
357
553
|
/** Export the current product-preview composite. Advanced warping is host-defined. */
|
|
358
554
|
toMockupImage(options?: PngExportOptions): Promise<Blob>;
|
|
359
555
|
/**
|
|
@@ -377,9 +573,10 @@ declare class CanvasEditor {
|
|
|
377
573
|
setBackground(color: string): void;
|
|
378
574
|
getDesignBackground(): string;
|
|
379
575
|
getDesignBackgroundImage(): FabricObject | null;
|
|
576
|
+
getBackgroundImageOptions(): SerializedBackgroundImageOptions | null;
|
|
380
577
|
setBackgroundImage(url: string | null, options?: BackgroundImageOptions): Promise<void>;
|
|
381
578
|
/** Used by state restoration and advanced integrations with an existing Fabric object. */
|
|
382
|
-
setBackgroundImageObject(image: FabricObject | null, save?: boolean): void;
|
|
579
|
+
setBackgroundImageObject(image: FabricObject | null, save?: boolean, options?: SerializedBackgroundImageOptions | null): void;
|
|
383
580
|
setTransparentBackground(): void;
|
|
384
581
|
resize(width: number, height: number, options?: ResizeOptions): void;
|
|
385
582
|
/** Effective source resolution for an image at its current physical size. */
|
|
@@ -404,13 +601,64 @@ declare class CanvasEditor {
|
|
|
404
601
|
zoomToSelection(padding?: number): void;
|
|
405
602
|
applyPattern(layerId: string, config: PatternConfig): Promise<void>;
|
|
406
603
|
clearPattern(layerId: string): Promise<void>;
|
|
407
|
-
|
|
604
|
+
applyTextCurve(layerId: string, config: Partial<TextCurveConfig>): boolean;
|
|
605
|
+
clearTextCurve(layerId: string): boolean;
|
|
606
|
+
getTextCurve(layerId: string): TextCurveConfig | null;
|
|
607
|
+
applyMaskPreset(layerId: string, id: MaskPresetId | null): boolean;
|
|
608
|
+
clearMaskPreset(layerId: string): boolean;
|
|
609
|
+
getMaskPreset(layerId: string): MaskPresetId | null;
|
|
610
|
+
/**
|
|
611
|
+
* Constrain a layer to its current proportions. Persisted on the layer so a
|
|
612
|
+
* reopened design still resizes the way it was set up to.
|
|
613
|
+
*/
|
|
614
|
+
setLayerAspectLock(layerId: string, locked: boolean): boolean;
|
|
615
|
+
getLayerAspectLock(layerId: string): boolean;
|
|
616
|
+
/** Re-apply every stored aspect lock — control visibility is not serialized. */
|
|
617
|
+
restoreAspectLocks(): void;
|
|
618
|
+
/** Drop scale, rotation, skew and flips; the layer stays where it is. */
|
|
619
|
+
resetLayerTransform(layerId: string): boolean;
|
|
620
|
+
setLayerShadow(layerId: string, config: Partial<LayerShadowConfig>): boolean;
|
|
621
|
+
getLayerShadow(layerId: string): LayerShadowConfig | null;
|
|
622
|
+
/**
|
|
623
|
+
* Show (or clear) the product preview. Pass `history: false` for preview-only
|
|
624
|
+
* changes such as swapping a colourway — those are not design edits and
|
|
625
|
+
* should not fill the undo stack.
|
|
626
|
+
*/
|
|
627
|
+
setMockup(mockup: MockupConfig | null, options?: {
|
|
628
|
+
history?: boolean;
|
|
629
|
+
}): void;
|
|
408
630
|
clearMockup(): void;
|
|
409
631
|
getMockup(): MockupConfig | null;
|
|
410
632
|
dispose(): void;
|
|
411
633
|
private setupCanvasEvents;
|
|
412
634
|
}
|
|
413
635
|
|
|
636
|
+
declare const DEFAULT_LAYER_SHADOW: LayerShadowConfig;
|
|
637
|
+
/**
|
|
638
|
+
* Read a layer's drop shadow back off its fabric object.
|
|
639
|
+
*
|
|
640
|
+
* Fabric serializes `shadow` with the object, so the object — not layer meta —
|
|
641
|
+
* is the source of truth; nothing extra has to round-trip through the editor
|
|
642
|
+
* state for a shadow to survive save/load.
|
|
643
|
+
*/
|
|
644
|
+
declare function readLayerShadow(object: FabricObject): LayerShadowConfig;
|
|
645
|
+
/** Install (or remove) a drop shadow on a fabric object. */
|
|
646
|
+
declare function applyLayerShadow(object: FabricObject, config: Partial<LayerShadowConfig>): void;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Constrain (or release) a layer's proportions.
|
|
650
|
+
*
|
|
651
|
+
* Fabric already scales uniformly from the corners (`canvas.uniformScaling`),
|
|
652
|
+
* so the lock is enforced by taking away the single-axis handles — every
|
|
653
|
+
* remaining control keeps the ratio.
|
|
654
|
+
*/
|
|
655
|
+
declare function applyAspectLock(object: FabricObject, locked: boolean): void;
|
|
656
|
+
/**
|
|
657
|
+
* Undo scaling, rotation, skew and flips, leaving the layer where it sits.
|
|
658
|
+
* Position is deliberately kept: this is "reset the shape", not "move it back".
|
|
659
|
+
*/
|
|
660
|
+
declare function resetTransform(object: FabricObject): void;
|
|
661
|
+
|
|
414
662
|
declare const generateId: () => string;
|
|
415
663
|
|
|
416
664
|
declare function clamp(v: number, min: number, max: number): number;
|
|
@@ -437,4 +685,77 @@ declare function deserializeEditor(editor: CanvasEditor, state: EditorState): Pr
|
|
|
437
685
|
/** Common print and digital canvas sizes. */
|
|
438
686
|
declare const CANVAS_SIZE_PRESETS: readonly CanvasSizePreset[];
|
|
439
687
|
|
|
440
|
-
|
|
688
|
+
type AnnotationPrimitive = {
|
|
689
|
+
id: string;
|
|
690
|
+
type: 'point';
|
|
691
|
+
x: number;
|
|
692
|
+
y: number;
|
|
693
|
+
label?: string;
|
|
694
|
+
} | {
|
|
695
|
+
id: string;
|
|
696
|
+
type: 'rectangle';
|
|
697
|
+
left: number;
|
|
698
|
+
top: number;
|
|
699
|
+
width: number;
|
|
700
|
+
height: number;
|
|
701
|
+
label?: string;
|
|
702
|
+
} | {
|
|
703
|
+
id: string;
|
|
704
|
+
type: 'label';
|
|
705
|
+
x: number;
|
|
706
|
+
y: number;
|
|
707
|
+
text: string;
|
|
708
|
+
} | {
|
|
709
|
+
id: string;
|
|
710
|
+
type: 'path';
|
|
711
|
+
points: Array<{
|
|
712
|
+
x: number;
|
|
713
|
+
y: number;
|
|
714
|
+
}>;
|
|
715
|
+
label?: string;
|
|
716
|
+
};
|
|
717
|
+
interface ViewportTransform {
|
|
718
|
+
zoom: number;
|
|
719
|
+
panX: number;
|
|
720
|
+
panY: number;
|
|
721
|
+
devicePixelRatio?: number;
|
|
722
|
+
}
|
|
723
|
+
/** Host-owned annotations that never enter editor layers, history, serialization, or exports. */
|
|
724
|
+
declare class AnnotationOverlay {
|
|
725
|
+
private items;
|
|
726
|
+
private transform;
|
|
727
|
+
set(annotation: AnnotationPrimitive): void;
|
|
728
|
+
remove(id: string): boolean;
|
|
729
|
+
clear(): void;
|
|
730
|
+
getAll(): AnnotationPrimitive[];
|
|
731
|
+
setTransform(transform: ViewportTransform): void;
|
|
732
|
+
documentToViewport(point: {
|
|
733
|
+
x: number;
|
|
734
|
+
y: number;
|
|
735
|
+
}): {
|
|
736
|
+
x: number;
|
|
737
|
+
y: number;
|
|
738
|
+
};
|
|
739
|
+
viewportToDocument(point: {
|
|
740
|
+
x: number;
|
|
741
|
+
y: number;
|
|
742
|
+
}): {
|
|
743
|
+
x: number;
|
|
744
|
+
y: number;
|
|
745
|
+
};
|
|
746
|
+
documentToDevice(point: {
|
|
747
|
+
x: number;
|
|
748
|
+
y: number;
|
|
749
|
+
}): {
|
|
750
|
+
x: number;
|
|
751
|
+
y: number;
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Warp RGBA pixels with an equally sized channel map. A channel value of 128
|
|
757
|
+
* is neutral; 0 and 255 move by the configured negative/positive maximum.
|
|
758
|
+
*/
|
|
759
|
+
declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
|
|
760
|
+
|
|
761
|
+
export { AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_SIZE_PRESETS, CanvasEditor, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, PatternSourceResolver, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyPatternLocks, buildCurvePathData, buildPatternDataURL, captureLocks, clamp, clearPatternImageCache, clearTextureMaskCache, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, loadPatternImage, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData };
|