@pixerate/editor 0.185.0 → 0.186.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GYYSPMVU.js → chunk-FW7N64XK.js} +295 -188
- package/dist/{chunk-C6TRAAG4.cjs → chunk-X2KQQZBT.cjs} +355 -248
- package/dist/image-editor/controller.d.cts +56 -0
- package/dist/image-editor/controller.d.ts +56 -0
- package/dist/image-editor/index.cjs +1461 -1030
- package/dist/image-editor/index.js +447 -16
- package/dist/image-editor/layers/model.d.cts +5 -1
- package/dist/image-editor/layers/model.d.ts +5 -1
- package/dist/image-editor/layers/paint-ui.d.cts +2 -1
- package/dist/image-editor/layers/paint-ui.d.ts +2 -1
- package/dist/image-editor/layers/serialize.d.cts +3 -0
- package/dist/image-editor/layers/serialize.d.ts +3 -0
- package/dist/image-editor/psd/channels.d.cts +24 -0
- package/dist/image-editor/psd/channels.d.ts +24 -0
- package/dist/image-editor/psd/export.d.cts +3 -0
- package/dist/image-editor/psd/export.d.ts +3 -0
- package/dist/image-editor/psd/import.d.cts +10 -0
- package/dist/image-editor/psd/import.d.ts +10 -0
- package/dist/image-editor/renderer.d.cts +6 -0
- package/dist/image-editor/renderer.d.ts +6 -0
- package/dist/image-editor/selection/channels.d.cts +52 -0
- package/dist/image-editor/selection/channels.d.ts +52 -0
- package/dist/image-editor/selection/gesture.d.cts +7 -0
- package/dist/image-editor/selection/gesture.d.ts +7 -0
- package/dist/image-editor/selection/index.d.cts +1 -0
- package/dist/image-editor/selection/index.d.ts +1 -0
- package/dist/image-editor/selection/overlay.d.cts +2 -0
- package/dist/image-editor/selection/overlay.d.ts +2 -0
- package/dist/image-editor/tools.d.cts +3 -1
- package/dist/image-editor/tools.d.ts +3 -1
- package/dist/image-editor/types.d.cts +10 -0
- package/dist/image-editor/types.d.ts +10 -0
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.js +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +7 -0
- package/skills/pixerate-image-selection-masking/SKILL.md +13 -1
|
@@ -6346,6 +6346,192 @@ function encodeLegacyName(s) {
|
|
|
6346
6346
|
return Uint8Array.from(out);
|
|
6347
6347
|
}
|
|
6348
6348
|
|
|
6349
|
+
// src/image-editor/psd/compression.ts
|
|
6350
|
+
var MAX_DECODED_BYTES = 2 ** 31;
|
|
6351
|
+
function rowBytes(width, depth) {
|
|
6352
|
+
return depth === 1 ? Math.ceil(width / 8) : width * Math.max(1, depth >> 3);
|
|
6353
|
+
}
|
|
6354
|
+
function decodedLength(l) {
|
|
6355
|
+
const total = l.planes * l.height * rowBytes(l.width, l.depth);
|
|
6356
|
+
if (total > MAX_DECODED_BYTES) throw new PsdError(`Decoded channel data of ${total} bytes is larger than the ${MAX_DECODED_BYTES}-byte limit.`);
|
|
6357
|
+
return total;
|
|
6358
|
+
}
|
|
6359
|
+
function packbitsBound(n) {
|
|
6360
|
+
return n + Math.ceil(n / 128);
|
|
6361
|
+
}
|
|
6362
|
+
function packbitsEncode(src, out, at) {
|
|
6363
|
+
const n = src.length;
|
|
6364
|
+
let i = 0;
|
|
6365
|
+
while (i < n) {
|
|
6366
|
+
let run = 1;
|
|
6367
|
+
while (i + run < n && run < 128 && src[i + run] === src[i]) run++;
|
|
6368
|
+
if (run >= 2) {
|
|
6369
|
+
out[at++] = 257 - run & 255;
|
|
6370
|
+
out[at++] = src[i];
|
|
6371
|
+
i += run;
|
|
6372
|
+
continue;
|
|
6373
|
+
}
|
|
6374
|
+
const start = i;
|
|
6375
|
+
let len = 0;
|
|
6376
|
+
while (i < n && len < 128) {
|
|
6377
|
+
if (i + 2 < n && src[i] === src[i + 1] && src[i] === src[i + 2]) break;
|
|
6378
|
+
i++;
|
|
6379
|
+
len++;
|
|
6380
|
+
}
|
|
6381
|
+
out[at++] = len - 1;
|
|
6382
|
+
out.set(src.subarray(start, start + len), at);
|
|
6383
|
+
at += len;
|
|
6384
|
+
}
|
|
6385
|
+
return at;
|
|
6386
|
+
}
|
|
6387
|
+
function packbitsDecodeInto(src, expected, out, at) {
|
|
6388
|
+
const target = at + expected;
|
|
6389
|
+
let i = 0;
|
|
6390
|
+
while (at < target) {
|
|
6391
|
+
if (i >= src.length) throw new PsdError("PackBits row ended early.");
|
|
6392
|
+
const h = src[i++];
|
|
6393
|
+
if (h < 128) {
|
|
6394
|
+
const len = h + 1;
|
|
6395
|
+
if (i + len > src.length) throw new PsdError("PackBits literal is truncated.");
|
|
6396
|
+
if (at + len > target) throw new PsdError("PackBits literal overflows its row.");
|
|
6397
|
+
out.set(src.subarray(i, i + len), at);
|
|
6398
|
+
at += len;
|
|
6399
|
+
i += len;
|
|
6400
|
+
} else if (h !== 128) {
|
|
6401
|
+
const len = 257 - h;
|
|
6402
|
+
if (i >= src.length) throw new PsdError("PackBits run is truncated.");
|
|
6403
|
+
const b = src[i++];
|
|
6404
|
+
if (at + len > target) throw new PsdError("PackBits run overflows its row.");
|
|
6405
|
+
out.fill(b, at, at + len);
|
|
6406
|
+
at += len;
|
|
6407
|
+
}
|
|
6408
|
+
}
|
|
6409
|
+
return at;
|
|
6410
|
+
}
|
|
6411
|
+
function inflateChecked(data, expected) {
|
|
6412
|
+
let out;
|
|
6413
|
+
try {
|
|
6414
|
+
out = _chunkXFM3OCHUcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
6415
|
+
} catch (e) {
|
|
6416
|
+
throw new PsdError(`ZIP channel data: ${e instanceof _chunkXFM3OCHUcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
6417
|
+
}
|
|
6418
|
+
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
6419
|
+
return out.length === expected ? out : out.subarray(0, expected);
|
|
6420
|
+
}
|
|
6421
|
+
function unpredict(buf, l) {
|
|
6422
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6423
|
+
if (rb === 0) return;
|
|
6424
|
+
const w = l.width;
|
|
6425
|
+
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
6426
|
+
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
6427
|
+
if (l.depth === 1 || l.depth === 8) {
|
|
6428
|
+
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
6429
|
+
} else if (l.depth === 16) {
|
|
6430
|
+
for (let i = 1; i < w; i++) {
|
|
6431
|
+
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
6432
|
+
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
6433
|
+
const v = a + b & 65535;
|
|
6434
|
+
buf[o + 2 * i] = v >> 8;
|
|
6435
|
+
buf[o + 2 * i + 1] = v & 255;
|
|
6436
|
+
}
|
|
6437
|
+
} else if (l.depth === 32) {
|
|
6438
|
+
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
6439
|
+
scratch.set(buf.subarray(o, o + rb));
|
|
6440
|
+
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + 4 * i + k] = scratch[k * w + i];
|
|
6441
|
+
} else {
|
|
6442
|
+
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
}
|
|
6446
|
+
function decodeRle(r, l, total) {
|
|
6447
|
+
const rows = l.planes * l.height;
|
|
6448
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6449
|
+
r.checkCount(rows, l.psb ? 4 : 2, "RLE row counts");
|
|
6450
|
+
const counts = new Array(rows);
|
|
6451
|
+
for (let i = 0; i < rows; i++) counts[i] = l.psb ? r.u32() : r.u16();
|
|
6452
|
+
if (total > r.remaining * 130) throw new PsdError("RLE data is too short for its declared size.");
|
|
6453
|
+
const out = new Uint8Array(total);
|
|
6454
|
+
let at = 0;
|
|
6455
|
+
for (const c of counts) at = packbitsDecodeInto(r.bytes(c), rb, out, at);
|
|
6456
|
+
return out;
|
|
6457
|
+
}
|
|
6458
|
+
function decodePlanes(compression, data, l) {
|
|
6459
|
+
const total = decodedLength(l);
|
|
6460
|
+
switch (compression) {
|
|
6461
|
+
case 0:
|
|
6462
|
+
if (data.length < total) throw new PsdError(`Raw channel data has ${data.length} of ${total} bytes.`);
|
|
6463
|
+
return data.slice(0, total);
|
|
6464
|
+
case 1:
|
|
6465
|
+
return decodeRle(new PsdReader(data), l, total);
|
|
6466
|
+
case 2:
|
|
6467
|
+
return inflateChecked(data, total).slice();
|
|
6468
|
+
case 3: {
|
|
6469
|
+
const v = inflateChecked(data, total).slice();
|
|
6470
|
+
unpredict(v, l);
|
|
6471
|
+
return v;
|
|
6472
|
+
}
|
|
6473
|
+
default:
|
|
6474
|
+
throw new PsdError(`Unsupported compression method ${compression}.`);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
function encodeRle(decoded2, l) {
|
|
6478
|
+
const rows = l.planes * l.height;
|
|
6479
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6480
|
+
const cs = l.psb ? 4 : 2;
|
|
6481
|
+
const packed = new Uint8Array(rows * packbitsBound(rb));
|
|
6482
|
+
let at = 0;
|
|
6483
|
+
const counts = new Uint8Array(rows * cs);
|
|
6484
|
+
for (let row = 0; row < rows; row++) {
|
|
6485
|
+
const start = at;
|
|
6486
|
+
at = packbitsEncode(decoded2.subarray(row * rb, (row + 1) * rb), packed, at);
|
|
6487
|
+
const n = at - start;
|
|
6488
|
+
if (cs === 2) {
|
|
6489
|
+
if (n > 65535) throw new PsdError("An RLE row is longer than 65535 bytes; write a PSB instead.");
|
|
6490
|
+
counts[row * 2] = n >> 8;
|
|
6491
|
+
counts[row * 2 + 1] = n & 255;
|
|
6492
|
+
} else {
|
|
6493
|
+
counts[row * 4] = n >>> 24;
|
|
6494
|
+
counts[row * 4 + 1] = n >>> 16 & 255;
|
|
6495
|
+
counts[row * 4 + 2] = n >>> 8 & 255;
|
|
6496
|
+
counts[row * 4 + 3] = n & 255;
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
const out = new Uint8Array(counts.length + at);
|
|
6500
|
+
out.set(counts);
|
|
6501
|
+
out.set(packed.subarray(0, at), counts.length);
|
|
6502
|
+
return out;
|
|
6503
|
+
}
|
|
6504
|
+
function predict(buf, l) {
|
|
6505
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6506
|
+
if (rb === 0) return;
|
|
6507
|
+
const w = l.width;
|
|
6508
|
+
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
6509
|
+
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
6510
|
+
if (l.depth === 1 || l.depth === 8) {
|
|
6511
|
+
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
6512
|
+
} else if (l.depth === 16) {
|
|
6513
|
+
for (let i = w - 1; i > 0; i--) {
|
|
6514
|
+
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
6515
|
+
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
6516
|
+
const v = a - b & 65535;
|
|
6517
|
+
buf[o + 2 * i] = v >> 8;
|
|
6518
|
+
buf[o + 2 * i + 1] = v & 255;
|
|
6519
|
+
}
|
|
6520
|
+
} else if (l.depth === 32) {
|
|
6521
|
+
scratch.set(buf.subarray(o, o + rb));
|
|
6522
|
+
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + k * w + i] = scratch[4 * i + k];
|
|
6523
|
+
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
6524
|
+
} else {
|
|
6525
|
+
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
6526
|
+
}
|
|
6527
|
+
}
|
|
6528
|
+
}
|
|
6529
|
+
function encodeZipPredicted(decoded2, l) {
|
|
6530
|
+
const buf = decoded2.slice();
|
|
6531
|
+
predict(buf, l);
|
|
6532
|
+
return _chunkXFM3OCHUcjs.deflate.call(void 0, buf);
|
|
6533
|
+
}
|
|
6534
|
+
|
|
6349
6535
|
// src/image-editor/psd/descriptor.ts
|
|
6350
6536
|
var MAX_DEPTH = 64;
|
|
6351
6537
|
var STRING_IDS = /* @__PURE__ */ new Set(["warp", "list", "time"]);
|
|
@@ -6945,6 +7131,97 @@ function writeAdjustmentBlock(kind, params) {
|
|
|
6945
7131
|
throw new Error(`Unknown adjustment kind "${kind}".`);
|
|
6946
7132
|
}
|
|
6947
7133
|
|
|
7134
|
+
// src/image-editor/psd/channels.ts
|
|
7135
|
+
var hexToRgb2 = (hex) => {
|
|
7136
|
+
const v = parseInt(_nullishCoalesce(_optionalChain([/^#?([0-9a-f]{6})$/i, 'access', _181 => _181.exec, 'call', _182 => _182(hex), 'optionalAccess', _183 => _183[1]]), () => ( "ff0000")), 16);
|
|
7137
|
+
return [v >> 16 & 255, v >> 8 & 255, v & 255];
|
|
7138
|
+
};
|
|
7139
|
+
var rgbToHex = (r, g, b) => `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
|
|
7140
|
+
function alphaChannelResources(channels) {
|
|
7141
|
+
if (!channels.length) return [];
|
|
7142
|
+
const names = new PsdWriter();
|
|
7143
|
+
for (const c of channels) names.pascal(encodeLegacyName(c.name), 1);
|
|
7144
|
+
const unicode = new PsdWriter();
|
|
7145
|
+
for (const c of channels) unicode.unicode(c.name);
|
|
7146
|
+
const display = new PsdWriter();
|
|
7147
|
+
display.u32(1);
|
|
7148
|
+
for (const c of channels) {
|
|
7149
|
+
const [r, g, b] = hexToRgb2(c.color);
|
|
7150
|
+
display.u16(0);
|
|
7151
|
+
for (const v of [r, g, b, 0]) display.u16(v * 257);
|
|
7152
|
+
display.u16(Math.round(Math.min(1, Math.max(0, c.opacity)) * 100));
|
|
7153
|
+
display.u8(c.indicates === "selected" ? 0 : 1);
|
|
7154
|
+
display.u8(0);
|
|
7155
|
+
}
|
|
7156
|
+
return [
|
|
7157
|
+
{ id: 1006, name: "", data: names.result() },
|
|
7158
|
+
{ id: 1045, name: "", data: unicode.result() },
|
|
7159
|
+
{ id: 1077, name: "", data: display.result() }
|
|
7160
|
+
];
|
|
7161
|
+
}
|
|
7162
|
+
function planeTo8(plane, n, depth) {
|
|
7163
|
+
if (depth === 8) return plane.slice(0, n);
|
|
7164
|
+
const out = new Uint8Array(n);
|
|
7165
|
+
const view = new DataView(plane.buffer, plane.byteOffset, plane.byteLength);
|
|
7166
|
+
for (let i = 0; i < n; i++) {
|
|
7167
|
+
if (depth === 16) out[i] = plane[2 * i];
|
|
7168
|
+
else out[i] = Math.round(Math.min(1, Math.max(0, view.getFloat32(4 * i, false))) * 255);
|
|
7169
|
+
}
|
|
7170
|
+
return out;
|
|
7171
|
+
}
|
|
7172
|
+
function readAlphaChannels(planes, header, first, resource2, warn) {
|
|
7173
|
+
const count = header.channels - first;
|
|
7174
|
+
if (count <= 0 || header.depth === 1) return [];
|
|
7175
|
+
const size = rowBytes(header.width, header.depth) * header.height;
|
|
7176
|
+
const n = header.width * header.height;
|
|
7177
|
+
const names = [];
|
|
7178
|
+
const unicode = resource2(1045);
|
|
7179
|
+
if (unicode) {
|
|
7180
|
+
const r = new PsdReader(unicode);
|
|
7181
|
+
while (r.remaining >= 4 && names.length < count) names.push(r.unicode().replace(/\0+$/, ""));
|
|
7182
|
+
} else {
|
|
7183
|
+
const legacy = resource2(1006);
|
|
7184
|
+
if (legacy) {
|
|
7185
|
+
const r = new PsdReader(legacy);
|
|
7186
|
+
while (r.remaining >= 1 && names.length < count) names.push(new TextDecoder("latin1").decode(r.pascal(1)));
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
const display = [];
|
|
7190
|
+
const info = resource2(1077);
|
|
7191
|
+
if (info && info.length >= 4) {
|
|
7192
|
+
const r = new PsdReader(info);
|
|
7193
|
+
r.u32();
|
|
7194
|
+
while (r.remaining >= 14 && display.length < count) {
|
|
7195
|
+
r.u16();
|
|
7196
|
+
const [cr, cg, cb] = [r.u16(), r.u16(), r.u16()];
|
|
7197
|
+
r.u16();
|
|
7198
|
+
const opacity = r.u16();
|
|
7199
|
+
const kind = r.u8();
|
|
7200
|
+
r.u8();
|
|
7201
|
+
display.push({ color: rgbToHex(cr >> 8, cg >> 8, cb >> 8), opacity: Math.min(100, opacity) / 100, kind });
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
const out = [];
|
|
7205
|
+
for (let i = 0; i < count; i++) {
|
|
7206
|
+
const start = (first + i) * size;
|
|
7207
|
+
if (start + size > planes.length) break;
|
|
7208
|
+
const d = display[i];
|
|
7209
|
+
const name = names[i] || `Alpha ${i + 1}`;
|
|
7210
|
+
if (_optionalChain([d, 'optionalAccess', _184 => _184.kind]) === 2) {
|
|
7211
|
+
warn(`Spot colour channel "${name}" is not supported and was left out.`);
|
|
7212
|
+
continue;
|
|
7213
|
+
}
|
|
7214
|
+
out.push({
|
|
7215
|
+
name,
|
|
7216
|
+
data: planeTo8(planes.subarray(start, start + size), n, header.depth),
|
|
7217
|
+
color: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _185 => _185.color]), () => ( "#ff0000")),
|
|
7218
|
+
opacity: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _186 => _186.opacity]), () => ( 0.5)),
|
|
7219
|
+
indicates: _optionalChain([d, 'optionalAccess', _187 => _187.kind]) === 0 ? "selected" : "masked"
|
|
7220
|
+
});
|
|
7221
|
+
}
|
|
7222
|
+
return out;
|
|
7223
|
+
}
|
|
7224
|
+
|
|
6948
7225
|
// src/image-editor/psd/paths.ts
|
|
6949
7226
|
var RECORD = 26;
|
|
6950
7227
|
var fixed = (v) => v / 16777216;
|
|
@@ -7084,7 +7361,7 @@ var enumV = (typeId, value) => ({ type: "enum", typeId, value });
|
|
|
7084
7361
|
var obj = (d) => ({ type: "Objc", value: d });
|
|
7085
7362
|
var enumOf = (d, key) => {
|
|
7086
7363
|
const v = descGet(d, key);
|
|
7087
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7364
|
+
return _optionalChain([v, 'optionalAccess', _188 => _188.type]) === "enum" ? v.value : void 0;
|
|
7088
7365
|
};
|
|
7089
7366
|
function read(data) {
|
|
7090
7367
|
try {
|
|
@@ -7166,7 +7443,7 @@ function strokeFromVstk(data, dpi, notes) {
|
|
|
7166
7443
|
const miter = descNumber(d, "strokeStyleMiterLimit");
|
|
7167
7444
|
if (miter !== void 0 && miter !== 100) stroke.miterLimit = Math.max(1, Math.min(500, miter));
|
|
7168
7445
|
const dashes = descGet(d, "strokeStyleLineDashSet");
|
|
7169
|
-
if (_optionalChain([dashes, 'optionalAccess',
|
|
7446
|
+
if (_optionalChain([dashes, 'optionalAccess', _189 => _189.type]) === "VlLs") {
|
|
7170
7447
|
const list2 = dashes.items.map((v) => v.type === "UntF" || v.type === "doub" || v.type === "long" ? v.value : NaN).filter((v) => Number.isFinite(v) && v >= 0);
|
|
7171
7448
|
if (list2.length && list2.some((v) => v > 0)) stroke.dashes = list2;
|
|
7172
7449
|
}
|
|
@@ -7318,7 +7595,7 @@ function vogkBytes(components, dpi) {
|
|
|
7318
7595
|
["keyOriginLineArrowEnd", boolV(Boolean(live.endArrow))],
|
|
7319
7596
|
["keyOriginLineArrWdth", dbl(head ? head.width / w * 100 : 0)],
|
|
7320
7597
|
["keyOriginLineArrLngth", dbl(head ? head.length / w * 100 : 0)],
|
|
7321
|
-
["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess',
|
|
7598
|
+
["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _190 => _190.concavity]) ? head.concavity * 100 : 0)]
|
|
7322
7599
|
];
|
|
7323
7600
|
}
|
|
7324
7601
|
const m = live.transform;
|
|
@@ -7351,7 +7628,7 @@ function shapeSignature(layer) {
|
|
|
7351
7628
|
return JSON.stringify([layer.components, layer.fill, layer.stroke, _nullishCoalesce(layer.fillRule, () => ( "nonzero")), Boolean(layer.inverted)]);
|
|
7352
7629
|
}
|
|
7353
7630
|
function shapeFromBlocks(blocks, width, height, dpi, notes) {
|
|
7354
|
-
const block = (k) => _optionalChain([blocks, 'access',
|
|
7631
|
+
const block = (k) => _optionalChain([blocks, 'access', _191 => _191.find, 'call', _192 => _192((b) => b.key === k), 'optionalAccess', _193 => _193.data]);
|
|
7355
7632
|
const vector = _nullishCoalesce(block("vsms"), () => ( block("vmsk")));
|
|
7356
7633
|
const path = vector ? componentsFromVectorBlock(vector, width, height) : null;
|
|
7357
7634
|
if (!path) return null;
|
|
@@ -7406,18 +7683,18 @@ function sameExtent(sub, c) {
|
|
|
7406
7683
|
return a.every((v, i) => Math.abs(v - b[i]) < 1);
|
|
7407
7684
|
}
|
|
7408
7685
|
function shapeBlocks(layer, width, height, dpi, notes) {
|
|
7409
|
-
const kept = _optionalChain([layer, 'access',
|
|
7410
|
-
if (_optionalChain([kept, 'optionalAccess',
|
|
7686
|
+
const kept = _optionalChain([layer, 'access', _194 => _194.psd, 'optionalAccess', _195 => _195.blocks]);
|
|
7687
|
+
if (_optionalChain([kept, 'optionalAccess', _196 => _196.length]) && _optionalChain([layer, 'access', _197 => _197.psd, 'optionalAccess', _198 => _198.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
|
|
7411
7688
|
const out = [];
|
|
7412
7689
|
out.push({ key: "vsms", data: vectorBlockForComponents(layer.components, Boolean(layer.inverted), width, height) });
|
|
7413
7690
|
if (layer.fillRule === "evenodd" && layer.components.some((c) => c.subpaths.length > 1)) notes.add("Even-odd fill rules were written as nonzero (Photoshop fills shapes nonzero)");
|
|
7414
7691
|
const fill = _nullishCoalesce(layer.fill, () => ( { type: "color", color: "#000000" }));
|
|
7415
|
-
if (_optionalChain([layer, 'access',
|
|
7692
|
+
if (_optionalChain([layer, 'access', _199 => _199.fill, 'optionalAccess', _200 => _200.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
|
|
7416
7693
|
out.push({ key: "vscg", data: vscgBytes(fill) });
|
|
7417
7694
|
if (layer.stroke || !layer.fill) out.push({ key: "vstk", data: vstkBytes(layer.stroke, Boolean(layer.fill), dpi) });
|
|
7418
7695
|
const vogk = vogkBytes(layer.components, dpi);
|
|
7419
7696
|
if (vogk) out.push({ key: "vogk", data: vogk });
|
|
7420
|
-
if (layer.components.some((c) => _optionalChain([c, 'access',
|
|
7697
|
+
if (layer.components.some((c) => _optionalChain([c, 'access', _201 => _201.live, 'optionalAccess', _202 => _202.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
|
|
7421
7698
|
notes.add("Lines with different start and end arrowheads were written with one arrowhead size (Photoshop has one)");
|
|
7422
7699
|
}
|
|
7423
7700
|
return out;
|
|
@@ -7626,7 +7903,7 @@ var E = {
|
|
|
7626
7903
|
bool: (value) => ({ t: "bool", value })
|
|
7627
7904
|
};
|
|
7628
7905
|
function eGet(v, key) {
|
|
7629
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7906
|
+
return _optionalChain([v, 'optionalAccess', _203 => _203.t]) === "dict" ? _optionalChain([v, 'access', _204 => _204.items, 'access', _205 => _205.find, 'call', _206 => _206(([k]) => k === key), 'optionalAccess', _207 => _207[1]]) : void 0;
|
|
7630
7907
|
}
|
|
7631
7908
|
function ePath(v, keys) {
|
|
7632
7909
|
return keys.reduce((at, k) => eGet(at, k), v);
|
|
@@ -7644,7 +7921,7 @@ function eStr(v) {
|
|
|
7644
7921
|
return v && (v.t === "string" || v.t === "name") ? v.value : void 0;
|
|
7645
7922
|
}
|
|
7646
7923
|
function eArray(v) {
|
|
7647
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7924
|
+
return _optionalChain([v, 'optionalAccess', _208 => _208.t]) === "array" ? v.items : [];
|
|
7648
7925
|
}
|
|
7649
7926
|
function eSet(d, key, value) {
|
|
7650
7927
|
if (d.t !== "dict") return;
|
|
@@ -7746,7 +8023,7 @@ function fontFromPostScript(ps) {
|
|
|
7746
8023
|
}
|
|
7747
8024
|
family += suffix;
|
|
7748
8025
|
const s = style.toLowerCase();
|
|
7749
|
-
const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access',
|
|
8026
|
+
const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _209 => _209.find, 'call', _210 => _210(([re]) => re.test(s)), 'optionalAccess', _211 => _211[1]]), () => ( 400));
|
|
7750
8027
|
return { family: family || ps, weight, italic: /italic|oblique|it$/.test(s) };
|
|
7751
8028
|
}
|
|
7752
8029
|
var STYLE_NAMES = [
|
|
@@ -7771,7 +8048,7 @@ var hex2 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).pad
|
|
|
7771
8048
|
function merged(levels) {
|
|
7772
8049
|
const items = [];
|
|
7773
8050
|
for (const l of levels) {
|
|
7774
|
-
if (_optionalChain([l, 'optionalAccess',
|
|
8051
|
+
if (_optionalChain([l, 'optionalAccess', _212 => _212.t]) !== "dict") continue;
|
|
7775
8052
|
for (const [k, v] of l.items) if (!items.some(([o]) => o === k)) items.push([k, v]);
|
|
7776
8053
|
}
|
|
7777
8054
|
return E.dict(items);
|
|
@@ -7842,10 +8119,10 @@ function typeFromTySh(data, notes) {
|
|
|
7842
8119
|
const t = parseTySh(data);
|
|
7843
8120
|
if (!t) return null;
|
|
7844
8121
|
const txtV = descGet(t.text, "Txt ");
|
|
7845
|
-
const txt = _optionalChain([txtV, 'optionalAccess',
|
|
8122
|
+
const txt = _optionalChain([txtV, 'optionalAccess', _213 => _213.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
|
|
7846
8123
|
const ed = descGet(t.text, "EngineData");
|
|
7847
8124
|
let engine = null;
|
|
7848
|
-
if (_optionalChain([ed, 'optionalAccess',
|
|
8125
|
+
if (_optionalChain([ed, 'optionalAccess', _214 => _214.type]) === "tdta") {
|
|
7849
8126
|
try {
|
|
7850
8127
|
engine = parseEngineData(ed.data);
|
|
7851
8128
|
} catch (e18) {
|
|
@@ -7853,12 +8130,12 @@ function typeFromTySh(data, notes) {
|
|
|
7853
8130
|
}
|
|
7854
8131
|
}
|
|
7855
8132
|
const anti = descGet(t.text, "AntA");
|
|
7856
|
-
const antiAlias = !(_optionalChain([anti, 'optionalAccess',
|
|
8133
|
+
const antiAlias = !(_optionalChain([anti, 'optionalAccess', _215 => _215.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
|
|
7857
8134
|
const ornt = descGet(t.text, "Ornt");
|
|
7858
|
-
if (_optionalChain([ornt, 'optionalAccess',
|
|
8135
|
+
if (_optionalChain([ornt, 'optionalAccess', _216 => _216.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
|
|
7859
8136
|
if (t.warp) {
|
|
7860
8137
|
const style = descGet(t.warp, "warpStyle");
|
|
7861
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
8138
|
+
if (_optionalChain([style, 'optionalAccess', _217 => _217.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
|
|
7862
8139
|
}
|
|
7863
8140
|
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
7864
8141
|
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
@@ -7907,7 +8184,7 @@ function typeFromTySh(data, notes) {
|
|
|
7907
8184
|
let at = 0;
|
|
7908
8185
|
runs = ssheets.map((sheet, i) => {
|
|
7909
8186
|
const own = named(styleSet, sheet);
|
|
7910
|
-
const paraDefault = _optionalChain([paraBases, 'access',
|
|
8187
|
+
const paraDefault = _optionalChain([paraBases, 'access', _218 => _218[paraAt(at)], 'optionalAccess', _219 => _219.charDefault]);
|
|
7911
8188
|
at += _nullishCoalesce(slens[i], () => ( 0));
|
|
7912
8189
|
const d = merged([eGet(sheet, "StyleSheetData"), eGet(own, "StyleSheetData"), eGet(paraDefault, "StyleSheetData"), eGet(normalStyle, "StyleSheetData")]);
|
|
7913
8190
|
return { length: _nullishCoalesce(slens[i], () => ( 0)), style: charStyle(d, fonts, notes) };
|
|
@@ -7986,8 +8263,8 @@ var fontEntry = (name) => E.dict([
|
|
|
7986
8263
|
["Synthetic", E.int(0)]
|
|
7987
8264
|
]);
|
|
7988
8265
|
function buildEngineData(layer, template) {
|
|
7989
|
-
const e = _optionalChain([template, 'optionalAccess',
|
|
7990
|
-
if (_optionalChain([eGet, 'call',
|
|
8266
|
+
const e = _optionalChain([template, 'optionalAccess', _220 => _220.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
|
|
8267
|
+
if (_optionalChain([eGet, 'call', _221 => _221(e, "EngineDict"), 'optionalAccess', _222 => _222.t]) !== "dict") eSet(e, "EngineDict", E.dict());
|
|
7991
8268
|
const dict = eGet(e, "EngineDict");
|
|
7992
8269
|
const text3 = layer.text.replace(/\n/g, "\r");
|
|
7993
8270
|
const edText = `${text3}\r`;
|
|
@@ -8066,7 +8343,7 @@ function buildEngineData(layer, template) {
|
|
|
8066
8343
|
eSet(e, key, rd);
|
|
8067
8344
|
}
|
|
8068
8345
|
eSet(rd, "FontSet", fontSet);
|
|
8069
|
-
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access',
|
|
8346
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _223 => _223[0], 'optionalAccess', _224 => _224.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8070
8347
|
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8071
8348
|
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8072
8349
|
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
@@ -8087,12 +8364,12 @@ function inkBounds2(layer) {
|
|
|
8087
8364
|
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))];
|
|
8088
8365
|
}
|
|
8089
8366
|
function tyShForLayer(layer) {
|
|
8090
|
-
const raw = _optionalChain([layer, 'access',
|
|
8091
|
-
if (raw && _optionalChain([layer, 'access',
|
|
8367
|
+
const raw = _optionalChain([layer, 'access', _225 => _225.psd, 'optionalAccess', _226 => _226.tySh]);
|
|
8368
|
+
if (raw && _optionalChain([layer, 'access', _227 => _227.psd, 'optionalAccess', _228 => _228.signature]) === typeSignature(layer)) return raw;
|
|
8092
8369
|
const old = raw ? parseTySh(raw) : null;
|
|
8093
8370
|
const oldEd = old ? descGet(old.text, "EngineData") : void 0;
|
|
8094
8371
|
let template = null;
|
|
8095
|
-
if (_optionalChain([oldEd, 'optionalAccess',
|
|
8372
|
+
if (_optionalChain([oldEd, 'optionalAccess', _229 => _229.type]) === "tdta") {
|
|
8096
8373
|
try {
|
|
8097
8374
|
template = parseEngineData(oldEd.data);
|
|
8098
8375
|
} catch (e19) {
|
|
@@ -8124,197 +8401,11 @@ function tyShForLayer(layer) {
|
|
|
8124
8401
|
set("boundingBox", rect("boundingBox"));
|
|
8125
8402
|
if (!descGet(text3, "TextIndex")) set("TextIndex", { type: "long", value: 0 });
|
|
8126
8403
|
set("EngineData", { type: "tdta", data: writeEngineData(engine) });
|
|
8127
|
-
const warpStyle = _optionalChain([old, 'optionalAccess',
|
|
8128
|
-
const warp = _optionalChain([old, 'optionalAccess',
|
|
8404
|
+
const warpStyle = _optionalChain([old, 'optionalAccess', _230 => _230.warp]) ? descGet(old.warp, "warpStyle") : void 0;
|
|
8405
|
+
const warp = _optionalChain([old, 'optionalAccess', _231 => _231.warp]) && _optionalChain([warpStyle, 'optionalAccess', _232 => _232.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
|
|
8129
8406
|
return writeTySh({ transform: textMatrix(layer), text: text3, warp, tail: new Uint8Array(16) });
|
|
8130
8407
|
}
|
|
8131
8408
|
|
|
8132
|
-
// src/image-editor/psd/compression.ts
|
|
8133
|
-
var MAX_DECODED_BYTES = 2 ** 31;
|
|
8134
|
-
function rowBytes(width, depth) {
|
|
8135
|
-
return depth === 1 ? Math.ceil(width / 8) : width * Math.max(1, depth >> 3);
|
|
8136
|
-
}
|
|
8137
|
-
function decodedLength(l) {
|
|
8138
|
-
const total = l.planes * l.height * rowBytes(l.width, l.depth);
|
|
8139
|
-
if (total > MAX_DECODED_BYTES) throw new PsdError(`Decoded channel data of ${total} bytes is larger than the ${MAX_DECODED_BYTES}-byte limit.`);
|
|
8140
|
-
return total;
|
|
8141
|
-
}
|
|
8142
|
-
function packbitsBound(n) {
|
|
8143
|
-
return n + Math.ceil(n / 128);
|
|
8144
|
-
}
|
|
8145
|
-
function packbitsEncode(src, out, at) {
|
|
8146
|
-
const n = src.length;
|
|
8147
|
-
let i = 0;
|
|
8148
|
-
while (i < n) {
|
|
8149
|
-
let run = 1;
|
|
8150
|
-
while (i + run < n && run < 128 && src[i + run] === src[i]) run++;
|
|
8151
|
-
if (run >= 2) {
|
|
8152
|
-
out[at++] = 257 - run & 255;
|
|
8153
|
-
out[at++] = src[i];
|
|
8154
|
-
i += run;
|
|
8155
|
-
continue;
|
|
8156
|
-
}
|
|
8157
|
-
const start = i;
|
|
8158
|
-
let len = 0;
|
|
8159
|
-
while (i < n && len < 128) {
|
|
8160
|
-
if (i + 2 < n && src[i] === src[i + 1] && src[i] === src[i + 2]) break;
|
|
8161
|
-
i++;
|
|
8162
|
-
len++;
|
|
8163
|
-
}
|
|
8164
|
-
out[at++] = len - 1;
|
|
8165
|
-
out.set(src.subarray(start, start + len), at);
|
|
8166
|
-
at += len;
|
|
8167
|
-
}
|
|
8168
|
-
return at;
|
|
8169
|
-
}
|
|
8170
|
-
function packbitsDecodeInto(src, expected, out, at) {
|
|
8171
|
-
const target = at + expected;
|
|
8172
|
-
let i = 0;
|
|
8173
|
-
while (at < target) {
|
|
8174
|
-
if (i >= src.length) throw new PsdError("PackBits row ended early.");
|
|
8175
|
-
const h = src[i++];
|
|
8176
|
-
if (h < 128) {
|
|
8177
|
-
const len = h + 1;
|
|
8178
|
-
if (i + len > src.length) throw new PsdError("PackBits literal is truncated.");
|
|
8179
|
-
if (at + len > target) throw new PsdError("PackBits literal overflows its row.");
|
|
8180
|
-
out.set(src.subarray(i, i + len), at);
|
|
8181
|
-
at += len;
|
|
8182
|
-
i += len;
|
|
8183
|
-
} else if (h !== 128) {
|
|
8184
|
-
const len = 257 - h;
|
|
8185
|
-
if (i >= src.length) throw new PsdError("PackBits run is truncated.");
|
|
8186
|
-
const b = src[i++];
|
|
8187
|
-
if (at + len > target) throw new PsdError("PackBits run overflows its row.");
|
|
8188
|
-
out.fill(b, at, at + len);
|
|
8189
|
-
at += len;
|
|
8190
|
-
}
|
|
8191
|
-
}
|
|
8192
|
-
return at;
|
|
8193
|
-
}
|
|
8194
|
-
function inflateChecked(data, expected) {
|
|
8195
|
-
let out;
|
|
8196
|
-
try {
|
|
8197
|
-
out = _chunkXFM3OCHUcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
8198
|
-
} catch (e) {
|
|
8199
|
-
throw new PsdError(`ZIP channel data: ${e instanceof _chunkXFM3OCHUcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
8200
|
-
}
|
|
8201
|
-
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
8202
|
-
return out.length === expected ? out : out.subarray(0, expected);
|
|
8203
|
-
}
|
|
8204
|
-
function unpredict(buf, l) {
|
|
8205
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8206
|
-
if (rb === 0) return;
|
|
8207
|
-
const w = l.width;
|
|
8208
|
-
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
8209
|
-
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
8210
|
-
if (l.depth === 1 || l.depth === 8) {
|
|
8211
|
-
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
8212
|
-
} else if (l.depth === 16) {
|
|
8213
|
-
for (let i = 1; i < w; i++) {
|
|
8214
|
-
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
8215
|
-
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
8216
|
-
const v = a + b & 65535;
|
|
8217
|
-
buf[o + 2 * i] = v >> 8;
|
|
8218
|
-
buf[o + 2 * i + 1] = v & 255;
|
|
8219
|
-
}
|
|
8220
|
-
} else if (l.depth === 32) {
|
|
8221
|
-
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
8222
|
-
scratch.set(buf.subarray(o, o + rb));
|
|
8223
|
-
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + 4 * i + k] = scratch[k * w + i];
|
|
8224
|
-
} else {
|
|
8225
|
-
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
8226
|
-
}
|
|
8227
|
-
}
|
|
8228
|
-
}
|
|
8229
|
-
function decodeRle(r, l, total) {
|
|
8230
|
-
const rows = l.planes * l.height;
|
|
8231
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8232
|
-
r.checkCount(rows, l.psb ? 4 : 2, "RLE row counts");
|
|
8233
|
-
const counts = new Array(rows);
|
|
8234
|
-
for (let i = 0; i < rows; i++) counts[i] = l.psb ? r.u32() : r.u16();
|
|
8235
|
-
if (total > r.remaining * 130) throw new PsdError("RLE data is too short for its declared size.");
|
|
8236
|
-
const out = new Uint8Array(total);
|
|
8237
|
-
let at = 0;
|
|
8238
|
-
for (const c of counts) at = packbitsDecodeInto(r.bytes(c), rb, out, at);
|
|
8239
|
-
return out;
|
|
8240
|
-
}
|
|
8241
|
-
function decodePlanes(compression, data, l) {
|
|
8242
|
-
const total = decodedLength(l);
|
|
8243
|
-
switch (compression) {
|
|
8244
|
-
case 0:
|
|
8245
|
-
if (data.length < total) throw new PsdError(`Raw channel data has ${data.length} of ${total} bytes.`);
|
|
8246
|
-
return data.slice(0, total);
|
|
8247
|
-
case 1:
|
|
8248
|
-
return decodeRle(new PsdReader(data), l, total);
|
|
8249
|
-
case 2:
|
|
8250
|
-
return inflateChecked(data, total).slice();
|
|
8251
|
-
case 3: {
|
|
8252
|
-
const v = inflateChecked(data, total).slice();
|
|
8253
|
-
unpredict(v, l);
|
|
8254
|
-
return v;
|
|
8255
|
-
}
|
|
8256
|
-
default:
|
|
8257
|
-
throw new PsdError(`Unsupported compression method ${compression}.`);
|
|
8258
|
-
}
|
|
8259
|
-
}
|
|
8260
|
-
function encodeRle(decoded2, l) {
|
|
8261
|
-
const rows = l.planes * l.height;
|
|
8262
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8263
|
-
const cs = l.psb ? 4 : 2;
|
|
8264
|
-
const packed = new Uint8Array(rows * packbitsBound(rb));
|
|
8265
|
-
let at = 0;
|
|
8266
|
-
const counts = new Uint8Array(rows * cs);
|
|
8267
|
-
for (let row = 0; row < rows; row++) {
|
|
8268
|
-
const start = at;
|
|
8269
|
-
at = packbitsEncode(decoded2.subarray(row * rb, (row + 1) * rb), packed, at);
|
|
8270
|
-
const n = at - start;
|
|
8271
|
-
if (cs === 2) {
|
|
8272
|
-
if (n > 65535) throw new PsdError("An RLE row is longer than 65535 bytes; write a PSB instead.");
|
|
8273
|
-
counts[row * 2] = n >> 8;
|
|
8274
|
-
counts[row * 2 + 1] = n & 255;
|
|
8275
|
-
} else {
|
|
8276
|
-
counts[row * 4] = n >>> 24;
|
|
8277
|
-
counts[row * 4 + 1] = n >>> 16 & 255;
|
|
8278
|
-
counts[row * 4 + 2] = n >>> 8 & 255;
|
|
8279
|
-
counts[row * 4 + 3] = n & 255;
|
|
8280
|
-
}
|
|
8281
|
-
}
|
|
8282
|
-
const out = new Uint8Array(counts.length + at);
|
|
8283
|
-
out.set(counts);
|
|
8284
|
-
out.set(packed.subarray(0, at), counts.length);
|
|
8285
|
-
return out;
|
|
8286
|
-
}
|
|
8287
|
-
function predict(buf, l) {
|
|
8288
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8289
|
-
if (rb === 0) return;
|
|
8290
|
-
const w = l.width;
|
|
8291
|
-
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
8292
|
-
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
8293
|
-
if (l.depth === 1 || l.depth === 8) {
|
|
8294
|
-
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
8295
|
-
} else if (l.depth === 16) {
|
|
8296
|
-
for (let i = w - 1; i > 0; i--) {
|
|
8297
|
-
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
8298
|
-
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
8299
|
-
const v = a - b & 65535;
|
|
8300
|
-
buf[o + 2 * i] = v >> 8;
|
|
8301
|
-
buf[o + 2 * i + 1] = v & 255;
|
|
8302
|
-
}
|
|
8303
|
-
} else if (l.depth === 32) {
|
|
8304
|
-
scratch.set(buf.subarray(o, o + rb));
|
|
8305
|
-
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + k * w + i] = scratch[4 * i + k];
|
|
8306
|
-
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
8307
|
-
} else {
|
|
8308
|
-
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
8309
|
-
}
|
|
8310
|
-
}
|
|
8311
|
-
}
|
|
8312
|
-
function encodeZipPredicted(decoded2, l) {
|
|
8313
|
-
const buf = decoded2.slice();
|
|
8314
|
-
predict(buf, l);
|
|
8315
|
-
return _chunkXFM3OCHUcjs.deflate.call(void 0, buf);
|
|
8316
|
-
}
|
|
8317
|
-
|
|
8318
8409
|
// src/image-editor/psd/smart.ts
|
|
8319
8410
|
var dbl2 = (value) => ({ type: "doub", value });
|
|
8320
8411
|
var unit2 = (u, value) => ({ type: "UntF", unit: u, value });
|
|
@@ -8325,15 +8416,15 @@ var textV = (value) => ({ type: "TEXT", value });
|
|
|
8325
8416
|
var obj2 = (d) => ({ type: "Objc", value: d });
|
|
8326
8417
|
var text = (d, key) => {
|
|
8327
8418
|
const v = descGet(d, key);
|
|
8328
|
-
return _optionalChain([v, 'optionalAccess',
|
|
8419
|
+
return _optionalChain([v, 'optionalAccess', _233 => _233.type]) === "TEXT" ? v.value : void 0;
|
|
8329
8420
|
};
|
|
8330
8421
|
var enumOf2 = (d, key) => {
|
|
8331
8422
|
const v = descGet(d, key);
|
|
8332
|
-
return _optionalChain([v, 'optionalAccess',
|
|
8423
|
+
return _optionalChain([v, 'optionalAccess', _234 => _234.type]) === "enum" ? v.value : void 0;
|
|
8333
8424
|
};
|
|
8334
8425
|
var numbers = (d, key) => {
|
|
8335
8426
|
const v = descGet(d, key);
|
|
8336
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
8427
|
+
if (_optionalChain([v, 'optionalAccess', _235 => _235.type]) !== "VlLs") return null;
|
|
8337
8428
|
const out = [];
|
|
8338
8429
|
for (const it of v.items) {
|
|
8339
8430
|
if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
|
|
@@ -8528,8 +8619,8 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8528
8619
|
const painted = _chunkCWM3CUUXcjs.contentBounds.call(void 0, mask.surface);
|
|
8529
8620
|
let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
8530
8621
|
if (mask.defaultValue !== 255 && area) {
|
|
8531
|
-
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
8532
|
-
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
8622
|
+
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _236 => _236.x]), () => ( area.x)));
|
|
8623
|
+
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _237 => _237.y]), () => ( area.y)));
|
|
8533
8624
|
const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
|
|
8534
8625
|
const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
|
|
8535
8626
|
b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
@@ -8549,7 +8640,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8549
8640
|
}
|
|
8550
8641
|
var warpStyleOf = (name) => {
|
|
8551
8642
|
if (!name.startsWith("warp")) return null;
|
|
8552
|
-
const s = _optionalChain([name, 'access',
|
|
8643
|
+
const s = _optionalChain([name, 'access', _238 => _238[4], 'optionalAccess', _239 => _239.toLowerCase, 'call', _240 => _240()]) + name.slice(5);
|
|
8553
8644
|
return _chunkEGZM52EOcjs.WARP_STYLES.includes(s) ? s : null;
|
|
8554
8645
|
};
|
|
8555
8646
|
function warpFromDescriptor(w, contents) {
|
|
@@ -8571,7 +8662,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8571
8662
|
if (!arr || arr.type !== "ObAr") return void 0;
|
|
8572
8663
|
const xs = descGet(arr.body, "Hrzn");
|
|
8573
8664
|
const ys = descGet(arr.body, "Vrtc");
|
|
8574
|
-
if (_optionalChain([xs, 'optionalAccess',
|
|
8665
|
+
if (_optionalChain([xs, 'optionalAccess', _241 => _241.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _242 => _242.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
|
|
8575
8666
|
mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
|
|
8576
8667
|
const px2 = mesh.points.map((p) => p.x);
|
|
8577
8668
|
const py = mesh.points.map((p) => p.y);
|
|
@@ -8738,13 +8829,13 @@ function blendOptions(f) {
|
|
|
8738
8829
|
function smartFiltersFromPsd(fx, newId, notes) {
|
|
8739
8830
|
const filters = [];
|
|
8740
8831
|
const list2 = descGet(fx, "filterFXList");
|
|
8741
|
-
for (const v of _optionalChain([list2, 'optionalAccess',
|
|
8832
|
+
for (const v of _optionalChain([list2, 'optionalAccess', _243 => _243.type]) === "VlLs" ? list2.items : []) {
|
|
8742
8833
|
if (v.type !== "Objc" && v.type !== "GlbO") continue;
|
|
8743
8834
|
const item = v.value;
|
|
8744
8835
|
const { blend, opacity } = blendOptionsOf(item);
|
|
8745
8836
|
const enabled = descBool(item, "enab") !== false;
|
|
8746
8837
|
const fltr = descObject(item, "Fltr");
|
|
8747
|
-
const radius = _optionalChain([fltr, 'optionalAccess',
|
|
8838
|
+
const radius = _optionalChain([fltr, 'optionalAccess', _244 => _244.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
|
|
8748
8839
|
if (radius !== void 0 && radius >= 0 && radius <= 50) {
|
|
8749
8840
|
filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
|
|
8750
8841
|
continue;
|
|
@@ -9097,7 +9188,7 @@ function readPsd(bytes) {
|
|
|
9097
9188
|
return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
|
|
9098
9189
|
}
|
|
9099
9190
|
function layerBlock(rec, key) {
|
|
9100
|
-
return _optionalChain([rec, 'access',
|
|
9191
|
+
return _optionalChain([rec, 'access', _245 => _245.blocks, 'access', _246 => _246.find, 'call', _247 => _247((b) => b.key === key), 'optionalAccess', _248 => _248.data]);
|
|
9101
9192
|
}
|
|
9102
9193
|
function layerName(rec) {
|
|
9103
9194
|
const luni = layerBlock(rec, "luni");
|
|
@@ -9128,7 +9219,7 @@ function u8Block(rec, key) {
|
|
|
9128
9219
|
function layerTree(file) {
|
|
9129
9220
|
const stack = [[]];
|
|
9130
9221
|
file.layers.forEach((rec, index) => {
|
|
9131
|
-
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call',
|
|
9222
|
+
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _249 => _249(rec), 'optionalAccess', _250 => _250.kind]), () => ( SECTION_OTHER));
|
|
9132
9223
|
if (kind === SECTION_DIVIDER) {
|
|
9133
9224
|
stack.push([]);
|
|
9134
9225
|
} else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
|
|
@@ -9146,7 +9237,7 @@ function layerTree(file) {
|
|
|
9146
9237
|
}
|
|
9147
9238
|
function channelRect(rec, id) {
|
|
9148
9239
|
if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
|
|
9149
|
-
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access',
|
|
9240
|
+
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _251 => _251.mask, 'access', _252 => _252.real, 'optionalAccess', _253 => _253.rect]), () => ( rec.mask.rect));
|
|
9150
9241
|
return rec.rect;
|
|
9151
9242
|
}
|
|
9152
9243
|
function decodeLayerChannel(file, rec, id) {
|
|
@@ -9164,7 +9255,7 @@ function decodeMergedImage(file) {
|
|
|
9164
9255
|
return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
|
|
9165
9256
|
}
|
|
9166
9257
|
function resource(file, id) {
|
|
9167
|
-
return _optionalChain([file, 'access',
|
|
9258
|
+
return _optionalChain([file, 'access', _254 => _254.resources, 'access', _255 => _255.find, 'call', _256 => _256((r) => r.id === id), 'optionalAccess', _257 => _257.data]);
|
|
9168
9259
|
}
|
|
9169
9260
|
function resolution(file) {
|
|
9170
9261
|
const d = resource(file, 1005);
|
|
@@ -9948,7 +10039,7 @@ function importNode(ctx, node, depth) {
|
|
|
9948
10039
|
if (node.children) {
|
|
9949
10040
|
const props2 = baseProps(ctx, rec, name, notes);
|
|
9950
10041
|
const divider = sectionDivider(rec);
|
|
9951
|
-
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess',
|
|
10042
|
+
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _258 => _258.blendKey]), () => ( rec.blendKey));
|
|
9952
10043
|
const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
|
|
9953
10044
|
const children = [];
|
|
9954
10045
|
for (const child of node.children) {
|
|
@@ -9958,7 +10049,7 @@ function importNode(ctx, node, depth) {
|
|
|
9958
10049
|
const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
|
|
9959
10050
|
const effects2 = recordEffects(ctx, rec, name, notes, true);
|
|
9960
10051
|
if (effects2) group.effects = effects2;
|
|
9961
|
-
if (_optionalChain([divider, 'optionalAccess',
|
|
10052
|
+
if (_optionalChain([divider, 'optionalAccess', _259 => _259.kind]) === SECTION_CLOSED) group.collapsed = true;
|
|
9962
10053
|
const mask2 = recordMask(ctx, rec, name);
|
|
9963
10054
|
if (mask2) group.mask = mask2;
|
|
9964
10055
|
entry.type = "group";
|
|
@@ -10181,7 +10272,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10181
10272
|
const file = ctx.linked.get(placed.idnt);
|
|
10182
10273
|
contents = {
|
|
10183
10274
|
id: placed.idnt || ctx.newId(`${name}-contents`),
|
|
10184
|
-
name: _optionalChain([file, 'optionalAccess',
|
|
10275
|
+
name: _optionalChain([file, 'optionalAccess', _260 => _260.name]) || `${name}.png`,
|
|
10185
10276
|
width,
|
|
10186
10277
|
height,
|
|
10187
10278
|
kind: "raster",
|
|
@@ -10338,7 +10429,7 @@ function psdToLayers(file, options = {}) {
|
|
|
10338
10429
|
if (mode !== "rgb" && header.depth > 8 && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP) {
|
|
10339
10430
|
warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to ${header.depth}-bit RGB.`);
|
|
10340
10431
|
} else if (mode !== "rgb" || header.depth !== 8 && header.depth !== 16 && header.depth !== 32) {
|
|
10341
|
-
const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess',
|
|
10432
|
+
const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _261 => _261.name]), () => ( "its profile"))}` : "";
|
|
10342
10433
|
warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB${how}.`);
|
|
10343
10434
|
}
|
|
10344
10435
|
let layers = [];
|
|
@@ -10361,6 +10452,16 @@ function psdToLayers(file, options = {}) {
|
|
|
10361
10452
|
const bg = mergedLayer(ctx);
|
|
10362
10453
|
if (bg) layers = [bg];
|
|
10363
10454
|
}
|
|
10455
|
+
let alphaChannels = [];
|
|
10456
|
+
const hasTransparency = header.channels > ctx.colorCount && (file.layers.length === 0 || file.mergedAlpha);
|
|
10457
|
+
const firstAlpha = ctx.colorCount + (hasTransparency ? 1 : 0);
|
|
10458
|
+
if (!ctx.skipPixels && header.channels > firstAlpha) {
|
|
10459
|
+
try {
|
|
10460
|
+
alphaChannels = readAlphaChannels(decodeMergedImage(file), header, firstAlpha, (id) => resource(file, id), (m) => warn.extra.push(m));
|
|
10461
|
+
} catch (e) {
|
|
10462
|
+
warn.extra.push(`The alpha channels could not be read (${e instanceof Error ? e.message : String(e)}).`);
|
|
10463
|
+
}
|
|
10464
|
+
}
|
|
10364
10465
|
const i32 = (b) => b && b.length >= 4 ? new DataView(b.buffer, b.byteOffset, 4).getInt32(0) : void 0;
|
|
10365
10466
|
const angle = i32(resource(file, 1037));
|
|
10366
10467
|
const altitude = i32(resource(file, 1049));
|
|
@@ -10374,6 +10475,7 @@ function psdToLayers(file, options = {}) {
|
|
|
10374
10475
|
patterns: [...ctx.patterns.values()],
|
|
10375
10476
|
...angle !== void 0 || altitude !== void 0 ? { globalLight: { angle: Math.max(-360, Math.min(360, _nullishCoalesce(angle, () => ( 120)))), altitude: Math.max(0, Math.min(90, _nullishCoalesce(altitude, () => ( 30)))) } } : {},
|
|
10376
10477
|
info: { psb: header.psb, depth: header.depth, colorMode: mode, channels: header.channels },
|
|
10478
|
+
...alphaChannels.length ? { alphaChannels } : {},
|
|
10377
10479
|
...cmykProfile ? { sourceMode: { mode: "cmyk", profile: cmykProfile } } : header.colorMode === MODE_LAB ? { sourceMode: { mode: "lab" } } : {},
|
|
10378
10480
|
...resource(file, 1039) ? { iccProfile: resource(file, 1039).slice() } : {},
|
|
10379
10481
|
bitDepth: (header.depth === 16 || header.depth === 32) && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP ? header.depth : 8
|
|
@@ -10444,15 +10546,15 @@ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
|
|
|
10444
10546
|
var bool = (d, key) => descBool(d, key) === true;
|
|
10445
10547
|
var enumOf3 = (d, key) => {
|
|
10446
10548
|
const v = descGet(d, key);
|
|
10447
|
-
return _optionalChain([v, 'optionalAccess',
|
|
10549
|
+
return _optionalChain([v, 'optionalAccess', _262 => _262.type]) === "enum" ? v.value : void 0;
|
|
10448
10550
|
};
|
|
10449
10551
|
var text2 = (d, key) => {
|
|
10450
10552
|
const v = d ? descGet(d, key) : void 0;
|
|
10451
|
-
return _optionalChain([v, 'optionalAccess',
|
|
10553
|
+
return _optionalChain([v, 'optionalAccess', _263 => _263.type]) === "TEXT" ? v.value : "";
|
|
10452
10554
|
};
|
|
10453
10555
|
var list = (d, key) => {
|
|
10454
10556
|
const v = descGet(d, key);
|
|
10455
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
10557
|
+
if (_optionalChain([v, 'optionalAccess', _264 => _264.type]) !== "VlLs") return [];
|
|
10456
10558
|
return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
|
|
10457
10559
|
};
|
|
10458
10560
|
var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
|
|
@@ -10522,8 +10624,8 @@ function contourOf(d, key) {
|
|
|
10522
10624
|
return { name, points };
|
|
10523
10625
|
}
|
|
10524
10626
|
function contourDesc(c) {
|
|
10525
|
-
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
10526
|
-
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
10627
|
+
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _265 => _265.name]), () => ( "Linear"));
|
|
10628
|
+
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _266 => _266.points]), () => ( [
|
|
10527
10629
|
{ input: 0, output: 0 },
|
|
10528
10630
|
{ input: 1, output: 1 }
|
|
10529
10631
|
]));
|
|
@@ -10558,7 +10660,7 @@ function gradientOf(d, notes) {
|
|
|
10558
10660
|
{ position: 0, color: "#000000" },
|
|
10559
10661
|
{ position: 1, color: "#ffffff" }
|
|
10560
10662
|
],
|
|
10561
|
-
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access',
|
|
10663
|
+
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _267 => _267.find, 'call', _268 => _268(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _269 => _269[0]]), () => ( "linear")),
|
|
10562
10664
|
angle: clamp3(num3(d, "Angl", 90), -360, 360),
|
|
10563
10665
|
scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
|
|
10564
10666
|
reverse: bool(d, "Rvrs"),
|
|
@@ -10612,7 +10714,7 @@ function gradientItems(g) {
|
|
|
10612
10714
|
)
|
|
10613
10715
|
)
|
|
10614
10716
|
};
|
|
10615
|
-
const op = _optionalChain([g, 'access',
|
|
10717
|
+
const op = _optionalChain([g, 'access', _270 => _270.opacityStops, 'optionalAccess', _271 => _271.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
|
|
10616
10718
|
const trns = {
|
|
10617
10719
|
type: "VlLs",
|
|
10618
10720
|
items: op.map(
|
|
@@ -11109,9 +11211,9 @@ function prepareNestedLayers(layers) {
|
|
|
11109
11211
|
if (l.type === "annotation") continue;
|
|
11110
11212
|
let next = l;
|
|
11111
11213
|
if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
|
|
11112
|
-
else if (l.type === "pixel" && (_optionalChain([l, 'access',
|
|
11214
|
+
else if (l.type === "pixel" && (_optionalChain([l, 'access', _272 => _272.filters, 'optionalAccess', _273 => _273.length]) || l.source === "document")) {
|
|
11113
11215
|
const p = { ...l };
|
|
11114
|
-
if (_optionalChain([l, 'access',
|
|
11216
|
+
if (_optionalChain([l, 'access', _274 => _274.filters, 'optionalAccess', _275 => _275.some, 'call', _276 => _276(isActiveFilter)])) {
|
|
11115
11217
|
const b = l.surface.bounds;
|
|
11116
11218
|
if (b) {
|
|
11117
11219
|
const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
|
|
@@ -11128,7 +11230,7 @@ function prepareNestedLayers(layers) {
|
|
|
11128
11230
|
delete p.source;
|
|
11129
11231
|
next = p;
|
|
11130
11232
|
}
|
|
11131
|
-
if (_optionalChain([next, 'access',
|
|
11233
|
+
if (_optionalChain([next, 'access', _277 => _277.mask, 'optionalAccess', _278 => _278.source])) {
|
|
11132
11234
|
next = { ...next };
|
|
11133
11235
|
delete next.mask;
|
|
11134
11236
|
}
|
|
@@ -11234,7 +11336,7 @@ function exportPsd(input) {
|
|
|
11234
11336
|
return {
|
|
11235
11337
|
opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
|
|
11236
11338
|
clipping: layer.clipped ? 1 : 0,
|
|
11237
|
-
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access',
|
|
11339
|
+
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _279 => _279.locks, 'optionalAccess', _280 => _280.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
|
|
11238
11340
|
legacyName: name,
|
|
11239
11341
|
blocks
|
|
11240
11342
|
};
|
|
@@ -11291,7 +11393,7 @@ function exportPsd(input) {
|
|
|
11291
11393
|
}
|
|
11292
11394
|
case "pixel": {
|
|
11293
11395
|
if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
|
|
11294
|
-
if (_optionalChain([layer, 'access',
|
|
11396
|
+
if (_optionalChain([layer, 'access', _281 => _281.filters, 'optionalAccess', _282 => _282.some, 'call', _283 => _283(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
|
|
11295
11397
|
const extra = [];
|
|
11296
11398
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
|
|
11297
11399
|
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
@@ -11323,7 +11425,7 @@ function exportPsd(input) {
|
|
|
11323
11425
|
if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
|
|
11324
11426
|
linkedFiles.set(idnt, smartContentsFile(c));
|
|
11325
11427
|
}
|
|
11326
|
-
let placedId = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
11428
|
+
let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _284 => _284.psd, 'optionalAccess', _285 => _285.placed]), () => ( psdUuid(`${layer.id}:placed`)));
|
|
11327
11429
|
if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
|
|
11328
11430
|
placedIds.add(placedId);
|
|
11329
11431
|
if (placedUnchanged(layer, idnt, placedId)) {
|
|
@@ -11333,12 +11435,12 @@ function exportPsd(input) {
|
|
|
11333
11435
|
const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
|
|
11334
11436
|
if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
|
|
11335
11437
|
const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
|
|
11336
|
-
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess',
|
|
11438
|
+
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _286 => _286.descriptor]) };
|
|
11337
11439
|
const wnotes = [];
|
|
11338
11440
|
extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
|
|
11339
11441
|
for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
|
|
11340
11442
|
}
|
|
11341
|
-
const fm = _optionalChain([layer, 'access',
|
|
11443
|
+
const fm = _optionalChain([layer, 'access', _287 => _287.smartFilters, 'optionalAccess', _288 => _288.mask]);
|
|
11342
11444
|
if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
|
|
11343
11445
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
11344
11446
|
const bounds = _chunkCWM3CUUXcjs.contentBounds.call(void 0, layer.surface);
|
|
@@ -11366,8 +11468,8 @@ function exportPsd(input) {
|
|
|
11366
11468
|
const losses = /* @__PURE__ */ new Set();
|
|
11367
11469
|
for (const b of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b.key, data: padEven(b.data) });
|
|
11368
11470
|
for (const n2 of losses) note(n2, layer.name);
|
|
11369
|
-
if (_optionalChain([layer, 'access',
|
|
11370
|
-
if (_optionalChain([layer, 'access',
|
|
11471
|
+
if (_optionalChain([layer, 'access', _289 => _289.fill, 'optionalAccess', _290 => _290.type]) === "pattern") patternIds2.add(layer.fill.patternId);
|
|
11472
|
+
if (_optionalChain([layer, 'access', _291 => _291.stroke, 'optionalAccess', _292 => _292.paint, 'access', _293 => _293.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
|
|
11371
11473
|
} else {
|
|
11372
11474
|
extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
|
|
11373
11475
|
}
|
|
@@ -11411,6 +11513,10 @@ function exportPsd(input) {
|
|
|
11411
11513
|
planes = transparent ? dp : dp.slice(0, 3);
|
|
11412
11514
|
}
|
|
11413
11515
|
}
|
|
11516
|
+
for (const ch of _nullishCoalesce(input.alphaChannels, () => ( []))) {
|
|
11517
|
+
if (ch.data.length !== n) throw new PsdError(`Alpha channel "${ch.name}" has ${ch.data.length} values, expected ${n}.`);
|
|
11518
|
+
planes.push(planeAtDepth(ch.data, depth));
|
|
11519
|
+
}
|
|
11414
11520
|
const planeBytes = n * (depth >> 3);
|
|
11415
11521
|
const merged2 = new Uint8Array(planeBytes * planes.length);
|
|
11416
11522
|
planes.forEach((p, i) => merged2.set(p, i * planeBytes));
|
|
@@ -11431,7 +11537,8 @@ function exportPsd(input) {
|
|
|
11431
11537
|
{ id: 1005, name: "", data: rw.result() },
|
|
11432
11538
|
{ id: 1057, name: "", data: version.result() }
|
|
11433
11539
|
];
|
|
11434
|
-
if (_optionalChain([input, 'access',
|
|
11540
|
+
if (_optionalChain([input, 'access', _294 => _294.iccProfile, 'optionalAccess', _295 => _295.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
|
|
11541
|
+
resources.push(...alphaChannelResources(_nullishCoalesce(input.alphaChannels, () => ( []))));
|
|
11435
11542
|
if (input.globalLight) {
|
|
11436
11543
|
const i32 = (v) => {
|
|
11437
11544
|
const w = new PsdWriter();
|
|
@@ -11847,4 +11954,4 @@ function exportPsd(input) {
|
|
|
11847
11954
|
|
|
11848
11955
|
|
|
11849
11956
|
|
|
11850
|
-
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
11957
|
+
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|