@overtone-art/canvas-editor-core 0.3.2 → 0.5.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/node.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as EditorState } from './types-Dh1unrzT.mjs';
1
+ import { c as EditorState } from './types-JP8MZsIs.mjs';
2
2
  import 'fabric';
3
3
 
4
4
  interface PrintPdfOptions {
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as EditorState } from './types-Dh1unrzT.js';
1
+ import { c as EditorState } from './types-JP8MZsIs.js';
2
2
  import 'fabric';
3
3
 
4
4
  interface PrintPdfOptions {
@@ -21,6 +21,10 @@ interface LayerMeta {
21
21
  };
22
22
  /** Preset silhouette or texture the layer is clipped to. */
23
23
  maskPreset?: MaskPresetId;
24
+ /** Ordered mask stack clipping this layer (see `LayerMaskManager`). */
25
+ maskStack?: LayerMaskEntry[];
26
+ /** Marks the overlay layer that carries the whole-design mask stack. */
27
+ canvasMask?: boolean;
24
28
  /** Baseline curve applied to a text layer. */
25
29
  curve?: TextCurveConfig;
26
30
  /** Text box width authored before a curve widened it, in px. */
@@ -41,6 +45,36 @@ interface TextCurveConfig {
41
45
  type ShapeMaskPresetId = 'circle' | 'square' | 'triangle' | 'star' | 'heart' | 'octagram' | 'arch' | 'zigzag';
42
46
  type TextureMaskPresetId = 'vignette' | 'halftone' | 'spray' | 'grunge' | 'torn' | 'band';
43
47
  type MaskPresetId = ShapeMaskPresetId | TextureMaskPresetId;
48
+ /**
49
+ * How one mask combines with the masks under it in the stack:
50
+ * - `add` — keeps what it covers, on top of what earlier masks kept (union)
51
+ * - `subtract` — punches its shape out of what earlier masks kept
52
+ * - `intersect` — keeps only what it and the earlier masks both cover
53
+ */
54
+ type LayerMaskMode = 'add' | 'subtract' | 'intersect';
55
+ interface LayerMaskEntry {
56
+ id: string;
57
+ name: string;
58
+ mode: LayerMaskMode;
59
+ /**
60
+ * A linked mask follows the host layer's transform; an unlinked one is pinned
61
+ * to the canvas, so moving the layer slides the artwork under a static mask.
62
+ * Always false on the whole-design stack, which has no host to follow.
63
+ */
64
+ linked: boolean;
65
+ /** A hidden mask keeps its slot and its geometry, contributing nothing. */
66
+ visible: boolean;
67
+ /** 0…1 — a partly transparent mask reveals its area partly. */
68
+ opacity: number;
69
+ /**
70
+ * The mask's transform relative to its host, recorded only while the stack is
71
+ * composed in canvas space (an unlinked sibling forces that), so a linked mask
72
+ * can be re-derived after the host moves.
73
+ */
74
+ rel?: number[];
75
+ /** Host data describing where the geometry came from (preset id, generator…). */
76
+ meta?: Record<string, unknown>;
77
+ }
44
78
  interface LayerShadowConfig {
45
79
  enabled: boolean;
46
80
  color: string;
@@ -74,8 +108,6 @@ interface EditorConfig {
74
108
  preserveObjectStacking?: boolean;
75
109
  unit?: Unit;
76
110
  dpi?: number;
77
- /** Resolve a non-CORS image through a trusted proxy or same-origin store for pattern rendering. */
78
- patternSourceResolver?: PatternSourceResolver;
79
111
  fonts?: FontDefinition[];
80
112
  license?: LicenseConfig;
81
113
  }
@@ -161,7 +193,6 @@ interface ImageAdjustments {
161
193
  /** Range 0 to 1. */
162
194
  blur?: number;
163
195
  }
164
- type PatternSourceResolver = (source: string) => Promise<string>;
165
196
  interface FontDefinition {
166
197
  family: string;
167
198
  /** URL, data URL, or a complete CSS FontFace source such as `local(...)`. */
@@ -346,28 +377,25 @@ interface PatternLocks {
346
377
  lockRotation: boolean;
347
378
  hasControls: boolean;
348
379
  }
349
- /** Persisted on a layer's meta while it is rendered as a repeating pattern. */
380
+ /**
381
+ * Persisted on a layer's meta while it is tiled across the print area.
382
+ *
383
+ * Current states carry `config` and nothing else: the layer keeps its real
384
+ * object and the tiling is drawn by a render proxy, so there is no "original"
385
+ * to remember. The `original*` fields belong to states written by the engine
386
+ * that baked the tiled bitmap into the layer; they are read once, on restore,
387
+ * to put the artwork back (see `PatternManager.rehydrateAll`).
388
+ */
350
389
  interface PatternState {
351
390
  config: PatternConfig;
352
- /** Original (pre-pattern) image source, as a durable data URL when possible. */
353
- originalSrc: string;
354
- /**
355
- * Serialized `clipPath` the image carried before it became a pattern, or null
356
- * if it had none. A pattern must fill the whole print area, so any pre-pattern
357
- * clip (e.g. a template crop sized to the original box) is stripped while the
358
- * pattern is on and re-applied when it is turned off. Persisted so it survives
359
- * serialization / reload / undo.
360
- */
391
+ /** Legacy: pre-bake image source, as a durable data URL when possible. */
392
+ originalSrc?: string;
393
+ /** Legacy: serialized `clipPath` the image carried before it was baked. */
361
394
  originalClip?: Record<string, unknown> | null;
362
- /**
363
- * Interaction flags the object carried before it became a pattern. A pattern
364
- * fills the whole print area, so while it is on the object is locked in place
365
- * (a drag/resize would slide the tiled bitmap off the area and leave a bare
366
- * band); the captured flags are restored when the pattern is turned off.
367
- */
395
+ /** Legacy: interaction flags frozen while the baked bitmap was in place. */
368
396
  originalLocks?: PatternLocks;
369
- /** Original fabric transform, restored when the pattern is turned off. */
370
- original: {
397
+ /** Legacy: fabric transform to restore when un-baking. */
398
+ original?: {
371
399
  left: number;
372
400
  top: number;
373
401
  scaleX: number;
@@ -439,6 +467,13 @@ interface EditorEvents {
439
467
  'layers:changed': {
440
468
  layers: LayerData[];
441
469
  };
470
+ 'masks:changed': {
471
+ target: string;
472
+ };
473
+ 'mask:selected': {
474
+ target: string | null;
475
+ maskId: string | null;
476
+ };
442
477
  'selection:changed': {
443
478
  selected: string[];
444
479
  };
@@ -485,4 +520,4 @@ interface EditorEvents {
485
520
  };
486
521
  }
487
522
 
488
- export { type TemplateParameter as $, type MockupOverlay as A, type BackgroundImageOptions as B, type CanvasSizePreset as C, DEFAULT_PATTERN_CONFIG as D, type EditorConfig as E, type FileAdapter as F, type MockupPrintArea as G, type PatternLocks as H, type ImageAdjustments as I, type PatternSourceResolver as J, type PatternState as K, type LayerData as L, type MaskBrushOptions as M, type NormalizedLayerPosition as N, type PositioningAdapter as O, type PatternConfig as P, type PrintifyPositioning as Q, type ProjectPage as R, type ProjectState as S, type ResizeOptions as T, type SemanticExportOptions as U, type SerializedBackgroundImageOptions as V, type SerializedLayer as W, type ShapeMaskPresetId as X, type ShapePlugin as Y, type SvgExportOptions as Z, type TemplateDefinition as _, type DpiIssue as a, type TextCurveConfig as a0, type TextureMaskPresetId as a1, type TileMode as a2, type Unit as a3, type EditorEvents as b, type EditorState as c, type ExportFormat as d, type FontDefinition as e, type ImageAttribution as f, type ImageProvider as g, type ImageProviderResult as h, type ImageSearchOptions as i, type ImageSearchResult as j, type LayerMeta as k, type LayerShadowConfig as l, type LayerType as m, type LicenseConfig as n, type LicensePayload as o, type LicenseStatus as p, type MaskPoint as q, type MaskPresetId as r, type MaskRefinementPrompt as s, type MaskRefinementProvider as t, type MaskRefinementRequest as u, type MaskRefinementResult as v, type MockupBlendMode as w, type MockupConfig as x, type MockupDisplacement as y, type MockupDisplacementChannel as z };
523
+ export { type TemplateDefinition as $, type MockupDisplacement as A, type BackgroundImageOptions as B, type CanvasSizePreset as C, DEFAULT_PATTERN_CONFIG as D, type EditorConfig as E, type FileAdapter as F, type MockupDisplacementChannel as G, type MockupOverlay as H, type ImageAdjustments as I, type MockupPrintArea as J, type PatternLocks as K, type LayerData as L, type MaskBrushOptions as M, type NormalizedLayerPosition as N, type PatternState as O, type PatternConfig as P, type PositioningAdapter as Q, type PrintifyPositioning as R, type ProjectPage as S, type ProjectState as T, type ResizeOptions as U, type SemanticExportOptions as V, type SerializedBackgroundImageOptions as W, type SerializedLayer as X, type ShapeMaskPresetId as Y, type ShapePlugin as Z, type SvgExportOptions as _, type DpiIssue as a, type TemplateParameter as a0, type TextCurveConfig as a1, type TextureMaskPresetId as a2, type TileMode as a3, type Unit as a4, type EditorEvents as b, type EditorState as c, type ExportFormat as d, type FontDefinition as e, type ImageAttribution as f, type ImageProvider as g, type ImageProviderResult as h, type ImageSearchOptions as i, type ImageSearchResult as j, type LayerMaskEntry as k, type LayerMaskMode as l, type LayerMeta as m, type LayerShadowConfig as n, type LayerType as o, type LicenseConfig as p, type LicensePayload as q, type LicenseStatus as r, type MaskPoint as s, type MaskPresetId as t, type MaskRefinementPrompt as u, type MaskRefinementProvider as v, type MaskRefinementRequest as w, type MaskRefinementResult as x, type MockupBlendMode as y, type MockupConfig as z };
@@ -21,6 +21,10 @@ interface LayerMeta {
21
21
  };
22
22
  /** Preset silhouette or texture the layer is clipped to. */
23
23
  maskPreset?: MaskPresetId;
24
+ /** Ordered mask stack clipping this layer (see `LayerMaskManager`). */
25
+ maskStack?: LayerMaskEntry[];
26
+ /** Marks the overlay layer that carries the whole-design mask stack. */
27
+ canvasMask?: boolean;
24
28
  /** Baseline curve applied to a text layer. */
25
29
  curve?: TextCurveConfig;
26
30
  /** Text box width authored before a curve widened it, in px. */
@@ -41,6 +45,36 @@ interface TextCurveConfig {
41
45
  type ShapeMaskPresetId = 'circle' | 'square' | 'triangle' | 'star' | 'heart' | 'octagram' | 'arch' | 'zigzag';
42
46
  type TextureMaskPresetId = 'vignette' | 'halftone' | 'spray' | 'grunge' | 'torn' | 'band';
43
47
  type MaskPresetId = ShapeMaskPresetId | TextureMaskPresetId;
48
+ /**
49
+ * How one mask combines with the masks under it in the stack:
50
+ * - `add` — keeps what it covers, on top of what earlier masks kept (union)
51
+ * - `subtract` — punches its shape out of what earlier masks kept
52
+ * - `intersect` — keeps only what it and the earlier masks both cover
53
+ */
54
+ type LayerMaskMode = 'add' | 'subtract' | 'intersect';
55
+ interface LayerMaskEntry {
56
+ id: string;
57
+ name: string;
58
+ mode: LayerMaskMode;
59
+ /**
60
+ * A linked mask follows the host layer's transform; an unlinked one is pinned
61
+ * to the canvas, so moving the layer slides the artwork under a static mask.
62
+ * Always false on the whole-design stack, which has no host to follow.
63
+ */
64
+ linked: boolean;
65
+ /** A hidden mask keeps its slot and its geometry, contributing nothing. */
66
+ visible: boolean;
67
+ /** 0…1 — a partly transparent mask reveals its area partly. */
68
+ opacity: number;
69
+ /**
70
+ * The mask's transform relative to its host, recorded only while the stack is
71
+ * composed in canvas space (an unlinked sibling forces that), so a linked mask
72
+ * can be re-derived after the host moves.
73
+ */
74
+ rel?: number[];
75
+ /** Host data describing where the geometry came from (preset id, generator…). */
76
+ meta?: Record<string, unknown>;
77
+ }
44
78
  interface LayerShadowConfig {
45
79
  enabled: boolean;
46
80
  color: string;
@@ -74,8 +108,6 @@ interface EditorConfig {
74
108
  preserveObjectStacking?: boolean;
75
109
  unit?: Unit;
76
110
  dpi?: number;
77
- /** Resolve a non-CORS image through a trusted proxy or same-origin store for pattern rendering. */
78
- patternSourceResolver?: PatternSourceResolver;
79
111
  fonts?: FontDefinition[];
80
112
  license?: LicenseConfig;
81
113
  }
@@ -161,7 +193,6 @@ interface ImageAdjustments {
161
193
  /** Range 0 to 1. */
162
194
  blur?: number;
163
195
  }
164
- type PatternSourceResolver = (source: string) => Promise<string>;
165
196
  interface FontDefinition {
166
197
  family: string;
167
198
  /** URL, data URL, or a complete CSS FontFace source such as `local(...)`. */
@@ -346,28 +377,25 @@ interface PatternLocks {
346
377
  lockRotation: boolean;
347
378
  hasControls: boolean;
348
379
  }
349
- /** Persisted on a layer's meta while it is rendered as a repeating pattern. */
380
+ /**
381
+ * Persisted on a layer's meta while it is tiled across the print area.
382
+ *
383
+ * Current states carry `config` and nothing else: the layer keeps its real
384
+ * object and the tiling is drawn by a render proxy, so there is no "original"
385
+ * to remember. The `original*` fields belong to states written by the engine
386
+ * that baked the tiled bitmap into the layer; they are read once, on restore,
387
+ * to put the artwork back (see `PatternManager.rehydrateAll`).
388
+ */
350
389
  interface PatternState {
351
390
  config: PatternConfig;
352
- /** Original (pre-pattern) image source, as a durable data URL when possible. */
353
- originalSrc: string;
354
- /**
355
- * Serialized `clipPath` the image carried before it became a pattern, or null
356
- * if it had none. A pattern must fill the whole print area, so any pre-pattern
357
- * clip (e.g. a template crop sized to the original box) is stripped while the
358
- * pattern is on and re-applied when it is turned off. Persisted so it survives
359
- * serialization / reload / undo.
360
- */
391
+ /** Legacy: pre-bake image source, as a durable data URL when possible. */
392
+ originalSrc?: string;
393
+ /** Legacy: serialized `clipPath` the image carried before it was baked. */
361
394
  originalClip?: Record<string, unknown> | null;
362
- /**
363
- * Interaction flags the object carried before it became a pattern. A pattern
364
- * fills the whole print area, so while it is on the object is locked in place
365
- * (a drag/resize would slide the tiled bitmap off the area and leave a bare
366
- * band); the captured flags are restored when the pattern is turned off.
367
- */
395
+ /** Legacy: interaction flags frozen while the baked bitmap was in place. */
368
396
  originalLocks?: PatternLocks;
369
- /** Original fabric transform, restored when the pattern is turned off. */
370
- original: {
397
+ /** Legacy: fabric transform to restore when un-baking. */
398
+ original?: {
371
399
  left: number;
372
400
  top: number;
373
401
  scaleX: number;
@@ -439,6 +467,13 @@ interface EditorEvents {
439
467
  'layers:changed': {
440
468
  layers: LayerData[];
441
469
  };
470
+ 'masks:changed': {
471
+ target: string;
472
+ };
473
+ 'mask:selected': {
474
+ target: string | null;
475
+ maskId: string | null;
476
+ };
442
477
  'selection:changed': {
443
478
  selected: string[];
444
479
  };
@@ -485,4 +520,4 @@ interface EditorEvents {
485
520
  };
486
521
  }
487
522
 
488
- export { type TemplateParameter as $, type MockupOverlay as A, type BackgroundImageOptions as B, type CanvasSizePreset as C, DEFAULT_PATTERN_CONFIG as D, type EditorConfig as E, type FileAdapter as F, type MockupPrintArea as G, type PatternLocks as H, type ImageAdjustments as I, type PatternSourceResolver as J, type PatternState as K, type LayerData as L, type MaskBrushOptions as M, type NormalizedLayerPosition as N, type PositioningAdapter as O, type PatternConfig as P, type PrintifyPositioning as Q, type ProjectPage as R, type ProjectState as S, type ResizeOptions as T, type SemanticExportOptions as U, type SerializedBackgroundImageOptions as V, type SerializedLayer as W, type ShapeMaskPresetId as X, type ShapePlugin as Y, type SvgExportOptions as Z, type TemplateDefinition as _, type DpiIssue as a, type TextCurveConfig as a0, type TextureMaskPresetId as a1, type TileMode as a2, type Unit as a3, type EditorEvents as b, type EditorState as c, type ExportFormat as d, type FontDefinition as e, type ImageAttribution as f, type ImageProvider as g, type ImageProviderResult as h, type ImageSearchOptions as i, type ImageSearchResult as j, type LayerMeta as k, type LayerShadowConfig as l, type LayerType as m, type LicenseConfig as n, type LicensePayload as o, type LicenseStatus as p, type MaskPoint as q, type MaskPresetId as r, type MaskRefinementPrompt as s, type MaskRefinementProvider as t, type MaskRefinementRequest as u, type MaskRefinementResult as v, type MockupBlendMode as w, type MockupConfig as x, type MockupDisplacement as y, type MockupDisplacementChannel as z };
523
+ export { type TemplateDefinition as $, type MockupDisplacement as A, type BackgroundImageOptions as B, type CanvasSizePreset as C, DEFAULT_PATTERN_CONFIG as D, type EditorConfig as E, type FileAdapter as F, type MockupDisplacementChannel as G, type MockupOverlay as H, type ImageAdjustments as I, type MockupPrintArea as J, type PatternLocks as K, type LayerData as L, type MaskBrushOptions as M, type NormalizedLayerPosition as N, type PatternState as O, type PatternConfig as P, type PositioningAdapter as Q, type PrintifyPositioning as R, type ProjectPage as S, type ProjectState as T, type ResizeOptions as U, type SemanticExportOptions as V, type SerializedBackgroundImageOptions as W, type SerializedLayer as X, type ShapeMaskPresetId as Y, type ShapePlugin as Z, type SvgExportOptions as _, type DpiIssue as a, type TemplateParameter as a0, type TextCurveConfig as a1, type TextureMaskPresetId as a2, type TileMode as a3, type Unit as a4, type EditorEvents as b, type EditorState as c, type ExportFormat as d, type FontDefinition as e, type ImageAttribution as f, type ImageProvider as g, type ImageProviderResult as h, type ImageSearchOptions as i, type ImageSearchResult as j, type LayerMaskEntry as k, type LayerMaskMode as l, type LayerMeta as m, type LayerShadowConfig as n, type LayerType as o, type LicenseConfig as p, type LicensePayload as q, type LicenseStatus as r, type MaskPoint as s, type MaskPresetId as t, type MaskRefinementPrompt as u, type MaskRefinementProvider as v, type MaskRefinementRequest as w, type MaskRefinementResult as x, type MockupBlendMode as y, type MockupConfig as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overtone-art/canvas-editor-core",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "Abstract pluggable canvas editor built on Fabric.js",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",