@pixerate/editor 0.111.0 → 0.112.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-HHZ6ZJTW.js → chunk-CZOXTEMN.js} +1772 -456
- package/dist/chunk-CZOXTEMN.js.map +1 -0
- package/dist/{chunk-PHUMLSCW.cjs → chunk-YGIMK4NX.cjs} +1810 -494
- package/dist/chunk-YGIMK4NX.cjs.map +1 -0
- package/dist/{export-DoDhCszr.d.cts → export-DBba-buV.d.cts} +40 -13
- package/dist/{export-DBNVwb6h.d.ts → export-DNu_Jr8p.d.ts} +40 -13
- package/dist/image-editor/index.cjs +1166 -619
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +159 -3
- package/dist/image-editor/index.d.ts +159 -3
- package/dist/image-editor/index.js +554 -7
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.d.cts +1 -1
- package/dist/paint-editor/index.d.ts +1 -1
- package/dist/paint-editor/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HHZ6ZJTW.js.map +0 -1
- package/dist/chunk-PHUMLSCW.cjs.map +0 -1
|
@@ -522,20 +522,20 @@ function hitTestCrop(canvasPt, state, vpWidth, vpHeight, handleThreshold = 14, c
|
|
|
522
522
|
}
|
|
523
523
|
function hitTestCropRect(canvasPt, rect, handleThreshold) {
|
|
524
524
|
const { x, y, width: w, height: h } = rect;
|
|
525
|
-
const
|
|
525
|
+
const px2 = canvasPt.x;
|
|
526
526
|
const py = canvasPt.y;
|
|
527
527
|
const dist = (x1, y1, x2, y2) => Math.hypot(x1 - x2, y1 - y2);
|
|
528
|
-
if (dist(
|
|
529
|
-
if (dist(
|
|
530
|
-
if (dist(
|
|
531
|
-
if (dist(
|
|
532
|
-
const nearX =
|
|
528
|
+
if (dist(px2, py, x, y) <= handleThreshold) return "nw";
|
|
529
|
+
if (dist(px2, py, x + w, y) <= handleThreshold) return "ne";
|
|
530
|
+
if (dist(px2, py, x + w, y + h) <= handleThreshold) return "se";
|
|
531
|
+
if (dist(px2, py, x, y + h) <= handleThreshold) return "sw";
|
|
532
|
+
const nearX = px2 >= x - handleThreshold && px2 <= x + w + handleThreshold;
|
|
533
533
|
const nearY = py >= y - handleThreshold && py <= y + h + handleThreshold;
|
|
534
534
|
if (nearX && Math.abs(py - y) <= handleThreshold) return "n";
|
|
535
535
|
if (nearX && Math.abs(py - (y + h)) <= handleThreshold) return "s";
|
|
536
|
-
if (nearY && Math.abs(
|
|
537
|
-
if (nearY && Math.abs(
|
|
538
|
-
if (
|
|
536
|
+
if (nearY && Math.abs(px2 - x) <= handleThreshold) return "w";
|
|
537
|
+
if (nearY && Math.abs(px2 - (x + w)) <= handleThreshold) return "e";
|
|
538
|
+
if (px2 >= x && px2 <= x + w && py >= y && py <= y + h) {
|
|
539
539
|
return "inside";
|
|
540
540
|
}
|
|
541
541
|
return null;
|
|
@@ -2146,8 +2146,8 @@ function applyFastBoxBlur(imageData, radius) {
|
|
|
2146
2146
|
let r = 0, g = 0, b = 0, a = 0;
|
|
2147
2147
|
let count = 0;
|
|
2148
2148
|
for (let k = -radius; k <= radius; k++) {
|
|
2149
|
-
const
|
|
2150
|
-
const idx = (y * w +
|
|
2149
|
+
const px2 = Math.min(w - 1, Math.max(0, x + k));
|
|
2150
|
+
const idx = (y * w + px2) * 4;
|
|
2151
2151
|
r += src[idx];
|
|
2152
2152
|
g += src[idx + 1];
|
|
2153
2153
|
b += src[idx + 2];
|
|
@@ -3129,9 +3129,9 @@ function updateLayerFilter(layers, id, filterId, changes) {
|
|
|
3129
3129
|
if (i === -1) fail(`Layer "${id}" has no filter "${filterId}". Filters: ${(_nullishCoalesce(layer.filters, () => ( []))).map((f) => f.id).join(", ") || "none"}.`);
|
|
3130
3130
|
const current = layer.filters[i];
|
|
3131
3131
|
if ("kind" in changes && changes.kind !== current.kind) fail("A filter kind cannot change; remove it and add another.");
|
|
3132
|
-
const
|
|
3132
|
+
const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
3133
3133
|
const filters = [...layer.filters];
|
|
3134
|
-
filters[i] =
|
|
3134
|
+
filters[i] = merged2;
|
|
3135
3135
|
return _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
|
|
3136
3136
|
}
|
|
3137
3137
|
function removeLayerFilter(layers, id, filterId) {
|
|
@@ -3418,7 +3418,8 @@ function shapeGeometry(layer) {
|
|
|
3418
3418
|
bounds = { x: x0, y: y0, width: Math.max(bounds.x + bounds.width, b.x + b.width) - x0, height: Math.max(bounds.y + bounds.height, b.y + b.height) - y0 };
|
|
3419
3419
|
}
|
|
3420
3420
|
};
|
|
3421
|
-
if (layer.fill)
|
|
3421
|
+
if (layer.fill && layer.inverted) add({ x: -1e7, y: -1e7, width: 2e7, height: 2e7 });
|
|
3422
|
+
else if (layer.fill) for (const f of fills) add(flatBounds(f.flat));
|
|
3422
3423
|
if (stroke) add(flatBounds(stroke));
|
|
3423
3424
|
const g = _nullishCoalesce(shapeGeometryBounds(layer), () => ( { x: 0, y: 0, width: 0, height: 0 }));
|
|
3424
3425
|
const frame = { x: Math.floor(g.x), y: Math.floor(g.y), width: Math.max(1, Math.ceil(g.x + g.width) - Math.floor(g.x)), height: Math.max(1, Math.ceil(g.y + g.height) - Math.floor(g.y)) };
|
|
@@ -3426,8 +3427,14 @@ function shapeGeometry(layer) {
|
|
|
3426
3427
|
geometryCache.set(layer, geo);
|
|
3427
3428
|
return geo;
|
|
3428
3429
|
}
|
|
3429
|
-
function fillCoverage(geo, rect, rule) {
|
|
3430
|
+
function fillCoverage(geo, rect, rule, inverted = false) {
|
|
3430
3431
|
const n = rect.width * rect.height;
|
|
3432
|
+
if (inverted) {
|
|
3433
|
+
const area = fillCoverage(geo, rect, rule);
|
|
3434
|
+
const out = new Float32Array(n);
|
|
3435
|
+
for (let i = 0; i < n; i++) out[i] = 1 - (area ? area[i] : 0);
|
|
3436
|
+
return out;
|
|
3437
|
+
}
|
|
3431
3438
|
let acc = null;
|
|
3432
3439
|
geo.fills.forEach((f, i) => {
|
|
3433
3440
|
const cov = f.flat.length > 1 ? rasterizeCoverageSampled(f.flat, rect, rule) : rasterizeCoverage(f.flat, rect, rule);
|
|
@@ -3465,7 +3472,7 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
|
|
|
3465
3472
|
const n = rect.width * rect.height;
|
|
3466
3473
|
const rule = _nullishCoalesce(layer.fillRule, () => ( "nonzero"));
|
|
3467
3474
|
const needArea = Boolean(layer.fill) || geo.stroke !== null && geo.align !== "center";
|
|
3468
|
-
const area = needArea ? fillCoverage(geo, rect, rule) : null;
|
|
3475
|
+
const area = needArea ? fillCoverage(geo, rect, rule, Boolean(layer.inverted && layer.fill)) : null;
|
|
3469
3476
|
let sCov = geo.stroke ? rasterizeCoverageSampled(geo.stroke, rect, "nonzero") : null;
|
|
3470
3477
|
if (sCov && geo.align === "inside") sCov = area ? combineCoverage(sCov, area, "intersect", n) : null;
|
|
3471
3478
|
else if (sCov && geo.align === "outside" && area) sCov = combineCoverage(sCov, area, "subtract", n);
|
|
@@ -3522,9 +3529,9 @@ function renderShape(layer, env, options = {}) {
|
|
|
3522
3529
|
const tiles = /* @__PURE__ */ new Map();
|
|
3523
3530
|
for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
|
|
3524
3531
|
const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
|
|
3525
|
-
const
|
|
3526
|
-
if (!
|
|
3527
|
-
const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0,
|
|
3532
|
+
const px2 = renderShapeRect(layer, rect, env, ctx);
|
|
3533
|
+
if (!px2) continue;
|
|
3534
|
+
const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px2, 4, 0);
|
|
3528
3535
|
if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
|
|
3529
3536
|
}
|
|
3530
3537
|
return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
|
|
@@ -3755,6 +3762,7 @@ function createShapeLayer(init, env, id = newLayerId()) {
|
|
|
3755
3762
|
offset: { x: 0, y: 0 }
|
|
3756
3763
|
};
|
|
3757
3764
|
if (init.fillRule && init.fillRule !== "nonzero") layer.fillRule = init.fillRule;
|
|
3765
|
+
if (init.inverted) layer.inverted = true;
|
|
3758
3766
|
return rerenderShape(layer, env);
|
|
3759
3767
|
}
|
|
3760
3768
|
function defaultShapeName(c) {
|
|
@@ -3807,7 +3815,7 @@ function mergeShapeComponents(components, fillRule = "nonzero") {
|
|
|
3807
3815
|
return [{ op: "combine", subpaths }];
|
|
3808
3816
|
}
|
|
3809
3817
|
function shapeAsPixelLayer(layer) {
|
|
3810
|
-
const { components: _c, fillRule: _r, fill: _f, stroke: _s, annotation: _a, psd: _p, type: _t, ...rest } = layer;
|
|
3818
|
+
const { components: _c, fillRule: _r, inverted: _i, fill: _f, stroke: _s, annotation: _a, psd: _p, type: _t, ...rest } = layer;
|
|
3811
3819
|
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
3812
3820
|
}
|
|
3813
3821
|
function annotationPaint(color, opacity) {
|
|
@@ -4302,16 +4310,16 @@ function renderOutlines(layer, shaper, region) {
|
|
|
4302
4310
|
}
|
|
4303
4311
|
}
|
|
4304
4312
|
if (!any) continue;
|
|
4305
|
-
const
|
|
4313
|
+
const px2 = new Uint8ClampedArray(n * 4);
|
|
4306
4314
|
for (let i = 0; i < n * 4; i += 4) {
|
|
4307
4315
|
const a = Math.round(acc[i + 3] * 255);
|
|
4308
4316
|
if (!a) continue;
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4317
|
+
px2[i] = Math.round(acc[i]);
|
|
4318
|
+
px2[i + 1] = Math.round(acc[i + 1]);
|
|
4319
|
+
px2[i + 2] = Math.round(acc[i + 2]);
|
|
4320
|
+
px2[i + 3] = a;
|
|
4313
4321
|
}
|
|
4314
|
-
const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0,
|
|
4322
|
+
const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px2, 4, 0);
|
|
4315
4323
|
if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
|
|
4316
4324
|
}
|
|
4317
4325
|
return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
|
|
@@ -5581,7 +5589,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5581
5589
|
const i = requireFilter(layer, filterId);
|
|
5582
5590
|
const current = layer.smartFilters.filters[i];
|
|
5583
5591
|
if ("kind" in changes && changes.kind !== current.kind) fail4("A smart filter kind cannot change; remove it and add another.");
|
|
5584
|
-
let
|
|
5592
|
+
let merged2;
|
|
5585
5593
|
if (current.kind === "psd") {
|
|
5586
5594
|
const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
|
|
5587
5595
|
if (extra.length) fail4(`"${current.name}" is a Photoshop filter we keep but do not model; only enabled, blend and opacity change. Unknown: ${extra.join(", ")}.`);
|
|
@@ -5589,14 +5597,14 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5589
5597
|
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
5590
5598
|
const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
|
|
5591
5599
|
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
5592
|
-
|
|
5600
|
+
merged2 = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
|
|
5593
5601
|
} else {
|
|
5594
|
-
|
|
5602
|
+
merged2 = normalizeSmartFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
5595
5603
|
}
|
|
5596
5604
|
const filters = [...layer.smartFilters.filters];
|
|
5597
|
-
filters[i] =
|
|
5605
|
+
filters[i] = merged2;
|
|
5598
5606
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5599
|
-
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter:
|
|
5607
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
|
|
5600
5608
|
}
|
|
5601
5609
|
function removeSmartFilter(layers, id, filterId, canvas) {
|
|
5602
5610
|
const layer = editableSmart(layers, id);
|
|
@@ -5782,6 +5790,7 @@ function serializeType(layer, base, ctx) {
|
|
|
5782
5790
|
out.psd = {};
|
|
5783
5791
|
if (layer.psd.tySh) out.psd.tySh = _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.tySh);
|
|
5784
5792
|
if (_optionalChain([layer, 'access', _134 => _134.psd, 'access', _135 => _135.blocks, 'optionalAccess', _136 => _136.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, b.data) }));
|
|
5793
|
+
if (layer.psd.signature) out.psd.signature = layer.psd.signature;
|
|
5785
5794
|
}
|
|
5786
5795
|
return out;
|
|
5787
5796
|
}
|
|
@@ -5820,6 +5829,7 @@ function readType(r, base, ctx) {
|
|
|
5820
5829
|
const psd = {};
|
|
5821
5830
|
if (typeof r.psd.tySh === "string") psd.tySh = _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.tySh);
|
|
5822
5831
|
if (Array.isArray(r.psd.blocks)) psd.blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5832
|
+
if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
|
|
5823
5833
|
if (psd.tySh || _optionalChain([psd, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) layer.psd = psd;
|
|
5824
5834
|
}
|
|
5825
5835
|
if (typeof r.asset === "string") return { ...layer, surface: readSurface(r.asset, r.x, r.y, 4, 0, ctx, label), rendering: "stored" };
|
|
@@ -5843,9 +5853,10 @@ function serializeShape(layer, base) {
|
|
|
5843
5853
|
stroke: layer.stroke ? JSON.parse(JSON.stringify(layer.stroke)) : null
|
|
5844
5854
|
};
|
|
5845
5855
|
if (layer.fillRule === "evenodd") out.fillRule = "evenodd";
|
|
5856
|
+
if (layer.inverted) out.inverted = true;
|
|
5846
5857
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5847
5858
|
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5848
|
-
if (_optionalChain([layer, 'access', _151 => _151.psd, 'optionalAccess', _152 => _152.blocks, 'optionalAccess', _153 => _153.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, b.data) })) };
|
|
5859
|
+
if (_optionalChain([layer, 'access', _151 => _151.psd, 'optionalAccess', _152 => _152.blocks, 'optionalAccess', _153 => _153.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
|
|
5849
5860
|
return out;
|
|
5850
5861
|
}
|
|
5851
5862
|
function readShape(r, base, ctx) {
|
|
@@ -5872,13 +5883,14 @@ function readShape(r, base, ctx) {
|
|
|
5872
5883
|
stroke: r.stroke === null || r.stroke === void 0 ? null : normalizeShapeStroke(r.stroke, "stroke")
|
|
5873
5884
|
};
|
|
5874
5885
|
}
|
|
5875
|
-
const layer = createShapeLayer({ ...data, fillRule: r.fillRule === "evenodd" ? "evenodd" : "nonzero" }, env, base.id);
|
|
5886
|
+
const layer = createShapeLayer({ ...data, fillRule: r.fillRule === "evenodd" ? "evenodd" : "nonzero", inverted: r.inverted === true && !a }, env, base.id);
|
|
5876
5887
|
const out = { ...layer, ...base, type: "shape", components: layer.components, fill: layer.fill, stroke: layer.stroke, surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
5877
5888
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5878
5889
|
if (a && shapeFromAnnotation(a)) out.annotation = a;
|
|
5879
5890
|
if (r.psd && Array.isArray(r.psd.blocks)) {
|
|
5880
5891
|
const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5881
5892
|
if (blocks.length) out.psd = { blocks };
|
|
5893
|
+
if (out.psd && typeof r.psd.signature === "string") out.psd.signature = r.psd.signature;
|
|
5882
5894
|
}
|
|
5883
5895
|
return out;
|
|
5884
5896
|
} catch (e) {
|
|
@@ -6035,8 +6047,8 @@ function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
|
|
|
6035
6047
|
return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
6036
6048
|
}
|
|
6037
6049
|
try {
|
|
6038
|
-
const
|
|
6039
|
-
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0,
|
|
6050
|
+
const px2 = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
|
|
6051
|
+
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, px2, channels, Math.round(num2(x, -1e7, 1e7, 0)), Math.round(num2(y, -1e7, 1e7, 0)), defaultValue);
|
|
6040
6052
|
} catch (err) {
|
|
6041
6053
|
ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
|
|
6042
6054
|
return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
@@ -6358,8 +6370,8 @@ var PsdReader = class _PsdReader {
|
|
|
6358
6370
|
return v;
|
|
6359
6371
|
}
|
|
6360
6372
|
/** A length field: 8 bytes in PSB where the format says so, else 4. */
|
|
6361
|
-
len(
|
|
6362
|
-
return
|
|
6373
|
+
len(long5) {
|
|
6374
|
+
return long5 ? this.u64() : this.u32();
|
|
6363
6375
|
}
|
|
6364
6376
|
bytes(n) {
|
|
6365
6377
|
this.need(n, `${n} bytes`);
|
|
@@ -6466,11 +6478,11 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
|
|
|
6466
6478
|
this.length += n;
|
|
6467
6479
|
}
|
|
6468
6480
|
/** Reserves a length field; `endLen` fills it with the bytes written since. */
|
|
6469
|
-
beginLen(
|
|
6481
|
+
beginLen(long5) {
|
|
6470
6482
|
const at = this.length;
|
|
6471
|
-
if (
|
|
6483
|
+
if (long5) this.u64(0);
|
|
6472
6484
|
else this.u32(0);
|
|
6473
|
-
return { at, long:
|
|
6485
|
+
return { at, long: long5 };
|
|
6474
6486
|
}
|
|
6475
6487
|
endLen(mark) {
|
|
6476
6488
|
const n = this.length - mark.at - (mark.long ? 8 : 4);
|
|
@@ -6515,162 +6527,6 @@ function encodeLegacyName(s) {
|
|
|
6515
6527
|
return Uint8Array.from(out);
|
|
6516
6528
|
}
|
|
6517
6529
|
|
|
6518
|
-
// src/image-editor/psd/compression.ts
|
|
6519
|
-
var MAX_DECODED_BYTES = 2 ** 31;
|
|
6520
|
-
function rowBytes(width, depth) {
|
|
6521
|
-
return depth === 1 ? Math.ceil(width / 8) : width * Math.max(1, depth >> 3);
|
|
6522
|
-
}
|
|
6523
|
-
function decodedLength(l) {
|
|
6524
|
-
const total = l.planes * l.height * rowBytes(l.width, l.depth);
|
|
6525
|
-
if (total > MAX_DECODED_BYTES) throw new PsdError(`Decoded channel data of ${total} bytes is larger than the ${MAX_DECODED_BYTES}-byte limit.`);
|
|
6526
|
-
return total;
|
|
6527
|
-
}
|
|
6528
|
-
function packbitsBound(n) {
|
|
6529
|
-
return n + Math.ceil(n / 128);
|
|
6530
|
-
}
|
|
6531
|
-
function packbitsEncode(src, out, at) {
|
|
6532
|
-
const n = src.length;
|
|
6533
|
-
let i = 0;
|
|
6534
|
-
while (i < n) {
|
|
6535
|
-
let run = 1;
|
|
6536
|
-
while (i + run < n && run < 128 && src[i + run] === src[i]) run++;
|
|
6537
|
-
if (run >= 2) {
|
|
6538
|
-
out[at++] = 257 - run & 255;
|
|
6539
|
-
out[at++] = src[i];
|
|
6540
|
-
i += run;
|
|
6541
|
-
continue;
|
|
6542
|
-
}
|
|
6543
|
-
const start = i;
|
|
6544
|
-
let len = 0;
|
|
6545
|
-
while (i < n && len < 128) {
|
|
6546
|
-
if (i + 2 < n && src[i] === src[i + 1] && src[i] === src[i + 2]) break;
|
|
6547
|
-
i++;
|
|
6548
|
-
len++;
|
|
6549
|
-
}
|
|
6550
|
-
out[at++] = len - 1;
|
|
6551
|
-
out.set(src.subarray(start, start + len), at);
|
|
6552
|
-
at += len;
|
|
6553
|
-
}
|
|
6554
|
-
return at;
|
|
6555
|
-
}
|
|
6556
|
-
function packbitsDecodeInto(src, expected, out, at) {
|
|
6557
|
-
const target = at + expected;
|
|
6558
|
-
let i = 0;
|
|
6559
|
-
while (at < target) {
|
|
6560
|
-
if (i >= src.length) throw new PsdError("PackBits row ended early.");
|
|
6561
|
-
const h = src[i++];
|
|
6562
|
-
if (h < 128) {
|
|
6563
|
-
const len = h + 1;
|
|
6564
|
-
if (i + len > src.length) throw new PsdError("PackBits literal is truncated.");
|
|
6565
|
-
if (at + len > target) throw new PsdError("PackBits literal overflows its row.");
|
|
6566
|
-
out.set(src.subarray(i, i + len), at);
|
|
6567
|
-
at += len;
|
|
6568
|
-
i += len;
|
|
6569
|
-
} else if (h !== 128) {
|
|
6570
|
-
const len = 257 - h;
|
|
6571
|
-
if (i >= src.length) throw new PsdError("PackBits run is truncated.");
|
|
6572
|
-
const b = src[i++];
|
|
6573
|
-
if (at + len > target) throw new PsdError("PackBits run overflows its row.");
|
|
6574
|
-
out.fill(b, at, at + len);
|
|
6575
|
-
at += len;
|
|
6576
|
-
}
|
|
6577
|
-
}
|
|
6578
|
-
return at;
|
|
6579
|
-
}
|
|
6580
|
-
function inflateChecked(data, expected) {
|
|
6581
|
-
let out;
|
|
6582
|
-
try {
|
|
6583
|
-
out = _chunkPOGBUYWEcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
6584
|
-
} catch (e) {
|
|
6585
|
-
throw new PsdError(`ZIP channel data: ${e instanceof _chunkPOGBUYWEcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
6586
|
-
}
|
|
6587
|
-
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
6588
|
-
return out.length === expected ? out : out.subarray(0, expected);
|
|
6589
|
-
}
|
|
6590
|
-
function unpredict(buf, l) {
|
|
6591
|
-
const rb = rowBytes(l.width, l.depth);
|
|
6592
|
-
if (rb === 0) return;
|
|
6593
|
-
const w = l.width;
|
|
6594
|
-
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
6595
|
-
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
6596
|
-
if (l.depth === 1 || l.depth === 8) {
|
|
6597
|
-
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
6598
|
-
} else if (l.depth === 16) {
|
|
6599
|
-
for (let i = 1; i < w; i++) {
|
|
6600
|
-
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
6601
|
-
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
6602
|
-
const v = a + b & 65535;
|
|
6603
|
-
buf[o + 2 * i] = v >> 8;
|
|
6604
|
-
buf[o + 2 * i + 1] = v & 255;
|
|
6605
|
-
}
|
|
6606
|
-
} else if (l.depth === 32) {
|
|
6607
|
-
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
6608
|
-
scratch.set(buf.subarray(o, o + rb));
|
|
6609
|
-
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + 4 * i + k] = scratch[k * w + i];
|
|
6610
|
-
} else {
|
|
6611
|
-
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
6612
|
-
}
|
|
6613
|
-
}
|
|
6614
|
-
}
|
|
6615
|
-
function decodeRle(r, l, total) {
|
|
6616
|
-
const rows = l.planes * l.height;
|
|
6617
|
-
const rb = rowBytes(l.width, l.depth);
|
|
6618
|
-
r.checkCount(rows, l.psb ? 4 : 2, "RLE row counts");
|
|
6619
|
-
const counts = new Array(rows);
|
|
6620
|
-
for (let i = 0; i < rows; i++) counts[i] = l.psb ? r.u32() : r.u16();
|
|
6621
|
-
if (total > r.remaining * 130) throw new PsdError("RLE data is too short for its declared size.");
|
|
6622
|
-
const out = new Uint8Array(total);
|
|
6623
|
-
let at = 0;
|
|
6624
|
-
for (const c of counts) at = packbitsDecodeInto(r.bytes(c), rb, out, at);
|
|
6625
|
-
return out;
|
|
6626
|
-
}
|
|
6627
|
-
function decodePlanes(compression, data, l) {
|
|
6628
|
-
const total = decodedLength(l);
|
|
6629
|
-
switch (compression) {
|
|
6630
|
-
case 0:
|
|
6631
|
-
if (data.length < total) throw new PsdError(`Raw channel data has ${data.length} of ${total} bytes.`);
|
|
6632
|
-
return data.slice(0, total);
|
|
6633
|
-
case 1:
|
|
6634
|
-
return decodeRle(new PsdReader(data), l, total);
|
|
6635
|
-
case 2:
|
|
6636
|
-
return inflateChecked(data, total).slice();
|
|
6637
|
-
case 3: {
|
|
6638
|
-
const v = inflateChecked(data, total).slice();
|
|
6639
|
-
unpredict(v, l);
|
|
6640
|
-
return v;
|
|
6641
|
-
}
|
|
6642
|
-
default:
|
|
6643
|
-
throw new PsdError(`Unsupported compression method ${compression}.`);
|
|
6644
|
-
}
|
|
6645
|
-
}
|
|
6646
|
-
function encodeRle(decoded2, l) {
|
|
6647
|
-
const rows = l.planes * l.height;
|
|
6648
|
-
const rb = rowBytes(l.width, l.depth);
|
|
6649
|
-
const cs = l.psb ? 4 : 2;
|
|
6650
|
-
const packed = new Uint8Array(rows * packbitsBound(rb));
|
|
6651
|
-
let at = 0;
|
|
6652
|
-
const counts = new Uint8Array(rows * cs);
|
|
6653
|
-
for (let row = 0; row < rows; row++) {
|
|
6654
|
-
const start = at;
|
|
6655
|
-
at = packbitsEncode(decoded2.subarray(row * rb, (row + 1) * rb), packed, at);
|
|
6656
|
-
const n = at - start;
|
|
6657
|
-
if (cs === 2) {
|
|
6658
|
-
if (n > 65535) throw new PsdError("An RLE row is longer than 65535 bytes; write a PSB instead.");
|
|
6659
|
-
counts[row * 2] = n >> 8;
|
|
6660
|
-
counts[row * 2 + 1] = n & 255;
|
|
6661
|
-
} else {
|
|
6662
|
-
counts[row * 4] = n >>> 24;
|
|
6663
|
-
counts[row * 4 + 1] = n >>> 16 & 255;
|
|
6664
|
-
counts[row * 4 + 2] = n >>> 8 & 255;
|
|
6665
|
-
counts[row * 4 + 3] = n & 255;
|
|
6666
|
-
}
|
|
6667
|
-
}
|
|
6668
|
-
const out = new Uint8Array(counts.length + at);
|
|
6669
|
-
out.set(counts);
|
|
6670
|
-
out.set(packed.subarray(0, at), counts.length);
|
|
6671
|
-
return out;
|
|
6672
|
-
}
|
|
6673
|
-
|
|
6674
6530
|
// src/image-editor/psd/descriptor.ts
|
|
6675
6531
|
var MAX_DEPTH = 64;
|
|
6676
6532
|
var STRING_IDS = /* @__PURE__ */ new Set(["warp", "list", "time"]);
|
|
@@ -6786,12 +6642,12 @@ function readValue(r, depth) {
|
|
|
6786
6642
|
case "UntF":
|
|
6787
6643
|
return { type, unit: r.ascii(4), value: r.f64() };
|
|
6788
6644
|
case "UnFl": {
|
|
6789
|
-
const
|
|
6645
|
+
const unit4 = r.ascii(4);
|
|
6790
6646
|
const n = r.u32();
|
|
6791
6647
|
r.checkCount(n, 8, "Unit float list");
|
|
6792
6648
|
const values = [];
|
|
6793
6649
|
for (let i = 0; i < n; i++) values.push(r.f64());
|
|
6794
|
-
return { type, unit:
|
|
6650
|
+
return { type, unit: unit4, values };
|
|
6795
6651
|
}
|
|
6796
6652
|
case "TEXT":
|
|
6797
6653
|
return { type, value: r.unicode() };
|
|
@@ -7244,11 +7100,11 @@ function writeAdjustmentBlock(kind, params) {
|
|
|
7244
7100
|
case "blackWhite": {
|
|
7245
7101
|
const p = params;
|
|
7246
7102
|
const tint = p.tint ? hexToRgb(p.tint) : BW_TINT;
|
|
7247
|
-
const
|
|
7103
|
+
const dbl4 = (v) => ({ type: "doub", value: clamp2(v, 0, 1) * 255 });
|
|
7248
7104
|
const items = BW_KEYS.map(([field, key]) => [key, long(clamp2(p[field], -200, 300))]);
|
|
7249
7105
|
items.push(
|
|
7250
7106
|
["useTint", { type: "bool", value: p.tint !== null }],
|
|
7251
|
-
["tintColor", { type: "Objc", value: descriptor("RGBC", [["Rd ",
|
|
7107
|
+
["tintColor", { type: "Objc", value: descriptor("RGBC", [["Rd ", dbl4(tint[0])], ["Grn ", dbl4(tint[1])], ["Bl ", dbl4(tint[2])]]) }],
|
|
7252
7108
|
["bwPresetKind", { type: "long", value: 1 }],
|
|
7253
7109
|
["blackAndWhitePresetFileName", { type: "TEXT", value: "" }]
|
|
7254
7110
|
);
|
|
@@ -7270,88 +7126,1428 @@ function writeAdjustmentBlock(kind, params) {
|
|
|
7270
7126
|
throw new Error(`Unknown adjustment kind "${kind}".`);
|
|
7271
7127
|
}
|
|
7272
7128
|
|
|
7273
|
-
// src/image-editor/psd/
|
|
7274
|
-
var
|
|
7129
|
+
// src/image-editor/psd/paths.ts
|
|
7130
|
+
var RECORD = 26;
|
|
7131
|
+
var fixed = (v) => v / 16777216;
|
|
7132
|
+
var toFixed = (v) => Math.max(-2147483648, Math.min(2147483647, Math.round(v * 16777216)));
|
|
7133
|
+
function readPathRecords(data) {
|
|
7134
|
+
const r = new PsdReader(data);
|
|
7135
|
+
const subpaths = [];
|
|
7136
|
+
let initialFill = false;
|
|
7137
|
+
let remaining = 0;
|
|
7138
|
+
while (r.remaining >= RECORD) {
|
|
7139
|
+
const selector = r.u16();
|
|
7140
|
+
const body = r.sub(24);
|
|
7141
|
+
if (selector === 0 || selector === 3) {
|
|
7142
|
+
remaining = body.u16();
|
|
7143
|
+
subpaths.push({ closed: selector === 0, operation: body.i16(), knots: [] });
|
|
7144
|
+
} else if (selector === 1 || selector === 2 || selector === 4 || selector === 5) {
|
|
7145
|
+
const closed = selector <= 2;
|
|
7146
|
+
const last = subpaths[subpaths.length - 1];
|
|
7147
|
+
if (remaining === 0 && (!last || last.closed !== closed)) subpaths.push({ closed, operation: -1, knots: [] });
|
|
7148
|
+
remaining = Math.max(0, remaining - 1);
|
|
7149
|
+
const pt = () => {
|
|
7150
|
+
const y = fixed(body.i32());
|
|
7151
|
+
const x = fixed(body.i32());
|
|
7152
|
+
return { x, y };
|
|
7153
|
+
};
|
|
7154
|
+
const pre = pt();
|
|
7155
|
+
const anchor = pt();
|
|
7156
|
+
const post = pt();
|
|
7157
|
+
subpaths[subpaths.length - 1].knots.push({ linked: selector === 1 || selector === 4, pre, anchor, post });
|
|
7158
|
+
} else if (selector === 8) {
|
|
7159
|
+
initialFill = body.u16() !== 0;
|
|
7160
|
+
}
|
|
7161
|
+
}
|
|
7162
|
+
return { subpaths, initialFill };
|
|
7163
|
+
}
|
|
7164
|
+
function writePathRecords(path) {
|
|
7165
|
+
const w = new PsdWriter();
|
|
7166
|
+
w.u16(6);
|
|
7167
|
+
w.zeros(24);
|
|
7168
|
+
w.u16(8);
|
|
7169
|
+
w.u16(path.initialFill ? 1 : 0);
|
|
7170
|
+
w.zeros(22);
|
|
7171
|
+
for (const s of path.subpaths) {
|
|
7172
|
+
w.u16(s.closed ? 0 : 3);
|
|
7173
|
+
w.u16(Math.min(s.knots.length, 65535));
|
|
7174
|
+
w.i16(s.operation);
|
|
7175
|
+
w.u16(1);
|
|
7176
|
+
w.zeros(18);
|
|
7177
|
+
for (const k of s.knots.slice(0, 65535)) {
|
|
7178
|
+
w.u16(s.closed ? k.linked ? 1 : 2 : k.linked ? 4 : 5);
|
|
7179
|
+
for (const p of [k.pre, k.anchor, k.post]) {
|
|
7180
|
+
w.i32(toFixed(p.y));
|
|
7181
|
+
w.i32(toFixed(p.x));
|
|
7182
|
+
}
|
|
7183
|
+
}
|
|
7184
|
+
}
|
|
7185
|
+
return w.result();
|
|
7186
|
+
}
|
|
7187
|
+
var VMSK_INVERT = 1;
|
|
7188
|
+
function readVectorBlock(data) {
|
|
7189
|
+
if (data.length < 8) return null;
|
|
7190
|
+
const r = new PsdReader(data);
|
|
7191
|
+
const version = r.u32();
|
|
7192
|
+
const flags = r.u32();
|
|
7193
|
+
return { version, flags, path: readPathRecords(data.subarray(8)) };
|
|
7194
|
+
}
|
|
7195
|
+
function writeVectorBlock(path, flags = 0) {
|
|
7196
|
+
const body = writePathRecords(path);
|
|
7197
|
+
const w = new PsdWriter();
|
|
7198
|
+
w.u32(3);
|
|
7199
|
+
w.u32(flags);
|
|
7200
|
+
w.bytes(body);
|
|
7201
|
+
return w.result();
|
|
7202
|
+
}
|
|
7203
|
+
var OP_TO_PSD = { combine: 1, subtract: 2, intersect: 3, exclude: 0 };
|
|
7204
|
+
var OP_FROM_PSD = (v) => v === 0 ? "exclude" : v === 2 ? "subtract" : v === 3 ? "intersect" : "combine";
|
|
7205
|
+
function componentsFromVectorBlock(data, width, height) {
|
|
7206
|
+
const block = readVectorBlock(data);
|
|
7207
|
+
if (!block) return null;
|
|
7208
|
+
const pt = (p) => ({ x: p.x * width, y: p.y * height });
|
|
7209
|
+
const comps = [];
|
|
7210
|
+
for (const s of block.path.subpaths) {
|
|
7211
|
+
if (!s.knots.length) continue;
|
|
7212
|
+
const anchors = s.knots.map((k) => {
|
|
7213
|
+
const a = pt(k.anchor);
|
|
7214
|
+
const pre = pt(k.pre);
|
|
7215
|
+
const post = pt(k.post);
|
|
7216
|
+
const out = { x: a.x, y: a.y };
|
|
7217
|
+
if (pre.x !== a.x || pre.y !== a.y) out.in = pre;
|
|
7218
|
+
if (post.x !== a.x || post.y !== a.y) out.out = post;
|
|
7219
|
+
if (k.linked && (out.in || out.out)) out.type = "smooth";
|
|
7220
|
+
return out;
|
|
7221
|
+
});
|
|
7222
|
+
const sp = { closed: s.closed, anchors };
|
|
7223
|
+
if (s.operation === -1 && comps.length) comps[comps.length - 1].subpaths.push(sp);
|
|
7224
|
+
else comps.push({ op: s.operation, subpaths: [sp] });
|
|
7225
|
+
}
|
|
7226
|
+
let inverted = comps.length ? comps[0].op === 2 : block.path.initialFill;
|
|
7227
|
+
const components = comps.map((c, i) => {
|
|
7228
|
+
let op = i === 0 ? "combine" : OP_FROM_PSD(c.op);
|
|
7229
|
+
if (inverted && i > 0) op = op === "combine" ? "subtract" : op === "subtract" ? "combine" : op;
|
|
7230
|
+
return { op, subpaths: c.subpaths };
|
|
7231
|
+
});
|
|
7232
|
+
if (block.flags & VMSK_INVERT) inverted = !inverted;
|
|
7233
|
+
return { components, inverted, flags: block.flags };
|
|
7234
|
+
}
|
|
7235
|
+
function vectorBlockForComponents(components, inverted, width, height, flags = 0) {
|
|
7236
|
+
const w = Math.max(1, width);
|
|
7237
|
+
const h = Math.max(1, height);
|
|
7238
|
+
const fr = (p) => ({ x: p.x / w, y: p.y / h });
|
|
7239
|
+
const subpaths = [];
|
|
7240
|
+
components.forEach((c, ci) => {
|
|
7241
|
+
_chunkW3GXSUSQcjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
|
|
7242
|
+
if (!sp.anchors.length) return;
|
|
7243
|
+
subpaths.push({
|
|
7244
|
+
closed: sp.closed,
|
|
7245
|
+
operation: si > 0 ? -1 : ci === 0 ? 1 : OP_TO_PSD[c.op],
|
|
7246
|
+
knots: sp.anchors.map((a) => ({
|
|
7247
|
+
linked: a.type === "smooth" || a.type === "symmetric",
|
|
7248
|
+
pre: fr(_nullishCoalesce(a.in, () => ( a))),
|
|
7249
|
+
anchor: fr(a),
|
|
7250
|
+
post: fr(_nullishCoalesce(a.out, () => ( a)))
|
|
7251
|
+
}))
|
|
7252
|
+
});
|
|
7253
|
+
});
|
|
7254
|
+
});
|
|
7255
|
+
return writeVectorBlock({ subpaths, initialFill: subpaths.length === 0 && inverted }, flags & ~VMSK_INVERT | (inverted && subpaths.length ? VMSK_INVERT : 0));
|
|
7256
|
+
}
|
|
7257
|
+
|
|
7258
|
+
// src/image-editor/psd/shapes.ts
|
|
7259
|
+
var SHAPE_PSD_KEYS = ["vsms", "vmsk", "vscg", "vstk", "vogk", "SoCo", "GdFl", "PtFl"];
|
|
7275
7260
|
var unit = (u, value) => ({ type: "UntF", unit: u, value });
|
|
7261
|
+
var dbl = (value) => ({ type: "doub", value });
|
|
7276
7262
|
var long2 = (value) => ({ type: "long", value: Math.round(value) });
|
|
7277
7263
|
var boolV = (value) => ({ type: "bool", value });
|
|
7278
7264
|
var enumV = (typeId, value) => ({ type: "enum", typeId, value });
|
|
7279
|
-
var textV = (value) => ({ type: "TEXT", value });
|
|
7280
7265
|
var obj = (d) => ({ type: "Objc", value: d });
|
|
7281
|
-
var text = (d, key) => {
|
|
7282
|
-
const v = descGet(d, key);
|
|
7283
|
-
return _optionalChain([v, 'optionalAccess', _174 => _174.type]) === "TEXT" ? v.value : void 0;
|
|
7284
|
-
};
|
|
7285
7266
|
var enumOf = (d, key) => {
|
|
7286
7267
|
const v = descGet(d, key);
|
|
7287
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7268
|
+
return _optionalChain([v, 'optionalAccess', _174 => _174.type]) === "enum" ? v.value : void 0;
|
|
7288
7269
|
};
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
|
|
7295
|
-
else return null;
|
|
7270
|
+
function read(data) {
|
|
7271
|
+
try {
|
|
7272
|
+
return parseVersionedDescriptor(data);
|
|
7273
|
+
} catch (e13) {
|
|
7274
|
+
return null;
|
|
7296
7275
|
}
|
|
7297
|
-
return out;
|
|
7298
|
-
};
|
|
7299
|
-
function setItem(d, key, v) {
|
|
7300
|
-
const i = d.items.findIndex(([k]) => k === key);
|
|
7301
|
-
if (i >= 0) d.items[i] = [key, v];
|
|
7302
|
-
else d.items.push([key, v]);
|
|
7303
|
-
}
|
|
7304
|
-
function cloneDescriptor(d) {
|
|
7305
|
-
return parseVersionedDescriptor(versionedDescriptorBytes(d));
|
|
7306
7276
|
}
|
|
7307
|
-
function
|
|
7308
|
-
if (
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
hex += h.toString(16).padStart(8, "0");
|
|
7277
|
+
function px(v, dpi) {
|
|
7278
|
+
if (!v) return void 0;
|
|
7279
|
+
if (v.type === "UntF") {
|
|
7280
|
+
if (v.unit === "#Pnt") return v.value * dpi / 72;
|
|
7281
|
+
if (v.unit === "#Mlm") return v.value * dpi / 25.4;
|
|
7282
|
+
return v.value;
|
|
7314
7283
|
}
|
|
7315
|
-
|
|
7284
|
+
if (v.type === "doub" || v.type === "long") return v.value;
|
|
7285
|
+
return void 0;
|
|
7316
7286
|
}
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
if (kind === "liFD") return { kind, uuid, name, fileType, bytes: r.bytes(Math.min(len, r.remaining)) };
|
|
7330
|
-
let path;
|
|
7331
|
-
if (kind === "liFE") {
|
|
7332
|
-
try {
|
|
7333
|
-
const d = readVersionedDescriptor(r);
|
|
7334
|
-
path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
|
|
7335
|
-
} catch (e13) {
|
|
7336
|
-
path = void 0;
|
|
7337
|
-
}
|
|
7338
|
-
void version;
|
|
7287
|
+
function paintFromContent(key, d, notes) {
|
|
7288
|
+
if (key === "SoCo") return { type: "color", color: colorOf(descObject(d, "Clr ")) };
|
|
7289
|
+
if (key === "GdFl") return { type: "gradient", gradient: gradientOf(d, notes) };
|
|
7290
|
+
if (key === "PtFl") {
|
|
7291
|
+
const ref = patternRefOf(d);
|
|
7292
|
+
const place = placementOf(d);
|
|
7293
|
+
const scale = (_nullishCoalesce(descNumber(d, "Scl "), () => ( 100))) / 100;
|
|
7294
|
+
const p = { type: "pattern", patternId: ref.patternId, name: ref.name, scale: Math.max(0.01, Math.min(10, scale)) };
|
|
7295
|
+
if (place.angle) p.angle = place.angle;
|
|
7296
|
+
if (!place.link) p.link = false;
|
|
7297
|
+
if (place.phase.x || place.phase.y) p.phase = place.phase;
|
|
7298
|
+
return p;
|
|
7339
7299
|
}
|
|
7340
|
-
return
|
|
7300
|
+
return null;
|
|
7341
7301
|
}
|
|
7342
|
-
function
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7302
|
+
function contentOfPaint(p) {
|
|
7303
|
+
if (p.type === "color") return { key: "SoCo", desc: descriptor("null", [["Clr ", obj(colorDesc(p.color))]]) };
|
|
7304
|
+
if (p.type === "gradient") return { key: "GdFl", desc: descriptor("null", gradientItems(p.gradient)) };
|
|
7305
|
+
return {
|
|
7306
|
+
key: "PtFl",
|
|
7307
|
+
desc: descriptor("null", [["Ptrn", patternRefDesc(p.patternId, p.name)], ["Scl ", unit("#Prc", p.scale * 100)], ...placementItems(_nullishCoalesce(p.angle, () => ( 0)), _nullishCoalesce(p.link, () => ( true)), _nullishCoalesce(p.phase, () => ( { x: 0, y: 0 })))])
|
|
7308
|
+
};
|
|
7309
|
+
}
|
|
7310
|
+
function paintFromVscg(data, notes) {
|
|
7311
|
+
if (data.length < 8) return null;
|
|
7312
|
+
const key = String.fromCharCode(...data.subarray(0, 4));
|
|
7313
|
+
const d = read(data.subarray(4));
|
|
7314
|
+
return d ? paintFromContent(key, d, notes) : null;
|
|
7315
|
+
}
|
|
7316
|
+
function vscgBytes(p) {
|
|
7317
|
+
const { key, desc } = contentOfPaint(p);
|
|
7318
|
+
const body = versionedDescriptorBytes(desc);
|
|
7319
|
+
const out = new Uint8Array(4 + body.length);
|
|
7320
|
+
for (let i = 0; i < 4; i++) out[i] = key.charCodeAt(i);
|
|
7321
|
+
out.set(body, 4);
|
|
7322
|
+
return out;
|
|
7323
|
+
}
|
|
7324
|
+
function classOfContent(d) {
|
|
7325
|
+
if (d.classId === "solidColorLayer" || descGet(d, "Clr ")) return "SoCo";
|
|
7326
|
+
if (d.classId === "gradientLayer" || descGet(d, "Grad")) return "GdFl";
|
|
7327
|
+
return "PtFl";
|
|
7328
|
+
}
|
|
7329
|
+
function strokeFromVstk(data, dpi, notes) {
|
|
7330
|
+
const d = read(data);
|
|
7331
|
+
if (!d) return null;
|
|
7332
|
+
const fillEnabled = descBool(d, "fillEnabled") !== false;
|
|
7333
|
+
if (descBool(d, "strokeEnabled") !== true) return { stroke: null, fillEnabled };
|
|
7334
|
+
const content = descObject(d, "strokeStyleContent");
|
|
7335
|
+
const paint = _nullishCoalesce((content ? paintFromContent(classOfContent(content), content, notes) : null), () => ( { type: "color", color: "#000000" }));
|
|
7336
|
+
const opacity = (_nullishCoalesce(descNumber(d, "strokeStyleOpacity"), () => ( 100))) / 100;
|
|
7337
|
+
const stroke = { width: _nullishCoalesce(px(descGet(d, "strokeStyleLineWidth"), dpi), () => ( 1)), paint: opacity < 1 ? { ...paint, opacity } : paint };
|
|
7338
|
+
const cap = enumOf(d, "strokeStyleLineCapType");
|
|
7339
|
+
if (cap === "strokeStyleRoundCap") stroke.cap = "round";
|
|
7340
|
+
else if (cap === "strokeStyleSquareCap") stroke.cap = "square";
|
|
7341
|
+
const join = enumOf(d, "strokeStyleLineJoinType");
|
|
7342
|
+
if (join === "strokeStyleRoundJoin") stroke.join = "round";
|
|
7343
|
+
else if (join === "strokeStyleBevelJoin") stroke.join = "bevel";
|
|
7344
|
+
const align = enumOf(d, "strokeStyleLineAlignment");
|
|
7345
|
+
if (align === "strokeStyleAlignInside") stroke.align = "inside";
|
|
7346
|
+
else if (align === "strokeStyleAlignOutside") stroke.align = "outside";
|
|
7347
|
+
const miter = descNumber(d, "strokeStyleMiterLimit");
|
|
7348
|
+
if (miter !== void 0 && miter !== 100) stroke.miterLimit = Math.max(1, Math.min(500, miter));
|
|
7349
|
+
const dashes = descGet(d, "strokeStyleLineDashSet");
|
|
7350
|
+
if (_optionalChain([dashes, 'optionalAccess', _175 => _175.type]) === "VlLs") {
|
|
7351
|
+
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);
|
|
7352
|
+
if (list2.length && list2.some((v) => v > 0)) stroke.dashes = list2;
|
|
7353
|
+
}
|
|
7354
|
+
const offset = descNumber(d, "strokeStyleLineDashOffset");
|
|
7355
|
+
if (offset) stroke.dashOffset = offset;
|
|
7356
|
+
if (enumOf(d, "strokeStyleBlendMode") && enumOf(d, "strokeStyleBlendMode") !== "Nrml" && enumOf(d, "strokeStyleBlendMode") !== "normal") notes.add("a shape stroke blend mode other than Normal became Normal");
|
|
7357
|
+
return { stroke, fillEnabled };
|
|
7358
|
+
}
|
|
7359
|
+
function vstkBytes(stroke, fillEnabled, dpi) {
|
|
7360
|
+
const s = _nullishCoalesce(stroke, () => ( { width: 3, paint: { type: "color", color: "#000000" } }));
|
|
7361
|
+
const { key, desc } = contentOfPaint(s.paint);
|
|
7362
|
+
const content = { ...desc, classId: key === "SoCo" ? "solidColorLayer" : key === "GdFl" ? "gradientLayer" : "patternLayer" };
|
|
7363
|
+
const d = descriptor("strokeStyle", [
|
|
7364
|
+
["strokeStyleVersion", long2(2)],
|
|
7365
|
+
["strokeEnabled", boolV(Boolean(stroke))],
|
|
7366
|
+
["fillEnabled", boolV(fillEnabled)],
|
|
7367
|
+
["strokeStyleLineWidth", unit("#Pxl", s.width)],
|
|
7368
|
+
["strokeStyleLineDashOffset", unit("#Pnt", _nullishCoalesce(s.dashOffset, () => ( 0)))],
|
|
7369
|
+
["strokeStyleMiterLimit", dbl(_nullishCoalesce(s.miterLimit, () => ( 100)))],
|
|
7370
|
+
["strokeStyleLineCapType", enumV("strokeStyleLineCapType", s.cap === "round" ? "strokeStyleRoundCap" : s.cap === "square" ? "strokeStyleSquareCap" : "strokeStyleButtCap")],
|
|
7371
|
+
["strokeStyleLineJoinType", enumV("strokeStyleLineJoinType", s.join === "round" ? "strokeStyleRoundJoin" : s.join === "bevel" ? "strokeStyleBevelJoin" : "strokeStyleMiterJoin")],
|
|
7372
|
+
["strokeStyleLineAlignment", enumV("strokeStyleLineAlignment", s.align === "inside" ? "strokeStyleAlignInside" : s.align === "outside" ? "strokeStyleAlignOutside" : "strokeStyleAlignCenter")],
|
|
7373
|
+
["strokeStyleScaleLock", boolV(false)],
|
|
7374
|
+
["strokeStyleStrokeAdjust", boolV(false)],
|
|
7375
|
+
["strokeStyleLineDashSet", { type: "VlLs", items: (_nullishCoalesce(s.dashes, () => ( []))).map((v) => unit("#Nne", v)) }],
|
|
7376
|
+
["strokeStyleBlendMode", enumV("BlnM", "Nrml")],
|
|
7377
|
+
["strokeStyleOpacity", unit("#Prc", (_nullishCoalesce(s.paint.opacity, () => ( 1))) * 100)],
|
|
7378
|
+
["strokeStyleContent", obj(content)],
|
|
7379
|
+
["strokeStyleResolution", dbl(dpi)]
|
|
7380
|
+
]);
|
|
7381
|
+
return versionedDescriptorBytes(d);
|
|
7382
|
+
}
|
|
7383
|
+
function rectOf(o) {
|
|
7384
|
+
const b = descObject(o, "keyOriginShapeBBox");
|
|
7385
|
+
if (!b) return null;
|
|
7386
|
+
const t = descNumber(b, "Top ");
|
|
7387
|
+
const l = descNumber(b, "Left");
|
|
7388
|
+
const bt = descNumber(b, "Btom");
|
|
7389
|
+
const r = descNumber(b, "Rght");
|
|
7390
|
+
if ([t, l, bt, r].some((v) => v === void 0 || !Number.isFinite(v))) return null;
|
|
7391
|
+
return { x: l, y: t, width: r - l, height: bt - t };
|
|
7392
|
+
}
|
|
7393
|
+
function pointOf(o, key) {
|
|
7394
|
+
const p = descObject(o, key);
|
|
7395
|
+
const x = p && descNumber(p, "Hrzn");
|
|
7396
|
+
const y = p && descNumber(p, "Vrtc");
|
|
7397
|
+
return x !== void 0 && y !== void 0 && Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
|
|
7398
|
+
}
|
|
7399
|
+
function liveShapesFromVogk(data) {
|
|
7400
|
+
const out = /* @__PURE__ */ new Map();
|
|
7401
|
+
if (data.length < 8) return out;
|
|
7402
|
+
const d = read(data.subarray(4));
|
|
7403
|
+
const list2 = d && descGet(d, "keyDescriptorList");
|
|
7404
|
+
if (!list2 || list2.type !== "VlLs") return out;
|
|
7405
|
+
list2.items.forEach((item, i) => {
|
|
7406
|
+
if (item.type !== "Objc") return;
|
|
7407
|
+
const o = item.value;
|
|
7408
|
+
if (descBool(o, "keyShapeInvalidated") === true) return;
|
|
7409
|
+
const index = _nullishCoalesce(descNumber(o, "keyOriginIndex"), () => ( i));
|
|
7410
|
+
let transform;
|
|
7411
|
+
const t = descObject(o, "Trnf");
|
|
7412
|
+
if (t) {
|
|
7413
|
+
const g = (k, dv) => _nullishCoalesce(descNumber(t, k), () => ( dv));
|
|
7414
|
+
const m = [g("xx", 1), g("xy", 0), g("yx", 0), g("yy", 1), g("tx", 0), g("ty", 0)];
|
|
7415
|
+
if (!(m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0)) transform = m;
|
|
7416
|
+
}
|
|
7417
|
+
const tt = transform ? { transform } : {};
|
|
7418
|
+
const type = descNumber(o, "keyOriginType");
|
|
7419
|
+
let live = null;
|
|
7420
|
+
const r = rectOf(o);
|
|
7421
|
+
if ((type === 1 || type === 2) && r) {
|
|
7422
|
+
const rr = type === 2 ? descObject(o, "keyOriginRRectRadii") : void 0;
|
|
7423
|
+
const g = (k) => rr ? _nullishCoalesce(descNumber(rr, k), () => ( 0)) : 0;
|
|
7424
|
+
const radii = [g("topLeft"), g("topRight"), g("bottomRight"), g("bottomLeft")];
|
|
7425
|
+
live = { kind: "rect", ...r, ...radii.some((v) => v > 0) ? { radii } : {}, ...tt };
|
|
7426
|
+
} else if (type === 5 && r) live = { kind: "ellipse", ...r, ...tt };
|
|
7427
|
+
else if (type === 4) {
|
|
7428
|
+
const a = pointOf(o, "keyOriginLineStart");
|
|
7429
|
+
const b = pointOf(o, "keyOriginLineEnd");
|
|
7430
|
+
if (a && b) {
|
|
7431
|
+
const weight = _nullishCoalesce(descNumber(o, "keyOriginLineWeight"), () => ( 1));
|
|
7432
|
+
const line = { kind: "line", x1: a.x, y1: a.y, x2: b.x, y2: b.y, weight, ...tt };
|
|
7433
|
+
const head = () => {
|
|
7434
|
+
const w = (_nullishCoalesce(descNumber(o, "keyOriginLineArrWdth"), () => ( 500))) / 100 * weight;
|
|
7435
|
+
const l = (_nullishCoalesce(descNumber(o, "keyOriginLineArrLngth"), () => ( 1e3))) / 100 * weight;
|
|
7436
|
+
const c = (_nullishCoalesce(descNumber(o, "keyOriginLineArrConc"), () => ( 0))) / 100;
|
|
7437
|
+
return c ? { width: w, length: l, concavity: Math.max(-0.5, Math.min(0.5, c)) } : { width: w, length: l };
|
|
7438
|
+
};
|
|
7439
|
+
if (descBool(o, "keyOriginLineArrowSt") === true) line.startArrow = head();
|
|
7440
|
+
if (descBool(o, "keyOriginLineArrowEnd") === true) line.endArrow = head();
|
|
7441
|
+
live = line;
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7444
|
+
if (live) out.set(index, live);
|
|
7445
|
+
});
|
|
7446
|
+
return out;
|
|
7447
|
+
}
|
|
7448
|
+
function vogkBytes(components, dpi) {
|
|
7449
|
+
const bbox = (r) => obj(
|
|
7450
|
+
descriptor("unitRect", [
|
|
7451
|
+
["unitValueQuadVersion", long2(1)],
|
|
7452
|
+
["Top ", unit("#Pxl", r.y)],
|
|
7453
|
+
["Left", unit("#Pxl", r.x)],
|
|
7454
|
+
["Btom", unit("#Pxl", r.y + r.height)],
|
|
7455
|
+
["Rght", unit("#Pxl", r.x + r.width)]
|
|
7456
|
+
])
|
|
7457
|
+
);
|
|
7458
|
+
const items = [];
|
|
7459
|
+
components.forEach((c, index) => {
|
|
7460
|
+
const live = c.live;
|
|
7461
|
+
if (!live || live.kind === "polygon" || live.kind === "star") return;
|
|
7462
|
+
const base = (type) => [
|
|
7463
|
+
["keyOriginType", long2(type)],
|
|
7464
|
+
["keyOriginResolution", dbl(dpi)]
|
|
7465
|
+
];
|
|
7466
|
+
let o;
|
|
7467
|
+
if (live.kind === "rect") {
|
|
7468
|
+
const radii = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
|
|
7469
|
+
if (radii.every((v) => v === 0)) o = [...base(1), ["keyOriginShapeBBox", bbox(live)]];
|
|
7470
|
+
else
|
|
7471
|
+
o = [
|
|
7472
|
+
...base(2),
|
|
7473
|
+
[
|
|
7474
|
+
"keyOriginRRectRadii",
|
|
7475
|
+
obj(
|
|
7476
|
+
descriptor("radii", [
|
|
7477
|
+
["unitValueQuadVersion", long2(1)],
|
|
7478
|
+
["topRight", unit("#Pxl", radii[1])],
|
|
7479
|
+
["topLeft", unit("#Pxl", radii[0])],
|
|
7480
|
+
["bottomLeft", unit("#Pxl", radii[3])],
|
|
7481
|
+
["bottomRight", unit("#Pxl", radii[2])]
|
|
7482
|
+
])
|
|
7483
|
+
)
|
|
7484
|
+
],
|
|
7485
|
+
["keyOriginShapeBBox", bbox(live)]
|
|
7486
|
+
];
|
|
7487
|
+
} else if (live.kind === "ellipse") o = [...base(5), ["keyOriginShapeBBox", bbox(live)]];
|
|
7488
|
+
else {
|
|
7489
|
+
const pnt = (x, y) => obj(descriptor("Pnt ", [["Hrzn", dbl(x)], ["Vrtc", dbl(y)]]));
|
|
7490
|
+
const head = _nullishCoalesce(live.endArrow, () => ( live.startArrow));
|
|
7491
|
+
const w = live.weight || 1;
|
|
7492
|
+
o = [
|
|
7493
|
+
...base(4),
|
|
7494
|
+
["keyOriginShapeBBox", bbox({ x: Math.min(live.x1, live.x2), y: Math.min(live.y1, live.y2), width: Math.abs(live.x2 - live.x1), height: Math.abs(live.y2 - live.y1) })],
|
|
7495
|
+
["keyOriginLineEnd", pnt(live.x2, live.y2)],
|
|
7496
|
+
["keyOriginLineStart", pnt(live.x1, live.y1)],
|
|
7497
|
+
["keyOriginLineWeight", dbl(live.weight)],
|
|
7498
|
+
["keyOriginLineArrowSt", boolV(Boolean(live.startArrow))],
|
|
7499
|
+
["keyOriginLineArrowEnd", boolV(Boolean(live.endArrow))],
|
|
7500
|
+
["keyOriginLineArrWdth", dbl(head ? head.width / w * 100 : 0)],
|
|
7501
|
+
["keyOriginLineArrLngth", dbl(head ? head.length / w * 100 : 0)],
|
|
7502
|
+
["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _176 => _176.concavity]) ? head.concavity * 100 : 0)]
|
|
7503
|
+
];
|
|
7504
|
+
}
|
|
7505
|
+
const m = live.transform;
|
|
7506
|
+
if (m) {
|
|
7507
|
+
o.push([
|
|
7508
|
+
"Trnf",
|
|
7509
|
+
obj(
|
|
7510
|
+
descriptor("Trnf", [
|
|
7511
|
+
["xx", dbl(m[0])],
|
|
7512
|
+
["xy", dbl(m[1])],
|
|
7513
|
+
["yx", dbl(m[2])],
|
|
7514
|
+
["yy", dbl(m[3])],
|
|
7515
|
+
["tx", dbl(m[4])],
|
|
7516
|
+
["ty", dbl(m[5])]
|
|
7517
|
+
])
|
|
7518
|
+
)
|
|
7519
|
+
]);
|
|
7520
|
+
}
|
|
7521
|
+
o.push(["keyOriginIndex", long2(index)]);
|
|
7522
|
+
items.push(obj(descriptor("null", o)));
|
|
7523
|
+
});
|
|
7524
|
+
if (!items.length) return null;
|
|
7525
|
+
const body = versionedDescriptorBytes(descriptor("null", [["keyDescriptorList", { type: "VlLs", items }]]));
|
|
7526
|
+
const out = new Uint8Array(4 + body.length);
|
|
7527
|
+
new DataView(out.buffer).setUint32(0, 1);
|
|
7528
|
+
out.set(body, 4);
|
|
7529
|
+
return out;
|
|
7530
|
+
}
|
|
7531
|
+
function shapeSignature(layer) {
|
|
7532
|
+
return JSON.stringify([layer.components, layer.fill, layer.stroke, _nullishCoalesce(layer.fillRule, () => ( "nonzero")), Boolean(layer.inverted)]);
|
|
7533
|
+
}
|
|
7534
|
+
function shapeFromBlocks(blocks, width, height, dpi, notes) {
|
|
7535
|
+
const block = (k) => _optionalChain([blocks, 'access', _177 => _177.find, 'call', _178 => _178((b) => b.key === k), 'optionalAccess', _179 => _179.data]);
|
|
7536
|
+
const vector = _nullishCoalesce(block("vsms"), () => ( block("vmsk")));
|
|
7537
|
+
const path = vector ? componentsFromVectorBlock(vector, width, height) : null;
|
|
7538
|
+
if (!path) return null;
|
|
7539
|
+
let fill = null;
|
|
7540
|
+
const vscg = block("vscg");
|
|
7541
|
+
if (vscg) fill = paintFromVscg(vscg, notes);
|
|
7542
|
+
for (const key of ["SoCo", "GdFl", "PtFl"]) {
|
|
7543
|
+
if (fill) break;
|
|
7544
|
+
const data = block(key);
|
|
7545
|
+
const d = data && (() => {
|
|
7546
|
+
try {
|
|
7547
|
+
return parseVersionedDescriptor(data);
|
|
7548
|
+
} catch (e14) {
|
|
7549
|
+
return null;
|
|
7550
|
+
}
|
|
7551
|
+
})();
|
|
7552
|
+
if (d) fill = paintFromContent(key, d, notes);
|
|
7553
|
+
}
|
|
7554
|
+
let stroke = null;
|
|
7555
|
+
const vstk = block("vstk");
|
|
7556
|
+
if (vstk) {
|
|
7557
|
+
const s = strokeFromVstk(vstk, dpi, notes);
|
|
7558
|
+
if (s) {
|
|
7559
|
+
stroke = s.stroke;
|
|
7560
|
+
if (!s.fillEnabled) fill = null;
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
const vogk = block("vogk");
|
|
7564
|
+
const live = vogk ? liveShapesFromVogk(vogk) : /* @__PURE__ */ new Map();
|
|
7565
|
+
const components = path.components.map((c, i) => {
|
|
7566
|
+
const l = live.get(i);
|
|
7567
|
+
return l && sameExtent(liveShapeSubpaths(l), c) ? { ...c, live: l } : c;
|
|
7568
|
+
});
|
|
7569
|
+
return { components, inverted: path.inverted, fill, stroke };
|
|
7570
|
+
}
|
|
7571
|
+
function sameExtent(sub, c) {
|
|
7572
|
+
const ext = (list2) => {
|
|
7573
|
+
let x0 = Infinity;
|
|
7574
|
+
let y0 = Infinity;
|
|
7575
|
+
let x1 = -Infinity;
|
|
7576
|
+
let y1 = -Infinity;
|
|
7577
|
+
for (const sp of list2) for (const a2 of sp.anchors) {
|
|
7578
|
+
x0 = Math.min(x0, a2.x);
|
|
7579
|
+
y0 = Math.min(y0, a2.y);
|
|
7580
|
+
x1 = Math.max(x1, a2.x);
|
|
7581
|
+
y1 = Math.max(y1, a2.y);
|
|
7582
|
+
}
|
|
7583
|
+
return [x0, y0, x1, y1];
|
|
7584
|
+
};
|
|
7585
|
+
const a = ext(sub);
|
|
7586
|
+
const b = ext(c.subpaths);
|
|
7587
|
+
return a.every((v, i) => Math.abs(v - b[i]) < 1);
|
|
7588
|
+
}
|
|
7589
|
+
function shapeBlocks(layer, width, height, dpi, notes) {
|
|
7590
|
+
const kept = _optionalChain([layer, 'access', _180 => _180.psd, 'optionalAccess', _181 => _181.blocks]);
|
|
7591
|
+
if (_optionalChain([kept, 'optionalAccess', _182 => _182.length]) && _optionalChain([layer, 'access', _183 => _183.psd, 'optionalAccess', _184 => _184.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
|
|
7592
|
+
const out = [];
|
|
7593
|
+
out.push({ key: "vsms", data: vectorBlockForComponents(layer.components, Boolean(layer.inverted), width, height) });
|
|
7594
|
+
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)");
|
|
7595
|
+
const fill = _nullishCoalesce(layer.fill, () => ( { type: "color", color: "#000000" }));
|
|
7596
|
+
if (_optionalChain([layer, 'access', _185 => _185.fill, 'optionalAccess', _186 => _186.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)");
|
|
7597
|
+
out.push({ key: "vscg", data: vscgBytes(fill) });
|
|
7598
|
+
if (layer.stroke || !layer.fill) out.push({ key: "vstk", data: vstkBytes(layer.stroke, Boolean(layer.fill), dpi) });
|
|
7599
|
+
const vogk = vogkBytes(layer.components, dpi);
|
|
7600
|
+
if (vogk) out.push({ key: "vogk", data: vogk });
|
|
7601
|
+
if (layer.components.some((c) => _optionalChain([c, 'access', _187 => _187.live, 'optionalAccess', _188 => _188.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
|
|
7602
|
+
notes.add("Lines with different start and end arrowheads were written with one arrowhead size (Photoshop has one)");
|
|
7603
|
+
}
|
|
7604
|
+
return out;
|
|
7605
|
+
}
|
|
7606
|
+
|
|
7607
|
+
// src/image-editor/psd/engine-data.ts
|
|
7608
|
+
var EngineDataError = class extends Error {
|
|
7609
|
+
constructor(message) {
|
|
7610
|
+
super(`EngineData: ${message}`);
|
|
7611
|
+
this.name = "EngineDataError";
|
|
7612
|
+
}
|
|
7613
|
+
};
|
|
7614
|
+
var MAX_DEPTH2 = 64;
|
|
7615
|
+
var isWs = (c) => c === 32 || c === 9 || c === 13 || c === 10 || c === 0;
|
|
7616
|
+
var isDelim = (c) => isWs(c) || c === 91 || c === 93 || c === 60 || c === 62 || c === 40 || c === 47;
|
|
7617
|
+
function parseEngineData(b) {
|
|
7618
|
+
let i = 0;
|
|
7619
|
+
const ws = () => {
|
|
7620
|
+
while (i < b.length && isWs(b[i])) i++;
|
|
7621
|
+
};
|
|
7622
|
+
const name = () => {
|
|
7623
|
+
i++;
|
|
7624
|
+
const start = i;
|
|
7625
|
+
while (i < b.length && !isDelim(b[i])) i++;
|
|
7626
|
+
let s = "";
|
|
7627
|
+
for (let k = start; k < i; k++) s += String.fromCharCode(b[k]);
|
|
7628
|
+
return s;
|
|
7629
|
+
};
|
|
7630
|
+
const value = (depth) => {
|
|
7631
|
+
if (depth > MAX_DEPTH2) throw new EngineDataError("nesting too deep");
|
|
7632
|
+
ws();
|
|
7633
|
+
if (i >= b.length) throw new EngineDataError("unexpected end");
|
|
7634
|
+
const c = b[i];
|
|
7635
|
+
if (c === 60 && b[i + 1] === 60) {
|
|
7636
|
+
i += 2;
|
|
7637
|
+
const items = [];
|
|
7638
|
+
for (; ; ) {
|
|
7639
|
+
ws();
|
|
7640
|
+
if (b[i] === 62 && b[i + 1] === 62) {
|
|
7641
|
+
i += 2;
|
|
7642
|
+
return { t: "dict", items };
|
|
7643
|
+
}
|
|
7644
|
+
if (b[i] !== 47) throw new EngineDataError(i >= b.length ? "unterminated dictionary" : `expected a key at byte ${i}`);
|
|
7645
|
+
const k = name();
|
|
7646
|
+
items.push([k, value(depth + 1)]);
|
|
7647
|
+
}
|
|
7648
|
+
}
|
|
7649
|
+
if (c === 91) {
|
|
7650
|
+
i++;
|
|
7651
|
+
const items = [];
|
|
7652
|
+
for (; ; ) {
|
|
7653
|
+
ws();
|
|
7654
|
+
if (i >= b.length) throw new EngineDataError("unterminated array");
|
|
7655
|
+
if (b[i] === 93) {
|
|
7656
|
+
i++;
|
|
7657
|
+
return { t: "array", items };
|
|
7658
|
+
}
|
|
7659
|
+
items.push(value(depth + 1));
|
|
7660
|
+
}
|
|
7661
|
+
}
|
|
7662
|
+
if (c === 40) {
|
|
7663
|
+
i++;
|
|
7664
|
+
const raw = [];
|
|
7665
|
+
for (; ; ) {
|
|
7666
|
+
if (i >= b.length) throw new EngineDataError("unterminated string");
|
|
7667
|
+
const x = b[i];
|
|
7668
|
+
if (x === 92) {
|
|
7669
|
+
if (i + 1 < b.length) raw.push(b[i + 1]);
|
|
7670
|
+
i += 2;
|
|
7671
|
+
} else if (x === 41) {
|
|
7672
|
+
i++;
|
|
7673
|
+
break;
|
|
7674
|
+
} else {
|
|
7675
|
+
raw.push(x);
|
|
7676
|
+
i++;
|
|
7677
|
+
}
|
|
7678
|
+
}
|
|
7679
|
+
return { t: "string", value: decodeString(raw) };
|
|
7680
|
+
}
|
|
7681
|
+
if (c === 47) return { t: "name", value: name() };
|
|
7682
|
+
const start = i;
|
|
7683
|
+
while (i < b.length && !isDelim(b[i])) i++;
|
|
7684
|
+
let tok = "";
|
|
7685
|
+
for (let k = start; k < i; k++) tok += String.fromCharCode(b[k]);
|
|
7686
|
+
if (tok === "true" || tok === "false") return { t: "bool", value: tok === "true" };
|
|
7687
|
+
if (!tok) throw new EngineDataError(`unexpected byte at ${i}`);
|
|
7688
|
+
const n = Number(tok);
|
|
7689
|
+
if (!Number.isFinite(n)) throw new EngineDataError(`bad number "${tok}"`);
|
|
7690
|
+
return /[.eE]/.test(tok) ? { t: "real", value: n } : { t: "int", value: n };
|
|
7691
|
+
};
|
|
7692
|
+
ws();
|
|
7693
|
+
if (b[i] === 47) {
|
|
7694
|
+
const items = [];
|
|
7695
|
+
while (i < b.length) {
|
|
7696
|
+
ws();
|
|
7697
|
+
if (i >= b.length) break;
|
|
7698
|
+
if (b[i] !== 47) throw new EngineDataError(`expected a key at byte ${i}`);
|
|
7699
|
+
const k = name();
|
|
7700
|
+
items.push([k, value(1)]);
|
|
7701
|
+
ws();
|
|
7702
|
+
}
|
|
7703
|
+
return { t: "dict", items };
|
|
7704
|
+
}
|
|
7705
|
+
return value(0);
|
|
7706
|
+
}
|
|
7707
|
+
function decodeString(raw) {
|
|
7708
|
+
if (raw.length >= 2 && raw[0] === 254 && raw[1] === 255) {
|
|
7709
|
+
let s = "";
|
|
7710
|
+
for (let k = 2; k + 1 < raw.length; k += 2) s += String.fromCharCode(raw[k] << 8 | raw[k + 1]);
|
|
7711
|
+
return s;
|
|
7712
|
+
}
|
|
7713
|
+
return String.fromCharCode(...raw);
|
|
7714
|
+
}
|
|
7715
|
+
var isContainer = (v) => v.t === "dict" || v.t === "array" && v.items.some((x) => x.t === "dict" || x.t === "array");
|
|
7716
|
+
function formatReal(r) {
|
|
7717
|
+
if (!Number.isFinite(r)) return "0.0";
|
|
7718
|
+
if (Number.isInteger(r) && Math.abs(r) < 1e15) return r.toFixed(1);
|
|
7719
|
+
let s = r.toFixed(5);
|
|
7720
|
+
while (s.endsWith("0")) s = s.slice(0, -1);
|
|
7721
|
+
if (s === "0." || s === "-0.") return "0.0";
|
|
7722
|
+
if (s.endsWith(".")) s += "0";
|
|
7723
|
+
return s.replace(/^(-?)0\./, "$1.");
|
|
7724
|
+
}
|
|
7725
|
+
function writeEngineData(v) {
|
|
7726
|
+
const out = [10, 10];
|
|
7727
|
+
const push = (s) => {
|
|
7728
|
+
for (let k = 0; k < s.length; k++) out.push(s.charCodeAt(k) & 255);
|
|
7729
|
+
};
|
|
7730
|
+
const indent = (n) => {
|
|
7731
|
+
for (let k = 0; k < n; k++) out.push(9);
|
|
7732
|
+
};
|
|
7733
|
+
const write = (x, depth) => {
|
|
7734
|
+
switch (x.t) {
|
|
7735
|
+
case "dict":
|
|
7736
|
+
push("<<\n");
|
|
7737
|
+
for (const [k, val] of x.items) {
|
|
7738
|
+
indent(depth + 1);
|
|
7739
|
+
push(`/${k}`);
|
|
7740
|
+
if (isContainer(val)) {
|
|
7741
|
+
push("\n");
|
|
7742
|
+
indent(depth + 1);
|
|
7743
|
+
} else push(" ");
|
|
7744
|
+
write(val, depth + 1);
|
|
7745
|
+
push("\n");
|
|
7746
|
+
}
|
|
7747
|
+
indent(depth);
|
|
7748
|
+
push(">>");
|
|
7749
|
+
break;
|
|
7750
|
+
case "array":
|
|
7751
|
+
if (isContainer(x)) {
|
|
7752
|
+
push("[\n");
|
|
7753
|
+
for (const item of x.items) {
|
|
7754
|
+
indent(depth);
|
|
7755
|
+
write(item, depth);
|
|
7756
|
+
push("\n");
|
|
7757
|
+
}
|
|
7758
|
+
indent(depth);
|
|
7759
|
+
push("]");
|
|
7760
|
+
} else {
|
|
7761
|
+
push("[");
|
|
7762
|
+
for (const item of x.items) {
|
|
7763
|
+
push(" ");
|
|
7764
|
+
write(item, depth);
|
|
7765
|
+
}
|
|
7766
|
+
push(" ]");
|
|
7767
|
+
}
|
|
7768
|
+
break;
|
|
7769
|
+
case "string": {
|
|
7770
|
+
out.push(40);
|
|
7771
|
+
const raw = [254, 255];
|
|
7772
|
+
for (let k = 0; k < x.value.length; k++) {
|
|
7773
|
+
const u = x.value.charCodeAt(k);
|
|
7774
|
+
raw.push(u >> 8, u & 255);
|
|
7775
|
+
}
|
|
7776
|
+
for (const c of raw) {
|
|
7777
|
+
if (c === 40 || c === 41 || c === 92) out.push(92);
|
|
7778
|
+
out.push(c);
|
|
7779
|
+
}
|
|
7780
|
+
out.push(41);
|
|
7781
|
+
break;
|
|
7782
|
+
}
|
|
7783
|
+
case "int":
|
|
7784
|
+
push(String(Math.round(x.value)));
|
|
7785
|
+
break;
|
|
7786
|
+
case "real":
|
|
7787
|
+
push(formatReal(x.value));
|
|
7788
|
+
break;
|
|
7789
|
+
case "bool":
|
|
7790
|
+
push(x.value ? "true" : "false");
|
|
7791
|
+
break;
|
|
7792
|
+
case "name":
|
|
7793
|
+
push(`/${x.value}`);
|
|
7794
|
+
break;
|
|
7795
|
+
}
|
|
7796
|
+
};
|
|
7797
|
+
write(v, 0);
|
|
7798
|
+
out.push(10);
|
|
7799
|
+
return Uint8Array.from(out);
|
|
7800
|
+
}
|
|
7801
|
+
var E = {
|
|
7802
|
+
dict: (items = []) => ({ t: "dict", items }),
|
|
7803
|
+
array: (items) => ({ t: "array", items }),
|
|
7804
|
+
str: (value) => ({ t: "string", value }),
|
|
7805
|
+
int: (value) => ({ t: "int", value }),
|
|
7806
|
+
real: (value) => ({ t: "real", value }),
|
|
7807
|
+
bool: (value) => ({ t: "bool", value })
|
|
7808
|
+
};
|
|
7809
|
+
function eGet(v, key) {
|
|
7810
|
+
return _optionalChain([v, 'optionalAccess', _189 => _189.t]) === "dict" ? _optionalChain([v, 'access', _190 => _190.items, 'access', _191 => _191.find, 'call', _192 => _192(([k]) => k === key), 'optionalAccess', _193 => _193[1]]) : void 0;
|
|
7811
|
+
}
|
|
7812
|
+
function ePath(v, keys) {
|
|
7813
|
+
return keys.reduce((at, k) => eGet(at, k), v);
|
|
7814
|
+
}
|
|
7815
|
+
function eNum(v) {
|
|
7816
|
+
return v && (v.t === "int" || v.t === "real") ? v.value : void 0;
|
|
7817
|
+
}
|
|
7818
|
+
function eBool(v) {
|
|
7819
|
+
if (!v) return void 0;
|
|
7820
|
+
if (v.t === "bool") return v.value;
|
|
7821
|
+
if (v.t === "int") return v.value !== 0;
|
|
7822
|
+
return void 0;
|
|
7823
|
+
}
|
|
7824
|
+
function eStr(v) {
|
|
7825
|
+
return v && (v.t === "string" || v.t === "name") ? v.value : void 0;
|
|
7826
|
+
}
|
|
7827
|
+
function eArray(v) {
|
|
7828
|
+
return _optionalChain([v, 'optionalAccess', _194 => _194.t]) === "array" ? v.items : [];
|
|
7829
|
+
}
|
|
7830
|
+
function eSet(d, key, value) {
|
|
7831
|
+
if (d.t !== "dict") return;
|
|
7832
|
+
const at = d.items.findIndex(([k]) => k === key);
|
|
7833
|
+
if (at >= 0) d.items[at] = [key, value];
|
|
7834
|
+
else d.items.push([key, value]);
|
|
7835
|
+
}
|
|
7836
|
+
function eClone(v) {
|
|
7837
|
+
return JSON.parse(JSON.stringify(v));
|
|
7838
|
+
}
|
|
7839
|
+
|
|
7840
|
+
// src/image-editor/psd/type.ts
|
|
7841
|
+
function parseTySh(data) {
|
|
7842
|
+
try {
|
|
7843
|
+
const r = new PsdReader(data);
|
|
7844
|
+
r.u16();
|
|
7845
|
+
const m = [];
|
|
7846
|
+
for (let k = 0; k < 6; k++) m.push(r.f64());
|
|
7847
|
+
r.u16();
|
|
7848
|
+
const text3 = readVersionedDescriptor(r);
|
|
7849
|
+
let warp = null;
|
|
7850
|
+
if (r.remaining >= 6) {
|
|
7851
|
+
const at = r.pos;
|
|
7852
|
+
try {
|
|
7853
|
+
r.u16();
|
|
7854
|
+
warp = readVersionedDescriptor(r);
|
|
7855
|
+
} catch (e15) {
|
|
7856
|
+
r.pos = at;
|
|
7857
|
+
}
|
|
7858
|
+
}
|
|
7859
|
+
return { transform: m, text: text3, warp, tail: r.rest() };
|
|
7860
|
+
} catch (e16) {
|
|
7861
|
+
return null;
|
|
7862
|
+
}
|
|
7863
|
+
}
|
|
7864
|
+
function defaultWarp() {
|
|
7865
|
+
return descriptor("warp", [
|
|
7866
|
+
["warpStyle", { type: "enum", typeId: "warpStyle", value: "warpNone" }],
|
|
7867
|
+
["warpValue", { type: "doub", value: 0 }],
|
|
7868
|
+
["warpPerspective", { type: "doub", value: 0 }],
|
|
7869
|
+
["warpPerspectiveOther", { type: "doub", value: 0 }],
|
|
7870
|
+
["warpRotate", { type: "enum", typeId: "Ornt", value: "Hrzn" }]
|
|
7871
|
+
]);
|
|
7872
|
+
}
|
|
7873
|
+
function writeTySh(t) {
|
|
7874
|
+
const w = new PsdWriter();
|
|
7875
|
+
w.u16(1);
|
|
7876
|
+
for (const v of t.transform) w.f64(v);
|
|
7877
|
+
w.u16(50);
|
|
7878
|
+
writeVersionedDescriptor(w, t.text);
|
|
7879
|
+
w.u16(1);
|
|
7880
|
+
writeVersionedDescriptor(w, _nullishCoalesce(t.warp, () => ( defaultWarp())));
|
|
7881
|
+
if (t.tail.length >= 16) w.bytes(t.tail);
|
|
7882
|
+
else w.zeros(16);
|
|
7883
|
+
return w.result();
|
|
7884
|
+
}
|
|
7885
|
+
var WEIGHTS = [
|
|
7886
|
+
[/thin|hairline/, 100],
|
|
7887
|
+
[/extralight|ultralight/, 200],
|
|
7888
|
+
[/semibold|demibold|demi/, 600],
|
|
7889
|
+
[/extrabold|ultrabold/, 800],
|
|
7890
|
+
[/black|heavy/, 900],
|
|
7891
|
+
[/bold/, 700],
|
|
7892
|
+
[/medium/, 500],
|
|
7893
|
+
[/light/, 300]
|
|
7894
|
+
];
|
|
7895
|
+
function fontFromPostScript(ps) {
|
|
7896
|
+
let pro = ps;
|
|
7897
|
+
let style = "";
|
|
7898
|
+
const dash = ps.lastIndexOf("-");
|
|
7899
|
+
if (dash > 0) {
|
|
7900
|
+
pro = ps.slice(0, dash);
|
|
7901
|
+
style = ps.slice(dash + 1);
|
|
7902
|
+
const prev = pro.lastIndexOf("-");
|
|
7903
|
+
if (/^(it|italic|oblique)$/i.test(style) && prev > 0 && /^(thin|hairline|extralight|ultralight|light|regular|roman|book|medium|semibold|demibold|demi|bold|extrabold|ultrabold|heavy|black)$/i.test(pro.slice(prev + 1))) {
|
|
7904
|
+
style = ps.slice(prev + 1);
|
|
7905
|
+
pro = ps.slice(0, prev);
|
|
7906
|
+
}
|
|
7907
|
+
} else {
|
|
7908
|
+
const m = /^(.*?)(Bold|Italic|Light|Medium|Black|Regular|Oblique)+$/.exec(ps);
|
|
7909
|
+
if (m && m[1]) {
|
|
7910
|
+
pro = m[1];
|
|
7911
|
+
style = ps.slice(m[1].length);
|
|
7912
|
+
}
|
|
7913
|
+
}
|
|
7914
|
+
let suffix = "";
|
|
7915
|
+
if (pro.endsWith("Pro")) suffix = " Pro";
|
|
7916
|
+
else if (pro.endsWith("Std")) suffix = " Std";
|
|
7917
|
+
const fam = pro.replace(/(MT|PS|Std|Pro)+$/, "");
|
|
7918
|
+
let family = "";
|
|
7919
|
+
for (let i = 0; i < fam.length; i++) {
|
|
7920
|
+
const c = fam[i];
|
|
7921
|
+
const upper = c >= "A" && c <= "Z";
|
|
7922
|
+
const prevLower = i > 0 && fam[i - 1] >= "a" && fam[i - 1] <= "z";
|
|
7923
|
+
const prevUpper = i > 0 && fam[i - 1] >= "A" && fam[i - 1] <= "Z";
|
|
7924
|
+
const nextLower = i + 1 < fam.length && fam[i + 1] >= "a" && fam[i + 1] <= "z";
|
|
7925
|
+
if (i > 0 && upper && (prevLower || prevUpper && nextLower)) family += " ";
|
|
7926
|
+
family += c;
|
|
7927
|
+
}
|
|
7928
|
+
family += suffix;
|
|
7929
|
+
const s = style.toLowerCase();
|
|
7930
|
+
const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _195 => _195.find, 'call', _196 => _196(([re]) => re.test(s)), 'optionalAccess', _197 => _197[1]]), () => ( 400));
|
|
7931
|
+
return { family: family || ps, weight, italic: /italic|oblique|it$/.test(s) };
|
|
7932
|
+
}
|
|
7933
|
+
var STYLE_NAMES = [
|
|
7934
|
+
[100, "Thin"],
|
|
7935
|
+
[200, "ExtraLight"],
|
|
7936
|
+
[300, "Light"],
|
|
7937
|
+
[400, "Regular"],
|
|
7938
|
+
[500, "Medium"],
|
|
7939
|
+
[600, "SemiBold"],
|
|
7940
|
+
[700, "Bold"],
|
|
7941
|
+
[800, "ExtraBold"],
|
|
7942
|
+
[900, "Black"]
|
|
7943
|
+
];
|
|
7944
|
+
function postScriptFor(s) {
|
|
7945
|
+
if (s.postScriptName) return s.postScriptName;
|
|
7946
|
+
const base = s.fontFamily.replace(/["',]/g, "").replace(/\s+/g, "");
|
|
7947
|
+
const weight = STYLE_NAMES.reduce((best, w) => Math.abs(w[0] - s.fontWeight) < Math.abs(best[0] - s.fontWeight) ? w : best)[1];
|
|
7948
|
+
if (weight === "Regular" && !s.italic) return base;
|
|
7949
|
+
return `${base}-${weight === "Regular" ? "" : weight}${s.italic ? "Italic" : ""}`;
|
|
7950
|
+
}
|
|
7951
|
+
var hex22 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).padStart(2, "0");
|
|
7952
|
+
function merged(levels) {
|
|
7953
|
+
const items = [];
|
|
7954
|
+
for (const l of levels) {
|
|
7955
|
+
if (_optionalChain([l, 'optionalAccess', _198 => _198.t]) !== "dict") continue;
|
|
7956
|
+
for (const [k, v] of l.items) if (!items.some(([o]) => o === k)) items.push([k, v]);
|
|
7957
|
+
}
|
|
7958
|
+
return E.dict(items);
|
|
7959
|
+
}
|
|
7960
|
+
function charStyle(d, fonts, notes) {
|
|
7961
|
+
const n = (k) => eNum(eGet(d, k));
|
|
7962
|
+
const flag = (k) => eBool(eGet(d, k));
|
|
7963
|
+
const s = { ...DEFAULT_TEXT_STYLE };
|
|
7964
|
+
const fi = n("Font");
|
|
7965
|
+
const ps = fi !== void 0 ? fonts[fi] : void 0;
|
|
7966
|
+
if (ps) {
|
|
7967
|
+
const f = fontFromPostScript(ps);
|
|
7968
|
+
s.fontFamily = f.family;
|
|
7969
|
+
s.fontWeight = f.weight;
|
|
7970
|
+
if (f.italic) s.italic = true;
|
|
7971
|
+
s.postScriptName = ps;
|
|
7972
|
+
}
|
|
7973
|
+
const size = n("FontSize");
|
|
7974
|
+
if (size !== void 0 && size > 0) s.fontSize = size;
|
|
7975
|
+
if (flag("AutoLeading") === false) {
|
|
7976
|
+
const lead = n("Leading");
|
|
7977
|
+
if (lead !== void 0 && lead > 0) s.leading = lead;
|
|
7978
|
+
}
|
|
7979
|
+
const tracking = n("Tracking");
|
|
7980
|
+
if (tracking) s.tracking = tracking;
|
|
7981
|
+
const shift = n("BaselineShift");
|
|
7982
|
+
if (shift) s.baselineShift = shift;
|
|
7983
|
+
if (flag("Underline")) s.underline = true;
|
|
7984
|
+
if (flag("Strikethrough")) s.strikethrough = true;
|
|
7985
|
+
if (flag("FauxBold")) notes.add("faux bold is drawn as the regular weight");
|
|
7986
|
+
if (flag("FauxItalic")) notes.add("faux italic is drawn upright");
|
|
7987
|
+
if ((_nullishCoalesce(n("HorizontalScale"), () => ( 1))) !== 1 || (_nullishCoalesce(n("VerticalScale"), () => ( 1))) !== 1) notes.add("horizontal and vertical character scaling is drawn at 100 %");
|
|
7988
|
+
if ((_nullishCoalesce(n("FontCaps"), () => ( 0))) !== 0) notes.add("small caps and all caps are drawn as typed");
|
|
7989
|
+
const color = eGet(d, "FillColor");
|
|
7990
|
+
const values = eArray(eGet(color, "Values")).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
7991
|
+
if (values.length === 4) {
|
|
7992
|
+
s.color = `#${hex22(values[1])}${hex22(values[2])}${hex22(values[3])}`;
|
|
7993
|
+
if (values[0] < 1) s.opacity = Math.max(0, values[0]);
|
|
7994
|
+
} else if (values.length === 2) {
|
|
7995
|
+
const g = hex22(values[1]);
|
|
7996
|
+
s.color = `#${g}${g}${g}`;
|
|
7997
|
+
} else if (values.length === 5) {
|
|
7998
|
+
const [c, m, y, k] = values.slice(1);
|
|
7999
|
+
s.color = `#${hex22((1 - c) * (1 - k))}${hex22((1 - m) * (1 - k))}${hex22((1 - y) * (1 - k))}`;
|
|
8000
|
+
notes.add("CMYK text colours were converted to RGB");
|
|
8001
|
+
}
|
|
8002
|
+
return s;
|
|
8003
|
+
}
|
|
8004
|
+
function paraStyle(d) {
|
|
8005
|
+
const n = (k) => eNum(eGet(d, k));
|
|
8006
|
+
const out = {};
|
|
8007
|
+
const j = n("Justification");
|
|
8008
|
+
const align = j === 1 ? "right" : j === 2 ? "center" : j !== void 0 && j >= 3 ? "justify" : "left";
|
|
8009
|
+
if (align !== "left") out.align = align;
|
|
8010
|
+
const set = (k, v) => {
|
|
8011
|
+
if (v) out[k] = v;
|
|
8012
|
+
};
|
|
8013
|
+
set("firstLineIndent", n("FirstLineIndent"));
|
|
8014
|
+
set("startIndent", n("StartIndent"));
|
|
8015
|
+
set("endIndent", n("EndIndent"));
|
|
8016
|
+
set("spaceBefore", n("SpaceBefore"));
|
|
8017
|
+
set("spaceAfter", n("SpaceAfter"));
|
|
8018
|
+
const auto = n("AutoLeading");
|
|
8019
|
+
if (auto !== void 0 && auto > 0 && Math.abs(auto - 1.2) > 1e-6) out.autoLeading = auto;
|
|
8020
|
+
return out;
|
|
8021
|
+
}
|
|
8022
|
+
function typeFromTySh(data, notes) {
|
|
8023
|
+
const t = parseTySh(data);
|
|
8024
|
+
if (!t) return null;
|
|
8025
|
+
const txtV = descGet(t.text, "Txt ");
|
|
8026
|
+
const txt = _optionalChain([txtV, 'optionalAccess', _199 => _199.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
|
|
8027
|
+
const ed = descGet(t.text, "EngineData");
|
|
8028
|
+
let engine = null;
|
|
8029
|
+
if (_optionalChain([ed, 'optionalAccess', _200 => _200.type]) === "tdta") {
|
|
8030
|
+
try {
|
|
8031
|
+
engine = parseEngineData(ed.data);
|
|
8032
|
+
} catch (e17) {
|
|
8033
|
+
notes.add("the text engine data could not be read; the text came in in one style");
|
|
8034
|
+
}
|
|
8035
|
+
}
|
|
8036
|
+
const anti = descGet(t.text, "AntA");
|
|
8037
|
+
const antiAlias = !(_optionalChain([anti, 'optionalAccess', _201 => _201.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
|
|
8038
|
+
const ornt = descGet(t.text, "Ornt");
|
|
8039
|
+
if (_optionalChain([ornt, 'optionalAccess', _202 => _202.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
|
|
8040
|
+
if (t.warp) {
|
|
8041
|
+
const style = descGet(t.warp, "warpStyle");
|
|
8042
|
+
if (_optionalChain([style, 'optionalAccess', _203 => _203.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
|
|
8043
|
+
}
|
|
8044
|
+
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
8045
|
+
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
8046
|
+
let runs = [{ length: text3.length, style: { ...DEFAULT_TEXT_STYLE } }];
|
|
8047
|
+
let paragraphs = [{ length: text3.length, style: {} }];
|
|
8048
|
+
let frame = { kind: "point" };
|
|
8049
|
+
let transform = t.transform;
|
|
8050
|
+
const fonts = [];
|
|
8051
|
+
if (engine) {
|
|
8052
|
+
const res = _nullishCoalesce(eGet(engine, "ResourceDict"), () => ( eGet(engine, "DocumentResources")));
|
|
8053
|
+
for (const f of eArray(eGet(res, "FontSet"))) fonts.push(_nullishCoalesce(eStr(eGet(f, "Name")), () => ( "")));
|
|
8054
|
+
const styleSet = eArray(eGet(res, "StyleSheetSet"));
|
|
8055
|
+
const paraSet = eArray(eGet(res, "ParagraphSheetSet"));
|
|
8056
|
+
const normalStyle = _nullishCoalesce(styleSet[_nullishCoalesce(eNum(eGet(res, "TheNormalStyleSheet")), () => ( 0))], () => ( styleSet[0]));
|
|
8057
|
+
const normalPara = _nullishCoalesce(paraSet[_nullishCoalesce(eNum(eGet(res, "TheNormalParagraphSheet")), () => ( 0))], () => ( paraSet[0]));
|
|
8058
|
+
const named = (set, sheet) => {
|
|
8059
|
+
const parent = eNum(eGet(sheet, "Parent"));
|
|
8060
|
+
if (parent !== void 0 && set[parent]) return set[parent];
|
|
8061
|
+
const name = eStr(eGet(sheet, "Name"));
|
|
8062
|
+
return name ? set.find((s) => eStr(eGet(s, "Name")) === name) : void 0;
|
|
8063
|
+
};
|
|
8064
|
+
const prun = ePath(engine, ["EngineDict", "ParagraphRun"]);
|
|
8065
|
+
const psheets = eArray(eGet(prun, "RunArray")).map((x) => eGet(x, "ParagraphSheet"));
|
|
8066
|
+
const plens = eArray(eGet(prun, "RunLengthArray")).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
8067
|
+
const paraBases = psheets.map((sheet) => {
|
|
8068
|
+
const own = named(paraSet, sheet);
|
|
8069
|
+
const base = merged([eGet(own, "Properties"), eGet(normalPara, "Properties")]);
|
|
8070
|
+
const di = _nullishCoalesce(eNum(eGet(sheet, "DefaultStyleSheet")), () => ( eNum(eGet(own, "DefaultStyleSheet"))));
|
|
8071
|
+
return { base, charDefault: di !== void 0 ? styleSet[di] : void 0 };
|
|
8072
|
+
});
|
|
8073
|
+
if (psheets.length) {
|
|
8074
|
+
paragraphs = psheets.map((sheet, i) => ({ length: _nullishCoalesce(plens[i], () => ( 0)), style: paraStyle(merged([eGet(sheet, "Properties"), paraBases[i].base])) }));
|
|
8075
|
+
}
|
|
8076
|
+
const srun = ePath(engine, ["EngineDict", "StyleRun"]);
|
|
8077
|
+
const ssheets = eArray(eGet(srun, "RunArray")).map((x) => eGet(x, "StyleSheet"));
|
|
8078
|
+
const slens = eArray(eGet(srun, "RunLengthArray")).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
8079
|
+
const paraAt = (at) => {
|
|
8080
|
+
let end = 0;
|
|
8081
|
+
for (let i = 0; i < plens.length; i++) {
|
|
8082
|
+
end += plens[i];
|
|
8083
|
+
if (at < end) return i;
|
|
8084
|
+
}
|
|
8085
|
+
return plens.length - 1;
|
|
8086
|
+
};
|
|
8087
|
+
if (ssheets.length) {
|
|
8088
|
+
let at = 0;
|
|
8089
|
+
runs = ssheets.map((sheet, i) => {
|
|
8090
|
+
const own = named(styleSet, sheet);
|
|
8091
|
+
const paraDefault = _optionalChain([paraBases, 'access', _204 => _204[paraAt(at)], 'optionalAccess', _205 => _205.charDefault]);
|
|
8092
|
+
at += _nullishCoalesce(slens[i], () => ( 0));
|
|
8093
|
+
const d = merged([eGet(sheet, "StyleSheetData"), eGet(own, "StyleSheetData"), eGet(paraDefault, "StyleSheetData"), eGet(normalStyle, "StyleSheetData")]);
|
|
8094
|
+
return { length: _nullishCoalesce(slens[i], () => ( 0)), style: charStyle(d, fonts, notes) };
|
|
8095
|
+
});
|
|
8096
|
+
}
|
|
8097
|
+
const shape = eArray(ePath(engine, ["EngineDict", "Rendered", "Shapes", "Children"]))[0];
|
|
8098
|
+
if (eNum(eGet(shape, "ShapeType")) === 1) {
|
|
8099
|
+
const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
8100
|
+
if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
|
|
8101
|
+
frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
|
|
8102
|
+
transform = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
|
|
8103
|
+
}
|
|
8104
|
+
}
|
|
8105
|
+
}
|
|
8106
|
+
return {
|
|
8107
|
+
text: text3,
|
|
8108
|
+
runs: fitRuns(runs, text3.length, DEFAULT_TEXT_STYLE),
|
|
8109
|
+
paragraphs: fitParagraphRuns(paragraphs, text3),
|
|
8110
|
+
frame,
|
|
8111
|
+
transform,
|
|
8112
|
+
antiAlias,
|
|
8113
|
+
fonts: [...new Set(fonts.filter(Boolean))]
|
|
8114
|
+
};
|
|
8115
|
+
}
|
|
8116
|
+
function typeSignature(layer) {
|
|
8117
|
+
return JSON.stringify([layer.text, layer.runs, layer.paragraphs, layer.frame, _nullishCoalesce(layer.transform, () => ( null)), _nullishCoalesce(layer.antiAlias, () => ( true))]);
|
|
8118
|
+
}
|
|
8119
|
+
function styleSheetData(s, font) {
|
|
8120
|
+
const [r, g, b] = [1, 3, 5].map((i) => parseInt(s.color.slice(i, i + 2), 16) / 255);
|
|
8121
|
+
return E.dict([
|
|
8122
|
+
["Font", E.int(font)],
|
|
8123
|
+
["FontSize", E.real(s.fontSize)],
|
|
8124
|
+
["FauxBold", E.bool(false)],
|
|
8125
|
+
["FauxItalic", E.bool(false)],
|
|
8126
|
+
["AutoLeading", E.bool(s.leading === void 0)],
|
|
8127
|
+
["Leading", E.real(_nullishCoalesce(s.leading, () => ( 0)))],
|
|
8128
|
+
["HorizontalScale", E.real(1)],
|
|
8129
|
+
["VerticalScale", E.real(1)],
|
|
8130
|
+
["Tracking", E.int(Math.round(_nullishCoalesce(s.tracking, () => ( 0))))],
|
|
8131
|
+
["AutoKerning", E.bool(true)],
|
|
8132
|
+
["Kerning", E.int(0)],
|
|
8133
|
+
["BaselineShift", E.real(_nullishCoalesce(s.baselineShift, () => ( 0)))],
|
|
8134
|
+
["FontCaps", E.int(0)],
|
|
8135
|
+
["Underline", E.bool(Boolean(s.underline))],
|
|
8136
|
+
["Strikethrough", E.bool(Boolean(s.strikethrough))],
|
|
8137
|
+
["Ligatures", E.bool(true)],
|
|
8138
|
+
["DLigatures", E.bool(false)],
|
|
8139
|
+
["FillFlag", E.bool(true)],
|
|
8140
|
+
[
|
|
8141
|
+
"FillColor",
|
|
8142
|
+
E.dict([
|
|
8143
|
+
["Type", E.int(1)],
|
|
8144
|
+
["Values", E.array([E.real(_nullishCoalesce(s.opacity, () => ( 1))), E.real(r), E.real(g), E.real(b)])]
|
|
8145
|
+
])
|
|
8146
|
+
]
|
|
8147
|
+
]);
|
|
8148
|
+
}
|
|
8149
|
+
function paragraphProperties(p) {
|
|
8150
|
+
const j = p.align === "right" ? 1 : p.align === "center" ? 2 : p.align === "justify" ? 3 : 0;
|
|
8151
|
+
return E.dict([
|
|
8152
|
+
["Justification", E.int(j)],
|
|
8153
|
+
["FirstLineIndent", E.real(_nullishCoalesce(p.firstLineIndent, () => ( 0)))],
|
|
8154
|
+
["StartIndent", E.real(_nullishCoalesce(p.startIndent, () => ( 0)))],
|
|
8155
|
+
["EndIndent", E.real(_nullishCoalesce(p.endIndent, () => ( 0)))],
|
|
8156
|
+
["SpaceBefore", E.real(_nullishCoalesce(p.spaceBefore, () => ( 0)))],
|
|
8157
|
+
["SpaceAfter", E.real(_nullishCoalesce(p.spaceAfter, () => ( 0)))],
|
|
8158
|
+
["AutoHyphenate", E.bool(false)],
|
|
8159
|
+
["AutoLeading", E.real(_nullishCoalesce(p.autoLeading, () => ( 1.2)))],
|
|
8160
|
+
["LeadingType", E.int(0)]
|
|
8161
|
+
]);
|
|
8162
|
+
}
|
|
8163
|
+
var fontEntry = (name) => E.dict([
|
|
8164
|
+
["Name", E.str(name)],
|
|
8165
|
+
["Script", E.int(0)],
|
|
8166
|
+
["FontType", E.int(1)],
|
|
8167
|
+
["Synthetic", E.int(0)]
|
|
8168
|
+
]);
|
|
8169
|
+
function buildEngineData(layer, template) {
|
|
8170
|
+
const e = _optionalChain([template, 'optionalAccess', _206 => _206.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
|
|
8171
|
+
if (_optionalChain([eGet, 'call', _207 => _207(e, "EngineDict"), 'optionalAccess', _208 => _208.t]) !== "dict") eSet(e, "EngineDict", E.dict());
|
|
8172
|
+
const dict = eGet(e, "EngineDict");
|
|
8173
|
+
const text3 = layer.text.replace(/\n/g, "\r");
|
|
8174
|
+
const edText = `${text3}\r`;
|
|
8175
|
+
const res0 = _nullishCoalesce(eGet(e, "ResourceDict"), () => ( eGet(e, "DocumentResources")));
|
|
8176
|
+
const fonts = eArray(eGet(res0, "FontSet")).map((f) => _nullishCoalesce(eStr(eGet(f, "Name")), () => ( "")));
|
|
8177
|
+
const fontIndex = (ps) => {
|
|
8178
|
+
const at = fonts.indexOf(ps);
|
|
8179
|
+
if (at >= 0) return at;
|
|
8180
|
+
fonts.push(ps);
|
|
8181
|
+
return fonts.length - 1;
|
|
8182
|
+
};
|
|
8183
|
+
const runs = fitRuns(layer.runs, layer.text.length, DEFAULT_TEXT_STYLE);
|
|
8184
|
+
const sruns = [];
|
|
8185
|
+
const slens = [];
|
|
8186
|
+
runs.forEach((r, i) => {
|
|
8187
|
+
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(r.style, fontIndex(postScriptFor(r.style)))]])]]));
|
|
8188
|
+
slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
|
|
8189
|
+
});
|
|
8190
|
+
if (!runs.length) {
|
|
8191
|
+
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(DEFAULT_TEXT_STYLE)))]])]]));
|
|
8192
|
+
slens.push(E.int(1));
|
|
8193
|
+
}
|
|
8194
|
+
const paras = fitParagraphRuns(layer.paragraphs, layer.text);
|
|
8195
|
+
const pruns = [];
|
|
8196
|
+
const plens = [];
|
|
8197
|
+
paras.forEach((p, i) => {
|
|
8198
|
+
pruns.push(E.dict([["ParagraphSheet", E.dict([["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties(p.style)]])]]));
|
|
8199
|
+
plens.push(E.int(p.length + (i === paras.length - 1 ? 1 : 0)));
|
|
8200
|
+
});
|
|
8201
|
+
const editor = _nullishCoalesce(eGet(dict, "Editor"), () => ( E.dict()));
|
|
8202
|
+
eSet(editor, "Text", E.str(edText));
|
|
8203
|
+
eSet(dict, "Editor", editor);
|
|
8204
|
+
const pr = _nullishCoalesce(eGet(dict, "ParagraphRun"), () => ( E.dict()));
|
|
8205
|
+
eSet(pr, "RunArray", E.array(pruns));
|
|
8206
|
+
eSet(pr, "RunLengthArray", E.array(plens));
|
|
8207
|
+
if (!eGet(pr, "IsJoinable")) eSet(pr, "IsJoinable", E.int(1));
|
|
8208
|
+
eSet(dict, "ParagraphRun", pr);
|
|
8209
|
+
const sr = _nullishCoalesce(eGet(dict, "StyleRun"), () => ( E.dict()));
|
|
8210
|
+
eSet(sr, "RunArray", E.array(sruns));
|
|
8211
|
+
eSet(sr, "RunLengthArray", E.array(slens));
|
|
8212
|
+
if (!eGet(sr, "IsJoinable")) eSet(sr, "IsJoinable", E.int(2));
|
|
8213
|
+
eSet(dict, "StyleRun", sr);
|
|
8214
|
+
eSet(dict, "AntiAlias", E.int(layer.antiAlias === false ? 0 : 3));
|
|
8215
|
+
if (!eGet(dict, "UseFractionalGlyphWidths")) eSet(dict, "UseFractionalGlyphWidths", E.bool(true));
|
|
8216
|
+
const box2 = layer.frame.kind === "box" ? layer.frame : null;
|
|
8217
|
+
const shapeType = box2 ? 1 : 0;
|
|
8218
|
+
const photoshop = E.dict([["ShapeType", E.int(shapeType)]]);
|
|
8219
|
+
if (box2) eSet(photoshop, "BoxBounds", E.array([E.real(0), E.real(0), E.real(box2.width), E.real(box2.height)]));
|
|
8220
|
+
else eSet(photoshop, "PointBase", E.array([E.real(0), E.real(0)]));
|
|
8221
|
+
eSet(
|
|
8222
|
+
photoshop,
|
|
8223
|
+
"Base",
|
|
8224
|
+
E.dict([
|
|
8225
|
+
["ShapeType", E.int(shapeType)],
|
|
8226
|
+
["TransformPoint0", E.array([E.real(1), E.real(0)])],
|
|
8227
|
+
["TransformPoint1", E.array([E.real(0), E.real(1)])],
|
|
8228
|
+
["TransformPoint2", E.array([E.real(0), E.real(0)])]
|
|
8229
|
+
])
|
|
8230
|
+
);
|
|
8231
|
+
const child = E.dict([
|
|
8232
|
+
["ShapeType", E.int(shapeType)],
|
|
8233
|
+
["Procession", E.int(0)],
|
|
8234
|
+
["Lines", E.dict([["WritingDirection", E.int(0)], ["Children", E.array([])]])],
|
|
8235
|
+
["Cookie", E.dict([["Photoshop", photoshop]])]
|
|
8236
|
+
]);
|
|
8237
|
+
eSet(dict, "Rendered", E.dict([["Version", E.int(1)], ["Shapes", E.dict([["WritingDirection", E.int(0)], ["Children", E.array([child])]])]]));
|
|
8238
|
+
const fontSet = E.array(fonts.map(fontEntry));
|
|
8239
|
+
for (const key of ["ResourceDict", "DocumentResources"]) {
|
|
8240
|
+
let rd = eGet(e, key);
|
|
8241
|
+
if (!rd) {
|
|
8242
|
+
if (key === "DocumentResources") {
|
|
8243
|
+
eSet(e, key, eClone(_nullishCoalesce(eGet(e, "ResourceDict"), () => ( E.dict()))));
|
|
8244
|
+
continue;
|
|
8245
|
+
}
|
|
8246
|
+
rd = E.dict();
|
|
8247
|
+
eSet(e, key, rd);
|
|
8248
|
+
}
|
|
8249
|
+
eSet(rd, "FontSet", fontSet);
|
|
8250
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _209 => _209[0], 'optionalAccess', _210 => _210.style]), () => ( DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8251
|
+
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8252
|
+
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8253
|
+
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
8254
|
+
}
|
|
8255
|
+
return e;
|
|
8256
|
+
}
|
|
8257
|
+
function inkBounds2(layer) {
|
|
8258
|
+
if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
|
|
8259
|
+
const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
8260
|
+
if (!b) return [0, 0, 0, 0];
|
|
8261
|
+
const inv = _chunkW3GXSUSQcjs.invertMatrix.call(void 0, textMatrix(layer));
|
|
8262
|
+
const pts = [
|
|
8263
|
+
{ x: b.x, y: b.y },
|
|
8264
|
+
{ x: b.x + b.width, y: b.y },
|
|
8265
|
+
{ x: b.x + b.width, y: b.y + b.height },
|
|
8266
|
+
{ x: b.x, y: b.y + b.height }
|
|
8267
|
+
].map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, inv, p));
|
|
8268
|
+
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))];
|
|
8269
|
+
}
|
|
8270
|
+
function tyShForLayer(layer) {
|
|
8271
|
+
const raw = _optionalChain([layer, 'access', _211 => _211.psd, 'optionalAccess', _212 => _212.tySh]);
|
|
8272
|
+
if (raw && _optionalChain([layer, 'access', _213 => _213.psd, 'optionalAccess', _214 => _214.signature]) === typeSignature(layer)) return raw;
|
|
8273
|
+
const old = raw ? parseTySh(raw) : null;
|
|
8274
|
+
const oldEd = old ? descGet(old.text, "EngineData") : void 0;
|
|
8275
|
+
let template = null;
|
|
8276
|
+
if (_optionalChain([oldEd, 'optionalAccess', _215 => _215.type]) === "tdta") {
|
|
8277
|
+
try {
|
|
8278
|
+
template = parseEngineData(oldEd.data);
|
|
8279
|
+
} catch (e18) {
|
|
8280
|
+
template = null;
|
|
8281
|
+
}
|
|
8282
|
+
}
|
|
8283
|
+
const engine = buildEngineData(layer, template);
|
|
8284
|
+
const text3 = old ? { ...old.text, items: [...old.text.items] } : descriptor("TxLr");
|
|
8285
|
+
const set = (key, v) => {
|
|
8286
|
+
const at = text3.items.findIndex(([k]) => k === key);
|
|
8287
|
+
if (at >= 0) text3.items[at] = [key, v];
|
|
8288
|
+
else text3.items.push([key, v]);
|
|
8289
|
+
};
|
|
8290
|
+
set("Txt ", { type: "TEXT", value: layer.text.replace(/\n/g, "\r") });
|
|
8291
|
+
if (!descGet(text3, "textGridding")) set("textGridding", { type: "enum", typeId: "textGridding", value: "None" });
|
|
8292
|
+
set("Ornt", { type: "enum", typeId: "Ornt", value: "Hrzn" });
|
|
8293
|
+
set("AntA", { type: "enum", typeId: "Annt", value: layer.antiAlias === false ? "Anno" : "AnSm" });
|
|
8294
|
+
const [l, t, r, b] = inkBounds2(layer);
|
|
8295
|
+
const rect = (cls) => ({
|
|
8296
|
+
type: "Objc",
|
|
8297
|
+
value: descriptor(cls, [
|
|
8298
|
+
["Left", { type: "UntF", unit: "#Pnt", value: l }],
|
|
8299
|
+
["Top ", { type: "UntF", unit: "#Pnt", value: t }],
|
|
8300
|
+
["Rght", { type: "UntF", unit: "#Pnt", value: r }],
|
|
8301
|
+
["Btom", { type: "UntF", unit: "#Pnt", value: b }]
|
|
8302
|
+
])
|
|
8303
|
+
});
|
|
8304
|
+
set("bounds", rect("bounds"));
|
|
8305
|
+
set("boundingBox", rect("boundingBox"));
|
|
8306
|
+
if (!descGet(text3, "TextIndex")) set("TextIndex", { type: "long", value: 0 });
|
|
8307
|
+
set("EngineData", { type: "tdta", data: writeEngineData(engine) });
|
|
8308
|
+
const warpStyle = _optionalChain([old, 'optionalAccess', _216 => _216.warp]) ? descGet(old.warp, "warpStyle") : void 0;
|
|
8309
|
+
const warp = _optionalChain([old, 'optionalAccess', _217 => _217.warp]) && _optionalChain([warpStyle, 'optionalAccess', _218 => _218.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
|
|
8310
|
+
return writeTySh({ transform: textMatrix(layer), text: text3, warp, tail: new Uint8Array(16) });
|
|
8311
|
+
}
|
|
8312
|
+
|
|
8313
|
+
// src/image-editor/psd/compression.ts
|
|
8314
|
+
var MAX_DECODED_BYTES = 2 ** 31;
|
|
8315
|
+
function rowBytes(width, depth) {
|
|
8316
|
+
return depth === 1 ? Math.ceil(width / 8) : width * Math.max(1, depth >> 3);
|
|
8317
|
+
}
|
|
8318
|
+
function decodedLength(l) {
|
|
8319
|
+
const total = l.planes * l.height * rowBytes(l.width, l.depth);
|
|
8320
|
+
if (total > MAX_DECODED_BYTES) throw new PsdError(`Decoded channel data of ${total} bytes is larger than the ${MAX_DECODED_BYTES}-byte limit.`);
|
|
8321
|
+
return total;
|
|
8322
|
+
}
|
|
8323
|
+
function packbitsBound(n) {
|
|
8324
|
+
return n + Math.ceil(n / 128);
|
|
8325
|
+
}
|
|
8326
|
+
function packbitsEncode(src, out, at) {
|
|
8327
|
+
const n = src.length;
|
|
8328
|
+
let i = 0;
|
|
8329
|
+
while (i < n) {
|
|
8330
|
+
let run = 1;
|
|
8331
|
+
while (i + run < n && run < 128 && src[i + run] === src[i]) run++;
|
|
8332
|
+
if (run >= 2) {
|
|
8333
|
+
out[at++] = 257 - run & 255;
|
|
8334
|
+
out[at++] = src[i];
|
|
8335
|
+
i += run;
|
|
8336
|
+
continue;
|
|
8337
|
+
}
|
|
8338
|
+
const start = i;
|
|
8339
|
+
let len = 0;
|
|
8340
|
+
while (i < n && len < 128) {
|
|
8341
|
+
if (i + 2 < n && src[i] === src[i + 1] && src[i] === src[i + 2]) break;
|
|
8342
|
+
i++;
|
|
8343
|
+
len++;
|
|
8344
|
+
}
|
|
8345
|
+
out[at++] = len - 1;
|
|
8346
|
+
out.set(src.subarray(start, start + len), at);
|
|
8347
|
+
at += len;
|
|
8348
|
+
}
|
|
8349
|
+
return at;
|
|
8350
|
+
}
|
|
8351
|
+
function packbitsDecodeInto(src, expected, out, at) {
|
|
8352
|
+
const target = at + expected;
|
|
8353
|
+
let i = 0;
|
|
8354
|
+
while (at < target) {
|
|
8355
|
+
if (i >= src.length) throw new PsdError("PackBits row ended early.");
|
|
8356
|
+
const h = src[i++];
|
|
8357
|
+
if (h < 128) {
|
|
8358
|
+
const len = h + 1;
|
|
8359
|
+
if (i + len > src.length) throw new PsdError("PackBits literal is truncated.");
|
|
8360
|
+
if (at + len > target) throw new PsdError("PackBits literal overflows its row.");
|
|
8361
|
+
out.set(src.subarray(i, i + len), at);
|
|
8362
|
+
at += len;
|
|
8363
|
+
i += len;
|
|
8364
|
+
} else if (h !== 128) {
|
|
8365
|
+
const len = 257 - h;
|
|
8366
|
+
if (i >= src.length) throw new PsdError("PackBits run is truncated.");
|
|
8367
|
+
const b = src[i++];
|
|
8368
|
+
if (at + len > target) throw new PsdError("PackBits run overflows its row.");
|
|
8369
|
+
out.fill(b, at, at + len);
|
|
8370
|
+
at += len;
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8373
|
+
return at;
|
|
8374
|
+
}
|
|
8375
|
+
function inflateChecked(data, expected) {
|
|
8376
|
+
let out;
|
|
8377
|
+
try {
|
|
8378
|
+
out = _chunkPOGBUYWEcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
8379
|
+
} catch (e) {
|
|
8380
|
+
throw new PsdError(`ZIP channel data: ${e instanceof _chunkPOGBUYWEcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
8381
|
+
}
|
|
8382
|
+
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
8383
|
+
return out.length === expected ? out : out.subarray(0, expected);
|
|
8384
|
+
}
|
|
8385
|
+
function unpredict(buf, l) {
|
|
8386
|
+
const rb = rowBytes(l.width, l.depth);
|
|
8387
|
+
if (rb === 0) return;
|
|
8388
|
+
const w = l.width;
|
|
8389
|
+
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
8390
|
+
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
8391
|
+
if (l.depth === 1 || l.depth === 8) {
|
|
8392
|
+
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
8393
|
+
} else if (l.depth === 16) {
|
|
8394
|
+
for (let i = 1; i < w; i++) {
|
|
8395
|
+
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
8396
|
+
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
8397
|
+
const v = a + b & 65535;
|
|
8398
|
+
buf[o + 2 * i] = v >> 8;
|
|
8399
|
+
buf[o + 2 * i + 1] = v & 255;
|
|
8400
|
+
}
|
|
8401
|
+
} else if (l.depth === 32) {
|
|
8402
|
+
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
8403
|
+
scratch.set(buf.subarray(o, o + rb));
|
|
8404
|
+
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + 4 * i + k] = scratch[k * w + i];
|
|
8405
|
+
} else {
|
|
8406
|
+
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
}
|
|
8410
|
+
function decodeRle(r, l, total) {
|
|
8411
|
+
const rows = l.planes * l.height;
|
|
8412
|
+
const rb = rowBytes(l.width, l.depth);
|
|
8413
|
+
r.checkCount(rows, l.psb ? 4 : 2, "RLE row counts");
|
|
8414
|
+
const counts = new Array(rows);
|
|
8415
|
+
for (let i = 0; i < rows; i++) counts[i] = l.psb ? r.u32() : r.u16();
|
|
8416
|
+
if (total > r.remaining * 130) throw new PsdError("RLE data is too short for its declared size.");
|
|
8417
|
+
const out = new Uint8Array(total);
|
|
8418
|
+
let at = 0;
|
|
8419
|
+
for (const c of counts) at = packbitsDecodeInto(r.bytes(c), rb, out, at);
|
|
8420
|
+
return out;
|
|
8421
|
+
}
|
|
8422
|
+
function decodePlanes(compression, data, l) {
|
|
8423
|
+
const total = decodedLength(l);
|
|
8424
|
+
switch (compression) {
|
|
8425
|
+
case 0:
|
|
8426
|
+
if (data.length < total) throw new PsdError(`Raw channel data has ${data.length} of ${total} bytes.`);
|
|
8427
|
+
return data.slice(0, total);
|
|
8428
|
+
case 1:
|
|
8429
|
+
return decodeRle(new PsdReader(data), l, total);
|
|
8430
|
+
case 2:
|
|
8431
|
+
return inflateChecked(data, total).slice();
|
|
8432
|
+
case 3: {
|
|
8433
|
+
const v = inflateChecked(data, total).slice();
|
|
8434
|
+
unpredict(v, l);
|
|
8435
|
+
return v;
|
|
8436
|
+
}
|
|
8437
|
+
default:
|
|
8438
|
+
throw new PsdError(`Unsupported compression method ${compression}.`);
|
|
8439
|
+
}
|
|
8440
|
+
}
|
|
8441
|
+
function encodeRle(decoded2, l) {
|
|
8442
|
+
const rows = l.planes * l.height;
|
|
8443
|
+
const rb = rowBytes(l.width, l.depth);
|
|
8444
|
+
const cs = l.psb ? 4 : 2;
|
|
8445
|
+
const packed = new Uint8Array(rows * packbitsBound(rb));
|
|
8446
|
+
let at = 0;
|
|
8447
|
+
const counts = new Uint8Array(rows * cs);
|
|
8448
|
+
for (let row = 0; row < rows; row++) {
|
|
8449
|
+
const start = at;
|
|
8450
|
+
at = packbitsEncode(decoded2.subarray(row * rb, (row + 1) * rb), packed, at);
|
|
8451
|
+
const n = at - start;
|
|
8452
|
+
if (cs === 2) {
|
|
8453
|
+
if (n > 65535) throw new PsdError("An RLE row is longer than 65535 bytes; write a PSB instead.");
|
|
8454
|
+
counts[row * 2] = n >> 8;
|
|
8455
|
+
counts[row * 2 + 1] = n & 255;
|
|
8456
|
+
} else {
|
|
8457
|
+
counts[row * 4] = n >>> 24;
|
|
8458
|
+
counts[row * 4 + 1] = n >>> 16 & 255;
|
|
8459
|
+
counts[row * 4 + 2] = n >>> 8 & 255;
|
|
8460
|
+
counts[row * 4 + 3] = n & 255;
|
|
8461
|
+
}
|
|
8462
|
+
}
|
|
8463
|
+
const out = new Uint8Array(counts.length + at);
|
|
8464
|
+
out.set(counts);
|
|
8465
|
+
out.set(packed.subarray(0, at), counts.length);
|
|
8466
|
+
return out;
|
|
8467
|
+
}
|
|
8468
|
+
|
|
8469
|
+
// src/image-editor/psd/smart.ts
|
|
8470
|
+
var dbl2 = (value) => ({ type: "doub", value });
|
|
8471
|
+
var unit2 = (u, value) => ({ type: "UntF", unit: u, value });
|
|
8472
|
+
var long3 = (value) => ({ type: "long", value: Math.round(value) });
|
|
8473
|
+
var boolV2 = (value) => ({ type: "bool", value });
|
|
8474
|
+
var enumV2 = (typeId, value) => ({ type: "enum", typeId, value });
|
|
8475
|
+
var textV = (value) => ({ type: "TEXT", value });
|
|
8476
|
+
var obj2 = (d) => ({ type: "Objc", value: d });
|
|
8477
|
+
var text = (d, key) => {
|
|
8478
|
+
const v = descGet(d, key);
|
|
8479
|
+
return _optionalChain([v, 'optionalAccess', _219 => _219.type]) === "TEXT" ? v.value : void 0;
|
|
8480
|
+
};
|
|
8481
|
+
var enumOf2 = (d, key) => {
|
|
8482
|
+
const v = descGet(d, key);
|
|
8483
|
+
return _optionalChain([v, 'optionalAccess', _220 => _220.type]) === "enum" ? v.value : void 0;
|
|
8484
|
+
};
|
|
8485
|
+
var numbers = (d, key) => {
|
|
8486
|
+
const v = descGet(d, key);
|
|
8487
|
+
if (_optionalChain([v, 'optionalAccess', _221 => _221.type]) !== "VlLs") return null;
|
|
8488
|
+
const out = [];
|
|
8489
|
+
for (const it of v.items) {
|
|
8490
|
+
if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
|
|
8491
|
+
else return null;
|
|
8492
|
+
}
|
|
8493
|
+
return out;
|
|
8494
|
+
};
|
|
8495
|
+
function setItem(d, key, v) {
|
|
8496
|
+
const i = d.items.findIndex(([k]) => k === key);
|
|
8497
|
+
if (i >= 0) d.items[i] = [key, v];
|
|
8498
|
+
else d.items.push([key, v]);
|
|
8499
|
+
}
|
|
8500
|
+
function cloneDescriptor(d) {
|
|
8501
|
+
return parseVersionedDescriptor(versionedDescriptorBytes(d));
|
|
8502
|
+
}
|
|
8503
|
+
function psdUuid(seed) {
|
|
8504
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(seed)) return seed;
|
|
8505
|
+
let hex = "";
|
|
8506
|
+
for (let k = 0; k < 4; k++) {
|
|
8507
|
+
let h = (2166136261 ^ k * 2654435769) >>> 0;
|
|
8508
|
+
for (let i = 0; i < seed.length; i++) h = Math.imul(h ^ seed.charCodeAt(i), 16777619) >>> 0;
|
|
8509
|
+
hex += h.toString(16).padStart(8, "0");
|
|
8510
|
+
}
|
|
8511
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
|
|
8512
|
+
}
|
|
8513
|
+
var LINKED_FILE_KEYS = ["lnk2", "lnk3", "lnkD", "lnkE"];
|
|
8514
|
+
function readLinkedItem(item) {
|
|
8515
|
+
const r = new PsdReader(item);
|
|
8516
|
+
const kind = r.ascii(4);
|
|
8517
|
+
const version = r.u32();
|
|
8518
|
+
const n = r.u8();
|
|
8519
|
+
const uuid = new TextDecoder().decode(r.bytes(n));
|
|
8520
|
+
const name = r.unicode();
|
|
8521
|
+
const fileType = r.ascii(4);
|
|
8522
|
+
r.skip(4);
|
|
8523
|
+
const len = r.u64();
|
|
8524
|
+
if (r.u8() !== 0) readVersionedDescriptor(r);
|
|
8525
|
+
if (kind === "liFD") return { kind, uuid, name, fileType, bytes: r.bytes(Math.min(len, r.remaining)) };
|
|
8526
|
+
let path;
|
|
8527
|
+
if (kind === "liFE") {
|
|
8528
|
+
try {
|
|
8529
|
+
const d = readVersionedDescriptor(r);
|
|
8530
|
+
path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
|
|
8531
|
+
} catch (e19) {
|
|
8532
|
+
path = void 0;
|
|
8533
|
+
}
|
|
8534
|
+
void version;
|
|
8535
|
+
}
|
|
8536
|
+
return { kind, uuid, name, fileType, bytes: new Uint8Array(0), path: _nullishCoalesce(path, () => ( name)) };
|
|
8537
|
+
}
|
|
8538
|
+
function parseLinkedFiles(data) {
|
|
8539
|
+
const out = [];
|
|
8540
|
+
let at = 0;
|
|
8541
|
+
while (at + 8 <= data.length) {
|
|
8542
|
+
const r = new PsdReader(data, at);
|
|
8543
|
+
const len = r.u64();
|
|
8544
|
+
if (!(len > 0) || at + 8 + len > data.length) break;
|
|
8545
|
+
try {
|
|
8546
|
+
const item = readLinkedItem(data.subarray(at + 8, at + 8 + len));
|
|
8547
|
+
if (item) out.push(item);
|
|
8548
|
+
} catch (e20) {
|
|
8549
|
+
}
|
|
8550
|
+
at = at + 8 + len + 3 & ~3;
|
|
7355
8551
|
}
|
|
7356
8552
|
return out;
|
|
7357
8553
|
}
|
|
@@ -7483,8 +8679,8 @@ function filterMaskItem(placed, mask, area) {
|
|
|
7483
8679
|
const painted = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
|
|
7484
8680
|
let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
7485
8681
|
if (mask.defaultValue !== 255 && area) {
|
|
7486
|
-
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
7487
|
-
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
8682
|
+
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _222 => _222.x]), () => ( area.x)));
|
|
8683
|
+
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _223 => _223.y]), () => ( area.y)));
|
|
7488
8684
|
const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
|
|
7489
8685
|
const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
|
|
7490
8686
|
b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
@@ -7504,12 +8700,12 @@ function filterMaskItem(placed, mask, area) {
|
|
|
7504
8700
|
}
|
|
7505
8701
|
var warpStyleOf = (name) => {
|
|
7506
8702
|
if (!name.startsWith("warp")) return null;
|
|
7507
|
-
const s = _optionalChain([name, 'access',
|
|
8703
|
+
const s = _optionalChain([name, 'access', _224 => _224[4], 'optionalAccess', _225 => _225.toLowerCase, 'call', _226 => _226()]) + name.slice(5);
|
|
7508
8704
|
return _chunkW3GXSUSQcjs.WARP_STYLES.includes(s) ? s : null;
|
|
7509
8705
|
};
|
|
7510
8706
|
function warpFromDescriptor(w, contents) {
|
|
7511
8707
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
7512
|
-
const styleName =
|
|
8708
|
+
const styleName = enumOf2(w, "warpStyle");
|
|
7513
8709
|
if (!styleName) return void 0;
|
|
7514
8710
|
if (styleName === "warpNone") return { mesh: null, frame: full };
|
|
7515
8711
|
const bd = descObject(w, "bounds");
|
|
@@ -7526,11 +8722,11 @@ function warpFromDescriptor(w, contents) {
|
|
|
7526
8722
|
if (!arr || arr.type !== "ObAr") return void 0;
|
|
7527
8723
|
const xs = descGet(arr.body, "Hrzn");
|
|
7528
8724
|
const ys = descGet(arr.body, "Vrtc");
|
|
7529
|
-
if (_optionalChain([xs, 'optionalAccess',
|
|
8725
|
+
if (_optionalChain([xs, 'optionalAccess', _227 => _227.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _228 => _228.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
|
|
7530
8726
|
mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
|
|
7531
|
-
const
|
|
8727
|
+
const px2 = mesh.points.map((p) => p.x);
|
|
7532
8728
|
const py = mesh.points.map((p) => p.y);
|
|
7533
|
-
const f = { x: Math.min(...
|
|
8729
|
+
const f = { x: Math.min(...px2), y: Math.min(...py), width: Math.max(...px2) - Math.min(...px2), height: Math.max(...py) - Math.min(...py) };
|
|
7534
8730
|
if (f.width > 1e-9 && f.height > 1e-9 && [f.x, f.y, f.width, f.height].every(Number.isFinite)) frame = f;
|
|
7535
8731
|
} else {
|
|
7536
8732
|
const style = warpStyleOf(styleName);
|
|
@@ -7541,7 +8737,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
7541
8737
|
bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
|
|
7542
8738
|
horizontal: _nullishCoalesce(descNumber(w, "warpPerspective"), () => ( 0)),
|
|
7543
8739
|
vertical: _nullishCoalesce(descNumber(w, "warpPerspectiveOther"), () => ( 0)),
|
|
7544
|
-
orientation:
|
|
8740
|
+
orientation: enumOf2(w, "warpRotate") === "Vrtc" ? "vertical" : "horizontal"
|
|
7545
8741
|
},
|
|
7546
8742
|
bounds
|
|
7547
8743
|
);
|
|
@@ -7558,20 +8754,20 @@ function warpDescriptor(mesh, contents) {
|
|
|
7558
8754
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
7559
8755
|
const single = mesh && mesh.us.length === 2 && mesh.vs.length === 2 && mesh.points.length === 16;
|
|
7560
8756
|
const bounds = descriptor("classFloatRect", [
|
|
7561
|
-
["Top ",
|
|
7562
|
-
["Left",
|
|
7563
|
-
["Btom",
|
|
7564
|
-
["Rght",
|
|
8757
|
+
["Top ", dbl2(0)],
|
|
8758
|
+
["Left", dbl2(0)],
|
|
8759
|
+
["Btom", dbl2(contents.height)],
|
|
8760
|
+
["Rght", dbl2(contents.width)]
|
|
7565
8761
|
]);
|
|
7566
8762
|
const items = [
|
|
7567
|
-
["warpStyle",
|
|
7568
|
-
["warpValue",
|
|
7569
|
-
["warpPerspective",
|
|
7570
|
-
["warpPerspectiveOther",
|
|
7571
|
-
["warpRotate",
|
|
7572
|
-
["bounds",
|
|
7573
|
-
["uOrder",
|
|
7574
|
-
["vOrder",
|
|
8763
|
+
["warpStyle", enumV2("warpStyle", single ? "warpCustom" : "warpNone")],
|
|
8764
|
+
["warpValue", dbl2(0)],
|
|
8765
|
+
["warpPerspective", dbl2(0)],
|
|
8766
|
+
["warpPerspectiveOther", dbl2(0)],
|
|
8767
|
+
["warpRotate", enumV2("Ornt", "Hrzn")],
|
|
8768
|
+
["bounds", obj2(bounds)],
|
|
8769
|
+
["uOrder", long3(4)],
|
|
8770
|
+
["vOrder", long3(4)]
|
|
7575
8771
|
];
|
|
7576
8772
|
let frame = full;
|
|
7577
8773
|
if (single) {
|
|
@@ -7579,10 +8775,10 @@ function warpDescriptor(mesh, contents) {
|
|
|
7579
8775
|
["Hrzn", { type: "UnFl", unit: "#Pxl", values: mesh.points.map((p) => p.x) }],
|
|
7580
8776
|
["Vrtc", { type: "UnFl", unit: "#Pxl", values: mesh.points.map((p) => p.y) }]
|
|
7581
8777
|
]);
|
|
7582
|
-
items.push(["customEnvelopeWarp",
|
|
7583
|
-
const
|
|
8778
|
+
items.push(["customEnvelopeWarp", obj2(descriptor("customEnvelopeWarp", [["meshPoints", { type: "ObAr", prefix: 16, body }]]))]);
|
|
8779
|
+
const px2 = mesh.points.map((p) => p.x);
|
|
7584
8780
|
const py = mesh.points.map((p) => p.y);
|
|
7585
|
-
frame = { x: Math.min(...
|
|
8781
|
+
frame = { x: Math.min(...px2), y: Math.min(...py), width: Math.max(...px2) - Math.min(...px2), height: Math.max(...py) - Math.min(...py) };
|
|
7586
8782
|
}
|
|
7587
8783
|
return { warp: descriptor("warp", items), frame, dropped: Boolean(mesh && !single) };
|
|
7588
8784
|
}
|
|
@@ -7647,13 +8843,13 @@ function parsePlaced(key, data) {
|
|
|
7647
8843
|
r.u32();
|
|
7648
8844
|
try {
|
|
7649
8845
|
warp = readVersionedDescriptor(r);
|
|
7650
|
-
} catch (
|
|
8846
|
+
} catch (e21) {
|
|
7651
8847
|
warp = void 0;
|
|
7652
8848
|
}
|
|
7653
8849
|
}
|
|
7654
8850
|
return { key, idnt, placed: idnt, quad, warp };
|
|
7655
8851
|
}
|
|
7656
|
-
} catch (
|
|
8852
|
+
} catch (e22) {
|
|
7657
8853
|
return null;
|
|
7658
8854
|
}
|
|
7659
8855
|
return null;
|
|
@@ -7679,27 +8875,27 @@ var BOX_BLUR = { classId: "boxblur", id: 840, name: "Box Blur..." };
|
|
|
7679
8875
|
function blendOptionsOf(item) {
|
|
7680
8876
|
const o = descObject(item, "blendOptions");
|
|
7681
8877
|
const opacity = o ? Math.min(1, Math.max(0, (_nullishCoalesce(descNumber(o, "Opct"), () => ( 100))) / 100)) : 1;
|
|
7682
|
-
const id = o ?
|
|
8878
|
+
const id = o ? enumOf2(o, "Md ") : void 0;
|
|
7683
8879
|
return { blend: id && blendFromPsdId(id) || "normal", opacity };
|
|
7684
8880
|
}
|
|
7685
8881
|
function blendOptions(f) {
|
|
7686
|
-
return
|
|
8882
|
+
return obj2(
|
|
7687
8883
|
descriptor("blendOptions", [
|
|
7688
|
-
["Opct",
|
|
7689
|
-
["Md ",
|
|
8884
|
+
["Opct", unit2("#Prc", Math.min(1, Math.max(0, f.opacity)) * 100)],
|
|
8885
|
+
["Md ", enumV2("BlnM", psdBlendId(f.blend))]
|
|
7690
8886
|
])
|
|
7691
8887
|
);
|
|
7692
8888
|
}
|
|
7693
8889
|
function smartFiltersFromPsd(fx, newId, notes) {
|
|
7694
8890
|
const filters = [];
|
|
7695
8891
|
const list2 = descGet(fx, "filterFXList");
|
|
7696
|
-
for (const v of _optionalChain([list2, 'optionalAccess',
|
|
8892
|
+
for (const v of _optionalChain([list2, 'optionalAccess', _229 => _229.type]) === "VlLs" ? list2.items : []) {
|
|
7697
8893
|
if (v.type !== "Objc" && v.type !== "GlbO") continue;
|
|
7698
8894
|
const item = v.value;
|
|
7699
8895
|
const { blend, opacity } = blendOptionsOf(item);
|
|
7700
8896
|
const enabled = descBool(item, "enab") !== false;
|
|
7701
8897
|
const fltr = descObject(item, "Fltr");
|
|
7702
|
-
const radius = _optionalChain([fltr, 'optionalAccess',
|
|
8898
|
+
const radius = _optionalChain([fltr, 'optionalAccess', _230 => _230.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
|
|
7703
8899
|
if (radius !== void 0 && radius >= 0 && radius <= 50) {
|
|
7704
8900
|
filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
|
|
7705
8901
|
continue;
|
|
@@ -7707,7 +8903,7 @@ function smartFiltersFromPsd(fx, newId, notes) {
|
|
|
7707
8903
|
const name = (_nullishCoalesce(text(item, "Nm "), () => ( "Filter"))).replace(/&/g, "");
|
|
7708
8904
|
const neutral = cloneDescriptor(item);
|
|
7709
8905
|
setItem(neutral, "blendOptions", blendOptions({ blend: "normal", opacity: 1 }));
|
|
7710
|
-
setItem(neutral, "enab",
|
|
8906
|
+
setItem(neutral, "enab", boolV2(true));
|
|
7711
8907
|
filters.push({ id: newId(), kind: "psd", enabled, name, data: versionedDescriptorBytes(neutral), blend, opacity });
|
|
7712
8908
|
notes.push(`the ${name.replace(/\.\.\.$/, "")} smart filter is kept but not drawn`);
|
|
7713
8909
|
}
|
|
@@ -7719,32 +8915,32 @@ function filterFXDescriptor(stack, dropped) {
|
|
|
7719
8915
|
if (f.kind === "psd") {
|
|
7720
8916
|
const d = parseVersionedDescriptor(f.data);
|
|
7721
8917
|
setItem(d, "blendOptions", blendOptions(f));
|
|
7722
|
-
setItem(d, "enab",
|
|
7723
|
-
list2.push(
|
|
8918
|
+
setItem(d, "enab", boolV2(f.enabled));
|
|
8919
|
+
list2.push(obj2(d));
|
|
7724
8920
|
} else if (f.kind === "blur") {
|
|
7725
|
-
const rgb = (v) =>
|
|
8921
|
+
const rgb = (v) => obj2(descriptor("RGBC", [["Rd ", dbl2(v)], ["Grn ", dbl2(v)], ["Bl ", dbl2(v)]]));
|
|
7726
8922
|
list2.push(
|
|
7727
|
-
|
|
8923
|
+
obj2(
|
|
7728
8924
|
descriptor("filterFX", [
|
|
7729
8925
|
["Nm ", textV(BOX_BLUR.name)],
|
|
7730
8926
|
["blendOptions", blendOptions(f)],
|
|
7731
|
-
["enab",
|
|
7732
|
-
["hasoptions",
|
|
8927
|
+
["enab", boolV2(f.enabled)],
|
|
8928
|
+
["hasoptions", boolV2(true)],
|
|
7733
8929
|
["FrgC", rgb(0)],
|
|
7734
8930
|
["BckC", rgb(255)],
|
|
7735
|
-
["Fltr",
|
|
7736
|
-
["filterID",
|
|
8931
|
+
["Fltr", obj2(descriptor(BOX_BLUR.classId, [["Rds ", unit2("#Pxl", f.radius)]]))],
|
|
8932
|
+
["filterID", long3(BOX_BLUR.id)]
|
|
7737
8933
|
])
|
|
7738
8934
|
)
|
|
7739
8935
|
);
|
|
7740
8936
|
} else dropped.push(f.kind);
|
|
7741
8937
|
}
|
|
7742
8938
|
return descriptor("filterFXStyle", [
|
|
7743
|
-
["enab",
|
|
7744
|
-
["validAtPosition",
|
|
7745
|
-
["filterMaskEnable",
|
|
7746
|
-
["filterMaskLinked",
|
|
7747
|
-
["filterMaskExtendWithWhite",
|
|
8939
|
+
["enab", boolV2(stack.enabled)],
|
|
8940
|
+
["validAtPosition", boolV2(true)],
|
|
8941
|
+
["filterMaskEnable", boolV2(stack.mask ? stack.mask.enabled !== false : true)],
|
|
8942
|
+
["filterMaskLinked", boolV2(stack.mask ? stack.mask.linked !== false : false)],
|
|
8943
|
+
["filterMaskExtendWithWhite", boolV2(true)],
|
|
7748
8944
|
["filterFXList", { type: "VlLs", items: list2 }]
|
|
7749
8945
|
]);
|
|
7750
8946
|
}
|
|
@@ -7759,7 +8955,7 @@ function filterStackKey(stack) {
|
|
|
7759
8955
|
function soldBytes(s, notes) {
|
|
7760
8956
|
const { warp, frame, dropped } = warpDescriptor(s.placement.warp, s.size);
|
|
7761
8957
|
if (dropped) notes.push("a warp of several patches was written without its warp (the layer\u2019s pixels still show it)");
|
|
7762
|
-
const quad = { type: "VlLs", items: quadFromCorners(s.placement.corners, frame, s.size).map(
|
|
8958
|
+
const quad = { type: "VlLs", items: quadFromCorners(s.placement.corners, frame, s.size).map(dbl2) };
|
|
7763
8959
|
let d;
|
|
7764
8960
|
if (s.template) {
|
|
7765
8961
|
d = cloneDescriptor(s.template);
|
|
@@ -7767,31 +8963,31 @@ function soldBytes(s, notes) {
|
|
|
7767
8963
|
setItem(d, "placed", textV(s.placed));
|
|
7768
8964
|
setItem(d, "Trnf", quad);
|
|
7769
8965
|
setItem(d, "nonAffineTransform", quad);
|
|
7770
|
-
setItem(d, "warp",
|
|
7771
|
-
setItem(d, "Sz ",
|
|
7772
|
-
if (s.filterFX) setItem(d, "filterFX",
|
|
8966
|
+
setItem(d, "warp", obj2(warp));
|
|
8967
|
+
setItem(d, "Sz ", obj2(descriptor("Pnt ", [["Wdth", dbl2(s.size.width)], ["Hght", dbl2(s.size.height)]])));
|
|
8968
|
+
if (s.filterFX) setItem(d, "filterFX", obj2(s.filterFX));
|
|
7773
8969
|
else d.items = d.items.filter(([k]) => k !== "filterFX");
|
|
7774
8970
|
} else {
|
|
7775
|
-
const ratio = (n, den) =>
|
|
8971
|
+
const ratio = (n, den) => obj2(descriptor("null", [["numerator", long3(n)], ["denominator", long3(den)]]));
|
|
7776
8972
|
const items = [
|
|
7777
8973
|
["Idnt", textV(s.idnt)],
|
|
7778
8974
|
["placed", textV(s.placed)],
|
|
7779
|
-
["PgNm",
|
|
7780
|
-
["totalPages",
|
|
7781
|
-
["Crop",
|
|
8975
|
+
["PgNm", long3(1)],
|
|
8976
|
+
["totalPages", long3(1)],
|
|
8977
|
+
["Crop", long3(1)],
|
|
7782
8978
|
["frameStep", ratio(0, 600)],
|
|
7783
8979
|
["duration", ratio(0, 600)],
|
|
7784
|
-
["frameCount",
|
|
7785
|
-
["Annt",
|
|
7786
|
-
["Type",
|
|
8980
|
+
["frameCount", long3(1)],
|
|
8981
|
+
["Annt", long3(16)],
|
|
8982
|
+
["Type", long3(2)],
|
|
7787
8983
|
["Trnf", quad],
|
|
7788
8984
|
["nonAffineTransform", quad],
|
|
7789
|
-
["warp",
|
|
7790
|
-
["Sz ",
|
|
7791
|
-
["Rslt",
|
|
8985
|
+
["warp", obj2(warp)],
|
|
8986
|
+
["Sz ", obj2(descriptor("Pnt ", [["Wdth", dbl2(s.size.width)], ["Hght", dbl2(s.size.height)]]))],
|
|
8987
|
+
["Rslt", unit2("#Rsl", 72)]
|
|
7792
8988
|
];
|
|
7793
|
-
if (s.filterFX) items.push(["filterFX",
|
|
7794
|
-
items.push(["comp",
|
|
8989
|
+
if (s.filterFX) items.push(["filterFX", obj2(s.filterFX)]);
|
|
8990
|
+
items.push(["comp", long3(-1)], ["compInfo", obj2(descriptor("null", [["compID", long3(-1)], ["originalCompID", long3(-1)]]))]);
|
|
7795
8991
|
d = descriptor("null", items);
|
|
7796
8992
|
}
|
|
7797
8993
|
const w = new PsdWriter();
|
|
@@ -7978,7 +9174,7 @@ function parseMask(d) {
|
|
|
7978
9174
|
}
|
|
7979
9175
|
if (!realFirst) m.real = readReal();
|
|
7980
9176
|
return m;
|
|
7981
|
-
} catch (
|
|
9177
|
+
} catch (e23) {
|
|
7982
9178
|
return void 0;
|
|
7983
9179
|
}
|
|
7984
9180
|
}
|
|
@@ -8011,9 +9207,9 @@ function readLayerInfo(data, psb) {
|
|
|
8011
9207
|
const count = r.i16();
|
|
8012
9208
|
const n = Math.abs(count);
|
|
8013
9209
|
r.checkCount(n, 34, "Layer records");
|
|
8014
|
-
const
|
|
8015
|
-
for (let i = 0; i < n; i++)
|
|
8016
|
-
for (const { record, lengths } of
|
|
9210
|
+
const read2 = [];
|
|
9211
|
+
for (let i = 0; i < n; i++) read2.push(readLayerRecord(r, psb));
|
|
9212
|
+
for (const { record, lengths } of read2) {
|
|
8017
9213
|
record.channels.forEach((ch, i) => {
|
|
8018
9214
|
const len = lengths[i];
|
|
8019
9215
|
if (len === 0) return;
|
|
@@ -8022,7 +9218,7 @@ function readLayerInfo(data, psb) {
|
|
|
8022
9218
|
ch.data = r.bytes(len - 2);
|
|
8023
9219
|
});
|
|
8024
9220
|
}
|
|
8025
|
-
return { layers:
|
|
9221
|
+
return { layers: read2.map((x) => x.record), mergedAlpha: count < 0 };
|
|
8026
9222
|
}
|
|
8027
9223
|
function readPsd(bytes) {
|
|
8028
9224
|
const r = new PsdReader(bytes);
|
|
@@ -8052,14 +9248,14 @@ function readPsd(bytes) {
|
|
|
8052
9248
|
return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
|
|
8053
9249
|
}
|
|
8054
9250
|
function layerBlock(rec, key) {
|
|
8055
|
-
return _optionalChain([rec, 'access',
|
|
9251
|
+
return _optionalChain([rec, 'access', _231 => _231.blocks, 'access', _232 => _232.find, 'call', _233 => _233((b) => b.key === key), 'optionalAccess', _234 => _234.data]);
|
|
8056
9252
|
}
|
|
8057
9253
|
function layerName(rec) {
|
|
8058
9254
|
const luni = layerBlock(rec, "luni");
|
|
8059
9255
|
if (luni) {
|
|
8060
9256
|
try {
|
|
8061
9257
|
return new PsdReader(luni).unicode();
|
|
8062
|
-
} catch (
|
|
9258
|
+
} catch (e24) {
|
|
8063
9259
|
}
|
|
8064
9260
|
}
|
|
8065
9261
|
return rec.legacyName;
|
|
@@ -8083,7 +9279,7 @@ function u8Block(rec, key) {
|
|
|
8083
9279
|
function layerTree(file) {
|
|
8084
9280
|
const stack = [[]];
|
|
8085
9281
|
file.layers.forEach((rec, index) => {
|
|
8086
|
-
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call',
|
|
9282
|
+
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _235 => _235(rec), 'optionalAccess', _236 => _236.kind]), () => ( SECTION_OTHER));
|
|
8087
9283
|
if (kind === SECTION_DIVIDER) {
|
|
8088
9284
|
stack.push([]);
|
|
8089
9285
|
} else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
|
|
@@ -8101,7 +9297,7 @@ function layerTree(file) {
|
|
|
8101
9297
|
}
|
|
8102
9298
|
function channelRect(rec, id) {
|
|
8103
9299
|
if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
|
|
8104
|
-
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access',
|
|
9300
|
+
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _237 => _237.mask, 'access', _238 => _238.real, 'optionalAccess', _239 => _239.rect]), () => ( rec.mask.rect));
|
|
8105
9301
|
return rec.rect;
|
|
8106
9302
|
}
|
|
8107
9303
|
function decodeLayerChannel(file, rec, id) {
|
|
@@ -8119,7 +9315,7 @@ function decodeMergedImage(file) {
|
|
|
8119
9315
|
return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
|
|
8120
9316
|
}
|
|
8121
9317
|
function resource(file, id) {
|
|
8122
|
-
return _optionalChain([file, 'access',
|
|
9318
|
+
return _optionalChain([file, 'access', _240 => _240.resources, 'access', _241 => _241.find, 'call', _242 => _242((r) => r.id === id), 'optionalAccess', _243 => _243.data]);
|
|
8123
9319
|
}
|
|
8124
9320
|
function resolution(file) {
|
|
8125
9321
|
const d = resource(file, 1005);
|
|
@@ -8134,11 +9330,11 @@ function writeRect(w, r) {
|
|
|
8134
9330
|
}
|
|
8135
9331
|
function writeBlocks(w, blocks, psb, alignment) {
|
|
8136
9332
|
for (const b of blocks) {
|
|
8137
|
-
const
|
|
8138
|
-
w.ascii(
|
|
9333
|
+
const long5 = psb && PSB_LONG_KEYS.has(b.key);
|
|
9334
|
+
w.ascii(long5 ? "8B64" : "8BIM");
|
|
8139
9335
|
w.ascii(b.key);
|
|
8140
9336
|
const pad = (alignment - b.data.length % alignment) % alignment;
|
|
8141
|
-
if (
|
|
9337
|
+
if (long5) w.u64(b.data.length + pad);
|
|
8142
9338
|
else w.u32(b.data.length + pad);
|
|
8143
9339
|
w.bytes(b.data);
|
|
8144
9340
|
w.zeros(pad);
|
|
@@ -8559,7 +9755,7 @@ var PSD_BLEND_KEYS = {
|
|
|
8559
9755
|
var BLEND_TO_PSD = Object.fromEntries(
|
|
8560
9756
|
Object.entries(PSD_BLEND_KEYS).map(([k, v]) => [v, k])
|
|
8561
9757
|
);
|
|
8562
|
-
var FILL_KEYS = ["SoCo", "GdFl", "PtFl"];
|
|
9758
|
+
var FILL_KEYS = ["SoCo", "GdFl", "PtFl", "vscg"];
|
|
8563
9759
|
var TYPE_KEYS = ["TySh", "tySh"];
|
|
8564
9760
|
var SMART_KEYS = ["SoLd", "SoLE", "PlLd"];
|
|
8565
9761
|
var VECTOR_KEYS = ["vmsk", "vsms"];
|
|
@@ -8740,7 +9936,7 @@ function importNode(ctx, node, depth) {
|
|
|
8740
9936
|
if (node.children) {
|
|
8741
9937
|
const props2 = baseProps(ctx, rec, name, notes);
|
|
8742
9938
|
const divider = sectionDivider(rec);
|
|
8743
|
-
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess',
|
|
9939
|
+
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _244 => _244.blendKey]), () => ( rec.blendKey));
|
|
8744
9940
|
const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
|
|
8745
9941
|
const children = [];
|
|
8746
9942
|
for (const child of node.children) {
|
|
@@ -8750,7 +9946,7 @@ function importNode(ctx, node, depth) {
|
|
|
8750
9946
|
const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
|
|
8751
9947
|
const effects2 = recordEffects(ctx, rec, name, notes, true);
|
|
8752
9948
|
if (effects2) group.effects = effects2;
|
|
8753
|
-
if (_optionalChain([divider, 'optionalAccess',
|
|
9949
|
+
if (_optionalChain([divider, 'optionalAccess', _245 => _245.kind]) === SECTION_CLOSED) group.collapsed = true;
|
|
8754
9950
|
const mask2 = recordMask(ctx, rec, name);
|
|
8755
9951
|
if (mask2) group.mask = mask2;
|
|
8756
9952
|
entry.type = "group";
|
|
@@ -8802,6 +9998,24 @@ function importNode(ctx, node, depth) {
|
|
|
8802
9998
|
return smart;
|
|
8803
9999
|
}
|
|
8804
10000
|
}
|
|
10001
|
+
if (kind === "shape") {
|
|
10002
|
+
const shape = importShape(ctx, rec, name, notes, props);
|
|
10003
|
+
if (shape) {
|
|
10004
|
+
entry.type = "shape";
|
|
10005
|
+
entry.id = shape.id;
|
|
10006
|
+
entry.status = notes.length ? "approximated" : "mapped";
|
|
10007
|
+
return shape;
|
|
10008
|
+
}
|
|
10009
|
+
}
|
|
10010
|
+
if (kind === "type") {
|
|
10011
|
+
const type = importType(ctx, rec, name, notes, props);
|
|
10012
|
+
if (type) {
|
|
10013
|
+
entry.type = "type";
|
|
10014
|
+
entry.id = type.id;
|
|
10015
|
+
entry.status = notes.length ? "approximated" : "mapped";
|
|
10016
|
+
return type;
|
|
10017
|
+
}
|
|
10018
|
+
}
|
|
8805
10019
|
if (kind !== "pixel") {
|
|
8806
10020
|
const what = kind === "smart-object" ? "Smart objects" : kind === "type" ? "Type layers" : kind === "shape" ? "Shape layers" : "Fill layers";
|
|
8807
10021
|
ctx.warn.add(`${what} came in as pixel layers (their stored pixels)`, name);
|
|
@@ -8819,6 +10033,69 @@ function importNode(ctx, node, depth) {
|
|
|
8819
10033
|
entry.status = notes.length ? "approximated" : "mapped";
|
|
8820
10034
|
return layer;
|
|
8821
10035
|
}
|
|
10036
|
+
function importShape(ctx, rec, name, notes, props) {
|
|
10037
|
+
const approx = /* @__PURE__ */ new Set();
|
|
10038
|
+
const { width, height } = ctx.file.header;
|
|
10039
|
+
const data = shapeFromBlocks(rec.blocks, width, height, ctx.dpi, approx);
|
|
10040
|
+
if (!data) return null;
|
|
10041
|
+
for (const n of approx) {
|
|
10042
|
+
ctx.warn.add(`A shape layer was approximated: ${n}`, name);
|
|
10043
|
+
notes.push(n);
|
|
10044
|
+
}
|
|
10045
|
+
const layer = {
|
|
10046
|
+
type: "shape",
|
|
10047
|
+
id: ctx.newId(name),
|
|
10048
|
+
...props,
|
|
10049
|
+
components: data.components,
|
|
10050
|
+
fill: data.fill,
|
|
10051
|
+
stroke: data.stroke,
|
|
10052
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
10053
|
+
offset: { x: 0, y: 0 }
|
|
10054
|
+
};
|
|
10055
|
+
if (data.inverted) layer.inverted = true;
|
|
10056
|
+
if (!ctx.skipPixels) layer.surface = renderShape(layer, { width, height, pattern: (id) => _nullishCoalesce(ctx.patterns.get(id), () => ( null)) });
|
|
10057
|
+
layer.psd = { blocks: rec.blocks.filter((b) => SHAPE_PSD_KEYS.includes(b.key)).map((b) => ({ key: b.key, data: b.data.slice() })), signature: shapeSignature(layer) };
|
|
10058
|
+
const fill = u8Block(rec, "iOpa");
|
|
10059
|
+
if (fill !== void 0 && fill < 255) layer.fillOpacity = percent(fill);
|
|
10060
|
+
const effects = recordEffects(ctx, rec, name, notes, false);
|
|
10061
|
+
if (effects) layer.effects = effects;
|
|
10062
|
+
const mask = recordMask(ctx, rec, name);
|
|
10063
|
+
if (mask) layer.mask = mask;
|
|
10064
|
+
return layer;
|
|
10065
|
+
}
|
|
10066
|
+
function importType(ctx, rec, name, notes, props) {
|
|
10067
|
+
const block = rec.blocks.find((b) => b.key === "TySh" || b.key === "tySh");
|
|
10068
|
+
if (!block || block.key !== "TySh") return null;
|
|
10069
|
+
const approx = /* @__PURE__ */ new Set();
|
|
10070
|
+
const data = typeFromTySh(block.data, approx);
|
|
10071
|
+
if (!data) return null;
|
|
10072
|
+
for (const n of approx) {
|
|
10073
|
+
ctx.warn.add(`A type layer was approximated: ${n}`, name);
|
|
10074
|
+
notes.push(n);
|
|
10075
|
+
}
|
|
10076
|
+
const layer = {
|
|
10077
|
+
type: "type",
|
|
10078
|
+
id: ctx.newId(name),
|
|
10079
|
+
...props,
|
|
10080
|
+
text: data.text,
|
|
10081
|
+
runs: data.runs,
|
|
10082
|
+
paragraphs: data.paragraphs,
|
|
10083
|
+
frame: data.frame,
|
|
10084
|
+
transform: data.transform,
|
|
10085
|
+
surface: recordPixels(ctx, rec, name),
|
|
10086
|
+
offset: { x: 0, y: 0 },
|
|
10087
|
+
rendering: "stored"
|
|
10088
|
+
};
|
|
10089
|
+
if (!data.antiAlias) layer.antiAlias = false;
|
|
10090
|
+
layer.psd = { tySh: block.data.slice(), signature: typeSignature(layer) };
|
|
10091
|
+
const fill = u8Block(rec, "iOpa");
|
|
10092
|
+
if (fill !== void 0 && fill < 255) layer.fillOpacity = percent(fill);
|
|
10093
|
+
const effects = recordEffects(ctx, rec, name, notes, false);
|
|
10094
|
+
if (effects) layer.effects = effects;
|
|
10095
|
+
const mask = recordMask(ctx, rec, name);
|
|
10096
|
+
if (mask) layer.mask = mask;
|
|
10097
|
+
return layer;
|
|
10098
|
+
}
|
|
8822
10099
|
function contentsFor(ctx, placed, name, notes) {
|
|
8823
10100
|
const memo = ctx.contents.get(placed.idnt);
|
|
8824
10101
|
if (memo !== void 0) return memo;
|
|
@@ -8892,7 +10169,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
8892
10169
|
const file = ctx.linked.get(placed.idnt);
|
|
8893
10170
|
contents = {
|
|
8894
10171
|
id: placed.idnt || ctx.newId(`${name}-contents`),
|
|
8895
|
-
name: _optionalChain([file, 'optionalAccess',
|
|
10172
|
+
name: _optionalChain([file, 'optionalAccess', _246 => _246.name]) || `${name}.png`,
|
|
8896
10173
|
width,
|
|
8897
10174
|
height,
|
|
8898
10175
|
kind: "raster",
|
|
@@ -8990,7 +10267,8 @@ function psdToLayers(file, options = {}) {
|
|
|
8990
10267
|
linked: /* @__PURE__ */ new Map(),
|
|
8991
10268
|
filterItems: /* @__PURE__ */ new Map(),
|
|
8992
10269
|
contents: /* @__PURE__ */ new Map(),
|
|
8993
|
-
depth: _nullishCoalesce(options.depth, () => ( 0))
|
|
10270
|
+
depth: _nullishCoalesce(options.depth, () => ( 0)),
|
|
10271
|
+
dpi: _nullishCoalesce(resolution(file), () => ( 72))
|
|
8994
10272
|
};
|
|
8995
10273
|
for (const block of file.globalBlocks) {
|
|
8996
10274
|
if (LINKED_FILE_KEYS.includes(block.key)) {
|
|
@@ -9115,29 +10393,29 @@ function psdBlendId(mode) {
|
|
|
9115
10393
|
var num3 = (d, key, fallback) => _nullishCoalesce(descNumber(d, key), () => ( fallback));
|
|
9116
10394
|
var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
|
|
9117
10395
|
var bool = (d, key) => descBool(d, key) === true;
|
|
9118
|
-
var
|
|
10396
|
+
var enumOf3 = (d, key) => {
|
|
9119
10397
|
const v = descGet(d, key);
|
|
9120
|
-
return _optionalChain([v, 'optionalAccess',
|
|
10398
|
+
return _optionalChain([v, 'optionalAccess', _247 => _247.type]) === "enum" ? v.value : void 0;
|
|
9121
10399
|
};
|
|
9122
10400
|
var text2 = (d, key) => {
|
|
9123
10401
|
const v = d ? descGet(d, key) : void 0;
|
|
9124
|
-
return _optionalChain([v, 'optionalAccess',
|
|
10402
|
+
return _optionalChain([v, 'optionalAccess', _248 => _248.type]) === "TEXT" ? v.value : "";
|
|
9125
10403
|
};
|
|
9126
10404
|
var list = (d, key) => {
|
|
9127
10405
|
const v = descGet(d, key);
|
|
9128
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
10406
|
+
if (_optionalChain([v, 'optionalAccess', _249 => _249.type]) !== "VlLs") return [];
|
|
9129
10407
|
return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
|
|
9130
10408
|
};
|
|
9131
10409
|
var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
|
|
9132
|
-
var
|
|
9133
|
-
var
|
|
9134
|
-
var
|
|
9135
|
-
var
|
|
9136
|
-
var
|
|
10410
|
+
var unit3 = (u, value) => ({ type: "UntF", unit: u, value });
|
|
10411
|
+
var dbl3 = (value) => ({ type: "doub", value });
|
|
10412
|
+
var long4 = (value) => ({ type: "long", value: Math.round(value) });
|
|
10413
|
+
var boolV3 = (value) => ({ type: "bool", value });
|
|
10414
|
+
var enumV3 = (typeId, value) => ({ type: "enum", typeId, value });
|
|
9137
10415
|
var textV2 = (value) => ({ type: "TEXT", value });
|
|
9138
|
-
var
|
|
10416
|
+
var obj3 = (d) => ({ type: "Objc", value: d });
|
|
9139
10417
|
function blendOf(d, key, fallback, notes) {
|
|
9140
|
-
const id =
|
|
10418
|
+
const id = enumOf3(d, key);
|
|
9141
10419
|
if (id === void 0) return fallback;
|
|
9142
10420
|
const m = BLEND_OF.get(id);
|
|
9143
10421
|
if (m) return m;
|
|
@@ -9176,9 +10454,9 @@ function colorOf(d, fallback = "#000000") {
|
|
|
9176
10454
|
function colorDesc(hex) {
|
|
9177
10455
|
const [r, g, b] = _nullishCoalesce(_chunkPOGBUYWEcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
|
|
9178
10456
|
return descriptor("RGBC", [
|
|
9179
|
-
["Rd ",
|
|
9180
|
-
["Grn ",
|
|
9181
|
-
["Bl ",
|
|
10457
|
+
["Rd ", dbl3(r * 255)],
|
|
10458
|
+
["Grn ", dbl3(g * 255)],
|
|
10459
|
+
["Bl ", dbl3(b * 255)]
|
|
9182
10460
|
]);
|
|
9183
10461
|
}
|
|
9184
10462
|
function contourOf(d, key) {
|
|
@@ -9195,8 +10473,8 @@ function contourOf(d, key) {
|
|
|
9195
10473
|
return { name, points };
|
|
9196
10474
|
}
|
|
9197
10475
|
function contourDesc(c) {
|
|
9198
|
-
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
9199
|
-
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
10476
|
+
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _250 => _250.name]), () => ( "Linear"));
|
|
10477
|
+
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _251 => _251.points]), () => ( [
|
|
9200
10478
|
{ input: 0, output: 0 },
|
|
9201
10479
|
{ input: 1, output: 1 }
|
|
9202
10480
|
]));
|
|
@@ -9204,14 +10482,14 @@ function contourDesc(c) {
|
|
|
9204
10482
|
type: "VlLs",
|
|
9205
10483
|
items: points.map((p) => {
|
|
9206
10484
|
const items = [
|
|
9207
|
-
["Hrzn",
|
|
9208
|
-
["Vrtc",
|
|
10485
|
+
["Hrzn", dbl3(p.input * 255)],
|
|
10486
|
+
["Vrtc", dbl3(p.output * 255)]
|
|
9209
10487
|
];
|
|
9210
|
-
if (p.corner) items.push(["Cnty",
|
|
9211
|
-
return
|
|
10488
|
+
if (p.corner) items.push(["Cnty", boolV3(false)]);
|
|
10489
|
+
return obj3(descriptor("CrPt", items));
|
|
9212
10490
|
})
|
|
9213
10491
|
};
|
|
9214
|
-
return
|
|
10492
|
+
return obj3(
|
|
9215
10493
|
descriptor("ShpC", [
|
|
9216
10494
|
["Nm ", textV2(name)],
|
|
9217
10495
|
["Crv ", pts]
|
|
@@ -9231,7 +10509,7 @@ function gradientOf(d, notes) {
|
|
|
9231
10509
|
{ position: 0, color: "#000000" },
|
|
9232
10510
|
{ position: 1, color: "#ffffff" }
|
|
9233
10511
|
],
|
|
9234
|
-
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access',
|
|
10512
|
+
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _252 => _252.find, 'call', _253 => _253(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _254 => _254[0]]), () => ( "linear")),
|
|
9235
10513
|
angle: clamp3(num3(d, "Angl", 90), -360, 360),
|
|
9236
10514
|
scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
|
|
9237
10515
|
reverse: bool(d, "Rvrs"),
|
|
@@ -9242,12 +10520,12 @@ function gradientOf(d, notes) {
|
|
|
9242
10520
|
if (off) g.offset = { x: clamp3(pct(off, "Hrzn", 0), -1, 1), y: clamp3(pct(off, "Vrtc", 0), -1, 1) };
|
|
9243
10521
|
const grad = descObject(d, "Grad");
|
|
9244
10522
|
if (!grad) return g;
|
|
9245
|
-
if (
|
|
10523
|
+
if (enumOf3(grad, "GrdF") === "ClNs") {
|
|
9246
10524
|
notes.add("noise gradients became black to white");
|
|
9247
10525
|
return g;
|
|
9248
10526
|
}
|
|
9249
10527
|
const raw = list(grad, "Clrs").map((s) => {
|
|
9250
|
-
const type =
|
|
10528
|
+
const type = enumOf3(s, "Type");
|
|
9251
10529
|
if (type === "FrgC" || type === "BckC") notes.add("foreground / background gradient stops became black / white");
|
|
9252
10530
|
const color = type === "BckC" ? "#ffffff" : colorOf(descObject(s, "Clr "));
|
|
9253
10531
|
return { position: clamp3(num3(s, "Lctn", 0) / 4096, 0, 1), color, mid: clamp3(num3(s, "Mdpn", 50) / 100, 0.05, 0.95) };
|
|
@@ -9275,49 +10553,49 @@ function gradientItems(g) {
|
|
|
9275
10553
|
const clrs = {
|
|
9276
10554
|
type: "VlLs",
|
|
9277
10555
|
items: g.stops.map(
|
|
9278
|
-
(s) =>
|
|
10556
|
+
(s) => obj3(
|
|
9279
10557
|
descriptor("Clrt", [
|
|
9280
|
-
["Clr ",
|
|
9281
|
-
["Type",
|
|
9282
|
-
["Lctn",
|
|
9283
|
-
["Mdpn",
|
|
10558
|
+
["Clr ", obj3(colorDesc(s.color))],
|
|
10559
|
+
["Type", enumV3("Clry", "UsrS")],
|
|
10560
|
+
["Lctn", long4(s.position * 4096)],
|
|
10561
|
+
["Mdpn", long4(50)]
|
|
9284
10562
|
])
|
|
9285
10563
|
)
|
|
9286
10564
|
)
|
|
9287
10565
|
};
|
|
9288
|
-
const op = _optionalChain([g, 'access',
|
|
10566
|
+
const op = _optionalChain([g, 'access', _255 => _255.opacityStops, 'optionalAccess', _256 => _256.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
|
|
9289
10567
|
const trns = {
|
|
9290
10568
|
type: "VlLs",
|
|
9291
10569
|
items: op.map(
|
|
9292
|
-
(s) =>
|
|
10570
|
+
(s) => obj3(
|
|
9293
10571
|
descriptor("TrnS", [
|
|
9294
|
-
["Opct",
|
|
9295
|
-
["Lctn",
|
|
9296
|
-
["Mdpn",
|
|
10572
|
+
["Opct", unit3("#Prc", s.opacity * 100)],
|
|
10573
|
+
["Lctn", long4(s.position * 4096)],
|
|
10574
|
+
["Mdpn", long4(50)]
|
|
9297
10575
|
])
|
|
9298
10576
|
)
|
|
9299
10577
|
)
|
|
9300
10578
|
};
|
|
9301
10579
|
const grad = descriptor("Grdn", [
|
|
9302
10580
|
["Nm ", textV2("Custom")],
|
|
9303
|
-
["GrdF",
|
|
9304
|
-
["Intr",
|
|
10581
|
+
["GrdF", enumV3("GrdF", "CstS")],
|
|
10582
|
+
["Intr", dbl3(0)],
|
|
9305
10583
|
["Clrs", clrs],
|
|
9306
10584
|
["Trns", trns]
|
|
9307
10585
|
]);
|
|
9308
10586
|
return [
|
|
9309
|
-
["Grad",
|
|
9310
|
-
["Angl",
|
|
9311
|
-
["Type",
|
|
9312
|
-
["Rvrs",
|
|
9313
|
-
["Algn",
|
|
9314
|
-
["Scl ",
|
|
10587
|
+
["Grad", obj3(grad)],
|
|
10588
|
+
["Angl", unit3("#Ang", g.angle)],
|
|
10589
|
+
["Type", enumV3("GrdT", GRADIENT_STYLES.find(([s]) => s === g.style)[1])],
|
|
10590
|
+
["Rvrs", boolV3(g.reverse)],
|
|
10591
|
+
["Algn", boolV3(g.align)],
|
|
10592
|
+
["Scl ", unit3("#Prc", g.scale * 100)],
|
|
9315
10593
|
[
|
|
9316
10594
|
"Ofst",
|
|
9317
|
-
|
|
10595
|
+
obj3(
|
|
9318
10596
|
descriptor("Pnt ", [
|
|
9319
|
-
["Hrzn",
|
|
9320
|
-
["Vrtc",
|
|
10597
|
+
["Hrzn", unit3("#Prc", g.offset.x * 100)],
|
|
10598
|
+
["Vrtc", unit3("#Prc", g.offset.y * 100)]
|
|
9321
10599
|
])
|
|
9322
10600
|
)
|
|
9323
10601
|
]
|
|
@@ -9328,7 +10606,7 @@ function patternRefOf(d) {
|
|
|
9328
10606
|
return { patternId: text2(p, "Idnt") || text2(p, "Nm "), name: text2(p, "Nm ") };
|
|
9329
10607
|
}
|
|
9330
10608
|
function patternRefDesc(patternId, name) {
|
|
9331
|
-
return
|
|
10609
|
+
return obj3(
|
|
9332
10610
|
descriptor("Ptrn", [
|
|
9333
10611
|
["Nm ", textV2(_nullishCoalesce(name, () => ( patternId)))],
|
|
9334
10612
|
["Idnt", textV2(patternId)]
|
|
@@ -9345,14 +10623,14 @@ function placementOf(d) {
|
|
|
9345
10623
|
}
|
|
9346
10624
|
function placementItems(angle, link, phase) {
|
|
9347
10625
|
const out = [];
|
|
9348
|
-
if (angle) out.push(["Angl",
|
|
9349
|
-
out.push(["Algn",
|
|
10626
|
+
if (angle) out.push(["Angl", unit3("#Ang", angle)]);
|
|
10627
|
+
out.push(["Algn", boolV3(link)]);
|
|
9350
10628
|
out.push([
|
|
9351
10629
|
"phase",
|
|
9352
|
-
|
|
10630
|
+
obj3(
|
|
9353
10631
|
descriptor("Pnt ", [
|
|
9354
|
-
["Hrzn",
|
|
9355
|
-
["Vrtc",
|
|
10632
|
+
["Hrzn", dbl3(phase.x)],
|
|
10633
|
+
["Vrtc", dbl3(phase.y)]
|
|
9356
10634
|
])
|
|
9357
10635
|
)
|
|
9358
10636
|
]);
|
|
@@ -9401,7 +10679,7 @@ function readOne(kind, d, notes) {
|
|
|
9401
10679
|
const base = {
|
|
9402
10680
|
...common(d, kind, notes),
|
|
9403
10681
|
fill,
|
|
9404
|
-
technique:
|
|
10682
|
+
technique: enumOf3(d, "GlwT") === "PrBL" ? "precise" : "softer",
|
|
9405
10683
|
size: size("blur", 5),
|
|
9406
10684
|
contour: contourOf(d, "TrnS"),
|
|
9407
10685
|
antiAlias: bool(d, "AntA"),
|
|
@@ -9410,7 +10688,7 @@ function readOne(kind, d, notes) {
|
|
|
9410
10688
|
noise: clamp3(pct(d, "Nose", 0), 0, 1)
|
|
9411
10689
|
};
|
|
9412
10690
|
const spread = clamp3(pct(d, "Ckmt", 0), 0, 1);
|
|
9413
|
-
return kind === "outer-glow" ? { ...base, kind, spread } : { ...base, kind, choke: spread, source:
|
|
10691
|
+
return kind === "outer-glow" ? { ...base, kind, spread } : { ...base, kind, choke: spread, source: enumOf3(d, "glwS") === "SrcC" ? "center" : "edge" };
|
|
9414
10692
|
}
|
|
9415
10693
|
case "bevel-emboss": {
|
|
9416
10694
|
const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
|
|
@@ -9418,10 +10696,10 @@ function readOne(kind, d, notes) {
|
|
|
9418
10696
|
id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ),
|
|
9419
10697
|
enabled: descBool(d, "enab") !== false,
|
|
9420
10698
|
kind,
|
|
9421
|
-
style: _nullishCoalesce(styles[_nullishCoalesce(
|
|
9422
|
-
technique:
|
|
10699
|
+
style: _nullishCoalesce(styles[_nullishCoalesce(enumOf3(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
|
|
10700
|
+
technique: enumOf3(d, "bvlT") === "PrBL" ? "chisel-hard" : enumOf3(d, "bvlT") === "Slmt" ? "chisel-soft" : "smooth",
|
|
9423
10701
|
depth: clamp3(pct(d, "srgR", 1), 0, 10),
|
|
9424
|
-
direction:
|
|
10702
|
+
direction: enumOf3(d, "bvlD") === "Out " ? "down" : "up",
|
|
9425
10703
|
size: size("blur", 5),
|
|
9426
10704
|
soften: clamp3(num3(d, "Sftn", 0), 0, 16),
|
|
9427
10705
|
angle: clamp3(num3(d, "lagl", 120), -360, 360),
|
|
@@ -9465,14 +10743,14 @@ function readOne(kind, d, notes) {
|
|
|
9465
10743
|
return { ...common(d, kind, notes), kind, patternId: ref.patternId, name: ref.name, scale: clamp3(pct(d, "Scl ", 1), 0.01, 10), angle: place.angle, link: place.link, phase: place.phase };
|
|
9466
10744
|
}
|
|
9467
10745
|
case "stroke": {
|
|
9468
|
-
const paint =
|
|
10746
|
+
const paint = enumOf3(d, "PntT");
|
|
9469
10747
|
let fill;
|
|
9470
10748
|
if (paint === "GrFl") fill = { type: "gradient", gradient: gradientOf(d, notes) };
|
|
9471
10749
|
else if (paint === "Ptrn") {
|
|
9472
10750
|
const ref = patternRefOf(d);
|
|
9473
10751
|
fill = { type: "pattern", patternId: ref.patternId, name: ref.name, scale: clamp3(pct(d, "Scl ", 1), 0.01, 10) };
|
|
9474
10752
|
} else fill = { type: "color", color: colorOf(descObject(d, "Clr ")) };
|
|
9475
|
-
const pos =
|
|
10753
|
+
const pos = enumOf3(d, "Styl");
|
|
9476
10754
|
return { ...common(d, kind, notes), kind, size: size("Sz ", 3), position: pos === "InsF" ? "inside" : pos === "CtrF" ? "center" : "outside", fill };
|
|
9477
10755
|
}
|
|
9478
10756
|
}
|
|
@@ -9481,7 +10759,7 @@ function parseLfx2(data) {
|
|
|
9481
10759
|
let d;
|
|
9482
10760
|
try {
|
|
9483
10761
|
d = parseVersionedDescriptor(data.subarray(4));
|
|
9484
|
-
} catch (
|
|
10762
|
+
} catch (e25) {
|
|
9485
10763
|
return null;
|
|
9486
10764
|
}
|
|
9487
10765
|
const notes = /* @__PURE__ */ new Set();
|
|
@@ -9499,11 +10777,11 @@ function parseLfx2(data) {
|
|
|
9499
10777
|
}
|
|
9500
10778
|
function commonItems(e) {
|
|
9501
10779
|
return [
|
|
9502
|
-
["enab",
|
|
9503
|
-
["present",
|
|
9504
|
-
["showInDialog",
|
|
9505
|
-
["Md ",
|
|
9506
|
-
["Opct",
|
|
10780
|
+
["enab", boolV3(e.enabled)],
|
|
10781
|
+
["present", boolV3(true)],
|
|
10782
|
+
["showInDialog", boolV3(true)],
|
|
10783
|
+
["Md ", enumV3("BlnM", _nullishCoalesce(BLEND_ID.get(e.blend), () => ( "Nrml")))],
|
|
10784
|
+
["Opct", unit3("#Prc", e.opacity * 100)]
|
|
9507
10785
|
];
|
|
9508
10786
|
}
|
|
9509
10787
|
function writeOne(e) {
|
|
@@ -9513,17 +10791,17 @@ function writeOne(e) {
|
|
|
9513
10791
|
const inner = e.kind === "inner-shadow";
|
|
9514
10792
|
const items = [
|
|
9515
10793
|
...commonItems(e),
|
|
9516
|
-
["Clr ",
|
|
9517
|
-
["uglg",
|
|
9518
|
-
["lagl",
|
|
9519
|
-
["Dstn",
|
|
9520
|
-
["Ckmt",
|
|
9521
|
-
["blur",
|
|
9522
|
-
["Nose",
|
|
9523
|
-
["AntA",
|
|
10794
|
+
["Clr ", obj3(colorDesc(e.color))],
|
|
10795
|
+
["uglg", boolV3(e.useGlobalLight)],
|
|
10796
|
+
["lagl", unit3("#Ang", e.angle)],
|
|
10797
|
+
["Dstn", unit3("#Pxl", e.distance)],
|
|
10798
|
+
["Ckmt", unit3("#Pxl", (inner ? e.choke : e.spread) * 100)],
|
|
10799
|
+
["blur", unit3("#Pxl", e.size)],
|
|
10800
|
+
["Nose", unit3("#Prc", e.noise * 100)],
|
|
10801
|
+
["AntA", boolV3(e.antiAlias)],
|
|
9524
10802
|
["TrnS", contourDesc(e.contour)]
|
|
9525
10803
|
];
|
|
9526
|
-
if (e.kind === "drop-shadow") items.push(["layerConceals",
|
|
10804
|
+
if (e.kind === "drop-shadow") items.push(["layerConceals", boolV3(e.knocksOut)]);
|
|
9527
10805
|
return descriptor(inner ? "IrSh" : "DrSh", items);
|
|
9528
10806
|
}
|
|
9529
10807
|
case "outer-glow":
|
|
@@ -9531,110 +10809,110 @@ function writeOne(e) {
|
|
|
9531
10809
|
const inner = e.kind === "inner-glow";
|
|
9532
10810
|
const items = [...commonItems(e)];
|
|
9533
10811
|
if (e.fill.type === "gradient") items.push(...gradientItems(e.fill.gradient));
|
|
9534
|
-
else items.push(["Clr ",
|
|
10812
|
+
else items.push(["Clr ", obj3(colorDesc(e.fill.color))]);
|
|
9535
10813
|
items.push(
|
|
9536
|
-
["GlwT",
|
|
9537
|
-
["Ckmt",
|
|
9538
|
-
["blur",
|
|
9539
|
-
["Nose",
|
|
9540
|
-
["ShdN",
|
|
9541
|
-
["AntA",
|
|
10814
|
+
["GlwT", enumV3("BETE", e.technique === "precise" ? "PrBL" : "SfBL")],
|
|
10815
|
+
["Ckmt", unit3("#Pxl", (inner ? e.choke : e.spread) * 100)],
|
|
10816
|
+
["blur", unit3("#Pxl", e.size)],
|
|
10817
|
+
["Nose", unit3("#Prc", e.noise * 100)],
|
|
10818
|
+
["ShdN", unit3("#Prc", e.jitter * 100)],
|
|
10819
|
+
["AntA", boolV3(e.antiAlias)],
|
|
9542
10820
|
["TrnS", contourDesc(e.contour)],
|
|
9543
|
-
["Inpr",
|
|
10821
|
+
["Inpr", unit3("#Prc", e.range * 100)]
|
|
9544
10822
|
);
|
|
9545
|
-
if (e.kind === "inner-glow") items.push(["glwS",
|
|
10823
|
+
if (e.kind === "inner-glow") items.push(["glwS", enumV3("IGSr", e.source === "center" ? "SrcC" : "SrcE")]);
|
|
9546
10824
|
return descriptor(inner ? "IrGl" : "OrGl", items);
|
|
9547
10825
|
}
|
|
9548
10826
|
case "bevel-emboss": {
|
|
9549
10827
|
const style = { "outer-bevel": "OtrB", "inner-bevel": "InrB", emboss: "Embs", "pillow-emboss": "PlEb", "stroke-emboss": "strokeEmboss" }[e.style];
|
|
9550
10828
|
const tech = { smooth: "SfBL", "chisel-hard": "PrBL", "chisel-soft": "Slmt" }[e.technique];
|
|
9551
10829
|
const items = [
|
|
9552
|
-
["enab",
|
|
9553
|
-
["present",
|
|
9554
|
-
["showInDialog",
|
|
9555
|
-
["hglM",
|
|
9556
|
-
["hglC",
|
|
9557
|
-
["hglO",
|
|
9558
|
-
["sdwM",
|
|
9559
|
-
["sdwC",
|
|
9560
|
-
["sdwO",
|
|
9561
|
-
["bvlT",
|
|
9562
|
-
["bvlS",
|
|
9563
|
-
["uglg",
|
|
9564
|
-
["lagl",
|
|
9565
|
-
["Lald",
|
|
9566
|
-
["srgR",
|
|
9567
|
-
["blur",
|
|
9568
|
-
["bvlD",
|
|
10830
|
+
["enab", boolV3(e.enabled)],
|
|
10831
|
+
["present", boolV3(true)],
|
|
10832
|
+
["showInDialog", boolV3(true)],
|
|
10833
|
+
["hglM", enumV3("BlnM", _nullishCoalesce(BLEND_ID.get(e.highlightBlend), () => ( "Scrn")))],
|
|
10834
|
+
["hglC", obj3(colorDesc(e.highlightColor))],
|
|
10835
|
+
["hglO", unit3("#Prc", e.highlightOpacity * 100)],
|
|
10836
|
+
["sdwM", enumV3("BlnM", _nullishCoalesce(BLEND_ID.get(e.shadowBlend), () => ( "Mltp")))],
|
|
10837
|
+
["sdwC", obj3(colorDesc(e.shadowColor))],
|
|
10838
|
+
["sdwO", unit3("#Prc", e.shadowOpacity * 100)],
|
|
10839
|
+
["bvlT", enumV3("bvlT", tech)],
|
|
10840
|
+
["bvlS", enumV3("BESl", style)],
|
|
10841
|
+
["uglg", boolV3(e.useGlobalLight)],
|
|
10842
|
+
["lagl", unit3("#Ang", e.angle)],
|
|
10843
|
+
["Lald", unit3("#Ang", e.altitude)],
|
|
10844
|
+
["srgR", unit3("#Prc", e.depth * 100)],
|
|
10845
|
+
["blur", unit3("#Pxl", e.size)],
|
|
10846
|
+
["bvlD", enumV3("BESs", e.direction === "up" ? "In " : "Out ")],
|
|
9569
10847
|
["TrnS", contourDesc(e.glossContour)],
|
|
9570
|
-
["Sftn",
|
|
10848
|
+
["Sftn", unit3("#Pxl", e.soften)]
|
|
9571
10849
|
];
|
|
9572
10850
|
if (e.contourElement) {
|
|
9573
|
-
items.push(["useShape",
|
|
9574
|
-
} else items.push(["useShape",
|
|
10851
|
+
items.push(["useShape", boolV3(true)], ["MpgS", contourDesc(e.contourElement.contour)], ["AntA", boolV3(e.contourElement.antiAlias)], ["Inpr", unit3("#Prc", e.contourElement.range * 100)]);
|
|
10852
|
+
} else items.push(["useShape", boolV3(false)]);
|
|
9575
10853
|
if (e.texture) {
|
|
9576
10854
|
const t = e.texture;
|
|
9577
10855
|
items.push(
|
|
9578
|
-
["useTexture",
|
|
9579
|
-
["InvT",
|
|
9580
|
-
["Scl ",
|
|
9581
|
-
["textureDepth",
|
|
10856
|
+
["useTexture", boolV3(true)],
|
|
10857
|
+
["InvT", boolV3(t.invert)],
|
|
10858
|
+
["Scl ", unit3("#Prc", t.scale * 100)],
|
|
10859
|
+
["textureDepth", unit3("#Prc", t.depth * 100)],
|
|
9582
10860
|
["Ptrn", patternRefDesc(t.patternId, t.name)],
|
|
9583
10861
|
...placementItems(0, _nullishCoalesce(t.link, () => ( true)), _nullishCoalesce(t.phase, () => ( { x: 0, y: 0 })))
|
|
9584
10862
|
);
|
|
9585
|
-
} else items.push(["useTexture",
|
|
10863
|
+
} else items.push(["useTexture", boolV3(false)]);
|
|
9586
10864
|
return descriptor("ebbl", items);
|
|
9587
10865
|
}
|
|
9588
10866
|
case "satin":
|
|
9589
10867
|
return descriptor("ChFX", [
|
|
9590
10868
|
...commonItems(e),
|
|
9591
|
-
["Clr ",
|
|
9592
|
-
["AntA",
|
|
9593
|
-
["Invr",
|
|
9594
|
-
["lagl",
|
|
9595
|
-
["Dstn",
|
|
9596
|
-
["blur",
|
|
10869
|
+
["Clr ", obj3(colorDesc(e.color))],
|
|
10870
|
+
["AntA", boolV3(e.antiAlias)],
|
|
10871
|
+
["Invr", boolV3(e.invert)],
|
|
10872
|
+
["lagl", unit3("#Ang", e.angle)],
|
|
10873
|
+
["Dstn", unit3("#Pxl", e.distance)],
|
|
10874
|
+
["blur", unit3("#Pxl", e.size)],
|
|
9597
10875
|
["MpgS", contourDesc(e.contour)]
|
|
9598
10876
|
]);
|
|
9599
10877
|
case "color-overlay":
|
|
9600
|
-
return descriptor("SoFi", [...commonItems(e), ["Clr ",
|
|
10878
|
+
return descriptor("SoFi", [...commonItems(e), ["Clr ", obj3(colorDesc(e.color))]]);
|
|
9601
10879
|
case "gradient-overlay":
|
|
9602
|
-
return descriptor("GrFl", [...commonItems(e), ...gradientItems(e.gradient), ["Dthr",
|
|
10880
|
+
return descriptor("GrFl", [...commonItems(e), ...gradientItems(e.gradient), ["Dthr", boolV3(e.dither)]]);
|
|
9603
10881
|
case "pattern-overlay":
|
|
9604
10882
|
return descriptor("patternFill", [
|
|
9605
10883
|
...commonItems(e),
|
|
9606
10884
|
["Ptrn", patternRefDesc(e.patternId, e.name)],
|
|
9607
|
-
["Scl ",
|
|
10885
|
+
["Scl ", unit3("#Prc", e.scale * 100)],
|
|
9608
10886
|
...placementItems(_nullishCoalesce(e.angle, () => ( 0)), _nullishCoalesce(e.link, () => ( true)), _nullishCoalesce(e.phase, () => ( { x: 0, y: 0 })))
|
|
9609
10887
|
]);
|
|
9610
10888
|
case "stroke": {
|
|
9611
10889
|
const items = [
|
|
9612
10890
|
...commonItems(e),
|
|
9613
|
-
["Styl",
|
|
9614
|
-
["Sz ",
|
|
10891
|
+
["Styl", enumV3("FStl", e.position === "inside" ? "InsF" : e.position === "center" ? "CtrF" : "OutF")],
|
|
10892
|
+
["Sz ", unit3("#Pxl", e.size)]
|
|
9615
10893
|
];
|
|
9616
10894
|
const f = e.fill;
|
|
9617
|
-
if (f.type === "color") items.push(["PntT",
|
|
9618
|
-
else if (f.type === "gradient") items.push(["PntT",
|
|
9619
|
-
else items.push(["PntT",
|
|
10895
|
+
if (f.type === "color") items.push(["PntT", enumV3("FrFl", "SClr")], ["Clr ", obj3(colorDesc(f.color))]);
|
|
10896
|
+
else if (f.type === "gradient") items.push(["PntT", enumV3("FrFl", "GrFl")], ...gradientItems(f.gradient));
|
|
10897
|
+
else items.push(["PntT", enumV3("FrFl", "Ptrn")], ["Ptrn", patternRefDesc(f.patternId, f.name)], ["Scl ", unit3("#Prc", f.scale * 100)]);
|
|
9620
10898
|
return descriptor("FrFX", items);
|
|
9621
10899
|
}
|
|
9622
10900
|
}
|
|
9623
10901
|
}
|
|
9624
10902
|
function writeLfx2(effects) {
|
|
9625
10903
|
const items = [
|
|
9626
|
-
["Scl ",
|
|
9627
|
-
["masterFXSwitch",
|
|
10904
|
+
["Scl ", unit3("#Prc", 100)],
|
|
10905
|
+
["masterFXSwitch", boolV3(effects.enabled)]
|
|
9628
10906
|
];
|
|
9629
10907
|
const scale = _chunkPOGBUYWEcjs.effectsScale.call(void 0, effects);
|
|
9630
10908
|
let dropped = 0;
|
|
9631
10909
|
for (const [single, multi, kind] of KINDS) {
|
|
9632
10910
|
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkPOGBUYWEcjs.scaleLayerEffect.call(void 0, e, scale)));
|
|
9633
10911
|
if (!of.length) continue;
|
|
9634
|
-
if (of.length === 1) items.push([single,
|
|
9635
|
-
else if (multi) items.push([multi, { type: "VlLs", items: of.map(
|
|
10912
|
+
if (of.length === 1) items.push([single, obj3(of[0])]);
|
|
10913
|
+
else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj3) }]);
|
|
9636
10914
|
else {
|
|
9637
|
-
items.push([single,
|
|
10915
|
+
items.push([single, obj3(of[0])]);
|
|
9638
10916
|
dropped += of.length - 1;
|
|
9639
10917
|
}
|
|
9640
10918
|
}
|
|
@@ -9652,7 +10930,7 @@ function parseLrfx(data) {
|
|
|
9652
10930
|
const count = r.u16();
|
|
9653
10931
|
const items = [];
|
|
9654
10932
|
const notes = /* @__PURE__ */ new Set();
|
|
9655
|
-
const
|
|
10933
|
+
const fixed2 = (v) => (v | 0) / 65536;
|
|
9656
10934
|
for (let i = 0; i < count; i++) {
|
|
9657
10935
|
if (new TextDecoder().decode(r.bytes(4)) !== "8BIM") return null;
|
|
9658
10936
|
const key = new TextDecoder().decode(r.bytes(4));
|
|
@@ -9671,10 +10949,10 @@ function parseLrfx(data) {
|
|
|
9671
10949
|
};
|
|
9672
10950
|
if (key === "dsdw" || key === "isdw") {
|
|
9673
10951
|
b.u32();
|
|
9674
|
-
const blur =
|
|
10952
|
+
const blur = fixed2(b.u32());
|
|
9675
10953
|
b.u32();
|
|
9676
|
-
const angle =
|
|
9677
|
-
const distance =
|
|
10954
|
+
const angle = fixed2(b.u32());
|
|
10955
|
+
const distance = fixed2(b.u32());
|
|
9678
10956
|
const color = colorAt(b);
|
|
9679
10957
|
const blend = blendAt(b);
|
|
9680
10958
|
const enabled = b.u8() !== 0;
|
|
@@ -9684,7 +10962,7 @@ function parseLrfx(data) {
|
|
|
9684
10962
|
items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
|
|
9685
10963
|
} else if (key === "oglw" || key === "iglw") {
|
|
9686
10964
|
b.u32();
|
|
9687
|
-
const blur =
|
|
10965
|
+
const blur = fixed2(b.u32());
|
|
9688
10966
|
b.u32();
|
|
9689
10967
|
const color = colorAt(b);
|
|
9690
10968
|
const blend = blendAt(b);
|
|
@@ -9702,7 +10980,7 @@ function parseLrfx(data) {
|
|
|
9702
10980
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
9703
10981
|
}
|
|
9704
10982
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
9705
|
-
} catch (
|
|
10983
|
+
} catch (e26) {
|
|
9706
10984
|
return null;
|
|
9707
10985
|
}
|
|
9708
10986
|
}
|
|
@@ -9770,9 +11048,9 @@ function prepareNestedLayers(layers) {
|
|
|
9770
11048
|
if (l.type === "annotation") continue;
|
|
9771
11049
|
let next = l;
|
|
9772
11050
|
if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
|
|
9773
|
-
else if (l.type === "pixel" && (_optionalChain([l, 'access',
|
|
11051
|
+
else if (l.type === "pixel" && (_optionalChain([l, 'access', _257 => _257.filters, 'optionalAccess', _258 => _258.length]) || l.source === "document")) {
|
|
9774
11052
|
const p = { ...l };
|
|
9775
|
-
if (_optionalChain([l, 'access',
|
|
11053
|
+
if (_optionalChain([l, 'access', _259 => _259.filters, 'optionalAccess', _260 => _260.some, 'call', _261 => _261(isActiveFilter)])) {
|
|
9776
11054
|
const b = l.surface.bounds;
|
|
9777
11055
|
if (b) {
|
|
9778
11056
|
const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
|
|
@@ -9789,7 +11067,7 @@ function prepareNestedLayers(layers) {
|
|
|
9789
11067
|
delete p.source;
|
|
9790
11068
|
next = p;
|
|
9791
11069
|
}
|
|
9792
|
-
if (_optionalChain([next, 'access',
|
|
11070
|
+
if (_optionalChain([next, 'access', _262 => _262.mask, 'optionalAccess', _263 => _263.source])) {
|
|
9793
11071
|
next = { ...next };
|
|
9794
11072
|
delete next.mask;
|
|
9795
11073
|
}
|
|
@@ -9805,8 +11083,8 @@ function smartContentsFile(c) {
|
|
|
9805
11083
|
return { name: `${base}.png`, bytes: _chunkPOGBUYWEcjs.encodePng.call(void 0, c.width, c.height, data) };
|
|
9806
11084
|
}
|
|
9807
11085
|
const doc = c.document;
|
|
9808
|
-
const
|
|
9809
|
-
const res = exportPsd({ width: c.width, height: c.height, layers: prepareNestedLayers(doc.layers), merged, patterns: doc.patterns, globalLight: doc.globalLight });
|
|
11086
|
+
const merged2 = _chunkXIOMMGPDcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
11087
|
+
const res = exportPsd({ width: c.width, height: c.height, layers: prepareNestedLayers(doc.layers), merged: merged2, patterns: doc.patterns, globalLight: doc.globalLight });
|
|
9810
11088
|
return { name: `${base}.${res.psb ? "psb" : "psd"}`, bytes: res.bytes };
|
|
9811
11089
|
}
|
|
9812
11090
|
var near = (a, b) => Math.abs(a - b) <= 1e-6 * (1 + Math.abs(a));
|
|
@@ -9870,7 +11148,7 @@ function exportPsd(input) {
|
|
|
9870
11148
|
return {
|
|
9871
11149
|
opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
|
|
9872
11150
|
clipping: layer.clipped ? 1 : 0,
|
|
9873
|
-
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access',
|
|
11151
|
+
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _264 => _264.locks, 'optionalAccess', _265 => _265.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
|
|
9874
11152
|
legacyName: name,
|
|
9875
11153
|
blocks
|
|
9876
11154
|
};
|
|
@@ -9927,7 +11205,7 @@ function exportPsd(input) {
|
|
|
9927
11205
|
}
|
|
9928
11206
|
case "pixel": {
|
|
9929
11207
|
if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
|
|
9930
|
-
if (_optionalChain([layer, 'access',
|
|
11208
|
+
if (_optionalChain([layer, 'access', _266 => _266.filters, 'optionalAccess', _267 => _267.some, 'call', _268 => _268(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
|
|
9931
11209
|
const extra = [];
|
|
9932
11210
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
|
|
9933
11211
|
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
@@ -9966,7 +11244,7 @@ function exportPsd(input) {
|
|
|
9966
11244
|
if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
|
|
9967
11245
|
linkedFiles.set(idnt, smartContentsFile(c));
|
|
9968
11246
|
}
|
|
9969
|
-
let placedId = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
11247
|
+
let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _269 => _269.psd, 'optionalAccess', _270 => _270.placed]), () => ( psdUuid(`${layer.id}:placed`)));
|
|
9970
11248
|
if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
|
|
9971
11249
|
placedIds.add(placedId);
|
|
9972
11250
|
if (placedUnchanged(layer, idnt, placedId)) {
|
|
@@ -9976,12 +11254,12 @@ function exportPsd(input) {
|
|
|
9976
11254
|
const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
|
|
9977
11255
|
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);
|
|
9978
11256
|
const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
|
|
9979
|
-
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess',
|
|
11257
|
+
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _271 => _271.descriptor]) };
|
|
9980
11258
|
const wnotes = [];
|
|
9981
11259
|
extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
|
|
9982
11260
|
for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
|
|
9983
11261
|
}
|
|
9984
|
-
const fm = _optionalChain([layer, 'access',
|
|
11262
|
+
const fm = _optionalChain([layer, 'access', _272 => _272.smartFilters, 'optionalAccess', _273 => _273.mask]);
|
|
9985
11263
|
if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
|
|
9986
11264
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
9987
11265
|
const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
@@ -10006,6 +11284,44 @@ function exportPsd(input) {
|
|
|
10006
11284
|
records.push(rec);
|
|
10007
11285
|
return;
|
|
10008
11286
|
}
|
|
11287
|
+
case "shape":
|
|
11288
|
+
case "type": {
|
|
11289
|
+
const extra = [];
|
|
11290
|
+
if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
|
|
11291
|
+
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
11292
|
+
}
|
|
11293
|
+
if (layer.type === "shape") {
|
|
11294
|
+
const losses = /* @__PURE__ */ new Set();
|
|
11295
|
+
for (const b2 of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b2.key, data: padEven(b2.data) });
|
|
11296
|
+
for (const n2 of losses) note(n2, layer.name);
|
|
11297
|
+
if (_optionalChain([layer, 'access', _274 => _274.fill, 'optionalAccess', _275 => _275.type]) === "pattern") patternIds2.add(layer.fill.patternId);
|
|
11298
|
+
if (_optionalChain([layer, 'access', _276 => _276.stroke, 'optionalAccess', _277 => _277.paint, 'access', _278 => _278.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
|
|
11299
|
+
} else {
|
|
11300
|
+
extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
|
|
11301
|
+
}
|
|
11302
|
+
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
11303
|
+
const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
11304
|
+
if (bounds) {
|
|
11305
|
+
const n2 = bounds.width * bounds.height;
|
|
11306
|
+
const [r2, g2, b2, a2] = rgbaToPlanes(_chunkXIOMMGPDcjs.readRegion.call(void 0, layer.surface, bounds), n2);
|
|
11307
|
+
rec.rect = toRect(bounds);
|
|
11308
|
+
rec.channels = [
|
|
11309
|
+
rleChannel(CHANNEL_ALPHA, a2, bounds.width, bounds.height, psb),
|
|
11310
|
+
rleChannel(0, r2, bounds.width, bounds.height, psb),
|
|
11311
|
+
rleChannel(1, g2, bounds.width, bounds.height, psb),
|
|
11312
|
+
rleChannel(2, b2, bounds.width, bounds.height, psb)
|
|
11313
|
+
];
|
|
11314
|
+
} else {
|
|
11315
|
+
rec.channels = [CHANNEL_ALPHA, 0, 1, 2].map(emptyChannel);
|
|
11316
|
+
}
|
|
11317
|
+
if (layer.mask) {
|
|
11318
|
+
const m = maskChannel(layer.mask, 0, 0, psb);
|
|
11319
|
+
rec.channels.push(m.channel);
|
|
11320
|
+
rec.mask = m.mask;
|
|
11321
|
+
}
|
|
11322
|
+
records.push(rec);
|
|
11323
|
+
return;
|
|
11324
|
+
}
|
|
10009
11325
|
case "annotation":
|
|
10010
11326
|
throw new PsdError(`Annotation layer "${layer.name}" must be rasterized before export.`);
|
|
10011
11327
|
}
|
|
@@ -10017,8 +11333,8 @@ function exportPsd(input) {
|
|
|
10017
11333
|
const [r, g, b, a] = rgbaToPlanes(matteWhite(input.merged), n);
|
|
10018
11334
|
const transparent = a.some((v) => v !== 255);
|
|
10019
11335
|
const planes = transparent ? [r, g, b, a] : [r, g, b];
|
|
10020
|
-
const
|
|
10021
|
-
planes.forEach((p, i) =>
|
|
11336
|
+
const merged2 = new Uint8Array(n * planes.length);
|
|
11337
|
+
planes.forEach((p, i) => merged2.set(p, i * n));
|
|
10022
11338
|
const res = Math.max(1, _nullishCoalesce(input.resolution, () => ( 72)));
|
|
10023
11339
|
const rw = new PsdWriter();
|
|
10024
11340
|
for (let k = 0; k < 2; k++) {
|
|
@@ -10075,7 +11391,7 @@ function exportPsd(input) {
|
|
|
10075
11391
|
mergedAlpha: transparent && records.length > 0,
|
|
10076
11392
|
globalBlocks,
|
|
10077
11393
|
imageCompression: 1,
|
|
10078
|
-
imageData: encodeRle(
|
|
11394
|
+
imageData: encodeRle(merged2, { planes: planes.length, width, height, depth: 8, psb })
|
|
10079
11395
|
},
|
|
10080
11396
|
encodeLegacyName
|
|
10081
11397
|
);
|
|
@@ -10447,5 +11763,5 @@ function exportPsd(input) {
|
|
|
10447
11763
|
|
|
10448
11764
|
|
|
10449
11765
|
|
|
10450
|
-
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.DEFAULT_TEXT_STYLE = DEFAULT_TEXT_STYLE; exports.DEFAULT_AUTO_LEADING = DEFAULT_AUTO_LEADING; exports.fitRuns = fitRuns; exports.styleAt = styleAt; exports.restyleRange = restyleRange; exports.spliceRuns = spliceRuns; exports.paragraphRanges = paragraphRanges; exports.fitParagraphRuns = fitParagraphRuns; exports.fontOf = fontOf; exports.layoutText = layoutText; exports.textIndexAt = textIndexAt; exports.caretAt = caretAt; 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.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
10451
|
-
//# sourceMappingURL=chunk-
|
|
11766
|
+
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.DEFAULT_TEXT_STYLE = DEFAULT_TEXT_STYLE; exports.DEFAULT_AUTO_LEADING = DEFAULT_AUTO_LEADING; exports.fitRuns = fitRuns; exports.styleAt = styleAt; exports.restyleRange = restyleRange; exports.spliceRuns = spliceRuns; exports.paragraphRanges = paragraphRanges; exports.fitParagraphRuns = fitParagraphRuns; exports.fontOf = fontOf; exports.layoutText = layoutText; exports.textIndexAt = textIndexAt; exports.caretAt = caretAt; 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.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.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;
|
|
11767
|
+
//# sourceMappingURL=chunk-YGIMK4NX.cjs.map
|