@pixerate/editor 0.110.0 → 0.111.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/THIRD_PARTY_NOTICES.md +3 -0
- package/dist/{chunk-DMRSJBJF.js → chunk-HHZ6ZJTW.js} +878 -84
- package/dist/chunk-HHZ6ZJTW.js.map +1 -0
- package/dist/{chunk-MGL4U5WA.cjs → chunk-PHUMLSCW.cjs} +951 -157
- package/dist/chunk-PHUMLSCW.cjs.map +1 -0
- package/dist/{export-CO2ryu3I.d.ts → export-DBNVwb6h.d.ts} +518 -9
- package/dist/{export-DRiLzP_j.d.cts → export-DoDhCszr.d.cts} +518 -9
- package/dist/image-editor/index.cjs +1381 -677
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +97 -9
- package/dist/image-editor/index.d.ts +97 -9
- package/dist/image-editor/index.js +746 -42
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.d.cts +2 -2
- package/dist/paint-editor/index.d.ts +2 -2
- package/dist/paint-editor/index.js +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +27 -30
- package/skills/pixerate-image-editor/references/shapes-and-type.md +60 -0
- package/dist/chunk-DMRSJBJF.js.map +0 -1
- package/dist/chunk-MGL4U5WA.cjs.map +0 -1
|
@@ -99,6 +99,7 @@ var _chunkW3GXSUSQcjs = require('./chunk-W3GXSUSQ.cjs');
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
|
|
102
103
|
var _chunkXGD3FSNCcjs = require('./chunk-XGD3FSNC.cjs');
|
|
103
104
|
|
|
104
105
|
// src/image-editor/color.ts
|
|
@@ -2224,6 +2225,7 @@ function removeAlpha(imageData) {
|
|
|
2224
2225
|
// src/image-editor/layers/model.ts
|
|
2225
2226
|
var SHAPE_OPERATIONS = ["combine", "subtract", "intersect", "exclude"];
|
|
2226
2227
|
var LIVE_SHAPE_KINDS = ["rect", "ellipse", "polygon", "star", "line"];
|
|
2228
|
+
var TEXT_ALIGNS = ["left", "center", "right", "justify"];
|
|
2227
2229
|
var idCounter = 0;
|
|
2228
2230
|
function newLayerId(prefix = "layer") {
|
|
2229
2231
|
return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
|
|
@@ -2251,13 +2253,13 @@ function pixelLayerBounds(layer, surface = layer.surface) {
|
|
|
2251
2253
|
return { x: b.x + layer.offset.x, y: b.y + layer.offset.y, width: b.width, height: b.height };
|
|
2252
2254
|
}
|
|
2253
2255
|
function layerTypeLabel(type) {
|
|
2254
|
-
return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : "Annotation";
|
|
2256
|
+
return type === "pixel" ? "Pixel layer" : type === "adjustment" ? "Adjustment layer" : type === "group" ? "Group" : type === "smart" ? "Smart object" : type === "shape" ? "Shape layer" : type === "type" ? "Type layer" : "Annotation";
|
|
2255
2257
|
}
|
|
2256
2258
|
function hasSurface(layer) {
|
|
2257
|
-
return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape";
|
|
2259
|
+
return layer.type === "pixel" || layer.type === "smart" || layer.type === "shape" || layer.type === "type";
|
|
2258
2260
|
}
|
|
2259
2261
|
function isRenderedLayer(layer) {
|
|
2260
|
-
return layer.type === "smart" || layer.type === "shape";
|
|
2262
|
+
return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
|
|
2261
2263
|
}
|
|
2262
2264
|
function shapeLayers(layers) {
|
|
2263
2265
|
return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
|
|
@@ -2359,7 +2361,7 @@ var PHOTO_PROFILE = {
|
|
|
2359
2361
|
* A smart object draws its rendered pixels (contents → placement → smart filters) like a pixel
|
|
2360
2362
|
* layer, and a shape layer the pixels rendered from its paths.
|
|
2361
2363
|
*/
|
|
2362
|
-
isPixelLike: (l) => l.type === "smart" || l.type === "shape",
|
|
2364
|
+
isPixelLike: (l) => l.type === "smart" || l.type === "shape" || l.type === "type",
|
|
2363
2365
|
maskSourcePlane: (source, W, H, sources) => {
|
|
2364
2366
|
const opts = source;
|
|
2365
2367
|
const depth = _nullishCoalesce(_optionalChain([sources, 'access', _17 => _17.depthMap, 'optionalCall', _18 => _18(opts)]), () => ( null));
|
|
@@ -2888,14 +2890,14 @@ function parseCssColor(value) {
|
|
|
2888
2890
|
if (h.length <= 4) h = h.replace(/./g, (c) => c + c);
|
|
2889
2891
|
return { hex: `#${h.slice(0, 6)}`, alpha: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1 };
|
|
2890
2892
|
}
|
|
2891
|
-
const
|
|
2892
|
-
m = new RegExp(`^rgba?\\(\\s*${
|
|
2893
|
+
const num4 = "([+-]?[\\d.]+%?)";
|
|
2894
|
+
m = new RegExp(`^rgba?\\(\\s*${num4}[\\s,]+${num4}[\\s,]+${num4}(?:\\s*[,/]\\s*${num4})?\\s*\\)$`).exec(text3);
|
|
2893
2895
|
if (m) {
|
|
2894
2896
|
const rgb = [m[1], m[2], m[3]].map(channel);
|
|
2895
2897
|
if (!rgb.every(Number.isFinite)) return null;
|
|
2896
2898
|
return { hex: `#${rgb.map(hex2).join("")}`, alpha: alphaOf(m[4]) };
|
|
2897
2899
|
}
|
|
2898
|
-
m = new RegExp(`^hsla?\\(\\s*([+-]?[\\d.]+)(?:deg)?[\\s,]+${
|
|
2900
|
+
m = new RegExp(`^hsla?\\(\\s*([+-]?[\\d.]+)(?:deg)?[\\s,]+${num4}[\\s,]+${num4}(?:\\s*[,/]\\s*${num4})?\\s*\\)$`).exec(text3);
|
|
2899
2901
|
if (m) {
|
|
2900
2902
|
const rgb = hslToRgb2(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
|
|
2901
2903
|
if (!rgb.every(Number.isFinite)) return null;
|
|
@@ -2962,7 +2964,7 @@ function withNewIds(layer) {
|
|
|
2962
2964
|
const next = { ...layer, id: newLayerId(layer.type === "adjustment" ? "adj" : layer.type) };
|
|
2963
2965
|
if (next.type === "group") next.children = next.children.map(withNewIds);
|
|
2964
2966
|
if (next.type === "annotation") next.annotation = { ...next.annotation, id: next.id };
|
|
2965
|
-
if (next.type === "shape") delete next.annotation;
|
|
2967
|
+
if (next.type === "shape" || next.type === "type") delete next.annotation;
|
|
2966
2968
|
if (next.type === "smart" && _optionalChain([next, 'access', _21 => _21.psd, 'optionalAccess', _22 => _22.placed])) {
|
|
2967
2969
|
next.psd = { ...next.psd };
|
|
2968
2970
|
delete next.psd.placed;
|
|
@@ -2992,7 +2994,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
2992
2994
|
next.opacity = props.opacity;
|
|
2993
2995
|
}
|
|
2994
2996
|
if (props.fillOpacity !== void 0) {
|
|
2995
|
-
if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape") fail(`fillOpacity applies to pixel, shape and smart object layers; "${id}" is a ${layer.type} layer.`);
|
|
2997
|
+
if (layer.type !== "pixel" && layer.type !== "smart" && layer.type !== "shape" && layer.type !== "type") fail(`fillOpacity applies to pixel, shape, type and smart object layers; "${id}" is a ${layer.type} layer.`);
|
|
2996
2998
|
if (!(typeof props.fillOpacity === "number" && props.fillOpacity >= 0 && props.fillOpacity <= 1)) fail("fillOpacity must be a number from 0 to 1.");
|
|
2997
2999
|
const p = next;
|
|
2998
3000
|
if (props.fillOpacity === 1) delete p.fillOpacity;
|
|
@@ -3887,6 +3889,671 @@ function annotationOfShape(layer) {
|
|
|
3887
3889
|
return out;
|
|
3888
3890
|
}
|
|
3889
3891
|
|
|
3892
|
+
// src/image-editor/layers/text.ts
|
|
3893
|
+
var fail3 = (message) => {
|
|
3894
|
+
throw new LayerOperationError(message);
|
|
3895
|
+
};
|
|
3896
|
+
var DEFAULT_TEXT_STYLE = { fontFamily: "sans-serif", fontWeight: 400, fontSize: 24, color: "#000000" };
|
|
3897
|
+
var DEFAULT_AUTO_LEADING = 1.2;
|
|
3898
|
+
var sameStyle = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
3899
|
+
function compact(runs) {
|
|
3900
|
+
const out = [];
|
|
3901
|
+
for (const r of runs) {
|
|
3902
|
+
if (r.length <= 0) continue;
|
|
3903
|
+
const last = out[out.length - 1];
|
|
3904
|
+
if (last && sameStyle(last.style, r.style)) out[out.length - 1] = { ...last, length: last.length + r.length };
|
|
3905
|
+
else out.push({ ...r });
|
|
3906
|
+
}
|
|
3907
|
+
return out;
|
|
3908
|
+
}
|
|
3909
|
+
function fitRuns(runs, length, fallback) {
|
|
3910
|
+
const out = [];
|
|
3911
|
+
let left = length;
|
|
3912
|
+
for (const r of runs) {
|
|
3913
|
+
if (left <= 0) break;
|
|
3914
|
+
const n = Math.min(Math.max(0, Math.floor(r.length)), left);
|
|
3915
|
+
if (n > 0) out.push({ ...r, length: n });
|
|
3916
|
+
left -= n;
|
|
3917
|
+
}
|
|
3918
|
+
if (left > 0) {
|
|
3919
|
+
if (out.length) out[out.length - 1] = { ...out[out.length - 1], length: out[out.length - 1].length + left };
|
|
3920
|
+
else out.push({ length: left, style: _nullishCoalesce(_optionalChain([runs, 'access', _59 => _59[runs.length - 1], 'optionalAccess', _60 => _60.style]), () => ( fallback)) });
|
|
3921
|
+
}
|
|
3922
|
+
return compact(out);
|
|
3923
|
+
}
|
|
3924
|
+
function styleAt(runs, index, fallback) {
|
|
3925
|
+
let at = 0;
|
|
3926
|
+
for (const r of runs) {
|
|
3927
|
+
if (index < at + r.length) return r.style;
|
|
3928
|
+
at += r.length;
|
|
3929
|
+
}
|
|
3930
|
+
return _nullishCoalesce(_optionalChain([runs, 'access', _61 => _61[runs.length - 1], 'optionalAccess', _62 => _62.style]), () => ( fallback));
|
|
3931
|
+
}
|
|
3932
|
+
function restyleRange(runs, start, end, patch) {
|
|
3933
|
+
const out = [];
|
|
3934
|
+
let at = 0;
|
|
3935
|
+
for (const r of runs) {
|
|
3936
|
+
const a = at;
|
|
3937
|
+
const b = at + r.length;
|
|
3938
|
+
at = b;
|
|
3939
|
+
const lo = Math.max(a, start);
|
|
3940
|
+
const hi = Math.min(b, end);
|
|
3941
|
+
if (hi <= lo) {
|
|
3942
|
+
out.push({ ...r });
|
|
3943
|
+
continue;
|
|
3944
|
+
}
|
|
3945
|
+
if (lo > a) out.push({ length: lo - a, style: r.style });
|
|
3946
|
+
out.push({ length: hi - lo, style: patch(r.style) });
|
|
3947
|
+
if (b > hi) out.push({ length: b - hi, style: r.style });
|
|
3948
|
+
}
|
|
3949
|
+
return compact(out);
|
|
3950
|
+
}
|
|
3951
|
+
function spliceRuns(runs, start, end, inserted, style) {
|
|
3952
|
+
const out = [];
|
|
3953
|
+
let at = 0;
|
|
3954
|
+
let placed = false;
|
|
3955
|
+
for (const r of runs) {
|
|
3956
|
+
const a = at;
|
|
3957
|
+
const b = at + r.length;
|
|
3958
|
+
at = b;
|
|
3959
|
+
if (b <= start) {
|
|
3960
|
+
out.push({ ...r });
|
|
3961
|
+
continue;
|
|
3962
|
+
}
|
|
3963
|
+
if (a < start) out.push({ length: start - a, style: r.style });
|
|
3964
|
+
if (!placed) {
|
|
3965
|
+
out.push({ length: inserted, style });
|
|
3966
|
+
placed = true;
|
|
3967
|
+
}
|
|
3968
|
+
if (b > end) out.push({ length: b - Math.max(end, a), style: r.style });
|
|
3969
|
+
}
|
|
3970
|
+
if (!placed) out.push({ length: inserted, style });
|
|
3971
|
+
return compact(out);
|
|
3972
|
+
}
|
|
3973
|
+
function paragraphRanges(text3) {
|
|
3974
|
+
const out = [];
|
|
3975
|
+
let start = 0;
|
|
3976
|
+
for (let i = 0; i < text3.length; i++) {
|
|
3977
|
+
if (text3[i] === "\n") {
|
|
3978
|
+
out.push({ start, end: i + 1, content: i });
|
|
3979
|
+
start = i + 1;
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
out.push({ start, end: text3.length, content: text3.length });
|
|
3983
|
+
return out;
|
|
3984
|
+
}
|
|
3985
|
+
function fitParagraphRuns(runs, text3) {
|
|
3986
|
+
const fallback = _nullishCoalesce(_optionalChain([runs, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.style]), () => ( {}));
|
|
3987
|
+
const out = compact(paragraphRanges(text3).map((p) => ({ length: p.end - p.start, style: styleAt(runs, p.start, fallback) })));
|
|
3988
|
+
return out.length ? out : [{ length: 0, style: fallback }];
|
|
3989
|
+
}
|
|
3990
|
+
function fontOf(style) {
|
|
3991
|
+
const f = { family: style.fontFamily, weight: style.fontWeight, italic: Boolean(style.italic), size: style.fontSize };
|
|
3992
|
+
if (style.postScriptName) f.postScriptName = style.postScriptName;
|
|
3993
|
+
return f;
|
|
3994
|
+
}
|
|
3995
|
+
var isBreakAfter = (c) => c === " " || c === " " || c === "-" || c === "\u2010" || c === "\u200B";
|
|
3996
|
+
var isSpace = (c) => c === " " || c === " ";
|
|
3997
|
+
var isWide = (code) => code >= 11904 && code <= 40959 || code >= 44032 && code <= 55215 || code >= 63744 && code <= 64255 || code >= 65280 && code <= 65519;
|
|
3998
|
+
var layoutCache = /* @__PURE__ */ new WeakMap();
|
|
3999
|
+
function layoutText(layer, shaper) {
|
|
4000
|
+
let byShaper = layoutCache.get(layer);
|
|
4001
|
+
const hit = _optionalChain([byShaper, 'optionalAccess', _65 => _65.get, 'call', _66 => _66(shaper.id)]);
|
|
4002
|
+
if (hit) return hit;
|
|
4003
|
+
const out = computeLayout(layer, shaper);
|
|
4004
|
+
if (!byShaper) {
|
|
4005
|
+
byShaper = /* @__PURE__ */ new Map();
|
|
4006
|
+
layoutCache.set(layer, byShaper);
|
|
4007
|
+
}
|
|
4008
|
+
byShaper.set(shaper.id, out);
|
|
4009
|
+
return out;
|
|
4010
|
+
}
|
|
4011
|
+
function computeLayout(layer, shaper) {
|
|
4012
|
+
const { text: text3, frame } = layer;
|
|
4013
|
+
const runs = fitRuns(layer.runs, text3.length, DEFAULT_TEXT_STYLE);
|
|
4014
|
+
const missing = /* @__PURE__ */ new Set();
|
|
4015
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
4016
|
+
const familyOf = (font) => {
|
|
4017
|
+
const key = `${font.family}|${font.weight}|${font.italic}|${_nullishCoalesce(font.postScriptName, () => ( ""))}`;
|
|
4018
|
+
let fam = resolved.get(key);
|
|
4019
|
+
if (fam === void 0) {
|
|
4020
|
+
const r = shaper.resolve(font);
|
|
4021
|
+
fam = r.family;
|
|
4022
|
+
if (!r.available) missing.add(font.family);
|
|
4023
|
+
resolved.set(key, fam);
|
|
4024
|
+
}
|
|
4025
|
+
return fam;
|
|
4026
|
+
};
|
|
4027
|
+
const resolvedFont = (style) => ({ ...fontOf(style), family: familyOf(fontOf(style)) });
|
|
4028
|
+
const box2 = frame.kind === "box" ? frame : null;
|
|
4029
|
+
const lines = [];
|
|
4030
|
+
let y = 0;
|
|
4031
|
+
let first = true;
|
|
4032
|
+
const paragraphs = paragraphRanges(text3);
|
|
4033
|
+
paragraphs.forEach((para, pi) => {
|
|
4034
|
+
const pstyle = styleAt(layer.paragraphs, para.start, {});
|
|
4035
|
+
const autoLeading = _nullishCoalesce(pstyle.autoLeading, () => ( DEFAULT_AUTO_LEADING));
|
|
4036
|
+
if (pi > 0) y += _nullishCoalesce(pstyle.spaceBefore, () => ( 0));
|
|
4037
|
+
const chars = [];
|
|
4038
|
+
let i = para.start;
|
|
4039
|
+
while (i < para.content) {
|
|
4040
|
+
const style = styleAt(runs, i, DEFAULT_TEXT_STYLE);
|
|
4041
|
+
let j = i + 1;
|
|
4042
|
+
while (j < para.content && styleAt(runs, j, DEFAULT_TEXT_STYLE) === style) j++;
|
|
4043
|
+
const seg = text3.slice(i, j);
|
|
4044
|
+
const carets = shaper.measure(seg, resolvedFont(style));
|
|
4045
|
+
const track = (_nullishCoalesce(style.tracking, () => ( 0))) / 1e3 * style.fontSize;
|
|
4046
|
+
for (let k = 0; k < seg.length; k++) chars.push({ index: i + k, ch: seg[k], advance: (_nullishCoalesce(carets[k + 1], () => ( 0))) - (_nullishCoalesce(carets[k], () => ( 0))) + track, style });
|
|
4047
|
+
i = j;
|
|
4048
|
+
}
|
|
4049
|
+
const startIndent = _nullishCoalesce(pstyle.startIndent, () => ( 0));
|
|
4050
|
+
const endIndent = _nullishCoalesce(pstyle.endIndent, () => ( 0));
|
|
4051
|
+
const firstIndent = _nullishCoalesce(pstyle.firstLineIndent, () => ( 0));
|
|
4052
|
+
const breaks = [];
|
|
4053
|
+
if (!box2 || !chars.length) breaks.push([0, chars.length]);
|
|
4054
|
+
else {
|
|
4055
|
+
let s = 0;
|
|
4056
|
+
while (s < chars.length) {
|
|
4057
|
+
const avail = box2.width - startIndent - endIndent - (breaks.length === 0 ? firstIndent : 0);
|
|
4058
|
+
let w = 0;
|
|
4059
|
+
let e = s;
|
|
4060
|
+
let lastBreak = -1;
|
|
4061
|
+
while (e < chars.length) {
|
|
4062
|
+
const c = chars[e];
|
|
4063
|
+
if (!isSpace(c.ch) && w + c.advance > avail && e > s) break;
|
|
4064
|
+
w += c.advance;
|
|
4065
|
+
if (isBreakAfter(c.ch) || isWide(c.ch.charCodeAt(0)) || e + 1 < chars.length && isWide(chars[e + 1].ch.charCodeAt(0))) lastBreak = e + 1;
|
|
4066
|
+
e++;
|
|
4067
|
+
}
|
|
4068
|
+
if (e < chars.length && lastBreak > s) e = lastBreak;
|
|
4069
|
+
while (e < chars.length && isSpace(chars[e].ch)) e++;
|
|
4070
|
+
breaks.push([s, e]);
|
|
4071
|
+
s = e;
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
const align = _nullishCoalesce(pstyle.align, () => ( "left"));
|
|
4075
|
+
breaks.forEach(([s, e], li) => {
|
|
4076
|
+
const lineChars = chars.slice(s, e);
|
|
4077
|
+
let visibleEnd = lineChars.length;
|
|
4078
|
+
while (visibleEnd > 0 && isSpace(lineChars[visibleEnd - 1].ch)) visibleEnd--;
|
|
4079
|
+
const styles = lineChars.length ? [...new Set(lineChars.map((c) => c.style))] : [styleAt(runs, Math.min(para.start, Math.max(0, text3.length - 1)), DEFAULT_TEXT_STYLE)];
|
|
4080
|
+
let ascent = 0;
|
|
4081
|
+
let descent = 0;
|
|
4082
|
+
let leading = 0;
|
|
4083
|
+
for (const st of styles) {
|
|
4084
|
+
const m = shaper.metrics(resolvedFont(st));
|
|
4085
|
+
ascent = Math.max(ascent, m.ascent);
|
|
4086
|
+
descent = Math.max(descent, m.descent);
|
|
4087
|
+
leading = Math.max(leading, _nullishCoalesce(st.leading, () => ( autoLeading * st.fontSize)));
|
|
4088
|
+
}
|
|
4089
|
+
if (first) {
|
|
4090
|
+
y = frame.kind === "box" || frame.kind === "point" && frame.origin === "top" ? ascent : 0;
|
|
4091
|
+
first = false;
|
|
4092
|
+
} else y += leading;
|
|
4093
|
+
const indent = startIndent + (li === 0 ? firstIndent : 0);
|
|
4094
|
+
let width = 0;
|
|
4095
|
+
for (let k2 = 0; k2 < visibleEnd; k2++) width += lineChars[k2].advance;
|
|
4096
|
+
const lastLine = li === breaks.length - 1;
|
|
4097
|
+
let extraPerSpace = 0;
|
|
4098
|
+
if (box2 && align === "justify" && !lastLine) {
|
|
4099
|
+
const spaces = lineChars.slice(0, visibleEnd).filter((c) => isSpace(c.ch)).length;
|
|
4100
|
+
const avail = box2.width - startIndent - endIndent - (li === 0 ? firstIndent : 0);
|
|
4101
|
+
if (spaces > 0 && avail > width) extraPerSpace = (avail - width) / spaces;
|
|
4102
|
+
}
|
|
4103
|
+
let x0;
|
|
4104
|
+
const fullWidth = width + extraPerSpace * lineChars.slice(0, visibleEnd).filter((c) => isSpace(c.ch)).length;
|
|
4105
|
+
if (box2) {
|
|
4106
|
+
const avail = box2.width - startIndent - endIndent - (li === 0 ? firstIndent : 0);
|
|
4107
|
+
x0 = indent + (align === "center" ? (avail - fullWidth) / 2 : align === "right" ? avail - fullWidth : 0);
|
|
4108
|
+
} else x0 = indent + (align === "center" ? -fullWidth / 2 : align === "right" ? -fullWidth : 0);
|
|
4109
|
+
const laid = [];
|
|
4110
|
+
let x = x0;
|
|
4111
|
+
for (const c of lineChars) {
|
|
4112
|
+
const adv = c.advance + (isSpace(c.ch) ? extraPerSpace : 0);
|
|
4113
|
+
laid.push({ index: c.index, x, advance: adv });
|
|
4114
|
+
x += adv;
|
|
4115
|
+
}
|
|
4116
|
+
const fragments = [];
|
|
4117
|
+
let k = 0;
|
|
4118
|
+
while (k < lineChars.length) {
|
|
4119
|
+
const st = lineChars[k].style;
|
|
4120
|
+
let m = k + 1;
|
|
4121
|
+
while (m < lineChars.length && lineChars[m].style === st) m++;
|
|
4122
|
+
const font = resolvedFont(st);
|
|
4123
|
+
const fx = laid[k].x;
|
|
4124
|
+
const carets = [0];
|
|
4125
|
+
for (let q2 = k; q2 < m; q2++) carets.push(laid[q2].x + laid[q2].advance - fx);
|
|
4126
|
+
fragments.push({
|
|
4127
|
+
start: lineChars[k].index,
|
|
4128
|
+
end: lineChars[m - 1].index + 1,
|
|
4129
|
+
style: st,
|
|
4130
|
+
font,
|
|
4131
|
+
family: font.family,
|
|
4132
|
+
x: fx,
|
|
4133
|
+
y: y - (_nullishCoalesce(st.baselineShift, () => ( 0))),
|
|
4134
|
+
carets,
|
|
4135
|
+
spaced: Boolean(st.tracking) || extraPerSpace > 0
|
|
4136
|
+
});
|
|
4137
|
+
k = m;
|
|
4138
|
+
}
|
|
4139
|
+
const lineStart = lineChars.length ? lineChars[0].index : para.start;
|
|
4140
|
+
lines.push({ start: lineStart, end: lineChars.length ? lineChars[lineChars.length - 1].index + 1 : para.start, baseline: y, ascent, descent, x: x0, width, chars: laid, fragments });
|
|
4141
|
+
});
|
|
4142
|
+
y += _nullishCoalesce(pstyle.spaceAfter, () => ( 0));
|
|
4143
|
+
});
|
|
4144
|
+
let bounds;
|
|
4145
|
+
if (box2) bounds = { x: 0, y: 0, width: box2.width, height: box2.height };
|
|
4146
|
+
else {
|
|
4147
|
+
let x0 = Infinity;
|
|
4148
|
+
let x1 = -Infinity;
|
|
4149
|
+
for (const l of lines) {
|
|
4150
|
+
x0 = Math.min(x0, l.x);
|
|
4151
|
+
x1 = Math.max(x1, l.x + l.width);
|
|
4152
|
+
}
|
|
4153
|
+
if (!Number.isFinite(x0)) x0 = x1 = 0;
|
|
4154
|
+
const top = lines.length ? lines[0].baseline - lines[0].ascent : 0;
|
|
4155
|
+
const last = lines[lines.length - 1];
|
|
4156
|
+
const bottom = last ? last.baseline + last.descent : 0;
|
|
4157
|
+
bounds = { x: x0, y: top, width: Math.max(0, x1 - x0), height: Math.max(0, bottom - top) };
|
|
4158
|
+
}
|
|
4159
|
+
return { lines, bounds, missingFonts: [...missing] };
|
|
4160
|
+
}
|
|
4161
|
+
function textIndexAt(layout, p) {
|
|
4162
|
+
if (!layout.lines.length) return 0;
|
|
4163
|
+
let line = layout.lines[layout.lines.length - 1];
|
|
4164
|
+
for (const l of layout.lines) {
|
|
4165
|
+
if (p.y <= l.baseline + l.descent) {
|
|
4166
|
+
line = l;
|
|
4167
|
+
break;
|
|
4168
|
+
}
|
|
4169
|
+
}
|
|
4170
|
+
if (!line.chars.length) return line.start;
|
|
4171
|
+
for (const c of line.chars) if (p.x < c.x + c.advance / 2) return c.index;
|
|
4172
|
+
const lastChar = line.chars[line.chars.length - 1];
|
|
4173
|
+
return lastChar.index + 1;
|
|
4174
|
+
}
|
|
4175
|
+
function caretAt(layout, index) {
|
|
4176
|
+
const lines = layout.lines;
|
|
4177
|
+
if (!lines.length) return { x: 0, top: 0, bottom: 0, line: 0 };
|
|
4178
|
+
for (let li = 0; li < lines.length; li++) {
|
|
4179
|
+
const l2 = lines[li];
|
|
4180
|
+
const next = lines[li + 1];
|
|
4181
|
+
if (next && index >= next.start && (next.chars.length || index > l2.end || next.start > l2.end)) continue;
|
|
4182
|
+
const c = l2.chars.find((ch) => ch.index === index);
|
|
4183
|
+
const prev = l2.chars.find((ch) => ch.index === index - 1);
|
|
4184
|
+
const x = c ? c.x : prev ? prev.x + prev.advance : l2.x;
|
|
4185
|
+
return { x, top: l2.baseline - l2.ascent, bottom: l2.baseline + l2.descent, line: li };
|
|
4186
|
+
}
|
|
4187
|
+
const l = lines[lines.length - 1];
|
|
4188
|
+
return { x: l.x + l.width, top: l.baseline - l.ascent, bottom: l.baseline + l.descent, line: lines.length - 1 };
|
|
4189
|
+
}
|
|
4190
|
+
var TEXT_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
|
|
4191
|
+
function textMatrix(layer) {
|
|
4192
|
+
return _nullishCoalesce(layer.transform, () => ( _chunkW3GXSUSQcjs.IDENTITY_MATRIX));
|
|
4193
|
+
}
|
|
4194
|
+
function rectCorners(r) {
|
|
4195
|
+
return [
|
|
4196
|
+
{ x: r.x, y: r.y },
|
|
4197
|
+
{ x: r.x + r.width, y: r.y },
|
|
4198
|
+
{ x: r.x + r.width, y: r.y + r.height },
|
|
4199
|
+
{ x: r.x, y: r.y + r.height }
|
|
4200
|
+
];
|
|
4201
|
+
}
|
|
4202
|
+
function docRect(r, m) {
|
|
4203
|
+
const pts = rectCorners(r).map((p) => _chunkW3GXSUSQcjs.applyMatrix.call(void 0, m, p));
|
|
4204
|
+
const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
|
|
4205
|
+
const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
|
|
4206
|
+
const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
|
|
4207
|
+
const y1 = Math.ceil(Math.max(...pts.map((p) => p.y)));
|
|
4208
|
+
return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
4209
|
+
}
|
|
4210
|
+
function intersect2(a, b) {
|
|
4211
|
+
const x0 = Math.max(a.x, b.x);
|
|
4212
|
+
const y0 = Math.max(a.y, b.y);
|
|
4213
|
+
const x1 = Math.min(a.x + a.width, b.x + b.width);
|
|
4214
|
+
const y1 = Math.min(a.y + a.height, b.y + b.height);
|
|
4215
|
+
return x1 > x0 && y1 > y0 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : null;
|
|
4216
|
+
}
|
|
4217
|
+
function inkBounds(layout) {
|
|
4218
|
+
let b = null;
|
|
4219
|
+
for (const l of layout.lines) {
|
|
4220
|
+
for (const f of l.fragments) {
|
|
4221
|
+
const pad = f.style.fontSize * 0.5;
|
|
4222
|
+
const w = f.carets[f.carets.length - 1];
|
|
4223
|
+
const r = { x: f.x - pad, y: f.y - l.ascent - pad, width: w + 2 * pad, height: l.ascent + l.descent + 2 * pad };
|
|
4224
|
+
if (!b) b = r;
|
|
4225
|
+
else {
|
|
4226
|
+
const x0 = Math.min(b.x, r.x);
|
|
4227
|
+
const y0 = Math.min(b.y, r.y);
|
|
4228
|
+
b = { x: x0, y: y0, width: Math.max(b.x + b.width, r.x + r.width) - x0, height: Math.max(b.y + b.height, r.y + r.height) - y0 };
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
}
|
|
4232
|
+
return b;
|
|
4233
|
+
}
|
|
4234
|
+
function decorations(f, l) {
|
|
4235
|
+
const out = [];
|
|
4236
|
+
const t = Math.max(1, f.style.fontSize / 15);
|
|
4237
|
+
const w = f.carets[f.carets.length - 1];
|
|
4238
|
+
if (f.style.underline) out.push({ x: f.x, y: f.y + Math.max(t, l.descent * 0.35), width: w, height: t });
|
|
4239
|
+
if (f.style.strikethrough) out.push({ x: f.x, y: f.y - l.ascent * 0.3 - t / 2, width: w, height: t });
|
|
4240
|
+
return out;
|
|
4241
|
+
}
|
|
4242
|
+
var rectPath = (r) => [
|
|
4243
|
+
{ type: "M", x: r.x, y: r.y },
|
|
4244
|
+
{ type: "L", x: r.x + r.width, y: r.y },
|
|
4245
|
+
{ type: "L", x: r.x + r.width, y: r.y + r.height },
|
|
4246
|
+
{ type: "L", x: r.x, y: r.y + r.height },
|
|
4247
|
+
{ type: "Z" }
|
|
4248
|
+
];
|
|
4249
|
+
function fragmentOutline(shaper, text3, f) {
|
|
4250
|
+
const s = text3.slice(f.start, f.end);
|
|
4251
|
+
if (!f.spaced) return shaper.outline(s, f.font, f.x, f.y);
|
|
4252
|
+
const out = [];
|
|
4253
|
+
for (let k = 0; k < s.length; k++) {
|
|
4254
|
+
if (isSpace(s[k])) continue;
|
|
4255
|
+
out.push(...shaper.outline(s[k], f.font, f.x + f.carets[k], f.y));
|
|
4256
|
+
}
|
|
4257
|
+
return out;
|
|
4258
|
+
}
|
|
4259
|
+
function textOutlines(layer, shaper) {
|
|
4260
|
+
if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
|
|
4261
|
+
const layout = layoutText(layer, shaper);
|
|
4262
|
+
const m = textMatrix(layer);
|
|
4263
|
+
const out = [];
|
|
4264
|
+
for (const l of layout.lines) {
|
|
4265
|
+
for (const f of l.fragments) {
|
|
4266
|
+
let path = fragmentOutline(shaper, layer.text, f);
|
|
4267
|
+
for (const r of decorations(f, l)) path = [...path, ...rectPath(r)];
|
|
4268
|
+
out.push({ fragment: f, path: _chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkXGD3FSNCcjs.transformBezierPath.call(void 0, path, m) });
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
return out;
|
|
4272
|
+
}
|
|
4273
|
+
var rgbOf = (hex) => {
|
|
4274
|
+
const c = parseCssColor(hex);
|
|
4275
|
+
const h = (_nullishCoalesce(_optionalChain([c, 'optionalAccess', _67 => _67.hex]), () => ( "#000000"))).slice(1);
|
|
4276
|
+
return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
|
|
4277
|
+
};
|
|
4278
|
+
function renderOutlines(layer, shaper, region) {
|
|
4279
|
+
const parts = textOutlines(layer, shaper).map(({ fragment, path }) => ({ style: fragment.style, flat: flattenPath(path) }));
|
|
4280
|
+
const tiles = /* @__PURE__ */ new Map();
|
|
4281
|
+
for (const { tx, ty } of _chunkXIOMMGPDcjs.tilesInRect.call(void 0, region)) {
|
|
4282
|
+
const rect = { x: tx * _chunkXIOMMGPDcjs.TILE, y: ty * _chunkXIOMMGPDcjs.TILE, width: _chunkXIOMMGPDcjs.TILE, height: _chunkXIOMMGPDcjs.TILE };
|
|
4283
|
+
const n = _chunkXIOMMGPDcjs.TILE * _chunkXIOMMGPDcjs.TILE;
|
|
4284
|
+
const acc = new Float32Array(n * 4);
|
|
4285
|
+
let any = false;
|
|
4286
|
+
for (const p of parts) {
|
|
4287
|
+
const cov = rasterizeCoverageSampled(p.flat, rect, "nonzero");
|
|
4288
|
+
if (!cov) continue;
|
|
4289
|
+
const [r, g, b] = rgbOf(p.style.color);
|
|
4290
|
+
const op = _nullishCoalesce(p.style.opacity, () => ( 1));
|
|
4291
|
+
for (let i = 0; i < n; i++) {
|
|
4292
|
+
const sa = layer.antiAlias === false ? cov[i] >= 0.5 ? op : 0 : cov[i] * op;
|
|
4293
|
+
if (!(sa > 0)) continue;
|
|
4294
|
+
const k = i * 4;
|
|
4295
|
+
const da = acc[k + 3];
|
|
4296
|
+
const ao = sa + da * (1 - sa);
|
|
4297
|
+
acc[k] = (r * sa + acc[k] * da * (1 - sa)) / ao;
|
|
4298
|
+
acc[k + 1] = (g * sa + acc[k + 1] * da * (1 - sa)) / ao;
|
|
4299
|
+
acc[k + 2] = (b * sa + acc[k + 2] * da * (1 - sa)) / ao;
|
|
4300
|
+
acc[k + 3] = ao;
|
|
4301
|
+
any = true;
|
|
4302
|
+
}
|
|
4303
|
+
}
|
|
4304
|
+
if (!any) continue;
|
|
4305
|
+
const px = new Uint8ClampedArray(n * 4);
|
|
4306
|
+
for (let i = 0; i < n * 4; i += 4) {
|
|
4307
|
+
const a = Math.round(acc[i + 3] * 255);
|
|
4308
|
+
if (!a) continue;
|
|
4309
|
+
px[i] = Math.round(acc[i]);
|
|
4310
|
+
px[i + 1] = Math.round(acc[i + 1]);
|
|
4311
|
+
px[i + 2] = Math.round(acc[i + 2]);
|
|
4312
|
+
px[i + 3] = a;
|
|
4313
|
+
}
|
|
4314
|
+
const tile = _chunkXIOMMGPDcjs.finishTile.call(void 0, px, 4, 0);
|
|
4315
|
+
if (tile) tiles.set(_chunkXIOMMGPDcjs.tileKey.call(void 0, tx, ty), tile);
|
|
4316
|
+
}
|
|
4317
|
+
return new (0, _chunkXIOMMGPDcjs.TiledSurface)(4, tiles, 0);
|
|
4318
|
+
}
|
|
4319
|
+
function renderOnCanvas(layer, shaper, region, env) {
|
|
4320
|
+
if (!env.createCanvas) return null;
|
|
4321
|
+
const canvas = env.createCanvas(region.width, region.height);
|
|
4322
|
+
const ctx = canvas.getContext("2d");
|
|
4323
|
+
if (!ctx || typeof ctx.getImageData !== "function") return null;
|
|
4324
|
+
const layout = layoutText(layer, shaper);
|
|
4325
|
+
const m = textMatrix(layer);
|
|
4326
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4327
|
+
ctx.clearRect(0, 0, region.width, region.height);
|
|
4328
|
+
ctx.setTransform(m[0], m[1], m[2], m[3], m[4] - region.x, m[5] - region.y);
|
|
4329
|
+
for (const l of layout.lines) {
|
|
4330
|
+
for (const f of l.fragments) {
|
|
4331
|
+
const [r, g, b] = rgbOf(f.style.color);
|
|
4332
|
+
ctx.fillStyle = `rgb(${r}, ${g}, ${b})`;
|
|
4333
|
+
ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
|
|
4334
|
+
const s = layer.text.slice(f.start, f.end);
|
|
4335
|
+
if (!f.spaced) shaper.draw(ctx, s, f.font, f.x, f.y);
|
|
4336
|
+
else for (let k = 0; k < s.length; k++) if (!isSpace(s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
|
|
4337
|
+
for (const d of decorations(f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
|
|
4338
|
+
}
|
|
4339
|
+
}
|
|
4340
|
+
ctx.globalAlpha = 1;
|
|
4341
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4342
|
+
const data = ctx.getImageData(0, 0, region.width, region.height).data;
|
|
4343
|
+
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: region.width, height: region.height, data: new Uint8ClampedArray(data) }, 4, region.x, region.y);
|
|
4344
|
+
}
|
|
4345
|
+
function renderText(layer, env) {
|
|
4346
|
+
const shaper = env.shaper;
|
|
4347
|
+
if (!shaper || !shaper.outline && !shaper.draw) return null;
|
|
4348
|
+
const layout = layoutText(layer, shaper);
|
|
4349
|
+
const ink = inkBounds(layout);
|
|
4350
|
+
const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
|
|
4351
|
+
const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
|
|
4352
|
+
if (!region) return { surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), missingFonts: layout.missingFonts };
|
|
4353
|
+
if (shaper.outline) return { surface: renderOutlines(layer, shaper, region), missingFonts: layout.missingFonts };
|
|
4354
|
+
const surface = renderOnCanvas(layer, shaper, region, env);
|
|
4355
|
+
return surface ? { surface, missingFonts: layout.missingFonts } : null;
|
|
4356
|
+
}
|
|
4357
|
+
function rerenderText(layer, env) {
|
|
4358
|
+
const r = renderText(layer, env);
|
|
4359
|
+
if (!r) return fail3("Type layers need a text shaper to draw them, and none is set here (no 2D canvas). Pass textShaper in the editor options (for example createOutlineTextShaper with your fonts), or edit in a browser.");
|
|
4360
|
+
const next = { ...layer, surface: r.surface };
|
|
4361
|
+
delete next.rendering;
|
|
4362
|
+
if (r.missingFonts.length) next.missingFonts = r.missingFonts;
|
|
4363
|
+
else delete next.missingFonts;
|
|
4364
|
+
return next;
|
|
4365
|
+
}
|
|
4366
|
+
var isNum2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
4367
|
+
function num(v, path, min, max) {
|
|
4368
|
+
if (!isNum2(v) || v < min || v > max) fail3(`${path} must be a number from ${min} to ${max}, got ${JSON.stringify(v)}.`);
|
|
4369
|
+
return v;
|
|
4370
|
+
}
|
|
4371
|
+
var TEXT_STYLE_FIELDS = ["fontFamily", "fontWeight", "italic", "fontSize", "color", "opacity", "tracking", "leading", "baselineShift", "underline", "strikethrough"];
|
|
4372
|
+
function patchTextStyle(base, patch, path = "style") {
|
|
4373
|
+
const out = { ...base };
|
|
4374
|
+
const o = out;
|
|
4375
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
4376
|
+
if (v === void 0) continue;
|
|
4377
|
+
switch (k) {
|
|
4378
|
+
case "fontFamily":
|
|
4379
|
+
if (typeof v !== "string" || !v.trim()) fail3(`${path}.fontFamily must be a font family name.`);
|
|
4380
|
+
out.fontFamily = v.trim();
|
|
4381
|
+
if (out.postScriptName) delete out.postScriptName;
|
|
4382
|
+
break;
|
|
4383
|
+
case "fontWeight": {
|
|
4384
|
+
const w = v === "normal" ? 400 : v === "bold" ? 700 : v;
|
|
4385
|
+
out.fontWeight = Math.round(num(w, `${path}.fontWeight`, 1, 1e3));
|
|
4386
|
+
if (out.postScriptName) delete out.postScriptName;
|
|
4387
|
+
break;
|
|
4388
|
+
}
|
|
4389
|
+
case "italic":
|
|
4390
|
+
case "underline":
|
|
4391
|
+
case "strikethrough":
|
|
4392
|
+
if (typeof v !== "boolean" && v !== null) fail3(`${path}.${k} must be true or false.`);
|
|
4393
|
+
if (v) o[k] = true;
|
|
4394
|
+
else delete o[k];
|
|
4395
|
+
if (k === "italic" && out.postScriptName) delete out.postScriptName;
|
|
4396
|
+
break;
|
|
4397
|
+
case "fontSize":
|
|
4398
|
+
out.fontSize = num(v, `${path}.fontSize`, 0.5, 5e3);
|
|
4399
|
+
break;
|
|
4400
|
+
case "color": {
|
|
4401
|
+
const c = parseCssColor(v);
|
|
4402
|
+
if (!c) fail3(`${path}.color must be a colour such as #rrggbb.`);
|
|
4403
|
+
out.color = c.hex;
|
|
4404
|
+
if (c.alpha < 1) out.opacity = c.alpha;
|
|
4405
|
+
break;
|
|
4406
|
+
}
|
|
4407
|
+
case "opacity":
|
|
4408
|
+
case "tracking":
|
|
4409
|
+
case "leading":
|
|
4410
|
+
case "baselineShift": {
|
|
4411
|
+
if (v === null) {
|
|
4412
|
+
delete o[k];
|
|
4413
|
+
break;
|
|
4414
|
+
}
|
|
4415
|
+
const [min, max] = k === "opacity" ? [0, 1] : k === "tracking" ? [-1e3, 1e4] : k === "leading" ? [0, 1e4] : [-5e3, 5e3];
|
|
4416
|
+
const value = num(v, `${path}.${k}`, min, max);
|
|
4417
|
+
if (k === "opacity" && value === 1 || (k === "tracking" || k === "baselineShift") && value === 0) delete o[k];
|
|
4418
|
+
else o[k] = value;
|
|
4419
|
+
break;
|
|
4420
|
+
}
|
|
4421
|
+
default:
|
|
4422
|
+
fail3(`${path}.${k} is not a character style field; use ${TEXT_STYLE_FIELDS.join(", ")}.`);
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
return out;
|
|
4426
|
+
}
|
|
4427
|
+
var PARAGRAPH_STYLE_FIELDS = ["align", "autoLeading", "firstLineIndent", "startIndent", "endIndent", "spaceBefore", "spaceAfter"];
|
|
4428
|
+
function patchParagraphStyle(base, patch, path = "paragraph") {
|
|
4429
|
+
const out = { ...base };
|
|
4430
|
+
const o = out;
|
|
4431
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
4432
|
+
if (v === void 0) continue;
|
|
4433
|
+
if (k === "align") {
|
|
4434
|
+
if (!TEXT_ALIGNS.includes(v)) fail3(`${path}.align must be one of ${TEXT_ALIGNS.join(", ")}.`);
|
|
4435
|
+
if (v === "left") delete out.align;
|
|
4436
|
+
else out.align = v;
|
|
4437
|
+
} else if (PARAGRAPH_STYLE_FIELDS.includes(k)) {
|
|
4438
|
+
if (v === null) {
|
|
4439
|
+
delete o[k];
|
|
4440
|
+
continue;
|
|
4441
|
+
}
|
|
4442
|
+
const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
|
|
4443
|
+
if (k === "autoLeading" && value === DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
|
|
4444
|
+
else o[k] = value;
|
|
4445
|
+
} else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
|
|
4446
|
+
}
|
|
4447
|
+
return out;
|
|
4448
|
+
}
|
|
4449
|
+
function textRange(text3, start, end) {
|
|
4450
|
+
const s = start === void 0 ? 0 : start;
|
|
4451
|
+
const e = end === void 0 ? text3.length : end;
|
|
4452
|
+
if (!Number.isInteger(s) || !Number.isInteger(e) || s < 0 || e > text3.length || s > e) {
|
|
4453
|
+
fail3(`start and end must be whole numbers with 0 \u2264 start \u2264 end \u2264 ${text3.length} (the text's length in UTF-16 code units), got ${String(start)} and ${String(end)}.`);
|
|
4454
|
+
}
|
|
4455
|
+
return [s, e];
|
|
4456
|
+
}
|
|
4457
|
+
function requireTypeLayer(layers, id) {
|
|
4458
|
+
const layer = requireLayer(layers, id).layer;
|
|
4459
|
+
if (layer.type !== "type") fail3(`Layer "${layer.name || id}" is a ${layer.type} layer, not a type layer; list_layers shows each layer's type.`);
|
|
4460
|
+
return layer;
|
|
4461
|
+
}
|
|
4462
|
+
function normalizeText(text3, path = "text") {
|
|
4463
|
+
if (typeof text3 !== "string") return fail3(`${path} must be a string.`);
|
|
4464
|
+
return text3.replace(/\r\n?/g, "\n");
|
|
4465
|
+
}
|
|
4466
|
+
function typeLayerName(text3) {
|
|
4467
|
+
const line = _nullishCoalesce(text3.split("\n").find((l) => l.trim()), () => ( ""));
|
|
4468
|
+
return line.trim().slice(0, 32) || "Text";
|
|
4469
|
+
}
|
|
4470
|
+
function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
|
|
4471
|
+
const text3 = normalizeText(init.text);
|
|
4472
|
+
const layer = {
|
|
4473
|
+
type: "type",
|
|
4474
|
+
id,
|
|
4475
|
+
name: _nullishCoalesce(init.name, () => ( typeLayerName(text3))),
|
|
4476
|
+
visible: true,
|
|
4477
|
+
opacity: 1,
|
|
4478
|
+
blend: "normal",
|
|
4479
|
+
text: text3,
|
|
4480
|
+
runs: fitRuns(init.runs, text3.length, DEFAULT_TEXT_STYLE),
|
|
4481
|
+
paragraphs: fitParagraphRuns(_nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
|
|
4482
|
+
frame: init.frame,
|
|
4483
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
4484
|
+
offset: { x: 0, y: 0 }
|
|
4485
|
+
};
|
|
4486
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _68 => _68.runs, 'access', _69 => _69[0], 'optionalAccess', _70 => _70.style]), () => ( DEFAULT_TEXT_STYLE)) }];
|
|
4487
|
+
if (init.transform && !_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
|
|
4488
|
+
if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
|
|
4489
|
+
return rerenderText(layer, env);
|
|
4490
|
+
}
|
|
4491
|
+
function updateTypeLayer(layers, id, change, env, action = "edit it") {
|
|
4492
|
+
const current = requireTypeLayer(layers, id);
|
|
4493
|
+
requireUnlocked(current, "pixels", action);
|
|
4494
|
+
const patch = change(current);
|
|
4495
|
+
const next = { ...current, ...patch };
|
|
4496
|
+
if (!("annotation" in patch)) delete next.annotation;
|
|
4497
|
+
if ("text" in patch || "runs" in patch) next.runs = fitRuns(next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _71 => _71.runs, 'access', _72 => _72[0], 'optionalAccess', _73 => _73.style]), () => ( DEFAULT_TEXT_STYLE)));
|
|
4498
|
+
if (!next.runs.length) next.runs = [{ length: 0, style: styleAt(current.runs, 0, DEFAULT_TEXT_STYLE) }];
|
|
4499
|
+
if ("text" in patch || "paragraphs" in patch) next.paragraphs = fitParagraphRuns(next.paragraphs, next.text);
|
|
4500
|
+
const rendered = rerenderText(next, env);
|
|
4501
|
+
return { layers: _chunkPOGBUYWEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
4502
|
+
}
|
|
4503
|
+
function replaceTextRange(layer, start, end, insert) {
|
|
4504
|
+
const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
|
|
4505
|
+
const style = styleAt(layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, DEFAULT_TEXT_STYLE);
|
|
4506
|
+
const runs = spliceRuns(layer.runs, start, end, insert.length, style);
|
|
4507
|
+
const pstyle = styleAt(layer.paragraphs, start, {});
|
|
4508
|
+
const paragraphs = spliceRuns(layer.paragraphs, start, end, insert.length, pstyle);
|
|
4509
|
+
return { text: text3, runs, paragraphs: fitParagraphRuns(paragraphs, text3) };
|
|
4510
|
+
}
|
|
4511
|
+
function transformTypeLayer(layer, m) {
|
|
4512
|
+
const t = _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
|
|
4513
|
+
const next = { ...layer };
|
|
4514
|
+
if (_chunkW3GXSUSQcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
|
|
4515
|
+
else next.transform = t;
|
|
4516
|
+
delete next.annotation;
|
|
4517
|
+
return next;
|
|
4518
|
+
}
|
|
4519
|
+
function typeFrame(layer, shaper) {
|
|
4520
|
+
if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
|
|
4521
|
+
if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
|
|
4522
|
+
const b = layoutText(layer, shaper).bounds;
|
|
4523
|
+
return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
|
|
4524
|
+
}
|
|
4525
|
+
function typeAsPixelLayer(layer) {
|
|
4526
|
+
const { text: _t, runs: _r, paragraphs: _p, frame: _f, transform: _m, antiAlias: _a, rendering: _g, missingFonts: _mf, annotation: _an, psd: _psd, type: _ty, ...rest } = layer;
|
|
4527
|
+
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
4528
|
+
}
|
|
4529
|
+
function toTextSpace(layer, p) {
|
|
4530
|
+
return _chunkW3GXSUSQcjs.applyMatrix.call(void 0, _chunkW3GXSUSQcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
|
|
4531
|
+
}
|
|
4532
|
+
function typeFromAnnotation(a) {
|
|
4533
|
+
if (a.type !== "text") return null;
|
|
4534
|
+
const t = a;
|
|
4535
|
+
const c = parseCssColor(t.color);
|
|
4536
|
+
if (!c) return null;
|
|
4537
|
+
const weight = t.fontWeight === void 0 || t.fontWeight === "normal" ? 400 : t.fontWeight === "bold" ? 700 : Number(t.fontWeight);
|
|
4538
|
+
if (!Number.isFinite(weight)) return null;
|
|
4539
|
+
const style = { fontFamily: t.fontFamily || "sans-serif", fontWeight: weight, fontSize: t.fontSize, color: c.hex };
|
|
4540
|
+
const op = c.alpha * (_nullishCoalesce(t.opacity, () => ( 1)));
|
|
4541
|
+
if (op !== 1) style.opacity = op;
|
|
4542
|
+
const text3 = t.text.replace(/\r?\n|\r/g, " ");
|
|
4543
|
+
const translate = [1, 0, 0, 1, t.x, t.y];
|
|
4544
|
+
const transform = t.rotation ? _chunkW3GXSUSQcjs.multiplyMatrices.call(void 0, translate, _chunkW3GXSUSQcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
|
|
4545
|
+
return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
|
|
4546
|
+
}
|
|
4547
|
+
function annotationOfType(layer) {
|
|
4548
|
+
const a = layer.annotation;
|
|
4549
|
+
if (!a) return null;
|
|
4550
|
+
if ((_nullishCoalesce(a.blend, () => ( "normal"))) === layer.blend) return a;
|
|
4551
|
+
const out = { ...a };
|
|
4552
|
+
if (layer.blend === "normal") delete out.blend;
|
|
4553
|
+
else out.blend = layer.blend;
|
|
4554
|
+
return out;
|
|
4555
|
+
}
|
|
4556
|
+
|
|
3890
4557
|
// src/image-editor/layers/defaults.ts
|
|
3891
4558
|
var DEFAULT_ADJUSTMENTS_VALUES = {
|
|
3892
4559
|
brightness: 0,
|
|
@@ -3988,6 +4655,12 @@ function annotationLayerName(annotation) {
|
|
|
3988
4655
|
}
|
|
3989
4656
|
}
|
|
3990
4657
|
function annotationLayerFor(annotation, canvas) {
|
|
4658
|
+
const blend = annotation.blend && annotation.blend !== "normal" ? annotation.blend : "normal";
|
|
4659
|
+
const type = canvas ? typeFromAnnotation(annotation) : null;
|
|
4660
|
+
if (type) {
|
|
4661
|
+
const layer = createTypeLayer({ ...type, name: annotationLayerName(annotation) }, { shaper: null, ...canvas }, annotation.id, true);
|
|
4662
|
+
return { ...layer, blend, annotation };
|
|
4663
|
+
}
|
|
3991
4664
|
const shape = canvas ? shapeFromAnnotation(annotation) : null;
|
|
3992
4665
|
if (shape) {
|
|
3993
4666
|
const layer = createShapeLayer(
|
|
@@ -4010,6 +4683,7 @@ function annotationLayerFor(annotation, canvas) {
|
|
|
4010
4683
|
function annotationOfLayer(layer) {
|
|
4011
4684
|
if (layer.type === "annotation") return layer.annotation;
|
|
4012
4685
|
if (layer.type === "shape") return annotationOfShape(layer);
|
|
4686
|
+
if (layer.type === "type") return annotationOfType(layer);
|
|
4013
4687
|
return null;
|
|
4014
4688
|
}
|
|
4015
4689
|
function adjustmentNodeFromLegacy(layer, width, height) {
|
|
@@ -4107,7 +4781,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
|
|
|
4107
4781
|
const { layers } = stack;
|
|
4108
4782
|
const target = developTarget(layers, activeLayerId);
|
|
4109
4783
|
const develop = target ? developFilter(target) : void 0;
|
|
4110
|
-
const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call',
|
|
4784
|
+
const blur = _nullishCoalesce(_nullishCoalesce(stack.legacyOutputBlur, () => ( (target ? _optionalChain([blurFilter, 'call', _74 => _74(target), 'optionalAccess', _75 => _75.radius]) : void 0))), () => ( 0));
|
|
4111
4785
|
const adjustments = {
|
|
4112
4786
|
...DEFAULT_ADJUSTMENTS_VALUES,
|
|
4113
4787
|
...develop ? {
|
|
@@ -4136,7 +4810,7 @@ function legacyView(stack, width, height, activeLayerId = null) {
|
|
|
4136
4810
|
};
|
|
4137
4811
|
walk(layers);
|
|
4138
4812
|
if (adjNodes.length) adjustments.layers = adjNodes.map((n) => legacyAdjustmentLayer(n, width, height));
|
|
4139
|
-
const depthSource = _optionalChain([target, 'optionalAccess',
|
|
4813
|
+
const depthSource = _optionalChain([target, 'optionalAccess', _76 => _76.mask, 'optionalAccess', _77 => _77.source]);
|
|
4140
4814
|
const depthMask = depthSource ? { ...depthSource, depthRange: [...depthSource.depthRange] } : { ...DEFAULT_DEPTH_MASK_VALUES, depthRange: [...DEFAULT_DEPTH_MASK_VALUES.depthRange] };
|
|
4141
4815
|
return { adjustments, depthMask, annotations, exact: isLegacyShape(stack) };
|
|
4142
4816
|
}
|
|
@@ -4161,12 +4835,12 @@ function isLegacyShape(stack) {
|
|
|
4161
4835
|
let adjustments = 0;
|
|
4162
4836
|
for (; i < layers.length && layers[i].type === "adjustment"; i++) {
|
|
4163
4837
|
const l = layers[i];
|
|
4164
|
-
if (l.clipped || l.locks || _optionalChain([l, 'access',
|
|
4838
|
+
if (l.clipped || l.locks || _optionalChain([l, 'access', _78 => _78.mask, 'optionalAccess', _79 => _79.source]) || l.effects) return false;
|
|
4165
4839
|
adjustments++;
|
|
4166
4840
|
}
|
|
4167
4841
|
for (; i < layers.length; i++) {
|
|
4168
4842
|
const l = layers[i];
|
|
4169
|
-
if (l.type === "shape") {
|
|
4843
|
+
if (l.type === "shape" || l.type === "type") {
|
|
4170
4844
|
const a = l.annotation;
|
|
4171
4845
|
if (!a || (_nullishCoalesce(a.blend, () => ( "normal"))) !== l.blend || !isPlain({ ...l, blend: "normal" }) || l.fillOpacity !== void 0) return false;
|
|
4172
4846
|
if (l.id !== a.id || l.name !== annotationLayerName(a)) return false;
|
|
@@ -4338,7 +5012,7 @@ function geometryHomography(geometry) {
|
|
|
4338
5012
|
}
|
|
4339
5013
|
|
|
4340
5014
|
// src/image-editor/layers/smart.ts
|
|
4341
|
-
var
|
|
5015
|
+
var fail4 = (message) => {
|
|
4342
5016
|
throw new LayerOperationError(message);
|
|
4343
5017
|
};
|
|
4344
5018
|
var SMART_RENDER_MARGIN = _chunkPOGBUYWEcjs.MAX_EFFECT_REACH;
|
|
@@ -4359,14 +5033,14 @@ function isContentsDecoded(contents) {
|
|
|
4359
5033
|
}
|
|
4360
5034
|
function requireDecoded(layer, action) {
|
|
4361
5035
|
if (isContentsDecoded(layer.contents)) return;
|
|
4362
|
-
const what = _optionalChain([layer, 'access',
|
|
4363
|
-
|
|
5036
|
+
const what = _optionalChain([layer, 'access', _80 => _80.contents, 'access', _81 => _81.file, 'optionalAccess', _82 => _82.type]) ? `a ${layer.contents.file.type.toUpperCase()} file` : "a file";
|
|
5037
|
+
fail4(
|
|
4364
5038
|
`The contents of smart object "${layer.name || layer.id}" are ${what} that could not be decoded here, so it cannot ${action}. Run prepareSmartObjects() in a browser first, or rasterize it.`
|
|
4365
5039
|
);
|
|
4366
5040
|
}
|
|
4367
5041
|
function requireSmartObject(layers, id) {
|
|
4368
5042
|
const layer = requireLayer(layers, id).layer;
|
|
4369
|
-
if (layer.type !== "smart")
|
|
5043
|
+
if (layer.type !== "smart") fail4(`Layer "${layer.name || id}" is a ${layer.type} layer, not a smart object; convert it with convert_to_smart_object.`);
|
|
4370
5044
|
return layer;
|
|
4371
5045
|
}
|
|
4372
5046
|
var contentsPixels = /* @__PURE__ */ new WeakMap();
|
|
@@ -4384,7 +5058,7 @@ function contentsSurface(contents) {
|
|
|
4384
5058
|
width: W,
|
|
4385
5059
|
height: H,
|
|
4386
5060
|
globalLight: doc.globalLight,
|
|
4387
|
-
pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access',
|
|
5061
|
+
pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _83 => _83.patterns, 'optionalAccess', _84 => _84.find, 'call', _85 => _85((p) => p.id === id)]), () => ( null))
|
|
4388
5062
|
});
|
|
4389
5063
|
s = _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
|
|
4390
5064
|
}
|
|
@@ -4392,11 +5066,11 @@ function contentsSurface(contents) {
|
|
|
4392
5066
|
return s;
|
|
4393
5067
|
}
|
|
4394
5068
|
function rasterContents(pixels, name, id = newContentsId()) {
|
|
4395
|
-
if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4)
|
|
5069
|
+
if (!(pixels.width > 0 && pixels.height > 0) || pixels.data.length < pixels.width * pixels.height * 4) fail4("Contents pixels must be RGBA with width \xD7 height \xD7 4 bytes.");
|
|
4396
5070
|
return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
|
|
4397
5071
|
}
|
|
4398
5072
|
function documentContents(document, width, height, name, id = newContentsId()) {
|
|
4399
|
-
if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0))
|
|
5073
|
+
if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail4("Contents width and height must be positive whole numbers.");
|
|
4400
5074
|
return { id, name, width, height, kind: "document", document };
|
|
4401
5075
|
}
|
|
4402
5076
|
var placedCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -4419,7 +5093,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4419
5093
|
const preview = Boolean(options.step && options.step > 1) || Boolean(options.clip);
|
|
4420
5094
|
const key = placementKey(placement, canvas);
|
|
4421
5095
|
if (!preview) {
|
|
4422
|
-
const hit = _optionalChain([placedCache, 'access',
|
|
5096
|
+
const hit = _optionalChain([placedCache, 'access', _86 => _86.get, 'call', _87 => _87(contents), 'optionalAccess', _88 => _88.get, 'call', _89 => _89(key)]);
|
|
4423
5097
|
if (hit) return hit;
|
|
4424
5098
|
}
|
|
4425
5099
|
const src = contentsSurface(contents);
|
|
@@ -4446,10 +5120,10 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4446
5120
|
let k = 1;
|
|
4447
5121
|
if (step > 1) {
|
|
4448
5122
|
k = step;
|
|
4449
|
-
let r = _optionalChain([options, 'access',
|
|
5123
|
+
let r = _optionalChain([options, 'access', _90 => _90.reduced, 'optionalAccess', _91 => _91.get, 'call', _92 => _92(k)]);
|
|
4450
5124
|
if (!r) {
|
|
4451
5125
|
r = _chunkPOGBUYWEcjs.reduceSurface.call(void 0, src, k);
|
|
4452
|
-
_optionalChain([options, 'access',
|
|
5126
|
+
_optionalChain([options, 'access', _93 => _93.reduced, 'optionalAccess', _94 => _94.set, 'call', _95 => _95(k, r)]);
|
|
4453
5127
|
}
|
|
4454
5128
|
source = r;
|
|
4455
5129
|
}
|
|
@@ -4457,16 +5131,16 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4457
5131
|
try {
|
|
4458
5132
|
if (hasWarp(g)) {
|
|
4459
5133
|
const f = transformMap(g);
|
|
4460
|
-
if (!f)
|
|
5134
|
+
if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4461
5135
|
out = _chunkPOGBUYWEcjs.warpSurface.call(void 0, source, (p) => f({ x: p.x * k, y: p.y * k }), { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
4462
5136
|
} else {
|
|
4463
5137
|
const h = transformHomography(g);
|
|
4464
|
-
if (!h)
|
|
5138
|
+
if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4465
5139
|
const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
|
|
4466
5140
|
out = _chunkPOGBUYWEcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
4467
5141
|
}
|
|
4468
5142
|
} catch (e) {
|
|
4469
|
-
if (e instanceof _chunkPOGBUYWEcjs.TransformTooLargeError)
|
|
5143
|
+
if (e instanceof _chunkPOGBUYWEcjs.TransformTooLargeError) fail4(e.message);
|
|
4470
5144
|
throw e;
|
|
4471
5145
|
}
|
|
4472
5146
|
}
|
|
@@ -4482,7 +5156,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4482
5156
|
return out;
|
|
4483
5157
|
}
|
|
4484
5158
|
function activeSmartFilters(stack) {
|
|
4485
|
-
if (!_optionalChain([stack, 'optionalAccess',
|
|
5159
|
+
if (!_optionalChain([stack, 'optionalAccess', _96 => _96.enabled])) return [];
|
|
4486
5160
|
return stack.filters.filter((f) => f.kind !== "psd" && isActiveFilter(f) && f.opacity > 0);
|
|
4487
5161
|
}
|
|
4488
5162
|
function filterMaskCoverage(mask, canvas) {
|
|
@@ -4557,21 +5231,21 @@ function rerender(layer, canvas, action = "change") {
|
|
|
4557
5231
|
return { ...layer, surface: renderSmartObject(layer, canvas) };
|
|
4558
5232
|
}
|
|
4559
5233
|
function normalizePlacement(raw, contents) {
|
|
4560
|
-
const c = _optionalChain([raw, 'optionalAccess',
|
|
5234
|
+
const c = _optionalChain([raw, 'optionalAccess', _97 => _97.corners]);
|
|
4561
5235
|
if (!Array.isArray(c) || c.length !== 4 || !c.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) {
|
|
4562
|
-
|
|
5236
|
+
fail4("corners must be four finite points [top-left, top-right, bottom-right, bottom-left] in document pixels.");
|
|
4563
5237
|
}
|
|
4564
5238
|
const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
|
|
4565
5239
|
if (raw.warp) {
|
|
4566
|
-
if (!_chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, raw.warp))
|
|
5240
|
+
if (!_chunkW3GXSUSQcjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
|
|
4567
5241
|
out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
4568
5242
|
}
|
|
4569
5243
|
if (raw.interpolation !== void 0) {
|
|
4570
|
-
if (!_chunkPOGBUYWEcjs.isInterpolation.call(void 0, raw.interpolation))
|
|
5244
|
+
if (!_chunkPOGBUYWEcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
4571
5245
|
if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
|
|
4572
5246
|
}
|
|
4573
5247
|
const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
|
|
4574
|
-
if (!transformHomography(g))
|
|
5248
|
+
if (!transformHomography(g)) fail4("These corners fold the contents over themselves or through the horizon; keep the quad convex.");
|
|
4575
5249
|
if (out.warp && !hasWarp(g)) delete out.warp;
|
|
4576
5250
|
return out;
|
|
4577
5251
|
}
|
|
@@ -4602,7 +5276,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
|
|
|
4602
5276
|
masksMoved ||= m !== layer.mask;
|
|
4603
5277
|
next.mask = m;
|
|
4604
5278
|
}
|
|
4605
|
-
if (_optionalChain([next, 'access',
|
|
5279
|
+
if (_optionalChain([next, 'access', _98 => _98.smartFilters, 'optionalAccess', _99 => _99.mask])) {
|
|
4606
5280
|
const m = followMask(next.smartFilters.mask, layer, next);
|
|
4607
5281
|
masksMoved ||= m !== next.smartFilters.mask;
|
|
4608
5282
|
next.smartFilters = { ...next.smartFilters, mask: m };
|
|
@@ -4620,12 +5294,12 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
|
4620
5294
|
let next = { ...layer, placement: { ...layer.placement, corners } };
|
|
4621
5295
|
const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
|
|
4622
5296
|
if (layer.mask) next.mask = moveMask(layer.mask);
|
|
4623
|
-
if (_optionalChain([layer, 'access',
|
|
5297
|
+
if (_optionalChain([layer, 'access', _100 => _100.smartFilters, 'optionalAccess', _101 => _101.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
|
|
4624
5298
|
const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur");
|
|
4625
5299
|
const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
4626
5300
|
const m = SMART_RENDER_MARGIN;
|
|
4627
5301
|
const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
|
|
4628
|
-
if (!spatial && !cut && !(_optionalChain([next, 'access',
|
|
5302
|
+
if (!spatial && !cut && !(_optionalChain([next, 'access', _102 => _102.smartFilters, 'optionalAccess', _103 => _103.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
|
|
4629
5303
|
next = { ...next, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, mx, my) };
|
|
4630
5304
|
} else {
|
|
4631
5305
|
next = rerender(next, canvas, "move");
|
|
@@ -4636,7 +5310,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
4636
5310
|
if (!dx && !dy) return layer;
|
|
4637
5311
|
const moveMask = (m) => {
|
|
4638
5312
|
if (!m) return m;
|
|
4639
|
-
if (m.source)
|
|
5313
|
+
if (m.source) fail4(`Layer "${layer.name || layer.id}" has a depth mask, which cannot move into a smart object; bake or remove it first.`);
|
|
4640
5314
|
return { ...m, surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, m.surface, dx, dy) };
|
|
4641
5315
|
};
|
|
4642
5316
|
switch (layer.type) {
|
|
@@ -4650,7 +5324,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
4650
5324
|
mask: moveMask(layer.mask)
|
|
4651
5325
|
};
|
|
4652
5326
|
if (!next.mask) delete next.mask;
|
|
4653
|
-
if (_optionalChain([layer, 'access',
|
|
5327
|
+
if (_optionalChain([layer, 'access', _104 => _104.smartFilters, 'optionalAccess', _105 => _105.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
|
|
4654
5328
|
return next;
|
|
4655
5329
|
}
|
|
4656
5330
|
case "group": {
|
|
@@ -4674,14 +5348,19 @@ function translateLayer(layer, dx, dy) {
|
|
|
4674
5348
|
delete next.annotation;
|
|
4675
5349
|
return next;
|
|
4676
5350
|
}
|
|
5351
|
+
case "type": {
|
|
5352
|
+
const next = { ...transformTypeLayer(layer, _chunkW3GXSUSQcjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkXIOMMGPDcjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
|
|
5353
|
+
if (!next.mask) delete next.mask;
|
|
5354
|
+
return next;
|
|
5355
|
+
}
|
|
4677
5356
|
case "annotation":
|
|
4678
|
-
return
|
|
5357
|
+
return fail4(`Annotation layer "${layer.name || layer.id}" cannot go into a smart object; rasterize it first.`);
|
|
4679
5358
|
}
|
|
4680
5359
|
}
|
|
4681
5360
|
function layerExtent(layer, surfaceOf, canvas) {
|
|
4682
5361
|
const full = { x: 0, y: 0, width: canvas.width, height: canvas.height };
|
|
4683
5362
|
let b = null;
|
|
4684
|
-
if (layer.type === "pixel" || layer.type === "smart" || layer.type === "shape") {
|
|
5363
|
+
if (layer.type === "pixel" || layer.type === "smart" || layer.type === "shape" || layer.type === "type") {
|
|
4685
5364
|
const s = layer.type === "pixel" ? surfaceOf(layer) : layer.surface;
|
|
4686
5365
|
if (s.defaultValue !== 0) b = full;
|
|
4687
5366
|
else {
|
|
@@ -4705,14 +5384,14 @@ function union(a, b) {
|
|
|
4705
5384
|
return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };
|
|
4706
5385
|
}
|
|
4707
5386
|
function asSmartFilters(filters) {
|
|
4708
|
-
if (!_optionalChain([filters, 'optionalAccess',
|
|
5387
|
+
if (!_optionalChain([filters, 'optionalAccess', _106 => _106.length])) return void 0;
|
|
4709
5388
|
return { enabled: true, filters: filters.map((f) => ({ ...f, blend: "normal", opacity: 1 })) };
|
|
4710
5389
|
}
|
|
4711
5390
|
function convertToSmartObject(layers, ids, canvas, options) {
|
|
4712
|
-
if (!ids.length)
|
|
5391
|
+
if (!ids.length) fail4("Give at least one layer id to convert.");
|
|
4713
5392
|
const locs = [...new Set(ids)].map((id) => requireLayer(layers, id));
|
|
4714
|
-
const parent = _nullishCoalesce(_optionalChain([locs, 'access',
|
|
4715
|
-
if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access',
|
|
5393
|
+
const parent = _nullishCoalesce(_optionalChain([locs, 'access', _107 => _107[0], 'access', _108 => _108.parent, 'optionalAccess', _109 => _109.id]), () => ( null));
|
|
5394
|
+
if (locs.some((l) => (_nullishCoalesce(_optionalChain([l, 'access', _110 => _110.parent, 'optionalAccess', _111 => _111.id]), () => ( null))) !== parent)) fail4("Layers to convert must share one parent; move them next to each other first.");
|
|
4716
5395
|
for (const l of locs) requireUnlocked(l.layer, "all", "convert it");
|
|
4717
5396
|
const ordered = locs.sort((a, b) => a.index - b.index);
|
|
4718
5397
|
const top = ordered[ordered.length - 1];
|
|
@@ -4720,9 +5399,9 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
4720
5399
|
const single = ordered.length === 1 ? ordered[0].layer : null;
|
|
4721
5400
|
if (single && single.type === "pixel") {
|
|
4722
5401
|
const surface = options.surfaceOf(single);
|
|
4723
|
-
if (surface.defaultValue !== 0)
|
|
5402
|
+
if (surface.defaultValue !== 0) fail4(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
|
|
4724
5403
|
const b = _chunkXIOMMGPDcjs.contentBounds.call(void 0, surface);
|
|
4725
|
-
if (!b)
|
|
5404
|
+
if (!b) fail4(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
|
|
4726
5405
|
const contents = {
|
|
4727
5406
|
id: newContentsId(),
|
|
4728
5407
|
name: `${single.name || "Layer"}.png`,
|
|
@@ -4754,7 +5433,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
4754
5433
|
} else {
|
|
4755
5434
|
let b = null;
|
|
4756
5435
|
for (const l of ordered) b = union(b, layerExtent(l.layer, options.surfaceOf, canvas));
|
|
4757
|
-
if (!b || !(b.width > 0 && b.height > 0))
|
|
5436
|
+
if (!b || !(b.width > 0 && b.height > 0)) fail4("The layers have no pixels to convert; paint something first.");
|
|
4758
5437
|
const nested = ordered.map((l) => {
|
|
4759
5438
|
let layer = l.layer;
|
|
4760
5439
|
if (layer.type === "pixel" && layer.source === "document") {
|
|
@@ -4762,7 +5441,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
4762
5441
|
delete resolved.source;
|
|
4763
5442
|
layer = resolved;
|
|
4764
5443
|
}
|
|
4765
|
-
if (_chunkPOGBUYWEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document"))
|
|
5444
|
+
if (_chunkPOGBUYWEcjs.flattenLayers.call(void 0, [layer]).some((x) => x.type === "pixel" && x.source === "document")) fail4(`Layer "${layer.name || layer.id}" holds the document image inside a group; convert the Background on its own.`);
|
|
4766
5445
|
return translateLayer(layer, -b.x, -b.y);
|
|
4767
5446
|
});
|
|
4768
5447
|
if (nested[0].clipped) {
|
|
@@ -4770,7 +5449,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
4770
5449
|
delete first.clipped;
|
|
4771
5450
|
nested[0] = first;
|
|
4772
5451
|
}
|
|
4773
|
-
const name = _optionalChain([options, 'access',
|
|
5452
|
+
const name = _optionalChain([options, 'access', _112 => _112.name, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]) || top.layer.name || "Smart Object";
|
|
4774
5453
|
const contents = documentContents({ layers: nested }, b.width, b.height, `${name}.psb`);
|
|
4775
5454
|
smart = {
|
|
4776
5455
|
type: "smart",
|
|
@@ -4785,7 +5464,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
4785
5464
|
offset: { x: 0, y: 0 }
|
|
4786
5465
|
};
|
|
4787
5466
|
}
|
|
4788
|
-
if (_optionalChain([options, 'access',
|
|
5467
|
+
if (_optionalChain([options, 'access', _115 => _115.name, 'optionalAccess', _116 => _116.trim, 'call', _117 => _117()])) smart.name = options.name.trim();
|
|
4789
5468
|
smart = { ...smart, surface: renderSmartObject(smart, canvas) };
|
|
4790
5469
|
const below = ordered.filter((l) => l.index < top.index).length;
|
|
4791
5470
|
let out = layers;
|
|
@@ -4815,19 +5494,19 @@ function rasterizeSmartObject(layers, id) {
|
|
|
4815
5494
|
function copySmartObject(layers, id, linked, name) {
|
|
4816
5495
|
const loc = requireLayer(layers, id);
|
|
4817
5496
|
const layer = requireSmartObject(layers, id);
|
|
4818
|
-
const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess',
|
|
5497
|
+
const copy = { ...layer, id: newLayerId("smart"), name: _optionalChain([name, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]) || `${layer.name || "Smart Object"} copy` };
|
|
4819
5498
|
delete copy.locks;
|
|
4820
5499
|
delete copy.psd;
|
|
4821
5500
|
if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
|
|
4822
5501
|
if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
|
|
4823
|
-
return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access',
|
|
5502
|
+
return { layers: _chunkPOGBUYWEcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _120 => _120.parent, 'optionalAccess', _121 => _121.id]), () => ( null)), loc.index + 1), layer: copy };
|
|
4824
5503
|
}
|
|
4825
5504
|
function instancesOf(layers, contentsId) {
|
|
4826
5505
|
return _chunkPOGBUYWEcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
|
|
4827
5506
|
}
|
|
4828
5507
|
function replaceContents(layers, contentsId, contents, canvas) {
|
|
4829
5508
|
const ids = instancesOf(layers, contentsId);
|
|
4830
|
-
if (!ids.length)
|
|
5509
|
+
if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
|
|
4831
5510
|
for (const id of ids) requireUnlocked(_chunkPOGBUYWEcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
|
|
4832
5511
|
const next = { ...contents, id: contentsId };
|
|
4833
5512
|
let out = layers;
|
|
@@ -4860,12 +5539,12 @@ function refitPlacement(layer, contents) {
|
|
|
4860
5539
|
return out;
|
|
4861
5540
|
}
|
|
4862
5541
|
function normalizeSmartFilter(raw, id = newLayerId("flt")) {
|
|
4863
|
-
if (raw.kind === "psd")
|
|
5542
|
+
if (raw.kind === "psd") fail4("Photoshop filters can only come from a PSD; add develop or blur.");
|
|
4864
5543
|
const base = normalizeFilter(raw, id);
|
|
4865
5544
|
const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
|
|
4866
|
-
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment")
|
|
5545
|
+
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
4867
5546
|
const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
|
|
4868
|
-
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1))
|
|
5547
|
+
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
4869
5548
|
return { ...base, blend, opacity };
|
|
4870
5549
|
}
|
|
4871
5550
|
function withStack(layer, stack, canvas) {
|
|
@@ -4878,9 +5557,9 @@ function stackOf(layer) {
|
|
|
4878
5557
|
return _nullishCoalesce(layer.smartFilters, () => ( { enabled: true, filters: [] }));
|
|
4879
5558
|
}
|
|
4880
5559
|
function requireFilter(layer, filterId) {
|
|
4881
|
-
const list2 = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
5560
|
+
const list2 = _nullishCoalesce(_optionalChain([layer, 'access', _122 => _122.smartFilters, 'optionalAccess', _123 => _123.filters]), () => ( []));
|
|
4882
5561
|
const i = list2.findIndex((f) => f.id === filterId);
|
|
4883
|
-
if (i === -1)
|
|
5562
|
+
if (i === -1) fail4(`Smart object "${layer.name || layer.id}" has no smart filter "${filterId}". Filters: ${list2.map((f) => `${f.id} (${f.kind})`).join(", ") || "none"}; call get_smart_object.`);
|
|
4884
5563
|
return i;
|
|
4885
5564
|
}
|
|
4886
5565
|
function editableSmart(layers, id) {
|
|
@@ -4901,15 +5580,15 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
4901
5580
|
const layer = editableSmart(layers, id);
|
|
4902
5581
|
const i = requireFilter(layer, filterId);
|
|
4903
5582
|
const current = layer.smartFilters.filters[i];
|
|
4904
|
-
if ("kind" in changes && changes.kind !== current.kind)
|
|
5583
|
+
if ("kind" in changes && changes.kind !== current.kind) fail4("A smart filter kind cannot change; remove it and add another.");
|
|
4905
5584
|
let merged;
|
|
4906
5585
|
if (current.kind === "psd") {
|
|
4907
5586
|
const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
|
|
4908
|
-
if (extra.length)
|
|
5587
|
+
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(", ")}.`);
|
|
4909
5588
|
const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
|
|
4910
|
-
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment")
|
|
5589
|
+
if (!_chunkXIOMMGPDcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
4911
5590
|
const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
|
|
4912
|
-
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1))
|
|
5591
|
+
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
4913
5592
|
merged = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
|
|
4914
5593
|
} else {
|
|
4915
5594
|
merged = normalizeSmartFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
@@ -4931,7 +5610,7 @@ function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
|
4931
5610
|
const layer = editableSmart(layers, id);
|
|
4932
5611
|
const i = requireFilter(layer, filterId);
|
|
4933
5612
|
const list2 = layer.smartFilters.filters;
|
|
4934
|
-
if (!Number.isInteger(index) || index < 0 || index >= list2.length)
|
|
5613
|
+
if (!Number.isInteger(index) || index < 0 || index >= list2.length) fail4(`index must be a whole number from 0 to ${list2.length - 1}.`);
|
|
4935
5614
|
const filters = [...list2];
|
|
4936
5615
|
const [f] = filters.splice(i, 1);
|
|
4937
5616
|
filters.splice(index, 0, f);
|
|
@@ -4945,7 +5624,7 @@ function setSmartFiltersEnabled(layers, id, enabled, canvas) {
|
|
|
4945
5624
|
}
|
|
4946
5625
|
function setSmartFilterMask(layers, id, mask, canvas) {
|
|
4947
5626
|
const layer = editableSmart(layers, id);
|
|
4948
|
-
if (_optionalChain([mask, 'optionalAccess',
|
|
5627
|
+
if (_optionalChain([mask, 'optionalAccess', _124 => _124.source])) fail4("A smart filter mask is painted, not generated; use a raster mask.");
|
|
4949
5628
|
const stack = { ...stackOf(layer) };
|
|
4950
5629
|
if (mask) stack.mask = mask;
|
|
4951
5630
|
else delete stack.mask;
|
|
@@ -4954,7 +5633,7 @@ function setSmartFilterMask(layers, id, mask, canvas) {
|
|
|
4954
5633
|
}
|
|
4955
5634
|
function withFilterMaskSurface(layer, surface, canvas) {
|
|
4956
5635
|
const stack = stackOf(layer);
|
|
4957
|
-
if (!stack.mask)
|
|
5636
|
+
if (!stack.mask) fail4(`Smart object "${layer.name || layer.id}" has no filter mask; add one with set_smart_filter_mask.`);
|
|
4958
5637
|
return withStack(layer, { ...stack, mask: { ...stack.mask, surface } }, canvas);
|
|
4959
5638
|
}
|
|
4960
5639
|
function placementBounds(layer) {
|
|
@@ -5059,7 +5738,7 @@ function serializeLayer(layer, ctx) {
|
|
|
5059
5738
|
}
|
|
5060
5739
|
}
|
|
5061
5740
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5062
|
-
if (_optionalChain([layer, 'access',
|
|
5741
|
+
if (_optionalChain([layer, 'access', _125 => _125.filters, 'optionalAccess', _126 => _126.length])) out.filters = JSON.parse(JSON.stringify(layer.filters));
|
|
5063
5742
|
return out;
|
|
5064
5743
|
}
|
|
5065
5744
|
case "adjustment":
|
|
@@ -5075,6 +5754,84 @@ function serializeLayer(layer, ctx) {
|
|
|
5075
5754
|
return serializeSmartObject(layer, base, ctx);
|
|
5076
5755
|
case "shape":
|
|
5077
5756
|
return serializeShape(layer, base);
|
|
5757
|
+
case "type":
|
|
5758
|
+
return serializeType(layer, base, ctx);
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
function serializeType(layer, base, ctx) {
|
|
5762
|
+
const out = {
|
|
5763
|
+
...base,
|
|
5764
|
+
type: "type",
|
|
5765
|
+
text: layer.text,
|
|
5766
|
+
runs: JSON.parse(JSON.stringify(layer.runs)),
|
|
5767
|
+
paragraphs: JSON.parse(JSON.stringify(layer.paragraphs)),
|
|
5768
|
+
frame: { ...layer.frame }
|
|
5769
|
+
};
|
|
5770
|
+
if (layer.transform) out.transform = [...layer.transform];
|
|
5771
|
+
if (layer.antiAlias === false) out.antiAlias = false;
|
|
5772
|
+
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5773
|
+
const enc = encodeSurface(layer.surface);
|
|
5774
|
+
if (enc) {
|
|
5775
|
+
out.asset = ctx.addAsset(enc.url, layer.id);
|
|
5776
|
+
out.x = enc.x;
|
|
5777
|
+
out.y = enc.y;
|
|
5778
|
+
}
|
|
5779
|
+
if (_optionalChain([layer, 'access', _127 => _127.missingFonts, 'optionalAccess', _128 => _128.length])) out.missingFonts = [...layer.missingFonts];
|
|
5780
|
+
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5781
|
+
if (_optionalChain([layer, 'access', _129 => _129.psd, 'optionalAccess', _130 => _130.tySh]) || _optionalChain([layer, 'access', _131 => _131.psd, 'optionalAccess', _132 => _132.blocks, 'optionalAccess', _133 => _133.length])) {
|
|
5782
|
+
out.psd = {};
|
|
5783
|
+
if (layer.psd.tySh) out.psd.tySh = _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, layer.psd.tySh);
|
|
5784
|
+
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) }));
|
|
5785
|
+
}
|
|
5786
|
+
return out;
|
|
5787
|
+
}
|
|
5788
|
+
function readType(r, base, ctx) {
|
|
5789
|
+
const label = `Layer "${base.name || base.id}"`;
|
|
5790
|
+
try {
|
|
5791
|
+
const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
|
|
5792
|
+
const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
|
|
5793
|
+
length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _137 => _137.length]), 0, 1e9, 0))),
|
|
5794
|
+
style: patchTextStyle(DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _138 => _138.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
|
|
5795
|
+
}));
|
|
5796
|
+
const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
|
|
5797
|
+
length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _139 => _139.length]), 0, 1e9, 0))),
|
|
5798
|
+
style: patchParagraphStyle({}, _optionalChain([p, 'optionalAccess', _140 => _140.style]) && typeof p.style === "object" ? p.style : {}, `paragraphs[${i}].style`)
|
|
5799
|
+
}));
|
|
5800
|
+
const f = r.frame;
|
|
5801
|
+
const frame = _optionalChain([f, 'optionalAccess', _141 => _141.kind]) === "box" ? { kind: "box", width: num2(f.width, 1, 1e6, 100), height: num2(f.height, 1, 1e6, 100) } : _optionalChain([f, 'optionalAccess', _142 => _142.origin]) === "top" ? { kind: "point", origin: "top" } : { kind: "point" };
|
|
5802
|
+
const m = Array.isArray(r.transform) && r.transform.length === 6 && r.transform.every((v) => typeof v === "number" && Number.isFinite(v)) ? r.transform : void 0;
|
|
5803
|
+
const layer = {
|
|
5804
|
+
...base,
|
|
5805
|
+
type: "type",
|
|
5806
|
+
text: text3,
|
|
5807
|
+
runs: fitRuns(runs, text3.length, DEFAULT_TEXT_STYLE),
|
|
5808
|
+
paragraphs: fitParagraphRuns(paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
|
|
5809
|
+
frame,
|
|
5810
|
+
surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4),
|
|
5811
|
+
offset: { x: 0, y: 0 }
|
|
5812
|
+
};
|
|
5813
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _143 => _143[0], 'optionalAccess', _144 => _144.style]), () => ( DEFAULT_TEXT_STYLE)) }];
|
|
5814
|
+
if (m) layer.transform = m;
|
|
5815
|
+
if (r.antiAlias === false) layer.antiAlias = false;
|
|
5816
|
+
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5817
|
+
if (Array.isArray(r.missingFonts)) layer.missingFonts = r.missingFonts.filter((x) => typeof x === "string");
|
|
5818
|
+
if (r.annotation && typeof r.annotation === "object" && r.annotation.type === "text") layer.annotation = JSON.parse(JSON.stringify({ ...r.annotation, id: _nullishCoalesce(r.annotation.id, () => ( base.id)) }));
|
|
5819
|
+
if (r.psd && typeof r.psd === "object") {
|
|
5820
|
+
const psd = {};
|
|
5821
|
+
if (typeof r.psd.tySh === "string") psd.tySh = _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.tySh);
|
|
5822
|
+
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) }));
|
|
5823
|
+
if (psd.tySh || _optionalChain([psd, 'access', _145 => _145.blocks, 'optionalAccess', _146 => _146.length])) layer.psd = psd;
|
|
5824
|
+
}
|
|
5825
|
+
if (typeof r.asset === "string") return { ...layer, surface: readSurface(r.asset, r.x, r.y, 4, 0, ctx, label), rendering: "stored" };
|
|
5826
|
+
const env = { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _147 => _147.text, 'optionalAccess', _148 => _148.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _149 => _149.text, 'optionalAccess', _150 => _150.createCanvas]) };
|
|
5827
|
+
try {
|
|
5828
|
+
return rerenderText(layer, env);
|
|
5829
|
+
} catch (e7) {
|
|
5830
|
+
return { ...layer, rendering: "stored" };
|
|
5831
|
+
}
|
|
5832
|
+
} catch (e) {
|
|
5833
|
+
ctx.problems.push(`${label}: the text could not be read (${e instanceof Error ? e.message : String(e)})`);
|
|
5834
|
+
return null;
|
|
5078
5835
|
}
|
|
5079
5836
|
}
|
|
5080
5837
|
function serializeShape(layer, base) {
|
|
@@ -5088,7 +5845,7 @@ function serializeShape(layer, base) {
|
|
|
5088
5845
|
if (layer.fillRule === "evenodd") out.fillRule = "evenodd";
|
|
5089
5846
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5090
5847
|
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5091
|
-
if (_optionalChain([layer, 'access',
|
|
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) })) };
|
|
5092
5849
|
return out;
|
|
5093
5850
|
}
|
|
5094
5851
|
function readShape(r, base, ctx) {
|
|
@@ -5102,12 +5859,12 @@ function readShape(r, base, ctx) {
|
|
|
5102
5859
|
if (!data) {
|
|
5103
5860
|
if (!Array.isArray(r.components) || !r.components.length) throw new Error("it has no components");
|
|
5104
5861
|
const components = r.components.map((c, i) => {
|
|
5105
|
-
const op = requireOperation(_optionalChain([c, 'optionalAccess',
|
|
5106
|
-
if (_optionalChain([c, 'optionalAccess',
|
|
5862
|
+
const op = requireOperation(_optionalChain([c, 'optionalAccess', _154 => _154.op]), `components[${i}].op`);
|
|
5863
|
+
if (_optionalChain([c, 'optionalAccess', _155 => _155.live])) {
|
|
5107
5864
|
const live = normalizeLiveShape(c.live, `components[${i}].live`);
|
|
5108
5865
|
return { op, subpaths: liveShapeSubpaths(live), live };
|
|
5109
5866
|
}
|
|
5110
|
-
return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess',
|
|
5867
|
+
return { op, subpaths: Array.isArray(_optionalChain([c, 'optionalAccess', _156 => _156.subpaths])) && !c.subpaths.length ? [] : normalizeSubpaths(_optionalChain([c, 'optionalAccess', _157 => _157.subpaths]), `components[${i}].subpaths`) };
|
|
5111
5868
|
});
|
|
5112
5869
|
data = {
|
|
5113
5870
|
components,
|
|
@@ -5117,7 +5874,7 @@ function readShape(r, base, ctx) {
|
|
|
5117
5874
|
}
|
|
5118
5875
|
const layer = createShapeLayer({ ...data, fillRule: r.fillRule === "evenodd" ? "evenodd" : "nonzero" }, env, base.id);
|
|
5119
5876
|
const out = { ...layer, ...base, type: "shape", components: layer.components, fill: layer.fill, stroke: layer.stroke, surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
5120
|
-
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity =
|
|
5877
|
+
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5121
5878
|
if (a && shapeFromAnnotation(a)) out.annotation = a;
|
|
5122
5879
|
if (r.psd && Array.isArray(r.psd.blocks)) {
|
|
5123
5880
|
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) }));
|
|
@@ -5177,7 +5934,7 @@ function serializeContents(c, ctx) {
|
|
|
5177
5934
|
if (c.kind === "document" && c.document) {
|
|
5178
5935
|
out.layers = c.document.layers.map((l) => serializeLayer(l, ctx));
|
|
5179
5936
|
if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
|
|
5180
|
-
if (_optionalChain([c, 'access',
|
|
5937
|
+
if (_optionalChain([c, 'access', _158 => _158.document, 'access', _159 => _159.patterns, 'optionalAccess', _160 => _160.length])) out.patterns = serializePatterns(c.document.patterns);
|
|
5181
5938
|
}
|
|
5182
5939
|
if (c.file) out.file = { type: c.file.type, data: _chunkPOGBUYWEcjs.bytesToBase64.call(void 0, c.file.bytes) };
|
|
5183
5940
|
if (c.linked) out.linked = { path: c.linked.path };
|
|
@@ -5269,7 +6026,7 @@ function decodePngDataUrl(url, channels) {
|
|
|
5269
6026
|
}
|
|
5270
6027
|
return { width: png.width, height: png.height, data: out };
|
|
5271
6028
|
}
|
|
5272
|
-
var
|
|
6029
|
+
var num2 = (v, lo, hi, fallback) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : fallback;
|
|
5273
6030
|
function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
|
|
5274
6031
|
if (typeof ref !== "string" || !ref) return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
5275
6032
|
const url = ctx.assets[ref];
|
|
@@ -5279,7 +6036,7 @@ function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
|
|
|
5279
6036
|
}
|
|
5280
6037
|
try {
|
|
5281
6038
|
const px = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
|
|
5282
|
-
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(
|
|
6039
|
+
return _chunkXIOMMGPDcjs.surfaceFromPixels.call(void 0, px, channels, Math.round(num2(x, -1e7, 1e7, 0)), Math.round(num2(y, -1e7, 1e7, 0)), defaultValue);
|
|
5283
6040
|
} catch (err) {
|
|
5284
6041
|
ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
|
|
5285
6042
|
return _chunkXIOMMGPDcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
@@ -5293,8 +6050,8 @@ function readMask(raw, ctx, what) {
|
|
|
5293
6050
|
surface: r.source ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
|
|
5294
6051
|
defaultValue: r.source ? 255 : defaultValue
|
|
5295
6052
|
};
|
|
5296
|
-
if (typeof r.density === "number" && r.density !== 1) mask.density =
|
|
5297
|
-
if (typeof r.feather === "number" && r.feather > 0) mask.feather =
|
|
6053
|
+
if (typeof r.density === "number" && r.density !== 1) mask.density = num2(r.density, 0, 1, 1);
|
|
6054
|
+
if (typeof r.feather === "number" && r.feather > 0) mask.feather = num2(r.feather, 0, 1e3, 0);
|
|
5298
6055
|
if (r.enabled === false) mask.enabled = false;
|
|
5299
6056
|
if (r.linked === false) mask.linked = false;
|
|
5300
6057
|
if (r.source && typeof r.source === "object") {
|
|
@@ -5311,18 +6068,18 @@ function readFilters(raw) {
|
|
|
5311
6068
|
const r = f;
|
|
5312
6069
|
const id = typeof r.id === "string" && r.id ? r.id : newLayerId("flt");
|
|
5313
6070
|
const enabled = r.enabled !== false;
|
|
5314
|
-
if (r.kind === "blur") out.push({ id, kind: "blur", enabled, radius:
|
|
6071
|
+
if (r.kind === "blur") out.push({ id, kind: "blur", enabled, radius: num2(r.radius, 0, 50, 0) });
|
|
5315
6072
|
else if (r.kind === "develop") {
|
|
5316
6073
|
out.push({
|
|
5317
6074
|
id,
|
|
5318
6075
|
kind: "develop",
|
|
5319
6076
|
enabled,
|
|
5320
|
-
brightness:
|
|
5321
|
-
contrast:
|
|
5322
|
-
saturation:
|
|
5323
|
-
exposure:
|
|
5324
|
-
temperature:
|
|
5325
|
-
tint:
|
|
6077
|
+
brightness: num2(r.brightness, -100, 100, 0),
|
|
6078
|
+
contrast: num2(r.contrast, -100, 100, 0),
|
|
6079
|
+
saturation: num2(r.saturation, -100, 100, 0),
|
|
6080
|
+
exposure: num2(r.exposure, -100, 100, 0),
|
|
6081
|
+
temperature: num2(r.temperature, -100, 100, 0),
|
|
6082
|
+
tint: num2(r.tint, -100, 100, 0),
|
|
5326
6083
|
process: normalizeProcessVersion(r.process)
|
|
5327
6084
|
});
|
|
5328
6085
|
}
|
|
@@ -5337,7 +6094,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
5337
6094
|
id,
|
|
5338
6095
|
name: typeof r.name === "string" ? r.name : "",
|
|
5339
6096
|
visible: r.visible !== false,
|
|
5340
|
-
opacity:
|
|
6097
|
+
opacity: num2(r.opacity, 0, 1, 1),
|
|
5341
6098
|
blend: _chunkXIOMMGPDcjs.normalizeBlendMode.call(void 0, r.blend)
|
|
5342
6099
|
};
|
|
5343
6100
|
if (r.clipped === true) base.clipped = true;
|
|
@@ -5356,10 +6113,10 @@ function deserializeLayer(raw, ctx) {
|
|
|
5356
6113
|
...base,
|
|
5357
6114
|
type: "pixel",
|
|
5358
6115
|
surface: r.source === "document" ? _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
|
|
5359
|
-
offset: { x: Math.round(
|
|
6116
|
+
offset: { x: Math.round(num2(_optionalChain([r, 'access', _161 => _161.offset, 'optionalAccess', _162 => _162.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _163 => _163.offset, 'optionalAccess', _164 => _164.y]), -1e7, 1e7, 0)) }
|
|
5360
6117
|
};
|
|
5361
6118
|
if (r.source === "document") layer.source = "document";
|
|
5362
|
-
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity =
|
|
6119
|
+
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5363
6120
|
const filters = readFilters(r.filters);
|
|
5364
6121
|
if (filters) layer.filters = filters;
|
|
5365
6122
|
return layer;
|
|
@@ -5386,15 +6143,17 @@ function deserializeLayer(raw, ctx) {
|
|
|
5386
6143
|
return null;
|
|
5387
6144
|
}
|
|
5388
6145
|
const annotation = JSON.parse(JSON.stringify({ ...a, id: typeof a.id === "string" ? a.id : id }));
|
|
5389
|
-
const migrated = annotationLayerFor(annotation, _nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })));
|
|
5390
|
-
if (migrated.type === "shape") {
|
|
6146
|
+
const migrated = annotationLayerFor(annotation, { ..._nullishCoalesce(ctx.canvas, () => ( { width: 1, height: 1 })), shaper: _nullishCoalesce(_optionalChain([ctx, 'access', _165 => _165.text, 'optionalAccess', _166 => _166.shaper]), () => ( null)), createCanvas: _optionalChain([ctx, 'access', _167 => _167.text, 'optionalAccess', _168 => _168.createCanvas]) });
|
|
6147
|
+
if (migrated.type === "shape" || migrated.type === "type") {
|
|
5391
6148
|
const blend = base.blend === "normal" ? migrated.blend : base.blend;
|
|
5392
|
-
return { ...migrated, ...base, blend,
|
|
6149
|
+
return { ...migrated, ...base, blend, id, name: base.name };
|
|
5393
6150
|
}
|
|
5394
6151
|
return { ...base, type: "annotation", annotation };
|
|
5395
6152
|
}
|
|
5396
6153
|
case "shape":
|
|
5397
6154
|
return readShape(r, base, ctx);
|
|
6155
|
+
case "type":
|
|
6156
|
+
return readType(r, base, ctx);
|
|
5398
6157
|
case "smart":
|
|
5399
6158
|
return readSmartObject(r, base, ctx);
|
|
5400
6159
|
default:
|
|
@@ -5414,8 +6173,8 @@ function readContents(id, ctx) {
|
|
|
5414
6173
|
ctx.problems.push(`Smart object contents "${id}" are missing`);
|
|
5415
6174
|
return null;
|
|
5416
6175
|
}
|
|
5417
|
-
const width = Math.round(
|
|
5418
|
-
const height = Math.round(
|
|
6176
|
+
const width = Math.round(num2(raw.width, 0, 3e5, 0));
|
|
6177
|
+
const height = Math.round(num2(raw.height, 0, 3e5, 0));
|
|
5419
6178
|
if (!(width > 0 && height > 0)) {
|
|
5420
6179
|
ctx.problems.push(`Smart object contents "${id}" have no size`);
|
|
5421
6180
|
return null;
|
|
@@ -5425,7 +6184,7 @@ function readContents(id, ctx) {
|
|
|
5425
6184
|
if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
|
|
5426
6185
|
try {
|
|
5427
6186
|
c.file = { type: raw.file.type, bytes: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, raw.file.data) };
|
|
5428
|
-
} catch (
|
|
6187
|
+
} catch (e8) {
|
|
5429
6188
|
ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
|
|
5430
6189
|
}
|
|
5431
6190
|
}
|
|
@@ -5439,7 +6198,7 @@ function readContents(id, ctx) {
|
|
|
5439
6198
|
const layers = deserializeLayers(raw.layers, ctx);
|
|
5440
6199
|
ctx.canvas = outer;
|
|
5441
6200
|
c.document = { layers };
|
|
5442
|
-
if (raw.globalLight && typeof raw.globalLight === "object") c.document.globalLight = { angle:
|
|
6201
|
+
if (raw.globalLight && typeof raw.globalLight === "object") c.document.globalLight = { angle: num2(raw.globalLight.angle, -360, 360, 120), altitude: num2(raw.globalLight.altitude, 0, 90, 30) };
|
|
5443
6202
|
const patterns = deserializePatterns(raw.patterns, ctx.problems);
|
|
5444
6203
|
if (patterns.length) c.document.patterns = patterns;
|
|
5445
6204
|
}
|
|
@@ -5456,11 +6215,11 @@ function readSmartFilters(raw, ctx, what) {
|
|
|
5456
6215
|
for (const f of list2) {
|
|
5457
6216
|
if (!f || typeof f !== "object") continue;
|
|
5458
6217
|
const blend = _chunkXIOMMGPDcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
|
|
5459
|
-
const opacity =
|
|
6218
|
+
const opacity = num2(f.opacity, 0, 1, 1);
|
|
5460
6219
|
if (f.kind === "psd") {
|
|
5461
6220
|
try {
|
|
5462
6221
|
filters.push({ id: typeof f.id === "string" ? f.id : newLayerId("flt"), kind: "psd", enabled: f.enabled !== false, name: typeof f.name === "string" ? f.name : "Filter", data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
|
|
5463
|
-
} catch (
|
|
6222
|
+
} catch (e9) {
|
|
5464
6223
|
ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
|
|
5465
6224
|
}
|
|
5466
6225
|
} else if (f.kind === "develop" || f.kind === "blur") {
|
|
@@ -5494,12 +6253,12 @@ function readSmartObject(r, base, ctx) {
|
|
|
5494
6253
|
const layer = { ...base, type: "smart", contents, placement, surface: _chunkXIOMMGPDcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
|
|
5495
6254
|
const filters = readSmartFilters(r.smartFilters, ctx, what);
|
|
5496
6255
|
if (filters) layer.smartFilters = filters;
|
|
5497
|
-
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity =
|
|
6256
|
+
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5498
6257
|
if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
|
|
5499
6258
|
try {
|
|
5500
6259
|
layer.psd = { key: r.psd.key, data: _chunkPOGBUYWEcjs.base64ToBytes.call(void 0, r.psd.data) };
|
|
5501
6260
|
if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
|
|
5502
|
-
} catch (
|
|
6261
|
+
} catch (e10) {
|
|
5503
6262
|
}
|
|
5504
6263
|
}
|
|
5505
6264
|
if (typeof r.asset === "string") layer.surface = readSurface(r.asset, r.x, r.y, 4, 0, ctx, what);
|
|
@@ -5742,7 +6501,7 @@ var PsdWriter = (_class = class {constructor() { _class.prototype.__init.call(th
|
|
|
5742
6501
|
function decodeLegacyName(b) {
|
|
5743
6502
|
try {
|
|
5744
6503
|
return new TextDecoder("utf-8", { fatal: true }).decode(b);
|
|
5745
|
-
} catch (
|
|
6504
|
+
} catch (e11) {
|
|
5746
6505
|
return String.fromCharCode(...b);
|
|
5747
6506
|
}
|
|
5748
6507
|
}
|
|
@@ -5919,7 +6678,7 @@ function descriptor(classId, items = []) {
|
|
|
5919
6678
|
return { name: "", classId, items };
|
|
5920
6679
|
}
|
|
5921
6680
|
function descGet(d, key) {
|
|
5922
|
-
return _optionalChain([d, 'access',
|
|
6681
|
+
return _optionalChain([d, 'access', _169 => _169.items, 'access', _170 => _170.find, 'call', _171 => _171(([k]) => k === key), 'optionalAccess', _172 => _172[1]]);
|
|
5923
6682
|
}
|
|
5924
6683
|
function descNumber(d, key) {
|
|
5925
6684
|
const v = descGet(d, key);
|
|
@@ -5929,7 +6688,7 @@ function descNumber(d, key) {
|
|
|
5929
6688
|
}
|
|
5930
6689
|
function descBool(d, key) {
|
|
5931
6690
|
const v = descGet(d, key);
|
|
5932
|
-
return _optionalChain([v, 'optionalAccess',
|
|
6691
|
+
return _optionalChain([v, 'optionalAccess', _173 => _173.type]) === "bool" ? v.value : void 0;
|
|
5933
6692
|
}
|
|
5934
6693
|
function descObject(d, key) {
|
|
5935
6694
|
const v = descGet(d, key);
|
|
@@ -6400,7 +7159,7 @@ function parseAdjustmentBlock(key, data) {
|
|
|
6400
7159
|
default:
|
|
6401
7160
|
return null;
|
|
6402
7161
|
}
|
|
6403
|
-
} catch (
|
|
7162
|
+
} catch (e12) {
|
|
6404
7163
|
return null;
|
|
6405
7164
|
}
|
|
6406
7165
|
}
|
|
@@ -6521,15 +7280,15 @@ var textV = (value) => ({ type: "TEXT", value });
|
|
|
6521
7280
|
var obj = (d) => ({ type: "Objc", value: d });
|
|
6522
7281
|
var text = (d, key) => {
|
|
6523
7282
|
const v = descGet(d, key);
|
|
6524
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7283
|
+
return _optionalChain([v, 'optionalAccess', _174 => _174.type]) === "TEXT" ? v.value : void 0;
|
|
6525
7284
|
};
|
|
6526
7285
|
var enumOf = (d, key) => {
|
|
6527
7286
|
const v = descGet(d, key);
|
|
6528
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7287
|
+
return _optionalChain([v, 'optionalAccess', _175 => _175.type]) === "enum" ? v.value : void 0;
|
|
6529
7288
|
};
|
|
6530
7289
|
var numbers = (d, key) => {
|
|
6531
7290
|
const v = descGet(d, key);
|
|
6532
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
7291
|
+
if (_optionalChain([v, 'optionalAccess', _176 => _176.type]) !== "VlLs") return null;
|
|
6533
7292
|
const out = [];
|
|
6534
7293
|
for (const it of v.items) {
|
|
6535
7294
|
if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
|
|
@@ -6573,7 +7332,7 @@ function readLinkedItem(item) {
|
|
|
6573
7332
|
try {
|
|
6574
7333
|
const d = readVersionedDescriptor(r);
|
|
6575
7334
|
path = _nullishCoalesce(_nullishCoalesce(text(d, "fullPath"), () => ( text(d, "originalPath"))), () => ( text(d, "relPath")));
|
|
6576
|
-
} catch (
|
|
7335
|
+
} catch (e13) {
|
|
6577
7336
|
path = void 0;
|
|
6578
7337
|
}
|
|
6579
7338
|
void version;
|
|
@@ -6590,7 +7349,7 @@ function parseLinkedFiles(data) {
|
|
|
6590
7349
|
try {
|
|
6591
7350
|
const item = readLinkedItem(data.subarray(at + 8, at + 8 + len));
|
|
6592
7351
|
if (item) out.push(item);
|
|
6593
|
-
} catch (
|
|
7352
|
+
} catch (e14) {
|
|
6594
7353
|
}
|
|
6595
7354
|
at = at + 8 + len + 3 & ~3;
|
|
6596
7355
|
}
|
|
@@ -6724,8 +7483,8 @@ function filterMaskItem(placed, mask, area) {
|
|
|
6724
7483
|
const painted = _chunkXIOMMGPDcjs.contentBounds.call(void 0, mask.surface);
|
|
6725
7484
|
let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
6726
7485
|
if (mask.defaultValue !== 255 && area) {
|
|
6727
|
-
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
6728
|
-
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
7486
|
+
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _177 => _177.x]), () => ( area.x)));
|
|
7487
|
+
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _178 => _178.y]), () => ( area.y)));
|
|
6729
7488
|
const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
|
|
6730
7489
|
const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
|
|
6731
7490
|
b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
@@ -6745,7 +7504,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
6745
7504
|
}
|
|
6746
7505
|
var warpStyleOf = (name) => {
|
|
6747
7506
|
if (!name.startsWith("warp")) return null;
|
|
6748
|
-
const s = _optionalChain([name, 'access',
|
|
7507
|
+
const s = _optionalChain([name, 'access', _179 => _179[4], 'optionalAccess', _180 => _180.toLowerCase, 'call', _181 => _181()]) + name.slice(5);
|
|
6749
7508
|
return _chunkW3GXSUSQcjs.WARP_STYLES.includes(s) ? s : null;
|
|
6750
7509
|
};
|
|
6751
7510
|
function warpFromDescriptor(w, contents) {
|
|
@@ -6767,7 +7526,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
6767
7526
|
if (!arr || arr.type !== "ObAr") return void 0;
|
|
6768
7527
|
const xs = descGet(arr.body, "Hrzn");
|
|
6769
7528
|
const ys = descGet(arr.body, "Vrtc");
|
|
6770
|
-
if (_optionalChain([xs, 'optionalAccess',
|
|
7529
|
+
if (_optionalChain([xs, 'optionalAccess', _182 => _182.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _183 => _183.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
|
|
6771
7530
|
mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
|
|
6772
7531
|
const px = mesh.points.map((p) => p.x);
|
|
6773
7532
|
const py = mesh.points.map((p) => p.y);
|
|
@@ -6888,13 +7647,13 @@ function parsePlaced(key, data) {
|
|
|
6888
7647
|
r.u32();
|
|
6889
7648
|
try {
|
|
6890
7649
|
warp = readVersionedDescriptor(r);
|
|
6891
|
-
} catch (
|
|
7650
|
+
} catch (e15) {
|
|
6892
7651
|
warp = void 0;
|
|
6893
7652
|
}
|
|
6894
7653
|
}
|
|
6895
7654
|
return { key, idnt, placed: idnt, quad, warp };
|
|
6896
7655
|
}
|
|
6897
|
-
} catch (
|
|
7656
|
+
} catch (e16) {
|
|
6898
7657
|
return null;
|
|
6899
7658
|
}
|
|
6900
7659
|
return null;
|
|
@@ -6934,13 +7693,13 @@ function blendOptions(f) {
|
|
|
6934
7693
|
function smartFiltersFromPsd(fx, newId, notes) {
|
|
6935
7694
|
const filters = [];
|
|
6936
7695
|
const list2 = descGet(fx, "filterFXList");
|
|
6937
|
-
for (const v of _optionalChain([list2, 'optionalAccess',
|
|
7696
|
+
for (const v of _optionalChain([list2, 'optionalAccess', _184 => _184.type]) === "VlLs" ? list2.items : []) {
|
|
6938
7697
|
if (v.type !== "Objc" && v.type !== "GlbO") continue;
|
|
6939
7698
|
const item = v.value;
|
|
6940
7699
|
const { blend, opacity } = blendOptionsOf(item);
|
|
6941
7700
|
const enabled = descBool(item, "enab") !== false;
|
|
6942
7701
|
const fltr = descObject(item, "Fltr");
|
|
6943
|
-
const radius = _optionalChain([fltr, 'optionalAccess',
|
|
7702
|
+
const radius = _optionalChain([fltr, 'optionalAccess', _185 => _185.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
|
|
6944
7703
|
if (radius !== void 0 && radius >= 0 && radius <= 50) {
|
|
6945
7704
|
filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
|
|
6946
7705
|
continue;
|
|
@@ -7219,7 +7978,7 @@ function parseMask(d) {
|
|
|
7219
7978
|
}
|
|
7220
7979
|
if (!realFirst) m.real = readReal();
|
|
7221
7980
|
return m;
|
|
7222
|
-
} catch (
|
|
7981
|
+
} catch (e17) {
|
|
7223
7982
|
return void 0;
|
|
7224
7983
|
}
|
|
7225
7984
|
}
|
|
@@ -7293,14 +8052,14 @@ function readPsd(bytes) {
|
|
|
7293
8052
|
return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
|
|
7294
8053
|
}
|
|
7295
8054
|
function layerBlock(rec, key) {
|
|
7296
|
-
return _optionalChain([rec, 'access',
|
|
8055
|
+
return _optionalChain([rec, 'access', _186 => _186.blocks, 'access', _187 => _187.find, 'call', _188 => _188((b) => b.key === key), 'optionalAccess', _189 => _189.data]);
|
|
7297
8056
|
}
|
|
7298
8057
|
function layerName(rec) {
|
|
7299
8058
|
const luni = layerBlock(rec, "luni");
|
|
7300
8059
|
if (luni) {
|
|
7301
8060
|
try {
|
|
7302
8061
|
return new PsdReader(luni).unicode();
|
|
7303
|
-
} catch (
|
|
8062
|
+
} catch (e18) {
|
|
7304
8063
|
}
|
|
7305
8064
|
}
|
|
7306
8065
|
return rec.legacyName;
|
|
@@ -7324,7 +8083,7 @@ function u8Block(rec, key) {
|
|
|
7324
8083
|
function layerTree(file) {
|
|
7325
8084
|
const stack = [[]];
|
|
7326
8085
|
file.layers.forEach((rec, index) => {
|
|
7327
|
-
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call',
|
|
8086
|
+
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _190 => _190(rec), 'optionalAccess', _191 => _191.kind]), () => ( SECTION_OTHER));
|
|
7328
8087
|
if (kind === SECTION_DIVIDER) {
|
|
7329
8088
|
stack.push([]);
|
|
7330
8089
|
} else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
|
|
@@ -7342,7 +8101,7 @@ function layerTree(file) {
|
|
|
7342
8101
|
}
|
|
7343
8102
|
function channelRect(rec, id) {
|
|
7344
8103
|
if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
|
|
7345
|
-
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access',
|
|
8104
|
+
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _192 => _192.mask, 'access', _193 => _193.real, 'optionalAccess', _194 => _194.rect]), () => ( rec.mask.rect));
|
|
7346
8105
|
return rec.rect;
|
|
7347
8106
|
}
|
|
7348
8107
|
function decodeLayerChannel(file, rec, id) {
|
|
@@ -7360,7 +8119,7 @@ function decodeMergedImage(file) {
|
|
|
7360
8119
|
return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
|
|
7361
8120
|
}
|
|
7362
8121
|
function resource(file, id) {
|
|
7363
|
-
return _optionalChain([file, 'access',
|
|
8122
|
+
return _optionalChain([file, 'access', _195 => _195.resources, 'access', _196 => _196.find, 'call', _197 => _197((r) => r.id === id), 'optionalAccess', _198 => _198.data]);
|
|
7364
8123
|
}
|
|
7365
8124
|
function resolution(file) {
|
|
7366
8125
|
const d = resource(file, 1005);
|
|
@@ -7981,7 +8740,7 @@ function importNode(ctx, node, depth) {
|
|
|
7981
8740
|
if (node.children) {
|
|
7982
8741
|
const props2 = baseProps(ctx, rec, name, notes);
|
|
7983
8742
|
const divider = sectionDivider(rec);
|
|
7984
|
-
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess',
|
|
8743
|
+
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _199 => _199.blendKey]), () => ( rec.blendKey));
|
|
7985
8744
|
const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
|
|
7986
8745
|
const children = [];
|
|
7987
8746
|
for (const child of node.children) {
|
|
@@ -7991,7 +8750,7 @@ function importNode(ctx, node, depth) {
|
|
|
7991
8750
|
const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
|
|
7992
8751
|
const effects2 = recordEffects(ctx, rec, name, notes, true);
|
|
7993
8752
|
if (effects2) group.effects = effects2;
|
|
7994
|
-
if (_optionalChain([divider, 'optionalAccess',
|
|
8753
|
+
if (_optionalChain([divider, 'optionalAccess', _200 => _200.kind]) === SECTION_CLOSED) group.collapsed = true;
|
|
7995
8754
|
const mask2 = recordMask(ctx, rec, name);
|
|
7996
8755
|
if (mask2) group.mask = mask2;
|
|
7997
8756
|
entry.type = "group";
|
|
@@ -8133,7 +8892,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
8133
8892
|
const file = ctx.linked.get(placed.idnt);
|
|
8134
8893
|
contents = {
|
|
8135
8894
|
id: placed.idnt || ctx.newId(`${name}-contents`),
|
|
8136
|
-
name: _optionalChain([file, 'optionalAccess',
|
|
8895
|
+
name: _optionalChain([file, 'optionalAccess', _201 => _201.name]) || `${name}.png`,
|
|
8137
8896
|
width,
|
|
8138
8897
|
height,
|
|
8139
8898
|
kind: "raster",
|
|
@@ -8353,20 +9112,20 @@ function blendFromPsdId(id) {
|
|
|
8353
9112
|
function psdBlendId(mode) {
|
|
8354
9113
|
return _nullishCoalesce(BLEND_ID.get(mode), () => ( "Nrml"));
|
|
8355
9114
|
}
|
|
8356
|
-
var
|
|
8357
|
-
var pct = (d, key, fallback) =>
|
|
9115
|
+
var num3 = (d, key, fallback) => _nullishCoalesce(descNumber(d, key), () => ( fallback));
|
|
9116
|
+
var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
|
|
8358
9117
|
var bool = (d, key) => descBool(d, key) === true;
|
|
8359
9118
|
var enumOf2 = (d, key) => {
|
|
8360
9119
|
const v = descGet(d, key);
|
|
8361
|
-
return _optionalChain([v, 'optionalAccess',
|
|
9120
|
+
return _optionalChain([v, 'optionalAccess', _202 => _202.type]) === "enum" ? v.value : void 0;
|
|
8362
9121
|
};
|
|
8363
9122
|
var text2 = (d, key) => {
|
|
8364
9123
|
const v = d ? descGet(d, key) : void 0;
|
|
8365
|
-
return _optionalChain([v, 'optionalAccess',
|
|
9124
|
+
return _optionalChain([v, 'optionalAccess', _203 => _203.type]) === "TEXT" ? v.value : "";
|
|
8366
9125
|
};
|
|
8367
9126
|
var list = (d, key) => {
|
|
8368
9127
|
const v = descGet(d, key);
|
|
8369
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
9128
|
+
if (_optionalChain([v, 'optionalAccess', _204 => _204.type]) !== "VlLs") return [];
|
|
8370
9129
|
return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
|
|
8371
9130
|
};
|
|
8372
9131
|
var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
|
|
@@ -8427,7 +9186,7 @@ function contourOf(d, key) {
|
|
|
8427
9186
|
if (!c) return void 0;
|
|
8428
9187
|
const name = text2(c, "Nm ");
|
|
8429
9188
|
const points = list(c, "Crv ").map((p) => {
|
|
8430
|
-
const out = { input: clamp3(
|
|
9189
|
+
const out = { input: clamp3(num3(p, "Hrzn", 0) / 255, 0, 1), output: clamp3(num3(p, "Vrtc", 0) / 255, 0, 1) };
|
|
8431
9190
|
if (descBool(p, "Cnty") === false) out.corner = true;
|
|
8432
9191
|
return out;
|
|
8433
9192
|
});
|
|
@@ -8436,8 +9195,8 @@ function contourOf(d, key) {
|
|
|
8436
9195
|
return { name, points };
|
|
8437
9196
|
}
|
|
8438
9197
|
function contourDesc(c) {
|
|
8439
|
-
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
8440
|
-
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
9198
|
+
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _205 => _205.name]), () => ( "Linear"));
|
|
9199
|
+
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _206 => _206.points]), () => ( [
|
|
8441
9200
|
{ input: 0, output: 0 },
|
|
8442
9201
|
{ input: 1, output: 1 }
|
|
8443
9202
|
]));
|
|
@@ -8472,8 +9231,8 @@ function gradientOf(d, notes) {
|
|
|
8472
9231
|
{ position: 0, color: "#000000" },
|
|
8473
9232
|
{ position: 1, color: "#ffffff" }
|
|
8474
9233
|
],
|
|
8475
|
-
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access',
|
|
8476
|
-
angle: clamp3(
|
|
9234
|
+
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _207 => _207.find, 'call', _208 => _208(([, id]) => id === enumOf2(d, "Type")), 'optionalAccess', _209 => _209[0]]), () => ( "linear")),
|
|
9235
|
+
angle: clamp3(num3(d, "Angl", 90), -360, 360),
|
|
8477
9236
|
scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
|
|
8478
9237
|
reverse: bool(d, "Rvrs"),
|
|
8479
9238
|
align: descBool(d, "Algn") !== false,
|
|
@@ -8491,7 +9250,7 @@ function gradientOf(d, notes) {
|
|
|
8491
9250
|
const type = enumOf2(s, "Type");
|
|
8492
9251
|
if (type === "FrgC" || type === "BckC") notes.add("foreground / background gradient stops became black / white");
|
|
8493
9252
|
const color = type === "BckC" ? "#ffffff" : colorOf(descObject(s, "Clr "));
|
|
8494
|
-
return { position: clamp3(
|
|
9253
|
+
return { position: clamp3(num3(s, "Lctn", 0) / 4096, 0, 1), color, mid: clamp3(num3(s, "Mdpn", 50) / 100, 0.05, 0.95) };
|
|
8495
9254
|
}).sort((a, b) => a.position - b.position);
|
|
8496
9255
|
if (raw.length) {
|
|
8497
9256
|
const stops = [];
|
|
@@ -8507,9 +9266,9 @@ function gradientOf(d, notes) {
|
|
|
8507
9266
|
});
|
|
8508
9267
|
g.stops = stops;
|
|
8509
9268
|
}
|
|
8510
|
-
const opacity = list(grad, "Trns").map((s) => ({ position: clamp3(
|
|
9269
|
+
const opacity = list(grad, "Trns").map((s) => ({ position: clamp3(num3(s, "Lctn", 0) / 4096, 0, 1), opacity: clamp3(num3(s, "Opct", 100) / 100, 0, 1) })).sort((a, b) => a.position - b.position);
|
|
8511
9270
|
if (opacity.some((o) => o.opacity < 1)) g.opacityStops = opacity;
|
|
8512
|
-
if (
|
|
9271
|
+
if (num3(grad, "Intr", 0) > 0) notes.add("gradient smoothness is drawn as straight segments");
|
|
8513
9272
|
return g;
|
|
8514
9273
|
}
|
|
8515
9274
|
function gradientItems(g) {
|
|
@@ -8526,7 +9285,7 @@ function gradientItems(g) {
|
|
|
8526
9285
|
)
|
|
8527
9286
|
)
|
|
8528
9287
|
};
|
|
8529
|
-
const op = _optionalChain([g, 'access',
|
|
9288
|
+
const op = _optionalChain([g, 'access', _210 => _210.opacityStops, 'optionalAccess', _211 => _211.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
|
|
8530
9289
|
const trns = {
|
|
8531
9290
|
type: "VlLs",
|
|
8532
9291
|
items: op.map(
|
|
@@ -8579,9 +9338,9 @@ function patternRefDesc(patternId, name) {
|
|
|
8579
9338
|
function placementOf(d) {
|
|
8580
9339
|
const phase = descObject(d, "phase");
|
|
8581
9340
|
return {
|
|
8582
|
-
angle: clamp3(
|
|
9341
|
+
angle: clamp3(num3(d, "Angl", 0), -360, 360),
|
|
8583
9342
|
link: descBool(d, "Algn") !== false,
|
|
8584
|
-
phase: phase ? { x:
|
|
9343
|
+
phase: phase ? { x: num3(phase, "Hrzn", 0), y: num3(phase, "Vrtc", 0) } : { x: 0, y: 0 }
|
|
8585
9344
|
};
|
|
8586
9345
|
}
|
|
8587
9346
|
function placementItems(angle, link, phase) {
|
|
@@ -8616,16 +9375,16 @@ function common(d, kind, notes) {
|
|
|
8616
9375
|
return { id: _chunkPOGBUYWEcjs.newEffectId.call(void 0, ), enabled: descBool(d, "enab") !== false, blend: blendOf(d, "Md ", def.blend, notes), opacity: clamp3(pct(d, "Opct", def.opacity), 0, 1) };
|
|
8617
9376
|
}
|
|
8618
9377
|
function readOne(kind, d, notes) {
|
|
8619
|
-
const size = (key, fallback) => clamp3(
|
|
9378
|
+
const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
|
|
8620
9379
|
switch (kind) {
|
|
8621
9380
|
case "drop-shadow":
|
|
8622
9381
|
case "inner-shadow": {
|
|
8623
9382
|
const base = {
|
|
8624
9383
|
...common(d, kind, notes),
|
|
8625
9384
|
color: colorOf(descObject(d, "Clr ")),
|
|
8626
|
-
angle: clamp3(
|
|
9385
|
+
angle: clamp3(num3(d, "lagl", 120), -360, 360),
|
|
8627
9386
|
useGlobalLight: descBool(d, "uglg") !== false,
|
|
8628
|
-
distance: clamp3(
|
|
9387
|
+
distance: clamp3(num3(d, "Dstn", 5), 0, 3e4),
|
|
8629
9388
|
size: size("blur", 5),
|
|
8630
9389
|
contour: contourOf(d, "TrnS"),
|
|
8631
9390
|
antiAlias: bool(d, "AntA"),
|
|
@@ -8664,9 +9423,9 @@ function readOne(kind, d, notes) {
|
|
|
8664
9423
|
depth: clamp3(pct(d, "srgR", 1), 0, 10),
|
|
8665
9424
|
direction: enumOf2(d, "bvlD") === "Out " ? "down" : "up",
|
|
8666
9425
|
size: size("blur", 5),
|
|
8667
|
-
soften: clamp3(
|
|
8668
|
-
angle: clamp3(
|
|
8669
|
-
altitude: clamp3(
|
|
9426
|
+
soften: clamp3(num3(d, "Sftn", 0), 0, 16),
|
|
9427
|
+
angle: clamp3(num3(d, "lagl", 120), -360, 360),
|
|
9428
|
+
altitude: clamp3(num3(d, "Lald", 30), 0, 90),
|
|
8670
9429
|
useGlobalLight: descBool(d, "uglg") !== false,
|
|
8671
9430
|
glossContour: contourOf(d, "TrnS"),
|
|
8672
9431
|
highlightColor: colorOf(descObject(d, "hglC"), "#ffffff"),
|
|
@@ -8689,7 +9448,7 @@ function readOne(kind, d, notes) {
|
|
|
8689
9448
|
...common(d, kind, notes),
|
|
8690
9449
|
kind,
|
|
8691
9450
|
color: colorOf(descObject(d, "Clr ")),
|
|
8692
|
-
angle: clamp3(
|
|
9451
|
+
angle: clamp3(num3(d, "lagl", 19), -360, 360),
|
|
8693
9452
|
distance: size("Dstn", 11),
|
|
8694
9453
|
size: size("blur", 14),
|
|
8695
9454
|
contour: contourOf(d, "MpgS"),
|
|
@@ -8722,7 +9481,7 @@ function parseLfx2(data) {
|
|
|
8722
9481
|
let d;
|
|
8723
9482
|
try {
|
|
8724
9483
|
d = parseVersionedDescriptor(data.subarray(4));
|
|
8725
|
-
} catch (
|
|
9484
|
+
} catch (e19) {
|
|
8726
9485
|
return null;
|
|
8727
9486
|
}
|
|
8728
9487
|
const notes = /* @__PURE__ */ new Set();
|
|
@@ -8943,7 +9702,7 @@ function parseLrfx(data) {
|
|
|
8943
9702
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
8944
9703
|
}
|
|
8945
9704
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
8946
|
-
} catch (
|
|
9705
|
+
} catch (e20) {
|
|
8947
9706
|
return null;
|
|
8948
9707
|
}
|
|
8949
9708
|
}
|
|
@@ -9011,9 +9770,9 @@ function prepareNestedLayers(layers) {
|
|
|
9011
9770
|
if (l.type === "annotation") continue;
|
|
9012
9771
|
let next = l;
|
|
9013
9772
|
if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
|
|
9014
|
-
else if (l.type === "pixel" && (_optionalChain([l, 'access',
|
|
9773
|
+
else if (l.type === "pixel" && (_optionalChain([l, 'access', _212 => _212.filters, 'optionalAccess', _213 => _213.length]) || l.source === "document")) {
|
|
9015
9774
|
const p = { ...l };
|
|
9016
|
-
if (_optionalChain([l, 'access',
|
|
9775
|
+
if (_optionalChain([l, 'access', _214 => _214.filters, 'optionalAccess', _215 => _215.some, 'call', _216 => _216(isActiveFilter)])) {
|
|
9017
9776
|
const b = l.surface.bounds;
|
|
9018
9777
|
if (b) {
|
|
9019
9778
|
const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
|
|
@@ -9030,7 +9789,7 @@ function prepareNestedLayers(layers) {
|
|
|
9030
9789
|
delete p.source;
|
|
9031
9790
|
next = p;
|
|
9032
9791
|
}
|
|
9033
|
-
if (_optionalChain([next, 'access',
|
|
9792
|
+
if (_optionalChain([next, 'access', _217 => _217.mask, 'optionalAccess', _218 => _218.source])) {
|
|
9034
9793
|
next = { ...next };
|
|
9035
9794
|
delete next.mask;
|
|
9036
9795
|
}
|
|
@@ -9111,7 +9870,7 @@ function exportPsd(input) {
|
|
|
9111
9870
|
return {
|
|
9112
9871
|
opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
|
|
9113
9872
|
clipping: layer.clipped ? 1 : 0,
|
|
9114
|
-
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access',
|
|
9873
|
+
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _219 => _219.locks, 'optionalAccess', _220 => _220.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
|
|
9115
9874
|
legacyName: name,
|
|
9116
9875
|
blocks
|
|
9117
9876
|
};
|
|
@@ -9168,7 +9927,7 @@ function exportPsd(input) {
|
|
|
9168
9927
|
}
|
|
9169
9928
|
case "pixel": {
|
|
9170
9929
|
if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
|
|
9171
|
-
if (_optionalChain([layer, 'access',
|
|
9930
|
+
if (_optionalChain([layer, 'access', _221 => _221.filters, 'optionalAccess', _222 => _222.some, 'call', _223 => _223(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
|
|
9172
9931
|
const extra = [];
|
|
9173
9932
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
|
|
9174
9933
|
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
@@ -9207,7 +9966,7 @@ function exportPsd(input) {
|
|
|
9207
9966
|
if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
|
|
9208
9967
|
linkedFiles.set(idnt, smartContentsFile(c));
|
|
9209
9968
|
}
|
|
9210
|
-
let placedId = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
9969
|
+
let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _224 => _224.psd, 'optionalAccess', _225 => _225.placed]), () => ( psdUuid(`${layer.id}:placed`)));
|
|
9211
9970
|
if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
|
|
9212
9971
|
placedIds.add(placedId);
|
|
9213
9972
|
if (placedUnchanged(layer, idnt, placedId)) {
|
|
@@ -9217,12 +9976,12 @@ function exportPsd(input) {
|
|
|
9217
9976
|
const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
|
|
9218
9977
|
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);
|
|
9219
9978
|
const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
|
|
9220
|
-
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess',
|
|
9979
|
+
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _226 => _226.descriptor]) };
|
|
9221
9980
|
const wnotes = [];
|
|
9222
9981
|
extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
|
|
9223
9982
|
for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
|
|
9224
9983
|
}
|
|
9225
|
-
const fm = _optionalChain([layer, 'access',
|
|
9984
|
+
const fm = _optionalChain([layer, 'access', _227 => _227.smartFilters, 'optionalAccess', _228 => _228.mask]);
|
|
9226
9985
|
if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
|
|
9227
9986
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
9228
9987
|
const bounds = _chunkXIOMMGPDcjs.contentBounds.call(void 0, layer.surface);
|
|
@@ -9653,5 +10412,40 @@ function exportPsd(input) {
|
|
|
9653
10412
|
|
|
9654
10413
|
|
|
9655
10414
|
|
|
9656
|
-
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.LayerCompositor = LayerCompositor; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.parseCssColor = parseCssColor; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
9657
|
-
|
|
10415
|
+
|
|
10416
|
+
|
|
10417
|
+
|
|
10418
|
+
|
|
10419
|
+
|
|
10420
|
+
|
|
10421
|
+
|
|
10422
|
+
|
|
10423
|
+
|
|
10424
|
+
|
|
10425
|
+
|
|
10426
|
+
|
|
10427
|
+
|
|
10428
|
+
|
|
10429
|
+
|
|
10430
|
+
|
|
10431
|
+
|
|
10432
|
+
|
|
10433
|
+
|
|
10434
|
+
|
|
10435
|
+
|
|
10436
|
+
|
|
10437
|
+
|
|
10438
|
+
|
|
10439
|
+
|
|
10440
|
+
|
|
10441
|
+
|
|
10442
|
+
|
|
10443
|
+
|
|
10444
|
+
|
|
10445
|
+
|
|
10446
|
+
|
|
10447
|
+
|
|
10448
|
+
|
|
10449
|
+
|
|
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-PHUMLSCW.cjs.map
|