ag-psd 30.1.1 → 31.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.13.1-x64-cf738c9d/017325ac +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/01e5e61b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/043c7b90 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/05135617 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/059f8558 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/06423db9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/06e765df +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0706ecb8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0930679d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/09519a62 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0a6607b0 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0ad8fa6e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0d390e10 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0db754a7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0dfa7b16 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0e9e09db +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1130885f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1222cb8c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/15e2c039 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/15f0e479 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1a2d469d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1b300c82 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1bc3d370 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1e44e5af +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1efa10a1 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1f6c8743 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/20477c23 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/20b27e40 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/20dfa422 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/257c62ba +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/25d60154 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/26f822f3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2a19133e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2a1e2a8d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2b02fded +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2b069ee0 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2c76dc0d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2de09439 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2deb286a +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2e44f5f0 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2fb229a9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/3144b401 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/32018e44 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/341402c3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/34e0fa2e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/37481985 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/3bbf643e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/3ceff89e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/404f5cdc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4087aa2b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4376c1f9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/44903df4 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/44d58dc8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4511bacf +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/47da0ce8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/48cd54a9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/49d22b79 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4d938476 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4ec6d390 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4f5702bd +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/514cc428 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/557d3b42 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/56abbff7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/57b540ee +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/57d3380b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/5e20c081 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6024ce3f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/61735b23 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/63dbdb75 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/651c4ada +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/652a0d59 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6a0e89ee +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6af33b91 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6c2562d2 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6cbfc0ec +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6dae0cfa +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6e2529ce +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6f08372c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7100ee08 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/71df9cb3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/72e1d543 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/75519c80 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/75e41e43 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/79bf115c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7a39347c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7b83e3d3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7cd71bc5 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7da78512 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7ea06cea +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/82c3b573 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/84c186e4 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8568576b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8607bd36 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/87372817 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/87cf2209 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/882aaa05 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8a4d3de8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8e223473 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/92b7aefd +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/932f0770 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/937c03a1 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/991e4758 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/9af658fb +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/9ed80ba5 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/9f0dc993 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a19c0c4f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a6409d95 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a79a40bb +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a7e80865 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ac9802c6 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/acc36e66 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ad11e2dc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b0c8fcd8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b1762958 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b3c2fab7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b5b3329b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b69ed3a3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b806679e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/bc1cdd48 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/bc7ebd1d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/bdff1628 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c0b789d2 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c314aece +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c399a5dc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c681cbc8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c6834ffc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c6f12ed5 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cb0f0a3d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cbcb7c95 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cdd9107c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cdf2c4a3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cfc49f4f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cff9434a +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d02dd6f7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d0507bf3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d60fce19 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d733d619 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d75b7803 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/dc86f000 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/de74e659 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/defa4f7f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e03e2acd +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e0e3f52c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e158d332 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6735171 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6745c2b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6b99945 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6d8ceb8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e7ffec37 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ea33b6de +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/eaafa3c4 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ebb50fca +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ec805f2e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/edaef8f1 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ee4401c8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/eeeebdfe +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/f3d51676 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/f7b50a75 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fa58ca72 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fbca6276 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fc97d72d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fd0a2987 +0 -0
- package/CHANGELOG.md +9 -0
- package/README.md +65 -1
- package/README_PSD.md +1 -1
- package/TODO.md +2 -0
- package/dist/abr.d.ts +196 -196
- package/dist/abr.js +364 -378
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.d.ts +26 -26
- package/dist/additionalInfo.js +3478 -3516
- package/dist/additionalInfo.js.map +1 -1
- package/dist/ase.d.ts +32 -32
- package/dist/ase.js +81 -82
- package/dist/ase.js.map +1 -1
- package/dist/bundle.js +12380 -12445
- package/dist/csh.d.ts +10 -10
- package/dist/csh.js +35 -47
- package/dist/csh.js.map +1 -1
- package/dist/descriptor.d.ts +601 -601
- package/dist/descriptor.js +2003 -2038
- package/dist/descriptor.js.map +1 -1
- package/dist/effectsHelpers.d.ts +5 -5
- package/dist/effectsHelpers.js +286 -308
- package/dist/effectsHelpers.js.map +1 -1
- package/dist/engineData.d.ts +2 -2
- package/dist/engineData.js +334 -341
- package/dist/engineData.js.map +1 -1
- package/dist/engineData2.d.ts +2 -2
- package/dist/engineData2.js +409 -411
- package/dist/engineData2.js.map +1 -1
- package/dist/helpers.d.ts +74 -74
- package/dist/helpers.js +353 -348
- package/dist/helpers.js.map +1 -1
- package/dist/imageResources.d.ts +17 -17
- package/dist/imageResources.js +1040 -1079
- package/dist/imageResources.js.map +1 -1
- package/dist/index.d.ts +20 -22
- package/dist/index.js +61 -56
- package/dist/index.js.map +1 -1
- package/dist/initializeCanvas.d.ts +1 -1
- package/dist/initializeCanvas.js +9 -10
- package/dist/initializeCanvas.js.map +1 -1
- package/dist/jpeg.d.ts +1 -1
- package/dist/jpeg.js +1020 -1021
- package/dist/jpeg.js.map +1 -1
- package/dist/psd.d.ts +1877 -1873
- package/dist/psd.js +45 -45
- package/dist/psd.js.map +1 -1
- package/dist/psdReader.d.ts +52 -45
- package/dist/psdReader.js +1385 -1293
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +34 -33
- package/dist/psdWriter.js +834 -805
- package/dist/psdWriter.js.map +1 -1
- package/dist/text.d.ts +179 -179
- package/dist/text.js +552 -577
- package/dist/text.js.map +1 -1
- package/dist/utf8.d.ts +4 -6
- package/dist/utf8.js +156 -157
- package/dist/utf8.js.map +1 -1
- package/dist-es/abr.d.ts +196 -196
- package/dist-es/abr.js +364 -374
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.d.ts +26 -26
- package/dist-es/additionalInfo.js +3478 -3510
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/ase.d.ts +32 -32
- package/dist-es/ase.js +81 -78
- package/dist-es/ase.js.map +1 -1
- package/dist-es/csh.d.ts +10 -10
- package/dist-es/csh.js +35 -43
- package/dist-es/csh.js.map +1 -1
- package/dist-es/descriptor.d.ts +601 -601
- package/dist-es/descriptor.js +2003 -2005
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/effectsHelpers.d.ts +5 -5
- package/dist-es/effectsHelpers.js +286 -303
- package/dist-es/effectsHelpers.js.map +1 -1
- package/dist-es/engineData.d.ts +2 -2
- package/dist-es/engineData.js +334 -336
- package/dist-es/engineData.js.map +1 -1
- package/dist-es/engineData2.d.ts +2 -2
- package/dist-es/engineData2.js +409 -407
- package/dist-es/engineData2.js.map +1 -1
- package/dist-es/helpers.d.ts +74 -74
- package/dist-es/helpers.js +353 -330
- package/dist-es/helpers.js.map +1 -1
- package/dist-es/imageResources.d.ts +17 -17
- package/dist-es/imageResources.js +1040 -1076
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/index.d.ts +20 -22
- package/dist-es/index.js +61 -33
- package/dist-es/index.js.map +1 -1
- package/dist-es/initializeCanvas.d.ts +1 -1
- package/dist-es/initializeCanvas.js +9 -6
- package/dist-es/initializeCanvas.js.map +1 -1
- package/dist-es/jpeg.d.ts +1 -1
- package/dist-es/jpeg.js +1020 -1017
- package/dist-es/jpeg.js.map +1 -1
- package/dist-es/psd.d.ts +1877 -1873
- package/dist-es/psd.js +45 -42
- package/dist-es/psd.js.map +1 -1
- package/dist-es/psdReader.d.ts +52 -45
- package/dist-es/psdReader.js +1385 -1255
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +34 -33
- package/dist-es/psdWriter.js +834 -776
- package/dist-es/psdWriter.js.map +1 -1
- package/dist-es/text.d.ts +179 -179
- package/dist-es/text.js +552 -572
- package/dist-es/text.js.map +1 -1
- package/dist-es/utf8.d.ts +4 -6
- package/dist-es/utf8.js +156 -150
- package/dist-es/utf8.js.map +1 -1
- package/package.json +4 -3
- package/publish.js +24 -0
- package/src/additionalInfo.ts +15 -11
- package/src/helpers.ts +13 -3
- package/src/index.ts +4 -6
- package/src/psd.ts +4 -0
- package/src/psdReader.ts +136 -43
- package/src/psdWriter.ts +118 -24
- package/tsconfig-es6.json +2 -1
- package/tsconfig.json +5 -3
package/dist/text.js
CHANGED
|
@@ -1,578 +1,553 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'
|
|
91
|
-
'
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
'
|
|
97
|
-
'
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
function
|
|
145
|
-
if (!a || !b)
|
|
146
|
-
return false;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
result.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (
|
|
315
|
-
result.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
var
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
{
|
|
480
|
-
Name: '
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
{
|
|
487
|
-
Name: '
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
},
|
|
554
|
-
AntiAlias: antialias.indexOf((_l = data.antiAlias) !== null && _l !== void 0 ? _l : 'sharp'),
|
|
555
|
-
UseFractionalGlyphWidths: (_m = data.useFractionalGlyphWidths) !== null && _m !== void 0 ? _m : true,
|
|
556
|
-
Rendered: {
|
|
557
|
-
Version: 1,
|
|
558
|
-
Shapes: {
|
|
559
|
-
WritingDirection: WritingDirection,
|
|
560
|
-
Children: [
|
|
561
|
-
{
|
|
562
|
-
ShapeType: ShapeType,
|
|
563
|
-
Procession: Procession,
|
|
564
|
-
Lines: { WritingDirection: WritingDirection, Children: [] },
|
|
565
|
-
Cookie: { Photoshop: Photoshop },
|
|
566
|
-
},
|
|
567
|
-
],
|
|
568
|
-
},
|
|
569
|
-
},
|
|
570
|
-
},
|
|
571
|
-
ResourceDict: __assign({}, defaultResources),
|
|
572
|
-
DocumentResources: __assign({}, defaultResources),
|
|
573
|
-
};
|
|
574
|
-
// console.log('encodeEngineData', require('util').inspect(engineData, false, 99, true));
|
|
575
|
-
return engineData;
|
|
576
|
-
}
|
|
577
|
-
exports.encodeEngineData = encodeEngineData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeEngineData = decodeEngineData;
|
|
4
|
+
exports.encodeEngineData = encodeEngineData;
|
|
5
|
+
const defaultFont = {
|
|
6
|
+
name: 'MyriadPro-Regular',
|
|
7
|
+
script: 0,
|
|
8
|
+
type: 0,
|
|
9
|
+
synthetic: 0,
|
|
10
|
+
};
|
|
11
|
+
const defaultParagraphStyle = {
|
|
12
|
+
justification: 'left',
|
|
13
|
+
firstLineIndent: 0,
|
|
14
|
+
startIndent: 0,
|
|
15
|
+
endIndent: 0,
|
|
16
|
+
spaceBefore: 0,
|
|
17
|
+
spaceAfter: 0,
|
|
18
|
+
autoHyphenate: true,
|
|
19
|
+
hyphenatedWordSize: 6,
|
|
20
|
+
preHyphen: 2,
|
|
21
|
+
postHyphen: 2,
|
|
22
|
+
consecutiveHyphens: 8,
|
|
23
|
+
zone: 36,
|
|
24
|
+
wordSpacing: [0.8, 1, 1.33],
|
|
25
|
+
letterSpacing: [0, 0, 0],
|
|
26
|
+
glyphSpacing: [1, 1, 1],
|
|
27
|
+
autoLeading: 1.2,
|
|
28
|
+
leadingType: 0,
|
|
29
|
+
hanging: false,
|
|
30
|
+
burasagari: false,
|
|
31
|
+
kinsokuOrder: 0,
|
|
32
|
+
everyLineComposer: false,
|
|
33
|
+
};
|
|
34
|
+
const defaultStyle = {
|
|
35
|
+
font: defaultFont,
|
|
36
|
+
fontSize: 12,
|
|
37
|
+
fauxBold: false,
|
|
38
|
+
fauxItalic: false,
|
|
39
|
+
autoLeading: true,
|
|
40
|
+
leading: 0,
|
|
41
|
+
horizontalScale: 1,
|
|
42
|
+
verticalScale: 1,
|
|
43
|
+
tracking: 0,
|
|
44
|
+
autoKerning: true,
|
|
45
|
+
kerning: 0,
|
|
46
|
+
baselineShift: 0,
|
|
47
|
+
fontCaps: 0,
|
|
48
|
+
fontBaseline: 0,
|
|
49
|
+
underline: false,
|
|
50
|
+
strikethrough: false,
|
|
51
|
+
ligatures: true,
|
|
52
|
+
dLigatures: false,
|
|
53
|
+
baselineDirection: 2,
|
|
54
|
+
tsume: 0,
|
|
55
|
+
styleRunAlignment: 2,
|
|
56
|
+
language: 0,
|
|
57
|
+
noBreak: false,
|
|
58
|
+
fillColor: { r: 0, g: 0, b: 0 },
|
|
59
|
+
strokeColor: { r: 0, g: 0, b: 0 },
|
|
60
|
+
fillFlag: true,
|
|
61
|
+
strokeFlag: false,
|
|
62
|
+
fillFirst: true,
|
|
63
|
+
yUnderline: 1,
|
|
64
|
+
outlineWidth: 1,
|
|
65
|
+
characterDirection: 0,
|
|
66
|
+
hindiNumbers: false,
|
|
67
|
+
kashida: 1,
|
|
68
|
+
diacriticPos: 2,
|
|
69
|
+
};
|
|
70
|
+
const defaultGridInfo = {
|
|
71
|
+
isOn: false,
|
|
72
|
+
show: false,
|
|
73
|
+
size: 18,
|
|
74
|
+
leading: 22,
|
|
75
|
+
color: { r: 0, g: 0, b: 255 },
|
|
76
|
+
leadingFillColor: { r: 0, g: 0, b: 255 },
|
|
77
|
+
alignLineHeightToGridFlags: false,
|
|
78
|
+
};
|
|
79
|
+
const paragraphStyleKeys = [
|
|
80
|
+
'justification', 'firstLineIndent', 'startIndent', 'endIndent', 'spaceBefore', 'spaceAfter',
|
|
81
|
+
'autoHyphenate', 'hyphenatedWordSize', 'preHyphen', 'postHyphen', 'consecutiveHyphens',
|
|
82
|
+
'zone', 'wordSpacing', 'letterSpacing', 'glyphSpacing', 'autoLeading', 'leadingType',
|
|
83
|
+
'hanging', 'burasagari', 'kinsokuOrder', 'everyLineComposer',
|
|
84
|
+
];
|
|
85
|
+
const styleKeys = [
|
|
86
|
+
'font', 'fontSize', 'fauxBold', 'fauxItalic', 'autoLeading', 'leading', 'horizontalScale',
|
|
87
|
+
'verticalScale', 'tracking', 'autoKerning', 'kerning', 'baselineShift', 'fontCaps', 'fontBaseline',
|
|
88
|
+
'underline', 'strikethrough', 'ligatures', 'dLigatures', 'baselineDirection', 'tsume',
|
|
89
|
+
'styleRunAlignment', 'language', 'noBreak', 'fillColor', 'strokeColor', 'fillFlag',
|
|
90
|
+
'strokeFlag', 'fillFirst', 'yUnderline', 'outlineWidth', 'characterDirection', 'hindiNumbers',
|
|
91
|
+
'kashida', 'diacriticPos',
|
|
92
|
+
];
|
|
93
|
+
const antialias = ['none', 'crisp', 'strong', 'smooth', 'sharp'];
|
|
94
|
+
const justification = [
|
|
95
|
+
'left', // 0
|
|
96
|
+
'right', // 1
|
|
97
|
+
'center', // 2
|
|
98
|
+
'justify-left', // 3
|
|
99
|
+
'justify-right', // 4
|
|
100
|
+
'justify-center', // 5
|
|
101
|
+
'justify-all', // 6
|
|
102
|
+
];
|
|
103
|
+
function upperFirst(value) {
|
|
104
|
+
return value.substring(0, 1).toUpperCase() + value.substring(1);
|
|
105
|
+
}
|
|
106
|
+
function decodeColor(color) {
|
|
107
|
+
const c = color.Values;
|
|
108
|
+
switch (color.Type) {
|
|
109
|
+
case 0: return { k: c[1] * 255 }; // grayscale (alpha?)
|
|
110
|
+
case 1: return c[0] === 1 ?
|
|
111
|
+
{ r: c[1] * 255, g: c[2] * 255, b: c[3] * 255 } : // rgb
|
|
112
|
+
{ r: c[1] * 255, g: c[2] * 255, b: c[3] * 255, a: c[0] * 255 }; // rgba
|
|
113
|
+
case 2: return { c: c[1] * 255, m: c[2] * 255, y: c[3] * 255, k: c[4] * 255 }; // cmyk (alpha?)
|
|
114
|
+
default: throw new Error('Unknown color type in text layer');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function encodeColor(color) {
|
|
118
|
+
if (!color) {
|
|
119
|
+
return { Type: 1, Values: [0, 0, 0, 0] };
|
|
120
|
+
}
|
|
121
|
+
else if ('r' in color) {
|
|
122
|
+
return { Type: 1, Values: ['a' in color ? color.a / 255 : 1, color.r / 255, color.g / 255, color.b / 255] };
|
|
123
|
+
}
|
|
124
|
+
else if ('c' in color) {
|
|
125
|
+
return { Type: 2, Values: [1, color.c / 255, color.m / 255, color.y / 255, color.k / 255] };
|
|
126
|
+
}
|
|
127
|
+
else if ('k' in color) {
|
|
128
|
+
return { Type: 0, Values: [1, color.k / 255] };
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error('Invalid color type in text layer');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function arraysEqual(a, b) {
|
|
135
|
+
if (!a || !b)
|
|
136
|
+
return false;
|
|
137
|
+
if (a.length !== b.length)
|
|
138
|
+
return false;
|
|
139
|
+
for (let i = 0; i < a.length; i++)
|
|
140
|
+
if (a[i] !== b[i])
|
|
141
|
+
return false;
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
function objectsEqual(a, b) {
|
|
145
|
+
if (!a || !b)
|
|
146
|
+
return false;
|
|
147
|
+
for (const key of Object.keys(a))
|
|
148
|
+
if (a[key] !== b[key])
|
|
149
|
+
return false;
|
|
150
|
+
for (const key of Object.keys(b))
|
|
151
|
+
if (a[key] !== b[key])
|
|
152
|
+
return false;
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
function findOrAddFont(fonts, font) {
|
|
156
|
+
for (let i = 0; i < fonts.length; i++) {
|
|
157
|
+
if (fonts[i].name === font.name)
|
|
158
|
+
return i;
|
|
159
|
+
}
|
|
160
|
+
fonts.push(font);
|
|
161
|
+
return fonts.length - 1;
|
|
162
|
+
}
|
|
163
|
+
function decodeObject(obj, keys, fonts) {
|
|
164
|
+
const result = {};
|
|
165
|
+
for (const key of keys) {
|
|
166
|
+
const Key = upperFirst(key);
|
|
167
|
+
if (obj[Key] === undefined)
|
|
168
|
+
continue;
|
|
169
|
+
if (key === 'justification') {
|
|
170
|
+
result[key] = justification[obj[Key]];
|
|
171
|
+
}
|
|
172
|
+
else if (key === 'font') {
|
|
173
|
+
result[key] = fonts[obj[Key]];
|
|
174
|
+
}
|
|
175
|
+
else if (key === 'fillColor' || key === 'strokeColor') {
|
|
176
|
+
result[key] = decodeColor(obj[Key]);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
result[key] = obj[Key];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
function encodeObject(obj, keys, fonts) {
|
|
185
|
+
var _a;
|
|
186
|
+
const result = {};
|
|
187
|
+
for (const key of keys) {
|
|
188
|
+
const Key = upperFirst(key);
|
|
189
|
+
if (obj[key] === undefined)
|
|
190
|
+
continue;
|
|
191
|
+
if (key === 'justification') {
|
|
192
|
+
result[Key] = justification.indexOf((_a = obj[key]) !== null && _a !== void 0 ? _a : 'left');
|
|
193
|
+
}
|
|
194
|
+
else if (key === 'font') {
|
|
195
|
+
result[Key] = findOrAddFont(fonts, obj[key]);
|
|
196
|
+
}
|
|
197
|
+
else if (key === 'fillColor' || key === 'strokeColor') {
|
|
198
|
+
result[Key] = encodeColor(obj[key]);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
result[Key] = obj[key];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
function decodeParagraphStyle(obj, fonts) {
|
|
207
|
+
return decodeObject(obj, paragraphStyleKeys, fonts);
|
|
208
|
+
}
|
|
209
|
+
function decodeStyle(obj, fonts) {
|
|
210
|
+
return decodeObject(obj, styleKeys, fonts);
|
|
211
|
+
}
|
|
212
|
+
function encodeParagraphStyle(obj, fonts) {
|
|
213
|
+
return encodeObject(obj, paragraphStyleKeys, fonts);
|
|
214
|
+
}
|
|
215
|
+
function encodeStyle(obj, fonts) {
|
|
216
|
+
return encodeObject(obj, styleKeys, fonts);
|
|
217
|
+
}
|
|
218
|
+
function deduplicateValues(base, runs, keys) {
|
|
219
|
+
if (!runs.length)
|
|
220
|
+
return;
|
|
221
|
+
for (const key of keys) {
|
|
222
|
+
const value = runs[0].style[key];
|
|
223
|
+
if (value !== undefined) {
|
|
224
|
+
let identical = false;
|
|
225
|
+
if (Array.isArray(value)) {
|
|
226
|
+
identical = runs.every(r => arraysEqual(r.style[key], value));
|
|
227
|
+
}
|
|
228
|
+
else if (typeof value === 'object') {
|
|
229
|
+
identical = runs.every(r => objectsEqual(r.style[key], value));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
identical = runs.every(r => r.style[key] === value);
|
|
233
|
+
}
|
|
234
|
+
if (identical) {
|
|
235
|
+
base[key] = value;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const styleValue = base[key];
|
|
239
|
+
if (styleValue !== undefined) {
|
|
240
|
+
for (const r of runs) {
|
|
241
|
+
let same = false;
|
|
242
|
+
if (Array.isArray(value)) {
|
|
243
|
+
same = arraysEqual(r.style[key], value);
|
|
244
|
+
}
|
|
245
|
+
else if (typeof value === 'object') {
|
|
246
|
+
same = objectsEqual(r.style[key], value);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
same = r.style[key] === value;
|
|
250
|
+
}
|
|
251
|
+
if (same)
|
|
252
|
+
delete r.style[key];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (runs.every(x => Object.keys(x.style).length === 0)) {
|
|
257
|
+
runs.length = 0;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function decodeEngineData(engineData) {
|
|
261
|
+
var _a, _b, _c, _d, _e, _f;
|
|
262
|
+
// console.log('engineData', require('util').inspect(engineData, false, 99, true));
|
|
263
|
+
const engineDict = engineData.EngineDict;
|
|
264
|
+
const resourceDict = engineData.ResourceDict;
|
|
265
|
+
const fonts = resourceDict.FontSet.map(f => ({
|
|
266
|
+
name: f.Name,
|
|
267
|
+
script: f.Script,
|
|
268
|
+
type: f.FontType,
|
|
269
|
+
synthetic: f.Synthetic,
|
|
270
|
+
}));
|
|
271
|
+
let text = engineDict.Editor.Text.replace(/\r/g, '\n');
|
|
272
|
+
let removedCharacters = 0;
|
|
273
|
+
while (/\n$/.test(text)) {
|
|
274
|
+
text = text.substring(0, text.length - 1);
|
|
275
|
+
removedCharacters++;
|
|
276
|
+
}
|
|
277
|
+
const result = {
|
|
278
|
+
text,
|
|
279
|
+
antiAlias: (_a = antialias[engineDict.AntiAlias]) !== null && _a !== void 0 ? _a : 'smooth',
|
|
280
|
+
useFractionalGlyphWidths: !!engineDict.UseFractionalGlyphWidths,
|
|
281
|
+
superscriptSize: resourceDict.SuperscriptSize,
|
|
282
|
+
superscriptPosition: resourceDict.SuperscriptPosition,
|
|
283
|
+
subscriptSize: resourceDict.SubscriptSize,
|
|
284
|
+
subscriptPosition: resourceDict.SubscriptPosition,
|
|
285
|
+
smallCapSize: resourceDict.SmallCapSize,
|
|
286
|
+
};
|
|
287
|
+
// shape
|
|
288
|
+
const photoshop = (_f = (_e = (_d = (_c = (_b = engineDict.Rendered) === null || _b === void 0 ? void 0 : _b.Shapes) === null || _c === void 0 ? void 0 : _c.Children) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.Cookie) === null || _f === void 0 ? void 0 : _f.Photoshop;
|
|
289
|
+
if (photoshop) {
|
|
290
|
+
result.shapeType = photoshop.ShapeType === 1 ? 'box' : 'point';
|
|
291
|
+
if (photoshop.PointBase)
|
|
292
|
+
result.pointBase = photoshop.PointBase;
|
|
293
|
+
if (photoshop.BoxBounds)
|
|
294
|
+
result.boxBounds = photoshop.BoxBounds;
|
|
295
|
+
}
|
|
296
|
+
// paragraph style
|
|
297
|
+
// const theNormalParagraphSheet = resourceDict.TheNormalParagraphSheet;
|
|
298
|
+
// const paragraphSheetSet = resourceDict.ParagraphSheetSet;
|
|
299
|
+
// const paragraphProperties = paragraphSheetSet[theNormalParagraphSheet].Properties;
|
|
300
|
+
const paragraphRun = engineDict.ParagraphRun;
|
|
301
|
+
result.paragraphStyle = {}; // decodeParagraphStyle(paragraphProperties, fonts);
|
|
302
|
+
result.paragraphStyleRuns = [];
|
|
303
|
+
for (let i = 0; i < paragraphRun.RunArray.length; i++) {
|
|
304
|
+
const run = paragraphRun.RunArray[i];
|
|
305
|
+
const length = paragraphRun.RunLengthArray[i];
|
|
306
|
+
const style = decodeParagraphStyle(run.ParagraphSheet.Properties, fonts);
|
|
307
|
+
// const adjustments = {
|
|
308
|
+
// axis: run.Adjustments.Axis,
|
|
309
|
+
// xy: run.Adjustments.XY,
|
|
310
|
+
// };
|
|
311
|
+
result.paragraphStyleRuns.push({ length, style /*, adjustments*/ });
|
|
312
|
+
}
|
|
313
|
+
for (let counter = removedCharacters; result.paragraphStyleRuns.length && counter > 0; counter--) {
|
|
314
|
+
if (--result.paragraphStyleRuns[result.paragraphStyleRuns.length - 1].length === 0) {
|
|
315
|
+
result.paragraphStyleRuns.pop();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
deduplicateValues(result.paragraphStyle, result.paragraphStyleRuns, paragraphStyleKeys);
|
|
319
|
+
if (!result.paragraphStyleRuns.length)
|
|
320
|
+
delete result.paragraphStyleRuns;
|
|
321
|
+
// style
|
|
322
|
+
// const theNormalStyleSheet = resourceDict.TheNormalStyleSheet;
|
|
323
|
+
// const styleSheetSet = resourceDict.StyleSheetSet;
|
|
324
|
+
// const styleSheetData = styleSheetSet[theNormalStyleSheet].StyleSheetData;
|
|
325
|
+
const styleRun = engineDict.StyleRun;
|
|
326
|
+
result.style = {}; // decodeStyle(styleSheetData, fonts);
|
|
327
|
+
result.styleRuns = [];
|
|
328
|
+
for (let i = 0; i < styleRun.RunArray.length; i++) {
|
|
329
|
+
const length = styleRun.RunLengthArray[i];
|
|
330
|
+
const style = decodeStyle(styleRun.RunArray[i].StyleSheet.StyleSheetData, fonts);
|
|
331
|
+
if (!style.font)
|
|
332
|
+
style.font = fonts[0];
|
|
333
|
+
result.styleRuns.push({ length, style });
|
|
334
|
+
}
|
|
335
|
+
for (let counter = removedCharacters; result.styleRuns.length && counter > 0; counter--) {
|
|
336
|
+
if (--result.styleRuns[result.styleRuns.length - 1].length === 0) {
|
|
337
|
+
result.styleRuns.pop();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
deduplicateValues(result.style, result.styleRuns, styleKeys);
|
|
341
|
+
if (!result.styleRuns.length)
|
|
342
|
+
delete result.styleRuns;
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
function encodeEngineData(data) {
|
|
346
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
347
|
+
const text = `${(data.text || '').replace(/\r?\n/g, '\r')}\r`;
|
|
348
|
+
const fonts = [
|
|
349
|
+
{ name: 'AdobeInvisFont', script: 0, type: 0, synthetic: 0 },
|
|
350
|
+
];
|
|
351
|
+
const defFont = ((_a = data.style) === null || _a === void 0 ? void 0 : _a.font) || ((_c = (_b = data.styleRuns) === null || _b === void 0 ? void 0 : _b.find(s => s.style.font)) === null || _c === void 0 ? void 0 : _c.style.font) || defaultFont;
|
|
352
|
+
const paragraphRunArray = [];
|
|
353
|
+
const paragraphRunLengthArray = [];
|
|
354
|
+
const paragraphRuns = data.paragraphStyleRuns;
|
|
355
|
+
if (paragraphRuns && paragraphRuns.length) {
|
|
356
|
+
let leftLength = text.length;
|
|
357
|
+
for (const run of paragraphRuns) {
|
|
358
|
+
let runLength = Math.min(run.length, leftLength);
|
|
359
|
+
leftLength -= runLength;
|
|
360
|
+
if (!runLength)
|
|
361
|
+
continue; // ignore 0 size runs
|
|
362
|
+
// extend last run if it's only for trailing \r
|
|
363
|
+
if (leftLength === 1 && run === paragraphRuns[paragraphRuns.length - 1]) {
|
|
364
|
+
runLength++;
|
|
365
|
+
leftLength--;
|
|
366
|
+
}
|
|
367
|
+
paragraphRunLengthArray.push(runLength);
|
|
368
|
+
paragraphRunArray.push({
|
|
369
|
+
ParagraphSheet: {
|
|
370
|
+
DefaultStyleSheet: 0,
|
|
371
|
+
Properties: encodeParagraphStyle(Object.assign(Object.assign(Object.assign({}, defaultParagraphStyle), data.paragraphStyle), run.style), fonts),
|
|
372
|
+
},
|
|
373
|
+
Adjustments: { Axis: [1, 0, 1], XY: [0, 0] },
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
if (leftLength) {
|
|
377
|
+
paragraphRunLengthArray.push(leftLength);
|
|
378
|
+
paragraphRunArray.push({
|
|
379
|
+
ParagraphSheet: {
|
|
380
|
+
DefaultStyleSheet: 0,
|
|
381
|
+
Properties: encodeParagraphStyle(Object.assign(Object.assign({}, defaultParagraphStyle), data.paragraphStyle), fonts),
|
|
382
|
+
},
|
|
383
|
+
Adjustments: { Axis: [1, 0, 1], XY: [0, 0] },
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
for (let i = 0, last = 0; i < text.length; i++) {
|
|
389
|
+
if (text.charCodeAt(i) === 13) { // \r
|
|
390
|
+
paragraphRunLengthArray.push(i - last + 1);
|
|
391
|
+
paragraphRunArray.push({
|
|
392
|
+
ParagraphSheet: {
|
|
393
|
+
DefaultStyleSheet: 0,
|
|
394
|
+
Properties: encodeParagraphStyle(Object.assign(Object.assign({}, defaultParagraphStyle), data.paragraphStyle), fonts),
|
|
395
|
+
},
|
|
396
|
+
Adjustments: { Axis: [1, 0, 1], XY: [0, 0] },
|
|
397
|
+
});
|
|
398
|
+
last = i + 1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const styleSheetData = encodeStyle(Object.assign(Object.assign({}, defaultStyle), { font: defFont }), fonts);
|
|
403
|
+
const styleRuns = data.styleRuns || [{ length: text.length, style: data.style || {} }];
|
|
404
|
+
const styleRunArray = [];
|
|
405
|
+
const styleRunLengthArray = [];
|
|
406
|
+
let leftLength = text.length;
|
|
407
|
+
for (const run of styleRuns) {
|
|
408
|
+
let runLength = Math.min(run.length, leftLength);
|
|
409
|
+
leftLength -= runLength;
|
|
410
|
+
if (!runLength)
|
|
411
|
+
continue; // ignore 0 size runs
|
|
412
|
+
// extend last run if it's only for trailing \r
|
|
413
|
+
if (leftLength === 1 && run === styleRuns[styleRuns.length - 1]) {
|
|
414
|
+
runLength++;
|
|
415
|
+
leftLength--;
|
|
416
|
+
}
|
|
417
|
+
styleRunLengthArray.push(runLength);
|
|
418
|
+
styleRunArray.push({
|
|
419
|
+
StyleSheet: {
|
|
420
|
+
StyleSheetData: encodeStyle(Object.assign(Object.assign({ kerning: 0, autoKerning: true, fillColor: { r: 0, g: 0, b: 0 } }, data.style), run.style), fonts),
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
// add extra run to the end if existing ones didn't fill it up
|
|
425
|
+
if (leftLength && styleRuns.length) {
|
|
426
|
+
styleRunLengthArray.push(leftLength);
|
|
427
|
+
styleRunArray.push({
|
|
428
|
+
StyleSheet: {
|
|
429
|
+
StyleSheetData: encodeStyle(Object.assign({ kerning: 0, autoKerning: true, fillColor: { r: 0, g: 0, b: 0 } }, data.style), fonts),
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
const gridInfo = Object.assign(Object.assign({}, defaultGridInfo), data.gridInfo);
|
|
434
|
+
const WritingDirection = data.orientation === 'vertical' ? 2 : 0;
|
|
435
|
+
const Procession = data.orientation === 'vertical' ? 1 : 0;
|
|
436
|
+
const ShapeType = data.shapeType === 'box' ? 1 : 0;
|
|
437
|
+
const Photoshop = {
|
|
438
|
+
ShapeType,
|
|
439
|
+
};
|
|
440
|
+
if (ShapeType === 0) {
|
|
441
|
+
Photoshop.PointBase = data.pointBase || [0, 0];
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
Photoshop.BoxBounds = data.boxBounds || [0, 0, 0, 0];
|
|
445
|
+
}
|
|
446
|
+
// needed for correct order of properties
|
|
447
|
+
Photoshop.Base = {
|
|
448
|
+
ShapeType,
|
|
449
|
+
TransformPoint0: [1, 0],
|
|
450
|
+
TransformPoint1: [0, 1],
|
|
451
|
+
TransformPoint2: [0, 0],
|
|
452
|
+
};
|
|
453
|
+
const defaultResources = {
|
|
454
|
+
KinsokuSet: [
|
|
455
|
+
{
|
|
456
|
+
Name: 'PhotoshopKinsokuHard',
|
|
457
|
+
NoStart: '、。,.・:;?!ー―’”)〕]}〉》」』】ヽヾゝゞ々ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ゛゜?!)]},.:;℃℉¢%‰',
|
|
458
|
+
NoEnd: '‘“(〔[{〈《「『【([{¥$£@§〒#',
|
|
459
|
+
Keep: '―‥',
|
|
460
|
+
Hanging: '、。.,',
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
Name: 'PhotoshopKinsokuSoft',
|
|
464
|
+
NoStart: '、。,.・:;?!’”)〕]}〉》」』】ヽヾゝゞ々',
|
|
465
|
+
NoEnd: '‘“(〔[{〈《「『【',
|
|
466
|
+
Keep: '―‥',
|
|
467
|
+
Hanging: '、。.,',
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
MojiKumiSet: [
|
|
471
|
+
{ InternalName: 'Photoshop6MojiKumiSet1' },
|
|
472
|
+
{ InternalName: 'Photoshop6MojiKumiSet2' },
|
|
473
|
+
{ InternalName: 'Photoshop6MojiKumiSet3' },
|
|
474
|
+
{ InternalName: 'Photoshop6MojiKumiSet4' },
|
|
475
|
+
],
|
|
476
|
+
TheNormalStyleSheet: 0,
|
|
477
|
+
TheNormalParagraphSheet: 0,
|
|
478
|
+
ParagraphSheetSet: [
|
|
479
|
+
{
|
|
480
|
+
Name: 'Normal RGB',
|
|
481
|
+
DefaultStyleSheet: 0,
|
|
482
|
+
Properties: encodeParagraphStyle(Object.assign(Object.assign({}, defaultParagraphStyle), data.paragraphStyle), fonts),
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
StyleSheetSet: [
|
|
486
|
+
{
|
|
487
|
+
Name: 'Normal RGB',
|
|
488
|
+
StyleSheetData: styleSheetData,
|
|
489
|
+
},
|
|
490
|
+
],
|
|
491
|
+
FontSet: fonts.map(f => ({
|
|
492
|
+
Name: f.name,
|
|
493
|
+
Script: f.script || 0,
|
|
494
|
+
FontType: f.type || 0,
|
|
495
|
+
Synthetic: f.synthetic || 0,
|
|
496
|
+
})),
|
|
497
|
+
SuperscriptSize: (_d = data.superscriptSize) !== null && _d !== void 0 ? _d : 0.583,
|
|
498
|
+
SuperscriptPosition: (_e = data.superscriptPosition) !== null && _e !== void 0 ? _e : 0.333,
|
|
499
|
+
SubscriptSize: (_f = data.subscriptSize) !== null && _f !== void 0 ? _f : 0.583,
|
|
500
|
+
SubscriptPosition: (_g = data.subscriptPosition) !== null && _g !== void 0 ? _g : 0.333,
|
|
501
|
+
SmallCapSize: (_h = data.smallCapSize) !== null && _h !== void 0 ? _h : 0.7,
|
|
502
|
+
};
|
|
503
|
+
const engineData = {
|
|
504
|
+
EngineDict: {
|
|
505
|
+
Editor: { Text: text },
|
|
506
|
+
ParagraphRun: {
|
|
507
|
+
DefaultRunData: {
|
|
508
|
+
ParagraphSheet: { DefaultStyleSheet: 0, Properties: {} },
|
|
509
|
+
Adjustments: { Axis: [1, 0, 1], XY: [0, 0] },
|
|
510
|
+
},
|
|
511
|
+
RunArray: paragraphRunArray,
|
|
512
|
+
RunLengthArray: paragraphRunLengthArray,
|
|
513
|
+
IsJoinable: 1,
|
|
514
|
+
},
|
|
515
|
+
StyleRun: {
|
|
516
|
+
DefaultRunData: { StyleSheet: { StyleSheetData: {} } },
|
|
517
|
+
RunArray: styleRunArray,
|
|
518
|
+
RunLengthArray: styleRunLengthArray,
|
|
519
|
+
IsJoinable: 2,
|
|
520
|
+
},
|
|
521
|
+
GridInfo: {
|
|
522
|
+
GridIsOn: !!gridInfo.isOn,
|
|
523
|
+
ShowGrid: !!gridInfo.show,
|
|
524
|
+
GridSize: (_j = gridInfo.size) !== null && _j !== void 0 ? _j : 18,
|
|
525
|
+
GridLeading: (_k = gridInfo.leading) !== null && _k !== void 0 ? _k : 22,
|
|
526
|
+
GridColor: encodeColor(gridInfo.color),
|
|
527
|
+
GridLeadingFillColor: encodeColor(gridInfo.color),
|
|
528
|
+
AlignLineHeightToGridFlags: !!gridInfo.alignLineHeightToGridFlags,
|
|
529
|
+
},
|
|
530
|
+
AntiAlias: antialias.indexOf((_l = data.antiAlias) !== null && _l !== void 0 ? _l : 'sharp'),
|
|
531
|
+
UseFractionalGlyphWidths: (_m = data.useFractionalGlyphWidths) !== null && _m !== void 0 ? _m : true,
|
|
532
|
+
Rendered: {
|
|
533
|
+
Version: 1,
|
|
534
|
+
Shapes: {
|
|
535
|
+
WritingDirection,
|
|
536
|
+
Children: [
|
|
537
|
+
{
|
|
538
|
+
ShapeType,
|
|
539
|
+
Procession,
|
|
540
|
+
Lines: { WritingDirection, Children: [] },
|
|
541
|
+
Cookie: { Photoshop },
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
ResourceDict: Object.assign({}, defaultResources),
|
|
548
|
+
DocumentResources: Object.assign({}, defaultResources),
|
|
549
|
+
};
|
|
550
|
+
// console.log('encodeEngineData', require('util').inspect(engineData, false, 99, true));
|
|
551
|
+
return engineData;
|
|
552
|
+
}
|
|
578
553
|
//# sourceMappingURL=text.js.map
|