@pixerate/editor 0.228.1 → 0.229.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-MXJP77K4.cjs → chunk-5VQXSS2S.cjs} +109 -103
- package/dist/{chunk-B46UQUDC.cjs → chunk-HB4ICNNA.cjs} +6 -2
- package/dist/{chunk-KN3Y3FRY.js → chunk-JVNGCS26.js} +8 -2
- package/dist/{chunk-QXY4YTRI.js → chunk-UOOK7HTX.js} +6 -2
- package/dist/image-editor/controller.d.cts +12 -0
- package/dist/image-editor/controller.d.ts +12 -0
- package/dist/image-editor/geometry.d.cts +6 -0
- package/dist/image-editor/geometry.d.ts +6 -0
- package/dist/image-editor/index.cjs +980 -881
- package/dist/image-editor/index.js +117 -18
- package/dist/image-editor/tool-groups.d.cts +57 -9
- package/dist/image-editor/tool-groups.d.ts +57 -9
- package/dist/image-editor/types.d.cts +3 -1
- package/dist/image-editor/types.d.ts +3 -1
- package/dist/paint-editor/index.cjs +80 -80
- package/dist/paint-editor/index.js +2 -2
- package/dist/raster/index.cjs +2 -2
- package/dist/raster/index.js +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +1 -0
|
@@ -7,7 +7,7 @@ var _chunkIGPEBXUDcjs = require('../chunk-IGPEBXUD.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk5VQXSS2Scjs = require('../chunk-5VQXSS2S.cjs');
|
|
11
11
|
require('../chunk-A2IS7EHE.cjs');
|
|
12
12
|
require('../chunk-SS53NNZO.cjs');
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ var _chunkPY4GWSE2cjs = require('../chunk-PY4GWSE2.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunkHB4ICNNAcjs = require('../chunk-HB4ICNNA.cjs');
|
|
24
24
|
require('../chunk-QT26RHKK.cjs');
|
|
25
25
|
require('../chunk-K6PXS6DO.cjs');
|
|
26
26
|
|
|
@@ -1597,7 +1597,7 @@ var PROFILE = {
|
|
|
1597
1597
|
}
|
|
1598
1598
|
};
|
|
1599
1599
|
function createPaintCompositor() {
|
|
1600
|
-
return new (0,
|
|
1600
|
+
return new (0, _chunkHB4ICNNAcjs.RasterCompositor)(PROFILE);
|
|
1601
1601
|
}
|
|
1602
1602
|
function downsampleRgba(data, width, height, tw, th) {
|
|
1603
1603
|
tw = Math.max(1, Math.round(tw));
|
|
@@ -1673,11 +1673,11 @@ function header(state, options) {
|
|
|
1673
1673
|
return out;
|
|
1674
1674
|
}
|
|
1675
1675
|
function serializePaintDocument(state, options = {}) {
|
|
1676
|
-
const { layers, assets } =
|
|
1676
|
+
const { layers, assets } = _chunk5VQXSS2Scjs.serializeLayers.call(void 0, state.layers);
|
|
1677
1677
|
return { ...header(state, options), layers, assets };
|
|
1678
1678
|
}
|
|
1679
1679
|
async function serializePaintDocumentExternal(state, store, options = {}) {
|
|
1680
|
-
const { layers, assets } = await
|
|
1680
|
+
const { layers, assets } = await _chunk5VQXSS2Scjs.serializeLayersExternal.call(void 0, state.layers, store);
|
|
1681
1681
|
return { ...header(state, options), layers, assets };
|
|
1682
1682
|
}
|
|
1683
1683
|
function paintLayersOnly(layers, problems) {
|
|
@@ -1714,9 +1714,9 @@ function deserializePaintDocument(raw) {
|
|
|
1714
1714
|
const canvas = normalizeCanvas({ width: r.width, height: r.height, dpi: _nullishCoalesce(r.dpi, () => ( void 0)) });
|
|
1715
1715
|
const paper = _chunkGNZI3KYKcjs.normalizePaper.call(void 0, _nullishCoalesce(r.paper, () => ( {})));
|
|
1716
1716
|
const assets = r.assets && typeof r.assets === "object" ? r.assets : {};
|
|
1717
|
-
const layers = paintLayersOnly(
|
|
1717
|
+
const layers = paintLayersOnly(_chunk5VQXSS2Scjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
|
|
1718
1718
|
const wanted = typeof r.activeLayerId === "string" ? r.activeLayerId : null;
|
|
1719
|
-
const activeLayerId = wanted &&
|
|
1719
|
+
const activeLayerId = wanted && _chunkHB4ICNNAcjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkHB4ICNNAcjs.flattenLayers.call(void 0, layers), 'access', _74 => _74.filter, 'call', _75 => _75((l) => l.type === "pixel"), 'access', _76 => _76.pop, 'call', _77 => _77(), 'optionalAccess', _78 => _78.id]), () => ( null));
|
|
1720
1720
|
const wetEvents = Array.isArray(r.wetEvents) ? r.wetEvents.filter((e) => e && typeof e === "object" && Number.isInteger(e.clock) && typeof e.kind === "string") : [];
|
|
1721
1721
|
const state = { canvas, paper, layers, activeLayerId, strokes: readStrokes(r.strokes, problems) };
|
|
1722
1722
|
if (wetEvents.length) state.wetEvents = wetEvents;
|
|
@@ -1730,7 +1730,7 @@ async function deserializePaintDocumentAsync(raw, store) {
|
|
|
1730
1730
|
if (!raw || typeof raw !== "object") throw new Error("Not a paint document: expected a JSON object.");
|
|
1731
1731
|
const r = raw;
|
|
1732
1732
|
const problems = [];
|
|
1733
|
-
const assets = await
|
|
1733
|
+
const assets = await _chunk5VQXSS2Scjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
|
|
1734
1734
|
const loaded = deserializePaintDocument({ ...r, assets });
|
|
1735
1735
|
return { ...loaded, problems: [...problems, ...loaded.problems] };
|
|
1736
1736
|
}
|
|
@@ -3095,7 +3095,7 @@ function replayItems(doc) {
|
|
|
3095
3095
|
}
|
|
3096
3096
|
function emptiedLayers(layers) {
|
|
3097
3097
|
let out = [...layers];
|
|
3098
|
-
for (const l of
|
|
3098
|
+
for (const l of _chunkHB4ICNNAcjs.flattenLayers.call(void 0, layers)) if (l.type === "pixel") out = _chunkHB4ICNNAcjs.mapLayer.call(void 0, out, l.id, () => ({ ...l, surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } }));
|
|
3099
3099
|
return out;
|
|
3100
3100
|
}
|
|
3101
3101
|
async function replayPainting(source, target, options = {}) {
|
|
@@ -3498,12 +3498,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3498
3498
|
canvas: () => this.doc.canvas,
|
|
3499
3499
|
paper: () => this.doc.paper,
|
|
3500
3500
|
layerSurface: (id) => {
|
|
3501
|
-
const l = _optionalChain([
|
|
3501
|
+
const l = _optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _175 => _175.layer]);
|
|
3502
3502
|
return isPixelLayer(l) ? l.surface : null;
|
|
3503
3503
|
},
|
|
3504
3504
|
updateSurfaces: (surfaces, rects) => {
|
|
3505
3505
|
let layers = this.doc.layers;
|
|
3506
|
-
for (const [id, surface] of surfaces) if (
|
|
3506
|
+
for (const [id, surface] of surfaces) if (_chunkHB4ICNNAcjs.findLayer.call(void 0, layers, id)) layers = _chunkHB4ICNNAcjs.mapLayer.call(void 0, layers, id, (l) => ({ ...l, surface }));
|
|
3507
3507
|
this.doc = { ...this.doc, layers };
|
|
3508
3508
|
this.emit(rects.length ? rects : "all");
|
|
3509
3509
|
},
|
|
@@ -3810,8 +3810,8 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3810
3810
|
}
|
|
3811
3811
|
let next = { ...shiftDocument(this.withWetEvents(this.doc), left, top), canvas: { ...was, width, height } };
|
|
3812
3812
|
for (const id of keptWet) {
|
|
3813
|
-
const l = _optionalChain([
|
|
3814
|
-
if (isPixelLayer(l)) next = { ...next, layers:
|
|
3813
|
+
const l = _optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, next.layers, id), 'optionalAccess', _190 => _190.layer]);
|
|
3814
|
+
if (isPixelLayer(l)) next = { ...next, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, next.layers, id, () => ({ ...l, surface: _chunk474IQG74cjs.translateSurface.call(void 0, l.surface, l.offset.x, l.offset.y), offset: { x: 0, y: 0 } })) };
|
|
3815
3815
|
}
|
|
3816
3816
|
if (this.wet.world) {
|
|
3817
3817
|
if (keptWet.length) this.wet.extend(width, height, left, top, next.paper);
|
|
@@ -3854,7 +3854,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3854
3854
|
}
|
|
3855
3855
|
// --- Layers --------------------------------------------------------------------
|
|
3856
3856
|
getLayer(id) {
|
|
3857
|
-
return _optionalChain([
|
|
3857
|
+
return _optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _191 => _191.layer]);
|
|
3858
3858
|
}
|
|
3859
3859
|
/** The active pixel layer (or `undefined`). */
|
|
3860
3860
|
getActiveLayer() {
|
|
@@ -3873,12 +3873,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3873
3873
|
walk(this.doc.layers, null, 0);
|
|
3874
3874
|
return out;
|
|
3875
3875
|
}
|
|
3876
|
-
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([
|
|
3876
|
+
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _192 => _192.parent, 'optionalAccess', _193 => _193.id]), () => ( null)), depth = _nullishCoalesce(_optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _194 => _194.path, 'access', _195 => _195.length]), () => ( 0))) {
|
|
3877
3877
|
let bounds = null;
|
|
3878
3878
|
if (l.type === "pixel") {
|
|
3879
3879
|
const b = _chunk474IQG74cjs.contentBounds.call(void 0, l.surface);
|
|
3880
3880
|
bounds = b ? { ...b, x: b.x + l.offset.x, y: b.y + l.offset.y } : null;
|
|
3881
|
-
} else for (const c of
|
|
3881
|
+
} else for (const c of _chunkHB4ICNNAcjs.flattenLayers.call(void 0, l.children)) if (c.type === "pixel") bounds = unionRect(bounds, this.describeLayer(c, l.id, depth + 1).bounds);
|
|
3882
3882
|
return {
|
|
3883
3883
|
id: l.id,
|
|
3884
3884
|
name: l.name,
|
|
@@ -3905,7 +3905,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3905
3905
|
if (!id) throw new PaintEditorError(`There is no active layer to ${what}; add one with add_layer.`);
|
|
3906
3906
|
const l = this.requireLayer(id);
|
|
3907
3907
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; ${what} a pixel layer inside it.`);
|
|
3908
|
-
if (
|
|
3908
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) before you ${what} it.`);
|
|
3909
3909
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) before you ${what} it.`);
|
|
3910
3910
|
return l;
|
|
3911
3911
|
}
|
|
@@ -3918,7 +3918,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3918
3918
|
/** Adds an empty pixel layer or group above `aboveId` (default: the active layer) and makes it active. */
|
|
3919
3919
|
addLayer(options = {}) {
|
|
3920
3920
|
this.requireIdle("adding a layer");
|
|
3921
|
-
const count =
|
|
3921
|
+
const count = _chunkHB4ICNNAcjs.flattenLayers.call(void 0, this.doc.layers).length;
|
|
3922
3922
|
const type = _nullishCoalesce(options.type, () => ( "pixel"));
|
|
3923
3923
|
const name = _optionalChain([options, 'access', _196 => _196.name, 'optionalAccess', _197 => _197.trim, 'call', _198 => _198()]) || (type === "group" ? `Group ${count + 1}` : `Layer ${count + 1}`);
|
|
3924
3924
|
const layer = type === "group" ? { type: "group", id: newPaintLayerId(), name, visible: true, opacity: 1, blend: "pass-through", children: [] } : createPaintLayer(name);
|
|
@@ -3930,19 +3930,19 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3930
3930
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
3931
3931
|
parentId = g.id;
|
|
3932
3932
|
} else if (above) {
|
|
3933
|
-
const loc =
|
|
3933
|
+
const loc = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, above);
|
|
3934
3934
|
if (!loc) throw new PaintEditorError(`Unknown layer "${above}". Call list_layers for the ids.`);
|
|
3935
3935
|
parentId = _nullishCoalesce(_optionalChain([loc, 'access', _199 => _199.parent, 'optionalAccess', _200 => _200.id]), () => ( null));
|
|
3936
3936
|
index = loc.index + 1;
|
|
3937
3937
|
}
|
|
3938
|
-
const layers =
|
|
3938
|
+
const layers = _chunkHB4ICNNAcjs.insertLayer.call(void 0, this.doc.layers, layer, parentId, index);
|
|
3939
3939
|
this.commit(type === "group" ? "Add group" : "Add layer", { ...this.doc, layers, activeLayerId: layer.id });
|
|
3940
3940
|
return this.describeLayer(layer);
|
|
3941
3941
|
}
|
|
3942
3942
|
updateLayer(id, update) {
|
|
3943
3943
|
this.requireIdle("changing a layer");
|
|
3944
3944
|
const l = this.requireLayer(id);
|
|
3945
|
-
if (
|
|
3945
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, l, "all") && Object.keys(update).some((k) => k !== "locks")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it first (locks {all: false}).`);
|
|
3946
3946
|
if (update.opacity !== void 0 && !(update.opacity >= 0 && update.opacity <= 1)) throw new PaintEditorError(`opacity ${update.opacity} is out of range; use 0..1.`);
|
|
3947
3947
|
if (update.blend !== void 0 && !_chunkOLNIPTB3cjs.isBlendMode.call(void 0, update.blend) && !(l.type === "group" && update.blend === "pass-through")) {
|
|
3948
3948
|
throw new PaintEditorError(`Unknown blend mode "${update.blend}". Call get_canvas_info for the blend modes.`);
|
|
@@ -3958,31 +3958,31 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3958
3958
|
const locks = { ..._nullishCoalesce(l.locks, () => ( {})), ...update.locks };
|
|
3959
3959
|
next.locks = Object.values(locks).some(Boolean) ? locks : void 0;
|
|
3960
3960
|
}
|
|
3961
|
-
this.commit("Layer properties", { ...this.doc, layers:
|
|
3961
|
+
this.commit("Layer properties", { ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, id, () => next) });
|
|
3962
3962
|
return this.describeLayer(next);
|
|
3963
3963
|
}
|
|
3964
3964
|
removeLayer(id) {
|
|
3965
3965
|
this.requireIdle("removing a layer");
|
|
3966
3966
|
const l = this.requireLayer(id);
|
|
3967
|
-
if (
|
|
3968
|
-
const wetIds = this.wet.wetLayerIds().filter((x) => x === id || l.type === "group" &&
|
|
3967
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, l, "all")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it before removing it.`);
|
|
3968
|
+
const wetIds = this.wet.wetLayerIds().filter((x) => x === id || l.type === "group" && _chunkHB4ICNNAcjs.findLayer.call(void 0, l.children, x));
|
|
3969
3969
|
if (wetIds.length) {
|
|
3970
3970
|
this.beginWetOp();
|
|
3971
3971
|
for (const x of wetIds) this.wet.world.removeLane(x);
|
|
3972
3972
|
}
|
|
3973
|
-
const layers =
|
|
3973
|
+
const layers = _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
3974
3974
|
let active = this.doc.activeLayerId;
|
|
3975
|
-
if (active && !
|
|
3976
|
-
this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active, ...this.thickWithout(
|
|
3975
|
+
if (active && !_chunkHB4ICNNAcjs.findLayer.call(void 0, layers, active)) active = _nullishCoalesce(_optionalChain([_chunkHB4ICNNAcjs.flattenLayers.call(void 0, layers), 'access', _201 => _201.filter, 'call', _202 => _202((x) => x.type === "pixel"), 'access', _203 => _203.pop, 'call', _204 => _204(), 'optionalAccess', _205 => _205.id]), () => ( null));
|
|
3976
|
+
this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active, ...this.thickWithout(_chunkHB4ICNNAcjs.flattenLayers.call(void 0, [l]).map((x) => x.id)), ...this.stickersWithout(_chunkHB4ICNNAcjs.flattenLayers.call(void 0, [l]).map((x) => x.id)) });
|
|
3977
3977
|
return { removed: id, activeLayerId: active };
|
|
3978
3978
|
}
|
|
3979
3979
|
duplicateLayer(id) {
|
|
3980
3980
|
this.requireIdle("duplicating a layer");
|
|
3981
|
-
if (
|
|
3981
|
+
if (_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id)) {
|
|
3982
3982
|
const inside = (l) => l.type === "group" ? l.children.flatMap(inside) : [l.id];
|
|
3983
|
-
this.dryLayersFirst(inside(
|
|
3983
|
+
this.dryLayersFirst(inside(_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id).layer));
|
|
3984
3984
|
}
|
|
3985
|
-
const loc =
|
|
3985
|
+
const loc = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
3986
3986
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
3987
3987
|
const thick = { ..._nullishCoalesce(this.doc.thick, () => ( {})) };
|
|
3988
3988
|
const stickers = { ..._nullishCoalesce(this.doc.stickers, () => ( {})) };
|
|
@@ -3993,43 +3993,43 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3993
3993
|
return l.type === "group" ? { ...l, id: id2, children: l.children.map(copy) } : { ...l, id: id2 };
|
|
3994
3994
|
};
|
|
3995
3995
|
const dup = { ...copy(loc.layer), name: `${loc.layer.name} copy` };
|
|
3996
|
-
const layers =
|
|
3996
|
+
const layers = _chunkHB4ICNNAcjs.insertLayer.call(void 0, this.doc.layers, dup, _nullishCoalesce(_optionalChain([loc, 'access', _206 => _206.parent, 'optionalAccess', _207 => _207.id]), () => ( null)), loc.index + 1);
|
|
3997
3997
|
this.commit("Duplicate layer", this.withWetEvents({ ...this.doc, layers, activeLayerId: dup.id, ...this.doc.thick ? { thick } : {}, ...this.doc.stickers ? { stickers } : {} }));
|
|
3998
3998
|
return this.describeLayer(dup);
|
|
3999
3999
|
}
|
|
4000
4000
|
/** Moves a layer to `index` (0 = bottom) within `parentId` (default its own parent; `null` = top level). */
|
|
4001
4001
|
moveLayer(id, index, parentId) {
|
|
4002
4002
|
this.requireIdle("moving a layer");
|
|
4003
|
-
const loc =
|
|
4003
|
+
const loc = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
4004
4004
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
4005
4005
|
const target = parentId === void 0 ? _nullishCoalesce(_optionalChain([loc, 'access', _208 => _208.parent, 'optionalAccess', _209 => _209.id]), () => ( null)) : parentId;
|
|
4006
4006
|
if (target) {
|
|
4007
4007
|
const g = this.requireLayer(target);
|
|
4008
4008
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
4009
|
-
if (target === id || loc.layer.type === "group" &&
|
|
4009
|
+
if (target === id || loc.layer.type === "group" && _chunkHB4ICNNAcjs.findLayer.call(void 0, loc.layer.children, target)) throw new PaintEditorError("A group cannot move into itself.");
|
|
4010
4010
|
}
|
|
4011
|
-
const without =
|
|
4012
|
-
const siblings = target ?
|
|
4011
|
+
const without = _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
4012
|
+
const siblings = target ? _chunkHB4ICNNAcjs.findLayer.call(void 0, without, target).layer.children : without;
|
|
4013
4013
|
if (!Number.isInteger(index) || index < 0 || index > siblings.length) throw new PaintEditorError(`index ${index} is out of range; use 0..${siblings.length} (0 is the bottom).`);
|
|
4014
|
-
const layers =
|
|
4014
|
+
const layers = _chunkHB4ICNNAcjs.insertLayer.call(void 0, without, loc.layer, target, index);
|
|
4015
4015
|
this.commit("Move layer", { ...this.doc, layers });
|
|
4016
4016
|
return this.describeLayer(loc.layer);
|
|
4017
4017
|
}
|
|
4018
4018
|
/** Merges a pixel layer into the pixel layer below it (keeping the lower one's settings). */
|
|
4019
4019
|
mergeDown(id) {
|
|
4020
4020
|
this.requireIdle("merging");
|
|
4021
|
-
const pre =
|
|
4021
|
+
const pre = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
4022
4022
|
if (pre) {
|
|
4023
4023
|
const sib = pre.parent ? pre.parent.children : this.doc.layers;
|
|
4024
4024
|
this.dryLayersFirst([id, _optionalChain([sib, 'access', _210 => _210[pre.index - 1], 'optionalAccess', _211 => _211.id])].filter((x) => Boolean(x)));
|
|
4025
4025
|
}
|
|
4026
|
-
const loc =
|
|
4026
|
+
const loc = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
4027
4027
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
4028
4028
|
const siblings = loc.parent ? loc.parent.children : this.doc.layers;
|
|
4029
4029
|
const below = siblings[loc.index - 1];
|
|
4030
4030
|
const upper = loc.layer;
|
|
4031
4031
|
if (!isPixelLayer(upper) || !isPixelLayer(below)) throw new PaintEditorError("Merge down needs a pixel layer directly above another pixel layer in the same group.");
|
|
4032
|
-
if (
|
|
4032
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, below, "pixels")) throw new PaintEditorError(`Layer "${below.name}" has its pixels locked; unlock it to merge into it.`);
|
|
4033
4033
|
const rect = unionRect(this.describeLayer(below).bounds, this.describeLayer(upper).bounds);
|
|
4034
4034
|
let surface = _chunk474IQG74cjs.emptySurface.call(void 0, 4);
|
|
4035
4035
|
if (rect) {
|
|
@@ -4039,7 +4039,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4039
4039
|
surface = _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width: rect.width, height: rect.height, data: px }, 4, rect.x, rect.y);
|
|
4040
4040
|
}
|
|
4041
4041
|
const merged = { ...below, surface, offset: { x: 0, y: 0 } };
|
|
4042
|
-
const layers =
|
|
4042
|
+
const layers = _chunkHB4ICNNAcjs.mapLayer.call(void 0, _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, upper.id, () => null), below.id, () => merged);
|
|
4043
4043
|
this.commit("Merge down", this.withWetEvents({ ...this.doc, layers, activeLayerId: below.id, ...this.thickWithout([upper.id]), ...this.stickersWithout([upper.id, below.id]) }));
|
|
4044
4044
|
return this.describeLayer(merged);
|
|
4045
4045
|
}
|
|
@@ -4052,7 +4052,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4052
4052
|
this.wet.world.removeLane(l.id);
|
|
4053
4053
|
}
|
|
4054
4054
|
const bounds = this.describeLayer(l).bounds;
|
|
4055
|
-
this.commit("Clear layer", this.withPaintEvent({ ...this.doc, layers:
|
|
4055
|
+
this.commit("Clear layer", this.withPaintEvent({ ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4) })), ...this.thickWithout([l.id]), ...this.stickersWithout([l.id]) }, { kind: "clear", layerId: l.id }));
|
|
4056
4056
|
return { layerId: l.id, bounds };
|
|
4057
4057
|
}
|
|
4058
4058
|
/**
|
|
@@ -4090,12 +4090,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4090
4090
|
background: rgbaOf(this.doc.paper.color),
|
|
4091
4091
|
opacity,
|
|
4092
4092
|
blend,
|
|
4093
|
-
lockTransparency:
|
|
4093
|
+
lockTransparency: _chunkHB4ICNNAcjs.isLayerLocked.call(void 0, l, "transparency"),
|
|
4094
4094
|
selection: null,
|
|
4095
4095
|
offset: l.offset
|
|
4096
4096
|
};
|
|
4097
4097
|
const surface = this.applyCoverage(l, coverage, rect, apply);
|
|
4098
|
-
this.commit("Fill layer", this.withPaintEvent(this.withWetEvents({ ...this.doc, layers:
|
|
4098
|
+
this.commit("Fill layer", this.withPaintEvent(this.withWetEvents({ ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })) }), { kind: "fill", layerId: l.id, data: { color, opacity, grain: grainAmount, pressure, blend } }));
|
|
4099
4099
|
return { layerId: l.id, bounds: rect };
|
|
4100
4100
|
}
|
|
4101
4101
|
applyCoverage(l, coverage, rect, apply) {
|
|
@@ -4136,7 +4136,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4136
4136
|
}
|
|
4137
4137
|
/** The effect a layer is drawn from, or `undefined` for other layers. */
|
|
4138
4138
|
getEffectLayer(layerId) {
|
|
4139
|
-
return
|
|
4139
|
+
return _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, layerId) ? _optionalChain([this, 'access', _220 => _220.doc, 'access', _221 => _221.effectLayers, 'optionalAccess', _222 => _222[layerId]]) : void 0;
|
|
4140
4140
|
}
|
|
4141
4141
|
/** The effect paper (without its pixels), or `null`. */
|
|
4142
4142
|
getPaperEffect() {
|
|
@@ -4264,10 +4264,10 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4264
4264
|
const pixels = await this.renderEffectCanvas(d, values, options.time);
|
|
4265
4265
|
this.requireIdle("adding a layer");
|
|
4266
4266
|
const above = _nullishCoalesce(options.aboveId, () => ( this.doc.activeLayerId));
|
|
4267
|
-
const loc = above ?
|
|
4267
|
+
const loc = above ? _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, above) : null;
|
|
4268
4268
|
if (options.aboveId !== void 0 && !loc) throw new PaintEditorError(`Layer "${options.aboveId}" was removed while the effect rendered.`);
|
|
4269
4269
|
const layer = { ...createPaintLayer(_optionalChain([options, 'access', _229 => _229.name, 'optionalAccess', _230 => _230.trim, 'call', _231 => _231()]) || d.name), surface: _chunk474IQG74cjs.surfaceFromPixels.call(void 0, pixels, 4), opacity: _nullishCoalesce(options.opacity, () => ( 1)), blend: _nullishCoalesce(options.blend, () => ( "normal")) };
|
|
4270
|
-
const layers =
|
|
4270
|
+
const layers = _chunkHB4ICNNAcjs.insertLayer.call(void 0, this.doc.layers, layer, _nullishCoalesce(_optionalChain([loc, 'optionalAccess', _232 => _232.parent, 'optionalAccess', _233 => _233.id]), () => ( null)), loc ? loc.index + 1 : void 0);
|
|
4271
4271
|
const source = this.sourceOf(d, values, options.time);
|
|
4272
4272
|
this.commit("Add effect layer", { ...this.doc, layers, activeLayerId: layer.id, effectLayers: { ..._nullishCoalesce(this.doc.effectLayers, () => ( {})), [layer.id]: source } });
|
|
4273
4273
|
return { layer: this.describeLayer(layer), source };
|
|
@@ -4291,7 +4291,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4291
4291
|
this.requireIdle("changing an effect layer");
|
|
4292
4292
|
if (!isPixelLayer(now)) throw new PaintEditorError(`Layer "${l.name}" was removed while the effect rendered.`);
|
|
4293
4293
|
const source = this.sourceOf(d, values, time);
|
|
4294
|
-
this.commitOrAmend("Effect layer", { ...this.doc, layers:
|
|
4294
|
+
this.commitOrAmend("Effect layer", { ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...now, surface: _chunk474IQG74cjs.surfaceFromPixels.call(void 0, pixels, 4), offset: { x: 0, y: 0 } })), effectLayers: { ..._nullishCoalesce(this.doc.effectLayers, () => ( {})), [l.id]: source } }, commitToHistory);
|
|
4295
4295
|
return source;
|
|
4296
4296
|
}
|
|
4297
4297
|
/** Turns an effect layer into a plain pixel layer, keeping its pixels (one undo step). */
|
|
@@ -4319,9 +4319,9 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4319
4319
|
const rect = this.canvasRectOf(now);
|
|
4320
4320
|
const before = _chunk474IQG74cjs.readRegion.call(void 0, now.surface, rect);
|
|
4321
4321
|
let after = overPixels(before, pixels.data, _nullishCoalesce(options.opacity, () => ( 1)));
|
|
4322
|
-
if (options.lockTransparency ||
|
|
4322
|
+
if (options.lockTransparency || _chunkHB4ICNNAcjs.isLayerLocked.call(void 0, now, "transparency")) after = mixPixels(before, after, 1);
|
|
4323
4323
|
const surface = _chunk474IQG74cjs.writeRegion.call(void 0, now.surface, rect, after);
|
|
4324
|
-
this.commit("Effect fill", { ...this.doc, layers:
|
|
4324
|
+
this.commit("Effect fill", { ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, now.id, () => ({ ...now, surface })) });
|
|
4325
4325
|
return { layerId: now.id, source: this.sourceOf(d, values, options.time) };
|
|
4326
4326
|
}
|
|
4327
4327
|
// --- Effect paint ----------------------------------------------------------------
|
|
@@ -4493,7 +4493,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4493
4493
|
const out = await this.effectsRenderer.render(this.effects.require(), d.id, { width: rect.width, height: rect.height }, { time: _nullishCoalesce(options.time, () => ( 0)), values, inputs });
|
|
4494
4494
|
const now = this.sameLayerAfterRender(l);
|
|
4495
4495
|
const surface = _chunk474IQG74cjs.writeRegion.call(void 0, now.surface, rect, mixPixels(before, out.data, amount));
|
|
4496
|
-
this.commit("Light effect", { ...this.doc, layers:
|
|
4496
|
+
this.commit("Light effect", { ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, now.id, () => ({ ...now, surface })) });
|
|
4497
4497
|
return { layerId: now.id, source: this.sourceOf(d, values, options.time), amount };
|
|
4498
4498
|
}
|
|
4499
4499
|
// --- Brushes -------------------------------------------------------------------
|
|
@@ -4737,11 +4737,11 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4737
4737
|
let layer = (() => {
|
|
4738
4738
|
const id = _nullishCoalesce(init.layerId, () => ( doc.activeLayerId));
|
|
4739
4739
|
if (!id) throw new PaintEditorError("There is no active layer to paint on; add one with add_layer.");
|
|
4740
|
-
const loc =
|
|
4740
|
+
const loc = _chunkHB4ICNNAcjs.findLayer.call(void 0, doc.layers, id);
|
|
4741
4741
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
4742
4742
|
const l = loc.layer;
|
|
4743
4743
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; paint on a pixel layer inside it.`);
|
|
4744
|
-
if (
|
|
4744
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it (update_layer locks) to paint on it.`);
|
|
4745
4745
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) to paint on it.`);
|
|
4746
4746
|
return l;
|
|
4747
4747
|
})();
|
|
@@ -4758,8 +4758,8 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4758
4758
|
this.requireWetIdle("painting");
|
|
4759
4759
|
if (layer.offset.x || layer.offset.y) {
|
|
4760
4760
|
const moved = { ...layer, surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, layer.offset.x, layer.offset.y), offset: { x: 0, y: 0 } };
|
|
4761
|
-
this.doc = { ...this.doc, layers:
|
|
4762
|
-
if (doc !== this.doc) doc = { ...doc, layers:
|
|
4761
|
+
this.doc = { ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => moved) };
|
|
4762
|
+
if (doc !== this.doc) doc = { ...doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, doc.layers, layer.id, () => moved) };
|
|
4763
4763
|
layer = moved;
|
|
4764
4764
|
}
|
|
4765
4765
|
if (!this.wet.wetLayerIds().includes(layer.id) && this.wet.wetLayerIds().length >= _chunkXFYLA3ZOcjs.MAX_WET_LANES) {
|
|
@@ -4792,7 +4792,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4792
4792
|
wet = { driver, surface: () => world.display(id).surface };
|
|
4793
4793
|
} else if (this.wet.wetLayerIds().includes(layer.id)) {
|
|
4794
4794
|
this.dryLayersFirst([layer.id]);
|
|
4795
|
-
const dried =
|
|
4795
|
+
const dried = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, layer.id).layer;
|
|
4796
4796
|
layer = dried;
|
|
4797
4797
|
}
|
|
4798
4798
|
let color = init.color === void 0 ? this.color : parseColor(init.color);
|
|
@@ -4811,7 +4811,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4811
4811
|
layerId: layer.id,
|
|
4812
4812
|
surface: layer.surface,
|
|
4813
4813
|
offset: layer.offset,
|
|
4814
|
-
lockTransparency:
|
|
4814
|
+
lockTransparency: _chunkHB4ICNNAcjs.isLayerLocked.call(void 0, layer, "transparency"),
|
|
4815
4815
|
brush,
|
|
4816
4816
|
color: rgba,
|
|
4817
4817
|
background: rgbaOf(doc.paper.color),
|
|
@@ -4908,7 +4908,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4908
4908
|
const thick = ch ? { ..._nullishCoalesce(this.doc.thick, () => ( {})), [l.id]: ch } : this.doc.thick;
|
|
4909
4909
|
const sprayed = s.stickers();
|
|
4910
4910
|
const stickers = sprayed ? { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [l.id]: [..._nullishCoalesce(_optionalChain([this, 'access', _258 => _258.doc, 'access', _259 => _259.stickers, 'optionalAccess', _260 => _260[l.id]]), () => ( [])), ...sprayed] } : this.doc.stickers;
|
|
4911
|
-
this.commit(`${brush.name} stroke`, this.withWetEvents({ ...this.doc, layers:
|
|
4911
|
+
this.commit(`${brush.name} stroke`, this.withWetEvents({ ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })), strokes: [...this.doc.strokes, stroke], ...thick ? { thick } : {}, ...stickers ? { stickers } : {} }), wetStroke ? before : this.doc);
|
|
4912
4912
|
}
|
|
4913
4913
|
};
|
|
4914
4914
|
let session;
|
|
@@ -4936,13 +4936,13 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4936
4936
|
if (cancelled || !surface) return;
|
|
4937
4937
|
const stroke = this.record(s);
|
|
4938
4938
|
s.result.strokeId = stroke.id;
|
|
4939
|
-
const l =
|
|
4939
|
+
const l = _chunkHB4ICNNAcjs.findLayer.call(void 0, out.layers, s.layerId).layer;
|
|
4940
4940
|
const offset = s.init.wet ? { x: 0, y: 0 } : l.offset;
|
|
4941
4941
|
const ch = s.thickChannels();
|
|
4942
4942
|
const sprayed = s.stickers();
|
|
4943
4943
|
out = {
|
|
4944
4944
|
...out,
|
|
4945
|
-
layers:
|
|
4945
|
+
layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, out.layers, l.id, () => ({ ...l, surface, offset })),
|
|
4946
4946
|
strokes: [...out.strokes, stroke],
|
|
4947
4947
|
...ch ? { thick: { ..._nullishCoalesce(out.thick, () => ( {})), [l.id]: ch } } : {},
|
|
4948
4948
|
...sprayed ? { stickers: { ..._nullishCoalesce(out.stickers, () => ( {})), [l.id]: [..._nullishCoalesce(_optionalChain([out, 'access', _261 => _261.stickers, 'optionalAccess', _262 => _262[l.id]]), () => ( [])), ...sprayed] } } : {}
|
|
@@ -4957,8 +4957,8 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4957
4957
|
if (this.wet.instantDry && result.strokeId) {
|
|
4958
4958
|
this.wet.dry(session.layerId);
|
|
4959
4959
|
this.logWet({ kind: "dry", layerId: session.layerId, at: out.strokes.length });
|
|
4960
|
-
const dried =
|
|
4961
|
-
out = { ...out, layers:
|
|
4960
|
+
const dried = _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, session.layerId).layer.surface;
|
|
4961
|
+
out = { ...out, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, out.layers, session.layerId, (l) => ({ ...l, surface: dried })) };
|
|
4962
4962
|
}
|
|
4963
4963
|
result.wet = this.wet.isWet(session.layerId);
|
|
4964
4964
|
}
|
|
@@ -5043,7 +5043,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5043
5043
|
brush = _chunkGNZI3KYKcjs.normalizePaintBrush.call(void 0, { tip: { ...b.tip, size: b.tip.size * (v.brush.tip.size / s.brush.tip.size) } }, b);
|
|
5044
5044
|
}
|
|
5045
5045
|
const layerId = _nullishCoalesce(options.layerId, () => ( s.layerId));
|
|
5046
|
-
if (!
|
|
5046
|
+
if (!_chunkHB4ICNNAcjs.findLayer.call(void 0, doc.layers, layerId)) throw new PaintEditorError(`Stroke "${s.id}" was painted on layer "${layerId}", which no longer exists; pass layerId to replay it elsewhere.`);
|
|
5047
5047
|
let load = s.load;
|
|
5048
5048
|
if (load && options.color !== void 0 && load.reservoir) {
|
|
5049
5049
|
const [r, g, b] = _chunkGNZI3KYKcjs.hexToRgb8.call(void 0, options.color);
|
|
@@ -5263,7 +5263,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5263
5263
|
wetPaper(options = {}) {
|
|
5264
5264
|
this.requireIdle("wetting the paper");
|
|
5265
5265
|
const l = this.wetLayer(options.layerId, "wet the paper of");
|
|
5266
|
-
if (
|
|
5266
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, l, "pixels")) throw new PaintEditorError(`Layer "${l.name}" has its pixels locked; unlock it first.`);
|
|
5267
5267
|
const amount = _nullishCoalesce(options.amount, () => ( 1));
|
|
5268
5268
|
if (!(amount > 0 && amount <= 1)) throw new PaintEditorError(`amount ${amount} is out of range; use above 0 up to 1.`);
|
|
5269
5269
|
const rect = _nullishCoalesce(this.checkRect(options.rect), () => ( { x: 0, y: 0, width: this.doc.canvas.width, height: this.doc.canvas.height }));
|
|
@@ -5347,7 +5347,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5347
5347
|
const live = this.live;
|
|
5348
5348
|
if (!live) return this.doc.layers;
|
|
5349
5349
|
if (_optionalChain([this, 'access', _274 => _274.liveLayers, 'optionalAccess', _275 => _275.key]) === live.surface) return this.liveLayers.layers;
|
|
5350
|
-
const layers =
|
|
5350
|
+
const layers = _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, live.layerId, (l) => ({ ...l, surface: live.surface }));
|
|
5351
5351
|
this.liveLayers = { key: live.surface, layers };
|
|
5352
5352
|
return layers;
|
|
5353
5353
|
}
|
|
@@ -5384,7 +5384,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5384
5384
|
let out = layers;
|
|
5385
5385
|
for (const id of ids) {
|
|
5386
5386
|
const baked = this.wet.bakedSurface(id);
|
|
5387
|
-
if (baked &&
|
|
5387
|
+
if (baked && _chunkHB4ICNNAcjs.findLayer.call(void 0, out, id)) out = _chunkHB4ICNNAcjs.mapLayer.call(void 0, out, id, (l) => ({ ...l, surface: baked }));
|
|
5388
5388
|
}
|
|
5389
5389
|
return out;
|
|
5390
5390
|
}
|
|
@@ -5397,12 +5397,12 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5397
5397
|
const ids = /* @__PURE__ */ new Set([...Object.keys(_nullishCoalesce(thick, () => ( {}))), ...live ? [live.layerId] : []]);
|
|
5398
5398
|
for (const id of ids) {
|
|
5399
5399
|
const ch = _optionalChain([live, 'optionalAccess', _278 => _278.layerId]) === id ? live.channels : _optionalChain([thick, 'optionalAccess', _279 => _279[id]]);
|
|
5400
|
-
const l = ch && _optionalChain([
|
|
5400
|
+
const l = ch && _optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, out, id), 'optionalAccess', _280 => _280.layer]);
|
|
5401
5401
|
if (!ch || !isPixelLayer(l)) continue;
|
|
5402
5402
|
let cache = this.litCaches.get(id);
|
|
5403
5403
|
if (!cache) this.litCaches.set(id, cache = new LitCache());
|
|
5404
5404
|
const lit = cache.lit(l.surface, ch, this.lighting);
|
|
5405
|
-
if (lit !== l.surface) out =
|
|
5405
|
+
if (lit !== l.surface) out = _chunkHB4ICNNAcjs.mapLayer.call(void 0, out, id, () => ({ ...l, surface: lit }));
|
|
5406
5406
|
}
|
|
5407
5407
|
return out;
|
|
5408
5408
|
}
|
|
@@ -5410,7 +5410,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5410
5410
|
let layers = this.litLayers((_nullishCoalesce(options.wet, () => ( "display"))) === "dried" ? this.driedLayers() : this.currentLayers());
|
|
5411
5411
|
if (options.layerIds) {
|
|
5412
5412
|
const picked = [];
|
|
5413
|
-
for (const id of options.layerIds) picked.push(_nullishCoalesce(_optionalChain([
|
|
5413
|
+
for (const id of options.layerIds) picked.push(_nullishCoalesce(_optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, layers, id), 'optionalAccess', _281 => _281.layer]), () => ( this.requireLayer(id))));
|
|
5414
5414
|
layers = picked.map((l) => ({ ...l, visible: true }));
|
|
5415
5415
|
}
|
|
5416
5416
|
const under = options.paper === false ? [] : [paperNode(this.doc.paper, this.lighting)];
|
|
@@ -5454,7 +5454,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5454
5454
|
/** Wet settings saved with the document (`null` when they are all defaults). */
|
|
5455
5455
|
wetJSON() {
|
|
5456
5456
|
const layers = {};
|
|
5457
|
-
for (const [id, set] of this.wet.settings) if (
|
|
5457
|
+
for (const [id, set] of this.wet.settings) if (_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id)) layers[id] = { params: { ...set.params }, flow: { ...set.flow } };
|
|
5458
5458
|
const flat = this.wet.tilt.angle === 0;
|
|
5459
5459
|
if (!Object.keys(layers).length && flat) return void 0;
|
|
5460
5460
|
return { tilt: { ...this.wet.tilt }, layers };
|
|
@@ -5480,17 +5480,17 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5480
5480
|
const ext = { ...this.extensions };
|
|
5481
5481
|
const channels = {};
|
|
5482
5482
|
for (const [id, ch] of Object.entries(_nullishCoalesce(this.doc.thick, () => ( {})))) {
|
|
5483
|
-
if (!
|
|
5483
|
+
if (!_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id)) continue;
|
|
5484
5484
|
const saved = thickToJSON(ch);
|
|
5485
5485
|
if (saved) channels[id] = saved;
|
|
5486
5486
|
}
|
|
5487
5487
|
if (Object.keys(channels).length) ext.layerChannels = channels;
|
|
5488
5488
|
else delete ext.layerChannels;
|
|
5489
5489
|
const stickers = {};
|
|
5490
|
-
for (const [id, list] of Object.entries(_nullishCoalesce(this.doc.stickers, () => ( {})))) if (list.length &&
|
|
5490
|
+
for (const [id, list] of Object.entries(_nullishCoalesce(this.doc.stickers, () => ( {})))) if (list.length && _chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id)) stickers[id] = list.map((x) => ({ ...x }));
|
|
5491
5491
|
if (Object.keys(stickers).length) ext.stickers = stickers;
|
|
5492
5492
|
else delete ext.stickers;
|
|
5493
|
-
const effectLayers = effectLayersToJSON(_nullishCoalesce(this.doc.effectLayers, () => ( {})), (id) => isPixelLayer(_optionalChain([
|
|
5493
|
+
const effectLayers = effectLayersToJSON(_nullishCoalesce(this.doc.effectLayers, () => ( {})), (id) => isPixelLayer(_optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _284 => _284.layer])));
|
|
5494
5494
|
if (effectLayers) ext.effectLayers = effectLayers;
|
|
5495
5495
|
else delete ext.effectLayers;
|
|
5496
5496
|
if (this.doc.paperEffect) ext.paperEffect = paperEffectToJSON(this.doc.paperEffect);
|
|
@@ -5506,7 +5506,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5506
5506
|
if (ext.stickers && typeof ext.stickers === "object") {
|
|
5507
5507
|
const stickers = {};
|
|
5508
5508
|
for (const [id, list] of Object.entries(ext.stickers)) {
|
|
5509
|
-
if (!
|
|
5509
|
+
if (!_chunkHB4ICNNAcjs.findLayer.call(void 0, state.layers, id) || !Array.isArray(list)) continue;
|
|
5510
5510
|
const ok = list.filter((x) => x && typeof x.id === "string" && _chunkGNZI3KYKcjs.STAMP_KINDS.includes(x.stamp) && Number.isFinite(x.x) && Number.isFinite(x.y) && x.size > 0);
|
|
5511
5511
|
if (ok.length !== list.length) problems.push(`Some stickers of layer "${id}" could not be read; they were dropped.`);
|
|
5512
5512
|
stickers[id] = ok.map((x) => ({ ...x }));
|
|
@@ -5516,7 +5516,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5516
5516
|
if (ext.effectLayers && typeof ext.effectLayers === "object") {
|
|
5517
5517
|
const effectLayers = {};
|
|
5518
5518
|
for (const [id, v] of Object.entries(ext.effectLayers)) {
|
|
5519
|
-
if (!isPixelLayer(_optionalChain([
|
|
5519
|
+
if (!isPixelLayer(_optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, state.layers, id), 'optionalAccess', _285 => _285.layer]))) continue;
|
|
5520
5520
|
const source = readPaintEffectSource(v);
|
|
5521
5521
|
if (source) effectLayers[id] = source;
|
|
5522
5522
|
else problems.push(`The effect of layer "${id}" could not be read; it loads as a plain layer.`);
|
|
@@ -5534,7 +5534,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5534
5534
|
if (!raw || typeof raw !== "object") return state;
|
|
5535
5535
|
const thick = {};
|
|
5536
5536
|
for (const [id, v] of Object.entries(raw)) {
|
|
5537
|
-
if (!
|
|
5537
|
+
if (!_chunkHB4ICNNAcjs.findLayer.call(void 0, state.layers, id)) continue;
|
|
5538
5538
|
try {
|
|
5539
5539
|
thick[id] = thickFromJSON(v);
|
|
5540
5540
|
} catch (e) {
|
|
@@ -5649,7 +5649,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5649
5649
|
return next.type === "group" ? { ...next, children: toStandard(next.children) } : next;
|
|
5650
5650
|
});
|
|
5651
5651
|
const layers = toStandard(dried);
|
|
5652
|
-
const result =
|
|
5652
|
+
const result = _chunk5VQXSS2Scjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
|
|
5653
5653
|
for (const [mode, names] of changed) {
|
|
5654
5654
|
const label = _nullishCoalesce(_optionalChain([_chunkOLNIPTB3cjs.BLEND_MODES, 'access', _289 => _289.find, 'call', _290 => _290((m) => m.id === mode), 'optionalAccess', _291 => _291.label]), () => ( mode));
|
|
5655
5655
|
const std = _nullishCoalesce(_optionalChain([_chunkOLNIPTB3cjs.BLEND_MODES, 'access', _292 => _292.find, 'call', _293 => _293((m) => m.id === _chunkOLNIPTB3cjs.standardBlendMode.call(void 0, mode)), 'optionalAccess', _294 => _294.label]), () => ( _chunkOLNIPTB3cjs.standardBlendMode.call(void 0, mode)));
|
|
@@ -5899,9 +5899,9 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
5899
5899
|
}
|
|
5900
5900
|
/** Replaces a layer's stickers and redraws its pixels from them (one undo step). */
|
|
5901
5901
|
commitStickers(label, layer, stickers) {
|
|
5902
|
-
if (
|
|
5902
|
+
if (_chunkHB4ICNNAcjs.isLayerLocked.call(void 0, layer, "pixels")) throw new PaintEditorError(`Layer "${layer.name}" has its pixels locked; unlock it first.`);
|
|
5903
5903
|
const surface = _chunkGNZI3KYKcjs.stickerSurface.call(void 0, stickers);
|
|
5904
|
-
const doc = { ...this.doc, layers:
|
|
5904
|
+
const doc = { ...this.doc, layers: _chunkHB4ICNNAcjs.mapLayer.call(void 0, this.doc.layers, layer.id, () => ({ ...layer, surface, offset: { x: 0, y: 0 } })), stickers: { ..._nullishCoalesce(this.doc.stickers, () => ( {})), [layer.id]: stickers } };
|
|
5905
5905
|
this.commit(label, this.withPaintEvent(doc, { kind: "stickers", layerId: layer.id, data: { stickers: stickers.map((s) => ({ ...s })) } }));
|
|
5906
5906
|
}
|
|
5907
5907
|
/** Moves, turns, resizes, recolours or restamps one sticker (one undo step). Returns it. */
|
|
@@ -6154,7 +6154,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
6154
6154
|
}
|
|
6155
6155
|
/** A layer's tile surface (live while stroking), for thumbnails. */
|
|
6156
6156
|
layerSurface(id) {
|
|
6157
|
-
const l = _optionalChain([
|
|
6157
|
+
const l = _optionalChain([_chunkHB4ICNNAcjs.findLayer.call(void 0, this.currentLayers(), id), 'optionalAccess', _317 => _317.layer]);
|
|
6158
6158
|
return isPixelLayer(l) ? l.surface : null;
|
|
6159
6159
|
}
|
|
6160
6160
|
}, _class10.__initStatic(), _class10);
|
|
@@ -6164,7 +6164,7 @@ var moveRect = (r, dx, dy) => ({ ...r, x: r.x + dx, y: r.y + dy });
|
|
|
6164
6164
|
function shiftDocument(doc, dx, dy) {
|
|
6165
6165
|
if (!dx && !dy) return doc;
|
|
6166
6166
|
let layers = doc.layers;
|
|
6167
|
-
for (const l of
|
|
6167
|
+
for (const l of _chunkHB4ICNNAcjs.flattenLayers.call(void 0, doc.layers)) if (l.type === "pixel") layers = _chunkHB4ICNNAcjs.mapLayer.call(void 0, layers, l.id, () => ({ ...l, offset: movePoint(l.offset, dx, dy) }));
|
|
6168
6168
|
const m = [1, 0, 0, 1, dx, dy];
|
|
6169
6169
|
const moveStickers = (list) => list.map((s) => ({ ...s, x: Math.round((s.x + dx) * 100) / 100, y: Math.round((s.y + dy) * 100) / 100 }));
|
|
6170
6170
|
const out = {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resolveExternalAssets,
|
|
8
8
|
serializeLayers,
|
|
9
9
|
serializeLayersExternal
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-JVNGCS26.js";
|
|
11
11
|
import "../chunk-3CI7FRMK.js";
|
|
12
12
|
import "../chunk-ZNA3IQZF.js";
|
|
13
13
|
import {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
insertLayer,
|
|
21
21
|
isLayerLocked,
|
|
22
22
|
mapLayer
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-UOOK7HTX.js";
|
|
24
24
|
import "../chunk-OHKOFKBY.js";
|
|
25
25
|
import "../chunk-ZIF4UJJ6.js";
|
|
26
26
|
import {
|