@pixerate/editor 0.157.0 → 0.159.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-CD7PLU77.cjs → chunk-3YDQLQH2.cjs} +3 -1
- package/dist/{chunk-ZQWLWDZI.js → chunk-72BGL3I2.js} +2 -0
- package/dist/image-editor/controller.d.cts +24 -1
- package/dist/image-editor/controller.d.ts +24 -1
- package/dist/image-editor/controls.d.cts +9 -0
- package/dist/image-editor/controls.d.ts +9 -0
- package/dist/image-editor/index.cjs +7498 -7202
- package/dist/image-editor/index.js +11107 -10811
- package/dist/image-editor/layers/panel.d.cts +24 -0
- package/dist/image-editor/layers/panel.d.ts +24 -0
- package/dist/image-editor/layers/smart.d.cts +2 -0
- package/dist/image-editor/layers/smart.d.ts +2 -0
- package/dist/image-editor/layers/transform-ui.d.cts +14 -1
- package/dist/image-editor/layers/transform-ui.d.ts +14 -1
- package/dist/image-editor/transform.d.cts +1 -0
- package/dist/image-editor/transform.d.ts +1 -0
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.js +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -23,7 +23,7 @@ import { type FreeTransformMode, type Quad, type TransformAnchor } from '../tran
|
|
|
23
23
|
import type { WarpMesh, WarpStyle } from '../../geom/types.cjs';
|
|
24
24
|
import type { Vec2 } from '../../geom/types.cjs';
|
|
25
25
|
import type { Interpolation } from '../../raster/transform.cjs';
|
|
26
|
-
import type { ImagePoint } from '../types.cjs';
|
|
26
|
+
import type { CropBox, ImagePoint } from '../types.cjs';
|
|
27
27
|
import type { ShortcutEvent } from './paint-ui.cjs';
|
|
28
28
|
/** What a pointer is over (`mesh:<index>`: a warp mesh control point). */
|
|
29
29
|
export type TransformHandle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'reference' | 'inside' | 'outside' | `mesh:${number}`;
|
|
@@ -131,6 +131,17 @@ export interface FreeTransformToolOptions {
|
|
|
131
131
|
/** Called whenever the overlay, readout or error changes. */
|
|
132
132
|
onChange?: () => void;
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* A Free Transform frame for a box with no transform open (a host's selected-layer frame): the
|
|
136
|
+
* outline, the eight handles (none with `handles = false`, e.g. for a layer locked in place) and
|
|
137
|
+
* the centre as the reference point. Same shape and handle order as `FreeTransformTool.overlay`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function boxFrameOverlay(box: CropBox, handles?: boolean): TransformOverlay;
|
|
140
|
+
/**
|
|
141
|
+
* What a document point is over on a frame from `boxFrameOverlay`: a handle (within `tolerance`),
|
|
142
|
+
* `inside`, `outside` within `band` of the outline (where a drag rotates), or `null` beyond that.
|
|
143
|
+
*/
|
|
144
|
+
export declare function boxFrameHit(overlay: TransformOverlay, p: ImagePoint, tolerance: number, band: number): TransformHandle | null;
|
|
134
145
|
/**
|
|
135
146
|
* The interactive Free Transform (see the module comment). `begin` opens a session on the
|
|
136
147
|
* controller; pointer and key methods drive it; `commit` / `cancel` close it.
|
|
@@ -161,6 +172,8 @@ export declare class FreeTransformTool {
|
|
|
161
172
|
get session(): FreeTransformSession | null;
|
|
162
173
|
get mode(): FreeTransformMode;
|
|
163
174
|
get interpolation(): Interpolation;
|
|
175
|
+
/** Whether the open transform has changed anything yet (a commit would add an undo step). */
|
|
176
|
+
get modified(): boolean;
|
|
164
177
|
private readonly listeners;
|
|
165
178
|
/** Calls `listener` whenever the overlay, readout, mode or error changes. Returns the unsubscribe. */
|
|
166
179
|
subscribe(listener: () => void): () => void;
|
|
@@ -23,7 +23,7 @@ import { type FreeTransformMode, type Quad, type TransformAnchor } from '../tran
|
|
|
23
23
|
import type { WarpMesh, WarpStyle } from '../../geom/types.js';
|
|
24
24
|
import type { Vec2 } from '../../geom/types.js';
|
|
25
25
|
import type { Interpolation } from '../../raster/transform.js';
|
|
26
|
-
import type { ImagePoint } from '../types.js';
|
|
26
|
+
import type { CropBox, ImagePoint } from '../types.js';
|
|
27
27
|
import type { ShortcutEvent } from './paint-ui.js';
|
|
28
28
|
/** What a pointer is over (`mesh:<index>`: a warp mesh control point). */
|
|
29
29
|
export type TransformHandle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'reference' | 'inside' | 'outside' | `mesh:${number}`;
|
|
@@ -131,6 +131,17 @@ export interface FreeTransformToolOptions {
|
|
|
131
131
|
/** Called whenever the overlay, readout or error changes. */
|
|
132
132
|
onChange?: () => void;
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* A Free Transform frame for a box with no transform open (a host's selected-layer frame): the
|
|
136
|
+
* outline, the eight handles (none with `handles = false`, e.g. for a layer locked in place) and
|
|
137
|
+
* the centre as the reference point. Same shape and handle order as `FreeTransformTool.overlay`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function boxFrameOverlay(box: CropBox, handles?: boolean): TransformOverlay;
|
|
140
|
+
/**
|
|
141
|
+
* What a document point is over on a frame from `boxFrameOverlay`: a handle (within `tolerance`),
|
|
142
|
+
* `inside`, `outside` within `band` of the outline (where a drag rotates), or `null` beyond that.
|
|
143
|
+
*/
|
|
144
|
+
export declare function boxFrameHit(overlay: TransformOverlay, p: ImagePoint, tolerance: number, band: number): TransformHandle | null;
|
|
134
145
|
/**
|
|
135
146
|
* The interactive Free Transform (see the module comment). `begin` opens a session on the
|
|
136
147
|
* controller; pointer and key methods drive it; `commit` / `cancel` close it.
|
|
@@ -161,6 +172,8 @@ export declare class FreeTransformTool {
|
|
|
161
172
|
get session(): FreeTransformSession | null;
|
|
162
173
|
get mode(): FreeTransformMode;
|
|
163
174
|
get interpolation(): Interpolation;
|
|
175
|
+
/** Whether the open transform has changed anything yet (a commit would add an undo step). */
|
|
176
|
+
get modified(): boolean;
|
|
164
177
|
private readonly listeners;
|
|
165
178
|
/** Calls `listener` whenever the overlay, readout, mode or error changes. Returns the unsubscribe. */
|
|
166
179
|
subscribe(listener: () => void): () => void;
|
|
@@ -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
|
|
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 } =
|
|
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
|
|
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(
|
|
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
|
|
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 =
|
|
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)));
|