ag-psd 17.0.2 → 17.0.3
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/CHANGELOG.md +3 -0
- package/dist/additionalInfo.js +43 -2
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +43 -2
- package/dist-es/additionalInfo.js +43 -2
- package/dist-es/additionalInfo.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +45 -2
- package/src/psd.ts +5 -5
package/dist/bundle.js
CHANGED
|
@@ -1124,6 +1124,9 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
1124
1124
|
var placed = target.placedLayer;
|
|
1125
1125
|
(0, psdWriter_1.writeSignature)(writer, 'plcL');
|
|
1126
1126
|
(0, psdWriter_1.writeInt32)(writer, 3); // version
|
|
1127
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
1128
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
1129
|
+
}
|
|
1127
1130
|
(0, psdWriter_1.writePascalString)(writer, placed.id, 1);
|
|
1128
1131
|
(0, psdWriter_1.writeInt32)(writer, 1); // pageNumber
|
|
1129
1132
|
(0, psdWriter_1.writeInt32)(writer, 1); // totalPages
|
|
@@ -2011,9 +2014,44 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
2011
2014
|
(0, psdWriter_1.writeSignature)(writer, 'soLD');
|
|
2012
2015
|
(0, psdWriter_1.writeInt32)(writer, 4); // version
|
|
2013
2016
|
var placed = target.placedLayer;
|
|
2017
|
+
var warp = placed.warp;
|
|
2018
|
+
if (!warp) {
|
|
2019
|
+
if (!placed.width || !placed.height)
|
|
2020
|
+
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
2021
|
+
var w = placed.width;
|
|
2022
|
+
var h = placed.height;
|
|
2023
|
+
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
2024
|
+
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
2025
|
+
warp = {
|
|
2026
|
+
style: 'custom',
|
|
2027
|
+
value: 0,
|
|
2028
|
+
perspective: 0,
|
|
2029
|
+
perspectiveOther: 0,
|
|
2030
|
+
rotate: 'horizontal',
|
|
2031
|
+
bounds: {
|
|
2032
|
+
top: { value: 0, units: 'Pixels' },
|
|
2033
|
+
left: { value: 0, units: 'Pixels' },
|
|
2034
|
+
bottom: { value: h, units: 'Pixels' },
|
|
2035
|
+
right: { value: w, units: 'Pixels' },
|
|
2036
|
+
},
|
|
2037
|
+
uOrder: 4,
|
|
2038
|
+
vOrder: 4,
|
|
2039
|
+
customEnvelopeWarp: {
|
|
2040
|
+
meshPoints: [
|
|
2041
|
+
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
2042
|
+
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
2043
|
+
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
2044
|
+
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
2045
|
+
],
|
|
2046
|
+
},
|
|
2047
|
+
};
|
|
2048
|
+
}
|
|
2049
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
2050
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
2051
|
+
}
|
|
2014
2052
|
var desc = __assign(__assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedLayerTypes.indexOf(placed.type), Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform,
|
|
2015
2053
|
// quiltWarp: {} as any,
|
|
2016
|
-
warp: encodeWarp(
|
|
2054
|
+
warp: encodeWarp(warp || {}), 'Sz ': {
|
|
2017
2055
|
_name: '',
|
|
2018
2056
|
_classID: 'Pnt ',
|
|
2019
2057
|
Wdth: placed.width || 0,
|
|
@@ -2281,7 +2319,10 @@ addHandler('lnk2', function (target) { return !!target.linkedFiles && target.lin
|
|
|
2281
2319
|
var sizeOffset = writer.offset;
|
|
2282
2320
|
(0, psdWriter_1.writeSignature)(writer, file.data ? 'liFD' : 'liFA');
|
|
2283
2321
|
(0, psdWriter_1.writeInt32)(writer, version);
|
|
2284
|
-
|
|
2322
|
+
if (!file.id || typeof file.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(file.id)) {
|
|
2323
|
+
throw new Error('Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
2324
|
+
}
|
|
2325
|
+
(0, psdWriter_1.writePascalString)(writer, file.id, 1);
|
|
2285
2326
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, file.name || '');
|
|
2286
2327
|
(0, psdWriter_1.writeSignature)(writer, file.type ? "".concat(file.type, " ").substring(0, 4) : ' ');
|
|
2287
2328
|
(0, psdWriter_1.writeSignature)(writer, file.creator ? "".concat(file.creator, " ").substring(0, 4) : '\0\0\0\0');
|
|
@@ -847,6 +847,9 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
847
847
|
var placed = target.placedLayer;
|
|
848
848
|
writeSignature(writer, 'plcL');
|
|
849
849
|
writeInt32(writer, 3); // version
|
|
850
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
851
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
852
|
+
}
|
|
850
853
|
writePascalString(writer, placed.id, 1);
|
|
851
854
|
writeInt32(writer, 1); // pageNumber
|
|
852
855
|
writeInt32(writer, 1); // totalPages
|
|
@@ -1734,9 +1737,44 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
1734
1737
|
writeSignature(writer, 'soLD');
|
|
1735
1738
|
writeInt32(writer, 4); // version
|
|
1736
1739
|
var placed = target.placedLayer;
|
|
1740
|
+
var warp = placed.warp;
|
|
1741
|
+
if (!warp) {
|
|
1742
|
+
if (!placed.width || !placed.height)
|
|
1743
|
+
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
1744
|
+
var w = placed.width;
|
|
1745
|
+
var h = placed.height;
|
|
1746
|
+
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
1747
|
+
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
1748
|
+
warp = {
|
|
1749
|
+
style: 'custom',
|
|
1750
|
+
value: 0,
|
|
1751
|
+
perspective: 0,
|
|
1752
|
+
perspectiveOther: 0,
|
|
1753
|
+
rotate: 'horizontal',
|
|
1754
|
+
bounds: {
|
|
1755
|
+
top: { value: 0, units: 'Pixels' },
|
|
1756
|
+
left: { value: 0, units: 'Pixels' },
|
|
1757
|
+
bottom: { value: h, units: 'Pixels' },
|
|
1758
|
+
right: { value: w, units: 'Pixels' },
|
|
1759
|
+
},
|
|
1760
|
+
uOrder: 4,
|
|
1761
|
+
vOrder: 4,
|
|
1762
|
+
customEnvelopeWarp: {
|
|
1763
|
+
meshPoints: [
|
|
1764
|
+
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
1765
|
+
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
1766
|
+
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
1767
|
+
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
1768
|
+
],
|
|
1769
|
+
},
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
1773
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
1774
|
+
}
|
|
1737
1775
|
var desc = __assign(__assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedLayerTypes.indexOf(placed.type), Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform,
|
|
1738
1776
|
// quiltWarp: {} as any,
|
|
1739
|
-
warp: encodeWarp(
|
|
1777
|
+
warp: encodeWarp(warp || {}), 'Sz ': {
|
|
1740
1778
|
_name: '',
|
|
1741
1779
|
_classID: 'Pnt ',
|
|
1742
1780
|
Wdth: placed.width || 0,
|
|
@@ -2004,7 +2042,10 @@ addHandler('lnk2', function (target) { return !!target.linkedFiles && target.lin
|
|
|
2004
2042
|
var sizeOffset = writer.offset;
|
|
2005
2043
|
writeSignature(writer, file.data ? 'liFD' : 'liFA');
|
|
2006
2044
|
writeInt32(writer, version);
|
|
2007
|
-
|
|
2045
|
+
if (!file.id || typeof file.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(file.id)) {
|
|
2046
|
+
throw new Error('Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
2047
|
+
}
|
|
2048
|
+
writePascalString(writer, file.id, 1);
|
|
2008
2049
|
writeUnicodeStringWithPadding(writer, file.name || '');
|
|
2009
2050
|
writeSignature(writer, file.type ? "".concat(file.type, " ").substring(0, 4) : ' ');
|
|
2010
2051
|
writeSignature(writer, file.creator ? "".concat(file.creator, " ").substring(0, 4) : '\0\0\0\0');
|