@pixerate/editor 0.108.0 → 0.109.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/animation/index.cjs +5 -5
- package/dist/animation/index.cjs.map +1 -1
- package/dist/animation/index.js +9 -9
- package/dist/animation-editor/index.cjs +59 -59
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +2 -1
- package/dist/animation-editor/index.d.ts +2 -1
- package/dist/animation-editor/index.js +29 -29
- package/dist/canvas/index.cjs +27 -27
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.js +11 -11
- package/dist/{chunk-2FGRTYJN.cjs → chunk-477UVMNR.cjs} +3 -3
- package/dist/{chunk-2FGRTYJN.cjs.map → chunk-477UVMNR.cjs.map} +1 -1
- package/dist/{chunk-T3QZ6S47.cjs → chunk-AZTZRLDI.cjs} +40 -2
- package/dist/chunk-AZTZRLDI.cjs.map +1 -0
- package/dist/{chunk-HUQ7EHVI.js → chunk-BLWCAQCW.js} +723 -1975
- package/dist/chunk-BLWCAQCW.js.map +1 -0
- package/dist/{chunk-G4BIYE6R.js → chunk-CFMWALBM.js} +39 -1
- package/dist/chunk-CFMWALBM.js.map +1 -0
- package/dist/{chunk-FRD3FUXI.cjs → chunk-D37BX2ZA.cjs} +2081 -460
- package/dist/chunk-D37BX2ZA.cjs.map +1 -0
- package/dist/chunk-JLYX4V57.cjs +2001 -0
- package/dist/chunk-JLYX4V57.cjs.map +1 -0
- package/dist/chunk-KB2YBCVS.js +2001 -0
- package/dist/chunk-KB2YBCVS.js.map +1 -0
- package/dist/{chunk-SOROZ2BF.js → chunk-RE77QYUF.js} +1938 -317
- package/dist/chunk-RE77QYUF.js.map +1 -0
- package/dist/{chunk-UTEVPQTS.cjs → chunk-W3GXSUSQ.cjs} +746 -1998
- package/dist/chunk-W3GXSUSQ.cjs.map +1 -0
- package/dist/{chunk-JK6M6V7G.js → chunk-Z3YWVUWT.js} +4 -4
- package/dist/{export-a9bnF7Cl.d.ts → export-BLPLaE6Z.d.ts} +417 -16
- package/dist/{export-JGWQEPJn.d.cts → export-DSUc4fQD.d.cts} +417 -16
- package/dist/image-editor/index.cjs +1527 -1001
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +73 -9
- package/dist/image-editor/index.d.ts +73 -9
- package/dist/image-editor/index.js +814 -288
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint-editor/index.cjs +56 -53
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +5 -2
- package/dist/paint-editor/index.d.ts +5 -2
- package/dist/paint-editor/index.js +6 -3
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +4 -2
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +3 -129
- package/dist/raster/index.d.ts +3 -129
- package/dist/raster/index.js +3 -1
- package/dist/{compositor-D92URMlm.d.cts → render-C-fO_mes.d.cts} +135 -1
- package/dist/{compositor-Kt_M4ruo.d.ts → render-OLIMk_v0.d.ts} +135 -1
- package/dist/{svg-SseJTIrA.d.ts → svg-D_cfkhlB.d.cts} +3 -629
- package/dist/{svg-ClVIG4T7.d.cts → svg-wIaKLrU0.d.ts} +3 -629
- package/dist/types-DtL_qLFz.d.ts +630 -0
- package/dist/types-DyQq-WPY.d.cts +630 -0
- package/dist/vector/index.cjs +563 -563
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +4 -2
- package/dist/vector/index.d.ts +4 -2
- package/dist/vector/index.js +69 -69
- package/dist/video-editor/index.cjs +3 -3
- package/dist/video-editor/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-DWGZUSES.cjs +0 -694
- package/dist/chunk-DWGZUSES.cjs.map +0 -1
- package/dist/chunk-FRD3FUXI.cjs.map +0 -1
- package/dist/chunk-G4BIYE6R.js.map +0 -1
- package/dist/chunk-HUQ7EHVI.js.map +0 -1
- package/dist/chunk-KKREERP2.js +0 -694
- package/dist/chunk-KKREERP2.js.map +0 -1
- package/dist/chunk-SOROZ2BF.js.map +0 -1
- package/dist/chunk-T3QZ6S47.cjs.map +0 -1
- package/dist/chunk-UTEVPQTS.cjs.map +0 -1
- /package/dist/{chunk-JK6M6V7G.js.map → chunk-Z3YWVUWT.js.map} +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkD37BX2ZAcjs = require('../chunk-D37BX2ZA.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ var _chunkFRD3FUXIcjs = require('../chunk-FRD3FUXI.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkAZTZRLDIcjs = require('../chunk-AZTZRLDI.cjs');
|
|
21
21
|
require('../chunk-MUUXNRU4.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
@@ -60,7 +60,10 @@ var _chunkSZ6KMZNMcjs = require('../chunk-SZ6KMZNM.cjs');
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
var _chunkEGFUVXKKcjs = require('../chunk-EGFUVXKK.cjs');
|
|
63
|
-
require('../chunk-
|
|
63
|
+
require('../chunk-W3GXSUSQ.cjs');
|
|
64
|
+
require('../chunk-XGD3FSNC.cjs');
|
|
65
|
+
require('../chunk-MR3Z4OQI.cjs');
|
|
66
|
+
require('../chunk-A6PHCAGX.cjs');
|
|
64
67
|
|
|
65
68
|
// src/paint-editor/noise.ts
|
|
66
69
|
function mix32(h) {
|
|
@@ -1274,7 +1277,7 @@ var PROFILE = {
|
|
|
1274
1277
|
}
|
|
1275
1278
|
};
|
|
1276
1279
|
function createPaintCompositor() {
|
|
1277
|
-
return new (0,
|
|
1280
|
+
return new (0, _chunkAZTZRLDIcjs.RasterCompositor)(PROFILE);
|
|
1278
1281
|
}
|
|
1279
1282
|
function downsampleRgba(data, width, height, tw, th) {
|
|
1280
1283
|
tw = Math.max(1, Math.round(tw));
|
|
@@ -1345,11 +1348,11 @@ function header(state, options) {
|
|
|
1345
1348
|
return out;
|
|
1346
1349
|
}
|
|
1347
1350
|
function serializePaintDocument(state, options = {}) {
|
|
1348
|
-
const { layers, assets } =
|
|
1351
|
+
const { layers, assets } = _chunkD37BX2ZAcjs.serializeLayers.call(void 0, state.layers);
|
|
1349
1352
|
return { ...header(state, options), layers, assets };
|
|
1350
1353
|
}
|
|
1351
1354
|
async function serializePaintDocumentExternal(state, store, options = {}) {
|
|
1352
|
-
const { layers, assets } = await
|
|
1355
|
+
const { layers, assets } = await _chunkD37BX2ZAcjs.serializeLayersExternal.call(void 0, state.layers, store);
|
|
1353
1356
|
return { ...header(state, options), layers, assets };
|
|
1354
1357
|
}
|
|
1355
1358
|
function paintLayersOnly(layers, problems) {
|
|
@@ -1386,16 +1389,16 @@ function deserializePaintDocument(raw) {
|
|
|
1386
1389
|
const canvas = normalizeCanvas({ width: r.width, height: r.height, dpi: _nullishCoalesce(r.dpi, () => ( void 0)) });
|
|
1387
1390
|
const paper = normalizePaper(_nullishCoalesce(r.paper, () => ( {})));
|
|
1388
1391
|
const assets = r.assets && typeof r.assets === "object" ? r.assets : {};
|
|
1389
|
-
const layers = paintLayersOnly(
|
|
1392
|
+
const layers = paintLayersOnly(_chunkD37BX2ZAcjs.deserializeLayers.call(void 0, r.layers, { assets, problems }), problems);
|
|
1390
1393
|
const wanted = typeof r.activeLayerId === "string" ? r.activeLayerId : null;
|
|
1391
|
-
const activeLayerId = wanted &&
|
|
1394
|
+
const activeLayerId = wanted && _chunkAZTZRLDIcjs.findLayer.call(void 0, layers, wanted) ? wanted : _nullishCoalesce(_optionalChain([_chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers), 'access', _25 => _25.filter, 'call', _26 => _26((l) => l.type === "pixel"), 'access', _27 => _27.pop, 'call', _28 => _28(), 'optionalAccess', _29 => _29.id]), () => ( null));
|
|
1392
1395
|
return { state: { canvas, paper, layers, activeLayerId, strokes: readStrokes(r.strokes, problems) }, extensions: documentExtensions(r), guides: r.guides, swatches: r.swatches, problems };
|
|
1393
1396
|
}
|
|
1394
1397
|
async function deserializePaintDocumentAsync(raw, store) {
|
|
1395
1398
|
if (!raw || typeof raw !== "object") throw new Error("Not a paint document: expected a JSON object.");
|
|
1396
1399
|
const r = raw;
|
|
1397
1400
|
const problems = [];
|
|
1398
|
-
const assets = await
|
|
1401
|
+
const assets = await _chunkD37BX2ZAcjs.resolveExternalAssets.call(void 0, _nullishCoalesce(r.assets, () => ( {})), store, problems);
|
|
1399
1402
|
const loaded = deserializePaintDocument({ ...r, assets });
|
|
1400
1403
|
return { ...loaded, problems: [...problems, ...loaded.problems] };
|
|
1401
1404
|
}
|
|
@@ -2213,7 +2216,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2213
2216
|
}
|
|
2214
2217
|
// --- Layers --------------------------------------------------------------------
|
|
2215
2218
|
getLayer(id) {
|
|
2216
|
-
return _optionalChain([
|
|
2219
|
+
return _optionalChain([_chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, id), 'optionalAccess', _35 => _35.layer]);
|
|
2217
2220
|
}
|
|
2218
2221
|
/** The active pixel layer (or `undefined`). */
|
|
2219
2222
|
getActiveLayer() {
|
|
@@ -2232,12 +2235,12 @@ var PaintEditorController = (_class9 = class {
|
|
|
2232
2235
|
walk(this.doc.layers, null, 0);
|
|
2233
2236
|
return out;
|
|
2234
2237
|
}
|
|
2235
|
-
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([
|
|
2238
|
+
describeLayer(l, parentId = _nullishCoalesce(_optionalChain([_chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _36 => _36.parent, 'optionalAccess', _37 => _37.id]), () => ( null)), depth = _nullishCoalesce(_optionalChain([_chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, l.id), 'optionalAccess', _38 => _38.path, 'access', _39 => _39.length]), () => ( 0))) {
|
|
2236
2239
|
let bounds = null;
|
|
2237
2240
|
if (l.type === "pixel") {
|
|
2238
2241
|
const b = _chunkSZ6KMZNMcjs.contentBounds.call(void 0, l.surface);
|
|
2239
2242
|
bounds = b ? { ...b, x: b.x + l.offset.x, y: b.y + l.offset.y } : null;
|
|
2240
|
-
} else for (const c of
|
|
2243
|
+
} else for (const c of _chunkAZTZRLDIcjs.flattenLayers.call(void 0, l.children)) if (c.type === "pixel") bounds = unionRect(bounds, this.describeLayer(c, l.id, depth + 1).bounds);
|
|
2241
2244
|
return {
|
|
2242
2245
|
id: l.id,
|
|
2243
2246
|
name: l.name,
|
|
@@ -2264,7 +2267,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2264
2267
|
if (!id) throw new PaintEditorError(`There is no active layer to ${what}; add one with add_layer.`);
|
|
2265
2268
|
const l = this.requireLayer(id);
|
|
2266
2269
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; ${what} a pixel layer inside it.`);
|
|
2267
|
-
if (
|
|
2270
|
+
if (_chunkAZTZRLDIcjs.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.`);
|
|
2268
2271
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) before you ${what} it.`);
|
|
2269
2272
|
return l;
|
|
2270
2273
|
}
|
|
@@ -2277,7 +2280,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2277
2280
|
/** Adds an empty pixel layer or group above `aboveId` (default: the active layer) and makes it active. */
|
|
2278
2281
|
addLayer(options = {}) {
|
|
2279
2282
|
this.requireIdle("adding a layer");
|
|
2280
|
-
const count =
|
|
2283
|
+
const count = _chunkAZTZRLDIcjs.flattenLayers.call(void 0, this.doc.layers).length;
|
|
2281
2284
|
const type = _nullishCoalesce(options.type, () => ( "pixel"));
|
|
2282
2285
|
const name = _optionalChain([options, 'access', _40 => _40.name, 'optionalAccess', _41 => _41.trim, 'call', _42 => _42()]) || (type === "group" ? `Group ${count + 1}` : `Layer ${count + 1}`);
|
|
2283
2286
|
const layer = type === "group" ? { type: "group", id: newPaintLayerId(), name, visible: true, opacity: 1, blend: "pass-through", children: [] } : createPaintLayer(name);
|
|
@@ -2289,19 +2292,19 @@ var PaintEditorController = (_class9 = class {
|
|
|
2289
2292
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
2290
2293
|
parentId = g.id;
|
|
2291
2294
|
} else if (above) {
|
|
2292
|
-
const loc =
|
|
2295
|
+
const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, above);
|
|
2293
2296
|
if (!loc) throw new PaintEditorError(`Unknown layer "${above}". Call list_layers for the ids.`);
|
|
2294
2297
|
parentId = _nullishCoalesce(_optionalChain([loc, 'access', _43 => _43.parent, 'optionalAccess', _44 => _44.id]), () => ( null));
|
|
2295
2298
|
index = loc.index + 1;
|
|
2296
2299
|
}
|
|
2297
|
-
const layers =
|
|
2300
|
+
const layers = _chunkAZTZRLDIcjs.insertLayer.call(void 0, this.doc.layers, layer, parentId, index);
|
|
2298
2301
|
this.commit(type === "group" ? "Add group" : "Add layer", { ...this.doc, layers, activeLayerId: layer.id });
|
|
2299
2302
|
return this.describeLayer(layer);
|
|
2300
2303
|
}
|
|
2301
2304
|
updateLayer(id, update) {
|
|
2302
2305
|
this.requireIdle("changing a layer");
|
|
2303
2306
|
const l = this.requireLayer(id);
|
|
2304
|
-
if (
|
|
2307
|
+
if (_chunkAZTZRLDIcjs.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}).`);
|
|
2305
2308
|
if (update.opacity !== void 0 && !(update.opacity >= 0 && update.opacity <= 1)) throw new PaintEditorError(`opacity ${update.opacity} is out of range; use 0..1.`);
|
|
2306
2309
|
if (update.blend !== void 0 && !_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, update.blend) && !(l.type === "group" && update.blend === "pass-through")) {
|
|
2307
2310
|
throw new PaintEditorError(`Unknown blend mode "${update.blend}". Call get_canvas_info for the blend modes.`);
|
|
@@ -2317,57 +2320,57 @@ var PaintEditorController = (_class9 = class {
|
|
|
2317
2320
|
const locks = { ..._nullishCoalesce(l.locks, () => ( {})), ...update.locks };
|
|
2318
2321
|
next.locks = Object.values(locks).some(Boolean) ? locks : void 0;
|
|
2319
2322
|
}
|
|
2320
|
-
this.commit("Layer properties", { ...this.doc, layers:
|
|
2323
|
+
this.commit("Layer properties", { ...this.doc, layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, id, () => next) });
|
|
2321
2324
|
return this.describeLayer(next);
|
|
2322
2325
|
}
|
|
2323
2326
|
removeLayer(id) {
|
|
2324
2327
|
this.requireIdle("removing a layer");
|
|
2325
2328
|
const l = this.requireLayer(id);
|
|
2326
|
-
if (
|
|
2327
|
-
const layers =
|
|
2329
|
+
if (_chunkAZTZRLDIcjs.isLayerLocked.call(void 0, l, "all")) throw new PaintEditorError(`Layer "${l.name}" is fully locked; unlock it before removing it.`);
|
|
2330
|
+
const layers = _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
2328
2331
|
let active = this.doc.activeLayerId;
|
|
2329
|
-
if (active && !
|
|
2332
|
+
if (active && !_chunkAZTZRLDIcjs.findLayer.call(void 0, layers, active)) active = _nullishCoalesce(_optionalChain([_chunkAZTZRLDIcjs.flattenLayers.call(void 0, layers), 'access', _45 => _45.filter, 'call', _46 => _46((x) => x.type === "pixel"), 'access', _47 => _47.pop, 'call', _48 => _48(), 'optionalAccess', _49 => _49.id]), () => ( null));
|
|
2330
2333
|
this.commit("Remove layer", { ...this.doc, layers, activeLayerId: active });
|
|
2331
2334
|
return { removed: id, activeLayerId: active };
|
|
2332
2335
|
}
|
|
2333
2336
|
duplicateLayer(id) {
|
|
2334
2337
|
this.requireIdle("duplicating a layer");
|
|
2335
|
-
const loc =
|
|
2338
|
+
const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
2336
2339
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2337
2340
|
const copy = (l) => l.type === "group" ? { ...l, id: newPaintLayerId(), children: l.children.map(copy) } : { ...l, id: newPaintLayerId() };
|
|
2338
2341
|
const dup = { ...copy(loc.layer), name: `${loc.layer.name} copy` };
|
|
2339
|
-
const layers =
|
|
2342
|
+
const layers = _chunkAZTZRLDIcjs.insertLayer.call(void 0, this.doc.layers, dup, _nullishCoalesce(_optionalChain([loc, 'access', _50 => _50.parent, 'optionalAccess', _51 => _51.id]), () => ( null)), loc.index + 1);
|
|
2340
2343
|
this.commit("Duplicate layer", { ...this.doc, layers, activeLayerId: dup.id });
|
|
2341
2344
|
return this.describeLayer(dup);
|
|
2342
2345
|
}
|
|
2343
2346
|
/** Moves a layer to `index` (0 = bottom) within `parentId` (default its own parent; `null` = top level). */
|
|
2344
2347
|
moveLayer(id, index, parentId) {
|
|
2345
2348
|
this.requireIdle("moving a layer");
|
|
2346
|
-
const loc =
|
|
2349
|
+
const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
2347
2350
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2348
2351
|
const target = parentId === void 0 ? _nullishCoalesce(_optionalChain([loc, 'access', _52 => _52.parent, 'optionalAccess', _53 => _53.id]), () => ( null)) : parentId;
|
|
2349
2352
|
if (target) {
|
|
2350
2353
|
const g = this.requireLayer(target);
|
|
2351
2354
|
if (g.type !== "group") throw new PaintEditorError(`Layer "${g.name}" is not a group; pass a group id as parentId.`);
|
|
2352
|
-
if (target === id || loc.layer.type === "group" &&
|
|
2355
|
+
if (target === id || loc.layer.type === "group" && _chunkAZTZRLDIcjs.findLayer.call(void 0, loc.layer.children, target)) throw new PaintEditorError("A group cannot move into itself.");
|
|
2353
2356
|
}
|
|
2354
|
-
const without =
|
|
2355
|
-
const siblings = target ?
|
|
2357
|
+
const without = _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, id, () => null);
|
|
2358
|
+
const siblings = target ? _chunkAZTZRLDIcjs.findLayer.call(void 0, without, target).layer.children : without;
|
|
2356
2359
|
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).`);
|
|
2357
|
-
const layers =
|
|
2360
|
+
const layers = _chunkAZTZRLDIcjs.insertLayer.call(void 0, without, loc.layer, target, index);
|
|
2358
2361
|
this.commit("Move layer", { ...this.doc, layers });
|
|
2359
2362
|
return this.describeLayer(loc.layer);
|
|
2360
2363
|
}
|
|
2361
2364
|
/** Merges a pixel layer into the pixel layer below it (keeping the lower one's settings). */
|
|
2362
2365
|
mergeDown(id) {
|
|
2363
2366
|
this.requireIdle("merging");
|
|
2364
|
-
const loc =
|
|
2367
|
+
const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, this.doc.layers, id);
|
|
2365
2368
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2366
2369
|
const siblings = loc.parent ? loc.parent.children : this.doc.layers;
|
|
2367
2370
|
const below = siblings[loc.index - 1];
|
|
2368
2371
|
const upper = loc.layer;
|
|
2369
2372
|
if (!isPixelLayer(upper) || !isPixelLayer(below)) throw new PaintEditorError("Merge down needs a pixel layer directly above another pixel layer in the same group.");
|
|
2370
|
-
if (
|
|
2373
|
+
if (_chunkAZTZRLDIcjs.isLayerLocked.call(void 0, below, "pixels")) throw new PaintEditorError(`Layer "${below.name}" has its pixels locked; unlock it to merge into it.`);
|
|
2371
2374
|
const rect = unionRect(this.describeLayer(below).bounds, this.describeLayer(upper).bounds);
|
|
2372
2375
|
let surface = _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4);
|
|
2373
2376
|
if (rect) {
|
|
@@ -2376,7 +2379,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2376
2379
|
surface = _chunkSZ6KMZNMcjs.surfaceFromPixels.call(void 0, { width: rect.width, height: rect.height, data: px }, 4, rect.x, rect.y);
|
|
2377
2380
|
}
|
|
2378
2381
|
const merged = { ...below, surface, offset: { x: 0, y: 0 } };
|
|
2379
|
-
const layers =
|
|
2382
|
+
const layers = _chunkAZTZRLDIcjs.mapLayer.call(void 0, _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, upper.id, () => null), below.id, () => merged);
|
|
2380
2383
|
this.commit("Merge down", { ...this.doc, layers, activeLayerId: below.id });
|
|
2381
2384
|
return this.describeLayer(merged);
|
|
2382
2385
|
}
|
|
@@ -2385,7 +2388,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2385
2388
|
this.requireIdle("clearing");
|
|
2386
2389
|
const l = this.paintTarget(layerId, "clear");
|
|
2387
2390
|
const bounds = this.describeLayer(l).bounds;
|
|
2388
|
-
this.commit("Clear layer", { ...this.doc, layers:
|
|
2391
|
+
this.commit("Clear layer", { ...this.doc, layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface: _chunkSZ6KMZNMcjs.emptySurface.call(void 0, 4) })) });
|
|
2389
2392
|
return { layerId: l.id, bounds };
|
|
2390
2393
|
}
|
|
2391
2394
|
/**
|
|
@@ -2420,12 +2423,12 @@ var PaintEditorController = (_class9 = class {
|
|
|
2420
2423
|
background: rgbaOf(this.doc.paper.color),
|
|
2421
2424
|
opacity,
|
|
2422
2425
|
blend,
|
|
2423
|
-
lockTransparency:
|
|
2426
|
+
lockTransparency: _chunkAZTZRLDIcjs.isLayerLocked.call(void 0, l, "transparency"),
|
|
2424
2427
|
selection: null,
|
|
2425
2428
|
offset: l.offset
|
|
2426
2429
|
};
|
|
2427
2430
|
const surface = this.applyCoverage(l, coverage, rect, apply);
|
|
2428
|
-
this.commit("Fill layer", { ...this.doc, layers:
|
|
2431
|
+
this.commit("Fill layer", { ...this.doc, layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })) });
|
|
2429
2432
|
return { layerId: l.id, bounds: rect };
|
|
2430
2433
|
}
|
|
2431
2434
|
applyCoverage(l, coverage, rect, apply) {
|
|
@@ -2608,11 +2611,11 @@ var PaintEditorController = (_class9 = class {
|
|
|
2608
2611
|
const layer = (() => {
|
|
2609
2612
|
const id = _nullishCoalesce(init.layerId, () => ( doc.activeLayerId));
|
|
2610
2613
|
if (!id) throw new PaintEditorError("There is no active layer to paint on; add one with add_layer.");
|
|
2611
|
-
const loc =
|
|
2614
|
+
const loc = _chunkAZTZRLDIcjs.findLayer.call(void 0, doc.layers, id);
|
|
2612
2615
|
if (!loc) throw new PaintEditorError(`Unknown layer "${id}". Call list_layers for the ids.`);
|
|
2613
2616
|
const l = loc.layer;
|
|
2614
2617
|
if (!isPixelLayer(l)) throw new PaintEditorError(`Layer "${l.name}" is a group; paint on a pixel layer inside it.`);
|
|
2615
|
-
if (
|
|
2618
|
+
if (_chunkAZTZRLDIcjs.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.`);
|
|
2616
2619
|
if (!l.visible) throw new PaintEditorError(`Layer "${l.name}" is hidden; show it (update_layer visible true) to paint on it.`);
|
|
2617
2620
|
return l;
|
|
2618
2621
|
})();
|
|
@@ -2629,7 +2632,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2629
2632
|
layerId: layer.id,
|
|
2630
2633
|
surface: layer.surface,
|
|
2631
2634
|
offset: layer.offset,
|
|
2632
|
-
lockTransparency:
|
|
2635
|
+
lockTransparency: _chunkAZTZRLDIcjs.isLayerLocked.call(void 0, layer, "transparency"),
|
|
2633
2636
|
brush,
|
|
2634
2637
|
color: rgba,
|
|
2635
2638
|
background: rgbaOf(doc.paper.color),
|
|
@@ -2681,7 +2684,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2681
2684
|
const stroke = this.record(s);
|
|
2682
2685
|
s.result.strokeId = stroke.id;
|
|
2683
2686
|
const l = this.getLayer(s.layerId);
|
|
2684
|
-
this.commit(`${brush.name} stroke`, { ...this.doc, layers:
|
|
2687
|
+
this.commit(`${brush.name} stroke`, { ...this.doc, layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, l.id, () => ({ ...l, surface })), strokes: [...this.doc.strokes, stroke] });
|
|
2685
2688
|
}
|
|
2686
2689
|
};
|
|
2687
2690
|
const session = this.sessionFor(this.doc, { snapToPerspective: true, ...init }, host);
|
|
@@ -2703,8 +2706,8 @@ var PaintEditorController = (_class9 = class {
|
|
|
2703
2706
|
if (cancelled || !surface) return;
|
|
2704
2707
|
const stroke = this.record(s);
|
|
2705
2708
|
s.result.strokeId = stroke.id;
|
|
2706
|
-
const l =
|
|
2707
|
-
out = { ...out, layers:
|
|
2709
|
+
const l = _chunkAZTZRLDIcjs.findLayer.call(void 0, out.layers, s.layerId).layer;
|
|
2710
|
+
out = { ...out, layers: _chunkAZTZRLDIcjs.mapLayer.call(void 0, out.layers, l.id, () => ({ ...l, surface })), strokes: [...out.strokes, stroke] };
|
|
2708
2711
|
}
|
|
2709
2712
|
};
|
|
2710
2713
|
const session = this.sessionFor(doc, init, host);
|
|
@@ -2776,7 +2779,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2776
2779
|
brush = normalizePaintBrush({ tip: { ...b.tip, size: b.tip.size * (v.brush.tip.size / s.brush.tip.size) } }, b);
|
|
2777
2780
|
}
|
|
2778
2781
|
const layerId = _nullishCoalesce(options.layerId, () => ( s.layerId));
|
|
2779
|
-
if (!
|
|
2782
|
+
if (!_chunkAZTZRLDIcjs.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.`);
|
|
2780
2783
|
const run = this.runStroke(doc, { layerId, color: _nullishCoalesce(options.color, () => ( s.color)), brush, seed: s.seed, copies: _nullishCoalesce(v.copies, () => ( [])) }, v.points);
|
|
2781
2784
|
doc = run.doc;
|
|
2782
2785
|
bounds = unionRect(bounds, run.result.bounds);
|
|
@@ -2796,7 +2799,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2796
2799
|
const live = this.live;
|
|
2797
2800
|
if (!live) return this.doc.layers;
|
|
2798
2801
|
if (_optionalChain([this, 'access', _63 => _63.liveLayers, 'optionalAccess', _64 => _64.key]) === live.surface) return this.liveLayers.layers;
|
|
2799
|
-
const layers =
|
|
2802
|
+
const layers = _chunkAZTZRLDIcjs.mapLayer.call(void 0, this.doc.layers, live.layerId, (l) => ({ ...l, surface: live.surface }));
|
|
2800
2803
|
this.liveLayers = { key: live.surface, layers };
|
|
2801
2804
|
return layers;
|
|
2802
2805
|
}
|
|
@@ -2900,7 +2903,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2900
2903
|
/** The canvas as PNG bytes (paper included by default; `scale` below 1 shrinks it). */
|
|
2901
2904
|
exportPng(options = {}) {
|
|
2902
2905
|
const img = this.scaled(options);
|
|
2903
|
-
return
|
|
2906
|
+
return _chunkAZTZRLDIcjs.encodePng.call(void 0, img.width, img.height, img.data);
|
|
2904
2907
|
}
|
|
2905
2908
|
scaled(options) {
|
|
2906
2909
|
const full = this.compositePixels(options);
|
|
@@ -2954,7 +2957,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2954
2957
|
return next.type === "group" ? { ...next, children: toStandard(next.children) } : next;
|
|
2955
2958
|
});
|
|
2956
2959
|
const layers = toStandard(this.doc.layers);
|
|
2957
|
-
const result =
|
|
2960
|
+
const result = _chunkD37BX2ZAcjs.exportPsd.call(void 0, { width, height, layers: [paperLayer, ...layers], merged, resolution: dpi });
|
|
2958
2961
|
for (const [mode, names] of changed) {
|
|
2959
2962
|
const label = _nullishCoalesce(_optionalChain([_chunkSZ6KMZNMcjs.BLEND_MODES, 'access', _72 => _72.find, 'call', _73 => _73((m) => m.id === mode), 'optionalAccess', _74 => _74.label]), () => ( mode));
|
|
2960
2963
|
const std = _nullishCoalesce(_optionalChain([_chunkSZ6KMZNMcjs.BLEND_MODES, 'access', _75 => _75.find, 'call', _76 => _76((m) => m.id === _chunkSZ6KMZNMcjs.standardBlendMode.call(void 0, mode)), 'optionalAccess', _77 => _77.label]), () => ( _chunkSZ6KMZNMcjs.standardBlendMode.call(void 0, mode)));
|
|
@@ -2967,7 +2970,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
2967
2970
|
/** `render_preview` as a base64 PNG. */
|
|
2968
2971
|
previewPngBase64(options = {}) {
|
|
2969
2972
|
const img = this.renderPreview(options);
|
|
2970
|
-
return { data:
|
|
2973
|
+
return { data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, _chunkAZTZRLDIcjs.encodePng.call(void 0, img.width, img.height, img.data)), width: img.width, height: img.height };
|
|
2971
2974
|
}
|
|
2972
2975
|
// --- Guides --------------------------------------------------------------------
|
|
2973
2976
|
setGuides(next) {
|
|
@@ -3005,17 +3008,17 @@ var PaintEditorController = (_class9 = class {
|
|
|
3005
3008
|
pixels = this.decodeImage(input.png.trim().startsWith("data:") ? input.png.trim() : `data:image/png;base64,${input.png.trim()}`, what);
|
|
3006
3009
|
} else throw new PaintEditorError(`${what}: pass png (a PNG as base64 or a data URL) or pixels.`);
|
|
3007
3010
|
if (pixels.width > MAX_IMAGE_SIDE || pixels.height > MAX_IMAGE_SIDE) throw new PaintEditorError(`${what} is ${pixels.width}\xD7${pixels.height}; the limit is ${MAX_IMAGE_SIDE} px per side.`);
|
|
3008
|
-
const src =
|
|
3011
|
+
const src = _chunkAZTZRLDIcjs.pngDataUrl.call(void 0, pixels.width, pixels.height, pixels.data);
|
|
3009
3012
|
this.imagePixels.set(src, pixels);
|
|
3010
3013
|
return { src, pixels };
|
|
3011
3014
|
}
|
|
3012
3015
|
decodeImage(src, what = "Image") {
|
|
3013
3016
|
const cached = this.imagePixels.get(src);
|
|
3014
3017
|
if (cached) return cached;
|
|
3015
|
-
const parsed =
|
|
3018
|
+
const parsed = _chunkAZTZRLDIcjs.parseDataUrl.call(void 0, src);
|
|
3016
3019
|
if (!parsed) throw new PaintEditorError(`${what} is not a data URL or base64 PNG.`);
|
|
3017
3020
|
try {
|
|
3018
|
-
const png =
|
|
3021
|
+
const png = _chunkAZTZRLDIcjs.decodePng.call(void 0, parsed.bytes);
|
|
3019
3022
|
const px = { width: png.width, height: png.height, data: png.data };
|
|
3020
3023
|
this.imagePixels.set(src, px);
|
|
3021
3024
|
return px;
|
|
@@ -3220,7 +3223,7 @@ var PaintEditorController = (_class9 = class {
|
|
|
3220
3223
|
}
|
|
3221
3224
|
/** A layer's tile surface (live while stroking), for thumbnails. */
|
|
3222
3225
|
layerSurface(id) {
|
|
3223
|
-
const l = _optionalChain([
|
|
3226
|
+
const l = _optionalChain([_chunkAZTZRLDIcjs.findLayer.call(void 0, this.currentLayers(), id), 'optionalAccess', _86 => _86.layer]);
|
|
3224
3227
|
return isPixelLayer(l) ? l.surface : null;
|
|
3225
3228
|
}
|
|
3226
3229
|
}, _class9);
|
|
@@ -3740,7 +3743,7 @@ function createPaintGuideTools(c) {
|
|
|
3740
3743
|
const pad = c.mixingPad;
|
|
3741
3744
|
return {
|
|
3742
3745
|
content: [
|
|
3743
|
-
{ type: "image", data:
|
|
3746
|
+
{ type: "image", data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, _chunkAZTZRLDIcjs.encodePng.call(void 0, pad.width, pad.height, pad.pixels())), mimeType: "image/png" },
|
|
3744
3747
|
{ type: "text", text: `Mixing pad ${pad.width}\xD7${pad.height}` }
|
|
3745
3748
|
]
|
|
3746
3749
|
};
|
|
@@ -4241,7 +4244,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4241
4244
|
const t = c.brushThumbnail(_nullishCoalesce(id, () => ( c.getState().brush.id)), { width, height, color });
|
|
4242
4245
|
return {
|
|
4243
4246
|
content: [
|
|
4244
|
-
{ type: "image", data:
|
|
4247
|
+
{ type: "image", data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, _chunkAZTZRLDIcjs.encodePng.call(void 0, t.width, t.height, t.data)), mimeType: "image/png" },
|
|
4245
4248
|
{ type: "text", text: `Brush ${_nullishCoalesce(id, () => ( c.getState().brush.id))} ${t.width}\xD7${t.height}` }
|
|
4246
4249
|
]
|
|
4247
4250
|
};
|
|
@@ -4496,7 +4499,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4496
4499
|
annotations: { title: "Export the painting", ...READ2 },
|
|
4497
4500
|
handler: async ({ format, quality, scale, paper }) => {
|
|
4498
4501
|
const bytes = await c.exportImage({ format, quality, scale, paper });
|
|
4499
|
-
return { mimeType: _nullishCoalesce(format, () => ( "image/png")), bytes: bytes.length, data:
|
|
4502
|
+
return { mimeType: _nullishCoalesce(format, () => ( "image/png")), bytes: bytes.length, data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, bytes) };
|
|
4500
4503
|
}
|
|
4501
4504
|
});
|
|
4502
4505
|
add({
|
|
@@ -4507,7 +4510,7 @@ function createPaintEditorToolProvider(controller, options = {}) {
|
|
|
4507
4510
|
annotations: { title: "Export as PSD", ...READ2 },
|
|
4508
4511
|
handler: () => {
|
|
4509
4512
|
const r = c.exportPsd();
|
|
4510
|
-
return { data:
|
|
4513
|
+
return { data: _chunkAZTZRLDIcjs.bytesToBase64.call(void 0, r.bytes), bytes: r.bytes.length, psb: r.psb, warnings: r.warnings };
|
|
4511
4514
|
}
|
|
4512
4515
|
});
|
|
4513
4516
|
add({
|