@pixerate/editor 0.248.0 → 0.249.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/README.md +1 -0
- package/dist/animation-editor/index.cjs +64 -61
- package/dist/animation-editor/index.js +8 -5
- package/dist/{brushstrokeRender-DTDPFBLC.cjs → brushstrokeRender-GCKK7V2I.cjs} +14 -11
- package/dist/{brushstrokeRender-QLCXROJK.js → brushstrokeRender-T3JZST44.js} +7 -4
- package/dist/canvas/index.cjs +8 -8
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-IBDU6EGZ.cjs → chunk-2SMMZDMG.cjs} +35 -35
- package/dist/{chunk-SC2RZ5EF.js → chunk-2VJAVXLI.js} +2 -2
- package/dist/{chunk-OLNIPTB3.cjs → chunk-2VX55NFM.cjs} +1 -320
- package/dist/chunk-3K6HWEXZ.cjs +92 -0
- package/dist/{chunk-UOOK7HTX.js → chunk-3PPJRMIG.js} +1 -1
- package/dist/chunk-4D6KP5BV.js +92 -0
- package/dist/chunk-5RH3VXAK.js +269 -0
- package/dist/{chunk-NZ3O3A5C.js → chunk-6BIDVPED.js} +1 -1
- package/dist/{chunk-2ONK3ERD.cjs → chunk-75K3W4D6.cjs} +20 -20
- package/dist/{chunk-7T7JWTVE.cjs → chunk-BOHDJJ2O.cjs} +8 -8
- package/dist/{chunk-2PBZBRP5.js → chunk-D5KGAO4Z.js} +10 -92
- package/dist/{chunk-5GLYUSNT.js → chunk-DOIU7VJG.js} +1 -1
- package/dist/{chunk-HB4ICNNA.cjs → chunk-DPYAO5U6.cjs} +42 -42
- package/dist/chunk-EJLRBS5Q.js +301 -0
- package/dist/{chunk-6G6ZDDDB.cjs → chunk-H4AOUUBE.cjs} +301 -149
- package/dist/{chunk-PQ3H2AAN.cjs → chunk-I7NJPHWV.cjs} +122 -204
- package/dist/{chunk-L6REDLNB.cjs → chunk-IOFVM3L3.cjs} +7 -7
- package/dist/{chunk-42TWUPNJ.js → chunk-IRSTHLQQ.js} +1 -320
- package/dist/{chunk-VNBUDVD4.js → chunk-J7T5QZ45.js} +226 -74
- package/dist/{chunk-VMROIWLL.cjs → chunk-KBYB7OWB.cjs} +3 -3
- package/dist/{chunk-TPWB4Y6L.cjs → chunk-KYX7NZ5V.cjs} +1 -1
- package/dist/chunk-LJRCU3BJ.cjs +301 -0
- package/dist/{chunk-WVS5KQDH.cjs → chunk-LP2MCSBE.cjs} +246 -244
- package/dist/{chunk-XNRBMYNB.js → chunk-O75V4ZS3.js} +1 -1
- package/dist/chunk-OTTT5N3K.js +322 -0
- package/dist/{chunk-Q2HA52V4.js → chunk-PZP2SZIZ.js} +2 -2
- package/dist/{chunk-ZFSLEOSQ.js → chunk-UBRJOIR5.js} +11 -9
- package/dist/chunk-W5M3J7PV.cjs +322 -0
- package/dist/{chunk-4P6H35HU.js → chunk-WA44NKPF.js} +2 -2
- package/dist/{chunk-XWTRATIM.cjs → chunk-WLJZZHUZ.cjs} +23 -23
- package/dist/{chunk-P3NIPIKS.js → chunk-WQCNC4DK.js} +1 -1
- package/dist/chunk-ZEYMKDYS.cjs +269 -0
- package/dist/image-editor/index.cjs +1055 -1050
- package/dist/image-editor/index.js +28 -23
- package/dist/paint/index.cjs +8 -5
- package/dist/paint/index.js +13 -10
- package/dist/paint-editor/controller.d.cts +37 -1
- package/dist/paint-editor/controller.d.ts +37 -1
- package/dist/paint-editor/index.cjs +745 -602
- package/dist/paint-editor/index.d.cts +3 -0
- package/dist/paint-editor/index.d.ts +3 -0
- package/dist/paint-editor/index.js +184 -41
- package/dist/paint-editor/sticker-art.d.cts +55 -0
- package/dist/paint-editor/sticker-art.d.ts +55 -0
- package/dist/paint-editor/stickers.d.cts +30 -17
- package/dist/paint-editor/stickers.d.ts +30 -17
- package/dist/paint-editor/stroke.d.cts +4 -0
- package/dist/paint-editor/stroke.d.ts +4 -0
- package/dist/paint-editor/ui.d.cts +10 -2
- package/dist/paint-editor/ui.d.ts +10 -2
- package/dist/raster/index.cjs +6 -4
- package/dist/raster/index.js +12 -10
- package/dist/stickers/browser.d.cts +48 -0
- package/dist/stickers/browser.d.ts +48 -0
- package/dist/stickers/combine.d.cts +10 -0
- package/dist/stickers/combine.d.ts +10 -0
- package/dist/stickers/conformance.d.cts +18 -0
- package/dist/stickers/conformance.d.ts +18 -0
- package/dist/stickers/editor.d.cts +14 -0
- package/dist/stickers/editor.d.ts +14 -0
- package/dist/stickers/errors.d.cts +6 -0
- package/dist/stickers/errors.d.ts +6 -0
- package/dist/stickers/fake.d.cts +16 -0
- package/dist/stickers/fake.d.ts +16 -0
- package/dist/stickers/helpers.d.cts +51 -0
- package/dist/stickers/helpers.d.ts +51 -0
- package/dist/stickers/index.cjs +331 -0
- package/dist/stickers/index.d.cts +16 -0
- package/dist/stickers/index.d.ts +16 -0
- package/dist/stickers/index.js +331 -0
- package/dist/stickers/stamps.d.cts +13 -0
- package/dist/stickers/stamps.d.ts +13 -0
- package/dist/stickers/tools.d.cts +25 -0
- package/dist/stickers/tools.d.ts +25 -0
- package/dist/stickers/types.d.cts +123 -0
- package/dist/stickers/types.d.ts +123 -0
- package/dist/vector/index.cjs +978 -975
- package/dist/vector/index.js +9 -6
- package/package.json +11 -1
- package/skills/README.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +8 -5
- package/skills/pixerate-stickers/SKILL.md +45 -0
|
@@ -48,7 +48,7 @@ var _chunkSS53NNZOcjs = require('./chunk-SS53NNZO.cjs');
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var _chunkDPYAO5U6cjs = require('./chunk-DPYAO5U6.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
@@ -106,7 +106,7 @@ var _chunkBROJYMWUcjs = require('./chunk-BROJYMWU.cjs');
|
|
|
106
106
|
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
var
|
|
109
|
+
var _chunkIOFVM3L3cjs = require('./chunk-IOFVM3L3.cjs');
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
|
|
@@ -126,13 +126,15 @@ var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
|
126
126
|
|
|
127
127
|
|
|
128
128
|
|
|
129
|
+
var _chunk2VX55NFMcjs = require('./chunk-2VX55NFM.cjs');
|
|
129
130
|
|
|
130
131
|
|
|
131
132
|
|
|
132
133
|
|
|
133
134
|
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
|
|
137
|
+
var _chunkW5M3J7PVcjs = require('./chunk-W5M3J7PV.cjs');
|
|
136
138
|
|
|
137
139
|
|
|
138
140
|
|
|
@@ -1030,7 +1032,7 @@ function normalizeAdjustmentLayer(raw) {
|
|
|
1030
1032
|
kind: r.kind,
|
|
1031
1033
|
enabled: r.enabled !== false,
|
|
1032
1034
|
opacity: clampTo(r.opacity, 0, 1, 1),
|
|
1033
|
-
blend:
|
|
1035
|
+
blend: _chunk2VX55NFMcjs.normalizeBlendMode.call(void 0, r.blend),
|
|
1034
1036
|
params: normParams(r.kind, r.params)
|
|
1035
1037
|
};
|
|
1036
1038
|
if (typeof r.name === "string" && r.name) layer.name = r.name;
|
|
@@ -1052,7 +1054,7 @@ function normalizeAdjustmentLayers(raw) {
|
|
|
1052
1054
|
return out;
|
|
1053
1055
|
}
|
|
1054
1056
|
function curveLutFromLevels(points) {
|
|
1055
|
-
return
|
|
1057
|
+
return _chunkDPYAO5U6cjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
|
|
1056
1058
|
}
|
|
1057
1059
|
var toUnitLevels = (c) => ({
|
|
1058
1060
|
inBlack: c.inBlack / 255,
|
|
@@ -1376,7 +1378,7 @@ function compileAdjustmentLayer(layer, options = {}) {
|
|
|
1376
1378
|
return (c) => {
|
|
1377
1379
|
const g = blackWhiteGray(c, weights);
|
|
1378
1380
|
if (tint) {
|
|
1379
|
-
const t =
|
|
1381
|
+
const t = _chunk2VX55NFMcjs.setLum.call(void 0, tint, g);
|
|
1380
1382
|
c[0] = clamp01(t[0]);
|
|
1381
1383
|
c[1] = clamp01(t[1]);
|
|
1382
1384
|
c[2] = clamp01(t[2]);
|
|
@@ -1395,7 +1397,7 @@ function compileAdjustmentLayer(layer, options = {}) {
|
|
|
1395
1397
|
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])));
|
|
1396
1398
|
if (preserve) {
|
|
1397
1399
|
const target = 0.3 * c[0] + 0.59 * c[1] + 0.11 * c[2];
|
|
1398
|
-
f =
|
|
1400
|
+
f = _chunk2VX55NFMcjs.setLum.call(void 0, f, target);
|
|
1399
1401
|
}
|
|
1400
1402
|
c[0] = clamp01(f[0]);
|
|
1401
1403
|
c[1] = clamp01(f[1]);
|
|
@@ -1462,10 +1464,10 @@ function applyLayer(c, layer, op, coverage = 1) {
|
|
|
1462
1464
|
const cb0 = c[0], cb1 = c[1], cb2 = c[2];
|
|
1463
1465
|
op(c);
|
|
1464
1466
|
if (blend === "pigment") {
|
|
1465
|
-
|
|
1467
|
+
_chunk2VX55NFMcjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
|
|
1466
1468
|
return;
|
|
1467
1469
|
}
|
|
1468
|
-
const b = blend === "normal" ? c :
|
|
1470
|
+
const b = blend === "normal" ? c : _chunk2VX55NFMcjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
|
|
1469
1471
|
c[0] = (1 - alpha) * cb0 + alpha * b[0];
|
|
1470
1472
|
c[1] = (1 - alpha) * cb1 + alpha * b[1];
|
|
1471
1473
|
c[2] = (1 - alpha) * cb2 + alpha * b[2];
|
|
@@ -2248,7 +2250,7 @@ function newLayerId(prefix = "layer") {
|
|
|
2248
2250
|
return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
|
|
2249
2251
|
}
|
|
2250
2252
|
function pixelLayers(layers) {
|
|
2251
|
-
return
|
|
2253
|
+
return _chunkDPYAO5U6cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
2252
2254
|
}
|
|
2253
2255
|
function developFilter(layer) {
|
|
2254
2256
|
return _optionalChain([layer, 'access', _10 => _10.filters, 'optionalAccess', _11 => _11.find, 'call', _12 => _12((f) => f.kind === "develop")]);
|
|
@@ -2279,14 +2281,14 @@ function isRenderedLayer(layer) {
|
|
|
2279
2281
|
return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
|
|
2280
2282
|
}
|
|
2281
2283
|
function shapeLayers(layers) {
|
|
2282
|
-
return
|
|
2284
|
+
return _chunkDPYAO5U6cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
|
|
2283
2285
|
}
|
|
2284
2286
|
function smartObjectLayers(layers) {
|
|
2285
|
-
return
|
|
2287
|
+
return _chunkDPYAO5U6cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
|
|
2286
2288
|
}
|
|
2287
2289
|
|
|
2288
2290
|
// src/image-editor/layers/shape.ts
|
|
2289
|
-
var SHAPE_RENDER_MARGIN =
|
|
2291
|
+
var SHAPE_RENDER_MARGIN = _chunkDPYAO5U6cjs.MAX_EFFECT_REACH;
|
|
2290
2292
|
var DEFAULT_MITER_LIMIT = 100;
|
|
2291
2293
|
var fail = (message) => {
|
|
2292
2294
|
throw new LayerOperationError(message);
|
|
@@ -2326,7 +2328,7 @@ function mapAnchor(a, f) {
|
|
|
2326
2328
|
return out;
|
|
2327
2329
|
}
|
|
2328
2330
|
function mapSubpaths(subpaths, f) {
|
|
2329
|
-
return
|
|
2331
|
+
return _chunkIOFVM3L3cjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
|
|
2330
2332
|
}
|
|
2331
2333
|
function liveShapeSubpaths(live) {
|
|
2332
2334
|
let out;
|
|
@@ -2334,19 +2336,19 @@ function liveShapeSubpaths(live) {
|
|
|
2334
2336
|
case "rect": {
|
|
2335
2337
|
const x = Math.min(live.x, live.x + live.width);
|
|
2336
2338
|
const y = Math.min(live.y, live.y + live.height);
|
|
2337
|
-
const sp =
|
|
2339
|
+
const sp = _chunkIOFVM3L3cjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
|
|
2338
2340
|
const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
|
|
2339
|
-
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ?
|
|
2341
|
+
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkIOFVM3L3cjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
|
|
2340
2342
|
break;
|
|
2341
2343
|
}
|
|
2342
2344
|
case "ellipse":
|
|
2343
|
-
out = [
|
|
2345
|
+
out = [_chunkIOFVM3L3cjs.ellipseSubpath.call(void 0, normBox(live))];
|
|
2344
2346
|
break;
|
|
2345
2347
|
case "polygon":
|
|
2346
|
-
out = [
|
|
2348
|
+
out = [_chunkIOFVM3L3cjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
|
|
2347
2349
|
break;
|
|
2348
2350
|
case "star":
|
|
2349
|
-
out = [
|
|
2351
|
+
out = [_chunkIOFVM3L3cjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
|
|
2350
2352
|
break;
|
|
2351
2353
|
case "line": {
|
|
2352
2354
|
const a = { x: live.x1, y: live.y1 };
|
|
@@ -2369,7 +2371,7 @@ function liveShapeSubpaths(live) {
|
|
|
2369
2371
|
}
|
|
2370
2372
|
}
|
|
2371
2373
|
const m = live.transform;
|
|
2372
|
-
return m && !
|
|
2374
|
+
return m && !_chunkIOFVM3L3cjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, p)) : out;
|
|
2373
2375
|
}
|
|
2374
2376
|
function normBox(b) {
|
|
2375
2377
|
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) };
|
|
@@ -2381,7 +2383,7 @@ var pathCache = /* @__PURE__ */ new WeakMap();
|
|
|
2381
2383
|
function componentPath(c) {
|
|
2382
2384
|
let p = pathCache.get(c.subpaths);
|
|
2383
2385
|
if (!p) {
|
|
2384
|
-
p =
|
|
2386
|
+
p = _chunkIOFVM3L3cjs.subpathsToBezier.call(void 0, c.subpaths);
|
|
2385
2387
|
pathCache.set(c.subpaths, p);
|
|
2386
2388
|
}
|
|
2387
2389
|
return p;
|
|
@@ -2506,11 +2508,11 @@ function componentsCoverage(components, rect, rule = "nonzero", inverted = false
|
|
|
2506
2508
|
function paintContext(env) {
|
|
2507
2509
|
const tiles = /* @__PURE__ */ new Map();
|
|
2508
2510
|
return {
|
|
2509
|
-
light:
|
|
2511
|
+
light: _chunkDPYAO5U6cjs.DEFAULT_GLOBAL_LIGHT,
|
|
2510
2512
|
pattern: (id) => {
|
|
2511
2513
|
if (tiles.has(id)) return tiles.get(id);
|
|
2512
|
-
const p = _nullishCoalesce(_optionalChain([env, 'access', _18 => _18.pattern, 'optionalCall', _19 => _19(id)]), () => (
|
|
2513
|
-
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0,
|
|
2514
|
+
const p = _nullishCoalesce(_optionalChain([env, 'access', _18 => _18.pattern, 'optionalCall', _19 => _19(id)]), () => ( _chunkDPYAO5U6cjs.builtinPattern.call(void 0, id)));
|
|
2515
|
+
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkDPYAO5U6cjs.PatternTile)(p) : null;
|
|
2514
2516
|
tiles.set(id, t);
|
|
2515
2517
|
return t;
|
|
2516
2518
|
}
|
|
@@ -2541,9 +2543,9 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
|
|
|
2541
2543
|
if (!fCov && !sCov) return null;
|
|
2542
2544
|
const canvas = { x: 0, y: 0, width: env.width, height: env.height };
|
|
2543
2545
|
const anchor = { x: geo.frame.x, y: geo.frame.y };
|
|
2544
|
-
const fc = fCov ?
|
|
2546
|
+
const fc = fCov ? _chunkDPYAO5U6cjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
2545
2547
|
const fo = _nullishCoalesce(_optionalChain([layer, 'access', _20 => _20.fill, 'optionalAccess', _21 => _21.opacity]), () => ( 1));
|
|
2546
|
-
const sc = sCov ?
|
|
2548
|
+
const sc = sCov ? _chunkDPYAO5U6cjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
2547
2549
|
const so = _nullishCoalesce(_optionalChain([layer, 'access', _22 => _22.stroke, 'optionalAccess', _23 => _23.paint, 'access', _24 => _24.opacity]), () => ( 1));
|
|
2548
2550
|
const out = new Uint8ClampedArray(n * 4);
|
|
2549
2551
|
let any = false;
|
|
@@ -2636,9 +2638,9 @@ function normalizeShapePaint(v, path = "paint") {
|
|
|
2636
2638
|
offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
|
|
2637
2639
|
};
|
|
2638
2640
|
try {
|
|
2639
|
-
|
|
2641
|
+
_chunkDPYAO5U6cjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
|
|
2640
2642
|
} catch (e) {
|
|
2641
|
-
if (e instanceof
|
|
2643
|
+
if (e instanceof _chunkDPYAO5U6cjs.LayerEffectError) fail(e.message);
|
|
2642
2644
|
throw e;
|
|
2643
2645
|
}
|
|
2644
2646
|
if (gradient.stops.length < 1) fail(`${path}.gradient.stops needs at least one { position, color }.`);
|
|
@@ -2708,7 +2710,7 @@ function matrixArg(v, path) {
|
|
|
2708
2710
|
if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail(`${path} must be six numbers [a, b, c, d, e, f].`);
|
|
2709
2711
|
const m = v;
|
|
2710
2712
|
if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail(`${path} is singular.`);
|
|
2711
|
-
return
|
|
2713
|
+
return _chunkIOFVM3L3cjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
|
|
2712
2714
|
}
|
|
2713
2715
|
function normalizeLiveShape(v, path = "shape") {
|
|
2714
2716
|
if (!v || typeof v !== "object") return fail(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
|
|
@@ -2769,7 +2771,7 @@ function normalizeSubpaths(v, path = "subpaths") {
|
|
|
2769
2771
|
if (typeof v === "string") {
|
|
2770
2772
|
let subs;
|
|
2771
2773
|
try {
|
|
2772
|
-
subs =
|
|
2774
|
+
subs = _chunkIOFVM3L3cjs.bezierToSubpaths.call(void 0, v);
|
|
2773
2775
|
} catch (e5) {
|
|
2774
2776
|
return fail(`${path}: could not read the SVG path data.`);
|
|
2775
2777
|
}
|
|
@@ -2850,20 +2852,20 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
|
|
|
2850
2852
|
if (!("annotation" in patch)) delete next.annotation;
|
|
2851
2853
|
if (!next.components.length) fail("A shape needs at least one component; delete the layer instead.");
|
|
2852
2854
|
const rendered = rerenderShape(next, env);
|
|
2853
|
-
return { layers:
|
|
2855
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
2854
2856
|
}
|
|
2855
2857
|
function transformShapeComponents(components, f, affine) {
|
|
2856
2858
|
return components.map((c) => {
|
|
2857
2859
|
if (affine && c.live) {
|
|
2858
|
-
const live = { ...c.live, transform:
|
|
2859
|
-
if (
|
|
2860
|
+
const live = { ...c.live, transform: _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkIOFVM3L3cjs.IDENTITY_MATRIX)), affine) };
|
|
2861
|
+
if (_chunkIOFVM3L3cjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
|
|
2860
2862
|
return { op: c.op, subpaths: liveShapeSubpaths(live), live };
|
|
2861
2863
|
}
|
|
2862
2864
|
return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
|
|
2863
2865
|
});
|
|
2864
2866
|
}
|
|
2865
2867
|
function offsetShape(layer, dx, dy, env) {
|
|
2866
|
-
const m =
|
|
2868
|
+
const m = _chunkIOFVM3L3cjs.translateMatrix.call(void 0, dx, dy);
|
|
2867
2869
|
const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
|
|
2868
2870
|
delete next.annotation;
|
|
2869
2871
|
return rerenderShape(next, env);
|
|
@@ -2871,7 +2873,7 @@ function offsetShape(layer, dx, dy, env) {
|
|
|
2871
2873
|
function mergeShapeComponents(components, fillRule = "nonzero") {
|
|
2872
2874
|
if (components.length < 2) return [...components];
|
|
2873
2875
|
const path = shapeOutline(components, fillRule);
|
|
2874
|
-
const subpaths =
|
|
2876
|
+
const subpaths = _chunkIOFVM3L3cjs.bezierToSubpaths.call(void 0, path);
|
|
2875
2877
|
if (!subpaths.length) fail("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
|
|
2876
2878
|
return [{ op: "combine", subpaths }];
|
|
2877
2879
|
}
|
|
@@ -2881,14 +2883,14 @@ function shapeAsPixelLayer(layer) {
|
|
|
2881
2883
|
}
|
|
2882
2884
|
function annotationPaint(color, opacity) {
|
|
2883
2885
|
const c = _chunkA2IS7EHEcjs.parseCssColor.call(void 0, color);
|
|
2884
|
-
if (!c || !
|
|
2886
|
+
if (!c || !_chunkDPYAO5U6cjs.parseEffectColor.call(void 0, c.hex)) return void 0;
|
|
2885
2887
|
const a = c.alpha * opacity;
|
|
2886
2888
|
return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
|
|
2887
2889
|
}
|
|
2888
2890
|
function shapeFromAnnotation(a) {
|
|
2889
2891
|
const opacity = _nullishCoalesce(a.opacity, () => ( 1));
|
|
2890
2892
|
const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
|
|
2891
|
-
const rotation = a.rotation ?
|
|
2893
|
+
const rotation = a.rotation ? _chunkIOFVM3L3cjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
|
|
2892
2894
|
const t = rotation ? { transform: rotation } : {};
|
|
2893
2895
|
const live = (l) => liveComponent(l);
|
|
2894
2896
|
switch (a.type) {
|
|
@@ -2931,7 +2933,7 @@ function shapeFromAnnotation(a) {
|
|
|
2931
2933
|
case "pen": {
|
|
2932
2934
|
const paint = annotationPaint(a.strokeColor, opacity);
|
|
2933
2935
|
if (!paint) return null;
|
|
2934
|
-
const pts = rotation ? a.points.map((p) =>
|
|
2936
|
+
const pts = rotation ? a.points.map((p) => _chunkIOFVM3L3cjs.applyMatrix.call(void 0, rotation, p)) : a.points;
|
|
2935
2937
|
const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
|
|
2936
2938
|
return {
|
|
2937
2939
|
components: [{ op: "combine", subpaths }],
|
|
@@ -2945,7 +2947,7 @@ function shapeFromAnnotation(a) {
|
|
|
2945
2947
|
}
|
|
2946
2948
|
function annotationBlend(a, layerBlend) {
|
|
2947
2949
|
if (layerBlend !== "normal") return layerBlend;
|
|
2948
|
-
return a.blend &&
|
|
2950
|
+
return a.blend && _chunk2VX55NFMcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
|
|
2949
2951
|
}
|
|
2950
2952
|
function annotationOfShape(layer) {
|
|
2951
2953
|
const a = layer.annotation;
|
|
@@ -2964,7 +2966,7 @@ var JOIN_SIGMA = 2;
|
|
|
2964
2966
|
function vectorMaskSegments(components) {
|
|
2965
2967
|
const out = [];
|
|
2966
2968
|
components.forEach((c, ci) => c.subpaths.forEach((sp, si) => {
|
|
2967
|
-
for (let k = 0; k <
|
|
2969
|
+
for (let k = 0; k < _chunkIOFVM3L3cjs.subpathSegmentCount.call(void 0, sp); k++) out.push({ component: ci, subpath: si, segment: k });
|
|
2968
2970
|
}));
|
|
2969
2971
|
return out;
|
|
2970
2972
|
}
|
|
@@ -2972,7 +2974,7 @@ function validVectorMaskEdges(edges, components) {
|
|
|
2972
2974
|
if (!_optionalChain([edges, 'optionalAccess', _34 => _34.length])) return [];
|
|
2973
2975
|
return edges.filter((e) => {
|
|
2974
2976
|
const sp = _optionalChain([components, 'access', _35 => _35[e.component], 'optionalAccess', _36 => _36.subpaths, 'access', _37 => _37[e.subpath]]);
|
|
2975
|
-
return Boolean(sp) && e.segment >= 0 && e.segment <
|
|
2977
|
+
return Boolean(sp) && e.segment >= 0 && e.segment < _chunkIOFVM3L3cjs.subpathSegmentCount.call(void 0, sp);
|
|
2976
2978
|
});
|
|
2977
2979
|
}
|
|
2978
2980
|
function reach(e) {
|
|
@@ -2995,8 +2997,8 @@ function hybridVectorMaskCoverage(vm, hard, width, height, guide) {
|
|
|
2995
2997
|
const seedClass = [];
|
|
2996
2998
|
vm.components.forEach(
|
|
2997
2999
|
(c, ci) => c.subpaths.forEach((sp, si) => {
|
|
2998
|
-
for (let k = 0; k <
|
|
2999
|
-
const seg =
|
|
3000
|
+
for (let k = 0; k < _chunkIOFVM3L3cjs.subpathSegmentCount.call(void 0, sp); k++) {
|
|
3001
|
+
const seg = _chunkIOFVM3L3cjs.subpathSegment.call(void 0, sp, k);
|
|
3000
3002
|
let len = 0;
|
|
3001
3003
|
for (let i = 1; i < seg.length; i++) len += Math.hypot(seg[i][0] - seg[i - 1][0], seg[i][1] - seg[i - 1][1]);
|
|
3002
3004
|
const steps = Math.max(2, Math.ceil(len * 2));
|
|
@@ -3320,18 +3322,18 @@ function userErrorMessage(err) {
|
|
|
3320
3322
|
return err instanceof Error ? err.message : String(err);
|
|
3321
3323
|
}
|
|
3322
3324
|
function isPaintableLayer(layer) {
|
|
3323
|
-
return layer.type === "pixel" && layer.visible && !
|
|
3325
|
+
return layer.type === "pixel" && layer.visible && !_chunkDPYAO5U6cjs.isLayerLocked.call(void 0, layer, "pixels");
|
|
3324
3326
|
}
|
|
3325
3327
|
function defaultActiveLayerId(layers) {
|
|
3326
|
-
const pixels =
|
|
3328
|
+
const pixels = _chunkDPYAO5U6cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
3327
3329
|
for (let i = pixels.length - 1; i >= 0; i--) if (isPaintableLayer(pixels[i])) return pixels[i].id;
|
|
3328
3330
|
return _nullishCoalesce(_optionalChain([pixels, 'access', _47 => _47[pixels.length - 1], 'optionalAccess', _48 => _48.id]), () => ( null));
|
|
3329
3331
|
}
|
|
3330
3332
|
function activeLayerAfterRemoval(prev, next, removedId) {
|
|
3331
|
-
const before =
|
|
3333
|
+
const before = _chunkDPYAO5U6cjs.flattenLayers.call(void 0, prev);
|
|
3332
3334
|
const at = before.findIndex((l) => l.id === removedId);
|
|
3333
3335
|
for (let i = at - 1; i >= 0; i--) {
|
|
3334
|
-
const loc =
|
|
3336
|
+
const loc = _chunkDPYAO5U6cjs.findLayer.call(void 0, next, before[i].id);
|
|
3335
3337
|
if (loc && isPaintableLayer(loc.layer)) return loc.layer.id;
|
|
3336
3338
|
}
|
|
3337
3339
|
return defaultActiveLayerId(next);
|
|
@@ -3340,47 +3342,47 @@ var fail2 = (message) => {
|
|
|
3340
3342
|
throw new LayerOperationError(message);
|
|
3341
3343
|
};
|
|
3342
3344
|
function requireLayer(layers, id) {
|
|
3343
|
-
const loc =
|
|
3345
|
+
const loc = _chunkDPYAO5U6cjs.findLayer.call(void 0, layers, id);
|
|
3344
3346
|
if (!loc) {
|
|
3345
|
-
const ids =
|
|
3347
|
+
const ids = _chunkDPYAO5U6cjs.flattenLayers.call(void 0, layers).map((l) => l.id);
|
|
3346
3348
|
fail2(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
|
|
3347
3349
|
}
|
|
3348
3350
|
return loc;
|
|
3349
3351
|
}
|
|
3350
3352
|
function requireUnlocked(layer, what, action) {
|
|
3351
|
-
if (
|
|
3352
|
-
if (what !== "all" &&
|
|
3353
|
+
if (_chunkDPYAO5U6cjs.isLayerLocked.call(void 0, layer, "all")) fail2(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
|
|
3354
|
+
if (what !== "all" && _chunkDPYAO5U6cjs.isLayerLocked.call(void 0, layer, what)) fail2(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
|
|
3353
3355
|
}
|
|
3354
3356
|
function placeLayer(layers, layer, placement = {}, defaultIndex) {
|
|
3355
3357
|
const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
|
|
3356
3358
|
if (given > 1) fail2("Give only one of aboveId, belowId and parentId.");
|
|
3357
3359
|
if (placement.aboveId || placement.belowId) {
|
|
3358
3360
|
const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
|
|
3359
|
-
return
|
|
3361
|
+
return _chunkDPYAO5U6cjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _49 => _49.parent, 'optionalAccess', _50 => _50.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
|
|
3360
3362
|
}
|
|
3361
3363
|
if (placement.parentId) {
|
|
3362
3364
|
const ref = requireLayer(layers, placement.parentId);
|
|
3363
3365
|
if (ref.layer.type !== "group") fail2(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
|
|
3364
|
-
return
|
|
3366
|
+
return _chunkDPYAO5U6cjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
|
|
3365
3367
|
}
|
|
3366
|
-
return
|
|
3368
|
+
return _chunkDPYAO5U6cjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
|
|
3367
3369
|
}
|
|
3368
3370
|
function removeLayer(layers, id) {
|
|
3369
3371
|
const loc = requireLayer(layers, id);
|
|
3370
3372
|
requireUnlocked(loc.layer, "all", "delete it");
|
|
3371
|
-
return
|
|
3373
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3372
3374
|
}
|
|
3373
3375
|
function moveLayer(layers, id, placement) {
|
|
3374
3376
|
const loc = requireLayer(layers, id);
|
|
3375
3377
|
requireUnlocked(loc.layer, "all", "move it");
|
|
3376
3378
|
const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
|
|
3377
3379
|
if (target === id) fail2("A layer cannot be placed relative to itself.");
|
|
3378
|
-
if (target && loc.layer.type === "group" &&
|
|
3380
|
+
if (target && loc.layer.type === "group" && _chunkDPYAO5U6cjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
|
|
3379
3381
|
fail2(`Group "${id}" cannot be moved into its own child "${target}".`);
|
|
3380
3382
|
}
|
|
3381
3383
|
if (target) requireLayer(layers, target);
|
|
3382
3384
|
if (!target && placement.index === void 0) fail2("Give aboveId, belowId, parentId or index.");
|
|
3383
|
-
const without =
|
|
3385
|
+
const without = _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3384
3386
|
return placeLayer(without, loc.layer, placement);
|
|
3385
3387
|
}
|
|
3386
3388
|
function withNewIds(layer) {
|
|
@@ -3399,7 +3401,7 @@ function duplicateLayer(layers, id, name) {
|
|
|
3399
3401
|
const copy = withNewIds(loc.layer);
|
|
3400
3402
|
copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
|
|
3401
3403
|
delete copy.locks;
|
|
3402
|
-
return { layers:
|
|
3404
|
+
return { layers: _chunkDPYAO5U6cjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _53 => _53.parent, 'optionalAccess', _54 => _54.id]), () => ( null)), loc.index + 1), id: copy.id };
|
|
3403
3405
|
}
|
|
3404
3406
|
function setLayerProperties(layers, id, props) {
|
|
3405
3407
|
const loc = requireLayer(layers, id);
|
|
@@ -3426,7 +3428,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
3426
3428
|
if (props.blend !== void 0) {
|
|
3427
3429
|
if (props.blend === "pass-through") {
|
|
3428
3430
|
if (layer.type !== "group") fail2("pass-through is only for groups.");
|
|
3429
|
-
} else if (!
|
|
3431
|
+
} else if (!_chunk2VX55NFMcjs.isBlendMode.call(void 0, props.blend)) fail2(`Unknown blend mode "${props.blend}".`);
|
|
3430
3432
|
next.blend = props.blend;
|
|
3431
3433
|
}
|
|
3432
3434
|
if (props.clipped !== void 0) {
|
|
@@ -3446,7 +3448,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
3446
3448
|
if (props.collapsed) g.collapsed = true;
|
|
3447
3449
|
else delete g.collapsed;
|
|
3448
3450
|
}
|
|
3449
|
-
return
|
|
3451
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3450
3452
|
}
|
|
3451
3453
|
function groupLayers(layers, ids, name = "Group") {
|
|
3452
3454
|
if (!ids.length) fail2("Give at least one layer id to group.");
|
|
@@ -3475,17 +3477,17 @@ function groupLayers(layers, ids, name = "Group") {
|
|
|
3475
3477
|
group.children[0] = c;
|
|
3476
3478
|
}
|
|
3477
3479
|
let out = layers;
|
|
3478
|
-
for (const l of ordered) out =
|
|
3479
|
-
return { layers:
|
|
3480
|
+
for (const l of ordered) out = _chunkDPYAO5U6cjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
3481
|
+
return { layers: _chunkDPYAO5U6cjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
|
|
3480
3482
|
}
|
|
3481
3483
|
function ungroupLayer(layers, id) {
|
|
3482
3484
|
const loc = requireLayer(layers, id);
|
|
3483
3485
|
if (loc.layer.type !== "group") fail2(`Layer "${id}" is not a group.`);
|
|
3484
3486
|
requireUnlocked(loc.layer, "all", "ungroup it");
|
|
3485
3487
|
const group = loc.layer;
|
|
3486
|
-
let out =
|
|
3488
|
+
let out = _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3487
3489
|
group.children.forEach((c, i) => {
|
|
3488
|
-
out =
|
|
3490
|
+
out = _chunkDPYAO5U6cjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _63 => _63.parent, 'optionalAccess', _64 => _64.id]), () => ( null)), loc.index + i);
|
|
3489
3491
|
});
|
|
3490
3492
|
return { layers: out, ids: group.children.map((c) => c.id) };
|
|
3491
3493
|
}
|
|
@@ -3500,12 +3502,12 @@ function offsetLayer(layers, id, offset) {
|
|
|
3500
3502
|
if (mask && mask.linked === false && !mask.source) {
|
|
3501
3503
|
next.mask = { ...mask, surface: _chunk474IQG74cjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
|
|
3502
3504
|
}
|
|
3503
|
-
return
|
|
3505
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => followLayerMove(next, next.offset.x - layer.offset.x, next.offset.y - layer.offset.y));
|
|
3504
3506
|
}
|
|
3505
3507
|
function setLayerMask(layers, id, mask) {
|
|
3506
3508
|
const loc = requireLayer(layers, id);
|
|
3507
3509
|
requireUnlocked(loc.layer, "all", "change its mask");
|
|
3508
|
-
return
|
|
3510
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, (l) => {
|
|
3509
3511
|
const next = { ...l };
|
|
3510
3512
|
if (mask) next.mask = mask;
|
|
3511
3513
|
else delete next.mask;
|
|
@@ -3544,7 +3546,7 @@ function requirePixelLayer(layers, id) {
|
|
|
3544
3546
|
function addLayerFilter(layers, id, filter) {
|
|
3545
3547
|
const layer = requirePixelLayer(layers, id);
|
|
3546
3548
|
if (_optionalChain([layer, 'access', _65 => _65.filters, 'optionalAccess', _66 => _66.some, 'call', _67 => _67((f) => f.kind === filter.kind)])) fail2(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
|
|
3547
|
-
return
|
|
3549
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
|
|
3548
3550
|
}
|
|
3549
3551
|
function updateLayerFilter(layers, id, filterId, changes) {
|
|
3550
3552
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -3555,7 +3557,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
|
|
|
3555
3557
|
const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
3556
3558
|
const filters = [...layer.filters];
|
|
3557
3559
|
filters[i] = merged2;
|
|
3558
|
-
return
|
|
3560
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
|
|
3559
3561
|
}
|
|
3560
3562
|
function removeLayerFilter(layers, id, filterId) {
|
|
3561
3563
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -3564,7 +3566,7 @@ function removeLayerFilter(layers, id, filterId) {
|
|
|
3564
3566
|
const next = { ...layer };
|
|
3565
3567
|
if (filters.length) next.filters = filters;
|
|
3566
3568
|
else delete next.filters;
|
|
3567
|
-
return
|
|
3569
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3568
3570
|
}
|
|
3569
3571
|
function requireEffectLayer(layers, id, action) {
|
|
3570
3572
|
const layer = requireLayer(layers, id).layer;
|
|
@@ -3579,7 +3581,7 @@ function guard(fn) {
|
|
|
3579
3581
|
try {
|
|
3580
3582
|
return fn();
|
|
3581
3583
|
} catch (e) {
|
|
3582
|
-
if (e instanceof
|
|
3584
|
+
if (e instanceof _chunkDPYAO5U6cjs.LayerEffectError) fail2(e.message);
|
|
3583
3585
|
throw e;
|
|
3584
3586
|
}
|
|
3585
3587
|
}
|
|
@@ -3587,20 +3589,20 @@ function setLayerEffects(layers, id, effects) {
|
|
|
3587
3589
|
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3588
3590
|
const next = { ...layer };
|
|
3589
3591
|
if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
|
|
3590
|
-
guard(() =>
|
|
3592
|
+
guard(() => _chunkDPYAO5U6cjs.validateLayerEffects.call(void 0, effects));
|
|
3591
3593
|
next.effects = effects;
|
|
3592
3594
|
} else delete next.effects;
|
|
3593
|
-
return
|
|
3595
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3594
3596
|
}
|
|
3595
3597
|
function addLayerEffect(layers, id, kind, params = {}, index) {
|
|
3596
|
-
if (!
|
|
3598
|
+
if (!_chunkDPYAO5U6cjs.isLayerEffectKind.call(void 0, kind)) fail2(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkDPYAO5U6cjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
3597
3599
|
const layer = requireEffectLayer(layers, id, "add effects");
|
|
3598
3600
|
const current = layerEffectsOf(layer);
|
|
3599
3601
|
const ids = new Set(current.items.map((e) => e.id));
|
|
3600
|
-
let effectId =
|
|
3601
|
-
while (ids.has(effectId)) effectId =
|
|
3602
|
+
let effectId = _chunkDPYAO5U6cjs.newEffectId.call(void 0, );
|
|
3603
|
+
while (ids.has(effectId)) effectId = _chunkDPYAO5U6cjs.newEffectId.call(void 0, );
|
|
3602
3604
|
const { id: _ignored, kind: _kind, ...rest } = params;
|
|
3603
|
-
const effect = guard(() =>
|
|
3605
|
+
const effect = guard(() => _chunkDPYAO5U6cjs.mergeLayerEffect.call(void 0, _chunkDPYAO5U6cjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
|
|
3604
3606
|
const items = [...current.items];
|
|
3605
3607
|
const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
|
|
3606
3608
|
items.splice(at, 0, effect);
|
|
@@ -3617,7 +3619,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
|
|
|
3617
3619
|
const i = requireEffect(layer, effectId);
|
|
3618
3620
|
const current = layer.effects;
|
|
3619
3621
|
const items = [...current.items];
|
|
3620
|
-
items[i] = guard(() =>
|
|
3622
|
+
items[i] = guard(() => _chunkDPYAO5U6cjs.mergeLayerEffect.call(void 0, items[i], changes));
|
|
3621
3623
|
return setLayerEffects(layers, id, { ...current, items });
|
|
3622
3624
|
}
|
|
3623
3625
|
function removeLayerEffect(layers, id, effectId) {
|
|
@@ -3640,7 +3642,7 @@ function setLayerEffectsEnabled(layers, id, enabled, scale) {
|
|
|
3640
3642
|
function parseBlend(value, allowPassThrough = false) {
|
|
3641
3643
|
if (value === void 0) return void 0;
|
|
3642
3644
|
if (value === "pass-through" && allowPassThrough) return value;
|
|
3643
|
-
if (!
|
|
3645
|
+
if (!_chunk2VX55NFMcjs.isBlendMode.call(void 0, value)) fail2(`Unknown blend mode "${String(value)}".`);
|
|
3644
3646
|
return value;
|
|
3645
3647
|
}
|
|
3646
3648
|
function unionRect(a, b) {
|
|
@@ -3862,7 +3864,7 @@ var PHOTO_PROFILE = {
|
|
|
3862
3864
|
return v;
|
|
3863
3865
|
}
|
|
3864
3866
|
};
|
|
3865
|
-
var LayerCompositor = class extends
|
|
3867
|
+
var LayerCompositor = class extends _chunkDPYAO5U6cjs.RasterCompositor {
|
|
3866
3868
|
constructor(options = {}) {
|
|
3867
3869
|
super(PHOTO_PROFILE, options);
|
|
3868
3870
|
}
|
|
@@ -3878,7 +3880,7 @@ var LayerCompositor = class extends _chunkHB4ICNNAcjs.RasterCompositor {
|
|
|
3878
3880
|
}
|
|
3879
3881
|
};
|
|
3880
3882
|
function compositeDeep(layers, rect, sources, depth) {
|
|
3881
|
-
const deep = new (0,
|
|
3883
|
+
const deep = new (0, _chunkDPYAO5U6cjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
|
|
3882
3884
|
applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks),
|
|
3883
3885
|
pixelFiltersDeep: (l) => {
|
|
3884
3886
|
if (l.type !== "pixel" || hasEdgeUnmix(l.edge)) return null;
|
|
@@ -3894,9 +3896,9 @@ function compositeDeep(layers, rect, sources, depth) {
|
|
|
3894
3896
|
var fail3 = (message) => {
|
|
3895
3897
|
throw new LayerOperationError(message);
|
|
3896
3898
|
};
|
|
3897
|
-
var TEXT_RENDER_MARGIN =
|
|
3899
|
+
var TEXT_RENDER_MARGIN = _chunkDPYAO5U6cjs.MAX_EFFECT_REACH;
|
|
3898
3900
|
function textMatrix(layer) {
|
|
3899
|
-
return _nullishCoalesce(layer.transform, () => (
|
|
3901
|
+
return _nullishCoalesce(layer.transform, () => ( _chunkIOFVM3L3cjs.IDENTITY_MATRIX));
|
|
3900
3902
|
}
|
|
3901
3903
|
function rectCorners(r) {
|
|
3902
3904
|
return [
|
|
@@ -3907,7 +3909,7 @@ function rectCorners(r) {
|
|
|
3907
3909
|
];
|
|
3908
3910
|
}
|
|
3909
3911
|
function docRect(r, m) {
|
|
3910
|
-
const pts = rectCorners(r).map((p) =>
|
|
3912
|
+
const pts = rectCorners(r).map((p) => _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, p));
|
|
3911
3913
|
const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
|
|
3912
3914
|
const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
|
|
3913
3915
|
const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
|
|
@@ -3927,7 +3929,7 @@ function inkBounds(layout) {
|
|
|
3927
3929
|
for (const f of l.fragments) {
|
|
3928
3930
|
const pad = f.style.fontSize * (l.matrix ? 1 : 0.5);
|
|
3929
3931
|
const w = f.carets[f.carets.length - 1];
|
|
3930
|
-
const r =
|
|
3932
|
+
const r = _chunkIOFVM3L3cjs.transformTextRect.call(void 0, l.matrix, { x: f.x - pad, y: l.baseline - l.ascent - pad + Math.min(0, f.y - l.baseline), width: w + 2 * pad, height: l.ascent + l.descent + 2 * pad + Math.abs(f.y - l.baseline) });
|
|
3931
3933
|
if (!b) b = r;
|
|
3932
3934
|
else {
|
|
3933
3935
|
const x0 = Math.min(b.x, r.x);
|
|
@@ -3940,14 +3942,14 @@ function inkBounds(layout) {
|
|
|
3940
3942
|
}
|
|
3941
3943
|
function textOutlines(layer, shaper) {
|
|
3942
3944
|
if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
|
|
3943
|
-
const layout =
|
|
3945
|
+
const layout = _chunkIOFVM3L3cjs.layoutText.call(void 0, layer, shaper);
|
|
3944
3946
|
const m = textMatrix(layer);
|
|
3945
3947
|
const out = [];
|
|
3946
3948
|
for (const l of layout.lines) {
|
|
3947
3949
|
for (const f of l.fragments) {
|
|
3948
|
-
let path =
|
|
3949
|
-
for (const r of
|
|
3950
|
-
out.push({ fragment: f, path:
|
|
3950
|
+
let path = _chunkIOFVM3L3cjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
|
|
3951
|
+
for (const r of _chunkIOFVM3L3cjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunkIOFVM3L3cjs.textRectPath.call(void 0, r)];
|
|
3952
|
+
out.push({ fragment: f, path: _chunkIOFVM3L3cjs.isIdentityMatrix.call(void 0, m) ? path : _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, path, m) });
|
|
3951
3953
|
}
|
|
3952
3954
|
}
|
|
3953
3955
|
return out;
|
|
@@ -4003,7 +4005,7 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4003
4005
|
const canvas = env.createCanvas(region.width, region.height);
|
|
4004
4006
|
const ctx = canvas.getContext("2d");
|
|
4005
4007
|
if (!ctx || typeof ctx.getImageData !== "function") return null;
|
|
4006
|
-
const layout =
|
|
4008
|
+
const layout = _chunkIOFVM3L3cjs.layoutText.call(void 0, layer, shaper);
|
|
4007
4009
|
const m = textMatrix(layer);
|
|
4008
4010
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4009
4011
|
ctx.clearRect(0, 0, region.width, region.height);
|
|
@@ -4013,8 +4015,8 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4013
4015
|
const [r, g, b] = rgbOf(f.style.color);
|
|
4014
4016
|
ctx.fillStyle = `rgb(${r}, ${g}, ${b})`;
|
|
4015
4017
|
ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
|
|
4016
|
-
|
|
4017
|
-
for (const d of
|
|
4018
|
+
_chunkIOFVM3L3cjs.drawTextFragment.call(void 0, ctx, shaper, layer.text, f);
|
|
4019
|
+
for (const d of _chunkIOFVM3L3cjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
|
|
4018
4020
|
}
|
|
4019
4021
|
}
|
|
4020
4022
|
ctx.globalAlpha = 1;
|
|
@@ -4025,7 +4027,7 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4025
4027
|
function renderText(layer, env) {
|
|
4026
4028
|
const shaper = env.shaper;
|
|
4027
4029
|
if (!shaper || !shaper.outline && !shaper.draw) return null;
|
|
4028
|
-
const layout =
|
|
4030
|
+
const layout = _chunkIOFVM3L3cjs.layoutText.call(void 0, layer, shaper);
|
|
4029
4031
|
const ink = inkBounds(layout);
|
|
4030
4032
|
const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
|
|
4031
4033
|
const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
|
|
@@ -4126,7 +4128,7 @@ function patchParagraphStyle(base, patch, path = "paragraph") {
|
|
|
4126
4128
|
continue;
|
|
4127
4129
|
}
|
|
4128
4130
|
const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
|
|
4129
|
-
if (k === "autoLeading" && value ===
|
|
4131
|
+
if (k === "autoLeading" && value === _chunkIOFVM3L3cjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
|
|
4130
4132
|
else o[k] = value;
|
|
4131
4133
|
} else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
|
|
4132
4134
|
}
|
|
@@ -4167,15 +4169,15 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
|
|
|
4167
4169
|
opacity: 1,
|
|
4168
4170
|
blend: "normal",
|
|
4169
4171
|
text: text3,
|
|
4170
|
-
runs:
|
|
4171
|
-
paragraphs:
|
|
4172
|
+
runs: _chunkIOFVM3L3cjs.fitRuns.call(void 0, init.runs, text3.length, _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE),
|
|
4173
|
+
paragraphs: _chunkIOFVM3L3cjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
|
|
4172
4174
|
frame: init.frame,
|
|
4173
4175
|
...init.orientation === "vertical" ? { orientation: "vertical" } : {},
|
|
4174
4176
|
surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4),
|
|
4175
4177
|
offset: { x: 0, y: 0 }
|
|
4176
4178
|
};
|
|
4177
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _79 => _79.runs, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.style]), () => (
|
|
4178
|
-
if (init.transform && !
|
|
4179
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _79 => _79.runs, 'access', _80 => _80[0], 'optionalAccess', _81 => _81.style]), () => ( _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE)) }];
|
|
4180
|
+
if (init.transform && !_chunkIOFVM3L3cjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
|
|
4179
4181
|
if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
|
|
4180
4182
|
return rerenderText(layer, env);
|
|
4181
4183
|
}
|
|
@@ -4186,24 +4188,24 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
|
|
|
4186
4188
|
const next = { ...current, ...patch };
|
|
4187
4189
|
if (!("annotation" in patch)) delete next.annotation;
|
|
4188
4190
|
if (next.orientation !== "vertical") delete next.orientation;
|
|
4189
|
-
if ("text" in patch || "runs" in patch) next.runs =
|
|
4190
|
-
if (!next.runs.length) next.runs = [{ length: 0, style:
|
|
4191
|
-
if ("text" in patch || "paragraphs" in patch) next.paragraphs =
|
|
4191
|
+
if ("text" in patch || "runs" in patch) next.runs = _chunkIOFVM3L3cjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _82 => _82.runs, 'access', _83 => _83[0], 'optionalAccess', _84 => _84.style]), () => ( _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE)));
|
|
4192
|
+
if (!next.runs.length) next.runs = [{ length: 0, style: _chunkIOFVM3L3cjs.styleAt.call(void 0, current.runs, 0, _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE) }];
|
|
4193
|
+
if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkIOFVM3L3cjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
|
|
4192
4194
|
const rendered = rerenderText(next, env);
|
|
4193
|
-
return { layers:
|
|
4195
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
4194
4196
|
}
|
|
4195
4197
|
function replaceTextRange(layer, start, end, insert) {
|
|
4196
4198
|
const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
|
|
4197
|
-
const style =
|
|
4198
|
-
const runs =
|
|
4199
|
-
const pstyle =
|
|
4200
|
-
const paragraphs =
|
|
4201
|
-
return { text: text3, runs, paragraphs:
|
|
4199
|
+
const style = _chunkIOFVM3L3cjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE);
|
|
4200
|
+
const runs = _chunkIOFVM3L3cjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
|
|
4201
|
+
const pstyle = _chunkIOFVM3L3cjs.styleAt.call(void 0, layer.paragraphs, start, {});
|
|
4202
|
+
const paragraphs = _chunkIOFVM3L3cjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
|
|
4203
|
+
return { text: text3, runs, paragraphs: _chunkIOFVM3L3cjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
|
|
4202
4204
|
}
|
|
4203
4205
|
function transformTypeLayer(layer, m) {
|
|
4204
|
-
const t =
|
|
4206
|
+
const t = _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
|
|
4205
4207
|
const next = { ...layer };
|
|
4206
|
-
if (
|
|
4208
|
+
if (_chunkIOFVM3L3cjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
|
|
4207
4209
|
else next.transform = t;
|
|
4208
4210
|
delete next.annotation;
|
|
4209
4211
|
return next;
|
|
@@ -4211,7 +4213,7 @@ function transformTypeLayer(layer, m) {
|
|
|
4211
4213
|
function typeFrame(layer, shaper) {
|
|
4212
4214
|
if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
|
|
4213
4215
|
if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
|
|
4214
|
-
const b =
|
|
4216
|
+
const b = _chunkIOFVM3L3cjs.layoutText.call(void 0, layer, shaper).bounds;
|
|
4215
4217
|
return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
|
|
4216
4218
|
}
|
|
4217
4219
|
function typeAsPixelLayer(layer) {
|
|
@@ -4219,7 +4221,7 @@ function typeAsPixelLayer(layer) {
|
|
|
4219
4221
|
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
4220
4222
|
}
|
|
4221
4223
|
function toTextSpace(layer, p) {
|
|
4222
|
-
return
|
|
4224
|
+
return _chunkIOFVM3L3cjs.applyMatrix.call(void 0, _chunkIOFVM3L3cjs.invertMatrix.call(void 0, textMatrix(layer)), p);
|
|
4223
4225
|
}
|
|
4224
4226
|
function typeFromAnnotation(a) {
|
|
4225
4227
|
if (a.type !== "text") return null;
|
|
@@ -4233,7 +4235,7 @@ function typeFromAnnotation(a) {
|
|
|
4233
4235
|
if (op !== 1) style.opacity = op;
|
|
4234
4236
|
const text3 = t.text.replace(/\r?\n|\r/g, " ");
|
|
4235
4237
|
const translate = [1, 0, 0, 1, t.x, t.y];
|
|
4236
|
-
const transform = t.rotation ?
|
|
4238
|
+
const transform = t.rotation ? _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, translate, _chunkIOFVM3L3cjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
|
|
4237
4239
|
return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
|
|
4238
4240
|
}
|
|
4239
4241
|
function annotationOfType(layer) {
|
|
@@ -4567,7 +4569,7 @@ function identityTransform(box2) {
|
|
|
4567
4569
|
}
|
|
4568
4570
|
function cornersFromMatrix(box2, m) {
|
|
4569
4571
|
const q2 = _chunkQT26RHKKcjs.boxQuad.call(void 0, box2);
|
|
4570
|
-
return [
|
|
4572
|
+
return [_chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[0]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[1]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[2]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4571
4573
|
}
|
|
4572
4574
|
function matrixFromCorners(box2, corners, eps = 1e-6) {
|
|
4573
4575
|
const [tl, tr, br, bl] = corners;
|
|
@@ -4584,7 +4586,7 @@ function transformHomography(geometry) {
|
|
|
4584
4586
|
function hasWarp(geometry) {
|
|
4585
4587
|
const w = geometry.warp;
|
|
4586
4588
|
if (!w) return false;
|
|
4587
|
-
const id =
|
|
4589
|
+
const id = _chunkIOFVM3L3cjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
|
|
4588
4590
|
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;
|
|
4589
4591
|
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);
|
|
4590
4592
|
}
|
|
@@ -4599,7 +4601,7 @@ function transformMap(geometry) {
|
|
|
4599
4601
|
const { box: box2 } = geometry;
|
|
4600
4602
|
const warp = hasWarp(geometry) ? geometry.warp : null;
|
|
4601
4603
|
if (!warp) return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h, p);
|
|
4602
|
-
return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h,
|
|
4604
|
+
return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h, _chunkIOFVM3L3cjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
|
|
4603
4605
|
}
|
|
4604
4606
|
function transformedPoint(geometry, fx, fy) {
|
|
4605
4607
|
const f = transformMap(geometry);
|
|
@@ -4643,8 +4645,8 @@ function matrixFromParams(box2, params) {
|
|
|
4643
4645
|
const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
|
|
4644
4646
|
const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
|
|
4645
4647
|
const ref = referencePoint(box2, params.reference);
|
|
4646
|
-
const linear =
|
|
4647
|
-
return
|
|
4648
|
+
const linear = _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkIOFVM3L3cjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
|
|
4649
|
+
return _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, _chunkIOFVM3L3cjs.matrixAbout.call(void 0, linear, ref), _chunkIOFVM3L3cjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
|
|
4648
4650
|
}
|
|
4649
4651
|
function describeTransform(geometry, reference = "center") {
|
|
4650
4652
|
const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4661,7 +4663,7 @@ function describeTransform(geometry, reference = "center") {
|
|
|
4661
4663
|
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
4662
4664
|
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
4663
4665
|
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
4664
|
-
const at =
|
|
4666
|
+
const at = _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, ref);
|
|
4665
4667
|
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
4666
4668
|
return {
|
|
4667
4669
|
affine: true,
|
|
@@ -4679,24 +4681,24 @@ function applyParams(geometry, params) {
|
|
|
4679
4681
|
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
4680
4682
|
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
4681
4683
|
const c = geometry.corners;
|
|
4682
|
-
return [
|
|
4684
|
+
return [_chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, c[0]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, c[1]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, c[2]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, c[3])];
|
|
4683
4685
|
}
|
|
4684
4686
|
function flipCorners(geometry, axis) {
|
|
4685
4687
|
const c = anchorPoint(geometry, "center");
|
|
4686
4688
|
const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
|
|
4687
4689
|
const q2 = geometry.corners;
|
|
4688
|
-
return [
|
|
4690
|
+
return [_chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[0]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[1]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[2]), _chunkIOFVM3L3cjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4689
4691
|
}
|
|
4690
4692
|
function boxPointOf(geometry, p) {
|
|
4691
4693
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
4692
|
-
if (m) return
|
|
4694
|
+
if (m) return _chunkIOFVM3L3cjs.applyMatrix.call(void 0, _chunkIOFVM3L3cjs.invertMatrix.call(void 0, m), p);
|
|
4693
4695
|
return null;
|
|
4694
4696
|
}
|
|
4695
4697
|
function presetWarp(box2, preset) {
|
|
4696
|
-
return
|
|
4698
|
+
return _chunkIOFVM3L3cjs.warpPresetMesh.call(void 0, preset, box2);
|
|
4697
4699
|
}
|
|
4698
4700
|
function isValidWarp(mesh) {
|
|
4699
|
-
return
|
|
4701
|
+
return _chunkIOFVM3L3cjs.isValidWarpMesh.call(void 0, mesh);
|
|
4700
4702
|
}
|
|
4701
4703
|
function geometryHomography(geometry) {
|
|
4702
4704
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4707,7 +4709,7 @@ function geometryHomography(geometry) {
|
|
|
4707
4709
|
var fail4 = (message) => {
|
|
4708
4710
|
throw new LayerOperationError(message);
|
|
4709
4711
|
};
|
|
4710
|
-
var SMART_RENDER_MARGIN =
|
|
4712
|
+
var SMART_RENDER_MARGIN = _chunkDPYAO5U6cjs.MAX_EFFECT_REACH;
|
|
4711
4713
|
var incompleteSurfaces = /* @__PURE__ */ new WeakSet();
|
|
4712
4714
|
var isSmartSurfaceIncomplete = (surface) => incompleteSurfaces.has(surface);
|
|
4713
4715
|
var surfaceIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -4823,7 +4825,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4823
4825
|
k = step;
|
|
4824
4826
|
let r = _optionalChain([options, 'access', _101 => _101.reduced, 'optionalAccess', _102 => _102.get, 'call', _103 => _103(k)]);
|
|
4825
4827
|
if (!r) {
|
|
4826
|
-
r =
|
|
4828
|
+
r = _chunkDPYAO5U6cjs.reduceSurface.call(void 0, src, k);
|
|
4827
4829
|
_optionalChain([options, 'access', _104 => _104.reduced, 'optionalAccess', _105 => _105.set, 'call', _106 => _106(k, r)]);
|
|
4828
4830
|
}
|
|
4829
4831
|
source = r;
|
|
@@ -4833,15 +4835,15 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4833
4835
|
if (hasWarp(g)) {
|
|
4834
4836
|
const f = transformMap(g);
|
|
4835
4837
|
if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4836
|
-
out =
|
|
4838
|
+
out = _chunkDPYAO5U6cjs.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 });
|
|
4837
4839
|
} else {
|
|
4838
4840
|
const h = transformHomography(g);
|
|
4839
4841
|
if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4840
4842
|
const hk = _chunkQT26RHKKcjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
|
|
4841
|
-
out =
|
|
4843
|
+
out = _chunkDPYAO5U6cjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
4842
4844
|
}
|
|
4843
4845
|
} catch (e) {
|
|
4844
|
-
if (e instanceof
|
|
4846
|
+
if (e instanceof _chunkDPYAO5U6cjs.TransformTooLargeError) fail4(e.message);
|
|
4845
4847
|
throw e;
|
|
4846
4848
|
}
|
|
4847
4849
|
}
|
|
@@ -4918,7 +4920,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
4918
4920
|
if (f.opacity >= 1) acc = out2;
|
|
4919
4921
|
else lerpInto(acc, out2, f.opacity, null);
|
|
4920
4922
|
} else {
|
|
4921
|
-
|
|
4923
|
+
_chunkDPYAO5U6cjs.blendTile.call(void 0, acc, out2, f.blend, f.opacity, null);
|
|
4922
4924
|
}
|
|
4923
4925
|
}
|
|
4924
4926
|
entry = { key, base, filtered: acc };
|
|
@@ -4975,11 +4977,11 @@ function normalizePlacement(raw, contents) {
|
|
|
4975
4977
|
}
|
|
4976
4978
|
const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
|
|
4977
4979
|
if (raw.warp) {
|
|
4978
|
-
if (!
|
|
4980
|
+
if (!_chunkIOFVM3L3cjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("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.");
|
|
4979
4981
|
out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
4980
4982
|
}
|
|
4981
4983
|
if (raw.interpolation !== void 0) {
|
|
4982
|
-
if (!
|
|
4984
|
+
if (!_chunkDPYAO5U6cjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
4983
4985
|
if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
|
|
4984
4986
|
}
|
|
4985
4987
|
const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
|
|
@@ -4999,7 +5001,7 @@ function followMask(mask, before, after) {
|
|
|
4999
5001
|
const inv = _chunkQT26RHKKcjs.invertHomography.call(void 0, h0);
|
|
5000
5002
|
if (!inv) return mask;
|
|
5001
5003
|
const delta = _chunkQT26RHKKcjs.multiplyHomographies.call(void 0, inv, h1);
|
|
5002
|
-
const surface =
|
|
5004
|
+
const surface = _chunkDPYAO5U6cjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
|
|
5003
5005
|
return { ...mask, surface };
|
|
5004
5006
|
}
|
|
5005
5007
|
function setSmartPlacement(layers, id, placement, canvas) {
|
|
@@ -5020,7 +5022,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
|
|
|
5020
5022
|
next.smartFilters = { ...next.smartFilters, mask: m };
|
|
5021
5023
|
}
|
|
5022
5024
|
next = rerender(next, canvas, "be transformed");
|
|
5023
|
-
return { layers:
|
|
5025
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
|
|
5024
5026
|
}
|
|
5025
5027
|
function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
5026
5028
|
const layer = requireSmartObject(layers, id);
|
|
@@ -5043,7 +5045,7 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
|
5043
5045
|
} else {
|
|
5044
5046
|
next = rerender(next, canvas, "move");
|
|
5045
5047
|
}
|
|
5046
|
-
return
|
|
5048
|
+
return _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next);
|
|
5047
5049
|
}
|
|
5048
5050
|
function translateLayer(layer, dx, dy) {
|
|
5049
5051
|
if (!dx && !dy) return layer;
|
|
@@ -5079,7 +5081,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5079
5081
|
case "shape": {
|
|
5080
5082
|
const next = {
|
|
5081
5083
|
...layer,
|
|
5082
|
-
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }),
|
|
5084
|
+
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkIOFVM3L3cjs.translateMatrix.call(void 0, dx, dy)),
|
|
5083
5085
|
surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
5084
5086
|
mask: moveMask(layer.mask)
|
|
5085
5087
|
};
|
|
@@ -5088,7 +5090,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5088
5090
|
return next;
|
|
5089
5091
|
}
|
|
5090
5092
|
case "type": {
|
|
5091
|
-
const next = { ...transformTypeLayer(layer,
|
|
5093
|
+
const next = { ...transformTypeLayer(layer, _chunkIOFVM3L3cjs.translateMatrix.call(void 0, dx, dy)), surface: _chunk474IQG74cjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
|
|
5092
5094
|
if (!next.mask) delete next.mask;
|
|
5093
5095
|
return next;
|
|
5094
5096
|
}
|
|
@@ -5111,7 +5113,7 @@ function layerExtent(layer, surfaceOf, canvas) {
|
|
|
5111
5113
|
} else {
|
|
5112
5114
|
b = full;
|
|
5113
5115
|
}
|
|
5114
|
-
const m =
|
|
5116
|
+
const m = _chunkDPYAO5U6cjs.effectsMargin.call(void 0, layer.effects);
|
|
5115
5117
|
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) };
|
|
5116
5118
|
return b;
|
|
5117
5119
|
}
|
|
@@ -5180,7 +5182,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5180
5182
|
delete resolved2.source;
|
|
5181
5183
|
layer = resolved2;
|
|
5182
5184
|
}
|
|
5183
|
-
if (
|
|
5185
|
+
if (_chunkDPYAO5U6cjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
|
|
5184
5186
|
return translateLayer(layer, -b.x, -b.y);
|
|
5185
5187
|
});
|
|
5186
5188
|
if (nested[0].clipped) {
|
|
@@ -5207,8 +5209,8 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5207
5209
|
smart = { ...smart, surface: renderSmartObject(smart, canvas) };
|
|
5208
5210
|
const below = ordered.filter((l) => l.index < top.index).length;
|
|
5209
5211
|
let out = layers;
|
|
5210
|
-
for (const l of ordered) out =
|
|
5211
|
-
return { layers:
|
|
5212
|
+
for (const l of ordered) out = _chunkDPYAO5U6cjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
5213
|
+
return { layers: _chunkDPYAO5U6cjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
|
|
5212
5214
|
}
|
|
5213
5215
|
function rasterizeSmartObject(layers, id) {
|
|
5214
5216
|
const layer = requireSmartObject(layers, id);
|
|
@@ -5228,7 +5230,7 @@ function rasterizeSmartObject(layers, id) {
|
|
|
5228
5230
|
if (layer.locks) out.locks = layer.locks;
|
|
5229
5231
|
if (layer.effects) out.effects = layer.effects;
|
|
5230
5232
|
if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
|
|
5231
|
-
return { layers:
|
|
5233
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
|
|
5232
5234
|
}
|
|
5233
5235
|
function copySmartObject(layers, id, linked, name) {
|
|
5234
5236
|
const loc = requireLayer(layers, id);
|
|
@@ -5238,19 +5240,19 @@ function copySmartObject(layers, id, linked, name) {
|
|
|
5238
5240
|
delete copy.psd;
|
|
5239
5241
|
if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
|
|
5240
5242
|
if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
|
|
5241
|
-
return { layers:
|
|
5243
|
+
return { layers: _chunkDPYAO5U6cjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _140 => _140.parent, 'optionalAccess', _141 => _141.id]), () => ( null)), loc.index + 1), layer: copy };
|
|
5242
5244
|
}
|
|
5243
5245
|
function instancesOf(layers, contentsId) {
|
|
5244
|
-
return
|
|
5246
|
+
return _chunkDPYAO5U6cjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
|
|
5245
5247
|
}
|
|
5246
5248
|
function replaceContents(layers, contentsId, contents, canvas) {
|
|
5247
5249
|
const ids = instancesOf(layers, contentsId);
|
|
5248
5250
|
if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
|
|
5249
|
-
for (const id of ids) requireUnlocked(
|
|
5251
|
+
for (const id of ids) requireUnlocked(_chunkDPYAO5U6cjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
|
|
5250
5252
|
const next = { ...contents, id: contentsId };
|
|
5251
5253
|
let out = layers;
|
|
5252
5254
|
for (const id of ids) {
|
|
5253
|
-
out =
|
|
5255
|
+
out = _chunkDPYAO5U6cjs.mapLayer.call(void 0, out, id, (l) => {
|
|
5254
5256
|
const layer = l;
|
|
5255
5257
|
return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
|
|
5256
5258
|
});
|
|
@@ -5274,14 +5276,14 @@ function refitPlacement(layer, contents) {
|
|
|
5274
5276
|
});
|
|
5275
5277
|
const out = { corners: pts };
|
|
5276
5278
|
if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
|
|
5277
|
-
if (layer.placement.warp) out.warp =
|
|
5279
|
+
if (layer.placement.warp) out.warp = _chunkIOFVM3L3cjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
|
|
5278
5280
|
return out;
|
|
5279
5281
|
}
|
|
5280
5282
|
function normalizeSmartFilter(raw, id = newLayerId("flt")) {
|
|
5281
5283
|
if (raw.kind === "psd") fail4("Photoshop filters can only come from a PSD; add develop or blur.");
|
|
5282
5284
|
const base = raw.kind === "effect" ? normalizeEffectSmartFilter(raw, id) : normalizeFilter(raw, id);
|
|
5283
5285
|
const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
|
|
5284
|
-
if (!
|
|
5286
|
+
if (!_chunk2VX55NFMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
5285
5287
|
const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
|
|
5286
5288
|
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
5287
5289
|
return { ...base, blend, opacity };
|
|
@@ -5329,7 +5331,7 @@ function addSmartFilter(layers, id, filter, canvas, index) {
|
|
|
5329
5331
|
const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
|
|
5330
5332
|
filters.splice(at, 0, filter);
|
|
5331
5333
|
const next = withStack(layer, { ...stack, filters }, canvas);
|
|
5332
|
-
return { layers:
|
|
5334
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
|
|
5333
5335
|
}
|
|
5334
5336
|
function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
5335
5337
|
const layer = editableSmart(layers, id);
|
|
@@ -5341,7 +5343,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5341
5343
|
const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
|
|
5342
5344
|
if (extra.length) fail4(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
|
|
5343
5345
|
const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
|
|
5344
|
-
if (!
|
|
5346
|
+
if (!_chunk2VX55NFMcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
5345
5347
|
const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
|
|
5346
5348
|
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
5347
5349
|
merged2 = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
|
|
@@ -5351,7 +5353,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5351
5353
|
const filters = [...layer.smartFilters.filters];
|
|
5352
5354
|
filters[i] = merged2;
|
|
5353
5355
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5354
|
-
return { layers:
|
|
5356
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
|
|
5355
5357
|
}
|
|
5356
5358
|
function removeSmartFilter(layers, id, filterId, canvas) {
|
|
5357
5359
|
const layer = editableSmart(layers, id);
|
|
@@ -5359,7 +5361,7 @@ function removeSmartFilter(layers, id, filterId, canvas) {
|
|
|
5359
5361
|
const stack = layer.smartFilters;
|
|
5360
5362
|
const filters = stack.filters.filter((f) => f.id !== filterId);
|
|
5361
5363
|
const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
|
|
5362
|
-
return { layers:
|
|
5364
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5363
5365
|
}
|
|
5364
5366
|
function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
5365
5367
|
const layer = editableSmart(layers, id);
|
|
@@ -5370,12 +5372,12 @@ function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
|
5370
5372
|
const [f] = filters.splice(i, 1);
|
|
5371
5373
|
filters.splice(index, 0, f);
|
|
5372
5374
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5373
|
-
return { layers:
|
|
5375
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5374
5376
|
}
|
|
5375
5377
|
function setSmartFiltersEnabled(layers, id, enabled, canvas) {
|
|
5376
5378
|
const layer = editableSmart(layers, id);
|
|
5377
5379
|
const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
|
|
5378
|
-
return { layers:
|
|
5380
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5379
5381
|
}
|
|
5380
5382
|
function setSmartFilterMask(layers, id, mask, canvas) {
|
|
5381
5383
|
const layer = editableSmart(layers, id);
|
|
@@ -5384,7 +5386,7 @@ function setSmartFilterMask(layers, id, mask, canvas) {
|
|
|
5384
5386
|
if (mask) stack.mask = mask;
|
|
5385
5387
|
else delete stack.mask;
|
|
5386
5388
|
const next = withStack(layer, stack, canvas);
|
|
5387
|
-
return { layers:
|
|
5389
|
+
return { layers: _chunkDPYAO5U6cjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5388
5390
|
}
|
|
5389
5391
|
function withFilterMaskSurface(layer, surface, canvas) {
|
|
5390
5392
|
const stack = stackOf(layer);
|
|
@@ -5398,7 +5400,7 @@ function placementBounds(layer) {
|
|
|
5398
5400
|
// src/image-editor/layers/serialize.ts
|
|
5399
5401
|
var LAYERED_SCHEMA_VERSION = 3;
|
|
5400
5402
|
function serializePatterns(patterns) {
|
|
5401
|
-
return patterns.map((p) => ({ id: p.id, name: p.name, png:
|
|
5403
|
+
return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkW5M3J7PVcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
|
|
5402
5404
|
}
|
|
5403
5405
|
function deserializePatterns(raw, problems = []) {
|
|
5404
5406
|
if (!Array.isArray(raw)) return [];
|
|
@@ -5421,7 +5423,7 @@ function encodeSurface(surface) {
|
|
|
5421
5423
|
let out = null;
|
|
5422
5424
|
if (b) {
|
|
5423
5425
|
const data = _chunk474IQG74cjs.readRegion.call(void 0, surface, b);
|
|
5424
|
-
out = { url:
|
|
5426
|
+
out = { url: _chunkW5M3J7PVcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
|
|
5425
5427
|
}
|
|
5426
5428
|
encodedCache.set(surface, out);
|
|
5427
5429
|
return out;
|
|
@@ -5430,15 +5432,15 @@ var deepCache = /* @__PURE__ */ new WeakMap();
|
|
|
5430
5432
|
function encodeDeepSurface(surface) {
|
|
5431
5433
|
if (deepCache.has(surface)) return deepCache.get(surface);
|
|
5432
5434
|
let out = null;
|
|
5433
|
-
const depth =
|
|
5435
|
+
const depth = _chunk2VX55NFMcjs.surfaceDepth.call(void 0, surface);
|
|
5434
5436
|
const b = depth === 8 ? null : _chunk474IQG74cjs.contentBounds.call(void 0, surface);
|
|
5435
5437
|
if (depth !== 8 && b) {
|
|
5436
|
-
const samples =
|
|
5438
|
+
const samples = _chunk2VX55NFMcjs.readDeepRegion.call(void 0, surface, b, depth);
|
|
5437
5439
|
const bytes = new Uint8Array(samples.byteLength);
|
|
5438
5440
|
const view = new DataView(bytes.buffer);
|
|
5439
5441
|
if (samples instanceof Uint16Array) for (let i = 0; i < samples.length; i++) view.setUint16(2 * i, samples[i], true);
|
|
5440
5442
|
else for (let i = 0; i < samples.length; i++) view.setFloat32(4 * i, samples[i], true);
|
|
5441
|
-
out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data:
|
|
5443
|
+
out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, _chunkXFM3OCHUcjs.deflate.call(void 0, bytes)) };
|
|
5442
5444
|
}
|
|
5443
5445
|
deepCache.set(surface, out);
|
|
5444
5446
|
return out;
|
|
@@ -5450,13 +5452,13 @@ function decodeDeepSurface(surface, raw, problems, label) {
|
|
|
5450
5452
|
if (d.depth !== 16 && d.depth !== 32 || !(d.width > 0 && d.height > 0) || !Number.isInteger(d.x) || !Number.isInteger(d.y) || typeof d.data !== "string") throw new Error("malformed");
|
|
5451
5453
|
const n = d.width * d.height * surface.channels;
|
|
5452
5454
|
const size = d.depth === 16 ? 2 : 4;
|
|
5453
|
-
const bytes = _chunkXFM3OCHUcjs.inflate.call(void 0,
|
|
5455
|
+
const bytes = _chunkXFM3OCHUcjs.inflate.call(void 0, _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, d.data), { maxOutput: n * size });
|
|
5454
5456
|
if (bytes.length !== n * size) throw new Error("wrong length");
|
|
5455
5457
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
5456
5458
|
const samples = d.depth === 16 ? new Uint16Array(n) : new Float32Array(n);
|
|
5457
5459
|
if (samples instanceof Uint16Array) for (let i = 0; i < n; i++) samples[i] = view.getUint16(2 * i, true);
|
|
5458
5460
|
else for (let i = 0; i < n; i++) samples[i] = view.getFloat32(4 * i, true);
|
|
5459
|
-
return
|
|
5461
|
+
return _chunk2VX55NFMcjs.writeDeepRegion.call(void 0, surface, { x: d.x, y: d.y, width: d.width, height: d.height }, samples);
|
|
5460
5462
|
} catch (e6) {
|
|
5461
5463
|
problems.push(`${label}: its ${d.depth}-bit samples could not be read, so it was opened at 8 bits`);
|
|
5462
5464
|
return surface;
|
|
@@ -5493,7 +5495,7 @@ function readEdgeColor(raw) {
|
|
|
5493
5495
|
function serializeEffects(effects) {
|
|
5494
5496
|
const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
|
|
5495
5497
|
if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
|
|
5496
|
-
if (effects.psd) out.psd = { key: effects.psd.key, data:
|
|
5498
|
+
if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, effects.psd.data) };
|
|
5497
5499
|
return out;
|
|
5498
5500
|
}
|
|
5499
5501
|
function deserializeEffects(raw) {
|
|
@@ -5503,12 +5505,12 @@ function deserializeEffects(raw) {
|
|
|
5503
5505
|
const p = r.psd;
|
|
5504
5506
|
if (p && typeof p.key === "string" && typeof p.data === "string") {
|
|
5505
5507
|
try {
|
|
5506
|
-
psd = { key: p.key, data:
|
|
5508
|
+
psd = { key: p.key, data: _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, p.data) };
|
|
5507
5509
|
} catch (e7) {
|
|
5508
5510
|
psd = void 0;
|
|
5509
5511
|
}
|
|
5510
5512
|
}
|
|
5511
|
-
return
|
|
5513
|
+
return _chunkDPYAO5U6cjs.normalizeLayerEffects.call(void 0, { ...r, psd });
|
|
5512
5514
|
}
|
|
5513
5515
|
function serializeVectorMask(vm) {
|
|
5514
5516
|
const out = { components: JSON.parse(JSON.stringify(vm.components)) };
|
|
@@ -5639,8 +5641,8 @@ function serializeType(layer, base, ctx) {
|
|
|
5639
5641
|
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5640
5642
|
if (_optionalChain([layer, 'access', _158 => _158.psd, 'optionalAccess', _159 => _159.tySh]) || _optionalChain([layer, 'access', _160 => _160.psd, 'optionalAccess', _161 => _161.blocks, 'optionalAccess', _162 => _162.length])) {
|
|
5641
5643
|
out.psd = {};
|
|
5642
|
-
if (layer.psd.tySh) out.psd.tySh =
|
|
5643
|
-
if (_optionalChain([layer, 'access', _163 => _163.psd, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data:
|
|
5644
|
+
if (layer.psd.tySh) out.psd.tySh = _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, layer.psd.tySh);
|
|
5645
|
+
if (_optionalChain([layer, 'access', _163 => _163.psd, 'access', _164 => _164.blocks, 'optionalAccess', _165 => _165.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, b.data) }));
|
|
5644
5646
|
if (layer.psd.signature) out.psd.signature = layer.psd.signature;
|
|
5645
5647
|
}
|
|
5646
5648
|
return out;
|
|
@@ -5651,7 +5653,7 @@ function readType(r, base, ctx) {
|
|
|
5651
5653
|
const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
|
|
5652
5654
|
const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
|
|
5653
5655
|
length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _166 => _166.length]), 0, 1e9, 0))),
|
|
5654
|
-
style: patchTextStyle(
|
|
5656
|
+
style: patchTextStyle(_chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _167 => _167.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
|
|
5655
5657
|
}));
|
|
5656
5658
|
const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
|
|
5657
5659
|
length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _168 => _168.length]), 0, 1e9, 0))),
|
|
@@ -5664,13 +5666,13 @@ function readType(r, base, ctx) {
|
|
|
5664
5666
|
...base,
|
|
5665
5667
|
type: "type",
|
|
5666
5668
|
text: text3,
|
|
5667
|
-
runs:
|
|
5668
|
-
paragraphs:
|
|
5669
|
+
runs: _chunkIOFVM3L3cjs.fitRuns.call(void 0, runs, text3.length, _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE),
|
|
5670
|
+
paragraphs: _chunkIOFVM3L3cjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
|
|
5669
5671
|
frame,
|
|
5670
5672
|
surface: _chunk474IQG74cjs.emptySurface.call(void 0, 4),
|
|
5671
5673
|
offset: { x: 0, y: 0 }
|
|
5672
5674
|
};
|
|
5673
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _172 => _172[0], 'optionalAccess', _173 => _173.style]), () => (
|
|
5675
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _172 => _172[0], 'optionalAccess', _173 => _173.style]), () => ( _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE)) }];
|
|
5674
5676
|
if (m) layer.transform = m;
|
|
5675
5677
|
if (r.orientation === "vertical") layer.orientation = "vertical";
|
|
5676
5678
|
if (r.antiAlias === false) layer.antiAlias = false;
|
|
@@ -5679,8 +5681,8 @@ function readType(r, base, ctx) {
|
|
|
5679
5681
|
if (r.annotation && typeof r.annotation === "object" && r.annotation.type === "text") layer.annotation = JSON.parse(JSON.stringify({ ...r.annotation, id: _nullishCoalesce(r.annotation.id, () => ( base.id)) }));
|
|
5680
5682
|
if (r.psd && typeof r.psd === "object") {
|
|
5681
5683
|
const psd = {};
|
|
5682
|
-
if (typeof r.psd.tySh === "string") psd.tySh =
|
|
5683
|
-
if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data:
|
|
5684
|
+
if (typeof r.psd.tySh === "string") psd.tySh = _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, r.psd.tySh);
|
|
5685
|
+
if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5684
5686
|
if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
|
|
5685
5687
|
if (psd.tySh || _optionalChain([psd, 'access', _174 => _174.blocks, 'optionalAccess', _175 => _175.length])) layer.psd = psd;
|
|
5686
5688
|
}
|
|
@@ -5708,7 +5710,7 @@ function serializeShape(layer, base) {
|
|
|
5708
5710
|
if (layer.inverted) out.inverted = true;
|
|
5709
5711
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5710
5712
|
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5711
|
-
if (_optionalChain([layer, 'access', _180 => _180.psd, 'optionalAccess', _181 => _181.blocks, 'optionalAccess', _182 => _182.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data:
|
|
5713
|
+
if (_optionalChain([layer, 'access', _180 => _180.psd, 'optionalAccess', _181 => _181.blocks, 'optionalAccess', _182 => _182.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
|
|
5712
5714
|
return out;
|
|
5713
5715
|
}
|
|
5714
5716
|
function readShape(r, base, ctx) {
|
|
@@ -5740,7 +5742,7 @@ function readShape(r, base, ctx) {
|
|
|
5740
5742
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5741
5743
|
if (a && shapeFromAnnotation(a)) out.annotation = a;
|
|
5742
5744
|
if (r.psd && Array.isArray(r.psd.blocks)) {
|
|
5743
|
-
const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data:
|
|
5745
|
+
const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5744
5746
|
if (blocks.length) out.psd = { blocks };
|
|
5745
5747
|
if (out.psd && typeof r.psd.signature === "string") out.psd.signature = r.psd.signature;
|
|
5746
5748
|
}
|
|
@@ -5753,7 +5755,7 @@ function readShape(r, base, ctx) {
|
|
|
5753
5755
|
function serializeSmartFilters(stack, layerId, ctx) {
|
|
5754
5756
|
const out = {
|
|
5755
5757
|
enabled: stack.enabled,
|
|
5756
|
-
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data:
|
|
5758
|
+
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
|
|
5757
5759
|
};
|
|
5758
5760
|
if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
|
|
5759
5761
|
return out;
|
|
@@ -5779,7 +5781,7 @@ function serializeSmartObject(layer, base, ctx) {
|
|
|
5779
5781
|
}
|
|
5780
5782
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5781
5783
|
if (layer.psd) {
|
|
5782
|
-
out.psd = { key: layer.psd.key, data:
|
|
5784
|
+
out.psd = { key: layer.psd.key, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, layer.psd.data) };
|
|
5783
5785
|
if (layer.psd.placed) out.psd.placed = layer.psd.placed;
|
|
5784
5786
|
}
|
|
5785
5787
|
return out;
|
|
@@ -5791,7 +5793,7 @@ function serializeContents(c, ctx) {
|
|
|
5791
5793
|
if (enc) {
|
|
5792
5794
|
if (enc.x !== 0 || enc.y !== 0) {
|
|
5793
5795
|
const data = _chunk474IQG74cjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
|
|
5794
|
-
out.asset = ctx.addAsset(
|
|
5796
|
+
out.asset = ctx.addAsset(_chunkW5M3J7PVcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
|
|
5795
5797
|
} else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
|
|
5796
5798
|
}
|
|
5797
5799
|
}
|
|
@@ -5800,7 +5802,7 @@ function serializeContents(c, ctx) {
|
|
|
5800
5802
|
if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
|
|
5801
5803
|
if (_optionalChain([c, 'access', _187 => _187.document, 'access', _188 => _188.patterns, 'optionalAccess', _189 => _189.length])) out.patterns = serializePatterns(c.document.patterns);
|
|
5802
5804
|
}
|
|
5803
|
-
if (c.file) out.file = { type: c.file.type, data:
|
|
5805
|
+
if (c.file) out.file = { type: c.file.type, data: _chunkW5M3J7PVcjs.bytesToBase64.call(void 0, c.file.bytes) };
|
|
5804
5806
|
if (c.linked) out.linked = { path: c.linked.path };
|
|
5805
5807
|
return out;
|
|
5806
5808
|
}
|
|
@@ -5836,7 +5838,7 @@ async function serializeLayersExternal(layers, store) {
|
|
|
5836
5838
|
for (const [id, url] of Object.entries(inline.assets)) {
|
|
5837
5839
|
let ref = refs.get(url);
|
|
5838
5840
|
if (!ref) {
|
|
5839
|
-
const parsed =
|
|
5841
|
+
const parsed = _chunkW5M3J7PVcjs.parseDataUrl.call(void 0, url);
|
|
5840
5842
|
const png = decodePngHeader(parsed.bytes);
|
|
5841
5843
|
ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
|
|
5842
5844
|
if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
|
|
@@ -5864,7 +5866,7 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
5864
5866
|
try {
|
|
5865
5867
|
const blob = await store.get(ref);
|
|
5866
5868
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
5867
|
-
out[id] = `data:image/png;base64,${
|
|
5869
|
+
out[id] = `data:image/png;base64,${_chunkW5M3J7PVcjs.bytesToBase64.call(void 0, bytes)}`;
|
|
5868
5870
|
} catch (err) {
|
|
5869
5871
|
problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
|
|
5870
5872
|
}
|
|
@@ -5872,9 +5874,9 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
5872
5874
|
return out;
|
|
5873
5875
|
}
|
|
5874
5876
|
function decodePngDataUrl(url, channels) {
|
|
5875
|
-
const parsed =
|
|
5877
|
+
const parsed = _chunkW5M3J7PVcjs.parseDataUrl.call(void 0, url);
|
|
5876
5878
|
if (!parsed) throw new Error("Asset is not a data URL.");
|
|
5877
|
-
const png =
|
|
5879
|
+
const png = _chunkW5M3J7PVcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
|
|
5878
5880
|
if (png.channels === channels) return png;
|
|
5879
5881
|
if (channels === 1) {
|
|
5880
5882
|
const out2 = new Uint8ClampedArray(png.width * png.height);
|
|
@@ -5960,7 +5962,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
5960
5962
|
name: typeof r.name === "string" ? r.name : "",
|
|
5961
5963
|
visible: r.visible !== false,
|
|
5962
5964
|
opacity: num2(r.opacity, 0, 1, 1),
|
|
5963
|
-
blend:
|
|
5965
|
+
blend: _chunk2VX55NFMcjs.normalizeBlendMode.call(void 0, r.blend)
|
|
5964
5966
|
};
|
|
5965
5967
|
if (r.clipped === true) base.clipped = true;
|
|
5966
5968
|
const edge = readEdgeColor(r.edge);
|
|
@@ -6015,7 +6017,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
6015
6017
|
}
|
|
6016
6018
|
case "group": {
|
|
6017
6019
|
const children = Array.isArray(r.children) ? r.children.map((c) => deserializeLayer(c, ctx)).filter(Boolean) : [];
|
|
6018
|
-
const blend = r.blend === "pass-through" ? "pass-through" :
|
|
6020
|
+
const blend = r.blend === "pass-through" ? "pass-through" : _chunk2VX55NFMcjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
|
|
6019
6021
|
const group = { ...base, type: "group", blend, children };
|
|
6020
6022
|
if (r.collapsed === true) group.collapsed = true;
|
|
6021
6023
|
return group;
|
|
@@ -6067,7 +6069,7 @@ function readContents(id, ctx) {
|
|
|
6067
6069
|
const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
|
|
6068
6070
|
if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
|
|
6069
6071
|
try {
|
|
6070
|
-
c.file = { type: raw.file.type, bytes:
|
|
6072
|
+
c.file = { type: raw.file.type, bytes: _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, raw.file.data) };
|
|
6071
6073
|
} catch (e9) {
|
|
6072
6074
|
ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
|
|
6073
6075
|
}
|
|
@@ -6107,11 +6109,11 @@ function readSmartFilters(raw, ctx, what) {
|
|
|
6107
6109
|
let k = 0;
|
|
6108
6110
|
for (const f of list2) {
|
|
6109
6111
|
if (!f || typeof f !== "object") continue;
|
|
6110
|
-
const blend =
|
|
6112
|
+
const blend = _chunk2VX55NFMcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
|
|
6111
6113
|
const opacity = num2(f.opacity, 0, 1, 1);
|
|
6112
6114
|
if (f.kind === "psd") {
|
|
6113
6115
|
try {
|
|
6114
|
-
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:
|
|
6116
|
+
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: _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
|
|
6115
6117
|
} catch (e10) {
|
|
6116
6118
|
ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
|
|
6117
6119
|
}
|
|
@@ -6140,8 +6142,8 @@ function readSmartObject(r, base, ctx) {
|
|
|
6140
6142
|
let placement;
|
|
6141
6143
|
try {
|
|
6142
6144
|
const raw = { corners: p.corners };
|
|
6143
|
-
if (p.warp &&
|
|
6144
|
-
if (
|
|
6145
|
+
if (p.warp && _chunkIOFVM3L3cjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
|
|
6146
|
+
if (_chunkDPYAO5U6cjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
|
|
6145
6147
|
placement = normalizePlacement(raw, contents);
|
|
6146
6148
|
} catch (e) {
|
|
6147
6149
|
ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
|
|
@@ -6153,7 +6155,7 @@ function readSmartObject(r, base, ctx) {
|
|
|
6153
6155
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
6154
6156
|
if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
|
|
6155
6157
|
try {
|
|
6156
|
-
layer.psd = { key: r.psd.key, data:
|
|
6158
|
+
layer.psd = { key: r.psd.key, data: _chunkW5M3J7PVcjs.base64ToBytes.call(void 0, r.psd.data) };
|
|
6157
6159
|
if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
|
|
6158
6160
|
} catch (e11) {
|
|
6159
6161
|
}
|
|
@@ -7311,7 +7313,7 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
|
|
|
7311
7313
|
const fr = (p) => ({ x: p.x / w, y: p.y / h });
|
|
7312
7314
|
const subpaths = [];
|
|
7313
7315
|
components.forEach((c, ci) => {
|
|
7314
|
-
|
|
7316
|
+
_chunkIOFVM3L3cjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
|
|
7315
7317
|
if (!sp.anchors.length) return;
|
|
7316
7318
|
subpaths.push({
|
|
7317
7319
|
closed: sp.closed,
|
|
@@ -8137,7 +8139,7 @@ function merged(levels) {
|
|
|
8137
8139
|
function charStyle(d, fonts, notes, vertical = false) {
|
|
8138
8140
|
const n = (k) => eNum(eGet(d, k));
|
|
8139
8141
|
const flag = (k) => eBool(eGet(d, k));
|
|
8140
|
-
const s = { ...
|
|
8142
|
+
const s = { ..._chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE };
|
|
8141
8143
|
const fi = n("Font");
|
|
8142
8144
|
const ps = fi !== void 0 ? fonts[fi] : void 0;
|
|
8143
8145
|
if (ps) {
|
|
@@ -8222,7 +8224,7 @@ function typeFromTySh(data, notes) {
|
|
|
8222
8224
|
}
|
|
8223
8225
|
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
8224
8226
|
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
8225
|
-
let runs = [{ length: text3.length, style: { ...
|
|
8227
|
+
let runs = [{ length: text3.length, style: { ..._chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE } }];
|
|
8226
8228
|
let paragraphs = [{ length: text3.length, style: {} }];
|
|
8227
8229
|
let frame = { kind: "point" };
|
|
8228
8230
|
let transform = t.transform;
|
|
@@ -8278,14 +8280,14 @@ function typeFromTySh(data, notes) {
|
|
|
8278
8280
|
const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
8279
8281
|
if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
|
|
8280
8282
|
frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
|
|
8281
|
-
transform =
|
|
8283
|
+
transform = _chunkIOFVM3L3cjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
|
|
8282
8284
|
}
|
|
8283
8285
|
}
|
|
8284
8286
|
}
|
|
8285
8287
|
return {
|
|
8286
8288
|
text: text3,
|
|
8287
|
-
runs:
|
|
8288
|
-
paragraphs:
|
|
8289
|
+
runs: _chunkIOFVM3L3cjs.fitRuns.call(void 0, runs, text3.length, _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE),
|
|
8290
|
+
paragraphs: _chunkIOFVM3L3cjs.fitParagraphRuns.call(void 0, paragraphs, text3),
|
|
8289
8291
|
frame,
|
|
8290
8292
|
orientation: vertical ? "vertical" : "horizontal",
|
|
8291
8293
|
transform,
|
|
@@ -8361,7 +8363,7 @@ function buildEngineData(layer, template) {
|
|
|
8361
8363
|
fonts.push(ps);
|
|
8362
8364
|
return fonts.length - 1;
|
|
8363
8365
|
};
|
|
8364
|
-
const runs =
|
|
8366
|
+
const runs = _chunkIOFVM3L3cjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE);
|
|
8365
8367
|
const vertical = layer.orientation === "vertical";
|
|
8366
8368
|
const sruns = [];
|
|
8367
8369
|
const slens = [];
|
|
@@ -8370,10 +8372,10 @@ function buildEngineData(layer, template) {
|
|
|
8370
8372
|
slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
|
|
8371
8373
|
});
|
|
8372
8374
|
if (!runs.length) {
|
|
8373
|
-
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(
|
|
8375
|
+
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE)))]])]]));
|
|
8374
8376
|
slens.push(E.int(1));
|
|
8375
8377
|
}
|
|
8376
|
-
const paras =
|
|
8378
|
+
const paras = _chunkIOFVM3L3cjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
|
|
8377
8379
|
const pruns = [];
|
|
8378
8380
|
const plens = [];
|
|
8379
8381
|
paras.forEach((p, i) => {
|
|
@@ -8429,7 +8431,7 @@ function buildEngineData(layer, template) {
|
|
|
8429
8431
|
eSet(e, key, rd);
|
|
8430
8432
|
}
|
|
8431
8433
|
eSet(rd, "FontSet", fontSet);
|
|
8432
|
-
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.style]), () => (
|
|
8434
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.style]), () => ( _chunkIOFVM3L3cjs.DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8433
8435
|
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8434
8436
|
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8435
8437
|
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
@@ -8440,13 +8442,13 @@ function inkBounds2(layer) {
|
|
|
8440
8442
|
if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
|
|
8441
8443
|
const b = _chunk474IQG74cjs.contentBounds.call(void 0, layer.surface);
|
|
8442
8444
|
if (!b) return [0, 0, 0, 0];
|
|
8443
|
-
const inv =
|
|
8445
|
+
const inv = _chunkIOFVM3L3cjs.invertMatrix.call(void 0, textMatrix(layer));
|
|
8444
8446
|
const pts = [
|
|
8445
8447
|
{ x: b.x, y: b.y },
|
|
8446
8448
|
{ x: b.x + b.width, y: b.y },
|
|
8447
8449
|
{ x: b.x + b.width, y: b.y + b.height },
|
|
8448
8450
|
{ x: b.x, y: b.y + b.height }
|
|
8449
|
-
].map((p) =>
|
|
8451
|
+
].map((p) => _chunkIOFVM3L3cjs.applyMatrix.call(void 0, inv, p));
|
|
8450
8452
|
return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
|
|
8451
8453
|
}
|
|
8452
8454
|
function tyShForLayer(layer) {
|
|
@@ -8727,7 +8729,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8727
8729
|
var warpStyleOf = (name) => {
|
|
8728
8730
|
if (!name.startsWith("warp")) return null;
|
|
8729
8731
|
const s = _optionalChain([name, 'access', _263 => _263[4], 'optionalAccess', _264 => _264.toLowerCase, 'call', _265 => _265()]) + name.slice(5);
|
|
8730
|
-
return
|
|
8732
|
+
return _chunkIOFVM3L3cjs.WARP_STYLES.includes(s) ? s : null;
|
|
8731
8733
|
};
|
|
8732
8734
|
function warpFromDescriptor(w, contents) {
|
|
8733
8735
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
@@ -8757,7 +8759,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8757
8759
|
} else {
|
|
8758
8760
|
const style = warpStyleOf(styleName);
|
|
8759
8761
|
if (!style) return void 0;
|
|
8760
|
-
mesh =
|
|
8762
|
+
mesh = _chunkIOFVM3L3cjs.warpPresetMesh.call(void 0,
|
|
8761
8763
|
{
|
|
8762
8764
|
style,
|
|
8763
8765
|
bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
|
|
@@ -8772,7 +8774,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8772
8774
|
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;
|
|
8773
8775
|
if (!same) {
|
|
8774
8776
|
const m = mesh;
|
|
8775
|
-
mesh =
|
|
8777
|
+
mesh = _chunkIOFVM3L3cjs.fitWarpMesh.call(void 0, (s, t) => _chunkIOFVM3L3cjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
|
|
8776
8778
|
}
|
|
8777
8779
|
return { mesh, frame };
|
|
8778
8780
|
}
|
|
@@ -10020,7 +10022,7 @@ function recordPixels(ctx, rec, name) {
|
|
|
10020
10022
|
cmykToRgb16: ctx.cmykToRgb16
|
|
10021
10023
|
};
|
|
10022
10024
|
const deep = set.cmykToRgb && !set.cmykToRgb16 ? null : toRgbaDeep(set);
|
|
10023
|
-
if (deep) return
|
|
10025
|
+
if (deep) return _chunk2VX55NFMcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4, rec.rect.left, rec.rect.top);
|
|
10024
10026
|
return _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width, height, data: toRgba8(set) }, 4, rec.rect.left, rec.rect.top);
|
|
10025
10027
|
}
|
|
10026
10028
|
function recordMask(ctx, rec, name) {
|
|
@@ -10037,7 +10039,7 @@ function recordMask(ctx, rec, name) {
|
|
|
10037
10039
|
if (width && height && !ctx.skipPixels) {
|
|
10038
10040
|
const plane = decodeOr(ctx, rec, id, name);
|
|
10039
10041
|
const depth = ctx.file.header.depth;
|
|
10040
|
-
if (plane && (depth === 16 || depth === 32)) surface =
|
|
10042
|
+
if (plane && (depth === 16 || depth === 32)) surface = _chunk2VX55NFMcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: toMaskDeep(plane, width, height, depth) }, 1, rect.left, rect.top, def);
|
|
10041
10043
|
else if (plane) surface = _chunk474IQG74cjs.surfaceFromPixels.call(void 0, { width, height, data: toMask8(plane, width, height, depth) }, 1, rect.left, rect.top, def);
|
|
10042
10044
|
}
|
|
10043
10045
|
const mask = { surface, defaultValue: def };
|
|
@@ -10111,7 +10113,7 @@ function recordEffects(ctx, rec, name, notes, group) {
|
|
|
10111
10113
|
}
|
|
10112
10114
|
for (const e of parsed.effects.items) {
|
|
10113
10115
|
for (const id of patternIds(e)) {
|
|
10114
|
-
if (ctx.patterns.has(id) ||
|
|
10116
|
+
if (ctx.patterns.has(id) || _chunkDPYAO5U6cjs.builtinPattern.call(void 0, id)) continue;
|
|
10115
10117
|
ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
|
|
10116
10118
|
notes.push(`pattern "${id}" is not in the file`);
|
|
10117
10119
|
}
|
|
@@ -10322,7 +10324,7 @@ function contentsFor(ctx, placed, name, notes) {
|
|
|
10322
10324
|
document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
|
|
10323
10325
|
};
|
|
10324
10326
|
} else if (t.ext === "png") {
|
|
10325
|
-
const png =
|
|
10327
|
+
const png = _chunkW5M3J7PVcjs.decodePng.call(void 0, file.bytes);
|
|
10326
10328
|
out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunk474IQG74cjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
|
|
10327
10329
|
} else {
|
|
10328
10330
|
const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
|
|
@@ -10364,7 +10366,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10364
10366
|
if (placement && (size.width !== contents.width || size.height !== contents.height)) {
|
|
10365
10367
|
const kx = contents.width / size.width;
|
|
10366
10368
|
const ky = contents.height / size.height;
|
|
10367
|
-
if (placement.warp) placement = { ...placement, warp:
|
|
10369
|
+
if (placement.warp) placement = { ...placement, warp: _chunkIOFVM3L3cjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
|
|
10368
10370
|
}
|
|
10369
10371
|
}
|
|
10370
10372
|
if (!contents || !placement) {
|
|
@@ -10448,7 +10450,7 @@ function mergedLayer(ctx) {
|
|
|
10448
10450
|
};
|
|
10449
10451
|
const deep = hasAlpha || set.cmykToRgb && !set.cmykToRgb16 ? null : toRgbaDeep(set);
|
|
10450
10452
|
let surface;
|
|
10451
|
-
if (deep) surface =
|
|
10453
|
+
if (deep) surface = _chunk2VX55NFMcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4);
|
|
10452
10454
|
else {
|
|
10453
10455
|
const data = toRgba8(set);
|
|
10454
10456
|
if (hasAlpha) unmatteWhite(data);
|
|
@@ -10689,34 +10691,34 @@ function blendOf(d, key, fallback, notes) {
|
|
|
10689
10691
|
function colorOf(d, fallback = "#000000") {
|
|
10690
10692
|
if (!d) return fallback;
|
|
10691
10693
|
const g = (k) => descNumber(d, k);
|
|
10692
|
-
if (g("redFloat") !== void 0) return
|
|
10694
|
+
if (g("redFloat") !== void 0) return _chunkDPYAO5U6cjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
|
|
10693
10695
|
switch (d.classId) {
|
|
10694
10696
|
case "HSBC": {
|
|
10695
10697
|
const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
|
|
10696
|
-
return rgb ?
|
|
10698
|
+
return rgb ? _chunkDPYAO5U6cjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10697
10699
|
}
|
|
10698
10700
|
case "CMYC": {
|
|
10699
10701
|
const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
|
|
10700
10702
|
const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
|
|
10701
|
-
return rgb ?
|
|
10703
|
+
return rgb ? _chunkDPYAO5U6cjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10702
10704
|
}
|
|
10703
10705
|
case "LbCl": {
|
|
10704
10706
|
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]);
|
|
10705
|
-
return rgb ?
|
|
10707
|
+
return rgb ? _chunkDPYAO5U6cjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10706
10708
|
}
|
|
10707
10709
|
case "Grsc": {
|
|
10708
10710
|
const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
|
|
10709
|
-
return
|
|
10711
|
+
return _chunkDPYAO5U6cjs.effectColorHex.call(void 0, [v, v, v]);
|
|
10710
10712
|
}
|
|
10711
10713
|
}
|
|
10712
10714
|
const r = g("Rd ");
|
|
10713
10715
|
const gr = g("Grn ");
|
|
10714
10716
|
const b = g("Bl ");
|
|
10715
10717
|
if (r === void 0 || gr === void 0 || b === void 0) return fallback;
|
|
10716
|
-
return
|
|
10718
|
+
return _chunkDPYAO5U6cjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
|
|
10717
10719
|
}
|
|
10718
10720
|
function colorDesc(hex) {
|
|
10719
|
-
const [r, g, b] = _nullishCoalesce(
|
|
10721
|
+
const [r, g, b] = _nullishCoalesce(_chunkDPYAO5U6cjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
|
|
10720
10722
|
return descriptor("RGBC", [
|
|
10721
10723
|
["Rd ", dbl3(r * 255)],
|
|
10722
10724
|
["Grn ", dbl3(g * 255)],
|
|
@@ -10799,9 +10801,9 @@ function gradientOf(d, notes) {
|
|
|
10799
10801
|
raw.forEach((s, i) => {
|
|
10800
10802
|
if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
|
|
10801
10803
|
const a = raw[i - 1];
|
|
10802
|
-
const ca =
|
|
10803
|
-
const cb =
|
|
10804
|
-
stops.push({ position: a.position + (s.position - a.position) * s.mid, color:
|
|
10804
|
+
const ca = _chunkDPYAO5U6cjs.parseEffectColor.call(void 0, a.color);
|
|
10805
|
+
const cb = _chunkDPYAO5U6cjs.parseEffectColor.call(void 0, s.color);
|
|
10806
|
+
stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkDPYAO5U6cjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
|
|
10805
10807
|
notes.add("gradient midpoints are drawn as straight segments");
|
|
10806
10808
|
}
|
|
10807
10809
|
stops.push({ position: s.position, color: s.color });
|
|
@@ -10913,8 +10915,8 @@ var KINDS = [
|
|
|
10913
10915
|
["FrFX", "frameFXMulti", "stroke"]
|
|
10914
10916
|
];
|
|
10915
10917
|
function common(d, kind, notes) {
|
|
10916
|
-
const def =
|
|
10917
|
-
return { id:
|
|
10918
|
+
const def = _chunkDPYAO5U6cjs.defaultLayerEffect.call(void 0, kind, "x");
|
|
10919
|
+
return { id: _chunkDPYAO5U6cjs.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) };
|
|
10918
10920
|
}
|
|
10919
10921
|
function readOne(kind, d, notes) {
|
|
10920
10922
|
const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
|
|
@@ -10957,7 +10959,7 @@ function readOne(kind, d, notes) {
|
|
|
10957
10959
|
case "bevel-emboss": {
|
|
10958
10960
|
const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
|
|
10959
10961
|
const out = {
|
|
10960
|
-
id:
|
|
10962
|
+
id: _chunkDPYAO5U6cjs.newEffectId.call(void 0, ),
|
|
10961
10963
|
enabled: descBool(d, "enab") !== false,
|
|
10962
10964
|
kind,
|
|
10963
10965
|
style: _nullishCoalesce(styles[_nullishCoalesce(enumOf3(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
|
|
@@ -11168,10 +11170,10 @@ function writeLfx2(effects) {
|
|
|
11168
11170
|
["Scl ", unit3("#Prc", 100)],
|
|
11169
11171
|
["masterFXSwitch", boolV3(effects.enabled)]
|
|
11170
11172
|
];
|
|
11171
|
-
const scale =
|
|
11173
|
+
const scale = _chunkDPYAO5U6cjs.effectsScale.call(void 0, effects);
|
|
11172
11174
|
let dropped = 0;
|
|
11173
11175
|
for (const [single, multi, kind] of KINDS) {
|
|
11174
|
-
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(
|
|
11176
|
+
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkDPYAO5U6cjs.scaleLayerEffect.call(void 0, e, scale)));
|
|
11175
11177
|
if (!of.length) continue;
|
|
11176
11178
|
if (of.length === 1) items.push([single, obj3(of[0])]);
|
|
11177
11179
|
else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj3) }]);
|
|
@@ -11203,7 +11205,7 @@ function parseLrfx(data) {
|
|
|
11203
11205
|
const colorAt = (rd) => {
|
|
11204
11206
|
rd.u16();
|
|
11205
11207
|
const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
|
|
11206
|
-
return
|
|
11208
|
+
return _chunkDPYAO5U6cjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
|
|
11207
11209
|
};
|
|
11208
11210
|
const blendAt = (rd) => {
|
|
11209
11211
|
rd.skip(4);
|
|
@@ -11222,7 +11224,7 @@ function parseLrfx(data) {
|
|
|
11222
11224
|
const enabled = b.u8() !== 0;
|
|
11223
11225
|
const useGlobalLight = b.u8() !== 0;
|
|
11224
11226
|
const opacity = b.u8() / 255;
|
|
11225
|
-
const base = { id:
|
|
11227
|
+
const base = { id: _chunkDPYAO5U6cjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
|
|
11226
11228
|
items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
|
|
11227
11229
|
} else if (key === "oglw" || key === "iglw") {
|
|
11228
11230
|
b.u32();
|
|
@@ -11232,7 +11234,7 @@ function parseLrfx(data) {
|
|
|
11232
11234
|
const blend = blendAt(b);
|
|
11233
11235
|
const enabled = b.u8() !== 0;
|
|
11234
11236
|
const opacity = b.u8() / 255;
|
|
11235
|
-
const base = { id:
|
|
11237
|
+
const base = { id: _chunkDPYAO5U6cjs.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 };
|
|
11236
11238
|
items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
|
|
11237
11239
|
} else if (key === "sofi") {
|
|
11238
11240
|
b.u32();
|
|
@@ -11240,7 +11242,7 @@ function parseLrfx(data) {
|
|
|
11240
11242
|
const color = colorAt(b);
|
|
11241
11243
|
const opacity = b.u8() / 255;
|
|
11242
11244
|
const enabled = b.u8() !== 0;
|
|
11243
|
-
items.push({ id:
|
|
11245
|
+
items.push({ id: _chunkDPYAO5U6cjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
|
|
11244
11246
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
11245
11247
|
}
|
|
11246
11248
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
@@ -11292,7 +11294,7 @@ function rleChannel(id, plane, width, height, psb, depth = 8) {
|
|
|
11292
11294
|
function surfacePlanes(surface, bounds, depth) {
|
|
11293
11295
|
const n = bounds.width * bounds.height;
|
|
11294
11296
|
if (depth === 8) return rgbaToPlanes(_chunk474IQG74cjs.readRegion.call(void 0, surface, bounds), n);
|
|
11295
|
-
return deepToPlanes(
|
|
11297
|
+
return deepToPlanes(_chunk2VX55NFMcjs.readDeepRegion.call(void 0, surface, bounds, depth), n);
|
|
11296
11298
|
}
|
|
11297
11299
|
var emptyChannel = (id) => ({ id, compression: 0, data: new Uint8Array(0) });
|
|
11298
11300
|
function maskChannel(mask, ox, oy, psb, depth = 8) {
|
|
@@ -11306,7 +11308,7 @@ function maskChannel(mask, ox, oy, psb, depth = 8) {
|
|
|
11306
11308
|
if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
|
|
11307
11309
|
m.rect = toRect({ ...bounds, x: bounds.x + ox, y: bounds.y + oy });
|
|
11308
11310
|
let bytes;
|
|
11309
|
-
if (depth !== 8 &&
|
|
11311
|
+
if (depth !== 8 && _chunk2VX55NFMcjs.surfaceDepth.call(void 0, mask.surface) !== 8) bytes = deepMaskPlane(_chunk2VX55NFMcjs.readDeepRegion.call(void 0, mask.surface, bounds, depth));
|
|
11310
11312
|
else {
|
|
11311
11313
|
const plane = _chunk474IQG74cjs.readRegion.call(void 0, mask.surface, bounds);
|
|
11312
11314
|
bytes = planeAtDepth(new Uint8Array(plane.buffer, plane.byteOffset, plane.length), depth);
|
|
@@ -11356,7 +11358,7 @@ function smartContentsFile(c) {
|
|
|
11356
11358
|
if (c.file) return { name: c.name, bytes: c.file.bytes };
|
|
11357
11359
|
if (c.kind === "raster") {
|
|
11358
11360
|
const data = _chunk474IQG74cjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
11359
|
-
return { name: `${base}.png`, bytes:
|
|
11361
|
+
return { name: `${base}.png`, bytes: _chunkW5M3J7PVcjs.encodePng.call(void 0, c.width, c.height, data) };
|
|
11360
11362
|
}
|
|
11361
11363
|
const doc = c.document;
|
|
11362
11364
|
const merged2 = _chunk474IQG74cjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
@@ -11406,7 +11408,7 @@ function exportPsd(input) {
|
|
|
11406
11408
|
const surfaceChannels = (surface, bounds) => {
|
|
11407
11409
|
if (mode !== "rgb" && depth === 16) {
|
|
11408
11410
|
const n2 = bounds.width * bounds.height;
|
|
11409
|
-
const s =
|
|
11411
|
+
const s = _chunk2VX55NFMcjs.readDeepRegion.call(void 0, surface, bounds, 16);
|
|
11410
11412
|
const alpha = new Uint16Array(n2);
|
|
11411
11413
|
for (let i = 0; i < n2; i++) alpha[i] = s[i * 4 + 3];
|
|
11412
11414
|
const planes2 = [alpha, ...input.colorPlanes16(s, n2)];
|
|
@@ -11433,7 +11435,7 @@ function exportPsd(input) {
|
|
|
11433
11435
|
const key = layer.type === "group" ? "lfxs" : "lfx2";
|
|
11434
11436
|
if (fx.psd) {
|
|
11435
11437
|
const original = parseLfx2(fx.psd.data);
|
|
11436
|
-
if (original ?
|
|
11438
|
+
if (original ? _chunkDPYAO5U6cjs.effectsFingerprint.call(void 0, original.effects) === _chunkDPYAO5U6cjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
|
|
11437
11439
|
}
|
|
11438
11440
|
if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
|
|
11439
11441
|
const { data, dropped } = writeLfx2(fx);
|
|
@@ -11685,7 +11687,7 @@ function exportPsd(input) {
|
|
|
11685
11687
|
const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
|
|
11686
11688
|
const embed = [];
|
|
11687
11689
|
for (const id of patternIds2) {
|
|
11688
|
-
const p = _nullishCoalesce(byId.get(id), () => (
|
|
11690
|
+
const p = _nullishCoalesce(byId.get(id), () => ( _chunkDPYAO5U6cjs.builtinPattern.call(void 0, id)));
|
|
11689
11691
|
if (p) embed.push(p);
|
|
11690
11692
|
else note(`Pattern "${id}" is not in the document and was not embedded`, id);
|
|
11691
11693
|
}
|
|
@@ -11732,7 +11734,7 @@ var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false
|
|
|
11732
11734
|
var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
11733
11735
|
var DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
|
|
11734
11736
|
var EFFECT_ID = { type: "string", description: "Effect id from list_layer_effects or add_layer_effect." };
|
|
11735
|
-
var BLEND_IDS =
|
|
11737
|
+
var BLEND_IDS = _chunk2VX55NFMcjs.BLEND_MODES.map((m) => m.id).filter((id) => id !== "pigment");
|
|
11736
11738
|
var DEFS = {
|
|
11737
11739
|
color: { type: "string", pattern: "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$", description: "Colour as #rrggbb." },
|
|
11738
11740
|
contour: {
|
|
@@ -11925,8 +11927,8 @@ function settingsSchema(forUpdate) {
|
|
|
11925
11927
|
}
|
|
11926
11928
|
function patternList(documentPatterns) {
|
|
11927
11929
|
const doc = documentPatterns.map((p) => ({ id: p.id, name: p.name, width: p.width, height: p.height, builtin: false }));
|
|
11928
|
-
const builtins =
|
|
11929
|
-
const p =
|
|
11930
|
+
const builtins = _chunkDPYAO5U6cjs.builtinPatternIds.call(void 0, ).map((id) => {
|
|
11931
|
+
const p = _chunkDPYAO5U6cjs.builtinPattern.call(void 0, id);
|
|
11930
11932
|
return { id, name: p.name, width: p.width, height: p.height, builtin: true };
|
|
11931
11933
|
});
|
|
11932
11934
|
return [...doc, ...builtins];
|
|
@@ -11935,9 +11937,9 @@ function describeLayerEffects(effects) {
|
|
|
11935
11937
|
return {
|
|
11936
11938
|
enabled: effects.enabled,
|
|
11937
11939
|
scale: _nullishCoalesce(effects.scale, () => ( 1)),
|
|
11938
|
-
margin:
|
|
11940
|
+
margin: _chunkDPYAO5U6cjs.effectsMargin.call(void 0, effects),
|
|
11939
11941
|
fromPsd: Boolean(effects.psd),
|
|
11940
|
-
effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label:
|
|
11942
|
+
effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: _chunkDPYAO5U6cjs.layerEffectLabel.call(void 0, e.kind) }))
|
|
11941
11943
|
};
|
|
11942
11944
|
}
|
|
11943
11945
|
function createImageEffectTools(controller) {
|
|
@@ -11965,14 +11967,14 @@ function createLayerEffectTools(host, options) {
|
|
|
11965
11967
|
return id;
|
|
11966
11968
|
};
|
|
11967
11969
|
const result = (layerId, extra = {}) => ({ layerId, ...extra, ...describeLayerEffects(host.getLayerEffects(layerId)) });
|
|
11968
|
-
const globalLight = () => _nullishCoalesce(_optionalChain([host, 'access', _325 => _325.getGlobalLight, 'optionalCall', _326 => _326()]), () => ( { ...
|
|
11970
|
+
const globalLight = () => _nullishCoalesce(_optionalChain([host, 'access', _325 => _325.getGlobalLight, 'optionalCall', _326 => _326()]), () => ( { ..._chunkDPYAO5U6cjs.DEFAULT_GLOBAL_LIGHT }));
|
|
11969
11971
|
const list2 = {
|
|
11970
11972
|
name: "list_layer_effects",
|
|
11971
11973
|
title: "List layer effects",
|
|
11972
11974
|
description: "Returns a layer's effects: the master switch (enabled), Scale Effects (scale, 1 = 100 %), margin (px the effects reach beyond the shape), whether they came from a PSD, and every effect with its id, kind, label and all settings. Also returns the document global light and the pattern ids pattern effects can use.",
|
|
11973
11975
|
inputSchema: { type: "object", properties: { layerId: LAYER_ID }, required: ["layerId"], additionalProperties: false },
|
|
11974
11976
|
annotations: { title: "List layer effects", ...READ },
|
|
11975
|
-
handler: ({ layerId }) => result(layerArg(layerId), { globalLight: globalLight(), patterns: patternList(_nullishCoalesce(_optionalChain([host, 'access', _327 => _327.getDocumentPatterns, 'optionalCall', _328 => _328()]), () => ( []))), kinds: [...
|
|
11977
|
+
handler: ({ layerId }) => result(layerArg(layerId), { globalLight: globalLight(), patterns: patternList(_nullishCoalesce(_optionalChain([host, 'access', _327 => _327.getDocumentPatterns, 'optionalCall', _328 => _328()]), () => ( []))), kinds: [..._chunkDPYAO5U6cjs.LAYER_EFFECT_KINDS] })
|
|
11976
11978
|
};
|
|
11977
11979
|
const add = {
|
|
11978
11980
|
name: "add_layer_effect",
|
|
@@ -11983,7 +11985,7 @@ function createLayerEffectTools(host, options) {
|
|
|
11983
11985
|
$defs: DEFS,
|
|
11984
11986
|
properties: {
|
|
11985
11987
|
layerId: LAYER_ID,
|
|
11986
|
-
kind: { type: "string", enum: [...
|
|
11988
|
+
kind: { type: "string", enum: [..._chunkDPYAO5U6cjs.LAYER_EFFECT_KINDS], description: "Effect kind." },
|
|
11987
11989
|
settings: settingsSchema(false),
|
|
11988
11990
|
index: { type: "integer", minimum: 0, description: "Position in the layer's effect list (default the end)." }
|
|
11989
11991
|
},
|
|
@@ -11993,7 +11995,7 @@ function createLayerEffectTools(host, options) {
|
|
|
11993
11995
|
annotations: { title: "Add a layer effect", ...WRITE },
|
|
11994
11996
|
handler: ({ layerId, kind, settings, index }) => {
|
|
11995
11997
|
const id = layerArg(layerId);
|
|
11996
|
-
if (!
|
|
11998
|
+
if (!_chunkDPYAO5U6cjs.isLayerEffectKind.call(void 0, kind)) throw error(`kind must be one of ${_chunkDPYAO5U6cjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
11997
11999
|
const { effect } = host.addLayerEffect(id, kind, _nullishCoalesce(settings, () => ( {})), index);
|
|
11998
12000
|
return result(id, { effectId: effect.id });
|
|
11999
12001
|
}
|