@pixerate/editor 0.157.0 → 0.158.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.
@@ -79,3 +79,27 @@ export declare const BIT_DEPTH_OPTIONS: readonly {
79
79
  label: string;
80
80
  title: string;
81
81
  }[];
82
+ export interface NewLayerOption {
83
+ id: string;
84
+ label: string;
85
+ icon: string;
86
+ group?: string;
87
+ disabled?: boolean;
88
+ reason?: string;
89
+ }
90
+ /**
91
+ * Catalogue of layer types and adjustment layers that can be added dynamically to the controller.
92
+ */
93
+ export declare function newLayerOptions(_controller: ImageEditorController): NewLayerOption[];
94
+ /**
95
+ * Adds a new layer of the specified catalogue kind to the controller.
96
+ */
97
+ export declare function addLayerOfKind(controller: ImageEditorController, id: string, init?: Record<string, unknown>): Promise<string>;
98
+ export interface LayerPanelDescriptor {
99
+ id: string;
100
+ title: string;
101
+ }
102
+ /**
103
+ * Returns contextual panels that apply to the currently active layer (or layer-independent panels if null).
104
+ */
105
+ export declare function layerPanels(layer: ImageLayer | null): LayerPanelDescriptor[];
@@ -79,3 +79,27 @@ export declare const BIT_DEPTH_OPTIONS: readonly {
79
79
  label: string;
80
80
  title: string;
81
81
  }[];
82
+ export interface NewLayerOption {
83
+ id: string;
84
+ label: string;
85
+ icon: string;
86
+ group?: string;
87
+ disabled?: boolean;
88
+ reason?: string;
89
+ }
90
+ /**
91
+ * Catalogue of layer types and adjustment layers that can be added dynamically to the controller.
92
+ */
93
+ export declare function newLayerOptions(_controller: ImageEditorController): NewLayerOption[];
94
+ /**
95
+ * Adds a new layer of the specified catalogue kind to the controller.
96
+ */
97
+ export declare function addLayerOfKind(controller: ImageEditorController, id: string, init?: Record<string, unknown>): Promise<string>;
98
+ export interface LayerPanelDescriptor {
99
+ id: string;
100
+ title: string;
101
+ }
102
+ /**
103
+ * Returns contextual panels that apply to the currently active layer (or layer-independent panels if null).
104
+ */
105
+ export declare function layerPanels(layer: ImageLayer | null): LayerPanelDescriptor[];
@@ -102,6 +102,8 @@ export declare function setSmartPlacement(layers: readonly ImageLayer[], id: str
102
102
  * move with it. Without spatial smart filters the rendered pixels are shifted, not resampled.
103
103
  */
104
104
  export declare function offsetSmartObject(layers: readonly ImageLayer[], id: string, dx: number, dy: number, canvas: SmartCanvas): ImageLayer[];
105
+ /** Moves a layer (and everything in it) by whole pixels, for nesting it in contents. */
106
+ export declare function translateLayer(layer: ImageLayer, dx: number, dy: number): ImageLayer;
105
107
  export interface ConvertOptions {
106
108
  /** The pixels of a pixel layer (resolves the Background's document source). */
107
109
  surfaceOf(layer: PixelLayer): PixelSurface;
@@ -102,6 +102,8 @@ export declare function setSmartPlacement(layers: readonly ImageLayer[], id: str
102
102
  * move with it. Without spatial smart filters the rendered pixels are shifted, not resampled.
103
103
  */
104
104
  export declare function offsetSmartObject(layers: readonly ImageLayer[], id: string, dx: number, dy: number, canvas: SmartCanvas): ImageLayer[];
105
+ /** Moves a layer (and everything in it) by whole pixels, for nesting it in contents. */
106
+ export declare function translateLayer(layer: ImageLayer, dx: number, dy: number): ImageLayer;
105
107
  export interface ConvertOptions {
106
108
  /** The pixels of a pixel layer (resolves the Background's document source). */
107
109
  surfaceOf(layer: PixelLayer): PixelSurface;
@@ -21,6 +21,7 @@ export declare const FREE_TRANSFORM_MODES: readonly FreeTransformMode[];
21
21
  /** The nine reference-point positions of the options bar's locator, over the transformed box. */
22
22
  export type TransformAnchor = 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
23
23
  export declare const TRANSFORM_ANCHORS: readonly TransformAnchor[];
24
+ export declare const ANCHOR_FRACTION: Record<TransformAnchor, [number, number]>;
24
25
  export declare function isTransformAnchor(value: unknown): value is TransformAnchor;
25
26
  /** A transform in progress: the frame, where its corners go and an optional warp over the frame. */
26
27
  export interface FreeTransformGeometry {
@@ -21,6 +21,7 @@ export declare const FREE_TRANSFORM_MODES: readonly FreeTransformMode[];
21
21
  /** The nine reference-point positions of the options bar's locator, over the transformed box. */
22
22
  export type TransformAnchor = 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
23
23
  export declare const TRANSFORM_ANCHORS: readonly TransformAnchor[];
24
+ export declare const ANCHOR_FRACTION: Record<TransformAnchor, [number, number]>;
24
25
  export declare function isTransformAnchor(value: unknown): value is TransformAnchor;
25
26
  /** A transform in progress: the frame, where its corners go and an optional warp over the frame. */
26
27
  export interface FreeTransformGeometry {
@@ -7,7 +7,7 @@ var _chunkVKF3PWKRcjs = require('../chunk-VKF3PWKR.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkCD7PLU77cjs = require('../chunk-CD7PLU77.cjs');
10
+ var _chunk3YDQLQH2cjs = require('../chunk-3YDQLQH2.cjs');
11
11
  require('../chunk-A2IS7EHE.cjs');
12
12
 
13
13
 
@@ -1651,11 +1651,11 @@ function header(state, options) {
1651
1651
  return out;
1652
1652
  }
1653
1653
  function serializePaintDocument(state, options = {}) {
1654
- const { layers, assets } = _chunkCD7PLU77cjs.serializeLayers.call(void 0, state.layers);
1654
+ const { layers, assets } = _chunk3YDQLQH2cjs.serializeLayers.call(void 0, state.layers);
1655
1655
  return { ...header(state, options), layers, assets };
1656
1656
  }
1657
1657
  async function serializePaintDocumentExternal(state, store, options = {}) {
1658
- const { layers, assets } = await _chunkCD7PLU77cjs.serializeLayersExternal.call(void 0, state.layers, store);
1658
+ const { layers, assets } = await _chunk3YDQLQH2cjs.serializeLayersExternal.call(void 0, state.layers, store);
1659
1659
  return { ...header(state, options), layers, assets };
1660
1660
  }
1661
1661
  function paintLayersOnly(layers, problems) {
@@ -1692,7 +1692,7 @@ function deserializePaintDocument(raw) {
1692
1692
  const canvas = normalizeCanvas({ width: r.width, height: r.height, dpi: _nullishCoalesce(r.dpi, () => ( void 0)) });
1693
1693
  const paper = _chunkJGKCC5OFcjs.normalizePaper.call(void 0, _nullishCoalesce(r.paper, () => ( {})));
1694
1694
  const assets = r.assets && typeof r.assets === "object" ? r.assets : {};
1695
- const layers = paintLayersOnly(_chunkCD7PLU77cjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
1695
+ const layers = paintLayersOnly(_chunk3YDQLQH2cjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
1696
1696
  const wanted = typeof r.activeLayerId === "string" ? r.activeLayerId : null;
1697
1697
  const activeLayerId = wanted && _chunkHGTDMKNEcjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkHGTDMKNEcjs.flattenLayers.call(void 0, layers), 'access', _70 => _70.filter, 'call', _71 => _71((l) => l.type === "pixel"), 'access', _72 => _72.pop, 'call', _73 => _73(), 'optionalAccess', _74 => _74.id]), () => ( null));
1698
1698
  const wetEvents = Array.isArray(r.wetEvents) ? r.wetEvents.filter((e) => e && typeof e === "object" && Number.isInteger(e.clock) && typeof e.kind === "string") : [];
@@ -1708,7 +1708,7 @@ async function deserializePaintDocumentAsync(raw, store) {
1708
1708
  if (!raw || typeof raw !== "object") throw new Error("Not a paint document: expected a JSON object.");
1709
1709
  const r = raw;
1710
1710
  const problems = [];
1711
- const assets = await _chunkCD7PLU77cjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
1711
+ const assets = await _chunk3YDQLQH2cjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
1712
1712
  const loaded = deserializePaintDocument({ ...r, assets });
1713
1713
  return { ...loaded, problems: [...problems, ...loaded.problems] };
1714
1714
  }
@@ -5407,7 +5407,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
5407
5407
  return next.type === "group" ? { ...next, children: toStandard(next.children) } : next;
5408
5408
  });
5409
5409
  const layers = toStandard(dried);
5410
- const result = _chunkCD7PLU77cjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
5410
+ const result = _chunk3YDQLQH2cjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
5411
5411
  for (const [mode, names] of changed) {
5412
5412
  const label = _nullishCoalesce(_optionalChain([_chunkCWM3CUUXcjs.BLEND_MODES, 'access', _271 => _271.find, 'call', _272 => _272((m) => m.id === mode), 'optionalAccess', _273 => _273.label]), () => ( mode));
5413
5413
  const std = _nullishCoalesce(_optionalChain([_chunkCWM3CUUXcjs.BLEND_MODES, 'access', _274 => _274.find, 'call', _275 => _275((m) => m.id === _chunkCWM3CUUXcjs.standardBlendMode.call(void 0, mode)), 'optionalAccess', _276 => _276.label]), () => ( _chunkCWM3CUUXcjs.standardBlendMode.call(void 0, mode)));
@@ -7,7 +7,7 @@ import {
7
7
  resolveExternalAssets,
8
8
  serializeLayers,
9
9
  serializeLayersExternal
10
- } from "../chunk-ZQWLWDZI.js";
10
+ } from "../chunk-72BGL3I2.js";
11
11
  import "../chunk-3CI7FRMK.js";
12
12
  import {
13
13
  EffectRendererPool
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.157.0",
3
+ "version": "0.158.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",