@pixerate/editor 0.136.0 → 0.137.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation-editor/index.cjs +60 -55
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +4 -4
- package/dist/animation-editor/index.d.ts +4 -4
- package/dist/animation-editor/index.js +7 -2
- package/dist/animation-editor/index.js.map +1 -1
- package/dist/{bezier-CdccFsF8.d.cts → bezier-CZ2AhjID.d.cts} +1 -1
- package/dist/{bezier-DG9qNZQV.d.ts → bezier-Dywv3Bw8.d.ts} +1 -1
- package/dist/blending-D7jCmjO6.d.cts +1026 -0
- package/dist/blending-NgF3qo3d.d.ts +1026 -0
- package/dist/brushes-CnvZSYYU.d.cts +744 -0
- package/dist/brushes-DJmUbIgz.d.ts +744 -0
- package/dist/{brushstrokeRender-SII6MG4R.js → brushstrokeRender-2FAXA3XC.js} +13 -16
- package/dist/{brushstrokeRender-SII6MG4R.js.map → brushstrokeRender-2FAXA3XC.js.map} +1 -1
- package/dist/{brushstrokeRender-JNHVEUFG.cjs → brushstrokeRender-IMFY3FF6.cjs} +16 -19
- package/dist/brushstrokeRender-IMFY3FF6.cjs.map +1 -0
- package/dist/canvas/index.cjs +10 -10
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +7 -7
- package/dist/canvas/index.d.ts +7 -7
- package/dist/canvas/index.js +4 -4
- package/dist/{chunk-W4LNKTHT.cjs → chunk-2XS6LTUP.cjs} +63 -63
- package/dist/{chunk-W4LNKTHT.cjs.map → chunk-2XS6LTUP.cjs.map} +1 -1
- package/dist/{chunk-MAHQC3SK.js → chunk-3D77LOBM.js} +222 -135
- package/dist/chunk-3D77LOBM.js.map +1 -0
- package/dist/{chunk-BR7EKQUP.js → chunk-3G6J7UFV.js} +322 -2
- package/dist/chunk-3G6J7UFV.js.map +1 -0
- package/dist/{chunk-62XUO5LB.js → chunk-3X6IAJUQ.js} +2 -2
- package/dist/{chunk-EM3FMJWE.js → chunk-5FSRTP6E.js} +320 -3
- package/dist/chunk-5FSRTP6E.js.map +1 -0
- package/dist/{chunk-2R3UW57U.cjs → chunk-5OOIUXNJ.cjs} +333 -246
- package/dist/chunk-5OOIUXNJ.cjs.map +1 -0
- package/dist/{chunk-KZXLZCQ7.js → chunk-6S6362D2.js} +2 -2
- package/dist/{chunk-24ATT2PE.cjs → chunk-AEAAN4AD.cjs} +120 -120
- package/dist/{chunk-24ATT2PE.cjs.map → chunk-AEAAN4AD.cjs.map} +1 -1
- package/dist/{chunk-SVYE5HIM.js → chunk-EQQMGO42.js} +2 -2
- package/dist/{chunk-FHPVDTI2.cjs → chunk-F2Y4E4GU.cjs} +22 -22
- package/dist/{chunk-FHPVDTI2.cjs.map → chunk-F2Y4E4GU.cjs.map} +1 -1
- package/dist/{chunk-UYQUPUR6.js → chunk-HUO3TI4C.js} +3 -3
- package/dist/{chunk-DDSO4HS7.cjs → chunk-KEENUAFN.cjs} +2 -2
- package/dist/{chunk-DDSO4HS7.cjs.map → chunk-KEENUAFN.cjs.map} +1 -1
- package/dist/{chunk-2HC4DRF4.js → chunk-LLFHCSU2.js} +2 -2
- package/dist/{chunk-J5BA3BQ6.cjs → chunk-O7LUD7MH.cjs} +323 -3
- package/dist/chunk-O7LUD7MH.cjs.map +1 -0
- package/dist/{chunk-ILYFOJUN.js → chunk-OIBIRXRG.js} +3 -3
- package/dist/{chunk-B2CUCM7Y.cjs → chunk-PRSRYHQD.cjs} +36 -36
- package/dist/{chunk-B2CUCM7Y.cjs.map → chunk-PRSRYHQD.cjs.map} +1 -1
- package/dist/{chunk-6GFRKLLS.cjs → chunk-QBWEH3IM.cjs} +429 -112
- package/dist/chunk-QBWEH3IM.cjs.map +1 -0
- package/dist/{chunk-6QQR4LKE.js → chunk-SYT2TLQF.js} +35 -37
- package/dist/{chunk-6QQR4LKE.js.map → chunk-SYT2TLQF.js.map} +1 -1
- package/dist/{chunk-YT3JL7YM.cjs → chunk-TLCTTQFF.cjs} +53 -53
- package/dist/{chunk-YT3JL7YM.cjs.map → chunk-TLCTTQFF.cjs.map} +1 -1
- package/dist/{chunk-JLGNZMUV.cjs → chunk-XN2NBLV5.cjs} +313 -315
- package/dist/chunk-XN2NBLV5.cjs.map +1 -0
- package/dist/effects/index.d.cts +4 -4
- package/dist/effects/index.d.ts +4 -4
- package/dist/{export-Ds7zgGD8.d.ts → export-41rL6Cne.d.ts} +1 -1
- package/dist/{export-BOheWw2R.d.cts → export-CyJdfP_Z.d.cts} +5 -4
- package/dist/{export-CEYeRQXH.d.cts → export-D9mXp05Q.d.cts} +1 -1
- package/dist/{export-ByKKIA2S.d.ts → export-DwnZ_hvQ.d.ts} +5 -4
- package/dist/{helpers--ns3W2D7.d.ts → helpers-C-RgeyvH.d.ts} +18 -7
- package/dist/{helpers-BVkU4oUi.d.cts → helpers-v6GMazzg.d.cts} +18 -7
- package/dist/image-editor/index.cjs +984 -987
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +12 -11
- package/dist/image-editor/index.d.ts +12 -11
- package/dist/image-editor/index.js +92 -95
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{opentype-yi-Kz4ND.d.cts → opentype-KR_jj6b_.d.cts} +1 -1
- package/dist/{opentype-DfoVYgmG.d.ts → opentype-a1KAW-qs.d.ts} +1 -1
- package/dist/paint/index.cjs +5 -8
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +4 -2
- package/dist/paint/index.d.ts +4 -2
- package/dist/paint/index.js +15 -18
- package/dist/paint-editor/index.cjs +403 -404
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +12 -748
- package/dist/paint-editor/index.d.ts +12 -748
- package/dist/paint-editor/index.js +77 -78
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/{pathfinder-7JkMwYvC.d.cts → pathfinder-BHS4vQNm.d.cts} +1 -1
- package/dist/{pathfinder-GM3UWdBZ.d.ts → pathfinder-BVvTIBMo.d.ts} +1 -1
- package/dist/{pool-CkTxlLMC.d.ts → pool-CZQOrSXZ.d.ts} +1 -1
- package/dist/{pool-04qp8iW4.d.cts → pool-FjZZmZ80.d.cts} +1 -1
- package/dist/rand-8xbUb6ur.d.ts +1118 -0
- package/dist/rand-Cw9VLrVC.d.cts +1118 -0
- package/dist/raster/index.cjs +17 -19
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.js +9 -11
- package/dist/raster/index.js.map +1 -1
- package/dist/{svg-rV6_HPmn.d.ts → svg-CSz3mzkw.d.ts} +2 -2
- package/dist/{svg-BDDKvWWY.d.cts → svg-DTb40ICU.d.cts} +2 -2
- package/dist/{tools-DPYerqeR.d.ts → tools-B0wXP5cF.d.ts} +1 -1
- package/dist/{tools-BAjSbTdY.d.cts → tools-Ca0kI1qo.d.cts} +1 -1
- package/dist/vector/index.cjs +1459 -1259
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +87 -11
- package/dist/vector/index.d.ts +87 -11
- package/dist/vector/index.js +213 -13
- package/dist/vector/index.js.map +1 -1
- package/dist/video-editor/index.d.cts +4 -4
- package/dist/video-editor/index.d.ts +4 -4
- package/dist/{warp-DQh9R7Ie.d.cts → warp-DTOp0lON.d.cts} +1 -1
- package/dist/{warp-XVL6SpSh.d.ts → warp-pd7hrH4T.d.ts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-vector/SKILL.md +8 -0
- package/dist/brushstrokeRender-JNHVEUFG.cjs.map +0 -1
- package/dist/chunk-2R3UW57U.cjs.map +0 -1
- package/dist/chunk-64PYNEHJ.js +0 -340
- package/dist/chunk-64PYNEHJ.js.map +0 -1
- package/dist/chunk-6GFRKLLS.cjs.map +0 -1
- package/dist/chunk-7QN76ESJ.js +0 -323
- package/dist/chunk-7QN76ESJ.js.map +0 -1
- package/dist/chunk-BR7EKQUP.js.map +0 -1
- package/dist/chunk-DCLJNVZS.cjs +0 -323
- package/dist/chunk-DCLJNVZS.cjs.map +0 -1
- package/dist/chunk-EM3FMJWE.js.map +0 -1
- package/dist/chunk-J5BA3BQ6.cjs.map +0 -1
- package/dist/chunk-JLGNZMUV.cjs.map +0 -1
- package/dist/chunk-MAHQC3SK.js.map +0 -1
- package/dist/chunk-Z6OUCS2K.cjs +0 -340
- package/dist/chunk-Z6OUCS2K.cjs.map +0 -1
- package/dist/rand-BszBST4s.d.ts +0 -2140
- package/dist/rand-DOH_aMvm.d.cts +0 -2140
- /package/dist/{chunk-62XUO5LB.js.map → chunk-3X6IAJUQ.js.map} +0 -0
- /package/dist/{chunk-KZXLZCQ7.js.map → chunk-6S6362D2.js.map} +0 -0
- /package/dist/{chunk-SVYE5HIM.js.map → chunk-EQQMGO42.js.map} +0 -0
- /package/dist/{chunk-UYQUPUR6.js.map → chunk-HUO3TI4C.js.map} +0 -0
- /package/dist/{chunk-2HC4DRF4.js.map → chunk-LLFHCSU2.js.map} +0 -0
- /package/dist/{chunk-ILYFOJUN.js.map → chunk-OIBIRXRG.js.map} +0 -0
|
@@ -37,7 +37,7 @@ var _chunk2YQONY6Gcjs = require('./chunk-2YQONY6G.cjs');
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkAEAAN4ADcjs = require('./chunk-AEAAN4AD.cjs');
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
@@ -53,6 +53,7 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
var _chunkG5NMLUVFcjs = require('./chunk-G5NMLUVF.cjs');
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
|
|
@@ -68,37 +69,34 @@ var _chunkMUUXNRU4cjs = require('./chunk-MUUXNRU4.cjs');
|
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
|
|
71
|
-
var _chunkJ5BA3BQ6cjs = require('./chunk-J5BA3BQ6.cjs');
|
|
72
|
-
|
|
73
72
|
|
|
74
73
|
|
|
75
74
|
|
|
76
75
|
|
|
77
76
|
|
|
78
77
|
|
|
79
|
-
var _chunkDCLJNVZScjs = require('./chunk-DCLJNVZS.cjs');
|
|
80
78
|
|
|
81
79
|
|
|
82
80
|
|
|
83
81
|
|
|
84
82
|
|
|
85
|
-
var _chunkG5NMLUVFcjs = require('./chunk-G5NMLUVF.cjs');
|
|
86
83
|
|
|
87
84
|
|
|
88
85
|
|
|
89
86
|
|
|
90
|
-
var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
|
|
91
87
|
|
|
92
88
|
|
|
93
89
|
|
|
94
90
|
|
|
95
91
|
|
|
92
|
+
var _chunk5OOIUXNJcjs = require('./chunk-5OOIUXNJ.cjs');
|
|
96
93
|
|
|
97
94
|
|
|
98
95
|
|
|
99
96
|
|
|
100
97
|
|
|
101
98
|
|
|
99
|
+
var _chunkBJTCSLF6cjs = require('./chunk-BJTCSLF6.cjs');
|
|
102
100
|
|
|
103
101
|
|
|
104
102
|
|
|
@@ -123,14 +121,14 @@ var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
|
|
|
123
121
|
|
|
124
122
|
|
|
125
123
|
|
|
126
|
-
var _chunk2R3UW57Ucjs = require('./chunk-2R3UW57U.cjs');
|
|
127
124
|
|
|
128
125
|
|
|
126
|
+
var _chunkO7LUD7MHcjs = require('./chunk-O7LUD7MH.cjs');
|
|
129
127
|
|
|
130
128
|
|
|
131
129
|
|
|
132
130
|
|
|
133
|
-
var
|
|
131
|
+
var _chunk643B2HKCcjs = require('./chunk-643B2HKC.cjs');
|
|
134
132
|
|
|
135
133
|
// src/image-editor/color.ts
|
|
136
134
|
var LEGACY_PROCESS_VERSION = 1;
|
|
@@ -1142,7 +1140,7 @@ function smoothCoverage(m, w, h, r) {
|
|
|
1142
1140
|
return src;
|
|
1143
1141
|
}
|
|
1144
1142
|
function featherCoverage(m, w, h, radius) {
|
|
1145
|
-
const out =
|
|
1143
|
+
const out = _chunkAEAAN4ADcjs.gaussianBlur.call(void 0, m, w, h, Number.isFinite(radius) ? Math.max(0, radius) : 0, "zero");
|
|
1146
1144
|
for (let i = 0; i < out.length; i++) if (Math.abs(out[i]) < 1e-7) out[i] = 0;
|
|
1147
1145
|
return out;
|
|
1148
1146
|
}
|
|
@@ -1290,7 +1288,7 @@ function layerMaskCoverage(mask) {
|
|
|
1290
1288
|
let v = new Float32Array(sel.data.length);
|
|
1291
1289
|
for (let i = 0; i < v.length; i++) v[i] = sel.data[i] / 255;
|
|
1292
1290
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
1293
|
-
if (feather > 0) v =
|
|
1291
|
+
if (feather > 0) v = _chunkAEAAN4ADcjs.gaussianBlur.call(void 0, v, mask.width, mask.height, feather, "clamp");
|
|
1294
1292
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
1295
1293
|
if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
|
|
1296
1294
|
return v;
|
|
@@ -1511,7 +1509,7 @@ function normalizeAdjustmentLayer(raw) {
|
|
|
1511
1509
|
kind: r.kind,
|
|
1512
1510
|
enabled: r.enabled !== false,
|
|
1513
1511
|
opacity: clampTo(r.opacity, 0, 1, 1),
|
|
1514
|
-
blend:
|
|
1512
|
+
blend: _chunkO7LUD7MHcjs.normalizeBlendMode.call(void 0, r.blend),
|
|
1515
1513
|
params: normParams(r.kind, r.params)
|
|
1516
1514
|
};
|
|
1517
1515
|
if (typeof r.name === "string" && r.name) layer.name = r.name;
|
|
@@ -1533,7 +1531,7 @@ function normalizeAdjustmentLayers(raw) {
|
|
|
1533
1531
|
return out;
|
|
1534
1532
|
}
|
|
1535
1533
|
function curveLutFromLevels(points) {
|
|
1536
|
-
return
|
|
1534
|
+
return _chunkAEAAN4ADcjs.curveLut.call(void 0, points.map((p) => ({ input: p.input / 255, output: p.output / 255 })));
|
|
1537
1535
|
}
|
|
1538
1536
|
var toUnitLevels = (c) => ({
|
|
1539
1537
|
inBlack: c.inBlack / 255,
|
|
@@ -1857,7 +1855,7 @@ function compileAdjustmentLayer(layer, options = {}) {
|
|
|
1857
1855
|
return (c) => {
|
|
1858
1856
|
const g = blackWhiteGray(c, weights);
|
|
1859
1857
|
if (tint) {
|
|
1860
|
-
const t =
|
|
1858
|
+
const t = _chunkO7LUD7MHcjs.setLum.call(void 0, tint, g);
|
|
1861
1859
|
c[0] = clamp01(t[0]);
|
|
1862
1860
|
c[1] = clamp01(t[1]);
|
|
1863
1861
|
c[2] = clamp01(t[2]);
|
|
@@ -1876,7 +1874,7 @@ function compileAdjustmentLayer(layer, options = {}) {
|
|
|
1876
1874
|
let f = [0, 1, 2].map((r) => linearToSrgb(Math.max(0, m[r][0] * l[0] + m[r][1] * l[1] + m[r][2] * l[2])));
|
|
1877
1875
|
if (preserve) {
|
|
1878
1876
|
const target = 0.3 * c[0] + 0.59 * c[1] + 0.11 * c[2];
|
|
1879
|
-
f =
|
|
1877
|
+
f = _chunkO7LUD7MHcjs.setLum.call(void 0, f, target);
|
|
1880
1878
|
}
|
|
1881
1879
|
c[0] = clamp01(f[0]);
|
|
1882
1880
|
c[1] = clamp01(f[1]);
|
|
@@ -1943,10 +1941,10 @@ function applyLayer(c, layer, op, coverage = 1) {
|
|
|
1943
1941
|
const cb0 = c[0], cb1 = c[1], cb2 = c[2];
|
|
1944
1942
|
op(c);
|
|
1945
1943
|
if (blend === "pigment") {
|
|
1946
|
-
|
|
1944
|
+
_chunkO7LUD7MHcjs.mixPigmentRgb.call(void 0, [clamp01(cb0), clamp01(cb1), clamp01(cb2)], [clamp01(c[0]), clamp01(c[1]), clamp01(c[2])], alpha, c);
|
|
1947
1945
|
return;
|
|
1948
1946
|
}
|
|
1949
|
-
const b = blend === "normal" ? c :
|
|
1947
|
+
const b = blend === "normal" ? c : _chunkO7LUD7MHcjs.blendRgb.call(void 0, blend, [cb0, cb1, cb2], c);
|
|
1950
1948
|
c[0] = (1 - alpha) * cb0 + alpha * b[0];
|
|
1951
1949
|
c[1] = (1 - alpha) * cb1 + alpha * b[1];
|
|
1952
1950
|
c[2] = (1 - alpha) * cb2 + alpha * b[2];
|
|
@@ -2394,7 +2392,7 @@ function newLayerId(prefix = "layer") {
|
|
|
2394
2392
|
return `${prefix}_${Date.now().toString(36)}_${(++idCounter).toString(36)}`;
|
|
2395
2393
|
}
|
|
2396
2394
|
function pixelLayers(layers) {
|
|
2397
|
-
return
|
|
2395
|
+
return _chunkAEAAN4ADcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "pixel");
|
|
2398
2396
|
}
|
|
2399
2397
|
function developFilter(layer) {
|
|
2400
2398
|
return _optionalChain([layer, 'access', _10 => _10.filters, 'optionalAccess', _11 => _11.find, 'call', _12 => _12((f) => f.kind === "develop")]);
|
|
@@ -2425,10 +2423,10 @@ function isRenderedLayer(layer) {
|
|
|
2425
2423
|
return layer.type === "smart" || layer.type === "shape" || layer.type === "type";
|
|
2426
2424
|
}
|
|
2427
2425
|
function shapeLayers(layers) {
|
|
2428
|
-
return
|
|
2426
|
+
return _chunkAEAAN4ADcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "shape");
|
|
2429
2427
|
}
|
|
2430
2428
|
function smartObjectLayers(layers) {
|
|
2431
|
-
return
|
|
2429
|
+
return _chunkAEAAN4ADcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart");
|
|
2432
2430
|
}
|
|
2433
2431
|
|
|
2434
2432
|
// src/image-editor/layers/compositor.ts
|
|
@@ -2550,13 +2548,13 @@ var PHOTO_PROFILE = {
|
|
|
2550
2548
|
return v;
|
|
2551
2549
|
}
|
|
2552
2550
|
};
|
|
2553
|
-
var LayerCompositor = class extends
|
|
2551
|
+
var LayerCompositor = class extends _chunkAEAAN4ADcjs.RasterCompositor {
|
|
2554
2552
|
constructor(options = {}) {
|
|
2555
2553
|
super(PHOTO_PROFILE, options);
|
|
2556
2554
|
}
|
|
2557
2555
|
};
|
|
2558
2556
|
function compositeDeep(layers, rect, sources, depth) {
|
|
2559
|
-
const deep = new (0,
|
|
2557
|
+
const deep = new (0, _chunkAEAAN4ADcjs.DeepCompositor)(new LayerCompositor(), PHOTO_PROFILE, {
|
|
2560
2558
|
applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks),
|
|
2561
2559
|
pixelFiltersDeep: (l) => {
|
|
2562
2560
|
if (l.type !== "pixel") return null;
|
|
@@ -2912,47 +2910,47 @@ var fail = (message) => {
|
|
|
2912
2910
|
throw new LayerOperationError(message);
|
|
2913
2911
|
};
|
|
2914
2912
|
function requireLayer(layers, id) {
|
|
2915
|
-
const loc =
|
|
2913
|
+
const loc = _chunkAEAAN4ADcjs.findLayer.call(void 0, layers, id);
|
|
2916
2914
|
if (!loc) {
|
|
2917
|
-
const ids =
|
|
2915
|
+
const ids = _chunkAEAAN4ADcjs.flattenLayers.call(void 0, layers).map((l) => l.id);
|
|
2918
2916
|
fail(`Unknown layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "The document has no layers."} Call list_layers for ids.`);
|
|
2919
2917
|
}
|
|
2920
2918
|
return loc;
|
|
2921
2919
|
}
|
|
2922
2920
|
function requireUnlocked(layer, what, action) {
|
|
2923
|
-
if (
|
|
2924
|
-
if (what !== "all" &&
|
|
2921
|
+
if (_chunkAEAAN4ADcjs.isLayerLocked.call(void 0, layer, "all")) fail(`Layer "${layer.name || layer.id}" is locked (all); unlock it before you ${action}.`);
|
|
2922
|
+
if (what !== "all" && _chunkAEAAN4ADcjs.isLayerLocked.call(void 0, layer, what)) fail(`Layer "${layer.name || layer.id}" has its ${what} locked; unlock it before you ${action}.`);
|
|
2925
2923
|
}
|
|
2926
2924
|
function placeLayer(layers, layer, placement = {}, defaultIndex) {
|
|
2927
2925
|
const given = [placement.aboveId, placement.belowId, placement.parentId].filter((v) => v !== void 0).length;
|
|
2928
2926
|
if (given > 1) fail("Give only one of aboveId, belowId and parentId.");
|
|
2929
2927
|
if (placement.aboveId || placement.belowId) {
|
|
2930
2928
|
const ref = requireLayer(layers, _nullishCoalesce(placement.aboveId, () => ( placement.belowId)));
|
|
2931
|
-
return
|
|
2929
|
+
return _chunkAEAAN4ADcjs.insertLayer.call(void 0, layers, layer, _nullishCoalesce(_optionalChain([ref, 'access', _21 => _21.parent, 'optionalAccess', _22 => _22.id]), () => ( null)), ref.index + (placement.aboveId ? 1 : 0));
|
|
2932
2930
|
}
|
|
2933
2931
|
if (placement.parentId) {
|
|
2934
2932
|
const ref = requireLayer(layers, placement.parentId);
|
|
2935
2933
|
if (ref.layer.type !== "group") fail(`Layer "${placement.parentId}" is not a group; parentId must be a group id.`);
|
|
2936
|
-
return
|
|
2934
|
+
return _chunkAEAAN4ADcjs.insertLayer.call(void 0, layers, layer, ref.layer.id, placement.index);
|
|
2937
2935
|
}
|
|
2938
|
-
return
|
|
2936
|
+
return _chunkAEAAN4ADcjs.insertLayer.call(void 0, layers, layer, null, _nullishCoalesce(placement.index, () => ( defaultIndex)));
|
|
2939
2937
|
}
|
|
2940
2938
|
function removeLayer(layers, id) {
|
|
2941
2939
|
const loc = requireLayer(layers, id);
|
|
2942
2940
|
requireUnlocked(loc.layer, "all", "delete it");
|
|
2943
|
-
return
|
|
2941
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
2944
2942
|
}
|
|
2945
2943
|
function moveLayer(layers, id, placement) {
|
|
2946
2944
|
const loc = requireLayer(layers, id);
|
|
2947
2945
|
requireUnlocked(loc.layer, "all", "move it");
|
|
2948
2946
|
const target = _nullishCoalesce(_nullishCoalesce(placement.aboveId, () => ( placement.belowId)), () => ( placement.parentId));
|
|
2949
2947
|
if (target === id) fail("A layer cannot be placed relative to itself.");
|
|
2950
|
-
if (target && loc.layer.type === "group" &&
|
|
2948
|
+
if (target && loc.layer.type === "group" && _chunkAEAAN4ADcjs.flattenLayers.call(void 0, loc.layer.children).some((l) => l.id === target)) {
|
|
2951
2949
|
fail(`Group "${id}" cannot be moved into its own child "${target}".`);
|
|
2952
2950
|
}
|
|
2953
2951
|
if (target) requireLayer(layers, target);
|
|
2954
2952
|
if (!target && placement.index === void 0) fail("Give aboveId, belowId, parentId or index.");
|
|
2955
|
-
const without =
|
|
2953
|
+
const without = _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
2956
2954
|
return placeLayer(without, loc.layer, placement);
|
|
2957
2955
|
}
|
|
2958
2956
|
function withNewIds(layer) {
|
|
@@ -2971,7 +2969,7 @@ function duplicateLayer(layers, id, name) {
|
|
|
2971
2969
|
const copy = withNewIds(loc.layer);
|
|
2972
2970
|
copy.name = _nullishCoalesce(name, () => ( `${loc.layer.name || "Layer"} copy`));
|
|
2973
2971
|
delete copy.locks;
|
|
2974
|
-
return { layers:
|
|
2972
|
+
return { layers: _chunkAEAAN4ADcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _25 => _25.parent, 'optionalAccess', _26 => _26.id]), () => ( null)), loc.index + 1), id: copy.id };
|
|
2975
2973
|
}
|
|
2976
2974
|
function setLayerProperties(layers, id, props) {
|
|
2977
2975
|
const loc = requireLayer(layers, id);
|
|
@@ -2998,7 +2996,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
2998
2996
|
if (props.blend !== void 0) {
|
|
2999
2997
|
if (props.blend === "pass-through") {
|
|
3000
2998
|
if (layer.type !== "group") fail("pass-through is only for groups.");
|
|
3001
|
-
} else if (!
|
|
2999
|
+
} else if (!_chunkO7LUD7MHcjs.isBlendMode.call(void 0, props.blend)) fail(`Unknown blend mode "${props.blend}".`);
|
|
3002
3000
|
next.blend = props.blend;
|
|
3003
3001
|
}
|
|
3004
3002
|
if (props.clipped !== void 0) {
|
|
@@ -3018,7 +3016,7 @@ function setLayerProperties(layers, id, props) {
|
|
|
3018
3016
|
if (props.collapsed) g.collapsed = true;
|
|
3019
3017
|
else delete g.collapsed;
|
|
3020
3018
|
}
|
|
3021
|
-
return
|
|
3019
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3022
3020
|
}
|
|
3023
3021
|
function groupLayers(layers, ids, name = "Group") {
|
|
3024
3022
|
if (!ids.length) fail("Give at least one layer id to group.");
|
|
@@ -3047,17 +3045,17 @@ function groupLayers(layers, ids, name = "Group") {
|
|
|
3047
3045
|
group.children[0] = c;
|
|
3048
3046
|
}
|
|
3049
3047
|
let out = layers;
|
|
3050
|
-
for (const l of ordered) out =
|
|
3051
|
-
return { layers:
|
|
3048
|
+
for (const l of ordered) out = _chunkAEAAN4ADcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
3049
|
+
return { layers: _chunkAEAAN4ADcjs.insertLayer.call(void 0, out, group, parent, top - below), id: group.id };
|
|
3052
3050
|
}
|
|
3053
3051
|
function ungroupLayer(layers, id) {
|
|
3054
3052
|
const loc = requireLayer(layers, id);
|
|
3055
3053
|
if (loc.layer.type !== "group") fail(`Layer "${id}" is not a group.`);
|
|
3056
3054
|
requireUnlocked(loc.layer, "all", "ungroup it");
|
|
3057
3055
|
const group = loc.layer;
|
|
3058
|
-
let out =
|
|
3056
|
+
let out = _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => null);
|
|
3059
3057
|
group.children.forEach((c, i) => {
|
|
3060
|
-
out =
|
|
3058
|
+
out = _chunkAEAAN4ADcjs.insertLayer.call(void 0, out, c, _nullishCoalesce(_optionalChain([loc, 'access', _35 => _35.parent, 'optionalAccess', _36 => _36.id]), () => ( null)), loc.index + i);
|
|
3061
3059
|
});
|
|
3062
3060
|
return { layers: out, ids: group.children.map((c) => c.id) };
|
|
3063
3061
|
}
|
|
@@ -3070,14 +3068,14 @@ function offsetLayer(layers, id, offset) {
|
|
|
3070
3068
|
const next = { ...layer, offset: { x: Math.round(offset.x), y: Math.round(offset.y) } };
|
|
3071
3069
|
const mask = layer.mask;
|
|
3072
3070
|
if (mask && mask.linked === false && !mask.source) {
|
|
3073
|
-
next.mask = { ...mask, surface:
|
|
3071
|
+
next.mask = { ...mask, surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, mask.surface, layer.offset.x - next.offset.x, layer.offset.y - next.offset.y) };
|
|
3074
3072
|
}
|
|
3075
|
-
return
|
|
3073
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3076
3074
|
}
|
|
3077
3075
|
function setLayerMask(layers, id, mask) {
|
|
3078
3076
|
const loc = requireLayer(layers, id);
|
|
3079
3077
|
requireUnlocked(loc.layer, "all", "change its mask");
|
|
3080
|
-
return
|
|
3078
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, (l) => {
|
|
3081
3079
|
const next = { ...l };
|
|
3082
3080
|
if (mask) next.mask = mask;
|
|
3083
3081
|
else delete next.mask;
|
|
@@ -3116,7 +3114,7 @@ function requirePixelLayer(layers, id) {
|
|
|
3116
3114
|
function addLayerFilter(layers, id, filter) {
|
|
3117
3115
|
const layer = requirePixelLayer(layers, id);
|
|
3118
3116
|
if (_optionalChain([layer, 'access', _37 => _37.filters, 'optionalAccess', _38 => _38.some, 'call', _39 => _39((f) => f.kind === filter.kind)])) fail(`Layer "${id}" already has a ${filter.kind} filter; change it with update_layer_filter.`);
|
|
3119
|
-
return
|
|
3117
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters: [..._nullishCoalesce(layer.filters, () => ( [])), filter] }));
|
|
3120
3118
|
}
|
|
3121
3119
|
function updateLayerFilter(layers, id, filterId, changes) {
|
|
3122
3120
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -3127,7 +3125,7 @@ function updateLayerFilter(layers, id, filterId, changes) {
|
|
|
3127
3125
|
const merged2 = normalizeFilter({ ...current, ...changes, kind: current.kind }, current.id);
|
|
3128
3126
|
const filters = [...layer.filters];
|
|
3129
3127
|
filters[i] = merged2;
|
|
3130
|
-
return
|
|
3128
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => ({ ...layer, filters }));
|
|
3131
3129
|
}
|
|
3132
3130
|
function removeLayerFilter(layers, id, filterId) {
|
|
3133
3131
|
const layer = requirePixelLayer(layers, id);
|
|
@@ -3136,7 +3134,7 @@ function removeLayerFilter(layers, id, filterId) {
|
|
|
3136
3134
|
const next = { ...layer };
|
|
3137
3135
|
if (filters.length) next.filters = filters;
|
|
3138
3136
|
else delete next.filters;
|
|
3139
|
-
return
|
|
3137
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3140
3138
|
}
|
|
3141
3139
|
function requireEffectLayer(layers, id, action) {
|
|
3142
3140
|
const layer = requireLayer(layers, id).layer;
|
|
@@ -3151,7 +3149,7 @@ function guard(fn) {
|
|
|
3151
3149
|
try {
|
|
3152
3150
|
return fn();
|
|
3153
3151
|
} catch (e) {
|
|
3154
|
-
if (e instanceof
|
|
3152
|
+
if (e instanceof _chunkAEAAN4ADcjs.LayerEffectError) fail(e.message);
|
|
3155
3153
|
throw e;
|
|
3156
3154
|
}
|
|
3157
3155
|
}
|
|
@@ -3159,20 +3157,20 @@ function setLayerEffects(layers, id, effects) {
|
|
|
3159
3157
|
const layer = requireEffectLayer(layers, id, "change its effects");
|
|
3160
3158
|
const next = { ...layer };
|
|
3161
3159
|
if (effects && (effects.items.length || effects.psd || effects.scale !== void 0 || !effects.enabled)) {
|
|
3162
|
-
guard(() =>
|
|
3160
|
+
guard(() => _chunkAEAAN4ADcjs.validateLayerEffects.call(void 0, effects));
|
|
3163
3161
|
next.effects = effects;
|
|
3164
3162
|
} else delete next.effects;
|
|
3165
|
-
return
|
|
3163
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
3166
3164
|
}
|
|
3167
3165
|
function addLayerEffect(layers, id, kind, params = {}, index) {
|
|
3168
|
-
if (!
|
|
3166
|
+
if (!_chunkAEAAN4ADcjs.isLayerEffectKind.call(void 0, kind)) fail(`Unknown effect kind "${String(kind)}". Kinds: ${_chunkAEAAN4ADcjs.LAYER_EFFECT_KINDS.join(", ")}.`);
|
|
3169
3167
|
const layer = requireEffectLayer(layers, id, "add effects");
|
|
3170
3168
|
const current = layerEffectsOf(layer);
|
|
3171
3169
|
const ids = new Set(current.items.map((e) => e.id));
|
|
3172
|
-
let effectId =
|
|
3173
|
-
while (ids.has(effectId)) effectId =
|
|
3170
|
+
let effectId = _chunkAEAAN4ADcjs.newEffectId.call(void 0, );
|
|
3171
|
+
while (ids.has(effectId)) effectId = _chunkAEAAN4ADcjs.newEffectId.call(void 0, );
|
|
3174
3172
|
const { id: _ignored, kind: _kind, ...rest } = params;
|
|
3175
|
-
const effect = guard(() =>
|
|
3173
|
+
const effect = guard(() => _chunkAEAAN4ADcjs.mergeLayerEffect.call(void 0, _chunkAEAAN4ADcjs.defaultLayerEffect.call(void 0, kind, effectId), rest));
|
|
3176
3174
|
const items = [...current.items];
|
|
3177
3175
|
const at = index === void 0 ? items.length : Math.max(0, Math.min(items.length, Math.floor(index)));
|
|
3178
3176
|
items.splice(at, 0, effect);
|
|
@@ -3189,7 +3187,7 @@ function updateLayerEffect(layers, id, effectId, changes) {
|
|
|
3189
3187
|
const i = requireEffect(layer, effectId);
|
|
3190
3188
|
const current = layer.effects;
|
|
3191
3189
|
const items = [...current.items];
|
|
3192
|
-
items[i] = guard(() =>
|
|
3190
|
+
items[i] = guard(() => _chunkAEAAN4ADcjs.mergeLayerEffect.call(void 0, items[i], changes));
|
|
3193
3191
|
return setLayerEffects(layers, id, { ...current, items });
|
|
3194
3192
|
}
|
|
3195
3193
|
function removeLayerEffect(layers, id, effectId) {
|
|
@@ -3212,7 +3210,7 @@ function setLayerEffectsEnabled(layers, id, enabled, scale) {
|
|
|
3212
3210
|
function parseBlend(value, allowPassThrough = false) {
|
|
3213
3211
|
if (value === void 0) return void 0;
|
|
3214
3212
|
if (value === "pass-through" && allowPassThrough) return value;
|
|
3215
|
-
if (!
|
|
3213
|
+
if (!_chunkO7LUD7MHcjs.isBlendMode.call(void 0, value)) fail(`Unknown blend mode "${String(value)}".`);
|
|
3216
3214
|
return value;
|
|
3217
3215
|
}
|
|
3218
3216
|
function unionRect(a, b) {
|
|
@@ -3224,7 +3222,7 @@ function unionRect(a, b) {
|
|
|
3224
3222
|
}
|
|
3225
3223
|
|
|
3226
3224
|
// src/image-editor/layers/shape.ts
|
|
3227
|
-
var SHAPE_RENDER_MARGIN =
|
|
3225
|
+
var SHAPE_RENDER_MARGIN = _chunkAEAAN4ADcjs.MAX_EFFECT_REACH;
|
|
3228
3226
|
var DEFAULT_MITER_LIMIT = 100;
|
|
3229
3227
|
var fail2 = (message) => {
|
|
3230
3228
|
throw new LayerOperationError(message);
|
|
@@ -3264,7 +3262,7 @@ function mapAnchor(a, f) {
|
|
|
3264
3262
|
return out;
|
|
3265
3263
|
}
|
|
3266
3264
|
function mapSubpaths(subpaths, f) {
|
|
3267
|
-
return
|
|
3265
|
+
return _chunk5OOIUXNJcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
|
|
3268
3266
|
}
|
|
3269
3267
|
function liveShapeSubpaths(live) {
|
|
3270
3268
|
let out;
|
|
@@ -3272,19 +3270,19 @@ function liveShapeSubpaths(live) {
|
|
|
3272
3270
|
case "rect": {
|
|
3273
3271
|
const x = Math.min(live.x, live.x + live.width);
|
|
3274
3272
|
const y = Math.min(live.y, live.y + live.height);
|
|
3275
|
-
const sp =
|
|
3273
|
+
const sp = _chunk5OOIUXNJcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
|
|
3276
3274
|
const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
|
|
3277
|
-
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ?
|
|
3275
|
+
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunk5OOIUXNJcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
|
|
3278
3276
|
break;
|
|
3279
3277
|
}
|
|
3280
3278
|
case "ellipse":
|
|
3281
|
-
out = [
|
|
3279
|
+
out = [_chunk5OOIUXNJcjs.ellipseSubpath.call(void 0, normBox(live))];
|
|
3282
3280
|
break;
|
|
3283
3281
|
case "polygon":
|
|
3284
|
-
out = [
|
|
3282
|
+
out = [_chunk5OOIUXNJcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
|
|
3285
3283
|
break;
|
|
3286
3284
|
case "star":
|
|
3287
|
-
out = [
|
|
3285
|
+
out = [_chunk5OOIUXNJcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
|
|
3288
3286
|
break;
|
|
3289
3287
|
case "line": {
|
|
3290
3288
|
const a = { x: live.x1, y: live.y1 };
|
|
@@ -3307,7 +3305,7 @@ function liveShapeSubpaths(live) {
|
|
|
3307
3305
|
}
|
|
3308
3306
|
}
|
|
3309
3307
|
const m = live.transform;
|
|
3310
|
-
return m && !
|
|
3308
|
+
return m && !_chunk5OOIUXNJcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, p)) : out;
|
|
3311
3309
|
}
|
|
3312
3310
|
function normBox(b) {
|
|
3313
3311
|
return { x: Math.min(b.x, b.x + b.width), y: Math.min(b.y, b.y + b.height), width: Math.abs(b.width), height: Math.abs(b.height) };
|
|
@@ -3319,7 +3317,7 @@ var pathCache = /* @__PURE__ */ new WeakMap();
|
|
|
3319
3317
|
function componentPath(c) {
|
|
3320
3318
|
let p = pathCache.get(c.subpaths);
|
|
3321
3319
|
if (!p) {
|
|
3322
|
-
p =
|
|
3320
|
+
p = _chunk5OOIUXNJcjs.subpathsToBezier.call(void 0, c.subpaths);
|
|
3323
3321
|
pathCache.set(c.subpaths, p);
|
|
3324
3322
|
}
|
|
3325
3323
|
return p;
|
|
@@ -3440,11 +3438,11 @@ function fillCoverage(geo, rect, rule, inverted = false) {
|
|
|
3440
3438
|
function paintContext(env) {
|
|
3441
3439
|
const tiles = /* @__PURE__ */ new Map();
|
|
3442
3440
|
return {
|
|
3443
|
-
light:
|
|
3441
|
+
light: _chunkAEAAN4ADcjs.DEFAULT_GLOBAL_LIGHT,
|
|
3444
3442
|
pattern: (id) => {
|
|
3445
3443
|
if (tiles.has(id)) return tiles.get(id);
|
|
3446
|
-
const p = _nullishCoalesce(_optionalChain([env, 'access', _44 => _44.pattern, 'optionalCall', _45 => _45(id)]), () => (
|
|
3447
|
-
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0,
|
|
3444
|
+
const p = _nullishCoalesce(_optionalChain([env, 'access', _44 => _44.pattern, 'optionalCall', _45 => _45(id)]), () => ( _chunkAEAAN4ADcjs.builtinPattern.call(void 0, id)));
|
|
3445
|
+
const t = p && p.width > 0 && p.height > 0 && p.data.length >= p.width * p.height * 4 ? new (0, _chunkAEAAN4ADcjs.PatternTile)(p) : null;
|
|
3448
3446
|
tiles.set(id, t);
|
|
3449
3447
|
return t;
|
|
3450
3448
|
}
|
|
@@ -3475,9 +3473,9 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
|
|
|
3475
3473
|
if (!fCov && !sCov) return null;
|
|
3476
3474
|
const canvas = { x: 0, y: 0, width: env.width, height: env.height };
|
|
3477
3475
|
const anchor = { x: geo.frame.x, y: geo.frame.y };
|
|
3478
|
-
const fc = fCov ?
|
|
3476
|
+
const fc = fCov ? _chunkAEAAN4ADcjs.effectFillColors.call(void 0, layer.fill, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
3479
3477
|
const fo = _nullishCoalesce(_optionalChain([layer, 'access', _46 => _46.fill, 'optionalAccess', _47 => _47.opacity]), () => ( 1));
|
|
3480
|
-
const sc = sCov ?
|
|
3478
|
+
const sc = sCov ? _chunkAEAAN4ADcjs.effectFillColors.call(void 0, layer.stroke.paint, rect, geo.frame, canvas, anchor, ctx) : null;
|
|
3481
3479
|
const so = _nullishCoalesce(_optionalChain([layer, 'access', _48 => _48.stroke, 'optionalAccess', _49 => _49.paint, 'access', _50 => _50.opacity]), () => ( 1));
|
|
3482
3480
|
const out = new Uint8ClampedArray(n * 4);
|
|
3483
3481
|
let any = false;
|
|
@@ -3516,20 +3514,20 @@ function renderShapeRect(layer, rect, env, ctx = paintContext(env)) {
|
|
|
3516
3514
|
}
|
|
3517
3515
|
function renderShape(layer, env, options = {}) {
|
|
3518
3516
|
const geo = shapeGeometry(layer);
|
|
3519
|
-
if (!geo.bounds) return
|
|
3517
|
+
if (!geo.bounds) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
3520
3518
|
let region = intersect(geo.bounds, shapeRenderClip(env));
|
|
3521
3519
|
if (region && options.clip) region = intersect(region, options.clip);
|
|
3522
|
-
if (!region) return
|
|
3520
|
+
if (!region) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
3523
3521
|
const ctx = paintContext(env);
|
|
3524
3522
|
const tiles = /* @__PURE__ */ new Map();
|
|
3525
|
-
for (const { tx, ty } of
|
|
3526
|
-
const rect = { x: tx *
|
|
3523
|
+
for (const { tx, ty } of _chunkO7LUD7MHcjs.tilesInRect.call(void 0, region)) {
|
|
3524
|
+
const rect = { x: tx * _chunkO7LUD7MHcjs.TILE, y: ty * _chunkO7LUD7MHcjs.TILE, width: _chunkO7LUD7MHcjs.TILE, height: _chunkO7LUD7MHcjs.TILE };
|
|
3527
3525
|
const px2 = renderShapeRect(layer, rect, env, ctx);
|
|
3528
3526
|
if (!px2) continue;
|
|
3529
|
-
const tile =
|
|
3530
|
-
if (tile) tiles.set(
|
|
3527
|
+
const tile = _chunkO7LUD7MHcjs.finishTile.call(void 0, px2, 4, 0);
|
|
3528
|
+
if (tile) tiles.set(_chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty), tile);
|
|
3531
3529
|
}
|
|
3532
|
-
return new (0,
|
|
3530
|
+
return new (0, _chunkO7LUD7MHcjs.TiledSurface)(4, tiles, 0);
|
|
3533
3531
|
}
|
|
3534
3532
|
function rerenderShape(layer, env) {
|
|
3535
3533
|
return { ...layer, surface: renderShape(layer, env) };
|
|
@@ -3570,9 +3568,9 @@ function normalizeShapePaint(v, path = "paint") {
|
|
|
3570
3568
|
offset: _nullishCoalesce(g.offset, () => ( { x: 0, y: 0 }))
|
|
3571
3569
|
};
|
|
3572
3570
|
try {
|
|
3573
|
-
|
|
3571
|
+
_chunkAEAAN4ADcjs.validateEffectGradient.call(void 0, gradient, `${path}.gradient`);
|
|
3574
3572
|
} catch (e) {
|
|
3575
|
-
if (e instanceof
|
|
3573
|
+
if (e instanceof _chunkAEAAN4ADcjs.LayerEffectError) fail2(e.message);
|
|
3576
3574
|
throw e;
|
|
3577
3575
|
}
|
|
3578
3576
|
if (gradient.stops.length < 1) fail2(`${path}.gradient.stops needs at least one { position, color }.`);
|
|
@@ -3642,7 +3640,7 @@ function matrixArg(v, path) {
|
|
|
3642
3640
|
if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
|
|
3643
3641
|
const m = v;
|
|
3644
3642
|
if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
|
|
3645
|
-
return
|
|
3643
|
+
return _chunk5OOIUXNJcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
|
|
3646
3644
|
}
|
|
3647
3645
|
function normalizeLiveShape(v, path = "shape") {
|
|
3648
3646
|
if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
|
|
@@ -3703,7 +3701,7 @@ function normalizeSubpaths(v, path = "subpaths") {
|
|
|
3703
3701
|
if (typeof v === "string") {
|
|
3704
3702
|
let subs;
|
|
3705
3703
|
try {
|
|
3706
|
-
subs =
|
|
3704
|
+
subs = _chunk5OOIUXNJcjs.bezierToSubpaths.call(void 0, v);
|
|
3707
3705
|
} catch (e5) {
|
|
3708
3706
|
return fail2(`${path}: could not read the SVG path data.`);
|
|
3709
3707
|
}
|
|
@@ -3753,7 +3751,7 @@ function createShapeLayer(init, env, id = newLayerId()) {
|
|
|
3753
3751
|
components: init.components,
|
|
3754
3752
|
fill: init.fill === void 0 ? null : init.fill,
|
|
3755
3753
|
stroke: _nullishCoalesce(init.stroke, () => ( null)),
|
|
3756
|
-
surface:
|
|
3754
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
3757
3755
|
offset: { x: 0, y: 0 }
|
|
3758
3756
|
};
|
|
3759
3757
|
if (init.fillRule && init.fillRule !== "nonzero") layer.fillRule = init.fillRule;
|
|
@@ -3784,20 +3782,20 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
|
|
|
3784
3782
|
if (!("annotation" in patch)) delete next.annotation;
|
|
3785
3783
|
if (!next.components.length) fail2("A shape needs at least one component; delete the layer instead.");
|
|
3786
3784
|
const rendered = rerenderShape(next, env);
|
|
3787
|
-
return { layers:
|
|
3785
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
3788
3786
|
}
|
|
3789
3787
|
function transformShapeComponents(components, f, affine) {
|
|
3790
3788
|
return components.map((c) => {
|
|
3791
3789
|
if (affine && c.live) {
|
|
3792
|
-
const live = { ...c.live, transform:
|
|
3793
|
-
if (
|
|
3790
|
+
const live = { ...c.live, transform: _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunk5OOIUXNJcjs.IDENTITY_MATRIX)), affine) };
|
|
3791
|
+
if (_chunk5OOIUXNJcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
|
|
3794
3792
|
return { op: c.op, subpaths: liveShapeSubpaths(live), live };
|
|
3795
3793
|
}
|
|
3796
3794
|
return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
|
|
3797
3795
|
});
|
|
3798
3796
|
}
|
|
3799
3797
|
function offsetShape(layer, dx, dy, env) {
|
|
3800
|
-
const m =
|
|
3798
|
+
const m = _chunk5OOIUXNJcjs.translateMatrix.call(void 0, dx, dy);
|
|
3801
3799
|
const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
|
|
3802
3800
|
delete next.annotation;
|
|
3803
3801
|
return rerenderShape(next, env);
|
|
@@ -3805,7 +3803,7 @@ function offsetShape(layer, dx, dy, env) {
|
|
|
3805
3803
|
function mergeShapeComponents(components, fillRule = "nonzero") {
|
|
3806
3804
|
if (components.length < 2) return [...components];
|
|
3807
3805
|
const path = shapeOutline(components, fillRule);
|
|
3808
|
-
const subpaths =
|
|
3806
|
+
const subpaths = _chunk5OOIUXNJcjs.bezierToSubpaths.call(void 0, path);
|
|
3809
3807
|
if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
|
|
3810
3808
|
return [{ op: "combine", subpaths }];
|
|
3811
3809
|
}
|
|
@@ -3815,14 +3813,14 @@ function shapeAsPixelLayer(layer) {
|
|
|
3815
3813
|
}
|
|
3816
3814
|
function annotationPaint(color, opacity) {
|
|
3817
3815
|
const c = _chunk2YQONY6Gcjs.parseCssColor.call(void 0, color);
|
|
3818
|
-
if (!c || !
|
|
3816
|
+
if (!c || !_chunkAEAAN4ADcjs.parseEffectColor.call(void 0, c.hex)) return void 0;
|
|
3819
3817
|
const a = c.alpha * opacity;
|
|
3820
3818
|
return a !== 1 ? { type: "color", color: c.hex, opacity: a } : { type: "color", color: c.hex };
|
|
3821
3819
|
}
|
|
3822
3820
|
function shapeFromAnnotation(a) {
|
|
3823
3821
|
const opacity = _nullishCoalesce(a.opacity, () => ( 1));
|
|
3824
3822
|
const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
|
|
3825
|
-
const rotation = a.rotation ?
|
|
3823
|
+
const rotation = a.rotation ? _chunk5OOIUXNJcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
|
|
3826
3824
|
const t = rotation ? { transform: rotation } : {};
|
|
3827
3825
|
const live = (l) => liveComponent(l);
|
|
3828
3826
|
switch (a.type) {
|
|
@@ -3865,7 +3863,7 @@ function shapeFromAnnotation(a) {
|
|
|
3865
3863
|
case "pen": {
|
|
3866
3864
|
const paint = annotationPaint(a.strokeColor, opacity);
|
|
3867
3865
|
if (!paint) return null;
|
|
3868
|
-
const pts = rotation ? a.points.map((p) =>
|
|
3866
|
+
const pts = rotation ? a.points.map((p) => _chunk5OOIUXNJcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
|
|
3869
3867
|
const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
|
|
3870
3868
|
return {
|
|
3871
3869
|
components: [{ op: "combine", subpaths }],
|
|
@@ -3879,7 +3877,7 @@ function shapeFromAnnotation(a) {
|
|
|
3879
3877
|
}
|
|
3880
3878
|
function annotationBlend(a, layerBlend) {
|
|
3881
3879
|
if (layerBlend !== "normal") return layerBlend;
|
|
3882
|
-
return a.blend &&
|
|
3880
|
+
return a.blend && _chunkO7LUD7MHcjs.isBlendMode.call(void 0, a.blend) ? a.blend : "normal";
|
|
3883
3881
|
}
|
|
3884
3882
|
function annotationOfShape(layer) {
|
|
3885
3883
|
const a = layer.annotation;
|
|
@@ -3896,9 +3894,9 @@ function annotationOfShape(layer) {
|
|
|
3896
3894
|
var fail3 = (message) => {
|
|
3897
3895
|
throw new LayerOperationError(message);
|
|
3898
3896
|
};
|
|
3899
|
-
var TEXT_RENDER_MARGIN =
|
|
3897
|
+
var TEXT_RENDER_MARGIN = _chunkAEAAN4ADcjs.MAX_EFFECT_REACH;
|
|
3900
3898
|
function textMatrix(layer) {
|
|
3901
|
-
return _nullishCoalesce(layer.transform, () => (
|
|
3899
|
+
return _nullishCoalesce(layer.transform, () => ( _chunk5OOIUXNJcjs.IDENTITY_MATRIX));
|
|
3902
3900
|
}
|
|
3903
3901
|
function rectCorners(r) {
|
|
3904
3902
|
return [
|
|
@@ -3909,7 +3907,7 @@ function rectCorners(r) {
|
|
|
3909
3907
|
];
|
|
3910
3908
|
}
|
|
3911
3909
|
function docRect(r, m) {
|
|
3912
|
-
const pts = rectCorners(r).map((p) =>
|
|
3910
|
+
const pts = rectCorners(r).map((p) => _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, p));
|
|
3913
3911
|
const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
|
|
3914
3912
|
const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
|
|
3915
3913
|
const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
|
|
@@ -3942,14 +3940,14 @@ function inkBounds(layout) {
|
|
|
3942
3940
|
}
|
|
3943
3941
|
function textOutlines(layer, shaper) {
|
|
3944
3942
|
if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
|
|
3945
|
-
const layout =
|
|
3943
|
+
const layout = _chunk5OOIUXNJcjs.layoutText.call(void 0, layer, shaper);
|
|
3946
3944
|
const m = textMatrix(layer);
|
|
3947
3945
|
const out = [];
|
|
3948
3946
|
for (const l of layout.lines) {
|
|
3949
3947
|
for (const f of l.fragments) {
|
|
3950
|
-
let path =
|
|
3951
|
-
for (const r of
|
|
3952
|
-
out.push({ fragment: f, path:
|
|
3948
|
+
let path = _chunk5OOIUXNJcjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
|
|
3949
|
+
for (const r of _chunk5OOIUXNJcjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunk5OOIUXNJcjs.textRectPath.call(void 0, r)];
|
|
3950
|
+
out.push({ fragment: f, path: _chunk5OOIUXNJcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkBJTCSLF6cjs.transformBezierPath.call(void 0, path, m) });
|
|
3953
3951
|
}
|
|
3954
3952
|
}
|
|
3955
3953
|
return out;
|
|
@@ -3962,9 +3960,9 @@ var rgbOf = (hex) => {
|
|
|
3962
3960
|
function renderOutlines(layer, shaper, region) {
|
|
3963
3961
|
const parts = textOutlines(layer, shaper).map(({ fragment, path }) => ({ style: fragment.style, flat: flattenPath(path) }));
|
|
3964
3962
|
const tiles = /* @__PURE__ */ new Map();
|
|
3965
|
-
for (const { tx, ty } of
|
|
3966
|
-
const rect = { x: tx *
|
|
3967
|
-
const n =
|
|
3963
|
+
for (const { tx, ty } of _chunkO7LUD7MHcjs.tilesInRect.call(void 0, region)) {
|
|
3964
|
+
const rect = { x: tx * _chunkO7LUD7MHcjs.TILE, y: ty * _chunkO7LUD7MHcjs.TILE, width: _chunkO7LUD7MHcjs.TILE, height: _chunkO7LUD7MHcjs.TILE };
|
|
3965
|
+
const n = _chunkO7LUD7MHcjs.TILE * _chunkO7LUD7MHcjs.TILE;
|
|
3968
3966
|
const acc = new Float32Array(n * 4);
|
|
3969
3967
|
let any = false;
|
|
3970
3968
|
for (const p of parts) {
|
|
@@ -3995,17 +3993,17 @@ function renderOutlines(layer, shaper, region) {
|
|
|
3995
3993
|
px2[i + 2] = Math.round(acc[i + 2]);
|
|
3996
3994
|
px2[i + 3] = a;
|
|
3997
3995
|
}
|
|
3998
|
-
const tile =
|
|
3999
|
-
if (tile) tiles.set(
|
|
3996
|
+
const tile = _chunkO7LUD7MHcjs.finishTile.call(void 0, px2, 4, 0);
|
|
3997
|
+
if (tile) tiles.set(_chunkO7LUD7MHcjs.tileKey.call(void 0, tx, ty), tile);
|
|
4000
3998
|
}
|
|
4001
|
-
return new (0,
|
|
3999
|
+
return new (0, _chunkO7LUD7MHcjs.TiledSurface)(4, tiles, 0);
|
|
4002
4000
|
}
|
|
4003
4001
|
function renderOnCanvas(layer, shaper, region, env) {
|
|
4004
4002
|
if (!env.createCanvas) return null;
|
|
4005
4003
|
const canvas = env.createCanvas(region.width, region.height);
|
|
4006
4004
|
const ctx = canvas.getContext("2d");
|
|
4007
4005
|
if (!ctx || typeof ctx.getImageData !== "function") return null;
|
|
4008
|
-
const layout =
|
|
4006
|
+
const layout = _chunk5OOIUXNJcjs.layoutText.call(void 0, layer, shaper);
|
|
4009
4007
|
const m = textMatrix(layer);
|
|
4010
4008
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4011
4009
|
ctx.clearRect(0, 0, region.width, region.height);
|
|
@@ -4017,23 +4015,23 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4017
4015
|
ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
|
|
4018
4016
|
const s = layer.text.slice(f.start, f.end);
|
|
4019
4017
|
if (!f.spaced) shaper.draw(ctx, s, f.font, f.x, f.y);
|
|
4020
|
-
else for (let k = 0; k < s.length; k++) if (!
|
|
4021
|
-
for (const d of
|
|
4018
|
+
else for (let k = 0; k < s.length; k++) if (!_chunk5OOIUXNJcjs.isTextSpace.call(void 0, s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
|
|
4019
|
+
for (const d of _chunk5OOIUXNJcjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
|
|
4022
4020
|
}
|
|
4023
4021
|
}
|
|
4024
4022
|
ctx.globalAlpha = 1;
|
|
4025
4023
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4026
4024
|
const data = ctx.getImageData(0, 0, region.width, region.height).data;
|
|
4027
|
-
return
|
|
4025
|
+
return _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width: region.width, height: region.height, data: new Uint8ClampedArray(data) }, 4, region.x, region.y);
|
|
4028
4026
|
}
|
|
4029
4027
|
function renderText(layer, env) {
|
|
4030
4028
|
const shaper = env.shaper;
|
|
4031
4029
|
if (!shaper || !shaper.outline && !shaper.draw) return null;
|
|
4032
|
-
const layout =
|
|
4030
|
+
const layout = _chunk5OOIUXNJcjs.layoutText.call(void 0, layer, shaper);
|
|
4033
4031
|
const ink = inkBounds(layout);
|
|
4034
4032
|
const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
|
|
4035
4033
|
const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
|
|
4036
|
-
if (!region) return { surface:
|
|
4034
|
+
if (!region) return { surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4), missingFonts: layout.missingFonts };
|
|
4037
4035
|
if (shaper.outline) return { surface: renderOutlines(layer, shaper, region), missingFonts: layout.missingFonts };
|
|
4038
4036
|
const surface = renderOnCanvas(layer, shaper, region, env);
|
|
4039
4037
|
return surface ? { surface, missingFonts: layout.missingFonts } : null;
|
|
@@ -4124,7 +4122,7 @@ function patchParagraphStyle(base, patch, path = "paragraph") {
|
|
|
4124
4122
|
continue;
|
|
4125
4123
|
}
|
|
4126
4124
|
const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
|
|
4127
|
-
if (k === "autoLeading" && value ===
|
|
4125
|
+
if (k === "autoLeading" && value === _chunk5OOIUXNJcjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
|
|
4128
4126
|
else o[k] = value;
|
|
4129
4127
|
} else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
|
|
4130
4128
|
}
|
|
@@ -4161,14 +4159,14 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
|
|
|
4161
4159
|
opacity: 1,
|
|
4162
4160
|
blend: "normal",
|
|
4163
4161
|
text: text3,
|
|
4164
|
-
runs:
|
|
4165
|
-
paragraphs:
|
|
4162
|
+
runs: _chunk5OOIUXNJcjs.fitRuns.call(void 0, init.runs, text3.length, _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE),
|
|
4163
|
+
paragraphs: _chunk5OOIUXNJcjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
|
|
4166
4164
|
frame: init.frame,
|
|
4167
|
-
surface:
|
|
4165
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
4168
4166
|
offset: { x: 0, y: 0 }
|
|
4169
4167
|
};
|
|
4170
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _61 => _61.runs, 'access', _62 => _62[0], 'optionalAccess', _63 => _63.style]), () => (
|
|
4171
|
-
if (init.transform && !
|
|
4168
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _61 => _61.runs, 'access', _62 => _62[0], 'optionalAccess', _63 => _63.style]), () => ( _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE)) }];
|
|
4169
|
+
if (init.transform && !_chunk5OOIUXNJcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
|
|
4172
4170
|
if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
|
|
4173
4171
|
return rerenderText(layer, env);
|
|
4174
4172
|
}
|
|
@@ -4178,24 +4176,24 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
|
|
|
4178
4176
|
const patch = change(current);
|
|
4179
4177
|
const next = { ...current, ...patch };
|
|
4180
4178
|
if (!("annotation" in patch)) delete next.annotation;
|
|
4181
|
-
if ("text" in patch || "runs" in patch) next.runs =
|
|
4182
|
-
if (!next.runs.length) next.runs = [{ length: 0, style:
|
|
4183
|
-
if ("text" in patch || "paragraphs" in patch) next.paragraphs =
|
|
4179
|
+
if ("text" in patch || "runs" in patch) next.runs = _chunk5OOIUXNJcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _64 => _64.runs, 'access', _65 => _65[0], 'optionalAccess', _66 => _66.style]), () => ( _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE)));
|
|
4180
|
+
if (!next.runs.length) next.runs = [{ length: 0, style: _chunk5OOIUXNJcjs.styleAt.call(void 0, current.runs, 0, _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE) }];
|
|
4181
|
+
if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunk5OOIUXNJcjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
|
|
4184
4182
|
const rendered = rerenderText(next, env);
|
|
4185
|
-
return { layers:
|
|
4183
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
4186
4184
|
}
|
|
4187
4185
|
function replaceTextRange(layer, start, end, insert) {
|
|
4188
4186
|
const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
|
|
4189
|
-
const style =
|
|
4190
|
-
const runs =
|
|
4191
|
-
const pstyle =
|
|
4192
|
-
const paragraphs =
|
|
4193
|
-
return { text: text3, runs, paragraphs:
|
|
4187
|
+
const style = _chunk5OOIUXNJcjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE);
|
|
4188
|
+
const runs = _chunk5OOIUXNJcjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
|
|
4189
|
+
const pstyle = _chunk5OOIUXNJcjs.styleAt.call(void 0, layer.paragraphs, start, {});
|
|
4190
|
+
const paragraphs = _chunk5OOIUXNJcjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
|
|
4191
|
+
return { text: text3, runs, paragraphs: _chunk5OOIUXNJcjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
|
|
4194
4192
|
}
|
|
4195
4193
|
function transformTypeLayer(layer, m) {
|
|
4196
|
-
const t =
|
|
4194
|
+
const t = _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
|
|
4197
4195
|
const next = { ...layer };
|
|
4198
|
-
if (
|
|
4196
|
+
if (_chunk5OOIUXNJcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
|
|
4199
4197
|
else next.transform = t;
|
|
4200
4198
|
delete next.annotation;
|
|
4201
4199
|
return next;
|
|
@@ -4203,7 +4201,7 @@ function transformTypeLayer(layer, m) {
|
|
|
4203
4201
|
function typeFrame(layer, shaper) {
|
|
4204
4202
|
if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
|
|
4205
4203
|
if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
|
|
4206
|
-
const b =
|
|
4204
|
+
const b = _chunk5OOIUXNJcjs.layoutText.call(void 0, layer, shaper).bounds;
|
|
4207
4205
|
return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
|
|
4208
4206
|
}
|
|
4209
4207
|
function typeAsPixelLayer(layer) {
|
|
@@ -4211,7 +4209,7 @@ function typeAsPixelLayer(layer) {
|
|
|
4211
4209
|
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
4212
4210
|
}
|
|
4213
4211
|
function toTextSpace(layer, p) {
|
|
4214
|
-
return
|
|
4212
|
+
return _chunk5OOIUXNJcjs.applyMatrix.call(void 0, _chunk5OOIUXNJcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
|
|
4215
4213
|
}
|
|
4216
4214
|
function typeFromAnnotation(a) {
|
|
4217
4215
|
if (a.type !== "text") return null;
|
|
@@ -4225,7 +4223,7 @@ function typeFromAnnotation(a) {
|
|
|
4225
4223
|
if (op !== 1) style.opacity = op;
|
|
4226
4224
|
const text3 = t.text.replace(/\r?\n|\r/g, " ");
|
|
4227
4225
|
const translate = [1, 0, 0, 1, t.x, t.y];
|
|
4228
|
-
const transform = t.rotation ?
|
|
4226
|
+
const transform = t.rotation ? _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, translate, _chunk5OOIUXNJcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
|
|
4229
4227
|
return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
|
|
4230
4228
|
}
|
|
4231
4229
|
function annotationOfType(layer) {
|
|
@@ -4274,7 +4272,7 @@ function rasterMaskFromLegacy(mask, width, height) {
|
|
|
4274
4272
|
const sel = decodeLayerMask(mask);
|
|
4275
4273
|
if (!sel) return null;
|
|
4276
4274
|
const sized = sel.width === width && sel.height === height ? sel : resizeSelection(sel, width, height);
|
|
4277
|
-
const surface =
|
|
4275
|
+
const surface = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width, height, data: sized.data }, 1, 0, 0, 0);
|
|
4278
4276
|
legacyMaskMemo.set(surface, { width: mask.width, height: mask.height, rle: mask.rle });
|
|
4279
4277
|
const out = { surface, defaultValue: 0 };
|
|
4280
4278
|
if (mask.density !== void 0 && mask.density !== 1) out.density = mask.density;
|
|
@@ -4293,7 +4291,7 @@ function hasResampledLegacyMask(layers, width, height) {
|
|
|
4293
4291
|
function legacyMaskOf(mask, width, height) {
|
|
4294
4292
|
let memo = legacyMaskMemo.get(mask.surface);
|
|
4295
4293
|
if (!memo) {
|
|
4296
|
-
const data =
|
|
4294
|
+
const data = _chunkO7LUD7MHcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width, height });
|
|
4297
4295
|
memo = { width, height, rle: encodeSelectionRle(new Uint8Array(data.buffer, data.byteOffset, data.length)) };
|
|
4298
4296
|
legacyMaskMemo.set(mask.surface, memo);
|
|
4299
4297
|
}
|
|
@@ -4395,7 +4393,7 @@ function backgroundLayer(filters = [], mask) {
|
|
|
4395
4393
|
visible: true,
|
|
4396
4394
|
opacity: 1,
|
|
4397
4395
|
blend: "normal",
|
|
4398
|
-
surface:
|
|
4396
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
4399
4397
|
offset: { x: 0, y: 0 },
|
|
4400
4398
|
source: "document",
|
|
4401
4399
|
filters
|
|
@@ -4405,7 +4403,7 @@ function backgroundLayer(filters = [], mask) {
|
|
|
4405
4403
|
}
|
|
4406
4404
|
function depthRasterMask(source) {
|
|
4407
4405
|
const out = {
|
|
4408
|
-
surface:
|
|
4406
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 1, 255),
|
|
4409
4407
|
defaultValue: 255,
|
|
4410
4408
|
source: { ...source, depthRange: [...source.depthRange] }
|
|
4411
4409
|
};
|
|
@@ -4559,7 +4557,7 @@ function identityTransform(box2) {
|
|
|
4559
4557
|
}
|
|
4560
4558
|
function cornersFromMatrix(box2, m) {
|
|
4561
4559
|
const q2 = _chunkMUUXNRU4cjs.boxQuad.call(void 0, box2);
|
|
4562
|
-
return [
|
|
4560
|
+
return [_chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[0]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[1]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[2]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4563
4561
|
}
|
|
4564
4562
|
function matrixFromCorners(box2, corners, eps = 1e-6) {
|
|
4565
4563
|
const [tl, tr, br, bl] = corners;
|
|
@@ -4576,7 +4574,7 @@ function transformHomography(geometry) {
|
|
|
4576
4574
|
function hasWarp(geometry) {
|
|
4577
4575
|
const w = geometry.warp;
|
|
4578
4576
|
if (!w) return false;
|
|
4579
|
-
const id =
|
|
4577
|
+
const id = _chunk5OOIUXNJcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
|
|
4580
4578
|
if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
|
|
4581
4579
|
return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
|
|
4582
4580
|
}
|
|
@@ -4591,7 +4589,7 @@ function transformMap(geometry) {
|
|
|
4591
4589
|
const { box: box2 } = geometry;
|
|
4592
4590
|
const warp = hasWarp(geometry) ? geometry.warp : null;
|
|
4593
4591
|
if (!warp) return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, p);
|
|
4594
|
-
return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h,
|
|
4592
|
+
return (p) => _chunkMUUXNRU4cjs.applyHomography.call(void 0, h, _chunk5OOIUXNJcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
|
|
4595
4593
|
}
|
|
4596
4594
|
function transformedPoint(geometry, fx, fy) {
|
|
4597
4595
|
const f = transformMap(geometry);
|
|
@@ -4635,8 +4633,8 @@ function matrixFromParams(box2, params) {
|
|
|
4635
4633
|
const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
|
|
4636
4634
|
const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
|
|
4637
4635
|
const ref = referencePoint(box2, params.reference);
|
|
4638
|
-
const linear =
|
|
4639
|
-
return
|
|
4636
|
+
const linear = _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunk5OOIUXNJcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
|
|
4637
|
+
return _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, _chunk5OOIUXNJcjs.matrixAbout.call(void 0, linear, ref), _chunk5OOIUXNJcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
|
|
4640
4638
|
}
|
|
4641
4639
|
function describeTransform(geometry, reference = "center") {
|
|
4642
4640
|
const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4653,7 +4651,7 @@ function describeTransform(geometry, reference = "center") {
|
|
|
4653
4651
|
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
4654
4652
|
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
4655
4653
|
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
4656
|
-
const at =
|
|
4654
|
+
const at = _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, ref);
|
|
4657
4655
|
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
4658
4656
|
return {
|
|
4659
4657
|
affine: true,
|
|
@@ -4671,24 +4669,24 @@ function applyParams(geometry, params) {
|
|
|
4671
4669
|
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
4672
4670
|
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
4673
4671
|
const c = geometry.corners;
|
|
4674
|
-
return [
|
|
4672
|
+
return [_chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, c[0]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, c[1]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, c[2]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, c[3])];
|
|
4675
4673
|
}
|
|
4676
4674
|
function flipCorners(geometry, axis) {
|
|
4677
4675
|
const c = anchorPoint(geometry, "center");
|
|
4678
4676
|
const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
|
|
4679
4677
|
const q2 = geometry.corners;
|
|
4680
|
-
return [
|
|
4678
|
+
return [_chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[0]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[1]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[2]), _chunk5OOIUXNJcjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4681
4679
|
}
|
|
4682
4680
|
function boxPointOf(geometry, p) {
|
|
4683
4681
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
4684
|
-
if (m) return
|
|
4682
|
+
if (m) return _chunk5OOIUXNJcjs.applyMatrix.call(void 0, _chunk5OOIUXNJcjs.invertMatrix.call(void 0, m), p);
|
|
4685
4683
|
return null;
|
|
4686
4684
|
}
|
|
4687
4685
|
function presetWarp(box2, preset) {
|
|
4688
|
-
return
|
|
4686
|
+
return _chunk5OOIUXNJcjs.warpPresetMesh.call(void 0, preset, box2);
|
|
4689
4687
|
}
|
|
4690
4688
|
function isValidWarp(mesh) {
|
|
4691
|
-
return
|
|
4689
|
+
return _chunk5OOIUXNJcjs.isValidWarpMesh.call(void 0, mesh);
|
|
4692
4690
|
}
|
|
4693
4691
|
function geometryHomography(geometry) {
|
|
4694
4692
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4699,7 +4697,7 @@ function geometryHomography(geometry) {
|
|
|
4699
4697
|
var fail4 = (message) => {
|
|
4700
4698
|
throw new LayerOperationError(message);
|
|
4701
4699
|
};
|
|
4702
|
-
var SMART_RENDER_MARGIN =
|
|
4700
|
+
var SMART_RENDER_MARGIN = _chunkAEAAN4ADcjs.MAX_EFFECT_REACH;
|
|
4703
4701
|
var incompleteSurfaces = /* @__PURE__ */ new WeakSet();
|
|
4704
4702
|
var isSmartSurfaceIncomplete = (surface) => incompleteSurfaces.has(surface);
|
|
4705
4703
|
var surfaceIds = /* @__PURE__ */ new WeakMap();
|
|
@@ -4741,10 +4739,10 @@ function contentsSurface(contents) {
|
|
|
4741
4739
|
let s = contentsPixels.get(contents);
|
|
4742
4740
|
if (s) return s;
|
|
4743
4741
|
if (contents.kind === "raster") {
|
|
4744
|
-
s = _nullishCoalesce(contents.raster, () => (
|
|
4742
|
+
s = _nullishCoalesce(contents.raster, () => ( _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4)));
|
|
4745
4743
|
} else {
|
|
4746
4744
|
const doc = contents.document;
|
|
4747
|
-
if (!doc) return
|
|
4745
|
+
if (!doc) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
4748
4746
|
const W = contents.width;
|
|
4749
4747
|
const H = contents.height;
|
|
4750
4748
|
const data = new LayerCompositor().composite(doc.layers, { x: 0, y: 0, width: W, height: H }, {
|
|
@@ -4753,14 +4751,14 @@ function contentsSurface(contents) {
|
|
|
4753
4751
|
globalLight: doc.globalLight,
|
|
4754
4752
|
pattern: (id) => _nullishCoalesce(_optionalChain([doc, 'access', _76 => _76.patterns, 'optionalAccess', _77 => _77.find, 'call', _78 => _78((p) => p.id === id)]), () => ( null))
|
|
4755
4753
|
});
|
|
4756
|
-
s =
|
|
4754
|
+
s = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data }, 4, 0, 0);
|
|
4757
4755
|
}
|
|
4758
4756
|
contentsPixels.set(contents, s);
|
|
4759
4757
|
return s;
|
|
4760
4758
|
}
|
|
4761
4759
|
function rasterContents(pixels, name, id = newContentsId()) {
|
|
4762
4760
|
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.");
|
|
4763
|
-
return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster:
|
|
4761
|
+
return { id, name, width: pixels.width, height: pixels.height, kind: "raster", raster: _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, pixels, 4, 0, 0) };
|
|
4764
4762
|
}
|
|
4765
4763
|
function documentContents(document, width, height, name, id = newContentsId()) {
|
|
4766
4764
|
if (!(Number.isInteger(width) && Number.isInteger(height) && width > 0 && height > 0)) fail4("Contents width and height must be positive whole numbers.");
|
|
@@ -4804,7 +4802,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4804
4802
|
let out;
|
|
4805
4803
|
const move = integerMove(layer);
|
|
4806
4804
|
if (move && !options.clip) {
|
|
4807
|
-
out =
|
|
4805
|
+
out = _chunkO7LUD7MHcjs.translateSurface.call(void 0, src, move.x, move.y);
|
|
4808
4806
|
} else {
|
|
4809
4807
|
const g = placementGeometry(layer);
|
|
4810
4808
|
const interpolation = preview ? placement.interpolation === "nearest" ? "nearest" : "bilinear" : _nullishCoalesce(placement.interpolation, () => ( "bicubic"));
|
|
@@ -4815,7 +4813,7 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4815
4813
|
k = step;
|
|
4816
4814
|
let r = _optionalChain([options, 'access', _83 => _83.reduced, 'optionalAccess', _84 => _84.get, 'call', _85 => _85(k)]);
|
|
4817
4815
|
if (!r) {
|
|
4818
|
-
r =
|
|
4816
|
+
r = _chunkAEAAN4ADcjs.reduceSurface.call(void 0, src, k);
|
|
4819
4817
|
_optionalChain([options, 'access', _86 => _86.reduced, 'optionalAccess', _87 => _87.set, 'call', _88 => _88(k, r)]);
|
|
4820
4818
|
}
|
|
4821
4819
|
source = r;
|
|
@@ -4825,15 +4823,15 @@ function placeContents(layer, canvas, options = {}) {
|
|
|
4825
4823
|
if (hasWarp(g)) {
|
|
4826
4824
|
const f = transformMap(g);
|
|
4827
4825
|
if (!f) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4828
|
-
out =
|
|
4826
|
+
out = _chunkAEAAN4ADcjs.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 });
|
|
4829
4827
|
} else {
|
|
4830
4828
|
const h = transformHomography(g);
|
|
4831
4829
|
if (!h) fail4("The placement folds the contents over itself or through the horizon; keep the corners a convex quad.");
|
|
4832
4830
|
const hk = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, [k, 0, 0, 0, k, 0, 0, 0, 1], h);
|
|
4833
|
-
out =
|
|
4831
|
+
out = _chunkAEAAN4ADcjs.transformSurface.call(void 0, source, hk, { interpolation, source: box2, clip, step: step > 1 ? step : void 0 });
|
|
4834
4832
|
}
|
|
4835
4833
|
} catch (e) {
|
|
4836
|
-
if (e instanceof
|
|
4834
|
+
if (e instanceof _chunkAEAAN4ADcjs.TransformTooLargeError) fail4(e.message);
|
|
4837
4835
|
throw e;
|
|
4838
4836
|
}
|
|
4839
4837
|
}
|
|
@@ -4864,7 +4862,7 @@ function filterMaskCoverage(mask, canvas) {
|
|
|
4864
4862
|
if (!mask || mask.enabled === false || mask.source) return null;
|
|
4865
4863
|
const W = canvas.width;
|
|
4866
4864
|
const H = canvas.height;
|
|
4867
|
-
const bytes =
|
|
4865
|
+
const bytes = _chunkO7LUD7MHcjs.readRegion.call(void 0, mask.surface, { x: 0, y: 0, width: W, height: H });
|
|
4868
4866
|
let v = new Float32Array(W * H);
|
|
4869
4867
|
let all = true;
|
|
4870
4868
|
for (let i = 0; i < v.length; i++) {
|
|
@@ -4873,7 +4871,7 @@ function filterMaskCoverage(mask, canvas) {
|
|
|
4873
4871
|
}
|
|
4874
4872
|
const feather = _nullishCoalesce(mask.feather, () => ( 0));
|
|
4875
4873
|
if (all && !(feather > 0)) return null;
|
|
4876
|
-
if (feather > 0) v =
|
|
4874
|
+
if (feather > 0) v = _chunkAEAAN4ADcjs.gaussianBlur.call(void 0, v, W, H, feather, "clamp");
|
|
4877
4875
|
const density = _nullishCoalesce(mask.density, () => ( 1));
|
|
4878
4876
|
if (density !== 1) for (let i = 0; i < v.length; i++) v[i] = 1 - density * (1 - v[i]);
|
|
4879
4877
|
return v;
|
|
@@ -4888,7 +4886,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
4888
4886
|
let entry = filteredCache.get(placed);
|
|
4889
4887
|
let incomplete = false;
|
|
4890
4888
|
if (!entry || entry.key !== key) {
|
|
4891
|
-
const base =
|
|
4889
|
+
const base = _chunkO7LUD7MHcjs.readRegion.call(void 0, placed, { x: 0, y: 0, width: W, height: H });
|
|
4892
4890
|
let acc = new Uint8ClampedArray(base);
|
|
4893
4891
|
for (const [i, f] of active.entries()) {
|
|
4894
4892
|
let out2;
|
|
@@ -4909,7 +4907,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
4909
4907
|
if (f.opacity >= 1) acc = out2;
|
|
4910
4908
|
else lerpInto(acc, out2, f.opacity, null);
|
|
4911
4909
|
} else {
|
|
4912
|
-
|
|
4910
|
+
_chunkAEAAN4ADcjs.blendTile.call(void 0, acc, out2, f.blend, f.opacity, null);
|
|
4913
4911
|
}
|
|
4914
4912
|
}
|
|
4915
4913
|
entry = { key, base, filtered: acc };
|
|
@@ -4921,7 +4919,7 @@ function applySmartFilters(placed, stack, canvas) {
|
|
|
4921
4919
|
result = new Uint8ClampedArray(entry.base);
|
|
4922
4920
|
lerpInto(result, entry.filtered, 1, cov);
|
|
4923
4921
|
}
|
|
4924
|
-
const out =
|
|
4922
|
+
const out = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width: W, height: H, data: result }, 4, 0, 0);
|
|
4925
4923
|
if (incomplete) incompleteSurfaces.add(out);
|
|
4926
4924
|
return out;
|
|
4927
4925
|
}
|
|
@@ -4954,11 +4952,11 @@ function normalizePlacement(raw, contents) {
|
|
|
4954
4952
|
}
|
|
4955
4953
|
const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
|
|
4956
4954
|
if (raw.warp) {
|
|
4957
|
-
if (!
|
|
4955
|
+
if (!_chunk5OOIUXNJcjs.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.");
|
|
4958
4956
|
out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
4959
4957
|
}
|
|
4960
4958
|
if (raw.interpolation !== void 0) {
|
|
4961
|
-
if (!
|
|
4959
|
+
if (!_chunkAEAAN4ADcjs.isInterpolation.call(void 0, raw.interpolation)) fail4(`Unknown interpolation "${String(raw.interpolation)}"; use nearest, bilinear or bicubic.`);
|
|
4962
4960
|
if (raw.interpolation !== "bicubic") out.interpolation = raw.interpolation;
|
|
4963
4961
|
}
|
|
4964
4962
|
const g = { box: { x: 0, y: 0, width: contents.width, height: contents.height }, corners: out.corners, warp: _nullishCoalesce(out.warp, () => ( null)) };
|
|
@@ -4978,7 +4976,7 @@ function followMask(mask, before, after) {
|
|
|
4978
4976
|
const inv = _chunkMUUXNRU4cjs.invertHomography.call(void 0, h0);
|
|
4979
4977
|
if (!inv) return mask;
|
|
4980
4978
|
const delta = _chunkMUUXNRU4cjs.multiplyHomographies.call(void 0, inv, h1);
|
|
4981
|
-
const surface =
|
|
4979
|
+
const surface = _chunkAEAAN4ADcjs.transformSurface.call(void 0, mask.surface, delta, { interpolation: "bilinear" });
|
|
4982
4980
|
return { ...mask, surface };
|
|
4983
4981
|
}
|
|
4984
4982
|
function setSmartPlacement(layers, id, placement, canvas) {
|
|
@@ -4999,7 +4997,7 @@ function setSmartPlacement(layers, id, placement, canvas) {
|
|
|
4999
4997
|
next.smartFilters = { ...next.smartFilters, mask: m };
|
|
5000
4998
|
}
|
|
5001
4999
|
next = rerender(next, canvas, "be transformed");
|
|
5002
|
-
return { layers:
|
|
5000
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, masksMoved };
|
|
5003
5001
|
}
|
|
5004
5002
|
function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
5005
5003
|
const layer = requireSmartObject(layers, id);
|
|
@@ -5009,26 +5007,26 @@ function offsetSmartObject(layers, id, dx, dy, canvas) {
|
|
|
5009
5007
|
if (!mx && !my) return layers;
|
|
5010
5008
|
const corners = layer.placement.corners.map((p) => ({ x: p.x + mx, y: p.y + my }));
|
|
5011
5009
|
let next = { ...layer, placement: { ...layer.placement, corners } };
|
|
5012
|
-
const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface:
|
|
5010
|
+
const moveMask = (m2) => m2 && m2.linked !== false && !m2.source ? { ...m2, surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, m2.surface, mx, my) } : m2;
|
|
5013
5011
|
if (layer.mask) next.mask = moveMask(layer.mask);
|
|
5014
5012
|
if (_optionalChain([layer, 'access', _102 => _102.smartFilters, 'optionalAccess', _103 => _103.mask])) next.smartFilters = { ...layer.smartFilters, mask: moveMask(layer.smartFilters.mask) };
|
|
5015
5013
|
const spatial = activeSmartFilters(layer.smartFilters).some((f) => f.kind === "blur") || activeEffectSmartFilters(layer.smartFilters).length > 0;
|
|
5016
|
-
const b =
|
|
5014
|
+
const b = _chunkO7LUD7MHcjs.contentBounds.call(void 0, layer.surface);
|
|
5017
5015
|
const m = SMART_RENDER_MARGIN;
|
|
5018
5016
|
const cut = b && (b.x <= -m || b.y <= -m || b.x + b.width >= canvas.width + m || b.y + b.height >= canvas.height + m);
|
|
5019
5017
|
if (!spatial && !cut && !(_optionalChain([next, 'access', _104 => _104.smartFilters, 'optionalAccess', _105 => _105.mask]) && activeSmartFilters(next.smartFilters).length && next.smartFilters.mask.linked === false)) {
|
|
5020
|
-
next = { ...next, surface:
|
|
5018
|
+
next = { ...next, surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, layer.surface, mx, my) };
|
|
5021
5019
|
} else {
|
|
5022
5020
|
next = rerender(next, canvas, "move");
|
|
5023
5021
|
}
|
|
5024
|
-
return
|
|
5022
|
+
return _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next);
|
|
5025
5023
|
}
|
|
5026
5024
|
function translateLayer(layer, dx, dy) {
|
|
5027
5025
|
if (!dx && !dy) return layer;
|
|
5028
5026
|
const moveMask = (m) => {
|
|
5029
5027
|
if (!m) return m;
|
|
5030
5028
|
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.`);
|
|
5031
|
-
return { ...m, surface:
|
|
5029
|
+
return { ...m, surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, m.surface, dx, dy) };
|
|
5032
5030
|
};
|
|
5033
5031
|
switch (layer.type) {
|
|
5034
5032
|
case "pixel":
|
|
@@ -5037,7 +5035,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5037
5035
|
const next = {
|
|
5038
5036
|
...layer,
|
|
5039
5037
|
placement: { ...layer.placement, corners: layer.placement.corners.map((p) => ({ x: p.x + dx, y: p.y + dy })) },
|
|
5040
|
-
surface:
|
|
5038
|
+
surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
5041
5039
|
mask: moveMask(layer.mask)
|
|
5042
5040
|
};
|
|
5043
5041
|
if (!next.mask) delete next.mask;
|
|
@@ -5057,8 +5055,8 @@ function translateLayer(layer, dx, dy) {
|
|
|
5057
5055
|
case "shape": {
|
|
5058
5056
|
const next = {
|
|
5059
5057
|
...layer,
|
|
5060
|
-
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }),
|
|
5061
|
-
surface:
|
|
5058
|
+
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunk5OOIUXNJcjs.translateMatrix.call(void 0, dx, dy)),
|
|
5059
|
+
surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
5062
5060
|
mask: moveMask(layer.mask)
|
|
5063
5061
|
};
|
|
5064
5062
|
if (!next.mask) delete next.mask;
|
|
@@ -5066,7 +5064,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5066
5064
|
return next;
|
|
5067
5065
|
}
|
|
5068
5066
|
case "type": {
|
|
5069
|
-
const next = { ...transformTypeLayer(layer,
|
|
5067
|
+
const next = { ...transformTypeLayer(layer, _chunk5OOIUXNJcjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
|
|
5070
5068
|
if (!next.mask) delete next.mask;
|
|
5071
5069
|
return next;
|
|
5072
5070
|
}
|
|
@@ -5081,7 +5079,7 @@ function layerExtent(layer, surfaceOf, canvas) {
|
|
|
5081
5079
|
const s = layer.type === "pixel" ? surfaceOf(layer) : layer.surface;
|
|
5082
5080
|
if (s.defaultValue !== 0) b = full;
|
|
5083
5081
|
else {
|
|
5084
|
-
const c =
|
|
5082
|
+
const c = _chunkO7LUD7MHcjs.contentBounds.call(void 0, s);
|
|
5085
5083
|
b = c ? { x: c.x + layer.offset.x, y: c.y + layer.offset.y, width: c.width, height: c.height } : null;
|
|
5086
5084
|
}
|
|
5087
5085
|
} else if (layer.type === "group") {
|
|
@@ -5089,7 +5087,7 @@ function layerExtent(layer, surfaceOf, canvas) {
|
|
|
5089
5087
|
} else {
|
|
5090
5088
|
b = full;
|
|
5091
5089
|
}
|
|
5092
|
-
const m =
|
|
5090
|
+
const m = _chunkAEAAN4ADcjs.effectsMargin.call(void 0, layer.effects);
|
|
5093
5091
|
if (b && m > 0) b = { x: b.x - Math.ceil(m), y: b.y - Math.ceil(m), width: b.width + 2 * Math.ceil(m), height: b.height + 2 * Math.ceil(m) };
|
|
5094
5092
|
return b;
|
|
5095
5093
|
}
|
|
@@ -5117,7 +5115,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5117
5115
|
if (single && single.type === "pixel") {
|
|
5118
5116
|
const surface = options.surfaceOf(single);
|
|
5119
5117
|
if (surface.defaultValue !== 0) fail4(`Layer "${single.name || single.id}" has no transparent area to crop to; it cannot be converted.`);
|
|
5120
|
-
const b =
|
|
5118
|
+
const b = _chunkO7LUD7MHcjs.contentBounds.call(void 0, surface);
|
|
5121
5119
|
if (!b) fail4(`Layer "${single.name || single.id}" has no pixels to convert; paint something first.`);
|
|
5122
5120
|
const contents = {
|
|
5123
5121
|
id: newContentsId(),
|
|
@@ -5125,7 +5123,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5125
5123
|
width: b.width,
|
|
5126
5124
|
height: b.height,
|
|
5127
5125
|
kind: "raster",
|
|
5128
|
-
raster:
|
|
5126
|
+
raster: _chunkO7LUD7MHcjs.translateSurface.call(void 0, surface, -b.x, -b.y)
|
|
5129
5127
|
};
|
|
5130
5128
|
smart = {
|
|
5131
5129
|
type: "smart",
|
|
@@ -5136,14 +5134,14 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5136
5134
|
blend: single.blend,
|
|
5137
5135
|
contents,
|
|
5138
5136
|
placement: placementAt(contents, b.x + single.offset.x, b.y + single.offset.y),
|
|
5139
|
-
surface:
|
|
5137
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
5140
5138
|
offset: { x: 0, y: 0 }
|
|
5141
5139
|
};
|
|
5142
5140
|
if (single.clipped) smart.clipped = true;
|
|
5143
5141
|
if (single.fillOpacity !== void 0) smart.fillOpacity = single.fillOpacity;
|
|
5144
5142
|
if (single.effects) smart.effects = single.effects;
|
|
5145
5143
|
if (single.mask) {
|
|
5146
|
-
smart.mask = single.mask.source ? single.mask : { ...single.mask, surface:
|
|
5144
|
+
smart.mask = single.mask.source ? single.mask : { ...single.mask, surface: _chunkO7LUD7MHcjs.translateSurface.call(void 0, single.mask.surface, single.offset.x, single.offset.y) };
|
|
5147
5145
|
}
|
|
5148
5146
|
const filters = asSmartFilters(single.filters);
|
|
5149
5147
|
if (filters) smart.smartFilters = filters;
|
|
@@ -5158,7 +5156,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5158
5156
|
delete resolved.source;
|
|
5159
5157
|
layer = resolved;
|
|
5160
5158
|
}
|
|
5161
|
-
if (
|
|
5159
|
+
if (_chunkAEAAN4ADcjs.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.`);
|
|
5162
5160
|
return translateLayer(layer, -b.x, -b.y);
|
|
5163
5161
|
});
|
|
5164
5162
|
if (nested[0].clipped) {
|
|
@@ -5177,7 +5175,7 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5177
5175
|
blend: "normal",
|
|
5178
5176
|
contents,
|
|
5179
5177
|
placement: placementAt(contents, b.x, b.y),
|
|
5180
|
-
surface:
|
|
5178
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
5181
5179
|
offset: { x: 0, y: 0 }
|
|
5182
5180
|
};
|
|
5183
5181
|
}
|
|
@@ -5185,8 +5183,8 @@ function convertToSmartObject(layers, ids, canvas, options) {
|
|
|
5185
5183
|
smart = { ...smart, surface: renderSmartObject(smart, canvas) };
|
|
5186
5184
|
const below = ordered.filter((l) => l.index < top.index).length;
|
|
5187
5185
|
let out = layers;
|
|
5188
|
-
for (const l of ordered) out =
|
|
5189
|
-
return { layers:
|
|
5186
|
+
for (const l of ordered) out = _chunkAEAAN4ADcjs.mapLayer.call(void 0, out, l.layer.id, () => null);
|
|
5187
|
+
return { layers: _chunkAEAAN4ADcjs.insertLayer.call(void 0, out, smart, parent, top.index - below), layer: smart };
|
|
5190
5188
|
}
|
|
5191
5189
|
function rasterizeSmartObject(layers, id) {
|
|
5192
5190
|
const layer = requireSmartObject(layers, id);
|
|
@@ -5206,7 +5204,7 @@ function rasterizeSmartObject(layers, id) {
|
|
|
5206
5204
|
if (layer.locks) out.locks = layer.locks;
|
|
5207
5205
|
if (layer.effects) out.effects = layer.effects;
|
|
5208
5206
|
if (layer.fillOpacity !== void 0) out.fillOpacity = layer.fillOpacity;
|
|
5209
|
-
return { layers:
|
|
5207
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => out), layer: out };
|
|
5210
5208
|
}
|
|
5211
5209
|
function copySmartObject(layers, id, linked, name) {
|
|
5212
5210
|
const loc = requireLayer(layers, id);
|
|
@@ -5216,19 +5214,19 @@ function copySmartObject(layers, id, linked, name) {
|
|
|
5216
5214
|
delete copy.psd;
|
|
5217
5215
|
if (!linked) copy.contents = { ...layer.contents, id: newContentsId() };
|
|
5218
5216
|
if (copy.smartFilters) copy.smartFilters = { ...copy.smartFilters, filters: copy.smartFilters.filters.map((f) => ({ ...f, id: newLayerId("flt") })) };
|
|
5219
|
-
return { layers:
|
|
5217
|
+
return { layers: _chunkAEAAN4ADcjs.insertLayer.call(void 0, layers, copy, _nullishCoalesce(_optionalChain([loc, 'access', _122 => _122.parent, 'optionalAccess', _123 => _123.id]), () => ( null)), loc.index + 1), layer: copy };
|
|
5220
5218
|
}
|
|
5221
5219
|
function instancesOf(layers, contentsId) {
|
|
5222
|
-
return
|
|
5220
|
+
return _chunkAEAAN4ADcjs.flattenLayers.call(void 0, layers).filter((l) => l.type === "smart" && l.contents.id === contentsId).map((l) => l.id);
|
|
5223
5221
|
}
|
|
5224
5222
|
function replaceContents(layers, contentsId, contents, canvas) {
|
|
5225
5223
|
const ids = instancesOf(layers, contentsId);
|
|
5226
5224
|
if (!ids.length) fail4(`No smart object uses contents "${contentsId}".`);
|
|
5227
|
-
for (const id of ids) requireUnlocked(
|
|
5225
|
+
for (const id of ids) requireUnlocked(_chunkAEAAN4ADcjs.findLayer.call(void 0, layers, id).layer, "all", "replace its contents");
|
|
5228
5226
|
const next = { ...contents, id: contentsId };
|
|
5229
5227
|
let out = layers;
|
|
5230
5228
|
for (const id of ids) {
|
|
5231
|
-
out =
|
|
5229
|
+
out = _chunkAEAAN4ADcjs.mapLayer.call(void 0, out, id, (l) => {
|
|
5232
5230
|
const layer = l;
|
|
5233
5231
|
return rerender({ ...layer, contents: next, placement: refitPlacement(layer, next) }, canvas, "take the new contents");
|
|
5234
5232
|
});
|
|
@@ -5252,14 +5250,14 @@ function refitPlacement(layer, contents) {
|
|
|
5252
5250
|
});
|
|
5253
5251
|
const out = { corners: pts };
|
|
5254
5252
|
if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
|
|
5255
|
-
if (layer.placement.warp) out.warp =
|
|
5253
|
+
if (layer.placement.warp) out.warp = _chunk5OOIUXNJcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
|
|
5256
5254
|
return out;
|
|
5257
5255
|
}
|
|
5258
5256
|
function normalizeSmartFilter(raw, id = newLayerId("flt")) {
|
|
5259
5257
|
if (raw.kind === "psd") fail4("Photoshop filters can only come from a PSD; add develop or blur.");
|
|
5260
5258
|
const base = raw.kind === "effect" ? normalizeEffectSmartFilter(raw, id) : normalizeFilter(raw, id);
|
|
5261
5259
|
const blend = _nullishCoalesce(raw.blend, () => ( "normal"));
|
|
5262
|
-
if (!
|
|
5260
|
+
if (!_chunkO7LUD7MHcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
5263
5261
|
const opacity = _nullishCoalesce(raw.opacity, () => ( 1));
|
|
5264
5262
|
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
5265
5263
|
return { ...base, blend, opacity };
|
|
@@ -5305,7 +5303,7 @@ function addSmartFilter(layers, id, filter, canvas, index) {
|
|
|
5305
5303
|
const at = index === void 0 ? filters.length : Math.max(0, Math.min(filters.length, Math.floor(index)));
|
|
5306
5304
|
filters.splice(at, 0, filter);
|
|
5307
5305
|
const next = withStack(layer, { ...stack, filters }, canvas);
|
|
5308
|
-
return { layers:
|
|
5306
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter };
|
|
5309
5307
|
}
|
|
5310
5308
|
function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
5311
5309
|
const layer = editableSmart(layers, id);
|
|
@@ -5317,7 +5315,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5317
5315
|
const extra = Object.keys(changes).filter((k) => !["enabled", "blend", "opacity", "kind"].includes(k));
|
|
5318
5316
|
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(", ")}.`);
|
|
5319
5317
|
const blend = _nullishCoalesce(changes.blend, () => ( current.blend));
|
|
5320
|
-
if (!
|
|
5318
|
+
if (!_chunkO7LUD7MHcjs.isBlendMode.call(void 0, blend) || blend === "pigment") fail4(`Unknown blend mode "${String(blend)}" for a smart filter.`);
|
|
5321
5319
|
const opacity = _nullishCoalesce(changes.opacity, () => ( current.opacity));
|
|
5322
5320
|
if (!(typeof opacity === "number" && opacity >= 0 && opacity <= 1)) fail4("opacity must be a number from 0 to 1.");
|
|
5323
5321
|
merged2 = { ...current, enabled: changes.enabled === void 0 ? current.enabled : Boolean(changes.enabled), blend, opacity };
|
|
@@ -5327,7 +5325,7 @@ function updateSmartFilter(layers, id, filterId, changes, canvas) {
|
|
|
5327
5325
|
const filters = [...layer.smartFilters.filters];
|
|
5328
5326
|
filters[i] = merged2;
|
|
5329
5327
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5330
|
-
return { layers:
|
|
5328
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next, filter: merged2 };
|
|
5331
5329
|
}
|
|
5332
5330
|
function removeSmartFilter(layers, id, filterId, canvas) {
|
|
5333
5331
|
const layer = editableSmart(layers, id);
|
|
@@ -5335,7 +5333,7 @@ function removeSmartFilter(layers, id, filterId, canvas) {
|
|
|
5335
5333
|
const stack = layer.smartFilters;
|
|
5336
5334
|
const filters = stack.filters.filter((f) => f.id !== filterId);
|
|
5337
5335
|
const next = withStack(layer, filters.length ? { ...stack, filters } : stack.enabled ? void 0 : { enabled: false, filters }, canvas);
|
|
5338
|
-
return { layers:
|
|
5336
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5339
5337
|
}
|
|
5340
5338
|
function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
5341
5339
|
const layer = editableSmart(layers, id);
|
|
@@ -5346,12 +5344,12 @@ function moveSmartFilter(layers, id, filterId, index, canvas) {
|
|
|
5346
5344
|
const [f] = filters.splice(i, 1);
|
|
5347
5345
|
filters.splice(index, 0, f);
|
|
5348
5346
|
const next = withStack(layer, { ...layer.smartFilters, filters }, canvas);
|
|
5349
|
-
return { layers:
|
|
5347
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5350
5348
|
}
|
|
5351
5349
|
function setSmartFiltersEnabled(layers, id, enabled, canvas) {
|
|
5352
5350
|
const layer = editableSmart(layers, id);
|
|
5353
5351
|
const next = withStack(layer, { ...stackOf(layer), enabled: Boolean(enabled) }, canvas);
|
|
5354
|
-
return { layers:
|
|
5352
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5355
5353
|
}
|
|
5356
5354
|
function setSmartFilterMask(layers, id, mask, canvas) {
|
|
5357
5355
|
const layer = editableSmart(layers, id);
|
|
@@ -5360,7 +5358,7 @@ function setSmartFilterMask(layers, id, mask, canvas) {
|
|
|
5360
5358
|
if (mask) stack.mask = mask;
|
|
5361
5359
|
else delete stack.mask;
|
|
5362
5360
|
const next = withStack(layer, stack, canvas);
|
|
5363
|
-
return { layers:
|
|
5361
|
+
return { layers: _chunkAEAAN4ADcjs.mapLayer.call(void 0, layers, id, () => next), layer: next };
|
|
5364
5362
|
}
|
|
5365
5363
|
function withFilterMaskSurface(layer, surface, canvas) {
|
|
5366
5364
|
const stack = stackOf(layer);
|
|
@@ -5374,7 +5372,7 @@ function placementBounds(layer) {
|
|
|
5374
5372
|
// src/image-editor/layers/serialize.ts
|
|
5375
5373
|
var LAYERED_SCHEMA_VERSION = 3;
|
|
5376
5374
|
function serializePatterns(patterns) {
|
|
5377
|
-
return patterns.map((p) => ({ id: p.id, name: p.name, png:
|
|
5375
|
+
return patterns.map((p) => ({ id: p.id, name: p.name, png: _chunkO7LUD7MHcjs.pngDataUrl.call(void 0, p.width, p.height, p.data) }));
|
|
5378
5376
|
}
|
|
5379
5377
|
function deserializePatterns(raw, problems = []) {
|
|
5380
5378
|
if (!Array.isArray(raw)) return [];
|
|
@@ -5393,11 +5391,11 @@ function deserializePatterns(raw, problems = []) {
|
|
|
5393
5391
|
var encodedCache = /* @__PURE__ */ new WeakMap();
|
|
5394
5392
|
function encodeSurface(surface) {
|
|
5395
5393
|
if (encodedCache.has(surface)) return encodedCache.get(surface);
|
|
5396
|
-
const b =
|
|
5394
|
+
const b = _chunkO7LUD7MHcjs.contentBounds.call(void 0, surface);
|
|
5397
5395
|
let out = null;
|
|
5398
5396
|
if (b) {
|
|
5399
|
-
const data =
|
|
5400
|
-
out = { url:
|
|
5397
|
+
const data = _chunkO7LUD7MHcjs.readRegion.call(void 0, surface, b);
|
|
5398
|
+
out = { url: _chunkO7LUD7MHcjs.pngDataUrl.call(void 0, b.width, b.height, data, surface.channels), x: b.x, y: b.y };
|
|
5401
5399
|
}
|
|
5402
5400
|
encodedCache.set(surface, out);
|
|
5403
5401
|
return out;
|
|
@@ -5406,15 +5404,15 @@ var deepCache = /* @__PURE__ */ new WeakMap();
|
|
|
5406
5404
|
function encodeDeepSurface(surface) {
|
|
5407
5405
|
if (deepCache.has(surface)) return deepCache.get(surface);
|
|
5408
5406
|
let out = null;
|
|
5409
|
-
const depth =
|
|
5410
|
-
const b = depth === 8 ? null :
|
|
5407
|
+
const depth = _chunkO7LUD7MHcjs.surfaceDepth.call(void 0, surface);
|
|
5408
|
+
const b = depth === 8 ? null : _chunkO7LUD7MHcjs.contentBounds.call(void 0, surface);
|
|
5411
5409
|
if (depth !== 8 && b) {
|
|
5412
|
-
const samples =
|
|
5410
|
+
const samples = _chunkO7LUD7MHcjs.readDeepRegion.call(void 0, surface, b, depth);
|
|
5413
5411
|
const bytes = new Uint8Array(samples.byteLength);
|
|
5414
5412
|
const view = new DataView(bytes.buffer);
|
|
5415
5413
|
if (samples instanceof Uint16Array) for (let i = 0; i < samples.length; i++) view.setUint16(2 * i, samples[i], true);
|
|
5416
5414
|
else for (let i = 0; i < samples.length; i++) view.setFloat32(4 * i, samples[i], true);
|
|
5417
|
-
out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data:
|
|
5415
|
+
out = { depth, x: b.x, y: b.y, width: b.width, height: b.height, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, _chunk643B2HKCcjs.deflate.call(void 0, bytes)) };
|
|
5418
5416
|
}
|
|
5419
5417
|
deepCache.set(surface, out);
|
|
5420
5418
|
return out;
|
|
@@ -5426,13 +5424,13 @@ function decodeDeepSurface(surface, raw, problems, label) {
|
|
|
5426
5424
|
if (d.depth !== 16 && d.depth !== 32 || !(d.width > 0 && d.height > 0) || !Number.isInteger(d.x) || !Number.isInteger(d.y) || typeof d.data !== "string") throw new Error("malformed");
|
|
5427
5425
|
const n = d.width * d.height * surface.channels;
|
|
5428
5426
|
const size = d.depth === 16 ? 2 : 4;
|
|
5429
|
-
const bytes = _chunk643B2HKCcjs.inflate.call(void 0,
|
|
5427
|
+
const bytes = _chunk643B2HKCcjs.inflate.call(void 0, _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, d.data), { maxOutput: n * size });
|
|
5430
5428
|
if (bytes.length !== n * size) throw new Error("wrong length");
|
|
5431
5429
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
5432
5430
|
const samples = d.depth === 16 ? new Uint16Array(n) : new Float32Array(n);
|
|
5433
5431
|
if (samples instanceof Uint16Array) for (let i = 0; i < n; i++) samples[i] = view.getUint16(2 * i, true);
|
|
5434
5432
|
else for (let i = 0; i < n; i++) samples[i] = view.getFloat32(4 * i, true);
|
|
5435
|
-
return
|
|
5433
|
+
return _chunkO7LUD7MHcjs.writeDeepRegion.call(void 0, surface, { x: d.x, y: d.y, width: d.width, height: d.height }, samples);
|
|
5436
5434
|
} catch (e6) {
|
|
5437
5435
|
problems.push(`${label}: its ${d.depth}-bit samples could not be read, so it was opened at 8 bits`);
|
|
5438
5436
|
return surface;
|
|
@@ -5455,7 +5453,7 @@ function baseFields(layer, ctx) {
|
|
|
5455
5453
|
function serializeEffects(effects) {
|
|
5456
5454
|
const out = { enabled: effects.enabled, items: JSON.parse(JSON.stringify(effects.items)) };
|
|
5457
5455
|
if (effects.scale !== void 0 && effects.scale !== 1) out.scale = effects.scale;
|
|
5458
|
-
if (effects.psd) out.psd = { key: effects.psd.key, data:
|
|
5456
|
+
if (effects.psd) out.psd = { key: effects.psd.key, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, effects.psd.data) };
|
|
5459
5457
|
return out;
|
|
5460
5458
|
}
|
|
5461
5459
|
function deserializeEffects(raw) {
|
|
@@ -5465,12 +5463,12 @@ function deserializeEffects(raw) {
|
|
|
5465
5463
|
const p = r.psd;
|
|
5466
5464
|
if (p && typeof p.key === "string" && typeof p.data === "string") {
|
|
5467
5465
|
try {
|
|
5468
|
-
psd = { key: p.key, data:
|
|
5466
|
+
psd = { key: p.key, data: _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, p.data) };
|
|
5469
5467
|
} catch (e7) {
|
|
5470
5468
|
psd = void 0;
|
|
5471
5469
|
}
|
|
5472
5470
|
}
|
|
5473
|
-
return
|
|
5471
|
+
return _chunkAEAAN4ADcjs.normalizeLayerEffects.call(void 0, { ...r, psd });
|
|
5474
5472
|
}
|
|
5475
5473
|
function serializeMask(mask, hint, ctx) {
|
|
5476
5474
|
const out = { defaultValue: mask.defaultValue };
|
|
@@ -5554,8 +5552,8 @@ function serializeType(layer, base, ctx) {
|
|
|
5554
5552
|
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5555
5553
|
if (_optionalChain([layer, 'access', _131 => _131.psd, 'optionalAccess', _132 => _132.tySh]) || _optionalChain([layer, 'access', _133 => _133.psd, 'optionalAccess', _134 => _134.blocks, 'optionalAccess', _135 => _135.length])) {
|
|
5556
5554
|
out.psd = {};
|
|
5557
|
-
if (layer.psd.tySh) out.psd.tySh =
|
|
5558
|
-
if (_optionalChain([layer, 'access', _136 => _136.psd, 'access', _137 => _137.blocks, 'optionalAccess', _138 => _138.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data:
|
|
5555
|
+
if (layer.psd.tySh) out.psd.tySh = _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, layer.psd.tySh);
|
|
5556
|
+
if (_optionalChain([layer, 'access', _136 => _136.psd, 'access', _137 => _137.blocks, 'optionalAccess', _138 => _138.length])) out.psd.blocks = layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, b.data) }));
|
|
5559
5557
|
if (layer.psd.signature) out.psd.signature = layer.psd.signature;
|
|
5560
5558
|
}
|
|
5561
5559
|
return out;
|
|
@@ -5566,7 +5564,7 @@ function readType(r, base, ctx) {
|
|
|
5566
5564
|
const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
|
|
5567
5565
|
const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
|
|
5568
5566
|
length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _139 => _139.length]), 0, 1e9, 0))),
|
|
5569
|
-
style: patchTextStyle(
|
|
5567
|
+
style: patchTextStyle(_chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _140 => _140.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
|
|
5570
5568
|
}));
|
|
5571
5569
|
const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
|
|
5572
5570
|
length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _141 => _141.length]), 0, 1e9, 0))),
|
|
@@ -5579,13 +5577,13 @@ function readType(r, base, ctx) {
|
|
|
5579
5577
|
...base,
|
|
5580
5578
|
type: "type",
|
|
5581
5579
|
text: text3,
|
|
5582
|
-
runs:
|
|
5583
|
-
paragraphs:
|
|
5580
|
+
runs: _chunk5OOIUXNJcjs.fitRuns.call(void 0, runs, text3.length, _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE),
|
|
5581
|
+
paragraphs: _chunk5OOIUXNJcjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
|
|
5584
5582
|
frame,
|
|
5585
|
-
surface:
|
|
5583
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
5586
5584
|
offset: { x: 0, y: 0 }
|
|
5587
5585
|
};
|
|
5588
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _145 => _145[0], 'optionalAccess', _146 => _146.style]), () => (
|
|
5586
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _145 => _145[0], 'optionalAccess', _146 => _146.style]), () => ( _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE)) }];
|
|
5589
5587
|
if (m) layer.transform = m;
|
|
5590
5588
|
if (r.antiAlias === false) layer.antiAlias = false;
|
|
5591
5589
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
@@ -5593,8 +5591,8 @@ function readType(r, base, ctx) {
|
|
|
5593
5591
|
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)) }));
|
|
5594
5592
|
if (r.psd && typeof r.psd === "object") {
|
|
5595
5593
|
const psd = {};
|
|
5596
|
-
if (typeof r.psd.tySh === "string") psd.tySh =
|
|
5597
|
-
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:
|
|
5594
|
+
if (typeof r.psd.tySh === "string") psd.tySh = _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, r.psd.tySh);
|
|
5595
|
+
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: _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5598
5596
|
if (typeof r.psd.signature === "string") psd.signature = r.psd.signature;
|
|
5599
5597
|
if (psd.tySh || _optionalChain([psd, 'access', _147 => _147.blocks, 'optionalAccess', _148 => _148.length])) layer.psd = psd;
|
|
5600
5598
|
}
|
|
@@ -5622,7 +5620,7 @@ function serializeShape(layer, base) {
|
|
|
5622
5620
|
if (layer.inverted) out.inverted = true;
|
|
5623
5621
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5624
5622
|
if (layer.annotation) out.annotation = JSON.parse(JSON.stringify(layer.annotation));
|
|
5625
|
-
if (_optionalChain([layer, 'access', _153 => _153.psd, 'optionalAccess', _154 => _154.blocks, 'optionalAccess', _155 => _155.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data:
|
|
5623
|
+
if (_optionalChain([layer, 'access', _153 => _153.psd, 'optionalAccess', _154 => _154.blocks, 'optionalAccess', _155 => _155.length])) out.psd = { blocks: layer.psd.blocks.map((b) => ({ key: b.key, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, b.data) })), ...layer.psd.signature ? { signature: layer.psd.signature } : {} };
|
|
5626
5624
|
return out;
|
|
5627
5625
|
}
|
|
5628
5626
|
function readShape(r, base, ctx) {
|
|
@@ -5654,7 +5652,7 @@ function readShape(r, base, ctx) {
|
|
|
5654
5652
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) out.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
5655
5653
|
if (a && shapeFromAnnotation(a)) out.annotation = a;
|
|
5656
5654
|
if (r.psd && Array.isArray(r.psd.blocks)) {
|
|
5657
|
-
const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data:
|
|
5655
|
+
const blocks = r.psd.blocks.filter((b) => b && typeof b.key === "string" && typeof b.data === "string").map((b) => ({ key: b.key, data: _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, b.data) }));
|
|
5658
5656
|
if (blocks.length) out.psd = { blocks };
|
|
5659
5657
|
if (out.psd && typeof r.psd.signature === "string") out.psd.signature = r.psd.signature;
|
|
5660
5658
|
}
|
|
@@ -5667,7 +5665,7 @@ function readShape(r, base, ctx) {
|
|
|
5667
5665
|
function serializeSmartFilters(stack, layerId, ctx) {
|
|
5668
5666
|
const out = {
|
|
5669
5667
|
enabled: stack.enabled,
|
|
5670
|
-
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data:
|
|
5668
|
+
filters: stack.filters.map((f) => f.kind === "psd" ? { ...f, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, f.data) } : JSON.parse(JSON.stringify(f)))
|
|
5671
5669
|
};
|
|
5672
5670
|
if (stack.mask) out.mask = serializeMask(stack.mask, `${layerId}-filter-mask`, ctx);
|
|
5673
5671
|
return out;
|
|
@@ -5693,7 +5691,7 @@ function serializeSmartObject(layer, base, ctx) {
|
|
|
5693
5691
|
}
|
|
5694
5692
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity !== 1) out.fillOpacity = layer.fillOpacity;
|
|
5695
5693
|
if (layer.psd) {
|
|
5696
|
-
out.psd = { key: layer.psd.key, data:
|
|
5694
|
+
out.psd = { key: layer.psd.key, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, layer.psd.data) };
|
|
5697
5695
|
if (layer.psd.placed) out.psd.placed = layer.psd.placed;
|
|
5698
5696
|
}
|
|
5699
5697
|
return out;
|
|
@@ -5704,8 +5702,8 @@ function serializeContents(c, ctx) {
|
|
|
5704
5702
|
const enc = encodeSurface(c.raster);
|
|
5705
5703
|
if (enc) {
|
|
5706
5704
|
if (enc.x !== 0 || enc.y !== 0) {
|
|
5707
|
-
const data =
|
|
5708
|
-
out.asset = ctx.addAsset(
|
|
5705
|
+
const data = _chunkO7LUD7MHcjs.readRegion.call(void 0, c.raster, { x: 0, y: 0, width: c.width, height: c.height });
|
|
5706
|
+
out.asset = ctx.addAsset(_chunkO7LUD7MHcjs.pngDataUrl.call(void 0, c.width, c.height, data, 4), `contents-${c.id}`);
|
|
5709
5707
|
} else out.asset = ctx.addAsset(enc.url, `contents-${c.id}`);
|
|
5710
5708
|
}
|
|
5711
5709
|
}
|
|
@@ -5714,7 +5712,7 @@ function serializeContents(c, ctx) {
|
|
|
5714
5712
|
if (c.document.globalLight) out.globalLight = { ...c.document.globalLight };
|
|
5715
5713
|
if (_optionalChain([c, 'access', _160 => _160.document, 'access', _161 => _161.patterns, 'optionalAccess', _162 => _162.length])) out.patterns = serializePatterns(c.document.patterns);
|
|
5716
5714
|
}
|
|
5717
|
-
if (c.file) out.file = { type: c.file.type, data:
|
|
5715
|
+
if (c.file) out.file = { type: c.file.type, data: _chunkO7LUD7MHcjs.bytesToBase64.call(void 0, c.file.bytes) };
|
|
5718
5716
|
if (c.linked) out.linked = { path: c.linked.path };
|
|
5719
5717
|
return out;
|
|
5720
5718
|
}
|
|
@@ -5750,7 +5748,7 @@ async function serializeLayersExternal(layers, store) {
|
|
|
5750
5748
|
for (const [id, url] of Object.entries(inline.assets)) {
|
|
5751
5749
|
let ref = refs.get(url);
|
|
5752
5750
|
if (!ref) {
|
|
5753
|
-
const parsed =
|
|
5751
|
+
const parsed = _chunkO7LUD7MHcjs.parseDataUrl.call(void 0, url);
|
|
5754
5752
|
const png = decodePngHeader(parsed.bytes);
|
|
5755
5753
|
ref = await store.put(new Blob([parsed.bytes], { type: "image/png" }), { id, width: png.width, height: png.height });
|
|
5756
5754
|
if (typeof ref !== "string" || !ref) throw new Error(`The asset store returned no reference for "${id}".`);
|
|
@@ -5778,7 +5776,7 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
5778
5776
|
try {
|
|
5779
5777
|
const blob = await store.get(ref);
|
|
5780
5778
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
5781
|
-
out[id] = `data:image/png;base64,${
|
|
5779
|
+
out[id] = `data:image/png;base64,${_chunkO7LUD7MHcjs.bytesToBase64.call(void 0, bytes)}`;
|
|
5782
5780
|
} catch (err) {
|
|
5783
5781
|
problems.push(`Asset "${id}" (${ref}) could not be fetched: ${err.message}`);
|
|
5784
5782
|
}
|
|
@@ -5786,9 +5784,9 @@ async function resolveExternalAssets(assets, store, problems) {
|
|
|
5786
5784
|
return out;
|
|
5787
5785
|
}
|
|
5788
5786
|
function decodePngDataUrl(url, channels) {
|
|
5789
|
-
const parsed =
|
|
5787
|
+
const parsed = _chunkO7LUD7MHcjs.parseDataUrl.call(void 0, url);
|
|
5790
5788
|
if (!parsed) throw new Error("Asset is not a data URL.");
|
|
5791
|
-
const png =
|
|
5789
|
+
const png = _chunkO7LUD7MHcjs.decodePng.call(void 0, parsed.bytes, { keepGray: channels === 1 });
|
|
5792
5790
|
if (png.channels === channels) return png;
|
|
5793
5791
|
if (channels === 1) {
|
|
5794
5792
|
const out2 = new Uint8ClampedArray(png.width * png.height);
|
|
@@ -5806,18 +5804,18 @@ function decodePngDataUrl(url, channels) {
|
|
|
5806
5804
|
}
|
|
5807
5805
|
var num2 = (v, lo, hi, fallback) => typeof v === "number" && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : fallback;
|
|
5808
5806
|
function readSurface(ref, x, y, channels, defaultValue, ctx, what) {
|
|
5809
|
-
if (typeof ref !== "string" || !ref) return
|
|
5807
|
+
if (typeof ref !== "string" || !ref) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
5810
5808
|
const url = ctx.assets[ref];
|
|
5811
5809
|
if (typeof url !== "string") {
|
|
5812
5810
|
ctx.problems.push(`${what}: asset "${ref}" is missing`);
|
|
5813
|
-
return
|
|
5811
|
+
return _chunkO7LUD7MHcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
5814
5812
|
}
|
|
5815
5813
|
try {
|
|
5816
5814
|
const px2 = (_nullishCoalesce(ctx.decodeAsset, () => ( decodePngDataUrl)))(url, channels);
|
|
5817
|
-
return
|
|
5815
|
+
return _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, px2, channels, Math.round(num2(x, -1e7, 1e7, 0)), Math.round(num2(y, -1e7, 1e7, 0)), defaultValue);
|
|
5818
5816
|
} catch (err) {
|
|
5819
5817
|
ctx.problems.push(`${what}: asset "${ref}" could not be decoded (${err.message})`);
|
|
5820
|
-
return
|
|
5818
|
+
return _chunkO7LUD7MHcjs.emptySurface.call(void 0, channels, defaultValue);
|
|
5821
5819
|
}
|
|
5822
5820
|
}
|
|
5823
5821
|
function readMask(raw, ctx, what) {
|
|
@@ -5825,7 +5823,7 @@ function readMask(raw, ctx, what) {
|
|
|
5825
5823
|
const r = raw;
|
|
5826
5824
|
const defaultValue = r.defaultValue === 255 ? 255 : 0;
|
|
5827
5825
|
const mask = {
|
|
5828
|
-
surface: r.source ?
|
|
5826
|
+
surface: r.source ? _chunkO7LUD7MHcjs.emptySurface.call(void 0, 1, 255) : readSurface(r.asset, r.x, r.y, 1, defaultValue, ctx, `${what} mask`),
|
|
5829
5827
|
defaultValue: r.source ? 255 : defaultValue
|
|
5830
5828
|
};
|
|
5831
5829
|
if (typeof r.density === "number" && r.density !== 1) mask.density = num2(r.density, 0, 1, 1);
|
|
@@ -5874,7 +5872,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
5874
5872
|
name: typeof r.name === "string" ? r.name : "",
|
|
5875
5873
|
visible: r.visible !== false,
|
|
5876
5874
|
opacity: num2(r.opacity, 0, 1, 1),
|
|
5877
|
-
blend:
|
|
5875
|
+
blend: _chunkO7LUD7MHcjs.normalizeBlendMode.call(void 0, r.blend)
|
|
5878
5876
|
};
|
|
5879
5877
|
if (r.clipped === true) base.clipped = true;
|
|
5880
5878
|
const mask = readMask(r.mask, ctx, `Layer "${base.name || id}"`);
|
|
@@ -5891,7 +5889,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
5891
5889
|
const layer = {
|
|
5892
5890
|
...base,
|
|
5893
5891
|
type: "pixel",
|
|
5894
|
-
surface: r.source === "document" ?
|
|
5892
|
+
surface: r.source === "document" ? _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4) : readSurface(r.asset, r.x, r.y, 4, 0, ctx, `Layer "${base.name || id}"`),
|
|
5895
5893
|
offset: { x: Math.round(num2(_optionalChain([r, 'access', _163 => _163.offset, 'optionalAccess', _164 => _164.x]), -1e7, 1e7, 0)), y: Math.round(num2(_optionalChain([r, 'access', _165 => _165.offset, 'optionalAccess', _166 => _166.y]), -1e7, 1e7, 0)) }
|
|
5896
5894
|
};
|
|
5897
5895
|
if (r.source === "document") layer.source = "document";
|
|
@@ -5913,7 +5911,7 @@ function deserializeLayer(raw, ctx) {
|
|
|
5913
5911
|
}
|
|
5914
5912
|
case "group": {
|
|
5915
5913
|
const children = Array.isArray(r.children) ? r.children.map((c) => deserializeLayer(c, ctx)).filter(Boolean) : [];
|
|
5916
|
-
const blend = r.blend === "pass-through" ? "pass-through" :
|
|
5914
|
+
const blend = r.blend === "pass-through" ? "pass-through" : _chunkO7LUD7MHcjs.isBlendMode.call(void 0, r.blend) ? r.blend : "pass-through";
|
|
5917
5915
|
const group = { ...base, type: "group", blend, children };
|
|
5918
5916
|
if (r.collapsed === true) group.collapsed = true;
|
|
5919
5917
|
return group;
|
|
@@ -5965,7 +5963,7 @@ function readContents(id, ctx) {
|
|
|
5965
5963
|
const c = { id, name: typeof raw.name === "string" ? raw.name : "Contents", width, height, kind: raw.kind === "document" ? "document" : "raster" };
|
|
5966
5964
|
if (raw.file && typeof raw.file.type === "string" && typeof raw.file.data === "string") {
|
|
5967
5965
|
try {
|
|
5968
|
-
c.file = { type: raw.file.type, bytes:
|
|
5966
|
+
c.file = { type: raw.file.type, bytes: _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, raw.file.data) };
|
|
5969
5967
|
} catch (e9) {
|
|
5970
5968
|
ctx.problems.push(`Smart object contents "${c.name}": the embedded file could not be read`);
|
|
5971
5969
|
}
|
|
@@ -5973,7 +5971,7 @@ function readContents(id, ctx) {
|
|
|
5973
5971
|
if (raw.linked && typeof raw.linked.path === "string") c.linked = { path: raw.linked.path };
|
|
5974
5972
|
if (c.kind === "raster") {
|
|
5975
5973
|
if (typeof raw.asset === "string") c.raster = readSurface(raw.asset, 0, 0, 4, 0, ctx, `Smart object contents "${c.name}"`);
|
|
5976
|
-
else if (!c.file) c.raster =
|
|
5974
|
+
else if (!c.file) c.raster = _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
5977
5975
|
} else {
|
|
5978
5976
|
const outer = ctx.canvas;
|
|
5979
5977
|
ctx.canvas = { width, height };
|
|
@@ -6005,11 +6003,11 @@ function readSmartFilters(raw, ctx, what) {
|
|
|
6005
6003
|
let k = 0;
|
|
6006
6004
|
for (const f of list2) {
|
|
6007
6005
|
if (!f || typeof f !== "object") continue;
|
|
6008
|
-
const blend =
|
|
6006
|
+
const blend = _chunkO7LUD7MHcjs.isBlendMode.call(void 0, f.blend) && f.blend !== "pigment" ? f.blend : "normal";
|
|
6009
6007
|
const opacity = num2(f.opacity, 0, 1, 1);
|
|
6010
6008
|
if (f.kind === "psd") {
|
|
6011
6009
|
try {
|
|
6012
|
-
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:
|
|
6010
|
+
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: _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, String(_nullishCoalesce(f.data, () => ( "")))), blend, opacity });
|
|
6013
6011
|
} catch (e10) {
|
|
6014
6012
|
ctx.problems.push(`${what}: a Photoshop smart filter could not be read`);
|
|
6015
6013
|
}
|
|
@@ -6038,20 +6036,20 @@ function readSmartObject(r, base, ctx) {
|
|
|
6038
6036
|
let placement;
|
|
6039
6037
|
try {
|
|
6040
6038
|
const raw = { corners: p.corners };
|
|
6041
|
-
if (p.warp &&
|
|
6042
|
-
if (
|
|
6039
|
+
if (p.warp && _chunk5OOIUXNJcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
|
|
6040
|
+
if (_chunkAEAAN4ADcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
|
|
6043
6041
|
placement = normalizePlacement(raw, contents);
|
|
6044
6042
|
} catch (e) {
|
|
6045
6043
|
ctx.problems.push(`${what}: its placement is invalid (${e instanceof Error ? e.message : String(e)}); it was placed at the top left`);
|
|
6046
6044
|
placement = { corners: [{ x: 0, y: 0 }, { x: contents.width, y: 0 }, { x: contents.width, y: contents.height }, { x: 0, y: contents.height }] };
|
|
6047
6045
|
}
|
|
6048
|
-
const layer = { ...base, type: "smart", contents, placement, surface:
|
|
6046
|
+
const layer = { ...base, type: "smart", contents, placement, surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
|
|
6049
6047
|
const filters = readSmartFilters(r.smartFilters, ctx, what);
|
|
6050
6048
|
if (filters) layer.smartFilters = filters;
|
|
6051
6049
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
6052
6050
|
if (r.psd && typeof r.psd.key === "string" && typeof r.psd.data === "string") {
|
|
6053
6051
|
try {
|
|
6054
|
-
layer.psd = { key: r.psd.key, data:
|
|
6052
|
+
layer.psd = { key: r.psd.key, data: _chunkO7LUD7MHcjs.base64ToBytes.call(void 0, r.psd.data) };
|
|
6055
6053
|
if (typeof r.psd.placed === "string") layer.psd.placed = r.psd.placed;
|
|
6056
6054
|
} catch (e11) {
|
|
6057
6055
|
}
|
|
@@ -7021,7 +7019,7 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
|
|
|
7021
7019
|
const fr = (p) => ({ x: p.x / w, y: p.y / h });
|
|
7022
7020
|
const subpaths = [];
|
|
7023
7021
|
components.forEach((c, ci) => {
|
|
7024
|
-
|
|
7022
|
+
_chunk5OOIUXNJcjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
|
|
7025
7023
|
if (!sp.anchors.length) return;
|
|
7026
7024
|
subpaths.push({
|
|
7027
7025
|
closed: sp.closed,
|
|
@@ -7743,7 +7741,7 @@ function merged(levels) {
|
|
|
7743
7741
|
function charStyle(d, fonts, notes) {
|
|
7744
7742
|
const n = (k) => eNum(eGet(d, k));
|
|
7745
7743
|
const flag = (k) => eBool(eGet(d, k));
|
|
7746
|
-
const s = { ...
|
|
7744
|
+
const s = { ..._chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE };
|
|
7747
7745
|
const fi = n("Font");
|
|
7748
7746
|
const ps = fi !== void 0 ? fonts[fi] : void 0;
|
|
7749
7747
|
if (ps) {
|
|
@@ -7826,7 +7824,7 @@ function typeFromTySh(data, notes) {
|
|
|
7826
7824
|
}
|
|
7827
7825
|
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
7828
7826
|
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
7829
|
-
let runs = [{ length: text3.length, style: { ...
|
|
7827
|
+
let runs = [{ length: text3.length, style: { ..._chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE } }];
|
|
7830
7828
|
let paragraphs = [{ length: text3.length, style: {} }];
|
|
7831
7829
|
let frame = { kind: "point" };
|
|
7832
7830
|
let transform = t.transform;
|
|
@@ -7882,14 +7880,14 @@ function typeFromTySh(data, notes) {
|
|
|
7882
7880
|
const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
7883
7881
|
if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
|
|
7884
7882
|
frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
|
|
7885
|
-
transform =
|
|
7883
|
+
transform = _chunk5OOIUXNJcjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
|
|
7886
7884
|
}
|
|
7887
7885
|
}
|
|
7888
7886
|
}
|
|
7889
7887
|
return {
|
|
7890
7888
|
text: text3,
|
|
7891
|
-
runs:
|
|
7892
|
-
paragraphs:
|
|
7889
|
+
runs: _chunk5OOIUXNJcjs.fitRuns.call(void 0, runs, text3.length, _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE),
|
|
7890
|
+
paragraphs: _chunk5OOIUXNJcjs.fitParagraphRuns.call(void 0, paragraphs, text3),
|
|
7893
7891
|
frame,
|
|
7894
7892
|
transform,
|
|
7895
7893
|
antiAlias,
|
|
@@ -7963,7 +7961,7 @@ function buildEngineData(layer, template) {
|
|
|
7963
7961
|
fonts.push(ps);
|
|
7964
7962
|
return fonts.length - 1;
|
|
7965
7963
|
};
|
|
7966
|
-
const runs =
|
|
7964
|
+
const runs = _chunk5OOIUXNJcjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE);
|
|
7967
7965
|
const sruns = [];
|
|
7968
7966
|
const slens = [];
|
|
7969
7967
|
runs.forEach((r, i) => {
|
|
@@ -7971,10 +7969,10 @@ function buildEngineData(layer, template) {
|
|
|
7971
7969
|
slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
|
|
7972
7970
|
});
|
|
7973
7971
|
if (!runs.length) {
|
|
7974
|
-
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(
|
|
7972
|
+
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE)))]])]]));
|
|
7975
7973
|
slens.push(E.int(1));
|
|
7976
7974
|
}
|
|
7977
|
-
const paras =
|
|
7975
|
+
const paras = _chunk5OOIUXNJcjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
|
|
7978
7976
|
const pruns = [];
|
|
7979
7977
|
const plens = [];
|
|
7980
7978
|
paras.forEach((p, i) => {
|
|
@@ -8030,7 +8028,7 @@ function buildEngineData(layer, template) {
|
|
|
8030
8028
|
eSet(e, key, rd);
|
|
8031
8029
|
}
|
|
8032
8030
|
eSet(rd, "FontSet", fontSet);
|
|
8033
|
-
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.style]), () => (
|
|
8031
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.style]), () => ( _chunk5OOIUXNJcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8034
8032
|
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8035
8033
|
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8036
8034
|
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
@@ -8039,15 +8037,15 @@ function buildEngineData(layer, template) {
|
|
|
8039
8037
|
}
|
|
8040
8038
|
function inkBounds2(layer) {
|
|
8041
8039
|
if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
|
|
8042
|
-
const b =
|
|
8040
|
+
const b = _chunkO7LUD7MHcjs.contentBounds.call(void 0, layer.surface);
|
|
8043
8041
|
if (!b) return [0, 0, 0, 0];
|
|
8044
|
-
const inv =
|
|
8042
|
+
const inv = _chunk5OOIUXNJcjs.invertMatrix.call(void 0, textMatrix(layer));
|
|
8045
8043
|
const pts = [
|
|
8046
8044
|
{ x: b.x, y: b.y },
|
|
8047
8045
|
{ x: b.x + b.width, y: b.y },
|
|
8048
8046
|
{ x: b.x + b.width, y: b.y + b.height },
|
|
8049
8047
|
{ x: b.x, y: b.y + b.height }
|
|
8050
|
-
].map((p) =>
|
|
8048
|
+
].map((p) => _chunk5OOIUXNJcjs.applyMatrix.call(void 0, inv, p));
|
|
8051
8049
|
return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
|
|
8052
8050
|
}
|
|
8053
8051
|
function tyShForLayer(layer) {
|
|
@@ -8485,11 +8483,11 @@ function filterMaskFromItem(item) {
|
|
|
8485
8483
|
const height = rect.bottom - rect.top;
|
|
8486
8484
|
if (!(width > 0 && height > 0) || width * height > 1 << 28) return null;
|
|
8487
8485
|
const bytes = decodePlanes(plane.compression, plane.data, { planes: 1, width, height, depth: 8, psb: true });
|
|
8488
|
-
const surface =
|
|
8486
|
+
const surface = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width, height, data: bytes }, 1, rect.left, rect.top, 255);
|
|
8489
8487
|
return { surface, defaultValue: 255 };
|
|
8490
8488
|
}
|
|
8491
8489
|
function filterMaskItem(placed, mask, area) {
|
|
8492
|
-
const painted =
|
|
8490
|
+
const painted = _chunkO7LUD7MHcjs.contentBounds.call(void 0, mask.surface);
|
|
8493
8491
|
let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
8494
8492
|
if (mask.defaultValue !== 255 && area) {
|
|
8495
8493
|
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _224 => _224.x]), () => ( area.x)));
|
|
@@ -8499,7 +8497,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8499
8497
|
b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
8500
8498
|
}
|
|
8501
8499
|
const rect = { top: b.y, left: b.x, bottom: b.y + b.height, right: b.x + b.width };
|
|
8502
|
-
const values =
|
|
8500
|
+
const values = _chunkO7LUD7MHcjs.readRegion.call(void 0, mask.surface, b);
|
|
8503
8501
|
const plane = new Uint8Array(values.buffer, values.byteOffset, values.length);
|
|
8504
8502
|
return {
|
|
8505
8503
|
id: placed,
|
|
@@ -8514,7 +8512,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8514
8512
|
var warpStyleOf = (name) => {
|
|
8515
8513
|
if (!name.startsWith("warp")) return null;
|
|
8516
8514
|
const s = _optionalChain([name, 'access', _226 => _226[4], 'optionalAccess', _227 => _227.toLowerCase, 'call', _228 => _228()]) + name.slice(5);
|
|
8517
|
-
return
|
|
8515
|
+
return _chunk5OOIUXNJcjs.WARP_STYLES.includes(s) ? s : null;
|
|
8518
8516
|
};
|
|
8519
8517
|
function warpFromDescriptor(w, contents) {
|
|
8520
8518
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
@@ -8544,7 +8542,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8544
8542
|
} else {
|
|
8545
8543
|
const style = warpStyleOf(styleName);
|
|
8546
8544
|
if (!style) return void 0;
|
|
8547
|
-
mesh =
|
|
8545
|
+
mesh = _chunk5OOIUXNJcjs.warpPresetMesh.call(void 0,
|
|
8548
8546
|
{
|
|
8549
8547
|
style,
|
|
8550
8548
|
bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
|
|
@@ -8559,7 +8557,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8559
8557
|
const same = Math.abs(bounds.x) < 1e-6 && Math.abs(bounds.y) < 1e-6 && Math.abs(bounds.width - contents.width) < 1e-6 && Math.abs(bounds.height - contents.height) < 1e-6;
|
|
8560
8558
|
if (!same) {
|
|
8561
8559
|
const m = mesh;
|
|
8562
|
-
mesh =
|
|
8560
|
+
mesh = _chunk5OOIUXNJcjs.fitWarpMesh.call(void 0, (s, t) => _chunk5OOIUXNJcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
|
|
8563
8561
|
}
|
|
8564
8562
|
return { mesh, frame };
|
|
8565
8563
|
}
|
|
@@ -9788,11 +9786,11 @@ function safeSize(ctx, rect, name) {
|
|
|
9788
9786
|
}
|
|
9789
9787
|
function recordPixels(ctx, rec, name) {
|
|
9790
9788
|
const { width, height } = safeSize(ctx, rec.rect, name);
|
|
9791
|
-
if (!width || !height || ctx.skipPixels) return
|
|
9789
|
+
if (!width || !height || ctx.skipPixels) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
9792
9790
|
const ids = [...Array.from({ length: ctx.colorCount }, (_, i) => i), CHANNEL_ALPHA];
|
|
9793
9791
|
const planes = ids.map((id) => rec.channels.some((c) => c.id === id) ? _nullishCoalesce(decodeOr(ctx, rec, id, name), () => ( null)) : void 0);
|
|
9794
|
-
if (planes.some((p) => p === null)) return
|
|
9795
|
-
if (planes.every((p) => p === void 0)) return
|
|
9792
|
+
if (planes.some((p) => p === null)) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
9793
|
+
if (planes.every((p) => p === void 0)) return _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4);
|
|
9796
9794
|
const set = {
|
|
9797
9795
|
width,
|
|
9798
9796
|
height,
|
|
@@ -9805,8 +9803,8 @@ function recordPixels(ctx, rec, name) {
|
|
|
9805
9803
|
cmykToRgb16: ctx.cmykToRgb16
|
|
9806
9804
|
};
|
|
9807
9805
|
const deep = set.cmykToRgb && !set.cmykToRgb16 ? null : toRgbaDeep(set);
|
|
9808
|
-
if (deep) return
|
|
9809
|
-
return
|
|
9806
|
+
if (deep) return _chunkO7LUD7MHcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4, rec.rect.left, rec.rect.top);
|
|
9807
|
+
return _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width, height, data: toRgba8(set) }, 4, rec.rect.left, rec.rect.top);
|
|
9810
9808
|
}
|
|
9811
9809
|
function recordMask(ctx, rec, name) {
|
|
9812
9810
|
const m = rec.mask;
|
|
@@ -9817,13 +9815,13 @@ function recordMask(ctx, rec, name) {
|
|
|
9817
9815
|
const rect = useReal ? m.real.rect : m.rect;
|
|
9818
9816
|
const def = (useReal ? m.real.background : m.defaultColor) >= 128 ? 255 : 0;
|
|
9819
9817
|
const flags = useReal ? m.real.flags : m.flags;
|
|
9820
|
-
let surface =
|
|
9818
|
+
let surface = _chunkO7LUD7MHcjs.emptySurface.call(void 0, 1, def);
|
|
9821
9819
|
const { width, height } = safeSize(ctx, rect, name);
|
|
9822
9820
|
if (width && height && !ctx.skipPixels) {
|
|
9823
9821
|
const plane = decodeOr(ctx, rec, id, name);
|
|
9824
9822
|
const depth = ctx.file.header.depth;
|
|
9825
|
-
if (plane && (depth === 16 || depth === 32)) surface =
|
|
9826
|
-
else if (plane) surface =
|
|
9823
|
+
if (plane && (depth === 16 || depth === 32)) surface = _chunkO7LUD7MHcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: toMaskDeep(plane, width, height, depth) }, 1, rect.left, rect.top, def);
|
|
9824
|
+
else if (plane) surface = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width, height, data: toMask8(plane, width, height, depth) }, 1, rect.left, rect.top, def);
|
|
9827
9825
|
}
|
|
9828
9826
|
const mask = { surface, defaultValue: def };
|
|
9829
9827
|
if (m.userDensity !== void 0 && m.userDensity < 255) mask.density = percent(m.userDensity);
|
|
@@ -9883,7 +9881,7 @@ function recordEffects(ctx, rec, name, notes, group) {
|
|
|
9883
9881
|
}
|
|
9884
9882
|
for (const e of parsed.effects.items) {
|
|
9885
9883
|
for (const id of patternIds(e)) {
|
|
9886
|
-
if (ctx.patterns.has(id) ||
|
|
9884
|
+
if (ctx.patterns.has(id) || _chunkAEAAN4ADcjs.builtinPattern.call(void 0, id)) continue;
|
|
9887
9885
|
ctx.warn.add("A pattern effect uses a pattern the file does not contain, and paints nothing", name);
|
|
9888
9886
|
notes.push(`pattern "${id}" is not in the file`);
|
|
9889
9887
|
}
|
|
@@ -9962,7 +9960,7 @@ function importNode(ctx, node, depth) {
|
|
|
9962
9960
|
if (!file || file.kind !== "liFD") notes.push("linked contents come in as the stored pixels");
|
|
9963
9961
|
entry.type = "smart";
|
|
9964
9962
|
entry.status = notes.length ? "approximated" : "mapped";
|
|
9965
|
-
return { type: "pixel", id: ctx.newId(name), ...props, surface:
|
|
9963
|
+
return { type: "pixel", id: ctx.newId(name), ...props, surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4), offset: { x: 0, y: 0 } };
|
|
9966
9964
|
}
|
|
9967
9965
|
}
|
|
9968
9966
|
if (kind === "smart-object" && !ctx.skipPixels) {
|
|
@@ -10025,7 +10023,7 @@ function importShape(ctx, rec, name, notes, props) {
|
|
|
10025
10023
|
components: data.components,
|
|
10026
10024
|
fill: data.fill,
|
|
10027
10025
|
stroke: data.stroke,
|
|
10028
|
-
surface:
|
|
10026
|
+
surface: _chunkO7LUD7MHcjs.emptySurface.call(void 0, 4),
|
|
10029
10027
|
offset: { x: 0, y: 0 }
|
|
10030
10028
|
};
|
|
10031
10029
|
if (data.inverted) layer.inverted = true;
|
|
@@ -10093,8 +10091,8 @@ function contentsFor(ctx, placed, name, notes) {
|
|
|
10093
10091
|
document: { layers: nested.layers, globalLight: nested.globalLight, patterns: nested.patterns.length ? nested.patterns : void 0 }
|
|
10094
10092
|
};
|
|
10095
10093
|
} else if (t.ext === "png") {
|
|
10096
|
-
const png =
|
|
10097
|
-
out = { ...base, kind: "raster", width: png.width, height: png.height, raster:
|
|
10094
|
+
const png = _chunkO7LUD7MHcjs.decodePng.call(void 0, file.bytes);
|
|
10095
|
+
out = { ...base, kind: "raster", width: png.width, height: png.height, raster: _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, png, 4, 0, 0) };
|
|
10098
10096
|
} else {
|
|
10099
10097
|
const size = _nullishCoalesce(placed.size, () => ( { width: 0, height: 0 }));
|
|
10100
10098
|
if (!(size.width > 0 && size.height > 0)) throw new PsdError("the contents have no stored size");
|
|
@@ -10135,7 +10133,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10135
10133
|
if (placement && (size.width !== contents.width || size.height !== contents.height)) {
|
|
10136
10134
|
const kx = contents.width / size.width;
|
|
10137
10135
|
const ky = contents.height / size.height;
|
|
10138
|
-
if (placement.warp) placement = { ...placement, warp:
|
|
10136
|
+
if (placement.warp) placement = { ...placement, warp: _chunk5OOIUXNJcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
|
|
10139
10137
|
}
|
|
10140
10138
|
}
|
|
10141
10139
|
if (!contents || !placement) {
|
|
@@ -10149,7 +10147,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10149
10147
|
width,
|
|
10150
10148
|
height,
|
|
10151
10149
|
kind: "raster",
|
|
10152
|
-
raster:
|
|
10150
|
+
raster: _chunkO7LUD7MHcjs.translateSurface.call(void 0, surface, -rec.rect.left, -rec.rect.top)
|
|
10153
10151
|
};
|
|
10154
10152
|
if (file && file.kind !== "liFD") {
|
|
10155
10153
|
contents.linked = { path: _nullishCoalesce(file.path, () => ( file.name)) };
|
|
@@ -10219,11 +10217,11 @@ function mergedLayer(ctx) {
|
|
|
10219
10217
|
};
|
|
10220
10218
|
const deep = hasAlpha || set.cmykToRgb && !set.cmykToRgb16 ? null : toRgbaDeep(set);
|
|
10221
10219
|
let surface;
|
|
10222
|
-
if (deep) surface =
|
|
10220
|
+
if (deep) surface = _chunkO7LUD7MHcjs.surfaceFromDeepPixels.call(void 0, { width, height, data: deep }, 4);
|
|
10223
10221
|
else {
|
|
10224
10222
|
const data = toRgba8(set);
|
|
10225
10223
|
if (hasAlpha) unmatteWhite(data);
|
|
10226
|
-
surface =
|
|
10224
|
+
surface = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width, height, data }, 4);
|
|
10227
10225
|
}
|
|
10228
10226
|
return {
|
|
10229
10227
|
type: "pixel",
|
|
@@ -10438,34 +10436,34 @@ function blendOf(d, key, fallback, notes) {
|
|
|
10438
10436
|
function colorOf(d, fallback = "#000000") {
|
|
10439
10437
|
if (!d) return fallback;
|
|
10440
10438
|
const g = (k) => descNumber(d, k);
|
|
10441
|
-
if (g("redFloat") !== void 0) return
|
|
10439
|
+
if (g("redFloat") !== void 0) return _chunkAEAAN4ADcjs.effectColorHex.call(void 0, [g("redFloat"), _nullishCoalesce(g("greenFloat"), () => ( 0)), _nullishCoalesce(g("blueFloat"), () => ( 0))]);
|
|
10442
10440
|
switch (d.classId) {
|
|
10443
10441
|
case "HSBC": {
|
|
10444
10442
|
const rgb = decodePsdColor(1, [(_nullishCoalesce(g("H "), () => ( 0))) / 360 * 65535, (_nullishCoalesce(g("Strt"), () => ( 0))) / 100 * 65535, (_nullishCoalesce(g("Brgh"), () => ( 0))) / 100 * 65535]);
|
|
10445
|
-
return rgb ?
|
|
10443
|
+
return rgb ? _chunkAEAAN4ADcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10446
10444
|
}
|
|
10447
10445
|
case "CMYC": {
|
|
10448
10446
|
const inv = (k) => (1 - (_nullishCoalesce(g(k), () => ( 0))) / 100) * 65535;
|
|
10449
10447
|
const rgb = decodePsdColor(2, [inv("Cyn "), inv("Mgnt"), inv("Ylw "), inv("Blck")]);
|
|
10450
|
-
return rgb ?
|
|
10448
|
+
return rgb ? _chunkAEAAN4ADcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10451
10449
|
}
|
|
10452
10450
|
case "LbCl": {
|
|
10453
10451
|
const rgb = decodePsdColor(7, [(_nullishCoalesce(g("Lmnc"), () => ( 0))) * 100, Math.round((_nullishCoalesce(g("A "), () => ( 0))) * 100) & 65535, Math.round((_nullishCoalesce(g("B "), () => ( 0))) * 100) & 65535]);
|
|
10454
|
-
return rgb ?
|
|
10452
|
+
return rgb ? _chunkAEAAN4ADcjs.effectColorHex.call(void 0, rgb) : fallback;
|
|
10455
10453
|
}
|
|
10456
10454
|
case "Grsc": {
|
|
10457
10455
|
const v = 1 - (_nullishCoalesce(g("Gry "), () => ( 0))) / 100;
|
|
10458
|
-
return
|
|
10456
|
+
return _chunkAEAAN4ADcjs.effectColorHex.call(void 0, [v, v, v]);
|
|
10459
10457
|
}
|
|
10460
10458
|
}
|
|
10461
10459
|
const r = g("Rd ");
|
|
10462
10460
|
const gr = g("Grn ");
|
|
10463
10461
|
const b = g("Bl ");
|
|
10464
10462
|
if (r === void 0 || gr === void 0 || b === void 0) return fallback;
|
|
10465
|
-
return
|
|
10463
|
+
return _chunkAEAAN4ADcjs.effectColorHex.call(void 0, [r / 255, gr / 255, b / 255]);
|
|
10466
10464
|
}
|
|
10467
10465
|
function colorDesc(hex) {
|
|
10468
|
-
const [r, g, b] = _nullishCoalesce(
|
|
10466
|
+
const [r, g, b] = _nullishCoalesce(_chunkAEAAN4ADcjs.parseEffectColor.call(void 0, hex), () => ( [0, 0, 0]));
|
|
10469
10467
|
return descriptor("RGBC", [
|
|
10470
10468
|
["Rd ", dbl3(r * 255)],
|
|
10471
10469
|
["Grn ", dbl3(g * 255)],
|
|
@@ -10548,9 +10546,9 @@ function gradientOf(d, notes) {
|
|
|
10548
10546
|
raw.forEach((s, i) => {
|
|
10549
10547
|
if (i > 0 && Math.abs(s.mid - 0.5) > 1e-3) {
|
|
10550
10548
|
const a = raw[i - 1];
|
|
10551
|
-
const ca =
|
|
10552
|
-
const cb =
|
|
10553
|
-
stops.push({ position: a.position + (s.position - a.position) * s.mid, color:
|
|
10549
|
+
const ca = _chunkAEAAN4ADcjs.parseEffectColor.call(void 0, a.color);
|
|
10550
|
+
const cb = _chunkAEAAN4ADcjs.parseEffectColor.call(void 0, s.color);
|
|
10551
|
+
stops.push({ position: a.position + (s.position - a.position) * s.mid, color: _chunkAEAAN4ADcjs.effectColorHex.call(void 0, ca.map((v, k) => (v + cb[k]) / 2)) });
|
|
10554
10552
|
notes.add("gradient midpoints are drawn as straight segments");
|
|
10555
10553
|
}
|
|
10556
10554
|
stops.push({ position: s.position, color: s.color });
|
|
@@ -10662,8 +10660,8 @@ var KINDS = [
|
|
|
10662
10660
|
["FrFX", "frameFXMulti", "stroke"]
|
|
10663
10661
|
];
|
|
10664
10662
|
function common(d, kind, notes) {
|
|
10665
|
-
const def =
|
|
10666
|
-
return { id:
|
|
10663
|
+
const def = _chunkAEAAN4ADcjs.defaultLayerEffect.call(void 0, kind, "x");
|
|
10664
|
+
return { id: _chunkAEAAN4ADcjs.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) };
|
|
10667
10665
|
}
|
|
10668
10666
|
function readOne(kind, d, notes) {
|
|
10669
10667
|
const size = (key, fallback) => clamp3(num3(d, key, fallback), 0, 250);
|
|
@@ -10706,7 +10704,7 @@ function readOne(kind, d, notes) {
|
|
|
10706
10704
|
case "bevel-emboss": {
|
|
10707
10705
|
const styles = { OtrB: "outer-bevel", InrB: "inner-bevel", Embs: "emboss", PlEb: "pillow-emboss", strokeEmboss: "stroke-emboss" };
|
|
10708
10706
|
const out = {
|
|
10709
|
-
id:
|
|
10707
|
+
id: _chunkAEAAN4ADcjs.newEffectId.call(void 0, ),
|
|
10710
10708
|
enabled: descBool(d, "enab") !== false,
|
|
10711
10709
|
kind,
|
|
10712
10710
|
style: _nullishCoalesce(styles[_nullishCoalesce(enumOf3(d, "bvlS"), () => ( ""))], () => ( "inner-bevel")),
|
|
@@ -10917,10 +10915,10 @@ function writeLfx2(effects) {
|
|
|
10917
10915
|
["Scl ", unit3("#Prc", 100)],
|
|
10918
10916
|
["masterFXSwitch", boolV3(effects.enabled)]
|
|
10919
10917
|
];
|
|
10920
|
-
const scale =
|
|
10918
|
+
const scale = _chunkAEAAN4ADcjs.effectsScale.call(void 0, effects);
|
|
10921
10919
|
let dropped = 0;
|
|
10922
10920
|
for (const [single, multi, kind] of KINDS) {
|
|
10923
|
-
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(
|
|
10921
|
+
const of = effects.items.filter((e) => e.kind === kind).map((e) => writeOne(_chunkAEAAN4ADcjs.scaleLayerEffect.call(void 0, e, scale)));
|
|
10924
10922
|
if (!of.length) continue;
|
|
10925
10923
|
if (of.length === 1) items.push([single, obj3(of[0])]);
|
|
10926
10924
|
else if (multi) items.push([multi, { type: "VlLs", items: of.map(obj3) }]);
|
|
@@ -10952,7 +10950,7 @@ function parseLrfx(data) {
|
|
|
10952
10950
|
const colorAt = (rd) => {
|
|
10953
10951
|
rd.u16();
|
|
10954
10952
|
const c = [rd.u16(), rd.u16(), rd.u16(), rd.u16()];
|
|
10955
|
-
return
|
|
10953
|
+
return _chunkAEAAN4ADcjs.effectColorHex.call(void 0, [c[0] >> 8, c[1] >> 8, c[2] >> 8].map((v) => v / 255));
|
|
10956
10954
|
};
|
|
10957
10955
|
const blendAt = (rd) => {
|
|
10958
10956
|
rd.skip(4);
|
|
@@ -10971,7 +10969,7 @@ function parseLrfx(data) {
|
|
|
10971
10969
|
const enabled = b.u8() !== 0;
|
|
10972
10970
|
const useGlobalLight = b.u8() !== 0;
|
|
10973
10971
|
const opacity = b.u8() / 255;
|
|
10974
|
-
const base = { id:
|
|
10972
|
+
const base = { id: _chunkAEAAN4ADcjs.newEffectId.call(void 0, ), enabled, blend, opacity, color, angle, useGlobalLight, distance: clamp3(distance, 0, 3e4), size: clamp3(blur, 0, 250), antiAlias: false, noise: 0 };
|
|
10975
10973
|
items.push(key === "dsdw" ? { ...base, kind: "drop-shadow", spread: 0, knocksOut: true } : { ...base, kind: "inner-shadow", choke: 0 });
|
|
10976
10974
|
} else if (key === "oglw" || key === "iglw") {
|
|
10977
10975
|
b.u32();
|
|
@@ -10981,7 +10979,7 @@ function parseLrfx(data) {
|
|
|
10981
10979
|
const blend = blendAt(b);
|
|
10982
10980
|
const enabled = b.u8() !== 0;
|
|
10983
10981
|
const opacity = b.u8() / 255;
|
|
10984
|
-
const base = { id:
|
|
10982
|
+
const base = { id: _chunkAEAAN4ADcjs.newEffectId.call(void 0, ), enabled, blend, opacity, fill: { type: "color", color }, technique: "softer", size: clamp3(blur, 0, 250), antiAlias: false, range: 0.5, jitter: 0, noise: 0 };
|
|
10985
10983
|
items.push(key === "oglw" ? { ...base, kind: "outer-glow", spread: 0 } : { ...base, kind: "inner-glow", choke: 0, source: "edge" });
|
|
10986
10984
|
} else if (key === "sofi") {
|
|
10987
10985
|
b.u32();
|
|
@@ -10989,7 +10987,7 @@ function parseLrfx(data) {
|
|
|
10989
10987
|
const color = colorAt(b);
|
|
10990
10988
|
const opacity = b.u8() / 255;
|
|
10991
10989
|
const enabled = b.u8() !== 0;
|
|
10992
|
-
items.push({ id:
|
|
10990
|
+
items.push({ id: _chunkAEAAN4ADcjs.newEffectId.call(void 0, ), kind: "color-overlay", enabled, blend, opacity, color });
|
|
10993
10991
|
} else if (key === "bevl") notes.add("legacy bevels are not read");
|
|
10994
10992
|
}
|
|
10995
10993
|
return { effects: { enabled: true, items }, notes: [...notes] };
|
|
@@ -11040,13 +11038,13 @@ function rleChannel(id, plane, width, height, psb, depth = 8) {
|
|
|
11040
11038
|
}
|
|
11041
11039
|
function surfacePlanes(surface, bounds, depth) {
|
|
11042
11040
|
const n = bounds.width * bounds.height;
|
|
11043
|
-
if (depth === 8) return rgbaToPlanes(
|
|
11044
|
-
return deepToPlanes(
|
|
11041
|
+
if (depth === 8) return rgbaToPlanes(_chunkO7LUD7MHcjs.readRegion.call(void 0, surface, bounds), n);
|
|
11042
|
+
return deepToPlanes(_chunkO7LUD7MHcjs.readDeepRegion.call(void 0, surface, bounds, depth), n);
|
|
11045
11043
|
}
|
|
11046
11044
|
var emptyChannel = (id) => ({ id, compression: 0, data: new Uint8Array(0) });
|
|
11047
11045
|
function maskChannel(mask, ox, oy, psb, depth = 8) {
|
|
11048
11046
|
if (mask.source) throw new PsdError("A parametric mask must be baked before export.");
|
|
11049
|
-
const bounds =
|
|
11047
|
+
const bounds = _chunkO7LUD7MHcjs.contentBounds.call(void 0, mask.surface);
|
|
11050
11048
|
const def = mask.defaultValue;
|
|
11051
11049
|
const flags = (mask.enabled === false ? MASK_FLAG_DISABLED : 0) | (mask.linked === false ? MASK_FLAG_UNLINKED : 0);
|
|
11052
11050
|
const m = { rect: EMPTY_RECT, defaultColor: def, flags };
|
|
@@ -11055,9 +11053,9 @@ function maskChannel(mask, ox, oy, psb, depth = 8) {
|
|
|
11055
11053
|
if (!bounds) return { channel: emptyChannel(CHANNEL_USER_MASK), mask: m };
|
|
11056
11054
|
m.rect = toRect({ ...bounds, x: bounds.x + ox, y: bounds.y + oy });
|
|
11057
11055
|
let bytes;
|
|
11058
|
-
if (depth !== 8 &&
|
|
11056
|
+
if (depth !== 8 && _chunkO7LUD7MHcjs.surfaceDepth.call(void 0, mask.surface) !== 8) bytes = deepMaskPlane(_chunkO7LUD7MHcjs.readDeepRegion.call(void 0, mask.surface, bounds, depth));
|
|
11059
11057
|
else {
|
|
11060
|
-
const plane =
|
|
11058
|
+
const plane = _chunkO7LUD7MHcjs.readRegion.call(void 0, mask.surface, bounds);
|
|
11061
11059
|
bytes = planeAtDepth(new Uint8Array(plane.buffer, plane.byteOffset, plane.length), depth);
|
|
11062
11060
|
}
|
|
11063
11061
|
return { channel: rleChannel(CHANNEL_USER_MASK, bytes, bounds.width, bounds.height, psb, depth), mask: m };
|
|
@@ -11085,7 +11083,7 @@ function prepareNestedLayers(layers) {
|
|
|
11085
11083
|
delete plain.effects;
|
|
11086
11084
|
delete plain.fillOpacity;
|
|
11087
11085
|
const data = new LayerCompositor().composite([plain], r, { width: r.x + r.width, height: r.y + r.height });
|
|
11088
|
-
p.surface =
|
|
11086
|
+
p.surface = _chunkO7LUD7MHcjs.surfaceFromPixels.call(void 0, { width: r.width, height: r.height, data }, 4, r.x - l.offset.x, r.y - l.offset.y);
|
|
11089
11087
|
}
|
|
11090
11088
|
}
|
|
11091
11089
|
delete p.filters;
|
|
@@ -11104,11 +11102,11 @@ function smartContentsFile(c) {
|
|
|
11104
11102
|
const base = c.name.replace(/\.\w+$/, "") || "Contents";
|
|
11105
11103
|
if (c.file) return { name: c.name, bytes: c.file.bytes };
|
|
11106
11104
|
if (c.kind === "raster") {
|
|
11107
|
-
const data =
|
|
11108
|
-
return { name: `${base}.png`, bytes:
|
|
11105
|
+
const data = _chunkO7LUD7MHcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
11106
|
+
return { name: `${base}.png`, bytes: _chunkO7LUD7MHcjs.encodePng.call(void 0, c.width, c.height, data) };
|
|
11109
11107
|
}
|
|
11110
11108
|
const doc = c.document;
|
|
11111
|
-
const merged2 =
|
|
11109
|
+
const merged2 = _chunkO7LUD7MHcjs.readRegion.call(void 0, contentsSurface(c), { x: 0, y: 0, width: c.width, height: c.height });
|
|
11112
11110
|
const res = exportPsd({ width: c.width, height: c.height, layers: prepareNestedLayers(doc.layers), merged: merged2, patterns: doc.patterns, globalLight: doc.globalLight });
|
|
11113
11111
|
return { name: `${base}.${res.psb ? "psb" : "psd"}`, bytes: res.bytes };
|
|
11114
11112
|
}
|
|
@@ -11155,13 +11153,13 @@ function exportPsd(input) {
|
|
|
11155
11153
|
const surfaceChannels = (surface, bounds) => {
|
|
11156
11154
|
if (mode !== "rgb" && depth === 16) {
|
|
11157
11155
|
const n2 = bounds.width * bounds.height;
|
|
11158
|
-
const s =
|
|
11156
|
+
const s = _chunkO7LUD7MHcjs.readDeepRegion.call(void 0, surface, bounds, 16);
|
|
11159
11157
|
const alpha = new Uint16Array(n2);
|
|
11160
11158
|
for (let i = 0; i < n2; i++) alpha[i] = s[i * 4 + 3];
|
|
11161
11159
|
const planes2 = [alpha, ...input.colorPlanes16(s, n2)];
|
|
11162
11160
|
return [CHANNEL_ALPHA, ...colorIds].map((id, i) => rleChannel(id, deepMaskPlane(planes2[i]), bounds.width, bounds.height, psb, 16));
|
|
11163
11161
|
}
|
|
11164
|
-
if (mode !== "rgb") return pixelChannels(
|
|
11162
|
+
if (mode !== "rgb") return pixelChannels(_chunkO7LUD7MHcjs.readRegion.call(void 0, surface, bounds), bounds.width, bounds.height);
|
|
11165
11163
|
const [r, g, b, a2] = surfacePlanes(surface, bounds, depth);
|
|
11166
11164
|
return [CHANNEL_ALPHA, 0, 1, 2].map((id, i) => rleChannel(id, [a2, r, g, b][i], bounds.width, bounds.height, psb, depth));
|
|
11167
11165
|
};
|
|
@@ -11181,7 +11179,7 @@ function exportPsd(input) {
|
|
|
11181
11179
|
const key = layer.type === "group" ? "lfxs" : "lfx2";
|
|
11182
11180
|
if (fx.psd) {
|
|
11183
11181
|
const original = parseLfx2(fx.psd.data);
|
|
11184
|
-
if (original ?
|
|
11182
|
+
if (original ? _chunkAEAAN4ADcjs.effectsFingerprint.call(void 0, original.effects) === _chunkAEAAN4ADcjs.effectsFingerprint.call(void 0, fx) : !fx.items.length) return { key, data: padEven(fx.psd.data) };
|
|
11185
11183
|
}
|
|
11186
11184
|
if (!fx.items.length && fx.enabled && (_nullishCoalesce(fx.scale, () => ( 1))) === 1) return null;
|
|
11187
11185
|
const { data, dropped } = writeLfx2(fx);
|
|
@@ -11261,7 +11259,7 @@ function exportPsd(input) {
|
|
|
11261
11259
|
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
11262
11260
|
}
|
|
11263
11261
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
11264
|
-
const bounds =
|
|
11262
|
+
const bounds = _chunkO7LUD7MHcjs.contentBounds.call(void 0, layer.surface);
|
|
11265
11263
|
if (bounds) {
|
|
11266
11264
|
rec.rect = toRect({ ...bounds, x: bounds.x + layer.offset.x, y: bounds.y + layer.offset.y });
|
|
11267
11265
|
rec.channels = surfaceChannels(layer.surface, bounds);
|
|
@@ -11305,7 +11303,7 @@ function exportPsd(input) {
|
|
|
11305
11303
|
const fm = _optionalChain([layer, 'access', _275 => _275.smartFilters, 'optionalAccess', _276 => _276.mask]);
|
|
11306
11304
|
if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
|
|
11307
11305
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
11308
|
-
const bounds =
|
|
11306
|
+
const bounds = _chunkO7LUD7MHcjs.contentBounds.call(void 0, layer.surface);
|
|
11309
11307
|
if (bounds) {
|
|
11310
11308
|
rec.rect = toRect(bounds);
|
|
11311
11309
|
rec.channels = surfaceChannels(layer.surface, bounds);
|
|
@@ -11336,7 +11334,7 @@ function exportPsd(input) {
|
|
|
11336
11334
|
extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
|
|
11337
11335
|
}
|
|
11338
11336
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
11339
|
-
const bounds =
|
|
11337
|
+
const bounds = _chunkO7LUD7MHcjs.contentBounds.call(void 0, layer.surface);
|
|
11340
11338
|
if (bounds) {
|
|
11341
11339
|
rec.rect = toRect(bounds);
|
|
11342
11340
|
rec.channels = surfaceChannels(layer.surface, bounds);
|
|
@@ -11409,7 +11407,7 @@ function exportPsd(input) {
|
|
|
11409
11407
|
const byId = new Map((_nullishCoalesce(input.patterns, () => ( []))).map((p) => [p.id, p]));
|
|
11410
11408
|
const embed = [];
|
|
11411
11409
|
for (const id of patternIds2) {
|
|
11412
|
-
const p = _nullishCoalesce(byId.get(id), () => (
|
|
11410
|
+
const p = _nullishCoalesce(byId.get(id), () => ( _chunkAEAAN4ADcjs.builtinPattern.call(void 0, id)));
|
|
11413
11411
|
if (p) embed.push(p);
|
|
11414
11412
|
else note(`Pattern "${id}" is not in the document and was not embedded`, id);
|
|
11415
11413
|
}
|
|
@@ -11805,4 +11803,4 @@ function exportPsd(input) {
|
|
|
11805
11803
|
|
|
11806
11804
|
|
|
11807
11805
|
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.LayerOperationError = LayerOperationError; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
11808
|
-
//# sourceMappingURL=chunk-
|
|
11806
|
+
//# sourceMappingURL=chunk-XN2NBLV5.cjs.map
|