ag-psd 16.0.0 → 17.0.1
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 +9 -0
- package/README.md +1 -0
- package/dist/additionalInfo.js +933 -247
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +1299 -325
- package/dist/descriptor.d.ts +140 -1
- package/dist/descriptor.js +297 -37
- package/dist/descriptor.js.map +1 -1
- package/dist/imageResources.js +13 -21
- package/dist/imageResources.js.map +1 -1
- package/dist/psd.d.ts +445 -62
- package/dist/psdReader.d.ts +2 -0
- package/dist/psdReader.js +30 -13
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +4 -0
- package/dist/psdWriter.js +26 -7
- package/dist/psdWriter.js.map +1 -1
- package/dist-es/additionalInfo.js +934 -248
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/descriptor.d.ts +140 -1
- package/dist-es/descriptor.js +293 -38
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/imageResources.js +14 -22
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/psd.d.ts +445 -62
- package/dist-es/psdReader.d.ts +2 -0
- package/dist-es/psdReader.js +27 -12
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +4 -0
- package/dist-es/psdWriter.js +22 -7
- package/dist-es/psdWriter.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +2014 -289
- package/src/descriptor.ts +329 -39
- package/src/imageResources.ts +18 -23
- package/src/psd.ts +477 -46
- package/src/psdReader.ts +26 -7
- package/src/psdWriter.ts +25 -8
package/dist-es/descriptor.js
CHANGED
|
@@ -10,8 +10,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { createEnum } from './helpers';
|
|
13
|
-
import { readSignature, readUnicodeString, readUint32, readUint8, readFloat64, readBytes, readAsciiString, readInt32, readFloat32, readInt32LE,
|
|
14
|
-
import { writeSignature, writeBytes, writeUint32, writeFloat64, writeUint8, writeUnicodeStringWithPadding, writeInt32, writeFloat32, writeUnicodeString } from './psdWriter';
|
|
13
|
+
import { readSignature, readUnicodeString, readUint32, readUint8, readFloat64, readBytes, readAsciiString, readInt32, readFloat32, readInt32LE, readUnicodeStringWithLengthLE } from './psdReader';
|
|
14
|
+
import { writeSignature, writeBytes, writeUint32, writeFloat64, writeUint8, writeUnicodeStringWithPadding, writeInt32, writeFloat32, writeUnicodeString, writeInt32LE, writeUnicodeStringWithoutLengthLE } from './psdWriter';
|
|
15
15
|
function revMap(map) {
|
|
16
16
|
var result = {};
|
|
17
17
|
Object.keys(map).forEach(function (key) { return result[map[key]] = key; });
|
|
@@ -102,6 +102,7 @@ var fieldToExtType = {
|
|
|
102
102
|
sheetStyle: nullType,
|
|
103
103
|
translation: nullType,
|
|
104
104
|
Skew: nullType,
|
|
105
|
+
boundingBox: makeType('', 'boundingBox'),
|
|
105
106
|
'Lnk ': makeType('', 'ExternalFileLink'),
|
|
106
107
|
frameReader: makeType('', 'FrameReader'),
|
|
107
108
|
effectParams: makeType('', 'motionTrackEffectParams'),
|
|
@@ -109,11 +110,15 @@ var fieldToExtType = {
|
|
|
109
110
|
Anch: makeType('', 'Pnt '),
|
|
110
111
|
'Fwd ': makeType('', 'Pnt '),
|
|
111
112
|
'Bwd ': makeType('', 'Pnt '),
|
|
113
|
+
FlrC: makeType('', 'Pnt '),
|
|
112
114
|
meshBoundaryPath: makeType('', 'pathClass'),
|
|
113
115
|
filterFX: makeType('', 'filterFXStyle'),
|
|
114
116
|
Fltr: makeType('', 'rigidTransform'),
|
|
115
117
|
FrgC: makeType('', 'RGBC'),
|
|
116
118
|
BckC: makeType('', 'RGBC'),
|
|
119
|
+
sdwM: makeType('Parameters', 'adaptCorrectTones'),
|
|
120
|
+
hglM: makeType('Parameters', 'adaptCorrectTones'),
|
|
121
|
+
customShape: makeType('', 'customShape'),
|
|
117
122
|
};
|
|
118
123
|
var fieldToArrayExtType = {
|
|
119
124
|
'Crv ': makeType('', 'CrPt'),
|
|
@@ -142,15 +147,20 @@ var fieldToArrayExtType = {
|
|
|
142
147
|
pathComponents: makeType('', 'PaCm'),
|
|
143
148
|
filterFXList: makeType('', 'filterFX'),
|
|
144
149
|
puppetShapeList: makeType('', 'puppetShape'),
|
|
150
|
+
channelDenoise: makeType('', 'channelDenoiseParams'),
|
|
151
|
+
ShrP: makeType('', 'Pnt '),
|
|
145
152
|
};
|
|
146
153
|
var typeToField = {
|
|
147
154
|
'TEXT': [
|
|
148
155
|
'Txt ', 'printerName', 'Nm ', 'Idnt', 'blackAndWhitePresetFileName', 'LUT3DFileName',
|
|
149
156
|
'presetFileName', 'curvesPresetFileName', 'mixerPresetFileName', 'placed', 'description', 'reason',
|
|
150
157
|
'artboardPresetName', 'json', 'clipID', 'relPath', 'fullPath', 'mediaDescriptor', 'Msge',
|
|
151
|
-
'altTag', 'url', 'cellText',
|
|
158
|
+
'altTag', 'url', 'cellText', 'preset', 'KnNm', 'FPth',
|
|
159
|
+
],
|
|
160
|
+
'tdta': [
|
|
161
|
+
'EngineData', 'LUT3DFileData', 'indexArray', 'originalVertexArray', 'deformedVertexArray',
|
|
162
|
+
'LqMe',
|
|
152
163
|
],
|
|
153
|
-
'tdta': ['EngineData', 'LUT3DFileData', 'indexArray', 'originalVertexArray', 'deformedVertexArray'],
|
|
154
164
|
'long': [
|
|
155
165
|
'TextIndex', 'RndS', 'Mdpn', 'Smth', 'Lctn', 'strokeStyleVersion', 'LaID', 'Vrsn', 'Cnt ',
|
|
156
166
|
'Brgh', 'Cntr', 'means', 'vibrance', 'Strt', 'bwPresetKind', 'presetKind', 'comp', 'compID', 'originalCompID',
|
|
@@ -161,16 +171,19 @@ var typeToField = {
|
|
|
161
171
|
'numBefore', 'numAfter', 'Spcn', 'minOpacity', 'maxOpacity', 'BlnM', 'sheetID', 'gblA', 'globalAltitude',
|
|
162
172
|
'descVersion', 'frameReaderType', 'LyrI', 'zoomOrigin', 'fontSize', 'Rds ', 'sliceID',
|
|
163
173
|
'topOutset', 'leftOutset', 'bottomOutset', 'rightOutset', 'filterID', 'meshQuality',
|
|
164
|
-
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN',
|
|
174
|
+
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN', 'NmbG', 'WLMn', 'WLMx', 'AmMn', 'AmMx', 'SclH', 'SclV',
|
|
175
|
+
'Lvl ', 'TlNm', 'TlOf', 'FlRs', 'Thsh', 'ShrS', 'ShrE', 'FlRs', 'Vrnc', 'Strg', 'ExtS', 'ExtD',
|
|
176
|
+
'HrzS', 'VrtS', 'NmbR', 'EdgF', 'Ang1', 'Ang2', 'Ang3', 'Ang4',
|
|
165
177
|
],
|
|
166
178
|
'enum': [
|
|
167
|
-
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS',
|
|
168
|
-
'
|
|
179
|
+
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS', 'BlrQ',
|
|
180
|
+
'bvlT', 'bvlS', 'bvlD', 'Md ', 'glwS', 'GrdF', 'GlwT', 'RplS', 'BlrM', 'SmBM',
|
|
169
181
|
'strokeStyleLineCapType', 'strokeStyleLineJoinType', 'strokeStyleLineAlignment',
|
|
170
182
|
'strokeStyleBlendMode', 'PntT', 'Styl', 'lookupType', 'LUTFormat', 'dataOrder',
|
|
171
183
|
'tableOrder', 'enableCompCore', 'enableCompCoreGPU', 'compCoreSupport', 'compCoreGPUSupport', 'Engn',
|
|
172
184
|
'enableCompCoreThreads', 'gs99', 'FrDs', 'trackID', 'animInterpStyle', 'horzAlign',
|
|
173
|
-
'vertAlign', 'bgColorType', 'shapeOperation',
|
|
185
|
+
'vertAlign', 'bgColorType', 'shapeOperation', 'UndA', 'Wvtp', 'Drct', 'WndM', 'Edg ', 'FlCl', 'IntE',
|
|
186
|
+
'IntC', 'Cnvr', 'Fl ', 'Dstr', 'MztT', 'Lns ', 'ExtT', 'DspM', 'ExtR', 'ZZTy', 'SphM', 'SmBQ',
|
|
174
187
|
],
|
|
175
188
|
'bool': [
|
|
176
189
|
'PstS', 'printSixteenBit', 'masterFXSwitch', 'enab', 'uglg', 'antialiasGloss',
|
|
@@ -182,7 +195,8 @@ var typeToField = {
|
|
|
182
195
|
'present', 'showInDialog', 'overprint', 'sheetDisclosed', 'lightsDisclosed', 'meshesDisclosed',
|
|
183
196
|
'materialsDisclosed', 'hasMotion', 'muted', 'Effc', 'selected', 'autoScope', 'fillCanvas',
|
|
184
197
|
'cellTextIsHTML', 'Smoo', 'Clsp', 'validAtPosition', 'rigidType', 'hasoptions', 'filterMaskEnable',
|
|
185
|
-
'filterMaskLinked', 'filterMaskExtendWithWhite',
|
|
198
|
+
'filterMaskLinked', 'filterMaskExtendWithWhite', 'removeJPEGArtifact', 'Mnch', 'ExtF', 'ExtM',
|
|
199
|
+
'moreAccurate', 'GpuY', 'LIWy',
|
|
186
200
|
],
|
|
187
201
|
'doub': [
|
|
188
202
|
'warpValue', 'warpPerspective', 'warpPerspectiveOther', 'Intr', 'Wdth', 'Hght',
|
|
@@ -192,10 +206,10 @@ var typeToField = {
|
|
|
192
206
|
'PuX0', 'PuX1', 'PuX2', 'PuX3', 'PuY0', 'PuY1', 'PuY2', 'PuY3'
|
|
193
207
|
],
|
|
194
208
|
'UntF': [
|
|
195
|
-
'
|
|
209
|
+
'sdwO', 'hglO', 'lagl', 'Lald', 'srgR', 'blur', 'Sftn', 'Opct', 'Dstn', 'Angl',
|
|
196
210
|
'Ckmt', 'Nose', 'Inpr', 'ShdN', 'strokeStyleLineWidth', 'strokeStyleLineDashOffset',
|
|
197
211
|
'strokeStyleOpacity', 'H ', 'Top ', 'Left', 'Btom', 'Rght', 'Rslt',
|
|
198
|
-
'topRight', 'topLeft', 'bottomLeft', 'bottomRight',
|
|
212
|
+
'topRight', 'topLeft', 'bottomLeft', 'bottomRight', 'ClNs', 'Shrp',
|
|
199
213
|
],
|
|
200
214
|
'VlLs': [
|
|
201
215
|
'Crv ', 'Clrs', 'Mnm ', 'Mxm ', 'Trns', 'pathList', 'strokeStyleLineDashSet', 'FrLs', 'slices',
|
|
@@ -203,10 +217,12 @@ var typeToField = {
|
|
|
203
217
|
'solidFillMulti', 'frameFXMulti', 'innerShadowMulti', 'dropShadowMulti', 'FrIn', 'FSts', 'FsFr',
|
|
204
218
|
'sheetTimelineOptions', 'audioClipList', 'trackList', 'globalTrackList', 'keyList', 'audioClipList',
|
|
205
219
|
'warpValues', 'selectedPin', 'Pts ', 'SbpL', 'pathComponents', 'pinOffsets', 'posFinalPins',
|
|
206
|
-
'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList',
|
|
220
|
+
'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList', 'ShrP',
|
|
221
|
+
'channelDenoise', 'Mtrx',
|
|
207
222
|
],
|
|
208
223
|
'ObAr': ['meshPoints', 'quiltSliceX', 'quiltSliceY'],
|
|
209
|
-
'obj ': ['null'],
|
|
224
|
+
'obj ': ['null', 'Chnl'],
|
|
225
|
+
'Pth ': ['DspF'],
|
|
210
226
|
};
|
|
211
227
|
var channels = [
|
|
212
228
|
'Rd ', 'Grn ', 'Bl ', 'Yllw', 'Ylw ', 'Cyn ', 'Mgnt', 'Blck', 'Gry ', 'Lmnc', 'A ', 'B ',
|
|
@@ -245,6 +261,9 @@ var fieldToArrayType = {
|
|
|
245
261
|
PnDp: 'doub',
|
|
246
262
|
filterFXList: 'Objc',
|
|
247
263
|
puppetShapeList: 'Objc',
|
|
264
|
+
ShrP: 'Objc',
|
|
265
|
+
channelDenoise: 'Objc',
|
|
266
|
+
Mtrx: 'long',
|
|
248
267
|
};
|
|
249
268
|
var fieldToType = {};
|
|
250
269
|
for (var _i = 0, _a = Object.keys(typeToField); _i < _a.length; _i++) {
|
|
@@ -319,11 +338,12 @@ function writeAsciiStringOrClassId(writer, value) {
|
|
|
319
338
|
}
|
|
320
339
|
}
|
|
321
340
|
export function readDescriptorStructure(reader) {
|
|
322
|
-
|
|
323
|
-
// object.__struct =
|
|
341
|
+
// const struct =
|
|
324
342
|
readClassStructure(reader);
|
|
343
|
+
// const object: any = { _name: struct.name, _classID: struct.classID };
|
|
344
|
+
var object = {};
|
|
345
|
+
// console.log('>> ', struct);
|
|
325
346
|
var itemsCount = readUint32(reader);
|
|
326
|
-
// console.log('//', object.__struct);
|
|
327
347
|
for (var i = 0; i < itemsCount; i++) {
|
|
328
348
|
var key = readAsciiStringOrClassId(reader);
|
|
329
349
|
var type = readSignature(reader);
|
|
@@ -341,21 +361,63 @@ export function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
341
361
|
writeUnicodeStringWithPadding(writer, name);
|
|
342
362
|
writeAsciiStringOrClassId(writer, classId);
|
|
343
363
|
var keys = Object.keys(value);
|
|
344
|
-
|
|
364
|
+
var keyCount = keys.length;
|
|
365
|
+
if ('_name' in value)
|
|
366
|
+
keyCount--;
|
|
367
|
+
if ('_classID' in value)
|
|
368
|
+
keyCount--;
|
|
369
|
+
writeUint32(writer, keyCount);
|
|
345
370
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
346
371
|
var key = keys_1[_i];
|
|
372
|
+
if (key === '_name' || key === '_classID')
|
|
373
|
+
continue;
|
|
347
374
|
var type = getTypeByKey(key, value[key], root, value);
|
|
348
375
|
var extType = fieldToExtType[key];
|
|
349
|
-
if (key === '
|
|
376
|
+
if (key === 'bounds' && root === 'text') {
|
|
377
|
+
extType = makeType('', 'bounds');
|
|
378
|
+
}
|
|
379
|
+
else if (key === 'origin') {
|
|
350
380
|
type = root === 'slices' ? 'enum' : 'Objc';
|
|
351
381
|
}
|
|
382
|
+
else if ((key === 'Cyn ' || key === 'Mgnt' || key === 'Ylw ' || key === 'Blck') && value._classID === 'CMYC') {
|
|
383
|
+
type = 'doub';
|
|
384
|
+
}
|
|
385
|
+
else if (/^PN[a-z][a-z]$/.test(key)) {
|
|
386
|
+
type = 'TEXT';
|
|
387
|
+
}
|
|
388
|
+
else if (/^PT[a-z][a-z]$/.test(key)) {
|
|
389
|
+
type = 'long';
|
|
390
|
+
}
|
|
391
|
+
else if (/^PF[a-z][a-z]$/.test(key)) {
|
|
392
|
+
type = 'doub';
|
|
393
|
+
}
|
|
394
|
+
else if (key === 'ClSz' || key === 'Rds ' || key === 'Amnt') {
|
|
395
|
+
type = typeof value[key] === 'number' ? 'long' : 'UntF';
|
|
396
|
+
}
|
|
397
|
+
else if ((key === 'sdwM' || key === 'hglM') && typeof value[key] === 'string') {
|
|
398
|
+
type = 'enum';
|
|
399
|
+
}
|
|
400
|
+
else if (key === 'blur' && typeof value[key] === 'string') {
|
|
401
|
+
type = 'enum';
|
|
402
|
+
}
|
|
403
|
+
else if (key === 'Angl' && typeof value[key] === 'number') {
|
|
404
|
+
type = 'doub'; // ???
|
|
405
|
+
}
|
|
352
406
|
else if (key === 'bounds' && root === 'slices') {
|
|
353
407
|
type = 'Objc';
|
|
354
408
|
extType = makeType('', 'Rct1');
|
|
355
409
|
}
|
|
356
|
-
else if (key === 'Scl '
|
|
357
|
-
|
|
358
|
-
|
|
410
|
+
else if (key === 'Scl ') {
|
|
411
|
+
if (typeof value[key] === 'object' && 'Hrzn' in value[key]) {
|
|
412
|
+
type = 'Objc';
|
|
413
|
+
extType = nullType;
|
|
414
|
+
}
|
|
415
|
+
else if (typeof value[key] === 'number') {
|
|
416
|
+
type = 'long';
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
type = 'UntF';
|
|
420
|
+
}
|
|
359
421
|
}
|
|
360
422
|
else if (key === 'audioClipGroupList' && keys.length === 1) {
|
|
361
423
|
type = 'VlLs';
|
|
@@ -363,7 +425,13 @@ export function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
363
425
|
else if ((key === 'Strt' || key === 'Brgh') && 'H ' in value) {
|
|
364
426
|
type = 'doub';
|
|
365
427
|
}
|
|
366
|
-
else if (key === '
|
|
428
|
+
else if (key === 'Wdth' && typeof value[key] === 'object') {
|
|
429
|
+
type = 'UntF';
|
|
430
|
+
}
|
|
431
|
+
else if (key === 'Ofst' && typeof value[key] === 'number') {
|
|
432
|
+
type = 'long';
|
|
433
|
+
}
|
|
434
|
+
else if (key === 'Strt' && typeof value[key] === 'object') {
|
|
367
435
|
type = 'Objc';
|
|
368
436
|
extType = nullType;
|
|
369
437
|
}
|
|
@@ -482,11 +550,11 @@ function readOSType(reader, type) {
|
|
|
482
550
|
return items;
|
|
483
551
|
}
|
|
484
552
|
case 'Pth ': { // File path
|
|
485
|
-
/*const length =*/ readInt32(reader);
|
|
553
|
+
/*const length =*/ readInt32(reader); // total size of all fields below
|
|
486
554
|
var sig = readSignature(reader);
|
|
487
|
-
/*const pathSize =*/ readInt32LE(reader);
|
|
555
|
+
/*const pathSize =*/ readInt32LE(reader); // the same as length
|
|
488
556
|
var charsCount = readInt32LE(reader);
|
|
489
|
-
var path =
|
|
557
|
+
var path = readUnicodeStringWithLengthLE(reader, charsCount);
|
|
490
558
|
return { sig: sig, path: path };
|
|
491
559
|
}
|
|
492
560
|
default:
|
|
@@ -504,12 +572,19 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
504
572
|
writeReferenceStructure(writer, key, value);
|
|
505
573
|
break;
|
|
506
574
|
case 'Objc': // Descriptor
|
|
507
|
-
case 'GlbO': // GlobalObject same as Descriptor
|
|
575
|
+
case 'GlbO': { // GlobalObject same as Descriptor
|
|
576
|
+
if (typeof value !== 'object')
|
|
577
|
+
throw new Error("Invalid struct value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
508
578
|
if (!extType)
|
|
509
579
|
throw new Error("Missing ext type for: '".concat(key, "' (").concat(JSON.stringify(value), ")"));
|
|
510
|
-
|
|
580
|
+
var name_1 = value._name || extType.name;
|
|
581
|
+
var classID = value._classID || extType.classID;
|
|
582
|
+
writeDescriptorStructure(writer, name_1, classID, value, root);
|
|
511
583
|
break;
|
|
584
|
+
}
|
|
512
585
|
case 'VlLs': // List
|
|
586
|
+
if (!Array.isArray(value))
|
|
587
|
+
throw new Error("Invalid list value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
513
588
|
writeInt32(writer, value.length);
|
|
514
589
|
for (var i = 0; i < value.length; i++) {
|
|
515
590
|
var type_3 = fieldToArrayType[key];
|
|
@@ -520,6 +595,8 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
520
595
|
}
|
|
521
596
|
break;
|
|
522
597
|
case 'doub': // Double
|
|
598
|
+
if (typeof value !== 'number')
|
|
599
|
+
throw new Error("Invalid number value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
523
600
|
writeFloat64(writer, value);
|
|
524
601
|
break;
|
|
525
602
|
case 'UntF': // Unit double
|
|
@@ -538,17 +615,23 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
538
615
|
writeUnicodeStringWithPadding(writer, value);
|
|
539
616
|
break;
|
|
540
617
|
case 'enum': { // Enumerated
|
|
618
|
+
if (typeof value !== 'string')
|
|
619
|
+
throw new Error("Invalid enum value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
541
620
|
var _a = value.split('.'), _type = _a[0], val = _a[1];
|
|
542
621
|
writeAsciiStringOrClassId(writer, _type);
|
|
543
622
|
writeAsciiStringOrClassId(writer, val);
|
|
544
623
|
break;
|
|
545
624
|
}
|
|
546
625
|
case 'long': // Integer
|
|
626
|
+
if (typeof value !== 'number')
|
|
627
|
+
throw new Error("Invalid integer value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
547
628
|
writeInt32(writer, value);
|
|
548
629
|
break;
|
|
549
630
|
// case 'comp': // Large Integer
|
|
550
631
|
// writeLargeInteger(reader);
|
|
551
632
|
case 'bool': // Boolean
|
|
633
|
+
if (typeof value !== 'boolean')
|
|
634
|
+
throw new Error("Invalid boolean value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
552
635
|
writeUint8(writer, value ? 1 : 0);
|
|
553
636
|
break;
|
|
554
637
|
// case 'type': // Class
|
|
@@ -579,8 +662,15 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
579
662
|
}
|
|
580
663
|
break;
|
|
581
664
|
}
|
|
582
|
-
|
|
583
|
-
|
|
665
|
+
case 'Pth ': { // File path
|
|
666
|
+
var length_5 = 4 + 4 + 4 + value.path.length * 2;
|
|
667
|
+
writeInt32(writer, length_5);
|
|
668
|
+
writeSignature(writer, value.sig);
|
|
669
|
+
writeInt32LE(writer, length_5);
|
|
670
|
+
writeInt32LE(writer, value.path.length);
|
|
671
|
+
writeUnicodeStringWithoutLengthLE(writer, value.path);
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
584
674
|
default:
|
|
585
675
|
throw new Error("Not implemented descriptor OSType: ".concat(type));
|
|
586
676
|
}
|
|
@@ -671,7 +761,6 @@ function writeReferenceStructure(writer, _key, items) {
|
|
|
671
761
|
function readClassStructure(reader) {
|
|
672
762
|
var name = readUnicodeString(reader);
|
|
673
763
|
var classID = readAsciiStringOrClassId(reader);
|
|
674
|
-
// console.log({ name, classID });
|
|
675
764
|
return { name: name, classID: classID };
|
|
676
765
|
}
|
|
677
766
|
function writeClassStructure(writer, name, classID) {
|
|
@@ -697,6 +786,24 @@ export function horzVrtcToXY(hv) {
|
|
|
697
786
|
export function xyToHorzVrtc(xy) {
|
|
698
787
|
return { Hrzn: xy.x, Vrtc: xy.y };
|
|
699
788
|
}
|
|
789
|
+
export function descBoundsToBounds(desc) {
|
|
790
|
+
return {
|
|
791
|
+
top: parseUnits(desc['Top ']),
|
|
792
|
+
left: parseUnits(desc.Left),
|
|
793
|
+
right: parseUnits(desc.Rght),
|
|
794
|
+
bottom: parseUnits(desc.Btom),
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
export function boundsToDescBounds(bounds) {
|
|
798
|
+
var _a;
|
|
799
|
+
return _a = {
|
|
800
|
+
Left: unitsValue(bounds.left, 'bounds.left')
|
|
801
|
+
},
|
|
802
|
+
_a['Top '] = unitsValue(bounds.top, 'bounds.top'),
|
|
803
|
+
_a.Rght = unitsValue(bounds.right, 'bounds.right'),
|
|
804
|
+
_a.Btom = unitsValue(bounds.bottom, 'bounds.bottom'),
|
|
805
|
+
_a;
|
|
806
|
+
}
|
|
700
807
|
function parseFxObject(fx) {
|
|
701
808
|
var stroke = {
|
|
702
809
|
enabled: !!fx.enab,
|
|
@@ -845,7 +952,8 @@ function parseKeyList(keyList, logMissingFeatures) {
|
|
|
845
952
|
var keys = [];
|
|
846
953
|
for (var j = 0; j < keyList.length; j++) {
|
|
847
954
|
var key = keyList[j];
|
|
848
|
-
var
|
|
955
|
+
var _a = key.time, denominator = _a.denominator, numerator = _a.numerator, selected = key.selected, animKey = key.animKey;
|
|
956
|
+
var time = { numerator: numerator, denominator: denominator };
|
|
849
957
|
var interpolation = animInterpStyleEnum.decode(key.animInterpStyle);
|
|
850
958
|
switch (animKey.Type) {
|
|
851
959
|
case 'keyType.Opct':
|
|
@@ -1092,6 +1200,9 @@ function parseEffectObject(obj, reportErrors) {
|
|
|
1092
1200
|
case 'antialiasGloss':
|
|
1093
1201
|
result[key] = val;
|
|
1094
1202
|
break;
|
|
1203
|
+
case '_name':
|
|
1204
|
+
case '_classID':
|
|
1205
|
+
break;
|
|
1095
1206
|
default:
|
|
1096
1207
|
reportErrors && console.log("Invalid effect key: '".concat(key, "', value:"), val);
|
|
1097
1208
|
}
|
|
@@ -1441,25 +1552,25 @@ export function parseColor(color) {
|
|
|
1441
1552
|
}
|
|
1442
1553
|
export function serializeColor(color) {
|
|
1443
1554
|
if (!color) {
|
|
1444
|
-
return { 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1555
|
+
return { _name: '', _classID: 'RGBC', 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1445
1556
|
}
|
|
1446
1557
|
else if ('r' in color) {
|
|
1447
|
-
return { 'Rd ': color.r || 0, 'Grn ': color.g || 0, 'Bl ': color.b || 0 };
|
|
1558
|
+
return { _name: '', _classID: 'RGBC', 'Rd ': color.r || 0, 'Grn ': color.g || 0, 'Bl ': color.b || 0 };
|
|
1448
1559
|
}
|
|
1449
1560
|
else if ('fr' in color) {
|
|
1450
|
-
return { redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
|
|
1561
|
+
return { _name: '', _classID: 'XXXX', redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
|
|
1451
1562
|
}
|
|
1452
1563
|
else if ('h' in color) {
|
|
1453
|
-
return { 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
|
|
1564
|
+
return { _name: '', _classID: 'HSBC', 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
|
|
1454
1565
|
}
|
|
1455
1566
|
else if ('c' in color) {
|
|
1456
|
-
return { 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
|
|
1567
|
+
return { _name: '', _classID: 'CMYC', 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
|
|
1457
1568
|
}
|
|
1458
1569
|
else if ('l' in color) {
|
|
1459
|
-
return { Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
|
|
1570
|
+
return { _name: '', _classID: 'LABC', Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
|
|
1460
1571
|
}
|
|
1461
1572
|
else if ('k' in color) {
|
|
1462
|
-
return { 'Gry ': color.k };
|
|
1573
|
+
return { _name: '', _classID: 'GRYC', 'Gry ': color.k };
|
|
1463
1574
|
}
|
|
1464
1575
|
else {
|
|
1465
1576
|
throw new Error('Invalid color value');
|
|
@@ -1514,6 +1625,9 @@ export function unitsAngle(value) {
|
|
|
1514
1625
|
export function unitsPercent(value) {
|
|
1515
1626
|
return { units: 'Percent', value: Math.round((value || 0) * 100) };
|
|
1516
1627
|
}
|
|
1628
|
+
export function unitsPercentF(value) {
|
|
1629
|
+
return { units: 'Percent', value: (value || 0) * 100 };
|
|
1630
|
+
}
|
|
1517
1631
|
export function unitsValue(x, key) {
|
|
1518
1632
|
if (x == null)
|
|
1519
1633
|
return { units: 'Pixels', value: 0 };
|
|
@@ -1528,6 +1642,10 @@ export function unitsValue(x, key) {
|
|
|
1528
1642
|
}
|
|
1529
1643
|
return { units: units, value: value };
|
|
1530
1644
|
}
|
|
1645
|
+
export function frac(_a) {
|
|
1646
|
+
var numerator = _a.numerator, denominator = _a.denominator;
|
|
1647
|
+
return { numerator: numerator, denominator: denominator };
|
|
1648
|
+
}
|
|
1531
1649
|
export var textGridding = createEnum('textGridding', 'none', {
|
|
1532
1650
|
none: 'None',
|
|
1533
1651
|
round: 'Rnd ',
|
|
@@ -1649,6 +1767,7 @@ export var ClrS = createEnum('ClrS', 'rgb', {
|
|
|
1649
1767
|
rgb: 'RGBC',
|
|
1650
1768
|
hsb: 'HSBl',
|
|
1651
1769
|
lab: 'LbCl',
|
|
1770
|
+
hsl: 'HSLC',
|
|
1652
1771
|
});
|
|
1653
1772
|
export var FStl = createEnum('FStl', 'outside', {
|
|
1654
1773
|
outside: 'OutF',
|
|
@@ -1695,4 +1814,140 @@ export var strokeStyleLineAlignment = createEnum('strokeStyleLineAlignment', 'in
|
|
|
1695
1814
|
center: 'strokeStyleAlignCenter',
|
|
1696
1815
|
outside: 'strokeStyleAlignOutside',
|
|
1697
1816
|
});
|
|
1817
|
+
export var BlrM = createEnum('BlrM', 'ispinmage', {
|
|
1818
|
+
spin: 'Spn ',
|
|
1819
|
+
zoom: 'Zm ',
|
|
1820
|
+
});
|
|
1821
|
+
export var BlrQ = createEnum('BlrQ', 'good', {
|
|
1822
|
+
draft: 'Drft',
|
|
1823
|
+
good: 'Gd ',
|
|
1824
|
+
best: 'Bst ',
|
|
1825
|
+
});
|
|
1826
|
+
export var SmBM = createEnum('SmBM', 'normal', {
|
|
1827
|
+
normal: 'SBMN',
|
|
1828
|
+
'edge only': 'SBME',
|
|
1829
|
+
'overlay edge': 'SBMO',
|
|
1830
|
+
});
|
|
1831
|
+
export var SmBQ = createEnum('SmBQ', 'medium', {
|
|
1832
|
+
low: 'SBQL',
|
|
1833
|
+
medium: 'SBQM',
|
|
1834
|
+
high: 'SBQH',
|
|
1835
|
+
});
|
|
1836
|
+
export var DspM = createEnum('DspM', 'stretch to fit', {
|
|
1837
|
+
'stretch to fit': 'StrF',
|
|
1838
|
+
'tile': 'Tile',
|
|
1839
|
+
});
|
|
1840
|
+
export var UndA = createEnum('UndA', 'repeat edge pixels', {
|
|
1841
|
+
'wrap around': 'WrpA',
|
|
1842
|
+
'repeat edge pixels': 'RptE',
|
|
1843
|
+
});
|
|
1844
|
+
export var Cnvr = createEnum('Cnvr', 'rectangular to polar', {
|
|
1845
|
+
'rectangular to polar': 'RctP',
|
|
1846
|
+
'polar to rectangular': 'PlrR',
|
|
1847
|
+
});
|
|
1848
|
+
export var RplS = createEnum('RplS', 'medium', {
|
|
1849
|
+
small: 'Sml ',
|
|
1850
|
+
medium: 'Mdm ',
|
|
1851
|
+
large: 'Lrg ',
|
|
1852
|
+
});
|
|
1853
|
+
export var SphM = createEnum('SphM', 'normal', {
|
|
1854
|
+
'normal': 'Nrml',
|
|
1855
|
+
'horizontal only': 'HrzO',
|
|
1856
|
+
'vertical only': 'VrtO',
|
|
1857
|
+
});
|
|
1858
|
+
export var Wvtp = createEnum('Wvtp', 'sine', {
|
|
1859
|
+
sine: 'WvSn',
|
|
1860
|
+
triangle: 'WvTr',
|
|
1861
|
+
square: 'WvSq',
|
|
1862
|
+
});
|
|
1863
|
+
export var ZZTy = createEnum('ZZTy', 'pond ripples', {
|
|
1864
|
+
'around center': 'ArnC',
|
|
1865
|
+
'out from center': 'OtFr',
|
|
1866
|
+
'pond ripples': 'PndR',
|
|
1867
|
+
});
|
|
1868
|
+
export var Dstr = createEnum('Dstr', 'uniform', {
|
|
1869
|
+
uniform: 'Unfr',
|
|
1870
|
+
gaussian: 'Gsn ',
|
|
1871
|
+
});
|
|
1872
|
+
export var Chnl = createEnum('Chnl', 'composite', {
|
|
1873
|
+
red: 'Rd ',
|
|
1874
|
+
green: 'Grn ',
|
|
1875
|
+
blue: 'Bl ',
|
|
1876
|
+
composite: 'Cmps',
|
|
1877
|
+
});
|
|
1878
|
+
export var MztT = createEnum('MztT', 'fine dots', {
|
|
1879
|
+
'fine dots': 'FnDt',
|
|
1880
|
+
'medium dots': 'MdmD',
|
|
1881
|
+
'grainy dots': 'GrnD',
|
|
1882
|
+
'coarse dots': 'CrsD',
|
|
1883
|
+
'short lines': 'ShrL',
|
|
1884
|
+
'medium lines': 'MdmL',
|
|
1885
|
+
'long lines': 'LngL',
|
|
1886
|
+
'short strokes': 'ShSt',
|
|
1887
|
+
'medium strokes': 'MdmS',
|
|
1888
|
+
'long strokes': 'LngS',
|
|
1889
|
+
});
|
|
1890
|
+
export var Lns = createEnum('Lns ', '50-300mm zoom', {
|
|
1891
|
+
'50-300mm zoom': 'Zm ',
|
|
1892
|
+
'32mm prime': 'Nkn ',
|
|
1893
|
+
'105mm prime': 'Nkn1',
|
|
1894
|
+
'movie prime': 'PnVs',
|
|
1895
|
+
});
|
|
1896
|
+
export var blurType = createEnum('blurType', 'gaussian blur', {
|
|
1897
|
+
'gaussian blur': 'GsnB',
|
|
1898
|
+
'lens blur': 'lensBlur',
|
|
1899
|
+
'motion blur': 'MtnB',
|
|
1900
|
+
});
|
|
1901
|
+
export var DfsM = createEnum('DfsM', 'normal', {
|
|
1902
|
+
'normal': 'Nrml',
|
|
1903
|
+
'darken only': 'DrkO',
|
|
1904
|
+
'lighten only': 'LghO',
|
|
1905
|
+
'anisotropic': 'anisotropic',
|
|
1906
|
+
});
|
|
1907
|
+
export var ExtT = createEnum('ExtT', 'blocks', {
|
|
1908
|
+
blocks: 'Blks',
|
|
1909
|
+
pyramids: 'Pyrm',
|
|
1910
|
+
});
|
|
1911
|
+
export var ExtR = createEnum('ExtR', 'random', {
|
|
1912
|
+
random: 'Rndm',
|
|
1913
|
+
'level-based': 'LvlB',
|
|
1914
|
+
});
|
|
1915
|
+
export var FlCl = createEnum('FlCl', 'background color', {
|
|
1916
|
+
'background color': 'FlBc',
|
|
1917
|
+
'foreground color': 'FlFr',
|
|
1918
|
+
'inverse image': 'FlIn',
|
|
1919
|
+
'unaltered image': 'FlSm',
|
|
1920
|
+
});
|
|
1921
|
+
export var CntE = createEnum('CntE', 'upper', {
|
|
1922
|
+
lower: 'Lwr ',
|
|
1923
|
+
upper: 'Upr ',
|
|
1924
|
+
});
|
|
1925
|
+
export var WndM = createEnum('WndM', 'wind', {
|
|
1926
|
+
wind: 'Wnd ',
|
|
1927
|
+
blast: 'Blst',
|
|
1928
|
+
stagger: 'Stgr',
|
|
1929
|
+
});
|
|
1930
|
+
export var Drct = createEnum('Drct', 'from the right', {
|
|
1931
|
+
left: 'Left',
|
|
1932
|
+
right: 'Rght',
|
|
1933
|
+
});
|
|
1934
|
+
export var IntE = createEnum('IntE', 'odd lines', {
|
|
1935
|
+
'odd lines': 'ElmO',
|
|
1936
|
+
'even lines': 'ElmE',
|
|
1937
|
+
});
|
|
1938
|
+
export var IntC = createEnum('IntC', 'interpolation', {
|
|
1939
|
+
duplication: 'CrtD',
|
|
1940
|
+
interpolation: 'CrtI',
|
|
1941
|
+
});
|
|
1942
|
+
export var FlMd = createEnum('FlMd', 'wrap around', {
|
|
1943
|
+
'set to transparent': 'Bckg',
|
|
1944
|
+
'repeat edge pixels': 'Rpt ',
|
|
1945
|
+
'wrap around': 'Wrp ',
|
|
1946
|
+
});
|
|
1947
|
+
export var prjM = createEnum('prjM', 'fisheye', {
|
|
1948
|
+
'fisheye': 'fisP',
|
|
1949
|
+
'perspective': 'perP',
|
|
1950
|
+
'auto': 'auto',
|
|
1951
|
+
'full spherical': 'fusP',
|
|
1952
|
+
});
|
|
1698
1953
|
//# sourceMappingURL=descriptor.js.map
|