ag-psd 34.2.2 → 34.2.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/.v8-cache/v26.13.0-x64-310b2ce3/4511bacf +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/71df9cb3 +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/7ea06cea +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/932f0770 +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/acc36e66 +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/b3c2fab7 +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/dc86f000 +0 -0
- package/.v8-cache/v26.13.0-x64-310b2ce3/e6735171 +0 -0
- package/CHANGELOG.md +4 -0
- package/README.md +22 -3
- package/dist/abr.js +5 -4
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.js +1 -1
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +30 -18
- package/dist/descriptor.js +6 -6
- package/dist/descriptor.js.map +1 -1
- package/dist/helpers.d.ts +4 -0
- package/dist/helpers.js +11 -0
- package/dist/helpers.js.map +1 -1
- package/dist/imageResources.js +1 -1
- package/dist/imageResources.js.map +1 -1
- package/dist/text.js +5 -5
- package/dist/text.js.map +1 -1
- package/dist-es/abr.js +5 -4
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.js +1 -1
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/descriptor.js +6 -6
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/helpers.d.ts +4 -0
- package/dist-es/helpers.js +11 -0
- package/dist-es/helpers.js.map +1 -1
- package/dist-es/imageResources.js +1 -1
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/text.js +5 -5
- package/dist-es/text.js.map +1 -1
- package/package.json +1 -1
- package/src/abr.ts +5 -4
- package/src/additionalInfo.ts +2 -2
- package/src/descriptor.ts +7 -7
- package/src/helpers.ts +11 -0
- package/src/imageResources.ts +2 -2
- package/src/text.ts +5 -5
package/dist/bundle.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.readAbr = readAbr;
|
|
5
5
|
const descriptor_1 = require("./descriptor");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
6
7
|
const psdReader_1 = require("./psdReader");
|
|
7
8
|
const dynamicsControl = ['off', 'fade', 'pen pressure', 'pen tilt', 'stylus wheel', 'initial direction', 'direction', 'initial rotation', 'rotation'];
|
|
8
9
|
const dynamicBrushShapeShapes = ['round point', 'round blunt', 'round curve', 'round angle', 'round fan', 'flat point', 'flat blunt', 'flat curve', 'flat angle', 'flat fan'];
|
|
@@ -20,7 +21,7 @@ const toBrushType = new Map([
|
|
|
20
21
|
]);
|
|
21
22
|
function parseDynamics(desc) {
|
|
22
23
|
return {
|
|
23
|
-
control: dynamicsControl
|
|
24
|
+
control: (0, helpers_1.arrayItem)(dynamicsControl, desc.bVTy),
|
|
24
25
|
steps: desc.fStp,
|
|
25
26
|
jitter: (0, descriptor_1.parsePercent)(desc.jitter),
|
|
26
27
|
minimum: (0, descriptor_1.parsePercent)(desc['Mnm ']),
|
|
@@ -58,7 +59,7 @@ function parseBrushShape(desc) {
|
|
|
58
59
|
case 'dBrush':
|
|
59
60
|
return {
|
|
60
61
|
type: 'dynamic',
|
|
61
|
-
shape: dynamicBrushShapeShapes
|
|
62
|
+
shape: (0, helpers_1.arrayItem)(dynamicBrushShapeShapes, desc['Shp ']),
|
|
62
63
|
angle: (0, descriptor_1.parseAngle)(desc.Angl),
|
|
63
64
|
size: (0, descriptor_1.parseUnitsToNumber)(desc.Dmtr, 'Pixels'),
|
|
64
65
|
density: (0, descriptor_1.parsePercent)(desc.Dnst),
|
|
@@ -73,9 +74,9 @@ function parseBrushShape(desc) {
|
|
|
73
74
|
flipY: desc.flipY,
|
|
74
75
|
};
|
|
75
76
|
case 'dTips': {
|
|
76
|
-
return Object.assign(Object.assign({ type: 'tips', angle: (0, descriptor_1.parseAngle)(desc.Angl), size: (0, descriptor_1.parseUnitsToNumber)(desc.Dmtr, 'Pixels'), shape: dynamicBrushShapeShapes
|
|
77
|
+
return Object.assign(Object.assign({ type: 'tips', angle: (0, descriptor_1.parseAngle)(desc.Angl), size: (0, descriptor_1.parseUnitsToNumber)(desc.Dmtr, 'Pixels'), shape: (0, helpers_1.arrayItem)(dynamicBrushShapeShapes, desc['Shp ']), physics: desc.physics, spacing: (0, descriptor_1.parsePercent)(desc.Spcn), spacingOn: desc.Intr, flipX: desc.flipX, flipY: desc.flipY,
|
|
77
78
|
// tips:
|
|
78
|
-
tipsType: tipsBrushShapeShapes
|
|
79
|
+
tipsType: (0, helpers_1.arrayItem)(tipsBrushShapeShapes, desc.dtipsType), tipsLengthRatio: (0, descriptor_1.parsePercent)(desc.dtipsLengthRatio), tipsHardness: (0, descriptor_1.parsePercent)(desc.dtipsHardness) }, ((desc.dtipsGridSize && desc.dtipsErodibleTipHeightMap) ? {
|
|
79
80
|
tipsGridSize: desc.dtipsGridSize,
|
|
80
81
|
tipsErodibleTipHeightMap: parseHeightmap(desc.dtipsErodibleTipHeightMap),
|
|
81
82
|
} : {})), {
|
|
@@ -507,7 +508,7 @@ function parseBrush(brush) {
|
|
|
507
508
|
return b;
|
|
508
509
|
}
|
|
509
510
|
|
|
510
|
-
},{"./descriptor":5,"./psdReader":14}],2:[function(require,module,exports){
|
|
511
|
+
},{"./descriptor":5,"./helpers":9,"./psdReader":14}],2:[function(require,module,exports){
|
|
511
512
|
"use strict";
|
|
512
513
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
513
514
|
var t = {};
|
|
@@ -3058,7 +3059,7 @@ addHandler('SoLd', target => !!target.placedLayer && !target.placedLayer.externa
|
|
|
3058
3059
|
target.placedLayer = {
|
|
3059
3060
|
id: desc.Idnt,
|
|
3060
3061
|
placed: desc.placed,
|
|
3061
|
-
type: placedLayerTypes
|
|
3062
|
+
type: (0, helpers_1.arrayItem)(placedLayerTypes, desc.Type),
|
|
3062
3063
|
pageNumber: desc.PgNm,
|
|
3063
3064
|
totalPages: desc.totalPages,
|
|
3064
3065
|
frameStep: (0, descriptor_1.frac)(desc.frameStep),
|
|
@@ -5332,7 +5333,7 @@ function getTypeByKey(key, value, root, parent) {
|
|
|
5332
5333
|
return 'long';
|
|
5333
5334
|
}
|
|
5334
5335
|
else {
|
|
5335
|
-
return fieldToType
|
|
5336
|
+
return (0, helpers_1.ownValue)(fieldToType, key);
|
|
5336
5337
|
}
|
|
5337
5338
|
}
|
|
5338
5339
|
function readAsciiStringOrClassId(reader) {
|
|
@@ -5389,9 +5390,9 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
5389
5390
|
for (const key of keys) {
|
|
5390
5391
|
let type = getTypeByKey(key, value[key], root, value);
|
|
5391
5392
|
let childRoot = root;
|
|
5392
|
-
let extType = fieldToExtType
|
|
5393
|
+
let extType = (0, helpers_1.ownValue)(fieldToExtType, key);
|
|
5393
5394
|
if (classId === exports.cameraRawFilterClassID) {
|
|
5394
|
-
type = (_a = exports.cameraRawFilterKeyTypes
|
|
5395
|
+
type = (_a = (0, helpers_1.ownValue)(exports.cameraRawFilterKeyTypes, key)) !== null && _a !== void 0 ? _a : 'long'; // other settings are integer levels
|
|
5395
5396
|
childRoot = exports.cameraRawFilterClassID; // lists (curves) contain integer levels
|
|
5396
5397
|
}
|
|
5397
5398
|
if (key === 'bounds' && root === 'text') {
|
|
@@ -5649,9 +5650,9 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
5649
5650
|
throw new Error(`Invalid list value: ${JSON.stringify(value)}, key: ${key}`);
|
|
5650
5651
|
(0, psdWriter_1.writeInt32)(writer, value.length);
|
|
5651
5652
|
for (let i = 0; i < value.length; i++) {
|
|
5652
|
-
const type = root === exports.cameraRawFilterClassID ? 'long' : ((_a = fieldToArrayType
|
|
5653
|
+
const type = root === exports.cameraRawFilterClassID ? 'long' : ((_a = (0, helpers_1.ownValue)(fieldToArrayType, key)) !== null && _a !== void 0 ? _a : guessOSType(value[i]));
|
|
5653
5654
|
(0, psdWriter_1.writeSignature)(writer, type || 'long');
|
|
5654
|
-
writeOSType(writer, type || 'long', value[i], `${key}[]`, fieldToArrayExtType
|
|
5655
|
+
writeOSType(writer, type || 'long', value[i], `${key}[]`, (0, helpers_1.ownValue)(fieldToArrayExtType, key), root);
|
|
5655
5656
|
if (writer.logMissingFeatures && !type)
|
|
5656
5657
|
writer.log(`Missing descriptor array type for: '${key}' in`, value);
|
|
5657
5658
|
}
|
|
@@ -5727,7 +5728,7 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
5727
5728
|
case 'ObAr': { // Object array
|
|
5728
5729
|
(0, psdWriter_1.writeInt32)(writer, 16); // version
|
|
5729
5730
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, ''); // name
|
|
5730
|
-
const type = ObArTypes
|
|
5731
|
+
const type = (0, helpers_1.ownValue)(ObArTypes, key);
|
|
5731
5732
|
if (!type)
|
|
5732
5733
|
throw new Error(`Not implemented ObArType for: ${key}`);
|
|
5733
5734
|
writeAsciiStringOrClassId(writer, type);
|
|
@@ -8328,6 +8329,8 @@ exports.offsetForChannel = offsetForChannel;
|
|
|
8328
8329
|
exports.normalizeLabAB = normalizeLabAB;
|
|
8329
8330
|
exports.denormalizeLabAB = denormalizeLabAB;
|
|
8330
8331
|
exports.clamp = clamp;
|
|
8332
|
+
exports.arrayItem = arrayItem;
|
|
8333
|
+
exports.ownValue = ownValue;
|
|
8331
8334
|
exports.hasAlpha = hasAlpha;
|
|
8332
8335
|
exports.cmykToRgbValues = cmykToRgbValues;
|
|
8333
8336
|
exports.rgbToCmykValues = rgbToCmykValues;
|
|
@@ -8463,6 +8466,15 @@ function denormalizeLabAB(value, scale = 1) {
|
|
|
8463
8466
|
function clamp(value, min, max) {
|
|
8464
8467
|
return value < min ? min : (value > max ? max : value);
|
|
8465
8468
|
}
|
|
8469
|
+
// index read from a file can be any type (e.g. string '__proto__' or a list coerced to 'length'),
|
|
8470
|
+
// only integer indexes within the array return an item, so inherited properties are never returned
|
|
8471
|
+
function arrayItem(array, index) {
|
|
8472
|
+
return (typeof index === 'number' && Number.isInteger(index) && index >= 0 && index < array.length) ? array[index] : undefined;
|
|
8473
|
+
}
|
|
8474
|
+
// key read from a file can be a name of an inherited property (e.g. 'constructor' or 'toString')
|
|
8475
|
+
function ownValue(dict, key) {
|
|
8476
|
+
return Object.prototype.hasOwnProperty.call(dict, key) ? dict[key] : undefined;
|
|
8477
|
+
}
|
|
8466
8478
|
function hasAlpha(data) {
|
|
8467
8479
|
const size = data.width * data.height * 4;
|
|
8468
8480
|
const max = data.data instanceof Float32Array ? 1 : (data.data instanceof Uint16Array ? 0xffff : 0xff);
|
|
@@ -9744,7 +9756,7 @@ target => target.onionSkins !== undefined, (reader, target) => {
|
|
|
9744
9756
|
frameSpacing: desc.Spcn,
|
|
9745
9757
|
minOpacity: desc.minOpacity / 100,
|
|
9746
9758
|
maxOpacity: desc.maxOpacity / 100,
|
|
9747
|
-
blendMode: onionSkinsBlendModes
|
|
9759
|
+
blendMode: (0, helpers_1.arrayItem)(onionSkinsBlendModes, desc.BlnM) || 'normal',
|
|
9748
9760
|
};
|
|
9749
9761
|
}, (writer, target) => {
|
|
9750
9762
|
const onionSkins = target.onionSkins;
|
|
@@ -15017,7 +15029,7 @@ function decodeGridInfo(grid) {
|
|
|
15017
15029
|
return isDefault ? undefined : result;
|
|
15018
15030
|
}
|
|
15019
15031
|
function decodeEngineData(engineData) {
|
|
15020
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
15032
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
15021
15033
|
// console.log('engineData', require('util').inspect(engineData, false, 99, true));
|
|
15022
15034
|
const engineDict = engineData.EngineDict;
|
|
15023
15035
|
const resourceDict = engineData.ResourceDict;
|
|
@@ -15037,7 +15049,7 @@ function decodeEngineData(engineData) {
|
|
|
15037
15049
|
}
|
|
15038
15050
|
const result = {
|
|
15039
15051
|
text,
|
|
15040
|
-
antiAlias: (_a = antialias
|
|
15052
|
+
antiAlias: (_a = (0, helpers_1.arrayItem)(antialias, engineDict.AntiAlias)) !== null && _a !== void 0 ? _a : 'smooth',
|
|
15041
15053
|
useFractionalGlyphWidths: !!engineDict.UseFractionalGlyphWidths,
|
|
15042
15054
|
superscriptSize: resourceDict.SuperscriptSize,
|
|
15043
15055
|
superscriptPosition: resourceDict.SuperscriptPosition,
|
|
@@ -15090,9 +15102,9 @@ function decodeEngineData(engineData) {
|
|
|
15090
15102
|
// const styleSheetData = styleSheetSet[theNormalStyleSheet].StyleSheetData;
|
|
15091
15103
|
const styleRun = engineDict.StyleRun;
|
|
15092
15104
|
// style runs without a font use the font of the normal style sheet
|
|
15093
|
-
const
|
|
15094
|
-
const
|
|
15095
|
-
const normalFont = (
|
|
15105
|
+
const styleSheetSet = Array.isArray(resourceDict.StyleSheetSet) ? resourceDict.StyleSheetSet : [];
|
|
15106
|
+
const normalStyleSheet = (_h = (0, helpers_1.arrayItem)(styleSheetSet, (_g = resourceDict.TheNormalStyleSheet) !== null && _g !== void 0 ? _g : 0)) === null || _h === void 0 ? void 0 : _h.StyleSheetData;
|
|
15107
|
+
const normalFont = (_j = (0, helpers_1.arrayItem)(fonts, normalStyleSheet === null || normalStyleSheet === void 0 ? void 0 : normalStyleSheet.Font)) !== null && _j !== void 0 ? _j : fonts[0];
|
|
15096
15108
|
result.style = {}; // decodeStyle(styleSheetData, fonts);
|
|
15097
15109
|
result.styleRuns = [];
|
|
15098
15110
|
for (let i = 0; i < styleRun.RunArray.length; i++) {
|
package/dist/descriptor.js
CHANGED
|
@@ -444,7 +444,7 @@ function getTypeByKey(key, value, root, parent) {
|
|
|
444
444
|
return 'long';
|
|
445
445
|
}
|
|
446
446
|
else {
|
|
447
|
-
return fieldToType
|
|
447
|
+
return (0, helpers_1.ownValue)(fieldToType, key);
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
function readAsciiStringOrClassId(reader) {
|
|
@@ -501,9 +501,9 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
501
501
|
for (const key of keys) {
|
|
502
502
|
let type = getTypeByKey(key, value[key], root, value);
|
|
503
503
|
let childRoot = root;
|
|
504
|
-
let extType = fieldToExtType
|
|
504
|
+
let extType = (0, helpers_1.ownValue)(fieldToExtType, key);
|
|
505
505
|
if (classId === exports.cameraRawFilterClassID) {
|
|
506
|
-
type = (_a = exports.cameraRawFilterKeyTypes
|
|
506
|
+
type = (_a = (0, helpers_1.ownValue)(exports.cameraRawFilterKeyTypes, key)) !== null && _a !== void 0 ? _a : 'long'; // other settings are integer levels
|
|
507
507
|
childRoot = exports.cameraRawFilterClassID; // lists (curves) contain integer levels
|
|
508
508
|
}
|
|
509
509
|
if (key === 'bounds' && root === 'text') {
|
|
@@ -761,9 +761,9 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
761
761
|
throw new Error(`Invalid list value: ${JSON.stringify(value)}, key: ${key}`);
|
|
762
762
|
(0, psdWriter_1.writeInt32)(writer, value.length);
|
|
763
763
|
for (let i = 0; i < value.length; i++) {
|
|
764
|
-
const type = root === exports.cameraRawFilterClassID ? 'long' : ((_a = fieldToArrayType
|
|
764
|
+
const type = root === exports.cameraRawFilterClassID ? 'long' : ((_a = (0, helpers_1.ownValue)(fieldToArrayType, key)) !== null && _a !== void 0 ? _a : guessOSType(value[i]));
|
|
765
765
|
(0, psdWriter_1.writeSignature)(writer, type || 'long');
|
|
766
|
-
writeOSType(writer, type || 'long', value[i], `${key}[]`, fieldToArrayExtType
|
|
766
|
+
writeOSType(writer, type || 'long', value[i], `${key}[]`, (0, helpers_1.ownValue)(fieldToArrayExtType, key), root);
|
|
767
767
|
if (writer.logMissingFeatures && !type)
|
|
768
768
|
writer.log(`Missing descriptor array type for: '${key}' in`, value);
|
|
769
769
|
}
|
|
@@ -839,7 +839,7 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
839
839
|
case 'ObAr': { // Object array
|
|
840
840
|
(0, psdWriter_1.writeInt32)(writer, 16); // version
|
|
841
841
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, ''); // name
|
|
842
|
-
const type = ObArTypes
|
|
842
|
+
const type = (0, helpers_1.ownValue)(ObArTypes, key);
|
|
843
843
|
if (!type)
|
|
844
844
|
throw new Error(`Not implemented ObArType for: ${key}`);
|
|
845
845
|
writeAsciiStringOrClassId(writer, type);
|