ag-psd 33.0.0 → 34.0.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/.v8-cache/v24.7.0-x64-ef5a0af0/05135617 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/226e2801 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/4511bacf +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/68416cb2 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/71df9cb3 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/7ea06cea +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/87cf2209 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/932f0770 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/acc36e66 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/b3c2fab7 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/c0b789d2 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/c314aece +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/cfc49f4f +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/d13d7610 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/dc86f000 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/e03e2acd +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/e6b99945 +0 -0
- package/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/README_PSD.md +25 -9
- package/TODO.md +13 -84
- package/dist/abr.js +12 -7
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.d.ts +2 -0
- package/dist/additionalInfo.js +361 -75
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +1524 -389
- package/dist/descriptor.d.ts +14 -5
- package/dist/descriptor.js +102 -64
- package/dist/descriptor.js.map +1 -1
- package/dist/helpers.d.ts +6 -0
- package/dist/helpers.js +242 -2
- package/dist/helpers.js.map +1 -1
- package/dist/imageResources.js +84 -3
- package/dist/imageResources.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/psd.d.ts +144 -2
- package/dist/psd.js.map +1 -1
- package/dist/psdReader.js +206 -110
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +1 -0
- package/dist/psdWriter.js +336 -91
- package/dist/psdWriter.js.map +1 -1
- package/dist/text.d.ts +32 -1
- package/dist/text.js +58 -0
- package/dist/text.js.map +1 -1
- package/dist-es/abr.js +12 -7
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.d.ts +2 -0
- package/dist-es/additionalInfo.js +361 -75
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/descriptor.d.ts +14 -5
- package/dist-es/descriptor.js +102 -64
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/helpers.d.ts +6 -0
- package/dist-es/helpers.js +242 -2
- package/dist-es/helpers.js.map +1 -1
- package/dist-es/imageResources.js +84 -3
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/index.d.ts +1 -0
- package/dist-es/index.js +1 -0
- package/dist-es/index.js.map +1 -1
- package/dist-es/psd.d.ts +144 -2
- package/dist-es/psd.js.map +1 -1
- package/dist-es/psdReader.js +206 -110
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +1 -0
- package/dist-es/psdWriter.js +336 -91
- package/dist-es/psdWriter.js.map +1 -1
- package/dist-es/text.d.ts +32 -1
- package/dist-es/text.js +58 -0
- package/dist-es/text.js.map +1 -1
- package/package.json +1 -1
- package/perf.js +312 -9
- package/src/abr.ts +14 -7
- package/src/additionalInfo.ts +433 -87
- package/src/descriptor.ts +103 -58
- package/src/helpers.ts +262 -2
- package/src/imageResources.ts +107 -4
- package/src/index.ts +1 -0
- package/src/psd.ts +115 -2
- package/src/psdReader.ts +226 -108
- package/src/psdWriter.ts +345 -90
- package/src/text.ts +76 -1
package/dist/descriptor.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { AntiAlias, BevelDirection, BevelStyle, BevelTechnique, BlendMode, Color, GlowSource, GlowTechnique, GradientStyle, InterpolationMethod, LayerEffectsInfo, LineAlignment, LineCapType, LineJoinType, Orientation, TextGridding, TimelineKeyInterpolation, TimelineTrack, TimelineTrackType, Units, UnitsBounds, UnitsValue, VectorContent, WarpStyle } from './psd';
|
|
2
2
|
import { PsdReader } from './psdReader';
|
|
3
3
|
import { PsdWriter } from './psdWriter';
|
|
4
|
-
|
|
4
|
+
interface Dict {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const cameraRawFilterClassID = "Adobe Camera Raw Filter";
|
|
8
|
+
export declare const cameraRawFilterKeyTypes: Dict;
|
|
5
9
|
export declare function readAsciiStringOrClassId(reader: PsdReader): string;
|
|
6
10
|
export declare function writeAsciiStringOrClassId(writer: PsdWriter, value: string): void;
|
|
7
11
|
export declare function readDescriptorStructure(reader: PsdReader, includeClass: boolean): any;
|
|
@@ -377,10 +381,10 @@ export interface LmfxDescriptor {
|
|
|
377
381
|
ChFX?: EffectDescriptor;
|
|
378
382
|
numModifyingFX?: number;
|
|
379
383
|
}
|
|
380
|
-
export declare function serializeEffects(e: LayerEffectsInfo,
|
|
381
|
-
export declare function parseEffects(info: Lfx2Descriptor & LmfxDescriptor,
|
|
382
|
-
export declare function parseTrackList(trackList: TimelineTrackDescriptor[],
|
|
383
|
-
export declare function serializeTrackList(tracks: TimelineTrack[]): TimelineTrackDescriptor[];
|
|
384
|
+
export declare function serializeEffects(e: LayerEffectsInfo, writer: PsdWriter, multi: boolean): Lfx2Descriptor & LmfxDescriptor;
|
|
385
|
+
export declare function parseEffects(info: Lfx2Descriptor & LmfxDescriptor, reader: PsdReader): LayerEffectsInfo;
|
|
386
|
+
export declare function parseTrackList(trackList: TimelineTrackDescriptor[], reader: PsdReader): TimelineTrack[];
|
|
387
|
+
export declare function serializeTrackList(tracks: TimelineTrack[], writer: PsdWriter): TimelineTrackDescriptor[];
|
|
384
388
|
export declare function parseVectorContent(descriptor: DescriptorVectorContent): VectorContent;
|
|
385
389
|
export declare function serializeVectorContent(content: VectorContent): {
|
|
386
390
|
descriptor: DescriptorVectorContent;
|
|
@@ -618,3 +622,8 @@ export declare const presetKindType: {
|
|
|
618
622
|
decode: (val: string) => "default" | "custom";
|
|
619
623
|
encode: (val: "default" | "custom" | undefined) => string;
|
|
620
624
|
};
|
|
625
|
+
export declare const patternColorHandling: {
|
|
626
|
+
decode: (val: string) => "convert" | "avoid conversion" | "luminance only";
|
|
627
|
+
encode: (val: "convert" | "avoid conversion" | "luminance only" | undefined) => string;
|
|
628
|
+
};
|
|
629
|
+
export {};
|
package/dist/descriptor.js
CHANGED
|
@@ -11,9 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
15
|
-
exports.presetKindType = exports.prjM = exports.FlMd = exports.IntC = exports.IntE = void 0;
|
|
16
|
-
exports.setLogErrors = setLogErrors;
|
|
14
|
+
exports.CntE = exports.FlCl = exports.ExtR = exports.ExtT = exports.DfsM = exports.blurType = exports.Lns = exports.MztT = exports.Chnl = exports.Dstr = exports.ZZTy = exports.Wvtp = exports.SphM = exports.RplS = exports.Cnvr = exports.UndA = exports.DspM = exports.SmBQ = exports.SmBM = exports.BlrQ = exports.BlrM = exports.strokeStyleLineAlignment = exports.strokeStyleLineJoinType = exports.strokeStyleLineCapType = exports.ESliceBGColorType = exports.ESliceOrigin = exports.ESliceVertAlign = exports.ESliceHorzAlign = exports.ESliceType = exports.FrFl = exports.FStl = exports.ClrS = exports.Clry = exports.gradientInterpolationMethodType = exports.stdTrackID = exports.animInterpStyleEnum = exports.GrdT = exports.IGSr = exports.BETE = exports.BESs = exports.bvlT = exports.BESl = exports.BlnM = exports.warpStyle = exports.Annt = exports.Ornt = exports.textGridding = exports.outputSettingsRoot = exports.cameraRawFilterKeyTypes = exports.cameraRawFilterClassID = void 0;
|
|
15
|
+
exports.patternColorHandling = exports.presetKindType = exports.prjM = exports.FlMd = exports.IntC = exports.IntE = exports.Drct = exports.WndM = void 0;
|
|
17
16
|
exports.readAsciiStringOrClassId = readAsciiStringOrClassId;
|
|
18
17
|
exports.writeAsciiStringOrClassId = writeAsciiStringOrClassId;
|
|
19
18
|
exports.readDescriptorStructure = readDescriptorStructure;
|
|
@@ -67,10 +66,6 @@ const unitsMap = {
|
|
|
67
66
|
'RrCm': 'Centimeters',
|
|
68
67
|
};
|
|
69
68
|
const unitsMapRev = revMap(unitsMap);
|
|
70
|
-
let logErrors = false;
|
|
71
|
-
function setLogErrors(value) {
|
|
72
|
-
logErrors = value;
|
|
73
|
-
}
|
|
74
69
|
function makeType(name, classID) {
|
|
75
70
|
return { name, classID };
|
|
76
71
|
}
|
|
@@ -116,6 +111,7 @@ const fieldToExtType = {
|
|
|
116
111
|
psVersion: nullType,
|
|
117
112
|
docDefaultNewArtboardBackgroundColor: makeType('', 'RGBC'),
|
|
118
113
|
artboardRect: makeType('', 'classFloatRect'),
|
|
114
|
+
framedGroupRect: makeType('', 'classFloatRect'),
|
|
119
115
|
keyOriginRRectRadii: makeType('', 'radii'),
|
|
120
116
|
keyOriginBoxCorners: nullType,
|
|
121
117
|
rectangleCornerA: makeType('', 'Pnt '),
|
|
@@ -201,7 +197,7 @@ const fieldToArrayExtType = {
|
|
|
201
197
|
const typeToField = {
|
|
202
198
|
'TEXT': [
|
|
203
199
|
'Txt ', 'printerName', 'Nm ', 'Idnt', 'blackAndWhitePresetFileName', 'LUT3DFileName', 'exportOption', 'scaleSettings',
|
|
204
|
-
'BackgroundImagePath', 'ImageSubfolderName',
|
|
200
|
+
'BackgroundImagePath', 'ImageSubfolderName', 'SavedIteratedName',
|
|
205
201
|
'presetFileName', 'curvesPresetFileName', 'mixerPresetFileName', 'placed', 'description', 'reason',
|
|
206
202
|
'artboardPresetName', 'json', 'clipID', 'relPath', 'fullPath', 'mediaDescriptor', 'Msge',
|
|
207
203
|
'altTag', 'url', 'cellText', 'preset', 'KnNm', 'FPth', 'comment', 'originalPath', 'Bk ', 'pathUnicodeName',
|
|
@@ -228,7 +224,7 @@ const typeToField = {
|
|
|
228
224
|
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN', 'NmbG', 'WLMn', 'WLMx', 'AmMn', 'AmMx', 'SclH', 'SclV',
|
|
229
225
|
'Lvl ', 'TlNm', 'TlOf', 'FlRs', 'Thsh', 'ShrS', 'ShrE', 'FlRs', 'Vrnc', 'Strg', 'ExtS', 'ExtD',
|
|
230
226
|
'HrzS', 'VrtS', 'NmbR', 'EdgF', 'Ang1', 'Ang2', 'Ang3', 'Ang4', 'lastAppliedComp', 'capturedInfo',
|
|
231
|
-
'pixelSourceType',
|
|
227
|
+
'pixelSourceType', 'framedGroupType',
|
|
232
228
|
],
|
|
233
229
|
'enum': [
|
|
234
230
|
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS', 'BlrQ',
|
|
@@ -252,7 +248,7 @@ const typeToField = {
|
|
|
252
248
|
'materialsDisclosed', 'hasMotion', 'muted', 'Effc', 'selected', 'autoScope', 'fillCanvas',
|
|
253
249
|
'cellTextIsHTML', 'Smoo', 'Clsp', 'validAtPosition', 'rigidType', 'hasoptions', 'filterMaskEnable',
|
|
254
250
|
'filterMaskLinked', 'filterMaskExtendWithWhite', 'removeJPEGArtifact', 'Mnch', 'ExtF', 'ExtM',
|
|
255
|
-
'moreAccurate', 'GpuY', 'LIWy', 'Cnty', 'Lnkd', 'showAlteredVideo', 'lightingOn',
|
|
251
|
+
'moreAccurate', 'GpuY', 'LIWy', 'Cnty', 'Lnkd', 'showAlteredVideo', 'lightingOn', 'LockPPI',
|
|
256
252
|
],
|
|
257
253
|
'doub': [
|
|
258
254
|
'warpValue', 'warpPerspective', 'warpPerspectiveOther', 'Intr', 'Wdth', 'Hght', 'Gmm ',
|
|
@@ -260,7 +256,7 @@ const typeToField = {
|
|
|
260
256
|
'xx', 'xy', 'yx', 'yy', 'tx', 'ty', 'FrGA', 'frameRate', 'audioLevel', 'rotation',
|
|
261
257
|
'X ', 'Y ', 'redFloat', 'greenFloat', 'blueFloat', 'imageResolution',
|
|
262
258
|
'PuX0', 'PuX1', 'PuX2', 'PuX3', 'PuY0', 'PuY1', 'PuY2', 'PuY3',
|
|
263
|
-
'stylization', 'cleanliness', 'brushScale', 'microBrush', 'specularity',
|
|
259
|
+
'stylization', 'cleanliness', 'brushScale', 'microBrush', 'specularity', 'PreferredResolution',
|
|
264
260
|
],
|
|
265
261
|
'UntF': [
|
|
266
262
|
'sdwO', 'hglO', 'lagl', 'Lald', 'srgR', 'blur', 'Sftn', 'Opct', 'Dstn', 'Angl',
|
|
@@ -289,6 +285,12 @@ const channels = [
|
|
|
289
285
|
// color classes whose channel values are written as doubles ('GRYC' and 'LABC' are kept for backwards compatibility)
|
|
290
286
|
const doubleColorClasses = ['Grsc', 'LbCl', 'GRYC', 'LABC'];
|
|
291
287
|
// fallback for unknown keys, based on the type of the value
|
|
288
|
+
exports.cameraRawFilterClassID = 'Adobe Camera Raw Filter';
|
|
289
|
+
// types of Camera Raw Filter settings (keys clash with other descriptors so they're typed by class)
|
|
290
|
+
exports.cameraRawFilterKeyTypes = {
|
|
291
|
+
CrVe: 'TEXT', PrVN: 'long', PrVe: 'long', WBal: 'enum', Ex12: 'doub', ShpR: 'doub',
|
|
292
|
+
'Crv ': 'VlLs', CrvR: 'VlLs', CrvG: 'VlLs', CrvB: 'VlLs',
|
|
293
|
+
};
|
|
292
294
|
function guessOSType(value) {
|
|
293
295
|
if (typeof value === 'boolean')
|
|
294
296
|
return 'bool';
|
|
@@ -464,8 +466,9 @@ function readDescriptorStructure(reader, includeClass) {
|
|
|
464
466
|
}
|
|
465
467
|
exports.outputSettingsRoot = 'outputSettings';
|
|
466
468
|
function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
var _a;
|
|
470
|
+
if (writer.logMissingFeatures && !classId)
|
|
471
|
+
writer.log('Missing classId for: ', name, classId, value);
|
|
469
472
|
// write class structure
|
|
470
473
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, name);
|
|
471
474
|
if (root === exports.outputSettingsRoot && classId === 'null') {
|
|
@@ -483,6 +486,10 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
483
486
|
let type = getTypeByKey(key, value[key], root, value);
|
|
484
487
|
let childRoot = root;
|
|
485
488
|
let extType = fieldToExtType[key];
|
|
489
|
+
if (classId === exports.cameraRawFilterClassID) {
|
|
490
|
+
type = (_a = exports.cameraRawFilterKeyTypes[key]) !== null && _a !== void 0 ? _a : 'long'; // other settings are integer levels
|
|
491
|
+
childRoot = exports.cameraRawFilterClassID; // lists (curves) contain integer levels
|
|
492
|
+
}
|
|
486
493
|
if (key === 'bounds' && root === 'text') {
|
|
487
494
|
extType = makeType('', 'bounds');
|
|
488
495
|
}
|
|
@@ -579,7 +586,7 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
579
586
|
extType = makeType('', 'patternLayer');
|
|
580
587
|
}
|
|
581
588
|
else {
|
|
582
|
-
|
|
589
|
+
writer.logMissingFeatures && writer.log('Invalid strokeStyleContent value', value[key]);
|
|
583
590
|
}
|
|
584
591
|
}
|
|
585
592
|
else if (key === 'bounds' && root === 'quiltWarp') {
|
|
@@ -601,8 +608,8 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
601
608
|
writeAsciiStringOrClassId(writer, key);
|
|
602
609
|
(0, psdWriter_1.writeSignature)(writer, type || 'long');
|
|
603
610
|
writeOSType(writer, type || 'long', value[key], key, extType, childRoot);
|
|
604
|
-
if (
|
|
605
|
-
|
|
611
|
+
if (writer.logMissingFeatures && !type)
|
|
612
|
+
writer.log(`Missing descriptor field type for: '${key}' in`, value);
|
|
606
613
|
}
|
|
607
614
|
}
|
|
608
615
|
function readOSType(reader, type, includeClass) {
|
|
@@ -723,11 +730,11 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
723
730
|
throw new Error(`Invalid list value: ${JSON.stringify(value)}, key: ${key}`);
|
|
724
731
|
(0, psdWriter_1.writeInt32)(writer, value.length);
|
|
725
732
|
for (let i = 0; i < value.length; i++) {
|
|
726
|
-
const type = (_a = fieldToArrayType[key]) !== null && _a !== void 0 ? _a : guessOSType(value[i]);
|
|
733
|
+
const type = root === exports.cameraRawFilterClassID ? 'long' : ((_a = fieldToArrayType[key]) !== null && _a !== void 0 ? _a : guessOSType(value[i]));
|
|
727
734
|
(0, psdWriter_1.writeSignature)(writer, type || 'long');
|
|
728
735
|
writeOSType(writer, type || 'long', value[i], `${key}[]`, fieldToArrayExtType[key], root);
|
|
729
|
-
if (
|
|
730
|
-
|
|
736
|
+
if (writer.logMissingFeatures && !type)
|
|
737
|
+
writer.log(`Missing descriptor array type for: '${key}' in`, value);
|
|
731
738
|
}
|
|
732
739
|
break;
|
|
733
740
|
case 'doub': // Double
|
|
@@ -1027,7 +1034,7 @@ function serializeFxObject(stroke) {
|
|
|
1027
1034
|
FrFX.overprint = !!stroke.overprint;
|
|
1028
1035
|
return FrFX;
|
|
1029
1036
|
}
|
|
1030
|
-
function serializeEffects(e,
|
|
1037
|
+
function serializeEffects(e, writer, multi) {
|
|
1031
1038
|
var _a, _b, _c;
|
|
1032
1039
|
const info = multi ? {
|
|
1033
1040
|
'Scl ': unitsPercentF((_a = e.scale) !== null && _a !== void 0 ? _a : 1),
|
|
@@ -1044,33 +1051,33 @@ function serializeEffects(e, log, multi) {
|
|
|
1044
1051
|
const useMulti = (arr) => !!arr && arr.length > 1 && multi;
|
|
1045
1052
|
const useSingle = (arr) => !!arr && arr.length >= 1 && (!multi || arr.length === 1);
|
|
1046
1053
|
if (useSingle(e.dropShadow))
|
|
1047
|
-
info.DrSh = serializeEffectObject(e.dropShadow[0], 'dropShadow',
|
|
1054
|
+
info.DrSh = serializeEffectObject(e.dropShadow[0], 'dropShadow', writer);
|
|
1048
1055
|
if (useMulti(e.dropShadow))
|
|
1049
|
-
info.dropShadowMulti = e.dropShadow.map(i => serializeEffectObject(i, 'dropShadow',
|
|
1056
|
+
info.dropShadowMulti = e.dropShadow.map(i => serializeEffectObject(i, 'dropShadow', writer));
|
|
1050
1057
|
if (useSingle(e.innerShadow))
|
|
1051
|
-
info.IrSh = serializeEffectObject(e.innerShadow[0], 'innerShadow',
|
|
1058
|
+
info.IrSh = serializeEffectObject(e.innerShadow[0], 'innerShadow', writer);
|
|
1052
1059
|
if (useMulti(e.innerShadow))
|
|
1053
|
-
info.innerShadowMulti = e.innerShadow.map(i => serializeEffectObject(i, 'innerShadow',
|
|
1060
|
+
info.innerShadowMulti = e.innerShadow.map(i => serializeEffectObject(i, 'innerShadow', writer));
|
|
1054
1061
|
if (e.outerGlow)
|
|
1055
|
-
info.OrGl = serializeEffectObject(e.outerGlow, 'outerGlow',
|
|
1062
|
+
info.OrGl = serializeEffectObject(e.outerGlow, 'outerGlow', writer);
|
|
1056
1063
|
if (useMulti(e.solidFill))
|
|
1057
|
-
info.solidFillMulti = e.solidFill.map(i => serializeEffectObject(i, 'solidFill',
|
|
1064
|
+
info.solidFillMulti = e.solidFill.map(i => serializeEffectObject(i, 'solidFill', writer));
|
|
1058
1065
|
if (useMulti(e.gradientOverlay))
|
|
1059
|
-
info.gradientFillMulti = e.gradientOverlay.map(i => serializeEffectObject(i, 'gradientOverlay',
|
|
1066
|
+
info.gradientFillMulti = e.gradientOverlay.map(i => serializeEffectObject(i, 'gradientOverlay', writer));
|
|
1060
1067
|
if (useMulti(e.stroke))
|
|
1061
1068
|
info.frameFXMulti = e.stroke.map(i => serializeFxObject(i));
|
|
1062
1069
|
if (e.innerGlow)
|
|
1063
|
-
info.IrGl = serializeEffectObject(e.innerGlow, 'innerGlow',
|
|
1070
|
+
info.IrGl = serializeEffectObject(e.innerGlow, 'innerGlow', writer);
|
|
1064
1071
|
if (e.bevel)
|
|
1065
|
-
info.ebbl = serializeEffectObject(e.bevel, 'bevel',
|
|
1072
|
+
info.ebbl = serializeEffectObject(e.bevel, 'bevel', writer);
|
|
1066
1073
|
if (useSingle(e.solidFill))
|
|
1067
|
-
info.SoFi = serializeEffectObject(e.solidFill[0], 'solidFill',
|
|
1074
|
+
info.SoFi = serializeEffectObject(e.solidFill[0], 'solidFill', writer);
|
|
1068
1075
|
if (e.patternOverlay)
|
|
1069
|
-
info.patternFill = serializeEffectObject(e.patternOverlay, 'patternOverlay',
|
|
1076
|
+
info.patternFill = serializeEffectObject(e.patternOverlay, 'patternOverlay', writer);
|
|
1070
1077
|
if (useSingle(e.gradientOverlay))
|
|
1071
|
-
info.GrFl = serializeEffectObject(e.gradientOverlay[0], 'gradientOverlay',
|
|
1078
|
+
info.GrFl = serializeEffectObject(e.gradientOverlay[0], 'gradientOverlay', writer);
|
|
1072
1079
|
if (e.satin)
|
|
1073
|
-
info.ChFX = serializeEffectObject(e.satin, 'satin',
|
|
1080
|
+
info.ChFX = serializeEffectObject(e.satin, 'satin', writer);
|
|
1074
1081
|
if (useSingle(e.stroke))
|
|
1075
1082
|
info.FrFX = serializeFxObject((_c = e.stroke) === null || _c === void 0 ? void 0 : _c[0]);
|
|
1076
1083
|
if (multi) {
|
|
@@ -1092,7 +1099,7 @@ function serializeEffects(e, log, multi) {
|
|
|
1092
1099
|
}
|
|
1093
1100
|
return info;
|
|
1094
1101
|
}
|
|
1095
|
-
function parseEffects(info,
|
|
1102
|
+
function parseEffects(info, reader) {
|
|
1096
1103
|
const effects = {};
|
|
1097
1104
|
const _a = info, { _name, _classID, 'Scl ': scale, masterFXSwitch, DrSh, dropShadowMulti, IrSh, innerShadowMulti, OrGl, IrGl, ebbl, SoFi, solidFillMulti, patternFill, GrFl, gradientFillMulti, ChFX, FrFX, frameFXMulti, numModifyingFX } = _a, rest = __rest(_a, ["_name", "_classID", 'Scl ', "masterFXSwitch", "DrSh", "dropShadowMulti", "IrSh", "innerShadowMulti", "OrGl", "IrGl", "ebbl", "SoFi", "solidFillMulti", "patternFill", "GrFl", "gradientFillMulti", "ChFX", "FrFX", "frameFXMulti", "numModifyingFX"]);
|
|
1098
1105
|
if (!masterFXSwitch)
|
|
@@ -1100,40 +1107,40 @@ function parseEffects(info, log) {
|
|
|
1100
1107
|
if (scale)
|
|
1101
1108
|
effects.scale = parsePercent(scale);
|
|
1102
1109
|
if (DrSh)
|
|
1103
|
-
effects.dropShadow = [parseEffectObject(DrSh,
|
|
1110
|
+
effects.dropShadow = [parseEffectObject(DrSh, reader)];
|
|
1104
1111
|
if (dropShadowMulti)
|
|
1105
|
-
effects.dropShadow = dropShadowMulti.map(i => parseEffectObject(i,
|
|
1112
|
+
effects.dropShadow = dropShadowMulti.map(i => parseEffectObject(i, reader));
|
|
1106
1113
|
if (IrSh)
|
|
1107
|
-
effects.innerShadow = [parseEffectObject(IrSh,
|
|
1114
|
+
effects.innerShadow = [parseEffectObject(IrSh, reader)];
|
|
1108
1115
|
if (innerShadowMulti)
|
|
1109
|
-
effects.innerShadow = innerShadowMulti.map(i => parseEffectObject(i,
|
|
1116
|
+
effects.innerShadow = innerShadowMulti.map(i => parseEffectObject(i, reader));
|
|
1110
1117
|
if (OrGl)
|
|
1111
|
-
effects.outerGlow = parseEffectObject(OrGl,
|
|
1118
|
+
effects.outerGlow = parseEffectObject(OrGl, reader);
|
|
1112
1119
|
if (IrGl)
|
|
1113
|
-
effects.innerGlow = parseEffectObject(IrGl,
|
|
1120
|
+
effects.innerGlow = parseEffectObject(IrGl, reader);
|
|
1114
1121
|
if (ebbl)
|
|
1115
|
-
effects.bevel = parseEffectObject(ebbl,
|
|
1122
|
+
effects.bevel = parseEffectObject(ebbl, reader, 'bevel');
|
|
1116
1123
|
if (SoFi)
|
|
1117
|
-
effects.solidFill = [parseEffectObject(SoFi,
|
|
1124
|
+
effects.solidFill = [parseEffectObject(SoFi, reader)];
|
|
1118
1125
|
if (solidFillMulti)
|
|
1119
|
-
effects.solidFill = solidFillMulti.map(i => parseEffectObject(i,
|
|
1126
|
+
effects.solidFill = solidFillMulti.map(i => parseEffectObject(i, reader));
|
|
1120
1127
|
if (patternFill)
|
|
1121
|
-
effects.patternOverlay = parseEffectObject(patternFill,
|
|
1128
|
+
effects.patternOverlay = parseEffectObject(patternFill, reader);
|
|
1122
1129
|
if (GrFl)
|
|
1123
|
-
effects.gradientOverlay = [parseEffectObject(GrFl,
|
|
1130
|
+
effects.gradientOverlay = [parseEffectObject(GrFl, reader)];
|
|
1124
1131
|
if (gradientFillMulti)
|
|
1125
|
-
effects.gradientOverlay = gradientFillMulti.map(i => parseEffectObject(i,
|
|
1132
|
+
effects.gradientOverlay = gradientFillMulti.map(i => parseEffectObject(i, reader));
|
|
1126
1133
|
if (ChFX)
|
|
1127
|
-
effects.satin = parseEffectObject(ChFX,
|
|
1134
|
+
effects.satin = parseEffectObject(ChFX, reader);
|
|
1128
1135
|
if (FrFX)
|
|
1129
1136
|
effects.stroke = [parseFxObject(FrFX)];
|
|
1130
1137
|
if (frameFXMulti)
|
|
1131
1138
|
effects.stroke = frameFXMulti.map(i => parseFxObject(i));
|
|
1132
|
-
if (
|
|
1133
|
-
|
|
1139
|
+
if (reader.logMissingFeatures && Object.keys(rest).length)
|
|
1140
|
+
reader.log('Unhandled effect keys:', rest);
|
|
1134
1141
|
return effects;
|
|
1135
1142
|
}
|
|
1136
|
-
function parseKeyList(keyList,
|
|
1143
|
+
function parseKeyList(keyList, reader) {
|
|
1137
1144
|
const keys = [];
|
|
1138
1145
|
for (let j = 0; j < keyList.length; j++) {
|
|
1139
1146
|
const key = keyList[j];
|
|
@@ -1156,7 +1163,7 @@ function parseKeyList(keyList, logMissingFeatures) {
|
|
|
1156
1163
|
case 'keyType.sheetStyle': {
|
|
1157
1164
|
const key = { interpolation, time, selected, type: 'style' };
|
|
1158
1165
|
if (animKey.sheetStyle.Lefx)
|
|
1159
|
-
key.style = parseEffects(animKey.sheetStyle.Lefx,
|
|
1166
|
+
key.style = parseEffects(animKey.sheetStyle.Lefx, reader);
|
|
1160
1167
|
keys.push(key);
|
|
1161
1168
|
break;
|
|
1162
1169
|
}
|
|
@@ -1172,7 +1179,7 @@ function parseKeyList(keyList, logMissingFeatures) {
|
|
|
1172
1179
|
}
|
|
1173
1180
|
return keys;
|
|
1174
1181
|
}
|
|
1175
|
-
function serializeKeyList(keys) {
|
|
1182
|
+
function serializeKeyList(keys, writer) {
|
|
1176
1183
|
const keyList = [];
|
|
1177
1184
|
for (let j = 0; j < keys.length; j++) {
|
|
1178
1185
|
const key = keys[j];
|
|
@@ -1192,7 +1199,7 @@ function serializeKeyList(keys) {
|
|
|
1192
1199
|
case 'style':
|
|
1193
1200
|
animKey = { Type: 'keyType.sheetStyle', sheetStyle: { Vrsn: 1, blendOptions: {} } };
|
|
1194
1201
|
if (key.style)
|
|
1195
|
-
animKey.sheetStyle = { Vrsn: 1, Lefx: serializeEffects(key.style,
|
|
1202
|
+
animKey.sheetStyle = { Vrsn: 1, Lefx: serializeEffects(key.style, writer, false), blendOptions: {} };
|
|
1196
1203
|
break;
|
|
1197
1204
|
case 'globalLighting': {
|
|
1198
1205
|
animKey = { Type: 'keyType.globalLighting', gblA: key.globalAngle, globalAltitude: key.globalAltitude };
|
|
@@ -1204,41 +1211,41 @@ function serializeKeyList(keys) {
|
|
|
1204
1211
|
}
|
|
1205
1212
|
return keyList;
|
|
1206
1213
|
}
|
|
1207
|
-
function parseTrackList(trackList,
|
|
1214
|
+
function parseTrackList(trackList, reader) {
|
|
1208
1215
|
const tracks = [];
|
|
1209
1216
|
for (let i = 0; i < trackList.length; i++) {
|
|
1210
1217
|
const tr = trackList[i];
|
|
1211
1218
|
const track = {
|
|
1212
1219
|
type: exports.stdTrackID.decode(tr.trackID),
|
|
1213
1220
|
enabled: tr.enab,
|
|
1214
|
-
keys: parseKeyList(tr.keyList,
|
|
1221
|
+
keys: parseKeyList(tr.keyList, reader),
|
|
1215
1222
|
};
|
|
1216
1223
|
if (tr.effectParams) {
|
|
1217
1224
|
track.effectParams = {
|
|
1218
1225
|
fillCanvas: tr.effectParams.fillCanvas,
|
|
1219
1226
|
zoomOrigin: tr.effectParams.zoomOrigin,
|
|
1220
|
-
keys: parseKeyList(tr.effectParams.keyList,
|
|
1227
|
+
keys: parseKeyList(tr.effectParams.keyList, reader),
|
|
1221
1228
|
};
|
|
1222
1229
|
}
|
|
1223
1230
|
tracks.push(track);
|
|
1224
1231
|
}
|
|
1225
1232
|
return tracks;
|
|
1226
1233
|
}
|
|
1227
|
-
function serializeTrackList(tracks) {
|
|
1234
|
+
function serializeTrackList(tracks, writer) {
|
|
1228
1235
|
const trackList = [];
|
|
1229
1236
|
for (let i = 0; i < tracks.length; i++) {
|
|
1230
1237
|
const t = tracks[i];
|
|
1231
1238
|
trackList.push(Object.assign(Object.assign({ trackID: exports.stdTrackID.encode(t.type), Vrsn: 1, enab: !!t.enabled, Effc: !!t.effectParams }, (t.effectParams ? {
|
|
1232
1239
|
effectParams: {
|
|
1233
|
-
keyList: serializeKeyList(t.effectParams.keys),
|
|
1240
|
+
keyList: serializeKeyList(t.effectParams.keys, writer),
|
|
1234
1241
|
fillCanvas: t.effectParams.fillCanvas,
|
|
1235
1242
|
zoomOrigin: t.effectParams.zoomOrigin,
|
|
1236
1243
|
}
|
|
1237
|
-
} : {})), { keyList: serializeKeyList(t.keys) }));
|
|
1244
|
+
} : {})), { keyList: serializeKeyList(t.keys, writer) }));
|
|
1238
1245
|
}
|
|
1239
1246
|
return trackList;
|
|
1240
1247
|
}
|
|
1241
|
-
function parseEffectObject(obj,
|
|
1248
|
+
function parseEffectObject(obj, reader, objName) {
|
|
1242
1249
|
const result = {};
|
|
1243
1250
|
for (const key of Object.keys(obj)) {
|
|
1244
1251
|
const val = obj[key];
|
|
@@ -1391,12 +1398,12 @@ function parseEffectObject(obj, reportErrors, objName) {
|
|
|
1391
1398
|
case '_classID':
|
|
1392
1399
|
break;
|
|
1393
1400
|
default:
|
|
1394
|
-
|
|
1401
|
+
reader.logMissingFeatures && reader.log(`Invalid effect key: '${key}', value:`, val);
|
|
1395
1402
|
}
|
|
1396
1403
|
}
|
|
1397
1404
|
return result;
|
|
1398
1405
|
}
|
|
1399
|
-
function serializeEffectObject(obj, objName,
|
|
1406
|
+
function serializeEffectObject(obj, objName, writer) {
|
|
1400
1407
|
const result = {
|
|
1401
1408
|
enab: false,
|
|
1402
1409
|
};
|
|
@@ -1546,7 +1553,7 @@ function serializeEffectObject(obj, objName, reportErrors) {
|
|
|
1546
1553
|
result[key] = val;
|
|
1547
1554
|
break;
|
|
1548
1555
|
default:
|
|
1549
|
-
|
|
1556
|
+
writer.logMissingFeatures && writer.log(`Invalid effect key: '${key}', value:`, val);
|
|
1550
1557
|
}
|
|
1551
1558
|
}
|
|
1552
1559
|
return result;
|
|
@@ -1791,6 +1798,21 @@ function isBookColor(color) {
|
|
|
1791
1798
|
return color._classID === 'BkCl' || 'Bk ' in color || 'bookID' in color;
|
|
1792
1799
|
}
|
|
1793
1800
|
function parseColor(color) {
|
|
1801
|
+
var _a, _b, _c;
|
|
1802
|
+
const result = parseColorValues(color);
|
|
1803
|
+
if (isBookColor(color)) {
|
|
1804
|
+
const book = color;
|
|
1805
|
+
const key = book.bookKey;
|
|
1806
|
+
result.book = {
|
|
1807
|
+
book: (_a = book['Bk ']) !== null && _a !== void 0 ? _a : '',
|
|
1808
|
+
name: (_b = book['Nm ']) !== null && _b !== void 0 ? _b : '',
|
|
1809
|
+
bookID: (_c = book.bookID) !== null && _c !== void 0 ? _c : 0,
|
|
1810
|
+
bookKey: typeof key === 'string' ? key : (key ? String.fromCharCode(...Array.from(key)) : ''),
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
return result;
|
|
1814
|
+
}
|
|
1815
|
+
function parseColorValues(color) {
|
|
1794
1816
|
if ('H ' in color) {
|
|
1795
1817
|
return { h: parsePercentOrAngle(color['H ']), s: color.Strt / 100, b: color.Brgh / 100 };
|
|
1796
1818
|
}
|
|
@@ -1815,13 +1837,24 @@ function parseColor(color) {
|
|
|
1815
1837
|
return { fr: color.redFloat, fg: color.greenFloat, fb: color.blueFloat };
|
|
1816
1838
|
}
|
|
1817
1839
|
else if (isBookColor(color)) {
|
|
1818
|
-
return { r: 0, g: 0, b: 0 }; // book (Pantone)
|
|
1840
|
+
return { r: 0, g: 0, b: 0 }; // book (Pantone) color without color values
|
|
1819
1841
|
}
|
|
1820
1842
|
else {
|
|
1821
1843
|
throw new Error('Unsupported color descriptor');
|
|
1822
1844
|
}
|
|
1823
1845
|
}
|
|
1824
1846
|
function serializeColor(color) {
|
|
1847
|
+
const result = serializeColorValues(color);
|
|
1848
|
+
if (color === null || color === void 0 ? void 0 : color.book) {
|
|
1849
|
+
const { book, name, bookID, bookKey } = color.book;
|
|
1850
|
+
const key = new Uint8Array(bookKey.length);
|
|
1851
|
+
for (let i = 0; i < key.length; i++)
|
|
1852
|
+
key[i] = bookKey.charCodeAt(i) & 0xff;
|
|
1853
|
+
Object.assign(result, { 'Bk ': book, 'Nm ': name, bookID, bookKey: key });
|
|
1854
|
+
}
|
|
1855
|
+
return result;
|
|
1856
|
+
}
|
|
1857
|
+
function serializeColorValues(color) {
|
|
1825
1858
|
if (!color) {
|
|
1826
1859
|
return { _name: '', _classID: 'RGBC', 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1827
1860
|
}
|
|
@@ -2247,4 +2280,9 @@ exports.presetKindType = (0, helpers_1.createEnum)('presetKindType', 'custom', {
|
|
|
2247
2280
|
custom: 'presetKindCustom',
|
|
2248
2281
|
default: 'presetKindDefault',
|
|
2249
2282
|
});
|
|
2283
|
+
exports.patternColorHandling = (0, helpers_1.createEnum)('', 'convert', {
|
|
2284
|
+
'convert': 'conv',
|
|
2285
|
+
'avoid conversion': 'avod',
|
|
2286
|
+
'luminance only': 'lumi',
|
|
2287
|
+
});
|
|
2250
2288
|
//# sourceMappingURL=descriptor.js.map
|