@pixerate/editor 0.108.0 → 0.110.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/blending-DXl06NSx.d.ts +486 -0
- package/dist/blending-aOE6Y3UE.d.cts +486 -0
- 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-7VOHOPLW.cjs +1136 -0
- package/dist/chunk-7VOHOPLW.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-SOROZ2BF.js → chunk-DMRSJBJF.js} +1939 -318
- package/dist/chunk-DMRSJBJF.js.map +1 -0
- package/dist/chunk-FTBZPI77.cjs +1 -0
- package/dist/chunk-FTBZPI77.cjs.map +1 -0
- package/dist/{chunk-WMBIJCHA.js → chunk-HNS7UHCM.js} +5 -1
- package/dist/{chunk-WMBIJCHA.js.map → chunk-HNS7UHCM.js.map} +1 -1
- 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-G4BIYE6R.js → chunk-LQEEDHOP.js} +40 -2
- package/dist/chunk-LQEEDHOP.js.map +1 -0
- package/dist/{chunk-FRD3FUXI.cjs → chunk-MGL4U5WA.cjs} +2144 -523
- package/dist/chunk-MGL4U5WA.cjs.map +1 -0
- package/dist/{chunk-T3QZ6S47.cjs → chunk-POGBUYWE.cjs} +131 -93
- package/dist/chunk-POGBUYWE.cjs.map +1 -0
- package/dist/chunk-VKK5VS2T.js +1 -0
- package/dist/{chunk-UTEVPQTS.cjs → chunk-W3GXSUSQ.cjs} +746 -1998
- package/dist/chunk-W3GXSUSQ.cjs.map +1 -0
- package/dist/{chunk-SZ6KMZNM.cjs → chunk-XIOMMGPD.cjs} +6 -2
- package/dist/chunk-XIOMMGPD.cjs.map +1 -0
- package/dist/{chunk-JK6M6V7G.js → chunk-Z3YWVUWT.js} +4 -4
- package/dist/{chunk-3PHA3UKI.js → chunk-Z4BC6M74.js} +523 -121
- package/dist/chunk-Z4BC6M74.js.map +1 -0
- package/dist/{export-a9bnF7Cl.d.ts → export-CO2ryu3I.d.ts} +419 -18
- package/dist/{export-JGWQEPJn.d.cts → export-DRiLzP_j.d.cts} +419 -18
- package/dist/image-editor/index.cjs +1665 -1113
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +78 -14
- package/dist/image-editor/index.d.ts +78 -14
- package/dist/image-editor/index.js +843 -291
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint/index.cjs +28 -4
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +3 -89
- package/dist/paint/index.d.ts +3 -89
- package/dist/paint/index.js +27 -3
- package/dist/paint-editor/index.cjs +1056 -287
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +304 -22
- package/dist/paint-editor/index.d.ts +304 -22
- package/dist/paint-editor/index.js +852 -83
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +7 -3
- 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 +6 -2
- package/dist/{compositor-D92URMlm.d.cts → render-BEriFuqK.d.cts} +136 -2
- package/dist/{compositor-Kt_M4ruo.d.ts → render-tjzKaik-.d.ts} +136 -2
- package/dist/{surface-CkKOHGPm.d.cts → surface-C8RRg_Bh.d.cts} +109 -1
- package/dist/{surface-CkKOHGPm.d.ts → surface-C8RRg_Bh.d.ts} +109 -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/skills/pixerate-paint-editor/SKILL.md +49 -13
- package/dist/chunk-3PHA3UKI.js.map +0 -1
- package/dist/chunk-6BU5WU4R.cjs +0 -1
- package/dist/chunk-6BU5WU4R.cjs.map +0 -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-HUFQD4CB.cjs +0 -734
- package/dist/chunk-HUFQD4CB.cjs.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-SZ6KMZNM.cjs.map +0 -1
- package/dist/chunk-T3QZ6S47.cjs.map +0 -1
- package/dist/chunk-UTEVPQTS.cjs.map +0 -1
- package/dist/chunk-XYBJKUAU.js +0 -1
- package/dist/mixer-5ziHU8OS.d.cts +0 -282
- package/dist/mixer-DNqiYXYQ.d.ts +0 -282
- /package/dist/{chunk-XYBJKUAU.js.map → chunk-VKK5VS2T.js.map} +0 -0
- /package/dist/{chunk-JK6M6V7G.js.map → chunk-Z3YWVUWT.js.map} +0 -0
|
@@ -37,7 +37,11 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
var _chunkPOGBUYWEcjs = require('./chunk-POGBUYWE.cjs');
|
|
41
45
|
|
|
42
46
|
|
|
43
47
|
|
|
@@ -59,7 +63,19 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
|
|
|
59
63
|
|
|
60
64
|
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
var _chunkXIOMMGPDcjs = require('./chunk-XIOMMGPD.cjs');
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
63
79
|
|
|
64
80
|
|
|
65
81
|
|
|
@@ -74,7 +90,16 @@ var _chunkSZ6KMZNMcjs = require('./chunk-SZ6KMZNM.cjs');
|
|
|
74
90
|
|
|
75
91
|
|
|
76
92
|
|
|
77
|
-
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
var _chunkW3GXSUSQcjs = require('./chunk-W3GXSUSQ.cjs');
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
var _chunkXGD3FSNCcjs = require('./chunk-XGD3FSNC.cjs');
|
|
78
103
|
|
|
79
104
|
// src/image-editor/color.ts
|
|
80
105
|
var LEGACY_PROCESS_VERSION = 1;
|
|
@@ -793,12 +818,12 @@ function selectionFromPixels(pixels, options = {}) {
|
|
|
793
818
|
const { width, height, data } = pixels;
|
|
794
819
|
checkSize(width, height);
|
|
795
820
|
if (data.length < width * height * 4) throw new Error("Pixel data is shorter than width \xD7 height \xD7 4");
|
|
796
|
-
const
|
|
821
|
+
const channel2 = _nullishCoalesce(options.channel, () => ( "luminance"));
|
|
797
822
|
const out = new Uint8Array(width * height);
|
|
798
823
|
const threshold = options.threshold;
|
|
799
824
|
for (let i = 0, p = 0; i < out.length; i++, p += 4) {
|
|
800
825
|
let v;
|
|
801
|
-
switch (
|
|
826
|
+
switch (channel2) {
|
|
802
827
|
case "alpha":
|
|
803
828
|
v = data[p + 3];
|
|
804
829
|
break;
|
|
@@ -1086,7 +1111,7 @@ function smoothCoverage(m, w, h, r) {
|
|
|
1086
1111
|
return src;
|
|
1087
1112
|
}
|
|
1088
1113
|
function featherCoverage(m, w, h, radius) {
|
|
1089
|
-
const out =
|
|
1114
|
+
const out = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
|
|
1090
1115
|
for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
|
|
1091
1116
|
return out;
|
|
1092
1117
|
}
|
|
@@ -1234,7 +1259,7 @@ function layerMaskCoverage(mask) {
|
|
|
1234
1259
|
let v = new Float32Array(sel.data.length);
|
|
1235
1260
|
for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
|
|
1236
1261
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
1237
|
-
if (feather > 0) v =
|
|
1262
|
+
if (feather > 0) v = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
|
|
1238
1263
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
1239
1264
|
if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
|
|
1240
1265
|
return v;
|
|
@@ -1455,7 +1480,7 @@ function normalizeAdjustmentLayer(raw) {
|
|
|
1455
1480
|
kind: r.kind,
|
|
1456
1481
|
enabled: r.enabled !== false,
|
|
1457
1482
|
opacity: clampTo(r.opacity, 0, 1, 1),
|
|
1458
|
-
blend:
|
|
1483
|
+
blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend),
|
|
1459
1484
|
params: normParams(r.kind, r.params)
|
|
1460
1485
|
};
|
|
1461
1486
|
if (typeof r.name === "string" && r.name) layer.name = r.name;
|
|
@@ -1477,7 +1502,7 @@ function normalizeAdjustmentLayers(raw) {
|
|
|
1477
1502
|
return out;
|
|
1478
1503
|
}
|
|
1479
1504
|
function curveLutFromLevels(points) {
|
|
1480
|
-
return
|
|
1505
|
+
return _chunkPOGBUYWEcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
|
|
1481
1506
|
}
|
|
1482
1507
|
var toUnitLevels = (c) => ({
|
|
1483
1508
|
inBlack: c.inBlack / 255,
|
|
@@ -1800,7 +1825,7 @@ function compileAdjustmentLayer(layer) {
|
|
|
1800
1825
|
return (c) => {
|
|
1801
1826
|
const g = blackWhiteGray(c, weights);
|
|
1802
1827
|
if (tint) {
|
|
1803
|
-
const t =
|
|
1828
|
+
const t = _chunkXIOMMGPDcjs.setLum.call(void 0, tint, g);
|
|
1804
1829
|
c[0] = clamp01(t[0]);
|
|
1805
1830
|
c[1] = clamp01(t[1]);
|
|
1806
1831
|
c[2] = clamp01(t[2]);
|
|
@@ -1819,7 +1844,7 @@ function compileAdjustmentLayer(layer) {
|
|
|
1819
1844
|
let f = [0, 1, 2].map((r) => linearToSrgb(Math.max(0, m[r][0] * l[0] + m[r][1] * l[1] + m[r][2] * l[2])));
|
|
1820
1845
|
if (preserve) {
|
|
1821
1846
|
const target = 0.3 * c[0] + 0.59 * c[1] + 0.11 * c[2];
|
|
1822
|
-
f =
|
|
1847
|
+
f = _chunkXIOMMGPDcjs.setLum.call(void 0, f, target);
|
|
1823
1848
|
}
|
|
1824
1849
|
c[0] = clamp01(f[0]);
|
|
1825
1850
|
c[1] = clamp01(f[1]);
|
|
@@ -1886,10 +1911,10 @@ function applyLayer(c, layer, op, coverage = 1) {
|
|
|
1886
1911
|
const cb0 = c[0], cb1 = c[1], cb2 = c[2];
|
|
1887
1912
|
op(c);
|
|
1888
1913
|
if (blend === "pigment") {
|
|
1889
|
-
|
|
1914
|
+
_chunkXIOMMGPDcjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
|
|
1890
1915
|
return;
|
|
1891
1916
|
}
|
|
1892
|
-
const b = blend === "normal" ? c :
|
|
1917
|
+
const b = blend === "normal" ? c : _chunkXIOMMGPDcjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
|
|
1893
1918
|
c[0] = (1 - alpha) * cb0 + alpha * b[0];
|
|
1894
1919
|
c[1] = (1 - alpha) * cb1 + alpha * b[1];
|
|
1895
1920
|
c[2] = (1 - alpha) * cb2 + alpha * b[2];
|
|
@@ -2197,12 +2222,14 @@ function removeAlpha(imageData) {
|
|
|
2197
2222
|
}
|
|
2198
2223
|
|
|
2199
2224
|
// src/image-editor/layers/model.ts
|
|
2225
|
+
var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
|
|
2226
|
+
var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
|
|
2200
2227
|
var idCounter = 0;
|
|
2201
2228
|
function newLayerId(prefix = "layer") {
|
|
2202
2229
|
return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
|
|
2203
2230
|
}
|
|
2204
2231
|
function pixelLayers(layers) {
|
|
2205
|
-
return
|
|
2232
|
+
return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
2206
2233
|
}
|
|
2207
2234
|
function developFilter(layer) {
|
|
2208
2235
|
return _optionalChain([layer, 'access', _8 => _8.filters, 'optionalAccess', _9 => _9.find, 'call', _10 => _10((f) => f.kind === "develop")]);
|
|
@@ -2224,13 +2251,19 @@ function pixelLayerBounds(layer, surface = layer.surface) {
|
|
|
2224
2251
|
return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height };
|
|
2225
2252
|
}
|
|
2226
2253
|
function layerTypeLabel(type) {
|
|
2227
|
-
return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : "Annotation";
|
|
2254
|
+
return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : "Annotation";
|
|
2228
2255
|
}
|
|
2229
2256
|
function hasSurface(layer) {
|
|
2230
|
-
return layer.type === "pixel" || layer.type === "smart";
|
|
2257
|
+
return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape";
|
|
2258
|
+
}
|
|
2259
|
+
function isRenderedLayer(layer) {
|
|
2260
|
+
return layer.type === "smart" || layer.type === "shape";
|
|
2261
|
+
}
|
|
2262
|
+
function shapeLayers(layers) {
|
|
2263
|
+
return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
|
|
2231
2264
|
}
|
|
2232
2265
|
function smartObjectLayers(layers) {
|
|
2233
|
-
return
|
|
2266
|
+
return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
|
|
2234
2267
|
}
|
|
2235
2268
|
|
|
2236
2269
|
// src/image-editor/layers/compositor.ts
|
|
@@ -2322,8 +2355,11 @@ var PHOTO_PROFILE = {
|
|
|
2322
2355
|
contentBlend: (l) => l.type === "annotation" && l.blend === "normal" && l.annotation.blend ? l.annotation.blend : l.blend,
|
|
2323
2356
|
layerKey: (l) => l.type === "pixel" ? [_nullishCoalesce(l.filters, () => ( null)), _nullishCoalesce(l.source, () => ( null))] : l.type === "adjustment" ? [l.kind, l.params] : l.type === "annotation" ? l.annotation : void 0,
|
|
2324
2357
|
pixelFilters: (l) => l.type === "pixel" ? pixelFilterSpec(l) : null,
|
|
2325
|
-
/**
|
|
2326
|
-
|
|
2358
|
+
/**
|
|
2359
|
+
* A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel
|
|
2360
|
+
* layer, and a shape layer the pixels rendered from its paths.
|
|
2361
|
+
*/
|
|
2362
|
+
isPixelLike: (l) => l.type === "smart" || l.type === "shape",
|
|
2327
2363
|
maskSourcePlane: (source, W, H, sources) => {
|
|
2328
2364
|
const opts = source;
|
|
2329
2365
|
const depth = _nullishCoalesce(_optionalChain([sources, 'access', _17 => _17.depthMap, 'optionalCall', _18 => _18(opts)]), () => ( null));
|
|
@@ -2333,169 +2369,540 @@ var PHOTO_PROFILE = {
|
|
|
2333
2369
|
return v;
|
|
2334
2370
|
}
|
|
2335
2371
|
};
|
|
2336
|
-
var LayerCompositor = class extends
|
|
2372
|
+
var LayerCompositor = class extends _chunkPOGBUYWEcjs.RasterCompositor {
|
|
2337
2373
|
constructor(options = {}) {
|
|
2338
2374
|
super(PHOTO_PROFILE, options);
|
|
2339
2375
|
}
|
|
2340
2376
|
};
|
|
2341
2377
|
|
|
2342
|
-
// src/image-editor/
|
|
2343
|
-
var
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
const [fx, fy] = ANCHOR_FRACTION[anchor];
|
|
2405
|
-
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
2406
|
-
const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
|
|
2407
|
-
return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
|
|
2408
|
-
}
|
|
2409
|
-
function transformedBox(geometry) {
|
|
2410
|
-
const f = transformMap(geometry);
|
|
2411
|
-
if (!f) return null;
|
|
2412
|
-
const { box } = geometry;
|
|
2413
|
-
const pts = [];
|
|
2414
|
-
const n = hasWarp(geometry) ? 16 : 1;
|
|
2415
|
-
for (let i = 0; i <= n; i++) {
|
|
2416
|
-
const t = i / n;
|
|
2417
|
-
for (const [fx, fy] of [[t, 0], [1, t], [1 - t, 1], [0, 1 - t]]) {
|
|
2418
|
-
const p = f({ x: box.x + fx * box.width, y: box.y + fy * box.height });
|
|
2419
|
-
if (!p) return null;
|
|
2420
|
-
pts.push(p);
|
|
2378
|
+
// src/image-editor/layers/vector-raster.ts
|
|
2379
|
+
var FLATNESS = 0.01;
|
|
2380
|
+
function flattenPath(path, tolerance = FLATNESS) {
|
|
2381
|
+
const out = [];
|
|
2382
|
+
let pts = [];
|
|
2383
|
+
let cx = 0;
|
|
2384
|
+
let cy = 0;
|
|
2385
|
+
let sx = 0;
|
|
2386
|
+
let sy = 0;
|
|
2387
|
+
const flush = () => {
|
|
2388
|
+
if (pts.length >= 6) out.push(Float64Array.from(pts));
|
|
2389
|
+
pts = [];
|
|
2390
|
+
};
|
|
2391
|
+
const steps = (dd, degree) => Math.max(1, Math.min(1024, Math.ceil(Math.sqrt(degree * (degree - 1) * dd / (8 * tolerance)))));
|
|
2392
|
+
for (const c of path) {
|
|
2393
|
+
switch (c.type) {
|
|
2394
|
+
case "M":
|
|
2395
|
+
flush();
|
|
2396
|
+
cx = sx = c.x;
|
|
2397
|
+
cy = sy = c.y;
|
|
2398
|
+
pts.push(cx, cy);
|
|
2399
|
+
break;
|
|
2400
|
+
case "L":
|
|
2401
|
+
if (!pts.length) pts.push(cx, cy);
|
|
2402
|
+
cx = c.x;
|
|
2403
|
+
cy = c.y;
|
|
2404
|
+
pts.push(cx, cy);
|
|
2405
|
+
break;
|
|
2406
|
+
case "Q": {
|
|
2407
|
+
if (!pts.length) pts.push(cx, cy);
|
|
2408
|
+
const n = steps(Math.hypot(cx - 2 * c.x1 + c.x, cy - 2 * c.y1 + c.y), 2);
|
|
2409
|
+
for (let k = 1; k <= n; k++) {
|
|
2410
|
+
const t = k / n;
|
|
2411
|
+
const u = 1 - t;
|
|
2412
|
+
pts.push(u * u * cx + 2 * u * t * c.x1 + t * t * c.x, u * u * cy + 2 * u * t * c.y1 + t * t * c.y);
|
|
2413
|
+
}
|
|
2414
|
+
cx = c.x;
|
|
2415
|
+
cy = c.y;
|
|
2416
|
+
break;
|
|
2417
|
+
}
|
|
2418
|
+
case "C": {
|
|
2419
|
+
if (!pts.length) pts.push(cx, cy);
|
|
2420
|
+
const dd = Math.max(Math.hypot(cx - 2 * c.x1 + c.x2, cy - 2 * c.y1 + c.y2), Math.hypot(c.x1 - 2 * c.x2 + c.x, c.y1 - 2 * c.y2 + c.y));
|
|
2421
|
+
const n = steps(dd, 3);
|
|
2422
|
+
for (let k = 1; k <= n; k++) {
|
|
2423
|
+
const t = k / n;
|
|
2424
|
+
const u = 1 - t;
|
|
2425
|
+
const a = u * u * u;
|
|
2426
|
+
const b = 3 * u * u * t;
|
|
2427
|
+
const d = 3 * u * t * t;
|
|
2428
|
+
const e = t * t * t;
|
|
2429
|
+
pts.push(a * cx + b * c.x1 + d * c.x2 + e * c.x, a * cy + b * c.y1 + d * c.y2 + e * c.y);
|
|
2430
|
+
}
|
|
2431
|
+
cx = c.x;
|
|
2432
|
+
cy = c.y;
|
|
2433
|
+
break;
|
|
2434
|
+
}
|
|
2435
|
+
case "Z":
|
|
2436
|
+
flush();
|
|
2437
|
+
cx = sx;
|
|
2438
|
+
cy = sy;
|
|
2439
|
+
break;
|
|
2421
2440
|
}
|
|
2422
2441
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
const
|
|
2441
|
-
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
if (
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2442
|
+
flush();
|
|
2443
|
+
return out.filter((p) => p.every(Number.isFinite));
|
|
2444
|
+
}
|
|
2445
|
+
function flatBounds(flat) {
|
|
2446
|
+
let x0 = Infinity;
|
|
2447
|
+
let y0 = Infinity;
|
|
2448
|
+
let x1 = -Infinity;
|
|
2449
|
+
let y1 = -Infinity;
|
|
2450
|
+
for (const p of flat) {
|
|
2451
|
+
for (let i = 0; i < p.length; i += 2) {
|
|
2452
|
+
if (p[i] < x0) x0 = p[i];
|
|
2453
|
+
if (p[i] > x1) x1 = p[i];
|
|
2454
|
+
if (p[i + 1] < y0) y0 = p[i + 1];
|
|
2455
|
+
if (p[i + 1] > y1) y1 = p[i + 1];
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
if (x0 === Infinity) return null;
|
|
2459
|
+
const x = Math.floor(x0);
|
|
2460
|
+
const y = Math.floor(y0);
|
|
2461
|
+
return { x, y, width: Math.ceil(x1) - x, height: Math.ceil(y1) - y };
|
|
2462
|
+
}
|
|
2463
|
+
function drawLine(a, w, h, x0, y0, x1, y1) {
|
|
2464
|
+
if (y0 === y1) return;
|
|
2465
|
+
let dir = 1;
|
|
2466
|
+
if (y0 > y1) {
|
|
2467
|
+
dir = -1;
|
|
2468
|
+
let t = x0;
|
|
2469
|
+
x0 = x1;
|
|
2470
|
+
x1 = t;
|
|
2471
|
+
t = y0;
|
|
2472
|
+
y0 = y1;
|
|
2473
|
+
y1 = t;
|
|
2474
|
+
}
|
|
2475
|
+
if (y1 <= 0 || y0 >= h) return;
|
|
2476
|
+
const dxdy = (x1 - x0) / (y1 - y0);
|
|
2477
|
+
let x = x0;
|
|
2478
|
+
if (y0 < 0) x -= y0 * dxdy;
|
|
2479
|
+
const rowStart = Math.max(0, Math.floor(y0));
|
|
2480
|
+
const rowEnd = Math.min(h, Math.ceil(y1));
|
|
2481
|
+
for (let y = rowStart; y < rowEnd; y++) {
|
|
2482
|
+
const line = y * w;
|
|
2483
|
+
const dy = Math.min(y + 1, y1) - Math.max(y, y0);
|
|
2484
|
+
const xnext = x + dxdy * dy;
|
|
2485
|
+
const d = dy * dir;
|
|
2486
|
+
const xa = x < xnext ? x : xnext;
|
|
2487
|
+
const xb = x < xnext ? xnext : x;
|
|
2488
|
+
const xaFloor = Math.floor(xa);
|
|
2489
|
+
const xai = xaFloor;
|
|
2490
|
+
const xbCeil = Math.ceil(xb);
|
|
2491
|
+
const xbi = xbCeil;
|
|
2492
|
+
if (xbi <= xai + 1) {
|
|
2493
|
+
const xmf = 0.5 * (x + xnext) - xaFloor;
|
|
2494
|
+
a[line + xai] += d - d * xmf;
|
|
2495
|
+
a[line + xai + 1] += d * xmf;
|
|
2496
|
+
} else {
|
|
2497
|
+
const s = 1 / (xb - xa);
|
|
2498
|
+
const xaf = xa - xaFloor;
|
|
2499
|
+
const a0 = 0.5 * s * (1 - xaf) * (1 - xaf);
|
|
2500
|
+
const xbf = xb - xbCeil + 1;
|
|
2501
|
+
const am = 0.5 * s * xbf * xbf;
|
|
2502
|
+
a[line + xai] += d * a0;
|
|
2503
|
+
if (xbi === xai + 2) a[line + xai + 1] += d * (1 - a0 - am);
|
|
2504
|
+
else {
|
|
2505
|
+
const a1 = s * (1.5 - xaf);
|
|
2506
|
+
a[line + xai + 1] += d * (a1 - a0);
|
|
2507
|
+
for (let xi = xai + 2; xi < xbi - 1; xi++) a[line + xi] += d * s;
|
|
2508
|
+
const a2 = a1 + (xbi - xai - 3) * s;
|
|
2509
|
+
a[line + xbi - 1] += d * (1 - a2 - am);
|
|
2510
|
+
}
|
|
2511
|
+
a[line + xbi] += d * am;
|
|
2512
|
+
}
|
|
2513
|
+
x = xnext;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
function drawClippedLine(a, w, h, x0, y0, x1, y1) {
|
|
2517
|
+
if (y0 === y1) return;
|
|
2518
|
+
if (y0 <= 0 && y1 <= 0 || y0 >= h && y1 >= h) return;
|
|
2519
|
+
if (x0 >= 0 && x0 <= w && x1 >= 0 && x1 <= w) return drawLine(a, w, h, x0, y0, x1, y1);
|
|
2520
|
+
const ts = [0, 1];
|
|
2521
|
+
const dx = x1 - x0;
|
|
2522
|
+
if (dx !== 0) {
|
|
2523
|
+
for (const edge of [0, w]) {
|
|
2524
|
+
const t = (edge - x0) / dx;
|
|
2525
|
+
if (t > 0 && t < 1) ts.push(t);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
ts.sort((p, q2) => p - q2);
|
|
2529
|
+
const clamp4 = (v) => v < 0 ? 0 : v > w ? w : v;
|
|
2530
|
+
for (let i = 0; i + 1 < ts.length; i++) {
|
|
2531
|
+
const ta = ts[i];
|
|
2532
|
+
const tb = ts[i + 1];
|
|
2533
|
+
drawLine(a, w, h, clamp4(x0 + dx * ta), y0 + (y1 - y0) * ta, clamp4(x0 + dx * tb), y0 + (y1 - y0) * tb);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
function ruleCoverage(v, rule) {
|
|
2537
|
+
const m = v < 0 ? -v : v;
|
|
2538
|
+
if (rule === "nonzero") return m >= 1 ? 1 : m;
|
|
2539
|
+
const f = m % 2;
|
|
2540
|
+
return f > 1 ? 2 - f : f;
|
|
2541
|
+
}
|
|
2542
|
+
function rasterizeCoverage(flat, rect, rule = "nonzero") {
|
|
2543
|
+
const w = rect.width;
|
|
2544
|
+
const h = rect.height;
|
|
2545
|
+
if (w <= 0 || h <= 0 || !flat.length) return null;
|
|
2546
|
+
const a = new Float64Array(w * h + w + 4);
|
|
2547
|
+
const ox = rect.x;
|
|
2548
|
+
const oy = rect.y;
|
|
2549
|
+
let touched = false;
|
|
2550
|
+
for (const p of flat) {
|
|
2551
|
+
const n = p.length;
|
|
2552
|
+
for (let i = 0; i < n; i += 2) {
|
|
2553
|
+
const j = i + 2 < n ? i + 2 : 0;
|
|
2554
|
+
const ya = p[i + 1] - oy;
|
|
2555
|
+
const yb = p[j + 1] - oy;
|
|
2556
|
+
if (ya <= 0 && yb <= 0 || ya >= h && yb >= h || ya === yb) continue;
|
|
2557
|
+
drawClippedLine(a, w, h, p[i] - ox, ya, p[j] - ox, yb);
|
|
2558
|
+
touched = true;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
if (!touched) return null;
|
|
2562
|
+
const out = new Float32Array(w * h);
|
|
2563
|
+
let acc = 0;
|
|
2564
|
+
let any = false;
|
|
2565
|
+
for (let i = 0; i < out.length; i++) {
|
|
2566
|
+
acc += a[i];
|
|
2567
|
+
const c = ruleCoverage(acc, rule);
|
|
2568
|
+
if (c > 1e-6) {
|
|
2569
|
+
out[i] = c;
|
|
2570
|
+
any = true;
|
|
2571
|
+
}
|
|
2451
2572
|
}
|
|
2452
|
-
|
|
2453
|
-
const sxAbs = Math.hypot(a, b);
|
|
2454
|
-
const rot = Math.atan2(b, a) * 180 / Math.PI;
|
|
2455
|
-
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
2456
|
-
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
2457
|
-
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
2458
|
-
const at = _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, ref);
|
|
2459
|
-
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
2460
|
-
return {
|
|
2461
|
-
affine: true,
|
|
2462
|
-
scaleX: clean(sxAbs * 100),
|
|
2463
|
-
scaleY: clean(sy * 100),
|
|
2464
|
-
rotate: clean(rot === -180 ? 180 : rot),
|
|
2465
|
-
skewX: clean(skew),
|
|
2466
|
-
x: at.x,
|
|
2467
|
-
y: at.y,
|
|
2468
|
-
bounds,
|
|
2469
|
-
corners: geometry.corners
|
|
2470
|
-
};
|
|
2471
|
-
}
|
|
2472
|
-
function applyParams(geometry, params) {
|
|
2473
|
-
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
2474
|
-
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
2475
|
-
const c = geometry.corners;
|
|
2476
|
-
return [_chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[0]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[1]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[2]), _chunkDWGZUSEScjs.applyMatrix.call(void 0, m, c[3])];
|
|
2573
|
+
return any ? out : null;
|
|
2477
2574
|
}
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
const
|
|
2481
|
-
const
|
|
2482
|
-
|
|
2575
|
+
var SUB_ROWS = 16;
|
|
2576
|
+
function rasterizeCoverageSampled(flat, rect, rule = "nonzero") {
|
|
2577
|
+
const w = rect.width;
|
|
2578
|
+
const h = rect.height;
|
|
2579
|
+
if (w <= 0 || h <= 0 || !flat.length) return null;
|
|
2580
|
+
let n = 0;
|
|
2581
|
+
for (const p of flat) n += p.length >> 1;
|
|
2582
|
+
const ey0 = new Float64Array(n);
|
|
2583
|
+
const ey1 = new Float64Array(n);
|
|
2584
|
+
const ex0 = new Float64Array(n);
|
|
2585
|
+
const eslope = new Float64Array(n);
|
|
2586
|
+
const edir = new Int8Array(n);
|
|
2587
|
+
let count = 0;
|
|
2588
|
+
for (const p of flat) {
|
|
2589
|
+
const len = p.length;
|
|
2590
|
+
for (let i = 0; i < len; i += 2) {
|
|
2591
|
+
const j = i + 2 < len ? i + 2 : 0;
|
|
2592
|
+
let xa = p[i] - rect.x;
|
|
2593
|
+
let ya = p[i + 1] - rect.y;
|
|
2594
|
+
let xb = p[j] - rect.x;
|
|
2595
|
+
let yb = p[j + 1] - rect.y;
|
|
2596
|
+
if (ya === yb) continue;
|
|
2597
|
+
let dir = 1;
|
|
2598
|
+
if (ya > yb) {
|
|
2599
|
+
dir = -1;
|
|
2600
|
+
let t = xa;
|
|
2601
|
+
xa = xb;
|
|
2602
|
+
xb = t;
|
|
2603
|
+
t = ya;
|
|
2604
|
+
ya = yb;
|
|
2605
|
+
yb = t;
|
|
2606
|
+
}
|
|
2607
|
+
if (yb <= 0 || ya >= h) continue;
|
|
2608
|
+
ey0[count] = ya;
|
|
2609
|
+
ey1[count] = yb;
|
|
2610
|
+
ex0[count] = xa;
|
|
2611
|
+
eslope[count] = (xb - xa) / (yb - ya);
|
|
2612
|
+
edir[count] = dir;
|
|
2613
|
+
count++;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
if (!count) return null;
|
|
2617
|
+
const order = Array.from({ length: count }, (_, i) => i).sort((a, b) => ey0[a] - ey0[b]);
|
|
2618
|
+
const out = new Float32Array(w * h);
|
|
2619
|
+
const diff = new Float32Array(w + 1);
|
|
2620
|
+
let active = [];
|
|
2621
|
+
let next = 0;
|
|
2622
|
+
const xs = [];
|
|
2623
|
+
const ds = [];
|
|
2624
|
+
const idx = [];
|
|
2625
|
+
const f = 1 / SUB_ROWS;
|
|
2626
|
+
let any = false;
|
|
2627
|
+
const firstRow = Math.max(0, Math.floor(ey0[order[0]]));
|
|
2628
|
+
for (let y = firstRow; y < h; y++) {
|
|
2629
|
+
if (next >= count && !active.length) break;
|
|
2630
|
+
const row = y * w;
|
|
2631
|
+
let rowTouched = false;
|
|
2632
|
+
for (let s = 0; s < SUB_ROWS; s++) {
|
|
2633
|
+
const sy = y + (s + 0.5) * f;
|
|
2634
|
+
while (next < count && ey0[order[next]] <= sy) active.push(order[next++]);
|
|
2635
|
+
if (!active.length) continue;
|
|
2636
|
+
active = active.filter((e) => ey1[e] > sy);
|
|
2637
|
+
xs.length = 0;
|
|
2638
|
+
ds.length = 0;
|
|
2639
|
+
idx.length = 0;
|
|
2640
|
+
for (const e of active) {
|
|
2641
|
+
if (ey0[e] > sy) continue;
|
|
2642
|
+
idx.push(xs.length);
|
|
2643
|
+
xs.push(ex0[e] + (sy - ey0[e]) * eslope[e]);
|
|
2644
|
+
ds.push(edir[e]);
|
|
2645
|
+
}
|
|
2646
|
+
if (xs.length < 2) continue;
|
|
2647
|
+
idx.sort((a, b) => xs[a] - xs[b]);
|
|
2648
|
+
let wind = 0;
|
|
2649
|
+
for (let k = 0; k + 1 < idx.length; k++) {
|
|
2650
|
+
wind += ds[idx[k]];
|
|
2651
|
+
const inside = rule === "nonzero" ? wind !== 0 : (wind & 1) !== 0;
|
|
2652
|
+
if (!inside) continue;
|
|
2653
|
+
let xa = xs[idx[k]];
|
|
2654
|
+
let xb = xs[idx[k + 1]];
|
|
2655
|
+
if (xb <= 0 || xa >= w || xb <= xa) continue;
|
|
2656
|
+
if (xa < 0) xa = 0;
|
|
2657
|
+
if (xb > w) xb = w;
|
|
2658
|
+
const ia = Math.floor(xa);
|
|
2659
|
+
const ib = Math.floor(xb);
|
|
2660
|
+
rowTouched = true;
|
|
2661
|
+
if (ia === ib) {
|
|
2662
|
+
out[row + ia] += (xb - xa) * f;
|
|
2663
|
+
continue;
|
|
2664
|
+
}
|
|
2665
|
+
out[row + ia] += (ia + 1 - xa) * f;
|
|
2666
|
+
diff[ia + 1] += f;
|
|
2667
|
+
diff[ib] -= f;
|
|
2668
|
+
if (ib < w) out[row + ib] += (xb - ib) * f;
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
if (!rowTouched) continue;
|
|
2672
|
+
let run = 0;
|
|
2673
|
+
for (let x = 0; x < w; x++) {
|
|
2674
|
+
run += diff[x];
|
|
2675
|
+
diff[x] = 0;
|
|
2676
|
+
const v = out[row + x] + run;
|
|
2677
|
+
out[row + x] = v > 1 ? 1 : v < 1e-6 ? 0 : v;
|
|
2678
|
+
if (out[row + x] > 0) any = true;
|
|
2679
|
+
}
|
|
2680
|
+
diff[w] = 0;
|
|
2681
|
+
}
|
|
2682
|
+
return any ? out : null;
|
|
2683
|
+
}
|
|
2684
|
+
function combineCoverage(a, b, op, n) {
|
|
2685
|
+
if (op === "combine") {
|
|
2686
|
+
if (!a) return b;
|
|
2687
|
+
if (!b) return a;
|
|
2688
|
+
const out2 = new Float32Array(n);
|
|
2689
|
+
for (let i = 0; i < n; i++) out2[i] = a[i] + b[i] - a[i] * b[i];
|
|
2690
|
+
return out2;
|
|
2691
|
+
}
|
|
2692
|
+
if (op === "subtract") {
|
|
2693
|
+
if (!a || !b) return a;
|
|
2694
|
+
const out2 = new Float32Array(n);
|
|
2695
|
+
for (let i = 0; i < n; i++) out2[i] = a[i] * (1 - b[i]);
|
|
2696
|
+
return out2;
|
|
2697
|
+
}
|
|
2698
|
+
if (op === "intersect") {
|
|
2699
|
+
if (!a || !b) return null;
|
|
2700
|
+
const out2 = new Float32Array(n);
|
|
2701
|
+
for (let i = 0; i < n; i++) out2[i] = a[i] * b[i];
|
|
2702
|
+
return out2;
|
|
2703
|
+
}
|
|
2704
|
+
if (!a) return b;
|
|
2705
|
+
if (!b) return a;
|
|
2706
|
+
const out = new Float32Array(n);
|
|
2707
|
+
for (let i = 0; i < n; i++) out[i] = a[i] + b[i] - 2 * a[i] * b[i];
|
|
2708
|
+
return out;
|
|
2483
2709
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2710
|
+
|
|
2711
|
+
// src/image-editor/layers/css-color.ts
|
|
2712
|
+
var NAMED = {
|
|
2713
|
+
aliceblue: "f0f8ff",
|
|
2714
|
+
antiquewhite: "faebd7",
|
|
2715
|
+
aqua: "00ffff",
|
|
2716
|
+
aquamarine: "7fffd4",
|
|
2717
|
+
azure: "f0ffff",
|
|
2718
|
+
beige: "f5f5dc",
|
|
2719
|
+
bisque: "ffe4c4",
|
|
2720
|
+
black: "000000",
|
|
2721
|
+
blanchedalmond: "ffebcd",
|
|
2722
|
+
blue: "0000ff",
|
|
2723
|
+
blueviolet: "8a2be2",
|
|
2724
|
+
brown: "a52a2a",
|
|
2725
|
+
burlywood: "deb887",
|
|
2726
|
+
cadetblue: "5f9ea0",
|
|
2727
|
+
chartreuse: "7fff00",
|
|
2728
|
+
chocolate: "d2691e",
|
|
2729
|
+
coral: "ff7f50",
|
|
2730
|
+
cornflowerblue: "6495ed",
|
|
2731
|
+
cornsilk: "fff8dc",
|
|
2732
|
+
crimson: "dc143c",
|
|
2733
|
+
cyan: "00ffff",
|
|
2734
|
+
darkblue: "00008b",
|
|
2735
|
+
darkcyan: "008b8b",
|
|
2736
|
+
darkgoldenrod: "b8860b",
|
|
2737
|
+
darkgray: "a9a9a9",
|
|
2738
|
+
darkgreen: "006400",
|
|
2739
|
+
darkgrey: "a9a9a9",
|
|
2740
|
+
darkkhaki: "bdb76b",
|
|
2741
|
+
darkmagenta: "8b008b",
|
|
2742
|
+
darkolivegreen: "556b2f",
|
|
2743
|
+
darkorange: "ff8c00",
|
|
2744
|
+
darkorchid: "9932cc",
|
|
2745
|
+
darkred: "8b0000",
|
|
2746
|
+
darksalmon: "e9967a",
|
|
2747
|
+
darkseagreen: "8fbc8f",
|
|
2748
|
+
darkslateblue: "483d8b",
|
|
2749
|
+
darkslategray: "2f4f4f",
|
|
2750
|
+
darkslategrey: "2f4f4f",
|
|
2751
|
+
darkturquoise: "00ced1",
|
|
2752
|
+
darkviolet: "9400d3",
|
|
2753
|
+
deeppink: "ff1493",
|
|
2754
|
+
deepskyblue: "00bfff",
|
|
2755
|
+
dimgray: "696969",
|
|
2756
|
+
dimgrey: "696969",
|
|
2757
|
+
dodgerblue: "1e90ff",
|
|
2758
|
+
firebrick: "b22222",
|
|
2759
|
+
floralwhite: "fffaf0",
|
|
2760
|
+
forestgreen: "228b22",
|
|
2761
|
+
fuchsia: "ff00ff",
|
|
2762
|
+
gainsboro: "dcdcdc",
|
|
2763
|
+
ghostwhite: "f8f8ff",
|
|
2764
|
+
gold: "ffd700",
|
|
2765
|
+
goldenrod: "daa520",
|
|
2766
|
+
gray: "808080",
|
|
2767
|
+
green: "008000",
|
|
2768
|
+
greenyellow: "adff2f",
|
|
2769
|
+
grey: "808080",
|
|
2770
|
+
honeydew: "f0fff0",
|
|
2771
|
+
hotpink: "ff69b4",
|
|
2772
|
+
indianred: "cd5c5c",
|
|
2773
|
+
indigo: "4b0082",
|
|
2774
|
+
ivory: "fffff0",
|
|
2775
|
+
khaki: "f0e68c",
|
|
2776
|
+
lavender: "e6e6fa",
|
|
2777
|
+
lavenderblush: "fff0f5",
|
|
2778
|
+
lawngreen: "7cfc00",
|
|
2779
|
+
lemonchiffon: "fffacd",
|
|
2780
|
+
lightblue: "add8e6",
|
|
2781
|
+
lightcoral: "f08080",
|
|
2782
|
+
lightcyan: "e0ffff",
|
|
2783
|
+
lightgoldenrodyellow: "fafad2",
|
|
2784
|
+
lightgray: "d3d3d3",
|
|
2785
|
+
lightgreen: "90ee90",
|
|
2786
|
+
lightgrey: "d3d3d3",
|
|
2787
|
+
lightpink: "ffb6c1",
|
|
2788
|
+
lightsalmon: "ffa07a",
|
|
2789
|
+
lightseagreen: "20b2aa",
|
|
2790
|
+
lightskyblue: "87cefa",
|
|
2791
|
+
lightslategray: "778899",
|
|
2792
|
+
lightslategrey: "778899",
|
|
2793
|
+
lightsteelblue: "b0c4de",
|
|
2794
|
+
lightyellow: "ffffe0",
|
|
2795
|
+
lime: "00ff00",
|
|
2796
|
+
limegreen: "32cd32",
|
|
2797
|
+
linen: "faf0e6",
|
|
2798
|
+
magenta: "ff00ff",
|
|
2799
|
+
maroon: "800000",
|
|
2800
|
+
mediumaquamarine: "66cdaa",
|
|
2801
|
+
mediumblue: "0000cd",
|
|
2802
|
+
mediumorchid: "ba55d3",
|
|
2803
|
+
mediumpurple: "9370db",
|
|
2804
|
+
mediumseagreen: "3cb371",
|
|
2805
|
+
mediumslateblue: "7b68ee",
|
|
2806
|
+
mediumspringgreen: "00fa9a",
|
|
2807
|
+
mediumturquoise: "48d1cc",
|
|
2808
|
+
mediumvioletred: "c71585",
|
|
2809
|
+
midnightblue: "191970",
|
|
2810
|
+
mintcream: "f5fffa",
|
|
2811
|
+
mistyrose: "ffe4e1",
|
|
2812
|
+
moccasin: "ffe4b5",
|
|
2813
|
+
navajowhite: "ffdead",
|
|
2814
|
+
navy: "000080",
|
|
2815
|
+
oldlace: "fdf5e6",
|
|
2816
|
+
olive: "808000",
|
|
2817
|
+
olivedrab: "6b8e23",
|
|
2818
|
+
orange: "ffa500",
|
|
2819
|
+
orangered: "ff4500",
|
|
2820
|
+
orchid: "da70d6",
|
|
2821
|
+
palegoldenrod: "eee8aa",
|
|
2822
|
+
palegreen: "98fb98",
|
|
2823
|
+
paleturquoise: "afeeee",
|
|
2824
|
+
palevioletred: "db7093",
|
|
2825
|
+
papayawhip: "ffefd5",
|
|
2826
|
+
peachpuff: "ffdab9",
|
|
2827
|
+
peru: "cd853f",
|
|
2828
|
+
pink: "ffc0cb",
|
|
2829
|
+
plum: "dda0dd",
|
|
2830
|
+
powderblue: "b0e0e6",
|
|
2831
|
+
purple: "800080",
|
|
2832
|
+
rebeccapurple: "663399",
|
|
2833
|
+
red: "ff0000",
|
|
2834
|
+
rosybrown: "bc8f8f",
|
|
2835
|
+
royalblue: "4169e1",
|
|
2836
|
+
saddlebrown: "8b4513",
|
|
2837
|
+
salmon: "fa8072",
|
|
2838
|
+
sandybrown: "f4a460",
|
|
2839
|
+
seagreen: "2e8b57",
|
|
2840
|
+
seashell: "fff5ee",
|
|
2841
|
+
sienna: "a0522d",
|
|
2842
|
+
silver: "c0c0c0",
|
|
2843
|
+
skyblue: "87ceeb",
|
|
2844
|
+
slateblue: "6a5acd",
|
|
2845
|
+
slategray: "708090",
|
|
2846
|
+
slategrey: "708090",
|
|
2847
|
+
snow: "fffafa",
|
|
2848
|
+
springgreen: "00ff7f",
|
|
2849
|
+
steelblue: "4682b4",
|
|
2850
|
+
tan: "d2b48c",
|
|
2851
|
+
teal: "008080",
|
|
2852
|
+
thistle: "d8bfd8",
|
|
2853
|
+
tomato: "ff6347",
|
|
2854
|
+
turquoise: "40e0d0",
|
|
2855
|
+
violet: "ee82ee",
|
|
2856
|
+
wheat: "f5deb3",
|
|
2857
|
+
white: "ffffff",
|
|
2858
|
+
whitesmoke: "f5f5f5",
|
|
2859
|
+
yellow: "ffff00",
|
|
2860
|
+
yellowgreen: "9acd32"
|
|
2861
|
+
};
|
|
2862
|
+
var hex2 = (v) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
|
|
2863
|
+
function channel(s) {
|
|
2864
|
+
return s.endsWith("%") ? parseFloat(s) / 100 * 255 : parseFloat(s);
|
|
2865
|
+
}
|
|
2866
|
+
function alphaOf(s) {
|
|
2867
|
+
if (s === void 0) return 1;
|
|
2868
|
+
const v = s.endsWith("%") ? parseFloat(s) / 100 : parseFloat(s);
|
|
2869
|
+
return Math.max(0, Math.min(1, v));
|
|
2870
|
+
}
|
|
2871
|
+
function hslToRgb2(h, s, l) {
|
|
2872
|
+
h = (h % 360 + 360) % 360;
|
|
2873
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
2874
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
2875
|
+
const m = l - c / 2;
|
|
2876
|
+
const [r, g, b] = h < 60 ? [c, x, 0] : h < 120 ? [x, c, 0] : h < 180 ? [0, c, x] : h < 240 ? [0, x, c] : h < 300 ? [x, 0, c] : [c, 0, x];
|
|
2877
|
+
return [(r + m) * 255, (g + m) * 255, (b + m) * 255];
|
|
2878
|
+
}
|
|
2879
|
+
function parseCssColor(value) {
|
|
2880
|
+
if (typeof value !== "string") return null;
|
|
2881
|
+
const text3 = value.trim().toLowerCase();
|
|
2882
|
+
if (text3 === "transparent") return { hex: "#000000", alpha: 0 };
|
|
2883
|
+
const named = NAMED[text3];
|
|
2884
|
+
if (named) return { hex: `#${named}`, alpha: 1 };
|
|
2885
|
+
let m = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(text3);
|
|
2886
|
+
if (m) {
|
|
2887
|
+
let h = m[1];
|
|
2888
|
+
if (h.length <= 4) h = h.replace(/./g, (c) => c + c);
|
|
2889
|
+
return { hex: `#${h.slice(0, 6)}`, alpha: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1 };
|
|
2890
|
+
}
|
|
2891
|
+
const num3 = "([+-]?[\\d.]+%?)";
|
|
2892
|
+
m = new RegExp(`^rgba?\\(\\s*${num3}[\\s,]+${num3}[\\s,]+${num3}(?:\\s*[,/]\\s*${num3})?\\s*\\)$`).exec(text3);
|
|
2893
|
+
if (m) {
|
|
2894
|
+
const rgb = [m[1], m[2], m[3]].map(channel);
|
|
2895
|
+
if (!rgb.every(Number.isFinite)) return null;
|
|
2896
|
+
return { hex: `#${rgb.map(hex2).join("")}`, alpha: alphaOf(m[4]) };
|
|
2897
|
+
}
|
|
2898
|
+
m = new RegExp(`^hsla?\\(\\s*([+-]?[\\d.]+)(?:deg)?[\\s,]+${num3}[\\s,]+${num3}(?:\\s*[,/]\\s*${num3})?\\s*\\)$`).exec(text3);
|
|
2899
|
+
if (m) {
|
|
2900
|
+
const rgb = hslToRgb2(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
|
|
2901
|
+
if (!rgb.every(Number.isFinite)) return null;
|
|
2902
|
+
return { hex: `#${rgb.map(hex2).join("")}`, alpha: alphaOf(m[4]) };
|
|
2903
|
+
}
|
|
2487
2904
|
return null;
|
|
2488
2905
|
}
|
|
2489
|
-
function presetWarp(box, preset) {
|
|
2490
|
-
return _chunkDWGZUSEScjs.warpPresetMesh.call(void 0, preset, box);
|
|
2491
|
-
}
|
|
2492
|
-
function isValidWarp(mesh) {
|
|
2493
|
-
return _chunkDWGZUSEScjs.isValidWarpMesh.call(void 0, mesh);
|
|
2494
|
-
}
|
|
2495
|
-
function geometryHomography(geometry) {
|
|
2496
|
-
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
2497
|
-
return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
|
|
2498
|
-
}
|
|
2499
2906
|
|
|
2500
2907
|
// src/image-editor/layers/ops.ts
|
|
2501
2908
|
var LayerOperationError = class extends Error {
|
|
@@ -2508,53 +2915,54 @@ var fail = (message) => {
|
|
|
2508
2915
|
throw new LayerOperationError(message);
|
|
2509
2916
|
};
|
|
2510
2917
|
function requireLayer(layers, id) {
|
|
2511
|
-
const loc =
|
|
2918
|
+
const loc = _chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id);
|
|
2512
2919
|
if (!loc) {
|
|
2513
|
-
const ids =
|
|
2920
|
+
const ids = _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
|
|
2514
2921
|
fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
|
|
2515
2922
|
}
|
|
2516
2923
|
return loc;
|
|
2517
2924
|
}
|
|
2518
2925
|
function requireUnlocked(layer, what, action) {
|
|
2519
|
-
if (
|
|
2520
|
-
if (what !== "all" &&
|
|
2926
|
+
if (_chunkPOGBUYWEcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
|
|
2927
|
+
if (what !== "all" && _chunkPOGBUYWEcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
|
|
2521
2928
|
}
|
|
2522
2929
|
function placeLayer(layers, layer, placement = {}, defaultIndex) {
|
|
2523
2930
|
const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
|
|
2524
2931
|
if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
|
|
2525
2932
|
if (placement.aboveId || placement.belowId) {
|
|
2526
2933
|
const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
|
|
2527
|
-
return
|
|
2934
|
+
return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _19 => _19.parent, 'optionalAccess', _20 => _20.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
|
|
2528
2935
|
}
|
|
2529
2936
|
if (placement.parentId) {
|
|
2530
2937
|
const ref = requireLayer(layers, placement.parentId);
|
|
2531
2938
|
if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
|
|
2532
|
-
return
|
|
2939
|
+
return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
|
|
2533
2940
|
}
|
|
2534
|
-
return
|
|
2941
|
+
return _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
|
|
2535
2942
|
}
|
|
2536
2943
|
function removeLayer(layers, id) {
|
|
2537
2944
|
const loc = requireLayer(layers, id);
|
|
2538
2945
|
requireUnlocked(loc.layer, "all", "delete it");
|
|
2539
|
-
return
|
|
2946
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
2540
2947
|
}
|
|
2541
2948
|
function moveLayer(layers, id, placement) {
|
|
2542
2949
|
const loc = requireLayer(layers, id);
|
|
2543
2950
|
requireUnlocked(loc.layer, "all", "move it");
|
|
2544
2951
|
const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
|
|
2545
2952
|
if (target === id) fail("A layer cannot be placed relative to itself.");
|
|
2546
|
-
if (target && loc.layer.type === "group" &&
|
|
2953
|
+
if (target && loc.layer.type === "group" && _chunkPOGBUYWEcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
|
|
2547
2954
|
fail(`Group "${id}" cannot be moved into its own child "${target}".`);
|
|
2548
2955
|
}
|
|
2549
2956
|
if (target) requireLayer(layers, target);
|
|
2550
2957
|
if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
|
|
2551
|
-
const without =
|
|
2958
|
+
const without = _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
2552
2959
|
return placeLayer(without, loc.layer, placement);
|
|
2553
2960
|
}
|
|
2554
2961
|
function withNewIds(layer) {
|
|
2555
2962
|
const next = { ...layer, id: newLayerId(layer.type === "adjustment" ? "adj" : layer.type) };
|
|
2556
2963
|
if (next.type === "group") next.children = next.children.map(withNewIds);
|
|
2557
2964
|
if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
|
|
2965
|
+
if (next.type === "shape") delete next.annotation;
|
|
2558
2966
|
if (next.type === "smart" && _optionalChain([next, 'access', _21 => _21.psd, 'optionalAccess', _22 => _22.placed])) {
|
|
2559
2967
|
next.psd = { ...next.psd };
|
|
2560
2968
|
delete next.psd.placed;
|
|
@@ -2566,7 +2974,7 @@ function duplicateLayer(layers, id, name) {
|
|
|
2566
2974
|
const copy = withNewIds(loc.layer);
|
|
2567
2975
|
copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
|
|
2568
2976
|
delete copy.locks;
|
|
2569
|
-
return { layers:
|
|
2977
|
+
return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _23 => _23.parent, 'optionalAccess', _24 => _24.id]), () => ( null)), loc.index + 1), id: copy.id };
|
|
2570
2978
|
}
|
|
2571
2979
|
function setLayerProperties(layers, id, props) {
|
|
2572
2980
|
const loc = requireLayer(layers, id);
|
|
@@ -2584,7 +2992,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
2584
2992
|
next.opacity = props.opacity;
|
|
2585
2993
|
}
|
|
2586
2994
|
if (props.fillOpacity !== void 0) {
|
|
2587
|
-
if (layer.type !== "pixel" && layer.type !== "smart") fail(`fillOpacity applies to pixel
|
|
2995
|
+
if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape") fail(`fillOpacity applies to pixel, shape and smart object layers; "${id}" is a ${layer.type} layer.`);
|
|
2588
2996
|
if (!(typeof props.fillOpacity === "number" && props.fillOpacity >= 0 && props.fillOpacity <= 1)) fail("fillOpacity must be a number from 0 to 1.");
|
|
2589
2997
|
const p = next;
|
|
2590
2998
|
if (props.fillOpacity === 1) delete p.fillOpacity;
|
|
@@ -2593,7 +3001,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
2593
3001
|
if (props.blend !== void 0) {
|
|
2594
3002
|
if (props.blend === "pass-through") {
|
|
2595
3003
|
if (layer.type !== "group") fail("pass-through is only for groups.");
|
|
2596
|
-
} else if (!
|
|
3004
|
+
} else if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
|
|
2597
3005
|
next.blend = props.blend;
|
|
2598
3006
|
}
|
|
2599
3007
|
if (props.clipped !== void 0) {
|
|
@@ -2613,7 +3021,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
2613
3021
|
if (props.collapsed) g.collapsed = true;
|
|
2614
3022
|
else delete g.collapsed;
|
|
2615
3023
|
}
|
|
2616
|
-
return
|
|
3024
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
2617
3025
|
}
|
|
2618
3026
|
function groupLayers(layers, ids, name = "Group") {
|
|
2619
3027
|
if (!ids.length) fail("Give at least one layer id to group.");
|
|
@@ -2642,17 +3050,17 @@ function groupLayers(layers, ids, name = "Group") {
|
|
|
2642
3050
|
group.children[0] = c;
|
|
2643
3051
|
}
|
|
2644
3052
|
let out = layers;
|
|
2645
|
-
for (const l of ordered) out =
|
|
2646
|
-
return { layers:
|
|
3053
|
+
for (const l of ordered) out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
3054
|
+
return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
|
|
2647
3055
|
}
|
|
2648
3056
|
function ungroupLayer(layers, id) {
|
|
2649
3057
|
const loc = requireLayer(layers, id);
|
|
2650
3058
|
if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
|
|
2651
3059
|
requireUnlocked(loc.layer, "all", "ungroup it");
|
|
2652
3060
|
const group = loc.layer;
|
|
2653
|
-
let out =
|
|
3061
|
+
let out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
2654
3062
|
group.children.forEach((c, i) => {
|
|
2655
|
-
out =
|
|
3063
|
+
out = _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _33 => _33.parent, 'optionalAccess', _34 => _34.id]), () => ( null)), loc.index + i);
|
|
2656
3064
|
});
|
|
2657
3065
|
return { layers: out, ids: group.children.map((c) => c.id) };
|
|
2658
3066
|
}
|
|
@@ -2665,14 +3073,14 @@ function offsetLayer(layers, id, offset) {
|
|
|
2665
3073
|
const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
|
|
2666
3074
|
const mask = layer.mask;
|
|
2667
3075
|
if (mask && mask.linked === false && !mask.source) {
|
|
2668
|
-
next.mask = { ...mask, surface:
|
|
3076
|
+
next.mask = { ...mask, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
|
|
2669
3077
|
}
|
|
2670
|
-
return
|
|
3078
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
2671
3079
|
}
|
|
2672
3080
|
function setLayerMask(layers, id, mask) {
|
|
2673
3081
|
const loc = requireLayer(layers, id);
|
|
2674
3082
|
requireUnlocked(loc.layer, "all", "change its mask");
|
|
2675
|
-
return
|
|
3083
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, (l) => {
|
|
2676
3084
|
const next = { ...l };
|
|
2677
3085
|
if (mask) next.mask = mask;
|
|
2678
3086
|
else delete next.mask;
|
|
@@ -2711,7 +3119,7 @@ function requirePixelLayer(layers, id) {
|
|
|
2711
3119
|
function addLayerFilter(layers, id, filter) {
|
|
2712
3120
|
const layer = requirePixelLayer(layers, id);
|
|
2713
3121
|
if (_optionalChain([layer, 'access', _35 => _35.filters, 'optionalAccess', _36 => _36.some, 'call', _37 => _37((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
|
|
2714
|
-
return
|
|
3122
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
|
|
2715
3123
|
}
|
|
2716
3124
|
function updateLayerFilter(layers, id, filterId, changes) {
|
|
2717
3125
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -2722,7 +3130,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
|
|
|
2722
3130
|
const merged = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
2723
3131
|
const filters = [...layer.filters];
|
|
2724
3132
|
filters[i] = merged;
|
|
2725
|
-
return
|
|
3133
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
|
|
2726
3134
|
}
|
|
2727
3135
|
function removeLayerFilter(layers, id, filterId) {
|
|
2728
3136
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -2731,98 +3139,1209 @@ function removeLayerFilter(layers, id, filterId) {
|
|
|
2731
3139
|
const next = { ...layer };
|
|
2732
3140
|
if (filters.length) next.filters = filters;
|
|
2733
3141
|
else delete next.filters;
|
|
2734
|
-
return
|
|
3142
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3143
|
+
}
|
|
3144
|
+
function requireEffectLayer(layers, id, action) {
|
|
3145
|
+
const layer = requireLayer(layers, id).layer;
|
|
3146
|
+
if (layer.type === "adjustment") fail(`Layer "${layer.name || id}" is an adjustment layer; effects go on pixel, annotation and group layers.`);
|
|
3147
|
+
requireUnlocked(layer, "all", action);
|
|
3148
|
+
return layer;
|
|
3149
|
+
}
|
|
3150
|
+
function layerEffectsOf(layer) {
|
|
3151
|
+
return _nullishCoalesce(layer.effects, () => ( { enabled: true, items: [] }));
|
|
3152
|
+
}
|
|
3153
|
+
function guard(fn) {
|
|
3154
|
+
try {
|
|
3155
|
+
return fn();
|
|
3156
|
+
} catch (e) {
|
|
3157
|
+
if (e instanceof _chunkPOGBUYWEcjs.LayerEffectError) fail(e.message);
|
|
3158
|
+
throw e;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
function setLayerEffects(layers, id, effects) {
|
|
3162
|
+
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3163
|
+
const next = { ...layer };
|
|
3164
|
+
if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
|
|
3165
|
+
guard(() => _chunkPOGBUYWEcjs.validateLayerEffects.call(void 0, effects));
|
|
3166
|
+
next.effects = effects;
|
|
3167
|
+
} else delete next.effects;
|
|
3168
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3169
|
+
}
|
|
3170
|
+
function addLayerEffect(layers, id, kind, params = {}, index) {
|
|
3171
|
+
if (!_chunkPOGBUYWEcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkPOGBUYWEcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
3172
|
+
const layer = requireEffectLayer(layers, id, "add effects");
|
|
3173
|
+
const current = layerEffectsOf(layer);
|
|
3174
|
+
const ids = new Set(current.items.map((e) => e.id));
|
|
3175
|
+
let effectId = _chunkPOGBUYWEcjs.newEffectId.call(void 0, );
|
|
3176
|
+
while (ids.has(effectId)) effectId = _chunkPOGBUYWEcjs.newEffectId.call(void 0, );
|
|
3177
|
+
const { id: _ignored, kind: _kind, ...rest } = params;
|
|
3178
|
+
const effect = guard(() => _chunkPOGBUYWEcjs.mergeLayerEffect.call(void 0, _chunkPOGBUYWEcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
|
|
3179
|
+
const items = [...current.items];
|
|
3180
|
+
const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
|
|
3181
|
+
items.splice(at, 0, effect);
|
|
3182
|
+
return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
|
|
3183
|
+
}
|
|
3184
|
+
function requireEffect(layer, effectId) {
|
|
3185
|
+
const items = _nullishCoalesce(_optionalChain([layer, 'access', _38 => _38.effects, 'optionalAccess', _39 => _39.items]), () => ( []));
|
|
3186
|
+
const i = items.findIndex((e) => e.id === effectId);
|
|
3187
|
+
if (i === -1) fail(`Layer "${layer.name || layer.id}" has no effect "${effectId}". Effects: ${items.map((e) => `${e.id} (${e.kind})`).join(", ") || "none"}; call list_layer_effects.`);
|
|
3188
|
+
return i;
|
|
3189
|
+
}
|
|
3190
|
+
function updateLayerEffect(layers, id, effectId, changes) {
|
|
3191
|
+
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3192
|
+
const i = requireEffect(layer, effectId);
|
|
3193
|
+
const current = layer.effects;
|
|
3194
|
+
const items = [...current.items];
|
|
3195
|
+
items[i] = guard(() => _chunkPOGBUYWEcjs.mergeLayerEffect.call(void 0, items[i], changes));
|
|
3196
|
+
return setLayerEffects(layers, id, { ...current, items });
|
|
3197
|
+
}
|
|
3198
|
+
function removeLayerEffect(layers, id, effectId) {
|
|
3199
|
+
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3200
|
+
requireEffect(layer, effectId);
|
|
3201
|
+
const current = layer.effects;
|
|
3202
|
+
return setLayerEffects(layers, id, { ...current, items: current.items.filter((e) => e.id !== effectId) });
|
|
3203
|
+
}
|
|
3204
|
+
function setLayerEffectsEnabled(layers, id, enabled, scale) {
|
|
3205
|
+
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3206
|
+
if (scale !== void 0 && !(Number.isFinite(scale) && scale >= 0.01 && scale <= 10)) fail(`scale must be from 0.01 to 10 (1 = 100 %), got ${scale}.`);
|
|
3207
|
+
const current = layerEffectsOf(layer);
|
|
3208
|
+
const next = { ...current, enabled };
|
|
3209
|
+
if (scale !== void 0) {
|
|
3210
|
+
if (scale === 1) delete next.scale;
|
|
3211
|
+
else next.scale = scale;
|
|
3212
|
+
}
|
|
3213
|
+
return setLayerEffects(layers, id, next);
|
|
3214
|
+
}
|
|
3215
|
+
function parseBlend(value, allowPassThrough = false) {
|
|
3216
|
+
if (value === void 0) return void 0;
|
|
3217
|
+
if (value === "pass-through" && allowPassThrough) return value;
|
|
3218
|
+
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
|
|
3219
|
+
return value;
|
|
3220
|
+
}
|
|
3221
|
+
function unionRect(a, b) {
|
|
3222
|
+
if (!a) return b;
|
|
3223
|
+
if (!b) return a;
|
|
3224
|
+
const x = Math.min(a.x, b.x);
|
|
3225
|
+
const y = Math.min(a.y, b.y);
|
|
3226
|
+
return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
// src/image-editor/layers/shape.ts
|
|
3230
|
+
var SHAPE_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
|
|
3231
|
+
var DEFAULT_MITER_LIMIT = 100;
|
|
3232
|
+
var fail2 = (message) => {
|
|
3233
|
+
throw new LayerOperationError(message);
|
|
3234
|
+
};
|
|
3235
|
+
var orientation = (anchors) => {
|
|
3236
|
+
let a = 0;
|
|
3237
|
+
for (let i = 0; i < anchors.length; i++) {
|
|
3238
|
+
const p = anchors[i];
|
|
3239
|
+
const q2 = anchors[(i + 1) % anchors.length];
|
|
3240
|
+
a += p.x * q2.y - q2.x * p.y;
|
|
3241
|
+
}
|
|
3242
|
+
return a;
|
|
3243
|
+
};
|
|
3244
|
+
function polygon(points) {
|
|
3245
|
+
const anchors = orientation(points) < 0 ? [...points].reverse() : points;
|
|
3246
|
+
return { closed: true, anchors: anchors.map((p) => ({ x: p.x, y: p.y })) };
|
|
3247
|
+
}
|
|
3248
|
+
function arrowheadPolygon(head, tip, dir) {
|
|
3249
|
+
const len = Math.max(0, head.length);
|
|
3250
|
+
const hw = Math.max(0, head.width) / 2;
|
|
3251
|
+
if (!(len > 0) || !(hw > 0)) return null;
|
|
3252
|
+
const n = { x: -dir.y, y: dir.x };
|
|
3253
|
+
const base = { x: tip.x - dir.x * len, y: tip.y - dir.y * len };
|
|
3254
|
+
const c = Math.max(-0.5, Math.min(0.5, _nullishCoalesce(head.concavity, () => ( 0))));
|
|
3255
|
+
const pts = [tip, { x: base.x + n.x * hw, y: base.y + n.y * hw }];
|
|
3256
|
+
if (c) pts.push({ x: base.x + dir.x * len * c, y: base.y + dir.y * len * c });
|
|
3257
|
+
pts.push({ x: base.x - n.x * hw, y: base.y - n.y * hw });
|
|
3258
|
+
return polygon(pts);
|
|
3259
|
+
}
|
|
3260
|
+
function mapAnchor(a, f) {
|
|
3261
|
+
const p = f(a);
|
|
3262
|
+
const out = { x: p.x, y: p.y };
|
|
3263
|
+
if (a.in) out.in = f(a.in);
|
|
3264
|
+
if (a.out) out.out = f(a.out);
|
|
3265
|
+
if (a.type) out.type = a.type;
|
|
3266
|
+
if (a.corner) out.corner = { ...a.corner };
|
|
3267
|
+
return out;
|
|
3268
|
+
}
|
|
3269
|
+
function mapSubpaths(subpaths, f) {
|
|
3270
|
+
return _chunkW3GXSUSQcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
|
|
3271
|
+
}
|
|
3272
|
+
function liveShapeSubpaths(live) {
|
|
3273
|
+
let out;
|
|
3274
|
+
switch (live.kind) {
|
|
3275
|
+
case "rect": {
|
|
3276
|
+
const x = Math.min(live.x, live.x + live.width);
|
|
3277
|
+
const y = Math.min(live.y, live.y + live.height);
|
|
3278
|
+
const sp = _chunkW3GXSUSQcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
|
|
3279
|
+
const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
|
|
3280
|
+
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkW3GXSUSQcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
|
|
3281
|
+
break;
|
|
3282
|
+
}
|
|
3283
|
+
case "ellipse":
|
|
3284
|
+
out = [_chunkW3GXSUSQcjs.ellipseSubpath.call(void 0, normBox(live))];
|
|
3285
|
+
break;
|
|
3286
|
+
case "polygon":
|
|
3287
|
+
out = [_chunkW3GXSUSQcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
|
|
3288
|
+
break;
|
|
3289
|
+
case "star":
|
|
3290
|
+
out = [_chunkW3GXSUSQcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
|
|
3291
|
+
break;
|
|
3292
|
+
case "line": {
|
|
3293
|
+
const a = { x: live.x1, y: live.y1 };
|
|
3294
|
+
const b = { x: live.x2, y: live.y2 };
|
|
3295
|
+
const len = Math.hypot(b.x - a.x, b.y - a.y);
|
|
3296
|
+
out = [];
|
|
3297
|
+
if (len > 0) {
|
|
3298
|
+
const d = { x: (b.x - a.x) / len, y: (b.y - a.y) / len };
|
|
3299
|
+
const hw = Math.max(0, live.weight) / 2;
|
|
3300
|
+
if (hw > 0) {
|
|
3301
|
+
const n = { x: -d.y * hw, y: d.x * hw };
|
|
3302
|
+
out.push(polygon([{ x: a.x + n.x, y: a.y + n.y }, { x: b.x + n.x, y: b.y + n.y }, { x: b.x - n.x, y: b.y - n.y }, { x: a.x - n.x, y: a.y - n.y }]));
|
|
3303
|
+
}
|
|
3304
|
+
const end = live.endArrow ? arrowheadPolygon(live.endArrow, b, d) : null;
|
|
3305
|
+
const start = live.startArrow ? arrowheadPolygon(live.startArrow, a, { x: -d.x, y: -d.y }) : null;
|
|
3306
|
+
if (start) out.push(start);
|
|
3307
|
+
if (end) out.push(end);
|
|
3308
|
+
}
|
|
3309
|
+
break;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
const m = live.transform;
|
|
3313
|
+
return m && !_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, p)) : out;
|
|
3314
|
+
}
|
|
3315
|
+
function normBox(b) {
|
|
3316
|
+
return { x: Math.min(b.x, b.x + b.width), y: Math.min(b.y, b.y + b.height), width: Math.abs(b.width), height: Math.abs(b.height) };
|
|
3317
|
+
}
|
|
3318
|
+
function liveComponent(live, op = "combine") {
|
|
3319
|
+
return { op, subpaths: liveShapeSubpaths(live), live };
|
|
3320
|
+
}
|
|
3321
|
+
var pathCache = /* @__PURE__ */ new WeakMap();
|
|
3322
|
+
function componentPath(c) {
|
|
3323
|
+
let p = pathCache.get(c.subpaths);
|
|
3324
|
+
if (!p) {
|
|
3325
|
+
p = _chunkW3GXSUSQcjs.subpathsToBezier.call(void 0, c.subpaths);
|
|
3326
|
+
pathCache.set(c.subpaths, p);
|
|
3327
|
+
}
|
|
3328
|
+
return p;
|
|
3329
|
+
}
|
|
3330
|
+
var BOOLEAN_OF = { combine: "union", subtract: "difference", intersect: "intersection", exclude: "xor" };
|
|
3331
|
+
var outlineCache = /* @__PURE__ */ new WeakMap();
|
|
3332
|
+
function shapeOutline(components, fillRule = "nonzero") {
|
|
3333
|
+
if (components.length === 1) return componentPath(components[0]);
|
|
3334
|
+
let byRule = outlineCache.get(components);
|
|
3335
|
+
if (!byRule) {
|
|
3336
|
+
byRule = /* @__PURE__ */ new Map();
|
|
3337
|
+
outlineCache.set(components, byRule);
|
|
3338
|
+
}
|
|
3339
|
+
const hit = byRule.get(fillRule);
|
|
3340
|
+
if (hit) return hit;
|
|
3341
|
+
let acc = [];
|
|
3342
|
+
components.forEach((c, i) => {
|
|
3343
|
+
const operand = { path: componentPath(c), fillRule };
|
|
3344
|
+
if (i === 0) acc = _chunkXGD3FSNCcjs.pathBoolean.call(void 0, "union", [operand]).path;
|
|
3345
|
+
else acc = _chunkXGD3FSNCcjs.pathBoolean.call(void 0, BOOLEAN_OF[c.op], [{ path: acc, fillRule: "nonzero" }, operand]).path;
|
|
3346
|
+
});
|
|
3347
|
+
byRule.set(fillRule, acc);
|
|
3348
|
+
return acc;
|
|
3349
|
+
}
|
|
3350
|
+
function shapeGeometryBounds(layer) {
|
|
3351
|
+
let b = null;
|
|
3352
|
+
for (const c of layer.components) {
|
|
3353
|
+
const cb = _chunkXGD3FSNCcjs.bezierPathBounds.call(void 0, componentPath(c));
|
|
3354
|
+
if (!cb) continue;
|
|
3355
|
+
b = b ? { minX: Math.min(b.minX, cb.minX), minY: Math.min(b.minY, cb.minY), maxX: Math.max(b.maxX, cb.maxX), maxY: Math.max(b.maxY, cb.maxY) } : cb;
|
|
3356
|
+
}
|
|
3357
|
+
return b ? { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY } : null;
|
|
3358
|
+
}
|
|
3359
|
+
function closedOutline(path) {
|
|
3360
|
+
let open = false;
|
|
3361
|
+
let inSub = false;
|
|
3362
|
+
for (const c of path) {
|
|
3363
|
+
if (c.type === "M") {
|
|
3364
|
+
if (inSub) open = true;
|
|
3365
|
+
inSub = true;
|
|
3366
|
+
} else if (c.type === "Z") inSub = false;
|
|
3367
|
+
}
|
|
3368
|
+
return !open && !inSub;
|
|
3369
|
+
}
|
|
3370
|
+
function strokeArea(path, stroke, double) {
|
|
3371
|
+
const w = stroke.width * (double ? 2 : 1);
|
|
3372
|
+
if (!(w > 0) || !path.length) return [];
|
|
3373
|
+
const dashes = _optionalChain([stroke, 'access', _40 => _40.dashes, 'optionalAccess', _41 => _41.length]) && stroke.dashes.some((d) => d > 0) ? stroke.dashes.map((d) => d * stroke.width) : void 0;
|
|
3374
|
+
const options = {
|
|
3375
|
+
width: w,
|
|
3376
|
+
cap: _nullishCoalesce(stroke.cap, () => ( "butt")),
|
|
3377
|
+
join: _nullishCoalesce(stroke.join, () => ( "miter")),
|
|
3378
|
+
miterLimit: _nullishCoalesce(stroke.miterLimit, () => ( DEFAULT_MITER_LIMIT)),
|
|
3379
|
+
...dashes ? { dash: dashes, dashOffset: (_nullishCoalesce(stroke.dashOffset, () => ( 0))) * stroke.width } : {}
|
|
3380
|
+
};
|
|
3381
|
+
const curved = path.some((c) => c.type === "C" || c.type === "Q");
|
|
3382
|
+
if (curved && path.length <= CLEAN_OUTLINE_LIMIT) {
|
|
3383
|
+
try {
|
|
3384
|
+
return _chunkXGD3FSNCcjs.outlineStroke.call(void 0, path, options);
|
|
3385
|
+
} catch (e3) {
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
return _chunkXGD3FSNCcjs.strokeOutlineRings.call(void 0, path, options);
|
|
3389
|
+
}
|
|
3390
|
+
var CLEAN_OUTLINE_LIMIT = 64;
|
|
3391
|
+
var geometryCache = /* @__PURE__ */ new WeakMap();
|
|
3392
|
+
function shapeGeometry(layer) {
|
|
3393
|
+
const hit = geometryCache.get(layer);
|
|
3394
|
+
if (hit) return hit;
|
|
3395
|
+
const fills = layer.components.map((c) => ({ op: c.op, flat: flattenPath(componentPath(c)) }));
|
|
3396
|
+
let stroke = null;
|
|
3397
|
+
let align = "center";
|
|
3398
|
+
const s = layer.stroke;
|
|
3399
|
+
if (s && s.width > 0 && layer.components.length) {
|
|
3400
|
+
let outline;
|
|
3401
|
+
try {
|
|
3402
|
+
outline = shapeOutline(layer.components, layer.fillRule);
|
|
3403
|
+
} catch (e4) {
|
|
3404
|
+
outline = layer.components.flatMap((c) => componentPath(c));
|
|
3405
|
+
}
|
|
3406
|
+
align = s.align && s.align !== "center" && closedOutline(outline) ? s.align : "center";
|
|
3407
|
+
stroke = flattenPath(strokeArea(outline, s, align !== "center"));
|
|
3408
|
+
}
|
|
3409
|
+
let bounds = null;
|
|
3410
|
+
const add = (b) => {
|
|
3411
|
+
if (!b) return;
|
|
3412
|
+
if (!bounds) bounds = { ...b };
|
|
3413
|
+
else {
|
|
3414
|
+
const x0 = Math.min(bounds.x, b.x);
|
|
3415
|
+
const y0 = Math.min(bounds.y, b.y);
|
|
3416
|
+
bounds = { x: x0, y: y0, width: Math.max(bounds.x + bounds.width, b.x + b.width) - x0, height: Math.max(bounds.y + bounds.height, b.y + b.height) - y0 };
|
|
3417
|
+
}
|
|
3418
|
+
};
|
|
3419
|
+
if (layer.fill) for (const f of fills) add(flatBounds(f.flat));
|
|
3420
|
+
if (stroke) add(flatBounds(stroke));
|
|
3421
|
+
const g = _nullishCoalesce(shapeGeometryBounds(layer), () => ( { x: 0, y: 0, width: 0, height: 0 }));
|
|
3422
|
+
const frame = { x: Math.floor(g.x), y: Math.floor(g.y), width: Math.max(1, Math.ceil(g.x + g.width) - Math.floor(g.x)), height: Math.max(1, Math.ceil(g.y + g.height) - Math.floor(g.y)) };
|
|
3423
|
+
const geo = { fills, stroke, align, bounds, frame };
|
|
3424
|
+
geometryCache.set(layer, geo);
|
|
3425
|
+
return geo;
|
|
3426
|
+
}
|
|
3427
|
+
function fillCoverage(geo, rect, rule) {
|
|
3428
|
+
const n = rect.width * rect.height;
|
|
3429
|
+
let acc = null;
|
|
3430
|
+
geo.fills.forEach((f, i) => {
|
|
3431
|
+
const cov = f.flat.length > 1 ? rasterizeCoverageSampled(f.flat, rect, rule) : rasterizeCoverage(f.flat, rect, rule);
|
|
3432
|
+
acc = i === 0 ? cov : combineCoverage(acc, cov, f.op, n);
|
|
3433
|
+
});
|
|
3434
|
+
return acc;
|
|
3435
|
+
}
|
|
3436
|
+
function paintContext(env) {
|
|
3437
|
+
const tiles = /* @__PURE__ */ new Map();
|
|
3438
|
+
return {
|
|
3439
|
+
light: _chunkPOGBUYWEcjs.DEFAULT_GLOBAL_LIGHT,
|
|
3440
|
+
pattern: (id) => {
|
|
3441
|
+
if (tiles.has(id)) return tiles.get(id);
|
|
3442
|
+
const p = _nullishCoalesce(_optionalChain([env, 'access', _42 => _42.pattern, 'optionalCall', _43 => _43(id)]), () => ( _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)));
|
|
3443
|
+
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkPOGBUYWEcjs.PatternTile)(p) : null;
|
|
3444
|
+
tiles.set(id, t);
|
|
3445
|
+
return t;
|
|
3446
|
+
}
|
|
3447
|
+
};
|
|
3448
|
+
}
|
|
3449
|
+
function shapeRenderClip(env) {
|
|
3450
|
+
const m = SHAPE_RENDER_MARGIN;
|
|
3451
|
+
return { x: -m, y: -m, width: env.width + 2 * m, height: env.height + 2 * m };
|
|
3452
|
+
}
|
|
3453
|
+
function intersect(a, b) {
|
|
3454
|
+
const x0 = Math.max(a.x, b.x);
|
|
3455
|
+
const y0 = Math.max(a.y, b.y);
|
|
3456
|
+
const x1 = Math.min(a.x + a.width, b.x + b.width);
|
|
3457
|
+
const y1 = Math.min(a.y + a.height, b.y + b.height);
|
|
3458
|
+
return x1 > x0 && y1 > y0 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;
|
|
3459
|
+
}
|
|
3460
|
+
function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
|
|
3461
|
+
const geo = shapeGeometry(layer);
|
|
3462
|
+
if (!geo.bounds || !intersect(geo.bounds, rect)) return null;
|
|
3463
|
+
const n = rect.width * rect.height;
|
|
3464
|
+
const rule = _nullishCoalesce(layer.fillRule, () => ( "nonzero"));
|
|
3465
|
+
const needArea = Boolean(layer.fill) || geo.stroke !== null && geo.align !== "center";
|
|
3466
|
+
const area = needArea ? fillCoverage(geo, rect, rule) : null;
|
|
3467
|
+
let sCov = geo.stroke ? rasterizeCoverageSampled(geo.stroke, rect, "nonzero") : null;
|
|
3468
|
+
if (sCov && geo.align === "inside") sCov = area ? combineCoverage(sCov, area, "intersect", n) : null;
|
|
3469
|
+
else if (sCov && geo.align === "outside" && area) sCov = combineCoverage(sCov, area, "subtract", n);
|
|
3470
|
+
const fCov = layer.fill ? area : null;
|
|
3471
|
+
if (!fCov && !sCov) return null;
|
|
3472
|
+
const canvas = { x: 0, y: 0, width: env.width, height: env.height };
|
|
3473
|
+
const anchor = { x: geo.frame.x, y: geo.frame.y };
|
|
3474
|
+
const fc = fCov ? _chunkPOGBUYWEcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
3475
|
+
const fo = _nullishCoalesce(_optionalChain([layer, 'access', _44 => _44.fill, 'optionalAccess', _45 => _45.opacity]), () => ( 1));
|
|
3476
|
+
const sc = sCov ? _chunkPOGBUYWEcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
3477
|
+
const so = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.stroke, 'optionalAccess', _47 => _47.paint, 'access', _48 => _48.opacity]), () => ( 1));
|
|
3478
|
+
const out = new Uint8ClampedArray(n * 4);
|
|
3479
|
+
let any = false;
|
|
3480
|
+
for (let i = 0; i < n; i++) {
|
|
3481
|
+
const k = i * 4;
|
|
3482
|
+
let r = 0;
|
|
3483
|
+
let g = 0;
|
|
3484
|
+
let b = 0;
|
|
3485
|
+
let a = 0;
|
|
3486
|
+
if (fCov && fCov[i] > 0) {
|
|
3487
|
+
a = fCov[i] * fo * fc[k + 3];
|
|
3488
|
+
r = fc[k];
|
|
3489
|
+
g = fc[k + 1];
|
|
3490
|
+
b = fc[k + 2];
|
|
3491
|
+
}
|
|
3492
|
+
if (sCov && sCov[i] > 0) {
|
|
3493
|
+
const sa = Math.min(1, sCov[i]) * so * sc[k + 3];
|
|
3494
|
+
const ao = sa + a * (1 - sa);
|
|
3495
|
+
if (ao > 0) {
|
|
3496
|
+
r = (sc[k] * sa + r * a * (1 - sa)) / ao;
|
|
3497
|
+
g = (sc[k + 1] * sa + g * a * (1 - sa)) / ao;
|
|
3498
|
+
b = (sc[k + 2] * sa + b * a * (1 - sa)) / ao;
|
|
3499
|
+
}
|
|
3500
|
+
a = ao;
|
|
3501
|
+
}
|
|
3502
|
+
if (a <= 0) continue;
|
|
3503
|
+
const ab = Math.round(Math.min(1, a) * 255);
|
|
3504
|
+
if (!ab) continue;
|
|
3505
|
+
out[k] = Math.round(r * 255);
|
|
3506
|
+
out[k + 1] = Math.round(g * 255);
|
|
3507
|
+
out[k + 2] = Math.round(b * 255);
|
|
3508
|
+
out[k + 3] = ab;
|
|
3509
|
+
any = true;
|
|
3510
|
+
}
|
|
3511
|
+
return any ? out : null;
|
|
3512
|
+
}
|
|
3513
|
+
function renderShape(layer, env, options = {}) {
|
|
3514
|
+
const geo = shapeGeometry(layer);
|
|
3515
|
+
if (!geo.bounds) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
3516
|
+
let region = intersect(geo.bounds, shapeRenderClip(env));
|
|
3517
|
+
if (region && options.clip) region = intersect(region, options.clip);
|
|
3518
|
+
if (!region) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
3519
|
+
const ctx = paintContext(env);
|
|
3520
|
+
const tiles = /* @__PURE__ */ new Map();
|
|
3521
|
+
for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
|
|
3522
|
+
const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
|
|
3523
|
+
const px = renderShapeRect(layer, rect, env, ctx);
|
|
3524
|
+
if (!px) continue;
|
|
3525
|
+
const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px, 4, 0);
|
|
3526
|
+
if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
|
|
3527
|
+
}
|
|
3528
|
+
return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
|
|
3529
|
+
}
|
|
3530
|
+
function rerenderShape(layer, env) {
|
|
3531
|
+
return { ...layer, surface: renderShape(layer, env) };
|
|
3532
|
+
}
|
|
3533
|
+
var isNum = (v) => typeof v === "number" && Number.isFinite(v);
|
|
3534
|
+
function requireNum(v, path, min = -Infinity, max = Infinity) {
|
|
3535
|
+
if (!isNum(v)) fail2(`${path} must be a finite number.`);
|
|
3536
|
+
if (v < min || v > max) fail2(`${path} must be between ${min} and ${max}, got ${v}.`);
|
|
3537
|
+
return v;
|
|
3538
|
+
}
|
|
3539
|
+
function normalizeShapePaint(v, path = "paint") {
|
|
3540
|
+
if (typeof v === "string") {
|
|
3541
|
+
const c = parseCssColor(v);
|
|
3542
|
+
if (!c) return fail2(`${path}: "${v}" is not a colour; use #rrggbb (or #rrggbbaa, rgb(), a CSS colour name).`);
|
|
3543
|
+
return c.alpha < 1 ? { type: "color", color: c.hex, opacity: c.alpha } : { type: "color", color: c.hex };
|
|
3544
|
+
}
|
|
3545
|
+
if (!v || typeof v !== "object") return fail2(`${path} must be a colour string or an object with type color, gradient or pattern.`);
|
|
3546
|
+
const o = v;
|
|
3547
|
+
const opacity = o.opacity === void 0 ? void 0 : requireNum(o.opacity, `${path}.opacity`, 0, 1);
|
|
3548
|
+
const withOpacity = (p) => opacity !== void 0 && opacity !== 1 ? { ...p, opacity } : p;
|
|
3549
|
+
if (o.type === "color") {
|
|
3550
|
+
const c = parseCssColor(o.color);
|
|
3551
|
+
if (!c) return fail2(`${path}.color must be a colour such as #rrggbb.`);
|
|
3552
|
+
const op = (_nullishCoalesce(opacity, () => ( 1))) * c.alpha;
|
|
3553
|
+
return op !== 1 ? { type: "color", color: c.hex, opacity: op } : { type: "color", color: c.hex };
|
|
3554
|
+
}
|
|
3555
|
+
if (o.type === "gradient") {
|
|
3556
|
+
const g = o.gradient;
|
|
3557
|
+
if (!g || typeof g !== "object") return fail2(`${path}.gradient is required: { stops: [{ position, color }], style, angle, \u2026 }.`);
|
|
3558
|
+
const gradient = {
|
|
3559
|
+
stops: Array.isArray(g.stops) ? g.stops.map((s) => ({ position: s.position, color: _nullishCoalesce(_optionalChain([parseCssColor, 'call', _49 => _49(s.color), 'optionalAccess', _50 => _50.hex]), () => ( s.color)) })) : [],
|
|
3560
|
+
...g.opacityStops ? { opacityStops: g.opacityStops } : {},
|
|
3561
|
+
style: _nullishCoalesce(g.style, () => ( "linear")),
|
|
3562
|
+
angle: _nullishCoalesce(g.angle, () => ( 90)),
|
|
3563
|
+
scale: _nullishCoalesce(g.scale, () => ( 1)),
|
|
3564
|
+
reverse: _nullishCoalesce(g.reverse, () => ( false)),
|
|
3565
|
+
align: _nullishCoalesce(g.align, () => ( true)),
|
|
3566
|
+
offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
|
|
3567
|
+
};
|
|
3568
|
+
try {
|
|
3569
|
+
_chunkPOGBUYWEcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
|
|
3570
|
+
} catch (e) {
|
|
3571
|
+
if (e instanceof _chunkPOGBUYWEcjs.LayerEffectError) fail2(e.message);
|
|
3572
|
+
throw e;
|
|
3573
|
+
}
|
|
3574
|
+
if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
|
|
3575
|
+
return withOpacity({ type: "gradient", gradient });
|
|
3576
|
+
}
|
|
3577
|
+
if (o.type === "pattern") {
|
|
3578
|
+
if (typeof o.patternId !== "string" || !o.patternId) fail2(`${path}.patternId is required (a document or built-in pattern id).`);
|
|
3579
|
+
const p = { type: "pattern", patternId: o.patternId, scale: o.scale === void 0 ? 1 : requireNum(o.scale, `${path}.scale`, 0.01, 10) };
|
|
3580
|
+
if (typeof o.name === "string") p.name = o.name;
|
|
3581
|
+
if (o.angle !== void 0) p.angle = requireNum(o.angle, `${path}.angle`, -360, 360);
|
|
3582
|
+
if (o.link !== void 0) p.link = Boolean(o.link);
|
|
3583
|
+
if (o.phase !== void 0) {
|
|
3584
|
+
const ph = o.phase;
|
|
3585
|
+
p.phase = { x: requireNum(_optionalChain([ph, 'optionalAccess', _51 => _51.x]), `${path}.phase.x`), y: requireNum(_optionalChain([ph, 'optionalAccess', _52 => _52.y]), `${path}.phase.y`) };
|
|
3586
|
+
}
|
|
3587
|
+
return withOpacity(p);
|
|
3588
|
+
}
|
|
3589
|
+
return fail2(`${path}.type must be color, gradient or pattern, got ${JSON.stringify(o.type)}.`);
|
|
3590
|
+
}
|
|
3591
|
+
function normalizeShapeStroke(v, path = "stroke", base) {
|
|
3592
|
+
if (!v || typeof v !== "object") return fail2(`${path} must be an object { width, paint, align?, cap?, join?, miterLimit?, dashes?, dashOffset? } or null.`);
|
|
3593
|
+
const o = v;
|
|
3594
|
+
const width = o.width === void 0 && base ? base.width : requireNum(o.width, `${path}.width`, 0, 1e4);
|
|
3595
|
+
const paint = o.paint === void 0 && base ? base.paint : o.paint === void 0 && o.color !== void 0 ? normalizeShapePaint(o.color, `${path}.color`) : normalizeShapePaint(o.paint, `${path}.paint`);
|
|
3596
|
+
const out = { width, paint };
|
|
3597
|
+
const pick = (k, allowed) => {
|
|
3598
|
+
const value = o[k] === void 0 ? _optionalChain([base, 'optionalAccess', _53 => _53[k]]) : o[k];
|
|
3599
|
+
if (value === void 0) return;
|
|
3600
|
+
if (!allowed.includes(value)) fail2(`${path}.${k} must be one of ${allowed.join(", ")}, got ${JSON.stringify(value)}.`);
|
|
3601
|
+
if (value !== (k === "align" ? "center" : k === "cap" ? "butt" : "miter")) out[k] = value;
|
|
3602
|
+
};
|
|
3603
|
+
pick("align", ["inside", "center", "outside"]);
|
|
3604
|
+
pick("cap", ["butt", "round", "square"]);
|
|
3605
|
+
pick("join", ["miter", "round", "bevel"]);
|
|
3606
|
+
const miter = o.miterLimit === void 0 ? _optionalChain([base, 'optionalAccess', _54 => _54.miterLimit]) : requireNum(o.miterLimit, `${path}.miterLimit`, 1, 500);
|
|
3607
|
+
if (miter !== void 0 && miter !== DEFAULT_MITER_LIMIT) out.miterLimit = miter;
|
|
3608
|
+
const dashes = o.dashes === void 0 ? _optionalChain([base, 'optionalAccess', _55 => _55.dashes]) : o.dashes;
|
|
3609
|
+
if (dashes !== void 0 && dashes !== null) {
|
|
3610
|
+
if (!Array.isArray(dashes) || dashes.length > 32 || !dashes.every((d) => isNum(d) && d >= 0 && d <= 1e4)) fail2(`${path}.dashes must be at most 32 lengths 0..10000 (multiples of the width).`);
|
|
3611
|
+
if (dashes.length) {
|
|
3612
|
+
if (dashes.reduce((s, d) => s + d, 0) < 0.01) fail2(`${path}.dashes must add up to at least 0.01 widths.`);
|
|
3613
|
+
out.dashes = [...dashes];
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
const offset = o.dashOffset === void 0 ? _optionalChain([base, 'optionalAccess', _56 => _56.dashOffset]) : requireNum(o.dashOffset, `${path}.dashOffset`, -1e6, 1e6);
|
|
3617
|
+
if (offset) out.dashOffset = offset;
|
|
3618
|
+
return out;
|
|
3619
|
+
}
|
|
3620
|
+
function box(o, path) {
|
|
3621
|
+
return {
|
|
3622
|
+
x: requireNum(o.x, `${path}.x`),
|
|
3623
|
+
y: requireNum(o.y, `${path}.y`),
|
|
3624
|
+
width: requireNum(o.width, `${path}.width`, -1e6, 1e6),
|
|
3625
|
+
height: requireNum(o.height, `${path}.height`, -1e6, 1e6)
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
function arrowhead(v, path) {
|
|
3629
|
+
if (v === null || v === void 0 || v === false) return null;
|
|
3630
|
+
if (typeof v !== "object") return fail2(`${path} must be { width, length, concavity? } in pixels, or null.`);
|
|
3631
|
+
const o = v;
|
|
3632
|
+
const head = { width: requireNum(o.width, `${path}.width`, 0, 1e5), length: requireNum(o.length, `${path}.length`, 0, 1e5) };
|
|
3633
|
+
if (o.concavity !== void 0 && o.concavity !== 0) head.concavity = requireNum(o.concavity, `${path}.concavity`, -0.5, 0.5);
|
|
3634
|
+
return head;
|
|
3635
|
+
}
|
|
3636
|
+
function matrixArg(v, path) {
|
|
3637
|
+
if (v === void 0 || v === null) return void 0;
|
|
3638
|
+
if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
|
|
3639
|
+
const m = v;
|
|
3640
|
+
if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
|
|
3641
|
+
return _chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
|
|
3642
|
+
}
|
|
3643
|
+
function normalizeLiveShape(v, path = "shape") {
|
|
3644
|
+
if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
|
|
3645
|
+
const o = v;
|
|
3646
|
+
const transform = matrixArg(o.transform, `${path}.transform`);
|
|
3647
|
+
const t = transform ? { transform } : {};
|
|
3648
|
+
switch (o.kind) {
|
|
3649
|
+
case "rect": {
|
|
3650
|
+
const b = box(o, path);
|
|
3651
|
+
let radii;
|
|
3652
|
+
if (o.radii !== void 0 || o.radius !== void 0) {
|
|
3653
|
+
const r = _nullishCoalesce(o.radii, () => ( o.radius));
|
|
3654
|
+
const list2 = typeof r === "number" ? [r, r, r, r] : r;
|
|
3655
|
+
if (!Array.isArray(list2) || list2.length !== 4 || !list2.every((x) => isNum(x) && x >= 0)) fail2(`${path}.radii must be four radii \u2265 0 [top-left, top-right, bottom-right, bottom-left] (or radius, one number).`);
|
|
3656
|
+
if (list2.some((x) => x > 0)) radii = [...list2];
|
|
3657
|
+
}
|
|
3658
|
+
return { kind: "rect", ...b, ...radii ? { radii } : {}, ...t };
|
|
3659
|
+
}
|
|
3660
|
+
case "ellipse":
|
|
3661
|
+
return { kind: "ellipse", ...box(o, path), ...t };
|
|
3662
|
+
case "polygon":
|
|
3663
|
+
return { kind: "polygon", ...box(o, path), sides: Math.round(requireNum(_nullishCoalesce(o.sides, () => ( 6)), `${path}.sides`, 3, 100)), ...t };
|
|
3664
|
+
case "star":
|
|
3665
|
+
return {
|
|
3666
|
+
kind: "star",
|
|
3667
|
+
...box(o, path),
|
|
3668
|
+
points: Math.round(requireNum(_nullishCoalesce(o.points, () => ( 5)), `${path}.points`, 3, 100)),
|
|
3669
|
+
innerRatio: requireNum(_nullishCoalesce(o.innerRatio, () => ( 0.5)), `${path}.innerRatio`, 0.01, 1),
|
|
3670
|
+
...t
|
|
3671
|
+
};
|
|
3672
|
+
case "line": {
|
|
3673
|
+
const line = {
|
|
3674
|
+
kind: "line",
|
|
3675
|
+
x1: requireNum(o.x1, `${path}.x1`),
|
|
3676
|
+
y1: requireNum(o.y1, `${path}.y1`),
|
|
3677
|
+
x2: requireNum(o.x2, `${path}.x2`),
|
|
3678
|
+
y2: requireNum(o.y2, `${path}.y2`),
|
|
3679
|
+
weight: requireNum(_nullishCoalesce(o.weight, () => ( 1)), `${path}.weight`, 0, 1e5),
|
|
3680
|
+
...t
|
|
3681
|
+
};
|
|
3682
|
+
const s = arrowhead(o.startArrow, `${path}.startArrow`);
|
|
3683
|
+
const e = arrowhead(o.endArrow, `${path}.endArrow`);
|
|
3684
|
+
if (s) line.startArrow = s;
|
|
3685
|
+
if (e) line.endArrow = e;
|
|
3686
|
+
if (line.x1 === line.x2 && line.y1 === line.y2) fail2(`${path}: the line's two ends are the same point.`);
|
|
3687
|
+
return line;
|
|
3688
|
+
}
|
|
3689
|
+
default:
|
|
3690
|
+
return fail2(`${path}.kind must be one of ${LIVE_SHAPE_KINDS.join(", ")}, got ${JSON.stringify(o.kind)}.`);
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
function point(v, path) {
|
|
3694
|
+
const p = v;
|
|
3695
|
+
if (!p || typeof p !== "object") return fail2(`${path} must be { x, y } in document pixels.`);
|
|
3696
|
+
return { x: requireNum(p.x, `${path}.x`), y: requireNum(p.y, `${path}.y`) };
|
|
3697
|
+
}
|
|
3698
|
+
function normalizeSubpaths(v, path = "subpaths") {
|
|
3699
|
+
if (typeof v === "string") {
|
|
3700
|
+
let subs;
|
|
3701
|
+
try {
|
|
3702
|
+
subs = _chunkW3GXSUSQcjs.bezierToSubpaths.call(void 0, v);
|
|
3703
|
+
} catch (e5) {
|
|
3704
|
+
return fail2(`${path}: could not read the SVG path data.`);
|
|
3705
|
+
}
|
|
3706
|
+
if (!subs.length || !subs.every((s) => s.anchors.every((a) => isNum(a.x) && isNum(a.y)))) fail2(`${path}: the SVG path data holds no drawable subpath.`);
|
|
3707
|
+
return subs;
|
|
3708
|
+
}
|
|
3709
|
+
if (!Array.isArray(v) || !v.length) return fail2(`${path} must be a non-empty array of { anchors: [{ x, y, in?, out? }], closed } (or SVG path data).`);
|
|
3710
|
+
return v.map((s, i) => {
|
|
3711
|
+
const sp = s;
|
|
3712
|
+
if (!sp || !Array.isArray(sp.anchors) || sp.anchors.length < 1) fail2(`${path}[${i}].anchors must be a non-empty array.`);
|
|
3713
|
+
const anchors = sp.anchors.map((a, j) => {
|
|
3714
|
+
const at = `${path}[${i}].anchors[${j}]`;
|
|
3715
|
+
const p = point(a, at);
|
|
3716
|
+
const ao = a;
|
|
3717
|
+
const out = { x: p.x, y: p.y };
|
|
3718
|
+
if (ao.in) out.in = point(ao.in, `${at}.in`);
|
|
3719
|
+
if (ao.out) out.out = point(ao.out, `${at}.out`);
|
|
3720
|
+
if (ao.corner !== void 0 && ao.corner !== null) {
|
|
3721
|
+
const c = ao.corner;
|
|
3722
|
+
const r = requireNum(typeof c === "number" ? c : c.radius, `${at}.corner.radius`, 0, 1e5);
|
|
3723
|
+
if (r > 0) out.corner = { radius: r };
|
|
3724
|
+
}
|
|
3725
|
+
return out;
|
|
3726
|
+
});
|
|
3727
|
+
return { anchors, closed: sp.closed !== false };
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3730
|
+
function requireOperation(v, path = "op") {
|
|
3731
|
+
if (v === void 0) return "combine";
|
|
3732
|
+
if (!SHAPE_OPERATIONS.includes(v)) fail2(`${path} must be one of ${SHAPE_OPERATIONS.join(", ")}, got ${JSON.stringify(v)}.`);
|
|
3733
|
+
return v;
|
|
3734
|
+
}
|
|
3735
|
+
function requireShapeLayer(layers, id) {
|
|
3736
|
+
const layer = requireLayer(layers, id).layer;
|
|
3737
|
+
if (layer.type !== "shape") fail2(`Layer "${layer.name || id}" is a ${layer.type} layer, not a shape layer; list_layers shows each layer's type.`);
|
|
3738
|
+
return layer;
|
|
3739
|
+
}
|
|
3740
|
+
function createShapeLayer(init, env, id = newLayerId()) {
|
|
3741
|
+
if (!init.components.length) fail2("A shape needs at least one component.");
|
|
3742
|
+
const layer = {
|
|
3743
|
+
type: "shape",
|
|
3744
|
+
id,
|
|
3745
|
+
name: _nullishCoalesce(init.name, () => ( defaultShapeName(init.components[0]))),
|
|
3746
|
+
visible: _nullishCoalesce(init.visible, () => ( true)),
|
|
3747
|
+
opacity: _nullishCoalesce(init.opacity, () => ( 1)),
|
|
3748
|
+
blend: _nullishCoalesce(init.blend, () => ( "normal")),
|
|
3749
|
+
components: init.components,
|
|
3750
|
+
fill: init.fill === void 0 ? null : init.fill,
|
|
3751
|
+
stroke: _nullishCoalesce(init.stroke, () => ( null)),
|
|
3752
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
3753
|
+
offset: { x: 0, y: 0 }
|
|
3754
|
+
};
|
|
3755
|
+
if (init.fillRule && init.fillRule !== "nonzero") layer.fillRule = init.fillRule;
|
|
3756
|
+
return rerenderShape(layer, env);
|
|
3757
|
+
}
|
|
3758
|
+
function defaultShapeName(c) {
|
|
3759
|
+
switch (_optionalChain([c, 'optionalAccess', _57 => _57.live, 'optionalAccess', _58 => _58.kind])) {
|
|
3760
|
+
case "rect":
|
|
3761
|
+
return "Rectangle";
|
|
3762
|
+
case "ellipse":
|
|
3763
|
+
return "Ellipse";
|
|
3764
|
+
case "polygon":
|
|
3765
|
+
return "Polygon";
|
|
3766
|
+
case "star":
|
|
3767
|
+
return "Star";
|
|
3768
|
+
case "line":
|
|
3769
|
+
return "Line";
|
|
3770
|
+
default:
|
|
3771
|
+
return "Shape";
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
function updateShapeLayer(layers, id, change, env, action = "edit it") {
|
|
3775
|
+
const current = requireShapeLayer(layers, id);
|
|
3776
|
+
requireUnlocked(current, "pixels", action);
|
|
3777
|
+
const patch = change(current);
|
|
3778
|
+
const next = { ...current, ...patch };
|
|
3779
|
+
if (!("annotation" in patch)) delete next.annotation;
|
|
3780
|
+
if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
|
|
3781
|
+
const rendered = rerenderShape(next, env);
|
|
3782
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
3783
|
+
}
|
|
3784
|
+
function transformShapeComponents(components, f, affine) {
|
|
3785
|
+
return components.map((c) => {
|
|
3786
|
+
if (affine && c.live) {
|
|
3787
|
+
const live = { ...c.live, transform: _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkW3GXSUSQcjs.IDENTITY_MATRIX)), affine) };
|
|
3788
|
+
if (_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
|
|
3789
|
+
return { op: c.op, subpaths: liveShapeSubpaths(live), live };
|
|
3790
|
+
}
|
|
3791
|
+
return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
function offsetShape(layer, dx, dy, env) {
|
|
3795
|
+
const m = _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy);
|
|
3796
|
+
const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
|
|
3797
|
+
delete next.annotation;
|
|
3798
|
+
return rerenderShape(next, env);
|
|
3799
|
+
}
|
|
3800
|
+
function mergeShapeComponents(components, fillRule = "nonzero") {
|
|
3801
|
+
if (components.length < 2) return [...components];
|
|
3802
|
+
const path = shapeOutline(components, fillRule);
|
|
3803
|
+
const subpaths = _chunkW3GXSUSQcjs.bezierToSubpaths.call(void 0, path);
|
|
3804
|
+
if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
|
|
3805
|
+
return [{ op: "combine", subpaths }];
|
|
3806
|
+
}
|
|
3807
|
+
function shapeAsPixelLayer(layer) {
|
|
3808
|
+
const { components: _c, fillRule: _r, fill: _f, stroke: _s, annotation: _a, psd: _p, type: _t, ...rest } = layer;
|
|
3809
|
+
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
3810
|
+
}
|
|
3811
|
+
function annotationPaint(color, opacity) {
|
|
3812
|
+
const c = parseCssColor(color);
|
|
3813
|
+
if (!c || !_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
|
|
3814
|
+
const a = c.alpha * opacity;
|
|
3815
|
+
return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
|
|
3816
|
+
}
|
|
3817
|
+
function shapeFromAnnotation(a) {
|
|
3818
|
+
const opacity = _nullishCoalesce(a.opacity, () => ( 1));
|
|
3819
|
+
const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
|
|
3820
|
+
const rotation = a.rotation ? _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
|
|
3821
|
+
const t = rotation ? { transform: rotation } : {};
|
|
3822
|
+
const live = (l) => liveComponent(l);
|
|
3823
|
+
switch (a.type) {
|
|
3824
|
+
case "rect": {
|
|
3825
|
+
const stroke = annotationPaint(a.strokeColor, opacity);
|
|
3826
|
+
if (!stroke) return null;
|
|
3827
|
+
const fill = a.fillColor ? annotationPaint(a.fillColor, opacity) : null;
|
|
3828
|
+
if (fill === void 0) return null;
|
|
3829
|
+
return {
|
|
3830
|
+
components: [live({ kind: "rect", x: a.x, y: a.y, width: a.width, height: a.height, ...t })],
|
|
3831
|
+
fill,
|
|
3832
|
+
stroke: a.strokeWidth > 0 ? { width: a.strokeWidth, paint: stroke } : null
|
|
3833
|
+
};
|
|
3834
|
+
}
|
|
3835
|
+
case "circle": {
|
|
3836
|
+
const stroke = annotationPaint(a.strokeColor, opacity);
|
|
3837
|
+
if (!stroke) return null;
|
|
3838
|
+
const fill = a.fillColor ? annotationPaint(a.fillColor, opacity) : null;
|
|
3839
|
+
if (fill === void 0) return null;
|
|
3840
|
+
const rx = Math.abs(a.radiusX);
|
|
3841
|
+
const ry = Math.abs(a.radiusY);
|
|
3842
|
+
return {
|
|
3843
|
+
components: [live({ kind: "ellipse", x: a.x - rx, y: a.y - ry, width: 2 * rx, height: 2 * ry, ...t })],
|
|
3844
|
+
fill,
|
|
3845
|
+
stroke: a.strokeWidth > 0 ? { width: a.strokeWidth, paint: stroke } : null
|
|
3846
|
+
};
|
|
3847
|
+
}
|
|
3848
|
+
case "line":
|
|
3849
|
+
case "arrow": {
|
|
3850
|
+
const paint = annotationPaint(a.strokeColor, opacity);
|
|
3851
|
+
if (!paint) return null;
|
|
3852
|
+
const line = { kind: "line", x1: a.x, y1: a.y, x2: a.endX, y2: a.endY, weight: lineWidth, ...t };
|
|
3853
|
+
if (a.type === "arrow") {
|
|
3854
|
+
const side = Math.max(12, a.strokeWidth * 3);
|
|
3855
|
+
line.endArrow = { width: side, length: side * Math.cos(Math.PI / 6) };
|
|
3856
|
+
}
|
|
3857
|
+
if (line.x1 === line.x2 && line.y1 === line.y2) return { components: [{ op: "combine", subpaths: [] }], fill: paint, stroke: null };
|
|
3858
|
+
return { components: [live(line)], fill: paint, stroke: null };
|
|
3859
|
+
}
|
|
3860
|
+
case "pen": {
|
|
3861
|
+
const paint = annotationPaint(a.strokeColor, opacity);
|
|
3862
|
+
if (!paint) return null;
|
|
3863
|
+
const pts = rotation ? a.points.map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
|
|
3864
|
+
const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
|
|
3865
|
+
return {
|
|
3866
|
+
components: [{ op: "combine", subpaths }],
|
|
3867
|
+
fill: null,
|
|
3868
|
+
stroke: { width: lineWidth, paint, cap: "round", join: "round" }
|
|
3869
|
+
};
|
|
3870
|
+
}
|
|
3871
|
+
default:
|
|
3872
|
+
return null;
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
function annotationBlend(a, layerBlend) {
|
|
3876
|
+
if (layerBlend !== "normal") return layerBlend;
|
|
3877
|
+
return a.blend && _chunkXIOMMGPDcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
|
|
3878
|
+
}
|
|
3879
|
+
function annotationOfShape(layer) {
|
|
3880
|
+
const a = layer.annotation;
|
|
3881
|
+
if (!a) return null;
|
|
3882
|
+
const blend = layer.blend;
|
|
3883
|
+
if ((_nullishCoalesce(a.blend, () => ( "normal"))) === blend) return a;
|
|
3884
|
+
const out = { ...a };
|
|
3885
|
+
if (blend === "normal") delete out.blend;
|
|
3886
|
+
else out.blend = blend;
|
|
3887
|
+
return out;
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
// src/image-editor/layers/defaults.ts
|
|
3891
|
+
var DEFAULT_ADJUSTMENTS_VALUES = {
|
|
3892
|
+
brightness: 0,
|
|
3893
|
+
contrast: 0,
|
|
3894
|
+
saturation: 0,
|
|
3895
|
+
exposure: 0,
|
|
3896
|
+
temperature: 0,
|
|
3897
|
+
tint: 0,
|
|
3898
|
+
blur: 0,
|
|
3899
|
+
opacity: 1,
|
|
3900
|
+
process: LATEST_PROCESS_VERSION
|
|
3901
|
+
};
|
|
3902
|
+
var DEFAULT_TRANSFORM_VALUES = {
|
|
3903
|
+
rotate: 0,
|
|
3904
|
+
flipH: false,
|
|
3905
|
+
flipV: false
|
|
3906
|
+
};
|
|
3907
|
+
var DEFAULT_DEPTH_MASK_VALUES = {
|
|
3908
|
+
enabled: false,
|
|
3909
|
+
maskSource: null,
|
|
3910
|
+
mode: "threshold",
|
|
3911
|
+
depthRange: [0, 255],
|
|
3912
|
+
softness: 10,
|
|
3913
|
+
invert: false
|
|
3914
|
+
};
|
|
3915
|
+
|
|
3916
|
+
// src/image-editor/layers/migrate.ts
|
|
3917
|
+
var BACKGROUND_LAYER_ID = "background";
|
|
3918
|
+
var BACKGROUND_LAYER_NAME = "Background";
|
|
3919
|
+
var DEVELOP_FILTER_ID = "develop";
|
|
3920
|
+
var BLUR_FILTER_ID = "blur";
|
|
3921
|
+
var legacyMaskMemo = /* @__PURE__ */ new WeakMap();
|
|
3922
|
+
function rasterMaskFromLegacy(mask, width, height) {
|
|
3923
|
+
const sel = decodeLayerMask(mask);
|
|
3924
|
+
if (!sel) return null;
|
|
3925
|
+
const sized = sel.width === width && sel.height === height ? sel : resizeSelection(sel, width, height);
|
|
3926
|
+
const surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
|
|
3927
|
+
legacyMaskMemo.set(surface, { width: mask.width, height: mask.height, rle: mask.rle });
|
|
3928
|
+
const out = { surface, defaultValue: 0 };
|
|
3929
|
+
if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
|
|
3930
|
+
if (mask.feather) out.feather = mask.feather;
|
|
3931
|
+
if (mask.enabled === false) out.enabled = false;
|
|
3932
|
+
return out;
|
|
3933
|
+
}
|
|
3934
|
+
function hasResampledLegacyMask(layers, width, height) {
|
|
3935
|
+
for (const l of layers) {
|
|
3936
|
+
if (l.type !== "adjustment" || !l.mask) continue;
|
|
3937
|
+
const memo = legacyMaskMemo.get(l.mask.surface);
|
|
3938
|
+
if (memo && (memo.width !== width || memo.height !== height)) return true;
|
|
3939
|
+
}
|
|
3940
|
+
return false;
|
|
3941
|
+
}
|
|
3942
|
+
function legacyMaskOf(mask, width, height) {
|
|
3943
|
+
let memo = legacyMaskMemo.get(mask.surface);
|
|
3944
|
+
if (!memo) {
|
|
3945
|
+
const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
|
|
3946
|
+
memo = { width, height, rle: encodeSelectionRle(new Uint8Array(data.buffer, data.byteOffset, data.length)) };
|
|
3947
|
+
legacyMaskMemo.set(mask.surface, memo);
|
|
3948
|
+
}
|
|
3949
|
+
return normalizeLayerMask({ ...memo, density: mask.density, feather: mask.feather, enabled: mask.enabled });
|
|
3950
|
+
}
|
|
3951
|
+
function sameJson(a, b) {
|
|
3952
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
3953
|
+
}
|
|
3954
|
+
function isDefaultDepthMask(mask) {
|
|
3955
|
+
if (!mask) return true;
|
|
3956
|
+
return sameJson({ ...DEFAULT_DEPTH_MASK_VALUES, ...mask, depthRange: [..._nullishCoalesce(mask.depthRange, () => ( []))] }, DEFAULT_DEPTH_MASK_VALUES);
|
|
3957
|
+
}
|
|
3958
|
+
function developFromAdjustments(adjustments) {
|
|
3959
|
+
return {
|
|
3960
|
+
id: DEVELOP_FILTER_ID,
|
|
3961
|
+
kind: "develop",
|
|
3962
|
+
enabled: true,
|
|
3963
|
+
brightness: _nullishCoalesce(adjustments.brightness, () => ( 0)),
|
|
3964
|
+
contrast: _nullishCoalesce(adjustments.contrast, () => ( 0)),
|
|
3965
|
+
saturation: _nullishCoalesce(adjustments.saturation, () => ( 0)),
|
|
3966
|
+
exposure: _nullishCoalesce(adjustments.exposure, () => ( 0)),
|
|
3967
|
+
temperature: _nullishCoalesce(adjustments.temperature, () => ( 0)),
|
|
3968
|
+
tint: _nullishCoalesce(adjustments.tint, () => ( 0)),
|
|
3969
|
+
process: normalizeProcessVersion(adjustments.process)
|
|
3970
|
+
};
|
|
3971
|
+
}
|
|
3972
|
+
function annotationLayerName(annotation) {
|
|
3973
|
+
switch (annotation.type) {
|
|
3974
|
+
case "pen":
|
|
3975
|
+
return "Pen";
|
|
3976
|
+
case "rect":
|
|
3977
|
+
return "Rectangle";
|
|
3978
|
+
case "circle":
|
|
3979
|
+
return "Ellipse";
|
|
3980
|
+
case "arrow":
|
|
3981
|
+
return "Arrow";
|
|
3982
|
+
case "line":
|
|
3983
|
+
return "Line";
|
|
3984
|
+
case "text":
|
|
3985
|
+
return annotation.text ? annotation.text.slice(0, 32) : "Text";
|
|
3986
|
+
case "image":
|
|
3987
|
+
return "Image";
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
function annotationLayerFor(annotation, canvas) {
|
|
3991
|
+
const shape = canvas ? shapeFromAnnotation(annotation) : null;
|
|
3992
|
+
if (shape) {
|
|
3993
|
+
const layer = createShapeLayer(
|
|
3994
|
+
{ ...shape, name: annotationLayerName(annotation), blend: annotation.blend && annotation.blend !== "normal" ? annotation.blend : "normal" },
|
|
3995
|
+
canvas,
|
|
3996
|
+
annotation.id
|
|
3997
|
+
);
|
|
3998
|
+
return { ...layer, annotation };
|
|
3999
|
+
}
|
|
4000
|
+
return {
|
|
4001
|
+
type: "annotation",
|
|
4002
|
+
id: annotation.id,
|
|
4003
|
+
name: annotationLayerName(annotation),
|
|
4004
|
+
visible: true,
|
|
4005
|
+
opacity: 1,
|
|
4006
|
+
blend: "normal",
|
|
4007
|
+
annotation
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
function annotationOfLayer(layer) {
|
|
4011
|
+
if (layer.type === "annotation") return layer.annotation;
|
|
4012
|
+
if (layer.type === "shape") return annotationOfShape(layer);
|
|
4013
|
+
return null;
|
|
4014
|
+
}
|
|
4015
|
+
function adjustmentNodeFromLegacy(layer, width, height) {
|
|
4016
|
+
const node = {
|
|
4017
|
+
type: "adjustment",
|
|
4018
|
+
id: layer.id,
|
|
4019
|
+
name: _nullishCoalesce(layer.name, () => ( "")),
|
|
4020
|
+
visible: layer.enabled !== false,
|
|
4021
|
+
opacity: _nullishCoalesce(layer.opacity, () => ( 1)),
|
|
4022
|
+
blend: _nullishCoalesce(layer.blend, () => ( "normal")),
|
|
4023
|
+
kind: layer.kind,
|
|
4024
|
+
params: JSON.parse(JSON.stringify(layer.params))
|
|
4025
|
+
};
|
|
4026
|
+
if (layer.mask) {
|
|
4027
|
+
const mask = rasterMaskFromLegacy(layer.mask, width, height);
|
|
4028
|
+
if (mask) node.mask = mask;
|
|
4029
|
+
}
|
|
4030
|
+
return node;
|
|
4031
|
+
}
|
|
4032
|
+
function backgroundLayer(filters = [], mask) {
|
|
4033
|
+
const layer = {
|
|
4034
|
+
type: "pixel",
|
|
4035
|
+
id: BACKGROUND_LAYER_ID,
|
|
4036
|
+
name: BACKGROUND_LAYER_NAME,
|
|
4037
|
+
visible: true,
|
|
4038
|
+
opacity: 1,
|
|
4039
|
+
blend: "normal",
|
|
4040
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
4041
|
+
offset: { x: 0, y: 0 },
|
|
4042
|
+
source: "document",
|
|
4043
|
+
filters
|
|
4044
|
+
};
|
|
4045
|
+
if (mask) layer.mask = mask;
|
|
4046
|
+
return layer;
|
|
4047
|
+
}
|
|
4048
|
+
function depthRasterMask(source) {
|
|
4049
|
+
const out = {
|
|
4050
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255),
|
|
4051
|
+
defaultValue: 255,
|
|
4052
|
+
source: { ...source, depthRange: [...source.depthRange] }
|
|
4053
|
+
};
|
|
4054
|
+
if (!source.enabled) out.enabled = false;
|
|
4055
|
+
return out;
|
|
4056
|
+
}
|
|
4057
|
+
function layersFromLegacy(parts, width, height) {
|
|
4058
|
+
const stored = parts.adjustments;
|
|
4059
|
+
const adjustments = stored ? { ...DEFAULT_ADJUSTMENTS_VALUES, ...stored, process: normalizeProcessVersion(stored.process) } : { ...DEFAULT_ADJUSTMENTS_VALUES };
|
|
4060
|
+
const adjLayers = normalizeAdjustmentLayers(adjustments.layers);
|
|
4061
|
+
const filters = [developFromAdjustments(adjustments)];
|
|
4062
|
+
const blur = typeof adjustments.blur === "number" && adjustments.blur > 0 ? adjustments.blur : 0;
|
|
4063
|
+
let legacyOutputBlur;
|
|
4064
|
+
if (blur > 0) {
|
|
4065
|
+
if (adjLayers.length) legacyOutputBlur = blur;
|
|
4066
|
+
else filters.push({ id: BLUR_FILTER_ID, kind: "blur", enabled: true, radius: blur });
|
|
4067
|
+
}
|
|
4068
|
+
const depth = parts.depthMask;
|
|
4069
|
+
const mask = depth && !isDefaultDepthMask(depth) ? depthRasterMask({ ...DEFAULT_DEPTH_MASK_VALUES, ...depth }) : void 0;
|
|
4070
|
+
const layers = [backgroundLayer(filters, mask)];
|
|
4071
|
+
for (const l of adjLayers) layers.push(adjustmentNodeFromLegacy(l, width, height));
|
|
4072
|
+
for (const a of _nullishCoalesce(parts.annotations, () => ( []))) layers.push(annotationLayerFor(JSON.parse(JSON.stringify(a)), { width, height }));
|
|
4073
|
+
const out = { layers, outputOpacity: typeof adjustments.opacity === "number" ? adjustments.opacity : 1 };
|
|
4074
|
+
if (legacyOutputBlur !== void 0) out.legacyOutputBlur = legacyOutputBlur;
|
|
4075
|
+
return out;
|
|
4076
|
+
}
|
|
4077
|
+
function legacyAdjustmentLayer(node, width, height) {
|
|
4078
|
+
const out = {
|
|
4079
|
+
id: node.id,
|
|
4080
|
+
kind: node.kind,
|
|
4081
|
+
enabled: node.visible,
|
|
4082
|
+
opacity: node.opacity,
|
|
4083
|
+
blend: node.blend,
|
|
4084
|
+
params: node.params
|
|
4085
|
+
};
|
|
4086
|
+
if (node.name) out.name = node.name;
|
|
4087
|
+
if (node.mask && !node.mask.source) out.mask = legacyMaskOf(node.mask, width, height);
|
|
4088
|
+
return out;
|
|
4089
|
+
}
|
|
4090
|
+
function developTarget(layers, activeLayerId) {
|
|
4091
|
+
const pixels = [];
|
|
4092
|
+
const walk = (list2) => {
|
|
4093
|
+
for (const l of list2) {
|
|
4094
|
+
if (l.type === "pixel") pixels.push(l);
|
|
4095
|
+
else if (l.type === "group") walk(l.children);
|
|
4096
|
+
}
|
|
4097
|
+
};
|
|
4098
|
+
walk(layers);
|
|
4099
|
+
if (activeLayerId) {
|
|
4100
|
+
const active = pixels.find((l) => l.id === activeLayerId);
|
|
4101
|
+
if (active) return active;
|
|
4102
|
+
}
|
|
4103
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(pixels.find((l) => l.source === "document"), () => ( pixels.find((l) => l.id === BACKGROUND_LAYER_ID))), () => ( pixels[0])), () => ( null));
|
|
4104
|
+
}
|
|
4105
|
+
var isPlain = (l) => l.visible && l.opacity === 1 && l.blend === "normal" && !l.clipped && !l.mask && !l.locks && !l.effects;
|
|
4106
|
+
function legacyView(stack, width, height, activeLayerId = null) {
|
|
4107
|
+
const { layers } = stack;
|
|
4108
|
+
const target = developTarget(layers, activeLayerId);
|
|
4109
|
+
const develop = target ? developFilter(target) : void 0;
|
|
4110
|
+
const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _59 => _59(target), 'optionalAccess', _60 => _60.radius]) : void 0))), () => ( 0));
|
|
4111
|
+
const adjustments = {
|
|
4112
|
+
...DEFAULT_ADJUSTMENTS_VALUES,
|
|
4113
|
+
...develop ? {
|
|
4114
|
+
brightness: develop.brightness,
|
|
4115
|
+
contrast: develop.contrast,
|
|
4116
|
+
saturation: develop.saturation,
|
|
4117
|
+
exposure: develop.exposure,
|
|
4118
|
+
temperature: develop.temperature,
|
|
4119
|
+
tint: _nullishCoalesce(develop.tint, () => ( 0))
|
|
4120
|
+
} : {},
|
|
4121
|
+
blur,
|
|
4122
|
+
opacity: stack.outputOpacity,
|
|
4123
|
+
process: develop ? normalizeProcessVersion(develop.process) : DEFAULT_ADJUSTMENTS_VALUES.process
|
|
4124
|
+
};
|
|
4125
|
+
const adjNodes = [];
|
|
4126
|
+
const annotations = [];
|
|
4127
|
+
const walk = (list2) => {
|
|
4128
|
+
for (const l of list2) {
|
|
4129
|
+
if (l.type === "adjustment") adjNodes.push(l);
|
|
4130
|
+
else if (l.type === "group") walk(l.children);
|
|
4131
|
+
else {
|
|
4132
|
+
const a = annotationOfLayer(l);
|
|
4133
|
+
if (a) annotations.push(a);
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
};
|
|
4137
|
+
walk(layers);
|
|
4138
|
+
if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
|
|
4139
|
+
const depthSource = _optionalChain([target, 'optionalAccess', _61 => _61.mask, 'optionalAccess', _62 => _62.source]);
|
|
4140
|
+
const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
|
|
4141
|
+
return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
|
|
4142
|
+
}
|
|
4143
|
+
function isLegacyShape(stack) {
|
|
4144
|
+
const { layers } = stack;
|
|
4145
|
+
const bg = layers[0];
|
|
4146
|
+
if (!bg || bg.type !== "pixel" || bg.source !== "document") return false;
|
|
4147
|
+
if (bg.id !== BACKGROUND_LAYER_ID || bg.name !== BACKGROUND_LAYER_NAME) return false;
|
|
4148
|
+
if (!bg.visible || bg.opacity !== 1 || bg.blend !== "normal" || bg.clipped || bg.locks || bg.effects) return false;
|
|
4149
|
+
if ((_nullishCoalesce(bg.fillOpacity, () => ( 1))) !== 1 || bg.offset.x !== 0 || bg.offset.y !== 0) return false;
|
|
4150
|
+
const filters = _nullishCoalesce(bg.filters, () => ( []));
|
|
4151
|
+
if (filters.length < 1 || filters.length > 2) return false;
|
|
4152
|
+
const [develop, blur] = filters;
|
|
4153
|
+
if (develop.kind !== "develop" || !develop.enabled || develop.id !== DEVELOP_FILTER_ID) return false;
|
|
4154
|
+
if (blur && (blur.kind !== "blur" || !blur.enabled || blur.id !== BLUR_FILTER_ID || !(blur.radius > 0))) return false;
|
|
4155
|
+
if (bg.mask) {
|
|
4156
|
+
const m = bg.mask;
|
|
4157
|
+
if (!m.source || m.density !== void 0 || m.feather !== void 0) return false;
|
|
4158
|
+
if (m.enabled !== false !== m.source.enabled) return false;
|
|
4159
|
+
}
|
|
4160
|
+
let i = 1;
|
|
4161
|
+
let adjustments = 0;
|
|
4162
|
+
for (; i < layers.length && layers[i].type === "adjustment"; i++) {
|
|
4163
|
+
const l = layers[i];
|
|
4164
|
+
if (l.clipped || l.locks || _optionalChain([l, 'access', _63 => _63.mask, 'optionalAccess', _64 => _64.source]) || l.effects) return false;
|
|
4165
|
+
adjustments++;
|
|
4166
|
+
}
|
|
4167
|
+
for (; i < layers.length; i++) {
|
|
4168
|
+
const l = layers[i];
|
|
4169
|
+
if (l.type === "shape") {
|
|
4170
|
+
const a = l.annotation;
|
|
4171
|
+
if (!a || (_nullishCoalesce(a.blend, () => ( "normal"))) !== l.blend || !isPlain({ ...l, blend: "normal" }) || l.fillOpacity !== void 0) return false;
|
|
4172
|
+
if (l.id !== a.id || l.name !== annotationLayerName(a)) return false;
|
|
4173
|
+
continue;
|
|
4174
|
+
}
|
|
4175
|
+
if (l.type !== "annotation" || !isPlain(l) || l.id !== l.annotation.id || l.name !== annotationLayerName(l.annotation)) return false;
|
|
4176
|
+
}
|
|
4177
|
+
if (blur && adjustments) return false;
|
|
4178
|
+
if (stack.legacyOutputBlur !== void 0 && (!adjustments || !(stack.legacyOutputBlur > 0))) return false;
|
|
4179
|
+
return true;
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
// src/image-editor/transform.ts
|
|
4183
|
+
var FREE_TRANSFORM_MODES = ["scale", "rotate", "skew", "distort", "perspective", "warp"];
|
|
4184
|
+
var TRANSFORM_ANCHORS = ["top-left", "top", "top-right", "left", "center", "right", "bottom-left", "bottom", "bottom-right"];
|
|
4185
|
+
var ANCHOR_FRACTION = {
|
|
4186
|
+
"top-left": [0, 0],
|
|
4187
|
+
top: [0.5, 0],
|
|
4188
|
+
"top-right": [1, 0],
|
|
4189
|
+
left: [0, 0.5],
|
|
4190
|
+
center: [0.5, 0.5],
|
|
4191
|
+
right: [1, 0.5],
|
|
4192
|
+
"bottom-left": [0, 1],
|
|
4193
|
+
bottom: [0.5, 1],
|
|
4194
|
+
"bottom-right": [1, 1]
|
|
4195
|
+
};
|
|
4196
|
+
function isTransformAnchor(value) {
|
|
4197
|
+
return typeof value === "string" && value in ANCHOR_FRACTION;
|
|
4198
|
+
}
|
|
4199
|
+
function identityTransform(box2) {
|
|
4200
|
+
return { box: { ...box2 }, corners: _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2) };
|
|
4201
|
+
}
|
|
4202
|
+
function cornersFromMatrix(box2, m) {
|
|
4203
|
+
const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2);
|
|
4204
|
+
return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4205
|
+
}
|
|
4206
|
+
function matrixFromCorners(box2, corners, eps = 1e-6) {
|
|
4207
|
+
const [tl, tr, br, bl] = corners;
|
|
4208
|
+
const size = 1 + Math.max(box2.width, box2.height);
|
|
4209
|
+
if (Math.abs(tl.x + br.x - tr.x - bl.x) > eps * size || Math.abs(tl.y + br.y - tr.y - bl.y) > eps * size) return null;
|
|
4210
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, box2, corners);
|
|
4211
|
+
return h ? _chunkMUUXNRU4cjs.affineFromHomography.call(void 0, h, 1e-9) : null;
|
|
4212
|
+
}
|
|
4213
|
+
function transformHomography(geometry) {
|
|
4214
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
4215
|
+
if (!h) return null;
|
|
4216
|
+
return _chunkMUUXNRU4cjs.homographyKeepsQuad.call(void 0, h, _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box)) ? h : null;
|
|
4217
|
+
}
|
|
4218
|
+
function hasWarp(geometry) {
|
|
4219
|
+
const w = geometry.warp;
|
|
4220
|
+
if (!w) return false;
|
|
4221
|
+
const id = _chunkW3GXSUSQcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
|
|
4222
|
+
if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
|
|
4223
|
+
return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
|
|
4224
|
+
}
|
|
4225
|
+
function isIdentityTransform(geometry) {
|
|
4226
|
+
if (hasWarp(geometry)) return false;
|
|
4227
|
+
const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, geometry.box);
|
|
4228
|
+
return geometry.corners.every((c, i) => Math.abs(c.x - q2[i].x) < 1e-6 && Math.abs(c.y - q2[i].y) < 1e-6);
|
|
4229
|
+
}
|
|
4230
|
+
function transformMap(geometry) {
|
|
4231
|
+
const h = transformHomography(geometry);
|
|
4232
|
+
if (!h) return null;
|
|
4233
|
+
const { box: box2 } = geometry;
|
|
4234
|
+
const warp = hasWarp(geometry) ? geometry.warp : null;
|
|
4235
|
+
if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
|
|
4236
|
+
return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunkW3GXSUSQcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
|
|
2735
4237
|
}
|
|
2736
|
-
function
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
return layer;
|
|
4238
|
+
function transformedPoint(geometry, fx, fy) {
|
|
4239
|
+
const f = transformMap(geometry);
|
|
4240
|
+
const { box: box2 } = geometry;
|
|
4241
|
+
return f ? f({ x: box2.x + fx * box2.width, y: box2.y + fy * box2.height }) : null;
|
|
2741
4242
|
}
|
|
2742
|
-
function
|
|
2743
|
-
|
|
4243
|
+
function anchorPoint(geometry, anchor) {
|
|
4244
|
+
const [fx, fy] = ANCHOR_FRACTION[anchor];
|
|
4245
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
4246
|
+
const p = { x: geometry.box.x + fx * geometry.box.width, y: geometry.box.y + fy * geometry.box.height };
|
|
4247
|
+
return _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p)), () => ( p));
|
|
2744
4248
|
}
|
|
2745
|
-
function
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
}
|
|
2749
|
-
|
|
2750
|
-
|
|
4249
|
+
function transformedBox(geometry) {
|
|
4250
|
+
const f = transformMap(geometry);
|
|
4251
|
+
if (!f) return null;
|
|
4252
|
+
const { box: box2 } = geometry;
|
|
4253
|
+
const pts = [];
|
|
4254
|
+
const n = hasWarp(geometry) ? 16 : 1;
|
|
4255
|
+
for (let i = 0; i <= n; i++) {
|
|
4256
|
+
const t = i / n;
|
|
4257
|
+
for (const [fx, fy] of [[t, 0], [1, t], [1 - t, 1], [0, 1 - t]]) {
|
|
4258
|
+
const p = f({ x: box2.x + fx * box2.width, y: box2.y + fy * box2.height });
|
|
4259
|
+
if (!p) return null;
|
|
4260
|
+
pts.push(p);
|
|
4261
|
+
}
|
|
2751
4262
|
}
|
|
4263
|
+
const xs = pts.map((p) => p.x);
|
|
4264
|
+
const ys = pts.map((p) => p.y);
|
|
4265
|
+
const x = Math.min(...xs);
|
|
4266
|
+
const y = Math.min(...ys);
|
|
4267
|
+
return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
|
|
2752
4268
|
}
|
|
2753
|
-
function
|
|
2754
|
-
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2757
|
-
guard(() => _chunkT3QZ6S47cjs.validateLayerEffects.call(void 0, effects));
|
|
2758
|
-
next.effects = effects;
|
|
2759
|
-
} else delete next.effects;
|
|
2760
|
-
return _chunkT3QZ6S47cjs.mapLayer.call(void 0, layers, id, () => next);
|
|
4269
|
+
function referencePoint(box2, reference) {
|
|
4270
|
+
if (reference && typeof reference === "object") return { x: reference.x, y: reference.y };
|
|
4271
|
+
const [fx, fy] = ANCHOR_FRACTION[_nullishCoalesce(reference, () => ( "center"))];
|
|
4272
|
+
return { x: box2.x + fx * box2.width, y: box2.y + fy * box2.height };
|
|
2761
4273
|
}
|
|
2762
|
-
function
|
|
2763
|
-
|
|
2764
|
-
const
|
|
2765
|
-
const
|
|
2766
|
-
const
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
const effect = guard(() => _chunkT3QZ6S47cjs.mergeLayerEffect.call(void 0, _chunkT3QZ6S47cjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
|
|
2771
|
-
const items = [...current.items];
|
|
2772
|
-
const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
|
|
2773
|
-
items.splice(at, 0, effect);
|
|
2774
|
-
return { layers: setLayerEffects(layers, id, { ...current, items }), effect };
|
|
4274
|
+
function matrixFromParams(box2, params) {
|
|
4275
|
+
const sx = (_nullishCoalesce(params.scaleX, () => ( 100))) / 100;
|
|
4276
|
+
const sy = (_nullishCoalesce(params.scaleY, () => ( 100))) / 100;
|
|
4277
|
+
const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
|
|
4278
|
+
const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
|
|
4279
|
+
const ref = referencePoint(box2, params.reference);
|
|
4280
|
+
const linear = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
|
|
4281
|
+
return _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, _chunkW3GXSUSQcjs.matrixAbout.call(void 0, linear, ref), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
|
|
2775
4282
|
}
|
|
2776
|
-
function
|
|
2777
|
-
const
|
|
2778
|
-
const
|
|
2779
|
-
|
|
2780
|
-
|
|
4283
|
+
function describeTransform(geometry, reference = "center") {
|
|
4284
|
+
const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
|
|
4285
|
+
const ref = referencePoint(geometry.box, reference);
|
|
4286
|
+
const bounds = transformedBox(geometry);
|
|
4287
|
+
if (!m) {
|
|
4288
|
+
const h = _chunkMUUXNRU4cjs.rectToQuad.call(void 0, geometry.box, geometry.corners);
|
|
4289
|
+
const at2 = _nullishCoalesce((h && _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, ref)), () => ( ref));
|
|
4290
|
+
return { affine: false, scaleX: 100, scaleY: 100, rotate: 0, skewX: 0, x: at2.x, y: at2.y, bounds, corners: geometry.corners };
|
|
4291
|
+
}
|
|
4292
|
+
const [a, b, c, d] = m;
|
|
4293
|
+
const sxAbs = Math.hypot(a, b);
|
|
4294
|
+
const rot = Math.atan2(b, a) * 180 / Math.PI;
|
|
4295
|
+
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
4296
|
+
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
4297
|
+
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
4298
|
+
const at = _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, ref);
|
|
4299
|
+
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
4300
|
+
return {
|
|
4301
|
+
affine: true,
|
|
4302
|
+
scaleX: clean(sxAbs * 100),
|
|
4303
|
+
scaleY: clean(sy * 100),
|
|
4304
|
+
rotate: clean(rot === -180 ? 180 : rot),
|
|
4305
|
+
skewX: clean(skew),
|
|
4306
|
+
x: at.x,
|
|
4307
|
+
y: at.y,
|
|
4308
|
+
bounds,
|
|
4309
|
+
corners: geometry.corners
|
|
4310
|
+
};
|
|
2781
4311
|
}
|
|
2782
|
-
function
|
|
2783
|
-
const
|
|
2784
|
-
const
|
|
2785
|
-
const
|
|
2786
|
-
|
|
2787
|
-
items[i] = guard(() => _chunkT3QZ6S47cjs.mergeLayerEffect.call(void 0, items[i], changes));
|
|
2788
|
-
return setLayerEffects(layers, id, { ...current, items });
|
|
4312
|
+
function applyParams(geometry, params) {
|
|
4313
|
+
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
4314
|
+
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
4315
|
+
const c = geometry.corners;
|
|
4316
|
+
return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, c[3])];
|
|
2789
4317
|
}
|
|
2790
|
-
function
|
|
2791
|
-
const
|
|
2792
|
-
|
|
2793
|
-
const
|
|
2794
|
-
return
|
|
4318
|
+
function flipCorners(geometry, axis) {
|
|
4319
|
+
const c = anchorPoint(geometry, "center");
|
|
4320
|
+
const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
|
|
4321
|
+
const q2 = geometry.corners;
|
|
4322
|
+
return [_chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[0]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[1]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[2]), _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, q2[3])];
|
|
2795
4323
|
}
|
|
2796
|
-
function
|
|
2797
|
-
const
|
|
2798
|
-
if (
|
|
2799
|
-
|
|
2800
|
-
const next = { ...current, enabled };
|
|
2801
|
-
if (scale !== void 0) {
|
|
2802
|
-
if (scale === 1) delete next.scale;
|
|
2803
|
-
else next.scale = scale;
|
|
2804
|
-
}
|
|
2805
|
-
return setLayerEffects(layers, id, next);
|
|
4324
|
+
function boxPointOf(geometry, p) {
|
|
4325
|
+
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
4326
|
+
if (m) return _chunkW3GXSUSQcjs.applyMatrix.call(void 0, _chunkW3GXSUSQcjs.invertMatrix.call(void 0, m), p);
|
|
4327
|
+
return null;
|
|
2806
4328
|
}
|
|
2807
|
-
function
|
|
2808
|
-
|
|
2809
|
-
if (value === "pass-through" && allowPassThrough) return value;
|
|
2810
|
-
if (!_chunkSZ6KMZNMcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
|
|
2811
|
-
return value;
|
|
4329
|
+
function presetWarp(box2, preset) {
|
|
4330
|
+
return _chunkW3GXSUSQcjs.warpPresetMesh.call(void 0, preset, box2);
|
|
2812
4331
|
}
|
|
2813
|
-
function
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
const
|
|
2818
|
-
return
|
|
4332
|
+
function isValidWarp(mesh) {
|
|
4333
|
+
return _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, mesh);
|
|
4334
|
+
}
|
|
4335
|
+
function geometryHomography(geometry) {
|
|
4336
|
+
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
4337
|
+
return m ? _chunkMUUXNRU4cjs.homographyFromAffine.call(void 0, m) : transformHomography(geometry);
|
|
2819
4338
|
}
|
|
2820
4339
|
|
|
2821
4340
|
// src/image-editor/layers/smart.ts
|
|
2822
|
-
var
|
|
4341
|
+
var fail3 = (message) => {
|
|
2823
4342
|
throw new LayerOperationError(message);
|
|
2824
4343
|
};
|
|
2825
|
-
var SMART_RENDER_MARGIN =
|
|
4344
|
+
var SMART_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
|
|
2826
4345
|
function newContentsId() {
|
|
2827
4346
|
return newLayerId("so");
|
|
2828
4347
|
}
|
|
@@ -2840,14 +4359,14 @@ function isContentsDecoded(contents) {
|
|
|
2840
4359
|
}
|
|
2841
4360
|
function requireDecoded(layer, action) {
|
|
2842
4361
|
if (isContentsDecoded(layer.contents)) return;
|
|
2843
|
-
const what = _optionalChain([layer, 'access',
|
|
2844
|
-
|
|
4362
|
+
const what = _optionalChain([layer, 'access', _65 => _65.contents, 'access', _66 => _66.file, 'optionalAccess', _67 => _67.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
|
|
4363
|
+
fail3(
|
|
2845
4364
|
`The contents of smart object "${layer.name || layer.id}" are ${what} that could not be decoded here, so it cannot ${action}. Run prepareSmartObjects() in a browser first, or rasterize it.`
|
|
2846
4365
|
);
|
|
2847
4366
|
}
|
|
2848
4367
|
function requireSmartObject(layers, id) {
|
|
2849
4368
|
const layer = requireLayer(layers, id).layer;
|
|
2850
|
-
if (layer.type !== "smart")
|
|
4369
|
+
if (layer.type !== "smart") fail3(`Layer "${layer.name || id}" is a ${layer.type} layer, not a smart object; convert it with convert_to_smart_object.`);
|
|
2851
4370
|
return layer;
|
|
2852
4371
|
}
|
|
2853
4372
|
var contentsPixels = /* @__PURE__ */ new WeakMap();
|
|
@@ -2855,29 +4374,29 @@ function contentsSurface(contents) {
|
|
|
2855
4374
|
let s = contentsPixels.get(contents);
|
|
2856
4375
|
if (s) return s;
|
|
2857
4376
|
if (contents.kind === "raster") {
|
|
2858
|
-
s = _nullishCoalesce(contents.raster, () => (
|
|
4377
|
+
s = _nullishCoalesce(contents.raster, () => ( _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4)));
|
|
2859
4378
|
} else {
|
|
2860
4379
|
const doc = contents.document;
|
|
2861
|
-
if (!doc) return
|
|
4380
|
+
if (!doc) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
2862
4381
|
const W = contents.width;
|
|
2863
4382
|
const H = contents.height;
|
|
2864
4383
|
const data = new LayerCompositor().composite(doc.layers, { x: 0, y: 0, width: W, height: H }, {
|
|
2865
4384
|
width: W,
|
|
2866
4385
|
height: H,
|
|
2867
4386
|
globalLight: doc.globalLight,
|
|
2868
|
-
pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access',
|
|
4387
|
+
pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _68 => _68.patterns, 'optionalAccess', _69 => _69.find, 'call', _70 => _70((p) => p.id === id)]), () => ( null))
|
|
2869
4388
|
});
|
|
2870
|
-
s =
|
|
4389
|
+
s = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
|
|
2871
4390
|
}
|
|
2872
4391
|
contentsPixels.set(contents, s);
|
|
2873
4392
|
return s;
|
|
2874
4393
|
}
|
|
2875
4394
|
function rasterContents(pixels, name, id = newContentsId()) {
|
|
2876
|
-
if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4)
|
|
2877
|
-
return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster:
|
|
4395
|
+
if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4) fail3("Contents pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
|
|
4396
|
+
return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
|
|
2878
4397
|
}
|
|
2879
4398
|
function documentContents(document, width, height, name, id = newContentsId()) {
|
|
2880
|
-
if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0))
|
|
4399
|
+
if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail3("Contents width and height must be positive whole numbers.");
|
|
2881
4400
|
return { id, name, width, height, kind: "document", document };
|
|
2882
4401
|
}
|
|
2883
4402
|
var placedCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -2900,7 +4419,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
2900
4419
|
const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
|
|
2901
4420
|
const key = placementKey(placement, canvas);
|
|
2902
4421
|
if (!preview) {
|
|
2903
|
-
const hit = _optionalChain([placedCache, 'access',
|
|
4422
|
+
const hit = _optionalChain([placedCache, 'access', _71 => _71.get, 'call', _72 => _72(contents), 'optionalAccess', _73 => _73.get, 'call', _74 => _74(key)]);
|
|
2904
4423
|
if (hit) return hit;
|
|
2905
4424
|
}
|
|
2906
4425
|
const src = contentsSurface(contents);
|
|
@@ -2918,7 +4437,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
2918
4437
|
let out;
|
|
2919
4438
|
const move = integerMove(layer);
|
|
2920
4439
|
if (move && !options.clip) {
|
|
2921
|
-
out =
|
|
4440
|
+
out = _chunkXIOMMGPDcjs.translateSurface.call(void 0, src, move.x, move.y);
|
|
2922
4441
|
} else {
|
|
2923
4442
|
const g = placementGeometry(layer);
|
|
2924
4443
|
const interpolation = preview ? placement.interpolation === "nearest" ? "nearest" : "bilinear" : _nullishCoalesce(placement.interpolation, () => ( "bicubic"));
|
|
@@ -2927,27 +4446,27 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
2927
4446
|
let k = 1;
|
|
2928
4447
|
if (step > 1) {
|
|
2929
4448
|
k = step;
|
|
2930
|
-
let r = _optionalChain([options, 'access',
|
|
4449
|
+
let r = _optionalChain([options, 'access', _75 => _75.reduced, 'optionalAccess', _76 => _76.get, 'call', _77 => _77(k)]);
|
|
2931
4450
|
if (!r) {
|
|
2932
|
-
r =
|
|
2933
|
-
_optionalChain([options, 'access',
|
|
4451
|
+
r = _chunkPOGBUYWEcjs.reduceSurface.call(void 0, src, k);
|
|
4452
|
+
_optionalChain([options, 'access', _78 => _78.reduced, 'optionalAccess', _79 => _79.set, 'call', _80 => _80(k, r)]);
|
|
2934
4453
|
}
|
|
2935
4454
|
source = r;
|
|
2936
4455
|
}
|
|
2937
|
-
const
|
|
4456
|
+
const box2 = { x: 0, y: 0, width: Math.ceil(contents.width / k), height: Math.ceil(contents.height / k) };
|
|
2938
4457
|
try {
|
|
2939
4458
|
if (hasWarp(g)) {
|
|
2940
4459
|
const f = transformMap(g);
|
|
2941
|
-
if (!f)
|
|
2942
|
-
out =
|
|
4460
|
+
if (!f) fail3("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4461
|
+
out = _chunkPOGBUYWEcjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
2943
4462
|
} else {
|
|
2944
4463
|
const h = transformHomography(g);
|
|
2945
|
-
if (!h)
|
|
4464
|
+
if (!h) fail3("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
2946
4465
|
const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
|
|
2947
|
-
out =
|
|
4466
|
+
out = _chunkPOGBUYWEcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
2948
4467
|
}
|
|
2949
4468
|
} catch (e) {
|
|
2950
|
-
if (e instanceof
|
|
4469
|
+
if (e instanceof _chunkPOGBUYWEcjs.TransformTooLargeError) fail3(e.message);
|
|
2951
4470
|
throw e;
|
|
2952
4471
|
}
|
|
2953
4472
|
}
|
|
@@ -2963,14 +4482,14 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
2963
4482
|
return out;
|
|
2964
4483
|
}
|
|
2965
4484
|
function activeSmartFilters(stack) {
|
|
2966
|
-
if (!_optionalChain([stack, 'optionalAccess',
|
|
4485
|
+
if (!_optionalChain([stack, 'optionalAccess', _81 => _81.enabled])) return [];
|
|
2967
4486
|
return stack.filters.filter((f) => f.kind !== "psd" && isActiveFilter(f) && f.opacity > 0);
|
|
2968
4487
|
}
|
|
2969
4488
|
function filterMaskCoverage(mask, canvas) {
|
|
2970
4489
|
if (!mask || mask.enabled === false || mask.source) return null;
|
|
2971
4490
|
const W = canvas.width;
|
|
2972
4491
|
const H = canvas.height;
|
|
2973
|
-
const bytes =
|
|
4492
|
+
const bytes = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width: W, height: H });
|
|
2974
4493
|
let v = new Float32Array(W * H);
|
|
2975
4494
|
let all = true;
|
|
2976
4495
|
for (let i = 0; i < v.length; i++) {
|
|
@@ -2979,7 +4498,7 @@ function filterMaskCoverage(mask, canvas) {
|
|
|
2979
4498
|
}
|
|
2980
4499
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
2981
4500
|
if (all && !(feather > 0)) return null;
|
|
2982
|
-
if (feather > 0) v =
|
|
4501
|
+
if (feather > 0) v = _chunkPOGBUYWEcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
|
|
2983
4502
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
2984
4503
|
if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
|
|
2985
4504
|
return v;
|
|
@@ -2992,7 +4511,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
2992
4511
|
const key = JSON.stringify([W, H, active.map((f) => ({ ...f, id: void 0 }))]);
|
|
2993
4512
|
let entry = filteredCache.get(placed);
|
|
2994
4513
|
if (!entry || entry.key !== key) {
|
|
2995
|
-
const base =
|
|
4514
|
+
const base = _chunkXIOMMGPDcjs.readRegion.call(void 0, placed, { x: 0, y: 0, width: W, height: H });
|
|
2996
4515
|
let acc = new Uint8ClampedArray(base);
|
|
2997
4516
|
for (const f of active) {
|
|
2998
4517
|
const out = new Uint8ClampedArray(acc);
|
|
@@ -3001,7 +4520,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
3001
4520
|
if (f.opacity >= 1) acc = out;
|
|
3002
4521
|
else lerpInto(acc, out, f.opacity, null);
|
|
3003
4522
|
} else {
|
|
3004
|
-
|
|
4523
|
+
_chunkPOGBUYWEcjs.blendTile.call(void 0, acc, out, f.blend, f.opacity, null);
|
|
3005
4524
|
}
|
|
3006
4525
|
}
|
|
3007
4526
|
entry = { key, base, filtered: acc };
|
|
@@ -3013,7 +4532,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
3013
4532
|
result = new Uint8ClampedArray(entry.base);
|
|
3014
4533
|
lerpInto(result, entry.filtered, 1, cov);
|
|
3015
4534
|
}
|
|
3016
|
-
return
|
|
4535
|
+
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data: result }, 4, 0, 0);
|
|
3017
4536
|
}
|
|
3018
4537
|
function lerpInto(dst, src, k, coverage) {
|
|
3019
4538
|
for (let i = 0, p = 0; i < dst.length; i += 4, p++) {
|
|
@@ -3038,21 +4557,21 @@ function rerender(layer, canvas, action = "change") {
|
|
|
3038
4557
|
return { ...layer, surface: renderSmartObject(layer, canvas) };
|
|
3039
4558
|
}
|
|
3040
4559
|
function normalizePlacement(raw, contents) {
|
|
3041
|
-
const c = _optionalChain([raw, 'optionalAccess',
|
|
4560
|
+
const c = _optionalChain([raw, 'optionalAccess', _82 => _82.corners]);
|
|
3042
4561
|
if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
|
|
3043
|
-
|
|
4562
|
+
fail3("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
|
|
3044
4563
|
}
|
|
3045
4564
|
const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
|
|
3046
4565
|
if (raw.warp) {
|
|
3047
|
-
if (!
|
|
4566
|
+
if (!_chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, raw.warp)) fail3("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
|
|
3048
4567
|
out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
3049
4568
|
}
|
|
3050
4569
|
if (raw.interpolation !== void 0) {
|
|
3051
|
-
if (!
|
|
4570
|
+
if (!_chunkPOGBUYWEcjs.isInterpolation.call(void 0, raw.interpolation)) fail3(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
3052
4571
|
if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
|
|
3053
4572
|
}
|
|
3054
4573
|
const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
|
|
3055
|
-
if (!transformHomography(g))
|
|
4574
|
+
if (!transformHomography(g)) fail3("These corners fold the contents over themselves or through the horizon; keep the quad convex.");
|
|
3056
4575
|
if (out.warp && !hasWarp(g)) delete out.warp;
|
|
3057
4576
|
return out;
|
|
3058
4577
|
}
|
|
@@ -3068,7 +4587,7 @@ function followMask(mask, before, after) {
|
|
|
3068
4587
|
const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, h0);
|
|
3069
4588
|
if (!inv) return mask;
|
|
3070
4589
|
const delta = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, inv, h1);
|
|
3071
|
-
const surface =
|
|
4590
|
+
const surface = _chunkPOGBUYWEcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
|
|
3072
4591
|
return { ...mask, surface };
|
|
3073
4592
|
}
|
|
3074
4593
|
function setSmartPlacement(layers, id, placement, canvas) {
|
|
@@ -3083,13 +4602,13 @@ function setSmartPlacement(layers, id, placement, canvas) {
|
|
|
3083
4602
|
masksMoved ||= m !== layer.mask;
|
|
3084
4603
|
next.mask = m;
|
|
3085
4604
|
}
|
|
3086
|
-
if (_optionalChain([next, 'access',
|
|
4605
|
+
if (_optionalChain([next, 'access', _83 => _83.smartFilters, 'optionalAccess', _84 => _84.mask])) {
|
|
3087
4606
|
const m = followMask(next.smartFilters.mask, layer, next);
|
|
3088
4607
|
masksMoved ||= m !== next.smartFilters.mask;
|
|
3089
4608
|
next.smartFilters = { ...next.smartFilters, mask: m };
|
|
3090
4609
|
}
|
|
3091
4610
|
next = rerender(next, canvas, "be transformed");
|
|
3092
|
-
return { layers:
|
|
4611
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
|
|
3093
4612
|
}
|
|
3094
4613
|
function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
3095
4614
|
const layer = requireSmartObject(layers, id);
|
|
@@ -3099,26 +4618,26 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
|
3099
4618
|
if (!mx && !my) return layers;
|
|
3100
4619
|
const corners = layer.placement.corners.map((p) => ({ x: p.x + mx, y: p.y + my }));
|
|
3101
4620
|
let next = { ...layer, placement: { ...layer.placement, corners } };
|
|
3102
|
-
const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface:
|
|
4621
|
+
const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
|
|
3103
4622
|
if (layer.mask) next.mask = moveMask(layer.mask);
|
|
3104
|
-
if (_optionalChain([layer, 'access',
|
|
4623
|
+
if (_optionalChain([layer, 'access', _85 => _85.smartFilters, 'optionalAccess', _86 => _86.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
|
|
3105
4624
|
const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur");
|
|
3106
|
-
const b =
|
|
4625
|
+
const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
3107
4626
|
const m = SMART_RENDER_MARGIN;
|
|
3108
4627
|
const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
|
|
3109
|
-
if (!spatial && !cut && !(_optionalChain([next, 'access',
|
|
3110
|
-
next = { ...next, surface:
|
|
4628
|
+
if (!spatial && !cut && !(_optionalChain([next, 'access', _87 => _87.smartFilters, 'optionalAccess', _88 => _88.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
|
|
4629
|
+
next = { ...next, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, mx, my) };
|
|
3111
4630
|
} else {
|
|
3112
4631
|
next = rerender(next, canvas, "move");
|
|
3113
4632
|
}
|
|
3114
|
-
return
|
|
4633
|
+
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3115
4634
|
}
|
|
3116
4635
|
function translateLayer(layer, dx, dy) {
|
|
3117
4636
|
if (!dx && !dy) return layer;
|
|
3118
4637
|
const moveMask = (m) => {
|
|
3119
4638
|
if (!m) return m;
|
|
3120
|
-
if (m.source)
|
|
3121
|
-
return { ...m, surface:
|
|
4639
|
+
if (m.source) fail3(`Layer "${layer.name || layer.id}" has a depth mask, which cannot move into a smart object; bake or remove it first.`);
|
|
4640
|
+
return { ...m, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m.surface, dx, dy) };
|
|
3122
4641
|
};
|
|
3123
4642
|
switch (layer.type) {
|
|
3124
4643
|
case "pixel":
|
|
@@ -3127,11 +4646,11 @@ function translateLayer(layer, dx, dy) {
|
|
|
3127
4646
|
const next = {
|
|
3128
4647
|
...layer,
|
|
3129
4648
|
placement: { ...layer.placement, corners: layer.placement.corners.map((p) => ({ x: p.x + dx, y: p.y + dy })) },
|
|
3130
|
-
surface:
|
|
4649
|
+
surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
3131
4650
|
mask: moveMask(layer.mask)
|
|
3132
4651
|
};
|
|
3133
4652
|
if (!next.mask) delete next.mask;
|
|
3134
|
-
if (_optionalChain([layer, 'access',
|
|
4653
|
+
if (_optionalChain([layer, 'access', _89 => _89.smartFilters, 'optionalAccess', _90 => _90.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
|
|
3135
4654
|
return next;
|
|
3136
4655
|
}
|
|
3137
4656
|
case "group": {
|
|
@@ -3144,18 +4663,29 @@ function translateLayer(layer, dx, dy) {
|
|
|
3144
4663
|
if (!next.mask) delete next.mask;
|
|
3145
4664
|
return next;
|
|
3146
4665
|
}
|
|
4666
|
+
case "shape": {
|
|
4667
|
+
const next = {
|
|
4668
|
+
...layer,
|
|
4669
|
+
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy)),
|
|
4670
|
+
surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
4671
|
+
mask: moveMask(layer.mask)
|
|
4672
|
+
};
|
|
4673
|
+
if (!next.mask) delete next.mask;
|
|
4674
|
+
delete next.annotation;
|
|
4675
|
+
return next;
|
|
4676
|
+
}
|
|
3147
4677
|
case "annotation":
|
|
3148
|
-
return
|
|
4678
|
+
return fail3(`Annotation layer "${layer.name || layer.id}" cannot go into a smart object; rasterize it first.`);
|
|
3149
4679
|
}
|
|
3150
4680
|
}
|
|
3151
4681
|
function layerExtent(layer, surfaceOf, canvas) {
|
|
3152
4682
|
const full = { x: 0, y: 0, width: canvas.width, height: canvas.height };
|
|
3153
4683
|
let b = null;
|
|
3154
|
-
if (layer.type === "pixel" || layer.type === "smart") {
|
|
4684
|
+
if (layer.type === "pixel" || layer.type === "smart" || layer.type === "shape") {
|
|
3155
4685
|
const s = layer.type === "pixel" ? surfaceOf(layer) : layer.surface;
|
|
3156
4686
|
if (s.defaultValue !== 0) b = full;
|
|
3157
4687
|
else {
|
|
3158
|
-
const c =
|
|
4688
|
+
const c = _chunkXIOMMGPDcjs.contentBounds.call(void 0, s);
|
|
3159
4689
|
b = c ? { x: c.x + layer.offset.x, y: c.y + layer.offset.y, width: c.width, height: c.height } : null;
|
|
3160
4690
|
}
|
|
3161
4691
|
} else if (layer.type === "group") {
|
|
@@ -3163,7 +4693,7 @@ function layerExtent(layer, surfaceOf, canvas) {
|
|
|
3163
4693
|
} else {
|
|
3164
4694
|
b = full;
|
|
3165
4695
|
}
|
|
3166
|
-
const m =
|
|
4696
|
+
const m = _chunkPOGBUYWEcjs.effectsMargin.call(void 0, layer.effects);
|
|
3167
4697
|
if (b && m > 0) b = { x: b.x - Math.ceil(m), y: b.y - Math.ceil(m), width: b.width + 2 * Math.ceil(m), height: b.height + 2 * Math.ceil(m) };
|
|
3168
4698
|
return b;
|
|
3169
4699
|
}
|
|
@@ -3175,14 +4705,14 @@ function union(a, b) {
|
|
|
3175
4705
|
return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
|
|
3176
4706
|
}
|
|
3177
4707
|
function asSmartFilters(filters) {
|
|
3178
|
-
if (!_optionalChain([filters, 'optionalAccess',
|
|
4708
|
+
if (!_optionalChain([filters, 'optionalAccess', _91 => _91.length])) return void 0;
|
|
3179
4709
|
return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
|
|
3180
4710
|
}
|
|
3181
4711
|
function convertToSmartObject(layers, ids, canvas, options) {
|
|
3182
|
-
if (!ids.length)
|
|
4712
|
+
if (!ids.length) fail3("Give at least one layer id to convert.");
|
|
3183
4713
|
const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
|
|
3184
|
-
const parent = _nullishCoalesce(_optionalChain([locs, 'access',
|
|
3185
|
-
if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access',
|
|
4714
|
+
const parent = _nullishCoalesce(_optionalChain([locs, 'access', _92 => _92[0], 'access', _93 => _93.parent, 'optionalAccess', _94 => _94.id]), () => ( null));
|
|
4715
|
+
if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _95 => _95.parent, 'optionalAccess', _96 => _96.id]), () => ( null))) !== parent)) fail3("Layers to convert must share one parent; move them next to each other first.");
|
|
3186
4716
|
for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
|
|
3187
4717
|
const ordered = locs.sort((a, b) => a.index - b.index);
|
|
3188
4718
|
const top = ordered[ordered.length - 1];
|
|
@@ -3190,16 +4720,16 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
3190
4720
|
const single = ordered.length === 1 ? ordered[0].layer : null;
|
|
3191
4721
|
if (single && single.type === "pixel") {
|
|
3192
4722
|
const surface = options.surfaceOf(single);
|
|
3193
|
-
if (surface.defaultValue !== 0)
|
|
3194
|
-
const b =
|
|
3195
|
-
if (!b)
|
|
4723
|
+
if (surface.defaultValue !== 0) fail3(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
|
|
4724
|
+
const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
|
|
4725
|
+
if (!b) fail3(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
|
|
3196
4726
|
const contents = {
|
|
3197
4727
|
id: newContentsId(),
|
|
3198
4728
|
name: `${single.name || "Layer"}.png`,
|
|
3199
4729
|
width: b.width,
|
|
3200
4730
|
height: b.height,
|
|
3201
4731
|
kind: "raster",
|
|
3202
|
-
raster:
|
|
4732
|
+
raster: _chunkXIOMMGPDcjs.translateSurface.call(void 0, surface, -b.x, -b.y)
|
|
3203
4733
|
};
|
|
3204
4734
|
smart = {
|
|
3205
4735
|
type: "smart",
|
|
@@ -3210,21 +4740,21 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
3210
4740
|
blend: single.blend,
|
|
3211
4741
|
contents,
|
|
3212
4742
|
placement: placementAt(contents, b.x + single.offset.x, b.y + single.offset.y),
|
|
3213
|
-
surface:
|
|
4743
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
3214
4744
|
offset: { x: 0, y: 0 }
|
|
3215
4745
|
};
|
|
3216
4746
|
if (single.clipped) smart.clipped = true;
|
|
3217
4747
|
if (single.fillOpacity !== void 0) smart.fillOpacity = single.fillOpacity;
|
|
3218
4748
|
if (single.effects) smart.effects = single.effects;
|
|
3219
4749
|
if (single.mask) {
|
|
3220
|
-
smart.mask = single.mask.source ? single.mask : { ...single.mask, surface:
|
|
4750
|
+
smart.mask = single.mask.source ? single.mask : { ...single.mask, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, single.mask.surface, single.offset.x, single.offset.y) };
|
|
3221
4751
|
}
|
|
3222
4752
|
const filters = asSmartFilters(single.filters);
|
|
3223
4753
|
if (filters) smart.smartFilters = filters;
|
|
3224
4754
|
} else {
|
|
3225
4755
|
let b = null;
|
|
3226
4756
|
for (const l of ordered) b = union(b, layerExtent(l.layer, options.surfaceOf, canvas));
|
|
3227
|
-
if (!b || !(b.width > 0 && b.height > 0))
|
|
4757
|
+
if (!b || !(b.width > 0 && b.height > 0)) fail3("The layers have no pixels to convert; paint something first.");
|
|
3228
4758
|
const nested = ordered.map((l) => {
|
|
3229
4759
|
let layer = l.layer;
|
|
3230
4760
|
if (layer.type === "pixel" && layer.source === "document") {
|
|
@@ -3232,7 +4762,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
3232
4762
|
delete resolved.source;
|
|
3233
4763
|
layer = resolved;
|
|
3234
4764
|
}
|
|
3235
|
-
if (
|
|
4765
|
+
if (_chunkPOGBUYWEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail3(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
|
|
3236
4766
|
return translateLayer(layer, -b.x, -b.y);
|
|
3237
4767
|
});
|
|
3238
4768
|
if (nested[0].clipped) {
|
|
@@ -3240,7 +4770,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
3240
4770
|
delete first.clipped;
|
|
3241
4771
|
nested[0] = first;
|
|
3242
4772
|
}
|
|
3243
|
-
const name = _optionalChain([options, 'access',
|
|
4773
|
+
const name = _optionalChain([options, 'access', _97 => _97.name, 'optionalAccess', _98 => _98.trim, 'call', _99 => _99()]) || top.layer.name || "Smart Object";
|
|
3244
4774
|
const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
|
|
3245
4775
|
smart = {
|
|
3246
4776
|
type: "smart",
|
|
@@ -3251,16 +4781,16 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
3251
4781
|
blend: "normal",
|
|
3252
4782
|
contents,
|
|
3253
4783
|
placement: placementAt(contents, b.x, b.y),
|
|
3254
|
-
surface:
|
|
4784
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
3255
4785
|
offset: { x: 0, y: 0 }
|
|
3256
4786
|
};
|
|
3257
4787
|
}
|
|
3258
|
-
if (_optionalChain([options, 'access',
|
|
4788
|
+
if (_optionalChain([options, 'access', _100 => _100.name, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()])) smart.name = options.name.trim();
|
|
3259
4789
|
smart = { ...smart, surface: renderSmartObject(smart, canvas) };
|
|
3260
4790
|
const below = ordered.filter((l) => l.index < top.index).length;
|
|
3261
4791
|
let out = layers;
|
|
3262
|
-
for (const l of ordered) out =
|
|
3263
|
-
return { layers:
|
|
4792
|
+
for (const l of ordered) out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
4793
|
+
return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
|
|
3264
4794
|
}
|
|
3265
4795
|
function rasterizeSmartObject(layers, id) {
|
|
3266
4796
|
const layer = requireSmartObject(layers, id);
|
|
@@ -3280,29 +4810,29 @@ function rasterizeSmartObject(layers, id) {
|
|
|
3280
4810
|
if (layer.locks) out.locks = layer.locks;
|
|
3281
4811
|
if (layer.effects) out.effects = layer.effects;
|
|
3282
4812
|
if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
|
|
3283
|
-
return { layers:
|
|
4813
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
|
|
3284
4814
|
}
|
|
3285
4815
|
function copySmartObject(layers, id, linked, name) {
|
|
3286
4816
|
const loc = requireLayer(layers, id);
|
|
3287
4817
|
const layer = requireSmartObject(layers, id);
|
|
3288
|
-
const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess',
|
|
4818
|
+
const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _103 => _103.trim, 'call', _104 => _104()]) || `${layer.name || "Smart Object"} copy` };
|
|
3289
4819
|
delete copy.locks;
|
|
3290
4820
|
delete copy.psd;
|
|
3291
4821
|
if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
|
|
3292
4822
|
if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
|
|
3293
|
-
return { layers:
|
|
4823
|
+
return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _105 => _105.parent, 'optionalAccess', _106 => _106.id]), () => ( null)), loc.index + 1), layer: copy };
|
|
3294
4824
|
}
|
|
3295
4825
|
function instancesOf(layers, contentsId) {
|
|
3296
|
-
return
|
|
4826
|
+
return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
|
|
3297
4827
|
}
|
|
3298
4828
|
function replaceContents(layers, contentsId, contents, canvas) {
|
|
3299
4829
|
const ids = instancesOf(layers, contentsId);
|
|
3300
|
-
if (!ids.length)
|
|
3301
|
-
for (const id of ids) requireUnlocked(
|
|
4830
|
+
if (!ids.length) fail3(`No smart object uses contents "${contentsId}".`);
|
|
4831
|
+
for (const id of ids) requireUnlocked(_chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
|
|
3302
4832
|
const next = { ...contents, id: contentsId };
|
|
3303
4833
|
let out = layers;
|
|
3304
4834
|
for (const id of ids) {
|
|
3305
|
-
out =
|
|
4835
|
+
out = _chunkPOGBUYWEcjs.mapLayer.call(void 0, out, id, (l) => {
|
|
3306
4836
|
const layer = l;
|
|
3307
4837
|
return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
|
|
3308
4838
|
});
|
|
@@ -3326,16 +4856,16 @@ function refitPlacement(layer, contents) {
|
|
|
3326
4856
|
});
|
|
3327
4857
|
const out = { corners: pts };
|
|
3328
4858
|
if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
|
|
3329
|
-
if (layer.placement.warp) out.warp =
|
|
4859
|
+
if (layer.placement.warp) out.warp = _chunkW3GXSUSQcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
|
|
3330
4860
|
return out;
|
|
3331
4861
|
}
|
|
3332
4862
|
function normalizeSmartFilter(raw, id = newLayerId("flt")) {
|
|
3333
|
-
if (raw.kind === "psd")
|
|
4863
|
+
if (raw.kind === "psd") fail3("Photoshop filters can only come from a PSD; add develop or blur.");
|
|
3334
4864
|
const base = normalizeFilter(raw, id);
|
|
3335
4865
|
const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
|
|
3336
|
-
if (!
|
|
4866
|
+
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail3(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
3337
4867
|
const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
|
|
3338
|
-
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1))
|
|
4868
|
+
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail3("opacity must be a number from 0 to 1.");
|
|
3339
4869
|
return { ...base, blend, opacity };
|
|
3340
4870
|
}
|
|
3341
4871
|
function withStack(layer, stack, canvas) {
|
|
@@ -3348,9 +4878,9 @@ function stackOf(layer) {
|
|
|
3348
4878
|
return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
|
|
3349
4879
|
}
|
|
3350
4880
|
function requireFilter(layer, filterId) {
|
|
3351
|
-
const list2 = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
4881
|
+
const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _107 => _107.smartFilters, 'optionalAccess', _108 => _108.filters]), () => ( []));
|
|
3352
4882
|
const i = list2.findIndex((f) => f.id === filterId);
|
|
3353
|
-
if (i === -1)
|
|
4883
|
+
if (i === -1) fail3(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
|
|
3354
4884
|
return i;
|
|
3355
4885
|
}
|
|
3356
4886
|
function editableSmart(layers, id) {
|
|
@@ -3365,21 +4895,21 @@ function addSmartFilter(layers, id, filter, canvas, index) {
|
|
|
3365
4895
|
const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
|
|
3366
4896
|
filters.splice(at, 0, filter);
|
|
3367
4897
|
const next = withStack(layer, { ...stack, filters }, canvas);
|
|
3368
|
-
return { layers:
|
|
4898
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
|
|
3369
4899
|
}
|
|
3370
4900
|
function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
3371
4901
|
const layer = editableSmart(layers, id);
|
|
3372
4902
|
const i = requireFilter(layer, filterId);
|
|
3373
4903
|
const current = layer.smartFilters.filters[i];
|
|
3374
|
-
if ("kind" in changes && changes.kind !== current.kind)
|
|
4904
|
+
if ("kind" in changes && changes.kind !== current.kind) fail3("A smart filter kind cannot change; remove it and add another.");
|
|
3375
4905
|
let merged;
|
|
3376
4906
|
if (current.kind === "psd") {
|
|
3377
4907
|
const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
|
|
3378
|
-
if (extra.length)
|
|
4908
|
+
if (extra.length) fail3(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
|
|
3379
4909
|
const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
|
|
3380
|
-
if (!
|
|
4910
|
+
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail3(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
3381
4911
|
const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
|
|
3382
|
-
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1))
|
|
4912
|
+
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail3("opacity must be a number from 0 to 1.");
|
|
3383
4913
|
merged = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
|
|
3384
4914
|
} else {
|
|
3385
4915
|
merged = normalizeSmartFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
@@ -3387,7 +4917,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
3387
4917
|
const filters = [...layer.smartFilters.filters];
|
|
3388
4918
|
filters[i] = merged;
|
|
3389
4919
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
3390
|
-
return { layers:
|
|
4920
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged };
|
|
3391
4921
|
}
|
|
3392
4922
|
function removeSmartFilter(layers, id, filterId, canvas) {
|
|
3393
4923
|
const layer = editableSmart(layers, id);
|
|
@@ -3395,72 +4925,46 @@ function removeSmartFilter(layers, id, filterId, canvas) {
|
|
|
3395
4925
|
const stack = layer.smartFilters;
|
|
3396
4926
|
const filters = stack.filters.filter((f) => f.id !== filterId);
|
|
3397
4927
|
const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
|
|
3398
|
-
return { layers:
|
|
4928
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
3399
4929
|
}
|
|
3400
4930
|
function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
3401
4931
|
const layer = editableSmart(layers, id);
|
|
3402
4932
|
const i = requireFilter(layer, filterId);
|
|
3403
4933
|
const list2 = layer.smartFilters.filters;
|
|
3404
|
-
if (!Number.isInteger(index) || index < 0 || index >= list2.length)
|
|
4934
|
+
if (!Number.isInteger(index) || index < 0 || index >= list2.length) fail3(`index must be a whole number from 0 to ${list2.length - 1}.`);
|
|
3405
4935
|
const filters = [...list2];
|
|
3406
4936
|
const [f] = filters.splice(i, 1);
|
|
3407
4937
|
filters.splice(index, 0, f);
|
|
3408
4938
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
3409
|
-
return { layers:
|
|
4939
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
3410
4940
|
}
|
|
3411
4941
|
function setSmartFiltersEnabled(layers, id, enabled, canvas) {
|
|
3412
4942
|
const layer = editableSmart(layers, id);
|
|
3413
4943
|
const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
|
|
3414
|
-
return { layers:
|
|
4944
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
3415
4945
|
}
|
|
3416
4946
|
function setSmartFilterMask(layers, id, mask, canvas) {
|
|
3417
4947
|
const layer = editableSmart(layers, id);
|
|
3418
|
-
if (_optionalChain([mask, 'optionalAccess',
|
|
4948
|
+
if (_optionalChain([mask, 'optionalAccess', _109 => _109.source])) fail3("A smart filter mask is painted, not generated; use a raster mask.");
|
|
3419
4949
|
const stack = { ...stackOf(layer) };
|
|
3420
4950
|
if (mask) stack.mask = mask;
|
|
3421
4951
|
else delete stack.mask;
|
|
3422
4952
|
const next = withStack(layer, stack, canvas);
|
|
3423
|
-
return { layers:
|
|
4953
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
3424
4954
|
}
|
|
3425
4955
|
function withFilterMaskSurface(layer, surface, canvas) {
|
|
3426
4956
|
const stack = stackOf(layer);
|
|
3427
|
-
if (!stack.mask)
|
|
4957
|
+
if (!stack.mask) fail3(`Smart object "${layer.name || layer.id}" has no filter mask; add one with set_smart_filter_mask.`);
|
|
3428
4958
|
return withStack(layer, { ...stack, mask: { ...stack.mask, surface } }, canvas);
|
|
3429
4959
|
}
|
|
3430
4960
|
function placementBounds(layer) {
|
|
3431
4961
|
return transformedBox(placementGeometry(layer));
|
|
3432
4962
|
}
|
|
3433
4963
|
|
|
3434
|
-
// src/image-editor/layers/defaults.ts
|
|
3435
|
-
var DEFAULT_ADJUSTMENTS_VALUES = {
|
|
3436
|
-
brightness: 0,
|
|
3437
|
-
contrast: 0,
|
|
3438
|
-
saturation: 0,
|
|
3439
|
-
exposure: 0,
|
|
3440
|
-
temperature: 0,
|
|
3441
|
-
tint: 0,
|
|
3442
|
-
blur: 0,
|
|
3443
|
-
opacity: 1,
|
|
3444
|
-
process: LATEST_PROCESS_VERSION
|
|
3445
|
-
};
|
|
3446
|
-
var DEFAULT_TRANSFORM_VALUES = {
|
|
3447
|
-
rotate: 0,
|
|
3448
|
-
flipH: false,
|
|
3449
|
-
flipV: false
|
|
3450
|
-
};
|
|
3451
|
-
var DEFAULT_DEPTH_MASK_VALUES = {
|
|
3452
|
-
enabled: false,
|
|
3453
|
-
maskSource: null,
|
|
3454
|
-
mode: "threshold",
|
|
3455
|
-
depthRange: [0, 255],
|
|
3456
|
-
softness: 10,
|
|
3457
|
-
invert: false
|
|
3458
|
-
};
|
|
3459
|
-
|
|
3460
4964
|
// src/image-editor/layers/serialize.ts
|
|
3461
4965
|
var LAYERED_SCHEMA_VERSION = 3;
|
|
3462
4966
|
function serializePatterns(patterns) {
|
|
3463
|
-
return patterns.map((p) => ({ id: p.id, name: p.name, png:
|
|
4967
|
+
return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkPOGBUYWEcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
|
|
3464
4968
|
}
|
|
3465
4969
|
function deserializePatterns(raw, problems = []) {
|
|
3466
4970
|
if (!Array.isArray(raw)) return [];
|
|
@@ -3479,11 +4983,11 @@ function deserializePatterns(raw, problems = []) {
|
|
|
3479
4983
|
var encodedCache = /* @__PURE__ */ new WeakMap();
|
|
3480
4984
|
function encodeSurface(surface) {
|
|
3481
4985
|
if (encodedCache.has(surface)) return encodedCache.get(surface);
|
|
3482
|
-
const b =
|
|
4986
|
+
const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
|
|
3483
4987
|
let out = null;
|
|
3484
4988
|
if (b) {
|
|
3485
|
-
const data =
|
|
3486
|
-
out = { url:
|
|
4989
|
+
const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, surface, b);
|
|
4990
|
+
out = { url: _chunkPOGBUYWEcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
|
|
3487
4991
|
}
|
|
3488
4992
|
encodedCache.set(surface, out);
|
|
3489
4993
|
return out;
|
|
@@ -3505,7 +5009,7 @@ function baseFields(layer, ctx) {
|
|
|
3505
5009
|
function serializeEffects(effects) {
|
|
3506
5010
|
const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
|
|
3507
5011
|
if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
|
|
3508
|
-
if (effects.psd) out.psd = { key: effects.psd.key, data:
|
|
5012
|
+
if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, effects.psd.data) };
|
|
3509
5013
|
return out;
|
|
3510
5014
|
}
|
|
3511
5015
|
function deserializeEffects(raw) {
|
|
@@ -3515,12 +5019,12 @@ function deserializeEffects(raw) {
|
|
|
3515
5019
|
const p = r.psd;
|
|
3516
5020
|
if (p && typeof p.key === "string" && typeof p.data === "string") {
|
|
3517
5021
|
try {
|
|
3518
|
-
psd = { key: p.key, data:
|
|
3519
|
-
} catch (
|
|
5022
|
+
psd = { key: p.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, p.data) };
|
|
5023
|
+
} catch (e6) {
|
|
3520
5024
|
psd = void 0;
|
|
3521
5025
|
}
|
|
3522
5026
|
}
|
|
3523
|
-
return
|
|
5027
|
+
return _chunkPOGBUYWEcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
|
|
3524
5028
|
}
|
|
3525
5029
|
function serializeMask(mask, hint, ctx) {
|
|
3526
5030
|
const out = { defaultValue: mask.defaultValue };
|
|
@@ -3555,7 +5059,7 @@ function serializeLayer(layer, ctx) {
|
|
|
3555
5059
|
}
|
|
3556
5060
|
}
|
|
3557
5061
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
3558
|
-
if (_optionalChain([layer, 'access',
|
|
5062
|
+
if (_optionalChain([layer, 'access', _110 => _110.filters, 'optionalAccess', _111 => _111.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
|
|
3559
5063
|
return out;
|
|
3560
5064
|
}
|
|
3561
5065
|
case "adjustment":
|
|
@@ -3569,12 +5073,66 @@ function serializeLayer(layer, ctx) {
|
|
|
3569
5073
|
return { ...base, type: "annotation", annotation: JSON.parse(JSON.stringify(layer.annotation)) };
|
|
3570
5074
|
case "smart":
|
|
3571
5075
|
return serializeSmartObject(layer, base, ctx);
|
|
5076
|
+
case "shape":
|
|
5077
|
+
return serializeShape(layer, base);
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
function serializeShape(layer, base) {
|
|
5081
|
+
const out = {
|
|
5082
|
+
...base,
|
|
5083
|
+
type: "shape",
|
|
5084
|
+
components: JSON.parse(JSON.stringify(layer.components)),
|
|
5085
|
+
fill: layer.fill ? JSON.parse(JSON.stringify(layer.fill)) : null,
|
|
5086
|
+
stroke: layer.stroke ? JSON.parse(JSON.stringify(layer.stroke)) : null
|
|
5087
|
+
};
|
|
5088
|
+
if (layer.fillRule === "evenodd") out.fillRule = "evenodd";
|
|
5089
|
+
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5090
|
+
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5091
|
+
if (_optionalChain([layer, 'access', _112 => _112.psd, 'optionalAccess', _113 => _113.blocks, 'optionalAccess', _114 => _114.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, b.data) })) };
|
|
5092
|
+
return out;
|
|
5093
|
+
}
|
|
5094
|
+
function readShape(r, base, ctx) {
|
|
5095
|
+
const label = `Layer "${base.name || base.id}"`;
|
|
5096
|
+
const canvas = _nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 }));
|
|
5097
|
+
const env = { ...canvas, pattern: ctx.pattern };
|
|
5098
|
+
try {
|
|
5099
|
+
let data = null;
|
|
5100
|
+
const a = r.annotation && typeof r.annotation === "object" && typeof r.annotation.type === "string" ? JSON.parse(JSON.stringify({ ...r.annotation, id: _nullishCoalesce(r.annotation.id, () => ( base.id)) })) : void 0;
|
|
5101
|
+
if (a) data = shapeFromAnnotation(a);
|
|
5102
|
+
if (!data) {
|
|
5103
|
+
if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
|
|
5104
|
+
const components = r.components.map((c, i) => {
|
|
5105
|
+
const op = requireOperation(_optionalChain([c, 'optionalAccess', _115 => _115.op]), `components[${i}].op`);
|
|
5106
|
+
if (_optionalChain([c, 'optionalAccess', _116 => _116.live])) {
|
|
5107
|
+
const live = normalizeLiveShape(c.live, `components[${i}].live`);
|
|
5108
|
+
return { op, subpaths: liveShapeSubpaths(live), live };
|
|
5109
|
+
}
|
|
5110
|
+
return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _117 => _117.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _118 => _118.subpaths]), `components[${i}].subpaths`) };
|
|
5111
|
+
});
|
|
5112
|
+
data = {
|
|
5113
|
+
components,
|
|
5114
|
+
fill: r.fill === null || r.fill === void 0 ? null : normalizeShapePaint(r.fill, "fill"),
|
|
5115
|
+
stroke: r.stroke === null || r.stroke === void 0 ? null : normalizeShapeStroke(r.stroke, "stroke")
|
|
5116
|
+
};
|
|
5117
|
+
}
|
|
5118
|
+
const layer = createShapeLayer({ ...data, fillRule: r.fillRule === "evenodd" ? "evenodd" : "nonzero" }, env, base.id);
|
|
5119
|
+
const out = { ...layer, ...base, type: "shape", components: layer.components, fill: layer.fill, stroke: layer.stroke, surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
5120
|
+
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num(r.fillOpacity, 0, 1, 1);
|
|
5121
|
+
if (a && shapeFromAnnotation(a)) out.annotation = a;
|
|
5122
|
+
if (r.psd && Array.isArray(r.psd.blocks)) {
|
|
5123
|
+
const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5124
|
+
if (blocks.length) out.psd = { blocks };
|
|
5125
|
+
}
|
|
5126
|
+
return out;
|
|
5127
|
+
} catch (e) {
|
|
5128
|
+
ctx.problems.push(`${label}: the shape could not be read (${e instanceof Error ? e.message : String(e)})`);
|
|
5129
|
+
return null;
|
|
3572
5130
|
}
|
|
3573
5131
|
}
|
|
3574
5132
|
function serializeSmartFilters(stack, layerId, ctx) {
|
|
3575
5133
|
const out = {
|
|
3576
5134
|
enabled: stack.enabled,
|
|
3577
|
-
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data:
|
|
5135
|
+
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
|
|
3578
5136
|
};
|
|
3579
5137
|
if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
|
|
3580
5138
|
return out;
|
|
@@ -3600,7 +5158,7 @@ function serializeSmartObject(layer, base, ctx) {
|
|
|
3600
5158
|
}
|
|
3601
5159
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
3602
5160
|
if (layer.psd) {
|
|
3603
|
-
out.psd = { key: layer.psd.key, data:
|
|
5161
|
+
out.psd = { key: layer.psd.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.data) };
|
|
3604
5162
|
if (layer.psd.placed) out.psd.placed = layer.psd.placed;
|
|
3605
5163
|
}
|
|
3606
5164
|
return out;
|
|
@@ -3611,17 +5169,17 @@ function serializeContents(c, ctx) {
|
|
|
3611
5169
|
const enc = encodeSurface(c.raster);
|
|
3612
5170
|
if (enc) {
|
|
3613
5171
|
if (enc.x !== 0 || enc.y !== 0) {
|
|
3614
|
-
const data =
|
|
3615
|
-
out.asset = ctx.addAsset(
|
|
5172
|
+
const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
|
|
5173
|
+
out.asset = ctx.addAsset(_chunkPOGBUYWEcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
|
|
3616
5174
|
} else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
|
|
3617
5175
|
}
|
|
3618
5176
|
}
|
|
3619
5177
|
if (c.kind === "document" && c.document) {
|
|
3620
5178
|
out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
|
|
3621
5179
|
if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
|
|
3622
|
-
if (_optionalChain([c, 'access',
|
|
5180
|
+
if (_optionalChain([c, 'access', _119 => _119.document, 'access', _120 => _120.patterns, 'optionalAccess', _121 => _121.length])) out.patterns = serializePatterns(c.document.patterns);
|
|
3623
5181
|
}
|
|
3624
|
-
if (c.file) out.file = { type: c.file.type, data:
|
|
5182
|
+
if (c.file) out.file = { type: c.file.type, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, c.file.bytes) };
|
|
3625
5183
|
if (c.linked) out.linked = { path: c.linked.path };
|
|
3626
5184
|
return out;
|
|
3627
5185
|
}
|
|
@@ -3657,7 +5215,7 @@ async function serializeLayersExternal(layers, store) {
|
|
|
3657
5215
|
for (const [id, url] of Object.entries(inline.assets)) {
|
|
3658
5216
|
let ref = refs.get(url);
|
|
3659
5217
|
if (!ref) {
|
|
3660
|
-
const parsed =
|
|
5218
|
+
const parsed = _chunkPOGBUYWEcjs.parseDataUrl.call(void 0, url);
|
|
3661
5219
|
const png = decodePngHeader(parsed.bytes);
|
|
3662
5220
|
ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
|
|
3663
5221
|
if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
|
|
@@ -3685,7 +5243,7 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
3685
5243
|
try {
|
|
3686
5244
|
const blob = await store.get(ref);
|
|
3687
5245
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
3688
|
-
out[id] = `data:image/png;base64,${
|
|
5246
|
+
out[id] = `data:image/png;base64,${_chunkPOGBUYWEcjs.bytesToBase64.call(void 0, bytes)}`;
|
|
3689
5247
|
} catch (err) {
|
|
3690
5248
|
problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
|
|
3691
5249
|
}
|
|
@@ -3693,9 +5251,9 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
3693
5251
|
return out;
|
|
3694
5252
|
}
|
|
3695
5253
|
function decodePngDataUrl(url, channels) {
|
|
3696
|
-
const parsed =
|
|
5254
|
+
const parsed = _chunkPOGBUYWEcjs.parseDataUrl.call(void 0, url);
|
|
3697
5255
|
if (!parsed) throw new Error("Asset is not a data URL.");
|
|
3698
|
-
const png =
|
|
5256
|
+
const png = _chunkPOGBUYWEcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
|
|
3699
5257
|
if (png.channels === channels) return png;
|
|
3700
5258
|
if (channels === 1) {
|
|
3701
5259
|
const out2 = new Uint8ClampedArray(png.width * png.height);
|
|
@@ -3713,18 +5271,18 @@ function decodePngDataUrl(url, channels) {
|
|
|
3713
5271
|
}
|
|
3714
5272
|
var num = (v, lo, hi, fallback) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : fallback;
|
|
3715
5273
|
function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
|
|
3716
|
-
if (typeof ref !== "string" || !ref) return
|
|
5274
|
+
if (typeof ref !== "string" || !ref) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
3717
5275
|
const url = ctx.assets[ref];
|
|
3718
5276
|
if (typeof url !== "string") {
|
|
3719
5277
|
ctx.problems.push(`${what}: asset "${ref}" is missing`);
|
|
3720
|
-
return
|
|
5278
|
+
return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
3721
5279
|
}
|
|
3722
5280
|
try {
|
|
3723
5281
|
const px = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
|
|
3724
|
-
return
|
|
5282
|
+
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(num(x, -1e7, 1e7, 0)), Math.round(num(y, -1e7, 1e7, 0)), defaultValue);
|
|
3725
5283
|
} catch (err) {
|
|
3726
5284
|
ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
|
|
3727
|
-
return
|
|
5285
|
+
return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
3728
5286
|
}
|
|
3729
5287
|
}
|
|
3730
5288
|
function readMask(raw, ctx, what) {
|
|
@@ -3732,7 +5290,7 @@ function readMask(raw, ctx, what) {
|
|
|
3732
5290
|
const r = raw;
|
|
3733
5291
|
const defaultValue = r.defaultValue === 255 ? 255 : 0;
|
|
3734
5292
|
const mask = {
|
|
3735
|
-
surface: r.source ?
|
|
5293
|
+
surface: r.source ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
|
|
3736
5294
|
defaultValue: r.source ? 255 : defaultValue
|
|
3737
5295
|
};
|
|
3738
5296
|
if (typeof r.density === "number" && r.density !== 1) mask.density = num(r.density, 0, 1, 1);
|
|
@@ -3780,7 +5338,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
3780
5338
|
name: typeof r.name === "string" ? r.name : "",
|
|
3781
5339
|
visible: r.visible !== false,
|
|
3782
5340
|
opacity: num(r.opacity, 0, 1, 1),
|
|
3783
|
-
blend:
|
|
5341
|
+
blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend)
|
|
3784
5342
|
};
|
|
3785
5343
|
if (r.clipped === true) base.clipped = true;
|
|
3786
5344
|
const mask = readMask(r.mask, ctx, `Layer "${base.name || id}"`);
|
|
@@ -3797,8 +5355,8 @@ function deserializeLayer(raw, ctx) {
|
|
|
3797
5355
|
const layer = {
|
|
3798
5356
|
...base,
|
|
3799
5357
|
type: "pixel",
|
|
3800
|
-
surface: r.source === "document" ?
|
|
3801
|
-
offset: { x: Math.round(num(_optionalChain([r, 'access',
|
|
5358
|
+
surface: r.source === "document" ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
|
|
5359
|
+
offset: { x: Math.round(num(_optionalChain([r, 'access', _122 => _122.offset, 'optionalAccess', _123 => _123.x]), -1e7, 1e7, 0)), y: Math.round(num(_optionalChain([r, 'access', _124 => _124.offset, 'optionalAccess', _125 => _125.y]), -1e7, 1e7, 0)) }
|
|
3802
5360
|
};
|
|
3803
5361
|
if (r.source === "document") layer.source = "document";
|
|
3804
5362
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num(r.fillOpacity, 0, 1, 1);
|
|
@@ -3816,7 +5374,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
3816
5374
|
}
|
|
3817
5375
|
case "group": {
|
|
3818
5376
|
const children = Array.isArray(r.children) ? r.children.map((c) => deserializeLayer(c, ctx)).filter(Boolean) : [];
|
|
3819
|
-
const blend = r.blend === "pass-through" ? "pass-through" :
|
|
5377
|
+
const blend = r.blend === "pass-through" ? "pass-through" : _chunkXIOMMGPDcjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
|
|
3820
5378
|
const group = { ...base, type: "group", blend, children };
|
|
3821
5379
|
if (r.collapsed === true) group.collapsed = true;
|
|
3822
5380
|
return group;
|
|
@@ -3827,8 +5385,16 @@ function deserializeLayer(raw, ctx) {
|
|
|
3827
5385
|
ctx.problems.push(`Layer "${base.name || id}": annotation is missing`);
|
|
3828
5386
|
return null;
|
|
3829
5387
|
}
|
|
3830
|
-
|
|
5388
|
+
const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
|
|
5389
|
+
const migrated = annotationLayerFor(annotation, _nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })));
|
|
5390
|
+
if (migrated.type === "shape") {
|
|
5391
|
+
const blend = base.blend === "normal" ? migrated.blend : base.blend;
|
|
5392
|
+
return { ...migrated, ...base, blend, type: "shape", id, name: base.name };
|
|
5393
|
+
}
|
|
5394
|
+
return { ...base, type: "annotation", annotation };
|
|
3831
5395
|
}
|
|
5396
|
+
case "shape":
|
|
5397
|
+
return readShape(r, base, ctx);
|
|
3832
5398
|
case "smart":
|
|
3833
5399
|
return readSmartObject(r, base, ctx);
|
|
3834
5400
|
default:
|
|
@@ -3858,15 +5424,15 @@ function readContents(id, ctx) {
|
|
|
3858
5424
|
const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
|
|
3859
5425
|
if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
|
|
3860
5426
|
try {
|
|
3861
|
-
c.file = { type: raw.file.type, bytes:
|
|
3862
|
-
} catch (
|
|
5427
|
+
c.file = { type: raw.file.type, bytes: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, raw.file.data) };
|
|
5428
|
+
} catch (e7) {
|
|
3863
5429
|
ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
|
|
3864
5430
|
}
|
|
3865
5431
|
}
|
|
3866
5432
|
if (raw.linked && typeof raw.linked.path === "string") c.linked = { path: raw.linked.path };
|
|
3867
5433
|
if (c.kind === "raster") {
|
|
3868
5434
|
if (typeof raw.asset === "string") c.raster = readSurface(raw.asset, 0, 0, 4, 0, ctx, `Smart object contents "${c.name}"`);
|
|
3869
|
-
else if (!c.file) c.raster =
|
|
5435
|
+
else if (!c.file) c.raster = _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
3870
5436
|
} else {
|
|
3871
5437
|
const outer = ctx.canvas;
|
|
3872
5438
|
ctx.canvas = { width, height };
|
|
@@ -3889,12 +5455,12 @@ function readSmartFilters(raw, ctx, what) {
|
|
|
3889
5455
|
let k = 0;
|
|
3890
5456
|
for (const f of list2) {
|
|
3891
5457
|
if (!f || typeof f !== "object") continue;
|
|
3892
|
-
const blend =
|
|
5458
|
+
const blend = _chunkXIOMMGPDcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
|
|
3893
5459
|
const opacity = num(f.opacity, 0, 1, 1);
|
|
3894
5460
|
if (f.kind === "psd") {
|
|
3895
5461
|
try {
|
|
3896
|
-
filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data:
|
|
3897
|
-
} catch (
|
|
5462
|
+
filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
|
|
5463
|
+
} catch (e8) {
|
|
3898
5464
|
ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
|
|
3899
5465
|
}
|
|
3900
5466
|
} else if (f.kind === "develop" || f.kind === "blur") {
|
|
@@ -3918,22 +5484,22 @@ function readSmartObject(r, base, ctx) {
|
|
|
3918
5484
|
let placement;
|
|
3919
5485
|
try {
|
|
3920
5486
|
const raw = { corners: p.corners };
|
|
3921
|
-
if (p.warp &&
|
|
3922
|
-
if (
|
|
5487
|
+
if (p.warp && _chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
|
|
5488
|
+
if (_chunkPOGBUYWEcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
|
|
3923
5489
|
placement = normalizePlacement(raw, contents);
|
|
3924
5490
|
} catch (e) {
|
|
3925
5491
|
ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
|
|
3926
5492
|
placement = { corners: [{ x: 0, y: 0 }, { x: contents.width, y: 0 }, { x: contents.width, y: contents.height }, { x: 0, y: contents.height }] };
|
|
3927
5493
|
}
|
|
3928
|
-
const layer = { ...base, type: "smart", contents, placement, surface:
|
|
5494
|
+
const layer = { ...base, type: "smart", contents, placement, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
|
|
3929
5495
|
const filters = readSmartFilters(r.smartFilters, ctx, what);
|
|
3930
5496
|
if (filters) layer.smartFilters = filters;
|
|
3931
5497
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num(r.fillOpacity, 0, 1, 1);
|
|
3932
5498
|
if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
|
|
3933
5499
|
try {
|
|
3934
|
-
layer.psd = { key: r.psd.key, data:
|
|
5500
|
+
layer.psd = { key: r.psd.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.data) };
|
|
3935
5501
|
if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
|
|
3936
|
-
} catch (
|
|
5502
|
+
} catch (e9) {
|
|
3937
5503
|
}
|
|
3938
5504
|
}
|
|
3939
5505
|
if (typeof r.asset === "string") layer.surface = readSurface(r.asset, r.x, r.y, 4, 0, ctx, what);
|
|
@@ -4176,7 +5742,7 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
|
|
|
4176
5742
|
function decodeLegacyName(b) {
|
|
4177
5743
|
try {
|
|
4178
5744
|
return new TextDecoder("utf-8", { fatal: true }).decode(b);
|
|
4179
|
-
} catch (
|
|
5745
|
+
} catch (e10) {
|
|
4180
5746
|
return String.fromCharCode(...b);
|
|
4181
5747
|
}
|
|
4182
5748
|
}
|
|
@@ -4255,9 +5821,9 @@ function packbitsDecodeInto(src, expected, out, at) {
|
|
|
4255
5821
|
function inflateChecked(data, expected) {
|
|
4256
5822
|
let out;
|
|
4257
5823
|
try {
|
|
4258
|
-
out =
|
|
5824
|
+
out = _chunkPOGBUYWEcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
4259
5825
|
} catch (e) {
|
|
4260
|
-
throw new PsdError(`ZIP channel data: ${e instanceof
|
|
5826
|
+
throw new PsdError(`ZIP channel data: ${e instanceof _chunkPOGBUYWEcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
4261
5827
|
}
|
|
4262
5828
|
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
4263
5829
|
return out.length === expected ? out : out.subarray(0, expected);
|
|
@@ -4353,7 +5919,7 @@ function descriptor(classId, items = []) {
|
|
|
4353
5919
|
return { name: "", classId, items };
|
|
4354
5920
|
}
|
|
4355
5921
|
function descGet(d, key) {
|
|
4356
|
-
return _optionalChain([d, 'access',
|
|
5922
|
+
return _optionalChain([d, 'access', _126 => _126.items, 'access', _127 => _127.find, 'call', _128 => _128(([k]) => k === key), 'optionalAccess', _129 => _129[1]]);
|
|
4357
5923
|
}
|
|
4358
5924
|
function descNumber(d, key) {
|
|
4359
5925
|
const v = descGet(d, key);
|
|
@@ -4363,7 +5929,7 @@ function descNumber(d, key) {
|
|
|
4363
5929
|
}
|
|
4364
5930
|
function descBool(d, key) {
|
|
4365
5931
|
const v = descGet(d, key);
|
|
4366
|
-
return _optionalChain([v, 'optionalAccess',
|
|
5932
|
+
return _optionalChain([v, 'optionalAccess', _130 => _130.type]) === "bool" ? v.value : void 0;
|
|
4367
5933
|
}
|
|
4368
5934
|
function descObject(d, key) {
|
|
4369
5935
|
const v = descGet(d, key);
|
|
@@ -4834,7 +6400,7 @@ function parseAdjustmentBlock(key, data) {
|
|
|
4834
6400
|
default:
|
|
4835
6401
|
return null;
|
|
4836
6402
|
}
|
|
4837
|
-
} catch (
|
|
6403
|
+
} catch (e11) {
|
|
4838
6404
|
return null;
|
|
4839
6405
|
}
|
|
4840
6406
|
}
|
|
@@ -4955,15 +6521,15 @@ var textV = (value) => ({ type: "TEXT", value });
|
|
|
4955
6521
|
var obj = (d) => ({ type: "Objc", value: d });
|
|
4956
6522
|
var text = (d, key) => {
|
|
4957
6523
|
const v = descGet(d, key);
|
|
4958
|
-
return _optionalChain([v, 'optionalAccess',
|
|
6524
|
+
return _optionalChain([v, 'optionalAccess', _131 => _131.type]) === "TEXT" ? v.value : void 0;
|
|
4959
6525
|
};
|
|
4960
6526
|
var enumOf = (d, key) => {
|
|
4961
6527
|
const v = descGet(d, key);
|
|
4962
|
-
return _optionalChain([v, 'optionalAccess',
|
|
6528
|
+
return _optionalChain([v, 'optionalAccess', _132 => _132.type]) === "enum" ? v.value : void 0;
|
|
4963
6529
|
};
|
|
4964
6530
|
var numbers = (d, key) => {
|
|
4965
6531
|
const v = descGet(d, key);
|
|
4966
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
6532
|
+
if (_optionalChain([v, 'optionalAccess', _133 => _133.type]) !== "VlLs") return null;
|
|
4967
6533
|
const out = [];
|
|
4968
6534
|
for (const it of v.items) {
|
|
4969
6535
|
if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
|
|
@@ -5007,7 +6573,7 @@ function readLinkedItem(item) {
|
|
|
5007
6573
|
try {
|
|
5008
6574
|
const d = readVersionedDescriptor(r);
|
|
5009
6575
|
path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
|
|
5010
|
-
} catch (
|
|
6576
|
+
} catch (e12) {
|
|
5011
6577
|
path = void 0;
|
|
5012
6578
|
}
|
|
5013
6579
|
void version;
|
|
@@ -5024,7 +6590,7 @@ function parseLinkedFiles(data) {
|
|
|
5024
6590
|
try {
|
|
5025
6591
|
const item = readLinkedItem(data.subarray(at + 8, at + 8 + len));
|
|
5026
6592
|
if (item) out.push(item);
|
|
5027
|
-
} catch (
|
|
6593
|
+
} catch (e13) {
|
|
5028
6594
|
}
|
|
5029
6595
|
at = at + 8 + len + 3 & ~3;
|
|
5030
6596
|
}
|
|
@@ -5151,21 +6717,21 @@ function filterMaskFromItem(item) {
|
|
|
5151
6717
|
const height = rect.bottom - rect.top;
|
|
5152
6718
|
if (!(width > 0 && height > 0) || width * height > 1 << 28) return null;
|
|
5153
6719
|
const bytes = decodePlanes(plane.compression, plane.data, { planes: 1, width, height, depth: 8, psb: true });
|
|
5154
|
-
const surface =
|
|
6720
|
+
const surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: bytes }, 1, rect.left, rect.top, 255);
|
|
5155
6721
|
return { surface, defaultValue: 255 };
|
|
5156
6722
|
}
|
|
5157
6723
|
function filterMaskItem(placed, mask, area) {
|
|
5158
|
-
const painted =
|
|
6724
|
+
const painted = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
|
|
5159
6725
|
let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
5160
6726
|
if (mask.defaultValue !== 255 && area) {
|
|
5161
|
-
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
5162
|
-
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
6727
|
+
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _134 => _134.x]), () => ( area.x)));
|
|
6728
|
+
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _135 => _135.y]), () => ( area.y)));
|
|
5163
6729
|
const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
|
|
5164
6730
|
const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
|
|
5165
6731
|
b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
5166
6732
|
}
|
|
5167
6733
|
const rect = { top: b.y, left: b.x, bottom: b.y + b.height, right: b.x + b.width };
|
|
5168
|
-
const values =
|
|
6734
|
+
const values = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, b);
|
|
5169
6735
|
const plane = new Uint8Array(values.buffer, values.byteOffset, values.length);
|
|
5170
6736
|
return {
|
|
5171
6737
|
id: placed,
|
|
@@ -5179,8 +6745,8 @@ function filterMaskItem(placed, mask, area) {
|
|
|
5179
6745
|
}
|
|
5180
6746
|
var warpStyleOf = (name) => {
|
|
5181
6747
|
if (!name.startsWith("warp")) return null;
|
|
5182
|
-
const s = _optionalChain([name, 'access',
|
|
5183
|
-
return
|
|
6748
|
+
const s = _optionalChain([name, 'access', _136 => _136[4], 'optionalAccess', _137 => _137.toLowerCase, 'call', _138 => _138()]) + name.slice(5);
|
|
6749
|
+
return _chunkW3GXSUSQcjs.WARP_STYLES.includes(s) ? s : null;
|
|
5184
6750
|
};
|
|
5185
6751
|
function warpFromDescriptor(w, contents) {
|
|
5186
6752
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
@@ -5201,7 +6767,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
5201
6767
|
if (!arr || arr.type !== "ObAr") return void 0;
|
|
5202
6768
|
const xs = descGet(arr.body, "Hrzn");
|
|
5203
6769
|
const ys = descGet(arr.body, "Vrtc");
|
|
5204
|
-
if (_optionalChain([xs, 'optionalAccess',
|
|
6770
|
+
if (_optionalChain([xs, 'optionalAccess', _139 => _139.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _140 => _140.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
|
|
5205
6771
|
mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
|
|
5206
6772
|
const px = mesh.points.map((p) => p.x);
|
|
5207
6773
|
const py = mesh.points.map((p) => p.y);
|
|
@@ -5210,7 +6776,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
5210
6776
|
} else {
|
|
5211
6777
|
const style = warpStyleOf(styleName);
|
|
5212
6778
|
if (!style) return void 0;
|
|
5213
|
-
mesh =
|
|
6779
|
+
mesh = _chunkW3GXSUSQcjs.warpPresetMesh.call(void 0,
|
|
5214
6780
|
{
|
|
5215
6781
|
style,
|
|
5216
6782
|
bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
|
|
@@ -5225,7 +6791,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
5225
6791
|
const same = Math.abs(bounds.x) < 1e-6 && Math.abs(bounds.y) < 1e-6 && Math.abs(bounds.width - contents.width) < 1e-6 && Math.abs(bounds.height - contents.height) < 1e-6;
|
|
5226
6792
|
if (!same) {
|
|
5227
6793
|
const m = mesh;
|
|
5228
|
-
mesh =
|
|
6794
|
+
mesh = _chunkW3GXSUSQcjs.fitWarpMesh.call(void 0, (s, t) => _chunkW3GXSUSQcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
|
|
5229
6795
|
}
|
|
5230
6796
|
return { mesh, frame };
|
|
5231
6797
|
}
|
|
@@ -5322,13 +6888,13 @@ function parsePlaced(key, data) {
|
|
|
5322
6888
|
r.u32();
|
|
5323
6889
|
try {
|
|
5324
6890
|
warp = readVersionedDescriptor(r);
|
|
5325
|
-
} catch (
|
|
6891
|
+
} catch (e14) {
|
|
5326
6892
|
warp = void 0;
|
|
5327
6893
|
}
|
|
5328
6894
|
}
|
|
5329
6895
|
return { key, idnt, placed: idnt, quad, warp };
|
|
5330
6896
|
}
|
|
5331
|
-
} catch (
|
|
6897
|
+
} catch (e15) {
|
|
5332
6898
|
return null;
|
|
5333
6899
|
}
|
|
5334
6900
|
return null;
|
|
@@ -5368,13 +6934,13 @@ function blendOptions(f) {
|
|
|
5368
6934
|
function smartFiltersFromPsd(fx, newId, notes) {
|
|
5369
6935
|
const filters = [];
|
|
5370
6936
|
const list2 = descGet(fx, "filterFXList");
|
|
5371
|
-
for (const v of _optionalChain([list2, 'optionalAccess',
|
|
6937
|
+
for (const v of _optionalChain([list2, 'optionalAccess', _141 => _141.type]) === "VlLs" ? list2.items : []) {
|
|
5372
6938
|
if (v.type !== "Objc" && v.type !== "GlbO") continue;
|
|
5373
6939
|
const item = v.value;
|
|
5374
6940
|
const { blend, opacity } = blendOptionsOf(item);
|
|
5375
6941
|
const enabled = descBool(item, "enab") !== false;
|
|
5376
6942
|
const fltr = descObject(item, "Fltr");
|
|
5377
|
-
const radius = _optionalChain([fltr, 'optionalAccess',
|
|
6943
|
+
const radius = _optionalChain([fltr, 'optionalAccess', _142 => _142.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
|
|
5378
6944
|
if (radius !== void 0 && radius >= 0 && radius <= 50) {
|
|
5379
6945
|
filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
|
|
5380
6946
|
continue;
|
|
@@ -5653,7 +7219,7 @@ function parseMask(d) {
|
|
|
5653
7219
|
}
|
|
5654
7220
|
if (!realFirst) m.real = readReal();
|
|
5655
7221
|
return m;
|
|
5656
|
-
} catch (
|
|
7222
|
+
} catch (e16) {
|
|
5657
7223
|
return void 0;
|
|
5658
7224
|
}
|
|
5659
7225
|
}
|
|
@@ -5727,14 +7293,14 @@ function readPsd(bytes) {
|
|
|
5727
7293
|
return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
|
|
5728
7294
|
}
|
|
5729
7295
|
function layerBlock(rec, key) {
|
|
5730
|
-
return _optionalChain([rec, 'access',
|
|
7296
|
+
return _optionalChain([rec, 'access', _143 => _143.blocks, 'access', _144 => _144.find, 'call', _145 => _145((b) => b.key === key), 'optionalAccess', _146 => _146.data]);
|
|
5731
7297
|
}
|
|
5732
7298
|
function layerName(rec) {
|
|
5733
7299
|
const luni = layerBlock(rec, "luni");
|
|
5734
7300
|
if (luni) {
|
|
5735
7301
|
try {
|
|
5736
7302
|
return new PsdReader(luni).unicode();
|
|
5737
|
-
} catch (
|
|
7303
|
+
} catch (e17) {
|
|
5738
7304
|
}
|
|
5739
7305
|
}
|
|
5740
7306
|
return rec.legacyName;
|
|
@@ -5758,7 +7324,7 @@ function u8Block(rec, key) {
|
|
|
5758
7324
|
function layerTree(file) {
|
|
5759
7325
|
const stack = [[]];
|
|
5760
7326
|
file.layers.forEach((rec, index) => {
|
|
5761
|
-
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call',
|
|
7327
|
+
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _147 => _147(rec), 'optionalAccess', _148 => _148.kind]), () => ( SECTION_OTHER));
|
|
5762
7328
|
if (kind === SECTION_DIVIDER) {
|
|
5763
7329
|
stack.push([]);
|
|
5764
7330
|
} else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
|
|
@@ -5776,7 +7342,7 @@ function layerTree(file) {
|
|
|
5776
7342
|
}
|
|
5777
7343
|
function channelRect(rec, id) {
|
|
5778
7344
|
if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
|
|
5779
|
-
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access',
|
|
7345
|
+
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _149 => _149.mask, 'access', _150 => _150.real, 'optionalAccess', _151 => _151.rect]), () => ( rec.mask.rect));
|
|
5780
7346
|
return rec.rect;
|
|
5781
7347
|
}
|
|
5782
7348
|
function decodeLayerChannel(file, rec, id) {
|
|
@@ -5794,7 +7360,7 @@ function decodeMergedImage(file) {
|
|
|
5794
7360
|
return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
|
|
5795
7361
|
}
|
|
5796
7362
|
function resource(file, id) {
|
|
5797
|
-
return _optionalChain([file, 'access',
|
|
7363
|
+
return _optionalChain([file, 'access', _152 => _152.resources, 'access', _153 => _153.find, 'call', _154 => _154((r) => r.id === id), 'optionalAccess', _155 => _155.data]);
|
|
5798
7364
|
}
|
|
5799
7365
|
function resolution(file) {
|
|
5800
7366
|
const d = resource(file, 1005);
|
|
@@ -6297,11 +7863,11 @@ function safeSize(ctx, rect, name) {
|
|
|
6297
7863
|
}
|
|
6298
7864
|
function recordPixels(ctx, rec, name) {
|
|
6299
7865
|
const { width, height } = safeSize(ctx, rec.rect, name);
|
|
6300
|
-
if (!width || !height || ctx.skipPixels) return
|
|
7866
|
+
if (!width || !height || ctx.skipPixels) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
6301
7867
|
const ids = [...Array.from({ length: ctx.colorCount }, (_, i) => i), CHANNEL_ALPHA];
|
|
6302
7868
|
const planes = ids.map((id) => rec.channels.some((c) => c.id === id) ? _nullishCoalesce(decodeOr(ctx, rec, id, name), () => ( null)) : void 0);
|
|
6303
|
-
if (planes.some((p) => p === null)) return
|
|
6304
|
-
if (planes.every((p) => p === void 0)) return
|
|
7869
|
+
if (planes.some((p) => p === null)) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
7870
|
+
if (planes.every((p) => p === void 0)) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4);
|
|
6305
7871
|
const data = toRgba8({
|
|
6306
7872
|
width,
|
|
6307
7873
|
height,
|
|
@@ -6311,7 +7877,7 @@ function recordPixels(ctx, rec, name) {
|
|
|
6311
7877
|
alpha: planes[ctx.colorCount],
|
|
6312
7878
|
palette: ctx.palette
|
|
6313
7879
|
});
|
|
6314
|
-
return
|
|
7880
|
+
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4, rec.rect.left, rec.rect.top);
|
|
6315
7881
|
}
|
|
6316
7882
|
function recordMask(ctx, rec, name) {
|
|
6317
7883
|
const m = rec.mask;
|
|
@@ -6322,11 +7888,11 @@ function recordMask(ctx, rec, name) {
|
|
|
6322
7888
|
const rect = useReal ? m.real.rect : m.rect;
|
|
6323
7889
|
const def = (useReal ? m.real.background : m.defaultColor) >= 128 ? 255 : 0;
|
|
6324
7890
|
const flags = useReal ? m.real.flags : m.flags;
|
|
6325
|
-
let surface =
|
|
7891
|
+
let surface = _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, def);
|
|
6326
7892
|
const { width, height } = safeSize(ctx, rect, name);
|
|
6327
7893
|
if (width && height && !ctx.skipPixels) {
|
|
6328
7894
|
const plane = decodeOr(ctx, rec, id, name);
|
|
6329
|
-
if (plane) surface =
|
|
7895
|
+
if (plane) surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data: toMask8(plane, width, height, ctx.file.header.depth) }, 1, rect.left, rect.top, def);
|
|
6330
7896
|
}
|
|
6331
7897
|
const mask = { surface, defaultValue: def };
|
|
6332
7898
|
if (m.userDensity !== void 0 && m.userDensity < 255) mask.density = percent(m.userDensity);
|
|
@@ -6386,7 +7952,7 @@ function recordEffects(ctx, rec, name, notes, group) {
|
|
|
6386
7952
|
}
|
|
6387
7953
|
for (const e of parsed.effects.items) {
|
|
6388
7954
|
for (const id of patternIds(e)) {
|
|
6389
|
-
if (ctx.patterns.has(id) ||
|
|
7955
|
+
if (ctx.patterns.has(id) || _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)) continue;
|
|
6390
7956
|
ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
|
|
6391
7957
|
notes.push(`pattern "${id}" is not in the file`);
|
|
6392
7958
|
}
|
|
@@ -6415,7 +7981,7 @@ function importNode(ctx, node, depth) {
|
|
|
6415
7981
|
if (node.children) {
|
|
6416
7982
|
const props2 = baseProps(ctx, rec, name, notes);
|
|
6417
7983
|
const divider = sectionDivider(rec);
|
|
6418
|
-
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess',
|
|
7984
|
+
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _156 => _156.blendKey]), () => ( rec.blendKey));
|
|
6419
7985
|
const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
|
|
6420
7986
|
const children = [];
|
|
6421
7987
|
for (const child of node.children) {
|
|
@@ -6425,7 +7991,7 @@ function importNode(ctx, node, depth) {
|
|
|
6425
7991
|
const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
|
|
6426
7992
|
const effects2 = recordEffects(ctx, rec, name, notes, true);
|
|
6427
7993
|
if (effects2) group.effects = effects2;
|
|
6428
|
-
if (_optionalChain([divider, 'optionalAccess',
|
|
7994
|
+
if (_optionalChain([divider, 'optionalAccess', _157 => _157.kind]) === SECTION_CLOSED) group.collapsed = true;
|
|
6429
7995
|
const mask2 = recordMask(ctx, rec, name);
|
|
6430
7996
|
if (mask2) group.mask = mask2;
|
|
6431
7997
|
entry.type = "group";
|
|
@@ -6465,7 +8031,7 @@ function importNode(ctx, node, depth) {
|
|
|
6465
8031
|
if (!file || file.kind !== "liFD") notes.push("linked contents come in as the stored pixels");
|
|
6466
8032
|
entry.type = "smart";
|
|
6467
8033
|
entry.status = notes.length ? "approximated" : "mapped";
|
|
6468
|
-
return { type: "pixel", id: ctx.newId(name), ...props, surface:
|
|
8034
|
+
return { type: "pixel", id: ctx.newId(name), ...props, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
|
|
6469
8035
|
}
|
|
6470
8036
|
}
|
|
6471
8037
|
if (kind === "smart-object" && !ctx.skipPixels) {
|
|
@@ -6515,8 +8081,8 @@ function contentsFor(ctx, placed, name, notes) {
|
|
|
6515
8081
|
document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
|
|
6516
8082
|
};
|
|
6517
8083
|
} else if (t.ext === "png") {
|
|
6518
|
-
const png =
|
|
6519
|
-
out = { ...base, kind: "raster", width: png.width, height: png.height, raster:
|
|
8084
|
+
const png = _chunkPOGBUYWEcjs.decodePng.call(void 0, file.bytes);
|
|
8085
|
+
out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
|
|
6520
8086
|
} else {
|
|
6521
8087
|
const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
|
|
6522
8088
|
if (!(size.width > 0 && size.height > 0)) throw new PsdError("the contents have no stored size");
|
|
@@ -6557,7 +8123,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
6557
8123
|
if (placement && (size.width !== contents.width || size.height !== contents.height)) {
|
|
6558
8124
|
const kx = contents.width / size.width;
|
|
6559
8125
|
const ky = contents.height / size.height;
|
|
6560
|
-
if (placement.warp) placement = { ...placement, warp:
|
|
8126
|
+
if (placement.warp) placement = { ...placement, warp: _chunkW3GXSUSQcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
|
|
6561
8127
|
}
|
|
6562
8128
|
}
|
|
6563
8129
|
if (!contents || !placement) {
|
|
@@ -6567,11 +8133,11 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
6567
8133
|
const file = ctx.linked.get(placed.idnt);
|
|
6568
8134
|
contents = {
|
|
6569
8135
|
id: placed.idnt || ctx.newId(`${name}-contents`),
|
|
6570
|
-
name: _optionalChain([file, 'optionalAccess',
|
|
8136
|
+
name: _optionalChain([file, 'optionalAccess', _158 => _158.name]) || `${name}.png`,
|
|
6571
8137
|
width,
|
|
6572
8138
|
height,
|
|
6573
8139
|
kind: "raster",
|
|
6574
|
-
raster:
|
|
8140
|
+
raster: _chunkXIOMMGPDcjs.translateSurface.call(void 0, surface, -rec.rect.left, -rec.rect.top)
|
|
6575
8141
|
};
|
|
6576
8142
|
if (file && file.kind !== "liFD") {
|
|
6577
8143
|
contents.linked = { path: _nullishCoalesce(file.path, () => ( file.name)) };
|
|
@@ -6645,7 +8211,7 @@ function mergedLayer(ctx) {
|
|
|
6645
8211
|
visible: true,
|
|
6646
8212
|
opacity: 1,
|
|
6647
8213
|
blend: "normal",
|
|
6648
|
-
surface:
|
|
8214
|
+
surface: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4),
|
|
6649
8215
|
offset: { x: 0, y: 0 }
|
|
6650
8216
|
};
|
|
6651
8217
|
}
|
|
@@ -6792,15 +8358,15 @@ var pct = (d, key, fallback) => num2(d, key, fallback * 100) / 100;
|
|
|
6792
8358
|
var bool = (d, key) => descBool(d, key) === true;
|
|
6793
8359
|
var enumOf2 = (d, key) => {
|
|
6794
8360
|
const v = descGet(d, key);
|
|
6795
|
-
return _optionalChain([v, 'optionalAccess',
|
|
8361
|
+
return _optionalChain([v, 'optionalAccess', _159 => _159.type]) === "enum" ? v.value : void 0;
|
|
6796
8362
|
};
|
|
6797
8363
|
var text2 = (d, key) => {
|
|
6798
8364
|
const v = d ? descGet(d, key) : void 0;
|
|
6799
|
-
return _optionalChain([v, 'optionalAccess',
|
|
8365
|
+
return _optionalChain([v, 'optionalAccess', _160 => _160.type]) === "TEXT" ? v.value : "";
|
|
6800
8366
|
};
|
|
6801
8367
|
var list = (d, key) => {
|
|
6802
8368
|
const v = descGet(d, key);
|
|
6803
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
8369
|
+
if (_optionalChain([v, 'optionalAccess', _161 => _161.type]) !== "VlLs") return [];
|
|
6804
8370
|
return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
|
|
6805
8371
|
};
|
|
6806
8372
|
var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
|
|
@@ -6822,34 +8388,34 @@ function blendOf(d, key, fallback, notes) {
|
|
|
6822
8388
|
function colorOf(d, fallback = "#000000") {
|
|
6823
8389
|
if (!d) return fallback;
|
|
6824
8390
|
const g = (k) => descNumber(d, k);
|
|
6825
|
-
if (g("redFloat") !== void 0) return
|
|
8391
|
+
if (g("redFloat") !== void 0) return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
|
|
6826
8392
|
switch (d.classId) {
|
|
6827
8393
|
case "HSBC": {
|
|
6828
8394
|
const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
|
|
6829
|
-
return rgb ?
|
|
8395
|
+
return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
6830
8396
|
}
|
|
6831
8397
|
case "CMYC": {
|
|
6832
8398
|
const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
|
|
6833
8399
|
const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
|
|
6834
|
-
return rgb ?
|
|
8400
|
+
return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
6835
8401
|
}
|
|
6836
8402
|
case "LbCl": {
|
|
6837
8403
|
const rgb = decodePsdColor(7, [(_nullishCoalesce(g("Lmnc"), () => ( 0))) * 100, Math.round((_nullishCoalesce(g("A "), () => ( 0))) * 100) & 65535, Math.round((_nullishCoalesce(g("B "), () => ( 0))) * 100) & 65535]);
|
|
6838
|
-
return rgb ?
|
|
8404
|
+
return rgb ? _chunkPOGBUYWEcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
6839
8405
|
}
|
|
6840
8406
|
case "Grsc": {
|
|
6841
8407
|
const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
|
|
6842
|
-
return
|
|
8408
|
+
return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [v, v, v]);
|
|
6843
8409
|
}
|
|
6844
8410
|
}
|
|
6845
8411
|
const r = g("Rd ");
|
|
6846
8412
|
const gr = g("Grn ");
|
|
6847
8413
|
const b = g("Bl ");
|
|
6848
8414
|
if (r === void 0 || gr === void 0 || b === void 0) return fallback;
|
|
6849
|
-
return
|
|
8415
|
+
return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
|
|
6850
8416
|
}
|
|
6851
8417
|
function colorDesc(hex) {
|
|
6852
|
-
const [r, g, b] = _nullishCoalesce(
|
|
8418
|
+
const [r, g, b] = _nullishCoalesce(_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
|
|
6853
8419
|
return descriptor("RGBC", [
|
|
6854
8420
|
["Rd ", dbl2(r * 255)],
|
|
6855
8421
|
["Grn ", dbl2(g * 255)],
|
|
@@ -6870,8 +8436,8 @@ function contourOf(d, key) {
|
|
|
6870
8436
|
return { name, points };
|
|
6871
8437
|
}
|
|
6872
8438
|
function contourDesc(c) {
|
|
6873
|
-
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
6874
|
-
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
8439
|
+
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _162 => _162.name]), () => ( "Linear"));
|
|
8440
|
+
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _163 => _163.points]), () => ( [
|
|
6875
8441
|
{ input: 0, output: 0 },
|
|
6876
8442
|
{ input: 1, output: 1 }
|
|
6877
8443
|
]));
|
|
@@ -6906,7 +8472,7 @@ function gradientOf(d, notes) {
|
|
|
6906
8472
|
{ position: 0, color: "#000000" },
|
|
6907
8473
|
{ position: 1, color: "#ffffff" }
|
|
6908
8474
|
],
|
|
6909
|
-
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access',
|
|
8475
|
+
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _164 => _164.find, 'call', _165 => _165(([, id]) => id === enumOf2(d, "Type")), 'optionalAccess', _166 => _166[0]]), () => ( "linear")),
|
|
6910
8476
|
angle: clamp3(num2(d, "Angl", 90), -360, 360),
|
|
6911
8477
|
scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
|
|
6912
8478
|
reverse: bool(d, "Rvrs"),
|
|
@@ -6932,9 +8498,9 @@ function gradientOf(d, notes) {
|
|
|
6932
8498
|
raw.forEach((s, i) => {
|
|
6933
8499
|
if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
|
|
6934
8500
|
const a = raw[i - 1];
|
|
6935
|
-
const ca =
|
|
6936
|
-
const cb =
|
|
6937
|
-
stops.push({ position: a.position + (s.position - a.position) * s.mid, color:
|
|
8501
|
+
const ca = _chunkPOGBUYWEcjs.parseEffectColor.call(void 0, a.color);
|
|
8502
|
+
const cb = _chunkPOGBUYWEcjs.parseEffectColor.call(void 0, s.color);
|
|
8503
|
+
stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkPOGBUYWEcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
|
|
6938
8504
|
notes.add("gradient midpoints are drawn as straight segments");
|
|
6939
8505
|
}
|
|
6940
8506
|
stops.push({ position: s.position, color: s.color });
|
|
@@ -6960,7 +8526,7 @@ function gradientItems(g) {
|
|
|
6960
8526
|
)
|
|
6961
8527
|
)
|
|
6962
8528
|
};
|
|
6963
|
-
const op = _optionalChain([g, 'access',
|
|
8529
|
+
const op = _optionalChain([g, 'access', _167 => _167.opacityStops, 'optionalAccess', _168 => _168.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
|
|
6964
8530
|
const trns = {
|
|
6965
8531
|
type: "VlLs",
|
|
6966
8532
|
items: op.map(
|
|
@@ -7046,8 +8612,8 @@ var KINDS = [
|
|
|
7046
8612
|
["FrFX", "frameFXMulti", "stroke"]
|
|
7047
8613
|
];
|
|
7048
8614
|
function common(d, kind, notes) {
|
|
7049
|
-
const def =
|
|
7050
|
-
return { id:
|
|
8615
|
+
const def = _chunkPOGBUYWEcjs.defaultLayerEffect.call(void 0, kind, "x");
|
|
8616
|
+
return { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
|
|
7051
8617
|
}
|
|
7052
8618
|
function readOne(kind, d, notes) {
|
|
7053
8619
|
const size = (key, fallback) => clamp3(num2(d, key, fallback), 0, 250);
|
|
@@ -7090,7 +8656,7 @@ function readOne(kind, d, notes) {
|
|
|
7090
8656
|
case "bevel-emboss": {
|
|
7091
8657
|
const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
|
|
7092
8658
|
const out = {
|
|
7093
|
-
id:
|
|
8659
|
+
id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ),
|
|
7094
8660
|
enabled: descBool(d, "enab") !== false,
|
|
7095
8661
|
kind,
|
|
7096
8662
|
style: _nullishCoalesce(styles[_nullishCoalesce(enumOf2(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
|
|
@@ -7156,7 +8722,7 @@ function parseLfx2(data) {
|
|
|
7156
8722
|
let d;
|
|
7157
8723
|
try {
|
|
7158
8724
|
d = parseVersionedDescriptor(data.subarray(4));
|
|
7159
|
-
} catch (
|
|
8725
|
+
} catch (e18) {
|
|
7160
8726
|
return null;
|
|
7161
8727
|
}
|
|
7162
8728
|
const notes = /* @__PURE__ */ new Set();
|
|
@@ -7301,10 +8867,10 @@ function writeLfx2(effects) {
|
|
|
7301
8867
|
["Scl ", unit2("#Prc", 100)],
|
|
7302
8868
|
["masterFXSwitch", boolV2(effects.enabled)]
|
|
7303
8869
|
];
|
|
7304
|
-
const scale =
|
|
8870
|
+
const scale = _chunkPOGBUYWEcjs.effectsScale.call(void 0, effects);
|
|
7305
8871
|
let dropped = 0;
|
|
7306
8872
|
for (const [single, multi, kind] of KINDS) {
|
|
7307
|
-
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(
|
|
8873
|
+
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkPOGBUYWEcjs.scaleLayerEffect.call(void 0, e, scale)));
|
|
7308
8874
|
if (!of.length) continue;
|
|
7309
8875
|
if (of.length === 1) items.push([single, obj2(of[0])]);
|
|
7310
8876
|
else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj2) }]);
|
|
@@ -7336,7 +8902,7 @@ function parseLrfx(data) {
|
|
|
7336
8902
|
const colorAt = (rd) => {
|
|
7337
8903
|
rd.u16();
|
|
7338
8904
|
const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
|
|
7339
|
-
return
|
|
8905
|
+
return _chunkPOGBUYWEcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
|
|
7340
8906
|
};
|
|
7341
8907
|
const blendAt = (rd) => {
|
|
7342
8908
|
rd.skip(4);
|
|
@@ -7355,7 +8921,7 @@ function parseLrfx(data) {
|
|
|
7355
8921
|
const enabled = b.u8() !== 0;
|
|
7356
8922
|
const useGlobalLight = b.u8() !== 0;
|
|
7357
8923
|
const opacity = b.u8() / 255;
|
|
7358
|
-
const base = { id:
|
|
8924
|
+
const base = { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
|
|
7359
8925
|
items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
|
|
7360
8926
|
} else if (key === "oglw" || key === "iglw") {
|
|
7361
8927
|
b.u32();
|
|
@@ -7365,7 +8931,7 @@ function parseLrfx(data) {
|
|
|
7365
8931
|
const blend = blendAt(b);
|
|
7366
8932
|
const enabled = b.u8() !== 0;
|
|
7367
8933
|
const opacity = b.u8() / 255;
|
|
7368
|
-
const base = { id:
|
|
8934
|
+
const base = { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
|
|
7369
8935
|
items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
|
|
7370
8936
|
} else if (key === "sofi") {
|
|
7371
8937
|
b.u32();
|
|
@@ -7373,11 +8939,11 @@ function parseLrfx(data) {
|
|
|
7373
8939
|
const color = colorAt(b);
|
|
7374
8940
|
const opacity = b.u8() / 255;
|
|
7375
8941
|
const enabled = b.u8() !== 0;
|
|
7376
|
-
items.push({ id:
|
|
8942
|
+
items.push({ id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
|
|
7377
8943
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
7378
8944
|
}
|
|
7379
8945
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
7380
|
-
} catch (
|
|
8946
|
+
} catch (e19) {
|
|
7381
8947
|
return null;
|
|
7382
8948
|
}
|
|
7383
8949
|
}
|
|
@@ -7423,14 +8989,14 @@ function rleChannel(id, plane, width, height, psb) {
|
|
|
7423
8989
|
var emptyChannel = (id) => ({ id, compression: 0, data: new Uint8Array(0) });
|
|
7424
8990
|
function maskChannel(mask, ox, oy, psb) {
|
|
7425
8991
|
if (mask.source) throw new PsdError("A parametric mask must be baked before export.");
|
|
7426
|
-
const bounds =
|
|
8992
|
+
const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
|
|
7427
8993
|
const def = mask.defaultValue;
|
|
7428
8994
|
const flags = (mask.enabled === false ? MASK_FLAG_DISABLED : 0) | (mask.linked === false ? MASK_FLAG_UNLINKED : 0);
|
|
7429
8995
|
const m = { rect: EMPTY_RECT, defaultColor: def, flags };
|
|
7430
8996
|
if ((_nullishCoalesce(mask.density, () => ( 1))) < 1) m.userDensity = Math.round(Math.max(0, _nullishCoalesce(mask.density, () => ( 1))) * 255);
|
|
7431
8997
|
if ((_nullishCoalesce(mask.feather, () => ( 0))) > 0) m.userFeather = mask.feather;
|
|
7432
8998
|
if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
|
|
7433
|
-
const plane =
|
|
8999
|
+
const plane = _chunkXIOMMGPDcjs.readRegion.call(void 0, mask.surface, bounds);
|
|
7434
9000
|
m.rect = toRect({ ...bounds, x: bounds.x + ox, y: bounds.y + oy });
|
|
7435
9001
|
return { channel: rleChannel(CHANNEL_USER_MASK, new Uint8Array(plane.buffer, plane.byteOffset, plane.length), bounds.width, bounds.height, psb), mask: m };
|
|
7436
9002
|
}
|
|
@@ -7445,9 +9011,9 @@ function prepareNestedLayers(layers) {
|
|
|
7445
9011
|
if (l.type === "annotation") continue;
|
|
7446
9012
|
let next = l;
|
|
7447
9013
|
if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
|
|
7448
|
-
else if (l.type === "pixel" && (_optionalChain([l, 'access',
|
|
9014
|
+
else if (l.type === "pixel" && (_optionalChain([l, 'access', _169 => _169.filters, 'optionalAccess', _170 => _170.length]) || l.source === "document")) {
|
|
7449
9015
|
const p = { ...l };
|
|
7450
|
-
if (_optionalChain([l, 'access',
|
|
9016
|
+
if (_optionalChain([l, 'access', _171 => _171.filters, 'optionalAccess', _172 => _172.some, 'call', _173 => _173(isActiveFilter)])) {
|
|
7451
9017
|
const b = l.surface.bounds;
|
|
7452
9018
|
if (b) {
|
|
7453
9019
|
const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
|
|
@@ -7457,14 +9023,14 @@ function prepareNestedLayers(layers) {
|
|
|
7457
9023
|
delete plain.effects;
|
|
7458
9024
|
delete plain.fillOpacity;
|
|
7459
9025
|
const data = new LayerCompositor().composite([plain], r, { width: r.x + r.width, height: r.y + r.height });
|
|
7460
|
-
p.surface =
|
|
9026
|
+
p.surface = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: r.width, height: r.height, data }, 4, r.x - l.offset.x, r.y - l.offset.y);
|
|
7461
9027
|
}
|
|
7462
9028
|
}
|
|
7463
9029
|
delete p.filters;
|
|
7464
9030
|
delete p.source;
|
|
7465
9031
|
next = p;
|
|
7466
9032
|
}
|
|
7467
|
-
if (_optionalChain([next, 'access',
|
|
9033
|
+
if (_optionalChain([next, 'access', _174 => _174.mask, 'optionalAccess', _175 => _175.source])) {
|
|
7468
9034
|
next = { ...next };
|
|
7469
9035
|
delete next.mask;
|
|
7470
9036
|
}
|
|
@@ -7476,11 +9042,11 @@ function smartContentsFile(c) {
|
|
|
7476
9042
|
const base = c.name.replace(/\.\w+$/, "") || "Contents";
|
|
7477
9043
|
if (c.file) return { name: c.name, bytes: c.file.bytes };
|
|
7478
9044
|
if (c.kind === "raster") {
|
|
7479
|
-
const data =
|
|
7480
|
-
return { name: `${base}.png`, bytes:
|
|
9045
|
+
const data = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
9046
|
+
return { name: `${base}.png`, bytes: _chunkPOGBUYWEcjs.encodePng.call(void 0, c.width, c.height, data) };
|
|
7481
9047
|
}
|
|
7482
9048
|
const doc = c.document;
|
|
7483
|
-
const merged =
|
|
9049
|
+
const merged = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
7484
9050
|
const res = exportPsd({ width: c.width, height: c.height, layers: prepareNestedLayers(doc.layers), merged, patterns: doc.patterns, globalLight: doc.globalLight });
|
|
7485
9051
|
return { name: `${base}.${res.psb ? "psb" : "psd"}`, bytes: res.bytes };
|
|
7486
9052
|
}
|
|
@@ -7528,7 +9094,7 @@ function exportPsd(input) {
|
|
|
7528
9094
|
const key = layer.type === "group" ? "lfxs" : "lfx2";
|
|
7529
9095
|
if (fx.psd) {
|
|
7530
9096
|
const original = parseLfx2(fx.psd.data);
|
|
7531
|
-
if (original ?
|
|
9097
|
+
if (original ? _chunkPOGBUYWEcjs.effectsFingerprint.call(void 0, original.effects) === _chunkPOGBUYWEcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
|
|
7532
9098
|
}
|
|
7533
9099
|
if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
|
|
7534
9100
|
const { data, dropped } = writeLfx2(fx);
|
|
@@ -7545,7 +9111,7 @@ function exportPsd(input) {
|
|
|
7545
9111
|
return {
|
|
7546
9112
|
opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
|
|
7547
9113
|
clipping: layer.clipped ? 1 : 0,
|
|
7548
|
-
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access',
|
|
9114
|
+
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _176 => _176.locks, 'optionalAccess', _177 => _177.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
|
|
7549
9115
|
legacyName: name,
|
|
7550
9116
|
blocks
|
|
7551
9117
|
};
|
|
@@ -7602,16 +9168,16 @@ function exportPsd(input) {
|
|
|
7602
9168
|
}
|
|
7603
9169
|
case "pixel": {
|
|
7604
9170
|
if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
|
|
7605
|
-
if (_optionalChain([layer, 'access',
|
|
9171
|
+
if (_optionalChain([layer, 'access', _178 => _178.filters, 'optionalAccess', _179 => _179.some, 'call', _180 => _180(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
|
|
7606
9172
|
const extra = [];
|
|
7607
9173
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
|
|
7608
9174
|
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
7609
9175
|
}
|
|
7610
9176
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
7611
|
-
const bounds =
|
|
9177
|
+
const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
7612
9178
|
if (bounds) {
|
|
7613
9179
|
const n2 = bounds.width * bounds.height;
|
|
7614
|
-
const [r2, g2, b2, a2] = rgbaToPlanes(
|
|
9180
|
+
const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
|
|
7615
9181
|
rec.rect = toRect({ ...bounds, x: bounds.x + layer.offset.x, y: bounds.y + layer.offset.y });
|
|
7616
9182
|
rec.channels = [
|
|
7617
9183
|
rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
|
|
@@ -7641,7 +9207,7 @@ function exportPsd(input) {
|
|
|
7641
9207
|
if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
|
|
7642
9208
|
linkedFiles.set(idnt, smartContentsFile(c));
|
|
7643
9209
|
}
|
|
7644
|
-
let placedId = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
9210
|
+
let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _181 => _181.psd, 'optionalAccess', _182 => _182.placed]), () => ( psdUuid(`${layer.id}:placed`)));
|
|
7645
9211
|
if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
|
|
7646
9212
|
placedIds.add(placedId);
|
|
7647
9213
|
if (placedUnchanged(layer, idnt, placedId)) {
|
|
@@ -7651,18 +9217,18 @@ function exportPsd(input) {
|
|
|
7651
9217
|
const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
|
|
7652
9218
|
if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
|
|
7653
9219
|
const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
|
|
7654
|
-
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess',
|
|
9220
|
+
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _183 => _183.descriptor]) };
|
|
7655
9221
|
const wnotes = [];
|
|
7656
9222
|
extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
|
|
7657
9223
|
for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
|
|
7658
9224
|
}
|
|
7659
|
-
const fm = _optionalChain([layer, 'access',
|
|
9225
|
+
const fm = _optionalChain([layer, 'access', _184 => _184.smartFilters, 'optionalAccess', _185 => _185.mask]);
|
|
7660
9226
|
if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
|
|
7661
9227
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
7662
|
-
const bounds =
|
|
9228
|
+
const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
7663
9229
|
if (bounds) {
|
|
7664
9230
|
const n2 = bounds.width * bounds.height;
|
|
7665
|
-
const [r2, g2, b2, a2] = rgbaToPlanes(
|
|
9231
|
+
const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
|
|
7666
9232
|
rec.rect = toRect(bounds);
|
|
7667
9233
|
rec.channels = [
|
|
7668
9234
|
rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
|
|
@@ -7724,7 +9290,7 @@ function exportPsd(input) {
|
|
|
7724
9290
|
const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
|
|
7725
9291
|
const embed = [];
|
|
7726
9292
|
for (const id of patternIds2) {
|
|
7727
|
-
const p = _nullishCoalesce(byId.get(id), () => (
|
|
9293
|
+
const p = _nullishCoalesce(byId.get(id), () => ( _chunkPOGBUYWEcjs.builtinPattern.call(void 0, id)));
|
|
7728
9294
|
if (p) embed.push(p);
|
|
7729
9295
|
else note(`Pattern "${id}" is not in the document and was not embedded`, id);
|
|
7730
9296
|
}
|
|
@@ -8032,5 +9598,60 @@ function exportPsd(input) {
|
|
|
8032
9598
|
|
|
8033
9599
|
|
|
8034
9600
|
|
|
8035
|
-
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
8036
|
-
|
|
9601
|
+
|
|
9602
|
+
|
|
9603
|
+
|
|
9604
|
+
|
|
9605
|
+
|
|
9606
|
+
|
|
9607
|
+
|
|
9608
|
+
|
|
9609
|
+
|
|
9610
|
+
|
|
9611
|
+
|
|
9612
|
+
|
|
9613
|
+
|
|
9614
|
+
|
|
9615
|
+
|
|
9616
|
+
|
|
9617
|
+
|
|
9618
|
+
|
|
9619
|
+
|
|
9620
|
+
|
|
9621
|
+
|
|
9622
|
+
|
|
9623
|
+
|
|
9624
|
+
|
|
9625
|
+
|
|
9626
|
+
|
|
9627
|
+
|
|
9628
|
+
|
|
9629
|
+
|
|
9630
|
+
|
|
9631
|
+
|
|
9632
|
+
|
|
9633
|
+
|
|
9634
|
+
|
|
9635
|
+
|
|
9636
|
+
|
|
9637
|
+
|
|
9638
|
+
|
|
9639
|
+
|
|
9640
|
+
|
|
9641
|
+
|
|
9642
|
+
|
|
9643
|
+
|
|
9644
|
+
|
|
9645
|
+
|
|
9646
|
+
|
|
9647
|
+
|
|
9648
|
+
|
|
9649
|
+
|
|
9650
|
+
|
|
9651
|
+
|
|
9652
|
+
|
|
9653
|
+
|
|
9654
|
+
|
|
9655
|
+
|
|
9656
|
+
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
9657
|
+
//# sourceMappingURL=chunk-MGL4U5WA.cjs.map
|